summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/include/fpdfapi/fpdf_resource.h2
-rw-r--r--core/include/fxcrt/fx_basic.h10
-rw-r--r--core/src/fdrm/crypto/fx_crypt_sha.cpp4
-rw-r--r--core/src/fpdfapi/fpdf_cmaps/fpdf_cmaps.cpp2
-rw-r--r--core/src/fpdfapi/fpdf_edit/fpdf_edit_content.cpp4
-rw-r--r--core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp16
-rw-r--r--core/src/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp14
-rw-r--r--core/src/fpdfapi/fpdf_edit/fpdf_edit_image.cpp4
-rw-r--r--core/src/fpdfapi/fpdf_font/fpdf_font.cpp31
-rw-r--r--core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp32
-rw-r--r--core/src/fpdfapi/fpdf_font/ttgsubtable.cpp4
-rw-r--r--core/src/fpdfapi/fpdf_page/fpdf_page.cpp17
-rw-r--r--core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp42
-rw-r--r--core/src/fpdfapi/fpdf_page/fpdf_page_func.cpp8
-rw-r--r--core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp8
-rw-r--r--core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp36
-rw-r--r--core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp14
-rw-r--r--core/src/fpdfapi/fpdf_page/fpdf_page_pattern.cpp6
-rw-r--r--core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp4
-rw-r--r--core/src/fpdfapi/fpdf_parser/fpdf_parser_document.cpp37
-rw-r--r--core/src/fpdfapi/fpdf_parser/fpdf_parser_encrypt.cpp10
-rw-r--r--core/src/fpdfapi/fpdf_parser/fpdf_parser_fdf.cpp6
-rw-r--r--core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp8
-rw-r--r--core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp48
-rw-r--r--core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp10
-rw-r--r--core/src/fpdfapi/fpdf_render/fpdf_render.cpp14
-rw-r--r--core/src/fpdfapi/fpdf_render/fpdf_render_cache.cpp8
-rw-r--r--core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp22
-rw-r--r--core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp24
-rw-r--r--core/src/fpdfapi/fpdf_render/fpdf_render_pattern.cpp12
-rw-r--r--core/src/fpdfapi/fpdf_render/fpdf_render_text.cpp26
-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
-rw-r--r--core/src/fpdftext/fpdf_text.cpp18
-rw-r--r--core/src/fpdftext/fpdf_text_int.cpp8
-rw-r--r--core/src/fpdftext/fpdf_text_search.cpp9
-rw-r--r--core/src/fxcodec/codec/fx_codec.cpp2
-rw-r--r--core/src/fxcodec/codec/fx_codec_flate.cpp4
-rw-r--r--core/src/fxcodec/codec/fx_codec_icc.cpp24
-rw-r--r--core/src/fxcodec/codec/fx_codec_jpeg.cpp9
-rw-r--r--core/src/fxcodec/codec/fx_codec_jpx_opj.cpp8
-rw-r--r--core/src/fxcrt/fx_basic_array.cpp26
-rw-r--r--core/src/fxcrt/fx_basic_bstring.cpp88
-rw-r--r--core/src/fxcrt/fx_basic_gcc.cpp10
-rw-r--r--core/src/fxcrt/fx_basic_list.cpp10
-rw-r--r--core/src/fxcrt/fx_basic_maps.cpp16
-rw-r--r--core/src/fxcrt/fx_basic_util.cpp20
-rw-r--r--core/src/fxcrt/fx_basic_wstring.cpp109
-rw-r--r--core/src/fxcrt/fx_extension.cpp3
-rw-r--r--core/src/fxcrt/fx_xml_parser.cpp8
-rw-r--r--core/src/fxge/agg/src/fx_agg_driver.cpp64
-rw-r--r--core/src/fxge/android/fpf_skiafontmgr.cpp2
-rw-r--r--core/src/fxge/dib/fx_dib_composite.cpp264
-rw-r--r--core/src/fxge/dib/fx_dib_convert.cpp24
-rw-r--r--core/src/fxge/dib/fx_dib_engine.cpp19
-rw-r--r--core/src/fxge/dib/fx_dib_main.cpp68
-rw-r--r--core/src/fxge/dib/fx_dib_transform.cpp4
-rw-r--r--core/src/fxge/ge/fx_ge.cpp2
-rw-r--r--core/src/fxge/ge/fx_ge_device.cpp2
-rw-r--r--core/src/fxge/ge/fx_ge_font.cpp8
-rw-r--r--core/src/fxge/ge/fx_ge_fontmap.cpp33
-rw-r--r--core/src/fxge/ge/fx_ge_path.cpp4
-rw-r--r--core/src/fxge/ge/fx_ge_ps.cpp10
-rw-r--r--core/src/fxge/ge/fx_ge_text.cpp22
-rw-r--r--core/src/fxge/skia/fx_skia_blitter_new.cpp24
-rw-r--r--core/src/fxge/skia/fx_skia_device.cpp38
-rw-r--r--core/src/fxge/win32/fx_win32_device.cpp25
-rw-r--r--core/src/fxge/win32/fx_win32_dib.cpp22
-rw-r--r--core/src/fxge/win32/fx_win32_dwrite.cpp4
-rw-r--r--core/src/fxge/win32/fx_win32_gdipext.cpp18
-rw-r--r--core/src/fxge/win32/fx_win32_print.cpp16
79 files changed, 925 insertions, 994 deletions
diff --git a/core/include/fpdfapi/fpdf_resource.h b/core/include/fpdfapi/fpdf_resource.h
index 1f6c8b005b..d6d43ee9a7 100644
--- a/core/include/fpdfapi/fpdf_resource.h
+++ b/core/include/fpdfapi/fpdf_resource.h
@@ -605,7 +605,7 @@ class CPDF_Color {
~CPDF_Color();
- FX_BOOL IsNull() const { return m_pBuffer == NULL; }
+ FX_BOOL IsNull() const { return !m_pBuffer; }
FX_BOOL IsEqual(const CPDF_Color& other) const;
diff --git a/core/include/fxcrt/fx_basic.h b/core/include/fxcrt/fx_basic.h
index e1c384f2c5..c5b8b38f3f 100644
--- a/core/include/fxcrt/fx_basic.h
+++ b/core/include/fxcrt/fx_basic.h
@@ -989,7 +989,7 @@ class CFX_CountRef {
void operator=(void* p) {
FXSYS_assert(p == 0);
- if (m_pObject == NULL) {
+ if (!m_pObject) {
return;
}
m_pObject->m_RefCount--;
@@ -1003,12 +1003,12 @@ class CFX_CountRef {
operator const ObjClass*() const { return m_pObject; }
- FX_BOOL IsNull() const { return m_pObject == NULL; }
+ FX_BOOL IsNull() const { return !m_pObject; }
- FX_BOOL NotNull() const { return m_pObject != NULL; }
+ FX_BOOL NotNull() const { return !IsNull(); }
ObjClass* GetModify() {
- if (m_pObject == NULL) {
+ if (!m_pObject) {
m_pObject = new CountedObj;
m_pObject->m_RefCount = 1;
} else if (m_pObject->m_RefCount > 1) {
@@ -1021,7 +1021,7 @@ class CFX_CountRef {
}
void SetNull() {
- if (m_pObject == NULL) {
+ if (!m_pObject) {
return;
}
m_pObject->m_RefCount--;
diff --git a/core/src/fdrm/crypto/fx_crypt_sha.cpp b/core/src/fdrm/crypto/fx_crypt_sha.cpp
index ecefdde05a..c7d171098b 100644
--- a/core/src/fdrm/crypto/fx_crypt_sha.cpp
+++ b/core/src/fdrm/crypto/fx_crypt_sha.cpp
@@ -390,7 +390,7 @@ uint64_t FX_ato64i(const FX_CHAR* str) {
return ret;
}
void CRYPT_SHA384Start(void* context) {
- if (context == NULL) {
+ if (!context) {
return;
}
sha384_context* ctx = (sha384_context*)context;
@@ -604,7 +604,7 @@ void CRYPT_SHA384Generate(const uint8_t* data,
CRYPT_SHA384Finish(&context, digest);
}
void CRYPT_SHA512Start(void* context) {
- if (context == NULL) {
+ if (!context) {
return;
}
sha384_context* ctx = (sha384_context*)context;
diff --git a/core/src/fpdfapi/fpdf_cmaps/fpdf_cmaps.cpp b/core/src/fpdfapi/fpdf_cmaps/fpdf_cmaps.cpp
index fba3a2b031..90091deaac 100644
--- a/core/src/fpdfapi/fpdf_cmaps/fpdf_cmaps.cpp
+++ b/core/src/fpdfapi/fpdf_cmaps/fpdf_cmaps.cpp
@@ -105,7 +105,7 @@ FX_WORD FPDFAPI_CIDFromCharCode(const FXCMAP_CMap* pMap, FX_DWORD charcode) {
}
FX_WORD code = (FX_WORD)charcode;
while (1) {
- if (pMap->m_pWordMap == NULL) {
+ if (!pMap->m_pWordMap) {
return 0;
}
if (pMap->m_WordMapType == FXCMAP_CMap::Single) {
diff --git a/core/src/fpdfapi/fpdf_edit/fpdf_edit_content.cpp b/core/src/fpdfapi/fpdf_edit/fpdf_edit_content.cpp
index eda51deb3b..5810da572b 100644
--- a/core/src/fpdfapi/fpdf_edit/fpdf_edit_content.cpp
+++ b/core/src/fpdfapi/fpdf_edit/fpdf_edit_content.cpp
@@ -56,13 +56,13 @@ void CPDF_PageContentGenerate::GenerateContent() {
CFX_ByteString CPDF_PageContentGenerate::RealizeResource(
CPDF_Object* pResourceObj,
const FX_CHAR* szType) {
- if (m_pPage->m_pResources == NULL) {
+ if (!m_pPage->m_pResources) {
m_pPage->m_pResources = new CPDF_Dictionary;
int objnum = m_pDocument->AddIndirectObject(m_pPage->m_pResources);
m_pPage->m_pFormDict->SetAtReference("Resources", m_pDocument, objnum);
}
CPDF_Dictionary* pResList = m_pPage->m_pResources->GetDict(szType);
- if (pResList == NULL) {
+ if (!pResList) {
pResList = new CPDF_Dictionary;
m_pPage->m_pResources->SetAt(szType, pResList);
}
diff --git a/core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp b/core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp
index a797332727..b200b8d37d 100644
--- a/core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp
+++ b/core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp
@@ -17,7 +17,7 @@ int32_t PDF_CreatorAppendObject(const CPDF_Object* pObj,
CFX_FileBufferArchive* pFile,
FX_FILESIZE& offset) {
int32_t len = 0;
- if (pObj == NULL) {
+ if (!pObj) {
if (pFile->AppendString(" null") < 0) {
return -1;
}
@@ -416,7 +416,7 @@ FX_BOOL CPDF_Encryptor::Initialize(CPDF_CryptoHandler* pHandler,
if (src_size == 0) {
return TRUE;
}
- if (pHandler == NULL) {
+ if (!pHandler) {
m_pData = (uint8_t*)src_data;
m_dwSize = src_size;
m_bNewBuf = FALSE;
@@ -1071,7 +1071,7 @@ int32_t CPDF_Creator::WriteDirectObj(FX_DWORD objnum,
const CPDF_Object* pObj,
FX_BOOL bEncrypt) {
int32_t len = 0;
- if (pObj == NULL) {
+ if (!pObj) {
if (m_File.AppendString(" null") < 0) {
return -1;
}
@@ -1098,7 +1098,7 @@ int32_t CPDF_Creator::WriteDirectObj(FX_DWORD objnum,
case PDFOBJ_STRING: {
CFX_ByteString str = pObj->GetString();
FX_BOOL bHex = pObj->AsString()->IsHex();
- if (m_pCryptoHandler == NULL || !bEncrypt) {
+ if (!m_pCryptoHandler || !bEncrypt) {
CFX_ByteString content = PDF_EncodeString(str, bHex);
if ((len = m_File.AppendString(content)) < 0) {
return -1;
@@ -1200,7 +1200,7 @@ int32_t CPDF_Creator::WriteDirectObj(FX_DWORD objnum,
break;
}
case PDFOBJ_DICTIONARY: {
- if (m_pCryptoHandler == NULL || pObj == m_pEncryptDict) {
+ if (!m_pCryptoHandler || pObj == m_pEncryptDict) {
return PDF_CreatorAppendObject(pObj, &m_File, m_Offset);
}
if (m_File.AppendString("<<") < 0) {
@@ -1263,7 +1263,7 @@ int32_t CPDF_Creator::WriteOldIndirectObject(FX_DWORD objnum) {
if (m_pParser->m_bVersionUpdated || m_bSecurityChanged || bExistInMap ||
bObjStm) {
CPDF_Object* pObj = m_pDocument->GetIndirectObject(objnum);
- if (pObj == NULL) {
+ if (!pObj) {
m_ObjectOffset[objnum] = 0;
m_ObjectSize[objnum] = 0;
return 0;
@@ -1278,7 +1278,7 @@ int32_t CPDF_Creator::WriteOldIndirectObject(FX_DWORD objnum) {
uint8_t* pBuffer;
FX_DWORD size;
m_pParser->GetIndirectBinary(objnum, pBuffer, size);
- if (pBuffer == NULL) {
+ if (!pBuffer) {
return 0;
}
if (m_pParser->m_V5Type[objnum] == 2) {
@@ -1477,7 +1477,7 @@ void CPDF_Creator::AppendNewObjNum(FX_DWORD objbum) {
int32_t CPDF_Creator::WriteDoc_Stage1(IFX_Pause* pPause) {
FXSYS_assert(m_iStage > -1 || m_iStage < 20);
if (m_iStage == 0) {
- if (m_pParser == NULL) {
+ if (!m_pParser) {
m_dwFlags &= ~FPDFCREATE_INCREMENTAL;
}
if (m_bSecurityChanged && (m_dwFlags & FPDFCREATE_NO_ORIGINAL) == 0) {
diff --git a/core/src/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp b/core/src/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp
index 7febc7932f..9c96a3027c 100644
--- a/core/src/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp
+++ b/core/src/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp
@@ -20,7 +20,7 @@ CPDF_Document::CPDF_Document() : CPDF_IndirectObjects(NULL) {
m_pDocRender = CPDF_ModuleMgr::Get()->GetRenderModule()->CreateDocData(this);
}
void CPDF_Document::CreateNewDoc() {
- ASSERT(m_pRootDict == NULL && m_pInfoDict == NULL);
+ ASSERT(!m_pRootDict && !m_pInfoDict);
m_pRootDict = new CPDF_Dictionary;
m_pRootDict->SetAtName("Type", "Catalog");
int objnum = AddIndirectObject(m_pRootDict);
@@ -550,7 +550,7 @@ CPDF_Font* CPDF_Document::AddMacFont(CTFontRef pFont,
FX_BOOL bTranslateName) {
CTFontRef font = (CTFontRef)pFont;
CTFontDescriptorRef descriptor = CTFontCopyFontDescriptor(font);
- if (descriptor == NULL) {
+ if (!descriptor) {
return NULL;
}
CFX_ByteString basefont;
@@ -560,7 +560,7 @@ CPDF_Font* CPDF_Document::AddMacFont(CTFontRef pFont,
FXSYS_memset(bbox, 0, sizeof(int) * 4);
CFArrayRef languages = (CFArrayRef)CTFontDescriptorCopyAttribute(
descriptor, kCTFontLanguagesAttribute);
- if (languages == NULL) {
+ if (!languages) {
CFRelease(descriptor);
return NULL;
}
@@ -574,7 +574,7 @@ CPDF_Font* CPDF_Document::AddMacFont(CTFontRef pFont,
}
CFRelease(descriptor);
CFDictionaryRef traits = (CFDictionaryRef)CTFontCopyTraits(font);
- if (traits == NULL) {
+ if (!traits) {
CFRelease(languages);
return NULL;
}
@@ -825,7 +825,7 @@ static void _InsertWidthArray1(CFX_Font* pFont,
}
CPDF_Font* CPDF_Document::AddFont(CFX_Font* pFont, int charset, FX_BOOL bVert) {
- if (pFont == NULL) {
+ if (!pFont) {
return NULL;
}
FX_BOOL bCJK = charset == FXFONT_CHINESEBIG5_CHARSET ||
@@ -1118,11 +1118,11 @@ CPDF_Font* CPDF_Document::AddStandardFont(const FX_CHAR* font,
void CPDF_Document::DeletePage(int iPage) {
CPDF_Dictionary* pRoot = GetRoot();
- if (pRoot == NULL) {
+ if (!pRoot) {
return;
}
CPDF_Dictionary* pPages = pRoot->GetDict("Pages");
- if (pPages == NULL) {
+ if (!pPages) {
return;
}
int nPages = pPages->GetInteger("Count");
diff --git a/core/src/fpdfapi/fpdf_edit/fpdf_edit_image.cpp b/core/src/fpdfapi/fpdf_edit/fpdf_edit_image.cpp
index 640e8671f8..10b0272b52 100644
--- a/core/src/fpdfapi/fpdf_edit/fpdf_edit_image.cpp
+++ b/core/src/fpdfapi/fpdf_edit/fpdf_edit_image.cpp
@@ -51,7 +51,7 @@ CPDF_Dictionary* CPDF_Image::InitJPEG(uint8_t* pData, FX_DWORD size) {
m_bIsMask = FALSE;
m_Width = width;
m_Height = height;
- if (m_pStream == NULL) {
+ if (!m_pStream) {
m_pStream = new CPDF_Stream(NULL, 0, NULL);
}
return pDict;
@@ -367,7 +367,7 @@ void CPDF_Image::SetImage(const CFX_DIBitmap* pBitmap,
dest_buf = NULL;
}
}
- if (m_pStream == NULL) {
+ if (!m_pStream) {
m_pStream = new CPDF_Stream(NULL, 0, NULL);
}
if (!bStream) {
diff --git a/core/src/fpdfapi/fpdf_font/fpdf_font.cpp b/core/src/fpdfapi/fpdf_font/fpdf_font.cpp
index 4a71382da4..3170b55e20 100644
--- a/core/src/fpdfapi/fpdf_font/fpdf_font.cpp
+++ b/core/src/fpdfapi/fpdf_font/fpdf_font.cpp
@@ -351,7 +351,7 @@ void CPDF_Font::CheckFontMetrics() {
void CPDF_Font::LoadUnicodeMap() {
m_bToUnicodeLoaded = TRUE;
CPDF_Stream* pStream = m_pFontDict->GetStream("ToUnicode");
- if (pStream == NULL) {
+ if (!pStream) {
return;
}
m_pToUnicodeMap = new CPDF_ToUnicodeMap;
@@ -425,7 +425,7 @@ CPDF_Font* CPDF_Font::CreateFontF(CPDF_Document* pDoc,
}
if (i < count) {
CPDF_Dictionary* pFontDesc = pFontDict->GetDict("FontDescriptor");
- if (pFontDesc == NULL || !pFontDesc->KeyExist("FontFile2")) {
+ if (!pFontDesc || !pFontDesc->KeyExist("FontFile2")) {
pFont = new CPDF_CIDFont;
pFont->m_pFontDict = pFontDict;
pFont->m_pDocument = pDoc;
@@ -455,7 +455,7 @@ CPDF_Font* CPDF_Font::CreateFontF(CPDF_Document* pDoc,
return pFont;
}
FX_BOOL CPDF_Font::Load() {
- if (m_pFontDict == NULL) {
+ if (!m_pFontDict) {
return FALSE;
}
CFX_ByteString type = m_pFontDict->GetString("Subtype");
@@ -488,7 +488,7 @@ CFX_WideString CPDF_ToUnicodeMap::Lookup(FX_DWORD charcode) {
}
const FX_WCHAR* buf = m_MultiCharBuf.GetBuffer();
FX_DWORD buf_len = m_MultiCharBuf.GetLength();
- if (buf == NULL || buf_len == 0) {
+ if (!buf || buf_len == 0) {
return CFX_WideString();
}
FX_DWORD index = value >> 16;
@@ -704,7 +704,7 @@ void CPDF_Font::LoadPDFEncoding(CPDF_Object* pEncoding,
CFX_ByteString*& pCharNames,
FX_BOOL bEmbedded,
FX_BOOL bTrueType) {
- if (pEncoding == NULL) {
+ if (!pEncoding) {
if (m_BaseFont == "Symbol") {
iBaseEncoding = bTrueType ? PDFFONT_ENCODING_MS_SYMBOL
: PDFFONT_ENCODING_ADOBE_SYMBOL;
@@ -748,7 +748,7 @@ void CPDF_Font::LoadPDFEncoding(CPDF_Object* pEncoding,
iBaseEncoding = PDFFONT_ENCODING_STANDARD;
}
CPDF_Array* pDiffs = pDict->GetArray("Differences");
- if (pDiffs == NULL) {
+ if (!pDiffs) {
return;
}
pCharNames = new CFX_ByteString[256];
@@ -879,13 +879,10 @@ const FX_CHAR* GetAdobeCharName(int iBaseEncoding,
if (pCharNames) {
name = pCharNames[charcode];
}
- if ((name == NULL || name[0] == 0) && iBaseEncoding) {
+ if ((!name || name[0] == 0) && iBaseEncoding) {
name = PDF_CharNameFromPredefinedCharSet(iBaseEncoding, charcode);
}
- if (name == NULL || name[0] == 0) {
- return NULL;
- }
- return name;
+ return name && name[0] ? name : nullptr;
}
FX_BOOL CPDF_SimpleFont::LoadCommon() {
CPDF_Dictionary* pFontDesc = m_pFontDict->GetDict("FontDescriptor");
@@ -1127,7 +1124,7 @@ void CPDF_Type1Font::LoadGlyphMap() {
for (int charcode = 0; charcode < 256; charcode++) {
const FX_CHAR* name =
GetAdobeCharName(m_BaseEncoding, m_pCharNames, charcode);
- if (name == NULL) {
+ if (!name) {
continue;
}
m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name);
@@ -1228,7 +1225,7 @@ void CPDF_Type1Font::LoadGlyphMap() {
for (int charcode = 0; charcode < 256; charcode++) {
const FX_CHAR* name =
GetAdobeCharName(m_BaseEncoding, m_pCharNames, charcode);
- if (name == NULL) {
+ if (!name) {
continue;
}
m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name);
@@ -1328,7 +1325,7 @@ void CPDF_Type1Font::LoadGlyphMap() {
for (int charcode = 0; charcode < 256; charcode++) {
const FX_CHAR* name =
GetAdobeCharName(m_BaseEncoding, m_pCharNames, charcode);
- if (name == NULL) {
+ if (!name) {
continue;
}
m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name);
@@ -1453,7 +1450,7 @@ void CPDF_TrueTypeFont::LoadGlyphMap() {
}
if (((baseEncoding == PDFFONT_ENCODING_MACROMAN ||
baseEncoding == PDFFONT_ENCODING_WINANSI) &&
- m_pCharNames == NULL) ||
+ !m_pCharNames) ||
(m_Flags & PDFFONT_NONSYMBOLIC)) {
if (!FXFT_Has_Glyph_Names(m_Font.GetFace()) &&
(!m_Font.GetFace()->num_charmaps || !m_Font.GetFace()->charmaps)) {
@@ -1486,7 +1483,7 @@ void CPDF_TrueTypeFont::LoadGlyphMap() {
for (int charcode = 0; charcode < 256; charcode++) {
const FX_CHAR* name =
GetAdobeCharName(baseEncoding, m_pCharNames, charcode);
- if (name == NULL) {
+ if (!name) {
m_GlyphIndex[charcode] =
m_pFontFile ? FXFT_Get_Char_Index(m_Font.GetFace(), charcode) : -1;
continue;
@@ -1562,7 +1559,7 @@ void CPDF_TrueTypeFont::LoadGlyphMap() {
for (int charcode = 0; charcode < 256; charcode++) {
const FX_CHAR* name =
GetAdobeCharName(baseEncoding, m_pCharNames, charcode);
- if (name == NULL) {
+ if (!name) {
continue;
}
m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name);
diff --git a/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp b/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp
index 89004fee55..6e7a051b34 100644
--- a/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp
+++ b/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp
@@ -848,14 +848,14 @@ FX_WORD CPDF_CMap::CIDFromCharCode(FX_DWORD charcode) const {
if (m_pEmbedMap) {
return FPDFAPI_CIDFromCharCode(m_pEmbedMap, charcode);
}
- if (m_pMapping == NULL) {
+ if (!m_pMapping) {
return (FX_WORD)charcode;
}
if (charcode >> 16) {
if (m_pAddMapping) {
void* found = FXSYS_bsearch(&charcode, m_pAddMapping + 4,
*(FX_DWORD*)m_pAddMapping, 8, CompareCID);
- if (found == NULL) {
+ if (!found) {
if (m_pUseMap) {
return m_pUseMap->CIDFromCharCode(charcode);
}
@@ -1058,7 +1058,7 @@ CPDF_CIDFont::~CPDF_CIDFont() {
delete m_pTTGSUBTable;
}
FX_WORD CPDF_CIDFont::CIDFromCharCode(FX_DWORD charcode) const {
- if (m_pCMap == NULL) {
+ if (!m_pCMap) {
return (FX_WORD)charcode;
}
return m_pCMap->CIDFromCharCode(charcode);
@@ -1073,12 +1073,12 @@ FX_WCHAR CPDF_CIDFont::_UnicodeFromCharCode(FX_DWORD charcode) const {
case CIDCODING_UTF16:
return (FX_WCHAR)charcode;
case CIDCODING_CID:
- if (m_pCID2UnicodeMap == NULL || !m_pCID2UnicodeMap->IsLoaded()) {
+ if (!m_pCID2UnicodeMap || !m_pCID2UnicodeMap->IsLoaded()) {
return 0;
}
return m_pCID2UnicodeMap->UnicodeFromCID((FX_WORD)charcode);
}
- if (!m_pCMap->IsLoaded() || m_pCID2UnicodeMap == NULL ||
+ if (!m_pCMap->IsLoaded() || !m_pCID2UnicodeMap ||
!m_pCID2UnicodeMap->IsLoaded()) {
#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
FX_WCHAR unicode;
@@ -1111,7 +1111,7 @@ FX_DWORD CPDF_CIDFont::_CharCodeFromUnicode(FX_WCHAR unicode) const {
case CIDCODING_UTF16:
return unicode;
case CIDCODING_CID: {
- if (m_pCID2UnicodeMap == NULL || !m_pCID2UnicodeMap->IsLoaded()) {
+ if (!m_pCID2UnicodeMap || !m_pCID2UnicodeMap->IsLoaded()) {
return 0;
}
FX_DWORD CID = 0;
@@ -1157,14 +1157,14 @@ FX_BOOL CPDF_CIDFont::_Load() {
return LoadGB2312();
}
CPDF_Array* pFonts = m_pFontDict->GetArray("DescendantFonts");
- if (pFonts == NULL) {
+ if (!pFonts) {
return FALSE;
}
if (pFonts->GetCount() != 1) {
return FALSE;
}
CPDF_Dictionary* pCIDFontDict = pFonts->GetDict(0);
- if (pCIDFontDict == NULL) {
+ if (!pCIDFontDict) {
return FALSE;
}
m_BaseFont = pCIDFontDict->GetString("BaseFont");
@@ -1180,7 +1180,7 @@ FX_BOOL CPDF_CIDFont::_Load() {
LoadFontDescriptor(pFontDesc);
}
CPDF_Object* pEncoding = m_pFontDict->GetElementValue("Encoding");
- if (pEncoding == NULL) {
+ if (!pEncoding) {
return FALSE;
}
CFX_ByteString subtype = pCIDFontDict->GetString("Subtype");
@@ -1201,7 +1201,7 @@ FX_BOOL CPDF_CIDFont::_Load() {
} else {
return FALSE;
}
- if (m_pCMap == NULL) {
+ if (!m_pCMap) {
return FALSE;
}
m_Charset = m_pCMap->m_Charset;
@@ -1218,8 +1218,8 @@ FX_BOOL CPDF_CIDFont::_Load() {
->GetFontGlobals()
->m_CMapManager.GetCID2UnicodeMap(
m_Charset,
- m_pFontFile == NULL && (m_pCMap->m_Coding == CIDCODING_CID ||
- pCIDFontDict->KeyExist("W")));
+ !m_pFontFile && (m_pCMap->m_Coding == CIDCODING_CID ||
+ pCIDFontDict->KeyExist("W")));
if (m_Font.GetFace()) {
if (m_bType1) {
FXFT_Select_Charmap(m_Font.GetFace(), FXFT_ENCODING_UNICODE);
@@ -1333,7 +1333,7 @@ void CPDF_CIDFont::GetCharBBox(FX_DWORD charcode, FX_RECT& rect, int level) {
} else {
rect = FX_RECT(0, 0, 0, 0);
}
- if (m_pFontFile == NULL && m_Charset == CIDSET_JAPAN1) {
+ if (!m_pFontFile && m_Charset == CIDSET_JAPAN1) {
FX_WORD CID = CIDFromCharCode(charcode);
const uint8_t* pTransform = GetCIDTransform(CID);
if (pTransform && !bVert) {
@@ -1458,7 +1458,7 @@ int CPDF_CIDFont::GlyphFromCharCode(FX_DWORD charcode, FX_BOOL* pVertGlyph) {
if (pVertGlyph) {
*pVertGlyph = FALSE;
}
- if (m_pFontFile == NULL && m_pCIDToGIDMap == NULL) {
+ if (!m_pFontFile && !m_pCIDToGIDMap) {
FX_WORD cid = CIDFromCharCode(charcode);
FX_WCHAR unicode = 0;
if (m_bCIDIsGID) {
@@ -1504,7 +1504,7 @@ int CPDF_CIDFont::GlyphFromCharCode(FX_DWORD charcode, FX_BOOL* pVertGlyph) {
iBaseEncoding = PDFFONT_ENCODING_MACROMAN;
}
const FX_CHAR* name = GetAdobeCharName(iBaseEncoding, NULL, charcode);
- if (name == NULL) {
+ if (!name) {
return charcode == 0 ? -1 : (int)charcode;
}
FX_WORD unicode = PDF_UnicodeFromAdobeName(name);
@@ -1616,7 +1616,7 @@ int CPDF_CIDFont::AppendChar(FX_CHAR* str, FX_DWORD charcode) const {
return m_pCMap->AppendChar(str, charcode);
}
FX_BOOL CPDF_CIDFont::IsUnicodeCompatible() const {
- if (!m_pCMap->IsLoaded() || m_pCID2UnicodeMap == NULL ||
+ if (!m_pCMap->IsLoaded() || !m_pCID2UnicodeMap ||
!m_pCID2UnicodeMap->IsLoaded()) {
return m_pCMap->m_Coding != CIDCODING_UNKNOWN;
}
diff --git a/core/src/fpdfapi/fpdf_font/ttgsubtable.cpp b/core/src/fpdfapi/fpdf_font/ttgsubtable.cpp
index 4786b8be94..035ea8a0ff 100644
--- a/core/src/fpdfapi/fpdf_font/ttgsubtable.cpp
+++ b/core/src/fpdfapi/fpdf_font/ttgsubtable.cpp
@@ -47,7 +47,7 @@ FX_BOOL CFX_GlyphMap::Lookup(int key, int& value) {
void* pResult = FXSYS_bsearch(&key, m_Buffer.GetBuffer(),
m_Buffer.GetSize() / sizeof(_IntPair),
sizeof(_IntPair), _CompareInt);
- if (pResult == NULL) {
+ if (!pResult) {
return FALSE;
}
value = ((FX_DWORD*)pResult)[1];
@@ -158,7 +158,7 @@ bool CFX_CTTGSUBTable::GetVerticalGlyphSub2(uint32_t glyphnum,
int CFX_CTTGSUBTable::GetCoverageIndex(struct TCoverageFormatBase* Coverage,
uint32_t g) {
int i = 0;
- if (Coverage == NULL) {
+ if (!Coverage) {
return -1;
}
switch (Coverage->CoverageFormat) {
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page.cpp
index f37dd770ca..1fef74b99b 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page.cpp
@@ -689,7 +689,7 @@ CPDF_PageObjects::~CPDF_PageObjects() {
}
}
void CPDF_PageObjects::ContinueParse(IFX_Pause* pPause) {
- if (m_pParser == NULL) {
+ if (!m_pParser) {
return;
}
m_pParser->Continue(pPause);
@@ -720,10 +720,7 @@ int CPDF_PageObjects::GetObjectIndex(CPDF_PageObject* pObj) const {
}
CPDF_PageObject* CPDF_PageObjects::GetObjectByIndex(int index) const {
FX_POSITION pos = m_ObjectList.FindIndex(index);
- if (pos == NULL) {
- return NULL;
- }
- return (CPDF_PageObject*)m_ObjectList.GetAt(pos);
+ return pos ? static_cast<CPDF_PageObject*>(m_ObjectList.GetAt(pos)) : nullptr;
}
void CPDF_PageObjects::Transform(const CFX_Matrix& matrix) {
FX_POSITION pos = m_ObjectList.GetHeadPosition();
@@ -758,11 +755,11 @@ CFX_FloatRect CPDF_PageObjects::CalcBoundingBox() const {
return CFX_FloatRect(left, bottom, right, top);
}
void CPDF_PageObjects::LoadTransInfo() {
- if (m_pFormDict == NULL) {
+ if (!m_pFormDict) {
return;
}
CPDF_Dictionary* pGroup = m_pFormDict->GetDict("Group");
- if (pGroup == NULL) {
+ if (!pGroup) {
return;
}
if (pGroup->GetString("S") != "Transparency") {
@@ -800,7 +797,7 @@ void CPDF_Page::Load(CPDF_Document* pDocument,
m_pPageRender =
CPDF_ModuleMgr::Get()->GetRenderModule()->CreatePageCache(this);
}
- if (pPageDict == NULL) {
+ if (!pPageDict) {
m_PageWidth = m_PageHeight = 100 * 1.0f;
m_pPageResources = m_pResources = NULL;
return;
@@ -912,10 +909,10 @@ CPDF_Form::CPDF_Form(CPDF_Document* pDoc,
m_pFormDict = pFormStream ? pFormStream->GetDict() : NULL;
m_pResources = m_pFormDict->GetDict("Resources");
m_pPageResources = pPageResources;
- if (m_pResources == NULL) {
+ if (!m_pResources) {
m_pResources = pParentResources;
}
- if (m_pResources == NULL) {
+ if (!m_pResources) {
m_pResources = pPageResources;
}
m_Transparency = 0;
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp
index 8deeb66deb..c9eee8e380 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp
@@ -688,7 +688,7 @@ CPDF_ICCBasedCS::~CPDF_ICCBasedCS() {
FX_BOOL CPDF_ICCBasedCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) {
CPDF_Stream* pStream = pArray->GetStream(1);
- if (pStream == NULL) {
+ if (!pStream) {
return FALSE;
}
m_pProfile = pDoc->LoadIccProfile(pStream);
@@ -699,7 +699,7 @@ FX_BOOL CPDF_ICCBasedCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) {
m_pProfile
->GetComponents(); // Try using the nComponents from ICC profile
CPDF_Dictionary* pDict = pStream->GetDict();
- if (m_pProfile->m_pTransform == NULL) { // No valid ICC profile or using sRGB
+ if (!m_pProfile->m_pTransform) { // No valid ICC profile or using sRGB
CPDF_Object* pAlterCSObj =
pDict ? pDict->GetElementValue("Alternate") : NULL;
if (pAlterCSObj) {
@@ -764,7 +764,7 @@ FX_BOOL CPDF_ICCBasedCS::GetRGB(FX_FLOAT* pBuf,
return TRUE;
}
ICodec_IccModule* pIccModule = CPDF_ModuleMgr::Get()->GetIccModule();
- if (m_pProfile->m_pTransform == NULL || pIccModule == NULL) {
+ if (!m_pProfile->m_pTransform || !pIccModule) {
if (m_pAlterCS) {
return m_pAlterCS->GetRGB(pBuf, R, G, B);
}
@@ -822,7 +822,7 @@ void CPDF_ICCBasedCS::TranslateImageLine(uint8_t* pDestBuf,
CPDF_ModuleMgr::Get()->GetIccModule()->TranslateScanline(
m_pProfile->m_pTransform, pDestBuf, pSrcBuf, pixels);
} else {
- if (m_pCache == NULL) {
+ if (!m_pCache) {
((CPDF_ICCBasedCS*)this)->m_pCache = FX_Alloc2D(uint8_t, nMaxColors, 3);
uint8_t* temp_src = FX_Alloc2D(uint8_t, nMaxColors, m_nComponents);
uint8_t* pSrc = temp_src;
@@ -897,7 +897,7 @@ FX_BOOL CPDF_IndexedCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) {
}
CPDF_DocPageData* pDocPageData = pDoc->GetPageData();
m_pBaseCS = pDocPageData->GetColorSpace(pBaseObj, NULL);
- if (m_pBaseCS == NULL) {
+ if (!m_pBaseCS) {
return FALSE;
}
m_pCountedBaseCS = pDocPageData->FindColorSpacePtr(m_pBaseCS->GetArray());
@@ -1078,8 +1078,8 @@ FX_BOOL CPDF_SeparationCS::GetRGB(FX_FLOAT* pBuf,
if (m_Type == None) {
return FALSE;
}
- if (m_pFunc == NULL) {
- if (m_pAltCS == NULL) {
+ if (!m_pFunc) {
+ if (!m_pAltCS) {
return FALSE;
}
int nComps = m_pAltCS->CountComponents();
@@ -1154,7 +1154,7 @@ FX_BOOL CPDF_DeviceNCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) {
}
m_pAltCS = Load(pDoc, pAltCS);
m_pFunc = CPDF_Function::Load(pArray->GetElementValue(3));
- if (m_pAltCS == NULL || m_pFunc == NULL) {
+ if (!m_pAltCS || !m_pFunc) {
return FALSE;
}
if (m_pFunc->CountOutputs() < m_pAltCS->CountComponents()) {
@@ -1166,7 +1166,7 @@ FX_BOOL CPDF_DeviceNCS::GetRGB(FX_FLOAT* pBuf,
FX_FLOAT& R,
FX_FLOAT& G,
FX_FLOAT& B) const {
- if (m_pFunc == NULL) {
+ if (!m_pFunc) {
return FALSE;
}
CFX_FixedBufGrow<FX_FLOAT, 16> results(m_pFunc->CountOutputs());
@@ -1331,7 +1331,7 @@ FX_BOOL CPDF_ColorSpace::SetCMYK(FX_FLOAT* pBuf,
return SetRGB(pBuf, R, G, B);
}
void CPDF_ColorSpace::GetDefaultColor(FX_FLOAT* buf) const {
- if (buf == NULL || m_Family == PDFCS_PATTERN) {
+ if (!buf || m_Family == PDFCS_PATTERN) {
return;
}
FX_FLOAT min, max;
@@ -1418,7 +1418,7 @@ void CPDF_Color::ReleaseColorSpace() {
}
void CPDF_Color::SetColorSpace(CPDF_ColorSpace* pCS) {
if (m_pCS == pCS) {
- if (m_pBuffer == NULL) {
+ if (!m_pBuffer) {
m_pBuffer = pCS->CreateBuf();
}
ReleaseColorSpace();
@@ -1434,7 +1434,7 @@ void CPDF_Color::SetColorSpace(CPDF_ColorSpace* pCS) {
}
}
void CPDF_Color::SetValue(FX_FLOAT* comps) {
- if (m_pBuffer == NULL) {
+ if (!m_pBuffer) {
return;
}
if (m_pCS->GetFamily() != PDFCS_PATTERN) {
@@ -1445,7 +1445,7 @@ void CPDF_Color::SetValue(CPDF_Pattern* pPattern, FX_FLOAT* comps, int ncomps) {
if (ncomps > MAX_PATTERN_COLORCOMPS) {
return;
}
- if (m_pCS == NULL || m_pCS->GetFamily() != PDFCS_PATTERN) {
+ if (!m_pCS || m_pCS->GetFamily() != PDFCS_PATTERN) {
FX_Free(m_pBuffer);
m_pCS = CPDF_ColorSpace::GetStockCS(PDFCS_PATTERN);
m_pBuffer = m_pCS->CreateBuf();
@@ -1482,7 +1482,7 @@ void CPDF_Color::Copy(const CPDF_Color* pSrc) {
m_pCS = m_pCS->m_pDocument->GetPageData()->GetCopiedColorSpace(pArray);
}
}
- if (m_pCS == NULL) {
+ if (!m_pCS) {
return;
}
m_pBuffer = m_pCS->CreateBuf();
@@ -1498,7 +1498,7 @@ void CPDF_Color::Copy(const CPDF_Color* pSrc) {
}
}
FX_BOOL CPDF_Color::GetRGB(int& R, int& G, int& B) const {
- if (m_pCS == NULL || m_pBuffer == NULL) {
+ if (!m_pCS || !m_pBuffer) {
return FALSE;
}
FX_FLOAT r = 0.0f, g = 0.0f, b = 0.0f;
@@ -1511,28 +1511,26 @@ FX_BOOL CPDF_Color::GetRGB(int& R, int& G, int& B) const {
return TRUE;
}
CPDF_Pattern* CPDF_Color::GetPattern() const {
- if (m_pBuffer == NULL || m_pCS->GetFamily() != PDFCS_PATTERN) {
+ if (!m_pBuffer || m_pCS->GetFamily() != PDFCS_PATTERN) {
return NULL;
}
PatternValue* pvalue = (PatternValue*)m_pBuffer;
return pvalue->m_pPattern;
}
CPDF_ColorSpace* CPDF_Color::GetPatternCS() const {
- if (m_pBuffer == NULL || m_pCS->GetFamily() != PDFCS_PATTERN) {
+ if (!m_pBuffer || m_pCS->GetFamily() != PDFCS_PATTERN) {
return NULL;
}
return m_pCS->GetBaseCS();
}
FX_FLOAT* CPDF_Color::GetPatternColor() const {
- if (m_pBuffer == NULL || m_pCS->GetFamily() != PDFCS_PATTERN) {
+ if (!m_pBuffer || m_pCS->GetFamily() != PDFCS_PATTERN) {
return NULL;
}
PatternValue* pvalue = (PatternValue*)m_pBuffer;
return pvalue->m_nComps ? pvalue->m_Comps : NULL;
}
FX_BOOL CPDF_Color::IsEqual(const CPDF_Color& other) const {
- if (m_pCS != other.m_pCS || m_pCS == NULL) {
- return FALSE;
- }
- return FXSYS_memcmp(m_pBuffer, other.m_pBuffer, m_pCS->GetBufSize()) == 0;
+ return m_pCS && m_pCS == other.m_pCS &&
+ FXSYS_memcmp(m_pBuffer, other.m_pBuffer, m_pCS->GetBufSize()) == 0;
}
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_func.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_func.cpp
index 5f9d038626..118f1cd5a3 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page_func.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page_func.cpp
@@ -207,7 +207,7 @@ FX_BOOL CPDF_PSProc::Parse(CPDF_SimpleParser& parser) {
}
i++;
}
- if (_PDF_PSOpNames[i].name == NULL) {
+ if (!_PDF_PSOpNames[i].name) {
FX_FLOAT* pd = FX_Alloc(FX_FLOAT, 1);
*pd = FX_atof(word);
m_Operators.Add((void*)PSOP_CONST);
@@ -683,7 +683,7 @@ CPDF_ExpIntFunc::~CPDF_ExpIntFunc() {
}
FX_BOOL CPDF_ExpIntFunc::v_Init(CPDF_Object* pObj) {
CPDF_Dictionary* pDict = pObj->GetDict();
- if (pDict == NULL) {
+ if (!pDict) {
return FALSE;
}
CPDF_Array* pArray0 = pDict->GetArray("C0");
@@ -813,7 +813,7 @@ FX_BOOL CPDF_StitchFunc::v_Call(FX_FLOAT* inputs, FX_FLOAT* outputs) const {
if (input < m_pBounds[i + 1]) {
break;
}
- if (m_pSubFunctions[i] == NULL) {
+ if (!m_pSubFunctions[i]) {
return FALSE;
}
input = PDF_Interpolate(input, m_pBounds[i], m_pBounds[i + 1],
@@ -823,7 +823,7 @@ FX_BOOL CPDF_StitchFunc::v_Call(FX_FLOAT* inputs, FX_FLOAT* outputs) const {
return TRUE;
}
CPDF_Function* CPDF_Function::Load(CPDF_Object* pFuncObj) {
- if (pFuncObj == NULL) {
+ if (!pFuncObj) {
return NULL;
}
CPDF_Function* pFunc = NULL;
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp
index 63f957a838..d8f21c692d 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp
@@ -103,7 +103,7 @@ CPDF_Rect CPDF_ClipPath::GetClipBox() const {
FX_BOOL bLayerStarted = FALSE;
for (int i = 0; i < count; i++) {
CPDF_TextObject* pTextObj = GetText(i);
- if (pTextObj == NULL) {
+ if (!pTextObj) {
if (!bStarted) {
rect = layer_rect;
bStarted = TRUE;
@@ -637,7 +637,7 @@ void CPDF_ContentMarkData::AddMark(const CFX_ByteString& name,
FX_BOOL bDirect) {
CPDF_ContentMarkItem& item = m_Marks.Add();
item.SetName(name);
- if (pDict == NULL) {
+ if (!pDict) {
return;
}
item.SetParam(bDirect ? CPDF_ContentMarkItem::DirectDict
@@ -652,7 +652,7 @@ void CPDF_ContentMarkData::DeleteLastMark() {
m_Marks.RemoveAt(size - 1);
}
FX_BOOL CPDF_ContentMark::HasMark(const CFX_ByteStringC& mark) const {
- if (m_pObject == NULL) {
+ if (!m_pObject) {
return FALSE;
}
for (int i = 0; i < m_pObject->CountItems(); i++) {
@@ -665,7 +665,7 @@ FX_BOOL CPDF_ContentMark::HasMark(const CFX_ByteStringC& mark) const {
}
FX_BOOL CPDF_ContentMark::LookupMark(const CFX_ByteStringC& mark,
CPDF_Dictionary*& pDict) const {
- if (m_pObject == NULL) {
+ if (!m_pObject) {
return FALSE;
}
for (int i = 0; i < m_pObject->CountItems(); i++) {
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp
index 1df0c605e4..e90c53c956 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp
@@ -117,7 +117,7 @@ void CPDF_StreamContentParser::AddNameParam(const FX_CHAR* name, int len) {
CPDF_Name::Create(PDF_NameDecode(CFX_ByteStringC(name, len)));
} else {
m_ParamBuf1[index].m_Type = PDFOBJ_NAME;
- if (FXSYS_memchr(name, '#', len) == NULL) {
+ if (!FXSYS_memchr(name, '#', len)) {
FXSYS_memcpy(m_ParamBuf1[index].m_Name.m_Buffer, name, len);
m_ParamBuf1[index].m_Name.m_Len = len;
} else {
@@ -410,7 +410,7 @@ void CPDF_StreamContentParser::Handle_BeginMarkedContent_Dictionary() {
}
CFX_ByteString tag = GetString(1);
CPDF_Object* pProperty = GetObject(0);
- if (pProperty == NULL) {
+ if (!pProperty) {
return;
}
FX_BOOL bDirect = TRUE;
@@ -631,7 +631,7 @@ void CPDF_StreamContentParser::Handle_SetColorSpace_Fill() {
}
CFX_ByteString csname = GetString(0);
CPDF_ColorSpace* pCS = FindColorSpace(csname);
- if (pCS == NULL) {
+ if (!pCS) {
return;
}
m_pCurStates->m_ColorState.GetModify()->m_FillColor.SetColorSpace(pCS);
@@ -642,7 +642,7 @@ void CPDF_StreamContentParser::Handle_SetColorSpace_Stroke() {
}
CFX_ByteString csname = GetString(0);
CPDF_ColorSpace* pCS = FindColorSpace(csname);
- if (pCS == NULL) {
+ if (!pCS) {
return;
}
m_pCurStates->m_ColorState.GetModify()->m_StrokeColor.SetColorSpace(pCS);
@@ -652,7 +652,7 @@ void CPDF_StreamContentParser::Handle_SetDash() {
return;
}
CPDF_Array* pArray = GetObject(1) ? GetObject(1)->GetArray() : NULL;
- if (pArray == NULL) {
+ if (!pArray) {
return;
}
m_pCurStates->SetLineDash(pArray, GetNumber(0), 1.0f);
@@ -771,7 +771,7 @@ void CPDF_StreamContentParser::AddForm(CPDF_Stream* pStream) {
CPDF_ImageObject* CPDF_StreamContentParser::AddImage(CPDF_Stream* pStream,
CPDF_Image* pImage,
FX_BOOL bInline) {
- if (pStream == NULL && pImage == NULL) {
+ if (!pStream && !pImage) {
return NULL;
}
CFX_Matrix ImageMatrix;
@@ -1032,7 +1032,7 @@ void CPDF_StreamContentParser::Handle_SetColorPS_Fill() {
return;
}
CPDF_Object* pLastParam = GetObject(0);
- if (pLastParam == NULL) {
+ if (!pLastParam) {
return;
}
int nargs = m_ParamCount;
@@ -1062,7 +1062,7 @@ void CPDF_StreamContentParser::Handle_SetColorPS_Stroke() {
return;
}
CPDF_Object* pLastParam = GetObject(0);
- if (pLastParam == NULL) {
+ if (!pLastParam) {
return;
}
int nargs = m_ParamCount;
@@ -1099,7 +1099,7 @@ void CPDF_StreamContentParser::Handle_ShadeFill() {
return;
}
CPDF_Pattern* pPattern = FindPattern(GetString(0), TRUE);
- if (pPattern == NULL) {
+ if (!pPattern) {
return;
}
if (pPattern->m_PatternType != PATTERN_SHADING) {
@@ -1162,24 +1162,24 @@ void CPDF_StreamContentParser::Handle_SetFont() {
CPDF_Object* CPDF_StreamContentParser::FindResourceObj(
const CFX_ByteStringC& type,
const CFX_ByteString& name) {
- if (m_pResources == NULL) {
+ if (!m_pResources) {
return NULL;
}
if (m_pResources == m_pPageResources) {
CPDF_Dictionary* pList = m_pResources->GetDict(type);
- if (pList == NULL) {
+ if (!pList) {
return NULL;
}
CPDF_Object* pRes = pList->GetElementValue(name);
return pRes;
}
CPDF_Dictionary* pList = m_pResources->GetDict(type);
- if (pList == NULL) {
- if (m_pPageResources == NULL) {
+ if (!pList) {
+ if (!m_pPageResources) {
return NULL;
}
CPDF_Dictionary* pList = m_pPageResources->GetDict(type);
- if (pList == NULL) {
+ if (!pList) {
return NULL;
}
CPDF_Object* pRes = pList->GetElementValue(name);
@@ -1211,7 +1211,7 @@ CPDF_ColorSpace* CPDF_StreamContentParser::FindColorSpace(
CFX_ByteString defname = "Default";
defname += name.Mid(7);
CPDF_Object* pDefObj = FindResourceObj("ColorSpace", defname);
- if (pDefObj == NULL) {
+ if (!pDefObj) {
if (name == "DeviceGray") {
return CPDF_ColorSpace::GetStockCS(PDFCS_DEVICEGRAY);
}
@@ -1223,7 +1223,7 @@ CPDF_ColorSpace* CPDF_StreamContentParser::FindColorSpace(
return m_pDocument->LoadColorSpace(pDefObj);
}
CPDF_Object* pCSObj = FindResourceObj("ColorSpace", name);
- if (pCSObj == NULL) {
+ if (!pCSObj) {
m_bResourceMissing = TRUE;
return NULL;
}
@@ -1253,7 +1253,7 @@ void CPDF_StreamContentParser::AddTextObject(CFX_ByteString* pStrs,
FX_FLOAT* pKerning,
int nsegs) {
CPDF_Font* pFont = m_pCurStates->m_TextState.GetFont();
- if (pFont == NULL) {
+ if (!pFont) {
return;
}
if (fInitKerning != 0) {
@@ -1324,7 +1324,7 @@ void CPDF_StreamContentParser::Handle_ShowText() {
}
void CPDF_StreamContentParser::Handle_ShowText_Positioning() {
CPDF_Array* pArray = GetObject(0) ? GetObject(0)->GetArray() : NULL;
- if (pArray == NULL) {
+ if (!pArray) {
return;
}
int n = pArray->GetCount();
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp
index fbe6faa471..2f68d78808 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp
@@ -249,7 +249,7 @@ CPDF_StreamParser::~CPDF_StreamParser() {
FX_DWORD _DecodeAllScanlines(ICodec_ScanlineDecoder* pDecoder,
uint8_t*& dest_buf,
FX_DWORD& dest_size) {
- if (pDecoder == NULL) {
+ if (!pDecoder) {
return (FX_DWORD)-1;
}
int ncomps = pDecoder->CountComps();
@@ -353,7 +353,7 @@ CPDF_Stream* CPDF_StreamParser::ReadInlineStream(CPDF_Document* pDoc,
FX_DWORD bpc = pDict->GetInteger("BitsPerComponent");
FX_DWORD nComponents = 1;
CPDF_ColorSpace* pCS = pDoc->LoadColorSpace(pCSObj);
- if (pCS == NULL) {
+ if (!pCS) {
nComponents = 3;
} else {
nComponents = pCS->CountComponents();
@@ -634,7 +634,7 @@ CPDF_Object* CPDF_StreamParser::ReadNextObject(FX_BOOL bAllowNestedArray,
CFX_ByteString key =
PDF_NameDecode(CFX_ByteStringC(m_WordBuffer + 1, m_WordSize - 1));
CPDF_Object* pObj = ReadNextObject(TRUE);
- if (pObj == NULL) {
+ if (!pObj) {
if (pDict) {
pDict->Release();
}
@@ -655,7 +655,7 @@ CPDF_Object* CPDF_StreamParser::ReadNextObject(FX_BOOL bAllowNestedArray,
CPDF_Array* pArray = CPDF_Array::Create();
while (1) {
CPDF_Object* pObj = ReadNextObject(bAllowNestedArray, TRUE);
- if (pObj == NULL) {
+ if (!pObj) {
if (m_WordSize == 0 || m_WordBuffer[0] == ']') {
return pArray;
}
@@ -924,8 +924,8 @@ void CPDF_ContentParser::Clear() {
m_Status = Ready;
}
void CPDF_ContentParser::Start(CPDF_Page* pPage, CPDF_ParseOptions* pOptions) {
- if (m_Status != Ready || pPage == NULL || pPage->m_pDocument == NULL ||
- pPage->m_pFormDict == NULL) {
+ if (m_Status != Ready || !pPage || !pPage->m_pDocument ||
+ !pPage->m_pFormDict) {
m_Status = Done;
return;
}
@@ -938,7 +938,7 @@ void CPDF_ContentParser::Start(CPDF_Page* pPage, CPDF_ParseOptions* pOptions) {
m_InternalStage = PAGEPARSE_STAGE_GETCONTENT;
m_CurrentOffset = 0;
CPDF_Object* pContent = pPage->m_pFormDict->GetElementValue("Contents");
- if (pContent == NULL) {
+ if (!pContent) {
m_Status = Done;
return;
}
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_pattern.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_pattern.cpp
index 5ead9a5bea..fc050b9369 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page_pattern.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page_pattern.cpp
@@ -129,7 +129,7 @@ FX_BOOL CPDF_ShadingPattern::Load() {
CPDF_Dictionary* pShadingDict =
m_pShadingObj ? m_pShadingObj->GetDict() : NULL;
- if (pShadingDict == NULL) {
+ if (!pShadingDict) {
return FALSE;
}
if (m_nFuncs) {
@@ -151,7 +151,7 @@ FX_BOOL CPDF_ShadingPattern::Load() {
}
}
CPDF_Object* pCSObj = pShadingDict->GetElementValue("ColorSpace");
- if (pCSObj == NULL) {
+ if (!pCSObj) {
return FALSE;
}
CPDF_DocPageData* pDocPageData = m_pDocument->GetPageData();
@@ -199,7 +199,7 @@ FX_BOOL CPDF_MeshStream::Load(CPDF_Stream* pShadingStream,
m_CoordMax = m_nCoordBits == 32 ? -1 : (1 << m_nCoordBits) - 1;
m_CompMax = (1 << m_nCompBits) - 1;
CPDF_Array* pDecode = pDict->GetArray("Decode");
- if (pDecode == NULL || pDecode->GetCount() != 4 + m_nComps * 2) {
+ if (!pDecode || pDecode->GetCount() != 4 + m_nComps * 2) {
return FALSE;
}
m_xmin = pDecode->GetNumber(0);
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp
index 5fbdcc634c..c855a7c5c2 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp
@@ -454,7 +454,7 @@ CFX_WideString PDF_DecodeText(const uint8_t* src_data,
}
}
result.ReleaseBuffer(dest_pos);
- } else if (pCharMap == NULL) {
+ } else if (!pCharMap) {
FX_WCHAR* dest_buf = result.GetBuffer(src_len);
for (FX_DWORD i = 0; i < src_len; i++) {
dest_buf[i] = PDFDocEncoding[src_data[i]];
@@ -473,7 +473,7 @@ CFX_ByteString PDF_EncodeText(const FX_WCHAR* pString,
len = FXSYS_wcslen(pString);
}
CFX_ByteString result;
- if (pCharMap == NULL) {
+ if (!pCharMap) {
FX_CHAR* dest_buf1 = result.GetBuffer(len);
int i;
for (i = 0; i < len; i++) {
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_document.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_document.cpp
index 6625cce2e6..bf94185720 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_document.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_document.cpp
@@ -35,11 +35,11 @@ CPDF_DocRenderData* CPDF_Document::GetValidateRenderData() {
void CPDF_Document::LoadDoc() {
m_LastObjNum = m_pParser->GetLastObjNum();
CPDF_Object* pRootObj = GetIndirectObject(m_pParser->GetRootObjNum());
- if (pRootObj == NULL) {
+ if (!pRootObj) {
return;
}
m_pRootDict = pRootObj->GetDict();
- if (m_pRootDict == NULL) {
+ if (!m_pRootDict) {
return;
}
CPDF_Object* pInfoObj = GetIndirectObject(m_pParser->GetInfoObjNum());
@@ -58,7 +58,7 @@ void CPDF_Document::LoadAsynDoc(CPDF_Dictionary* pLinearized) {
m_LastObjNum = m_pParser->GetLastObjNum();
CPDF_Object* indirectObj = GetIndirectObject(m_pParser->GetRootObjNum());
m_pRootDict = indirectObj ? indirectObj->GetDict() : NULL;
- if (m_pRootDict == NULL) {
+ if (!m_pRootDict) {
return;
}
indirectObj = GetIndirectObject(m_pParser->GetInfoObjNum());
@@ -100,7 +100,7 @@ CPDF_Dictionary* CPDF_Document::_FindPDFPage(CPDF_Dictionary* pPages,
int nPagesToGo,
int level) {
CPDF_Array* pKidList = pPages->GetArray("Kids");
- if (pKidList == NULL) {
+ if (!pKidList) {
if (nPagesToGo == 0) {
return pPages;
}
@@ -112,7 +112,7 @@ CPDF_Dictionary* CPDF_Document::_FindPDFPage(CPDF_Dictionary* pPages,
int nKids = pKidList->GetCount();
for (int i = 0; i < nKids; i++) {
CPDF_Dictionary* pKid = pKidList->GetDict(i);
- if (pKid == NULL) {
+ if (!pKid) {
nPagesToGo--;
continue;
}
@@ -175,7 +175,7 @@ int CPDF_Document::_FindPageIndex(CPDF_Dictionary* pNode,
int level) {
if (pNode->KeyExist("Kids")) {
CPDF_Array* pKidList = pNode->GetArray("Kids");
- if (pKidList == NULL) {
+ if (!pKidList) {
return -1;
}
if (level >= FX_MAX_PAGE_LEVEL) {
@@ -199,7 +199,7 @@ int CPDF_Document::_FindPageIndex(CPDF_Dictionary* pNode,
}
for (FX_DWORD i = 0; i < pKidList->GetCount(); i++) {
CPDF_Dictionary* pKid = pKidList->GetDict(i);
- if (pKid == NULL) {
+ if (!pKid) {
continue;
}
if (pKid == pNode) {
@@ -237,11 +237,11 @@ int CPDF_Document::GetPageIndex(FX_DWORD objnum) {
}
}
CPDF_Dictionary* pRoot = GetRoot();
- if (pRoot == NULL) {
+ if (!pRoot) {
return -1;
}
CPDF_Dictionary* pPages = pRoot->GetDict("Pages");
- if (pPages == NULL) {
+ if (!pPages) {
return -1;
}
int index = 0;
@@ -259,13 +259,13 @@ static int _CountPages(CPDF_Dictionary* pPages, int level) {
return count;
}
CPDF_Array* pKidList = pPages->GetArray("Kids");
- if (pKidList == NULL) {
+ if (!pKidList) {
return 0;
}
count = 0;
for (FX_DWORD i = 0; i < pKidList->GetCount(); i++) {
CPDF_Dictionary* pKid = pKidList->GetDict(i);
- if (pKid == NULL) {
+ if (!pKid) {
continue;
}
if (!pKid->KeyExist("Kids")) {
@@ -279,11 +279,11 @@ static int _CountPages(CPDF_Dictionary* pPages, int level) {
}
int CPDF_Document::_GetPageCount() const {
CPDF_Dictionary* pRoot = GetRoot();
- if (pRoot == NULL) {
+ if (!pRoot) {
return 0;
}
CPDF_Dictionary* pPages = pRoot->GetDict("Pages");
- if (pPages == NULL) {
+ if (!pPages) {
return 0;
}
if (!pPages->KeyExist("Kids")) {
@@ -300,7 +300,7 @@ FX_BOOL CPDF_Document::IsContentUsedElsewhere(FX_DWORD objnum,
}
CPDF_Object* pContents =
pPageDict ? pPageDict->GetElement("Contents") : NULL;
- if (pContents == NULL) {
+ if (!pContents) {
continue;
}
if (pContents->GetDirectType() == PDFOBJ_ARRAY) {
@@ -317,16 +317,13 @@ FX_BOOL CPDF_Document::IsContentUsedElsewhere(FX_DWORD objnum,
return FALSE;
}
FX_DWORD CPDF_Document::GetUserPermissions(FX_BOOL bCheckRevision) const {
- if (m_pParser == NULL) {
+ if (!m_pParser) {
return (FX_DWORD)-1;
}
return m_pParser->GetPermissions(bCheckRevision);
}
FX_BOOL CPDF_Document::IsOwner() const {
- if (m_pParser == NULL) {
- return TRUE;
- }
- return m_pParser->IsOwner();
+ return !m_pParser || m_pParser->IsOwner();
}
FX_BOOL CPDF_Document::IsFormStream(FX_DWORD objnum, FX_BOOL& bForm) const {
{
@@ -337,7 +334,7 @@ FX_BOOL CPDF_Document::IsFormStream(FX_DWORD objnum, FX_BOOL& bForm) const {
return TRUE;
}
}
- if (m_pParser == NULL) {
+ if (!m_pParser) {
bForm = FALSE;
return TRUE;
}
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_encrypt.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_encrypt.cpp
index d2379fea6c..0ee0d9a3e8 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_encrypt.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_encrypt.cpp
@@ -115,14 +115,14 @@ static FX_BOOL _LoadCryptInfo(CPDF_Dictionary* pEncryptDict,
keylen = 0;
if (Version >= 4) {
CPDF_Dictionary* pCryptFilters = pEncryptDict->GetDict("CF");
- if (pCryptFilters == NULL) {
+ if (!pCryptFilters) {
return FALSE;
}
if (name == "Identity") {
cipher = FXCIPHER_NONE;
} else {
CPDF_Dictionary* pDefFilter = pCryptFilters->GetDict(name);
- if (pDefFilter == NULL) {
+ if (!pDefFilter) {
return FALSE;
}
int nKeyBits = 0;
@@ -329,7 +329,7 @@ FX_BOOL CPDF_StandardSecurityHandler::AES256_CheckPassword(
if (FXSYS_memcmp(digest, pkey, 32) != 0) {
return FALSE;
}
- if (key == NULL) {
+ if (!key) {
return TRUE;
}
if (m_Revision >= 6) {
@@ -399,7 +399,7 @@ int CPDF_StandardSecurityHandler::CheckPassword(const uint8_t* password,
return AES256_CheckPassword(password, size, bOwner, key);
}
uint8_t keybuf[32];
- if (key == NULL) {
+ if (!key) {
key = keybuf;
}
if (bOwner) {
@@ -541,7 +541,7 @@ void CPDF_StandardSecurityHandler::OnCreate(CPDF_Dictionary* pEncryptDict,
if (!LoadDict(pEncryptDict, type, cipher, key_len)) {
return;
}
- if (bDefault && (owner_pass == NULL || owner_size == 0)) {
+ if (bDefault && (!owner_pass || owner_size == 0)) {
owner_pass = user_pass;
owner_size = user_size;
}
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_fdf.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_fdf.cpp
index f61036aef6..df7b7a33cb 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_fdf.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_fdf.cpp
@@ -30,7 +30,7 @@ CFDF_Document* CFDF_Document::ParseFile(IFX_FileRead* pFile, FX_BOOL bOwnFile) {
}
CFDF_Document* pDoc = new CFDF_Document;
pDoc->ParseStream(pFile, bOwnFile);
- if (pDoc->m_pRootDict == NULL) {
+ if (!pDoc->m_pRootDict) {
delete pDoc;
return NULL;
}
@@ -59,7 +59,7 @@ void CFDF_Document::ParseStream(IFX_FileRead* pFile, FX_BOOL bOwnFile) {
break;
}
CPDF_Object* pObj = parser.GetObject(this, objnum, 0, 0);
- if (pObj == NULL) {
+ if (!pObj) {
break;
}
InsertIndirectObject(objnum, pObj);
@@ -81,7 +81,7 @@ void CFDF_Document::ParseStream(IFX_FileRead* pFile, FX_BOOL bOwnFile) {
}
}
FX_BOOL CFDF_Document::WriteBuf(CFX_ByteTextBuf& buf) const {
- if (m_pRootDict == NULL) {
+ if (!m_pRootDict) {
return FALSE;
}
buf << "%FDF-1.2\r\n";
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp
index 58b03c1887..c503277f87 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp
@@ -582,7 +582,7 @@ FX_POSITION CPDF_Dictionary::GetStartPos() const {
}
CPDF_Object* CPDF_Dictionary::GetNextElement(FX_POSITION& pos,
CFX_ByteString& key) const {
- if (pos == NULL) {
+ if (!pos) {
return NULL;
}
CPDF_Object* p;
@@ -736,7 +736,7 @@ void CPDF_Dictionary::RemoveAt(const CFX_ByteStringC& key) {
ASSERT(m_Type == PDFOBJ_DICTIONARY);
CPDF_Object* p = NULL;
m_Map.Lookup(key, (void*&)p);
- if (p == NULL) {
+ if (!p) {
return;
}
p->Release();
@@ -747,14 +747,14 @@ void CPDF_Dictionary::ReplaceKey(const CFX_ByteStringC& oldkey,
ASSERT(m_Type == PDFOBJ_DICTIONARY);
CPDF_Object* p = NULL;
m_Map.Lookup(oldkey, (void*&)p);
- if (p == NULL) {
+ if (!p) {
return;
}
m_Map.RemoveKey(oldkey);
m_Map.SetAt(newkey, p);
}
FX_BOOL CPDF_Dictionary::Identical(CPDF_Dictionary* pOther) const {
- if (pOther == NULL) {
+ if (!pOther) {
return FALSE;
}
if (m_Map.GetCount() != pOther->m_Map.GetCount()) {
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
index fcb1c2ed86..f18b733ab7 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
@@ -273,7 +273,7 @@ FX_DWORD CPDF_Parser::StartParse(IFX_FileRead* pFileAccess,
FX_DWORD CPDF_Parser::SetEncryptHandler() {
ReleaseEncryptHandler();
SetEncryptDictionary(NULL);
- if (m_pTrailer == NULL) {
+ if (!m_pTrailer) {
return PDFPARSE_ERROR_FORMAT;
}
CPDF_Object* pEncryptObj = m_pTrailer->GetElement("Encrypt");
@@ -348,7 +348,7 @@ FX_BOOL CPDF_Parser::LoadAllCrossRefV4(FX_FILESIZE xrefpos) {
return FALSE;
}
m_pTrailer = LoadTrailerV4();
- if (m_pTrailer == NULL) {
+ if (!m_pTrailer) {
return FALSE;
}
int32_t xrefsize = GetDirectInteger(m_pTrailer, "Size");
@@ -399,7 +399,7 @@ FX_BOOL CPDF_Parser::LoadLinearizedAllCrossRefV4(FX_FILESIZE xrefpos,
return FALSE;
}
m_pTrailer = LoadTrailerV4();
- if (m_pTrailer == NULL) {
+ if (!m_pTrailer) {
return FALSE;
}
int32_t xrefsize = GetDirectInteger(m_pTrailer, "Size");
@@ -414,7 +414,7 @@ FX_BOOL CPDF_Parser::LoadLinearizedAllCrossRefV4(FX_FILESIZE xrefpos,
CrossRefList.InsertAt(0, xrefpos);
LoadCrossRefV4(xrefpos, 0, TRUE, FALSE);
CPDF_Dictionary* pDict = LoadTrailerV4();
- if (pDict == NULL) {
+ if (!pDict) {
return FALSE;
}
xrefpos = GetDirectInteger(pDict, "Prev");
@@ -434,7 +434,7 @@ FX_BOOL CPDF_Parser::LoadLinearizedCrossRefV4(FX_FILESIZE pos,
void* pResult =
FXSYS_bsearch(&pos, m_SortedOffset.GetData(), m_SortedOffset.GetSize(),
sizeof(FX_FILESIZE), CompareFileSize);
- if (pResult == NULL) {
+ if (!pResult) {
m_SortedOffset.Add(pos);
}
FX_DWORD start_objnum = 0;
@@ -478,7 +478,7 @@ FX_BOOL CPDF_Parser::LoadLinearizedCrossRefV4(FX_FILESIZE pos,
void* pResult = FXSYS_bsearch(
&m_CrossRef[objnum], m_SortedOffset.GetData(),
m_SortedOffset.GetSize(), sizeof(FX_FILESIZE), CompareFileSize);
- if (pResult == NULL) {
+ if (!pResult) {
m_SortedOffset.Add(m_CrossRef[objnum]);
}
}
@@ -778,7 +778,7 @@ FX_BOOL CPDF_Parser::RebuildCrossRef() {
FXSYS_bsearch(&obj_pos, m_SortedOffset.GetData(),
m_SortedOffset.GetSize(), sizeof(FX_FILESIZE),
CompareFileSize);
- if (pResult == NULL) {
+ if (!pResult) {
m_SortedOffset.Add(obj_pos);
}
FX_FILESIZE obj_end = 0;
@@ -980,7 +980,7 @@ FX_BOOL CPDF_Parser::RebuildCrossRef() {
void* pResult =
FXSYS_bsearch(&offset, m_SortedOffset.GetData(), m_SortedOffset.GetSize(),
sizeof(FX_FILESIZE), CompareFileSize);
- if (pResult == NULL) {
+ if (!pResult) {
m_SortedOffset.Add(offset);
}
FX_Free(buffer);
@@ -1043,7 +1043,7 @@ FX_BOOL CPDF_Parser::LoadCrossRefV5(FX_FILESIZE* pos, FX_BOOL bMainXRef) {
arrIndex.push_back(std::make_pair(0, size));
}
pArray = pStream->GetDict()->GetArray("W");
- if (pArray == NULL) {
+ if (!pArray) {
pStream->Release();
return FALSE;
}
@@ -1100,7 +1100,7 @@ FX_BOOL CPDF_Parser::LoadCrossRefV5(FX_FILESIZE* pos, FX_BOOL bMainXRef) {
void* pResult = FXSYS_bsearch(&offset, m_SortedOffset.GetData(),
m_SortedOffset.GetSize(),
sizeof(FX_FILESIZE), CompareFileSize);
- if (pResult == NULL) {
+ if (!pResult) {
m_SortedOffset.Add(offset);
}
continue;
@@ -1119,7 +1119,7 @@ FX_BOOL CPDF_Parser::LoadCrossRefV5(FX_FILESIZE* pos, FX_BOOL bMainXRef) {
void* pResult = FXSYS_bsearch(&offset, m_SortedOffset.GetData(),
m_SortedOffset.GetSize(),
sizeof(FX_FILESIZE), CompareFileSize);
- if (pResult == NULL) {
+ if (!pResult) {
m_SortedOffset.Add(offset);
}
} else {
@@ -1172,7 +1172,7 @@ FX_BOOL CPDF_Parser::IsFormStream(FX_DWORD objnum, FX_BOOL& bForm) {
void* pResult =
FXSYS_bsearch(&pos, m_SortedOffset.GetData(), m_SortedOffset.GetSize(),
sizeof(FX_FILESIZE), CompareFileSize);
- if (pResult == NULL) {
+ if (!pResult) {
return TRUE;
}
if ((FX_FILESIZE*)pResult - (FX_FILESIZE*)m_SortedOffset.GetData() ==
@@ -1261,7 +1261,7 @@ FX_FILESIZE CPDF_Parser::GetObjectSize(FX_DWORD objnum) {
void* pResult = FXSYS_bsearch(&offset, m_SortedOffset.GetData(),
m_SortedOffset.GetSize(), sizeof(FX_FILESIZE),
CompareFileSize);
- if (pResult == NULL) {
+ if (!pResult) {
return 0;
}
if ((FX_FILESIZE*)pResult - (FX_FILESIZE*)m_SortedOffset.GetData() ==
@@ -1344,7 +1344,7 @@ void CPDF_Parser::GetIndirectBinary(FX_DWORD objnum,
void* pResult =
FXSYS_bsearch(&pos, m_SortedOffset.GetData(), m_SortedOffset.GetSize(),
sizeof(FX_FILESIZE), CompareFileSize);
- if (pResult == NULL) {
+ if (!pResult) {
m_Syntax.RestorePos(SavedPos);
return;
}
@@ -1490,7 +1490,7 @@ FX_DWORD CPDF_Parser::GetPermissions(FX_BOOL bCheckRevision) {
return dwPermission;
}
FX_BOOL CPDF_Parser::IsOwner() {
- return m_pSecurityHandler == NULL ? TRUE : m_pSecurityHandler->IsOwner();
+ return !m_pSecurityHandler || m_pSecurityHandler->IsOwner();
}
void CPDF_Parser::SetSecurityHandler(CPDF_SecurityHandler* pSecurityHandler,
FX_BOOL bForced) {
@@ -1584,7 +1584,7 @@ FX_DWORD CPDF_Parser::StartAsynParse(IFX_FileRead* pFileAccess,
}
if (bLoadV4) {
m_pTrailer = LoadTrailerV4();
- if (m_pTrailer == NULL) {
+ if (!m_pTrailer) {
return FALSE;
}
int32_t xrefsize = GetDirectInteger(m_pTrailer, "Size");
@@ -1598,7 +1598,7 @@ FX_DWORD CPDF_Parser::StartAsynParse(IFX_FileRead* pFileAccess,
return dwRet;
}
m_pDocument->LoadAsynDoc(m_pLinearized->GetDict());
- if (m_pDocument->GetRoot() == NULL || m_pDocument->GetPageCount() == 0) {
+ if (!m_pDocument->GetRoot() || m_pDocument->GetPageCount() == 0) {
if (bXRefRebuilt) {
return PDFPARSE_ERROR_FORMAT;
}
@@ -1611,7 +1611,7 @@ FX_DWORD CPDF_Parser::StartAsynParse(IFX_FileRead* pFileAccess,
return dwRet;
}
m_pDocument->LoadAsynDoc(m_pLinearized->GetDict());
- if (m_pDocument->GetRoot() == NULL) {
+ if (!m_pDocument->GetRoot()) {
return PDFPARSE_ERROR_FORMAT;
}
}
@@ -2984,7 +2984,7 @@ void CPDF_DataAvail::SetDocument(CPDF_Document* pDoc) {
}
FX_DWORD CPDF_DataAvail::GetObjectSize(FX_DWORD objnum, FX_FILESIZE& offset) {
CPDF_Parser* pParser = (CPDF_Parser*)(m_pDocument->GetParser());
- if (pParser == NULL) {
+ if (!pParser) {
return 0;
}
if (objnum >= (FX_DWORD)pParser->m_CrossRef.GetSize()) {
@@ -3001,7 +3001,7 @@ FX_DWORD CPDF_DataAvail::GetObjectSize(FX_DWORD objnum, FX_FILESIZE& offset) {
void* pResult = FXSYS_bsearch(&offset, pParser->m_SortedOffset.GetData(),
pParser->m_SortedOffset.GetSize(),
sizeof(FX_FILESIZE), CompareFileSize);
- if (pResult == NULL) {
+ if (!pResult) {
return 0;
}
if ((FX_FILESIZE*)pResult -
@@ -3255,13 +3255,13 @@ CPDF_Object* CPDF_DataAvail::GetObject(FX_DWORD objnum,
if (pExistInFile)
*pExistInFile = TRUE;
- if (m_pDocument == NULL) {
+ if (m_pDocument) {
+ size = GetObjectSize(objnum, offset);
+ pParser = (CPDF_Parser*)(m_pDocument->GetParser());
+ } else {
size = (FX_DWORD)m_parser.GetObjectSize(objnum);
offset = m_parser.GetObjectOffset(objnum);
pParser = &m_parser;
- } else {
- size = GetObjectSize(objnum, offset);
- pParser = (CPDF_Parser*)(m_pDocument->GetParser());
}
if (!IsDataAvail(offset, size, pHints)) {
return nullptr;
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp
index 121b2f4a04..6e20b582fc 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp
@@ -284,7 +284,7 @@ FX_BOOL CPDF_SimpleParser::FindTagParam(const CFX_ByteStringC& token,
CFX_ByteString PDF_NameDecode(const CFX_ByteStringC& bstr) {
int size = bstr.GetLength();
const FX_CHAR* pSrc = bstr.GetCStr();
- if (FXSYS_memchr(pSrc, '#', size) == NULL) {
+ if (!FXSYS_memchr(pSrc, '#', size)) {
return bstr;
}
CFX_ByteString result;
@@ -303,7 +303,7 @@ CFX_ByteString PDF_NameDecode(const CFX_ByteStringC& bstr) {
return result;
}
CFX_ByteString PDF_NameDecode(const CFX_ByteString& orig) {
- if (FXSYS_memchr(orig.c_str(), '#', orig.GetLength()) == NULL) {
+ if (!FXSYS_memchr(orig.c_str(), '#', orig.GetLength())) {
return orig;
}
return PDF_NameDecode(CFX_ByteStringC(orig));
@@ -344,7 +344,7 @@ CFX_ByteString PDF_NameEncode(const CFX_ByteString& orig) {
return res;
}
CFX_ByteTextBuf& operator<<(CFX_ByteTextBuf& buf, const CPDF_Object* pObj) {
- if (pObj == NULL) {
+ if (!pObj) {
buf << " null";
return buf;
}
@@ -444,12 +444,12 @@ static CPDF_Object* SearchNumberNode(CPDF_Dictionary* pNode, int num) {
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 = SearchNumberNode(pKid, num);
diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render.cpp
index 801f9e737c..bee188e049 100644
--- a/core/src/fpdfapi/fpdf_render/fpdf_render.cpp
+++ b/core/src/fpdfapi/fpdf_render/fpdf_render.cpp
@@ -258,7 +258,7 @@ void CPDF_RenderStatus::RenderObjectList(const CPDF_PageObjects* pObjs,
if (!pCurObj) {
continue;
}
- if (pCurObj == NULL || pCurObj->m_Left > clip_rect.right ||
+ if (!pCurObj || pCurObj->m_Left > clip_rect.right ||
pCurObj->m_Right < clip_rect.left ||
pCurObj->m_Bottom > clip_rect.top ||
pCurObj->m_Top < clip_rect.bottom) {
@@ -358,7 +358,7 @@ FX_BOOL CPDF_RenderStatus::GetObjectClippedRect(const CPDF_PageObject* pObj,
void CPDF_RenderStatus::DitherObjectArea(const CPDF_PageObject* pObj,
const CFX_Matrix* pObj2Device) {
CFX_DIBitmap* pBitmap = m_pDevice->GetBitmap();
- if (pBitmap == NULL) {
+ if (!pBitmap) {
return;
}
FX_RECT rect;
@@ -684,7 +684,7 @@ void CPDF_RenderStatus::DrawClipPath(CPDF_ClipPath ClipPath,
int i;
for (i = 0; i < nClipPath; i++) {
const CFX_PathData* pPathData = ClipPath.GetPath(i);
- if (pPathData == NULL) {
+ if (!pPathData) {
continue;
}
CFX_GraphStateData stroke_state;
@@ -780,8 +780,8 @@ FX_BOOL CPDF_RenderStatus::ProcessTransparency(const CPDF_PageObject* pPageObj,
pDocument->GetPageData()->ReleaseColorSpace(pCSObj);
}
}
- if (pSMaskDict == NULL && group_alpha == 1.0f &&
- blend_type == FXDIB_BLEND_NORMAL && !bTextClip && !bGroupTransparent) {
+ if (!pSMaskDict && group_alpha == 1.0f && blend_type == FXDIB_BLEND_NORMAL &&
+ !bTextClip && !bGroupTransparent) {
return FALSE;
}
FX_BOOL isolated = Transparency & PDFTRANS_ISOLATED;
@@ -838,7 +838,7 @@ FX_BOOL CPDF_RenderStatus::ProcessTransparency(const CPDF_PageObject* pPageObj,
text_device.Attach(pTextMask.get());
for (FX_DWORD i = 0; i < pPageObj->m_ClipPath.GetTextCount(); i++) {
CPDF_TextObject* textobj = pPageObj->m_ClipPath.GetText(i);
- if (textobj == NULL) {
+ if (!textobj) {
break;
}
CFX_Matrix text_matrix;
@@ -1079,7 +1079,7 @@ void CPDF_ProgressiveRenderer::Continue(IFX_Pause* pPause) {
for (; m_LayerIndex < nLayers; m_LayerIndex++) {
_PDF_RenderItem* pItem = m_pContext->m_ContentList.GetDataPtr(m_LayerIndex);
FX_POSITION LastPos = pItem->m_pObjectList->GetLastObjectPosition();
- if (m_ObjectPos == NULL) {
+ if (!m_ObjectPos) {
if (LastPos == m_PrevLastPos) {
if (!pItem->m_pObjectList->IsParsed()) {
pItem->m_pObjectList->ContinueParse(pPause);
diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render_cache.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render_cache.cpp
index 7a28ddc782..babf70396b 100644
--- a/core/src/fpdfapi/fpdf_render/fpdf_render_cache.cpp
+++ b/core/src/fpdfapi/fpdf_render/fpdf_render_cache.cpp
@@ -74,7 +74,7 @@ void CPDF_PageRenderCache::CacheOptimization(int32_t dwLimitCacheSize) {
}
void CPDF_PageRenderCache::ClearImageCache(CPDF_Stream* pStream) {
void* value = m_ImageCaches.GetValueAt(pStream);
- if (value == NULL) {
+ if (!value) {
m_ImageCaches.RemoveKey(pStream);
return;
}
@@ -95,7 +95,7 @@ FX_DWORD CPDF_PageRenderCache::EstimateSize() {
return dwSize;
}
FX_DWORD CPDF_PageRenderCache::GetCachedSize(CPDF_Stream* pStream) const {
- if (pStream == NULL) {
+ if (!pStream) {
return m_nCacheSize;
}
CPDF_ImageCache* pImageCache;
@@ -175,7 +175,7 @@ void CPDF_PageRenderCache::ResetBitmap(CPDF_Stream* pStream,
const CFX_DIBitmap* pBitmap) {
CPDF_ImageCache* pImageCache;
if (!m_ImageCaches.Lookup(pStream, (void*&)pImageCache)) {
- if (pBitmap == NULL) {
+ if (!pBitmap) {
return;
}
pImageCache = new CPDF_ImageCache(m_pPage->m_pDocument, pStream);
@@ -220,7 +220,7 @@ void CPDF_PageRenderCache::ClearImageData() {
}
}
void CPDF_ImageCache::ClearImageData() {
- if (m_pCachedBitmap && m_pCachedBitmap->GetBuffer() == NULL) {
+ if (m_pCachedBitmap && !m_pCachedBitmap->GetBuffer()) {
((CPDF_DIBSource*)m_pCachedBitmap)->ClearImageData();
}
}
diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp
index 938a495eb1..d3390517e9 100644
--- a/core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp
+++ b/core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp
@@ -29,7 +29,7 @@ void CPDF_RenderStatus::CompositeDIBitmap(CFX_DIBitmap* pDIBitmap,
int bitmap_alpha,
int blend_mode,
int Transparency) {
- if (pDIBitmap == NULL) {
+ if (!pDIBitmap) {
return;
}
FX_BOOL bIsolated = Transparency & PDFTRANS_ISOLATED;
@@ -353,7 +353,7 @@ FX_BOOL CPDF_ImageRenderer::StartLoadDIBSource() {
return FALSE;
}
FX_BOOL CPDF_ImageRenderer::StartRenderDIBSource() {
- if (m_Loader.m_pBitmap == NULL) {
+ if (!m_Loader.m_pBitmap) {
return FALSE;
}
m_BitmapAlpha = 255;
@@ -363,7 +363,7 @@ FX_BOOL CPDF_ImageRenderer::StartRenderDIBSource() {
}
m_pDIBSource = m_Loader.m_pBitmap;
if (m_pRenderStatus->m_Options.m_ColorMode == RENDER_COLOR_ALPHA &&
- m_Loader.m_pMask == NULL) {
+ !m_Loader.m_pMask) {
return StartBitmapAlpha();
}
if (pGeneralState && pGeneralState->m_pTR) {
@@ -844,7 +844,7 @@ FX_BOOL CPDF_ImageRenderer::Continue(IFX_Pause* pPause) {
return TRUE;
}
CFX_DIBitmap* pBitmap = m_pTransformer->m_Storer.Detach();
- if (pBitmap == NULL) {
+ if (!pBitmap) {
return FALSE;
}
if (pBitmap->IsAlphaMask()) {
@@ -934,11 +934,11 @@ FX_BOOL CPDF_QuickStretcher::Start(CPDF_ImageObject* pImageObj,
m_pCS = NULL;
m_Bpp = 3;
CPDF_Object* pCSObj = pDict->GetElementValue("ColorSpace");
- if (pCSObj == NULL) {
+ if (!pCSObj) {
return FALSE;
}
m_pCS = CPDF_ColorSpace::Load(pImageObj->m_pImage->GetDocument(), pCSObj);
- if (m_pCS == NULL) {
+ if (!m_pCS) {
return FALSE;
}
if (!_IsSupported(m_pCS)) {
@@ -995,12 +995,12 @@ FX_BOOL CPDF_QuickStretcher::Continue(IFX_Pause* pPause) {
const uint8_t* src_scan;
if (m_pDecoder) {
src_scan = m_pDecoder->GetScanline(src_y);
- if (src_scan == NULL) {
+ if (!src_scan) {
break;
}
} else {
src_scan = m_StreamAcc.GetData();
- if (src_scan == NULL) {
+ if (!src_scan) {
break;
}
src_scan += src_y * src_pitch;
@@ -1011,7 +1011,7 @@ FX_BOOL CPDF_QuickStretcher::Continue(IFX_Pause* pPause) {
int src_x = (m_bFlipX ? (m_DestWidth - dest_x - 1) : dest_x) * src_width /
m_DestWidth;
const uint8_t* src_pixel = src_scan + src_x * m_Bpp;
- if (m_pCS == NULL) {
+ if (!m_pCS) {
*result_scan = src_pixel[2];
result_scan++;
*result_scan = src_pixel[1];
@@ -1040,7 +1040,7 @@ FX_BOOL CPDF_QuickStretcher::Continue(IFX_Pause* pPause) {
CFX_DIBitmap* CPDF_RenderStatus::LoadSMask(CPDF_Dictionary* pSMaskDict,
FX_RECT* pClipRect,
const CFX_Matrix* pMatrix) {
- if (pSMaskDict == NULL) {
+ if (!pSMaskDict) {
return NULL;
}
int width = pClipRect->right - pClipRect->left;
@@ -1048,7 +1048,7 @@ CFX_DIBitmap* CPDF_RenderStatus::LoadSMask(CPDF_Dictionary* pSMaskDict,
FX_BOOL bLuminosity = FALSE;
bLuminosity = pSMaskDict->GetConstString("S") != "Alpha";
CPDF_Stream* pGroup = pSMaskDict->GetStream("G");
- if (pGroup == NULL) {
+ if (!pGroup) {
return NULL;
}
nonstd::unique_ptr<CPDF_Function> pFunc;
diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp
index 521ec16be1..7b34c5721a 100644
--- a/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp
+++ b/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp
@@ -212,12 +212,12 @@ FX_BOOL CPDF_DIBSource::Load(CPDF_Document* pDoc,
FX_BOOL bStdCS,
FX_DWORD GroupFamily,
FX_BOOL bLoadMask) {
- if (pStream == NULL) {
+ if (!pStream) {
return FALSE;
}
m_pDocument = pDoc;
m_pDict = pStream->GetDict();
- if (m_pDict == NULL) {
+ if (!m_pDict) {
return FALSE;
}
m_pStream = pStream;
@@ -243,7 +243,7 @@ FX_BOOL CPDF_DIBSource::Load(CPDF_Document* pDoc,
}
m_pStreamAcc = new CPDF_StreamAcc;
m_pStreamAcc->LoadAllData(pStream, FALSE, src_size.ValueOrDie(), TRUE);
- if (m_pStreamAcc->GetSize() == 0 || m_pStreamAcc->GetData() == NULL) {
+ if (m_pStreamAcc->GetSize() == 0 || !m_pStreamAcc->GetData()) {
return FALSE;
}
if (!CreateDecoder()) {
@@ -333,7 +333,7 @@ int CPDF_DIBSource::StartLoadDIBSource(CPDF_Document* pDoc,
FX_BOOL bStdCS,
FX_DWORD GroupFamily,
FX_BOOL bLoadMask) {
- if (pStream == NULL) {
+ if (!pStream) {
return 0;
}
m_pDocument = pDoc;
@@ -363,7 +363,7 @@ int CPDF_DIBSource::StartLoadDIBSource(CPDF_Document* pDoc,
}
m_pStreamAcc = new CPDF_StreamAcc;
m_pStreamAcc->LoadAllData(pStream, FALSE, src_size.ValueOrDie(), TRUE);
- if (m_pStreamAcc->GetSize() == 0 || m_pStreamAcc->GetData() == NULL) {
+ if (m_pStreamAcc->GetSize() == 0 || !m_pStreamAcc->GetData()) {
return 0;
}
int ret = CreateDecoder();
@@ -401,7 +401,7 @@ int CPDF_DIBSource::ContinueLoadDIBSource(IFX_Pause* pPause) {
return 0;
}
ICodec_Jbig2Module* pJbig2Module = CPDF_ModuleMgr::Get()->GetJbig2Module();
- if (m_pJbig2Context == NULL) {
+ if (!m_pJbig2Context) {
m_pJbig2Context = pJbig2Module->CreateJbig2Context();
if (m_pStreamAcc->GetImageParam()) {
CPDF_Stream* pGlobals =
@@ -531,7 +531,7 @@ bool CPDF_DIBSource::LoadColorInfo(const CPDF_Dictionary* pFormResources,
DIB_COMP_DATA* CPDF_DIBSource::GetDecodeAndMaskArray(FX_BOOL& bDefaultDecode,
FX_BOOL& bColorKey) {
- if (m_pColorSpace == NULL) {
+ if (!m_pColorSpace) {
return NULL;
}
DIB_COMP_DATA* pCompData = FX_Alloc(DIB_COMP_DATA, m_nComponents);
@@ -565,7 +565,7 @@ DIB_COMP_DATA* CPDF_DIBSource::GetDecodeAndMaskArray(FX_BOOL& bDefaultDecode,
}
if (!m_pDict->KeyExist("SMask")) {
CPDF_Object* pMask = m_pDict->GetElementValue("Mask");
- if (pMask == NULL) {
+ if (!pMask) {
return pCompData;
}
if (CPDF_Array* pArray = pMask->AsArray()) {
@@ -628,7 +628,7 @@ int CPDF_DIBSource::CreateDecoder() {
return 0;
}
m_pCompData = GetDecodeAndMaskArray(m_bDefaultDecode, m_bColorKey);
- if (m_pCompData == NULL) {
+ if (!m_pCompData) {
return 0;
}
}
@@ -807,7 +807,7 @@ int CPDF_DIBSource::StratLoadMask() {
return m_pMaskStream ? StartLoadMaskDIB() : 1;
}
int CPDF_DIBSource::ContinueLoadMaskDIB(IFX_Pause* pPause) {
- if (m_pMask == NULL) {
+ if (!m_pMask) {
return 1;
}
int ret = m_pMask->ContinueLoadDIBSource(pPause);
@@ -860,7 +860,7 @@ void CPDF_DIBSource::LoadPalette() {
if (m_bpc * m_nComponents > 8) {
return;
}
- if (m_pColorSpace == NULL) {
+ if (!m_pColorSpace) {
return;
}
if (m_bpc * m_nComponents == 1) {
@@ -1606,7 +1606,7 @@ FX_BOOL CPDF_ImageLoader::Load(const CPDF_ImageObject* pImage,
FX_DWORD GroupFamily,
FX_BOOL bLoadMask,
CPDF_RenderStatus* pRenderStatus) {
- if (pImage == NULL) {
+ if (!pImage) {
return FALSE;
}
if (pCache) {
diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render_pattern.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render_pattern.cpp
index 8b6c0d1fd1..9076b7ba20 100644
--- a/core/src/fpdfapi/fpdf_render/fpdf_render_pattern.cpp
+++ b/core/src/fpdfapi/fpdf_render/fpdf_render_pattern.cpp
@@ -21,7 +21,7 @@ static void DrawAxialShading(CFX_DIBitmap* pBitmap,
int alpha) {
ASSERT(pBitmap->GetFormat() == FXDIB_Argb);
CPDF_Array* pCoords = pDict->GetArray("Coords");
- if (pCoords == NULL) {
+ if (!pCoords) {
return;
}
FX_FLOAT start_x = pCoords->GetNumber(0);
@@ -112,7 +112,7 @@ static void DrawRadialShading(CFX_DIBitmap* pBitmap,
int alpha) {
ASSERT(pBitmap->GetFormat() == FXDIB_Argb);
CPDF_Array* pCoords = pDict->GetArray("Coords");
- if (pCoords == NULL) {
+ if (!pCoords) {
return;
}
FX_FLOAT start_x = pCoords->GetNumber(0);
@@ -834,7 +834,7 @@ void CPDF_RenderStatus::DrawShading(CPDF_ShadingPattern* pPattern,
int nFuncs = pPattern->m_nFuncs;
CPDF_Dictionary* pDict = pPattern->m_pShadingObj->GetDict();
CPDF_ColorSpace* pColorSpace = pPattern->m_pCS;
- if (pColorSpace == NULL) {
+ if (!pColorSpace) {
return;
}
FX_ARGB background = 0;
@@ -864,7 +864,7 @@ void CPDF_RenderStatus::DrawShading(CPDF_ShadingPattern* pPattern,
CFX_Matrix FinalMatrix = *pMatrix;
FinalMatrix.Concat(*buffer.GetMatrix());
CFX_DIBitmap* pBitmap = buffer.GetBitmap();
- if (pBitmap->GetBuffer() == NULL) {
+ if (!pBitmap->GetBuffer()) {
return;
}
pBitmap->Clear(background);
@@ -1121,7 +1121,7 @@ void CPDF_RenderStatus::DrawTilingPattern(CPDF_TilingPattern* pPattern,
m_pContext->m_pDocument, m_pContext->m_pPageCache, pPattern,
pObj2Device, width, height, m_Options.m_Flags);
}
- if (pPatternBitmap == NULL) {
+ if (!pPatternBitmap) {
m_pDevice->RestoreState();
return;
}
@@ -1185,7 +1185,7 @@ void CPDF_RenderStatus::DrawPathWithPattern(CPDF_PathObject* pPathObj,
CPDF_Color* pColor,
FX_BOOL bStroke) {
CPDF_Pattern* pattern = pColor->GetPattern();
- if (pattern == NULL) {
+ if (!pattern) {
return;
}
if (pattern->m_PatternType == PATTERN_TILING) {
diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render_text.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render_text.cpp
index 774e749322..05a5e040e3 100644
--- a/core/src/fpdfapi/fpdf_render/fpdf_render_text.cpp
+++ b/core/src/fpdfapi/fpdf_render/fpdf_render_text.cpp
@@ -163,11 +163,11 @@ CFX_GlyphBitmap* CPDF_Type3Cache::RenderGlyph(CPDF_Type3Glyphs* pSize,
} else {
}
}
- if (pResBitmap == NULL) {
+ if (!pResBitmap) {
image_matrix.Scale(retinaScaleX, retinaScaleY);
pResBitmap = pBitmap->TransformTo(&image_matrix, left, top);
}
- if (pResBitmap == NULL) {
+ if (!pResBitmap) {
return NULL;
}
CFX_GlyphBitmap* pGlyph = new CFX_GlyphBitmap;
@@ -212,7 +212,7 @@ FX_BOOL CPDF_RenderStatus::ProcessText(const CPDF_TextObject* textobj,
break;
case 1:
case 5:
- if (pFont->GetFace() == NULL &&
+ if (!pFont->GetFace() &&
!(pFont->GetSubstFont()->m_SubstFlags & FXFONT_SUBST_GLYPHPATH)) {
bFill = TRUE;
} else {
@@ -221,7 +221,7 @@ FX_BOOL CPDF_RenderStatus::ProcessText(const CPDF_TextObject* textobj,
break;
case 2:
case 6:
- if (pFont->GetFace() == NULL &&
+ if (!pFont->GetFace() &&
!(pFont->GetSubstFont()->m_SubstFlags & FXFONT_SUBST_GLYPHPATH)) {
bFill = TRUE;
} else {
@@ -299,21 +299,21 @@ FX_BOOL CPDF_RenderStatus::ProcessText(const CPDF_TextObject* textobj,
pFont, font_size, &text_matrix, fill_argb, &m_Options);
}
CPDF_Type3Cache* CPDF_RenderStatus::GetCachedType3(CPDF_Type3Font* pFont) {
- if (pFont->m_pDocument == NULL) {
+ if (!pFont->m_pDocument) {
return NULL;
}
pFont->m_pDocument->GetPageData()->GetFont(pFont->GetFontDict(), FALSE);
return pFont->m_pDocument->GetRenderData()->GetCachedType3(pFont);
}
static void ReleaseCachedType3(CPDF_Type3Font* pFont) {
- if (pFont->m_pDocument == NULL) {
+ if (!pFont->m_pDocument) {
return;
}
pFont->m_pDocument->GetRenderData()->ReleaseCachedType3(pFont);
pFont->m_pDocument->GetPageData()->ReleaseFont(pFont->GetFontDict());
}
FX_BOOL CPDF_Type3Char::LoadBitmap(CPDF_RenderContext* pContext) {
- if (m_pBitmap || m_pForm == NULL) {
+ if (m_pBitmap || !m_pForm) {
return TRUE;
}
if (m_pForm->CountObjects() == 1 && !m_bColored) {
@@ -383,7 +383,7 @@ FX_BOOL CPDF_RenderStatus::ProcessType3Text(const CPDF_TextObject* textobj,
continue;
}
CPDF_Type3Char* pType3Char = pType3Font->LoadChar(charcode);
- if (pType3Char == NULL) {
+ if (!pType3Char) {
continue;
}
CFX_Matrix matrix = char_matrix;
@@ -394,7 +394,7 @@ FX_BOOL CPDF_RenderStatus::ProcessType3Text(const CPDF_TextObject* textobj,
if (pGlyphAndPos) {
for (int i = 0; i < iChar; i++) {
FXTEXT_GLYPHPOS& glyph = pGlyphAndPos[i];
- if (glyph.m_pGlyph == NULL) {
+ if (!glyph.m_pGlyph) {
continue;
}
m_pDevice->SetBitMask(&glyph.m_pGlyph->m_Bitmap,
@@ -452,7 +452,7 @@ FX_BOOL CPDF_RenderStatus::ProcessType3Text(const CPDF_TextObject* textobj,
CPDF_Type3Cache* pCache = GetCachedType3(pType3Font);
refTypeCache.m_dwCount++;
CFX_GlyphBitmap* pBitmap = pCache->LoadGlyph(charcode, &matrix, sa, sd);
- if (pBitmap == NULL) {
+ if (!pBitmap) {
continue;
}
int origin_x = FXSYS_round(matrix.e);
@@ -491,7 +491,7 @@ FX_BOOL CPDF_RenderStatus::ProcessType3Text(const CPDF_TextObject* textobj,
bitmap.Clear(0);
for (int iChar = 0; iChar < textobj->m_nChars; iChar++) {
FXTEXT_GLYPHPOS& glyph = pGlyphAndPos[iChar];
- if (glyph.m_pGlyph == NULL) {
+ if (!glyph.m_pGlyph) {
continue;
}
bitmap.TransferBitmap(
@@ -557,7 +557,7 @@ void CPDF_CharPosList::Load(int nChars,
charpos.m_OriginX = iChar ? pCharPos[iChar - 1] : 0;
charpos.m_OriginY = 0;
charpos.m_bGlyphAdjust = FALSE;
- if (pCIDFont == NULL) {
+ if (!pCIDFont) {
continue;
}
FX_WORD CID = pCIDFont->CIDFromCharCode(CharCode);
@@ -762,7 +762,7 @@ void CPDF_RenderStatus::DrawTextPathWithPattern(const CPDF_TextObject* textobj,
FXTEXT_CHARPOS& charpos = CharPosList.m_pCharPos[i];
const CFX_PathData* pPath = pFaceCache->LoadGlyphPath(
&pFont->m_Font, charpos.m_GlyphIndex, charpos.m_FontCharWidth);
- if (pPath == NULL) {
+ if (!pPath) {
continue;
}
CPDF_PathObject path;
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);
diff --git a/core/src/fpdftext/fpdf_text.cpp b/core/src/fpdftext/fpdf_text.cpp
index 9a967e62fd..1e56bf901d 100644
--- a/core/src/fpdftext/fpdf_text.cpp
+++ b/core/src/fpdftext/fpdf_text.cpp
@@ -168,7 +168,7 @@ CTextBaseLine* CTextPage::InsertTextBox(CTextBaseLine* pBaseLine,
if (str.GetLength() == 0) {
return NULL;
}
- if (pBaseLine == NULL) {
+ if (!pBaseLine) {
int i;
for (i = 0; i < m_BaseLines.GetSize(); i++) {
CTextBaseLine* pExistLine = m_BaseLines.GetAt(i);
@@ -180,7 +180,7 @@ CTextBaseLine* CTextPage::InsertTextBox(CTextBaseLine* pBaseLine,
break;
}
}
- if (pBaseLine == NULL) {
+ if (!pBaseLine) {
pBaseLine = new CTextBaseLine;
pBaseLine->m_BaseLine = basey;
m_BaseLines.InsertAt(i, pBaseLine);
@@ -448,17 +448,17 @@ void CTextPage::FindColumns() {
for (int j = 0; j < pBaseLine->m_TextList.GetSize(); j++) {
CTextBox* pTextBox = pBaseLine->m_TextList.GetAt(j);
CTextColumn* pColumn = FindColumn(pTextBox->m_Right);
- if (pColumn == NULL) {
+ if (pColumn) {
+ pColumn->m_AvgPos =
+ (pColumn->m_Count * pColumn->m_AvgPos + pTextBox->m_Right) /
+ (pColumn->m_Count + 1);
+ pColumn->m_Count++;
+ } else {
pColumn = new CTextColumn;
pColumn->m_Count = 1;
pColumn->m_AvgPos = pTextBox->m_Right;
pColumn->m_TextPos = -1;
m_TextColumns.Add(pColumn);
- } else {
- pColumn->m_AvgPos =
- (pColumn->m_Count * pColumn->m_AvgPos + pTextBox->m_Right) /
- (pColumn->m_Count + 1);
- pColumn->m_Count++;
}
}
}
@@ -726,7 +726,7 @@ void PDF_GetPageText_Unicode(CFX_WideStringArray& lines,
int iMinWidth,
FX_DWORD flags) {
lines.RemoveAll();
- if (pPage == NULL) {
+ if (!pPage) {
return;
}
CPDF_Page page;
diff --git a/core/src/fpdftext/fpdf_text_int.cpp b/core/src/fpdftext/fpdf_text_int.cpp
index 8a359fe9af..1e6d54d133 100644
--- a/core/src/fpdftext/fpdf_text_int.cpp
+++ b/core/src/fpdftext/fpdf_text_int.cpp
@@ -2464,12 +2464,12 @@ FX_BOOL CPDF_TextPageFind::ExtractSubString(CFX_WideString& rString,
const FX_WCHAR* lpszFullString,
int iSubString,
FX_WCHAR chSep) {
- if (lpszFullString == NULL) {
+ if (!lpszFullString) {
return FALSE;
}
while (iSubString--) {
lpszFullString = FXSYS_wcschr(lpszFullString, chSep);
- if (lpszFullString == NULL) {
+ if (!lpszFullString) {
rString.Empty();
return FALSE;
}
@@ -2479,8 +2479,8 @@ FX_BOOL CPDF_TextPageFind::ExtractSubString(CFX_WideString& rString,
}
}
const FX_WCHAR* lpchEnd = FXSYS_wcschr(lpszFullString, chSep);
- int nLen = (lpchEnd == NULL) ? (int)FXSYS_wcslen(lpszFullString)
- : (int)(lpchEnd - lpszFullString);
+ int nLen = lpchEnd ? (int)(lpchEnd - lpszFullString)
+ : (int)FXSYS_wcslen(lpszFullString);
ASSERT(nLen >= 0);
FXSYS_memcpy(rString.GetBuffer(nLen), lpszFullString,
nLen * sizeof(FX_WCHAR));
diff --git a/core/src/fpdftext/fpdf_text_search.cpp b/core/src/fpdftext/fpdf_text_search.cpp
index 43486c7ab8..80bf5ec99a 100644
--- a/core/src/fpdftext/fpdf_text_search.cpp
+++ b/core/src/fpdftext/fpdf_text_search.cpp
@@ -303,13 +303,8 @@ void GetTextStream_Unicode(CFX_WideTextBuf& buffer,
FX_POSITION pos = pPage->GetFirstObjectPosition();
while (pos) {
CPDF_PageObject* pObject = pPage->GetNextObject(pos);
- if (pObject == NULL) {
- continue;
- }
- if (pObject->m_Type != PDFPAGE_TEXT) {
- continue;
- }
- textstream.ProcessObject((CPDF_TextObject*)pObject, FALSE);
+ if (pObject && pObject->m_Type == PDFPAGE_TEXT)
+ textstream.ProcessObject((CPDF_TextObject*)pObject, FALSE);
}
}
CFX_WideString PDF_GetFirstTextLine_Unicode(CPDF_Document* pDoc,
diff --git a/core/src/fxcodec/codec/fx_codec.cpp b/core/src/fxcodec/codec/fx_codec.cpp
index a52dd8a496..5143f76f88 100644
--- a/core/src/fxcodec/codec/fx_codec.cpp
+++ b/core/src/fxcodec/codec/fx_codec.cpp
@@ -175,7 +175,7 @@ extern "C" double FXstrtod(const char* nptr, char** endptr) {
const char* exp_ptr = NULL;
int e_number = 0, e_signal = 0, e_point = 0, is_negative = 0;
int exp_ret = 0, exp_sig = 1, fra_ret = 0, fra_count = 0, fra_base = 1;
- if (nptr == NULL) {
+ if (!nptr) {
return 0.0;
}
for (;; ptr++) {
diff --git a/core/src/fxcodec/codec/fx_codec_flate.cpp b/core/src/fxcodec/codec/fx_codec_flate.cpp
index f9959589b3..b293781318 100644
--- a/core/src/fxcodec/codec/fx_codec_flate.cpp
+++ b/core/src/fxcodec/codec/fx_codec_flate.cpp
@@ -34,7 +34,7 @@ static void FPDFAPI_FlateCompress(unsigned char* dest_buf,
void* FPDFAPI_FlateInit(void* (*alloc_func)(void*, unsigned int, unsigned int),
void (*free_func)(void*, void*)) {
z_stream* p = (z_stream*)alloc_func(0, 1, sizeof(z_stream));
- if (p == NULL) {
+ if (!p) {
return NULL;
}
FXSYS_memset(p, 0, sizeof(z_stream));
@@ -835,7 +835,7 @@ FX_BOOL CCodec_FlateScanlineDecoder::v_Rewind() {
FPDFAPI_FlateEnd(m_pFlate);
}
m_pFlate = FPDFAPI_FlateInit(my_alloc_func, my_free_func);
- if (m_pFlate == NULL) {
+ if (!m_pFlate) {
return FALSE;
}
FPDFAPI_FlateInput(m_pFlate, m_SrcBuf, m_SrcSize);
diff --git a/core/src/fxcodec/codec/fx_codec_icc.cpp b/core/src/fxcodec/codec/fx_codec_icc.cpp
index 862872010b..7ae59a6510 100644
--- a/core/src/fxcodec/codec/fx_codec_icc.cpp
+++ b/core/src/fxcodec/codec/fx_codec_icc.cpp
@@ -102,16 +102,16 @@ void* IccLib_CreateTransform(const unsigned char* pSrcProfileData,
CLcmsCmm* pCmm = NULL;
nSrcComponents = 0;
srcProfile = cmsOpenProfileFromMem((void*)pSrcProfileData, dwSrcProfileSize);
- if (srcProfile == NULL) {
+ if (!srcProfile) {
return NULL;
}
- if (pDstProfileData == NULL && dwDstProfileSize == 0 && nDstComponents == 3) {
+ if (!pDstProfileData && dwDstProfileSize == 0 && nDstComponents == 3) {
dstProfile = cmsCreate_sRGBProfile();
} else {
dstProfile =
cmsOpenProfileFromMem((void*)pDstProfileData, dwDstProfileSize);
}
- if (dstProfile == NULL) {
+ if (!dstProfile) {
cmsCloseProfile(srcProfile);
return NULL;
}
@@ -153,7 +153,7 @@ void* IccLib_CreateTransform(const unsigned char* pSrcProfileData,
default:
break;
}
- if (hTransform == NULL) {
+ if (!hTransform) {
cmsCloseProfile(srcProfile);
cmsCloseProfile(dstProfile);
return NULL;
@@ -176,7 +176,7 @@ void* IccLib_CreateTransform_sRGB(const unsigned char* pProfileData,
0, 3, intent, dwSrcFormat);
}
void IccLib_DestroyTransform(void* pTransform) {
- if (pTransform == NULL) {
+ if (!pTransform) {
return;
}
cmsDeleteTransform(((CLcmsCmm*)pTransform)->m_hTransform);
@@ -186,7 +186,7 @@ void IccLib_Translate(void* pTransform,
FX_DWORD nSrcComponents,
FX_FLOAT* pSrcValues,
FX_FLOAT* pDestValues) {
- if (pTransform == NULL) {
+ if (!pTransform) {
return;
}
CLcmsCmm* p = (CLcmsCmm*)pTransform;
@@ -242,7 +242,7 @@ void* CreateProfile_Gray(double gamma) {
return NULL;
}
cmsToneCurve* curve = cmsBuildGamma(NULL, gamma);
- if (curve == NULL) {
+ if (!curve) {
return NULL;
}
void* profile = cmsCreateGrayProfile(D50, curve);
@@ -250,7 +250,7 @@ void* CreateProfile_Gray(double gamma) {
return profile;
}
ICodec_IccModule::IccCS GetProfileCSFromHandle(void* pProfile) {
- if (pProfile == NULL) {
+ if (!pProfile) {
return ICodec_IccModule::IccCS_Unknown;
}
switch (cmsGetColorSpace(pProfile)) {
@@ -286,7 +286,7 @@ ICodec_IccModule::IccCS CCodec_IccModule::GetProfileCS(
ICodec_IccModule::IccCS cs;
cmsHPROFILE hProfile =
cmsOpenProfileFromMem((void*)pProfileData, dwProfileSize);
- if (hProfile == NULL) {
+ if (!hProfile) {
return IccCS_Unknown;
}
cs = GetProfileCSFromHandle(hProfile);
@@ -296,7 +296,7 @@ ICodec_IccModule::IccCS CCodec_IccModule::GetProfileCS(
return cs;
}
ICodec_IccModule::IccCS CCodec_IccModule::GetProfileCS(IFX_FileRead* pFile) {
- if (pFile == NULL) {
+ if (!pFile) {
return IccCS_Unknown;
}
ICodec_IccModule::IccCS cs;
@@ -476,11 +476,11 @@ void* CCodec_IccModule::CreateTransform(
ASSERT(pInputParam && pOutputParam);
CFX_ByteStringKey key;
void* pInputProfile = CreateProfile(pInputParam, Icc_CLASS_INPUT, &key);
- if (pInputProfile == NULL) {
+ if (!pInputProfile) {
return NULL;
}
void* pOutputProfile = CreateProfile(pOutputParam, Icc_CLASS_OUTPUT, &key);
- if (pOutputProfile == NULL) {
+ if (!pOutputProfile) {
return NULL;
}
FX_DWORD dwInputProfileType =
diff --git a/core/src/fxcodec/codec/fx_codec_jpeg.cpp b/core/src/fxcodec/codec/fx_codec_jpeg.cpp
index 0bb9e8aa26..4f0494691c 100644
--- a/core/src/fxcodec/codec/fx_codec_jpeg.cpp
+++ b/core/src/fxcodec/codec/fx_codec_jpeg.cpp
@@ -82,7 +82,7 @@ static void _error_do_nothing2(j_common_ptr cinfo, char*) {}
static FX_BOOL _JpegEmbedIccProfile(j_compress_ptr cinfo,
const uint8_t* icc_buf_ptr,
FX_DWORD icc_length) {
- if (icc_buf_ptr == NULL || icc_length == 0) {
+ if (!icc_buf_ptr || icc_length == 0) {
return FALSE;
}
FX_DWORD icc_segment_size = (JPEG_MARKER_MAXSIZE - 2 - JPEG_OVERHEAD_LEN);
@@ -516,7 +516,7 @@ ICodec_ScanlineDecoder* CCodec_JpegModule::CreateDecoder(
int height,
int nComps,
FX_BOOL ColorTransform) {
- if (src_buf == NULL || src_size == 0) {
+ if (!src_buf || src_size == 0) {
return NULL;
}
CCodec_JpegDecoder* pDecoder = new CCodec_JpegDecoder;
@@ -546,10 +546,9 @@ FX_BOOL CCodec_JpegModule::Encode(const CFX_DIBSource* pSource,
int quality,
const uint8_t* icc_buf,
FX_DWORD icc_length) {
- if (pSource->GetBPP() < 8 || pSource->GetPalette()) {
- ASSERT(pSource->GetBPP() >= 8 && pSource->GetPalette() == NULL);
+ if (pSource->GetBPP() < 8 || pSource->GetPalette())
return FALSE;
- }
+
_JpegEncode(pSource, dest_buf, dest_size, quality, icc_buf, icc_length);
return TRUE;
}
diff --git a/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp b/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp
index cf017ca17a..21c1e441f0 100644
--- a/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp
+++ b/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp
@@ -438,7 +438,7 @@ void color_apply_icc_profile(opj_image_t* image) {
int max;
cmsHPROFILE in_prof =
cmsOpenProfileFromMem(image->icc_profile_buf, image->icc_profile_len);
- if (in_prof == NULL) {
+ if (!in_prof) {
return;
}
cmsColorSpaceSignature out_space = cmsGetColorSpace(in_prof);
@@ -479,7 +479,7 @@ void color_apply_icc_profile(opj_image_t* image) {
cmsCreateTransform(in_prof, in_type, out_prof, out_type, intent, 0);
cmsCloseProfile(in_prof);
cmsCloseProfile(out_prof);
- if (transform == NULL) {
+ if (!transform) {
image->color_space = oldspace;
return;
}
@@ -597,7 +597,7 @@ void color_apply_conversion(opj_image_t* image) {
INTENT_PERCEPTUAL, 0);
cmsCloseProfile(in);
cmsCloseProfile(out);
- if (transform == NULL) {
+ if (!transform) {
return;
}
prec0 = (double)image->comps[0].prec;
@@ -708,7 +708,7 @@ FX_BOOL CJPX_Decoder::Init(const unsigned char* src_data, FX_DWORD src_size) {
DecodeData srcData(const_cast<unsigned char*>(src_data), src_size);
l_stream = fx_opj_stream_create_memory_stream(&srcData,
OPJ_J2K_STREAM_CHUNK_SIZE, 1);
- if (l_stream == NULL) {
+ if (!l_stream) {
return FALSE;
}
opj_dparameters_t parameters;
diff --git a/core/src/fxcrt/fx_basic_array.cpp b/core/src/fxcrt/fx_basic_array.cpp
index ccb80eba23..9c4aa0fa35 100644
--- a/core/src/fxcrt/fx_basic_array.cpp
+++ b/core/src/fxcrt/fx_basic_array.cpp
@@ -26,7 +26,7 @@ FX_BOOL CFX_BasicArray::SetSize(int nNewSize) {
return 0 == nNewSize;
}
- if (m_pData == NULL) {
+ if (!m_pData) {
pdfium::base::CheckedNumeric<int> totalSize = nNewSize;
totalSize *= m_nUnitSize;
if (!totalSize.IsValid()) {
@@ -49,7 +49,7 @@ FX_BOOL CFX_BasicArray::SetSize(int nNewSize) {
return FALSE;
}
uint8_t* pNewData = FX_Realloc(uint8_t, m_pData, totalSize.ValueOrDie());
- if (pNewData == NULL) {
+ if (!pNewData) {
return FALSE;
}
FXSYS_memset(pNewData + m_nSize * m_nUnitSize, 0,
@@ -115,7 +115,7 @@ FX_BOOL CFX_BasicArray::RemoveAt(int nIndex, int nCount) {
}
FX_BOOL CFX_BasicArray::InsertAt(int nStartIndex,
const CFX_BasicArray* pNewArray) {
- if (pNewArray == NULL) {
+ if (!pNewArray) {
return FALSE;
}
if (pNewArray->m_nSize == 0) {
@@ -129,7 +129,7 @@ FX_BOOL CFX_BasicArray::InsertAt(int nStartIndex,
return TRUE;
}
const void* CFX_BasicArray::GetDataPtr(int index) const {
- if (index < 0 || index >= m_nSize || m_pData == NULL) {
+ if (index < 0 || index >= m_nSize || !m_pData) {
return NULL;
}
return m_pData + index * m_nUnitSize;
@@ -159,16 +159,14 @@ static void _ClearIndex(int level, int size, void** pIndex) {
FX_Free(pIndex);
return;
}
- for (int i = 0; i < size; i++) {
- if (pIndex[i] == NULL) {
- continue;
- }
- _ClearIndex(level - 1, size, (void**)pIndex[i]);
+ for (int i = 0; i < size; ++i) {
+ if (pIndex[i])
+ _ClearIndex(level - 1, size, (void**)pIndex[i]);
}
FX_Free(pIndex);
}
void CFX_BaseSegmentedArray::RemoveAll() {
- if (m_pIndex == NULL) {
+ if (!m_pIndex) {
return;
}
_ClearIndex(m_IndexDepth, m_IndexSize, (void**)m_pIndex);
@@ -181,7 +179,7 @@ void* CFX_BaseSegmentedArray::Add() {
return GetAt(m_DataSize++);
}
void* pSegment = FX_Alloc2D(uint8_t, m_UnitSize, m_SegmentSize);
- if (m_pIndex == NULL) {
+ if (!m_pIndex) {
m_pIndex = pSegment;
m_DataSize++;
return pSegment;
@@ -217,7 +215,7 @@ void* CFX_BaseSegmentedArray::Add() {
}
void** pSpot = (void**)m_pIndex;
for (i = 1; i < m_IndexDepth; i++) {
- if (pSpot[seg_index / tree_size] == NULL) {
+ if (!pSpot[seg_index / tree_size]) {
pSpot[seg_index / tree_size] = FX_Alloc(void*, m_IndexSize);
}
pSpot = (void**)pSpot[seg_index / tree_size];
@@ -281,7 +279,7 @@ void* CFX_BaseSegmentedArray::IterateIndex(int level,
return IterateSegment((const uint8_t*)pIndex, count, callback, param);
}
for (int i = 0; i < m_IndexSize; i++) {
- if (pIndex[i] == NULL) {
+ if (!pIndex[i]) {
continue;
}
void* p =
@@ -295,7 +293,7 @@ void* CFX_BaseSegmentedArray::IterateIndex(int level,
void* CFX_BaseSegmentedArray::Iterate(FX_BOOL (*callback)(void* param,
void* pData),
void* param) const {
- if (m_pIndex == NULL) {
+ if (!m_pIndex) {
return NULL;
}
int start = 0;
diff --git a/core/src/fxcrt/fx_basic_bstring.cpp b/core/src/fxcrt/fx_basic_bstring.cpp
index cd4770282a..e0d1146068 100644
--- a/core/src/fxcrt/fx_basic_bstring.cpp
+++ b/core/src/fxcrt/fx_basic_bstring.cpp
@@ -108,7 +108,7 @@ CFX_ByteString::CFX_ByteString(char ch) {
}
}
CFX_ByteString::CFX_ByteString(const CFX_ByteString& stringSrc) {
- if (stringSrc.m_pData == NULL) {
+ if (!stringSrc.m_pData) {
m_pData = NULL;
return;
}
@@ -143,7 +143,7 @@ CFX_ByteString::CFX_ByteString(const CFX_ByteStringC& str1,
}
}
const CFX_ByteString& CFX_ByteString::operator=(const FX_CHAR* lpsz) {
- if (lpsz == NULL || lpsz[0] == 0) {
+ if (!lpsz || lpsz[0] == 0) {
Empty();
} else {
AssignCopy(FXSYS_strlen(lpsz), lpsz);
@@ -203,7 +203,7 @@ const CFX_ByteString& CFX_ByteString::operator+=(char ch) {
return *this;
}
const CFX_ByteString& CFX_ByteString::operator+=(const CFX_ByteString& string) {
- if (string.m_pData == NULL) {
+ if (!string.m_pData) {
return *this;
}
ConcatInPlace(string.m_pData->m_nDataLength, string.m_pData->m_String);
@@ -228,7 +228,7 @@ bool CFX_ByteString::Equal(const char* ptr) const {
FXSYS_memcmp(ptr, m_pData->m_String, m_pData->m_nDataLength) == 0;
}
bool CFX_ByteString::Equal(const CFX_ByteStringC& str) const {
- if (m_pData == NULL) {
+ if (!m_pData) {
return str.IsEmpty();
}
return m_pData->m_nDataLength == str.GetLength() &&
@@ -252,7 +252,7 @@ void CFX_ByteString::Empty() {
}
}
bool CFX_ByteString::EqualNoCase(const CFX_ByteStringC& str) const {
- if (m_pData == NULL) {
+ if (!m_pData) {
return str.IsEmpty();
}
FX_STRSIZE len = str.GetLength();
@@ -288,7 +288,7 @@ void CFX_ByteString::AssignCopy(FX_STRSIZE nSrcLen,
m_pData->m_String[nSrcLen] = 0;
}
void CFX_ByteString::CopyBeforeWrite() {
- if (m_pData == NULL || m_pData->m_nRefs <= 1) {
+ if (!m_pData || m_pData->m_nRefs <= 1) {
return;
}
StringData* pData = m_pData;
@@ -307,7 +307,7 @@ void CFX_ByteString::AllocBeforeWrite(FX_STRSIZE nLen) {
m_pData = StringData::Create(nLen);
}
void CFX_ByteString::ReleaseBuffer(FX_STRSIZE nNewLength) {
- if (m_pData == NULL) {
+ if (!m_pData) {
return;
}
CopyBeforeWrite();
@@ -327,14 +327,14 @@ void CFX_ByteString::Reserve(FX_STRSIZE len) {
ReleaseBuffer(GetLength());
}
FX_CHAR* CFX_ByteString::GetBuffer(FX_STRSIZE nMinBufLength) {
- if (m_pData == NULL && nMinBufLength == 0) {
+ if (!m_pData && nMinBufLength == 0) {
return NULL;
}
if (m_pData && m_pData->m_nRefs <= 1 &&
m_pData->m_nAllocLength >= nMinBufLength) {
return m_pData->m_String;
}
- if (m_pData == NULL) {
+ if (!m_pData) {
m_pData = StringData::Create(nMinBufLength);
if (!m_pData) {
return NULL;
@@ -358,7 +358,7 @@ FX_CHAR* CFX_ByteString::GetBuffer(FX_STRSIZE nMinBufLength) {
return m_pData->m_String;
}
FX_STRSIZE CFX_ByteString::Delete(FX_STRSIZE nIndex, FX_STRSIZE nCount) {
- if (m_pData == NULL) {
+ if (!m_pData) {
return 0;
}
if (nIndex < 0) {
@@ -381,10 +381,10 @@ FX_STRSIZE CFX_ByteString::Delete(FX_STRSIZE nIndex, FX_STRSIZE nCount) {
}
void CFX_ByteString::ConcatInPlace(FX_STRSIZE nSrcLen,
const FX_CHAR* lpszSrcData) {
- if (nSrcLen == 0 || lpszSrcData == NULL) {
+ if (nSrcLen == 0 || !lpszSrcData) {
return;
}
- if (m_pData == NULL) {
+ if (!m_pData) {
m_pData = StringData::Create(nSrcLen);
if (!m_pData) {
return;
@@ -420,7 +420,7 @@ void CFX_ByteString::ConcatCopy(FX_STRSIZE nSrc1Len,
pOldData->Release();
}
CFX_ByteString CFX_ByteString::Mid(FX_STRSIZE nFirst) const {
- if (m_pData == NULL) {
+ if (!m_pData) {
return CFX_ByteString();
}
return Mid(nFirst, m_pData->m_nDataLength - nFirst);
@@ -453,7 +453,7 @@ void CFX_ByteString::AllocCopy(CFX_ByteString& dest,
if (nCopyLen == 0 || nCopyLen < 0) {
return;
}
- ASSERT(dest.m_pData == NULL);
+ ASSERT(!dest.m_pData);
dest.m_pData = StringData::Create(nCopyLen);
if (dest.m_pData) {
FXSYS_memcpy(dest.m_pData->m_String, m_pData->m_String + nCopyIndex,
@@ -558,48 +558,48 @@ void CFX_ByteString::FormatV(const FX_CHAR* lpszFormat, va_list argList) {
break;
case 's': {
const FX_CHAR* pstrNextArg = va_arg(argList, const FX_CHAR*);
- if (pstrNextArg == NULL) {
- nItemLen = 6;
- } else {
+ if (pstrNextArg) {
nItemLen = FXSYS_strlen(pstrNextArg);
if (nItemLen < 1) {
nItemLen = 1;
}
+ } else {
+ nItemLen = 6;
}
} break;
case 'S': {
FX_WCHAR* pstrNextArg = va_arg(argList, FX_WCHAR*);
- if (pstrNextArg == NULL) {
- nItemLen = 6;
- } else {
+ if (pstrNextArg) {
nItemLen = FXSYS_wcslen(pstrNextArg);
if (nItemLen < 1) {
nItemLen = 1;
}
+ } else {
+ nItemLen = 6;
}
} break;
case 's' | FORCE_ANSI:
case 'S' | FORCE_ANSI: {
const FX_CHAR* pstrNextArg = va_arg(argList, const FX_CHAR*);
- if (pstrNextArg == NULL) {
- nItemLen = 6;
- } else {
+ if (pstrNextArg) {
nItemLen = FXSYS_strlen(pstrNextArg);
if (nItemLen < 1) {
nItemLen = 1;
}
+ } else {
+ nItemLen = 6;
}
} break;
case 's' | FORCE_UNICODE:
case 'S' | FORCE_UNICODE: {
FX_WCHAR* pstrNextArg = va_arg(argList, FX_WCHAR*);
- if (pstrNextArg == NULL) {
- nItemLen = 6;
- } else {
+ if (pstrNextArg) {
nItemLen = FXSYS_wcslen(pstrNextArg);
if (nItemLen < 1) {
nItemLen = 1;
}
+ } else {
+ nItemLen = 6;
}
} break;
}
@@ -691,7 +691,7 @@ FX_STRSIZE CFX_ByteString::Insert(FX_STRSIZE nIndex, FX_CHAR ch) {
nIndex = nNewLength;
}
nNewLength++;
- if (m_pData == NULL || m_pData->m_nAllocLength < nNewLength) {
+ if (!m_pData || m_pData->m_nAllocLength < nNewLength) {
StringData* pOldData = m_pData;
const FX_CHAR* pstr = m_pData->m_String;
m_pData = StringData::Create(nNewLength);
@@ -712,7 +712,7 @@ FX_STRSIZE CFX_ByteString::Insert(FX_STRSIZE nIndex, FX_CHAR ch) {
return nNewLength;
}
CFX_ByteString CFX_ByteString::Right(FX_STRSIZE nCount) const {
- if (m_pData == NULL) {
+ if (!m_pData) {
return CFX_ByteString();
}
if (nCount < 0) {
@@ -726,7 +726,7 @@ CFX_ByteString CFX_ByteString::Right(FX_STRSIZE nCount) const {
return dest;
}
CFX_ByteString CFX_ByteString::Left(FX_STRSIZE nCount) const {
- if (m_pData == NULL) {
+ if (!m_pData) {
return CFX_ByteString();
}
if (nCount < 0) {
@@ -740,7 +740,7 @@ CFX_ByteString CFX_ByteString::Left(FX_STRSIZE nCount) const {
return dest;
}
FX_STRSIZE CFX_ByteString::Find(FX_CHAR ch, FX_STRSIZE nStart) const {
- if (m_pData == NULL) {
+ if (!m_pData) {
return -1;
}
FX_STRSIZE nLength = m_pData->m_nDataLength;
@@ -748,10 +748,10 @@ FX_STRSIZE CFX_ByteString::Find(FX_CHAR ch, FX_STRSIZE nStart) const {
return -1;
}
const FX_CHAR* lpsz = FXSYS_strchr(m_pData->m_String + nStart, ch);
- return (lpsz == NULL) ? -1 : (int)(lpsz - m_pData->m_String);
+ return lpsz ? (int)(lpsz - m_pData->m_String) : -1;
}
FX_STRSIZE CFX_ByteString::ReverseFind(FX_CHAR ch) const {
- if (m_pData == NULL) {
+ if (!m_pData) {
return -1;
}
FX_STRSIZE nLength = m_pData->m_nDataLength;
@@ -788,7 +788,7 @@ const FX_CHAR* FX_strstr(const FX_CHAR* str1,
}
FX_STRSIZE CFX_ByteString::Find(const CFX_ByteStringC& lpszSub,
FX_STRSIZE nStart) const {
- if (m_pData == NULL) {
+ if (!m_pData) {
return -1;
}
FX_STRSIZE nLength = m_pData->m_nDataLength;
@@ -798,10 +798,10 @@ FX_STRSIZE CFX_ByteString::Find(const CFX_ByteStringC& lpszSub,
const FX_CHAR* lpsz =
FX_strstr(m_pData->m_String + nStart, m_pData->m_nDataLength - nStart,
lpszSub.GetCStr(), lpszSub.GetLength());
- return (lpsz == NULL) ? -1 : (int)(lpsz - m_pData->m_String);
+ return lpsz ? (int)(lpsz - m_pData->m_String) : -1;
}
void CFX_ByteString::MakeLower() {
- if (m_pData == NULL) {
+ if (!m_pData) {
return;
}
CopyBeforeWrite();
@@ -811,7 +811,7 @@ void CFX_ByteString::MakeLower() {
FXSYS_strlwr(m_pData->m_String);
}
void CFX_ByteString::MakeUpper() {
- if (m_pData == NULL) {
+ if (!m_pData) {
return;
}
CopyBeforeWrite();
@@ -821,7 +821,7 @@ void CFX_ByteString::MakeUpper() {
FXSYS_strupr(m_pData->m_String);
}
FX_STRSIZE CFX_ByteString::Remove(FX_CHAR chRemove) {
- if (m_pData == NULL) {
+ if (!m_pData) {
return 0;
}
CopyBeforeWrite();
@@ -845,7 +845,7 @@ FX_STRSIZE CFX_ByteString::Remove(FX_CHAR chRemove) {
}
FX_STRSIZE CFX_ByteString::Replace(const CFX_ByteStringC& lpszOld,
const CFX_ByteStringC& lpszNew) {
- if (m_pData == NULL) {
+ if (!m_pData) {
return 0;
}
if (lpszOld.IsEmpty()) {
@@ -859,7 +859,7 @@ FX_STRSIZE CFX_ByteString::Replace(const CFX_ByteStringC& lpszOld,
while (1) {
const FX_CHAR* pTarget = FX_strstr(pStart, (FX_STRSIZE)(pEnd - pStart),
lpszOld.GetCStr(), nSourceLen);
- if (pTarget == NULL) {
+ if (!pTarget) {
break;
}
nCount++;
@@ -895,7 +895,7 @@ FX_STRSIZE CFX_ByteString::Replace(const CFX_ByteStringC& lpszOld,
return nCount;
}
void CFX_ByteString::SetAt(FX_STRSIZE nIndex, FX_CHAR ch) {
- if (m_pData == NULL) {
+ if (!m_pData) {
return;
}
FXSYS_assert(nIndex >= 0);
@@ -924,13 +924,13 @@ CFX_ByteString CFX_ByteString::FromUnicode(const CFX_WideString& str) {
}
void CFX_ByteString::ConvertFrom(const CFX_WideString& str,
CFX_CharMap* pCharMap) {
- if (pCharMap == NULL) {
+ if (!pCharMap) {
pCharMap = CFX_CharMap::GetDefaultMapper();
}
*this = (*pCharMap->m_GetByteString)(pCharMap, str);
}
int CFX_ByteString::Compare(const CFX_ByteStringC& str) const {
- if (m_pData == NULL) {
+ if (!m_pData) {
return str.IsEmpty() ? 0 : -1;
}
int this_len = m_pData->m_nDataLength;
@@ -953,7 +953,7 @@ int CFX_ByteString::Compare(const CFX_ByteStringC& str) const {
return 0;
}
void CFX_ByteString::TrimRight(const CFX_ByteStringC& lpszTargets) {
- if (m_pData == NULL || lpszTargets.IsEmpty()) {
+ if (!m_pData || lpszTargets.IsEmpty()) {
return;
}
CopyBeforeWrite();
@@ -984,7 +984,7 @@ void CFX_ByteString::TrimRight() {
TrimRight("\x09\x0a\x0b\x0c\x0d\x20");
}
void CFX_ByteString::TrimLeft(const CFX_ByteStringC& lpszTargets) {
- if (m_pData == NULL) {
+ if (!m_pData) {
return;
}
if (lpszTargets.IsEmpty()) {
diff --git a/core/src/fxcrt/fx_basic_gcc.cpp b/core/src/fxcrt/fx_basic_gcc.cpp
index c352ee3f81..50499a8dc4 100644
--- a/core/src/fxcrt/fx_basic_gcc.cpp
+++ b/core/src/fxcrt/fx_basic_gcc.cpp
@@ -120,7 +120,7 @@ FX_DWORD FXSYS_GetFullPathName(const FX_CHAR* filename,
FX_CHAR* buf,
FX_CHAR** filepart) {
int srclen = FXSYS_strlen(filename);
- if (buf == NULL || (int)buflen < srclen + 1) {
+ if (!buf || (int)buflen < srclen + 1) {
return srclen + 1;
}
FXSYS_strcpy(buf, filename);
@@ -142,7 +142,7 @@ FXSYS_FILE* FXSYS_wfopen(const FX_WCHAR* filename, const FX_WCHAR* mode) {
CFX_ByteString::FromUnicode(mode));
}
char* FXSYS_strlwr(char* str) {
- if (str == NULL) {
+ if (!str) {
return NULL;
}
char* s = str;
@@ -153,7 +153,7 @@ char* FXSYS_strlwr(char* str) {
return s;
}
char* FXSYS_strupr(char* str) {
- if (str == NULL) {
+ if (!str) {
return NULL;
}
char* s = str;
@@ -164,7 +164,7 @@ char* FXSYS_strupr(char* str) {
return s;
}
FX_WCHAR* FXSYS_wcslwr(FX_WCHAR* str) {
- if (str == NULL) {
+ if (!str) {
return NULL;
}
FX_WCHAR* s = str;
@@ -175,7 +175,7 @@ FX_WCHAR* FXSYS_wcslwr(FX_WCHAR* str) {
return s;
}
FX_WCHAR* FXSYS_wcsupr(FX_WCHAR* str) {
- if (str == NULL) {
+ if (!str) {
return NULL;
}
FX_WCHAR* s = str;
diff --git a/core/src/fxcrt/fx_basic_list.cpp b/core/src/fxcrt/fx_basic_list.cpp
index 292e2a7b53..81173d6a0b 100644
--- a/core/src/fxcrt/fx_basic_list.cpp
+++ b/core/src/fxcrt/fx_basic_list.cpp
@@ -37,7 +37,7 @@ FX_POSITION CFX_PtrList::AddHead(void* newElement) {
return (FX_POSITION)pNewNode;
}
FX_POSITION CFX_PtrList::InsertAfter(FX_POSITION position, void* newElement) {
- if (position == NULL) {
+ if (!position) {
return AddTail(newElement);
}
CNode* pOldNode = (CNode*)position;
@@ -81,7 +81,7 @@ void CFX_PtrList::RemoveAll() {
}
CFX_PtrList::CNode* CFX_PtrList::NewNode(CFX_PtrList::CNode* pPrev,
CFX_PtrList::CNode* pNext) {
- if (m_pNodeFree == NULL) {
+ if (!m_pNodeFree) {
CFX_Plex* pNewBlock =
CFX_Plex::Create(m_pBlocks, m_nBlockSize, sizeof(CNode));
CNode* pNode = (CNode*)pNewBlock->data();
@@ -116,11 +116,7 @@ FX_POSITION CFX_PtrList::FindIndex(int nIndex) const {
}
FX_POSITION CFX_PtrList::Find(void* searchValue, FX_POSITION startAfter) const {
CNode* pNode = (CNode*)startAfter;
- if (pNode == NULL) {
- pNode = m_pNodeHead;
- } else {
- pNode = pNode->pNext;
- }
+ pNode = pNode ? pNode->pNext : m_pNodeHead;
for (; pNode; pNode = pNode->pNext) {
if (pNode->data == searchValue)
return (FX_POSITION)pNode;
diff --git a/core/src/fxcrt/fx_basic_maps.cpp b/core/src/fxcrt/fx_basic_maps.cpp
index f8751ae340..f8a0390163 100644
--- a/core/src/fxcrt/fx_basic_maps.cpp
+++ b/core/src/fxcrt/fx_basic_maps.cpp
@@ -60,7 +60,7 @@ void CFX_MapPtrToPtr::GetNextAssoc(FX_POSITION& rNextPosition,
FX_BOOL CFX_MapPtrToPtr::Lookup(void* key, void*& rValue) const {
FX_DWORD nHash;
CAssoc* pAssoc = GetAssocAt(key, nHash);
- if (pAssoc == NULL) {
+ if (!pAssoc) {
return FALSE;
}
rValue = pAssoc->value;
@@ -69,7 +69,7 @@ FX_BOOL CFX_MapPtrToPtr::Lookup(void* key, void*& rValue) const {
void* CFX_MapPtrToPtr::GetValueAt(void* key) const {
FX_DWORD nHash;
CAssoc* pAssoc = GetAssocAt(key, nHash);
- if (pAssoc == NULL) {
+ if (!pAssoc) {
return NULL;
}
return pAssoc->value;
@@ -78,7 +78,7 @@ void*& CFX_MapPtrToPtr::operator[](void* key) {
FX_DWORD nHash;
CAssoc* pAssoc;
if ((pAssoc = GetAssocAt(key, nHash)) == NULL) {
- if (m_pHashTable == NULL) {
+ if (!m_pHashTable) {
InitHashTable(m_nHashTableSize);
}
pAssoc = NewAssoc();
@@ -91,7 +91,7 @@ void*& CFX_MapPtrToPtr::operator[](void* key) {
CFX_MapPtrToPtr::CAssoc* CFX_MapPtrToPtr::GetAssocAt(void* key,
FX_DWORD& nHash) const {
nHash = HashKey(key) % m_nHashTableSize;
- if (m_pHashTable == NULL) {
+ if (!m_pHashTable) {
return NULL;
}
CAssoc* pAssoc;
@@ -102,7 +102,7 @@ CFX_MapPtrToPtr::CAssoc* CFX_MapPtrToPtr::GetAssocAt(void* key,
return NULL;
}
CFX_MapPtrToPtr::CAssoc* CFX_MapPtrToPtr::NewAssoc() {
- if (m_pFreeList == NULL) {
+ if (!m_pFreeList) {
CFX_Plex* newBlock = CFX_Plex::Create(m_pBlocks, m_nBlockSize,
sizeof(CFX_MapPtrToPtr::CAssoc));
CFX_MapPtrToPtr::CAssoc* pAssoc =
@@ -132,7 +132,7 @@ void CFX_MapPtrToPtr::InitHashTable(FX_DWORD nHashSize, FX_BOOL bAllocNow) {
m_nHashTableSize = nHashSize;
}
FX_BOOL CFX_MapPtrToPtr::RemoveKey(void* key) {
- if (m_pHashTable == NULL) {
+ if (!m_pHashTable) {
return FALSE;
}
CAssoc** ppAssocPrev;
@@ -237,7 +237,7 @@ FX_POSITION CFX_CMapByteStringToPtr::GetStartPosition() const {
void CFX_CMapByteStringToPtr::GetNextAssoc(FX_POSITION& rNextPosition,
CFX_ByteString& rKey,
void*& rValue) const {
- if (rNextPosition == NULL) {
+ if (!rNextPosition) {
return;
}
int index = (int)(uintptr_t)rNextPosition - 1;
@@ -257,7 +257,7 @@ void CFX_CMapByteStringToPtr::GetNextAssoc(FX_POSITION& rNextPosition,
rNextPosition = NULL;
}
void* CFX_CMapByteStringToPtr::GetNextValue(FX_POSITION& rNextPosition) const {
- if (rNextPosition == NULL) {
+ if (!rNextPosition) {
return NULL;
}
int index = (int)(uintptr_t)rNextPosition - 1;
diff --git a/core/src/fxcrt/fx_basic_util.cpp b/core/src/fxcrt/fx_basic_util.cpp
index b4c7064da2..9f32ebe752 100644
--- a/core/src/fxcrt/fx_basic_util.cpp
+++ b/core/src/fxcrt/fx_basic_util.cpp
@@ -20,7 +20,7 @@ CFX_PrivateData::~CFX_PrivateData() {
ClearAll();
}
void FX_PRIVATEDATA::FreeData() {
- if (m_pData == NULL) {
+ if (!m_pData) {
return;
}
if (m_bSelfDestruct) {
@@ -33,7 +33,7 @@ void CFX_PrivateData::AddData(void* pModuleId,
void* pData,
PD_CALLBACK_FREEDATA callback,
FX_BOOL bSelfDestruct) {
- if (pModuleId == NULL) {
+ if (!pModuleId) {
return;
}
FX_PRIVATEDATA* pList = m_DataList.GetData();
@@ -58,7 +58,7 @@ void CFX_PrivateData::SetPrivateObj(void* pModuleId, CFX_DestructObject* pObj) {
AddData(pModuleId, pObj, NULL, TRUE);
}
FX_BOOL CFX_PrivateData::RemovePrivateData(void* pModuleId) {
- if (pModuleId == NULL) {
+ if (!pModuleId) {
return FALSE;
}
FX_PRIVATEDATA* pList = m_DataList.GetData();
@@ -72,7 +72,7 @@ FX_BOOL CFX_PrivateData::RemovePrivateData(void* pModuleId) {
return FALSE;
}
void* CFX_PrivateData::GetPrivateData(void* pModuleId) {
- if (pModuleId == NULL) {
+ if (!pModuleId) {
return NULL;
}
FX_PRIVATEDATA* pList = m_DataList.GetData();
@@ -93,7 +93,7 @@ void CFX_PrivateData::ClearAll() {
m_DataList.RemoveAll();
}
void FX_atonum(const CFX_ByteStringC& strc, FX_BOOL& bInteger, void* pData) {
- if (FXSYS_memchr(strc.GetPtr(), '.', strc.GetLength()) == NULL) {
+ if (!FXSYS_memchr(strc.GetPtr(), '.', strc.GetLength())) {
bInteger = TRUE;
int cc = 0, integer = 0;
const FX_CHAR* str = strc.GetCStr();
@@ -257,7 +257,7 @@ void* FX_OpenFolder(const FX_WCHAR* path) {
FX_BOOL FX_GetNextFile(void* handle,
CFX_ByteString& filename,
FX_BOOL& bFolder) {
- if (handle == NULL) {
+ if (!handle) {
return FALSE;
}
#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
@@ -289,7 +289,7 @@ FX_BOOL FX_GetNextFile(void* handle,
return FALSE;
#else
struct dirent* de = readdir((DIR*)handle);
- if (de == NULL) {
+ if (!de) {
return FALSE;
}
filename = de->d_name;
@@ -300,7 +300,7 @@ FX_BOOL FX_GetNextFile(void* handle,
FX_BOOL FX_GetNextFile(void* handle,
CFX_WideString& filename,
FX_BOOL& bFolder) {
- if (handle == NULL) {
+ if (!handle) {
return FALSE;
}
#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
@@ -319,7 +319,7 @@ FX_BOOL FX_GetNextFile(void* handle,
return FALSE;
#else
struct dirent* de = readdir((DIR*)handle);
- if (de == NULL) {
+ if (!de) {
return FALSE;
}
filename = CFX_WideString::FromLocal(de->d_name);
@@ -328,7 +328,7 @@ FX_BOOL FX_GetNextFile(void* handle,
#endif
}
void FX_CloseFolder(void* handle) {
- if (handle == NULL) {
+ if (!handle) {
return;
}
#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
diff --git a/core/src/fxcrt/fx_basic_wstring.cpp b/core/src/fxcrt/fx_basic_wstring.cpp
index a3de140e8b..119de66b84 100644
--- a/core/src/fxcrt/fx_basic_wstring.cpp
+++ b/core/src/fxcrt/fx_basic_wstring.cpp
@@ -43,7 +43,7 @@ CFX_WideString::~CFX_WideString() {
}
}
CFX_WideString::CFX_WideString(const CFX_WideString& stringSrc) {
- if (stringSrc.m_pData == NULL) {
+ if (!stringSrc.m_pData) {
m_pData = NULL;
return;
}
@@ -101,7 +101,7 @@ CFX_WideString::CFX_WideString(const CFX_WideStringC& str1,
}
}
void CFX_WideString::ReleaseBuffer(FX_STRSIZE nNewLength) {
- if (m_pData == NULL) {
+ if (!m_pData) {
return;
}
CopyBeforeWrite();
@@ -117,7 +117,7 @@ void CFX_WideString::ReleaseBuffer(FX_STRSIZE nNewLength) {
m_pData->m_String[nNewLength] = 0;
}
const CFX_WideString& CFX_WideString::operator=(const FX_WCHAR* lpsz) {
- if (lpsz == NULL || lpsz[0] == 0) {
+ if (!lpsz || lpsz[0] == 0) {
Empty();
} else {
AssignCopy(FXSYS_wcslen(lpsz), lpsz);
@@ -163,7 +163,7 @@ const CFX_WideString& CFX_WideString::operator+=(const FX_WCHAR* lpsz) {
return *this;
}
const CFX_WideString& CFX_WideString::operator+=(const CFX_WideString& string) {
- if (string.m_pData == NULL) {
+ if (!string.m_pData) {
return *this;
}
ConcatInPlace(string.m_pData->m_nDataLength, string.m_pData->m_String);
@@ -188,7 +188,7 @@ bool CFX_WideString::Equal(const wchar_t* ptr) const {
wmemcmp(ptr, m_pData->m_String, m_pData->m_nDataLength) == 0;
}
bool CFX_WideString::Equal(const CFX_WideStringC& str) const {
- if (m_pData == NULL) {
+ if (!m_pData) {
return str.IsEmpty();
}
return str.GetLength() == m_pData->m_nDataLength &&
@@ -213,10 +213,10 @@ void CFX_WideString::Empty() {
}
void CFX_WideString::ConcatInPlace(FX_STRSIZE nSrcLen,
const FX_WCHAR* lpszSrcData) {
- if (nSrcLen == 0 || lpszSrcData == NULL) {
+ if (nSrcLen == 0 || !lpszSrcData) {
return;
}
- if (m_pData == NULL) {
+ if (!m_pData) {
m_pData = StringData::Create(nSrcLen);
if (m_pData) {
FXSYS_memcpy(m_pData->m_String, lpszSrcData, nSrcLen * sizeof(FX_WCHAR));
@@ -251,7 +251,7 @@ void CFX_WideString::ConcatCopy(FX_STRSIZE nSrc1Len,
pOldData->Release();
}
void CFX_WideString::CopyBeforeWrite() {
- if (m_pData == NULL || m_pData->m_nRefs <= 1) {
+ if (!m_pData || m_pData->m_nRefs <= 1) {
return;
}
StringData* pData = m_pData;
@@ -278,16 +278,15 @@ void CFX_WideString::AssignCopy(FX_STRSIZE nSrcLen,
m_pData->m_String[nSrcLen] = 0;
}
int CFX_WideString::Compare(const FX_WCHAR* lpsz) const {
- if (m_pData == NULL) {
- return (lpsz == NULL || lpsz[0] == 0) ? 0 : -1;
- }
- return FXSYS_wcscmp(m_pData->m_String, lpsz);
+ if (m_pData)
+ return FXSYS_wcscmp(m_pData->m_String, lpsz);
+ return (!lpsz || lpsz[0] == 0) ? 0 : -1;
}
CFX_ByteString CFX_WideString::UTF8Encode() const {
return FX_UTF8Encode(*this);
}
CFX_ByteString CFX_WideString::UTF16LE_Encode() const {
- if (m_pData == NULL) {
+ if (!m_pData) {
return CFX_ByteString("\0\0", 2);
}
int len = m_pData->m_nDataLength;
@@ -304,7 +303,7 @@ CFX_ByteString CFX_WideString::UTF16LE_Encode() const {
}
void CFX_WideString::ConvertFrom(const CFX_ByteString& str,
CFX_CharMap* pCharMap) {
- if (pCharMap == NULL) {
+ if (!pCharMap) {
pCharMap = CFX_CharMap::GetDefaultMapper();
}
*this = pCharMap->m_GetWideString(pCharMap, str);
@@ -314,14 +313,14 @@ void CFX_WideString::Reserve(FX_STRSIZE len) {
ReleaseBuffer(GetLength());
}
FX_WCHAR* CFX_WideString::GetBuffer(FX_STRSIZE nMinBufLength) {
- if (m_pData == NULL && nMinBufLength == 0) {
+ if (!m_pData && nMinBufLength == 0) {
return NULL;
}
if (m_pData && m_pData->m_nRefs <= 1 &&
m_pData->m_nAllocLength >= nMinBufLength) {
return m_pData->m_String;
}
- if (m_pData == NULL) {
+ if (!m_pData) {
m_pData = StringData::Create(nMinBufLength);
if (!m_pData) {
return NULL;
@@ -394,7 +393,7 @@ void CFX_WideString::AllocCopy(CFX_WideString& dest,
pdfium::base::CheckedNumeric<FX_STRSIZE> iSize =
static_cast<FX_STRSIZE>(sizeof(FX_WCHAR));
iSize *= nCopyLen;
- ASSERT(dest.m_pData == NULL);
+ ASSERT(!dest.m_pData);
dest.m_pData = StringData::Create(nCopyLen);
if (dest.m_pData) {
FXSYS_memcpy(dest.m_pData->m_String, m_pData->m_String + nCopyIndex,
@@ -402,7 +401,7 @@ void CFX_WideString::AllocCopy(CFX_WideString& dest,
}
}
CFX_WideString CFX_WideString::Left(FX_STRSIZE nCount) const {
- if (m_pData == NULL) {
+ if (!m_pData) {
return CFX_WideString();
}
if (nCount < 0) {
@@ -419,7 +418,7 @@ CFX_WideString CFX_WideString::Mid(FX_STRSIZE nFirst) const {
return Mid(nFirst, m_pData->m_nDataLength - nFirst);
}
CFX_WideString CFX_WideString::Mid(FX_STRSIZE nFirst, FX_STRSIZE nCount) const {
- if (m_pData == NULL) {
+ if (!m_pData) {
return CFX_WideString();
}
if (nFirst < 0) {
@@ -442,7 +441,7 @@ CFX_WideString CFX_WideString::Mid(FX_STRSIZE nFirst, FX_STRSIZE nCount) const {
return dest;
}
CFX_WideString CFX_WideString::Right(FX_STRSIZE nCount) const {
- if (m_pData == NULL) {
+ if (!m_pData) {
return CFX_WideString();
}
if (nCount < 0) {
@@ -456,19 +455,19 @@ CFX_WideString CFX_WideString::Right(FX_STRSIZE nCount) const {
return dest;
}
int CFX_WideString::CompareNoCase(const FX_WCHAR* lpsz) const {
- if (m_pData == NULL) {
- return (lpsz == NULL || lpsz[0] == 0) ? 0 : -1;
+ if (!m_pData) {
+ return (!lpsz || lpsz[0] == 0) ? 0 : -1;
}
return FXSYS_wcsicmp(m_pData->m_String, lpsz);
}
int CFX_WideString::Compare(const CFX_WideString& str) const {
- if (m_pData == NULL) {
- if (str.m_pData == NULL) {
+ if (!m_pData) {
+ if (!str.m_pData) {
return 0;
}
return -1;
}
- if (str.m_pData == NULL) {
+ if (!str.m_pData) {
return 1;
}
int this_len = m_pData->m_nDataLength;
@@ -491,7 +490,7 @@ int CFX_WideString::Compare(const CFX_WideString& str) const {
return 0;
}
void CFX_WideString::SetAt(FX_STRSIZE nIndex, FX_WCHAR ch) {
- if (m_pData == NULL) {
+ if (!m_pData) {
return;
}
ASSERT(nIndex >= 0);
@@ -500,7 +499,7 @@ void CFX_WideString::SetAt(FX_STRSIZE nIndex, FX_WCHAR ch) {
m_pData->m_String[nIndex] = ch;
}
void CFX_WideString::MakeLower() {
- if (m_pData == NULL) {
+ if (!m_pData) {
return;
}
CopyBeforeWrite();
@@ -510,7 +509,7 @@ void CFX_WideString::MakeLower() {
FXSYS_wcslwr(m_pData->m_String);
}
void CFX_WideString::MakeUpper() {
- if (m_pData == NULL) {
+ if (!m_pData) {
return;
}
CopyBeforeWrite();
@@ -526,10 +525,10 @@ FX_STRSIZE CFX_WideString::Find(const FX_WCHAR* lpszSub,
return -1;
}
const FX_WCHAR* lpsz = FXSYS_wcsstr(m_pData->m_String + nStart, lpszSub);
- return (lpsz == NULL) ? -1 : (int)(lpsz - m_pData->m_String);
+ return lpsz ? (int)(lpsz - m_pData->m_String) : -1;
}
FX_STRSIZE CFX_WideString::Find(FX_WCHAR ch, FX_STRSIZE nStart) const {
- if (m_pData == NULL) {
+ if (!m_pData) {
return -1;
}
FX_STRSIZE nLength = m_pData->m_nDataLength;
@@ -537,11 +536,11 @@ FX_STRSIZE CFX_WideString::Find(FX_WCHAR ch, FX_STRSIZE nStart) const {
return -1;
}
const FX_WCHAR* lpsz = FXSYS_wcschr(m_pData->m_String + nStart, ch);
- return (lpsz == NULL) ? -1 : (int)(lpsz - m_pData->m_String);
+ return (lpsz) ? (int)(lpsz - m_pData->m_String) : -1;
}
void CFX_WideString::TrimRight(const FX_WCHAR* lpszTargetList) {
FXSYS_assert(lpszTargetList);
- if (m_pData == NULL || *lpszTargetList == 0) {
+ if (!m_pData || *lpszTargetList == 0) {
return;
}
CopyBeforeWrite();
@@ -551,7 +550,7 @@ void CFX_WideString::TrimRight(const FX_WCHAR* lpszTargetList) {
}
FX_STRSIZE pos = len;
while (pos) {
- if (FXSYS_wcschr(lpszTargetList, m_pData->m_String[pos - 1]) == NULL) {
+ if (!FXSYS_wcschr(lpszTargetList, m_pData->m_String[pos - 1])) {
break;
}
pos--;
@@ -570,7 +569,7 @@ void CFX_WideString::TrimRight() {
}
void CFX_WideString::TrimLeft(const FX_WCHAR* lpszTargets) {
FXSYS_assert(lpszTargets);
- if (m_pData == NULL || *lpszTargets == 0) {
+ if (!m_pData || *lpszTargets == 0) {
return;
}
CopyBeforeWrite();
@@ -579,7 +578,7 @@ void CFX_WideString::TrimLeft(const FX_WCHAR* lpszTargets) {
}
const FX_WCHAR* lpsz = m_pData->m_String;
while (*lpsz != 0) {
- if (FXSYS_wcschr(lpszTargets, *lpsz) == NULL) {
+ if (!FXSYS_wcschr(lpszTargets, *lpsz)) {
break;
}
lpsz++;
@@ -604,7 +603,7 @@ FX_STRSIZE CFX_WideString::Replace(const FX_WCHAR* lpszOld,
if (GetLength() < 1) {
return 0;
}
- if (lpszOld == NULL) {
+ if (!lpszOld) {
return 0;
}
FX_STRSIZE nSourceLen = FXSYS_wcslen(lpszOld);
@@ -671,7 +670,7 @@ FX_STRSIZE CFX_WideString::Insert(FX_STRSIZE nIndex, FX_WCHAR ch) {
nIndex = nNewLength;
}
nNewLength++;
- if (m_pData == NULL || m_pData->m_nAllocLength < nNewLength) {
+ if (!m_pData || m_pData->m_nAllocLength < nNewLength) {
StringData* pOldData = m_pData;
const FX_WCHAR* pstr = m_pData->m_String;
m_pData = StringData::Create(nNewLength);
@@ -711,7 +710,7 @@ FX_STRSIZE CFX_WideString::Delete(FX_STRSIZE nIndex, FX_STRSIZE nCount) {
return m_pData->m_nDataLength;
}
FX_STRSIZE CFX_WideString::Remove(FX_WCHAR chRemove) {
- if (m_pData == NULL) {
+ if (!m_pData) {
return 0;
}
CopyBeforeWrite();
@@ -831,48 +830,48 @@ void CFX_WideString::FormatV(const FX_WCHAR* lpszFormat, va_list argList) {
break;
case 's': {
const FX_WCHAR* pstrNextArg = va_arg(argList, const FX_WCHAR*);
- if (pstrNextArg == NULL) {
- nItemLen = 6;
- } else {
+ if (pstrNextArg) {
nItemLen = FXSYS_wcslen(pstrNextArg);
if (nItemLen < 1) {
nItemLen = 1;
}
+ } else {
+ nItemLen = 6;
}
} break;
case 'S': {
const FX_CHAR* pstrNextArg = va_arg(argList, const FX_CHAR*);
- if (pstrNextArg == NULL) {
- nItemLen = 6;
- } else {
+ if (pstrNextArg) {
nItemLen = FXSYS_strlen(pstrNextArg);
if (nItemLen < 1) {
nItemLen = 1;
}
+ } else {
+ nItemLen = 6;
}
} break;
case 's' | FORCE_ANSI:
case 'S' | FORCE_ANSI: {
const FX_CHAR* pstrNextArg = va_arg(argList, const FX_CHAR*);
- if (pstrNextArg == NULL) {
- nItemLen = 6;
- } else {
+ if (pstrNextArg) {
nItemLen = FXSYS_strlen(pstrNextArg);
if (nItemLen < 1) {
nItemLen = 1;
}
+ } else {
+ nItemLen = 6;
}
} break;
case 's' | FORCE_UNICODE:
case 'S' | FORCE_UNICODE: {
FX_WCHAR* pstrNextArg = va_arg(argList, FX_WCHAR*);
- if (pstrNextArg == NULL) {
- nItemLen = 6;
- } else {
+ if (pstrNextArg) {
nItemLen = FXSYS_wcslen(pstrNextArg);
if (nItemLen < 1) {
nItemLen = 1;
}
+ } else {
+ nItemLen = 6;
}
} break;
}
@@ -987,16 +986,10 @@ FX_FLOAT FX_wtof(const FX_WCHAR* str, int len) {
return bNegative ? -fraction : fraction;
}
int CFX_WideString::GetInteger() const {
- if (m_pData == NULL) {
- return 0;
- }
- return FXSYS_wtoi(m_pData->m_String);
+ return m_pData ? FXSYS_wtoi(m_pData->m_String) : 0;
}
FX_FLOAT CFX_WideString::GetFloat() const {
- if (m_pData == NULL) {
- return 0.0;
- }
- return FX_wtof(m_pData->m_String, m_pData->m_nDataLength);
+ return m_pData ? FX_wtof(m_pData->m_String, m_pData->m_nDataLength) : 0.0;
}
static CFX_ByteString _DefMap_GetByteString(CFX_CharMap* pCharMap,
const CFX_WideString& widestr) {
diff --git a/core/src/fxcrt/fx_extension.cpp b/core/src/fxcrt/fx_extension.cpp
index fd1ecafe06..4669ac4be4 100644
--- a/core/src/fxcrt/fx_extension.cpp
+++ b/core/src/fxcrt/fx_extension.cpp
@@ -290,8 +290,7 @@ void FX_Random_GenerateBase(FX_DWORD* pBuffer, int32_t iCount) {
#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
FX_BOOL FX_GenerateCryptoRandom(FX_DWORD* pBuffer, int32_t iCount) {
HCRYPTPROV hCP = NULL;
- if (!::CryptAcquireContext(&hCP, NULL, NULL, PROV_RSA_FULL, 0) ||
- hCP == NULL) {
+ if (!::CryptAcquireContext(&hCP, NULL, NULL, PROV_RSA_FULL, 0) || !hCP) {
return FALSE;
}
::CryptGenRandom(hCP, iCount * sizeof(FX_DWORD), (uint8_t*)pBuffer);
diff --git a/core/src/fxcrt/fx_xml_parser.cpp b/core/src/fxcrt/fx_xml_parser.cpp
index 56fbada3ad..0b71836ef9 100644
--- a/core/src/fxcrt/fx_xml_parser.cpp
+++ b/core/src/fxcrt/fx_xml_parser.cpp
@@ -463,7 +463,7 @@ CXML_Element* CXML_Parser::ParseElement(CXML_Element* pParent,
iState = 0;
m_dwIndex--;
CXML_Element* pSubElement = ParseElement(pElement, TRUE);
- if (pSubElement == NULL) {
+ if (!pSubElement) {
break;
}
pSubElement->m_pParent = pElement;
@@ -767,7 +767,7 @@ FX_DWORD CXML_Element::FindElement(CXML_Element* pChild) const {
}
const CFX_WideString* CXML_AttrMap::Lookup(const CFX_ByteStringC& space,
const CFX_ByteStringC& name) const {
- if (m_pMap == NULL) {
+ if (!m_pMap) {
return NULL;
}
for (int i = 0; i < m_pMap->GetSize(); i++) {
@@ -803,7 +803,7 @@ void CXML_AttrMap::SetAt(const CFX_ByteStringC& space,
}
void CXML_AttrMap::RemoveAt(const CFX_ByteStringC& space,
const CFX_ByteStringC& name) {
- if (m_pMap == NULL) {
+ if (!m_pMap) {
return;
}
for (int i = 0; i < m_pMap->GetSize(); i++) {
@@ -816,7 +816,7 @@ void CXML_AttrMap::RemoveAt(const CFX_ByteStringC& space,
}
}
int CXML_AttrMap::GetSize() const {
- return m_pMap == NULL ? 0 : m_pMap->GetSize();
+ return m_pMap ? m_pMap->GetSize() : 0;
}
CXML_AttrItem& CXML_AttrMap::GetAt(int index) const {
return (*m_pMap)[index];
diff --git a/core/src/fxge/agg/src/fx_agg_driver.cpp b/core/src/fxge/agg/src/fx_agg_driver.cpp
index dfa5c27ebf..ed2e8e41f0 100644
--- a/core/src/fxge/agg/src/fx_agg_driver.cpp
+++ b/core/src/fxge/agg/src/fx_agg_driver.cpp
@@ -150,14 +150,7 @@ static void RasterizeStroke(agg::rasterizer_scanline_aa& rasterizer,
if (width < unit) {
width = unit;
}
- if (pGraphState->m_DashArray == NULL) {
- agg::conv_stroke<agg::path_storage> stroke(path_data);
- stroke.line_join(join);
- stroke.line_cap(cap);
- stroke.miter_limit(pGraphState->m_MiterLimit);
- stroke.width(width);
- rasterizer.add_path_transformed(stroke, pObject2Device);
- } else {
+ if (pGraphState->m_DashArray) {
typedef agg::conv_dash<agg::path_storage> dash_converter;
dash_converter dash(path_data);
for (int i = 0; i < (pGraphState->m_DashCount + 1) / 2; i++) {
@@ -181,6 +174,13 @@ static void RasterizeStroke(agg::rasterizer_scanline_aa& rasterizer,
stroke.miter_limit(pGraphState->m_MiterLimit);
stroke.width(width);
rasterizer.add_path_transformed(stroke, pObject2Device);
+ } else {
+ agg::conv_stroke<agg::path_storage> stroke(path_data);
+ stroke.line_join(join);
+ stroke.line_cap(cap);
+ stroke.miter_limit(pGraphState->m_MiterLimit);
+ stroke.width(width);
+ rasterizer.add_path_transformed(stroke, pObject2Device);
}
}
IFX_RenderDeviceDriver* IFX_RenderDeviceDriver::CreateFxgeDriver(
@@ -554,13 +554,14 @@ class CFX_Renderer {
}
} else {
int index = 0;
- if (m_pDevice->GetPalette() == NULL) {
- index = ((uint8_t)m_Color == 0xff) ? 1 : 0;
- } else {
- for (int i = 0; i < 2; i++)
+ if (m_pDevice->GetPalette()) {
+ for (int i = 0; i < 2; i++) {
if (FXARGB_TODIB(m_pDevice->GetPalette()[i]) == m_Color) {
index = i;
}
+ }
+ } else {
+ index = ((uint8_t)m_Color == 0xff) ? 1 : 0;
}
uint8_t* dest_scan1 = dest_scan;
for (int col = col_start; col < col_end; col++) {
@@ -598,13 +599,14 @@ class CFX_Renderer {
: (clip_right - span_left);
dest_scan += col_start / 8;
int index = 0;
- if (m_pDevice->GetPalette() == NULL) {
- index = ((uint8_t)m_Color == 0xff) ? 1 : 0;
- } else {
- for (int i = 0; i < 2; i++)
+ if (m_pDevice->GetPalette()) {
+ for (int i = 0; i < 2; i++) {
if (FXARGB_TODIB(m_pDevice->GetPalette()[i]) == m_Color) {
index = i;
}
+ }
+ } else {
+ index = ((uint8_t)m_Color == 0xff) ? 1 : 0;
}
uint8_t* dest_scan1 = dest_scan;
for (int col = col_start; col < col_end; col++) {
@@ -994,7 +996,7 @@ class CFX_Renderer {
}
template <class Scanline>
void render(const Scanline& sl) {
- if (m_pOriDevice == NULL && composite_span == NULL) {
+ if (!m_pOriDevice && !composite_span) {
return;
}
int y = sl.y();
@@ -1212,7 +1214,7 @@ FX_BOOL CFX_AggDeviceDriver::DrawPath(const CFX_PathData* pPathData,
if (blend_type != FXDIB_BLEND_NORMAL) {
return FALSE;
}
- if (GetBuffer() == NULL) {
+ if (!GetBuffer()) {
return TRUE;
}
m_FillFlags = fill_mode;
@@ -1386,7 +1388,7 @@ void RgbByteOrderTransferBitmap(CFX_DIBitmap* pBitmap,
const CFX_DIBSource* pSrcBitmap,
int src_left,
int src_top) {
- if (pBitmap == NULL) {
+ if (!pBitmap) {
return;
}
pBitmap->GetOverlapRect(dest_left, dest_top, width, height,
@@ -1527,14 +1529,14 @@ FX_BOOL CFX_AggDeviceDriver::SetPixel(int x,
FX_DWORD color,
int alpha_flag,
void* pIccTransform) {
- if (m_pBitmap->GetBuffer() == NULL) {
+ if (!m_pBitmap->GetBuffer()) {
return TRUE;
}
if (!CFX_GEModule::Get()->GetCodecModule() ||
!CFX_GEModule::Get()->GetCodecModule()->GetIccModule()) {
pIccTransform = NULL;
}
- if (m_pClipRgn == NULL) {
+ if (!m_pClipRgn) {
if (m_bRgbByteOrder) {
RgbByteOrderSetPixel(m_pBitmap, x, y, color);
} else {
@@ -1576,7 +1578,7 @@ FX_BOOL CFX_AggDeviceDriver::FillRect(const FX_RECT* pRect,
if (blend_type != FXDIB_BLEND_NORMAL) {
return FALSE;
}
- if (m_pBitmap->GetBuffer() == NULL) {
+ if (!m_pBitmap->GetBuffer()) {
return TRUE;
}
FX_RECT clip_rect;
@@ -1588,7 +1590,7 @@ FX_BOOL CFX_AggDeviceDriver::FillRect(const FX_RECT* pRect,
if (draw_rect.IsEmpty()) {
return TRUE;
}
- if (m_pClipRgn == NULL || m_pClipRgn->GetType() == CFX_ClipRgn::RectI) {
+ if (!m_pClipRgn || m_pClipRgn->GetType() == CFX_ClipRgn::RectI) {
if (m_bRgbByteOrder) {
RgbByteOrderCompositeRect(m_pBitmap, draw_rect.left, draw_rect.top,
draw_rect.Width(), draw_rect.Height(),
@@ -1608,7 +1610,7 @@ FX_BOOL CFX_AggDeviceDriver::FillRect(const FX_RECT* pRect,
return TRUE;
}
FX_BOOL CFX_AggDeviceDriver::GetClipBox(FX_RECT* pRect) {
- if (m_pClipRgn == NULL) {
+ if (!m_pClipRgn) {
pRect->left = pRect->top = 0;
pRect->right = GetDeviceCaps(FXDC_PIXEL_WIDTH);
pRect->bottom = GetDeviceCaps(FXDC_PIXEL_HEIGHT);
@@ -1622,7 +1624,7 @@ FX_BOOL CFX_AggDeviceDriver::GetDIBits(CFX_DIBitmap* pBitmap,
int top,
void* pIccTransform,
FX_BOOL bDEdge) {
- if (m_pBitmap->GetBuffer() == NULL) {
+ if (!m_pBitmap->GetBuffer()) {
return TRUE;
}
if (bDEdge) {
@@ -1673,7 +1675,7 @@ FX_BOOL CFX_AggDeviceDriver::SetDIBits(const CFX_DIBSource* pBitmap,
int blend_type,
int alpha_flag,
void* pIccTransform) {
- if (m_pBitmap->GetBuffer() == NULL) {
+ if (!m_pBitmap->GetBuffer()) {
return TRUE;
}
if (pBitmap->IsAlphaMask())
@@ -1696,7 +1698,7 @@ FX_BOOL CFX_AggDeviceDriver::StretchDIBits(const CFX_DIBSource* pSource,
int alpha_flag,
void* pIccTransform,
int blend_type) {
- if (m_pBitmap->GetBuffer() == NULL) {
+ if (!m_pBitmap->GetBuffer()) {
return TRUE;
}
if (dest_width == pSource->GetWidth() &&
@@ -1731,7 +1733,7 @@ FX_BOOL CFX_AggDeviceDriver::StartDIBits(const CFX_DIBSource* pSource,
int alpha_flag,
void* pIccTransform,
int blend_type) {
- if (m_pBitmap->GetBuffer() == NULL) {
+ if (!m_pBitmap->GetBuffer()) {
return TRUE;
}
CFX_ImageRenderer* pRenderer = new CFX_ImageRenderer;
@@ -1741,13 +1743,13 @@ FX_BOOL CFX_AggDeviceDriver::StartDIBits(const CFX_DIBSource* pSource,
return TRUE;
}
FX_BOOL CFX_AggDeviceDriver::ContinueDIBits(void* pHandle, IFX_Pause* pPause) {
- if (m_pBitmap->GetBuffer() == NULL) {
+ if (!m_pBitmap->GetBuffer()) {
return TRUE;
}
return ((CFX_ImageRenderer*)pHandle)->Continue(pPause);
}
void CFX_AggDeviceDriver::CancelDIBits(void* pHandle) {
- if (m_pBitmap->GetBuffer() == NULL) {
+ if (!m_pBitmap->GetBuffer()) {
return;
}
delete (CFX_ImageRenderer*)pHandle;
@@ -1760,7 +1762,7 @@ FX_BOOL CFX_FxgeDevice::Attach(CFX_DIBitmap* pBitmap,
FX_BOOL bRgbByteOrder,
CFX_DIBitmap* pOriDevice,
FX_BOOL bGroupKnockout) {
- if (pBitmap == NULL) {
+ if (!pBitmap) {
return FALSE;
}
SetBitmap(pBitmap);
diff --git a/core/src/fxge/android/fpf_skiafontmgr.cpp b/core/src/fxge/android/fpf_skiafontmgr.cpp
index 254f806fec..9dbe35d0e5 100644
--- a/core/src/fxge/android/fpf_skiafontmgr.cpp
+++ b/core/src/fxge/android/fpf_skiafontmgr.cpp
@@ -238,7 +238,7 @@ CFPF_SkiaFontMgr::~CFPF_SkiaFontMgr() {
}
}
FX_BOOL CFPF_SkiaFontMgr::InitFTLibrary() {
- if (m_FTLibrary == NULL) {
+ if (!m_FTLibrary) {
FXFT_Init_FreeType(&m_FTLibrary);
}
return m_FTLibrary != NULL;
diff --git a/core/src/fxge/dib/fx_dib_composite.cpp b/core/src/fxge/dib/fx_dib_composite.cpp
index e89fdcec99..e284f62050 100644
--- a/core/src/fxge/dib/fx_dib_composite.cpp
+++ b/core/src/fxge/dib/fx_dib_composite.cpp
@@ -737,8 +737,8 @@ void _CompositeRow_Argb2Argb(uint8_t* dest_scan,
const uint8_t* src_alpha_scan) {
int blended_colors[3];
FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE;
- if (dest_alpha_scan == NULL) {
- if (src_alpha_scan == NULL) {
+ if (!dest_alpha_scan) {
+ if (!src_alpha_scan) {
uint8_t back_alpha = 0;
for (int col = 0; col < pixel_count; col++) {
back_alpha = dest_scan[3];
@@ -755,10 +755,10 @@ void _CompositeRow_Argb2Argb(uint8_t* dest_scan,
continue;
}
uint8_t src_alpha;
- if (clip_scan == NULL) {
- src_alpha = src_scan[3];
- } else {
+ if (clip_scan) {
src_alpha = clip_scan[col] * src_scan[3] / 255;
+ } else {
+ src_alpha = src_scan[3];
}
if (src_alpha == 0) {
dest_scan += 4;
@@ -807,10 +807,10 @@ void _CompositeRow_Argb2Argb(uint8_t* dest_scan,
continue;
}
uint8_t src_alpha;
- if (clip_scan == NULL) {
- src_alpha = *src_alpha_scan++;
- } else {
+ if (clip_scan) {
src_alpha = clip_scan[col] * (*src_alpha_scan++) / 255;
+ } else {
+ src_alpha = *src_alpha_scan++;
}
if (src_alpha == 0) {
dest_scan += 4;
@@ -862,10 +862,10 @@ void _CompositeRow_Argb2Argb(uint8_t* dest_scan,
continue;
}
uint8_t src_alpha;
- if (clip_scan == NULL) {
- src_alpha = *src_alpha_scan++;
- } else {
+ if (clip_scan) {
src_alpha = clip_scan[col] * (*src_alpha_scan++) / 255;
+ } else {
+ src_alpha = *src_alpha_scan++;
}
if (src_alpha == 0) {
dest_scan += 3;
@@ -915,10 +915,10 @@ void _CompositeRow_Argb2Argb(uint8_t* dest_scan,
continue;
}
uint8_t src_alpha;
- if (clip_scan == NULL) {
- src_alpha = src_scan[3];
- } else {
+ if (clip_scan) {
src_alpha = clip_scan[col] * src_scan[3] / 255;
+ } else {
+ src_alpha = src_scan[3];
}
if (src_alpha == 0) {
dest_scan += 3;
@@ -960,21 +960,18 @@ void _CompositeRow_Rgb2Argb_Blend_NoClip(uint8_t* dest_scan,
int blended_colors[3];
FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE;
int src_gap = src_Bpp - 3;
- if (dest_alpha_scan == NULL) {
+ if (dest_alpha_scan) {
for (int col = 0; col < width; col++) {
- uint8_t back_alpha = dest_scan[3];
+ uint8_t back_alpha = *dest_alpha_scan;
if (back_alpha == 0) {
- if (src_Bpp == 4) {
- FXARGB_SETDIB(dest_scan, 0xff000000 | FXARGB_GETDIB(src_scan));
- } else {
- FXARGB_SETDIB(dest_scan, FXARGB_MAKE(0xff, src_scan[2], src_scan[1],
- src_scan[0]));
- }
- dest_scan += 4;
- src_scan += src_Bpp;
+ *dest_scan++ = *src_scan++;
+ *dest_scan++ = *src_scan++;
+ *dest_scan++ = *src_scan++;
+ *dest_alpha_scan++ = 0xff;
+ src_scan += src_gap;
continue;
}
- dest_scan[3] = 0xff;
+ *dest_alpha_scan++ = 0xff;
if (bNonseparableBlend) {
_RGB_Blend(blend_type, src_scan, dest_scan, blended_colors);
}
@@ -987,21 +984,23 @@ void _CompositeRow_Rgb2Argb_Blend_NoClip(uint8_t* dest_scan,
dest_scan++;
src_scan++;
}
- dest_scan++;
src_scan += src_gap;
}
} else {
for (int col = 0; col < width; col++) {
- uint8_t back_alpha = *dest_alpha_scan;
+ uint8_t back_alpha = dest_scan[3];
if (back_alpha == 0) {
- *dest_scan++ = *src_scan++;
- *dest_scan++ = *src_scan++;
- *dest_scan++ = *src_scan++;
- *dest_alpha_scan++ = 0xff;
- src_scan += src_gap;
+ if (src_Bpp == 4) {
+ FXARGB_SETDIB(dest_scan, 0xff000000 | FXARGB_GETDIB(src_scan));
+ } else {
+ FXARGB_SETDIB(dest_scan, FXARGB_MAKE(0xff, src_scan[2], src_scan[1],
+ src_scan[0]));
+ }
+ dest_scan += 4;
+ src_scan += src_Bpp;
continue;
}
- *dest_alpha_scan++ = 0xff;
+ dest_scan[3] = 0xff;
if (bNonseparableBlend) {
_RGB_Blend(blend_type, src_scan, dest_scan, blended_colors);
}
@@ -1014,6 +1013,7 @@ void _CompositeRow_Rgb2Argb_Blend_NoClip(uint8_t* dest_scan,
dest_scan++;
src_scan++;
}
+ dest_scan++;
src_scan += src_gap;
}
}
@@ -1028,26 +1028,27 @@ inline void _CompositeRow_Rgb2Argb_Blend_Clip(uint8_t* dest_scan,
int blended_colors[3];
FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE;
int src_gap = src_Bpp - 3;
- if (dest_alpha_scan == NULL) {
+ if (dest_alpha_scan) {
for (int col = 0; col < width; col++) {
int src_alpha = *clip_scan++;
- uint8_t back_alpha = dest_scan[3];
+ uint8_t back_alpha = *dest_alpha_scan;
if (back_alpha == 0) {
*dest_scan++ = *src_scan++;
*dest_scan++ = *src_scan++;
*dest_scan++ = *src_scan++;
src_scan += src_gap;
- dest_scan++;
+ dest_alpha_scan++;
continue;
}
if (src_alpha == 0) {
- dest_scan += 4;
+ dest_scan += 3;
+ dest_alpha_scan++;
src_scan += src_Bpp;
continue;
}
uint8_t dest_alpha =
back_alpha + src_alpha - back_alpha * src_alpha / 255;
- dest_scan[3] = dest_alpha;
+ *dest_alpha_scan++ = dest_alpha;
int alpha_ratio = src_alpha * 255 / dest_alpha;
if (bNonseparableBlend) {
_RGB_Blend(blend_type, src_scan, dest_scan, blended_colors);
@@ -1062,30 +1063,28 @@ inline void _CompositeRow_Rgb2Argb_Blend_Clip(uint8_t* dest_scan,
dest_scan++;
src_scan++;
}
- dest_scan++;
src_scan += src_gap;
}
} else {
for (int col = 0; col < width; col++) {
int src_alpha = *clip_scan++;
- uint8_t back_alpha = *dest_alpha_scan;
+ uint8_t back_alpha = dest_scan[3];
if (back_alpha == 0) {
*dest_scan++ = *src_scan++;
*dest_scan++ = *src_scan++;
*dest_scan++ = *src_scan++;
src_scan += src_gap;
- dest_alpha_scan++;
+ dest_scan++;
continue;
}
if (src_alpha == 0) {
- dest_scan += 3;
- dest_alpha_scan++;
+ dest_scan += 4;
src_scan += src_Bpp;
continue;
}
uint8_t dest_alpha =
back_alpha + src_alpha - back_alpha * src_alpha / 255;
- *dest_alpha_scan++ = dest_alpha;
+ dest_scan[3] = dest_alpha;
int alpha_ratio = src_alpha * 255 / dest_alpha;
if (bNonseparableBlend) {
_RGB_Blend(blend_type, src_scan, dest_scan, blended_colors);
@@ -1100,6 +1099,7 @@ inline void _CompositeRow_Rgb2Argb_Blend_Clip(uint8_t* dest_scan,
dest_scan++;
src_scan++;
}
+ dest_scan++;
src_scan += src_gap;
}
}
@@ -1111,33 +1111,33 @@ inline void _CompositeRow_Rgb2Argb_NoBlend_Clip(uint8_t* dest_scan,
const uint8_t* clip_scan,
uint8_t* dest_alpha_scan) {
int src_gap = src_Bpp - 3;
- if (dest_alpha_scan == NULL) {
+ if (dest_alpha_scan) {
for (int col = 0; col < width; col++) {
int src_alpha = clip_scan[col];
if (src_alpha == 255) {
*dest_scan++ = *src_scan++;
*dest_scan++ = *src_scan++;
*dest_scan++ = *src_scan++;
- *dest_scan++ = 255;
+ *dest_alpha_scan++ = 255;
src_scan += src_gap;
continue;
}
if (src_alpha == 0) {
- dest_scan += 4;
+ dest_scan += 3;
+ dest_alpha_scan++;
src_scan += src_Bpp;
continue;
}
- int back_alpha = dest_scan[3];
+ int back_alpha = *dest_alpha_scan;
uint8_t dest_alpha =
back_alpha + src_alpha - back_alpha * src_alpha / 255;
- dest_scan[3] = dest_alpha;
+ *dest_alpha_scan++ = dest_alpha;
int alpha_ratio = src_alpha * 255 / dest_alpha;
for (int color = 0; color < 3; color++) {
*dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, *src_scan, alpha_ratio);
dest_scan++;
src_scan++;
}
- dest_scan++;
src_scan += src_gap;
}
} else {
@@ -1147,26 +1147,26 @@ inline void _CompositeRow_Rgb2Argb_NoBlend_Clip(uint8_t* dest_scan,
*dest_scan++ = *src_scan++;
*dest_scan++ = *src_scan++;
*dest_scan++ = *src_scan++;
- *dest_alpha_scan++ = 255;
+ *dest_scan++ = 255;
src_scan += src_gap;
continue;
}
if (src_alpha == 0) {
- dest_scan += 3;
- dest_alpha_scan++;
+ dest_scan += 4;
src_scan += src_Bpp;
continue;
}
- int back_alpha = *dest_alpha_scan;
+ int back_alpha = dest_scan[3];
uint8_t dest_alpha =
back_alpha + src_alpha - back_alpha * src_alpha / 255;
- *dest_alpha_scan++ = dest_alpha;
+ dest_scan[3] = dest_alpha;
int alpha_ratio = src_alpha * 255 / dest_alpha;
for (int color = 0; color < 3; color++) {
*dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, *src_scan, alpha_ratio);
dest_scan++;
src_scan++;
}
+ dest_scan++;
src_scan += src_gap;
}
}
@@ -1176,7 +1176,16 @@ inline void _CompositeRow_Rgb2Argb_NoBlend_NoClip(uint8_t* dest_scan,
int width,
int src_Bpp,
uint8_t* dest_alpha_scan) {
- if (dest_alpha_scan == NULL) {
+ if (dest_alpha_scan) {
+ int src_gap = src_Bpp - 3;
+ for (int col = 0; col < width; col++) {
+ *dest_scan++ = *src_scan++;
+ *dest_scan++ = *src_scan++;
+ *dest_scan++ = *src_scan++;
+ *dest_alpha_scan++ = 0xff;
+ src_scan += src_gap;
+ }
+ } else {
for (int col = 0; col < width; col++) {
if (src_Bpp == 4) {
FXARGB_SETDIB(dest_scan, 0xff000000 | FXARGB_GETDIB(src_scan));
@@ -1187,15 +1196,6 @@ inline void _CompositeRow_Rgb2Argb_NoBlend_NoClip(uint8_t* dest_scan,
dest_scan += 4;
src_scan += src_Bpp;
}
- } else {
- int src_gap = src_Bpp - 3;
- for (int col = 0; col < width; col++) {
- *dest_scan++ = *src_scan++;
- *dest_scan++ = *src_scan++;
- *dest_scan++ = *src_scan++;
- *dest_alpha_scan++ = 0xff;
- src_scan += src_gap;
- }
}
}
inline void _CompositeRow_Argb2Rgb_Blend(uint8_t* dest_scan,
@@ -1208,17 +1208,17 @@ inline void _CompositeRow_Argb2Rgb_Blend(uint8_t* dest_scan,
int blended_colors[3];
FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE;
int dest_gap = dest_Bpp - 3;
- if (src_alpha_scan == NULL) {
+ if (src_alpha_scan) {
for (int col = 0; col < width; col++) {
uint8_t src_alpha;
if (clip_scan) {
- src_alpha = src_scan[3] * (*clip_scan++) / 255;
+ src_alpha = (*src_alpha_scan++) * (*clip_scan++) / 255;
} else {
- src_alpha = src_scan[3];
+ src_alpha = *src_alpha_scan++;
}
if (src_alpha == 0) {
dest_scan += dest_Bpp;
- src_scan += 4;
+ src_scan += 3;
continue;
}
if (bNonseparableBlend) {
@@ -1234,19 +1234,18 @@ inline void _CompositeRow_Argb2Rgb_Blend(uint8_t* dest_scan,
src_scan++;
}
dest_scan += dest_gap;
- src_scan++;
}
} else {
for (int col = 0; col < width; col++) {
uint8_t src_alpha;
if (clip_scan) {
- src_alpha = (*src_alpha_scan++) * (*clip_scan++) / 255;
+ src_alpha = src_scan[3] * (*clip_scan++) / 255;
} else {
- src_alpha = *src_alpha_scan++;
+ src_alpha = src_scan[3];
}
if (src_alpha == 0) {
dest_scan += dest_Bpp;
- src_scan += 3;
+ src_scan += 4;
continue;
}
if (bNonseparableBlend) {
@@ -1262,6 +1261,7 @@ inline void _CompositeRow_Argb2Rgb_Blend(uint8_t* dest_scan,
src_scan++;
}
dest_scan += dest_gap;
+ src_scan++;
}
}
}
@@ -1272,25 +1272,24 @@ inline void _CompositeRow_Argb2Rgb_NoBlend(uint8_t* dest_scan,
const uint8_t* clip_scan,
const uint8_t* src_alpha_scan) {
int dest_gap = dest_Bpp - 3;
- if (src_alpha_scan == NULL) {
+ if (src_alpha_scan) {
for (int col = 0; col < width; col++) {
uint8_t src_alpha;
if (clip_scan) {
- src_alpha = src_scan[3] * (*clip_scan++) / 255;
+ src_alpha = (*src_alpha_scan++) * (*clip_scan++) / 255;
} else {
- src_alpha = src_scan[3];
+ src_alpha = *src_alpha_scan++;
}
if (src_alpha == 255) {
*dest_scan++ = *src_scan++;
*dest_scan++ = *src_scan++;
*dest_scan++ = *src_scan++;
dest_scan += dest_gap;
- src_scan++;
continue;
}
if (src_alpha == 0) {
dest_scan += dest_Bpp;
- src_scan += 4;
+ src_scan += 3;
continue;
}
for (int color = 0; color < 3; color++) {
@@ -1299,26 +1298,26 @@ inline void _CompositeRow_Argb2Rgb_NoBlend(uint8_t* dest_scan,
src_scan++;
}
dest_scan += dest_gap;
- src_scan++;
}
} else {
for (int col = 0; col < width; col++) {
uint8_t src_alpha;
if (clip_scan) {
- src_alpha = (*src_alpha_scan++) * (*clip_scan++) / 255;
+ src_alpha = src_scan[3] * (*clip_scan++) / 255;
} else {
- src_alpha = *src_alpha_scan++;
+ src_alpha = src_scan[3];
}
if (src_alpha == 255) {
*dest_scan++ = *src_scan++;
*dest_scan++ = *src_scan++;
*dest_scan++ = *src_scan++;
dest_scan += dest_gap;
+ src_scan++;
continue;
}
if (src_alpha == 0) {
dest_scan += dest_Bpp;
- src_scan += 3;
+ src_scan += 4;
continue;
}
for (int color = 0; color < 3; color++) {
@@ -1327,6 +1326,7 @@ inline void _CompositeRow_Argb2Rgb_NoBlend(uint8_t* dest_scan,
src_scan++;
}
dest_scan += dest_gap;
+ src_scan++;
}
}
}
@@ -1451,7 +1451,9 @@ void _CompositeRow_Argb2Argb_Transform(uint8_t* dest_scan,
ICodec_IccModule* pIccModule =
CFX_GEModule::Get()->GetCodecModule()->GetIccModule();
if (src_alpha_scan) {
- if (dest_alpha_scan == NULL) {
+ if (dest_alpha_scan) {
+ pIccModule->TranslateScanline(pIccTransform, dp, src_scan, pixel_count);
+ } else {
for (int col = 0; col < pixel_count; col++) {
pIccModule->TranslateScanline(pIccTransform, dp, src_scan, 1);
dp[3] = *src_alpha_scan++;
@@ -1459,18 +1461,9 @@ void _CompositeRow_Argb2Argb_Transform(uint8_t* dest_scan,
dp += 4;
}
src_alpha_scan = NULL;
- } else {
- pIccModule->TranslateScanline(pIccTransform, dp, src_scan, pixel_count);
}
} else {
- if (dest_alpha_scan == NULL) {
- for (int col = 0; col < pixel_count; col++) {
- pIccModule->TranslateScanline(pIccTransform, dp, src_scan, 1);
- dp[3] = src_scan[3];
- src_scan += 4;
- dp += 4;
- }
- } else {
+ if (dest_alpha_scan) {
int blended_colors[3];
FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE;
for (int col = 0; col < pixel_count; col++) {
@@ -1495,10 +1488,10 @@ void _CompositeRow_Argb2Argb_Transform(uint8_t* dest_scan,
continue;
}
uint8_t src_alpha;
- if (clip_scan == NULL) {
- src_alpha = src_scan[3];
- } else {
+ if (clip_scan) {
src_alpha = clip_scan[col] * src_scan[3] / 255;
+ } else {
+ src_alpha = src_scan[3];
}
src_scan += 4;
if (src_alpha == 0) {
@@ -1531,6 +1524,12 @@ void _CompositeRow_Argb2Argb_Transform(uint8_t* dest_scan,
}
return;
}
+ for (int col = 0; col < pixel_count; col++) {
+ pIccModule->TranslateScanline(pIccTransform, dp, src_scan, 1);
+ dp[3] = src_scan[3];
+ src_scan += 4;
+ dp += 4;
+ }
}
_CompositeRow_Argb2Argb(dest_scan, src_cache_scan, pixel_count, blend_type,
clip_scan, dest_alpha_scan, src_alpha_scan);
@@ -2007,7 +2006,7 @@ inline void _CompositeRow_8bppPal2Graya(uint8_t* dest_scan,
for (int col = 0; col < pixel_count; col++) {
uint8_t gray = pPalette[*src_scan];
src_scan++;
- if (clip_scan == NULL || clip_scan[col] == 255) {
+ if (!clip_scan || clip_scan[col] == 255) {
*dest_scan++ = gray;
*dest_alpha_scan++ = 255;
continue;
@@ -2037,7 +2036,7 @@ inline void _CompositeRow_8bppPal2Graya(uint8_t* dest_scan,
for (int col = 0; col < pixel_count; col++) {
uint8_t gray = pPalette[*src_scan];
src_scan++;
- if (clip_scan == NULL || clip_scan[col] == 255) {
+ if (!clip_scan || clip_scan[col] == 255) {
*dest_scan++ = gray;
*dest_alpha_scan++ = 255;
continue;
@@ -2121,7 +2120,7 @@ inline void _CompositeRow_1bppPal2Graya(uint8_t* dest_scan,
(src_scan[(col + src_left) / 8] & (1 << (7 - (col + src_left) % 8)))
? set_gray
: reset_gray;
- if (clip_scan == NULL || clip_scan[col] == 255) {
+ if (!clip_scan || clip_scan[col] == 255) {
*dest_scan++ = gray;
*dest_alpha_scan++ = 255;
continue;
@@ -2153,7 +2152,7 @@ inline void _CompositeRow_1bppPal2Graya(uint8_t* dest_scan,
(src_scan[(col + src_left) / 8] & (1 << (7 - (col + src_left) % 8)))
? set_gray
: reset_gray;
- if (clip_scan == NULL || clip_scan[col] == 255) {
+ if (!clip_scan || clip_scan[col] == 255) {
*dest_scan++ = gray;
*dest_alpha_scan++ = 255;
continue;
@@ -2309,10 +2308,10 @@ inline void _CompositeRow_8bppRgb2Argb_NoBlend(uint8_t* dest_scan,
continue;
}
uint8_t src_alpha;
- if (clip_scan == NULL) {
- src_alpha = *src_alpha_scan++;
- } else {
+ if (clip_scan) {
src_alpha = clip_scan[col] * (*src_alpha_scan++) / 255;
+ } else {
+ src_alpha = *src_alpha_scan++;
}
if (src_alpha == 0) {
dest_scan += 4;
@@ -2336,7 +2335,7 @@ inline void _CompositeRow_8bppRgb2Argb_NoBlend(uint8_t* dest_scan,
int src_r = FXARGB_R(argb);
int src_g = FXARGB_G(argb);
int src_b = FXARGB_B(argb);
- if (clip_scan == NULL || clip_scan[col] == 255) {
+ if (!clip_scan || clip_scan[col] == 255) {
*dest_scan++ = src_b;
*dest_scan++ = src_g;
*dest_scan++ = src_r;
@@ -2394,10 +2393,10 @@ void _CompositeRow_8bppRgb2Rgba_NoBlend(uint8_t* dest_scan,
continue;
}
uint8_t src_alpha;
- if (clip_scan == NULL) {
- src_alpha = *src_alpha_scan++;
- } else {
+ if (clip_scan) {
src_alpha = clip_scan[col] * (*src_alpha_scan++) / 255;
+ } else {
+ src_alpha = *src_alpha_scan++;
}
if (src_alpha == 0) {
dest_scan += 3;
@@ -2421,7 +2420,7 @@ void _CompositeRow_8bppRgb2Rgba_NoBlend(uint8_t* dest_scan,
int src_r = FXARGB_R(argb);
int src_g = FXARGB_G(argb);
int src_b = FXARGB_B(argb);
- if (clip_scan == NULL || clip_scan[col] == 255) {
+ if (!clip_scan || clip_scan[col] == 255) {
*dest_scan++ = src_b;
*dest_scan++ = src_g;
*dest_scan++ = src_r;
@@ -2475,7 +2474,7 @@ inline void _CompositeRow_1bppRgb2Argb_NoBlend(uint8_t* dest_scan,
src_g = reset_g;
src_b = reset_b;
}
- if (clip_scan == NULL || clip_scan[col] == 255) {
+ if (!clip_scan || clip_scan[col] == 255) {
*dest_scan++ = src_b;
*dest_scan++ = src_g;
*dest_scan++ = src_r;
@@ -2526,7 +2525,7 @@ void _CompositeRow_1bppRgb2Rgba_NoBlend(uint8_t* dest_scan,
src_g = reset_g;
src_b = reset_b;
}
- if (clip_scan == NULL || clip_scan[col] == 255) {
+ if (!clip_scan || clip_scan[col] == 255) {
*dest_scan++ = src_b;
*dest_scan++ = src_g;
*dest_scan++ = src_r;
@@ -2823,8 +2822,7 @@ void _CompositeRow_BitMask2Argb(uint8_t* dest_scan,
int pixel_count,
int blend_type,
const uint8_t* clip_scan) {
- if (blend_type == FXDIB_BLEND_NORMAL && clip_scan == NULL &&
- mask_alpha == 255) {
+ if (blend_type == FXDIB_BLEND_NORMAL && !clip_scan && mask_alpha == 255) {
FX_ARGB argb = FXARGB_MAKE(0xff, src_r, src_g, src_b);
for (int col = 0; col < pixel_count; col++) {
if (src_scan[(src_left + col) / 8] & (1 << (7 - (src_left + col) % 8))) {
@@ -2902,8 +2900,7 @@ void _CompositeRow_BitMask2Rgba(uint8_t* dest_scan,
int blend_type,
const uint8_t* clip_scan,
uint8_t* dest_alpha_scan) {
- if (blend_type == FXDIB_BLEND_NORMAL && clip_scan == NULL &&
- mask_alpha == 255) {
+ if (blend_type == FXDIB_BLEND_NORMAL && !clip_scan && mask_alpha == 255) {
for (int col = 0; col < pixel_count; col++) {
if (src_scan[(src_left + col) / 8] & (1 << (7 - (src_left + col) % 8))) {
dest_scan[0] = src_b;
@@ -2989,8 +2986,7 @@ void _CompositeRow_BitMask2Rgb(uint8_t* dest_scan,
int blend_type,
int Bpp,
const uint8_t* clip_scan) {
- if (blend_type == FXDIB_BLEND_NORMAL && clip_scan == NULL &&
- mask_alpha == 255) {
+ if (blend_type == FXDIB_BLEND_NORMAL && !clip_scan && mask_alpha == 255) {
for (int col = 0; col < pixel_count; col++) {
if (src_scan[(src_left + col) / 8] & (1 << (7 - (src_left + col) % 8))) {
dest_scan[2] = src_r;
@@ -3159,10 +3155,10 @@ void _CompositeRow_Argb2Argb_RgbByteOrder(uint8_t* dest_scan,
continue;
}
uint8_t src_alpha;
- if (clip_scan == NULL) {
- src_alpha = src_scan[3];
- } else {
+ if (clip_scan) {
src_alpha = clip_scan[col] * src_scan[3] / 255;
+ } else {
+ src_alpha = src_scan[3];
}
if (src_alpha == 0) {
dest_scan += 4;
@@ -3623,7 +3619,7 @@ inline void _CompositeRow_8bppRgb2Argb_NoBlend_RgbByteOrder(
} else {
src_r = src_g = src_b = *src_scan;
}
- if (clip_scan == NULL || clip_scan[col] == 255) {
+ if (!clip_scan || clip_scan[col] == 255) {
dest_scan[2] = FX_GAMMA(src_b);
dest_scan[1] = FX_GAMMA(src_g);
dest_scan[0] = FX_GAMMA(src_r);
@@ -3683,7 +3679,7 @@ inline void _CompositeRow_1bppRgb2Argb_NoBlend_RgbByteOrder(
src_g = reset_g;
src_b = reset_b;
}
- if (clip_scan == NULL || clip_scan[col] == 255) {
+ if (!clip_scan || clip_scan[col] == 255) {
dest_scan[2] = FX_GAMMA(src_b);
dest_scan[1] = FX_GAMMA(src_g);
dest_scan[0] = FX_GAMMA(src_r);
@@ -3837,8 +3833,7 @@ void _CompositeRow_BitMask2Argb_RgbByteOrder(uint8_t* dest_scan,
int pixel_count,
int blend_type,
const uint8_t* clip_scan) {
- if (blend_type == FXDIB_BLEND_NORMAL && clip_scan == NULL &&
- mask_alpha == 255) {
+ if (blend_type == FXDIB_BLEND_NORMAL && !clip_scan && mask_alpha == 255) {
FX_ARGB argb = FXARGB_MAKE(0xff, src_r, src_g, src_b);
for (int col = 0; col < pixel_count; col++) {
if (src_scan[(src_left + col) / 8] & (1 << (7 - (src_left + col) % 8))) {
@@ -3915,8 +3910,7 @@ void _CompositeRow_BitMask2Rgb_RgbByteOrder(uint8_t* dest_scan,
int blend_type,
int Bpp,
const uint8_t* clip_scan) {
- if (blend_type == FXDIB_BLEND_NORMAL && clip_scan == NULL &&
- mask_alpha == 255) {
+ if (blend_type == FXDIB_BLEND_NORMAL && !clip_scan && mask_alpha == 255) {
for (int col = 0; col < pixel_count; col++) {
if (src_scan[(src_left + col) / 8] & (1 << (7 - (src_left + col) % 8))) {
dest_scan[2] = src_b;
@@ -4215,7 +4209,7 @@ FX_BOOL CFX_ScanlineCompositor::Init(FXDIB_Format dest_format,
if (CFX_GEModule::Get()->GetCodecModule()) {
pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule();
}
- if (pIccModule == NULL) {
+ if (!pIccModule) {
pIccTransform = NULL;
}
m_pIccTransform = pIccTransform;
@@ -4227,8 +4221,7 @@ FX_BOOL CFX_ScanlineCompositor::Init(FXDIB_Format dest_format,
dest_format, alpha_flag, mask_color, m_MaskAlpha, m_MaskRed,
m_MaskGreen, m_MaskBlue, m_MaskBlack, pIccModule, pIccTransform);
}
- if (pIccTransform == NULL && (~src_format & 0x0400) &&
- (dest_format & 0x0400)) {
+ if (!pIccTransform && (~src_format & 0x0400) && (dest_format & 0x0400)) {
return FALSE;
}
if ((m_SrcFormat & 0xff) <= 8) {
@@ -4662,7 +4655,7 @@ FX_BOOL CFX_DIBitmap::CompositeBitmap(int dest_left,
const CFX_ClipRgn* pClipRgn,
FX_BOOL bRgbByteOrder,
void* pIccTransform) {
- if (m_pBuffer == NULL) {
+ if (!m_pBuffer) {
return FALSE;
}
ASSERT(!pSrcBitmap->IsAlphaMask());
@@ -4735,7 +4728,7 @@ FX_BOOL CFX_DIBitmap::CompositeMask(int dest_left,
FX_BOOL bRgbByteOrder,
int alpha_flag,
void* pIccTransform) {
- if (m_pBuffer == NULL) {
+ if (!m_pBuffer) {
return FALSE;
}
ASSERT(pMask->IsAlphaMask());
@@ -4799,7 +4792,7 @@ FX_BOOL CFX_DIBitmap::CompositeRect(int left,
FX_DWORD color,
int alpha_flag,
void* pIccTransform) {
- if (m_pBuffer == NULL) {
+ if (!m_pBuffer) {
return FALSE;
}
int src_alpha = (alpha_flag >> 8) ? (alpha_flag & 0xff) : FXARGB_A(color);
@@ -4859,13 +4852,14 @@ FX_BOOL CFX_DIBitmap::CompositeRect(int left,
int right_shift = rect.right % 8;
int width = rect.right / 8 - rect.left / 8;
int index = 0;
- if (m_pPalette == NULL) {
- index = ((uint8_t)color == 0xff) ? 1 : 0;
- } else {
- for (int i = 0; i < 2; i++)
+ if (m_pPalette) {
+ for (int i = 0; i < 2; i++) {
if (m_pPalette[i] == color) {
index = i;
}
+ }
+ } else {
+ index = ((uint8_t)color == 0xff) ? 1 : 0;
}
for (int row = rect.top; row < rect.bottom; row++) {
uint8_t* dest_scan_top = (uint8_t*)GetScanline(row) + rect.left / 8;
diff --git a/core/src/fxge/dib/fx_dib_convert.cpp b/core/src/fxge/dib/fx_dib_convert.cpp
index 2c310f3cea..d87b1f9a97 100644
--- a/core/src/fxge/dib/fx_dib_convert.cpp
+++ b/core/src/fxge/dib/fx_dib_convert.cpp
@@ -209,7 +209,7 @@ CFX_Palette::~CFX_Palette() {
m_lut = 0;
}
FX_BOOL CFX_Palette::BuildPalette(const CFX_DIBSource* pBitmap, int pal_type) {
- if (pBitmap == NULL) {
+ if (!pBitmap) {
return FALSE;
}
FX_Free(m_pPalette);
@@ -560,7 +560,7 @@ inline FX_BOOL _ConvertBuffer_Rgb2PltRgb8_NoTransform(
palette.BuildPalette(pSrcBitmap, FXDIB_PALETTE_LOC);
FX_DWORD* cLut = palette.GetColorLut();
FX_DWORD* aLut = palette.GetAmountLut();
- if (cLut == NULL || aLut == NULL) {
+ if (!cLut || !aLut) {
return FALSE;
}
int lut = palette.Getlut();
@@ -987,7 +987,7 @@ FX_BOOL ConvertBuffer(FXDIB_Format dest_format,
}
case FXDIB_8bppRgb:
case FXDIB_8bppRgba: {
- if ((src_format & 0xff) == 8 && pSrcBitmap->GetPalette() == NULL) {
+ if ((src_format & 0xff) == 8 && !pSrcBitmap->GetPalette()) {
return ConvertBuffer(FXDIB_8bppMask, dest_buf, dest_pitch, width,
height, pSrcBitmap, src_left, src_top, d_pal,
pIccTransform);
@@ -1082,12 +1082,12 @@ FX_BOOL ConvertBuffer(FXDIB_Format dest_format,
CFX_DIBitmap* CFX_DIBSource::CloneConvert(FXDIB_Format dest_format,
const FX_RECT* pClip,
void* pIccTransform) const {
- if (dest_format == GetFormat() && pIccTransform == NULL) {
+ if (dest_format == GetFormat() && !pIccTransform) {
return Clone(pClip);
}
if (pClip) {
CFX_DIBitmap* pClone = Clone(pClip);
- if (pClone == NULL) {
+ if (!pClone) {
return NULL;
}
if (!pClone->ConvertFormat(dest_format, pIccTransform)) {
@@ -1105,7 +1105,7 @@ CFX_DIBitmap* CFX_DIBSource::CloneConvert(FXDIB_Format dest_format,
CFX_DIBitmap* pSrcAlpha = NULL;
if (HasAlpha()) {
pSrcAlpha = (GetFormat() == FXDIB_Argb) ? GetAlphaMask() : m_pAlphaMask;
- if (pSrcAlpha == NULL) {
+ if (!pSrcAlpha) {
delete pClone;
return NULL;
}
@@ -1144,16 +1144,16 @@ CFX_DIBitmap* CFX_DIBSource::CloneConvert(FXDIB_Format dest_format,
FX_BOOL CFX_DIBitmap::ConvertFormat(FXDIB_Format dest_format,
void* pIccTransform) {
FXDIB_Format src_format = GetFormat();
- if (dest_format == src_format && pIccTransform == NULL) {
+ if (dest_format == src_format && !pIccTransform) {
return TRUE;
}
if (dest_format == FXDIB_8bppMask && src_format == FXDIB_8bppRgb &&
- m_pPalette == NULL) {
+ !m_pPalette) {
m_AlphaFlag = 1;
return TRUE;
}
if (dest_format == FXDIB_Argb && src_format == FXDIB_Rgb32 &&
- pIccTransform == NULL) {
+ !pIccTransform) {
m_AlphaFlag = 2;
for (int row = 0; row < m_Height; row++) {
uint8_t* scanline = m_pBuffer + row * m_Pitch + 3;
@@ -1167,7 +1167,7 @@ FX_BOOL CFX_DIBitmap::ConvertFormat(FXDIB_Format dest_format,
int dest_bpp = dest_format & 0xff;
int dest_pitch = (dest_bpp * m_Width + 31) / 32 * 4;
uint8_t* dest_buf = FX_TryAlloc(uint8_t, dest_pitch * m_Height + 4);
- if (dest_buf == NULL) {
+ if (!dest_buf) {
return FALSE;
}
CFX_DIBitmap* pAlphaMask = NULL;
@@ -1186,12 +1186,12 @@ FX_BOOL CFX_DIBitmap::ConvertFormat(FXDIB_Format dest_format,
} else if (dest_format & 0x0200) {
if (src_format == FXDIB_Argb) {
pAlphaMask = GetAlphaMask();
- if (pAlphaMask == NULL) {
+ if (!pAlphaMask) {
FX_Free(dest_buf);
return FALSE;
}
} else {
- if (m_pAlphaMask == NULL) {
+ if (!m_pAlphaMask) {
if (!BuildAlphaMask()) {
FX_Free(dest_buf);
return FALSE;
diff --git a/core/src/fxge/dib/fx_dib_engine.cpp b/core/src/fxge/dib/fx_dib_engine.cpp
index 314b600b6c..16772ed003 100644
--- a/core/src/fxge/dib/fx_dib_engine.cpp
+++ b/core/src/fxge/dib/fx_dib_engine.cpp
@@ -36,7 +36,7 @@ void CWeightTable::Calc(int dest_len,
}
m_pWeightTables =
FX_TryAlloc(uint8_t, (dest_max - dest_min) * m_ItemSize + 4);
- if (m_pWeightTables == NULL) {
+ if (!m_pWeightTables) {
return;
}
if ((flags & FXDIB_NOSMOOTH) != 0 || FXSYS_fabs((FX_FLOAT)scale) < 1.0f) {
@@ -242,7 +242,7 @@ CStretchEngine::CStretchEngine(IFX_ScanlineComposer* pDestBitmap,
size += 31;
size = size / 32 * 4;
m_pDestScanline = FX_TryAlloc(uint8_t, size);
- if (m_pDestScanline == NULL) {
+ if (!m_pDestScanline) {
return;
}
if (dest_format == FXDIB_Rgb32) {
@@ -339,13 +339,13 @@ CStretchEngine::~CStretchEngine() {
FX_Free(m_pDestMaskScanline);
}
FX_BOOL CStretchEngine::StartStretchHorz() {
- if (m_DestWidth == 0 || m_pDestScanline == NULL ||
+ if (m_DestWidth == 0 || !m_pDestScanline ||
m_SrcClip.Height() > (int)((1U << 29) / m_InterPitch) ||
m_SrcClip.Height() == 0) {
return FALSE;
}
m_pInterBuf = FX_TryAlloc(unsigned char, m_SrcClip.Height() * m_InterPitch);
- if (m_pInterBuf == NULL) {
+ if (!m_pInterBuf) {
return FALSE;
}
if (m_pSource && m_bHasAlpha && m_pSource->m_pAlphaMask) {
@@ -359,7 +359,7 @@ FX_BOOL CStretchEngine::StartStretchHorz() {
}
m_WeightTable.Calc(m_DestWidth, m_DestClip.left, m_DestClip.right, m_SrcWidth,
m_SrcClip.left, m_SrcClip.right, m_Flags);
- if (m_WeightTable.m_pWeightTables == NULL) {
+ if (!m_WeightTable.m_pWeightTables) {
return FALSE;
}
m_CurRow = m_SrcClip.top;
@@ -603,7 +603,7 @@ void CStretchEngine::StretchVert() {
CWeightTable table;
table.Calc(m_DestHeight, m_DestClip.top, m_DestClip.bottom, m_SrcHeight,
m_SrcClip.top, m_SrcClip.bottom, m_Flags);
- if (table.m_pWeightTables == NULL) {
+ if (!table.m_pWeightTables) {
return;
}
int DestBpp = m_DestBpp / 8;
@@ -849,10 +849,7 @@ FX_BOOL CFX_ImageStretcher::StartStretch() {
return TRUE;
}
FX_BOOL CFX_ImageStretcher::ContinueStretch(IFX_Pause* pPause) {
- if (m_pStretchEngine == NULL) {
- return FALSE;
- }
- return m_pStretchEngine->Continue(pPause);
+ return m_pStretchEngine && m_pStretchEngine->Continue(pPause);
}
FX_BOOL CFX_ImageStretcher::StartQuickStretch() {
m_bFlipX = FALSE;
@@ -883,7 +880,7 @@ FX_BOOL CFX_ImageStretcher::StartQuickStretch() {
return TRUE;
}
FX_BOOL CFX_ImageStretcher::ContinueQuickStretch(IFX_Pause* pPause) {
- if (m_pScanline == NULL) {
+ if (!m_pScanline) {
return FALSE;
}
int result_width = m_ClipRect.Width(), result_height = m_ClipRect.Height();
diff --git a/core/src/fxge/dib/fx_dib_main.cpp b/core/src/fxge/dib/fx_dib_main.cpp
index 44d6c5022c..87c113d4ae 100644
--- a/core/src/fxge/dib/fx_dib_main.cpp
+++ b/core/src/fxge/dib/fx_dib_main.cpp
@@ -89,7 +89,7 @@ FX_BOOL CFX_DIBitmap::Create(int width,
int oomlimit = _MAX_OOM_LIMIT_;
if (oomlimit >= 0 && size >= oomlimit) {
m_pBuffer = FX_TryAlloc(uint8_t, size);
- if (m_pBuffer == NULL) {
+ if (!m_pBuffer) {
return FALSE;
}
} else {
@@ -250,14 +250,14 @@ FX_DWORD CFX_DIBSource::GetPaletteEntry(int index) const {
}
void CFX_DIBSource::SetPaletteEntry(int index, FX_DWORD color) {
ASSERT((GetBPP() == 1 || GetBPP() == 8) && !IsAlphaMask());
- if (m_pPalette == NULL) {
+ if (!m_pPalette) {
BuildPalette();
}
m_pPalette[index] = color;
}
int CFX_DIBSource::FindPalette(FX_DWORD color) const {
ASSERT((GetBPP() == 1 || GetBPP() == 8) && !IsAlphaMask());
- if (m_pPalette == NULL) {
+ if (!m_pPalette) {
if (IsCmykImage()) {
if (GetBPP() == 1) {
return ((uint8_t)color == 0xff) ? 0 : 1;
@@ -277,7 +277,7 @@ int CFX_DIBSource::FindPalette(FX_DWORD color) const {
return -1;
}
void CFX_DIBitmap::Clear(FX_DWORD color) {
- if (m_pBuffer == NULL) {
+ if (!m_pBuffer) {
return;
}
switch (GetFormat()) {
@@ -377,7 +377,7 @@ FX_BOOL CFX_DIBitmap::TransferBitmap(int dest_left,
int src_left,
int src_top,
void* pIccTransform) {
- if (m_pBuffer == NULL) {
+ if (!m_pBuffer) {
return FALSE;
}
GetOverlapRect(dest_left, dest_top, width, height, pSrcBitmap->GetWidth(),
@@ -387,7 +387,7 @@ FX_BOOL CFX_DIBitmap::TransferBitmap(int dest_left,
}
FXDIB_Format dest_format = GetFormat();
FXDIB_Format src_format = pSrcBitmap->GetFormat();
- if (dest_format == src_format && pIccTransform == NULL) {
+ if (dest_format == src_format && !pIccTransform) {
if (GetBPP() == 1) {
for (int row = 0; row < height; row++) {
uint8_t* dest_scan = m_pBuffer + (dest_top + row) * m_Pitch;
@@ -440,7 +440,7 @@ FX_BOOL CFX_DIBitmap::TransferMask(int dest_left,
int src_top,
int alpha_flag,
void* pIccTransform) {
- if (m_pBuffer == NULL) {
+ if (!m_pBuffer) {
return FALSE;
}
ASSERT(HasAlpha() && (m_bpp >= 24));
@@ -540,12 +540,12 @@ FX_BOOL CFX_DIBitmap::TransferMask(int dest_left,
return TRUE;
}
void CFX_DIBSource::CopyPalette(const FX_DWORD* pSrc, FX_DWORD size) {
- if (pSrc == NULL || GetBPP() > 8) {
+ if (!pSrc || GetBPP() > 8) {
FX_Free(m_pPalette);
m_pPalette = NULL;
} else {
FX_DWORD pal_size = 1 << GetBPP();
- if (m_pPalette == NULL) {
+ if (!m_pPalette) {
m_pPalette = FX_Alloc(FX_DWORD, pal_size);
}
if (pal_size > size) {
@@ -628,7 +628,7 @@ const int g_ChannelOffset[] = {0, 2, 1, 0, 0, 1, 2, 3, 3};
FX_BOOL CFX_DIBitmap::LoadChannel(FXDIB_Channel destChannel,
const CFX_DIBSource* pSrcBitmap,
FXDIB_Channel srcChannel) {
- if (m_pBuffer == NULL) {
+ if (!m_pBuffer) {
return FALSE;
}
CFX_DIBSource* pSrcClone = (CFX_DIBSource*)pSrcBitmap;
@@ -640,7 +640,7 @@ FX_BOOL CFX_DIBitmap::LoadChannel(FXDIB_Channel destChannel,
}
if (pSrcBitmap->GetBPP() == 1) {
pSrcClone = pSrcBitmap->CloneConvert(FXDIB_8bppMask);
- if (pSrcClone == NULL) {
+ if (!pSrcClone) {
return FALSE;
}
}
@@ -661,7 +661,7 @@ FX_BOOL CFX_DIBitmap::LoadChannel(FXDIB_Channel destChannel,
pSrcClone = pSrcBitmap->CloneConvert(
(FXDIB_Format)((pSrcBitmap->GetFormat() & 0xff00) | 0x18));
}
- if (pSrcClone == NULL) {
+ if (!pSrcClone) {
return FALSE;
}
}
@@ -723,7 +723,7 @@ FX_BOOL CFX_DIBitmap::LoadChannel(FXDIB_Channel destChannel,
pSrcClone->GetHeight() != m_Height) {
if (pAlphaMask) {
pAlphaMask = pAlphaMask->StretchTo(m_Width, m_Height);
- if (pAlphaMask == NULL) {
+ if (!pAlphaMask) {
if (pSrcClone != pSrcBitmap) {
delete pSrcClone;
}
@@ -743,7 +743,7 @@ FX_BOOL CFX_DIBitmap::LoadChannel(FXDIB_Channel destChannel,
if (pSrcClone != pSrcBitmap) {
delete pSrcClone;
}
- if (pSrcMatched == NULL) {
+ if (!pSrcMatched) {
return FALSE;
}
pSrcClone = pSrcMatched;
@@ -769,7 +769,7 @@ FX_BOOL CFX_DIBitmap::LoadChannel(FXDIB_Channel destChannel,
return TRUE;
}
FX_BOOL CFX_DIBitmap::LoadChannel(FXDIB_Channel destChannel, int value) {
- if (m_pBuffer == NULL) {
+ if (!m_pBuffer) {
return FALSE;
}
int destOffset;
@@ -830,7 +830,7 @@ FX_BOOL CFX_DIBitmap::LoadChannel(FXDIB_Channel destChannel, int value) {
return TRUE;
}
FX_BOOL CFX_DIBitmap::MultiplyAlpha(const CFX_DIBSource* pSrcBitmap) {
- if (m_pBuffer == NULL) {
+ if (!m_pBuffer) {
return FALSE;
}
ASSERT(pSrcBitmap->IsAlphaMask());
@@ -844,7 +844,7 @@ FX_BOOL CFX_DIBitmap::MultiplyAlpha(const CFX_DIBSource* pSrcBitmap) {
if (pSrcBitmap->GetWidth() != m_Width ||
pSrcBitmap->GetHeight() != m_Height) {
pSrcClone = pSrcBitmap->StretchTo(m_Width, m_Height);
- if (pSrcClone == NULL) {
+ if (!pSrcClone) {
return FALSE;
}
}
@@ -897,12 +897,12 @@ FX_BOOL CFX_DIBitmap::MultiplyAlpha(const CFX_DIBSource* pSrcBitmap) {
return TRUE;
}
FX_BOOL CFX_DIBitmap::GetGrayData(void* pIccTransform) {
- if (m_pBuffer == NULL) {
+ if (!m_pBuffer) {
return FALSE;
}
switch (GetFormat()) {
case FXDIB_1bppRgb: {
- if (m_pPalette == NULL) {
+ if (!m_pPalette) {
return FALSE;
}
uint8_t gray[2];
@@ -933,7 +933,7 @@ FX_BOOL CFX_DIBitmap::GetGrayData(void* pIccTransform) {
break;
}
case FXDIB_8bppRgb: {
- if (m_pPalette == NULL) {
+ if (!m_pPalette) {
return FALSE;
}
uint8_t gray[256];
@@ -1001,7 +1001,7 @@ FX_BOOL CFX_DIBitmap::GetGrayData(void* pIccTransform) {
return TRUE;
}
FX_BOOL CFX_DIBitmap::MultiplyAlpha(int alpha) {
- if (m_pBuffer == NULL) {
+ if (!m_pBuffer) {
return FALSE;
}
switch (GetFormat()) {
@@ -1049,7 +1049,7 @@ FX_BOOL CFX_DIBitmap::MultiplyAlpha(int alpha) {
return TRUE;
}
FX_DWORD CFX_DIBitmap::GetPixel(int x, int y) const {
- if (m_pBuffer == NULL) {
+ if (!m_pBuffer) {
return 0;
}
uint8_t* pos = m_pBuffer + y * m_Pitch + x * GetBPP() / 8;
@@ -1082,7 +1082,7 @@ FX_DWORD CFX_DIBitmap::GetPixel(int x, int y) const {
return 0;
}
void CFX_DIBitmap::SetPixel(int x, int y, FX_DWORD color) {
- if (m_pBuffer == NULL) {
+ if (!m_pBuffer) {
return;
}
if (x < 0 || x >= m_Width || y < 0 || y >= m_Height) {
@@ -1157,7 +1157,7 @@ void CFX_DIBitmap::DownSampleScanline(int line,
FX_BOOL bFlipX,
int clip_left,
int clip_width) const {
- if (m_pBuffer == NULL) {
+ if (!m_pBuffer) {
return;
}
int src_Bpp = m_bpp / 8;
@@ -1217,7 +1217,7 @@ void CFX_DIBitmap::DownSampleScanline(int line,
FX_BOOL CFX_DIBitmap::ConvertColorScale(FX_DWORD forecolor,
FX_DWORD backcolor) {
ASSERT(!IsAlphaMask());
- if (m_pBuffer == NULL || IsAlphaMask()) {
+ if (!m_pBuffer || IsAlphaMask()) {
return FALSE;
}
int fc, fm, fy, fk, bc, bm, by, bk;
@@ -1242,13 +1242,13 @@ FX_BOOL CFX_DIBitmap::ConvertColorScale(FX_DWORD forecolor,
}
if (m_bpp <= 8) {
if (isCmykImage) {
- if (forecolor == 0xff && backcolor == 0 && m_pPalette == NULL) {
+ if (forecolor == 0xff && backcolor == 0 && !m_pPalette) {
return TRUE;
}
- } else if (forecolor == 0 && backcolor == 0xffffff && m_pPalette == NULL) {
+ } else if (forecolor == 0 && backcolor == 0xffffff && !m_pPalette) {
return TRUE;
}
- if (m_pPalette == NULL) {
+ if (!m_pPalette) {
BuildPalette();
}
int size = 1 << m_bpp;
@@ -1336,7 +1336,7 @@ FX_BOOL CFX_DIBitmap::ConvertColorScale(FX_DWORD forecolor,
FX_BOOL CFX_DIBitmap::DitherFS(const FX_DWORD* pPalette,
int pal_size,
const FX_RECT* pRect) {
- if (m_pBuffer == NULL) {
+ if (!m_pBuffer) {
return FALSE;
}
if (m_bpp != 8 && m_pPalette && m_AlphaFlag != 0) {
@@ -1490,9 +1490,7 @@ CFX_DIBitmap* CFX_DIBSource::FlipImage(FX_BOOL bXFlip, FX_BOOL bYFlip) const {
}
CFX_DIBExtractor::CFX_DIBExtractor(const CFX_DIBSource* pSrc) {
m_pBitmap = NULL;
- if (pSrc->GetBuffer() == NULL) {
- m_pBitmap = pSrc->Clone();
- } else {
+ if (pSrc->GetBuffer()) {
m_pBitmap = new CFX_DIBitmap;
if (!m_pBitmap->Create(pSrc->GetWidth(), pSrc->GetHeight(),
pSrc->GetFormat(), pSrc->GetBuffer())) {
@@ -1502,6 +1500,8 @@ CFX_DIBExtractor::CFX_DIBExtractor(const CFX_DIBSource* pSrc) {
}
m_pBitmap->CopyPalette(pSrc->GetPalette());
m_pBitmap->CopyAlphaMask(pSrc->m_pAlphaMask);
+ } else {
+ m_pBitmap = pSrc->Clone();
}
}
CFX_DIBExtractor::~CFX_DIBExtractor() {
@@ -1640,10 +1640,10 @@ FX_BOOL CFX_ImageRenderer::Continue(IFX_Pause* pPause) {
return TRUE;
}
CFX_DIBitmap* pBitmap = m_pTransformer->m_Storer.Detach();
- if (pBitmap == NULL) {
+ if (!pBitmap) {
return FALSE;
}
- if (pBitmap->GetBuffer() == NULL) {
+ if (!pBitmap->GetBuffer()) {
delete pBitmap;
return FALSE;
}
diff --git a/core/src/fxge/dib/fx_dib_transform.cpp b/core/src/fxge/dib/fx_dib_transform.cpp
index 7ff96d5ebf..d9740e0111 100644
--- a/core/src/fxge/dib/fx_dib_transform.cpp
+++ b/core/src/fxge/dib/fx_dib_transform.cpp
@@ -423,7 +423,7 @@ FX_BOOL CFX_ImageTransformer::Continue(IFX_Pause* pPause) {
}
int stretch_width = m_StretchClip.Width();
int stretch_height = m_StretchClip.Height();
- if (m_Storer.GetBitmap() == NULL) {
+ if (!m_Storer.GetBitmap()) {
return FALSE;
}
const uint8_t* stretch_buf = m_Storer.GetBitmap()->GetBuffer();
@@ -446,7 +446,7 @@ FX_BOOL CFX_ImageTransformer::Continue(IFX_Pause* pPause) {
(FX_FLOAT)(m_ResultTop));
result2stretch.Concat(m_dest2stretch);
result2stretch.TranslateI(-m_StretchClip.left, -m_StretchClip.top);
- if (stretch_buf_mask == NULL && pTransformed->m_pAlphaMask) {
+ if (!stretch_buf_mask && pTransformed->m_pAlphaMask) {
pTransformed->m_pAlphaMask->Clear(0xff000000);
} else if (pTransformed->m_pAlphaMask) {
int stretch_pitch_mask = m_Storer.GetBitmap()->m_pAlphaMask->GetPitch();
diff --git a/core/src/fxge/ge/fx_ge.cpp b/core/src/fxge/ge/fx_ge.cpp
index 138f81840e..f7787cf22c 100644
--- a/core/src/fxge/ge/fx_ge.cpp
+++ b/core/src/fxge/ge/fx_ge.cpp
@@ -41,7 +41,7 @@ void CFX_GEModule::Destroy() {
g_pGEModule = NULL;
}
CFX_FontCache* CFX_GEModule::GetFontCache() {
- if (m_pFontCache == NULL) {
+ if (!m_pFontCache) {
m_pFontCache = new CFX_FontCache();
}
return m_pFontCache;
diff --git a/core/src/fxge/ge/fx_ge_device.cpp b/core/src/fxge/ge/fx_ge_device.cpp
index 37204268f2..268001b285 100644
--- a/core/src/fxge/ge/fx_ge_device.cpp
+++ b/core/src/fxge/ge/fx_ge_device.cpp
@@ -130,7 +130,7 @@ FX_BOOL CFX_RenderDevice::DrawPath(const CFX_PathData* pPathData,
if ((fill_mode & 3) == 0) {
fill_alpha = 0;
}
- if (pGraphState == NULL) {
+ if (!pGraphState) {
stroke_alpha = 0;
}
if (stroke_alpha == 0 && pPathData->GetPointCount() == 2) {
diff --git a/core/src/fxge/ge/fx_ge_font.cpp b/core/src/fxge/ge/fx_ge_font.cpp
index 92dbf3adeb..4c0cef40c4 100644
--- a/core/src/fxge/ge/fx_ge_font.cpp
+++ b/core/src/fxge/ge/fx_ge_font.cpp
@@ -373,7 +373,7 @@ FX_BOOL CFX_Font::IsFixedWidth() const {
}
CFX_WideString CFX_Font::GetPsName() const {
- if (m_Face == NULL) {
+ if (!m_Face) {
return CFX_WideString();
}
CFX_WideString psName =
@@ -384,7 +384,7 @@ CFX_WideString CFX_Font::GetPsName() const {
return psName;
}
CFX_ByteString CFX_Font::GetFamilyName() const {
- if (m_Face == NULL && m_pSubstFont == NULL) {
+ if (!m_Face && !m_pSubstFont) {
return CFX_ByteString();
}
if (m_Face) {
@@ -393,7 +393,7 @@ CFX_ByteString CFX_Font::GetFamilyName() const {
return m_pSubstFont->m_Family;
}
CFX_ByteString CFX_Font::GetFaceName() const {
- if (m_Face == NULL && m_pSubstFont == NULL) {
+ if (!m_Face && !m_pSubstFont) {
return CFX_ByteString();
}
if (m_Face) {
@@ -411,7 +411,7 @@ CFX_ByteString CFX_Font::GetFaceName() const {
return m_pSubstFont->m_Family;
}
FX_BOOL CFX_Font::GetBBox(FX_RECT& bbox) {
- if (m_Face == NULL) {
+ if (!m_Face) {
return FALSE;
}
int em = FXFT_Get_Face_UnitsPerEM(m_Face);
diff --git a/core/src/fxge/ge/fx_ge_fontmap.cpp b/core/src/fxge/ge/fx_ge_fontmap.cpp
index dfd6704fe1..7f5dbe0ce7 100644
--- a/core/src/fxge/ge/fx_ge_fontmap.cpp
+++ b/core/src/fxge/ge/fx_ge_fontmap.cpp
@@ -315,10 +315,7 @@ CFX_ByteString GetFontFamily(CFX_ByteString fontName, int nStyle) {
fontName.c_str(), g_AltFontFamilies,
sizeof g_AltFontFamilies / sizeof(AltFontFamily), sizeof(AltFontFamily),
CompareFontFamilyString);
- if (found == NULL) {
- return fontName;
- }
- return found->m_pFontFamily;
+ return found ? CFX_ByteString(found->m_pFontFamily) : fontName;
}
CFX_ByteString ParseStyle(const FX_CHAR* pStyle, int iLen, int iIndex) {
@@ -679,7 +676,7 @@ CFX_FontMapper::~CFX_FontMapper() {
}
}
void CFX_FontMapper::SetSystemFontInfo(IFX_SystemFontInfo* pFontInfo) {
- if (pFontInfo == NULL) {
+ if (!pFontInfo) {
return;
}
if (m_pFontInfo) {
@@ -721,7 +718,7 @@ CFX_ByteString CFX_FontMapper::GetPSNameFromTT(void* hFont) {
}
void CFX_FontMapper::AddInstalledFont(const CFX_ByteString& name, int charset) {
- if (m_pFontInfo == NULL) {
+ if (!m_pFontInfo) {
return;
}
if (m_CharsetArray.Find((FX_DWORD)charset) == -1) {
@@ -740,11 +737,11 @@ void CFX_FontMapper::AddInstalledFont(const CFX_ByteString& name, int charset) {
}
if (bLocalized) {
void* hFont = m_pFontInfo->GetFont(name);
- if (hFont == NULL) {
+ if (!hFont) {
int iExact;
hFont =
m_pFontInfo->MapFont(0, 0, FXFONT_DEFAULT_CHARSET, 0, name, iExact);
- if (hFont == NULL) {
+ if (!hFont) {
return;
}
}
@@ -759,7 +756,7 @@ void CFX_FontMapper::AddInstalledFont(const CFX_ByteString& name, int charset) {
m_LastFamily = name;
}
void CFX_FontMapper::LoadInstalledFonts() {
- if (m_pFontInfo == NULL) {
+ if (!m_pFontInfo) {
return;
}
if (m_bListLoaded) {
@@ -1019,7 +1016,7 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name,
Charset == FXFONT_CHINESEBIG5_CHARSET) {
bCJK = TRUE;
}
- if (m_pFontInfo == NULL) {
+ if (!m_pFontInfo) {
pSubstFont->m_SubstFlags |= FXFONT_SUBST_STANDARD;
return UseInternalSubst(pSubstFont, iBaseFont, italic_angle, old_weight,
PitchFamily);
@@ -1088,7 +1085,7 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name,
if (iExact) {
pSubstFont->m_SubstFlags |= FXFONT_SUBST_EXACT;
}
- if (hFont == NULL) {
+ if (!hFont) {
#ifdef PDF_ENABLE_XFA
if (flags & FXFONT_EXACTMATCH) {
return NULL;
@@ -1104,7 +1101,7 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name,
}
if (!match.IsEmpty()) {
hFont = m_pFontInfo->GetFont(match);
- if (hFont == NULL) {
+ if (!hFont) {
return UseInternalSubst(pSubstFont, iBaseFont, italic_angle, old_weight,
PitchFamily);
}
@@ -1168,7 +1165,7 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name,
uint8_t* pFontData;
face = m_pFontMgr->GetCachedTTCFace(ttc_size, checksum,
ttc_size - font_size, pFontData);
- if (face == NULL) {
+ if (!face) {
pFontData = FX_Alloc(uint8_t, ttc_size);
m_pFontInfo->GetFontData(hFont, kTableTTCF, pFontData, ttc_size);
face = m_pFontMgr->AddCachedTTCFace(ttc_size, checksum, pFontData,
@@ -1177,7 +1174,7 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name,
} else {
uint8_t* pFontData;
face = m_pFontMgr->GetCachedFace(SubstName, weight, bItalic, pFontData);
- if (face == NULL) {
+ if (!face) {
pFontData = FX_Alloc(uint8_t, font_size);
m_pFontInfo->GetFontData(hFont, 0, pFontData, font_size);
face = m_pFontMgr->AddCachedFace(SubstName, weight, bItalic, pFontData,
@@ -1185,7 +1182,7 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name,
m_pFontInfo->GetFaceIndex(hFont));
}
}
- if (face == NULL) {
+ if (!face) {
m_pFontInfo->DeleteFont(hFont);
return NULL;
}
@@ -1337,7 +1334,7 @@ FX_BOOL CFX_FolderFontInfo::EnumFontList(CFX_FontMapper* pMapper) {
}
void CFX_FolderFontInfo::ScanPath(CFX_ByteString& path) {
void* handle = FX_OpenFolder(path);
- if (handle == NULL) {
+ if (!handle) {
return;
}
CFX_ByteString filename;
@@ -1371,7 +1368,7 @@ void CFX_FolderFontInfo::ScanPath(CFX_ByteString& path) {
}
void CFX_FolderFontInfo::ScanFile(CFX_ByteString& path) {
FXSYS_FILE* pFile = FXSYS_fopen(path, "rb");
- if (pFile == NULL) {
+ if (!pFile) {
return;
}
FXSYS_fseek(pFile, 0, FXSYS_SEEK_END);
@@ -1582,7 +1579,7 @@ FX_DWORD CFX_FolderFontInfo::GetFontData(void* hFont,
void CFX_FolderFontInfo::DeleteFont(void* hFont) {}
FX_BOOL CFX_FolderFontInfo::GetFaceName(void* hFont, CFX_ByteString& name) {
- if (hFont == NULL) {
+ if (!hFont) {
return FALSE;
}
CFX_FontFaceInfo* pFont = (CFX_FontFaceInfo*)hFont;
diff --git a/core/src/fxge/ge/fx_ge_path.cpp b/core/src/fxge/ge/fx_ge_path.cpp
index 543c33ba14..23b1c2fe07 100644
--- a/core/src/fxge/ge/fx_ge_path.cpp
+++ b/core/src/fxge/ge/fx_ge_path.cpp
@@ -384,7 +384,7 @@ CFX_FloatRect CFX_PathData::GetBoundingBox(FX_FLOAT line_width,
return rect;
}
void CFX_PathData::Transform(const CFX_Matrix* pMatrix) {
- if (pMatrix == NULL) {
+ if (!pMatrix) {
return;
}
for (int i = 0; i < m_PointCount; i++) {
@@ -564,7 +564,7 @@ FX_BOOL CFX_PathData::IsRect() const {
}
FX_BOOL CFX_PathData::IsRect(const CFX_Matrix* pMatrix,
CFX_FloatRect* pRect) const {
- if (pMatrix == NULL) {
+ if (!pMatrix) {
if (!IsRect()) {
return FALSE;
}
diff --git a/core/src/fxge/ge/fx_ge_ps.cpp b/core/src/fxge/ge/fx_ge_ps.cpp
index ceb2acf2bc..f9fd8dea30 100644
--- a/core/src/fxge/ge/fx_ge_ps.cpp
+++ b/core/src/fxge/ge/fx_ge_ps.cpp
@@ -374,7 +374,7 @@ FX_BOOL CFX_PSRenderer::DrawDIBits(const CFX_DIBSource* pSource,
int width = pSource->GetWidth();
int height = pSource->GetHeight();
buf << width << " " << height;
- if (pSource->GetBPP() == 1 && pSource->GetPalette() == NULL) {
+ if (pSource->GetBPP() == 1 && !pSource->GetPalette()) {
int pitch = (width + 7) / 8;
FX_DWORD src_size = height * pitch;
uint8_t* src_buf = FX_Alloc(uint8_t, src_size);
@@ -433,7 +433,7 @@ FX_BOOL CFX_PSRenderer::DrawDIBits(const CFX_DIBSource* pSource,
break;
}
}
- if (pConverted == NULL) {
+ if (!pConverted) {
OUTPUT_PS("\nQ\n");
return FALSE;
}
@@ -449,7 +449,7 @@ FX_BOOL CFX_PSRenderer::DrawDIBits(const CFX_DIBSource* pSource,
filter = "/DCTDecode filter ";
}
}
- if (filter == NULL) {
+ if (!filter) {
int src_pitch = width * Bpp;
output_size = height * src_pitch;
output_buf = FX_Alloc(uint8_t, output_size);
@@ -603,7 +603,7 @@ void CFX_PSRenderer::FindPSFontGlyph(CFX_FaceCache* pFaceCache,
matrix.Concat(1.0f, 0, 0, 1.0f, 0, 0);
const CFX_PathData* pPathData = pFaceCache->LoadGlyphPath(
pFont, charpos.m_GlyphIndex, charpos.m_FontCharWidth);
- if (pPathData == NULL) {
+ if (!pPathData) {
return;
}
CFX_PathData TransformedPath(*pPathData);
@@ -663,7 +663,7 @@ FX_BOOL CFX_PSRenderer::DrawText(int nChars,
buf << "q[" << pObject2Device->a << " " << pObject2Device->b << " "
<< pObject2Device->c << " " << pObject2Device->d << " "
<< pObject2Device->e << " " << pObject2Device->f << "]cm\n";
- if (pCache == NULL) {
+ if (!pCache) {
pCache = CFX_GEModule::Get()->GetFontCache();
}
CFX_FaceCache* pFaceCache = pCache->GetCachedFace(pFont);
diff --git a/core/src/fxge/ge/fx_ge_text.cpp b/core/src/fxge/ge/fx_ge_text.cpp
index cd6b690a12..0ed0bbbbd6 100644
--- a/core/src/fxge/ge/fx_ge_text.cpp
+++ b/core/src/fxge/ge/fx_ge_text.cpp
@@ -51,7 +51,7 @@ FX_RECT FXGE_GetGlyphsBBox(FXTEXT_GLYPHPOS* pGlyphAndPos,
for (int iChar = 0; iChar < nChars; iChar++) {
FXTEXT_GLYPHPOS& glyph = pGlyphAndPos[iChar];
const CFX_GlyphBitmap* pGlyph = glyph.m_pGlyph;
- if (pGlyph == NULL) {
+ if (!pGlyph) {
continue;
}
int char_left = glyph.m_OriginX + pGlyph->m_Left;
@@ -141,7 +141,7 @@ void _Color2Argb(FX_ARGB& argb,
FX_DWORD color,
int alpha_flag,
void* pIccTransform) {
- if (pIccTransform == NULL && !FXGETFLAG_COLORTYPE(alpha_flag)) {
+ if (!pIccTransform && !FXGETFLAG_COLORTYPE(alpha_flag)) {
argb = color;
return;
}
@@ -243,7 +243,7 @@ FX_BOOL CFX_RenderDevice::DrawNormalText(int nChars,
if ((text_flags & FXTEXT_NOSMOOTH) == 0) {
if (m_DeviceClass == FXDC_DISPLAY && m_bpp > 1) {
FX_BOOL bClearType;
- if (pFont->GetFace() == NULL &&
+ if (!pFont->GetFace() &&
!(pFont->GetSubstFont()->m_SubstFlags & FXFONT_SUBST_CLEARTYPE)) {
bClearType = FALSE;
} else {
@@ -264,7 +264,7 @@ FX_BOOL CFX_RenderDevice::DrawNormalText(int nChars,
}
}
}
- if (pCache == NULL) {
+ if (!pCache) {
pCache = CFX_GEModule::Get()->GetFontCache();
}
CFX_FaceCache* pFaceCache = pCache->GetCachedFace(pFont);
@@ -335,7 +335,7 @@ FX_BOOL CFX_RenderDevice::DrawNormalText(int nChars,
bitmap.Clear(0);
for (iChar = 0; iChar < nChars; iChar++) {
FXTEXT_GLYPHPOS& glyph = pGlyphAndPos[iChar];
- if (glyph.m_pGlyph == NULL) {
+ if (!glyph.m_pGlyph) {
continue;
}
const CFX_DIBitmap* pGlyph = &glyph.m_pGlyph->m_Bitmap;
@@ -385,7 +385,7 @@ FX_BOOL CFX_RenderDevice::DrawNormalText(int nChars,
}
for (iChar = 0; iChar < nChars; iChar++) {
FXTEXT_GLYPHPOS& glyph = pGlyphAndPos[iChar];
- if (glyph.m_pGlyph == NULL) {
+ if (!glyph.m_pGlyph) {
continue;
}
const CFX_DIBitmap* pGlyph = &glyph.m_pGlyph->m_Bitmap;
@@ -1118,7 +1118,7 @@ FX_BOOL CFX_RenderDevice::DrawTextPath(int nChars,
int alpha_flag,
void* pIccTransform,
int blend_type) {
- if (pCache == NULL) {
+ if (!pCache) {
pCache = CFX_GEModule::Get()->GetFontCache();
}
CFX_FaceCache* pFaceCache = pCache->GetCachedFace(pFont);
@@ -1133,7 +1133,7 @@ FX_BOOL CFX_RenderDevice::DrawTextPath(int nChars,
charpos.m_OriginY);
const CFX_PathData* pPath = pFaceCache->LoadGlyphPath(
pFont, charpos.m_GlyphIndex, charpos.m_FontCharWidth);
- if (pPath == NULL) {
+ if (!pPath) {
continue;
}
matrix.Concat(*pText2User);
@@ -1378,7 +1378,7 @@ CFX_SizeGlyphCache::~CFX_SizeGlyphCache() {
void CFX_Font::AdjustMMParams(int glyph_index, int dest_width, int weight) {
FXFT_MM_Var pMasters = NULL;
FXFT_Get_MM_Var(m_Face, &pMasters);
- if (pMasters == NULL) {
+ if (!pMasters) {
return;
}
long coords[2];
@@ -1511,7 +1511,7 @@ CFX_GlyphBitmap* CFX_FaceCache::RenderGlyph(CFX_Font* pFont,
const CFX_Matrix* pMatrix,
int dest_width,
int anti_alias) {
- if (m_Face == NULL) {
+ if (!m_Face) {
return NULL;
}
FXFT_Matrix ft_matrix;
@@ -1787,7 +1787,7 @@ static int _Outline_CubicTo(const FXFT_Vector* control1,
}
};
CFX_PathData* CFX_Font::LoadGlyphPath(FX_DWORD glyph_index, int dest_width) {
- if (m_Face == NULL) {
+ if (!m_Face) {
return NULL;
}
FXFT_Set_Pixel_Sizes(m_Face, 0, 64);
diff --git a/core/src/fxge/skia/fx_skia_blitter_new.cpp b/core/src/fxge/skia/fx_skia_blitter_new.cpp
index ed7b1c74bf..85391cb77a 100644
--- a/core/src/fxge/skia/fx_skia_blitter_new.cpp
+++ b/core/src/fxge/skia/fx_skia_blitter_new.cpp
@@ -16,7 +16,7 @@ void CFX_SkiaRenderer::blitAntiH(int x,
const SkAlpha antialias[],
const int16_t runs[]) {
FXSYS_assert(m_Alpha);
- if (m_pOriDevice == NULL && composite_span == NULL)
+ if (!m_pOriDevice && !composite_span)
return;
if (y < m_ClipBox.top || y >= m_ClipBox.bottom)
return;
@@ -106,12 +106,13 @@ void CFX_SkiaRenderer::CompositeSpan1bpp_0(uint8_t* dest_scan,
dest_scan += col_start / 8;
int index = 0;
- if (m_pDevice->GetPalette() == NULL)
- index = ((uint8_t)m_Color == 0xff) ? 1 : 0;
- else {
- for (int i = 0; i < 2; i++)
+ if (m_pDevice->GetPalette()) {
+ for (int i = 0; i < 2; i++) {
if (FXARGB_TODIB(m_pDevice->GetPalette()[i]) == m_Color)
index = i;
+ }
+ } else {
+ index = ((uint8_t)m_Color == 0xff) ? 1 : 0;
}
uint8_t* dest_scan1 = dest_scan;
int src_alpha = m_Alpha * cover_scan / 255;
@@ -150,12 +151,13 @@ void CFX_SkiaRenderer::CompositeSpan1bpp_4(uint8_t* dest_scan,
dest_scan += col_start / 8;
int index = 0;
- if (m_pDevice->GetPalette() == NULL)
- index = ((uint8_t)m_Color == 0xff) ? 1 : 0;
- else {
- for (int i = 0; i < 2; i++)
+ if (m_pDevice->GetPalette()) {
+ for (int i = 0; i < 2; i++) {
if (FXARGB_TODIB(m_pDevice->GetPalette()[i]) == m_Color)
index = i;
+ }
+ } else {
+ index = ((uint8_t)m_Color == 0xff) ? 1 : 0;
}
uint8_t* dest_scan1 = dest_scan;
int src_alpha = m_Alpha * cover_scan / 255;
@@ -1736,9 +1738,7 @@ FX_BOOL CFX_SkiaRenderer::Init(
composite_span = &CFX_SkiaRenderer::CompositeSpanRGB24_14;
break;
}
- if (composite_span == NULL)
- return FALSE;
- return TRUE;
+ return !!composite_span;
}
/*----------------------------------------------------------------------------------------------------*/
diff --git a/core/src/fxge/skia/fx_skia_device.cpp b/core/src/fxge/skia/fx_skia_device.cpp
index 8e012c82e0..2e0371f312 100644
--- a/core/src/fxge/skia/fx_skia_device.cpp
+++ b/core/src/fxge/skia/fx_skia_device.cpp
@@ -212,20 +212,7 @@ static void SkRasterizeStroke(SkPaint& spaint,
if (width <= unit)
width = unit;
- if (pGraphState->m_DashArray == NULL) {
- SkStroke stroker;
- stroker.setCap(cap);
- stroker.setJoin(join);
- stroker.setMiterLimit(pGraphState->m_MiterLimit);
- stroker.setWidth(width);
- stroker.setDoFill(FALSE);
- stroker.strokePath(path_data, dstPathData);
- SkMatrix smatrix;
- smatrix.setAll(pObject2Device->a, pObject2Device->c, pObject2Device->e,
- pObject2Device->b, pObject2Device->d, pObject2Device->f, 0,
- 0, 1);
- dstPathData->transform(smatrix);
- } else {
+ if (pGraphState->m_DashArray) {
int count = (pGraphState->m_DashCount + 1) / 2;
SkScalar* intervals = FX_Alloc2D(SkScalar, count, sizeof(SkScalar));
// Set dash pattern
@@ -255,6 +242,19 @@ static void SkRasterizeStroke(SkPaint& spaint,
0, 1);
dstPathData->transform(smatrix);
FX_Free(intervals);
+ } else {
+ SkStroke stroker;
+ stroker.setCap(cap);
+ stroker.setJoin(join);
+ stroker.setMiterLimit(pGraphState->m_MiterLimit);
+ stroker.setWidth(width);
+ stroker.setDoFill(FALSE);
+ stroker.strokePath(path_data, dstPathData);
+ SkMatrix smatrix;
+ smatrix.setAll(pObject2Device->a, pObject2Device->c, pObject2Device->e,
+ pObject2Device->b, pObject2Device->d, pObject2Device->f, 0,
+ 0, 1);
+ dstPathData->transform(smatrix);
}
}
@@ -331,9 +331,10 @@ FX_BOOL CFX_SkiaDeviceDriver::SetClip_PathFill(
const CFX_Matrix* pObject2Device, // optional transformation
int fill_mode // fill mode, WINDING or ALTERNATE
) {
- if (m_pAggDriver->m_pClipRgn == NULL)
+ if (!m_pAggDriver->m_pClipRgn) {
m_pAggDriver->m_pClipRgn = new CFX_ClipRgn(
GetDeviceCaps(FXDC_PIXEL_WIDTH), GetDeviceCaps(FXDC_PIXEL_HEIGHT));
+ }
if (pPathData->GetPointCount() == 5 || pPathData->GetPointCount() == 4) {
CFX_FloatRect rectf;
@@ -368,9 +369,10 @@ FX_BOOL CFX_SkiaDeviceDriver::SetClip_PathStroke(
const CFX_Matrix* pObject2Device, // optional transformation
const CFX_GraphStateData* pGraphState // graphic state, for pen attributes
) {
- if (m_pAggDriver->m_pClipRgn == NULL)
+ if (!m_pAggDriver->m_pClipRgn) {
m_pAggDriver->m_pClipRgn = new CFX_ClipRgn(
GetDeviceCaps(FXDC_PIXEL_WIDTH), GetDeviceCaps(FXDC_PIXEL_HEIGHT));
+ }
// build path data
CSkia_PathData path_data;
@@ -432,7 +434,7 @@ FX_BOOL CFX_SkiaDeviceDriver::DrawPath(
int fill_mode, // fill mode, WINDING or ALTERNATE. 0 for not filled
int alpha_flag,
void* pIccTransform) {
- if (GetBuffer() == NULL)
+ if (!GetBuffer())
return TRUE;
FOXIT_DEBUG1("CFX_SkiaDeviceDriver::DrawPath: entering");
SkIRect rect;
@@ -592,7 +594,7 @@ FX_BOOL CFX_SkiaDevice::Attach(CFX_DIBitmap* pBitmap,
FX_BOOL bRgbByteOrder,
CFX_DIBitmap* pOriDevice,
FX_BOOL bGroupKnockout) {
- if (pBitmap == NULL)
+ if (!pBitmap)
return FALSE;
SetBitmap(pBitmap);
CFX_SkiaDeviceDriver* pDriver = new CFX_SkiaDeviceDriver(
diff --git a/core/src/fxge/win32/fx_win32_device.cpp b/core/src/fxge/win32/fx_win32_device.cpp
index 6d520468a3..c346d1bbc1 100644
--- a/core/src/fxge/win32/fx_win32_device.cpp
+++ b/core/src/fxge/win32/fx_win32_device.cpp
@@ -192,7 +192,7 @@ static const struct {
{"Times-Italic", "Times New Roman", FALSE, TRUE},
};
CFX_ByteString CFX_Win32FontInfo::FindFont(const CFX_ByteString& name) {
- if (m_pMapper == NULL) {
+ if (!m_pMapper) {
return name;
}
int nFonts = m_pMapper->m_InstalledTTFonts.GetSize();
@@ -251,7 +251,7 @@ FX_BOOL _GetSubFontName(CFX_ByteString& name) {
_FontNameMap* found = (_FontNameMap*)FXSYS_bsearch(
name.c_str(), pFontnameMap, size / sizeof(_FontNameMap),
sizeof(_FontNameMap), compareString);
- if (found == NULL) {
+ if (!found) {
return FALSE;
}
name = found->m_pSubFontName;
@@ -528,7 +528,7 @@ FX_BOOL CGdiDeviceDriver::GDI_SetDIBits(const CFX_DIBitmap* pBitmap1,
void* pIccTransform) {
if (m_DeviceClass == FXDC_PRINTER) {
CFX_DIBitmap* pBitmap = pBitmap1->FlipImage(FALSE, TRUE);
- if (pBitmap == NULL) {
+ if (!pBitmap) {
return FALSE;
}
if ((pBitmap->IsCmykImage() || pIccTransform) &&
@@ -575,7 +575,7 @@ FX_BOOL CGdiDeviceDriver::GDI_StretchDIBits(const CFX_DIBitmap* pBitmap1,
FX_DWORD flags,
void* pIccTransform) {
CFX_DIBitmap* pBitmap = (CFX_DIBitmap*)pBitmap1;
- if (pBitmap == NULL || dest_width == 0 || dest_height == 0) {
+ if (!pBitmap || dest_width == 0 || dest_height == 0) {
return FALSE;
}
if ((pBitmap->IsCmykImage() || pIccTransform) &&
@@ -620,7 +620,7 @@ FX_BOOL CGdiDeviceDriver::GDI_StretchBitMask(const CFX_DIBitmap* pBitmap1,
int alpha_flag,
void* pIccTransform) {
CFX_DIBitmap* pBitmap = (CFX_DIBitmap*)pBitmap1;
- if (pBitmap == NULL || dest_width == 0 || dest_height == 0) {
+ if (!pBitmap || dest_width == 0 || dest_height == 0) {
return FALSE;
}
_Color2Argb(bitmap_color, bitmap_color, alpha_flag | (1 << 24),
@@ -855,7 +855,7 @@ FX_BOOL CGdiDeviceDriver::DrawPath(const CFX_PathData* pPathData,
_Color2Argb(stroke_color, stroke_color, alpha_flag, pIccTransform);
CWin32Platform* pPlatform =
(CWin32Platform*)CFX_GEModule::Get()->GetPlatformData();
- if ((pGraphState == NULL || stroke_color == 0) &&
+ if (!(pGraphState || stroke_color == 0) &&
!pPlatform->m_GdiplusExt.IsAvailable()) {
CFX_FloatRect bbox_f = pPathData->GetBoundingBox();
if (pMatrix) {
@@ -1066,8 +1066,7 @@ FX_BOOL CGdiDisplayDriver::GetDIBits(CFX_DIBitmap* pBitmap,
!CFX_GEModule::Get()->GetCodecModule()->GetIccModule()) {
pIccTransform = NULL;
}
- if (pBitmap->GetBPP() > 8 && !pBitmap->IsCmykImage() &&
- pIccTransform == NULL) {
+ if (pBitmap->GetBPP() > 8 && !pBitmap->IsCmykImage() && !pIccTransform) {
ret = ::GetDIBits(hDCMemory, hbmp, 0, height, pBitmap->GetBuffer(), &bmi,
DIB_RGB_COLORS) == height;
} else {
@@ -1165,7 +1164,7 @@ FX_BOOL CGdiDisplayDriver::UseFoxitStretchEngine(const CFX_DIBSource* pSource,
bitmap_clip.Offset(-dest_left, -dest_top);
CFX_DIBitmap* pStretched =
pSource->StretchTo(dest_width, dest_height, render_flags, &bitmap_clip);
- if (pStretched == NULL) {
+ if (!pStretched) {
return TRUE;
}
FX_RECT src_rect(0, 0, pStretched->GetWidth(), pStretched->GetHeight());
@@ -1205,7 +1204,7 @@ FX_BOOL CGdiDisplayDriver::StretchDIBits(const CFX_DIBSource* pSource,
int clip_width = clip_rect.Width(), clip_height = clip_rect.Height();
CFX_DIBitmap* pStretched =
pSource->StretchTo(dest_width, dest_height, flags, &clip_rect);
- if (pStretched == NULL) {
+ if (!pStretched) {
return TRUE;
}
CFX_DIBitmap background;
@@ -1228,11 +1227,11 @@ FX_BOOL CGdiDisplayDriver::StretchDIBits(const CFX_DIBSource* pSource,
if (pSource->HasAlpha()) {
CWin32Platform* pPlatform =
(CWin32Platform*)CFX_GEModule::Get()->GetPlatformData();
- if (pPlatform->m_GdiplusExt.IsAvailable() && pIccTransform == NULL &&
+ if (pPlatform->m_GdiplusExt.IsAvailable() && !pIccTransform &&
!pSource->IsCmykImage()) {
CFX_DIBExtractor temp(pSource);
CFX_DIBitmap* pBitmap = temp;
- if (pBitmap == NULL) {
+ if (!pBitmap) {
return FALSE;
}
return pPlatform->m_GdiplusExt.StretchDIBits(
@@ -1340,7 +1339,7 @@ CFX_WinBitmapDevice::CFX_WinBitmapDevice(int width,
uint8_t* pBuffer;
m_hBitmap = CreateDIBSection(NULL, (BITMAPINFO*)&bmih, DIB_RGB_COLORS,
(void**)&pBuffer, NULL, 0);
- if (m_hBitmap == NULL) {
+ if (!m_hBitmap) {
return;
}
CFX_DIBitmap* pBitmap = new CFX_DIBitmap;
diff --git a/core/src/fxge/win32/fx_win32_dib.cpp b/core/src/fxge/win32/fx_win32_dib.cpp
index 1aa60f084e..1fdf3ae9b1 100644
--- a/core/src/fxge/win32/fx_win32_dib.cpp
+++ b/core/src/fxge/win32/fx_win32_dib.cpp
@@ -28,24 +28,24 @@ CFX_ByteString CFX_WindowsDIB::GetBitmapInfo(const CFX_DIBitmap* pBitmap) {
pbmih->biWidth = pBitmap->GetWidth();
if (pBitmap->GetBPP() == 8) {
FX_DWORD* pPalette = (FX_DWORD*)(pbmih + 1);
- if (pBitmap->GetPalette() == NULL) {
+ if (pBitmap->GetPalette()) {
for (int i = 0; i < 256; i++) {
- pPalette[i] = i * 0x010101;
+ pPalette[i] = pBitmap->GetPalette()[i];
}
} else {
for (int i = 0; i < 256; i++) {
- pPalette[i] = pBitmap->GetPalette()[i];
+ pPalette[i] = i * 0x010101;
}
}
}
if (pBitmap->GetBPP() == 1) {
FX_DWORD* pPalette = (FX_DWORD*)(pbmih + 1);
- if (pBitmap->GetPalette() == NULL) {
- pPalette[0] = 0;
- pPalette[1] = 0xffffff;
- } else {
+ if (pBitmap->GetPalette()) {
pPalette[0] = pBitmap->GetPalette()[0];
pPalette[1] = pBitmap->GetPalette()[1];
+ } else {
+ pPalette[0] = 0;
+ pPalette[1] = 0xffffff;
}
}
result.ReleaseBuffer(len);
@@ -125,7 +125,7 @@ CFX_DIBitmap* CFX_WindowsDIB::LoadFromFile(const FX_WCHAR* filename) {
}
HBITMAP hBitmap = (HBITMAP)LoadImageW(NULL, (wchar_t*)filename, IMAGE_BITMAP,
0, 0, LR_LOADFROMFILE);
- if (hBitmap == NULL) {
+ if (!hBitmap) {
return NULL;
}
HDC hDC = CreateCompatibleDC(NULL);
@@ -158,7 +158,7 @@ CFX_DIBitmap* CFX_WindowsDIB::LoadDIBitmap(WINDIB_Open_Args_ args) {
}
HBITMAP hBitmap = (HBITMAP)LoadImageW(NULL, (wchar_t*)args.path_name,
IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
- if (hBitmap == NULL) {
+ if (!hBitmap) {
return NULL;
}
HDC hDC = CreateCompatibleDC(NULL);
@@ -184,8 +184,8 @@ CFX_DIBitmap* CFX_WindowsDIB::LoadFromDDB(HDC hDC,
HBITMAP hBitmap,
FX_DWORD* pPalette,
FX_DWORD palsize) {
- FX_BOOL bCreatedDC = hDC == NULL;
- if (hDC == NULL) {
+ FX_BOOL bCreatedDC = !hDC;
+ if (bCreatedDC) {
hDC = CreateCompatibleDC(NULL);
}
BITMAPINFOHEADER bmih;
diff --git a/core/src/fxge/win32/fx_win32_dwrite.cpp b/core/src/fxge/win32/fx_win32_dwrite.cpp
index 83924f23e7..9e56ee7672 100644
--- a/core/src/fxge/win32/fx_win32_dwrite.cpp
+++ b/core/src/fxge/win32/fx_win32_dwrite.cpp
@@ -65,7 +65,7 @@ class CDwFontFileLoader final : public IDWriteFontFileLoader {
OUT IDWriteFontFileStream** fontFileStream);
static IDWriteFontFileLoader* GetLoader() {
- if (instance_ == NULL) {
+ if (!instance_) {
instance_ = new CDwFontFileLoader();
}
return instance_;
@@ -216,7 +216,7 @@ FX_BOOL CDWriteExt::DwRendingString(void* renderTarget,
FX_FLOAT baselineOriginY,
void* glyph_offsets,
FX_FLOAT* glyph_advances) {
- if (renderTarget == NULL) {
+ if (!renderTarget) {
return TRUE;
}
CDwGdiTextRenderer* pTextRenderer = (CDwGdiTextRenderer*)renderTarget;
diff --git a/core/src/fxge/win32/fx_win32_gdipext.cpp b/core/src/fxge/win32/fx_win32_gdipext.cpp
index e79a88cb81..1e4f89540b 100644
--- a/core/src/fxge/win32/fx_win32_gdipext.cpp
+++ b/core/src/fxge/win32/fx_win32_gdipext.cpp
@@ -686,12 +686,12 @@ void CGdiplusExt::Load() {
strPlusPath += "\\";
strPlusPath += "GDIPLUS.DLL";
m_hModule = LoadLibraryA(strPlusPath);
- if (m_hModule == NULL) {
+ if (!m_hModule) {
return;
}
for (int i = 0; i < sizeof g_GdipFuncNames / sizeof(LPCSTR); i++) {
m_Functions[i] = GetProcAddress(m_hModule, g_GdipFuncNames[i]);
- if (m_Functions[i] == NULL) {
+ if (!m_Functions[i]) {
m_hModule = NULL;
return;
}
@@ -701,7 +701,7 @@ void CGdiplusExt::Load() {
((FuncType_GdiplusStartup)m_Functions[FuncId_GdiplusStartup])(
&gdiplusToken, &gdiplusStartupInput, NULL);
m_GdiModule = LoadLibraryA("GDI32.DLL");
- if (m_GdiModule == NULL) {
+ if (!m_GdiModule) {
return;
}
m_pGdiAddFontMemResourceEx =
@@ -973,9 +973,9 @@ static GpPen* _GdipCreatePen(const CFX_GraphStateData* pGraphState,
FX_FLOAT width = pGraphState ? pGraphState->m_LineWidth : 1.0f;
if (!bTextMode) {
FX_FLOAT unit =
- pMatrix == NULL
- ? 1.0f
- : FXSYS_Div(1.0f, (pMatrix->GetXUnit() + pMatrix->GetYUnit()) / 2);
+ pMatrix
+ ? FXSYS_Div(1.0f, (pMatrix->GetXUnit() + pMatrix->GetYUnit()) / 2)
+ : 1.0f;
if (width < unit) {
width = unit;
}
@@ -1198,7 +1198,7 @@ FX_BOOL CGdiplusExt::DrawPath(HDC hDC,
}
}
int new_fill_mode = fill_mode & 3;
- if (nPoints == 4 && pGraphState == NULL) {
+ if (nPoints == 4 && !pGraphState) {
int v1, v2;
if (IsSmallTriangle(points, pObject2Device, v1, v2)) {
GpPen* pPen = NULL;
@@ -1380,7 +1380,7 @@ class GpStream final : public IStream {
return S_OK;
}
virtual HRESULT STDMETHODCALLTYPE Stat(STATSTG* pStatstg, DWORD grfStatFlag) {
- if (pStatstg == NULL) {
+ if (!pStatstg) {
return STG_E_INVALIDFUNCTION;
}
ZeroMemory(pStatstg, sizeof(STATSTG));
@@ -1492,7 +1492,7 @@ CFX_DIBitmap* _FX_WindowsDIB_LoadFromBuf(BITMAPINFO* pbmi,
FX_BOOL bAlpha);
CFX_DIBitmap* CGdiplusExt::LoadDIBitmap(WINDIB_Open_Args_ args) {
PREVIEW3_DIBITMAP* pInfo = ::LoadDIBitmap(args);
- if (pInfo == NULL) {
+ if (!pInfo) {
return NULL;
}
int height = abs(pInfo->pbmi->bmiHeader.biHeight);
diff --git a/core/src/fxge/win32/fx_win32_print.cpp b/core/src/fxge/win32/fx_win32_print.cpp
index 39828b14d8..0c00a7b3d9 100644
--- a/core/src/fxge/win32/fx_win32_print.cpp
+++ b/core/src/fxge/win32/fx_win32_print.cpp
@@ -56,7 +56,7 @@ FX_BOOL CGdiPrinterDriver::SetDIBits(const CFX_DIBSource* pSource,
}
CFX_DIBExtractor temp(pSource);
CFX_DIBitmap* pBitmap = temp;
- if (pBitmap == NULL) {
+ if (!pBitmap) {
return FALSE;
}
return GDI_SetDIBits(pBitmap, pSrcRect, left, top, pIccTransform);
@@ -82,7 +82,7 @@ FX_BOOL CGdiPrinterDriver::StretchDIBits(const CFX_DIBSource* pSource,
if (dest_width < 0 || dest_height < 0) {
CFX_DIBitmap* pFlipped =
pSource->FlipImage(dest_width < 0, dest_height < 0);
- if (pFlipped == NULL) {
+ if (!pFlipped) {
return FALSE;
}
if (dest_width < 0) {
@@ -99,7 +99,7 @@ FX_BOOL CGdiPrinterDriver::StretchDIBits(const CFX_DIBSource* pSource,
}
CFX_DIBExtractor temp(pSource);
CFX_DIBitmap* pBitmap = temp;
- if (pBitmap == NULL) {
+ if (!pBitmap) {
return FALSE;
}
return GDI_StretchBitMask(pBitmap, dest_left, dest_top, dest_width,
@@ -112,7 +112,7 @@ FX_BOOL CGdiPrinterDriver::StretchDIBits(const CFX_DIBSource* pSource,
if (dest_width < 0 || dest_height < 0) {
CFX_DIBitmap* pFlipped =
pSource->FlipImage(dest_width < 0, dest_height < 0);
- if (pFlipped == NULL) {
+ if (!pFlipped) {
return FALSE;
}
if (dest_width < 0) {
@@ -129,7 +129,7 @@ FX_BOOL CGdiPrinterDriver::StretchDIBits(const CFX_DIBSource* pSource,
}
CFX_DIBExtractor temp(pSource);
CFX_DIBitmap* pBitmap = temp;
- if (pBitmap == NULL) {
+ if (!pBitmap) {
return FALSE;
}
return GDI_StretchDIBits(pBitmap, dest_left, dest_top, dest_width,
@@ -142,7 +142,7 @@ static CFX_DIBitmap* Transform1bppBitmap(const CFX_DIBSource* pSrc,
pSrc->GetFormat() == FXDIB_1bppCmyk);
CFX_DIBExtractor src_bitmap(pSrc);
CFX_DIBitmap* pSrcBitmap = src_bitmap;
- if (pSrcBitmap == NULL) {
+ if (!pSrcBitmap) {
return NULL;
}
int src_width = pSrcBitmap->GetWidth(), src_height = pSrcBitmap->GetHeight();
@@ -250,7 +250,7 @@ FX_BOOL CGdiPrinterDriver::StartDIBits(const CFX_DIBSource* pSource,
if (FXSYS_fabs(pMatrix->a) < 0.5f && FXSYS_fabs(pMatrix->d) < 0.5f) {
CFX_DIBitmap* pTransformed =
pSource->SwapXY(pMatrix->c > 0, pMatrix->b < 0);
- if (pTransformed == NULL) {
+ if (!pTransformed) {
return FALSE;
}
FX_BOOL ret = StretchDIBits(
@@ -261,7 +261,7 @@ FX_BOOL CGdiPrinterDriver::StartDIBits(const CFX_DIBSource* pSource,
}
if (pSource->GetBPP() == 1) {
CFX_DIBitmap* pTransformed = Transform1bppBitmap(pSource, pMatrix);
- if (pIccTransform == NULL) {
+ if (!pIccTransform) {
return FALSE;
}
SaveState();