summaryrefslogtreecommitdiff
path: root/core/src/fpdfdoc
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2015-12-14 18:34:00 -0800
committerLei Zhang <thestig@chromium.org>2015-12-14 18:34:00 -0800
commit412e908082a361d0fd9591eab939e96a882212f1 (patch)
tree11726052ae08f13dc5a05a82cbce870758580aeb /core/src/fpdfdoc
parent96660d6f382204339d6b1aadc3913303d436e252 (diff)
downloadpdfium-412e908082a361d0fd9591eab939e96a882212f1.tar.xz
Merge to XFA: Get rid of most instance of 'foo == NULL'
TBR=tsepez@chromium.org Review URL: https://codereview.chromium.org/1520063002 . (cherry picked from commit e385244f8cd6ae376f6b3cf1265a0795d5d30eff) Review URL: https://codereview.chromium.org/1528763003 .
Diffstat (limited to 'core/src/fpdfdoc')
-rw-r--r--core/src/fpdfdoc/doc_action.cpp29
-rw-r--r--core/src/fpdfdoc/doc_annot.cpp8
-rw-r--r--core/src/fpdfdoc/doc_ap.cpp13
-rw-r--r--core/src/fpdfdoc/doc_basic.cpp30
-rw-r--r--core/src/fpdfdoc/doc_form.cpp96
-rw-r--r--core/src/fpdfdoc/doc_formcontrol.cpp27
-rw-r--r--core/src/fpdfdoc/doc_formfield.cpp62
-rw-r--r--core/src/fpdfdoc/doc_ocg.cpp6
-rw-r--r--core/src/fpdfdoc/doc_tagged.cpp12
-rw-r--r--core/src/fpdfdoc/doc_utils.cpp108
10 files changed, 181 insertions, 210 deletions
diff --git a/core/src/fpdfdoc/doc_action.cpp b/core/src/fpdfdoc/doc_action.cpp
index 87cfe7e642..e68a8c8a06 100644
--- a/core/src/fpdfdoc/doc_action.cpp
+++ b/core/src/fpdfdoc/doc_action.cpp
@@ -56,7 +56,7 @@ CFX_WideString CPDF_Action::GetFilePath() const {
}
CPDF_Object* pFile = m_pDict->GetElementValue("F");
CFX_WideString path;
- if (pFile == NULL) {
+ if (!pFile) {
if (type == "Launch") {
CPDF_Dictionary* pWinDict = m_pDict->GetDict("Win");
if (pWinDict) {
@@ -71,7 +71,7 @@ CFX_WideString CPDF_Action::GetFilePath() const {
}
CFX_ByteString CPDF_Action::GetURI(CPDF_Document* pDoc) const {
CFX_ByteString csURI;
- if (m_pDict == NULL) {
+ if (!m_pDict) {
return csURI;
}
if (m_pDict->GetString("S") != "URI") {
@@ -88,11 +88,11 @@ CFX_ByteString CPDF_Action::GetURI(CPDF_Document* pDoc) const {
return csURI;
}
FX_DWORD CPDF_ActionFields::GetFieldsCount() const {
- if (m_pAction == NULL) {
+ if (!m_pAction) {
return 0;
}
CPDF_Dictionary* pDict = m_pAction->GetDict();
- if (pDict == NULL) {
+ if (!pDict) {
return 0;
}
CFX_ByteString csType = pDict->GetString("S");
@@ -146,11 +146,11 @@ std::vector<CPDF_Object*> CPDF_ActionFields::GetAllFields() const {
}
CPDF_Object* CPDF_ActionFields::GetField(FX_DWORD iIndex) const {
- if (m_pAction == NULL) {
+ if (!m_pAction) {
return NULL;
}
CPDF_Dictionary* pDict = m_pAction->GetDict();
- if (pDict == NULL) {
+ if (!pDict) {
return NULL;
}
CFX_ByteString csType = pDict->GetString("S");
@@ -160,7 +160,7 @@ CPDF_Object* CPDF_ActionFields::GetField(FX_DWORD iIndex) const {
} else {
pFields = pDict->GetArray("Fields");
}
- if (pFields == NULL) {
+ if (!pFields) {
return NULL;
}
CPDF_Object* pFindObj = NULL;
@@ -175,7 +175,7 @@ CPDF_Object* CPDF_ActionFields::GetField(FX_DWORD iIndex) const {
CFX_WideString CPDF_Action::GetJavaScript() const {
CFX_WideString csJS;
- if (m_pDict == NULL) {
+ if (!m_pDict) {
return csJS;
}
CPDF_Object* pJS = m_pDict->GetElementValue("JS");
@@ -195,7 +195,7 @@ CPDF_Dictionary* CPDF_Action::GetAnnot() const {
return nullptr;
}
int32_t CPDF_Action::GetOperationType() const {
- if (m_pDict == NULL) {
+ if (!m_pDict) {
return 0;
}
CFX_ByteString csType = m_pDict->GetString("S");
@@ -233,7 +233,7 @@ FX_DWORD CPDF_Action::GetSubActionsCount() const {
return 0;
}
CPDF_Action CPDF_Action::GetSubAction(FX_DWORD iIndex) const {
- if (m_pDict == NULL || !m_pDict->KeyExist("Next")) {
+ if (!m_pDict || !m_pDict->KeyExist("Next")) {
return CPDF_Action();
}
CPDF_Object* pNext = m_pDict->GetElementValue("Next");
@@ -249,10 +249,7 @@ const FX_CHAR* g_sAATypes[] = {"E", "X", "D", "U", "Fo", "Bl", "PO", "PC",
"PV", "PI", "O", "C", "K", "F", "V", "C",
"WC", "WS", "DS", "WP", "DP", ""};
FX_BOOL CPDF_AAction::ActionExist(AActionType eType) const {
- if (m_pDict == NULL) {
- return FALSE;
- }
- return m_pDict->KeyExist(g_sAATypes[(int)eType]);
+ return m_pDict && m_pDict->KeyExist(g_sAATypes[(int)eType]);
}
CPDF_Action CPDF_AAction::GetAction(AActionType eType) const {
if (!m_pDict) {
@@ -261,14 +258,14 @@ CPDF_Action CPDF_AAction::GetAction(AActionType eType) const {
return CPDF_Action(m_pDict->GetDict(g_sAATypes[(int)eType]));
}
FX_POSITION CPDF_AAction::GetStartPos() const {
- if (m_pDict == NULL) {
+ if (!m_pDict) {
return NULL;
}
return m_pDict->GetStartPos();
}
CPDF_Action CPDF_AAction::GetNextAction(FX_POSITION& pos,
AActionType& eType) const {
- if (m_pDict == NULL) {
+ if (!m_pDict) {
return CPDF_Action();
}
CFX_ByteString csKey;
diff --git a/core/src/fpdfdoc/doc_annot.cpp b/core/src/fpdfdoc/doc_annot.cpp
index 0871b357cf..8f3d7f99eb 100644
--- a/core/src/fpdfdoc/doc_annot.cpp
+++ b/core/src/fpdfdoc/doc_annot.cpp
@@ -133,7 +133,7 @@ CFX_ByteString CPDF_Annot::GetSubType() const {
}
void CPDF_Annot::GetRect(CPDF_Rect& rect) const {
- if (m_pAnnotDict == NULL) {
+ if (!m_pAnnotDict) {
return;
}
rect = m_pAnnotDict->GetRect("Rect");
@@ -147,7 +147,7 @@ FX_DWORD CPDF_Annot::GetFlags() const {
CPDF_Stream* FPDFDOC_GetAnnotAP(CPDF_Dictionary* pAnnotDict,
CPDF_Annot::AppearanceMode mode) {
CPDF_Dictionary* pAP = pAnnotDict->GetDict("AP");
- if (pAP == NULL) {
+ if (!pAP) {
return NULL;
}
const FX_CHAR* ap_entry = "N";
@@ -267,14 +267,14 @@ void CPDF_Annot::DrawBorder(CFX_RenderDevice* pDevice,
char style_char;
FX_FLOAT width;
CPDF_Array* pDashArray = NULL;
- if (pBS == NULL) {
+ if (!pBS) {
CPDF_Array* pBorderArray = m_pAnnotDict->GetArray("Border");
style_char = 'S';
if (pBorderArray) {
width = pBorderArray->GetNumber(2);
if (pBorderArray->GetCount() == 4) {
pDashArray = pBorderArray->GetArray(3);
- if (pDashArray == NULL) {
+ if (!pDashArray) {
return;
}
int nLen = pDashArray->GetCount();
diff --git a/core/src/fpdfdoc/doc_ap.cpp b/core/src/fpdfdoc/doc_ap.cpp
index 1392ae6e2e..0efaa8caa5 100644
--- a/core/src/fpdfdoc/doc_ap.cpp
+++ b/core/src/fpdfdoc/doc_ap.cpp
@@ -292,7 +292,7 @@ static FX_BOOL GenerateWidgetAP(CPDF_Document* pDoc,
FX_BOOL bUseFormRes = FALSE;
CPDF_Dictionary* pFontDict = NULL;
CPDF_Dictionary* pDRDict = pAnnotDict->GetDict("DR");
- if (pDRDict == NULL) {
+ if (!pDRDict) {
pDRDict = pFormDict->GetDict("DR");
bUseFormRes = TRUE;
}
@@ -312,7 +312,7 @@ static FX_BOOL GenerateWidgetAP(CPDF_Document* pDoc,
}
if (!pFontDict) {
pFontDict = CPDF_Dictionary::Create();
- if (pFontDict == NULL) {
+ if (!pFontDict) {
return FALSE;
}
pFontDict->SetAtName("Type", "Font");
@@ -418,11 +418,8 @@ static FX_BOOL GenerateWidgetAP(CPDF_Document* pDoc,
rcBBox.right - fBorderWidth, rcBBox.top - fBorderWidth);
rcBody.Normalize();
CPDF_Dictionary* pAPDict = pAnnotDict->GetDict("AP");
- if (pAPDict == NULL) {
+ if (!pAPDict) {
pAPDict = CPDF_Dictionary::Create();
- if (pAPDict == NULL) {
- return FALSE;
- }
pAnnotDict->SetAt("AP", pAPDict);
}
CPDF_Stream* pNormalStream = pAPDict->GetStream("N");
@@ -440,7 +437,7 @@ static FX_BOOL GenerateWidgetAP(CPDF_Document* pDoc,
CPDF_Dictionary* pStreamResFontList = pStreamResList->GetDict("Font");
if (!pStreamResFontList) {
pStreamResFontList = CPDF_Dictionary::Create();
- if (pStreamResFontList == NULL) {
+ if (!pStreamResFontList) {
return FALSE;
}
pStreamResList->SetAt("Font", pStreamResFontList);
@@ -688,7 +685,7 @@ static FX_BOOL GenerateWidgetAP(CPDF_Document* pDoc,
CPDF_Dictionary* pStreamResFontList = pStreamResList->GetDict("Font");
if (!pStreamResFontList) {
pStreamResFontList = CPDF_Dictionary::Create();
- if (pStreamResFontList == NULL) {
+ if (!pStreamResFontList) {
return FALSE;
}
pStreamResList->SetAt("Font", pStreamResFontList);
diff --git a/core/src/fpdfdoc/doc_basic.cpp b/core/src/fpdfdoc/doc_basic.cpp
index c58e10b779..d976650ae0 100644
--- a/core/src/fpdfdoc/doc_basic.cpp
+++ b/core/src/fpdfdoc/doc_basic.cpp
@@ -112,12 +112,12 @@ static CPDF_Object* SearchNameNode(CPDF_Dictionary* pNode,
return NULL;
}
CPDF_Array* pKids = pNode->GetArray("Kids");
- if (pKids == NULL) {
+ if (!pKids) {
return NULL;
}
for (FX_DWORD i = 0; i < pKids->GetCount(); i++) {
CPDF_Dictionary* pKid = pKids->GetDict(i);
- if (pKid == NULL) {
+ if (!pKid) {
continue;
}
CPDF_Object* pFound =
@@ -151,12 +151,12 @@ static CPDF_Object* SearchNameNode(CPDF_Dictionary* pNode,
return pNames->GetElementValue((nIndex - nCurIndex) * 2 + 1);
}
CPDF_Array* pKids = pNode->GetArray("Kids");
- if (pKids == NULL) {
+ if (!pKids) {
return NULL;
}
for (FX_DWORD i = 0; i < pKids->GetCount(); i++) {
CPDF_Dictionary* pKid = pKids->GetDict(i);
- if (pKid == NULL) {
+ if (!pKid) {
continue;
}
CPDF_Object* pFound =
@@ -176,13 +176,13 @@ static int CountNames(CPDF_Dictionary* pNode, int nLevel = 0) {
return pNames->GetCount() / 2;
}
CPDF_Array* pKids = pNode->GetArray("Kids");
- if (pKids == NULL) {
+ if (!pKids) {
return 0;
}
int nCount = 0;
for (FX_DWORD i = 0; i < pKids->GetCount(); i++) {
CPDF_Dictionary* pKid = pKids->GetDict(i);
- if (pKid == NULL) {
+ if (!pKid) {
continue;
}
nCount += CountNames(pKid, nLevel + 1);
@@ -190,31 +190,31 @@ static int CountNames(CPDF_Dictionary* pNode, int nLevel = 0) {
return nCount;
}
int CPDF_NameTree::GetCount() const {
- if (m_pRoot == NULL) {
+ if (!m_pRoot) {
return 0;
}
return ::CountNames(m_pRoot);
}
int CPDF_NameTree::GetIndex(const CFX_ByteString& csName) const {
- if (m_pRoot == NULL) {
+ if (!m_pRoot) {
return -1;
}
int nIndex = 0;
- if (SearchNameNode(m_pRoot, csName, nIndex, NULL) == NULL) {
+ if (!SearchNameNode(m_pRoot, csName, nIndex, NULL)) {
return -1;
}
return nIndex;
}
CPDF_Object* CPDF_NameTree::LookupValue(int nIndex,
CFX_ByteString& csName) const {
- if (m_pRoot == NULL) {
+ if (!m_pRoot) {
return NULL;
}
int nCurIndex = 0;
return SearchNameNode(m_pRoot, nIndex, nCurIndex, csName, NULL);
}
CPDF_Object* CPDF_NameTree::LookupValue(const CFX_ByteString& csName) const {
- if (m_pRoot == NULL) {
+ if (!m_pRoot) {
return NULL;
}
int nIndex = 0;
@@ -468,11 +468,11 @@ static CFX_WideString _GetLabelNumPortion(int num,
}
CFX_WideString CPDF_PageLabel::GetLabel(int nPage) const {
CFX_WideString wsLabel;
- if (m_pDocument == NULL) {
+ if (!m_pDocument) {
return wsLabel;
}
CPDF_Dictionary* pPDFRoot = m_pDocument->GetRoot();
- if (pPDFRoot == NULL) {
+ if (!pPDFRoot) {
return wsLabel;
}
CPDF_Dictionary* pLabels = pPDFRoot->GetDict("PageLabels");
@@ -504,11 +504,11 @@ CFX_WideString CPDF_PageLabel::GetLabel(int nPage) const {
return wsLabel;
}
int32_t CPDF_PageLabel::GetPageByLabel(const CFX_ByteStringC& bsLabel) const {
- if (m_pDocument == NULL) {
+ if (!m_pDocument) {
return -1;
}
CPDF_Dictionary* pPDFRoot = m_pDocument->GetRoot();
- if (pPDFRoot == NULL) {
+ if (!pPDFRoot) {
return -1;
}
int nPages = m_pDocument->GetPageCount();
diff --git a/core/src/fpdfdoc/doc_form.cpp b/core/src/fpdfdoc/doc_form.cpp
index 0617609fc2..dfdd7225b2 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);
diff --git a/core/src/fpdfdoc/doc_formcontrol.cpp b/core/src/fpdfdoc/doc_formcontrol.cpp
index 0d2f9905d9..fa0441cf79 100644
--- a/core/src/fpdfdoc/doc_formcontrol.cpp
+++ b/core/src/fpdfdoc/doc_formcontrol.cpp
@@ -20,11 +20,11 @@ CFX_ByteString CPDF_FormControl::GetOnStateName() {
GetType() == CPDF_FormField::RadioButton);
CFX_ByteString csOn;
CPDF_Dictionary* pAP = m_pWidgetDict->GetDict("AP");
- if (pAP == NULL) {
+ if (!pAP) {
return csOn;
}
CPDF_Dictionary* pN = pAP->GetDict("N");
- if (pN == NULL) {
+ if (!pN) {
return csOn;
}
FX_POSITION pos = pN->GetStartPos();
@@ -51,14 +51,14 @@ void CPDF_FormControl::SetOnStateName(const CFX_ByteString& csOn) {
m_pWidgetDict->SetAtName("AS", csValue);
}
CPDF_Dictionary* pAP = m_pWidgetDict->GetDict("AP");
- if (pAP == NULL) {
+ if (!pAP) {
return;
}
FX_POSITION pos1 = pAP->GetStartPos();
while (pos1) {
CFX_ByteString csKey1;
CPDF_Object* pObj1 = pAP->GetNextElement(pos1, csKey1);
- if (pObj1 == NULL) {
+ if (!pObj1) {
continue;
}
CPDF_Object* pObjDirect1 = pObj1->GetDirect();
@@ -70,7 +70,7 @@ void CPDF_FormControl::SetOnStateName(const CFX_ByteString& csOn) {
while (pos2) {
CFX_ByteString csKey2;
CPDF_Object* pObj2 = pSubDict->GetNextElement(pos2, csKey2);
- if (pObj2 == NULL) {
+ if (!pObj2) {
continue;
}
if (csKey2 != "Off") {
@@ -124,7 +124,7 @@ FX_BOOL CPDF_FormControl::IsDefaultChecked() {
ASSERT(GetType() == CPDF_FormField::CheckBox ||
GetType() == CPDF_FormField::RadioButton);
CPDF_Object* pDV = FPDF_GetFieldAttr(m_pField->m_pDict, "DV");
- if (pDV == NULL) {
+ if (!pDV) {
return FALSE;
}
CFX_ByteString csDV = pDV->GetString();
@@ -157,7 +157,7 @@ void CPDF_FormControl::DrawControl(CFX_RenderDevice* pDevice,
return;
}
CPDF_Stream* pStream = FPDFDOC_GetAnnotAP(m_pWidgetDict, mode);
- if (pStream == NULL) {
+ if (!pStream) {
return;
}
CFX_FloatRect form_bbox = pStream->GetDict()->GetRect("BBox");
@@ -176,7 +176,7 @@ void CPDF_FormControl::DrawControl(CFX_RenderDevice* pDevice,
}
const FX_CHAR* g_sHighlightingMode[] = {"N", "I", "O", "P", "T", ""};
CPDF_FormControl::HighlightingMode CPDF_FormControl::GetHighlightingMode() {
- if (m_pWidgetDict == NULL) {
+ if (!m_pWidgetDict) {
return Invert;
}
CFX_ByteString csH = m_pWidgetDict->GetString("H", "I");
@@ -317,10 +317,9 @@ int CPDF_FormControl::GetControlAlignment() {
return m_pWidgetDict->GetInteger("Q", 0);
}
CPDF_Object* pObj = FPDF_GetFieldAttr(m_pField->m_pDict, "Q");
- if (pObj == NULL) {
- return m_pField->m_pForm->GetFormAlignment();
- }
- return pObj->GetInteger();
+ if (pObj)
+ return pObj->GetInteger();
+ return m_pField->m_pForm->GetFormAlignment();
}
CPDF_ApSettings::CPDF_ApSettings(CPDF_Dictionary* pDict) : m_pDict(pDict) {}
@@ -386,11 +385,11 @@ void CPDF_ApSettings::GetOriginalColor(int& iColorType,
for (int i = 0; i < 4; i++) {
fc[i] = 0;
}
- if (m_pDict == NULL) {
+ if (!m_pDict) {
return;
}
CPDF_Array* pEntry = m_pDict->GetArray(csEntry);
- if (pEntry == NULL) {
+ if (!pEntry) {
return;
}
FX_DWORD dwCount = pEntry->GetCount();
diff --git a/core/src/fpdfdoc/doc_formfield.cpp b/core/src/fpdfdoc/doc_formfield.cpp
index e14b5ad31a..c6428157e5 100644
--- a/core/src/fpdfdoc/doc_formfield.cpp
+++ b/core/src/fpdfdoc/doc_formfield.cpp
@@ -184,12 +184,9 @@ FX_BOOL CPDF_FormField::ResetField(FX_BOOL bNotify) {
return FALSE;
}
}
- if (pDV == NULL) {
- m_pDict->RemoveAt("V");
- m_pDict->RemoveAt("RV");
- } else {
+ if (pDV) {
CPDF_Object* pClone = pDV->Clone();
- if (pClone == NULL) {
+ if (!pClone) {
return FALSE;
}
m_pDict->SetAt("V", pClone);
@@ -197,6 +194,9 @@ FX_BOOL CPDF_FormField::ResetField(FX_BOOL bNotify) {
CPDF_Object* pCloneR = pDV->Clone();
m_pDict->SetAt("RV", pCloneR);
}
+ } else {
+ m_pDict->RemoveAt("V");
+ m_pDict->RemoveAt("RV");
}
if (bNotify && m_pForm->m_pFormNotify) {
m_pForm->m_pFormNotify->AfterValueChange(this);
@@ -241,42 +241,42 @@ int CPDF_FormField::GetFieldType() {
}
CPDF_AAction CPDF_FormField::GetAdditionalAction() {
CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "AA");
- if (pObj == NULL) {
+ if (!pObj) {
return NULL;
}
return pObj->GetDict();
}
CFX_WideString CPDF_FormField::GetAlternateName() {
CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "TU");
- if (pObj == NULL) {
+ if (!pObj) {
return L"";
}
return pObj->GetUnicodeText();
}
CFX_WideString CPDF_FormField::GetMappingName() {
CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "TM");
- if (pObj == NULL) {
+ if (!pObj) {
return L"";
}
return pObj->GetUnicodeText();
}
FX_DWORD CPDF_FormField::GetFieldFlags() {
CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "Ff");
- if (pObj == NULL) {
+ if (!pObj) {
return 0;
}
return pObj->GetInteger();
}
CFX_ByteString CPDF_FormField::GetDefaultStyle() {
CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "DS");
- if (pObj == NULL) {
+ if (!pObj) {
return "";
}
return pObj->GetString();
}
CFX_WideString CPDF_FormField::GetRichTextString() {
CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "RV");
- if (pObj == NULL) {
+ if (!pObj) {
return L"";
}
return pObj->GetUnicodeText();
@@ -286,16 +286,16 @@ CFX_WideString CPDF_FormField::GetValue(FX_BOOL bDefault) {
return GetCheckValue(bDefault);
}
CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict, bDefault ? "DV" : "V");
- if (pValue == NULL) {
+ if (!pValue) {
if (!bDefault) {
if (m_Type == RichText) {
pValue = FPDF_GetFieldAttr(m_pDict, "V");
}
- if (pValue == NULL && m_Type != Text) {
+ if (!pValue && m_Type != Text) {
pValue = FPDF_GetFieldAttr(m_pDict, "DV");
}
}
- if (pValue == NULL) {
+ if (!pValue) {
return CFX_WideString();
}
}
@@ -507,9 +507,9 @@ FX_BOOL CPDF_FormField::IsItemSelected(int index) {
}
CFX_WideString opt_value = GetOptionValue(index);
CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict, "V");
- if (pValue == NULL) {
+ if (!pValue) {
pValue = FPDF_GetFieldAttr(m_pDict, "I");
- if (pValue == NULL) {
+ if (!pValue) {
return FALSE;
}
}
@@ -599,7 +599,7 @@ FX_BOOL CPDF_FormField::SetItemSelection(int index,
m_pDict->SetAtString("V", PDF_EncodeText(opt_value));
} else {
CPDF_Array* pArray = CPDF_Array::Create();
- if (pArray == NULL) {
+ if (!pArray) {
return FALSE;
}
FX_BOOL bSelected;
@@ -620,7 +620,7 @@ FX_BOOL CPDF_FormField::SetItemSelection(int index,
} else if (m_Type == ComboBox) {
m_pDict->SetAtString("V", PDF_EncodeText(opt_value));
CPDF_Array* pI = CPDF_Array::Create();
- if (pI == NULL) {
+ if (!pI) {
return FALSE;
}
pI->AddInteger(index);
@@ -655,7 +655,7 @@ FX_BOOL CPDF_FormField::IsItemDefaultSelected(int index) {
int CPDF_FormField::GetDefaultSelectedItem() {
ASSERT(GetType() == ComboBox || GetType() == ListBox);
CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict, "DV");
- if (pValue == NULL) {
+ if (!pValue) {
return -1;
}
CFX_WideString csDV = pValue->GetUnicodeText();
@@ -817,7 +817,7 @@ FX_BOOL CPDF_FormField::CheckControl(int iControlIndex,
FX_BOOL bNotify) {
ASSERT(GetType() == CheckBox || GetType() == RadioButton);
CPDF_FormControl* pControl = GetControl(iControlIndex);
- if (pControl == NULL) {
+ if (!pControl) {
return FALSE;
}
if (!bChecked && pControl->IsChecked() == bChecked) {
@@ -929,29 +929,29 @@ FX_BOOL CPDF_FormField::SetCheckValue(const CFX_WideString& value,
}
int CPDF_FormField::GetTopVisibleIndex() {
CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "TI");
- if (pObj == NULL) {
+ if (!pObj) {
return 0;
}
return pObj->GetInteger();
}
int CPDF_FormField::CountSelectedOptions() {
CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "I");
- if (pObj == NULL) {
+ if (!pObj) {
return 0;
}
CPDF_Array* pArray = pObj->GetArray();
- if (pArray == NULL) {
+ if (!pArray) {
return 0;
}
return (int)pArray->GetCount();
}
int CPDF_FormField::GetSelectedOptionIndex(int index) {
CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "I");
- if (pObj == NULL) {
+ if (!pObj) {
return -1;
}
CPDF_Array* pArray = pObj->GetArray();
- if (pArray == NULL) {
+ if (!pArray) {
return -1;
}
int iCount = (int)pArray->GetCount();
@@ -962,11 +962,11 @@ int CPDF_FormField::GetSelectedOptionIndex(int index) {
}
FX_BOOL CPDF_FormField::IsOptionSelected(int iOptIndex) {
CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "I");
- if (pObj == NULL) {
+ if (!pObj) {
return FALSE;
}
CPDF_Array* pArray = pObj->GetArray();
- if (pArray == NULL) {
+ if (!pArray) {
return FALSE;
}
int iCount = (int)pArray->GetCount();
@@ -981,12 +981,12 @@ FX_BOOL CPDF_FormField::SelectOption(int iOptIndex,
FX_BOOL bSelected,
FX_BOOL bNotify) {
CPDF_Array* pArray = m_pDict->GetArray("I");
- if (pArray == NULL) {
+ if (!pArray) {
if (!bSelected) {
return TRUE;
}
pArray = CPDF_Array::Create();
- if (pArray == NULL) {
+ if (!pArray) {
return FALSE;
}
m_pDict->SetAt("I", pArray);
@@ -1032,7 +1032,7 @@ FX_BOOL CPDF_FormField::SelectOption(int iOptIndex,
}
}
CPDF_Number* pNum = CPDF_Number::Create(iOptIndex);
- if (pNum == NULL) {
+ if (!pNum) {
return FALSE;
}
pArray->InsertAt(i, pNum);
@@ -1109,7 +1109,7 @@ void CPDF_FormField::LoadDA() {
pFontDict = m_pForm->m_pFormDict->GetDict("DR")->GetDict("Font")->GetDict(
font_name);
- if (pFontDict == NULL) {
+ if (!pFontDict) {
return;
}
m_pFont = m_pForm->m_pDocument->LoadFont(pFontDict);
diff --git a/core/src/fpdfdoc/doc_ocg.cpp b/core/src/fpdfdoc/doc_ocg.cpp
index cfca121d36..539c038b41 100644
--- a/core/src/fpdfdoc/doc_ocg.cpp
+++ b/core/src/fpdfdoc/doc_ocg.cpp
@@ -25,7 +25,7 @@ static FX_BOOL FPDFDOC_OCG_HasIntent(const CPDF_Dictionary* pDict,
const CFX_ByteStringC& csElement,
const CFX_ByteStringC& csDef = "") {
CPDF_Object* pIntent = pDict->GetElementValue("Intent");
- if (pIntent == NULL) {
+ if (!pIntent) {
return csElement == csDef;
}
CFX_ByteString bsIntent;
@@ -189,7 +189,7 @@ FX_BOOL CPDF_OCContext::GetOCGVE(CPDF_Array* pExpression,
if (nLevel > 32) {
return FALSE;
}
- if (pExpression == NULL) {
+ if (!pExpression) {
return FALSE;
}
int32_t iCount = pExpression->GetCount();
@@ -209,7 +209,7 @@ FX_BOOL CPDF_OCContext::GetOCGVE(CPDF_Array* pExpression,
FX_BOOL bValue = FALSE;
for (int32_t i = 1; i < iCount; i++) {
pOCGObj = pExpression->GetElementValue(1);
- if (pOCGObj == NULL) {
+ if (!pOCGObj) {
continue;
}
FX_BOOL bItem = FALSE;
diff --git a/core/src/fpdfdoc/doc_tagged.cpp b/core/src/fpdfdoc/doc_tagged.cpp
index 7869834dd9..d51743b0dc 100644
--- a/core/src/fpdfdoc/doc_tagged.cpp
+++ b/core/src/fpdfdoc/doc_tagged.cpp
@@ -35,7 +35,7 @@ CPDF_StructTree* CPDF_StructTree::LoadDoc(const CPDF_Document* pDoc) {
CPDF_StructTreeImpl::CPDF_StructTreeImpl(const CPDF_Document* pDoc) {
CPDF_Dictionary* pCatalog = pDoc->GetRoot();
m_pTreeRoot = pCatalog->GetDict("StructTreeRoot");
- if (m_pTreeRoot == NULL) {
+ if (!m_pTreeRoot) {
return;
}
m_pRoleMap = m_pTreeRoot->GetDict("RoleMap");
@@ -95,7 +95,7 @@ void CPDF_StructTreeImpl::LoadPageTree(const CPDF_Dictionary* pPageDict) {
}
CFX_MapPtrToPtr element_map;
CPDF_Dictionary* pParentTree = m_pTreeRoot->GetDict("ParentTree");
- if (pParentTree == NULL) {
+ if (!pParentTree) {
return;
}
CPDF_NumberTree parent_tree(pParentTree);
@@ -107,7 +107,7 @@ void CPDF_StructTreeImpl::LoadPageTree(const CPDF_Dictionary* pPageDict) {
for (i = 0; i < pParentArray->GetCount(); i++) {
CPDF_Dictionary* pParent = pParentArray->GetDict(i);
- if (pParent == NULL) {
+ if (!pParent) {
continue;
}
AddPageNode(pParent, element_map);
@@ -127,7 +127,7 @@ CPDF_StructElementImpl* CPDF_StructTreeImpl::AddPageNode(CPDF_Dictionary* pDict,
pElement = new CPDF_StructElementImpl(this, NULL, pDict);
map.SetAt(pDict, pElement);
CPDF_Dictionary* pParent = pDict->GetDict("P");
- if (pParent == NULL || pParent->GetString("Type") == "StructTreeRoot") {
+ if (!pParent || pParent->GetString("Type") == "StructTreeRoot") {
if (!AddTopLevelNode(pDict, pElement)) {
pElement->Release();
map.RemoveKey(pDict);
@@ -294,7 +294,7 @@ void CPDF_StructElementImpl::LoadKid(FX_DWORD PageObjNum,
} else {
pKid->m_Type = CPDF_StructKid::Element;
pKid->m_Element.m_pDict = pKidDict;
- if (m_pTree->m_pPage == NULL) {
+ if (!m_pTree->m_pPage) {
pKid->m_Element.m_pElement =
new CPDF_StructElementImpl(m_pTree, this, pKidDict);
} else {
@@ -339,7 +339,7 @@ CPDF_Object* CPDF_StructElementImpl::GetAttr(const CFX_ByteStringC& owner,
if (pAttr) {
return pAttr;
}
- if (m_pParent == NULL) {
+ if (!m_pParent) {
return NULL;
}
return m_pParent->GetAttr(owner, name, TRUE, fLevel + 1);
diff --git a/core/src/fpdfdoc/doc_utils.cpp b/core/src/fpdfdoc/doc_utils.cpp
index f26355fae5..b0705ea556 100644
--- a/core/src/fpdfdoc/doc_utils.cpp
+++ b/core/src/fpdfdoc/doc_utils.cpp
@@ -224,14 +224,11 @@ CFX_Matrix CPDF_DefaultAppearance::GetTextMatrix() {
return tm;
}
void InitInterFormDict(CPDF_Dictionary*& pFormDict, CPDF_Document* pDocument) {
- if (pDocument == NULL) {
+ if (!pDocument) {
return;
}
- if (pFormDict == NULL) {
+ if (!pFormDict) {
pFormDict = CPDF_Dictionary::Create();
- if (pFormDict == NULL) {
- return;
- }
FX_DWORD dwObjNum = pDocument->AddIndirectObject(pFormDict);
CPDF_Dictionary* pRoot = pDocument->GetRoot();
pRoot->SetAtReference("AcroForm", pDocument, dwObjNum);
@@ -248,7 +245,7 @@ void InitInterFormDict(CPDF_Dictionary*& pFormDict, CPDF_Document* pDocument) {
}
if (charSet != 0) {
CFX_ByteString csFontName = CPDF_InterForm::GetNativeFont(charSet, NULL);
- if (pFont == NULL || csFontName != "Helvetica") {
+ if (!pFont || csFontName != "Helvetica") {
pFont = CPDF_InterForm::AddNativeFont(pDocument);
if (pFont) {
csBaseName = "";
@@ -270,15 +267,15 @@ void InitInterFormDict(CPDF_Dictionary*& pFormDict, CPDF_Document* pDocument) {
}
}
FX_DWORD CountInterFormFonts(CPDF_Dictionary* pFormDict) {
- if (pFormDict == NULL) {
+ if (!pFormDict) {
return 0;
}
CPDF_Dictionary* pDR = pFormDict->GetDict("DR");
- if (pDR == NULL) {
+ if (!pDR) {
return 0;
}
CPDF_Dictionary* pFonts = pDR->GetDict("Font");
- if (pFonts == NULL) {
+ if (!pFonts) {
return 0;
}
FX_DWORD dwCount = 0;
@@ -287,7 +284,7 @@ FX_DWORD CountInterFormFonts(CPDF_Dictionary* pFormDict) {
CPDF_Object* pObj = NULL;
CFX_ByteString csKey;
pObj = pFonts->GetNextElement(pos, csKey);
- if (pObj == NULL) {
+ if (!pObj) {
continue;
}
if (CPDF_Dictionary* pDirect = ToDictionary(pObj->GetDirect())) {
@@ -302,15 +299,15 @@ CPDF_Font* GetInterFormFont(CPDF_Dictionary* pFormDict,
CPDF_Document* pDocument,
FX_DWORD index,
CFX_ByteString& csNameTag) {
- if (pFormDict == NULL) {
+ if (!pFormDict) {
return NULL;
}
CPDF_Dictionary* pDR = pFormDict->GetDict("DR");
- if (pDR == NULL) {
+ if (!pDR) {
return NULL;
}
CPDF_Dictionary* pFonts = pDR->GetDict("Font");
- if (pFonts == NULL) {
+ if (!pFonts) {
return NULL;
}
FX_DWORD dwCount = 0;
@@ -319,7 +316,7 @@ CPDF_Font* GetInterFormFont(CPDF_Dictionary* pFormDict,
CPDF_Object* pObj = NULL;
CFX_ByteString csKey;
pObj = pFonts->GetNextElement(pos, csKey);
- if (pObj == NULL) {
+ if (!pObj) {
continue;
}
CPDF_Dictionary* pElement = ToDictionary(pObj->GetDirect());
@@ -339,19 +336,19 @@ CPDF_Font* GetInterFormFont(CPDF_Dictionary* pFormDict,
CPDF_Document* pDocument,
CFX_ByteString csNameTag) {
CFX_ByteString csAlias = PDF_NameDecode(csNameTag);
- if (pFormDict == NULL || csAlias.IsEmpty()) {
+ if (!pFormDict || csAlias.IsEmpty()) {
return NULL;
}
CPDF_Dictionary* pDR = pFormDict->GetDict("DR");
- if (pDR == NULL) {
+ if (!pDR) {
return NULL;
}
CPDF_Dictionary* pFonts = pDR->GetDict("Font");
- if (pFonts == NULL) {
+ if (!pFonts) {
return NULL;
}
CPDF_Dictionary* pElement = pFonts->GetDict(csAlias);
- if (pElement == NULL) {
+ if (!pElement) {
return NULL;
}
if (pElement->GetString("Type") == "Font") {
@@ -363,15 +360,15 @@ CPDF_Font* GetInterFormFont(CPDF_Dictionary* pFormDict,
CPDF_Document* pDocument,
CFX_ByteString csFontName,
CFX_ByteString& csNameTag) {
- if (pFormDict == NULL || csFontName.IsEmpty()) {
+ if (!pFormDict || csFontName.IsEmpty()) {
return NULL;
}
CPDF_Dictionary* pDR = pFormDict->GetDict("DR");
- if (pDR == NULL) {
+ if (!pDR) {
return NULL;
}
CPDF_Dictionary* pFonts = pDR->GetDict("Font");
- if (pFonts == NULL) {
+ if (!pFonts) {
return NULL;
}
FX_POSITION pos = pFonts->GetStartPos();
@@ -379,7 +376,7 @@ CPDF_Font* GetInterFormFont(CPDF_Dictionary* pFormDict,
CPDF_Object* pObj = NULL;
CFX_ByteString csKey;
pObj = pFonts->GetNextElement(pos, csKey);
- if (pObj == NULL) {
+ if (!pObj) {
continue;
}
CPDF_Dictionary* pElement = ToDictionary(pObj->GetDirect());
@@ -406,15 +403,15 @@ CPDF_Font* GetNativeInterFormFont(CPDF_Dictionary* pFormDict,
CPDF_Document* pDocument,
uint8_t charSet,
CFX_ByteString& csNameTag) {
- if (pFormDict == NULL) {
+ if (!pFormDict) {
return NULL;
}
CPDF_Dictionary* pDR = pFormDict->GetDict("DR");
- if (pDR == NULL) {
+ if (!pDR) {
return NULL;
}
CPDF_Dictionary* pFonts = pDR->GetDict("Font");
- if (pFonts == NULL) {
+ if (!pFonts) {
return NULL;
}
FX_POSITION pos = pFonts->GetStartPos();
@@ -422,7 +419,7 @@ CPDF_Font* GetNativeInterFormFont(CPDF_Dictionary* pFormDict,
CPDF_Object* pObj = NULL;
CFX_ByteString csKey;
pObj = pFonts->GetNextElement(pos, csKey);
- if (pObj == NULL) {
+ if (!pObj) {
continue;
}
CPDF_Dictionary* pElement = ToDictionary(pObj->GetDirect());
@@ -431,11 +428,11 @@ CPDF_Font* GetNativeInterFormFont(CPDF_Dictionary* pFormDict,
if (pElement->GetString("Type") != "Font")
continue;
CPDF_Font* pFind = pDocument->LoadFont(pElement);
- if (pFind == NULL) {
+ if (!pFind) {
continue;
}
CFX_SubstFont* pSubst = (CFX_SubstFont*)pFind->GetSubstFont();
- if (pSubst == NULL) {
+ if (!pSubst) {
continue;
}
if (pSubst->m_Charset == (int)charSet) {
@@ -464,15 +461,15 @@ CPDF_Font* GetNativeInterFormFont(CPDF_Dictionary* pFormDict,
FX_BOOL FindInterFormFont(CPDF_Dictionary* pFormDict,
const CPDF_Font* pFont,
CFX_ByteString& csNameTag) {
- if (pFormDict == NULL || pFont == NULL) {
+ if (!pFormDict || !pFont) {
return FALSE;
}
CPDF_Dictionary* pDR = pFormDict->GetDict("DR");
- if (pDR == NULL) {
+ if (!pDR) {
return FALSE;
}
CPDF_Dictionary* pFonts = pDR->GetDict("Font");
- if (pFonts == NULL) {
+ if (!pFonts) {
return FALSE;
}
FX_POSITION pos = pFonts->GetStartPos();
@@ -480,7 +477,7 @@ FX_BOOL FindInterFormFont(CPDF_Dictionary* pFormDict,
CPDF_Object* pObj = NULL;
CFX_ByteString csKey;
pObj = pFonts->GetNextElement(pos, csKey);
- if (pObj == NULL) {
+ if (!pObj) {
continue;
}
CPDF_Dictionary* pElement = ToDictionary(pObj->GetDirect());
@@ -501,15 +498,15 @@ FX_BOOL FindInterFormFont(CPDF_Dictionary* pFormDict,
CFX_ByteString csFontName,
CPDF_Font*& pFont,
CFX_ByteString& csNameTag) {
- if (pFormDict == NULL) {
+ if (!pFormDict) {
return FALSE;
}
CPDF_Dictionary* pDR = pFormDict->GetDict("DR");
- if (pDR == NULL) {
+ if (!pDR) {
return FALSE;
}
CPDF_Dictionary* pFonts = pDR->GetDict("Font");
- if (pFonts == NULL) {
+ if (!pFonts) {
return FALSE;
}
if (csFontName.GetLength() > 0) {
@@ -520,7 +517,7 @@ FX_BOOL FindInterFormFont(CPDF_Dictionary* pFormDict,
CPDF_Object* pObj = NULL;
CFX_ByteString csKey, csTmp;
pObj = pFonts->GetNextElement(pos, csKey);
- if (pObj == NULL) {
+ if (!pObj) {
continue;
}
CPDF_Dictionary* pElement = ToDictionary(pObj->GetDirect());
@@ -530,7 +527,7 @@ FX_BOOL FindInterFormFont(CPDF_Dictionary* pFormDict,
continue;
}
pFont = pDocument->LoadFont(pElement);
- if (pFont == NULL) {
+ if (!pFont) {
continue;
}
CFX_ByteString csBaseFont;
@@ -547,10 +544,10 @@ void AddInterFormFont(CPDF_Dictionary*& pFormDict,
CPDF_Document* pDocument,
const CPDF_Font* pFont,
CFX_ByteString& csNameTag) {
- if (pFont == NULL) {
+ if (!pFont) {
return;
}
- if (pFormDict == NULL) {
+ if (!pFormDict) {
InitInterFormDict(pFormDict, pDocument);
}
CFX_ByteString csTag;
@@ -558,19 +555,16 @@ void AddInterFormFont(CPDF_Dictionary*& pFormDict,
csNameTag = csTag;
return;
}
- if (pFormDict == NULL) {
+ if (!pFormDict) {
InitInterFormDict(pFormDict, pDocument);
}
CPDF_Dictionary* pDR = pFormDict->GetDict("DR");
- if (pDR == NULL) {
+ if (!pDR) {
pDR = CPDF_Dictionary::Create();
- if (pDR == NULL) {
- return;
- }
pFormDict->SetAt("DR", pDR);
}
CPDF_Dictionary* pFonts = pDR->GetDict("Font");
- if (pFonts == NULL) {
+ if (!pFonts) {
pFonts = CPDF_Dictionary::Create();
pDR->SetAt("Font", pFonts);
}
@@ -586,7 +580,7 @@ CPDF_Font* AddNativeInterFormFont(CPDF_Dictionary*& pFormDict,
CPDF_Document* pDocument,
uint8_t charSet,
CFX_ByteString& csNameTag) {
- if (pFormDict == NULL) {
+ if (!pFormDict) {
InitInterFormDict(pFormDict, pDocument);
}
CFX_ByteString csTemp;
@@ -615,7 +609,7 @@ CPDF_Font* AddNativeInterFormFont(CPDF_Dictionary*& pFormDict,
return AddNativeInterFormFont(pFormDict, pDocument, charSet, csNameTag);
}
void RemoveInterFormFont(CPDF_Dictionary* pFormDict, const CPDF_Font* pFont) {
- if (pFormDict == NULL || pFont == NULL) {
+ if (!pFormDict || !pFont) {
return;
}
CFX_ByteString csTag;
@@ -627,22 +621,22 @@ void RemoveInterFormFont(CPDF_Dictionary* pFormDict, const CPDF_Font* pFont) {
pFonts->RemoveAt(csTag);
}
void RemoveInterFormFont(CPDF_Dictionary* pFormDict, CFX_ByteString csNameTag) {
- if (pFormDict == NULL || csNameTag.IsEmpty()) {
+ if (!pFormDict || csNameTag.IsEmpty()) {
return;
}
CPDF_Dictionary* pDR = pFormDict->GetDict("DR");
- if (pDR == NULL) {
+ if (!pDR) {
return;
}
CPDF_Dictionary* pFonts = pDR->GetDict("Font");
- if (pFonts == NULL) {
+ if (!pFonts) {
return;
}
pFonts->RemoveAt(csNameTag);
}
CPDF_Font* GetDefaultInterFormFont(CPDF_Dictionary* pFormDict,
CPDF_Document* pDocument) {
- if (pFormDict == NULL) {
+ if (!pFormDict) {
return NULL;
}
CPDF_DefaultAppearance cDA = pFormDict->GetString("DA");
@@ -668,14 +662,14 @@ CPDF_IconFit::ScaleMethod CPDF_IconFit::GetScaleMethod() {
return Always;
}
FX_BOOL CPDF_IconFit::IsProportionalScale() {
- if (m_pDict == NULL) {
+ if (!m_pDict) {
return TRUE;
}
return m_pDict->GetString("S", "P") != "A";
}
void CPDF_IconFit::GetIconPosition(FX_FLOAT& fLeft, FX_FLOAT& fBottom) {
fLeft = fBottom = 0.5;
- if (m_pDict == NULL) {
+ if (!m_pDict) {
return;
}
CPDF_Array* pA = m_pDict->GetArray("A");
@@ -690,7 +684,7 @@ void CPDF_IconFit::GetIconPosition(FX_FLOAT& fLeft, FX_FLOAT& fBottom) {
}
}
FX_BOOL CPDF_IconFit::GetFittingBounds() {
- if (m_pDict == NULL) {
+ if (!m_pDict) {
return FALSE;
}
return m_pDict->GetBoolean("FB");
@@ -700,7 +694,7 @@ void SaveCheckedFieldStatus(CPDF_FormField* pField,
int iCount = pField->CountControls();
for (int i = 0; i < iCount; i++) {
CPDF_FormControl* pControl = pField->GetControl(i);
- if (pControl == NULL) {
+ if (!pControl) {
continue;
}
statusArray.Add(pControl->IsChecked() ? 1 : 0);
@@ -712,7 +706,7 @@ CPDF_Object* FPDF_GetFieldAttr(CPDF_Dictionary* pFieldDict,
if (nLevel > FPDFDOC_UTILS_MAXRECURSION) {
return NULL;
}
- if (pFieldDict == NULL) {
+ if (!pFieldDict) {
return NULL;
}
CPDF_Object* pAttr = pFieldDict->GetElementValue(name);
@@ -720,7 +714,7 @@ CPDF_Object* FPDF_GetFieldAttr(CPDF_Dictionary* pFieldDict,
return pAttr;
}
CPDF_Dictionary* pParent = pFieldDict->GetDict("Parent");
- if (pParent == NULL) {
+ if (!pParent) {
return NULL;
}
return FPDF_GetFieldAttr(pParent, name, nLevel + 1);