summaryrefslogtreecommitdiff
path: root/core/fpdfdoc/cpdf_formfield.cpp
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-11-02 15:17:29 -0700
committerCommit bot <commit-bot@chromium.org>2016-11-02 15:17:30 -0700
commit12f3e4a58f05850b93af35619cb04f0231d86acc (patch)
tree9851d8e46e5c168f5d148864caa2eebf814529dd /core/fpdfdoc/cpdf_formfield.cpp
parent3b3ce1a242f8445848d3f23d6c35ba01d7c645f4 (diff)
downloadpdfium-12f3e4a58f05850b93af35619cb04f0231d86acc.tar.xz
Remove FX_BOOL from core
Review-Url: https://codereview.chromium.org/2477443002
Diffstat (limited to 'core/fpdfdoc/cpdf_formfield.cpp')
-rw-r--r--core/fpdfdoc/cpdf_formfield.cpp164
1 files changed, 80 insertions, 84 deletions
diff --git a/core/fpdfdoc/cpdf_formfield.cpp b/core/fpdfdoc/cpdf_formfield.cpp
index dc45fbcec7..e82ef7800e 100644
--- a/core/fpdfdoc/cpdf_formfield.cpp
+++ b/core/fpdfdoc/cpdf_formfield.cpp
@@ -161,7 +161,7 @@ CFX_WideString CPDF_FormField::GetFullName() const {
return FPDF_GetFullName(m_pDict);
}
-FX_BOOL CPDF_FormField::ResetField(FX_BOOL bNotify) {
+bool CPDF_FormField::ResetField(bool bNotify) {
switch (m_Type) {
case CPDF_FormField::CheckBox:
case CPDF_FormField::RadioButton: {
@@ -171,10 +171,10 @@ FX_BOOL CPDF_FormField::ResetField(FX_BOOL bNotify) {
// unison field. Otherwise, merge these branches.
if (IsUnison(this)) {
for (int i = 0; i < iCount; i++)
- CheckControl(i, GetControl(i)->IsDefaultChecked(), FALSE);
+ CheckControl(i, GetControl(i)->IsDefaultChecked(), false);
} else {
for (int i = 0; i < iCount; i++)
- CheckControl(i, GetControl(i)->IsDefaultChecked(), FALSE);
+ CheckControl(i, GetControl(i)->IsDefaultChecked(), false);
}
}
if (bNotify && m_pForm->m_pFormNotify)
@@ -190,9 +190,9 @@ FX_BOOL CPDF_FormField::ResetField(FX_BOOL bNotify) {
csValue = GetOptionLabel(iIndex);
if (bNotify && !NotifyListOrComboBoxBeforeChange(csValue))
- return FALSE;
+ return false;
- SetItemSelection(iIndex, TRUE);
+ SetItemSelection(iIndex, true);
if (bNotify)
NotifyListOrComboBoxAfterChange();
break;
@@ -213,15 +213,15 @@ FX_BOOL CPDF_FormField::ResetField(FX_BOOL bNotify) {
CPDF_Object* pRV = FPDF_GetFieldAttr(m_pDict, "RV");
if (!pRV && (csDValue == csValue))
- return FALSE;
+ return false;
if (bNotify && !NotifyBeforeValueChange(csDValue))
- return FALSE;
+ return false;
if (pDV) {
CPDF_Object* pClone = pDV->Clone();
if (!pClone)
- return FALSE;
+ return false;
m_pDict->SetFor("V", pClone);
if (pRV) {
@@ -237,7 +237,7 @@ FX_BOOL CPDF_FormField::ResetField(FX_BOOL bNotify) {
break;
}
}
- return TRUE;
+ return true;
}
int CPDF_FormField::GetControlIndex(const CPDF_FormControl* pControl) const {
@@ -305,7 +305,7 @@ CFX_WideString CPDF_FormField::GetRichTextString() const {
return pObj ? pObj->GetUnicodeText() : L"";
}
-CFX_WideString CPDF_FormField::GetValue(FX_BOOL bDefault) const {
+CFX_WideString CPDF_FormField::GetValue(bool bDefault) const {
if (GetType() == CheckBox || GetType() == RadioButton)
return GetCheckValue(bDefault);
@@ -337,21 +337,21 @@ CFX_WideString CPDF_FormField::GetValue(FX_BOOL bDefault) const {
}
CFX_WideString CPDF_FormField::GetValue() const {
- return GetValue(FALSE);
+ return GetValue(false);
}
CFX_WideString CPDF_FormField::GetDefaultValue() const {
- return GetValue(TRUE);
+ return GetValue(true);
}
-FX_BOOL CPDF_FormField::SetValue(const CFX_WideString& value,
- FX_BOOL bDefault,
- FX_BOOL bNotify) {
+bool CPDF_FormField::SetValue(const CFX_WideString& value,
+ bool bDefault,
+ bool bNotify) {
switch (m_Type) {
case CheckBox:
case RadioButton: {
SetCheckValue(value, bDefault, bNotify);
- return TRUE;
+ return true;
}
case File:
case RichText:
@@ -359,7 +359,7 @@ FX_BOOL CPDF_FormField::SetValue(const CFX_WideString& value,
case ComboBox: {
CFX_WideString csValue = value;
if (bNotify && !NotifyBeforeValueChange(csValue))
- return FALSE;
+ return false;
int iIndex = FindOptionValue(csValue);
if (iIndex < 0) {
@@ -372,7 +372,7 @@ FX_BOOL CPDF_FormField::SetValue(const CFX_WideString& value,
m_pDict->SetStringFor(bDefault ? "DV" : "V", PDF_EncodeText(csValue));
if (!bDefault) {
ClearSelection();
- SetItemSelection(iIndex, TRUE);
+ SetItemSelection(iIndex, true);
}
}
if (bNotify)
@@ -382,17 +382,17 @@ FX_BOOL CPDF_FormField::SetValue(const CFX_WideString& value,
case ListBox: {
int iIndex = FindOptionValue(value);
if (iIndex < 0)
- return FALSE;
+ return false;
if (bDefault && iIndex == GetDefaultSelectedItem())
- return FALSE;
+ return false;
if (bNotify && !NotifyBeforeSelectionChange(value))
- return FALSE;
+ return false;
if (!bDefault) {
ClearSelection();
- SetItemSelection(iIndex, TRUE);
+ SetItemSelection(iIndex, true);
}
if (bNotify)
NotifyAfterSelectionChange();
@@ -401,11 +401,11 @@ FX_BOOL CPDF_FormField::SetValue(const CFX_WideString& value,
default:
break;
}
- return TRUE;
+ return true;
}
-FX_BOOL CPDF_FormField::SetValue(const CFX_WideString& value, FX_BOOL bNotify) {
- return SetValue(value, FALSE, bNotify);
+bool CPDF_FormField::SetValue(const CFX_WideString& value, bool bNotify) {
+ return SetValue(value, false, bNotify);
}
int CPDF_FormField::GetMaxLen() const {
@@ -476,7 +476,7 @@ int CPDF_FormField::GetSelectedIndex(int index) const {
return -1;
}
-FX_BOOL CPDF_FormField::ClearSelection(FX_BOOL bNotify) {
+bool CPDF_FormField::ClearSelection(bool bNotify) {
if (bNotify && m_pForm->m_pFormNotify) {
CFX_WideString csValue;
int iIndex = GetSelectedIndex(0);
@@ -484,28 +484,28 @@ FX_BOOL CPDF_FormField::ClearSelection(FX_BOOL bNotify) {
csValue = GetOptionLabel(iIndex);
if (!NotifyListOrComboBoxBeforeChange(csValue))
- return FALSE;
+ return false;
}
m_pDict->RemoveFor("V");
m_pDict->RemoveFor("I");
if (bNotify)
NotifyListOrComboBoxAfterChange();
- return TRUE;
+ return true;
}
-FX_BOOL CPDF_FormField::IsItemSelected(int index) const {
+bool CPDF_FormField::IsItemSelected(int index) const {
ASSERT(GetType() == ComboBox || GetType() == ListBox);
if (index < 0 || index >= CountOptions())
- return FALSE;
+ return false;
if (IsOptionSelected(index))
- return TRUE;
+ return true;
CFX_WideString opt_value = GetOptionValue(index);
CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict, "V");
if (!pValue) {
pValue = FPDF_GetFieldAttr(m_pDict, "I");
if (!pValue)
- return FALSE;
+ return false;
}
if (pValue->IsString())
@@ -513,13 +513,13 @@ FX_BOOL CPDF_FormField::IsItemSelected(int index) const {
if (pValue->IsNumber()) {
if (pValue->GetString().IsEmpty())
- return FALSE;
+ return false;
return (pValue->GetInteger() == index);
}
CPDF_Array* pArray = pValue->AsArray();
if (!pArray)
- return FALSE;
+ return false;
int iPos = -1;
for (int j = 0; j < CountSelectedOptions(); j++) {
@@ -531,25 +531,23 @@ FX_BOOL CPDF_FormField::IsItemSelected(int index) const {
for (int i = 0; i < static_cast<int>(pArray->GetCount()); i++)
if (pArray->GetDirectObjectAt(i)->GetUnicodeText() == opt_value &&
i == iPos) {
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
-FX_BOOL CPDF_FormField::SetItemSelection(int index,
- FX_BOOL bSelected,
- FX_BOOL bNotify) {
+bool CPDF_FormField::SetItemSelection(int index, bool bSelected, bool bNotify) {
ASSERT(GetType() == ComboBox || GetType() == ListBox);
if (index < 0 || index >= CountOptions())
- return FALSE;
+ return false;
CFX_WideString opt_value = GetOptionValue(index);
if (bNotify && !NotifyListOrComboBoxBeforeChange(opt_value))
- return FALSE;
+ return false;
if (bSelected) {
if (GetType() == ListBox) {
- SelectOption(index, TRUE);
+ SelectOption(index, true);
if (!(m_Flags & kFormListMultiSelect)) {
m_pDict->SetStringFor("V", PDF_EncodeText(opt_value));
} else {
@@ -572,7 +570,7 @@ FX_BOOL CPDF_FormField::SetItemSelection(int index,
CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict, "V");
if (pValue) {
if (GetType() == ListBox) {
- SelectOption(index, FALSE);
+ SelectOption(index, false);
if (pValue->IsString()) {
if (pValue->GetUnicodeText() == opt_value)
m_pDict->RemoveFor("V");
@@ -596,13 +594,13 @@ FX_BOOL CPDF_FormField::SetItemSelection(int index,
}
if (bNotify)
NotifyListOrComboBoxAfterChange();
- return TRUE;
+ return true;
}
-FX_BOOL CPDF_FormField::IsItemDefaultSelected(int index) const {
+bool CPDF_FormField::IsItemDefaultSelected(int index) const {
ASSERT(GetType() == ComboBox || GetType() == ListBox);
if (index < 0 || index >= CountOptions())
- return FALSE;
+ return false;
int iDVIndex = GetDefaultSelectedItem();
return iDVIndex >= 0 && iDVIndex == index;
}
@@ -669,7 +667,7 @@ int CPDF_FormField::FindOptionValue(const CFX_WideString& csOptValue) const {
#ifdef PDF_ENABLE_XFA
int CPDF_FormField::InsertOption(CFX_WideString csOptLabel,
int index,
- FX_BOOL bNotify) {
+ bool bNotify) {
if (csOptLabel.IsEmpty())
return -1;
@@ -690,7 +688,7 @@ int CPDF_FormField::InsertOption(CFX_WideString csOptLabel,
pOpt->AddString(csStr);
index = iCount;
} else {
- CPDF_String* pString = new CPDF_String(csStr, FALSE);
+ CPDF_String* pString = new CPDF_String(csStr, false);
pOpt->InsertAt(index, pString);
}
@@ -699,14 +697,14 @@ int CPDF_FormField::InsertOption(CFX_WideString csOptLabel,
return index;
}
-FX_BOOL CPDF_FormField::ClearOptions(FX_BOOL bNotify) {
+bool CPDF_FormField::ClearOptions(bool bNotify) {
if (bNotify && m_pForm->m_pFormNotify) {
CFX_WideString csValue;
int iIndex = GetSelectedIndex(0);
if (iIndex >= 0)
csValue = GetOptionLabel(iIndex);
if (!NotifyListOrComboBoxBeforeChange(csValue))
- return FALSE;
+ return false;
}
m_pDict->RemoveFor("Opt");
@@ -718,19 +716,19 @@ FX_BOOL CPDF_FormField::ClearOptions(FX_BOOL bNotify) {
if (bNotify)
NotifyListOrComboBoxAfterChange();
- return TRUE;
+ return true;
}
#endif // PDF_ENABLE_XFA
-FX_BOOL CPDF_FormField::CheckControl(int iControlIndex,
- bool bChecked,
- bool bNotify) {
+bool CPDF_FormField::CheckControl(int iControlIndex,
+ bool bChecked,
+ bool bNotify) {
ASSERT(GetType() == CheckBox || GetType() == RadioButton);
CPDF_FormControl* pControl = GetControl(iControlIndex);
if (!pControl)
- return FALSE;
+ return false;
if (!bChecked && pControl->IsChecked() == bChecked)
- return FALSE;
+ return false;
CFX_WideString csWExport = pControl->GetExportValue();
CFX_ByteString csBExport = PDF_EncodeText(csWExport);
@@ -744,15 +742,15 @@ FX_BOOL CPDF_FormField::CheckControl(int iControlIndex,
if (pCtrl->GetOnStateName() == pControl->GetOnStateName())
pCtrl->CheckControl(bChecked);
else if (bChecked)
- pCtrl->CheckControl(FALSE);
+ pCtrl->CheckControl(false);
} else if (bChecked) {
- pCtrl->CheckControl(FALSE);
+ pCtrl->CheckControl(false);
}
} else {
if (i == iControlIndex)
pCtrl->CheckControl(bChecked);
else if (bChecked)
- pCtrl->CheckControl(FALSE);
+ pCtrl->CheckControl(false);
}
}
@@ -775,16 +773,16 @@ FX_BOOL CPDF_FormField::CheckControl(int iControlIndex,
}
if (bNotify && m_pForm->m_pFormNotify)
m_pForm->m_pFormNotify->AfterCheckedStatusChange(this);
- return TRUE;
+ return true;
}
-CFX_WideString CPDF_FormField::GetCheckValue(FX_BOOL bDefault) const {
+CFX_WideString CPDF_FormField::GetCheckValue(bool bDefault) const {
ASSERT(GetType() == CheckBox || GetType() == RadioButton);
CFX_WideString csExport = L"Off";
int iCount = CountControls();
for (int i = 0; i < iCount; i++) {
CPDF_FormControl* pControl = GetControl(i);
- FX_BOOL bChecked =
+ bool bChecked =
bDefault ? pControl->IsDefaultChecked() : pControl->IsChecked();
if (bChecked) {
csExport = pControl->GetExportValue();
@@ -794,9 +792,9 @@ CFX_WideString CPDF_FormField::GetCheckValue(FX_BOOL bDefault) const {
return csExport;
}
-FX_BOOL CPDF_FormField::SetCheckValue(const CFX_WideString& value,
- FX_BOOL bDefault,
- FX_BOOL bNotify) {
+bool CPDF_FormField::SetCheckValue(const CFX_WideString& value,
+ bool bDefault,
+ bool bNotify) {
ASSERT(GetType() == CheckBox || GetType() == RadioButton);
int iCount = CountControls();
for (int i = 0; i < iCount; i++) {
@@ -810,7 +808,7 @@ FX_BOOL CPDF_FormField::SetCheckValue(const CFX_WideString& value,
}
if (bNotify && m_pForm->m_pFormNotify)
m_pForm->m_pFormNotify->AfterCheckedStatusChange(this);
- return TRUE;
+ return true;
}
int CPDF_FormField::GetTopVisibleIndex() const {
@@ -834,44 +832,42 @@ int CPDF_FormField::GetSelectedOptionIndex(int index) const {
return pArray->GetIntegerAt(index);
}
-FX_BOOL CPDF_FormField::IsOptionSelected(int iOptIndex) const {
+bool CPDF_FormField::IsOptionSelected(int iOptIndex) const {
CPDF_Array* pArray = ToArray(FPDF_GetFieldAttr(m_pDict, "I"));
if (!pArray)
- return FALSE;
+ return false;
for (CPDF_Object* pObj : *pArray) {
if (pObj->GetInteger() == iOptIndex)
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
-FX_BOOL CPDF_FormField::SelectOption(int iOptIndex,
- FX_BOOL bSelected,
- FX_BOOL bNotify) {
+bool CPDF_FormField::SelectOption(int iOptIndex, bool bSelected, bool bNotify) {
CPDF_Array* pArray = m_pDict->GetArrayFor("I");
if (!pArray) {
if (!bSelected)
- return TRUE;
+ return true;
pArray = new CPDF_Array;
m_pDict->SetFor("I", pArray);
}
- FX_BOOL bReturn = FALSE;
+ bool bReturn = false;
for (size_t i = 0; i < pArray->GetCount(); i++) {
int iFind = pArray->GetIntegerAt(i);
if (iFind == iOptIndex) {
if (bSelected)
- return TRUE;
+ return true;
if (bNotify && m_pForm->m_pFormNotify) {
CFX_WideString csValue = GetOptionLabel(iOptIndex);
if (!NotifyListOrComboBoxBeforeChange(csValue))
- return FALSE;
+ return false;
}
pArray->RemoveAt(i);
- bReturn = TRUE;
+ bReturn = true;
break;
}
@@ -882,10 +878,10 @@ FX_BOOL CPDF_FormField::SelectOption(int iOptIndex,
if (bNotify && m_pForm->m_pFormNotify) {
CFX_WideString csValue = GetOptionLabel(iOptIndex);
if (!NotifyListOrComboBoxBeforeChange(csValue))
- return FALSE;
+ return false;
}
pArray->InsertAt(i, new CPDF_Number(iOptIndex));
- bReturn = TRUE;
+ bReturn = true;
break;
}
}
@@ -899,10 +895,10 @@ FX_BOOL CPDF_FormField::SelectOption(int iOptIndex,
if (bNotify)
NotifyListOrComboBoxAfterChange();
- return TRUE;
+ return true;
}
-FX_BOOL CPDF_FormField::ClearSelectedOptions(FX_BOOL bNotify) {
+bool CPDF_FormField::ClearSelectedOptions(bool bNotify) {
if (bNotify && m_pForm->m_pFormNotify) {
CFX_WideString csValue;
int iIndex = GetSelectedIndex(0);
@@ -910,13 +906,13 @@ FX_BOOL CPDF_FormField::ClearSelectedOptions(FX_BOOL bNotify) {
csValue = GetOptionLabel(iIndex);
if (!NotifyListOrComboBoxBeforeChange(csValue))
- return FALSE;
+ return false;
}
m_pDict->RemoveFor("I");
if (bNotify)
NotifyListOrComboBoxAfterChange();
- return TRUE;
+ return true;
}
void CPDF_FormField::LoadDA() {