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

Unified Diff: core/src/fpdfdoc/doc_form.cpp

Issue 1243953004: Re-land else-after-returns (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « core/src/fpdfdoc/doc_basic.cpp ('k') | core/src/fpdfdoc/doc_formcontrol.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/src/fpdfdoc/doc_form.cpp
diff --git a/core/src/fpdfdoc/doc_form.cpp b/core/src/fpdfdoc/doc_form.cpp
index 2b59bee6ee6f8aedd85fe4370af18e0d37f77984..735231cc1d113edcc9d3770f5e0353095b3fce80 100644
--- a/core/src/fpdfdoc/doc_form.cpp
+++ b/core/src/fpdfdoc/doc_form.cpp
@@ -354,12 +354,11 @@ static int CALLBACK EnumFontFamExProc( ENUMLOGFONTEXA *lpelfe,
{
if (FontType != 0x004 || strchr(lpelfe->elfLogFont.lfFaceName, '@') != NULL) {
return 1;
- } else {
- LPDF_FONTDATA pData = (LPDF_FONTDATA)lParam;
- memcpy(&pData->lf, &lpelfe->elfLogFont, sizeof(LOGFONTA));
- pData->bFind = TRUE;
- return 0;
}
+ LPDF_FONTDATA pData = (LPDF_FONTDATA)lParam;
+ memcpy(&pData->lf, &lpelfe->elfLogFont, sizeof(LOGFONTA));
+ pData->bFind = TRUE;
+ return 0;
}
static FX_BOOL RetrieveSpecificFont(LOGFONTA& lf)
{
@@ -697,41 +696,39 @@ int CPDF_InterForm::CompareFieldName(const CFX_ByteString& name1, const CFX_Byte
{
const FX_CHAR* ptr1 = name1;
const FX_CHAR* ptr2 = name2;
- if (name1.GetLength() != name2.GetLength()) {
- int i = 0;
- while (ptr1[i] == ptr2[i]) {
- i ++;
- }
- if (i == name1.GetLength()) {
- return 2;
- }
- if (i == name2.GetLength()) {
- return 3;
- }
- return 0;
- } else {
+ if (name1.GetLength() == name2.GetLength()) {
return name1 == name2 ? 1 : 0;
}
+ int i = 0;
+ while (ptr1[i] == ptr2[i]) {
+ i ++;
+ }
+ if (i == name1.GetLength()) {
+ return 2;
+ }
+ if (i == name2.GetLength()) {
+ return 3;
+ }
+ return 0;
}
int CPDF_InterForm::CompareFieldName(const CFX_WideString& name1, const CFX_WideString& name2)
{
const FX_WCHAR* ptr1 = name1.c_str();
const FX_WCHAR* ptr2 = name2.c_str();
- if (name1.GetLength() != name2.GetLength()) {
- int i = 0;
- while (ptr1[i] == ptr2[i]) {
- i ++;
- }
- if (i == name1.GetLength()) {
- return 2;
- }
- if (i == name2.GetLength()) {
- return 3;
- }
- return 0;
- } else {
+ if (name1.GetLength() == name2.GetLength()) {
return name1 == name2 ? 1 : 0;
}
+ int i = 0;
+ while (ptr1[i] == ptr2[i]) {
+ i ++;
+ }
+ if (i == name1.GetLength()) {
+ return 2;
+ }
+ if (i == name2.GetLength()) {
+ return 3;
+ }
+ return 0;
}
FX_DWORD CPDF_InterForm::CountFields(const CFX_WideString &csFieldName)
{
@@ -900,115 +897,104 @@ CPDF_FormControl* CPDF_InterForm::GetControlByDict(CPDF_Dictionary* pWidgetDict)
}
FX_DWORD CPDF_InterForm::CountInternalFields(const CFX_WideString& csFieldName) const
{
- if (m_pFormDict == NULL) {
+ if (!m_pFormDict) {
return 0;
}
CPDF_Array* pArray = m_pFormDict->GetArray("Fields");
- if (pArray == NULL) {
+ if (!pArray) {
return 0;
}
if (csFieldName.IsEmpty()) {
return pArray->GetCount();
- } else {
- int iLength = csFieldName.GetLength();
- int iPos = 0;
- CPDF_Dictionary* pDict = NULL;
- while (pArray != NULL) {
- CFX_WideString csSub;
- if (iPos < iLength && csFieldName[iPos] == L'.') {
- iPos ++;
- }
- while (iPos < iLength && csFieldName[iPos] != L'.') {
- csSub += csFieldName[iPos ++];
- }
- int iCount = pArray->GetCount();
- FX_BOOL bFind = FALSE;
- for (int i = 0; i < iCount; i ++) {
- pDict = pArray->GetDict(i);
- if (pDict == NULL) {
- continue;
- }
- CFX_WideString csT = pDict->GetUnicodeText("T");
- if (csT == csSub) {
- bFind = TRUE;
- break;
- }
- }
- if (!bFind) {
- return 0;
+ }
+ int iLength = csFieldName.GetLength();
+ int iPos = 0;
+ CPDF_Dictionary* pDict = NULL;
+ while (pArray != NULL) {
+ CFX_WideString csSub;
+ if (iPos < iLength && csFieldName[iPos] == L'.') {
+ iPos ++;
+ }
+ while (iPos < iLength && csFieldName[iPos] != L'.') {
+ csSub += csFieldName[iPos ++];
+ }
+ int iCount = pArray->GetCount();
+ FX_BOOL bFind = FALSE;
+ for (int i = 0; i < iCount; i ++) {
+ pDict = pArray->GetDict(i);
+ if (pDict == NULL) {
+ continue;
}
- if (iPos >= iLength) {
+ CFX_WideString csT = pDict->GetUnicodeText("T");
+ if (csT == csSub) {
+ bFind = TRUE;
break;
}
- pArray = pDict->GetArray("Kids");
}
- if (pDict == NULL) {
+ if (!bFind) {
return 0;
- } else {
- pArray = pDict->GetArray("Kids");
- if (pArray == NULL) {
- return 1;
- } else {
- return pArray->GetCount();
- }
}
+ if (iPos >= iLength) {
+ break;
+ }
+ pArray = pDict->GetArray("Kids");
+ }
+ if (!pDict) {
+ return 0;
}
+ pArray = pDict->GetArray("Kids");
+ return pArray ? pArray->GetCount() : 1;
}
+
CPDF_Dictionary* CPDF_InterForm::GetInternalField(FX_DWORD index, const CFX_WideString& csFieldName) const
{
- if (m_pFormDict == NULL) {
- return NULL;
+ if (!m_pFormDict) {
+ return nullptr;
}
CPDF_Array* pArray = m_pFormDict->GetArray("Fields");
- if (pArray == NULL) {
- return 0;
+ if (!pArray) {
+ return nullptr;
}
if (csFieldName.IsEmpty()) {
return pArray->GetDict(index);
- } else {
- int iLength = csFieldName.GetLength();
- int iPos = 0;
- CPDF_Dictionary* pDict = NULL;
- while (pArray != NULL) {
- CFX_WideString csSub;
- if (iPos < iLength && csFieldName[iPos] == L'.') {
- iPos ++;
- }
- while (iPos < iLength && csFieldName[iPos] != L'.') {
- csSub += csFieldName[iPos ++];
- }
- int iCount = pArray->GetCount();
- FX_BOOL bFind = FALSE;
- for (int i = 0; i < iCount; i ++) {
- pDict = pArray->GetDict(i);
- if (pDict == NULL) {
- continue;
- }
- CFX_WideString csT = pDict->GetUnicodeText("T");
- if (csT == csSub) {
- bFind = TRUE;
- break;
- }
- }
- if (!bFind) {
- return NULL;
+ }
+ int iLength = csFieldName.GetLength();
+ int iPos = 0;
+ CPDF_Dictionary* pDict = NULL;
+ while (pArray != NULL) {
+ CFX_WideString csSub;
+ if (iPos < iLength && csFieldName[iPos] == L'.') {
+ iPos ++;
+ }
+ while (iPos < iLength && csFieldName[iPos] != L'.') {
+ csSub += csFieldName[iPos ++];
+ }
+ int iCount = pArray->GetCount();
+ FX_BOOL bFind = FALSE;
+ for (int i = 0; i < iCount; i ++) {
+ pDict = pArray->GetDict(i);
+ if (pDict == NULL) {
+ continue;
}
- if (iPos >= iLength) {
+ CFX_WideString csT = pDict->GetUnicodeText("T");
+ if (csT == csSub) {
+ bFind = TRUE;
break;
}
- pArray = pDict->GetArray("Kids");
}
- if (pDict == NULL) {
+ if (!bFind) {
return NULL;
- } else {
- pArray = pDict->GetArray("Kids");
- if (pArray == NULL) {
- return pDict;
- } else {
- return pArray->GetDict(index);
- }
}
+ if (iPos >= iLength) {
+ break;
+ }
+ pArray = pDict->GetArray("Kids");
+ }
+ if (!pDict) {
+ return nullptr;
}
+ pArray = pDict->GetArray("Kids");
+ return pArray ? pArray->GetDict(index) : pDict;
}
FX_BOOL CPDF_InterForm::NeedConstructAP()
{
« no previous file with comments | « core/src/fpdfdoc/doc_basic.cpp ('k') | core/src/fpdfdoc/doc_formcontrol.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698