summaryrefslogtreecommitdiff
path: root/core/fpdfdoc/cpdf_formfield.cpp
diff options
context:
space:
mode:
authorRyan Harrison <rharrison@chromium.org>2017-09-18 14:23:18 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-09-18 18:40:16 +0000
commit275e260a6cd4a8e506ba974feb85ebcd926c1739 (patch)
tree2029b9158ec044764ceff122fe5fb5d0a3f123d1 /core/fpdfdoc/cpdf_formfield.cpp
parent450fbeaaabf1ab340c1018de2e58f1950657517e (diff)
downloadpdfium-275e260a6cd4a8e506ba974feb85ebcd926c1739.tar.xz
Convert string class names
Automated using git grep & sed. Replace StringC classes with StringView classes. Remove the CFX_ prefix and put string classes in fxcrt namespace. Change AsStringC() to AsStringView(). Rename tests from TEST(fxcrt, *String*Foo) to TEST(*String*, Foo). Couple of tests needed to have their names regularlized. BUG=pdfium:894 Change-Id: I7ca038685c8d803795f3ed02545124f7a224c83d Reviewed-on: https://pdfium-review.googlesource.com/14151 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Diffstat (limited to 'core/fpdfdoc/cpdf_formfield.cpp')
-rw-r--r--core/fpdfdoc/cpdf_formfield.cpp118
1 files changed, 58 insertions, 60 deletions
diff --git a/core/fpdfdoc/cpdf_formfield.cpp b/core/fpdfdoc/cpdf_formfield.cpp
index acb46a5beb..fec1945956 100644
--- a/core/fpdfdoc/cpdf_formfield.cpp
+++ b/core/fpdfdoc/cpdf_formfield.cpp
@@ -65,13 +65,13 @@ CPDF_Object* FPDF_GetFieldAttr(const CPDF_Dictionary* pFieldDict,
return FPDF_GetFieldAttr(pParent, name, nLevel + 1);
}
-CFX_WideString FPDF_GetFullName(CPDF_Dictionary* pFieldDict) {
- CFX_WideString full_name;
+WideString FPDF_GetFullName(CPDF_Dictionary* pFieldDict) {
+ WideString full_name;
std::set<CPDF_Dictionary*> visited;
CPDF_Dictionary* pLevel = pFieldDict;
while (pLevel) {
visited.insert(pLevel);
- CFX_WideString short_name = pLevel->GetUnicodeTextFor("T");
+ WideString short_name = pLevel->GetUnicodeTextFor("T");
if (!short_name.IsEmpty()) {
if (full_name.IsEmpty())
full_name = short_name;
@@ -98,7 +98,7 @@ CPDF_FormField::~CPDF_FormField() {}
void CPDF_FormField::SyncFieldFlags() {
CPDF_Object* ft_attr = FPDF_GetFieldAttr(m_pDict.Get(), "FT");
- CFX_ByteString type_name = ft_attr ? ft_attr->GetString() : CFX_ByteString();
+ ByteString type_name = ft_attr ? ft_attr->GetString() : ByteString();
CPDF_Object* ff_attr = FPDF_GetFieldAttr(m_pDict.Get(), "Ff");
uint32_t flags = ff_attr ? ff_attr->GetInteger() : 0;
m_Flags = 0;
@@ -154,7 +154,7 @@ void CPDF_FormField::SyncFieldFlags() {
}
}
-CFX_WideString CPDF_FormField::GetFullName() const {
+WideString CPDF_FormField::GetFullName() const {
return FPDF_GetFullName(m_pDict.Get());
}
@@ -180,7 +180,7 @@ bool CPDF_FormField::ResetField(bool bNotify) {
}
case CPDF_FormField::ComboBox:
case CPDF_FormField::ListBox: {
- CFX_WideString csValue;
+ WideString csValue;
ClearSelection();
int iIndex = GetDefaultSelectedItem();
if (iIndex >= 0)
@@ -199,12 +199,12 @@ bool CPDF_FormField::ResetField(bool bNotify) {
case CPDF_FormField::File:
default: {
CPDF_Object* pDV = FPDF_GetFieldAttr(m_pDict.Get(), "DV");
- CFX_WideString csDValue;
+ WideString csDValue;
if (pDV)
csDValue = pDV->GetUnicodeText();
CPDF_Object* pV = FPDF_GetFieldAttr(m_pDict.Get(), "V");
- CFX_WideString csValue;
+ WideString csValue;
if (pV)
csValue = pV->GetUnicodeText();
@@ -272,12 +272,12 @@ CPDF_AAction CPDF_FormField::GetAdditionalAction() const {
return CPDF_AAction(pObj ? pObj->GetDict() : nullptr);
}
-CFX_WideString CPDF_FormField::GetAlternateName() const {
+WideString CPDF_FormField::GetAlternateName() const {
CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict.Get(), "TU");
return pObj ? pObj->GetUnicodeText() : L"";
}
-CFX_WideString CPDF_FormField::GetMappingName() const {
+WideString CPDF_FormField::GetMappingName() const {
CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict.Get(), "TM");
return pObj ? pObj->GetUnicodeText() : L"";
}
@@ -287,17 +287,17 @@ uint32_t CPDF_FormField::GetFieldFlags() const {
return pObj ? pObj->GetInteger() : 0;
}
-CFX_ByteString CPDF_FormField::GetDefaultStyle() const {
+ByteString CPDF_FormField::GetDefaultStyle() const {
CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict.Get(), "DS");
return pObj ? pObj->GetString() : "";
}
-CFX_WideString CPDF_FormField::GetRichTextString() const {
+WideString CPDF_FormField::GetRichTextString() const {
CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict.Get(), "RV");
return pObj ? pObj->GetUnicodeText() : L"";
}
-CFX_WideString CPDF_FormField::GetValue(bool bDefault) const {
+WideString CPDF_FormField::GetValue(bool bDefault) const {
if (GetType() == CheckBox || GetType() == RadioButton)
return GetCheckValue(bDefault);
@@ -310,7 +310,7 @@ CFX_WideString CPDF_FormField::GetValue(bool bDefault) const {
pValue = FPDF_GetFieldAttr(m_pDict.Get(), "DV");
}
if (!pValue)
- return CFX_WideString();
+ return WideString();
}
switch (pValue->GetType()) {
@@ -325,18 +325,18 @@ CFX_WideString CPDF_FormField::GetValue(bool bDefault) const {
default:
break;
}
- return CFX_WideString();
+ return WideString();
}
-CFX_WideString CPDF_FormField::GetValue() const {
+WideString CPDF_FormField::GetValue() const {
return GetValue(false);
}
-CFX_WideString CPDF_FormField::GetDefaultValue() const {
+WideString CPDF_FormField::GetDefaultValue() const {
return GetValue(true);
}
-bool CPDF_FormField::SetValue(const CFX_WideString& value,
+bool CPDF_FormField::SetValue(const WideString& value,
bool bDefault,
bool bNotify) {
switch (m_Type) {
@@ -349,14 +349,14 @@ bool CPDF_FormField::SetValue(const CFX_WideString& value,
case RichText:
case Text:
case ComboBox: {
- CFX_WideString csValue = value;
+ WideString csValue = value;
if (bNotify && !NotifyBeforeValueChange(csValue))
return false;
- CFX_ByteString key(bDefault ? "DV" : "V");
+ ByteString key(bDefault ? "DV" : "V");
int iIndex = FindOptionValue(csValue);
if (iIndex < 0) {
- CFX_ByteString bsEncodeText = PDF_EncodeText(csValue);
+ ByteString bsEncodeText = PDF_EncodeText(csValue);
m_pDict->SetNewFor<CPDF_String>(key, bsEncodeText, false);
if (m_Type == RichText && !bDefault)
m_pDict->SetNewFor<CPDF_String>("RV", bsEncodeText, false);
@@ -397,7 +397,7 @@ bool CPDF_FormField::SetValue(const CFX_WideString& value,
return true;
}
-bool CPDF_FormField::SetValue(const CFX_WideString& value, bool bNotify) {
+bool CPDF_FormField::SetValue(const WideString& value, bool bNotify) {
return SetValue(value, false, bNotify);
}
@@ -440,7 +440,7 @@ int CPDF_FormField::GetSelectedIndex(int index) const {
if (pValue->IsNumber())
return pValue->GetInteger();
- CFX_WideString sel_value;
+ WideString sel_value;
if (pValue->IsString()) {
if (index != 0)
return -1;
@@ -451,12 +451,11 @@ int CPDF_FormField::GetSelectedIndex(int index) const {
return -1;
CPDF_Object* elementValue = pArray->GetDirectObjectAt(index);
- sel_value =
- elementValue ? elementValue->GetUnicodeText() : CFX_WideString();
+ sel_value = elementValue ? elementValue->GetUnicodeText() : WideString();
}
if (index < CountSelectedOptions()) {
int iOptIndex = GetSelectedOptionIndex(index);
- CFX_WideString csOpt = GetOptionValue(iOptIndex);
+ WideString csOpt = GetOptionValue(iOptIndex);
if (csOpt == sel_value)
return iOptIndex;
}
@@ -469,7 +468,7 @@ int CPDF_FormField::GetSelectedIndex(int index) const {
bool CPDF_FormField::ClearSelection(bool bNotify) {
if (bNotify && m_pForm->m_pFormNotify) {
- CFX_WideString csValue;
+ WideString csValue;
int iIndex = GetSelectedIndex(0);
if (iIndex >= 0)
csValue = GetOptionLabel(iIndex);
@@ -491,7 +490,7 @@ bool CPDF_FormField::IsItemSelected(int index) const {
if (IsOptionSelected(index))
return true;
- CFX_WideString opt_value = GetOptionValue(index);
+ WideString opt_value = GetOptionValue(index);
CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict.Get(), "V");
if (!pValue) {
pValue = FPDF_GetFieldAttr(m_pDict.Get(), "I");
@@ -532,7 +531,7 @@ bool CPDF_FormField::SetItemSelection(int index, bool bSelected, bool bNotify) {
if (index < 0 || index >= CountOptions())
return false;
- CFX_WideString opt_value = GetOptionValue(index);
+ WideString opt_value = GetOptionValue(index);
if (bNotify && !NotifyListOrComboBoxBeforeChange(opt_value))
return false;
@@ -598,7 +597,7 @@ int CPDF_FormField::GetDefaultSelectedItem() const {
CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict.Get(), "DV");
if (!pValue)
return -1;
- CFX_WideString csDV = pValue->GetUnicodeText();
+ WideString csDV = pValue->GetUnicodeText();
if (csDV.IsEmpty())
return -1;
for (int i = 0; i < CountOptions(); i++) {
@@ -613,30 +612,30 @@ int CPDF_FormField::CountOptions() const {
return pArray ? pArray->GetCount() : 0;
}
-CFX_WideString CPDF_FormField::GetOptionText(int index, int sub_index) const {
+WideString CPDF_FormField::GetOptionText(int index, int sub_index) const {
CPDF_Array* pArray = ToArray(FPDF_GetFieldAttr(m_pDict.Get(), "Opt"));
if (!pArray)
- return CFX_WideString();
+ return WideString();
CPDF_Object* pOption = pArray->GetDirectObjectAt(index);
if (!pOption)
- return CFX_WideString();
+ return WideString();
if (CPDF_Array* pOptionArray = pOption->AsArray())
pOption = pOptionArray->GetDirectObjectAt(sub_index);
CPDF_String* pString = ToString(pOption);
- return pString ? pString->GetUnicodeText() : CFX_WideString();
+ return pString ? pString->GetUnicodeText() : WideString();
}
-CFX_WideString CPDF_FormField::GetOptionLabel(int index) const {
+WideString CPDF_FormField::GetOptionLabel(int index) const {
return GetOptionText(index, 1);
}
-CFX_WideString CPDF_FormField::GetOptionValue(int index) const {
+WideString CPDF_FormField::GetOptionValue(int index) const {
return GetOptionText(index, 0);
}
-int CPDF_FormField::FindOption(CFX_WideString csOptLabel) const {
+int CPDF_FormField::FindOption(WideString csOptLabel) const {
for (int i = 0; i < CountOptions(); i++) {
if (GetOptionValue(i) == csOptLabel)
return i;
@@ -644,7 +643,7 @@ int CPDF_FormField::FindOption(CFX_WideString csOptLabel) const {
return -1;
}
-int CPDF_FormField::FindOptionValue(const CFX_WideString& csOptValue) const {
+int CPDF_FormField::FindOptionValue(const WideString& csOptValue) const {
for (int i = 0; i < CountOptions(); i++) {
if (GetOptionValue(i) == csOptValue)
return i;
@@ -653,7 +652,7 @@ int CPDF_FormField::FindOptionValue(const CFX_WideString& csOptValue) const {
}
#ifdef PDF_ENABLE_XFA
-int CPDF_FormField::InsertOption(CFX_WideString csOptLabel,
+int CPDF_FormField::InsertOption(WideString csOptLabel,
int index,
bool bNotify) {
if (csOptLabel.IsEmpty())
@@ -662,7 +661,7 @@ int CPDF_FormField::InsertOption(CFX_WideString csOptLabel,
if (bNotify && !NotifyListOrComboBoxBeforeChange(csOptLabel))
return -1;
- CFX_ByteString csStr = PDF_EncodeText(csOptLabel);
+ ByteString csStr = PDF_EncodeText(csOptLabel);
CPDF_Array* pOpt = ToArray(FPDF_GetFieldAttr(m_pDict.Get(), "Opt"));
if (!pOpt)
pOpt = m_pDict->SetNewFor<CPDF_Array>("Opt");
@@ -682,7 +681,7 @@ int CPDF_FormField::InsertOption(CFX_WideString csOptLabel,
bool CPDF_FormField::ClearOptions(bool bNotify) {
if (bNotify && m_pForm->m_pFormNotify) {
- CFX_WideString csValue;
+ WideString csValue;
int iIndex = GetSelectedIndex(0);
if (iIndex >= 0)
csValue = GetOptionLabel(iIndex);
@@ -713,14 +712,14 @@ bool CPDF_FormField::CheckControl(int iControlIndex,
if (!bChecked && pControl->IsChecked() == bChecked)
return false;
- CFX_WideString csWExport = pControl->GetExportValue();
- CFX_ByteString csBExport = PDF_EncodeText(csWExport);
+ WideString csWExport = pControl->GetExportValue();
+ ByteString csBExport = PDF_EncodeText(csWExport);
int iCount = CountControls();
bool bUnison = IsUnison(this);
for (int i = 0; i < iCount; i++) {
CPDF_FormControl* pCtrl = GetControl(i);
if (bUnison) {
- CFX_WideString csEValue = pCtrl->GetExportValue();
+ WideString csEValue = pCtrl->GetExportValue();
if (csEValue == csWExport) {
if (pCtrl->GetOnStateName() == pControl->GetOnStateName())
pCtrl->CheckControl(bChecked);
@@ -742,7 +741,7 @@ bool CPDF_FormField::CheckControl(int iControlIndex,
if (bChecked) {
m_pDict->SetNewFor<CPDF_Name>("V", csBExport);
} else {
- CFX_ByteString csV;
+ ByteString csV;
CPDF_Object* pV = FPDF_GetFieldAttr(m_pDict.Get(), "V");
if (pV)
csV = pV->GetString();
@@ -750,7 +749,7 @@ bool CPDF_FormField::CheckControl(int iControlIndex,
m_pDict->SetNewFor<CPDF_Name>("V", "Off");
}
} else if (bChecked) {
- CFX_ByteString csIndex;
+ ByteString csIndex;
csIndex.Format("%d", iControlIndex);
m_pDict->SetNewFor<CPDF_Name>("V", csIndex);
}
@@ -759,9 +758,9 @@ bool CPDF_FormField::CheckControl(int iControlIndex,
return true;
}
-CFX_WideString CPDF_FormField::GetCheckValue(bool bDefault) const {
+WideString CPDF_FormField::GetCheckValue(bool bDefault) const {
ASSERT(GetType() == CheckBox || GetType() == RadioButton);
- CFX_WideString csExport = L"Off";
+ WideString csExport = L"Off";
int iCount = CountControls();
for (int i = 0; i < iCount; i++) {
CPDF_FormControl* pControl = GetControl(i);
@@ -775,14 +774,14 @@ CFX_WideString CPDF_FormField::GetCheckValue(bool bDefault) const {
return csExport;
}
-bool CPDF_FormField::SetCheckValue(const CFX_WideString& value,
+bool CPDF_FormField::SetCheckValue(const WideString& value,
bool bDefault,
bool bNotify) {
ASSERT(GetType() == CheckBox || GetType() == RadioButton);
int iCount = CountControls();
for (int i = 0; i < iCount; i++) {
CPDF_FormControl* pControl = GetControl(i);
- CFX_WideString csExport = pControl->GetExportValue();
+ WideString csExport = pControl->GetExportValue();
bool val = csExport == value;
if (!bDefault)
CheckControl(GetControlIndex(pControl), val);
@@ -844,7 +843,7 @@ bool CPDF_FormField::SelectOption(int iOptIndex, bool bSelected, bool bNotify) {
return true;
if (bNotify && m_pForm->m_pFormNotify) {
- CFX_WideString csValue = GetOptionLabel(iOptIndex);
+ WideString csValue = GetOptionLabel(iOptIndex);
if (!NotifyListOrComboBoxBeforeChange(csValue))
return false;
}
@@ -858,7 +857,7 @@ bool CPDF_FormField::SelectOption(int iOptIndex, bool bSelected, bool bNotify) {
continue;
if (bNotify && m_pForm->m_pFormNotify) {
- CFX_WideString csValue = GetOptionLabel(iOptIndex);
+ WideString csValue = GetOptionLabel(iOptIndex);
if (!NotifyListOrComboBoxBeforeChange(csValue))
return false;
}
@@ -882,7 +881,7 @@ bool CPDF_FormField::SelectOption(int iOptIndex, bool bSelected, bool bNotify) {
bool CPDF_FormField::ClearSelectedOptions(bool bNotify) {
if (bNotify && m_pForm->m_pFormNotify) {
- CFX_WideString csValue;
+ WideString csValue;
int iIndex = GetSelectedIndex(0);
if (iIndex >= 0)
csValue = GetOptionLabel(iIndex);
@@ -902,7 +901,7 @@ void CPDF_FormField::LoadDA() {
if (!pFormDict)
return;
- CFX_ByteString DA;
+ ByteString DA;
if (CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict.Get(), "DA"))
DA = pObj->GetString();
@@ -920,9 +919,9 @@ void CPDF_FormField::LoadDA() {
if (!pFont)
return;
- CPDF_SimpleParser syntax(DA.AsStringC());
+ CPDF_SimpleParser syntax(DA.AsStringView());
syntax.FindTagParamFromStart("Tf", 2);
- CFX_ByteString font_name(syntax.GetWord());
+ ByteString font_name(syntax.GetWord());
CPDF_Dictionary* pFontDict = pFont->GetDictFor(font_name);
if (!pFontDict)
return;
@@ -931,7 +930,7 @@ void CPDF_FormField::LoadDA() {
m_FontSize = FX_atof(syntax.GetWord());
}
-bool CPDF_FormField::NotifyBeforeSelectionChange(const CFX_WideString& value) {
+bool CPDF_FormField::NotifyBeforeSelectionChange(const WideString& value) {
if (!m_pForm->m_pFormNotify)
return true;
return m_pForm->m_pFormNotify->BeforeSelectionChange(this, value) >= 0;
@@ -943,7 +942,7 @@ void CPDF_FormField::NotifyAfterSelectionChange() {
m_pForm->m_pFormNotify->AfterSelectionChange(this);
}
-bool CPDF_FormField::NotifyBeforeValueChange(const CFX_WideString& value) {
+bool CPDF_FormField::NotifyBeforeValueChange(const WideString& value) {
if (!m_pForm->m_pFormNotify)
return true;
return m_pForm->m_pFormNotify->BeforeValueChange(this, value) >= 0;
@@ -955,8 +954,7 @@ void CPDF_FormField::NotifyAfterValueChange() {
m_pForm->m_pFormNotify->AfterValueChange(this);
}
-bool CPDF_FormField::NotifyListOrComboBoxBeforeChange(
- const CFX_WideString& value) {
+bool CPDF_FormField::NotifyListOrComboBoxBeforeChange(const WideString& value) {
switch (GetType()) {
case ListBox:
return NotifyBeforeSelectionChange(value);