diff options
author | Lei Zhang <thestig@chromium.org> | 2015-12-14 18:29:28 -0800 |
---|---|---|
committer | Lei Zhang <thestig@chromium.org> | 2015-12-14 18:29:28 -0800 |
commit | e385244f8cd6ae376f6b3cf1265a0795d5d30eff (patch) | |
tree | 4bdd7c459f167ee56ae35f3b87222c2557f501f8 /core/src/fpdfdoc | |
parent | e3c7c2b54348da4a6939f6672f6c6bff126815a7 (diff) | |
download | pdfium-e385244f8cd6ae376f6b3cf1265a0795d5d30eff.tar.xz |
Get rid of most instance of 'foo == NULL'
R=tsepez@chromium.org
Review URL: https://codereview.chromium.org/1520063002 .
Diffstat (limited to 'core/src/fpdfdoc')
-rw-r--r-- | core/src/fpdfdoc/doc_action.cpp | 29 | ||||
-rw-r--r-- | core/src/fpdfdoc/doc_annot.cpp | 8 | ||||
-rw-r--r-- | core/src/fpdfdoc/doc_ap.cpp | 13 | ||||
-rw-r--r-- | core/src/fpdfdoc/doc_basic.cpp | 30 | ||||
-rw-r--r-- | core/src/fpdfdoc/doc_form.cpp | 96 | ||||
-rw-r--r-- | core/src/fpdfdoc/doc_formcontrol.cpp | 27 | ||||
-rw-r--r-- | core/src/fpdfdoc/doc_formfield.cpp | 62 | ||||
-rw-r--r-- | core/src/fpdfdoc/doc_ocg.cpp | 6 | ||||
-rw-r--r-- | core/src/fpdfdoc/doc_tagged.cpp | 12 | ||||
-rw-r--r-- | core/src/fpdfdoc/doc_utils.cpp | 108 |
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 80938f47c0..20b59cd498 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; @@ -536,7 +536,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) { @@ -580,15 +580,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(); @@ -638,10 +637,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) { @@ -649,10 +645,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(); @@ -668,7 +661,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); @@ -712,34 +705,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 = @@ -749,11 +736,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++) { @@ -819,7 +806,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"); @@ -829,10 +816,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, @@ -877,7 +861,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(); @@ -887,7 +871,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")) { @@ -908,11 +892,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(); @@ -934,7 +918,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") { @@ -969,14 +953,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") { @@ -1049,7 +1033,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"); @@ -1065,14 +1049,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(); @@ -1160,7 +1144,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) { @@ -1173,7 +1157,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; @@ -1216,15 +1200,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"); @@ -1236,7 +1220,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 767b31b1d5..987dbd6b20 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(); @@ -738,7 +738,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) { @@ -850,29 +850,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(); @@ -883,11 +883,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(); @@ -902,12 +902,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); @@ -953,7 +953,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); @@ -1030,7 +1030,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); |