Index: core/src/fpdfdoc/doc_form.cpp |
diff --git a/core/src/fpdfdoc/doc_form.cpp b/core/src/fpdfdoc/doc_form.cpp |
index 0617609fc278dd30f94238f175ecf999ca1a7ab1..dfdd7225b26fd2b6c430d3979db22a4ec3915c6e 100644 |
--- a/core/src/fpdfdoc/doc_form.cpp |
+++ b/core/src/fpdfdoc/doc_form.cpp |
@@ -95,7 +95,7 @@ CFieldTree::~CFieldTree() { |
CFieldTree::_Node* CFieldTree::AddChild(_Node* pParent, |
const CFX_WideString& short_name, |
CPDF_FormField* field_ptr) { |
- if (pParent == NULL) { |
+ if (!pParent) { |
return NULL; |
} |
_Node* pNode = new _Node; |
@@ -118,7 +118,7 @@ void CFieldTree::RemoveNode(_Node* pNode, int nLevel) { |
} |
CFieldTree::_Node* CFieldTree::_Lookup(_Node* pParent, |
const CFX_WideString& short_name) { |
- if (pParent == NULL) { |
+ if (!pParent) { |
return NULL; |
} |
for (int i = 0; i < pParent->children.GetSize(); i++) { |
@@ -150,7 +150,7 @@ void CFieldTree::SetField(const CFX_WideString& full_name, |
pLast = pNode; |
CFX_WideString name = CFX_WideString(pName, nLength); |
pNode = _Lookup(pLast, name); |
- if (pNode == NULL) { |
+ if (!pNode) { |
pNode = AddChild(pLast, name, NULL); |
} |
name_extractor.GetNext(pName, nLength); |
@@ -297,11 +297,11 @@ CFX_ByteString CPDF_InterForm::GenerateNewResourceName( |
} else { |
m = iCount; |
} |
- if (pResDict == NULL) { |
+ if (!pResDict) { |
return csTmp; |
} |
CPDF_Dictionary* pDict = pResDict->GetDict(csType); |
- if (pDict == NULL) { |
+ if (!pDict) { |
return csTmp; |
} |
int num = 0; |
@@ -551,7 +551,7 @@ FX_BOOL CPDF_InterForm::ValidateFieldName( |
FX_DWORD dwCount = m_pFieldTree->m_Root.CountFields(); |
for (FX_DWORD m = 0; m < dwCount; m++) { |
CPDF_FormField* pField = m_pFieldTree->m_Root.GetField(m); |
- if (pField == NULL) { |
+ if (!pField) { |
continue; |
} |
if (pField == pExcludedField) { |
@@ -595,15 +595,14 @@ FX_BOOL CPDF_InterForm::ValidateFieldName(CFX_WideString& csNewFieldName, |
} |
FX_BOOL CPDF_InterForm::ValidateFieldName(const CPDF_FormField* pField, |
CFX_WideString& csNewFieldName) { |
- if (pField == NULL || csNewFieldName.IsEmpty()) { |
- return FALSE; |
- } |
- return ValidateFieldName( |
- csNewFieldName, ((CPDF_FormField*)pField)->GetFieldType(), pField, NULL); |
+ return pField && !csNewFieldName.IsEmpty() && |
+ ValidateFieldName(csNewFieldName, |
+ ((CPDF_FormField*)pField)->GetFieldType(), pField, |
+ NULL); |
} |
FX_BOOL CPDF_InterForm::ValidateFieldName(const CPDF_FormControl* pControl, |
CFX_WideString& csNewFieldName) { |
- if (pControl == NULL || csNewFieldName.IsEmpty()) { |
+ if (!pControl || csNewFieldName.IsEmpty()) { |
return FALSE; |
} |
CPDF_FormField* pField = ((CPDF_FormControl*)pControl)->GetField(); |
@@ -653,10 +652,7 @@ FX_DWORD CPDF_InterForm::CountFields(const CFX_WideString& csFieldName) { |
return (FX_DWORD)m_pFieldTree->m_Root.CountFields(); |
} |
CFieldTree::_Node* pNode = m_pFieldTree->FindNode(csFieldName); |
- if (pNode == NULL) { |
- return 0; |
- } |
- return pNode->CountFields(); |
+ return pNode ? pNode->CountFields() : 0; |
} |
CPDF_FormField* CPDF_InterForm::GetField(FX_DWORD index, |
const CFX_WideString& csFieldName) { |
@@ -664,10 +660,7 @@ CPDF_FormField* CPDF_InterForm::GetField(FX_DWORD index, |
return m_pFieldTree->m_Root.GetField(index); |
} |
CFieldTree::_Node* pNode = m_pFieldTree->FindNode(csFieldName); |
- if (pNode == NULL) { |
- return NULL; |
- } |
- return pNode->GetField(index); |
+ return pNode ? pNode->GetField(index) : nullptr; |
} |
void CPDF_InterForm::GetAllFieldNames(CFX_WideStringArray& allFieldNames) { |
allFieldNames.RemoveAll(); |
@@ -683,7 +676,7 @@ void CPDF_InterForm::GetAllFieldNames(CFX_WideStringArray& allFieldNames) { |
CPDF_FormField* CPDF_InterForm::GetFieldByDict( |
CPDF_Dictionary* pFieldDict) const { |
- if (pFieldDict == NULL) { |
+ if (!pFieldDict) { |
return NULL; |
} |
CFX_WideString csWName = GetFullName(pFieldDict); |
@@ -727,34 +720,28 @@ CPDF_FormControl* CPDF_InterForm::GetControlByDict( |
} |
FX_BOOL CPDF_InterForm::NeedConstructAP() { |
- if (m_pFormDict == NULL) { |
- return FALSE; |
- } |
- return m_pFormDict->GetBoolean("NeedAppearances"); |
+ return m_pFormDict && m_pFormDict->GetBoolean("NeedAppearances"); |
} |
void CPDF_InterForm::NeedConstructAP(FX_BOOL bNeedAP) { |
- if (m_pFormDict == NULL) { |
+ if (!m_pFormDict) { |
InitInterFormDict(m_pFormDict, m_pDocument); |
} |
m_pFormDict->SetAtBoolean("NeedAppearances", bNeedAP); |
m_bGenerateAP = bNeedAP; |
} |
int CPDF_InterForm::CountFieldsInCalculationOrder() { |
- if (m_pFormDict == NULL) { |
+ if (!m_pFormDict) { |
return 0; |
} |
CPDF_Array* pArray = m_pFormDict->GetArray("CO"); |
- if (pArray == NULL) { |
- return 0; |
- } |
- return pArray->GetCount(); |
+ return pArray ? pArray->GetCount() : 0; |
} |
CPDF_FormField* CPDF_InterForm::GetFieldInCalculationOrder(int index) { |
- if (m_pFormDict == NULL || index < 0) { |
+ if (!m_pFormDict || index < 0) { |
return NULL; |
} |
CPDF_Array* pArray = m_pFormDict->GetArray("CO"); |
- if (pArray == NULL) { |
+ if (!pArray) { |
return NULL; |
} |
if (CPDF_Dictionary* pElement = |
@@ -764,11 +751,11 @@ CPDF_FormField* CPDF_InterForm::GetFieldInCalculationOrder(int index) { |
return NULL; |
} |
int CPDF_InterForm::FindFieldInCalculationOrder(const CPDF_FormField* pField) { |
- if (m_pFormDict == NULL || pField == NULL) { |
+ if (!m_pFormDict || !pField) { |
return -1; |
} |
CPDF_Array* pArray = m_pFormDict->GetArray("CO"); |
- if (pArray == NULL) { |
+ if (!pArray) { |
return -1; |
} |
for (FX_DWORD i = 0; i < pArray->GetCount(); i++) { |
@@ -834,7 +821,7 @@ void CPDF_InterForm::RemoveFormFont(CFX_ByteString csNameTag) { |
} |
CPDF_DefaultAppearance CPDF_InterForm::GetDefaultAppearance() { |
CFX_ByteString csDA; |
- if (m_pFormDict == NULL) { |
+ if (!m_pFormDict) { |
return csDA; |
} |
csDA = m_pFormDict->GetString("DA"); |
@@ -844,10 +831,7 @@ CPDF_Font* CPDF_InterForm::GetDefaultFormFont() { |
return GetDefaultInterFormFont(m_pFormDict, m_pDocument); |
} |
int CPDF_InterForm::GetFormAlignment() { |
- if (m_pFormDict == NULL) { |
- return 0; |
- } |
- return m_pFormDict->GetInteger("Q", 0); |
+ return m_pFormDict ? m_pFormDict->GetInteger("Q", 0) : 0; |
} |
bool CPDF_InterForm::ResetForm(const std::vector<CPDF_FormField*>& fields, |
@@ -892,7 +876,7 @@ void CPDF_InterForm::LoadField(CPDF_Dictionary* pFieldDict, int nLevel) { |
if (nLevel > nMaxRecursion) { |
return; |
} |
- if (pFieldDict == NULL) { |
+ if (!pFieldDict) { |
return; |
} |
FX_DWORD dwParentObjNum = pFieldDict->GetObjNum(); |
@@ -902,7 +886,7 @@ void CPDF_InterForm::LoadField(CPDF_Dictionary* pFieldDict, int nLevel) { |
return; |
} |
CPDF_Dictionary* pFirstKid = pKids->GetDict(0); |
- if (pFirstKid == NULL) { |
+ if (!pFirstKid) { |
return; |
} |
if (pFirstKid->KeyExist("T") || pFirstKid->KeyExist("Kids")) { |
@@ -923,11 +907,11 @@ FX_BOOL CPDF_InterForm::HasXFAForm() const { |
} |
void CPDF_InterForm::FixPageFields(const CPDF_Page* pPage) { |
CPDF_Dictionary* pPageDict = pPage->m_pFormDict; |
- if (pPageDict == NULL) { |
+ if (!pPageDict) { |
return; |
} |
CPDF_Array* pAnnots = pPageDict->GetArray("Annots"); |
- if (pAnnots == NULL) { |
+ if (!pAnnots) { |
return; |
} |
int iAnnotCount = pAnnots->GetCount(); |
@@ -949,7 +933,7 @@ CPDF_FormField* CPDF_InterForm::AddTerminalField(CPDF_Dictionary* pFieldDict) { |
} |
CPDF_FormField* pField = NULL; |
pField = m_pFieldTree->GetField(csWName); |
- if (pField == NULL) { |
+ if (!pField) { |
CPDF_Dictionary* pParent = pFieldDict; |
if (!pFieldDict->KeyExist("T") && |
pFieldDict->GetString("Subtype") == "Widget") { |
@@ -984,14 +968,14 @@ CPDF_FormField* CPDF_InterForm::AddTerminalField(CPDF_Dictionary* pFieldDict) { |
m_pFieldTree->SetField(csWName, pField); |
} |
CPDF_Array* pKids = pFieldDict->GetArray("Kids"); |
- if (pKids == NULL) { |
+ if (!pKids) { |
if (pFieldDict->GetString("Subtype") == "Widget") { |
AddControl(pField, pFieldDict); |
} |
} else { |
for (FX_DWORD i = 0; i < pKids->GetCount(); i++) { |
CPDF_Dictionary* pKid = pKids->GetDict(i); |
- if (pKid == NULL) { |
+ if (!pKid) { |
continue; |
} |
if (pKid->GetString("Subtype") != "Widget") { |
@@ -1064,7 +1048,7 @@ CFDF_Document* CPDF_InterForm::ExportToFDF( |
bool bIncludeOrExclude, |
bool bSimpleFileSpec) const { |
CFDF_Document* pDoc = CFDF_Document::CreateNewDoc(); |
- if (pDoc == NULL) { |
+ if (!pDoc) { |
return NULL; |
} |
CPDF_Dictionary* pMainDict = pDoc->GetRoot()->GetDict("FDF"); |
@@ -1080,14 +1064,14 @@ CFDF_Document* CPDF_InterForm::ExportToFDF( |
} |
} |
CPDF_Array* pFields = CPDF_Array::Create(); |
- if (pFields == NULL) { |
+ if (!pFields) { |
return NULL; |
} |
pMainDict->SetAt("Fields", pFields); |
int nCount = m_pFieldTree->m_Root.CountFields(); |
for (int i = 0; i < nCount; i++) { |
CPDF_FormField* pField = m_pFieldTree->m_Root.GetField(i); |
- if (pField == NULL || pField->GetType() == CPDF_FormField::PushButton) { |
+ if (!pField || pField->GetType() == CPDF_FormField::PushButton) { |
continue; |
} |
FX_DWORD dwFlags = pField->GetFieldFlags(); |
@@ -1175,7 +1159,7 @@ void CPDF_InterForm::FDF_ImportField(CPDF_Dictionary* pFieldDict, |
if (pKids) { |
for (FX_DWORD i = 0; i < pKids->GetCount(); i++) { |
CPDF_Dictionary* pKid = pKids->GetDict(i); |
- if (pKid == NULL) { |
+ if (!pKid) { |
continue; |
} |
if (nLevel <= nMaxRecursion) { |
@@ -1188,7 +1172,7 @@ void CPDF_InterForm::FDF_ImportField(CPDF_Dictionary* pFieldDict, |
return; |
} |
CPDF_FormField* pField = m_pFieldTree->GetField(name); |
- if (pField == NULL) { |
+ if (!pField) { |
return; |
} |
CFX_WideString csWValue; |
@@ -1231,15 +1215,15 @@ void CPDF_InterForm::FDF_ImportField(CPDF_Dictionary* pFieldDict, |
} |
FX_BOOL CPDF_InterForm::ImportFromFDF(const CFDF_Document* pFDF, |
FX_BOOL bNotify) { |
- if (pFDF == NULL) { |
+ if (!pFDF) { |
return FALSE; |
} |
CPDF_Dictionary* pMainDict = pFDF->GetRoot()->GetDict("FDF"); |
- if (pMainDict == NULL) { |
+ if (!pMainDict) { |
return FALSE; |
} |
CPDF_Array* pFields = pMainDict->GetArray("Fields"); |
- if (pFields == NULL) { |
+ if (!pFields) { |
return FALSE; |
} |
m_bsEncoding = pMainDict->GetString("Encoding"); |
@@ -1251,7 +1235,7 @@ FX_BOOL CPDF_InterForm::ImportFromFDF(const CFDF_Document* pFDF, |
} |
for (FX_DWORD i = 0; i < pFields->GetCount(); i++) { |
CPDF_Dictionary* pField = pFields->GetDict(i); |
- if (pField == NULL) { |
+ if (!pField) { |
continue; |
} |
FDF_ImportField(pField, L"", bNotify); |