diff options
Diffstat (limited to 'core/src/fpdfdoc/doc_utils.cpp')
-rw-r--r-- | core/src/fpdfdoc/doc_utils.cpp | 108 |
1 files changed, 51 insertions, 57 deletions
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); |