From 4997b22f84307521a62838f874928bf56cd3423c Mon Sep 17 00:00:00 2001 From: thestig Date: Tue, 7 Jun 2016 10:46:22 -0700 Subject: Get rid of NULLs in core/ Review-Url: https://codereview.chromium.org/2032613003 --- core/fdrm/crypto/fx_crypt.cpp | 2 +- core/fpdfapi/fpdf_cmaps/CNS1/cmaps_cns1.cpp | 24 +- core/fpdfapi/fpdf_cmaps/GB1/cmaps_gb1.cpp | 26 +- core/fpdfapi/fpdf_cmaps/Japan1/cmaps_japan1.cpp | 44 +-- core/fpdfapi/fpdf_cmaps/Korea1/cmaps_korea1.cpp | 22 +- core/fpdfapi/fpdf_cmaps/fpdf_cmaps.cpp | 2 +- .../fpdf_edit/cpdf_pagecontentgenerator.cpp | 11 +- core/fpdfapi/fpdf_edit/include/cpdf_creator.h | 2 +- core/fpdfapi/fpdf_font/cpdf_cidfont.cpp | 8 +- core/fpdfapi/fpdf_font/cpdf_cidfont.h | 3 +- core/fpdfapi/fpdf_font/cpdf_font.cpp | 4 +- core/fpdfapi/fpdf_font/cpdf_fontencoding.cpp | 409 +++++++++++---------- core/fpdfapi/fpdf_font/cpdf_simplefont.cpp | 6 +- core/fpdfapi/fpdf_font/cpdf_simplefont.h | 3 +- core/fpdfapi/fpdf_font/cpdf_type1font.cpp | 2 +- core/fpdfapi/fpdf_font/fpdf_font.cpp | 2 +- core/fpdfapi/fpdf_font/fpdf_font_cid.cpp | 14 +- core/fpdfapi/fpdf_font/ttgsubtable.cpp | 2 +- core/fpdfapi/fpdf_font/ttgsubtable.h | 32 +- core/fpdfapi/fpdf_page/cpdf_allstates.cpp | 2 +- core/fpdfapi/fpdf_page/cpdf_colorspace.cpp | 16 +- core/fpdfapi/fpdf_page/cpdf_image.cpp | 14 +- core/fpdfapi/fpdf_page/cpdf_textstate.cpp | 4 +- core/fpdfapi/fpdf_page/fpdf_page_colors.cpp | 2 +- core/fpdfapi/fpdf_page/fpdf_page_doc.cpp | 4 +- core/fpdfapi/fpdf_page/fpdf_page_parser.cpp | 32 +- core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp | 18 +- core/fpdfapi/fpdf_page/include/cpdf_colorspace.h | 2 +- core/fpdfapi/fpdf_page/include/cpdf_form.h | 2 +- core/fpdfapi/fpdf_page/include/cpdf_image.h | 6 +- core/fpdfapi/fpdf_page/pageint.h | 2 +- core/fpdfapi/fpdf_parser/cfdf_document.cpp | 6 +- core/fpdfapi/fpdf_parser/cpdf_array.cpp | 4 +- core/fpdfapi/fpdf_parser/cpdf_crypto_handler.cpp | 2 +- core/fpdfapi/fpdf_parser/cpdf_data_avail.cpp | 22 +- core/fpdfapi/fpdf_parser/cpdf_security_handler.cpp | 5 +- core/fpdfapi/fpdf_parser/include/cpdf_document.h | 2 +- core/fpdfapi/fpdf_render/cpdf_pagerendercache.h | 4 +- core/fpdfapi/fpdf_render/fpdf_render.cpp | 55 +-- core/fpdfapi/fpdf_render/fpdf_render_cache.cpp | 28 +- core/fpdfapi/fpdf_render/fpdf_render_image.cpp | 77 ++-- core/fpdfapi/fpdf_render/fpdf_render_pattern.cpp | 4 +- core/fpdfapi/fpdf_render/fpdf_render_text.cpp | 26 +- core/fpdfapi/fpdf_render/render_int.h | 18 +- core/fpdfdoc/cpdf_variabletext.cpp | 2 +- core/fpdfdoc/doc_action.cpp | 12 +- core/fpdfdoc/doc_annot.cpp | 6 +- core/fpdfdoc/doc_basic.cpp | 32 +- core/fpdfdoc/doc_form.cpp | 56 +-- core/fpdfdoc/doc_tagged.cpp | 10 +- core/fpdfdoc/doc_utils.cpp | 59 +-- core/fpdfdoc/doc_viewerPreferences.cpp | 51 +-- core/fpdfdoc/include/cpdf_variabletext.h | 14 +- core/fpdfdoc/include/fpdf_doc.h | 3 +- core/fpdfdoc/pdf_vt.h | 2 +- core/fpdftext/fpdf_text_int.cpp | 12 +- core/fxcodec/codec/fx_codec.cpp | 6 +- core/fxcodec/codec/fx_codec_bmp.cpp | 4 +- core/fxcodec/codec/fx_codec_fax.cpp | 2 +- core/fxcodec/codec/fx_codec_flate.cpp | 15 +- core/fxcodec/codec/fx_codec_gif.cpp | 4 +- core/fxcodec/codec/fx_codec_icc.cpp | 56 +-- core/fxcodec/codec/fx_codec_jbig.cpp | 6 +- core/fxcodec/codec/fx_codec_jpeg.cpp | 7 +- core/fxcodec/codec/fx_codec_jpx_opj.cpp | 20 +- core/fxcodec/codec/fx_codec_png.cpp | 22 +- core/fxcodec/codec/fx_codec_progress.cpp | 221 ++++++----- core/fxcodec/codec/fx_codec_tiff.cpp | 32 +- .../codec/include/ccodec_progressivedecoder.h | 6 +- core/fxcodec/jbig2/JBig2_Context.cpp | 20 +- core/fxcodec/jbig2/JBig2_Context.h | 2 +- core/fxcodec/jbig2/JBig2_Image.cpp | 33 +- core/fxcodec/jbig2/JBig2_PatternDict.cpp | 2 +- core/fxcodec/jbig2/JBig2_Segment.cpp | 4 +- core/fxcodec/lbmp/fx_bmp.cpp | 117 +++--- core/fxcodec/lbmp/fx_bmp.h | 2 +- core/fxcodec/lgif/fx_gif.cpp | 214 ++++++----- core/fxcodec/lgif/fx_gif.h | 4 +- core/fxcrt/fx_arabic.cpp | 2 +- core/fxcrt/fx_basic_array.cpp | 12 +- core/fxcrt/fx_basic_bstring_unittest.cpp | 14 +- core/fxcrt/fx_basic_gcc.cpp | 8 +- core/fxcrt/fx_basic_list.cpp | 16 +- core/fxcrt/fx_basic_maps.cpp | 13 +- core/fxcrt/fx_extension.cpp | 17 +- core/fxcrt/fxcrt_windows.cpp | 31 +- core/fxcrt/include/fx_basic.h | 23 +- core/fxcrt/include/fx_ext.h | 4 +- core/fxcrt/include/fx_system.h | 4 - core/fxcrt/include/fx_ucd.h | 4 +- core/fxcrt/include/fx_xml.h | 6 +- core/fxcrt/xml_int.h | 2 +- core/fxge/agg/fx_agg_driver.h | 2 +- core/fxge/android/fpf_skiafontmgr.cpp | 25 +- core/fxge/android/fpf_skiafontmgr.h | 8 +- core/fxge/android/fx_android_font.cpp | 2 +- core/fxge/apple/apple_int.h | 20 +- core/fxge/apple/fx_apple_platform.cpp | 16 +- core/fxge/apple/fx_mac_imp.cpp | 6 +- core/fxge/apple/fx_quartz_device.cpp | 67 ++-- core/fxge/dib/dib_int.h | 4 +- core/fxge/dib/fx_dib_convert.cpp | 38 +- core/fxge/dib/fx_dib_engine.cpp | 16 +- core/fxge/dib/fx_dib_main.cpp | 46 +-- core/fxge/dib/fx_dib_transform.cpp | 4 +- core/fxge/freetype/fx_freetype.cpp | 2 +- core/fxge/ge/fx_ge.cpp | 18 +- core/fxge/ge/fx_ge_device.cpp | 8 +- core/fxge/ge/fx_ge_font.cpp | 34 +- core/fxge/ge/fx_ge_fontmap.cpp | 42 +-- core/fxge/ge/fx_ge_linux.cpp | 6 +- core/fxge/ge/fx_ge_path.cpp | 12 +- core/fxge/ge/fx_ge_text.cpp | 24 +- core/fxge/ge/fx_text_int.h | 2 +- core/fxge/include/fx_dib.h | 62 ++-- core/fxge/include/fx_font.h | 2 +- core/fxge/include/fx_ge.h | 24 +- core/fxge/include/fx_ge_win32.h | 2 +- core/fxge/skia/fx_skia_device.h | 16 +- core/fxge/win32/dwrite_int.h | 2 +- core/fxge/win32/fx_win32_dib.cpp | 50 ++- core/fxge/win32/fx_win32_dwrite.cpp | 50 +-- core/fxge/win32/fx_win32_gdipext.cpp | 60 +-- core/fxge/win32/win32_int.h | 6 +- fpdfsdk/fpdfdoc_embeddertest.cpp | 14 +- fpdfsdk/fpdftext_embeddertest.cpp | 30 +- fpdfsdk/fxedit/fxet_edit.cpp | 1 - xfa/fde/cfde_txtedtpage.cpp | 3 +- xfa/fwl/basewidget/fwl_datetimepickerimp.cpp | 5 +- xfa/fwl/core/fwl_widgetimp.cpp | 2 + xfa/fwl/core/ifwl_widget.h | 2 +- xfa/fxfa/app/xfa_textlayout.cpp | 4 - xfa/fxfa/parser/cxfa_widgetdata.cpp | 2 +- 133 files changed, 1442 insertions(+), 1486 deletions(-) diff --git a/core/fdrm/crypto/fx_crypt.cpp b/core/fdrm/crypto/fx_crypt.cpp index 9e10f369ca..ed7ede0b5a 100644 --- a/core/fdrm/crypto/fx_crypt.cpp +++ b/core/fdrm/crypto/fx_crypt.cpp @@ -248,7 +248,7 @@ void CRYPT_MD5Generate(const uint8_t* input, static FX_BOOL (*g_PubKeyDecryptor)(const uint8_t* pData, uint32_t size, uint8_t* data_buf, - uint32_t& data_len) = NULL; + uint32_t& data_len) = nullptr; void CRYPT_SetPubKeyDecryptor(FX_BOOL (*func)(const uint8_t* pData, uint32_t size, uint8_t* data_buf, diff --git a/core/fpdfapi/fpdf_cmaps/CNS1/cmaps_cns1.cpp b/core/fpdfapi/fpdf_cmaps/CNS1/cmaps_cns1.cpp index 119c42b5c1..2da1197787 100644 --- a/core/fpdfapi/fpdf_cmaps/CNS1/cmaps_cns1.cpp +++ b/core/fpdfapi/fpdf_cmaps/CNS1/cmaps_cns1.cpp @@ -14,33 +14,33 @@ static const FXCMAP_CMap g_FXCMAP_CNS1_cmaps[] = { {"B5pc-H", FXCMAP_CMap::Range, g_FXCMAP_B5pc_H_0, 247, FXCMAP_CMap::None, - NULL, 0, 0}, + nullptr, 0, 0}, {"B5pc-V", FXCMAP_CMap::Range, g_FXCMAP_B5pc_V_0, 12, FXCMAP_CMap::None, - NULL, 0, -1}, + nullptr, 0, -1}, {"HKscs-B5-H", FXCMAP_CMap::Range, g_FXCMAP_HKscs_B5_H_5, 1210, - FXCMAP_CMap::None, NULL, 0, 0}, + FXCMAP_CMap::None, nullptr, 0, 0}, {"HKscs-B5-V", FXCMAP_CMap::Range, g_FXCMAP_HKscs_B5_V_5, 13, - FXCMAP_CMap::None, NULL, 0, -1}, + FXCMAP_CMap::None, nullptr, 0, -1}, {"ETen-B5-H", FXCMAP_CMap::Range, g_FXCMAP_ETen_B5_H_0, 254, - FXCMAP_CMap::None, NULL, 0, 0}, + FXCMAP_CMap::None, nullptr, 0, 0}, {"ETen-B5-V", FXCMAP_CMap::Range, g_FXCMAP_ETen_B5_V_0, 13, - FXCMAP_CMap::None, NULL, 0, -1}, + FXCMAP_CMap::None, nullptr, 0, -1}, {"ETenms-B5-H", FXCMAP_CMap::Range, g_FXCMAP_ETenms_B5_H_0, 1, - FXCMAP_CMap::None, NULL, 0, -2}, + FXCMAP_CMap::None, nullptr, 0, -2}, {"ETenms-B5-V", FXCMAP_CMap::Range, g_FXCMAP_ETenms_B5_V_0, 18, - FXCMAP_CMap::None, NULL, 0, -1}, + FXCMAP_CMap::None, nullptr, 0, -1}, {"CNS-EUC-H", FXCMAP_CMap::Range, g_FXCMAP_CNS_EUC_H_0, 157, FXCMAP_CMap::Range, g_FXCMAP_CNS_EUC_H_0_DWord, 238, 0}, {"CNS-EUC-V", FXCMAP_CMap::Range, g_FXCMAP_CNS_EUC_V_0, 180, FXCMAP_CMap::Range, g_FXCMAP_CNS_EUC_V_0_DWord, 261, 0}, {"UniCNS-UCS2-H", FXCMAP_CMap::Range, g_FXCMAP_UniCNS_UCS2_H_3, 16418, - FXCMAP_CMap::None, NULL, 0, 0}, + FXCMAP_CMap::None, nullptr, 0, 0}, {"UniCNS-UCS2-V", FXCMAP_CMap::Range, g_FXCMAP_UniCNS_UCS2_V_3, 13, - FXCMAP_CMap::None, NULL, 0, -1}, + FXCMAP_CMap::None, nullptr, 0, -1}, {"UniCNS-UTF16-H", FXCMAP_CMap::Single, g_FXCMAP_UniCNS_UTF16_H_0, 14557, - FXCMAP_CMap::None, NULL, 0, 0}, + FXCMAP_CMap::None, nullptr, 0, 0}, {"UniCNS-UTF16-V", FXCMAP_CMap::Range, g_FXCMAP_UniCNS_UCS2_V_3, 13, - FXCMAP_CMap::None, NULL, 0, -1}, + FXCMAP_CMap::None, nullptr, 0, -1}, }; void CPDF_ModuleMgr::LoadEmbeddedCNS1CMaps() { diff --git a/core/fpdfapi/fpdf_cmaps/GB1/cmaps_gb1.cpp b/core/fpdfapi/fpdf_cmaps/GB1/cmaps_gb1.cpp index 34a43858b4..35e4894382 100644 --- a/core/fpdfapi/fpdf_cmaps/GB1/cmaps_gb1.cpp +++ b/core/fpdfapi/fpdf_cmaps/GB1/cmaps_gb1.cpp @@ -14,33 +14,33 @@ static const FXCMAP_CMap g_FXCMAP_GB1_cmaps[] = { {"GB-EUC-H", FXCMAP_CMap::Range, g_FXCMAP_GB_EUC_H_0, 90, FXCMAP_CMap::None, - NULL, 0, 0}, + nullptr, 0, 0}, {"GB-EUC-V", FXCMAP_CMap::Range, g_FXCMAP_GB_EUC_V_0, 20, FXCMAP_CMap::None, - NULL, 0, -1}, + nullptr, 0, -1}, {"GBpc-EUC-H", FXCMAP_CMap::Range, g_FXCMAP_GBpc_EUC_H_0, 91, - FXCMAP_CMap::None, NULL, 0, 0}, + FXCMAP_CMap::None, nullptr, 0, 0}, {"GBpc-EUC-V", FXCMAP_CMap::Range, g_FXCMAP_GBpc_EUC_V_0, 20, - FXCMAP_CMap::None, NULL, 0, -1}, + FXCMAP_CMap::None, nullptr, 0, -1}, {"GBK-EUC-H", FXCMAP_CMap::Range, g_FXCMAP_GBK_EUC_H_2, 4071, - FXCMAP_CMap::None, NULL, 0, 0}, + FXCMAP_CMap::None, nullptr, 0, 0}, {"GBK-EUC-V", FXCMAP_CMap::Range, g_FXCMAP_GBK_EUC_V_2, 20, - FXCMAP_CMap::None, NULL, 0, -1}, + FXCMAP_CMap::None, nullptr, 0, -1}, {"GBKp-EUC-H", FXCMAP_CMap::Range, g_FXCMAP_GBKp_EUC_H_2, 4070, - FXCMAP_CMap::None, NULL, 0, -2}, + FXCMAP_CMap::None, nullptr, 0, -2}, {"GBKp-EUC-V", FXCMAP_CMap::Range, g_FXCMAP_GBKp_EUC_V_2, 20, - FXCMAP_CMap::None, NULL, 0, -1}, + FXCMAP_CMap::None, nullptr, 0, -1}, {"GBK2K-H", FXCMAP_CMap::Range, g_FXCMAP_GBK2K_H_5, 4071, FXCMAP_CMap::Single, g_FXCMAP_GBK2K_H_5_DWord, 1017, -4}, {"GBK2K-V", FXCMAP_CMap::Range, g_FXCMAP_GBK2K_V_5, 41, FXCMAP_CMap::None, - NULL, 0, -1}, + nullptr, 0, -1}, {"UniGB-UCS2-H", FXCMAP_CMap::Range, g_FXCMAP_UniGB_UCS2_H_4, 13825, - FXCMAP_CMap::None, NULL, 0, 0}, + FXCMAP_CMap::None, nullptr, 0, 0}, {"UniGB-UCS2-V", FXCMAP_CMap::Range, g_FXCMAP_UniGB_UCS2_V_4, 24, - FXCMAP_CMap::None, NULL, 0, -1}, + FXCMAP_CMap::None, nullptr, 0, -1}, {"UniGB-UTF16-H", FXCMAP_CMap::Range, g_FXCMAP_UniGB_UCS2_H_4, 13825, - FXCMAP_CMap::None, NULL, 0, 0}, + FXCMAP_CMap::None, nullptr, 0, 0}, {"UniGB-UTF16-V", FXCMAP_CMap::Range, g_FXCMAP_UniGB_UCS2_V_4, 24, - FXCMAP_CMap::None, NULL, 0, -1}, + FXCMAP_CMap::None, nullptr, 0, -1}, }; void CPDF_ModuleMgr::LoadEmbeddedGB1CMaps() { diff --git a/core/fpdfapi/fpdf_cmaps/Japan1/cmaps_japan1.cpp b/core/fpdfapi/fpdf_cmaps/Japan1/cmaps_japan1.cpp index 6299579081..595989be3c 100644 --- a/core/fpdfapi/fpdf_cmaps/Japan1/cmaps_japan1.cpp +++ b/core/fpdfapi/fpdf_cmaps/Japan1/cmaps_japan1.cpp @@ -14,43 +14,45 @@ static const FXCMAP_CMap g_FXCMAP_Japan1_cmaps[] = { {"83pv-RKSJ-H", FXCMAP_CMap::Range, g_FXCMAP_83pv_RKSJ_H_1, 222, - FXCMAP_CMap::None, NULL, 0, 0}, + FXCMAP_CMap::None, nullptr, 0, 0}, {"90ms-RKSJ-H", FXCMAP_CMap::Range, g_FXCMAP_90ms_RKSJ_H_2, 171, - FXCMAP_CMap::None, NULL, 0, 0}, + FXCMAP_CMap::None, nullptr, 0, 0}, {"90ms-RKSJ-V", FXCMAP_CMap::Range, g_FXCMAP_90ms_RKSJ_V_2, 78, - FXCMAP_CMap::None, NULL, 0, -1}, + FXCMAP_CMap::None, nullptr, 0, -1}, {"90msp-RKSJ-H", FXCMAP_CMap::Range, g_FXCMAP_90msp_RKSJ_H_2, 170, - FXCMAP_CMap::None, NULL, 0, -2}, + FXCMAP_CMap::None, nullptr, 0, -2}, {"90msp-RKSJ-V", FXCMAP_CMap::Range, g_FXCMAP_90msp_RKSJ_V_2, 78, - FXCMAP_CMap::None, NULL, 0, -1}, + FXCMAP_CMap::None, nullptr, 0, -1}, {"90pv-RKSJ-H", FXCMAP_CMap::Range, g_FXCMAP_90pv_RKSJ_H_1, 263, - FXCMAP_CMap::None, NULL, 0, 0}, + FXCMAP_CMap::None, nullptr, 0, 0}, {"Add-RKSJ-H", FXCMAP_CMap::Range, g_FXCMAP_Add_RKSJ_H_1, 635, - FXCMAP_CMap::None, NULL, 0, 0}, + FXCMAP_CMap::None, nullptr, 0, 0}, {"Add-RKSJ-V", FXCMAP_CMap::Range, g_FXCMAP_Add_RKSJ_V_1, 57, - FXCMAP_CMap::None, NULL, 0, -1}, + FXCMAP_CMap::None, nullptr, 0, -1}, {"EUC-H", FXCMAP_CMap::Range, g_FXCMAP_EUC_H_1, 120, FXCMAP_CMap::None, - NULL, 0, 0}, - {"EUC-V", FXCMAP_CMap::Range, g_FXCMAP_EUC_V_1, 27, FXCMAP_CMap::None, NULL, - 0, -1}, + nullptr, 0, 0}, + {"EUC-V", FXCMAP_CMap::Range, g_FXCMAP_EUC_V_1, 27, FXCMAP_CMap::None, + nullptr, 0, -1}, {"Ext-RKSJ-H", FXCMAP_CMap::Range, g_FXCMAP_Ext_RKSJ_H_2, 665, - FXCMAP_CMap::None, NULL, 0, -4}, + FXCMAP_CMap::None, nullptr, 0, -4}, {"Ext-RKSJ-V", FXCMAP_CMap::Range, g_FXCMAP_Ext_RKSJ_V_2, 39, - FXCMAP_CMap::None, NULL, 0, -1}, - {"H", FXCMAP_CMap::Range, g_FXCMAP_H_1, 118, FXCMAP_CMap::None, NULL, 0, 0}, - {"V", FXCMAP_CMap::Range, g_FXCMAP_V_1, 27, FXCMAP_CMap::None, NULL, 0, -1}, + FXCMAP_CMap::None, nullptr, 0, -1}, + {"H", FXCMAP_CMap::Range, g_FXCMAP_H_1, 118, FXCMAP_CMap::None, nullptr, 0, + 0}, + {"V", FXCMAP_CMap::Range, g_FXCMAP_V_1, 27, FXCMAP_CMap::None, nullptr, 0, + -1}, {"UniJIS-UCS2-H", FXCMAP_CMap::Single, g_FXCMAP_UniJIS_UCS2_H_4, 9772, - FXCMAP_CMap::None, NULL, 0, 0}, + FXCMAP_CMap::None, nullptr, 0, 0}, {"UniJIS-UCS2-V", FXCMAP_CMap::Single, g_FXCMAP_UniJIS_UCS2_V_4, 251, - FXCMAP_CMap::None, NULL, 0, -1}, + FXCMAP_CMap::None, nullptr, 0, -1}, {"UniJIS-UCS2-HW-H", FXCMAP_CMap::Range, g_FXCMAP_UniJIS_UCS2_HW_H_4, 4, - FXCMAP_CMap::None, NULL, 0, -2}, + FXCMAP_CMap::None, nullptr, 0, -2}, {"UniJIS-UCS2-HW-V", FXCMAP_CMap::Range, g_FXCMAP_UniJIS_UCS2_HW_V_4, 199, - FXCMAP_CMap::None, NULL, 0, -1}, + FXCMAP_CMap::None, nullptr, 0, -1}, {"UniJIS-UTF16-H", FXCMAP_CMap::Single, g_FXCMAP_UniJIS_UCS2_H_4, 9772, - FXCMAP_CMap::None, NULL, 0, 0}, + FXCMAP_CMap::None, nullptr, 0, 0}, {"UniJIS-UTF16-V", FXCMAP_CMap::Single, g_FXCMAP_UniJIS_UCS2_V_4, 251, - FXCMAP_CMap::None, NULL, 0, -1}, + FXCMAP_CMap::None, nullptr, 0, -1}, }; void CPDF_ModuleMgr::LoadEmbeddedJapan1CMaps() { diff --git a/core/fpdfapi/fpdf_cmaps/Korea1/cmaps_korea1.cpp b/core/fpdfapi/fpdf_cmaps/Korea1/cmaps_korea1.cpp index ac6346cf7f..1649bf429f 100644 --- a/core/fpdfapi/fpdf_cmaps/Korea1/cmaps_korea1.cpp +++ b/core/fpdfapi/fpdf_cmaps/Korea1/cmaps_korea1.cpp @@ -14,27 +14,27 @@ static const FXCMAP_CMap g_FXCMAP_Korea1_cmaps[] = { {"KSC-EUC-H", FXCMAP_CMap::Range, g_FXCMAP_KSC_EUC_H_0, 467, - FXCMAP_CMap::None, NULL, 0, 0}, + FXCMAP_CMap::None, nullptr, 0, 0}, {"KSC-EUC-V", FXCMAP_CMap::Range, g_FXCMAP_KSC_EUC_V_0, 16, - FXCMAP_CMap::None, NULL, 0, -1}, + FXCMAP_CMap::None, nullptr, 0, -1}, {"KSCms-UHC-H", FXCMAP_CMap::Range, g_FXCMAP_KSCms_UHC_H_1, 675, - FXCMAP_CMap::None, NULL, 0, -2}, + FXCMAP_CMap::None, nullptr, 0, -2}, {"KSCms-UHC-V", FXCMAP_CMap::Range, g_FXCMAP_KSCms_UHC_V_1, 16, - FXCMAP_CMap::None, NULL, 0, -1}, + FXCMAP_CMap::None, nullptr, 0, -1}, {"KSCms-UHC-HW-H", FXCMAP_CMap::Range, g_FXCMAP_KSCms_UHC_HW_H_1, 675, - FXCMAP_CMap::None, NULL, 0, 0}, + FXCMAP_CMap::None, nullptr, 0, 0}, {"KSCms-UHC-HW-V", FXCMAP_CMap::Range, g_FXCMAP_KSCms_UHC_HW_V_1, 16, - FXCMAP_CMap::None, NULL, 0, -1}, + FXCMAP_CMap::None, nullptr, 0, -1}, {"KSCpc-EUC-H", FXCMAP_CMap::Range, g_FXCMAP_KSCpc_EUC_H_0, 509, - FXCMAP_CMap::None, NULL, 0, -6}, + FXCMAP_CMap::None, nullptr, 0, -6}, {"UniKS-UCS2-H", FXCMAP_CMap::Range, g_FXCMAP_UniKS_UCS2_H_1, 8394, - FXCMAP_CMap::None, NULL, 0, 0}, + FXCMAP_CMap::None, nullptr, 0, 0}, {"UniKS-UCS2-V", FXCMAP_CMap::Range, g_FXCMAP_UniKS_UCS2_V_1, 18, - FXCMAP_CMap::None, NULL, 0, -1}, + FXCMAP_CMap::None, nullptr, 0, -1}, {"UniKS-UTF16-H", FXCMAP_CMap::Single, g_FXCMAP_UniKS_UTF16_H_0, 158, - FXCMAP_CMap::None, NULL, 0, -2}, + FXCMAP_CMap::None, nullptr, 0, -2}, {"UniKS-UTF16-V", FXCMAP_CMap::Range, g_FXCMAP_UniKS_UCS2_V_1, 18, - FXCMAP_CMap::None, NULL, 0, -1}, + FXCMAP_CMap::None, nullptr, 0, -1}, }; void CPDF_ModuleMgr::LoadEmbeddedKorea1CMaps() { diff --git a/core/fpdfapi/fpdf_cmaps/fpdf_cmaps.cpp b/core/fpdfapi/fpdf_cmaps/fpdf_cmaps.cpp index e0c5b9b7d6..2a9900df91 100644 --- a/core/fpdfapi/fpdf_cmaps/fpdf_cmaps.cpp +++ b/core/fpdfapi/fpdf_cmaps/fpdf_cmaps.cpp @@ -14,7 +14,7 @@ void FPDFAPI_FindEmbeddedCMap(const char* name, int charset, int coding, const FXCMAP_CMap*& pMap) { - pMap = NULL; + pMap = nullptr; CPDF_FontGlobals* pFontGlobals = CPDF_ModuleMgr::Get()->GetPageModule()->GetFontGlobals(); const FXCMAP_CMap* pCMaps = diff --git a/core/fpdfapi/fpdf_edit/cpdf_pagecontentgenerator.cpp b/core/fpdfapi/fpdf_edit/cpdf_pagecontentgenerator.cpp index 2907ebe71c..20ae34349b 100644 --- a/core/fpdfapi/fpdf_edit/cpdf_pagecontentgenerator.cpp +++ b/core/fpdfapi/fpdf_edit/cpdf_pagecontentgenerator.cpp @@ -47,11 +47,11 @@ void CPDF_PageContentGenerator::GenerateContent() { ProcessImage(buf, pPageObj->AsImage()); } CPDF_Object* pContent = - pPageDict ? pPageDict->GetDirectObjectBy("Contents") : NULL; + pPageDict ? pPageDict->GetDirectObjectBy("Contents") : nullptr; if (pContent) { pPageDict->RemoveAt("Contents"); } - CPDF_Stream* pStream = new CPDF_Stream(NULL, 0, NULL); + CPDF_Stream* pStream = new CPDF_Stream(nullptr, 0, nullptr); pStream->SetData(buf.GetBuffer(), buf.GetLength(), FALSE, FALSE); m_pDocument->AddIndirectObject(pStream); pPageDict->SetAtReference("Contents", m_pDocument, pStream->GetObjNum()); @@ -108,7 +108,7 @@ void CPDF_PageContentGenerator::ProcessForm(CFX_ByteTextBuf& buf, if (!data || !size) { return; } - CPDF_Stream* pStream = new CPDF_Stream(NULL, 0, NULL); + CPDF_Stream* pStream = new CPDF_Stream(nullptr, 0, nullptr); CPDF_Dictionary* pFormDict = new CPDF_Dictionary; pFormDict->SetAtName("Type", "XObject"); pFormDict->SetAtName("Subtype", "Form"); @@ -122,7 +122,8 @@ void CPDF_PageContentGenerator::ProcessForm(CFX_ByteTextBuf& buf, } void CPDF_PageContentGenerator::TransformContent(CFX_Matrix& matrix) { CPDF_Dictionary* pDict = m_pPage->m_pFormDict; - CPDF_Object* pContent = pDict ? pDict->GetDirectObjectBy("Contents") : NULL; + CPDF_Object* pContent = + pDict ? pDict->GetDirectObjectBy("Contents") : nullptr; if (!pContent) return; @@ -159,7 +160,7 @@ void CPDF_PageContentGenerator::TransformContent(CFX_Matrix& matrix) { contentStream.LoadAllData(pStream); ProcessForm(buf, contentStream.GetData(), contentStream.GetSize(), matrix); } - CPDF_Stream* pStream = new CPDF_Stream(NULL, 0, NULL); + CPDF_Stream* pStream = new CPDF_Stream(nullptr, 0, nullptr); pStream->SetData(buf.GetBuffer(), buf.GetLength(), FALSE, FALSE); m_pDocument->AddIndirectObject(pStream); m_pPage->m_pFormDict->SetAtReference("Contents", m_pDocument, diff --git a/core/fpdfapi/fpdf_edit/include/cpdf_creator.h b/core/fpdfapi/fpdf_edit/include/cpdf_creator.h index 8782c54f86..285efff4b0 100644 --- a/core/fpdfapi/fpdf_edit/include/cpdf_creator.h +++ b/core/fpdfapi/fpdf_edit/include/cpdf_creator.h @@ -33,7 +33,7 @@ class CPDF_Creator { void RemoveSecurity(); bool Create(IFX_StreamWrite* pFile, uint32_t flags = 0); - int32_t Continue(IFX_Pause* pPause = NULL); + int32_t Continue(IFX_Pause* pPause = nullptr); FX_BOOL SetFileVersion(int32_t fileVersion = 17); private: diff --git a/core/fpdfapi/fpdf_font/cpdf_cidfont.cpp b/core/fpdfapi/fpdf_font/cpdf_cidfont.cpp index 194db8b25c..af4121da16 100644 --- a/core/fpdfapi/fpdf_font/cpdf_cidfont.cpp +++ b/core/fpdfapi/fpdf_font/cpdf_cidfont.cpp @@ -320,7 +320,7 @@ uint32_t CPDF_CIDFont::CharCodeFromUnicode(FX_WCHAR unicode) const { uint8_t buffer[32]; int ret = FXSYS_WideCharToMultiByte(g_CharsetCPs[m_pCMap->m_Coding], 0, &unicode, 1, - (char*)buffer, 4, NULL, NULL); + (char*)buffer, 4, nullptr, nullptr); if (ret == 1) { return buffer[0]; } @@ -603,13 +603,13 @@ int CPDF_CIDFont::GetGlyphIndex(uint32_t unicode, FX_BOOL* pVertGlyph) { if (!m_Font.GetSubData()) { unsigned long length = 0; int error = FXFT_Load_Sfnt_Table(face, FT_MAKE_TAG('G', 'S', 'U', 'B'), 0, - NULL, &length); + nullptr, &length); if (!error) { m_Font.SetSubData(FX_Alloc(uint8_t, length)); } } int error = FXFT_Load_Sfnt_Table(face, FT_MAKE_TAG('G', 'S', 'U', 'B'), 0, - m_Font.GetSubData(), NULL); + m_Font.GetSubData(), nullptr); if (!error && m_Font.GetSubData()) { m_pTTGSUBTable.reset(new CFX_CTTGSUBTable); m_pTTGSUBTable->LoadGSUBTable((FT_Bytes)m_Font.GetSubData()); @@ -678,7 +678,7 @@ int CPDF_CIDFont::GlyphFromCharCode(uint32_t charcode, FX_BOOL* pVertGlyph) { } else if (bMacRoman) { iBaseEncoding = PDFFONT_ENCODING_MACROMAN; } - const FX_CHAR* name = GetAdobeCharName(iBaseEncoding, NULL, charcode); + const FX_CHAR* name = GetAdobeCharName(iBaseEncoding, nullptr, charcode); if (!name) { return charcode == 0 ? -1 : (int)charcode; } diff --git a/core/fpdfapi/fpdf_font/cpdf_cidfont.h b/core/fpdfapi/fpdf_font/cpdf_cidfont.h index 62840f847a..f1c72c65cf 100644 --- a/core/fpdfapi/fpdf_font/cpdf_cidfont.h +++ b/core/fpdfapi/fpdf_font/cpdf_cidfont.h @@ -40,7 +40,8 @@ class CPDF_CIDFont : public CPDF_Font { bool IsCIDFont() const override; const CPDF_CIDFont* AsCIDFont() const override; CPDF_CIDFont* AsCIDFont() override; - int GlyphFromCharCode(uint32_t charcode, FX_BOOL* pVertGlyph = NULL) override; + int GlyphFromCharCode(uint32_t charcode, + FX_BOOL* pVertGlyph = nullptr) override; int GetCharWidthF(uint32_t charcode, int level = 0) override; FX_RECT GetCharBBox(uint32_t charcode, int level = 0) override; uint32_t GetNextChar(const FX_CHAR* pString, diff --git a/core/fpdfapi/fpdf_font/cpdf_font.cpp b/core/fpdfapi/fpdf_font/cpdf_font.cpp index 9fb54a828b..78bdeeffaa 100644 --- a/core/fpdfapi/fpdf_font/cpdf_font.cpp +++ b/core/fpdfapi/fpdf_font/cpdf_font.cpp @@ -60,7 +60,7 @@ CPDF_Font::CPDF_Font() CPDF_Font::~CPDF_Font() { delete m_pToUnicodeMap; - m_pToUnicodeMap = NULL; + m_pToUnicodeMap = nullptr; if (m_pFontFile) { m_pDocument->GetPageData()->ReleaseFontFileStreamAcc( @@ -332,7 +332,7 @@ CPDF_Font* CPDF_Font::GetStockFont(CPDF_Document* pDoc, pDict->SetAtName("Subtype", "Type1"); pDict->SetAtName("BaseFont", fontname); pDict->SetAtName("Encoding", "WinAnsiEncoding"); - pFont = CPDF_Font::CreateFontF(NULL, pDict); + pFont = CPDF_Font::CreateFontF(nullptr, pDict); pFontGlobals->Set(pDoc, font_id, pFont); return pFont; } diff --git a/core/fpdfapi/fpdf_font/cpdf_fontencoding.cpp b/core/fpdfapi/fpdf_font/cpdf_fontencoding.cpp index 8a280e6ba0..6b726f0a32 100644 --- a/core/fpdfapi/fpdf_font/cpdf_fontencoding.cpp +++ b/core/fpdfapi/fpdf_font/cpdf_fontencoding.cpp @@ -330,40 +330,40 @@ const FX_CHAR* const StandardEncodingNames[224] = { "bar", "braceright", "asciitilde", - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, "exclamdown", "cent", "sterling", @@ -379,12 +379,12 @@ const FX_CHAR* const StandardEncodingNames[224] = { "guilsinglright", "fi", "fl", - NULL, + nullptr, "endash", "dagger", "daggerdbl", "periodcentered", - NULL, + nullptr, "paragraph", "bullet", "quotesinglbase", @@ -393,9 +393,9 @@ const FX_CHAR* const StandardEncodingNames[224] = { "guillemotright", "ellipsis", "perthousand", - NULL, + nullptr, "questiondown", - NULL, + nullptr, "grave", "acute", "circumflex", @@ -404,61 +404,61 @@ const FX_CHAR* const StandardEncodingNames[224] = { "breve", "dotaccent", "dieresis", - NULL, + nullptr, "ring", "cedilla", - NULL, + nullptr, "hungarumlaut", "ogonek", "caron", "emdash", - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, "AE", - NULL, + nullptr, "ordfeminine", - NULL, - NULL, - NULL, - NULL, + nullptr, + nullptr, + nullptr, + nullptr, "Lslash", "Oslash", "OE", "ordmasculine", - NULL, - NULL, - NULL, - NULL, - NULL, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, "ae", - NULL, - NULL, - NULL, + nullptr, + nullptr, + nullptr, "dotlessi", - NULL, - NULL, + nullptr, + nullptr, "lslash", "oslash", "oe", "germandbls", - NULL, - NULL, - NULL, - NULL, + nullptr, + nullptr, + nullptr, + nullptr, }; const FX_CHAR* const AdobeWinAnsiEncodingNames[224] = { @@ -784,7 +784,7 @@ const FX_CHAR* const MacRomanEncodingNames[224] = { "bar", "braceright", "asciitilde", - NULL, + nullptr, "Adieresis", "Aring", "Ccedilla", @@ -944,17 +944,17 @@ const FX_CHAR* const MacExpertEncodingNames[224] = { "nineoldstyle", "colon", "semicolon", - NULL, + nullptr, "threequartersemdash", - NULL, + nullptr, "questionsmall", - NULL, - NULL, - NULL, - NULL, + nullptr, + nullptr, + nullptr, + nullptr, "Ethsmall", - NULL, - NULL, + nullptr, + nullptr, "onequarter", "onehalf", "threequarters", @@ -964,19 +964,19 @@ const FX_CHAR* const MacExpertEncodingNames[224] = { "seveneighths", "onethird", "twothirds", - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, "ff", "fi", "fl", "ffi", "ffl", "parenleftinferior", - NULL, + nullptr, "parenrightinferior", "Circumflexsmall", "hypheninferior", @@ -1011,14 +1011,14 @@ const FX_CHAR* const MacExpertEncodingNames[224] = { "onefitted", "rupiah", "Tildesmall", - NULL, - NULL, + nullptr, + nullptr, "asuperior", "centsuperior", - NULL, - NULL, - NULL, - NULL, + nullptr, + nullptr, + nullptr, + nullptr, "Aacutesmall", "Agravesmall", "Acircumflexsmall", @@ -1044,7 +1044,7 @@ const FX_CHAR* const MacExpertEncodingNames[224] = { "Ugravesmall", "Ucircumflexsmall", "Udieresissmall", - NULL, + nullptr, "eightsuperior", "fourinferior", "threeinferior", @@ -1052,25 +1052,25 @@ const FX_CHAR* const MacExpertEncodingNames[224] = { "eightinferior", "seveninferior", "Scaronsmall", - NULL, + nullptr, "centinferior", "twoinferior", - NULL, + nullptr, "Dieresissmall", - NULL, + nullptr, "Caronsmall", "Scaronsmall", "fiveinferior", - NULL, + nullptr, "commainferior", "periodinferior", "Yacutesmall", - NULL, + nullptr, "dollarinferior", - NULL, - NULL, + nullptr, + nullptr, "Thornsmall", - NULL, + nullptr, "nineinferior", "zeroinferior", "Zcaronsmall", @@ -1079,29 +1079,29 @@ const FX_CHAR* const MacExpertEncodingNames[224] = { "questiondownsmall", "oneinferior", "asuperior", - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, "Cedillasmall", - NULL, - NULL, - NULL, - NULL, - NULL, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, "OEsmall", "figuredash", "hyphensuperior", - NULL, - NULL, - NULL, - NULL, + nullptr, + nullptr, + nullptr, + nullptr, "exclamdownsmall", - NULL, + nullptr, "Ydieresissmall", - NULL, + nullptr, "onesuperior", "twosuperior", "threesuperior", @@ -1111,20 +1111,20 @@ const FX_CHAR* const MacExpertEncodingNames[224] = { "sevensuperior", "ninesuperior", "zerosuperior", - NULL, + nullptr, "esuperior", "rsuperior", - NULL, - NULL, - NULL, + nullptr, + nullptr, + nullptr, "isuperior", "ssuperior", "dsuperior", - NULL, - NULL, - NULL, - NULL, - NULL, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, "lsuperior", "Ogoneksmall", "Brevesmall", @@ -1136,10 +1136,10 @@ const FX_CHAR* const MacExpertEncodingNames[224] = { "periodsuperior", "Dotaccentsmall", "Ringsmall", - NULL, - NULL, - NULL, - NULL, + nullptr, + nullptr, + nullptr, + nullptr, }; const FX_CHAR* const PDFDocEncodingNames[232] = { @@ -1246,7 +1246,7 @@ const FX_CHAR* const PDFDocEncodingNames[232] = { "bar", "braceright", "asciitilde", - NULL, + nullptr, "bullet3", "dagger", "daggerdbl", @@ -1278,7 +1278,7 @@ const FX_CHAR* const PDFDocEncodingNames[232] = { "oe", "scaron", "zcaron2", - NULL, + nullptr, "Euro", "exclamdown", "cent", @@ -1292,7 +1292,7 @@ const FX_CHAR* const PDFDocEncodingNames[232] = { "ordfeminine", "guillemotleft4", "logicalnot", - NULL, + nullptr, "registered", "macron", "degree", @@ -1473,39 +1473,39 @@ const FX_CHAR* const AdobeSymbolEncodingNames[224] = { "bar", "braceright", "similar", - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, "Euro", "Upsilon1", "minute", @@ -1586,7 +1586,7 @@ const FX_CHAR* const AdobeSymbolEncodingNames[224] = { "braceleftmid", "braceleftbt", "braceex", - NULL, + nullptr, "angleright", "integral", "integraltp", @@ -1601,35 +1601,38 @@ const FX_CHAR* const AdobeSymbolEncodingNames[224] = { "bracerighttp", "bracerightmid", "bracerightbt", - NULL, + nullptr, }; const FX_CHAR* const ZapfEncodingNames[224] = { - "space", "a1", "a2", "a202", "a3", "a4", "a5", "a119", "a118", - "a117", "a11", "a12", "a13", "a14", "a15", "a16", "a105", "a17", - "a18", "a19", "a20", "a21", "a22", "a23", "a24", "a25", "a26", - "a27", "a28", "a6", "a7", "a8", "a9", "a10", "a29", "a30", - "a31", "a32", "a33", "a34", "a35", "a36", "a37", "a38", "a39", - "a40", "a41", "a42", "a43", "a44", "a45", "a46", "a47", "a48", - "a49", "a50", "a51", "a52", "a53", "a54", "a55", "a56", "a57", - "a58", "a59", "a60", "a61", "a62", "a63", "a64", "a65", "a66", - "a67", "a68", "a69", "a70", "a71", "a72", "a73", "a74", "a203", - "a75", "a204", "a76", "a77", "a78", "a79", "a81", "a82", "a83", - "a84", "a97", "a98", "a99", "a100", NULL, "a89", "a90", "a93", - "a94", "a91", "a92", "a205", "a85", "a206", "a86", "a87", "a88", - "a95", "a96", NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, "a101", "a102", "a103", "a104", "a106", "a107", - "a108", "a112", "a111", "a110", "a109", "a120", "a121", "a122", "a123", - "a124", "a125", "a126", "a127", "a128", "a129", "a130", "a131", "a132", - "a133", "a134", "a135", "a136", "a137", "a138", "a139", "a140", "a141", - "a142", "a143", "a144", "a145", "a146", "a147", "a148", "a149", "a150", - "a151", "a152", "a153", "a154", "a155", "a156", "a157", "a158", "a159", - "a160", "a161", "a163", "a164", "a196", "a165", "a192", "a166", "a167", - "a168", "a169", "a170", "a171", "a172", "a173", "a162", "a174", "a175", - "a176", "a177", "a178", "a179", "a193", "a180", "a199", "a181", "a200", - "a182", NULL, "a201", "a183", "a184", "a197", "a185", "a194", "a198", - "a186", "a195", "a187", "a188", "a189", "a190", "a191", NULL}; + "space", "a1", "a2", "a202", "a3", "a4", "a5", "a119", + "a118", "a117", "a11", "a12", "a13", "a14", "a15", "a16", + "a105", "a17", "a18", "a19", "a20", "a21", "a22", "a23", + "a24", "a25", "a26", "a27", "a28", "a6", "a7", "a8", + "a9", "a10", "a29", "a30", "a31", "a32", "a33", "a34", + "a35", "a36", "a37", "a38", "a39", "a40", "a41", "a42", + "a43", "a44", "a45", "a46", "a47", "a48", "a49", "a50", + "a51", "a52", "a53", "a54", "a55", "a56", "a57", "a58", + "a59", "a60", "a61", "a62", "a63", "a64", "a65", "a66", + "a67", "a68", "a69", "a70", "a71", "a72", "a73", "a74", + "a203", "a75", "a204", "a76", "a77", "a78", "a79", "a81", + "a82", "a83", "a84", "a97", "a98", "a99", "a100", nullptr, + "a89", "a90", "a93", "a94", "a91", "a92", "a205", "a85", + "a206", "a86", "a87", "a88", "a95", "a96", nullptr, nullptr, + nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, + nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, + nullptr, "a101", "a102", "a103", "a104", "a106", "a107", "a108", + "a112", "a111", "a110", "a109", "a120", "a121", "a122", "a123", + "a124", "a125", "a126", "a127", "a128", "a129", "a130", "a131", + "a132", "a133", "a134", "a135", "a136", "a137", "a138", "a139", + "a140", "a141", "a142", "a143", "a144", "a145", "a146", "a147", + "a148", "a149", "a150", "a151", "a152", "a153", "a154", "a155", + "a156", "a157", "a158", "a159", "a160", "a161", "a163", "a164", + "a196", "a165", "a192", "a166", "a167", "a168", "a169", "a170", + "a171", "a172", "a173", "a162", "a174", "a175", "a176", "a177", + "a178", "a179", "a193", "a180", "a199", "a181", "a200", "a182", + nullptr, "a201", "a183", "a184", "a197", "a185", "a194", "a198", + "a186", "a195", "a187", "a188", "a189", "a190", "a191", nullptr}; uint32_t PDF_FindCode(const uint16_t* pCodes, uint16_t unicode) { for (uint32_t i = 0; i < 256; i++) @@ -1694,7 +1697,7 @@ CPDF_Object* CPDF_FontEncoding::Realize() { if (predefined == PDFFONT_ENCODING_MACEXPERT) { return new CPDF_Name("MacExpertEncoding"); } - return NULL; + return nullptr; } const uint16_t* pStandard = PDF_UnicodesForPredefinedCharSet(PDFFONT_ENCODING_WINANSI); @@ -1751,7 +1754,7 @@ const uint16_t* PDF_UnicodesForPredefinedCharSet(int encoding) { case PDFFONT_ENCODING_MS_SYMBOL: return MSSymbolEncoding; } - return NULL; + return nullptr; } FX_WCHAR PDF_UnicodeFromAdobeName(const FX_CHAR* name) { @@ -1768,12 +1771,12 @@ const FX_CHAR* PDF_CharNameFromPredefinedCharSet(int encoding, uint8_t charcode) { if (encoding == PDFFONT_ENCODING_PDFDOC) { if (charcode < 24) - return NULL; + return nullptr; charcode -= 24; } else { if (charcode < 32) - return NULL; + return nullptr; charcode -= 32; } diff --git a/core/fpdfapi/fpdf_font/cpdf_simplefont.cpp b/core/fpdfapi/fpdf_font/cpdf_simplefont.cpp index b367184e2e..129441625a 100644 --- a/core/fpdfapi/fpdf_font/cpdf_simplefont.cpp +++ b/core/fpdfapi/fpdf_font/cpdf_simplefont.cpp @@ -142,11 +142,11 @@ FX_BOOL CPDF_SimpleFont::LoadCommon() { m_BaseEncoding = PDFFONT_ENCODING_STANDARD; } CPDF_Object* pEncoding = m_pFontDict->GetDirectObjectBy("Encoding"); - LoadPDFEncoding(pEncoding, m_BaseEncoding, m_pCharNames, m_pFontFile != NULL, + LoadPDFEncoding(pEncoding, m_BaseEncoding, m_pCharNames, !!m_pFontFile, m_Font.IsTTFont()); LoadGlyphMap(); delete[] m_pCharNames; - m_pCharNames = NULL; + m_pCharNames = nullptr; if (!m_Font.GetFace()) return TRUE; @@ -189,8 +189,6 @@ void CPDF_SimpleFont::LoadSubstFont() { int weight = m_StemV < 140 ? m_StemV * 5 : (m_StemV * 4 + 140); m_Font.LoadSubst(m_BaseFont, IsTrueTypeFont(), m_Flags, weight, m_ItalicAngle, 0); - if (m_Font.GetSubstFont()->m_SubstFlags & FXFONT_SUBST_NONSYMBOL) { - } } FX_BOOL CPDF_SimpleFont::IsUnicodeCompatible() const { diff --git a/core/fpdfapi/fpdf_font/cpdf_simplefont.h b/core/fpdfapi/fpdf_font/cpdf_simplefont.h index 7b07c9971e..881744a405 100644 --- a/core/fpdfapi/fpdf_font/cpdf_simplefont.h +++ b/core/fpdfapi/fpdf_font/cpdf_simplefont.h @@ -20,7 +20,8 @@ class CPDF_SimpleFont : public CPDF_Font { // CPDF_Font: int GetCharWidthF(uint32_t charcode, int level = 0) override; FX_RECT GetCharBBox(uint32_t charcode, int level = 0) override; - int GlyphFromCharCode(uint32_t charcode, FX_BOOL* pVertGlyph = NULL) override; + int GlyphFromCharCode(uint32_t charcode, + FX_BOOL* pVertGlyph = nullptr) override; FX_BOOL IsUnicodeCompatible() const override; CFX_WideString UnicodeFromCharCode(uint32_t charcode) const override; uint32_t CharCodeFromUnicode(FX_WCHAR Unicode) const override; diff --git a/core/fpdfapi/fpdf_font/cpdf_type1font.cpp b/core/fpdfapi/fpdf_font/cpdf_type1font.cpp index fc12ae78ee..908b6e3a2f 100644 --- a/core/fpdfapi/fpdf_font/cpdf_type1font.cpp +++ b/core/fpdfapi/fpdf_font/cpdf_type1font.cpp @@ -40,7 +40,7 @@ const FX_CHAR* GlyphNameRemap(const FX_CHAR* pStrAdobe) { compareString); if (found) return found->m_pStrUnicode; - return NULL; + return nullptr; } #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ diff --git a/core/fpdfapi/fpdf_font/fpdf_font.cpp b/core/fpdfapi/fpdf_font/fpdf_font.cpp index 9f7b127d60..e5442215c4 100644 --- a/core/fpdfapi/fpdf_font/fpdf_font.cpp +++ b/core/fpdfapi/fpdf_font/fpdf_font.cpp @@ -297,6 +297,6 @@ void CPDF_ToUnicodeMap::Load(CPDF_Stream* pStream) { ->GetFontGlobals() ->m_CMapManager.GetCID2UnicodeMap(cid_set, FALSE); } else { - m_pBaseMap = NULL; + m_pBaseMap = nullptr; } } diff --git a/core/fpdfapi/fpdf_font/fpdf_font_cid.cpp b/core/fpdfapi/fpdf_font/fpdf_font_cid.cpp index 01a0f6cbdd..2a55955cc0 100644 --- a/core/fpdfapi/fpdf_font/fpdf_font_cid.cpp +++ b/core/fpdfapi/fpdf_font/fpdf_font_cid.cpp @@ -336,13 +336,13 @@ CPDF_CID2UnicodeMap* CPDF_CMapManager::LoadCID2UnicodeMap(CIDSet charset, CPDF_CID2UnicodeMap* pMap = new CPDF_CID2UnicodeMap(); if (!pMap->Initialize()) { delete pMap; - return NULL; + return nullptr; } pMap->Load(this, charset, bPromptCJK); return pMap; } CPDF_CMapParser::CPDF_CMapParser() { - m_pCMap = NULL; + m_pCMap = nullptr; m_Status = 0; m_CodeSeq = 0; } @@ -506,11 +506,11 @@ CPDF_CMap::CPDF_CMap() { m_CodingScheme = TwoBytes; m_bVertical = 0; m_bLoaded = FALSE; - m_pMapping = NULL; - m_pLeadingBytes = NULL; - m_pAddMapping = NULL; - m_pEmbedMap = NULL; - m_pUseMap = NULL; + m_pMapping = nullptr; + m_pLeadingBytes = nullptr; + m_pAddMapping = nullptr; + m_pEmbedMap = nullptr; + m_pUseMap = nullptr; m_nCodeRanges = 0; } CPDF_CMap::~CPDF_CMap() { diff --git a/core/fpdfapi/fpdf_font/ttgsubtable.cpp b/core/fpdfapi/fpdf_font/ttgsubtable.cpp index f6d6400f47..5734816a87 100644 --- a/core/fpdfapi/fpdf_font/ttgsubtable.cpp +++ b/core/fpdfapi/fpdf_font/ttgsubtable.cpp @@ -290,7 +290,7 @@ void CFX_CTTGSUBTable::ParseLookup(FT_Bytes raw, TLookup* rec) { } rec->SubTable = new struct TSubTableBase*[rec->SubTableCount]; for (i = 0; i < rec->SubTableCount; i++) { - rec->SubTable[i] = NULL; + rec->SubTable[i] = nullptr; } if (rec->LookupType != 1) { return; diff --git a/core/fpdfapi/fpdf_font/ttgsubtable.h b/core/fpdfapi/fpdf_font/ttgsubtable.h index 0ef2351336..830e67af88 100644 --- a/core/fpdfapi/fpdf_font/ttgsubtable.h +++ b/core/fpdfapi/fpdf_font/ttgsubtable.h @@ -53,7 +53,7 @@ class CFX_CTTGSUBTable { : LookupOrder(0), ReqFeatureIndex(0), FeatureCount(0), - FeatureIndex(NULL) {} + FeatureIndex(nullptr) {} ~TLangSys() { delete[] FeatureIndex; } private: @@ -73,7 +73,7 @@ class CFX_CTTGSUBTable { uint16_t DefaultLangSys; uint16_t LangSysCount; struct TLangSysRecord* LangSysRecord; - TScript() : DefaultLangSys(0), LangSysCount(0), LangSysRecord(NULL) {} + TScript() : DefaultLangSys(0), LangSysCount(0), LangSysRecord(nullptr) {} ~TScript() { delete[] LangSysRecord; } private: @@ -92,7 +92,7 @@ class CFX_CTTGSUBTable { struct TScriptList { uint16_t ScriptCount; struct TScriptRecord* ScriptRecord; - TScriptList() : ScriptCount(0), ScriptRecord(NULL) {} + TScriptList() : ScriptCount(0), ScriptRecord(nullptr) {} ~TScriptList() { delete[] ScriptRecord; } private: @@ -103,7 +103,7 @@ class CFX_CTTGSUBTable { uint16_t FeatureParams; int LookupCount; uint16_t* LookupListIndex; - TFeature() : FeatureParams(0), LookupCount(0), LookupListIndex(NULL) {} + TFeature() : FeatureParams(0), LookupCount(0), LookupListIndex(nullptr) {} ~TFeature() { delete[] LookupListIndex; } private: @@ -122,7 +122,7 @@ class CFX_CTTGSUBTable { struct TFeatureList { int FeatureCount; struct TFeatureRecord* FeatureRecord; - TFeatureList() : FeatureCount(0), FeatureRecord(NULL) {} + TFeatureList() : FeatureCount(0), FeatureRecord(nullptr) {} ~TFeatureList() { delete[] FeatureRecord; } private: @@ -150,7 +150,9 @@ class CFX_CTTGSUBTable { struct TCoverageFormat1 : public TCoverageFormatBase { uint16_t GlyphCount; uint16_t* GlyphArray; - TCoverageFormat1() : GlyphCount(0), GlyphArray(NULL) { CoverageFormat = 1; } + TCoverageFormat1() : GlyphCount(0), GlyphArray(nullptr) { + CoverageFormat = 1; + } ~TCoverageFormat1() override { delete[] GlyphArray; } private: @@ -172,7 +174,7 @@ class CFX_CTTGSUBTable { struct TCoverageFormat2 : public TCoverageFormatBase { uint16_t RangeCount; struct TRangeRecord* RangeRecord; - TCoverageFormat2() : RangeCount(0), RangeRecord(NULL) { + TCoverageFormat2() : RangeCount(0), RangeRecord(nullptr) { CoverageFormat = 2; } ~TCoverageFormat2() override { delete[] RangeRecord; } @@ -194,7 +196,8 @@ class CFX_CTTGSUBTable { uint16_t StartGlyph; uint16_t GlyphCount; uint16_t* ClassValueArray; - TClassDefFormat1() : StartGlyph(0), GlyphCount(0), ClassValueArray(NULL) { + TClassDefFormat1() + : StartGlyph(0), GlyphCount(0), ClassValueArray(nullptr) { ClassFormat = 1; } ~TClassDefFormat1() override { delete[] ClassValueArray; } @@ -216,7 +219,7 @@ class CFX_CTTGSUBTable { struct TClassDefFormat2 : public TClassDefFormatBase { uint16_t ClassRangeCount; struct TClassRangeRecord* ClassRangeRecord; - TClassDefFormat2() : ClassRangeCount(0), ClassRangeRecord(NULL) { + TClassDefFormat2() : ClassRangeCount(0), ClassRangeRecord(nullptr) { ClassFormat = 2; } ~TClassDefFormat2() override { delete[] ClassRangeRecord; } @@ -247,7 +250,9 @@ class CFX_CTTGSUBTable { struct TSingleSubstFormat1 : public TSubTableBase { TCoverageFormatBase* Coverage; int16_t DeltaGlyphID; - TSingleSubstFormat1() : Coverage(NULL), DeltaGlyphID(0) { SubstFormat = 1; } + TSingleSubstFormat1() : Coverage(nullptr), DeltaGlyphID(0) { + SubstFormat = 1; + } ~TSingleSubstFormat1() override { delete Coverage; } private: @@ -258,7 +263,8 @@ class CFX_CTTGSUBTable { TCoverageFormatBase* Coverage; uint16_t GlyphCount; uint16_t* Substitute; - TSingleSubstFormat2() : Coverage(NULL), GlyphCount(0), Substitute(NULL) { + TSingleSubstFormat2() + : Coverage(nullptr), GlyphCount(0), Substitute(nullptr) { SubstFormat = 2; } ~TSingleSubstFormat2() override { @@ -276,7 +282,7 @@ class CFX_CTTGSUBTable { uint16_t SubTableCount; struct TSubTableBase** SubTable; TLookup() - : LookupType(0), LookupFlag(0), SubTableCount(0), SubTable(NULL) {} + : LookupType(0), LookupFlag(0), SubTableCount(0), SubTable(nullptr) {} ~TLookup() { if (SubTable) { for (int i = 0; i < SubTableCount; ++i) @@ -292,7 +298,7 @@ class CFX_CTTGSUBTable { struct TLookupList { int LookupCount; struct TLookup* Lookup; - TLookupList() : LookupCount(0), Lookup(NULL) {} + TLookupList() : LookupCount(0), Lookup(nullptr) {} ~TLookupList() { delete[] Lookup; } private: diff --git a/core/fpdfapi/fpdf_page/cpdf_allstates.cpp b/core/fpdfapi/fpdf_page/cpdf_allstates.cpp index 4fe5283251..5230b3b206 100644 --- a/core/fpdfapi/fpdf_page/cpdf_allstates.cpp +++ b/core/fpdfapi/fpdf_page/cpdf_allstates.cpp @@ -126,7 +126,7 @@ void CPDF_AllStates::ProcessExtGS(CPDF_Dictionary* pGS, FXSYS_memcpy(pGeneralState->m_SMaskMatrix, &pParser->GetCurStates()->m_CTM, sizeof(CFX_Matrix)); } else { - pGeneralState->m_pSoftMask = NULL; + pGeneralState->m_pSoftMask = nullptr; } break; case FXBSTR_ID('C', 'A', 0, 0): diff --git a/core/fpdfapi/fpdf_page/cpdf_colorspace.cpp b/core/fpdfapi/fpdf_page/cpdf_colorspace.cpp index d66b920f07..9300f1081b 100644 --- a/core/fpdfapi/fpdf_page/cpdf_colorspace.cpp +++ b/core/fpdfapi/fpdf_page/cpdf_colorspace.cpp @@ -325,7 +325,7 @@ CPDF_ColorSpace* CPDF_ColorSpace::ColorspaceFromName( if (name == "Pattern") { return CPDF_ColorSpace::GetStockCS(PDFCS_PATTERN); } - return NULL; + return nullptr; } CPDF_ColorSpace* CPDF_ColorSpace::GetStockCS(int family) { @@ -366,7 +366,7 @@ CPDF_ColorSpace* CPDF_ColorSpace::Load(CPDF_Document* pDoc, CPDF_Object* pObj) { if (pArray->GetCount() == 1) return ColorspaceFromName(familyname); - CPDF_ColorSpace* pCS = NULL; + CPDF_ColorSpace* pCS = nullptr; uint32_t id = familyname.GetID(); if (id == FXBSTR_ID('C', 'a', 'l', 'G')) { pCS = new CPDF_CalGray(pDoc); @@ -386,12 +386,12 @@ CPDF_ColorSpace* CPDF_ColorSpace::Load(CPDF_Document* pDoc, CPDF_Object* pObj) { } else if (id == FXBSTR_ID('P', 'a', 't', 't')) { pCS = new CPDF_PatternCS(pDoc); } else { - return NULL; + return nullptr; } pCS->m_pArray = pArray; if (!pCS->v_Load(pDoc, pArray)) { pCS->ReleaseCS(); - return NULL; + return nullptr; } return pCS; } @@ -965,7 +965,7 @@ CPDF_IndexedCS::CPDF_IndexedCS(CPDF_Document* pDoc) CPDF_IndexedCS::~CPDF_IndexedCS() { FX_Free(m_pCompMinMax); - CPDF_ColorSpace* pCS = m_pCountedBaseCS ? m_pCountedBaseCS->get() : NULL; + CPDF_ColorSpace* pCS = m_pCountedBaseCS ? m_pCountedBaseCS->get() : nullptr; if (pCS && m_pDocument) { m_pDocument->GetPageData()->ReleaseColorSpace(pCS->GetArray()); } @@ -980,7 +980,7 @@ FX_BOOL CPDF_IndexedCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) { return FALSE; } CPDF_DocPageData* pDocPageData = pDoc->GetPageData(); - m_pBaseCS = pDocPageData->GetColorSpace(pBaseObj, NULL); + m_pBaseCS = pDocPageData->GetColorSpace(pBaseObj, nullptr); if (!m_pBaseCS) { return FALSE; } @@ -1052,7 +1052,7 @@ CPDF_PatternCS::CPDF_PatternCS(CPDF_Document* pDoc) m_pCountedBaseCS(nullptr) {} CPDF_PatternCS::~CPDF_PatternCS() { - CPDF_ColorSpace* pCS = m_pCountedBaseCS ? m_pCountedBaseCS->get() : NULL; + CPDF_ColorSpace* pCS = m_pCountedBaseCS ? m_pCountedBaseCS->get() : nullptr; if (pCS && m_pDocument) { m_pDocument->GetPageData()->ReleaseColorSpace(pCS->GetArray()); } @@ -1064,7 +1064,7 @@ FX_BOOL CPDF_PatternCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) { return FALSE; } CPDF_DocPageData* pDocPageData = pDoc->GetPageData(); - m_pBaseCS = pDocPageData->GetColorSpace(pBaseCS, NULL); + m_pBaseCS = pDocPageData->GetColorSpace(pBaseCS, nullptr); if (m_pBaseCS) { if (m_pBaseCS->GetFamily() == PDFCS_PATTERN) { return FALSE; diff --git a/core/fpdfapi/fpdf_page/cpdf_image.cpp b/core/fpdfapi/fpdf_page/cpdf_image.cpp index d7e50d8291..63e006fc06 100644 --- a/core/fpdfapi/fpdf_page/cpdf_image.cpp +++ b/core/fpdfapi/fpdf_page/cpdf_image.cpp @@ -58,7 +58,7 @@ FX_BOOL CPDF_Image::LoadImageF(CPDF_Stream* pStream, FX_BOOL bInline) { m_pStream = pStream; if (m_bInline && m_pInlineDict) { m_pInlineDict->Release(); - m_pInlineDict = NULL; + m_pInlineDict = nullptr; } m_bInline = bInline; CPDF_Dictionary* pDict = pStream->GetDict(); @@ -168,7 +168,7 @@ void CPDF_Image::SetImage(const CFX_DIBitmap* pBitmap, int32_t iCompress) { pDict->SetAtName("Subtype", "Image"); pDict->SetAtInteger("Width", BitmapWidth); pDict->SetAtInteger("Height", BitmapHeight); - uint8_t* dest_buf = NULL; + uint8_t* dest_buf = nullptr; FX_STRSIZE dest_pitch = 0, dest_size = 0, opType = -1; if (bpp == 1) { int32_t reset_a = 0, reset_r = 0, reset_g = 0, reset_b = 0; @@ -252,7 +252,7 @@ void CPDF_Image::SetImage(const CFX_DIBitmap* pBitmap, int32_t iCompress) { opType = 0; } } - const CFX_DIBitmap* pMaskBitmap = NULL; + const CFX_DIBitmap* pMaskBitmap = nullptr; FX_BOOL bDeleteMask = FALSE; if (pBitmap->HasAlpha()) { pMaskBitmap = pBitmap->GetAlphaMask(); @@ -261,7 +261,7 @@ void CPDF_Image::SetImage(const CFX_DIBitmap* pBitmap, int32_t iCompress) { if (pMaskBitmap) { int32_t maskWidth = pMaskBitmap->GetWidth(); int32_t maskHeight = pMaskBitmap->GetHeight(); - uint8_t* mask_buf = NULL; + uint8_t* mask_buf = nullptr; FX_STRSIZE mask_size = 0; CPDF_Dictionary* pMaskDict = new CPDF_Dictionary; pMaskDict->SetAtName("Type", "XObject"); @@ -301,10 +301,10 @@ void CPDF_Image::SetImage(const CFX_DIBitmap* pBitmap, int32_t iCompress) { SetImage(pNewBitmap, iCompress); if (pDict) { pDict->Release(); - pDict = NULL; + pDict = nullptr; } FX_Free(dest_buf); - dest_buf = NULL; + dest_buf = nullptr; dest_size = 0; delete pNewBitmap; return; @@ -343,7 +343,7 @@ void CPDF_Image::SetImage(const CFX_DIBitmap* pBitmap, int32_t iCompress) { } } if (!m_pStream) { - m_pStream = new CPDF_Stream(NULL, 0, NULL); + m_pStream = new CPDF_Stream(nullptr, 0, nullptr); } m_pStream->InitStream(dest_buf, dest_size, pDict); m_bIsMask = pBitmap->IsAlphaMask(); diff --git a/core/fpdfapi/fpdf_page/cpdf_textstate.cpp b/core/fpdfapi/fpdf_page/cpdf_textstate.cpp index 5269cae44b..50fc7789fe 100644 --- a/core/fpdfapi/fpdf_page/cpdf_textstate.cpp +++ b/core/fpdfapi/fpdf_page/cpdf_textstate.cpp @@ -13,11 +13,11 @@ void CPDF_TextState::SetFont(CPDF_Font* pFont) { CPDF_TextStateData* pStateData = GetModify(); if (pStateData) { CPDF_Document* pDoc = pStateData->m_pDocument; - CPDF_DocPageData* pPageData = pDoc ? pDoc->GetPageData() : NULL; + CPDF_DocPageData* pPageData = pDoc ? pDoc->GetPageData() : nullptr; if (pPageData && pStateData->m_pFont && !pPageData->IsForceClear()) { pPageData->ReleaseFont(pStateData->m_pFont->GetFontDict()); } - pStateData->m_pDocument = pFont ? pFont->m_pDocument : NULL; + pStateData->m_pDocument = pFont ? pFont->m_pDocument : nullptr; pStateData->m_pFont = pFont; } } diff --git a/core/fpdfapi/fpdf_page/fpdf_page_colors.cpp b/core/fpdfapi/fpdf_page/fpdf_page_colors.cpp index 2256fda585..6fd7621a51 100644 --- a/core/fpdfapi/fpdf_page/fpdf_page_colors.cpp +++ b/core/fpdfapi/fpdf_page/fpdf_page_colors.cpp @@ -217,7 +217,7 @@ void CPDF_DeviceCS::TranslateImageLine(uint8_t* pDestBuf, } CPDF_IccProfile::CPDF_IccProfile(const uint8_t* pData, uint32_t dwSize) - : m_bsRGB(FALSE), m_pTransform(NULL), m_nSrcComponents(0) { + : m_bsRGB(FALSE), m_pTransform(nullptr), m_nSrcComponents(0) { if (dwSize == 3144 && FXSYS_memcmp(pData + 0x190, "sRGB IEC61966-2.1", 17) == 0) { m_bsRGB = TRUE; diff --git a/core/fpdfapi/fpdf_page/fpdf_page_doc.cpp b/core/fpdfapi/fpdf_page/fpdf_page_doc.cpp index ae02cfb4a7..e7f68224a4 100644 --- a/core/fpdfapi/fpdf_page/fpdf_page_doc.cpp +++ b/core/fpdfapi/fpdf_page/fpdf_page_doc.cpp @@ -128,7 +128,7 @@ void CPDF_DocPageData::Clear(FX_BOOL bForceRelease) { CPDF_Font* CPDF_DocPageData::GetFont(CPDF_Dictionary* pFontDict, FX_BOOL findOnly) { if (!pFontDict) { - return NULL; + return nullptr; } if (findOnly) { auto it = m_FontMap.find(pFontDict); @@ -434,7 +434,7 @@ void CPDF_DocPageData::ReleaseImage(CPDF_Object* pImageStream) { CPDF_IccProfile* CPDF_DocPageData::GetIccProfile( CPDF_Stream* pIccProfileStream) { if (!pIccProfileStream) - return NULL; + return nullptr; auto it = m_IccProfileMap.find(pIccProfileStream); if (it != m_IccProfileMap.end()) { diff --git a/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp b/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp index 4bd4a4d529..802f424274 100644 --- a/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp +++ b/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp @@ -82,7 +82,7 @@ class CPDF_StreamParserAutoClearer { : scoped_variable_(scoped_variable) { *scoped_variable_ = new_parser; } - ~CPDF_StreamParserAutoClearer() { *scoped_variable_ = NULL; } + ~CPDF_StreamParserAutoClearer() { *scoped_variable_ = nullptr; } private: CPDF_StreamParser** scoped_variable_; @@ -321,7 +321,7 @@ void CPDF_StreamContentParser::ClearAllParams() { CPDF_Object* CPDF_StreamContentParser::GetObject(uint32_t index) { if (index >= m_ParamCount) { - return NULL; + return nullptr; } int real_index = m_ParamStartPos + m_ParamCount - index - 1; if (real_index >= PARAM_BUF_SIZE) { @@ -348,7 +348,7 @@ CPDF_Object* CPDF_StreamContentParser::GetObject(uint32_t index) { return param.m_pObject; } ASSERT(FALSE); - return NULL; + return nullptr; } CFX_ByteString CPDF_StreamContentParser::GetString(uint32_t index) { @@ -612,7 +612,7 @@ void CPDF_StreamContentParser::Handle_BeginImage() { } } PDF_ReplaceAbbr(pDict); - CPDF_Object* pCSObj = NULL; + CPDF_Object* pCSObj = nullptr; if (pDict->KeyExist("ColorSpace")) { pCSObj = pDict->GetDirectObjectBy("ColorSpace"); if (pCSObj->IsName()) { @@ -642,7 +642,7 @@ void CPDF_StreamContentParser::Handle_BeginImage() { } } pDict->SetAtName("Subtype", "Image"); - CPDF_ImageObject* pImgObj = AddImage(pStream, NULL, TRUE); + CPDF_ImageObject* pImgObj = AddImage(pStream, nullptr, TRUE); if (!pImgObj) { if (pStream) { pStream->Release(); @@ -654,7 +654,7 @@ void CPDF_StreamContentParser::Handle_BeginImage() { void CPDF_StreamContentParser::Handle_BeginMarkedContent() { CFX_ByteString tag = GetString(0); - m_CurContentMark.GetModify()->AddMark(tag, NULL, FALSE); + m_CurContentMark.GetModify()->AddMark(tag, nullptr, FALSE); } void CPDF_StreamContentParser::Handle_BeginText() { @@ -738,7 +738,7 @@ void CPDF_StreamContentParser::Handle_ExecuteXObject() { type = pXObject->GetDict()->GetStringBy("Subtype"); if (type == "Image") { - CPDF_ImageObject* pObj = AddImage(pXObject, NULL, FALSE); + CPDF_ImageObject* pObj = AddImage(pXObject, nullptr, FALSE); m_LastImageName = name; m_pLastImage = pObj->m_pImage; if (!m_pObjectHolder->HasImageMask()) @@ -773,7 +773,7 @@ CPDF_ImageObject* CPDF_StreamContentParser::AddImage(CPDF_Stream* pStream, CPDF_Image* pImage, FX_BOOL bInline) { if (!pStream && !pImage) { - return NULL; + return nullptr; } CFX_Matrix ImageMatrix; ImageMatrix.Copy(m_pCurStates->m_CTM); @@ -1010,7 +1010,7 @@ void CPDF_StreamContentParser::Handle_SetColor_Fill() { for (int i = 0; i < nargs; i++) { values[i] = GetNumber(nargs - i - 1); } - m_pCurStates->m_ColorState.SetFillColor(NULL, values, nargs); + m_pCurStates->m_ColorState.SetFillColor(nullptr, values, nargs); } void CPDF_StreamContentParser::Handle_SetColor_Stroke() { @@ -1022,7 +1022,7 @@ void CPDF_StreamContentParser::Handle_SetColor_Stroke() { for (int i = 0; i < nargs; i++) { values[i] = GetNumber(nargs - i - 1); } - m_pCurStates->m_ColorState.SetStrokeColor(NULL, values, nargs); + m_pCurStates->m_ColorState.SetStrokeColor(nullptr, values, nargs); } void CPDF_StreamContentParser::Handle_SetColorPS_Fill() { @@ -1034,7 +1034,7 @@ void CPDF_StreamContentParser::Handle_SetColorPS_Fill() { uint32_t nvalues = nargs; if (pLastParam->IsName()) nvalues--; - FX_FLOAT* values = NULL; + FX_FLOAT* values = nullptr; if (nvalues) { values = FX_Alloc(FX_FLOAT, nvalues); for (uint32_t i = 0; i < nvalues; i++) { @@ -1047,7 +1047,7 @@ void CPDF_StreamContentParser::Handle_SetColorPS_Fill() { m_pCurStates->m_ColorState.SetFillPattern(pPattern, values, nvalues); } } else { - m_pCurStates->m_ColorState.SetFillColor(NULL, values, nvalues); + m_pCurStates->m_ColorState.SetFillColor(nullptr, values, nvalues); } FX_Free(values); } @@ -1062,7 +1062,7 @@ void CPDF_StreamContentParser::Handle_SetColorPS_Stroke() { if (pLastParam->IsName()) nvalues--; - FX_FLOAT* values = NULL; + FX_FLOAT* values = nullptr; if (nvalues) { values = FX_Alloc(FX_FLOAT, nvalues); for (int i = 0; i < nvalues; i++) { @@ -1075,7 +1075,7 @@ void CPDF_StreamContentParser::Handle_SetColorPS_Stroke() { m_pCurStates->m_ColorState.SetStrokePattern(pPattern, values, nvalues); } } else { - m_pCurStates->m_ColorState.SetStrokeColor(NULL, values, nvalues); + m_pCurStates->m_ColorState.SetStrokeColor(nullptr, values, nvalues); } FX_Free(values); } @@ -1189,7 +1189,7 @@ CPDF_ColorSpace* CPDF_StreamContentParser::FindColorSpace( CPDF_Object* pCSObj = FindResourceObj("ColorSpace", name); if (!pCSObj) { m_bResourceMissing = TRUE; - return NULL; + return nullptr; } return m_pDocument->LoadColorSpace(pCSObj); } @@ -1284,7 +1284,7 @@ void CPDF_StreamContentParser::Handle_ShowText() { if (str.IsEmpty()) { return; } - AddTextObject(&str, 0, NULL, 1); + AddTextObject(&str, 0, nullptr, 1); } void CPDF_StreamContentParser::Handle_ShowText_Positioning() { diff --git a/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp b/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp index 5bac23e137..42adb84638 100644 --- a/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp +++ b/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp @@ -43,7 +43,7 @@ CPDF_StreamParser::CPDF_StreamParser(const uint8_t* pData, uint32_t dwSize) { m_pBuf = pData; m_Size = dwSize; m_Pos = 0; - m_pLastObj = NULL; + m_pLastObj = nullptr; } CPDF_StreamParser::~CPDF_StreamParser() { @@ -168,30 +168,30 @@ CPDF_Stream* CPDF_StreamParser::ReadInlineStream(CPDF_Document* pDoc, } uint32_t pitch = width; if (bpc && pitch > INT_MAX / bpc) { - return NULL; + return nullptr; } pitch *= bpc; if (nComponents && pitch > INT_MAX / nComponents) { - return NULL; + return nullptr; } pitch *= nComponents; if (pitch > INT_MAX - 7) { - return NULL; + return nullptr; } pitch += 7; pitch /= 8; OrigSize = pitch; } else { if (width > INT_MAX - 7) { - return NULL; + return nullptr; } OrigSize = ((width + 7) / 8); } if (height && OrigSize > INT_MAX / height) { - return NULL; + return nullptr; } OrigSize *= height; - uint8_t* pData = NULL; + uint8_t* pData = nullptr; uint32_t dwStreamSize; if (Decoder.IsEmpty()) { if (OrigSize > m_Size - m_Pos) { @@ -208,7 +208,7 @@ CPDF_Stream* CPDF_StreamParser::ReadInlineStream(CPDF_Document* pDoc, Decoder, pParam, pData, dwDestSize); FX_Free(pData); if ((int)dwStreamSize < 0) - return NULL; + return nullptr; uint32_t dwSavePos = m_Pos; m_Pos += dwStreamSize; @@ -714,7 +714,7 @@ void CPDF_ContentParser::Start(CPDF_Form* pForm, pData->m_BlendType = FXDIB_BLEND_NORMAL; pData->m_StrokeAlpha = 1.0f; pData->m_FillAlpha = 1.0f; - pData->m_pSoftMask = NULL; + pData->m_pSoftMask = nullptr; } m_nStreams = 0; m_pSingleStream.reset(new CPDF_StreamAcc); diff --git a/core/fpdfapi/fpdf_page/include/cpdf_colorspace.h b/core/fpdfapi/fpdf_page/include/cpdf_colorspace.h index 48ace36835..8bb6c57260 100644 --- a/core/fpdfapi/fpdf_page/include/cpdf_colorspace.h +++ b/core/fpdfapi/fpdf_page/include/cpdf_colorspace.h @@ -79,7 +79,7 @@ class CPDF_ColorSpace { FX_BOOL bTransMask = FALSE) const; CPDF_Array*& GetArray() { return m_pArray; } - virtual CPDF_ColorSpace* GetBaseCS() const { return NULL; } + virtual CPDF_ColorSpace* GetBaseCS() const { return nullptr; } virtual void EnableStdConversion(FX_BOOL bEnabled); diff --git a/core/fpdfapi/fpdf_page/include/cpdf_form.h b/core/fpdfapi/fpdf_page/include/cpdf_form.h index d36a976176..92acbca25a 100644 --- a/core/fpdfapi/fpdf_page/include/cpdf_form.h +++ b/core/fpdfapi/fpdf_page/include/cpdf_form.h @@ -21,7 +21,7 @@ class CPDF_Form : public CPDF_PageObjectHolder { CPDF_Form(CPDF_Document* pDocument, CPDF_Dictionary* pPageResources, CPDF_Stream* pFormStream, - CPDF_Dictionary* pParentResources = NULL); + CPDF_Dictionary* pParentResources = nullptr); ~CPDF_Form(); diff --git a/core/fpdfapi/fpdf_page/include/cpdf_image.h b/core/fpdfapi/fpdf_page/include/cpdf_image.h index 48349deb3b..f475e53478 100644 --- a/core/fpdfapi/fpdf_page/include/cpdf_image.h +++ b/core/fpdfapi/fpdf_page/include/cpdf_image.h @@ -39,7 +39,7 @@ class CPDF_Image { CPDF_Dictionary* GetInlineDict() const { return m_pInlineDict; } CPDF_Stream* GetStream() const { return m_pStream; } CPDF_Dictionary* GetDict() const { - return m_pStream ? m_pStream->GetDict() : NULL; + return m_pStream ? m_pStream->GetDict() : nullptr; } CPDF_Dictionary* GetOC() const { return m_pOC; } CPDF_Document* GetDocument() const { return m_pDocument; } @@ -51,8 +51,8 @@ class CPDF_Image { FX_BOOL IsMask() const { return m_bIsMask; } FX_BOOL IsInterpol() const { return m_bInterpolate; } - CFX_DIBSource* LoadDIBSource(CFX_DIBSource** ppMask = NULL, - uint32_t* pMatteColor = NULL, + CFX_DIBSource* LoadDIBSource(CFX_DIBSource** ppMask = nullptr, + uint32_t* pMatteColor = nullptr, FX_BOOL bStdCS = FALSE, uint32_t GroupFamily = 0, FX_BOOL bLoadMask = FALSE) const; diff --git a/core/fpdfapi/fpdf_page/pageint.h b/core/fpdfapi/fpdf_page/pageint.h index b2204d8dbf..29fd6fb86e 100644 --- a/core/fpdfapi/fpdf_page/pageint.h +++ b/core/fpdfapi/fpdf_page/pageint.h @@ -52,7 +52,7 @@ class CPDF_StreamParser { uint32_t GetWordSize() const { return m_WordSize; } CPDF_Object* GetObject() { CPDF_Object* pObj = m_pLastObj; - m_pLastObj = NULL; + m_pLastObj = nullptr; return pObj; } uint32_t GetPos() const { return m_Pos; } diff --git a/core/fpdfapi/fpdf_parser/cfdf_document.cpp b/core/fpdfapi/fpdf_parser/cfdf_document.cpp index d4f49f659b..c039871401 100644 --- a/core/fpdfapi/fpdf_parser/cfdf_document.cpp +++ b/core/fpdfapi/fpdf_parser/cfdf_document.cpp @@ -10,9 +10,9 @@ #include "core/fpdfapi/fpdf_parser/cpdf_syntax_parser.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" -CFDF_Document::CFDF_Document() : CPDF_IndirectObjectHolder(NULL) { - m_pRootDict = NULL; - m_pFile = NULL; +CFDF_Document::CFDF_Document() : CPDF_IndirectObjectHolder(nullptr) { + m_pRootDict = nullptr; + m_pFile = nullptr; m_bOwnFile = FALSE; } CFDF_Document::~CFDF_Document() { diff --git a/core/fpdfapi/fpdf_parser/cpdf_array.cpp b/core/fpdfapi/fpdf_parser/cpdf_array.cpp index 20073772b7..a047b3af7b 100644 --- a/core/fpdfapi/fpdf_parser/cpdf_array.cpp +++ b/core/fpdfapi/fpdf_parser/cpdf_array.cpp @@ -101,12 +101,12 @@ FX_FLOAT CPDF_Array::GetNumberAt(size_t i) const { CPDF_Dictionary* CPDF_Array::GetDictAt(size_t i) const { CPDF_Object* p = GetDirectObjectAt(i); if (!p) - return NULL; + return nullptr; if (CPDF_Dictionary* pDict = p->AsDictionary()) return pDict; if (CPDF_Stream* pStream = p->AsStream()) return pStream->GetDict(); - return NULL; + return nullptr; } CPDF_Stream* CPDF_Array::GetStreamAt(size_t i) const { diff --git a/core/fpdfapi/fpdf_parser/cpdf_crypto_handler.cpp b/core/fpdfapi/fpdf_parser/cpdf_crypto_handler.cpp index 2d845d856a..3cd973c277 100644 --- a/core/fpdfapi/fpdf_parser/cpdf_crypto_handler.cpp +++ b/core/fpdfapi/fpdf_parser/cpdf_crypto_handler.cpp @@ -328,7 +328,7 @@ FX_BOOL CPDF_CryptoHandler::EncryptContent(uint32_t objnum, return TRUE; } CPDF_CryptoHandler::CPDF_CryptoHandler() { - m_pAESContext = NULL; + m_pAESContext = nullptr; m_Cipher = FXCIPHER_NONE; m_KeyLen = 0; } diff --git a/core/fpdfapi/fpdf_parser/cpdf_data_avail.cpp b/core/fpdfapi/fpdf_parser/cpdf_data_avail.cpp index c705a657aa..d3f9a54f4c 100644 --- a/core/fpdfapi/fpdf_parser/cpdf_data_avail.cpp +++ b/core/fpdfapi/fpdf_parser/cpdf_data_avail.cpp @@ -74,13 +74,13 @@ CPDF_DataAvail::CPDF_DataAvail(IPDF_DataAvail::FileAvail* pFileAvail, m_bPageLoadedOK = FALSE; m_bNeedDownLoadResource = FALSE; m_bLinearizedFormParamLoad = FALSE; - m_pLinearized = NULL; - m_pRoot = NULL; - m_pTrailer = NULL; - m_pCurrentParser = NULL; - m_pAcroForm = NULL; - m_pPageDict = NULL; - m_pPageResource = NULL; + m_pLinearized = nullptr; + m_pRoot = nullptr; + m_pTrailer = nullptr; + m_pCurrentParser = nullptr; + m_pAcroForm = nullptr; + m_pPageDict = nullptr; + m_pPageResource = nullptr; m_docStatus = PDF_DATAAVAIL_HEADER; m_parser.m_bOwnFileRead = false; m_bTotalLoadPageTree = FALSE; @@ -569,7 +569,7 @@ FX_BOOL CPDF_DataAvail::GetPageKids(CPDF_Parser* pParser, CPDF_Object* pPages) { } CPDF_Dictionary* pDict = pPages->GetDict(); - CPDF_Object* pKids = pDict ? pDict->GetObjectBy("Kids") : NULL; + CPDF_Object* pKids = pDict ? pDict->GetObjectBy("Kids") : nullptr; if (!pKids) return TRUE; @@ -642,19 +642,19 @@ FX_BOOL CPDF_DataAvail::CheckHeader(IPDF_DataAvail::DownloadHints* pHints) { FX_BOOL CPDF_DataAvail::CheckFirstPage(IPDF_DataAvail::DownloadHints* pHints) { CPDF_Dictionary* pDict = m_pLinearized->GetDict(); - CPDF_Object* pEndOffSet = pDict ? pDict->GetObjectBy("E") : NULL; + CPDF_Object* pEndOffSet = pDict ? pDict->GetObjectBy("E") : nullptr; if (!pEndOffSet) { m_docStatus = PDF_DATAAVAIL_ERROR; return FALSE; } - CPDF_Object* pXRefOffset = pDict ? pDict->GetObjectBy("T") : NULL; + CPDF_Object* pXRefOffset = pDict ? pDict->GetObjectBy("T") : nullptr; if (!pXRefOffset) { m_docStatus = PDF_DATAAVAIL_ERROR; return FALSE; } - CPDF_Object* pFileLen = pDict ? pDict->GetObjectBy("L") : NULL; + CPDF_Object* pFileLen = pDict ? pDict->GetObjectBy("L") : nullptr; if (!pFileLen) { m_docStatus = PDF_DATAAVAIL_ERROR; return FALSE; diff --git a/core/fpdfapi/fpdf_parser/cpdf_security_handler.cpp b/core/fpdfapi/fpdf_parser/cpdf_security_handler.cpp index a4629dcf6b..65d3173613 100644 --- a/core/fpdfapi/fpdf_parser/cpdf_security_handler.cpp +++ b/core/fpdfapi/fpdf_parser/cpdf_security_handler.cpp @@ -531,7 +531,7 @@ void CPDF_SecurityHandler::OnCreate(CPDF_Dictionary* pEncryptDict, owner_size = user_size; } if (m_Revision >= 5) { - int t = (int)time(NULL); + int t = (int)time(nullptr); uint8_t sha[128]; CRYPT_SHA256Start(sha); CRYPT_SHA256Update(sha, (uint8_t*)&t, sizeof t); @@ -620,7 +620,8 @@ void CPDF_SecurityHandler::OnCreate(CPDF_Dictionary* pEncryptDict, const uint8_t* user_pass, uint32_t user_size, uint32_t type) { - OnCreate(pEncryptDict, pIdArray, user_pass, user_size, NULL, 0, FALSE, type); + OnCreate(pEncryptDict, pIdArray, user_pass, user_size, nullptr, 0, FALSE, + type); } void CPDF_SecurityHandler::AES256_SetPassword(CPDF_Dictionary* pEncryptDict, const uint8_t* password, diff --git a/core/fpdfapi/fpdf_parser/include/cpdf_document.h b/core/fpdfapi/fpdf_parser/include/cpdf_document.h index e1d1c77a12..24d400fcd7 100644 --- a/core/fpdfapi/fpdf_parser/include/cpdf_document.h +++ b/core/fpdfapi/fpdf_parser/include/cpdf_document.h @@ -70,7 +70,7 @@ class CPDF_Document : public CPDF_IndirectObjectHolder { // |pFontDict| must not be null. CPDF_Font* LoadFont(CPDF_Dictionary* pFontDict); CPDF_ColorSpace* LoadColorSpace(CPDF_Object* pCSObj, - CPDF_Dictionary* pResources = NULL); + CPDF_Dictionary* pResources = nullptr); CPDF_Pattern* LoadPattern(CPDF_Object* pObj, FX_BOOL bShading, diff --git a/core/fpdfapi/fpdf_render/cpdf_pagerendercache.h b/core/fpdfapi/fpdf_render/cpdf_pagerendercache.h index 4f9ea1fe46..df0d73ac64 100644 --- a/core/fpdfapi/fpdf_render/cpdf_pagerendercache.h +++ b/core/fpdfapi/fpdf_render/cpdf_pagerendercache.h @@ -41,7 +41,7 @@ class CPDF_PageRenderCache { FX_BOOL bStdCS = FALSE, uint32_t GroupFamily = 0, FX_BOOL bLoadMask = FALSE, - CPDF_RenderStatus* pRenderStatus = NULL, + CPDF_RenderStatus* pRenderStatus = nullptr, int32_t downsampleWidth = 0, int32_t downsampleHeight = 0); @@ -56,7 +56,7 @@ class CPDF_PageRenderCache { FX_BOOL bStdCS = FALSE, uint32_t GroupFamily = 0, FX_BOOL bLoadMask = FALSE, - CPDF_RenderStatus* pRenderStatus = NULL, + CPDF_RenderStatus* pRenderStatus = nullptr, int32_t downsampleWidth = 0, int32_t downsampleHeight = 0); diff --git a/core/fpdfapi/fpdf_render/fpdf_render.cpp b/core/fpdfapi/fpdf_render/fpdf_render.cpp index 6ac78ecd43..7e8c8348a5 100644 --- a/core/fpdfapi/fpdf_render/fpdf_render.cpp +++ b/core/fpdfapi/fpdf_render/fpdf_render.cpp @@ -61,7 +61,7 @@ void CPDF_DocRenderData::Clear(FX_BOOL bRelease) { if (m_pFontCache) { if (bRelease) { delete m_pFontCache; - m_pFontCache = NULL; + m_pFontCache = nullptr; } else { m_pFontCache->FreeCache(FALSE); } @@ -92,7 +92,7 @@ CPDF_RenderOptions::CPDF_RenderOptions() m_Flags(RENDER_CLEARTYPE), m_Interpolation(0), m_AddFlags(0), - m_pOCContext(NULL), + m_pOCContext(nullptr), m_dwLimitCacheSize(1024 * 1024 * 100), m_HalftoneLimit(-1) {} FX_ARGB CPDF_RenderOptions::TranslateColor(FX_ARGB argb) const { @@ -324,7 +324,7 @@ void CPDF_RenderStatus::ProcessObjectNoClip(const CPDF_PageObject* pObj, FX_BOOL bRet = FALSE; switch (pObj->GetType()) { case CPDF_PageObject::TEXT: - bRet = ProcessText(pObj->AsText(), pObj2Device, NULL); + bRet = ProcessText(pObj->AsText(), pObj2Device, nullptr); break; case CPDF_PageObject::PATH: bRet = ProcessPath(pObj->AsPath(), pObj2Device); @@ -384,7 +384,7 @@ void CPDF_RenderStatus::DrawObjWithBackground(const CPDF_PageObject* pObj, CFX_Matrix matrix = *pObj2Device; matrix.Concat(*buffer.GetMatrix()); GetScaledMatrix(matrix); - CPDF_Dictionary* pFormResource = NULL; + CPDF_Dictionary* pFormResource = nullptr; if (pObj->IsForm()) { const CPDF_FormObject* pFormObj = pObj->AsForm(); if (pFormObj->m_pForm && pFormObj->m_pForm->m_pFormDict) { @@ -392,9 +392,9 @@ void CPDF_RenderStatus::DrawObjWithBackground(const CPDF_PageObject* pObj, } } CPDF_RenderStatus status; - status.Initialize(m_pContext, buffer.GetDevice(), buffer.GetMatrix(), NULL, - NULL, NULL, &m_Options, m_Transparency, m_bDropObjects, - pFormResource); + status.Initialize(m_pContext, buffer.GetDevice(), buffer.GetMatrix(), nullptr, + nullptr, nullptr, &m_Options, m_Transparency, + m_bDropObjects, pFormResource); status.RenderSingleObject(pObj, &matrix); buffer.OutputToDevice(); } @@ -407,12 +407,12 @@ FX_BOOL CPDF_RenderStatus::ProcessForm(const CPDF_FormObject* pFormObj, } CFX_Matrix matrix = pFormObj->m_FormMatrix; matrix.Concat(*pObj2Device); - CPDF_Dictionary* pResources = NULL; + CPDF_Dictionary* pResources = nullptr; if (pFormObj->m_pForm && pFormObj->m_pForm->m_pFormDict) { pResources = pFormObj->m_pForm->m_pFormDict->GetDictBy("Resources"); } CPDF_RenderStatus status; - status.Initialize(m_pContext, m_pDevice, NULL, m_pStopObj, this, pFormObj, + status.Initialize(m_pContext, m_pDevice, nullptr, m_pStopObj, this, pFormObj, &m_Options, m_Transparency, m_bDropObjects, pResources, FALSE); status.m_curBlend = m_curBlend; @@ -669,14 +669,14 @@ FX_BOOL CPDF_RenderStatus::ProcessTransparency(const CPDF_PageObject* pPageObj, return TRUE; } CPDF_Dictionary* pSMaskDict = - pGeneralState ? ToDictionary(pGeneralState->m_pSoftMask) : NULL; + pGeneralState ? ToDictionary(pGeneralState->m_pSoftMask) : nullptr; if (pSMaskDict) { if (pPageObj->IsImage() && pPageObj->AsImage()->m_pImage->GetDict()->KeyExist("SMask")) { - pSMaskDict = NULL; + pSMaskDict = nullptr; } } - CPDF_Dictionary* pFormResource = NULL; + CPDF_Dictionary* pFormResource = nullptr; FX_FLOAT group_alpha = 1.0f; int Transparency = m_Transparency; FX_BOOL bGroupTransparent = FALSE; @@ -701,15 +701,15 @@ FX_BOOL CPDF_RenderStatus::ProcessTransparency(const CPDF_PageObject* pPageObj, } if ((m_Options.m_Flags & RENDER_OVERPRINT) && pPageObj->IsImage() && pGeneralState && pGeneralState->m_FillOP && pGeneralState->m_StrokeOP) { - CPDF_Document* pDocument = NULL; - CPDF_Page* pPage = NULL; + CPDF_Document* pDocument = nullptr; + CPDF_Page* pPage = nullptr; if (m_pContext->GetPageCache()) { pPage = m_pContext->GetPageCache()->GetPage(); pDocument = pPage->m_pDocument; } else { pDocument = pPageObj->AsImage()->m_pImage->GetDocument(); } - CPDF_Dictionary* pPageResources = pPage ? pPage->m_pPageResources : NULL; + CPDF_Dictionary* pPageResources = pPage ? pPage->m_pPageResources : nullptr; CPDF_Object* pCSObj = pPageObj->AsImage() ->m_pImage->GetStream() ->GetDict() @@ -796,9 +796,9 @@ FX_BOOL CPDF_RenderStatus::ProcessTransparency(const CPDF_PageObject* pPageObj, } } CPDF_RenderStatus bitmap_render; - bitmap_render.Initialize(m_pContext, &bitmap_device, NULL, m_pStopObj, NULL, - NULL, &m_Options, 0, m_bDropObjects, pFormResource, - TRUE); + bitmap_render.Initialize(m_pContext, &bitmap_device, nullptr, m_pStopObj, + nullptr, nullptr, &m_Options, 0, m_bDropObjects, + pFormResource, TRUE); bitmap_render.ProcessObjectNoClip(pPageObj, &new_matrix); m_bStopped = bitmap_render.m_bStopped; if (pSMaskDict) { @@ -891,7 +891,7 @@ CPDF_GraphicStates* CPDF_RenderStatus::CloneObjStates( const CPDF_GraphicStates* pSrcStates, FX_BOOL bStroke) { if (!pSrcStates) { - return NULL; + return nullptr; } CPDF_GraphicStates* pStates = new CPDF_GraphicStates; pStates->CopyStates(*pSrcStates); @@ -935,7 +935,7 @@ void CPDF_RenderContext::AppendLayer(CPDF_PageObjectHolder* pObjectHolder, void CPDF_RenderContext::Render(CFX_RenderDevice* pDevice, const CPDF_RenderOptions* pOptions, const CFX_Matrix* pLastMatrix) { - Render(pDevice, NULL, pOptions, pLastMatrix); + Render(pDevice, nullptr, pOptions, pLastMatrix); } void CPDF_RenderContext::Render(CFX_RenderDevice* pDevice, const CPDF_PageObject* pStopObj, @@ -949,9 +949,9 @@ void CPDF_RenderContext::Render(CFX_RenderDevice* pDevice, CFX_Matrix FinalMatrix = pLayer->m_Matrix; FinalMatrix.Concat(*pLastMatrix); CPDF_RenderStatus status; - status.Initialize(this, pDevice, pLastMatrix, pStopObj, NULL, NULL, + status.Initialize(this, pDevice, pLastMatrix, pStopObj, nullptr, nullptr, pOptions, pLayer->m_pObjectHolder->m_Transparency, - FALSE, NULL); + FALSE, nullptr); status.RenderObjectList(pLayer->m_pObjectHolder, &FinalMatrix); if (status.m_Options.m_Flags & RENDER_LIMITEDIMAGECACHE) { m_pPageCache->CacheOptimization(status.m_Options.m_dwLimitCacheSize); @@ -962,8 +962,9 @@ void CPDF_RenderContext::Render(CFX_RenderDevice* pDevice, } } else { CPDF_RenderStatus status; - status.Initialize(this, pDevice, NULL, pStopObj, NULL, NULL, pOptions, - pLayer->m_pObjectHolder->m_Transparency, FALSE, NULL); + status.Initialize(this, pDevice, nullptr, pStopObj, nullptr, nullptr, + pOptions, pLayer->m_pObjectHolder->m_Transparency, + FALSE, nullptr); status.RenderObjectList(pLayer->m_pObjectHolder, &pLayer->m_Matrix); if (status.m_Options.m_Flags & RENDER_LIMITEDIMAGECACHE) { m_pPageCache->CacheOptimization(status.m_Options.m_dwLimitCacheSize); @@ -1014,8 +1015,8 @@ void CPDF_ProgressiveRenderer::Continue(IFX_Pause* pPause) { m_pCurrentLayer->m_pObjectHolder->GetPageObjectList()->end(); m_pRenderStatus.reset(new CPDF_RenderStatus()); m_pRenderStatus->Initialize( - m_pContext, m_pDevice, NULL, NULL, NULL, NULL, m_pOptions, - m_pCurrentLayer->m_pObjectHolder->m_Transparency, FALSE, NULL); + m_pContext, m_pDevice, nullptr, nullptr, nullptr, nullptr, m_pOptions, + m_pCurrentLayer->m_pObjectHolder->m_Transparency, FALSE, nullptr); m_pDevice->SaveState(); m_ClipRect = CFX_FloatRect(m_pDevice->GetClipBox()); CFX_Matrix device2object; @@ -1204,7 +1205,7 @@ void CPDF_DeviceBuffer::OutputToDevice() { CFX_DIBitmap buffer; m_pDevice->CreateCompatibleBitmap(&buffer, m_pBitmap->GetWidth(), m_pBitmap->GetHeight()); - m_pContext->GetBackground(&buffer, m_pObject, NULL, &m_Matrix); + m_pContext->GetBackground(&buffer, m_pObject, nullptr, &m_Matrix); buffer.CompositeBitmap(0, 0, buffer.GetWidth(), buffer.GetHeight(), m_pBitmap.get(), 0, 0); m_pDevice->StretchDIBits(&buffer, m_Rect.left, m_Rect.top, m_Rect.Width(), diff --git a/core/fpdfapi/fpdf_render/fpdf_render_cache.cpp b/core/fpdfapi/fpdf_render/fpdf_render_cache.cpp index b0539a2014..07fa2e7b82 100644 --- a/core/fpdfapi/fpdf_render/fpdf_render_cache.cpp +++ b/core/fpdfapi/fpdf_render/fpdf_render_cache.cpp @@ -166,14 +166,14 @@ void CPDF_PageRenderCache::ResetBitmap(CPDF_Stream* pStream, CPDF_ImageCacheEntry::CPDF_ImageCacheEntry(CPDF_Document* pDoc, CPDF_Stream* pStream) : m_dwTimeCount(0), - m_pCurBitmap(NULL), - m_pCurMask(NULL), + m_pCurBitmap(nullptr), + m_pCurMask(nullptr), m_MatteColor(0), - m_pRenderStatus(NULL), + m_pRenderStatus(nullptr), m_pDocument(pDoc), m_pStream(pStream), - m_pCachedBitmap(NULL), - m_pCachedMask(NULL), + m_pCachedBitmap(nullptr), + m_pCachedMask(nullptr), m_dwCacheSize(0) {} CPDF_ImageCacheEntry::~CPDF_ImageCacheEntry() { delete m_pCachedBitmap; @@ -181,7 +181,7 @@ CPDF_ImageCacheEntry::~CPDF_ImageCacheEntry() { } void CPDF_ImageCacheEntry::Reset(const CFX_DIBitmap* pBitmap) { delete m_pCachedBitmap; - m_pCachedBitmap = NULL; + m_pCachedBitmap = nullptr; if (pBitmap) { m_pCachedBitmap = pBitmap->Clone(); } @@ -217,12 +217,12 @@ FX_BOOL CPDF_ImageCacheEntry::GetCachedBitmap(CFX_DIBSource*& pBitmap, CPDF_PageRenderCache* pPageRenderCache = pContext->GetPageCache(); m_dwTimeCount = pPageRenderCache->GetTimeCount(); CPDF_DIBSource* pSrc = new CPDF_DIBSource; - CPDF_DIBSource* pMaskSrc = NULL; + CPDF_DIBSource* pMaskSrc = nullptr; if (!pSrc->Load(m_pDocument, m_pStream, &pMaskSrc, &MatteColor, pRenderStatus->m_pFormResource, pPageResources, bStdCS, GroupFamily, bLoadMask)) { delete pSrc; - pBitmap = NULL; + pBitmap = nullptr; return FALSE; } m_MatteColor = MatteColor; @@ -244,12 +244,12 @@ FX_BOOL CPDF_ImageCacheEntry::GetCachedBitmap(CFX_DIBSource*& pBitmap, } CFX_DIBSource* CPDF_ImageCacheEntry::DetachBitmap() { CFX_DIBSource* pDIBSource = m_pCurBitmap; - m_pCurBitmap = NULL; + m_pCurBitmap = nullptr; return pDIBSource; } CFX_DIBSource* CPDF_ImageCacheEntry::DetachMask() { CFX_DIBSource* pDIBSource = m_pCurMask; - m_pCurMask = NULL; + m_pCurMask = nullptr; return pDIBSource; } int CPDF_ImageCacheEntry::StartGetCachedBitmap(CPDF_Dictionary* pFormResources, @@ -279,7 +279,7 @@ int CPDF_ImageCacheEntry::StartGetCachedBitmap(CPDF_Dictionary* pFormResources, } if (!ret) { delete m_pCurBitmap; - m_pCurBitmap = NULL; + m_pCurBitmap = nullptr; return 0; } ContinueGetCachedBitmap(); @@ -295,14 +295,14 @@ void CPDF_ImageCacheEntry::ContinueGetCachedBitmap() { FPDF_HUGE_IMAGE_SIZE) { m_pCachedBitmap = m_pCurBitmap->Clone(); delete m_pCurBitmap; - m_pCurBitmap = NULL; + m_pCurBitmap = nullptr; } else { m_pCachedBitmap = m_pCurBitmap; } if (m_pCurMask) { m_pCachedMask = m_pCurMask->Clone(); delete m_pCurMask; - m_pCurMask = NULL; + m_pCurMask = nullptr; } m_pCurBitmap = m_pCachedBitmap; m_pCurMask = m_pCachedMask; @@ -315,7 +315,7 @@ int CPDF_ImageCacheEntry::Continue(IFX_Pause* pPause) { } if (!ret) { delete m_pCurBitmap; - m_pCurBitmap = NULL; + m_pCurBitmap = nullptr; return 0; } ContinueGetCachedBitmap(); diff --git a/core/fpdfapi/fpdf_render/fpdf_render_image.cpp b/core/fpdfapi/fpdf_render/fpdf_render_image.cpp index acfb20314a..76a6d4e764 100644 --- a/core/fpdfapi/fpdf_render/fpdf_render_image.cpp +++ b/core/fpdfapi/fpdf_render/fpdf_render_image.cpp @@ -31,7 +31,7 @@ FX_BOOL CPDF_RenderStatus::ProcessImage(const CPDF_ImageObject* pImageObj, const CFX_Matrix* pObj2Device) { CPDF_ImageRenderer render; if (render.Start(this, pImageObj, pObj2Device, m_bStdCS, m_curBlend)) { - render.Continue(NULL); + render.Continue(nullptr); } return render.m_Result; } @@ -89,7 +89,7 @@ void CPDF_RenderStatus::CompositeDIBitmap(CFX_DIBitmap* pDIBitmap, FX_RECT rect(left, top, left + pDIBitmap->GetWidth(), top + pDIBitmap->GetHeight()); rect.Intersect(m_pDevice->GetClipBox()); - CFX_DIBitmap* pClone = NULL; + CFX_DIBitmap* pClone = nullptr; FX_BOOL bClone = FALSE; if (m_pDevice->GetBackDrop() && m_pDevice->GetBitmap()) { bClone = TRUE; @@ -315,19 +315,19 @@ void CPDF_DIBTransferFunc::TranslateDownSamples(uint8_t* dest_buf, } } CPDF_ImageRenderer::CPDF_ImageRenderer() { - m_pRenderStatus = NULL; - m_pImageObject = NULL; + m_pRenderStatus = nullptr; + m_pImageObject = nullptr; m_Result = TRUE; m_Status = 0; - m_pTransformer = NULL; - m_DeviceHandle = NULL; - m_LoadHandle = NULL; - m_pClone = NULL; + m_pTransformer = nullptr; + m_DeviceHandle = nullptr; + m_LoadHandle = nullptr; + m_pClone = nullptr; m_bStdCS = FALSE; m_bPatternColor = FALSE; m_BlendType = FXDIB_BLEND_NORMAL; - m_pPattern = NULL; - m_pObj2Device = NULL; + m_pPattern = nullptr; + m_pObj2Device = nullptr; } CPDF_ImageRenderer::~CPDF_ImageRenderer() { delete m_pTransformer; @@ -392,7 +392,7 @@ FX_BOOL CPDF_ImageRenderer::StartRenderDIBSource() { } m_FillArgb = 0; m_bPatternColor = FALSE; - m_pPattern = NULL; + m_pPattern = nullptr; if (m_pDIBSource->IsAlphaMask()) { CPDF_Color* pColor = m_pImageObject->m_ColorState.GetFillColor(); if (pColor && pColor->IsPattern()) { @@ -450,15 +450,15 @@ FX_BOOL CPDF_ImageRenderer::StartRenderDIBSource() { pGeneralState->m_OPMode == 0 && pGeneralState->m_BlendType == FXDIB_BLEND_NORMAL && pGeneralState->m_StrokeAlpha == 1 && pGeneralState->m_FillAlpha == 1) { - CPDF_Document* pDocument = NULL; - CPDF_Page* pPage = NULL; + CPDF_Document* pDocument = nullptr; + CPDF_Page* pPage = nullptr; if (m_pRenderStatus->m_pContext->GetPageCache()) { pPage = m_pRenderStatus->m_pContext->GetPageCache()->GetPage(); pDocument = pPage->m_pDocument; } else { pDocument = m_pImageObject->m_pImage->GetDocument(); } - CPDF_Dictionary* pPageResources = pPage ? pPage->m_pPageResources : NULL; + CPDF_Dictionary* pPageResources = pPage ? pPage->m_pPageResources : nullptr; CPDF_Object* pCSObj = m_pImageObject->m_pImage->GetStream()->GetDict()->GetDirectObjectBy( "ColorSpace"); @@ -537,9 +537,10 @@ FX_BOOL CPDF_ImageRenderer::DrawPatternImage(const CFX_Matrix* pObj2Device) { bitmap_device1.GetBitmap()->Clear(0xffffff); { CPDF_RenderStatus bitmap_render; - bitmap_render.Initialize(m_pRenderStatus->m_pContext, &bitmap_device1, NULL, - NULL, NULL, NULL, &m_pRenderStatus->m_Options, 0, - m_pRenderStatus->m_bDropObjects, NULL, TRUE); + bitmap_render.Initialize(m_pRenderStatus->m_pContext, &bitmap_device1, + nullptr, nullptr, nullptr, nullptr, + &m_pRenderStatus->m_Options, 0, + m_pRenderStatus->m_bDropObjects, nullptr, TRUE); CFX_Matrix patternDevice = *pObj2Device; patternDevice.Translate((FX_FLOAT)-rect.left, (FX_FLOAT)-rect.top); if (CPDF_TilingPattern* pTilingPattern = m_pPattern->AsTilingPattern()) { @@ -559,13 +560,13 @@ FX_BOOL CPDF_ImageRenderer::DrawPatternImage(const CFX_Matrix* pObj2Device) { } bitmap_device2.GetBitmap()->Clear(0); CPDF_RenderStatus bitmap_render; - bitmap_render.Initialize(m_pRenderStatus->m_pContext, &bitmap_device2, NULL, - NULL, NULL, NULL, NULL, 0, - m_pRenderStatus->m_bDropObjects, NULL, TRUE); + bitmap_render.Initialize(m_pRenderStatus->m_pContext, &bitmap_device2, + nullptr, nullptr, nullptr, nullptr, nullptr, 0, + m_pRenderStatus->m_bDropObjects, nullptr, TRUE); CPDF_ImageRenderer image_render; if (image_render.Start(&bitmap_render, m_pDIBSource, 0xffffffff, 255, &new_matrix, m_Flags, TRUE)) { - image_render.Continue(NULL); + image_render.Continue(nullptr); } if (m_Loader.m_MatteColor != 0xffffffff) { int matte_r = FXARGB_R(m_Loader.m_MatteColor); @@ -636,13 +637,13 @@ FX_BOOL CPDF_ImageRenderer::DrawMaskedImage() { bitmap_device1.GetBitmap()->Clear(0xffffff); { CPDF_RenderStatus bitmap_render; - bitmap_render.Initialize(m_pRenderStatus->m_pContext, &bitmap_device1, NULL, - NULL, NULL, NULL, NULL, 0, - m_pRenderStatus->m_bDropObjects, NULL, TRUE); + bitmap_render.Initialize(m_pRenderStatus->m_pContext, &bitmap_device1, + nullptr, nullptr, nullptr, nullptr, nullptr, 0, + m_pRenderStatus->m_bDropObjects, nullptr, TRUE); CPDF_ImageRenderer image_render; if (image_render.Start(&bitmap_render, m_pDIBSource, 0, 255, &new_matrix, m_Flags, TRUE)) { - image_render.Continue(NULL); + image_render.Continue(nullptr); } } { @@ -652,13 +653,13 @@ FX_BOOL CPDF_ImageRenderer::DrawMaskedImage() { bitmap_device2.GetBitmap()->Clear(0); CPDF_RenderStatus bitmap_render; - bitmap_render.Initialize(m_pRenderStatus->m_pContext, &bitmap_device2, NULL, - NULL, NULL, NULL, NULL, 0, - m_pRenderStatus->m_bDropObjects, NULL, TRUE); + bitmap_render.Initialize(m_pRenderStatus->m_pContext, &bitmap_device2, + nullptr, nullptr, nullptr, nullptr, nullptr, 0, + m_pRenderStatus->m_bDropObjects, nullptr, TRUE); CPDF_ImageRenderer image_render; if (image_render.Start(&bitmap_render, m_Loader.m_pMask, 0xffffffff, 255, &new_matrix, m_Flags, TRUE)) { - image_render.Continue(NULL); + image_render.Continue(nullptr); } if (m_Loader.m_MatteColor != 0xffffffff) { int matte_r = FXARGB_R(m_Loader.m_MatteColor); @@ -803,7 +804,7 @@ FX_BOOL CPDF_ImageRenderer::StartBitmapAlpha() { path.Transform(&m_ImageMatrix); uint32_t fill_color = ArgbEncode(0xff, m_BitmapAlpha, m_BitmapAlpha, m_BitmapAlpha); - m_pRenderStatus->m_pDevice->DrawPath(&path, NULL, NULL, fill_color, 0, + m_pRenderStatus->m_pDevice->DrawPath(&path, nullptr, nullptr, fill_color, 0, FXFILL_WINDING); } else { const CFX_DIBSource* pAlphaMask = m_pDIBSource->IsAlphaMask() @@ -922,8 +923,8 @@ CFX_DIBitmap* CPDF_RenderStatus::LoadSMask(CPDF_Dictionary* pSMaskDict, return nullptr; CFX_DIBitmap& bitmap = *bitmap_device.GetBitmap(); - CPDF_Object* pCSObj = NULL; - CPDF_ColorSpace* pCS = NULL; + CPDF_Object* pCSObj = nullptr; + CPDF_ColorSpace* pCS = nullptr; if (bLuminosity) { CPDF_Array* pBC = pSMaskDict->GetArrayBy("BC"); FX_ARGB back_color = 0xff000000; @@ -932,7 +933,7 @@ CFX_DIBitmap* CPDF_RenderStatus::LoadSMask(CPDF_Dictionary* pSMaskDict, if (pDict && pDict->GetDictBy("Group")) pCSObj = pDict->GetDictBy("Group")->GetDirectObjectBy("CS"); else - pCSObj = NULL; + pCSObj = nullptr; pCS = m_pContext->GetDocument()->LoadColorSpace(pCSObj); if (pCS) { FX_FLOAT R, G, B; @@ -945,7 +946,7 @@ CFX_DIBitmap* CPDF_RenderStatus::LoadSMask(CPDF_Dictionary* pSMaskDict, FX_SAFE_UINT32 num_floats = comps; num_floats *= sizeof(FX_FLOAT); if (!num_floats.IsValid()) { - return NULL; + return nullptr; } FXSYS_memset(pFloats, 0, num_floats.ValueOrDie()); size_t count = pBC->GetCount() > 8 ? 8 : pBC->GetCount(); @@ -962,16 +963,16 @@ CFX_DIBitmap* CPDF_RenderStatus::LoadSMask(CPDF_Dictionary* pSMaskDict, } else { bitmap.Clear(0); } - CPDF_Dictionary* pFormResource = NULL; + CPDF_Dictionary* pFormResource = nullptr; if (form.m_pFormDict) { pFormResource = form.m_pFormDict->GetDictBy("Resources"); } CPDF_RenderOptions options; options.m_ColorMode = bLuminosity ? RENDER_COLOR_NORMAL : RENDER_COLOR_ALPHA; CPDF_RenderStatus status; - status.Initialize(m_pContext, &bitmap_device, NULL, NULL, NULL, NULL, - &options, 0, m_bDropObjects, pFormResource, TRUE, NULL, 0, - pCS ? pCS->GetFamily() : 0, bLuminosity); + status.Initialize(m_pContext, &bitmap_device, nullptr, nullptr, nullptr, + nullptr, &options, 0, m_bDropObjects, pFormResource, TRUE, + nullptr, 0, pCS ? pCS->GetFamily() : 0, bLuminosity); status.RenderObjectList(&form, &matrix); std::unique_ptr pMask(new CFX_DIBitmap); if (!pMask->Create(width, height, FXDIB_8bppMask)) diff --git a/core/fpdfapi/fpdf_render/fpdf_render_pattern.cpp b/core/fpdfapi/fpdf_render/fpdf_render_pattern.cpp index 7896f83459..20278f71d9 100644 --- a/core/fpdfapi/fpdf_render/fpdf_render_pattern.cpp +++ b/core/fpdfapi/fpdf_render/fpdf_render_pattern.cpp @@ -677,7 +677,7 @@ struct CPDF_PatchDrawer { fillFlags |= FXFILL_NOPATHSMOOTH; } pDevice->DrawPath( - &path, NULL, NULL, + &path, nullptr, nullptr, FXARGB_MAKE(alpha, div_colors[0].comp[0], div_colors[0].comp[1], div_colors[0].comp[2]), 0, fillFlags); @@ -1044,7 +1044,7 @@ void CPDF_RenderStatus::DrawTilingPattern(CPDF_TilingPattern* pPattern, if (width > clip_box.Width() || height > clip_box.Height() || width * height > clip_box.Width() * clip_box.Height()) { - CPDF_GraphicStates* pStates = NULL; + CPDF_GraphicStates* pStates = nullptr; if (!pPattern->colored()) pStates = CloneObjStates(pPageObj, bStroke); diff --git a/core/fpdfapi/fpdf_render/fpdf_render_text.cpp b/core/fpdfapi/fpdf_render/fpdf_render_text.cpp index a3df1c2214..43816c4d99 100644 --- a/core/fpdfapi/fpdf_render/fpdf_render_text.cpp +++ b/core/fpdfapi/fpdf_render/fpdf_render_text.cpp @@ -328,7 +328,7 @@ FX_BOOL CPDF_RenderStatus::ProcessText(const CPDF_TextObject* textobj, CPDF_Type3Cache* CPDF_RenderStatus::GetCachedType3(CPDF_Type3Font* pFont) { if (!pFont->m_pDocument) { - return NULL; + return nullptr; } pFont->m_pDocument->GetPageData()->GetFont(pFont->GetFontDict(), FALSE); return pFont->m_pDocument->GetRenderData()->GetCachedType3(pFont); @@ -415,17 +415,17 @@ FX_BOOL CPDF_RenderStatus::ProcessType3Text(const CPDF_TextObject* textobj, CPDF_RenderOptions Options = m_Options; Options.m_Flags |= RENDER_FORCE_HALFTONE | RENDER_RECT_AA; Options.m_Flags &= ~RENDER_FORCE_DOWNSAMPLE; - CPDF_Dictionary* pFormResource = NULL; + CPDF_Dictionary* pFormResource = nullptr; if (pType3Char->m_pForm && pType3Char->m_pForm->m_pFormDict) { pFormResource = pType3Char->m_pForm->m_pFormDict->GetDictBy("Resources"); } if (fill_alpha == 255) { CPDF_RenderStatus status; - status.Initialize(m_pContext, m_pDevice, NULL, NULL, this, pStates, - &Options, pType3Char->m_pForm->m_Transparency, - m_bDropObjects, pFormResource, FALSE, pType3Char, - fill_argb); + status.Initialize(m_pContext, m_pDevice, nullptr, nullptr, this, + pStates, &Options, + pType3Char->m_pForm->m_Transparency, m_bDropObjects, + pFormResource, FALSE, pType3Char, fill_argb); status.m_Type3FontCache.Append(m_Type3FontCache); status.m_Type3FontCache.Add(pType3Font); m_pDevice->SaveState(); @@ -443,10 +443,10 @@ FX_BOOL CPDF_RenderStatus::ProcessType3Text(const CPDF_TextObject* textobj, } bitmap_device.GetBitmap()->Clear(0); CPDF_RenderStatus status; - status.Initialize(m_pContext, &bitmap_device, NULL, NULL, this, pStates, - &Options, pType3Char->m_pForm->m_Transparency, - m_bDropObjects, pFormResource, FALSE, pType3Char, - fill_argb); + status.Initialize(m_pContext, &bitmap_device, nullptr, nullptr, this, + pStates, &Options, + pType3Char->m_pForm->m_Transparency, m_bDropObjects, + pFormResource, FALSE, pType3Char, fill_argb); status.m_Type3FontCache.Append(m_Type3FontCache); status.m_Type3FontCache.Add(pType3Font); matrix.TranslateI(-rect.left, -rect.top); @@ -527,7 +527,7 @@ class CPDF_CharPosList { }; CPDF_CharPosList::CPDF_CharPosList() { - m_pCharPos = NULL; + m_pCharPos = nullptr; } CPDF_CharPosList::~CPDF_CharPosList() { @@ -641,7 +641,7 @@ void CPDF_TextRenderer::DrawTextString(CFX_RenderDevice* pDevice, if (nChars == 1) { charcode = pFont->GetNextChar(str.c_str(), str.GetLength(), offset); pCharCodes = (uint32_t*)(uintptr_t)charcode; - pCharPos = NULL; + pCharPos = nullptr; } else { pCharCodes = FX_Alloc(uint32_t, nChars); pCharPos = FX_Alloc(FX_FLOAT, nChars - 1); @@ -690,7 +690,7 @@ FX_BOOL CPDF_TextRenderer::DrawNormalText(CFX_RenderDevice* pDevice, const CPDF_RenderOptions* pOptions) { CFX_FontCache* pCache = pFont->m_pDocument ? pFont->m_pDocument->GetRenderData()->GetFontCache() - : NULL; + : nullptr; CPDF_CharPosList CharPosList; CharPosList.Load(nChars, pCharCodes, pCharPos, pFont, font_size); int FXGE_flags = 0; diff --git a/core/fpdfapi/fpdf_render/render_int.h b/core/fpdfapi/fpdf_render/render_int.h index 98822797b0..f373b9371a 100644 --- a/core/fpdfapi/fpdf_render/render_int.h +++ b/core/fpdfapi/fpdf_render/render_int.h @@ -98,7 +98,7 @@ class CPDF_TransferFunc { class CPDF_DocRenderData { public: - CPDF_DocRenderData(CPDF_Document* pPDFDoc = NULL); + CPDF_DocRenderData(CPDF_Document* pPDFDoc = nullptr); ~CPDF_DocRenderData(); CPDF_Type3Cache* GetCachedType3(CPDF_Type3Font* pFont); CPDF_TransferFunc* GetTransferFunc(CPDF_Object* pObj); @@ -133,9 +133,9 @@ class CPDF_RenderStatus { const CPDF_RenderOptions* pOptions, int transparency, FX_BOOL bDropObjects, - CPDF_Dictionary* pFormResource = NULL, + CPDF_Dictionary* pFormResource = nullptr, FX_BOOL bStdCS = FALSE, - CPDF_Type3Char* pType3Char = NULL, + CPDF_Type3Char* pType3Char = nullptr, FX_ARGB fill_color = 0, uint32_t GroupFamily = 0, FX_BOOL bLoadMask = FALSE); @@ -291,7 +291,7 @@ class CPDF_ImageLoader { FX_BOOL bStdCS = FALSE, uint32_t GroupFamily = 0, FX_BOOL bLoadMask = FALSE, - CPDF_RenderStatus* pRenderStatus = NULL, + CPDF_RenderStatus* pRenderStatus = nullptr, int32_t nDownsampleWidth = 0, int32_t nDownsampleHeight = 0); FX_BOOL Continue(CPDF_ImageLoaderHandle* LoadHandle, IFX_Pause* pPause); @@ -316,7 +316,7 @@ class CPDF_ImageLoaderHandle { FX_BOOL bStdCS = FALSE, uint32_t GroupFamily = 0, FX_BOOL bLoadMask = FALSE, - CPDF_RenderStatus* pRenderStatus = NULL, + CPDF_RenderStatus* pRenderStatus = nullptr, int32_t nDownsampleWidth = 0, int32_t nDownsampleHeight = 0); FX_BOOL Continue(IFX_Pause* pPause); @@ -389,7 +389,7 @@ class CPDF_ScaledRenderBuffer { CFX_RenderDevice* pDevice, const FX_RECT& pRect, const CPDF_PageObject* pObj, - const CPDF_RenderOptions* pOptions = NULL, + const CPDF_RenderOptions* pOptions = nullptr, int max_dpi = 0); CFX_RenderDevice* GetDevice() { return m_pBitmapDevice ? m_pBitmapDevice.get() : m_pDevice; @@ -441,7 +441,7 @@ class CPDF_ImageCacheEntry { FX_BOOL bStdCS = FALSE, uint32_t GroupFamily = 0, FX_BOOL bLoadMask = FALSE, - CPDF_RenderStatus* pRenderStatus = NULL, + CPDF_RenderStatus* pRenderStatus = nullptr, int32_t downsampleWidth = 0, int32_t downsampleHeight = 0); uint32_t EstimateSize() const { return m_dwCacheSize; } @@ -456,7 +456,7 @@ class CPDF_ImageCacheEntry { FX_BOOL bStdCS = FALSE, uint32_t GroupFamily = 0, FX_BOOL bLoadMask = FALSE, - CPDF_RenderStatus* pRenderStatus = NULL, + CPDF_RenderStatus* pRenderStatus = nullptr, int32_t downsampleWidth = 0, int32_t downsampleHeight = 0); int Continue(IFX_Pause* pPause); @@ -610,7 +610,7 @@ class CPDF_DIBTransferFunc : public CFX_FilteredDIB { // CFX_FilteredDIB FXDIB_Format GetDestFormat() override; - FX_ARGB* GetDestPalette() override { return NULL; } + FX_ARGB* GetDestPalette() override { return nullptr; } void TranslateScanline(uint8_t* dest_buf, const uint8_t* src_buf) const override; void TranslateDownSamples(uint8_t* dest_buf, diff --git a/core/fpdfdoc/cpdf_variabletext.cpp b/core/fpdfdoc/cpdf_variabletext.cpp index a8b9c3c778..1d5fde289d 100644 --- a/core/fpdfdoc/cpdf_variabletext.cpp +++ b/core/fpdfdoc/cpdf_variabletext.cpp @@ -310,7 +310,7 @@ CPVT_WordPlace CPDF_VariableText::InsertWord(const CPVT_WordPlace& place, int32_t nFontIndex = GetSubWord() > 0 ? GetDefaultFontIndex() : GetWordFontIndex(word, charset, GetDefaultFontIndex()); - return AddWord(newplace, CPVT_WordInfo(word, charset, nFontIndex, NULL)); + return AddWord(newplace, CPVT_WordInfo(word, charset, nFontIndex, nullptr)); } CPVT_WordPlace CPDF_VariableText::InsertSection( diff --git a/core/fpdfdoc/doc_action.cpp b/core/fpdfdoc/doc_action.cpp index e646df2b4c..c512d1afa9 100644 --- a/core/fpdfdoc/doc_action.cpp +++ b/core/fpdfdoc/doc_action.cpp @@ -109,7 +109,7 @@ size_t CPDF_ActionFields::GetFieldsCount() const { return 0; } CFX_ByteString csType = pDict->GetStringBy("S"); - CPDF_Object* pFields = NULL; + CPDF_Object* pFields = nullptr; if (csType == "Hide") { pFields = pDict->GetDirectObjectBy("T"); } else { @@ -159,23 +159,23 @@ std::vector CPDF_ActionFields::GetAllFields() const { CPDF_Object* CPDF_ActionFields::GetField(size_t iIndex) const { if (!m_pAction) { - return NULL; + return nullptr; } CPDF_Dictionary* pDict = m_pAction->GetDict(); if (!pDict) { - return NULL; + return nullptr; } CFX_ByteString csType = pDict->GetStringBy("S"); - CPDF_Object* pFields = NULL; + CPDF_Object* pFields = nullptr; if (csType == "Hide") { pFields = pDict->GetDirectObjectBy("T"); } else { pFields = pDict->GetArrayBy("Fields"); } if (!pFields) { - return NULL; + return nullptr; } - CPDF_Object* pFindObj = NULL; + CPDF_Object* pFindObj = nullptr; if (pFields->IsDictionary() || pFields->IsString()) { if (iIndex == 0) pFindObj = pFields; diff --git a/core/fpdfdoc/doc_annot.cpp b/core/fpdfdoc/doc_annot.cpp index f8bad07ceb..9b2f9e505f 100644 --- a/core/fpdfdoc/doc_annot.cpp +++ b/core/fpdfdoc/doc_annot.cpp @@ -158,7 +158,7 @@ CPDF_Stream* FPDFDOC_GetAnnotAP(CPDF_Dictionary* pAnnotDict, CPDF_Annot::AppearanceMode mode) { CPDF_Dictionary* pAP = pAnnotDict->GetDictBy("AP"); if (!pAP) { - return NULL; + return nullptr; } const FX_CHAR* ap_entry = "N"; if (mode == CPDF_Annot::Down) @@ -215,7 +215,7 @@ static CPDF_Form* FPDFDOC_Annot_GetMatrix(const CPDF_Page* pPage, CFX_Matrix& matrix) { CPDF_Form* pForm = pAnnot->GetAPForm(pPage, mode); if (!pForm) { - return NULL; + return nullptr; } CFX_FloatRect form_bbox = pForm->m_pFormDict->GetRectBy("BBox"); CFX_Matrix form_matrix = pForm->m_pFormDict->GetMatrixBy("Matrix"); @@ -276,7 +276,7 @@ void CPDF_Annot::DrawBorder(CFX_RenderDevice* pDevice, CPDF_Dictionary* pBS = m_pAnnotDict->GetDictBy("BS"); char style_char; FX_FLOAT width; - CPDF_Array* pDashArray = NULL; + CPDF_Array* pDashArray = nullptr; if (!pBS) { CPDF_Array* pBorderArray = m_pAnnotDict->GetArrayBy("Border"); style_char = 'S'; diff --git a/core/fpdfdoc/doc_basic.cpp b/core/fpdfdoc/doc_basic.cpp index ab99cff772..72f2985cef 100644 --- a/core/fpdfdoc/doc_basic.cpp +++ b/core/fpdfdoc/doc_basic.cpp @@ -92,7 +92,7 @@ static CPDF_Object* SearchNameNode(CPDF_Dictionary* pNode, CPDF_Array** ppFind, int nLevel = 0) { if (nLevel > nMaxRecursion) { - return NULL; + return nullptr; } CPDF_Array* pLimits = pNode->GetArrayBy("Limits"); if (pLimits) { @@ -105,7 +105,7 @@ static CPDF_Object* SearchNameNode(CPDF_Dictionary* pNode, } if (csName.Compare(csLeft.AsStringC()) < 0 || csName.Compare(csRight.AsStringC()) > 0) { - return NULL; + return nullptr; } } CPDF_Array* pNames = pNode->GetArrayBy("Names"); @@ -128,11 +128,11 @@ static CPDF_Object* SearchNameNode(CPDF_Dictionary* pNode, return pNames->GetDirectObjectAt(i * 2 + 1); } nIndex += dwCount; - return NULL; + return nullptr; } CPDF_Array* pKids = pNode->GetArrayBy("Kids"); if (!pKids) { - return NULL; + return nullptr; } for (size_t i = 0; i < pKids->GetCount(); i++) { CPDF_Dictionary* pKid = pKids->GetDictAt(i); @@ -145,7 +145,7 @@ static CPDF_Object* SearchNameNode(CPDF_Dictionary* pNode, return pFound; } } - return NULL; + return nullptr; } static CPDF_Object* SearchNameNode(CPDF_Dictionary* pNode, @@ -155,14 +155,14 @@ static CPDF_Object* SearchNameNode(CPDF_Dictionary* pNode, CPDF_Array** ppFind, int nLevel = 0) { if (nLevel > nMaxRecursion) - return NULL; + return nullptr; CPDF_Array* pNames = pNode->GetArrayBy("Names"); if (pNames) { size_t nCount = pNames->GetCount() / 2; if (nIndex >= nCurIndex + nCount) { nCurIndex += nCount; - return NULL; + return nullptr; } if (ppFind) *ppFind = pNames; @@ -171,7 +171,7 @@ static CPDF_Object* SearchNameNode(CPDF_Dictionary* pNode, } CPDF_Array* pKids = pNode->GetArrayBy("Kids"); if (!pKids) - return NULL; + return nullptr; for (size_t i = 0; i < pKids->GetCount(); i++) { CPDF_Dictionary* pKid = pKids->GetDictAt(i); if (!pKid) @@ -181,7 +181,7 @@ static CPDF_Object* SearchNameNode(CPDF_Dictionary* pNode, if (pFound) return pFound; } - return NULL; + return nullptr; } static size_t CountNames(CPDF_Dictionary* pNode, int nLevel = 0) { @@ -219,7 +219,7 @@ int CPDF_NameTree::GetIndex(const CFX_ByteString& csName) const { return -1; } size_t nIndex = 0; - if (!SearchNameNode(m_pRoot, csName, nIndex, NULL)) { + if (!SearchNameNode(m_pRoot, csName, nIndex, nullptr)) { return -1; } return nIndex; @@ -227,17 +227,17 @@ int CPDF_NameTree::GetIndex(const CFX_ByteString& csName) const { CPDF_Object* CPDF_NameTree::LookupValue(int nIndex, CFX_ByteString& csName) const { if (!m_pRoot) { - return NULL; + return nullptr; } size_t nCurIndex = 0; - return SearchNameNode(m_pRoot, nIndex, nCurIndex, csName, NULL); + return SearchNameNode(m_pRoot, nIndex, nCurIndex, csName, nullptr); } CPDF_Object* CPDF_NameTree::LookupValue(const CFX_ByteString& csName) const { if (!m_pRoot) { - return NULL; + return nullptr; } size_t nIndex = 0; - return SearchNameNode(m_pRoot, csName, nIndex, NULL); + return SearchNameNode(m_pRoot, csName, nIndex, nullptr); } CPDF_Array* CPDF_NameTree::LookupNamedDest(CPDF_Document* pDoc, const CFX_ByteString& sName) { @@ -474,7 +474,7 @@ CFX_WideString CPDF_PageLabel::GetLabel(int nPage) const { } CPDF_Dictionary* pLabels = pPDFRoot->GetDictBy("PageLabels"); CPDF_NumberTree numberTree(pLabels); - CPDF_Object* pValue = NULL; + CPDF_Object* pValue = nullptr; int n = nPage; while (n >= 0) { pValue = numberTree.LookupValue(n); @@ -489,7 +489,7 @@ CFX_WideString CPDF_PageLabel::GetLabel(int nPage) const { if (pLabel->KeyExist("P")) { wsLabel += pLabel->GetUnicodeTextBy("P"); } - CFX_ByteString bsNumberingStyle = pLabel->GetStringBy("S", nullptr); + CFX_ByteString bsNumberingStyle = pLabel->GetStringBy("S", ""); int nLabelNum = nPage - n + pLabel->GetIntegerBy("St", 1); CFX_WideString wsNumPortion = _GetLabelNumPortion(nLabelNum, bsNumberingStyle); diff --git a/core/fpdfdoc/doc_form.cpp b/core/fpdfdoc/doc_form.cpp index 1570a6800c..7ecf35de37 100644 --- a/core/fpdfdoc/doc_form.cpp +++ b/core/fpdfdoc/doc_form.cpp @@ -97,13 +97,13 @@ class CFieldTree { return field_ptr; } --*fields_to_go; - return NULL; + return nullptr; } for (int i = 0; i < children.GetSize(); i++) { if (CPDF_FormField* pField = children.GetAt(i)->GetField(fields_to_go)) return pField; } - return NULL; + return nullptr; } CPDF_FormField* GetField(int index) { int fields_to_go = index; @@ -125,8 +125,8 @@ class CFieldTree { _Node m_Root; }; CFieldTree::CFieldTree() { - m_Root.parent = NULL; - m_Root.field_ptr = NULL; + m_Root.parent = nullptr; + m_Root.field_ptr = nullptr; } CFieldTree::~CFieldTree() { RemoveAll(); @@ -135,7 +135,7 @@ CFieldTree::_Node* CFieldTree::AddChild(_Node* pParent, const CFX_WideString& short_name, CPDF_FormField* field_ptr) { if (!pParent) { - return NULL; + return nullptr; } _Node* pNode = new _Node; pNode->parent = pParent; @@ -158,7 +158,7 @@ void CFieldTree::RemoveNode(_Node* pNode, int nLevel) { CFieldTree::_Node* CFieldTree::_Lookup(_Node* pParent, const CFX_WideString& short_name) { if (!pParent) { - return NULL; + return nullptr; } for (int i = 0; i < pParent->children.GetSize(); i++) { _Node* pNode = pParent->children[i]; @@ -168,7 +168,7 @@ CFieldTree::_Node* CFieldTree::_Lookup(_Node* pParent, return pNode; } } - return NULL; + return nullptr; } void CFieldTree::RemoveAll() { for (int i = 0; i < m_Root.children.GetSize(); i++) { @@ -184,13 +184,13 @@ void CFieldTree::SetField(const CFX_WideString& full_name, const FX_WCHAR* pName; FX_STRSIZE nLength; name_extractor.GetNext(pName, nLength); - _Node *pNode = &m_Root, *pLast = NULL; + _Node *pNode = &m_Root, *pLast = nullptr; while (nLength > 0) { pLast = pNode; CFX_WideString name = CFX_WideString(pName, nLength); pNode = _Lookup(pLast, name); if (!pNode) { - pNode = AddChild(pLast, name, NULL); + pNode = AddChild(pLast, name, nullptr); } name_extractor.GetNext(pName, nLength); } @@ -200,30 +200,31 @@ void CFieldTree::SetField(const CFX_WideString& full_name, } CPDF_FormField* CFieldTree::GetField(const CFX_WideString& full_name) { if (full_name == L"") { - return NULL; + return nullptr; } CFieldNameExtractor name_extractor(full_name); const FX_WCHAR* pName; FX_STRSIZE nLength; name_extractor.GetNext(pName, nLength); - _Node *pNode = &m_Root, *pLast = NULL; + _Node *pNode = &m_Root, *pLast = nullptr; while (nLength > 0 && pNode) { pLast = pNode; CFX_WideString name = CFX_WideString(pName, nLength); pNode = _Lookup(pLast, name); name_extractor.GetNext(pName, nLength); } - return pNode ? pNode->field_ptr : NULL; + return pNode ? pNode->field_ptr : nullptr; } CPDF_FormField* CFieldTree::RemoveField(const CFX_WideString& full_name) { if (full_name == L"") { - return NULL; + return nullptr; } CFieldNameExtractor name_extractor(full_name); const FX_WCHAR* pName; FX_STRSIZE nLength; name_extractor.GetNext(pName, nLength); - _Node *pNode = &m_Root, *pLast = NULL; + _Node* pNode = &m_Root; + _Node* pLast = nullptr; while (nLength > 0 && pNode) { pLast = pNode; CFX_WideString name = CFX_WideString(pName, nLength); @@ -241,17 +242,17 @@ CPDF_FormField* CFieldTree::RemoveField(const CFX_WideString& full_name) { RemoveNode(pNode); return pField; } - return NULL; + return nullptr; } CFieldTree::_Node* CFieldTree::FindNode(const CFX_WideString& full_name) { if (full_name == L"") { - return NULL; + return nullptr; } CFieldNameExtractor name_extractor(full_name); const FX_WCHAR* pName; FX_STRSIZE nLength; name_extractor.GetNext(pName, nLength); - _Node *pNode = &m_Root, *pLast = NULL; + _Node *pNode = &m_Root, *pLast = nullptr; while (nLength > 0 && pNode) { pLast = pNode; CFX_WideString name = CFX_WideString(pName, nLength); @@ -375,10 +376,10 @@ static int CALLBACK EnumFontFamExProc(ENUMLOGFONTEXA* lpelfe, static FX_BOOL RetrieveSpecificFont(LOGFONTA& lf) { PDF_FONTDATA fd; memset(&fd, 0, sizeof(PDF_FONTDATA)); - HDC hDC = ::GetDC(NULL); + HDC hDC = ::GetDC(nullptr); EnumFontFamiliesExA(hDC, &lf, (FONTENUMPROCA)EnumFontFamExProc, (LPARAM)&fd, 0); - ::ReleaseDC(NULL, hDC); + ::ReleaseDC(nullptr, hDC); if (fd.bFind) { memcpy(&lf, &fd.lf, sizeof(LOGFONTA)); } @@ -440,7 +441,8 @@ CFX_ByteString CPDF_InterForm::GetNativeFont(uint8_t charSet, void* pLogFont) { "Microsoft Sans Serif", lf); } if (!bRet) { - bRet = RetrieveSpecificFont(charSet, DEFAULT_PITCH | FF_DONTCARE, NULL, lf); + bRet = + RetrieveSpecificFont(charSet, DEFAULT_PITCH | FF_DONTCARE, nullptr, lf); } if (bRet) { if (pLogFont) { @@ -613,14 +615,14 @@ FX_BOOL CPDF_InterForm::ValidateFieldName( } FX_BOOL CPDF_InterForm::ValidateFieldName(CFX_WideString& csNewFieldName, int iType) { - return ValidateFieldName(csNewFieldName, iType, NULL, NULL); + return ValidateFieldName(csNewFieldName, iType, nullptr, nullptr); } FX_BOOL CPDF_InterForm::ValidateFieldName(const CPDF_FormField* pField, CFX_WideString& csNewFieldName) { return pField && !csNewFieldName.IsEmpty() && ValidateFieldName(csNewFieldName, ((CPDF_FormField*)pField)->GetFieldType(), pField, - NULL); + nullptr); } FX_BOOL CPDF_InterForm::ValidateFieldName(const CPDF_FormControl* pControl, CFX_WideString& csNewFieldName) { @@ -688,7 +690,7 @@ CPDF_FormField* CPDF_InterForm::GetField(uint32_t index, CPDF_FormField* CPDF_InterForm::GetFieldByDict( CPDF_Dictionary* pFieldDict) const { if (!pFieldDict) { - return NULL; + return nullptr; } CFX_WideString csWName = GetFullName(pFieldDict); return m_pFieldTree->GetField(csWName); @@ -926,14 +928,14 @@ void CPDF_InterForm::FixPageFields(const CPDF_Page* pPage) { } CPDF_FormField* CPDF_InterForm::AddTerminalField(CPDF_Dictionary* pFieldDict) { if (!pFieldDict->KeyExist("T")) { - return NULL; + return nullptr; } CPDF_Dictionary* pDict = pFieldDict; CFX_WideString csWName = GetFullName(pFieldDict); if (csWName.IsEmpty()) { - return NULL; + return nullptr; } - CPDF_FormField* pField = NULL; + CPDF_FormField* pField = nullptr; pField = m_pFieldTree->GetField(csWName); if (!pField) { CPDF_Dictionary* pParent = pFieldDict; @@ -1049,7 +1051,7 @@ CFDF_Document* CPDF_InterForm::ExportToFDF( bool bSimpleFileSpec) const { CFDF_Document* pDoc = CFDF_Document::CreateNewDoc(); if (!pDoc) { - return NULL; + return nullptr; } CPDF_Dictionary* pMainDict = pDoc->GetRoot()->GetDictBy("FDF"); if (!pdf_path.IsEmpty()) { diff --git a/core/fpdfdoc/doc_tagged.cpp b/core/fpdfdoc/doc_tagged.cpp index b5b89a017e..05109bb747 100644 --- a/core/fpdfdoc/doc_tagged.cpp +++ b/core/fpdfdoc/doc_tagged.cpp @@ -132,14 +132,14 @@ CPDF_StructElementImpl* CPDF_StructTreeImpl::AddPageNode( std::map& map, int nLevel) { if (nLevel > nMaxRecursion) - return NULL; + return nullptr; auto it = map.find(pDict); if (it != map.end()) return it->second; CPDF_StructElementImpl* pElement = - new CPDF_StructElementImpl(this, NULL, pDict); + new CPDF_StructElementImpl(this, nullptr, pDict); map[pDict] = pElement; CPDF_Dictionary* pParent = pDict->GetDictBy("P"); if (!pParent || pParent->GetStringBy("Type") == "StructTreeRoot") { @@ -301,7 +301,7 @@ void CPDF_StructElementImpl::LoadKid(uint32_t PageObjNum, pKid->m_Element.m_pElement = new CPDF_StructElementImpl(m_pTree, this, pKidDict); } else { - pKid->m_Element.m_pElement = NULL; + pKid->m_Element.m_pElement = nullptr; } } } @@ -335,7 +335,7 @@ CPDF_Object* CPDF_StructElementImpl::GetAttr(const CFX_ByteStringC& owner, FX_BOOL bInheritable, FX_FLOAT fLevel) { if (fLevel > nMaxRecursion) { - return NULL; + return nullptr; } if (bInheritable) { CPDF_Object* pAttr = GetAttr(owner, name, FALSE); @@ -343,7 +343,7 @@ CPDF_Object* CPDF_StructElementImpl::GetAttr(const CFX_ByteStringC& owner, return pAttr; } if (!m_pParent) { - return NULL; + return nullptr; } return m_pParent->GetAttr(owner, name, TRUE, fLevel + 1); } diff --git a/core/fpdfdoc/doc_utils.cpp b/core/fpdfdoc/doc_utils.cpp index 6c61c3d75e..05197380a6 100644 --- a/core/fpdfdoc/doc_utils.cpp +++ b/core/fpdfdoc/doc_utils.cpp @@ -23,7 +23,7 @@ CPDF_Object* SearchNumberNode(const CPDF_Dictionary* pNode, int num) { CPDF_Array* pLimits = pNode->GetArrayBy("Limits"); if (pLimits && (num < pLimits->GetIntegerAt(0) || num > pLimits->GetIntegerAt(1))) { - return NULL; + return nullptr; } CPDF_Array* pNumbers = pNode->GetArrayBy("Nums"); if (pNumbers) { @@ -36,11 +36,11 @@ CPDF_Object* SearchNumberNode(const CPDF_Dictionary* pNode, int num) { break; } } - return NULL; + return nullptr; } CPDF_Array* pKids = pNode->GetArrayBy("Kids"); if (!pKids) { - return NULL; + return nullptr; } for (size_t i = 0; i < pKids->GetCount(); i++) { CPDF_Dictionary* pKid = pKids->GetDictAt(i); @@ -52,7 +52,7 @@ CPDF_Object* SearchNumberNode(const CPDF_Dictionary* pNode, int num) { return pFound; } } - return NULL; + return nullptr; } } // namespace @@ -279,16 +279,17 @@ void InitInterFormDict(CPDF_Dictionary*& pFormDict, CPDF_Document* pDocument) { } CFX_ByteString csDA; if (!pFormDict->KeyExist("DR")) { - CPDF_Font* pFont = NULL; - CFX_ByteString csBaseName, csDefault; + CFX_ByteString csBaseName; + CFX_ByteString csDefault; uint8_t charSet = CPDF_InterForm::GetNativeCharSet(); - pFont = CPDF_InterForm::AddStandardFont(pDocument, "Helvetica"); + CPDF_Font* pFont = CPDF_InterForm::AddStandardFont(pDocument, "Helvetica"); if (pFont) { AddInterFormFont(pFormDict, pDocument, pFont, csBaseName); csDefault = csBaseName; } if (charSet != 0) { - CFX_ByteString csFontName = CPDF_InterForm::GetNativeFont(charSet, NULL); + CFX_ByteString csFontName = + CPDF_InterForm::GetNativeFont(charSet, nullptr); if (!pFont || csFontName != "Helvetica") { pFont = CPDF_InterForm::AddNativeFont(pDocument); if (pFont) { @@ -341,15 +342,15 @@ CPDF_Font* GetInterFormFont(CPDF_Dictionary* pFormDict, uint32_t index, CFX_ByteString& csNameTag) { if (!pFormDict) { - return NULL; + return nullptr; } CPDF_Dictionary* pDR = pFormDict->GetDictBy("DR"); if (!pDR) { - return NULL; + return nullptr; } CPDF_Dictionary* pFonts = pDR->GetDictBy("Font"); if (!pFonts) { - return NULL; + return nullptr; } uint32_t dwCount = 0; for (const auto& it : *pFonts) { @@ -369,46 +370,46 @@ CPDF_Font* GetInterFormFont(CPDF_Dictionary* pFormDict, } dwCount++; } - return NULL; + return nullptr; } CPDF_Font* GetInterFormFont(CPDF_Dictionary* pFormDict, CPDF_Document* pDocument, CFX_ByteString csNameTag) { CFX_ByteString csAlias = PDF_NameDecode(csNameTag); if (!pFormDict || csAlias.IsEmpty()) { - return NULL; + return nullptr; } CPDF_Dictionary* pDR = pFormDict->GetDictBy("DR"); if (!pDR) { - return NULL; + return nullptr; } CPDF_Dictionary* pFonts = pDR->GetDictBy("Font"); if (!pFonts) { - return NULL; + return nullptr; } CPDF_Dictionary* pElement = pFonts->GetDictBy(csAlias); if (!pElement) { - return NULL; + return nullptr; } if (pElement->GetStringBy("Type") == "Font") { return pDocument->LoadFont(pElement); } - return NULL; + return nullptr; } CPDF_Font* GetInterFormFont(CPDF_Dictionary* pFormDict, CPDF_Document* pDocument, CFX_ByteString csFontName, CFX_ByteString& csNameTag) { if (!pFormDict || csFontName.IsEmpty()) { - return NULL; + return nullptr; } CPDF_Dictionary* pDR = pFormDict->GetDictBy("DR"); if (!pDR) { - return NULL; + return nullptr; } CPDF_Dictionary* pFonts = pDR->GetDictBy("Font"); if (!pFonts) { - return NULL; + return nullptr; } for (const auto& it : *pFonts) { const CFX_ByteString& csKey = it.first; @@ -434,22 +435,22 @@ CPDF_Font* GetInterFormFont(CPDF_Dictionary* pFormDict, return pFind; } } - return NULL; + return nullptr; } CPDF_Font* GetNativeInterFormFont(CPDF_Dictionary* pFormDict, CPDF_Document* pDocument, uint8_t charSet, CFX_ByteString& csNameTag) { if (!pFormDict) { - return NULL; + return nullptr; } CPDF_Dictionary* pDR = pFormDict->GetDictBy("DR"); if (!pDR) { - return NULL; + return nullptr; } CPDF_Dictionary* pFonts = pDR->GetDictBy("Font"); if (!pFonts) { - return NULL; + return nullptr; } for (const auto& it : *pFonts) { const CFX_ByteString& csKey = it.first; @@ -475,7 +476,7 @@ CPDF_Font* GetNativeInterFormFont(CPDF_Dictionary* pFormDict, return pFind; } } - return NULL; + return nullptr; } CPDF_Font* GetNativeInterFormFont(CPDF_Dictionary* pFormDict, CPDF_Document* pDocument, @@ -669,7 +670,7 @@ void RemoveInterFormFont(CPDF_Dictionary* pFormDict, CFX_ByteString csNameTag) { CPDF_Font* GetDefaultInterFormFont(CPDF_Dictionary* pFormDict, CPDF_Document* pDocument) { if (!pFormDict) { - return NULL; + return nullptr; } CPDF_DefaultAppearance cDA(pFormDict->GetStringBy("DA")); CFX_ByteString csFontNameTag; @@ -735,10 +736,10 @@ CPDF_Object* FPDF_GetFieldAttr(CPDF_Dictionary* pFieldDict, const FX_CHAR* name, int nLevel) { if (nLevel > FPDFDOC_UTILS_MAXRECURSION) { - return NULL; + return nullptr; } if (!pFieldDict) { - return NULL; + return nullptr; } CPDF_Object* pAttr = pFieldDict->GetDirectObjectBy(name); if (pAttr) { @@ -746,7 +747,7 @@ CPDF_Object* FPDF_GetFieldAttr(CPDF_Dictionary* pFieldDict, } CPDF_Dictionary* pParent = pFieldDict->GetDictBy("Parent"); if (!pParent) { - return NULL; + return nullptr; } return FPDF_GetFieldAttr(pParent, name, nLevel + 1); } diff --git a/core/fpdfdoc/doc_viewerPreferences.cpp b/core/fpdfdoc/doc_viewerPreferences.cpp index a355635bf0..1de8c92614 100644 --- a/core/fpdfdoc/doc_viewerPreferences.cpp +++ b/core/fpdfdoc/doc_viewerPreferences.cpp @@ -9,46 +9,35 @@ CPDF_ViewerPreferences::CPDF_ViewerPreferences(CPDF_Document* pDoc) : m_pDoc(pDoc) {} + CPDF_ViewerPreferences::~CPDF_ViewerPreferences() {} + FX_BOOL CPDF_ViewerPreferences::IsDirectionR2L() const { - CPDF_Dictionary* pDict = m_pDoc->GetRoot(); - pDict = pDict->GetDictBy("ViewerPreferences"); - if (!pDict) { - return FALSE; - } - return "R2L" == pDict->GetStringBy("Direction"); + CPDF_Dictionary* pDict = GetViewerPreferences(); + return pDict ? pDict->GetStringBy("Direction") == "R2L" : FALSE; } + FX_BOOL CPDF_ViewerPreferences::PrintScaling() const { - CPDF_Dictionary* pDict = m_pDoc->GetRoot(); - pDict = pDict->GetDictBy("ViewerPreferences"); - if (!pDict) { - return TRUE; - } - return "None" != pDict->GetStringBy("PrintScaling"); + CPDF_Dictionary* pDict = GetViewerPreferences(); + return pDict ? pDict->GetStringBy("PrintScaling") != "None" : TRUE; } + int32_t CPDF_ViewerPreferences::NumCopies() const { - CPDF_Dictionary* pDict = m_pDoc->GetRoot(); - pDict = pDict->GetDictBy("ViewerPreferences"); - if (!pDict) { - return 1; - } - return pDict->GetIntegerBy("NumCopies"); + CPDF_Dictionary* pDict = GetViewerPreferences(); + return pDict ? pDict->GetIntegerBy("NumCopies") : 1; } + CPDF_Array* CPDF_ViewerPreferences::PrintPageRange() const { - CPDF_Dictionary* pDict = m_pDoc->GetRoot(); - CPDF_Array* pRange = NULL; - pDict = pDict->GetDictBy("ViewerPreferences"); - if (!pDict) { - return pRange; - } - pRange = pDict->GetArrayBy("PrintPageRange"); - return pRange; + CPDF_Dictionary* pDict = GetViewerPreferences(); + return pDict ? pDict->GetArrayBy("PrintPageRange") : nullptr; } + CFX_ByteString CPDF_ViewerPreferences::Duplex() const { + CPDF_Dictionary* pDict = GetViewerPreferences(); + return pDict ? pDict->GetStringBy("Duplex") : CFX_ByteString("None"); +} + +CPDF_Dictionary* CPDF_ViewerPreferences::GetViewerPreferences() const { CPDF_Dictionary* pDict = m_pDoc->GetRoot(); - pDict = pDict->GetDictBy("ViewerPreferences"); - if (!pDict) { - return "None"; - } - return pDict->GetStringBy("Duplex"); + return pDict ? pDict->GetDictBy("ViewerPreferences") : nullptr; } diff --git a/core/fpdfdoc/include/cpdf_variabletext.h b/core/fpdfdoc/include/cpdf_variabletext.h index faa5036469..06b41f186c 100644 --- a/core/fpdfdoc/include/cpdf_variabletext.h +++ b/core/fpdfdoc/include/cpdf_variabletext.h @@ -115,20 +115,20 @@ class CPDF_VariableText : private CPDF_EditContainer { void ResetAll(); void SetText(const FX_WCHAR* text, int32_t charset = 1, - const CPVT_SecProps* pSecProps = NULL, - const CPVT_WordProps* pWordProps = NULL); + const CPVT_SecProps* pSecProps = nullptr, + const CPVT_WordProps* pWordProps = nullptr); CPVT_WordPlace InsertWord(const CPVT_WordPlace& place, uint16_t word, int32_t charset = 1, - const CPVT_WordProps* pWordProps = NULL); + const CPVT_WordProps* pWordProps = nullptr); CPVT_WordPlace InsertSection(const CPVT_WordPlace& place, - const CPVT_SecProps* pSecProps = NULL, - const CPVT_WordProps* pWordProps = NULL); + const CPVT_SecProps* pSecProps = nullptr, + const CPVT_WordProps* pWordProps = nullptr); CPVT_WordPlace InsertText(const CPVT_WordPlace& place, const FX_WCHAR* text, int32_t charset = 1, - const CPVT_SecProps* pSecProps = NULL, - const CPVT_WordProps* pWordProps = NULL); + const CPVT_SecProps* pSecProps = nullptr, + const CPVT_WordProps* pWordProps = nullptr); CPVT_WordPlace DeleteWords(const CPVT_WordRange& PlaceRange); CPVT_WordPlace DeleteWord(const CPVT_WordPlace& place); CPVT_WordPlace BackSpaceWord(const CPVT_WordPlace& place); diff --git a/core/fpdfdoc/include/fpdf_doc.h b/core/fpdfdoc/include/fpdf_doc.h index 339182c19b..a70a24c1e3 100644 --- a/core/fpdfdoc/include/fpdf_doc.h +++ b/core/fpdfdoc/include/fpdf_doc.h @@ -44,7 +44,6 @@ class CPDF_Page; class CPDF_PageObject; class CPDF_RenderContext; class CPDF_RenderOptions; -class CPDF_ViewerPreferences; class CXML_Element; class IPDF_FormNotify; @@ -899,6 +898,8 @@ class CPDF_ViewerPreferences { CFX_ByteString Duplex() const; protected: + CPDF_Dictionary* GetViewerPreferences() const; + CPDF_Document* const m_pDoc; }; diff --git a/core/fpdfdoc/pdf_vt.h b/core/fpdfdoc/pdf_vt.h index 9026eeee9e..3f06f7d6d6 100644 --- a/core/fpdfdoc/pdf_vt.h +++ b/core/fpdfdoc/pdf_vt.h @@ -28,7 +28,7 @@ class CPVT_ArrayTemplate : public CFX_ArrayTemplate { if (nIndex >= 0 && nIndex < CFX_ArrayTemplate::GetSize()) { return CFX_ArrayTemplate::GetAt(nIndex); } - return NULL; + return nullptr; } void RemoveAt(int nIndex) { if (nIndex >= 0 && nIndex < CFX_ArrayTemplate::GetSize()) { diff --git a/core/fpdftext/fpdf_text_int.cpp b/core/fpdftext/fpdf_text_int.cpp index 1f8ab75e85..fd1214b588 100644 --- a/core/fpdftext/fpdf_text_int.cpp +++ b/core/fpdftext/fpdf_text_int.cpp @@ -177,7 +177,7 @@ void CPDF_TextPage::ParseTextPage() { m_bIsParsed = false; m_TextBuf.Clear(); m_CharList.clear(); - m_pPreTextObj = NULL; + m_pPreTextObj = nullptr; ProcessObject(); m_bIsParsed = true; @@ -836,7 +836,7 @@ void CPDF_TextPage::AddCharInfoByLRDirection(FX_WCHAR wChar, if (!IsControlChar(info)) { info.m_Index = m_TextBuf.GetLength(); if (wChar >= 0xFB00 && wChar <= 0xFB06) { - FX_WCHAR* pDst = NULL; + FX_WCHAR* pDst = nullptr; FX_STRSIZE nCount = Unicode_GetNormalization(wChar, pDst); if (nCount >= 1) { pDst = FX_Alloc(FX_WCHAR, nCount); @@ -864,7 +864,7 @@ void CPDF_TextPage::AddCharInfoByRLDirection(FX_WCHAR wChar, if (!IsControlChar(info)) { info.m_Index = m_TextBuf.GetLength(); wChar = FX_GetMirrorChar(wChar, TRUE, FALSE); - FX_WCHAR* pDst = NULL; + FX_WCHAR* pDst = nullptr; FX_STRSIZE nCount = Unicode_GetNormalization(wChar, pDst); if (nCount >= 1) { pDst = FX_Alloc(FX_WCHAR, nCount); @@ -1019,7 +1019,7 @@ FPDFText_MarkedContent CPDF_TextPage::PreMarkedContent(PDFTEXT_Obj Obj) { CFX_WideString actText; FX_BOOL bExist = FALSE; - CPDF_Dictionary* pDict = NULL; + CPDF_Dictionary* pDict = nullptr; int n = 0; for (n = 0; n < nContentMark; n++) { CPDF_ContentMarkItem& item = pMarkData->GetItem(n); @@ -1085,7 +1085,7 @@ void CPDF_TextPage::ProcessMarkedContent(PDFTEXT_Obj Obj) { if (nContentMark < 1) return; CFX_WideString actText; - CPDF_Dictionary* pDict = NULL; + CPDF_Dictionary* pDict = nullptr; for (int n = 0; n < nContentMark; n++) { CPDF_ContentMarkItem& item = pMarkData->GetItem(n); if (item.GetParamType() == CPDF_ContentMarkItem::ParamType::None) @@ -1760,7 +1760,7 @@ FX_BOOL CPDF_TextPage::GenerateCharInfo(FX_WCHAR unicode, PAGECHAR_INFO& info) { } info.m_Index = m_TextBuf.GetLength(); info.m_Unicode = unicode; - info.m_pTextObj = NULL; + info.m_pTextObj = nullptr; info.m_CharCode = CPDF_Font::kInvalidCharCode; info.m_Flag = FPDFTEXT_CHAR_GENERATED; int preWidth = 0; diff --git a/core/fxcodec/codec/fx_codec.cpp b/core/fxcodec/codec/fx_codec.cpp index 6a45737b10..55cb6ee7fb 100644 --- a/core/fxcodec/codec/fx_codec.cpp +++ b/core/fxcodec/codec/fx_codec.cpp @@ -127,8 +127,8 @@ class CCodec_RLScanlineDecoder : public CCodec_ScanlineDecoder { uint8_t m_Operator; }; CCodec_RLScanlineDecoder::CCodec_RLScanlineDecoder() - : m_pScanline(NULL), - m_pSrcBuf(NULL), + : m_pScanline(nullptr), + m_pSrcBuf(nullptr), m_SrcSize(0), m_dwLineBytes(0), m_SrcOffset(0), @@ -206,7 +206,7 @@ uint8_t* CCodec_RLScanlineDecoder::v_GetNextLine() { GetNextOperator(); } else { if (m_bEOD) { - return NULL; + return nullptr; } } FXSYS_memset(m_pScanline, 0, m_Pitch); diff --git a/core/fxcodec/codec/fx_codec_bmp.cpp b/core/fxcodec/codec/fx_codec_bmp.cpp index 03390cfea3..beda53c05b 100644 --- a/core/fxcodec/codec/fx_codec_bmp.cpp +++ b/core/fxcodec/codec/fx_codec_bmp.cpp @@ -113,8 +113,8 @@ int32_t CCodec_BmpModule::LoadImage(FXBMP_Context* ctx) { } uint32_t CCodec_BmpModule::GetAvailInput(FXBMP_Context* ctx, - uint8_t** avial_buf_ptr) { - return bmp_get_avail_input(ctx->bmp_ptr, avial_buf_ptr); + uint8_t** avail_buf_ptr) { + return bmp_get_avail_input(ctx->bmp_ptr, avail_buf_ptr); } void CCodec_BmpModule::Input(FXBMP_Context* ctx, diff --git a/core/fxcodec/codec/fx_codec_fax.cpp b/core/fxcodec/codec/fx_codec_fax.cpp index 90d3b24cab..c0202829ee 100644 --- a/core/fxcodec/codec/fx_codec_fax.cpp +++ b/core/fxcodec/codec/fx_codec_fax.cpp @@ -537,7 +537,7 @@ uint8_t* CCodec_FaxDecoder::v_GetNextLine() { int bitsize = m_SrcSize * 8; FaxSkipEOL(m_pSrcBuf, bitsize, bitpos); if (bitpos >= bitsize) { - return NULL; + return nullptr; } FXSYS_memset(m_pScanlineBuf, 0xff, m_Pitch); if (m_Encoding < 0) { diff --git a/core/fxcodec/codec/fx_codec_flate.cpp b/core/fxcodec/codec/fx_codec_flate.cpp index cd24b6624c..d32a8a13ba 100644 --- a/core/fxcodec/codec/fx_codec_flate.cpp +++ b/core/fxcodec/codec/fx_codec_flate.cpp @@ -648,11 +648,11 @@ class CCodec_FlateScanlineDecoder : public CCodec_ScanlineDecoder { }; CCodec_FlateScanlineDecoder::CCodec_FlateScanlineDecoder() { - m_pFlate = NULL; - m_pScanline = NULL; - m_pLastLine = NULL; - m_pPredictBuffer = NULL; - m_pPredictRaw = NULL; + m_pFlate = nullptr; + m_pScanline = nullptr; + m_pLastLine = nullptr; + m_pPredictBuffer = nullptr; + m_pPredictRaw = nullptr; m_LeftOver = 0; } CCodec_FlateScanlineDecoder::~CCodec_FlateScanlineDecoder() { @@ -799,7 +799,7 @@ uint32_t CCodec_FlateModule::FlateOrLZWDecode(FX_BOOL bLZW, uint32_t estimated_size, uint8_t*& dest_buf, uint32_t& dest_size) { - dest_buf = NULL; + dest_buf = nullptr; uint32_t offset = 0; int predictor_type = 0; if (predictor) { @@ -814,7 +814,8 @@ uint32_t CCodec_FlateModule::FlateOrLZWDecode(FX_BOOL bLZW, std::unique_ptr decoder(new CLZWDecoder); dest_size = (uint32_t)-1; offset = src_size; - int err = decoder->Decode(NULL, dest_size, src_buf, offset, bEarlyChange); + int err = + decoder->Decode(nullptr, dest_size, src_buf, offset, bEarlyChange); if (err || dest_size == 0 || dest_size + 1 < dest_size) { return FX_INVALID_OFFSET; } diff --git a/core/fxcodec/codec/fx_codec_gif.cpp b/core/fxcodec/codec/fx_codec_gif.cpp index 13576412c2..f04192ebef 100644 --- a/core/fxcodec/codec/fx_codec_gif.cpp +++ b/core/fxcodec/codec/fx_codec_gif.cpp @@ -175,8 +175,8 @@ int32_t CCodec_GifModule::LoadFrame(FXGIF_Context* ctx, } uint32_t CCodec_GifModule::GetAvailInput(FXGIF_Context* ctx, - uint8_t** avial_buf_ptr) { - return gif_get_avail_input(ctx->gif_ptr, avial_buf_ptr); + uint8_t** avail_buf_ptr) { + return gif_get_avail_input(ctx->gif_ptr, avail_buf_ptr); } void CCodec_GifModule::Input(FXGIF_Context* ctx, diff --git a/core/fxcodec/codec/fx_codec_icc.cpp b/core/fxcodec/codec/fx_codec_icc.cpp index 876297fd40..4903c24715 100644 --- a/core/fxcodec/codec/fx_codec_icc.cpp +++ b/core/fxcodec/codec/fx_codec_icc.cpp @@ -98,15 +98,13 @@ void* IccLib_CreateTransform(const unsigned char* pSrcProfileData, int intent, uint32_t dwSrcFormat = Icc_FORMAT_DEFAULT, uint32_t dwDstFormat = Icc_FORMAT_DEFAULT) { - cmsHPROFILE srcProfile = NULL; - cmsHPROFILE dstProfile = NULL; - cmsHTRANSFORM hTransform = NULL; - CLcmsCmm* pCmm = NULL; nSrcComponents = 0; - srcProfile = cmsOpenProfileFromMem((void*)pSrcProfileData, dwSrcProfileSize); - if (!srcProfile) { - return NULL; - } + cmsHPROFILE srcProfile = + cmsOpenProfileFromMem((void*)pSrcProfileData, dwSrcProfileSize); + if (!srcProfile) + return nullptr; + + cmsHPROFILE dstProfile; if (!pDstProfileData && dwDstProfileSize == 0 && nDstComponents == 3) { dstProfile = cmsCreate_sRGBProfile(); } else { @@ -115,7 +113,7 @@ void* IccLib_CreateTransform(const unsigned char* pSrcProfileData, } if (!dstProfile) { cmsCloseProfile(srcProfile); - return NULL; + return nullptr; } int srcFormat; FX_BOOL bLab = FALSE; @@ -136,8 +134,10 @@ void* IccLib_CreateTransform(const unsigned char* pSrcProfileData, if (!CheckComponents(dstCS, nDstComponents, TRUE)) { cmsCloseProfile(srcProfile); cmsCloseProfile(dstProfile); - return NULL; + return nullptr; } + + cmsHTRANSFORM hTransform = nullptr; switch (dstCS) { case cmsSigGrayData: hTransform = cmsCreateTransform(srcProfile, srcFormat, dstProfile, @@ -158,9 +158,9 @@ void* IccLib_CreateTransform(const unsigned char* pSrcProfileData, if (!hTransform) { cmsCloseProfile(srcProfile); cmsCloseProfile(dstProfile); - return NULL; + return nullptr; } - pCmm = new CLcmsCmm; + CLcmsCmm* pCmm = new CLcmsCmm; pCmm->m_nSrcComponents = nSrcComponents; pCmm->m_nDstComponents = nDstComponents; pCmm->m_hTransform = hTransform; @@ -174,8 +174,8 @@ void* IccLib_CreateTransform_sRGB(const unsigned char* pProfileData, uint32_t& nComponents, int32_t intent, uint32_t dwSrcFormat) { - return IccLib_CreateTransform(pProfileData, dwProfileSize, nComponents, NULL, - 0, 3, intent, dwSrcFormat); + return IccLib_CreateTransform(pProfileData, dwProfileSize, nComponents, + nullptr, 0, 3, intent, dwSrcFormat); } void IccLib_DestroyTransform(void* pTransform) { if (!pTransform) { @@ -241,11 +241,11 @@ void IccLib_TranslateImage(void* pTransform, void* CreateProfile_Gray(double gamma) { cmsCIExyY* D50 = (cmsCIExyY*)cmsD50_xyY(); if (!cmsWhitePointFromTemp(D50, 6504)) { - return NULL; + return nullptr; } - cmsToneCurve* curve = cmsBuildGamma(NULL, gamma); + cmsToneCurve* curve = cmsBuildGamma(nullptr, gamma); if (!curve) { - return NULL; + return nullptr; } void* profile = cmsCreateGrayProfile(D50, curve); cmsFreeToneCurve(curve); @@ -365,7 +365,7 @@ class CFX_IccProfileCache { void Purge(); }; CFX_IccProfileCache::CFX_IccProfileCache() { - m_pProfile = NULL; + m_pProfile = nullptr; m_dwRate = 1; } CFX_IccProfileCache::~CFX_IccProfileCache() { @@ -376,7 +376,7 @@ CFX_IccProfileCache::~CFX_IccProfileCache() { void CFX_IccProfileCache::Purge() {} class CFX_IccTransformCache { public: - CFX_IccTransformCache(CLcmsCmm* pCmm = NULL); + CFX_IccTransformCache(CLcmsCmm* pCmm = nullptr); ~CFX_IccTransformCache(); void* m_pIccTransform; uint32_t m_dwRate; @@ -386,7 +386,7 @@ class CFX_IccTransformCache { void Purge(); }; CFX_IccTransformCache::CFX_IccTransformCache(CLcmsCmm* pCmm) { - m_pIccTransform = NULL; + m_pIccTransform = nullptr; m_dwRate = 1; m_pCmm = pCmm; } @@ -409,14 +409,14 @@ CFX_ByteStringKey& CFX_ByteStringKey::operator<<(uint32_t i) { void* CCodec_IccModule::CreateProfile(CCodec_IccModule::IccParam* pIccParam, Icc_CLASS ic, CFX_BinaryBuf* pTransformKey) { - CFX_IccProfileCache* pCache = NULL; + CFX_IccProfileCache* pCache = nullptr; CFX_ByteStringKey key; CFX_ByteString text; key << pIccParam->ColorSpace << (pIccParam->dwProfileType | ic << 8); uint8_t ID[16]; switch (pIccParam->dwProfileType) { case Icc_PARAMTYPE_NONE: - return NULL; + return nullptr; case Icc_PARAMTYPE_BUFFER: MD5ComputeID(pIccParam->pProfileData, pIccParam->dwProfileSize, ID); break; @@ -476,30 +476,30 @@ void* CCodec_IccModule::CreateTransform( uint32_t dwFlag, uint32_t dwPrfIntent, uint32_t dwPrfFlag) { - CLcmsCmm* pCmm = NULL; + CLcmsCmm* pCmm = nullptr; ASSERT(pInputParam && pOutputParam); CFX_ByteStringKey key; void* pInputProfile = CreateProfile(pInputParam, Icc_CLASS_INPUT, &key); if (!pInputProfile) { - return NULL; + return nullptr; } void* pOutputProfile = CreateProfile(pOutputParam, Icc_CLASS_OUTPUT, &key); if (!pOutputProfile) { - return NULL; + return nullptr; } uint32_t dwInputProfileType = TransferProfileType(pInputProfile, pInputParam->dwFormat); uint32_t dwOutputProfileType = TransferProfileType(pOutputProfile, pOutputParam->dwFormat); if (dwInputProfileType == 0 || dwOutputProfileType == 0) { - return NULL; + return nullptr; } - void* pProofProfile = NULL; + void* pProofProfile = nullptr; if (pProofParam) { pProofProfile = CreateProfile(pProofParam, Icc_CLASS_PROOF, &key); } key << dwInputProfileType << dwOutputProfileType << dwIntent << dwFlag - << (pProofProfile != NULL) << dwPrfIntent << dwPrfFlag; + << !!pProofProfile << dwPrfIntent << dwPrfFlag; CFX_ByteString TransformKey(key.GetBuffer(), key.GetSize()); CFX_IccTransformCache* pTransformCache; auto it = m_MapTranform.find(TransformKey); diff --git a/core/fxcodec/codec/fx_codec_jbig.cpp b/core/fxcodec/codec/fx_codec_jbig.cpp index 2b0be1070e..30798fe361 100644 --- a/core/fxcodec/codec/fx_codec_jbig.cpp +++ b/core/fxcodec/codec/fx_codec_jbig.cpp @@ -68,7 +68,7 @@ void CCodec_Jbig2Module::DestroyJbig2Context(void* pJbig2Content) { ((CCodec_Jbig2Context*)pJbig2Content)->m_pContext); delete (CCodec_Jbig2Context*)pJbig2Content; } - pJbig2Content = NULL; + pJbig2Content = nullptr; } FXCODEC_STATUS CCodec_Jbig2Module::StartDecode( void* pJbig2Context, @@ -105,7 +105,7 @@ FXCODEC_STATUS CCodec_Jbig2Module::StartDecode( if (m_pJbig2Context->m_pContext->GetProcessingStatus() == FXCODEC_STATUS_DECODE_FINISH) { CJBig2_Context::DestroyContext(m_pJbig2Context->m_pContext); - m_pJbig2Context->m_pContext = NULL; + m_pJbig2Context->m_pContext = nullptr; if (ret != JBIG2_SUCCESS) { return FXCODEC_STATUS_ERROR; } @@ -127,7 +127,7 @@ FXCODEC_STATUS CCodec_Jbig2Module::ContinueDecode(void* pJbig2Context, return m_pJbig2Context->m_pContext->GetProcessingStatus(); } CJBig2_Context::DestroyContext(m_pJbig2Context->m_pContext); - m_pJbig2Context->m_pContext = NULL; + m_pJbig2Context->m_pContext = nullptr; if (ret != JBIG2_SUCCESS) { return FXCODEC_STATUS_ERROR; } diff --git a/core/fxcodec/codec/fx_codec_jpeg.cpp b/core/fxcodec/codec/fx_codec_jpeg.cpp index cbfea59329..c2814a4b4c 100644 --- a/core/fxcodec/codec/fx_codec_jpeg.cpp +++ b/core/fxcodec/codec/fx_codec_jpeg.cpp @@ -78,11 +78,10 @@ static void _error_do_nothing2(j_common_ptr cinfo, char*) {} #define JPEG_MARKER_ICC (JPEG_APP0 + 2) #define JPEG_MARKER_MAXSIZE 0xFFFF - #ifdef PDF_ENABLE_XFA static void JpegLoadAttribute(struct jpeg_decompress_struct* pInfo, CFX_DIBAttribute* pAttribute) { - if (!pInfo || !pAttribute) + if (!pAttribute) return; pAttribute->m_nXDPI = pInfo->X_density; @@ -178,7 +177,7 @@ class CCodec_JpegDecoder : public CCodec_ScanlineDecoder { }; CCodec_JpegDecoder::CCodec_JpegDecoder() { - m_pScanlineBuf = NULL; + m_pScanlineBuf = nullptr; m_bStarted = FALSE; m_bInited = FALSE; FXSYS_memset(&cinfo, 0, sizeof(cinfo)); @@ -470,7 +469,7 @@ FX_BOOL CCodec_JpegModule::ReadScanline(FXJPEG_Context* ctx, uint32_t CCodec_JpegModule::GetAvailInput(FXJPEG_Context* ctx, uint8_t** avail_buf_ptr) { if (avail_buf_ptr) { - *avail_buf_ptr = NULL; + *avail_buf_ptr = nullptr; if (ctx->m_SrcMgr.bytes_in_buffer > 0) { *avail_buf_ptr = (uint8_t*)ctx->m_SrcMgr.next_input_byte; } diff --git a/core/fxcodec/codec/fx_codec_jpx_opj.cpp b/core/fxcodec/codec/fx_codec_jpx_opj.cpp index a0f2e65c75..9e72c509d7 100644 --- a/core/fxcodec/codec/fx_codec_jpx_opj.cpp +++ b/core/fxcodec/codec/fx_codec_jpx_opj.cpp @@ -122,13 +122,13 @@ opj_stream_t* fx_opj_stream_create_memory_stream(DecodeData* data, OPJ_BOOL p_is_read_stream) { opj_stream_t* l_stream = 00; if (!data || !data->src_data || data->src_size <= 0) { - return NULL; + return nullptr; } l_stream = opj_stream_create(p_size, p_is_read_stream); if (!l_stream) { - return NULL; + return nullptr; } - opj_stream_set_user_data(l_stream, data, NULL); + opj_stream_set_user_data(l_stream, data, nullptr); opj_stream_set_user_data_length(l_stream, data->src_size); opj_stream_set_read_function(l_stream, opj_read_from_memory); opj_stream_set_write_function(l_stream, opj_write_from_memory); @@ -611,7 +611,7 @@ void color_apply_conversion(opj_image_t* image) { cmsHTRANSFORM transform; cmsUInt16Number RGB[3]; cmsCIELab Lab; - in = cmsCreateLab4Profile(NULL); + in = cmsCreateLab4Profile(nullptr); out = cmsCreate_sRGBProfile(); transform = cmsCreateTransform(in, TYPE_Lab_DBL, out, TYPE_RGB_16, INTENT_PERCEPTUAL, 0); @@ -718,7 +718,7 @@ FX_BOOL CJPX_Decoder::Init(const unsigned char* src_data, uint32_t src_size) { if (!src_data || src_size < sizeof(szJP2Header)) return FALSE; - image = NULL; + image = nullptr; m_SrcData = src_data; m_SrcSize = src_size; DecodeData srcData(const_cast(src_data), src_size); @@ -749,7 +749,7 @@ FX_BOOL CJPX_Decoder::Init(const unsigned char* src_data, uint32_t src_size) { return FALSE; } if (!opj_read_header(l_stream, l_codec, &image)) { - image = NULL; + image = nullptr; return FALSE; } image->pdfium_use_colorspace = !!m_ColorSpace; @@ -758,13 +758,13 @@ FX_BOOL CJPX_Decoder::Init(const unsigned char* src_data, uint32_t src_size) { if (!opj_set_decode_area(l_codec, image, parameters.DA_x0, parameters.DA_y0, parameters.DA_x1, parameters.DA_y1)) { opj_image_destroy(image); - image = NULL; + image = nullptr; return FALSE; } if (!(opj_decode(l_codec, l_stream, image) && opj_end_decompress(l_codec, l_stream))) { opj_image_destroy(image); - image = NULL; + image = nullptr; return FALSE; } } else { @@ -774,7 +774,7 @@ FX_BOOL CJPX_Decoder::Init(const unsigned char* src_data, uint32_t src_size) { } } opj_stream_destroy(l_stream); - l_stream = NULL; + l_stream = nullptr; if (image->color_space != OPJ_CLRSPC_SYCC && image->numcomps == 3 && image->comps[0].dx == image->comps[0].dy && image->comps[1].dx != 1) { image->color_space = OPJ_CLRSPC_SYCC; @@ -786,7 +786,7 @@ FX_BOOL CJPX_Decoder::Init(const unsigned char* src_data, uint32_t src_size) { } if (image->icc_profile_buf) { FX_Free(image->icc_profile_buf); - image->icc_profile_buf = NULL; + image->icc_profile_buf = nullptr; image->icc_profile_len = 0; } if (!image) { diff --git a/core/fxcodec/codec/fx_codec_png.cpp b/core/fxcodec/codec/fx_codec_png.cpp index f7b922973e..9f7faa68e0 100644 --- a/core/fxcodec/codec/fx_codec_png.cpp +++ b/core/fxcodec/codec/fx_codec_png.cpp @@ -51,7 +51,7 @@ static void _png_load_bmp_attribute(png_structp png_ptr, #endif int bTime = 0; #if defined(PNG_tIME_SUPPORTED) - png_timep t = NULL; + png_timep t = nullptr; png_get_tIME(png_ptr, info_ptr, &t); if (t) { FXSYS_memset(pAttribute->m_strTime, 0, sizeof(pAttribute->m_strTime)); @@ -67,7 +67,7 @@ static void _png_load_bmp_attribute(png_structp png_ptr, FX_STRSIZE len; const FX_CHAR* buf; int num_text; - png_textp text = NULL; + png_textp text = nullptr; png_get_text(png_ptr, info_ptr, &text, &num_text); for (i = 0; i < num_text; i++) { len = FXSYS_strlen(text[i].key); @@ -110,18 +110,18 @@ static void _png_free_func(void* p) { }; static void _png_get_header_func(png_structp png_ptr, png_infop info_ptr) { FXPNG_Context* p = (FXPNG_Context*)png_get_progressive_ptr(png_ptr); - if (p == NULL) { + if (!p) return; - } + CCodec_PngModule* pModule = (CCodec_PngModule*)p->parent_ptr; - if (pModule == NULL) { + if (!pModule) return; - } + png_uint_32 width = 0, height = 0; int bpc = 0, color_type = 0, color_type1 = 0, pass = 0; double gamma = 1.0; - png_get_IHDR(png_ptr, info_ptr, &width, &height, &bpc, &color_type, NULL, - NULL, NULL); + png_get_IHDR(png_ptr, info_ptr, &width, &height, &bpc, &color_type, nullptr, + nullptr, nullptr); color_type1 = color_type; if (bpc > 8) { png_set_strip_16(png_ptr); @@ -182,11 +182,11 @@ static void _png_get_row_func(png_structp png_ptr, png_uint_32 row_num, int pass) { FXPNG_Context* p = (FXPNG_Context*)png_get_progressive_ptr(png_ptr); - if (p == NULL) { + if (!p) return; - } + CCodec_PngModule* pModule = (CCodec_PngModule*)p->parent_ptr; - uint8_t* src_buf = NULL; + uint8_t* src_buf = nullptr; if (!pModule->AskScanlineBufCallback(p->child_ptr, row_num, src_buf)) { png_error(png_ptr, "Ask Scanline buffer Callback Error"); } diff --git a/core/fxcodec/codec/fx_codec_progress.cpp b/core/fxcodec/codec/fx_codec_progress.cpp index 95a90b3e68..ec3347cdaa 100644 --- a/core/fxcodec/codec/fx_codec_progress.cpp +++ b/core/fxcodec/codec/fx_codec_progress.cpp @@ -39,9 +39,6 @@ void CCodec_ProgressiveDecoder::CFXCODEC_WeightTable::Calc(int dest_len, sizeof(int) * (FXSYS_ceil(FXSYS_fabs((FX_FLOAT)scale)) + 1)); m_DestMin = dest_min; m_pWeightTables = FX_Alloc(uint8_t, (dest_max - dest_min) * m_ItemSize + 4); - if (m_pWeightTables == NULL) { - return; - } if (FXSYS_fabs((FX_FLOAT)scale) < 1.0f) { for (int dest_pixel = dest_min; dest_pixel < dest_max; dest_pixel++) { PixelWeight& pixel_weights = *GetPixelWeight(dest_pixel); @@ -131,9 +128,6 @@ void CCodec_ProgressiveDecoder::CFXCODEC_HorzTable::Calc(int dest_len, m_ItemSize = sizeof(int) * 4; int size = dest_len * m_ItemSize + 4; m_pWeightTables = FX_Alloc(uint8_t, size); - if (m_pWeightTables == NULL) { - return; - } FXSYS_memset(m_pWeightTables, 0, size); if (scale > 1) { int pre_des_col = 0; @@ -192,9 +186,6 @@ void CCodec_ProgressiveDecoder::CFXCODEC_VertTable::Calc(int dest_len, m_ItemSize = sizeof(int) * 4; int size = dest_len * m_ItemSize + 4; m_pWeightTables = FX_Alloc(uint8_t, size); - if (m_pWeightTables == NULL) { - return; - } FXSYS_memset(m_pWeightTables, 0, size); if (scale > 1) { double step = 0.0; @@ -247,17 +238,17 @@ void CCodec_ProgressiveDecoder::CFXCODEC_VertTable::Calc(int dest_len, } CCodec_ProgressiveDecoder::CCodec_ProgressiveDecoder( CCodec_ModuleMgr* pCodecMgr) { - m_pFile = NULL; - m_pJpegContext = NULL; - m_pPngContext = NULL; - m_pGifContext = NULL; - m_pBmpContext = NULL; - m_pTiffContext = NULL; - m_pCodecMgr = NULL; - m_pSrcBuf = NULL; - m_pDecodeBuf = NULL; - m_pDeviceBitmap = NULL; - m_pSrcPalette = NULL; + m_pFile = nullptr; + m_pJpegContext = nullptr; + m_pPngContext = nullptr; + m_pGifContext = nullptr; + m_pBmpContext = nullptr; + m_pTiffContext = nullptr; + m_pCodecMgr = nullptr; + m_pSrcBuf = nullptr; + m_pDecodeBuf = nullptr; + m_pDeviceBitmap = nullptr; + m_pSrcPalette = nullptr; m_pCodecMgr = pCodecMgr; m_offSet = 0; m_SrcSize = 0; @@ -278,13 +269,13 @@ CCodec_ProgressiveDecoder::CCodec_ProgressiveDecoder( m_SrcPaletteNumber = 0; m_GifPltNumber = 0; m_GifBgIndex = 0; - m_pGifPalette = NULL; + m_pGifPalette = nullptr; m_GifTransIndex = -1; m_GifFrameRect = FX_RECT(0, 0, 0, 0); m_BmpIsTopBottom = FALSE; } CCodec_ProgressiveDecoder::~CCodec_ProgressiveDecoder() { - m_pFile = NULL; + m_pFile = nullptr; if (m_pJpegContext) { m_pCodecMgr->GetJpegModule()->Finish(m_pJpegContext); } @@ -312,7 +303,7 @@ FX_BOOL CCodec_ProgressiveDecoder::JpegReadMoreData( return FALSE; } dwSize = dwSize - m_offSet; - uint32_t dwAvail = pJpegModule->GetAvailInput(m_pJpegContext, NULL); + uint32_t dwAvail = pJpegModule->GetAvailInput(m_pJpegContext, nullptr); if (dwAvail == m_SrcSize) { if (dwSize > FXCODEC_BLOCK_SIZE) { dwSize = FXCODEC_BLOCK_SIZE; @@ -349,7 +340,7 @@ FX_BOOL CCodec_ProgressiveDecoder::PngReadHeaderFunc(void* pModule, int* color_type, double* gamma) { CCodec_ProgressiveDecoder* pCodec = (CCodec_ProgressiveDecoder*)pModule; - if (pCodec->m_pDeviceBitmap == NULL) { + if (!pCodec->m_pDeviceBitmap) { pCodec->m_SrcWidth = width; pCodec->m_SrcHeight = height; pCodec->m_SrcBPC = bpc; @@ -570,7 +561,7 @@ FX_BOOL CCodec_ProgressiveDecoder::GifReadMoreData(CCodec_GifModule* pGifModule, return FALSE; } dwSize = dwSize - m_offSet; - uint32_t dwAvail = pGifModule->GetAvailInput(m_pGifContext, NULL); + uint32_t dwAvail = pGifModule->GetAvailInput(m_pGifContext, nullptr); if (dwAvail == m_SrcSize) { if (dwSize > FXCODEC_BLOCK_SIZE) { dwSize = FXCODEC_BLOCK_SIZE; @@ -631,21 +622,21 @@ FX_BOOL CCodec_ProgressiveDecoder::GifInputRecordPositionBufCallback( error_status)) { return FALSE; } - uint8_t* pPalette = NULL; + uint8_t* pPalette = nullptr; if (pal_num != 0 && pal_ptr) { pPalette = (uint8_t*)pal_ptr; } else { pal_num = pCodec->m_GifPltNumber; pPalette = pCodec->m_pGifPalette; } - if (pCodec->m_pSrcPalette == NULL) { + if (!pCodec->m_pSrcPalette) { pCodec->m_pSrcPalette = FX_Alloc(FX_ARGB, pal_num); } else if (pal_num > pCodec->m_SrcPaletteNumber) { pCodec->m_pSrcPalette = FX_Realloc(FX_ARGB, pCodec->m_pSrcPalette, pal_num); } - if (pCodec->m_pSrcPalette == NULL) { + if (!pCodec->m_pSrcPalette) return FALSE; - } + pCodec->m_SrcPaletteNumber = pal_num; for (int i = 0; i < pal_num; i++) { uint32_t j = i * 3; @@ -852,7 +843,7 @@ FX_BOOL CCodec_ProgressiveDecoder::BmpReadMoreData(CCodec_BmpModule* pBmpModule, return FALSE; } dwSize = dwSize - m_offSet; - uint32_t dwAvail = pBmpModule->GetAvailInput(m_pBmpContext, NULL); + uint32_t dwAvail = pBmpModule->GetAvailInput(m_pBmpContext, nullptr); if (dwAvail == m_SrcSize) { if (dwSize > FXCODEC_BLOCK_SIZE) { dwSize = FXCODEC_BLOCK_SIZE; @@ -1020,7 +1011,7 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType( switch (imageType) { case FXCODEC_IMAGE_BMP: { CCodec_BmpModule* pBmpModule = m_pCodecMgr->GetBmpModule(); - if (pBmpModule == NULL) { + if (!pBmpModule) { m_status = FXCODEC_STATUS_ERR_MEMORY; return FALSE; } @@ -1028,7 +1019,7 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType( BmpInputImagePositionBufCallback; pBmpModule->ReadScanlineCallback = BmpReadScanlineCallback; m_pBmpContext = pBmpModule->Start((void*)this); - if (m_pBmpContext == NULL) { + if (!m_pBmpContext) { m_status = FXCODEC_STATUS_ERR_MEMORY; return FALSE; } @@ -1039,7 +1030,7 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType( } m_offSet += size; pBmpModule->Input(m_pBmpContext, m_pSrcBuf, size); - uint32_t* pPalette = NULL; + uint32_t* pPalette = nullptr; int32_t readResult = pBmpModule->ReadHeader( m_pBmpContext, &m_SrcWidth, &m_SrcHeight, &m_BmpIsTopBottom, &m_SrcComponents, &m_SrcPaletteNumber, &pPalette, pAttribute); @@ -1068,19 +1059,19 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType( } if (m_pBmpContext) { pBmpModule->Finish(m_pBmpContext); - m_pBmpContext = NULL; + m_pBmpContext = nullptr; } m_status = FXCODEC_STATUS_ERR_FORMAT; return FALSE; } break; case FXCODEC_IMAGE_JPG: { CCodec_JpegModule* pJpegModule = m_pCodecMgr->GetJpegModule(); - if (pJpegModule == NULL) { + if (!pJpegModule) { m_status = FXCODEC_STATUS_ERR_MEMORY; return FALSE; } m_pJpegContext = pJpegModule->Start(); - if (m_pJpegContext == NULL) { + if (!m_pJpegContext) { m_status = FXCODEC_STATUS_ERR_MEMORY; return FALSE; } @@ -1111,14 +1102,14 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType( } if (m_pJpegContext) { pJpegModule->Finish(m_pJpegContext); - m_pJpegContext = NULL; + m_pJpegContext = nullptr; } m_status = FXCODEC_STATUS_ERR_FORMAT; return FALSE; } break; case FXCODEC_IMAGE_PNG: { CCodec_PngModule* pPngModule = m_pCodecMgr->GetPngModule(); - if (pPngModule == NULL) { + if (!pPngModule) { m_status = FXCODEC_STATUS_ERR_MEMORY; return FALSE; } @@ -1129,7 +1120,7 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType( pPngModule->FillScanlineBufCompletedCallback = CCodec_ProgressiveDecoder::PngFillScanlineBufCompletedFunc; m_pPngContext = pPngModule->Start((void*)this); - if (m_pPngContext == NULL) { + if (!m_pPngContext) { m_status = FXCODEC_STATUS_ERR_MEMORY; return FALSE; } @@ -1148,7 +1139,7 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType( if (m_pPngContext) { pPngModule->Finish(m_pPngContext); } - m_pPngContext = NULL; + m_pPngContext = nullptr; m_status = FXCODEC_STATUS_ERR_FORMAT; return FALSE; } @@ -1170,7 +1161,7 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType( ASSERT(!bResult); if (m_pPngContext) { pPngModule->Finish(m_pPngContext); - m_pPngContext = NULL; + m_pPngContext = nullptr; } if (m_SrcPassNumber == 0) { m_status = FXCODEC_STATUS_ERR_FORMAT; @@ -1179,7 +1170,7 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType( } break; case FXCODEC_IMAGE_GIF: { CCodec_GifModule* pGifModule = m_pCodecMgr->GetGifModule(); - if (pGifModule == NULL) { + if (!pGifModule) { m_status = FXCODEC_STATUS_ERR_MEMORY; return FALSE; } @@ -1192,7 +1183,7 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType( pGifModule->ReadScanlineCallback = CCodec_ProgressiveDecoder::GifReadScanlineCallback; m_pGifContext = pGifModule->Start((void*)this); - if (m_pGifContext == NULL) { + if (!m_pGifContext) { m_status = FXCODEC_STATUS_ERR_MEMORY; return FALSE; } @@ -1224,19 +1215,19 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType( } if (m_pGifContext) { pGifModule->Finish(m_pGifContext); - m_pGifContext = NULL; + m_pGifContext = nullptr; } m_status = FXCODEC_STATUS_ERR_FORMAT; return FALSE; } break; case FXCODEC_IMAGE_TIF: { CCodec_TiffModule* pTiffModule = m_pCodecMgr->GetTiffModule(); - if (pTiffModule == NULL) { + if (!pTiffModule) { m_status = FXCODEC_STATUS_ERR_FORMAT; return FALSE; } m_pTiffContext = pTiffModule->CreateDecoder(m_pFile); - if (m_pTiffContext == NULL) { + if (!m_pTiffContext) { m_status = FXCODEC_STATUS_ERR_FORMAT; return FALSE; } @@ -1250,7 +1241,7 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType( m_clipBox = FX_RECT(0, 0, m_SrcWidth, m_SrcHeight); if (!ret) { pTiffModule->DestroyDecoder(m_pTiffContext); - (m_pTiffContext = NULL); + (m_pTiffContext = nullptr); (m_status = FXCODEC_STATUS_ERR_FORMAT); return FALSE; } @@ -1274,9 +1265,9 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::LoadImageInfo( default: break; } - if (pFile == NULL) { + if (!pFile) { m_status = FXCODEC_STATUS_ERR_PARAMS; - m_pFile = NULL; + m_pFile = nullptr; return m_status; } m_pFile = pFile; @@ -1301,7 +1292,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::LoadImageInfo( } } m_status = FXCODEC_STATUS_ERR_FORMAT; - m_pFile = NULL; + m_pFile = nullptr; return m_status; } void CCodec_ProgressiveDecoder::SetClipBox(FX_RECT* clip) { @@ -1830,7 +1821,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::GetFrames(int32_t& frames, } if (m_pGifContext) { pGifModule->Finish(m_pGifContext); - m_pGifContext = NULL; + m_pGifContext = nullptr; } return m_status = FXCODEC_STATUS_ERROR; } @@ -1847,10 +1838,10 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::StartDecode(CFX_DIBitmap* pDIBitmap, int size_y, int32_t frames, FX_BOOL bInterpol) { - if (m_status != FXCODEC_STATUS_DECODE_READY) { + if (m_status != FXCODEC_STATUS_DECODE_READY) return FXCODEC_STATUS_ERROR; - } - if (pDIBitmap == NULL || pDIBitmap->GetBPP() < 8 || frames < 0 || + + if (!pDIBitmap || pDIBitmap->GetBPP() < 8 || frames < 0 || frames >= m_FrameNumber) { return FXCODEC_STATUS_ERR_PARAMS; } @@ -1906,8 +1897,8 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::StartDecode(CFX_DIBitmap* pDIBitmap, while (!bStart) { FXCODEC_STATUS error_status = FXCODEC_STATUS_ERROR; if (!JpegReadMoreData(pJpegModule, error_status)) { - m_pDeviceBitmap = NULL; - m_pFile = NULL; + m_pDeviceBitmap = nullptr; + m_pFile = nullptr; return m_status = error_status; } bStart = pJpegModule->StartScanline(m_pJpegContext, down_scale); @@ -1936,19 +1927,19 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::StartDecode(CFX_DIBitmap* pDIBitmap, } break; case FXCODEC_IMAGE_PNG: { CCodec_PngModule* pPngModule = m_pCodecMgr->GetPngModule(); - if (pPngModule == NULL) { - m_pDeviceBitmap = NULL; - m_pFile = NULL; + if (!pPngModule) { + m_pDeviceBitmap = nullptr; + m_pFile = nullptr; return m_status = FXCODEC_STATUS_ERR_MEMORY; } if (m_pPngContext) { pPngModule->Finish(m_pPngContext); - m_pPngContext = NULL; + m_pPngContext = nullptr; } m_pPngContext = pPngModule->Start((void*)this); - if (m_pPngContext == NULL) { - m_pDeviceBitmap = NULL; - m_pFile = NULL; + if (!m_pPngContext) { + m_pDeviceBitmap = nullptr; + m_pFile = nullptr; return m_status = FXCODEC_STATUS_ERR_MEMORY; } m_offSet = 0; @@ -1968,8 +1959,8 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::StartDecode(CFX_DIBitmap* pDIBitmap, m_SrcFormat = FXCodec_Argb; break; default: { - m_pDeviceBitmap = NULL; - m_pFile = NULL; + m_pDeviceBitmap = nullptr; + m_pFile = nullptr; return m_status = FXCODEC_STATUS_ERR_PARAMS; } } @@ -1984,9 +1975,9 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::StartDecode(CFX_DIBitmap* pDIBitmap, } break; case FXCODEC_IMAGE_GIF: { CCodec_GifModule* pGifModule = m_pCodecMgr->GetGifModule(); - if (pGifModule == NULL) { - m_pDeviceBitmap = NULL; - m_pFile = NULL; + if (!pGifModule) { + m_pDeviceBitmap = nullptr; + m_pFile = nullptr; return m_status = FXCODEC_STATUS_ERR_MEMORY; } m_SrcFormat = FXCodec_8bppRgb; @@ -2003,9 +1994,9 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::StartDecode(CFX_DIBitmap* pDIBitmap, } break; case FXCODEC_IMAGE_BMP: { CCodec_BmpModule* pBmpModule = m_pCodecMgr->GetBmpModule(); - if (pBmpModule == NULL) { - m_pDeviceBitmap = NULL; - m_pFile = NULL; + if (!pBmpModule) { + m_pDeviceBitmap = nullptr; + m_pFile = nullptr; return m_status = FXCODEC_STATUS_ERR_MEMORY; } switch (m_SrcComponents) { @@ -2049,8 +2040,8 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) { while (!readRes) { FXCODEC_STATUS error_status = FXCODEC_STATUS_DECODE_FINISH; if (!JpegReadMoreData(pJpegModule, error_status)) { - m_pDeviceBitmap = NULL; - m_pFile = NULL; + m_pDeviceBitmap = nullptr; + m_pFile = nullptr; return m_status = error_status; } readRes = pJpegModule->ReadScanline(m_pJpegContext, m_pDecodeBuf); @@ -2060,8 +2051,8 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) { _RGB2BGR(m_pDecodeBuf + m_clipBox.left * src_Bpp, m_clipBox.Width()); } if (m_SrcRow >= m_clipBox.bottom) { - m_pDeviceBitmap = NULL; - m_pFile = NULL; + m_pDeviceBitmap = nullptr; + m_pFile = nullptr; return m_status = FXCODEC_STATUS_DECODE_FINISH; } Resample(m_pDeviceBitmap, m_SrcRow, m_pDecodeBuf, m_SrcFormat); @@ -2081,9 +2072,9 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) { if (m_pPngContext) { pPngModule->Finish(m_pPngContext); } - m_pPngContext = NULL; - m_pDeviceBitmap = NULL; - m_pFile = NULL; + m_pPngContext = nullptr; + m_pDeviceBitmap = nullptr; + m_pFile = nullptr; return m_status = FXCODEC_STATUS_DECODE_FINISH; } if (m_pSrcBuf && input_size > m_SrcSize) { @@ -2094,16 +2085,16 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) { } FX_BOOL bResult = m_pFile->ReadBlock(m_pSrcBuf, m_offSet, input_size); if (!bResult) { - m_pDeviceBitmap = NULL; - m_pFile = NULL; + m_pDeviceBitmap = nullptr; + m_pFile = nullptr; return m_status = FXCODEC_STATUS_ERR_READ; } m_offSet += input_size; bResult = pPngModule->Input(m_pPngContext, m_pSrcBuf, input_size, nullptr); if (!bResult) { - m_pDeviceBitmap = NULL; - m_pFile = NULL; + m_pDeviceBitmap = nullptr; + m_pFile = nullptr; return m_status = FXCODEC_STATUS_ERROR; } if (pPause && pPause->NeedToPauseNow()) { @@ -2119,8 +2110,8 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) { while (readRes == 2) { FXCODEC_STATUS error_status = FXCODEC_STATUS_DECODE_FINISH; if (!GifReadMoreData(pGifModule, error_status)) { - m_pDeviceBitmap = NULL; - m_pFile = NULL; + m_pDeviceBitmap = nullptr; + m_pFile = nullptr; return m_status = error_status; } if (pPause && pPause->NeedToPauseNow()) { @@ -2129,12 +2120,12 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) { readRes = pGifModule->LoadFrame(m_pGifContext, m_FrameCur, nullptr); } if (readRes == 1) { - m_pDeviceBitmap = NULL; - m_pFile = NULL; + m_pDeviceBitmap = nullptr; + m_pFile = nullptr; return m_status = FXCODEC_STATUS_DECODE_FINISH; } - m_pDeviceBitmap = NULL; - m_pFile = NULL; + m_pDeviceBitmap = nullptr; + m_pFile = nullptr; return m_status = FXCODEC_STATUS_ERROR; } } break; @@ -2145,8 +2136,8 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) { while (readRes == 2) { FXCODEC_STATUS error_status = FXCODEC_STATUS_DECODE_FINISH; if (!BmpReadMoreData(pBmpModule, error_status)) { - m_pDeviceBitmap = NULL; - m_pFile = NULL; + m_pDeviceBitmap = nullptr; + m_pFile = nullptr; return m_status = error_status; } if (pPause && pPause->NeedToPauseNow()) { @@ -2155,12 +2146,12 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) { readRes = pBmpModule->LoadImage(m_pBmpContext); } if (readRes == 1) { - m_pDeviceBitmap = NULL; - m_pFile = NULL; + m_pDeviceBitmap = nullptr; + m_pFile = nullptr; return m_status = FXCODEC_STATUS_DECODE_FINISH; } - m_pDeviceBitmap = NULL; - m_pFile = NULL; + m_pDeviceBitmap = nullptr; + m_pFile = nullptr; return m_status = FXCODEC_STATUS_ERROR; } } break; @@ -2174,8 +2165,8 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) { m_clipBox.left == 0 && m_clipBox.top == 0 && m_clipBox.right == m_SrcWidth && m_clipBox.bottom == m_SrcHeight) { ret = pTiffModule->Decode(m_pTiffContext, m_pDeviceBitmap); - m_pDeviceBitmap = NULL; - m_pFile = NULL; + m_pDeviceBitmap = nullptr; + m_pFile = nullptr; if (!ret) { return m_status = FXCODEC_STATUS_ERROR; } @@ -2183,17 +2174,17 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) { } else { CFX_DIBitmap* pDIBitmap = new CFX_DIBitmap; pDIBitmap->Create(m_SrcWidth, m_SrcHeight, FXDIB_Argb); - if (pDIBitmap->GetBuffer() == NULL) { + if (!pDIBitmap->GetBuffer()) { delete pDIBitmap; - m_pDeviceBitmap = NULL; - m_pFile = NULL; + m_pDeviceBitmap = nullptr; + m_pFile = nullptr; return m_status = FXCODEC_STATUS_ERR_MEMORY; } ret = pTiffModule->Decode(m_pTiffContext, pDIBitmap); if (!ret) { delete pDIBitmap; - m_pDeviceBitmap = NULL; - m_pFile = NULL; + m_pDeviceBitmap = nullptr; + m_pFile = nullptr; return m_status = FXCODEC_STATUS_ERROR; } CFX_DIBitmap* pClipBitmap = @@ -2204,12 +2195,12 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) { if (pDIBitmap != pClipBitmap) { delete pDIBitmap; } - if (pClipBitmap == NULL) { - m_pDeviceBitmap = NULL; - m_pFile = NULL; + if (!pClipBitmap) { + m_pDeviceBitmap = nullptr; + m_pFile = nullptr; return m_status = FXCODEC_STATUS_ERR_MEMORY; } - CFX_DIBitmap* pFormatBitmap = NULL; + CFX_DIBitmap* pFormatBitmap = nullptr; switch (m_pDeviceBitmap->GetFormat()) { case FXDIB_8bppRgb: pFormatBitmap = new CFX_DIBitmap; @@ -2279,26 +2270,26 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) { if (pClipBitmap != pFormatBitmap) { delete pClipBitmap; } - if (pFormatBitmap == NULL) { - m_pDeviceBitmap = NULL; - m_pFile = NULL; + if (!pFormatBitmap) { + m_pDeviceBitmap = nullptr; + m_pFile = nullptr; return m_status = FXCODEC_STATUS_ERR_MEMORY; } CFX_DIBitmap* pStrechBitmap = pFormatBitmap->StretchTo( m_sizeX, m_sizeY, m_bInterpol ? FXDIB_INTERPOL : FXDIB_DOWNSAMPLE); delete pFormatBitmap; - pFormatBitmap = NULL; - if (pStrechBitmap == NULL) { - m_pDeviceBitmap = NULL; - m_pFile = NULL; + pFormatBitmap = nullptr; + if (!pStrechBitmap) { + m_pDeviceBitmap = nullptr; + m_pFile = nullptr; return m_status = FXCODEC_STATUS_ERR_MEMORY; } m_pDeviceBitmap->TransferBitmap(m_startX, m_startY, m_sizeX, m_sizeY, pStrechBitmap, 0, 0); delete pStrechBitmap; - pStrechBitmap = NULL; - m_pDeviceBitmap = NULL; - m_pFile = NULL; + pStrechBitmap = nullptr; + m_pDeviceBitmap = nullptr; + m_pFile = nullptr; return m_status = FXCODEC_STATUS_DECODE_FINISH; } } break; diff --git a/core/fxcodec/codec/fx_codec_tiff.cpp b/core/fxcodec/codec/fx_codec_tiff.cpp index d4dc139265..c8c94dbcdb 100644 --- a/core/fxcodec/codec/fx_codec_tiff.cpp +++ b/core/fxcodec/codec/fx_codec_tiff.cpp @@ -73,15 +73,15 @@ CCodec_TiffContext::CCodec_TiffContext() { offset = 0; frame_num = 0; frame_cur = 0; - io.in = NULL; - tif_ctx = NULL; - icc_ctx = NULL; + io.in = nullptr; + tif_ctx = nullptr; + icc_ctx = nullptr; isDecoder = TRUE; } CCodec_TiffContext::~CCodec_TiffContext() { if (icc_ctx) { IccLib_DestroyTransform(icc_ctx); - icc_ctx = NULL; + icc_ctx = nullptr; } if (tif_ctx) { TIFFClose(tif_ctx); @@ -193,9 +193,9 @@ int TIFFCmyk2Rgb(thandle_t context, uint8* r, uint8* g, uint8* b) { - if (context == NULL) { + if (!context) return 0; - } + CCodec_TiffContext* p = (CCodec_TiffContext*)context; if (p->icc_ctx) { unsigned char cmyk[4], bgr[3]; @@ -209,11 +209,7 @@ int TIFFCmyk2Rgb(thandle_t context, } FX_BOOL CCodec_TiffContext::InitDecoder(IFX_FileRead* file_ptr) { io.in = file_ptr; - tif_ctx = _tiff_open(this, "r"); - if (tif_ctx == NULL) { - return FALSE; - } - return TRUE; + return !!_tiff_open(this, "r"); } void CCodec_TiffContext::GetFrames(int32_t& frames) { frames = frame_num = TIFFNumberOfDirectories(tif_ctx); @@ -231,11 +227,11 @@ void CCodec_TiffContext::GetFrames(int32_t& frames) { } \ } \ } \ - (key) = NULL; + (key) = nullptr; #define TIFF_EXIF_GETSTRINGINFO(key, tag) \ { \ uint32_t size = 0; \ - uint8_t* buf = NULL; \ + uint8_t* buf = nullptr; \ TIFFGetField(tif_ctx, tag, &size, &buf); \ if (size && buf) { \ (key) = FX_Alloc(uint8_t, size); \ @@ -245,7 +241,7 @@ void CCodec_TiffContext::GetFrames(int32_t& frames) { } \ } \ } \ - (key) = NULL; + (key) = nullptr; namespace { @@ -287,7 +283,7 @@ FX_BOOL CCodec_TiffContext::LoadFrameInfo(int32_t frame, } uint16_t tif_cs; uint32_t tif_icc_size = 0; - uint8_t* tif_icc_buf = NULL; + uint8_t* tif_icc_buf = nullptr; uint16_t tif_bpc = 0; uint16_t tif_cps; uint32_t tif_rps; @@ -399,7 +395,7 @@ FX_BOOL CCodec_TiffContext::Decode1bppRGB(CFX_DIBitmap* pDIBitmap, SetPalette(pDIBitmap, bps); int32_t size = (int32_t)TIFFScanlineSize(tif_ctx); uint8_t* buf = (uint8_t*)_TIFFmalloc(size); - if (buf == NULL) { + if (!buf) { TIFFError(TIFFFileName(tif_ctx), "No space for scanline buffer"); return FALSE; } @@ -426,7 +422,7 @@ FX_BOOL CCodec_TiffContext::Decode8bppRGB(CFX_DIBitmap* pDIBitmap, SetPalette(pDIBitmap, bps); int32_t size = (int32_t)TIFFScanlineSize(tif_ctx); uint8_t* buf = (uint8_t*)_TIFFmalloc(size); - if (buf == NULL) { + if (!buf) { TIFFError(TIFFFileName(tif_ctx), "No space for scanline buffer"); return FALSE; } @@ -459,7 +455,7 @@ FX_BOOL CCodec_TiffContext::Decode24bppRGB(CFX_DIBitmap* pDIBitmap, } int32_t size = (int32_t)TIFFScanlineSize(tif_ctx); uint8_t* buf = (uint8_t*)_TIFFmalloc(size); - if (buf == NULL) { + if (!buf) { TIFFError(TIFFFileName(tif_ctx), "No space for scanline buffer"); return FALSE; } diff --git a/core/fxcodec/codec/include/ccodec_progressivedecoder.h b/core/fxcodec/codec/include/ccodec_progressivedecoder.h index 83b73e1ba7..5421d73494 100644 --- a/core/fxcodec/codec/include/ccodec_progressivedecoder.h +++ b/core/fxcodec/codec/include/ccodec_progressivedecoder.h @@ -73,7 +73,7 @@ class CCodec_ProgressiveDecoder { class CFXCODEC_WeightTable { public: - CFXCODEC_WeightTable() { m_pWeightTables = NULL; } + CFXCODEC_WeightTable() { m_pWeightTables = nullptr; } ~CFXCODEC_WeightTable() { FX_Free(m_pWeightTables); } void Calc(int dest_len, @@ -93,7 +93,7 @@ class CCodec_ProgressiveDecoder { class CFXCODEC_HorzTable { public: - CFXCODEC_HorzTable() { m_pWeightTables = NULL; } + CFXCODEC_HorzTable() { m_pWeightTables = nullptr; } ~CFXCODEC_HorzTable() { FX_Free(m_pWeightTables); } void Calc(int dest_len, int src_len, FX_BOOL bInterpol); @@ -107,7 +107,7 @@ class CCodec_ProgressiveDecoder { class CFXCODEC_VertTable { public: - CFXCODEC_VertTable() { m_pWeightTables = NULL; } + CFXCODEC_VertTable() { m_pWeightTables = nullptr; } ~CFXCODEC_VertTable() { FX_Free(m_pWeightTables); } void Calc(int dest_len, int src_len); PixelWeight* GetPixelWeight(int pixel) { diff --git a/core/fxcodec/jbig2/JBig2_Context.cpp b/core/fxcodec/jbig2/JBig2_Context.cpp index 25c9ff7649..8dde290be6 100644 --- a/core/fxcodec/jbig2/JBig2_Context.cpp +++ b/core/fxcodec/jbig2/JBig2_Context.cpp @@ -69,7 +69,7 @@ CJBig2_Context::CJBig2_Context(CPDF_StreamAcc* pGlobalStream, m_PauseStep(10), m_pPause(pPause), m_ProcessingStatus(FXCODEC_STATUS_FRAME_READY), - m_gbContext(NULL), + m_gbContext(nullptr), m_dwOffset(0), m_pSymbolDictCache(pSymbolDictCache), m_bIsGlobal(bIsGlobal) { @@ -85,9 +85,9 @@ CJBig2_Context::CJBig2_Context(CPDF_StreamAcc* pGlobalStream, CJBig2_Context::~CJBig2_Context() { FX_Free(m_gbContext); - m_gbContext = NULL; + m_gbContext = nullptr; delete m_pGlobalContext; - m_pGlobalContext = NULL; + m_pGlobalContext = nullptr; } int32_t CJBig2_Context::decode_SquentialOrgnazation(IFX_Pause* pPause) { @@ -259,7 +259,7 @@ CJBig2_Segment* CJBig2_Context::findReferredSegmentByTypeAndIndex( ++count; } } - return NULL; + return nullptr; } int32_t CJBig2_Context::parseSegmentHeader(CJBig2_Segment* pSegment) { if (m_pStream->readInteger(&pSegment->m_dwNumber) != 0 || @@ -737,7 +737,7 @@ int32_t CJBig2_Context::parseTextRegion(CJBig2_Segment* pSegment) { } pTRD->SBSYMS = SBSYMS.get(); } else { - pTRD->SBSYMS = NULL; + pTRD->SBSYMS = nullptr; } std::unique_ptr SBSYMCODES; @@ -946,7 +946,7 @@ int32_t CJBig2_Context::parseTextRegion(CJBig2_Segment* pSegment) { m_pPage->composeFrom(ri.x, ri.y, pSegment->m_Result.im, (JBig2ComposeOp)(ri.flags & 0x03)); delete pSegment->m_Result.im; - pSegment->m_Result.im = NULL; + pSegment->m_Result.im = nullptr; } return JBIG2_SUCCESS; } @@ -1064,7 +1064,7 @@ int32_t CJBig2_Context::parseHalftoneRegion(CJBig2_Segment* pSegment, m_pPage->composeFrom(ri.x, ri.y, pSegment->m_Result.im, (JBig2ComposeOp)(ri.flags & 0x03)); delete pSegment->m_Result.im; - pSegment->m_Result.im = NULL; + pSegment->m_Result.im = nullptr; } return JBIG2_SUCCESS; } @@ -1137,7 +1137,7 @@ int32_t CJBig2_Context::parseGenericRegion(CJBig2_Segment* pSegment, } else { m_pArithDecoder.reset(); FX_Free(m_gbContext); - m_gbContext = NULL; + m_gbContext = nullptr; if (!pSegment->m_Result.im) { m_ProcessingStatus = FXCODEC_STATUS_ERROR; m_pGRD.reset(); @@ -1168,7 +1168,7 @@ int32_t CJBig2_Context::parseGenericRegion(CJBig2_Segment* pSegment, pSegment->m_Result.im, (JBig2ComposeOp)(m_ri.flags & 0x03), &Rect); delete pSegment->m_Result.im; - pSegment->m_Result.im = NULL; + pSegment->m_Result.im = nullptr; } m_pGRD.reset(); return JBIG2_SUCCESS; @@ -1238,7 +1238,7 @@ int32_t CJBig2_Context::parseGenericRefinementRegion(CJBig2_Segment* pSegment) { m_pPage->composeFrom(ri.x, ri.y, pSegment->m_Result.im, (JBig2ComposeOp)(ri.flags & 0x03)); delete pSegment->m_Result.im; - pSegment->m_Result.im = NULL; + pSegment->m_Result.im = nullptr; } return JBIG2_SUCCESS; } diff --git a/core/fxcodec/jbig2/JBig2_Context.h b/core/fxcodec/jbig2/JBig2_Context.h index fa68588a4a..950ad130d7 100644 --- a/core/fxcodec/jbig2/JBig2_Context.h +++ b/core/fxcodec/jbig2/JBig2_Context.h @@ -44,7 +44,7 @@ class CJBig2_Context { CPDF_StreamAcc* pGlobalStream, CPDF_StreamAcc* pSrcStream, std::list* pSymbolDictCache, - IFX_Pause* pPause = NULL); + IFX_Pause* pPause = nullptr); static void DestroyContext(CJBig2_Context* pContext); diff --git a/core/fxcodec/jbig2/JBig2_Image.cpp b/core/fxcodec/jbig2/JBig2_Image.cpp index 6a1c060b75..cf0ee3bbbc 100644 --- a/core/fxcodec/jbig2/JBig2_Image.cpp +++ b/core/fxcodec/jbig2/JBig2_Image.cpp @@ -14,7 +14,7 @@ CJBig2_Image::CJBig2_Image(int32_t w, int32_t h) { m_nWidth = w; m_nHeight = h; if (m_nWidth <= 0 || m_nHeight <= 0 || m_nWidth > INT_MAX - 31) { - m_pData = NULL; + m_pData = nullptr; m_bNeedFree = FALSE; return; } @@ -22,7 +22,7 @@ CJBig2_Image::CJBig2_Image(int32_t w, int32_t h) { if (m_nStride * m_nHeight > 0 && 104857600 / (int)m_nStride > m_nHeight) { m_pData = FX_Alloc2D(uint8_t, m_nStride, m_nHeight); } else { - m_pData = NULL; + m_pData = nullptr; } m_bNeedFree = TRUE; } @@ -44,7 +44,7 @@ CJBig2_Image::CJBig2_Image(const CJBig2_Image& im) { m_pData = FX_Alloc2D(uint8_t, m_nStride, m_nHeight); JBIG2_memcpy(m_pData, im.m_pData, m_nStride * m_nHeight); } else { - m_pData = NULL; + m_pData = nullptr; } m_bNeedFree = TRUE; } @@ -120,12 +120,12 @@ FX_BOOL CJBig2_Image::composeTo(CJBig2_Image* pDst, int32_t y, JBig2ComposeOp op, const FX_RECT* pSrcRect) { - if (!m_pData) { + if (!m_pData) return FALSE; - } - if (NULL == pSrcRect || *pSrcRect == FX_RECT(0, 0, m_nWidth, m_nHeight)) { + + if (!pSrcRect || *pSrcRect == FX_RECT(0, 0, m_nWidth, m_nHeight)) return composeTo_opt2(pDst, x, y, op); - } + return composeTo_opt2(pDst, x, y, op, pSrcRect); } @@ -159,7 +159,7 @@ CJBig2_Image* CJBig2_Image::subImage(int32_t x, uint32_t wTmp; uint8_t *pSrc, *pSrcEnd, *pDst, *pDstEnd; if (w == 0 || h == 0) { - return NULL; + return nullptr; } CJBig2_Image* pImage = new CJBig2_Image(w, h); if (!m_pData) { @@ -243,14 +243,12 @@ FX_BOOL CJBig2_Image::composeTo_opt2(CJBig2_Image* pDst, uint32_t s1 = 0, d1 = 0, d2 = 0, shift = 0, shift1 = 0, shift2 = 0, tmp = 0, tmp1 = 0, tmp2 = 0, maskL = 0, maskR = 0, maskM = 0; - uint8_t *lineSrc = NULL, *lineDst = NULL, *sp = NULL, *dp = NULL; - - if (!m_pData) { + if (!m_pData) return FALSE; - } - if (x < -1048576 || x > 1048576 || y < -1048576 || y > 1048576) { + + if (x < -1048576 || x > 1048576 || y < -1048576 || y > 1048576) return FALSE; - } + if (y < 0) { ys0 = -y; } @@ -286,9 +284,9 @@ FX_BOOL CJBig2_Image::composeTo_opt2(CJBig2_Image* pDst, maskL = 0xffffffff >> d1; maskR = 0xffffffff << ((32 - (xd1 & 31)) % 32); maskM = maskL & maskR; - lineSrc = m_pData + ys0 * m_nStride + ((xs0 >> 5) << 2); + uint8_t* lineSrc = m_pData + ys0 * m_nStride + ((xs0 >> 5) << 2); lineLeft = m_nStride - ((xs0 >> 5) << 2); - lineDst = pDst->m_pData + yd0 * pDst->m_nStride + ((xd0 >> 5) << 2); + uint8_t* lineDst = pDst->m_pData + yd0 * pDst->m_nStride + ((xd0 >> 5) << 2); if ((xd0 & ~31) == ((xd1 - 1) & ~31)) { if ((xs0 & ~31) == ((xs1 - 1) & ~31)) { if (s1 > d1) { @@ -383,6 +381,9 @@ FX_BOOL CJBig2_Image::composeTo_opt2(CJBig2_Image* pDst, } } } else { + uint8_t* sp = nullptr; + uint8_t* dp = nullptr; + if (s1 > d1) { shift1 = s1 - d1; shift2 = 32 - shift1; diff --git a/core/fxcodec/jbig2/JBig2_PatternDict.cpp b/core/fxcodec/jbig2/JBig2_PatternDict.cpp index e74d83647c..9598dc4bae 100644 --- a/core/fxcodec/jbig2/JBig2_PatternDict.cpp +++ b/core/fxcodec/jbig2/JBig2_PatternDict.cpp @@ -10,7 +10,7 @@ CJBig2_PatternDict::CJBig2_PatternDict() { NUMPATS = 0; - HDPATS = NULL; + HDPATS = nullptr; } CJBig2_PatternDict::~CJBig2_PatternDict() { diff --git a/core/fxcodec/jbig2/JBig2_Segment.cpp b/core/fxcodec/jbig2/JBig2_Segment.cpp index 64df0db5f7..0f53abcee3 100644 --- a/core/fxcodec/jbig2/JBig2_Segment.cpp +++ b/core/fxcodec/jbig2/JBig2_Segment.cpp @@ -12,7 +12,7 @@ CJBig2_Segment::CJBig2_Segment() { m_dwNumber = 0; m_cFlags.c = 0; m_nReferred_to_segment_count = 0; - m_pReferred_to_segment_numbers = NULL; + m_pReferred_to_segment_numbers = nullptr; m_dwPage_association = 0; m_dwData_length = 0; m_dwHeader_Length = 0; @@ -20,7 +20,7 @@ CJBig2_Segment::CJBig2_Segment() { m_dwDataOffset = 0; m_State = JBIG2_SEGMENT_HEADER_UNPARSED; m_nResultType = JBIG2_VOID_POINTER; - m_Result.vd = NULL; + m_Result.vd = nullptr; } CJBig2_Segment::~CJBig2_Segment() { FX_Free(m_pReferred_to_segment_numbers); diff --git a/core/fxcodec/lbmp/fx_bmp.cpp b/core/fxcodec/lbmp/fx_bmp.cpp index be5d93e1b8..dcf1ee11f9 100644 --- a/core/fxcodec/lbmp/fx_bmp.cpp +++ b/core/fxcodec/lbmp/fx_bmp.cpp @@ -40,20 +40,17 @@ void bmp_error(bmp_decompress_struct_p bmp_ptr, const FX_CHAR* err_msg) { } bmp_decompress_struct_p bmp_create_decompress() { bmp_decompress_struct_p bmp_ptr = FX_Alloc(bmp_decompress_struct, 1); - if (bmp_ptr == NULL) { - return NULL; - } FXSYS_memset(bmp_ptr, 0, sizeof(bmp_decompress_struct)); bmp_ptr->decode_status = BMP_D_STATUS_HEADER; bmp_ptr->bmp_header_ptr = FX_Alloc(BmpFileHeader, 1); return bmp_ptr; } void bmp_destroy_decompress(bmp_decompress_struct_pp bmp_ptr_ptr) { - if (bmp_ptr_ptr == NULL || *bmp_ptr_ptr == NULL) { + if (!bmp_ptr_ptr || !*bmp_ptr_ptr) return; - } + bmp_decompress_struct_p bmp_ptr = *bmp_ptr_ptr; - *bmp_ptr_ptr = NULL; + *bmp_ptr_ptr = nullptr; if (bmp_ptr->out_row_buffer) { FX_Free(bmp_ptr->out_row_buffer); } @@ -62,16 +59,16 @@ void bmp_destroy_decompress(bmp_decompress_struct_pp bmp_ptr_ptr) { FX_Free(bmp_ptr); } int32_t bmp_read_header(bmp_decompress_struct_p bmp_ptr) { - if (bmp_ptr == NULL) { + if (!bmp_ptr) return 0; - } + uint32_t skip_size_org = bmp_ptr->skip_size; if (bmp_ptr->decode_status == BMP_D_STATUS_HEADER) { ASSERT(sizeof(BmpFileHeader) == 14); - BmpFileHeader* bmp_header_ptr = NULL; - if (bmp_read_data(bmp_ptr, (uint8_t**)&bmp_header_ptr, 14) == NULL) { + BmpFileHeader* bmp_header_ptr = nullptr; + if (!bmp_read_data(bmp_ptr, (uint8_t**)&bmp_header_ptr, 14)) return 2; - } + bmp_ptr->bmp_header_ptr->bfType = GetWord_LSBFirst((uint8_t*)&bmp_header_ptr->bfType); bmp_ptr->bmp_header_ptr->bfOffBits = @@ -95,9 +92,9 @@ int32_t bmp_read_header(bmp_decompress_struct_p bmp_ptr) { switch (bmp_ptr->img_ifh_size) { case kBmpCoreHeaderSize: { bmp_ptr->pal_type = 1; - BmpCoreHeaderPtr bmp_core_header_ptr = NULL; - if (bmp_read_data(bmp_ptr, (uint8_t**)&bmp_core_header_ptr, - bmp_ptr->img_ifh_size) == NULL) { + BmpCoreHeaderPtr bmp_core_header_ptr = nullptr; + if (!bmp_read_data(bmp_ptr, (uint8_t**)&bmp_core_header_ptr, + bmp_ptr->img_ifh_size)) { bmp_ptr->skip_size = skip_size_org; return 2; } @@ -111,9 +108,9 @@ int32_t bmp_read_header(bmp_decompress_struct_p bmp_ptr) { bmp_ptr->imgTB_flag = FALSE; } break; case kBmpInfoHeaderSize: { - BmpInfoHeaderPtr bmp_info_header_ptr = NULL; - if (bmp_read_data(bmp_ptr, (uint8_t**)&bmp_info_header_ptr, - bmp_ptr->img_ifh_size) == NULL) { + BmpInfoHeaderPtr bmp_info_header_ptr = nullptr; + if (!bmp_read_data(bmp_ptr, (uint8_t**)&bmp_info_header_ptr, + bmp_ptr->img_ifh_size)) { bmp_ptr->skip_size = skip_size_org; return 2; } @@ -139,9 +136,9 @@ int32_t bmp_read_header(bmp_decompress_struct_p bmp_ptr) { default: { if (bmp_ptr->img_ifh_size > std::min(kBmpInfoHeaderSize, sizeof(BmpInfoHeader))) { - BmpInfoHeaderPtr bmp_info_header_ptr = NULL; - if (bmp_read_data(bmp_ptr, (uint8_t**)&bmp_info_header_ptr, - bmp_ptr->img_ifh_size) == NULL) { + BmpInfoHeaderPtr bmp_info_header_ptr = nullptr; + if (!bmp_read_data(bmp_ptr, (uint8_t**)&bmp_info_header_ptr, + bmp_ptr->img_ifh_size)) { bmp_ptr->skip_size = skip_size_org; return 2; } @@ -229,7 +226,7 @@ int32_t bmp_read_header(bmp_decompress_struct_p bmp_ptr) { } uint32_t* mask; if (bmp_read_data(bmp_ptr, (uint8_t**)&mask, 3 * sizeof(uint32_t)) == - NULL) { + nullptr) { bmp_ptr->skip_size = skip_size_org; return 2; } @@ -258,10 +255,10 @@ int32_t bmp_read_header(bmp_decompress_struct_p bmp_ptr) { if (bmp_ptr->color_used != 0) { bmp_ptr->pal_num = bmp_ptr->color_used; } - uint8_t* src_pal_ptr = NULL; + uint8_t* src_pal_ptr = nullptr; uint32_t src_pal_size = bmp_ptr->pal_num * (bmp_ptr->pal_type ? 3 : 4); if (bmp_read_data(bmp_ptr, (uint8_t**)&src_pal_ptr, src_pal_size) == - NULL) { + nullptr) { bmp_ptr->skip_size = skip_size_org; return 2; } @@ -321,11 +318,11 @@ int32_t bmp_decode_image(bmp_decompress_struct_p bmp_ptr) { } int32_t bmp_decode_rgb(bmp_decompress_struct_p bmp_ptr) { uint8_t* row_buf = bmp_ptr->out_row_buffer; - uint8_t* des_buf = NULL; + uint8_t* des_buf = nullptr; while (bmp_ptr->row_num < bmp_ptr->height) { - if (bmp_read_data(bmp_ptr, &des_buf, bmp_ptr->src_row_bytes) == NULL) { + if (!bmp_read_data(bmp_ptr, &des_buf, bmp_ptr->src_row_bytes)) return 2; - } + bmp_save_decoding_status(bmp_ptr, BMP_D_STATUS_DATA); switch (bmp_ptr->bitCounts) { case 1: { @@ -384,17 +381,17 @@ int32_t bmp_decode_rgb(bmp_decompress_struct_p bmp_ptr) { return 1; } int32_t bmp_decode_rle8(bmp_decompress_struct_p bmp_ptr) { - uint8_t* first_byte_ptr = NULL; - uint8_t* second_byte_ptr = NULL; + uint8_t* first_byte_ptr = nullptr; + uint8_t* second_byte_ptr = nullptr; bmp_ptr->col_num = 0; while (TRUE) { uint32_t skip_size_org = bmp_ptr->skip_size; - if (bmp_read_data(bmp_ptr, &first_byte_ptr, 1) == NULL) { + if (!bmp_read_data(bmp_ptr, &first_byte_ptr, 1)) return 2; - } + switch (*first_byte_ptr) { case RLE_MARKER: { - if (bmp_read_data(bmp_ptr, &first_byte_ptr, 1) == NULL) { + if (!bmp_read_data(bmp_ptr, &first_byte_ptr, 1)) { bmp_ptr->skip_size = skip_size_org; return 2; } @@ -428,7 +425,7 @@ int32_t bmp_decode_rle8(bmp_decompress_struct_p bmp_ptr) { } case RLE_DELTA: { uint8_t* delta_ptr; - if (bmp_read_data(bmp_ptr, &delta_ptr, 2) == NULL) { + if (!bmp_read_data(bmp_ptr, &delta_ptr, 2)) { bmp_ptr->skip_size = skip_size_org; return 2; } @@ -454,9 +451,9 @@ int32_t bmp_decode_rle8(bmp_decompress_struct_p bmp_ptr) { bmp_error(bmp_ptr, "The Bmp File Is Corrupt"); return 0; } - if (bmp_read_data(bmp_ptr, &second_byte_ptr, - *first_byte_ptr & 1 ? *first_byte_ptr + 1 - : *first_byte_ptr) == NULL) { + if (!bmp_read_data(bmp_ptr, &second_byte_ptr, + *first_byte_ptr & 1 ? *first_byte_ptr + 1 + : *first_byte_ptr)) { bmp_ptr->skip_size = skip_size_org; return 2; } @@ -467,7 +464,7 @@ int32_t bmp_decode_rle8(bmp_decompress_struct_p bmp_ptr) { } } break; default: { - if (bmp_read_data(bmp_ptr, &second_byte_ptr, 1) == NULL) { + if (!bmp_read_data(bmp_ptr, &second_byte_ptr, 1)) { bmp_ptr->skip_size = skip_size_org; return 2; } @@ -486,17 +483,17 @@ int32_t bmp_decode_rle8(bmp_decompress_struct_p bmp_ptr) { return 0; } int32_t bmp_decode_rle4(bmp_decompress_struct_p bmp_ptr) { - uint8_t* first_byte_ptr = NULL; - uint8_t* second_byte_ptr = NULL; + uint8_t* first_byte_ptr = nullptr; + uint8_t* second_byte_ptr = nullptr; bmp_ptr->col_num = 0; while (TRUE) { uint32_t skip_size_org = bmp_ptr->skip_size; - if (bmp_read_data(bmp_ptr, &first_byte_ptr, 1) == NULL) { + if (!bmp_read_data(bmp_ptr, &first_byte_ptr, 1)) return 2; - } + switch (*first_byte_ptr) { case RLE_MARKER: { - if (bmp_read_data(bmp_ptr, &first_byte_ptr, 1) == NULL) { + if (!bmp_read_data(bmp_ptr, &first_byte_ptr, 1)) { bmp_ptr->skip_size = skip_size_org; return 2; } @@ -530,7 +527,7 @@ int32_t bmp_decode_rle4(bmp_decompress_struct_p bmp_ptr) { } case RLE_DELTA: { uint8_t* delta_ptr; - if (bmp_read_data(bmp_ptr, &delta_ptr, 2) == NULL) { + if (!bmp_read_data(bmp_ptr, &delta_ptr, 2)) { bmp_ptr->skip_size = skip_size_org; return 2; } @@ -560,8 +557,8 @@ int32_t bmp_decode_rle4(bmp_decompress_struct_p bmp_ptr) { } *first_byte_ptr = bmp_ptr->out_row_bytes - bmp_ptr->col_num - 1; } - if (bmp_read_data(bmp_ptr, &second_byte_ptr, - size & 1 ? size + 1 : size) == NULL) { + if (!bmp_read_data(bmp_ptr, &second_byte_ptr, + size & 1 ? size + 1 : size)) { bmp_ptr->skip_size = skip_size_org; return 2; } @@ -578,7 +575,7 @@ int32_t bmp_decode_rle4(bmp_decompress_struct_p bmp_ptr) { } } break; default: { - if (bmp_read_data(bmp_ptr, &second_byte_ptr, 1) == NULL) { + if (!bmp_read_data(bmp_ptr, &second_byte_ptr, 1)) { bmp_ptr->skip_size = skip_size_org; return 2; } @@ -609,9 +606,9 @@ int32_t bmp_decode_rle4(bmp_decompress_struct_p bmp_ptr) { uint8_t* bmp_read_data(bmp_decompress_struct_p bmp_ptr, uint8_t** des_buf_pp, uint32_t data_size) { - if (bmp_ptr == NULL || bmp_ptr->avail_in < bmp_ptr->skip_size + data_size) { - return NULL; - } + if (!bmp_ptr || bmp_ptr->avail_in < bmp_ptr->skip_size + data_size) + return nullptr; + *des_buf_pp = bmp_ptr->next_in + bmp_ptr->skip_size; bmp_ptr->skip_size += data_size; return *des_buf_pp; @@ -630,11 +627,11 @@ void bmp_input_buffer(bmp_decompress_struct_p bmp_ptr, bmp_ptr->skip_size = 0; } uint32_t bmp_get_avail_input(bmp_decompress_struct_p bmp_ptr, - uint8_t** avial_buf_ptr) { - if (avial_buf_ptr) { - *avial_buf_ptr = NULL; + uint8_t** avail_buf_ptr) { + if (avail_buf_ptr) { + *avail_buf_ptr = nullptr; if (bmp_ptr->avail_in > 0) { - *avial_buf_ptr = bmp_ptr->next_in; + *avail_buf_ptr = bmp_ptr->next_in; } } return bmp_ptr->avail_in; @@ -708,9 +705,6 @@ static void bmp_encode_bitfields(bmp_compress_struct_p bmp_ptr, dst_pos = bmp_ptr->file_header.bfOffBits; dst_size += size; dst_buf = FX_Realloc(uint8_t, dst_buf, dst_size); - if (dst_buf == NULL) { - return; - } FXSYS_memset(&dst_buf[dst_pos], 0, size); uint32_t mask_red; uint32_t mask_green; @@ -795,9 +789,6 @@ static void bmp_encode_rgb(bmp_compress_struct_p bmp_ptr, dst_pos = bmp_ptr->file_header.bfOffBits; dst_size += size; dst_buf = FX_Realloc(uint8_t, dst_buf, dst_size); - if (dst_buf == NULL) { - return; - } FXSYS_memset(&dst_buf[dst_pos], 0, size); for (int32_t row_num = bmp_ptr->src_row - 1; row_num > -1; row_num--) { FXSYS_memcpy(&dst_buf[dst_pos], @@ -827,9 +818,6 @@ static void bmp_encode_rle8(bmp_compress_struct_p bmp_ptr, dst_pos = bmp_ptr->file_header.bfOffBits; dst_size += size; dst_buf = FX_Realloc(uint8_t, dst_buf, dst_size); - if (dst_buf == NULL) { - return; - } FXSYS_memset(&dst_buf[dst_pos], 0, size); for (int32_t row_num = bmp_ptr->src_row - 1, i = 0; row_num > -1;) { index = row_num * bmp_ptr->src_pitch; @@ -875,9 +863,6 @@ static void bmp_encode_rle4(bmp_compress_struct_p bmp_ptr, dst_pos = bmp_ptr->file_header.bfOffBits; dst_size += size; dst_buf = FX_Realloc(uint8_t, dst_buf, dst_size); - if (dst_buf == NULL) { - return; - } FXSYS_memset(&dst_buf[dst_pos], 0, size); for (int32_t row_num = bmp_ptr->src_row - 1, i = 0; row_num > -1; rle[1] = 0) { @@ -916,9 +901,9 @@ FX_BOOL bmp_encode_image(bmp_compress_struct_p bmp_ptr, } dst_size = head_size + sizeof(uint32_t) * bmp_ptr->pal_num; dst_buf = FX_TryAlloc(uint8_t, dst_size); - if (dst_buf == NULL) { + if (!dst_buf) return FALSE; - } + FXSYS_memset(dst_buf, 0, dst_size); bmp_ptr->file_header.bfOffBits = head_size; if (bmp_ptr->pal_ptr && pal_size) { diff --git a/core/fxcodec/lbmp/fx_bmp.h b/core/fxcodec/lbmp/fx_bmp.h index 870eae478c..5c4837807f 100644 --- a/core/fxcodec/lbmp/fx_bmp.h +++ b/core/fxcodec/lbmp/fx_bmp.h @@ -125,7 +125,7 @@ void bmp_input_buffer(bmp_decompress_struct_p bmp_ptr, uint8_t* src_buf, uint32_t src_size); uint32_t bmp_get_avail_input(bmp_decompress_struct_p bmp_ptr, - uint8_t** avial_buf_ptr); + uint8_t** avail_buf_ptr); typedef struct tag_bmp_compress_struct bmp_compress_struct; typedef bmp_compress_struct* bmp_compress_struct_p; typedef bmp_compress_struct_p* bmp_compress_struct_pp; diff --git a/core/fxcodec/lgif/fx_gif.cpp b/core/fxcodec/lgif/fx_gif.cpp index 53298c831a..e22bbc7774 100644 --- a/core/fxcodec/lgif/fx_gif.cpp +++ b/core/fxcodec/lgif/fx_gif.cpp @@ -21,7 +21,7 @@ void CGifLZWDecoder::InitTable(uint8_t code_len) { code_end = code_clear + 1; bits_left = 0; code_store = 0; - next_in = NULL; + next_in = nullptr; avail_in = 0; stack_size = 0; code_first = 0; @@ -151,17 +151,15 @@ static FX_BOOL gif_grow_buf(uint8_t*& dst_buf, uint32_t len_org = dst_len; while (dst_buf && dst_len < size) { dst_len <<= 1; + // TODO(thestig): Probably should be a try-realloc here. dst_buf = FX_Realloc(uint8_t, dst_buf, dst_len); } - if (dst_buf == NULL) { + if (!dst_buf) { dst_len = size; dst_buf = FX_Realloc(uint8_t, dst_buf, dst_len); - if (dst_buf == NULL) { - return FALSE; - } } FXSYS_memset(dst_buf + len_org, 0, dst_len - len_org); - return dst_buf != NULL; + return !!dst_buf; } return TRUE; } @@ -359,9 +357,9 @@ void CGifLZWEncoder::Finish(uint8_t*& dst_buf, gif_decompress_struct_p gif_create_decompress() { gif_decompress_struct_p gif_ptr = (gif_decompress_struct*)FX_Alloc(uint8_t, sizeof(gif_decompress_struct)); - if (gif_ptr == NULL) { - return NULL; - } + if (!gif_ptr) + return nullptr; + FXSYS_memset(gif_ptr, 0, sizeof(gif_decompress_struct)); gif_ptr->decode_status = GIF_D_STATUS_SIG; gif_ptr->img_ptr_arr_ptr = new CFX_ArrayTemplate; @@ -370,11 +368,11 @@ gif_decompress_struct_p gif_create_decompress() { return gif_ptr; } void gif_destroy_decompress(gif_decompress_struct_pp gif_ptr_ptr) { - if (gif_ptr_ptr == NULL || *gif_ptr_ptr == NULL) { + if (!gif_ptr_ptr || !*gif_ptr_ptr) return; - } + gif_decompress_struct_p gif_ptr = *gif_ptr_ptr; - *gif_ptr_ptr = NULL; + *gif_ptr_ptr = nullptr; FX_Free(gif_ptr->global_pal_ptr); delete gif_ptr->img_decoder_ptr; if (gif_ptr->img_ptr_arr_ptr) { @@ -410,66 +408,66 @@ void gif_destroy_decompress(gif_decompress_struct_pp gif_ptr_ptr) { gif_compress_struct_p gif_create_compress() { gif_compress_struct_p gif_ptr = (gif_compress_struct*)FX_Alloc(uint8_t, sizeof(gif_compress_struct)); - if (gif_ptr == NULL) { - return NULL; - } + if (!gif_ptr) + return nullptr; + FXSYS_memset(gif_ptr, 0, sizeof(gif_compress_struct)); gif_ptr->img_encoder_ptr = new CGifLZWEncoder; gif_ptr->header_ptr = (GifHeader*)FX_Alloc(uint8_t, sizeof(GifHeader)); - if (gif_ptr->header_ptr == NULL) { + if (!gif_ptr->header_ptr) { delete (gif_ptr->img_encoder_ptr); FX_Free(gif_ptr); - return NULL; + return nullptr; } FXSYS_memcpy(gif_ptr->header_ptr->signature, GIF_SIGNATURE, 3); FXSYS_memcpy(gif_ptr->header_ptr->version, "89a", 3); gif_ptr->lsd_ptr = (GifLSD*)FX_Alloc(uint8_t, sizeof(GifLSD)); - if (gif_ptr->lsd_ptr == NULL) { + if (!gif_ptr->lsd_ptr) { FX_Free(gif_ptr->header_ptr); delete (gif_ptr->img_encoder_ptr); FX_Free(gif_ptr); - return NULL; + return nullptr; } FXSYS_memset(gif_ptr->lsd_ptr, 0, sizeof(GifLSD)); gif_ptr->image_info_ptr = (GifImageInfo*)FX_Alloc(uint8_t, sizeof(GifImageInfo)); - if (gif_ptr->image_info_ptr == NULL) { + if (!gif_ptr->image_info_ptr) { FX_Free(gif_ptr->lsd_ptr); FX_Free(gif_ptr->header_ptr); delete (gif_ptr->img_encoder_ptr); FX_Free(gif_ptr); - return NULL; + return nullptr; } FXSYS_memset(gif_ptr->image_info_ptr, 0, sizeof(GifImageInfo)); gif_ptr->gce_ptr = (GifGCE*)FX_Alloc(uint8_t, sizeof(GifGCE)); - if (gif_ptr->gce_ptr == NULL) { + if (!gif_ptr->gce_ptr) { FX_Free(gif_ptr->image_info_ptr); FX_Free(gif_ptr->lsd_ptr); FX_Free(gif_ptr->header_ptr); delete (gif_ptr->img_encoder_ptr); FX_Free(gif_ptr); - return NULL; + return nullptr; } gif_ptr->pte_ptr = (GifPTE*)FX_Alloc(uint8_t, sizeof(GifPTE)); - if (gif_ptr->pte_ptr == NULL) { + if (!gif_ptr->pte_ptr) { FX_Free(gif_ptr->gce_ptr); FX_Free(gif_ptr->image_info_ptr); FX_Free(gif_ptr->lsd_ptr); FX_Free(gif_ptr->header_ptr); delete (gif_ptr->img_encoder_ptr); FX_Free(gif_ptr); - return NULL; + return nullptr; } FXSYS_memset(gif_ptr->pte_ptr, 0, sizeof(GifPTE)); gif_ptr->pte_ptr->block_size = 12; return gif_ptr; } void gif_destroy_compress(gif_compress_struct_pp gif_ptr_ptr) { - if (gif_ptr_ptr == NULL || *gif_ptr_ptr == NULL) { + if (!gif_ptr_ptr || !*gif_ptr_ptr) return; - } + gif_compress_struct_p gif_ptr = *gif_ptr_ptr; - *gif_ptr_ptr = NULL; + *gif_ptr_ptr = nullptr; FX_Free(gif_ptr->header_ptr); FX_Free(gif_ptr->lsd_ptr); FX_Free(gif_ptr->global_pal); @@ -488,23 +486,23 @@ void gif_error(gif_decompress_struct_p gif_ptr, const FX_CHAR* err_msg) { } void gif_warn(gif_decompress_struct_p gif_ptr, const FX_CHAR* err_msg) {} int32_t gif_read_header(gif_decompress_struct_p gif_ptr) { - if (gif_ptr == NULL) { + if (!gif_ptr) return 0; - } + uint32_t skip_size_org = gif_ptr->skip_size; ASSERT(sizeof(GifHeader) == 6); - GifHeader* gif_header_ptr = NULL; - if (gif_read_data(gif_ptr, (uint8_t**)&gif_header_ptr, 6) == NULL) { + GifHeader* gif_header_ptr = nullptr; + if (!gif_read_data(gif_ptr, (uint8_t**)&gif_header_ptr, 6)) return 2; - } + if (FXSYS_strncmp(gif_header_ptr->signature, GIF_SIGNATURE, 3) != 0 || gif_header_ptr->version[0] != '8' || gif_header_ptr->version[2] != 'a') { gif_error(gif_ptr, "Not A Gif Image"); return 0; } ASSERT(sizeof(GifLSD) == 7); - GifLSD* gif_lsd_ptr = NULL; - if (gif_read_data(gif_ptr, (uint8_t**)&gif_lsd_ptr, 7) == NULL) { + GifLSD* gif_lsd_ptr = nullptr; + if (!gif_read_data(gif_ptr, (uint8_t**)&gif_lsd_ptr, 7)) { gif_ptr->skip_size = skip_size_org; return 2; } @@ -513,8 +511,8 @@ int32_t gif_read_header(gif_decompress_struct_p gif_ptr) { << ((GifGF*)&gif_lsd_ptr->global_flag)->pal_bits; ASSERT(sizeof(GifPalette) == 3); int32_t global_pal_size = gif_ptr->global_pal_num * 3; - uint8_t* global_pal_ptr = NULL; - if (gif_read_data(gif_ptr, &global_pal_ptr, global_pal_size) == NULL) { + uint8_t* global_pal_ptr = nullptr; + if (!gif_read_data(gif_ptr, &global_pal_ptr, global_pal_size)) { gif_ptr->skip_size = skip_size_org; return 2; } @@ -532,19 +530,19 @@ int32_t gif_read_header(gif_decompress_struct_p gif_ptr) { return 1; } int32_t gif_get_frame(gif_decompress_struct_p gif_ptr) { - if (gif_ptr == NULL) { + if (!gif_ptr) return 0; - } + int32_t ret = 1; while (TRUE) { switch (gif_ptr->decode_status) { case GIF_D_STATUS_TAIL: return 1; case GIF_D_STATUS_SIG: { - uint8_t* sig_ptr = NULL; - if (gif_read_data(gif_ptr, &sig_ptr, 1) == NULL) { + uint8_t* sig_ptr = nullptr; + if (!gif_read_data(gif_ptr, &sig_ptr, 1)) return 2; - } + switch (*sig_ptr) { case GIF_SIG_EXTENSION: gif_save_decoding_status(gif_ptr, GIF_D_STATUS_EXT); @@ -566,10 +564,10 @@ int32_t gif_get_frame(gif_decompress_struct_p gif_ptr) { } } case GIF_D_STATUS_EXT: { - uint8_t* ext_ptr = NULL; - if (gif_read_data(gif_ptr, &ext_ptr, 1) == NULL) { + uint8_t* ext_ptr = nullptr; + if (!gif_read_data(gif_ptr, &ext_ptr, 1)) return 2; - } + switch (*ext_ptr) { case GIF_BLOCK_CE: gif_save_decoding_status(gif_ptr, GIF_D_STATUS_EXT_CE); @@ -598,22 +596,21 @@ int32_t gif_get_frame(gif_decompress_struct_p gif_ptr) { continue; } case GIF_D_STATUS_IMG_DATA: { - uint8_t* data_size_ptr = NULL; - uint8_t* data_ptr = NULL; + uint8_t* data_size_ptr = nullptr; + uint8_t* data_ptr = nullptr; uint32_t skip_size_org = gif_ptr->skip_size; - if (gif_read_data(gif_ptr, &data_size_ptr, 1) == NULL) { + if (!gif_read_data(gif_ptr, &data_size_ptr, 1)) return 2; - } + while (*data_size_ptr != GIF_BLOCK_TERMINAL) { - if (gif_read_data(gif_ptr, &data_ptr, *data_size_ptr) == NULL) { + if (!gif_read_data(gif_ptr, &data_ptr, *data_size_ptr)) { gif_ptr->skip_size = skip_size_org; return 2; } gif_save_decoding_status(gif_ptr, GIF_D_STATUS_IMG_DATA); skip_size_org = gif_ptr->skip_size; - if (gif_read_data(gif_ptr, &data_size_ptr, 1) == NULL) { + if (!gif_read_data(gif_ptr, &data_size_ptr, 1)) return 2; - } } gif_save_decoding_status(gif_ptr, GIF_D_STATUS_SIG); continue; @@ -631,27 +628,27 @@ int32_t gif_get_frame(gif_decompress_struct_p gif_ptr) { } void gif_takeover_gce_ptr(gif_decompress_struct_p gif_ptr, GifGCE** gce_ptr_ptr) { - *gce_ptr_ptr = NULL; + *gce_ptr_ptr = nullptr; if (gif_ptr->gce_ptr && gce_ptr_ptr) { *gce_ptr_ptr = gif_ptr->gce_ptr; - gif_ptr->gce_ptr = NULL; + gif_ptr->gce_ptr = nullptr; } } int32_t gif_decode_extension(gif_decompress_struct_p gif_ptr) { - uint8_t* data_size_ptr = NULL; - uint8_t* data_ptr = NULL; + uint8_t* data_size_ptr = nullptr; + uint8_t* data_ptr = nullptr; uint32_t skip_size_org = gif_ptr->skip_size; switch (gif_ptr->decode_status) { case GIF_D_STATUS_EXT_CE: { - if (gif_read_data(gif_ptr, &data_size_ptr, 1) == NULL) { + if (!gif_read_data(gif_ptr, &data_size_ptr, 1)) { gif_ptr->skip_size = skip_size_org; return 2; } gif_ptr->cmt_data_ptr->clear(); while (*data_size_ptr != GIF_BLOCK_TERMINAL) { uint8_t data_size = *data_size_ptr; - if (gif_read_data(gif_ptr, &data_ptr, *data_size_ptr) == NULL || - gif_read_data(gif_ptr, &data_size_ptr, 1) == NULL) { + if (!gif_read_data(gif_ptr, &data_ptr, *data_size_ptr) || + !gif_read_data(gif_ptr, &data_size_ptr, 1)) { gif_ptr->skip_size = skip_size_org; return 2; } @@ -661,8 +658,8 @@ int32_t gif_decode_extension(gif_decompress_struct_p gif_ptr) { } break; case GIF_D_STATUS_EXT_PTE: { ASSERT(sizeof(GifPTE) == 13); - GifPTE* gif_pte_ptr = NULL; - if (gif_read_data(gif_ptr, (uint8_t**)&gif_pte_ptr, 13) == NULL) { + GifPTE* gif_pte_ptr = nullptr; + if (!gif_read_data(gif_ptr, (uint8_t**)&gif_pte_ptr, 13)) { return 2; } GifPlainText* gif_pt_ptr = FX_Alloc(GifPlainText, 1); @@ -683,7 +680,7 @@ int32_t gif_decode_extension(gif_decompress_struct_p gif_ptr) { gif_pt_ptr->pte_ptr->char_height = gif_pte_ptr->char_height; gif_pt_ptr->pte_ptr->fc_index = gif_pte_ptr->fc_index; gif_pt_ptr->pte_ptr->bc_index = gif_pte_ptr->bc_index; - if (gif_read_data(gif_ptr, &data_size_ptr, 1) == NULL) { + if (!gif_read_data(gif_ptr, &data_size_ptr, 1)) { gif_ptr->skip_size = skip_size_org; if (gif_pt_ptr) { FX_Free(gif_pt_ptr->gce_ptr); @@ -695,8 +692,8 @@ int32_t gif_decode_extension(gif_decompress_struct_p gif_ptr) { } while (*data_size_ptr != GIF_BLOCK_TERMINAL) { uint8_t data_size = *data_size_ptr; - if (gif_read_data(gif_ptr, &data_ptr, *data_size_ptr) == NULL || - gif_read_data(gif_ptr, &data_size_ptr, 1) == NULL) { + if (!gif_read_data(gif_ptr, &data_ptr, *data_size_ptr) || + !gif_read_data(gif_ptr, &data_size_ptr, 1)) { gif_ptr->skip_size = skip_size_org; if (gif_pt_ptr) { FX_Free(gif_pt_ptr->gce_ptr); @@ -713,13 +710,12 @@ int32_t gif_decode_extension(gif_decompress_struct_p gif_ptr) { } break; case GIF_D_STATUS_EXT_GCE: { ASSERT(sizeof(GifGCE) == 5); - GifGCE* gif_gce_ptr = NULL; - if (gif_read_data(gif_ptr, (uint8_t**)&gif_gce_ptr, 6) == NULL) { + GifGCE* gif_gce_ptr = nullptr; + if (!gif_read_data(gif_ptr, (uint8_t**)&gif_gce_ptr, 6)) return 2; - } - if (gif_ptr->gce_ptr == NULL) { + + if (!gif_ptr->gce_ptr) gif_ptr->gce_ptr = (GifGCE*)FX_Alloc(uint8_t, sizeof(GifGCE)); - } gif_ptr->gce_ptr->block_size = gif_gce_ptr->block_size; gif_ptr->gce_ptr->gce_flag = gif_gce_ptr->gce_flag; gif_ptr->gce_ptr->delay_time = @@ -729,14 +725,14 @@ int32_t gif_decode_extension(gif_decompress_struct_p gif_ptr) { default: { if (gif_ptr->decode_status == GIF_D_STATUS_EXT_PTE) { FX_Free(gif_ptr->gce_ptr); - gif_ptr->gce_ptr = NULL; + gif_ptr->gce_ptr = nullptr; } - if (gif_read_data(gif_ptr, &data_size_ptr, 1) == NULL) { + if (!gif_read_data(gif_ptr, &data_size_ptr, 1)) return 2; - } + while (*data_size_ptr != GIF_BLOCK_TERMINAL) { - if (gif_read_data(gif_ptr, &data_ptr, *data_size_ptr) == NULL || - gif_read_data(gif_ptr, &data_size_ptr, 1) == NULL) { + if (!gif_read_data(gif_ptr, &data_ptr, *data_size_ptr) || + !gif_read_data(gif_ptr, &data_size_ptr, 1)) { gif_ptr->skip_size = skip_size_org; return 2; } @@ -753,10 +749,10 @@ int32_t gif_decode_image_info(gif_decompress_struct_p gif_ptr) { } uint32_t skip_size_org = gif_ptr->skip_size; ASSERT(sizeof(GifImageInfo) == 9); - GifImageInfo* gif_img_info_ptr = NULL; - if (gif_read_data(gif_ptr, (uint8_t**)&gif_img_info_ptr, 9) == NULL) { + GifImageInfo* gif_img_info_ptr = nullptr; + if (!gif_read_data(gif_ptr, (uint8_t**)&gif_img_info_ptr, 9)) return 2; - } + GifImage* gif_image_ptr = (GifImage*)FX_Alloc(uint8_t, sizeof(GifImage)); FXSYS_memset(gif_image_ptr, 0, sizeof(GifImage)); gif_image_ptr->image_info_ptr = @@ -786,8 +782,8 @@ int32_t gif_decode_image_info(gif_decompress_struct_p gif_ptr) { if (gif_img_info_lf_ptr->local_pal) { ASSERT(sizeof(GifPalette) == 3); int32_t loc_pal_size = (2 << gif_img_info_lf_ptr->pal_bits) * 3; - uint8_t* loc_pal_ptr = NULL; - if (gif_read_data(gif_ptr, &loc_pal_ptr, loc_pal_size) == NULL) { + uint8_t* loc_pal_ptr = nullptr; + if (!gif_read_data(gif_ptr, &loc_pal_ptr, loc_pal_size)) { gif_ptr->skip_size = skip_size_org; FX_Free(gif_image_ptr->image_info_ptr); FX_Free(gif_image_ptr->image_row_buf); @@ -801,8 +797,8 @@ int32_t gif_decode_image_info(gif_decompress_struct_p gif_ptr) { loc_pal_size); } } - uint8_t* code_size_ptr = NULL; - if (gif_read_data(gif_ptr, &code_size_ptr, 1) == NULL) { + uint8_t* code_size_ptr = nullptr; + if (!gif_read_data(gif_ptr, &code_size_ptr, 1)) { gif_ptr->skip_size = skip_size_org; FX_Free(gif_image_ptr->image_info_ptr); FX_Free(gif_image_ptr->local_pal_ptr); @@ -820,19 +816,19 @@ int32_t gif_decode_image_info(gif_decompress_struct_p gif_ptr) { return 1; } int32_t gif_load_frame(gif_decompress_struct_p gif_ptr, int32_t frame_num) { - if (gif_ptr == NULL || frame_num < 0 || + if (!gif_ptr || frame_num < 0 || frame_num >= gif_ptr->img_ptr_arr_ptr->GetSize()) { return 0; } - uint8_t* data_size_ptr = NULL; - uint8_t* data_ptr = NULL; + uint8_t* data_size_ptr = nullptr; + uint8_t* data_ptr = nullptr; uint32_t skip_size_org = gif_ptr->skip_size; GifImage* gif_image_ptr = gif_ptr->img_ptr_arr_ptr->GetAt(frame_num); uint32_t gif_img_row_bytes = gif_image_ptr->image_info_ptr->width; if (gif_ptr->decode_status == GIF_D_STATUS_TAIL) { if (gif_image_ptr->image_row_buf) { FX_Free(gif_image_ptr->image_row_buf); - gif_image_ptr->image_row_buf = NULL; + gif_image_ptr->image_row_buf = nullptr; } gif_image_ptr->image_row_buf = FX_Alloc(uint8_t, gif_img_row_bytes); GifGCE* gif_img_gce_ptr = gif_image_ptr->image_gce_ptr; @@ -842,7 +838,7 @@ int32_t gif_load_frame(gif_decompress_struct_p gif_ptr, int32_t frame_num) { ->pal_bits) : 0; gif_ptr->avail_in = 0; - if (gif_img_gce_ptr == NULL) { + if (!gif_img_gce_ptr) { FX_BOOL bRes = gif_ptr->gif_get_record_position_fn( gif_ptr, gif_image_ptr->image_data_pos, gif_image_ptr->image_info_ptr->left, @@ -854,7 +850,7 @@ int32_t gif_load_frame(gif_decompress_struct_p gif_ptr, int32_t frame_num) { ->interlace); if (!bRes) { FX_Free(gif_image_ptr->image_row_buf); - gif_image_ptr->image_row_buf = NULL; + gif_image_ptr->image_row_buf = nullptr; gif_error(gif_ptr, "Error Read Record Position Data"); return 0; } @@ -878,14 +874,13 @@ int32_t gif_load_frame(gif_decompress_struct_p gif_ptr, int32_t frame_num) { ->interlace); if (!bRes) { FX_Free(gif_image_ptr->image_row_buf); - gif_image_ptr->image_row_buf = NULL; + gif_image_ptr->image_row_buf = nullptr; gif_error(gif_ptr, "Error Read Record Position Data"); return 0; } } - if (gif_ptr->img_decoder_ptr == NULL) { + if (!gif_ptr->img_decoder_ptr) gif_ptr->img_decoder_ptr = new CGifLZWDecoder(gif_ptr->err_ptr); - } gif_ptr->img_decoder_ptr->InitTable(gif_image_ptr->image_code_size); gif_ptr->img_row_offset = 0; gif_ptr->img_row_avail_size = 0; @@ -895,11 +890,11 @@ int32_t gif_load_frame(gif_decompress_struct_p gif_ptr, int32_t frame_num) { } CGifLZWDecoder* img_decoder_ptr = gif_ptr->img_decoder_ptr; if (gif_ptr->decode_status == GIF_D_STATUS_IMG_DATA) { - if (gif_read_data(gif_ptr, &data_size_ptr, 1) == NULL) { + if (!gif_read_data(gif_ptr, &data_size_ptr, 1)) return 2; - } + if (*data_size_ptr != GIF_BLOCK_TERMINAL) { - if (gif_read_data(gif_ptr, &data_ptr, *data_size_ptr) == NULL) { + if (!gif_read_data(gif_ptr, &data_ptr, *data_size_ptr)) { gif_ptr->skip_size = skip_size_org; return 2; } @@ -912,7 +907,7 @@ int32_t gif_load_frame(gif_decompress_struct_p gif_ptr, int32_t frame_num) { gif_ptr->img_row_avail_size); if (ret == 0) { FX_Free(gif_image_ptr->image_row_buf); - gif_image_ptr->image_row_buf = NULL; + gif_image_ptr->image_row_buf = nullptr; gif_save_decoding_status(gif_ptr, GIF_D_STATUS_TAIL); gif_error(gif_ptr, "Decode Image Data Error"); return 0; @@ -922,18 +917,18 @@ int32_t gif_load_frame(gif_decompress_struct_p gif_ptr, int32_t frame_num) { gif_ptr->gif_get_row_fn(gif_ptr, gif_image_ptr->image_row_num, gif_image_ptr->image_row_buf); FX_Free(gif_image_ptr->image_row_buf); - gif_image_ptr->image_row_buf = NULL; + gif_image_ptr->image_row_buf = nullptr; gif_save_decoding_status(gif_ptr, GIF_D_STATUS_TAIL); return 1; } if (ret == 2) { ASSERT(img_decoder_ptr->GetAvailInput() == 0); skip_size_org = gif_ptr->skip_size; - if (gif_read_data(gif_ptr, &data_size_ptr, 1) == NULL) { + if (!gif_read_data(gif_ptr, &data_size_ptr, 1)) return 2; - } + if (*data_size_ptr != GIF_BLOCK_TERMINAL) { - if (gif_read_data(gif_ptr, &data_ptr, *data_size_ptr) == NULL) { + if (!gif_read_data(gif_ptr, &data_ptr, *data_size_ptr)) { gif_ptr->skip_size = skip_size_org; return 2; } @@ -971,7 +966,7 @@ int32_t gif_load_frame(gif_decompress_struct_p gif_ptr, int32_t frame_num) { } if (ret == 0) { FX_Free(gif_image_ptr->image_row_buf); - gif_image_ptr->image_row_buf = NULL; + gif_image_ptr->image_row_buf = nullptr; gif_save_decoding_status(gif_ptr, GIF_D_STATUS_TAIL); gif_error(gif_ptr, "Decode Image Data Error"); return 0; @@ -992,9 +987,9 @@ void gif_save_decoding_status(gif_decompress_struct_p gif_ptr, int32_t status) { uint8_t* gif_read_data(gif_decompress_struct_p gif_ptr, uint8_t** des_buf_pp, uint32_t data_size) { - if (gif_ptr == NULL || gif_ptr->avail_in < gif_ptr->skip_size + data_size) { - return NULL; - } + if (!gif_ptr || gif_ptr->avail_in < gif_ptr->skip_size + data_size) + return nullptr; + *des_buf_pp = gif_ptr->next_in + gif_ptr->skip_size; gif_ptr->skip_size += data_size; return *des_buf_pp; @@ -1007,11 +1002,11 @@ void gif_input_buffer(gif_decompress_struct_p gif_ptr, gif_ptr->skip_size = 0; } uint32_t gif_get_avail_input(gif_decompress_struct_p gif_ptr, - uint8_t** avial_buf_ptr) { - if (avial_buf_ptr) { - *avial_buf_ptr = NULL; + uint8_t** avail_buf_ptr) { + if (avail_buf_ptr) { + *avail_buf_ptr = nullptr; if (gif_ptr->avail_in > 0) { - *avial_buf_ptr = gif_ptr->next_in; + *avail_buf_ptr = gif_ptr->next_in; } } return gif_ptr->avail_in; @@ -1027,9 +1022,9 @@ static FX_BOOL gif_write_header(gif_compress_struct_p gif_ptr, } dst_len = sizeof(GifHeader) + sizeof(GifLSD) + sizeof(GifGF); dst_buf = FX_TryAlloc(uint8_t, dst_len); - if (dst_buf == NULL) { + if (!dst_buf) return FALSE; - } + FXSYS_memset(dst_buf, 0, dst_len); FXSYS_memcpy(dst_buf, gif_ptr->header_ptr, sizeof(GifHeader)); gif_ptr->cur_offset += sizeof(GifHeader); @@ -1067,9 +1062,6 @@ void interlace_buf(const uint8_t* buf, uint32_t pitch, uint32_t height) { j = 3; } temp = FX_Alloc(uint8_t, pitch); - if (temp == NULL) { - return; - } FXSYS_memcpy(temp, &buf[pitch * row], pitch); pass[j].Add(temp); row++; diff --git a/core/fxcodec/lgif/fx_gif.h b/core/fxcodec/lgif/fx_gif.h index 47e5eebab7..7d325fb3fe 100644 --- a/core/fxcodec/lgif/fx_gif.h +++ b/core/fxcodec/lgif/fx_gif.h @@ -118,7 +118,7 @@ class CGifLZWDecoder { uint16_t prefix; uint8_t suffix; }; - CGifLZWDecoder(FX_CHAR* error_ptr = NULL) { err_msg_ptr = error_ptr; } + CGifLZWDecoder(FX_CHAR* error_ptr = nullptr) { err_msg_ptr = error_ptr; } void InitTable(uint8_t code_len); int32_t Decode(uint8_t* des_buf, uint32_t& des_size); @@ -287,7 +287,7 @@ void gif_input_buffer(gif_decompress_struct_p gif_ptr, uint8_t* src_buf, uint32_t src_size); uint32_t gif_get_avail_input(gif_decompress_struct_p gif_ptr, - uint8_t** avial_buf_ptr); + uint8_t** avail_buf_ptr); void interlace_buf(const uint8_t* buf, uint32_t width, uint32_t height); FX_BOOL gif_encode(gif_compress_struct_p gif_ptr, uint8_t*& dst_buf, diff --git a/core/fxcrt/fx_arabic.cpp b/core/fxcrt/fx_arabic.cpp index 434c203120..2c0a1bbad7 100644 --- a/core/fxcrt/fx_arabic.cpp +++ b/core/fxcrt/fx_arabic.cpp @@ -251,7 +251,7 @@ const FX_ARBFORMTABLE* ParseChar(const CFX_Char* pTC, const FX_ARBFORMTABLE* FX_GetArabicFormTable(FX_WCHAR unicode) { if (unicode < 0x622 || unicode > 0x6d5) { - return NULL; + return nullptr; } return g_FX_ArabicFormTables + unicode - 0x622; } diff --git a/core/fxcrt/fx_basic_array.cpp b/core/fxcrt/fx_basic_array.cpp index eb6570d950..0a2dc43fc5 100644 --- a/core/fxcrt/fx_basic_array.cpp +++ b/core/fxcrt/fx_basic_array.cpp @@ -8,7 +8,7 @@ #include "third_party/base/numerics/safe_math.h" CFX_BasicArray::CFX_BasicArray(int unit_size) - : m_pData(NULL), m_nSize(0), m_nMaxSize(0) { + : m_pData(nullptr), m_nSize(0), m_nMaxSize(0) { if (unit_size < 0 || unit_size > (1 << 28)) { m_nUnitSize = 4; } else { @@ -21,7 +21,7 @@ CFX_BasicArray::~CFX_BasicArray() { FX_BOOL CFX_BasicArray::SetSize(int nNewSize) { if (nNewSize <= 0) { FX_Free(m_pData); - m_pData = NULL; + m_pData = nullptr; m_nSize = m_nMaxSize = 0; return 0 == nNewSize; } @@ -82,16 +82,16 @@ FX_BOOL CFX_BasicArray::Copy(const CFX_BasicArray& src) { } uint8_t* CFX_BasicArray::InsertSpaceAt(int nIndex, int nCount) { if (nIndex < 0 || nCount <= 0) { - return NULL; + return nullptr; } if (nIndex >= m_nSize) { if (!SetSize(nIndex + nCount)) { - return NULL; + return nullptr; } } else { int nOldSize = m_nSize; if (!SetSize(m_nSize + nCount)) { - return NULL; + return nullptr; } FXSYS_memmove(m_pData + (nIndex + nCount) * m_nUnitSize, m_pData + nIndex * m_nUnitSize, @@ -130,7 +130,7 @@ FX_BOOL CFX_BasicArray::InsertAt(int nStartIndex, } const void* CFX_BasicArray::GetDataPtr(int index) const { if (index < 0 || index >= m_nSize || !m_pData) { - return NULL; + return nullptr; } return m_pData + index * m_nUnitSize; } diff --git a/core/fxcrt/fx_basic_bstring_unittest.cpp b/core/fxcrt/fx_basic_bstring_unittest.cpp index fe98b53b45..220105aa95 100644 --- a/core/fxcrt/fx_basic_bstring_unittest.cpp +++ b/core/fxcrt/fx_basic_bstring_unittest.cpp @@ -251,7 +251,7 @@ TEST(fxcrt, ByteStringOperatorNE) { TEST(fxcrt, ByteStringCNull) { CFX_ByteStringC null_string; - EXPECT_EQ(null_string.raw_str(), nullptr); + EXPECT_FALSE(null_string.raw_str()); EXPECT_EQ(null_string.GetLength(), 0); EXPECT_TRUE(null_string.IsEmpty()); @@ -259,27 +259,27 @@ TEST(fxcrt, ByteStringCNull) { EXPECT_EQ(null_string, another_null_string); CFX_ByteStringC copied_null_string(null_string); - EXPECT_EQ(copied_null_string.raw_str(), nullptr); + EXPECT_FALSE(copied_null_string.raw_str()); EXPECT_EQ(copied_null_string.GetLength(), 0); EXPECT_TRUE(copied_null_string.IsEmpty()); EXPECT_EQ(null_string, copied_null_string); CFX_ByteStringC empty_string(""); // Pointer to NUL, not NULL pointer. - EXPECT_NE(empty_string.raw_str(), nullptr); + EXPECT_TRUE(empty_string.raw_str()); EXPECT_EQ(empty_string.GetLength(), 0); EXPECT_TRUE(empty_string.IsEmpty()); EXPECT_EQ(null_string, empty_string); - CFX_ByteStringC assigned_null_string("initially not NULL"); + CFX_ByteStringC assigned_null_string("initially not nullptr"); assigned_null_string = null_string; - EXPECT_EQ(assigned_null_string.raw_str(), nullptr); + EXPECT_FALSE(assigned_null_string.raw_str()); EXPECT_EQ(assigned_null_string.GetLength(), 0); EXPECT_TRUE(assigned_null_string.IsEmpty()); EXPECT_EQ(null_string, assigned_null_string); - CFX_ByteStringC assigned_nullptr_string("initially not NULL"); + CFX_ByteStringC assigned_nullptr_string("initially not nullptr"); assigned_nullptr_string = (const FX_CHAR*)nullptr; - EXPECT_EQ(assigned_nullptr_string.raw_str(), nullptr); + EXPECT_FALSE(assigned_nullptr_string.raw_str()); EXPECT_EQ(assigned_nullptr_string.GetLength(), 0); EXPECT_TRUE(assigned_nullptr_string.IsEmpty()); EXPECT_EQ(null_string, assigned_nullptr_string); diff --git a/core/fxcrt/fx_basic_gcc.cpp b/core/fxcrt/fx_basic_gcc.cpp index a55a486293..3547e5fbf0 100644 --- a/core/fxcrt/fx_basic_gcc.cpp +++ b/core/fxcrt/fx_basic_gcc.cpp @@ -138,7 +138,7 @@ FXSYS_FILE* FXSYS_wfopen(const FX_WCHAR* filename, const FX_WCHAR* mode) { } char* FXSYS_strlwr(char* str) { if (!str) { - return NULL; + return nullptr; } char* s = str; while (*str) { @@ -149,7 +149,7 @@ char* FXSYS_strlwr(char* str) { } char* FXSYS_strupr(char* str) { if (!str) { - return NULL; + return nullptr; } char* s = str; while (*str) { @@ -160,7 +160,7 @@ char* FXSYS_strupr(char* str) { } FX_WCHAR* FXSYS_wcslwr(FX_WCHAR* str) { if (!str) { - return NULL; + return nullptr; } FX_WCHAR* s = str; while (*str) { @@ -171,7 +171,7 @@ FX_WCHAR* FXSYS_wcslwr(FX_WCHAR* str) { } FX_WCHAR* FXSYS_wcsupr(FX_WCHAR* str) { if (!str) { - return NULL; + return nullptr; } FX_WCHAR* s = str; while (*str) { diff --git a/core/fxcrt/fx_basic_list.cpp b/core/fxcrt/fx_basic_list.cpp index f128176d00..53e0621a6e 100644 --- a/core/fxcrt/fx_basic_list.cpp +++ b/core/fxcrt/fx_basic_list.cpp @@ -8,14 +8,14 @@ #include "core/fxcrt/plex.h" CFX_PtrList::CFX_PtrList(int nBlockSize) - : m_pNodeHead(NULL), - m_pNodeTail(NULL), + : m_pNodeHead(nullptr), + m_pNodeTail(nullptr), m_nCount(0), - m_pNodeFree(NULL), - m_pBlocks(NULL), + m_pNodeFree(nullptr), + m_pBlocks(nullptr), m_nBlockSize(nBlockSize) {} FX_POSITION CFX_PtrList::AddTail(void* newElement) { - CNode* pNewNode = NewNode(m_pNodeTail, NULL); + CNode* pNewNode = NewNode(m_pNodeTail, nullptr); pNewNode->data = newElement; if (m_pNodeTail) { m_pNodeTail->pNext = pNewNode; @@ -26,7 +26,7 @@ FX_POSITION CFX_PtrList::AddTail(void* newElement) { return (FX_POSITION)pNewNode; } FX_POSITION CFX_PtrList::AddHead(void* newElement) { - CNode* pNewNode = NewNode(NULL, m_pNodeHead); + CNode* pNewNode = NewNode(nullptr, m_pNodeHead); pNewNode->data = newElement; if (m_pNodeHead) { m_pNodeHead->pPrev = pNewNode; @@ -112,7 +112,7 @@ CFX_PtrList::~CFX_PtrList() { } FX_POSITION CFX_PtrList::FindIndex(int nIndex) const { if (nIndex >= m_nCount || nIndex < 0) { - return NULL; + return nullptr; } CNode* pNode = m_pNodeHead; while (nIndex--) { @@ -127,5 +127,5 @@ FX_POSITION CFX_PtrList::Find(void* searchValue, FX_POSITION startAfter) const { if (pNode->data == searchValue) return (FX_POSITION)pNode; } - return NULL; + return nullptr; } diff --git a/core/fxcrt/fx_basic_maps.cpp b/core/fxcrt/fx_basic_maps.cpp index dda8167bdb..2424b82714 100644 --- a/core/fxcrt/fx_basic_maps.cpp +++ b/core/fxcrt/fx_basic_maps.cpp @@ -76,11 +76,10 @@ void* CFX_MapPtrToPtr::GetValueAt(void* key) const { void*& CFX_MapPtrToPtr::operator[](void* key) { uint32_t nHash; - CAssoc* pAssoc; - if ((pAssoc = GetAssocAt(key, nHash)) == NULL) { - if (!m_pHashTable) { + CAssoc* pAssoc = GetAssocAt(key, nHash); + if (!pAssoc) { + if (!m_pHashTable) InitHashTable(m_nHashTableSize); - } pAssoc = NewAssoc(); pAssoc->key = key; pAssoc->pNext = m_pHashTable[nHash]; @@ -92,14 +91,14 @@ CFX_MapPtrToPtr::CAssoc* CFX_MapPtrToPtr::GetAssocAt(void* key, uint32_t& nHash) const { nHash = HashKey(key) % m_nHashTableSize; if (!m_pHashTable) { - return NULL; + return nullptr; } CAssoc* pAssoc; for (pAssoc = m_pHashTable[nHash]; pAssoc; pAssoc = pAssoc->pNext) { if (pAssoc->key == key) return pAssoc; } - return NULL; + return nullptr; } CFX_MapPtrToPtr::CAssoc* CFX_MapPtrToPtr::NewAssoc() { if (!m_pFreeList) { @@ -125,7 +124,7 @@ void CFX_MapPtrToPtr::InitHashTable(uint32_t nHashSize, FX_BOOL bAllocNow) { ASSERT(m_nCount == 0); ASSERT(nHashSize > 0); FX_Free(m_pHashTable); - m_pHashTable = NULL; + m_pHashTable = nullptr; if (bAllocNow) { m_pHashTable = FX_Alloc(CAssoc*, nHashSize); } diff --git a/core/fxcrt/fx_extension.cpp b/core/fxcrt/fx_extension.cpp index 197022362f..1a95e8c318 100644 --- a/core/fxcrt/fx_extension.cpp +++ b/core/fxcrt/fx_extension.cpp @@ -68,13 +68,9 @@ FX_BOOL CFX_CRTFileStream::Flush() { #ifdef PDF_ENABLE_XFA IFX_FileAccess* FX_CreateDefaultFileAccess(const CFX_WideStringC& wsPath) { if (wsPath.GetLength() == 0) - return NULL; - - CFX_CRTFileAccess* pFA = NULL; - pFA = new CFX_CRTFileAccess; - if (NULL == pFA) - return NULL; + return nullptr; + CFX_CRTFileAccess* pFA = new CFX_CRTFileAccess; pFA->Init(wsPath); return pFA; } @@ -305,9 +301,9 @@ void FX_Random_GenerateBase(uint32_t* pBuffer, int32_t iCount) { FX_HashCode_GetA(CFX_ByteStringC((uint8_t*)&st2, sizeof(st2)), true); ::srand((dwHash1 << 16) | (uint32_t)dwHash2); #else - time_t tmLast = time(NULL); + time_t tmLast = time(nullptr); time_t tmCur; - while ((tmCur = time(NULL)) == tmLast) { + while ((tmCur = time(nullptr)) == tmLast) { continue; } @@ -319,8 +315,9 @@ void FX_Random_GenerateBase(uint32_t* pBuffer, int32_t iCount) { } #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ FX_BOOL FX_GenerateCryptoRandom(uint32_t* pBuffer, int32_t iCount) { - HCRYPTPROV hCP = NULL; - if (!::CryptAcquireContext(&hCP, NULL, NULL, PROV_RSA_FULL, 0) || !hCP) { + HCRYPTPROV hCP = 0; + if (!::CryptAcquireContext(&hCP, nullptr, nullptr, PROV_RSA_FULL, 0) || + !hCP) { return FALSE; } ::CryptGenRandom(hCP, iCount * sizeof(uint32_t), (uint8_t*)pBuffer); diff --git a/core/fxcrt/fxcrt_windows.cpp b/core/fxcrt/fxcrt_windows.cpp index d4b4e50c2c..271cc8fda8 100644 --- a/core/fxcrt/fxcrt_windows.cpp +++ b/core/fxcrt/fxcrt_windows.cpp @@ -39,7 +39,7 @@ WINBASEAPI BOOL WINAPI SetFilePointerEx(HANDLE hFile, #ifdef __cplusplus } #endif -CFXCRT_FileAccess_Win64::CFXCRT_FileAccess_Win64() : m_hFile(NULL) {} +CFXCRT_FileAccess_Win64::CFXCRT_FileAccess_Win64() : m_hFile(nullptr) {} CFXCRT_FileAccess_Win64::~CFXCRT_FileAccess_Win64() { Close(); } @@ -50,12 +50,11 @@ FX_BOOL CFXCRT_FileAccess_Win64::Open(const CFX_ByteStringC& fileName, } uint32_t dwAccess, dwShare, dwCreation; FXCRT_Windows_GetFileMode(dwMode, dwAccess, dwShare, dwCreation); - m_hFile = ::CreateFileA(fileName.c_str(), dwAccess, dwShare, NULL, dwCreation, - FILE_ATTRIBUTE_NORMAL, NULL); - if (m_hFile == INVALID_HANDLE_VALUE) { - m_hFile = NULL; - } - return m_hFile != NULL; + m_hFile = ::CreateFileA(fileName.c_str(), dwAccess, dwShare, nullptr, + dwCreation, FILE_ATTRIBUTE_NORMAL, nullptr); + if (m_hFile == INVALID_HANDLE_VALUE) + m_hFile = nullptr; + return !!m_hFile; } FX_BOOL CFXCRT_FileAccess_Win64::Open(const CFX_WideStringC& fileName, uint32_t dwMode) { @@ -64,19 +63,18 @@ FX_BOOL CFXCRT_FileAccess_Win64::Open(const CFX_WideStringC& fileName, } uint32_t dwAccess, dwShare, dwCreation; FXCRT_Windows_GetFileMode(dwMode, dwAccess, dwShare, dwCreation); - m_hFile = ::CreateFileW((LPCWSTR)fileName.c_str(), dwAccess, dwShare, NULL, - dwCreation, FILE_ATTRIBUTE_NORMAL, NULL); - if (m_hFile == INVALID_HANDLE_VALUE) { - m_hFile = NULL; - } - return m_hFile != NULL; + m_hFile = ::CreateFileW((LPCWSTR)fileName.c_str(), dwAccess, dwShare, nullptr, + dwCreation, FILE_ATTRIBUTE_NORMAL, nullptr); + if (m_hFile == INVALID_HANDLE_VALUE) + m_hFile = nullptr; + return !!m_hFile; } void CFXCRT_FileAccess_Win64::Close() { if (!m_hFile) { return; } ::CloseHandle(m_hFile); - m_hFile = NULL; + m_hFile = nullptr; } FX_FILESIZE CFXCRT_FileAccess_Win64::GetSize() const { if (!m_hFile) { @@ -116,7 +114,8 @@ size_t CFXCRT_FileAccess_Win64::Read(void* pBuffer, size_t szBuffer) { return 0; } size_t szRead = 0; - if (!::ReadFile(m_hFile, pBuffer, (DWORD)szBuffer, (LPDWORD)&szRead, NULL)) { + if (!::ReadFile(m_hFile, pBuffer, (DWORD)szBuffer, (LPDWORD)&szRead, + nullptr)) { return 0; } return szRead; @@ -127,7 +126,7 @@ size_t CFXCRT_FileAccess_Win64::Write(const void* pBuffer, size_t szBuffer) { } size_t szWrite = 0; if (!::WriteFile(m_hFile, pBuffer, (DWORD)szBuffer, (LPDWORD)&szWrite, - NULL)) { + nullptr)) { return 0; } return szWrite; diff --git a/core/fxcrt/include/fx_basic.h b/core/fxcrt/include/fx_basic.h index 13b51bd3fa..8e39f5577a 100644 --- a/core/fxcrt/include/fx_basic.h +++ b/core/fxcrt/include/fx_basic.h @@ -476,7 +476,7 @@ class CFX_MapPtrToPtr { void RemoveAll(); FX_POSITION GetStartPosition() const { - return (m_nCount == 0) ? NULL : (FX_POSITION)-1; + return m_nCount == 0 ? nullptr : (FX_POSITION)-1; } void GetNextAssoc(FX_POSITION& rNextPosition, @@ -515,7 +515,7 @@ class CFX_MapPtrTemplate : public CFX_MapPtrToPtr { CFX_MapPtrTemplate() : CFX_MapPtrToPtr(10) {} FX_BOOL Lookup(KeyType key, ValueType& rValue) const { - void* pValue = NULL; + void* pValue = nullptr; if (!CFX_MapPtrToPtr::Lookup((void*)(uintptr_t)key, pValue)) { return FALSE; } @@ -538,8 +538,8 @@ class CFX_MapPtrTemplate : public CFX_MapPtrToPtr { void GetNextAssoc(FX_POSITION& rNextPosition, KeyType& rKey, ValueType& rValue) const { - void* pKey = NULL; - void* pValue = NULL; + void* pKey = nullptr; + void* pValue = nullptr; CFX_MapPtrToPtr::GetNextAssoc(rNextPosition, pKey, pValue); rKey = (KeyType)(uintptr_t)pKey; rValue = (ValueType)(uintptr_t)pValue; @@ -596,7 +596,7 @@ class CFX_PtrList { } FX_POSITION InsertAfter(FX_POSITION pos, void* newElement); - FX_POSITION Find(void* searchValue, FX_POSITION startAfter = NULL) const; + FX_POSITION Find(void* searchValue, FX_POSITION startAfter = nullptr) const; FX_POSITION FindIndex(int index) const; void RemoveAt(FX_POSITION pos); @@ -662,7 +662,7 @@ class CFX_CountRef { int m_RefCount; }; - CFX_CountRef() { m_pObject = NULL; } + CFX_CountRef() { m_pObject = nullptr; } CFX_CountRef(const Ref& ref) { m_pObject = ref.m_pObject; @@ -716,7 +716,7 @@ class CFX_CountRef { if (m_pObject->m_RefCount <= 0) { delete m_pObject; } - m_pObject = NULL; + m_pObject = nullptr; } bool operator==(const Ref& ref) const { return m_pObject == ref.m_pObject; } @@ -785,15 +785,15 @@ class CFX_SortListArray { uint8_t* GetAt(int32_t nIndex) { if (nIndex < 0) { - return NULL; + return nullptr; } if (m_CurList < 0 || m_CurList >= m_DataLists.GetSize()) { - return NULL; + return nullptr; } DataList* pCurList = m_DataLists.GetDataPtr(m_CurList); if (!pCurList || nIndex < pCurList->start || nIndex >= pCurList->start + pCurList->count) { - pCurList = NULL; + pCurList = nullptr; int32_t iStart = 0; int32_t iEnd = m_DataLists.GetUpperBound(); int32_t iMid = 0; @@ -811,7 +811,8 @@ class CFX_SortListArray { } } } - return pCurList ? pCurList->data + (nIndex - pCurList->start) * unit : NULL; + return pCurList ? pCurList->data + (nIndex - pCurList->start) * unit + : nullptr; } protected: diff --git a/core/fxcrt/include/fx_ext.h b/core/fxcrt/include/fx_ext.h index b6c05ae9bc..d37db67d4a 100644 --- a/core/fxcrt/include/fx_ext.h +++ b/core/fxcrt/include/fx_ext.h @@ -24,10 +24,10 @@ FX_FLOAT FXSYS_tan(FX_FLOAT a); FX_FLOAT FXSYS_logb(FX_FLOAT b, FX_FLOAT x); FX_FLOAT FXSYS_strtof(const FX_CHAR* pcsStr, int32_t iLength = -1, - int32_t* pUsedLen = NULL); + int32_t* pUsedLen = nullptr); FX_FLOAT FXSYS_wcstof(const FX_WCHAR* pwsStr, int32_t iLength = -1, - int32_t* pUsedLen = NULL); + int32_t* pUsedLen = nullptr); FX_WCHAR* FXSYS_wcsncpy(FX_WCHAR* dstStr, const FX_WCHAR* srcStr, size_t count); int32_t FXSYS_wcsnicmp(const FX_WCHAR* s1, const FX_WCHAR* s2, size_t count); int32_t FXSYS_strnicmp(const FX_CHAR* s1, const FX_CHAR* s2, size_t count); diff --git a/core/fxcrt/include/fx_system.h b/core/fxcrt/include/fx_system.h index 61acd73492..ca5d49aad6 100644 --- a/core/fxcrt/include/fx_system.h +++ b/core/fxcrt/include/fx_system.h @@ -91,10 +91,6 @@ static_assert(TRUE == true, "true_needs_to_be_true"); static_assert(FALSE == false, "false_needs_to_be_false"); #endif -#ifndef NULL -#define NULL 0 -#endif - #ifndef ASSERT #ifndef NDEBUG #define ASSERT assert diff --git a/core/fxcrt/include/fx_ucd.h b/core/fxcrt/include/fx_ucd.h index fbf3187c86..c2c4688628 100644 --- a/core/fxcrt/include/fx_ucd.h +++ b/core/fxcrt/include/fx_ucd.h @@ -158,7 +158,7 @@ class CFX_TxtChar : public CFX_Char { m_iBidiLevel(0), m_iBidiPos(0), m_iBidiOrder(0), - m_pUserData(NULL) {} + m_pUserData(nullptr) {} uint32_t m_dwStatus; int16_t m_iBidiClass; int16_t m_iBidiLevel; @@ -179,7 +179,7 @@ class CFX_RTFChar : public CFX_Char { m_iBidiPos(0), m_dwLayoutStyles(0), m_dwIdentity(0), - m_pUserData(NULL) {} + m_pUserData(nullptr) {} uint32_t m_dwStatus; int32_t m_iFontSize; int32_t m_iFontHeight; diff --git a/core/fxcrt/include/fx_xml.h b/core/fxcrt/include/fx_xml.h index 8816e2eae1..0e8c82b103 100644 --- a/core/fxcrt/include/fx_xml.h +++ b/core/fxcrt/include/fx_xml.h @@ -53,13 +53,13 @@ class CXML_Element { static CXML_Element* Parse(const void* pBuffer, size_t size, FX_BOOL bSaveSpaceChars = FALSE, - FX_FILESIZE* pParsedSize = NULL); + FX_FILESIZE* pParsedSize = nullptr); static CXML_Element* Parse(IFX_FileRead* pFile, FX_BOOL bSaveSpaceChars = FALSE, - FX_FILESIZE* pParsedSize = NULL); + FX_FILESIZE* pParsedSize = nullptr); static CXML_Element* Parse(IFX_BufferRead* pBuffer, FX_BOOL bSaveSpaceChars = FALSE, - FX_FILESIZE* pParsedSize = NULL); + FX_FILESIZE* pParsedSize = nullptr); CXML_Element(const CFX_ByteStringC& qSpace, const CFX_ByteStringC& tagName); CXML_Element(const CFX_ByteStringC& qTagName); diff --git a/core/fxcrt/xml_int.h b/core/fxcrt/xml_int.h index 864b4e8789..6d3db4f525 100644 --- a/core/fxcrt/xml_int.h +++ b/core/fxcrt/xml_int.h @@ -48,7 +48,7 @@ class CXML_DataBufAcc : public IFX_BufferRead { class CXML_DataStmAcc : public IFX_BufferRead { public: explicit CXML_DataStmAcc(IFX_FileRead* pFileRead) - : m_pFileRead(pFileRead), m_pBuffer(NULL), m_nStart(0), m_dwSize(0) { + : m_pFileRead(pFileRead), m_pBuffer(nullptr), m_nStart(0), m_dwSize(0) { ASSERT(m_pFileRead); } ~CXML_DataStmAcc() override { FX_Free(m_pBuffer); } diff --git a/core/fxge/agg/fx_agg_driver.h b/core/fxge/agg/fx_agg_driver.h index 3462b61bb2..2c4e292faf 100644 --- a/core/fxge/agg/fx_agg_driver.h +++ b/core/fxge/agg/fx_agg_driver.h @@ -79,7 +79,7 @@ class CFX_AggDeviceDriver : public IFX_RenderDeviceDriver { FX_BOOL GetDIBits(CFX_DIBitmap* pBitmap, int left, int top, - void* pIccTransform = NULL, + void* pIccTransform = nullptr, FX_BOOL bDEdge = FALSE) override; CFX_DIBitmap* GetBackDrop() override { return m_pOriDevice; } FX_BOOL SetDIBits(const CFX_DIBSource* pBitmap, diff --git a/core/fxge/android/fpf_skiafontmgr.cpp b/core/fxge/android/fpf_skiafontmgr.cpp index 3158f4ca52..8a8cc83fb7 100644 --- a/core/fxge/android/fpf_skiafontmgr.cpp +++ b/core/fxge/android/fpf_skiafontmgr.cpp @@ -218,7 +218,7 @@ static FX_BOOL FPF_SkiaMaybeArabic(const CFX_ByteStringC& bsFacename) { bsName.MakeLower(); return bsName.Find("arabic") > -1; } -CFPF_SkiaFontMgr::CFPF_SkiaFontMgr() : m_bLoaded(FALSE), m_FTLibrary(NULL) {} +CFPF_SkiaFontMgr::CFPF_SkiaFontMgr() : m_bLoaded(FALSE), m_FTLibrary(nullptr) {} CFPF_SkiaFontMgr::~CFPF_SkiaFontMgr() { for (const auto& pair : m_FamilyFonts) { if (pair.second) @@ -234,10 +234,9 @@ CFPF_SkiaFontMgr::~CFPF_SkiaFontMgr() { } } FX_BOOL CFPF_SkiaFontMgr::InitFTLibrary() { - if (!m_FTLibrary) { + if (!m_FTLibrary) FXFT_Init_FreeType(&m_FTLibrary); - } - return m_FTLibrary != NULL; + return !!m_FTLibrary; } void CFPF_SkiaFontMgr::LoadSystemFonts() { if (m_bLoaded) { @@ -333,18 +332,18 @@ CFPF_SkiaFont* CFPF_SkiaFontMgr::CreateFont(const CFX_ByteStringC& bsFamilyname, } pFont->Release(); } - return NULL; + return nullptr; } FXFT_Face CFPF_SkiaFontMgr::GetFontFace(IFX_FileRead* pFileRead, int32_t iFaceIndex) { if (!pFileRead) { - return NULL; + return nullptr; } if (pFileRead->GetSize() == 0) { - return NULL; + return nullptr; } if (iFaceIndex < 0) { - return NULL; + return nullptr; } FXFT_StreamRec streamRec; FXSYS_memset(&streamRec, 0, sizeof(FXFT_StreamRec)); @@ -357,7 +356,7 @@ FXFT_Face CFPF_SkiaFontMgr::GetFontFace(IFX_FileRead* pFileRead, args.stream = &streamRec; FXFT_Face face; if (FXFT_Open_Face(m_FTLibrary, &args, iFaceIndex, &face)) { - return NULL; + return nullptr; } FXFT_Set_Pixel_Sizes(face, 0, 64); return face; @@ -365,10 +364,10 @@ FXFT_Face CFPF_SkiaFontMgr::GetFontFace(IFX_FileRead* pFileRead, FXFT_Face CFPF_SkiaFontMgr::GetFontFace(const CFX_ByteStringC& bsFile, int32_t iFaceIndex) { if (bsFile.IsEmpty()) { - return NULL; + return nullptr; } if (iFaceIndex < 0) { - return NULL; + return nullptr; } FXFT_Open_Args args; args.flags = FT_OPEN_PATHNAME; @@ -384,10 +383,10 @@ FXFT_Face CFPF_SkiaFontMgr::GetFontFace(const uint8_t* pBuffer, size_t szBuffer, int32_t iFaceIndex) { if (!pBuffer || szBuffer < 1) { - return NULL; + return nullptr; } if (iFaceIndex < 0) { - return NULL; + return nullptr; } FXFT_Open_Args args; args.flags = FT_OPEN_MEMORY; diff --git a/core/fxge/android/fpf_skiafontmgr.h b/core/fxge/android/fpf_skiafontmgr.h index be3ea460da..ec27a7fb21 100644 --- a/core/fxge/android/fpf_skiafontmgr.h +++ b/core/fxge/android/fpf_skiafontmgr.h @@ -28,7 +28,7 @@ class CFPF_SkiaFont; class CFPF_SkiaFontDescriptor { public: CFPF_SkiaFontDescriptor() - : m_pFamily(NULL), + : m_pFamily(nullptr), m_dwStyle(0), m_iFaceIndex(0), m_dwCharsets(0), @@ -53,7 +53,7 @@ class CFPF_SkiaFontDescriptor { class CFPF_SkiaPathFont : public CFPF_SkiaFontDescriptor { public: - CFPF_SkiaPathFont() : m_pPath(NULL) {} + CFPF_SkiaPathFont() : m_pPath(nullptr) {} ~CFPF_SkiaPathFont() override { FX_Free(m_pPath); } // CFPF_SkiaFontDescriptor @@ -71,7 +71,7 @@ class CFPF_SkiaPathFont : public CFPF_SkiaFontDescriptor { class CFPF_SkiaFileFont : public CFPF_SkiaFontDescriptor { public: - CFPF_SkiaFileFont() : m_pFile(NULL) {} + CFPF_SkiaFileFont() : m_pFile(nullptr) {} // CFPF_SkiaFontDescriptor int32_t GetType() const override { return FPF_SKIAFONTTYPE_File; } @@ -80,7 +80,7 @@ class CFPF_SkiaFileFont : public CFPF_SkiaFontDescriptor { class CFPF_SkiaBufferFont : public CFPF_SkiaFontDescriptor { public: - CFPF_SkiaBufferFont() : m_pBuffer(NULL), m_szBuffer(0) {} + CFPF_SkiaBufferFont() : m_pBuffer(nullptr), m_szBuffer(0) {} // CFPF_SkiaFontDescriptor int32_t GetType() const override { return FPF_SKIAFONTTYPE_Buffer; } diff --git a/core/fxge/android/fx_android_font.cpp b/core/fxge/android/fx_android_font.cpp index b1606bbd69..3246eb7f9e 100644 --- a/core/fxge/android/fx_android_font.cpp +++ b/core/fxge/android/fx_android_font.cpp @@ -12,7 +12,7 @@ #include "core/fxge/android/fpf_skiafontmgr.h" #include "core/fxge/android/fx_android_font.h" -CFX_AndroidFontInfo::CFX_AndroidFontInfo() : m_pFontMgr(NULL) {} +CFX_AndroidFontInfo::CFX_AndroidFontInfo() : m_pFontMgr(nullptr) {} FX_BOOL CFX_AndroidFontInfo::Init(CFPF_SkiaFontMgr* pFontMgr) { if (!pFontMgr) return FALSE; diff --git a/core/fxge/apple/apple_int.h b/core/fxge/apple/apple_int.h index 1ef1f6c2b9..6afda63ee0 100644 --- a/core/fxge/apple/apple_int.h +++ b/core/fxge/apple/apple_int.h @@ -66,7 +66,7 @@ class CQuartz2D { CGPoint* glyphPositions, int32_t chars, FX_ARGB argb, - CFX_Matrix* matrix = NULL); + CFX_Matrix* matrix = nullptr); void saveGraphicsState(void* graphics); void restoreGraphicsState(void* graphics); }; @@ -102,12 +102,12 @@ class CFX_QuartzDeviceDriver : public IFX_RenderDeviceDriver { uint32_t stroke_color, int fill_mode, int alpha_flag = 0, - void* pIccTransform = NULL, + void* pIccTransform = nullptr, int blend_type = FXDIB_BLEND_NORMAL) override; FX_BOOL FillRect(const FX_RECT* pRect, uint32_t fill_color, int alpha_flag = 0, - void* pIccTransform = NULL, + void* pIccTransform = nullptr, int blend_type = FXDIB_BLEND_NORMAL) override; FX_BOOL DrawCosmeticLine(FX_FLOAT x1, FX_FLOAT y1, @@ -115,13 +115,13 @@ class CFX_QuartzDeviceDriver : public IFX_RenderDeviceDriver { FX_FLOAT y2, uint32_t color, int alpha_flag = 0, - void* pIccTransform = NULL, + void* pIccTransform = nullptr, int blend_type = FXDIB_BLEND_NORMAL) override; FX_BOOL GetClipBox(FX_RECT* pRect) override; FX_BOOL GetDIBits(CFX_DIBitmap* pBitmap, int left, int top, - void* pIccTransform = NULL, + void* pIccTransform = nullptr, FX_BOOL bDEdge = FALSE) override; FX_BOOL SetDIBits(const CFX_DIBSource* pBitmap, uint32_t color, @@ -130,7 +130,7 @@ class CFX_QuartzDeviceDriver : public IFX_RenderDeviceDriver { int dest_top, int blend_type, int alpha_flag = 0, - void* pIccTransform = NULL) override; + void* pIccTransform = nullptr) override; FX_BOOL StretchDIBits(const CFX_DIBSource* pBitmap, uint32_t color, int dest_left, @@ -140,7 +140,7 @@ class CFX_QuartzDeviceDriver : public IFX_RenderDeviceDriver { const FX_RECT* pClipRect, uint32_t flags, int alpha_flag = 0, - void* pIccTransform = NULL, + void* pIccTransform = nullptr, int blend_type = FXDIB_BLEND_NORMAL) override; FX_BOOL StartDIBits(const CFX_DIBSource* pBitmap, int bitmap_alpha, @@ -149,7 +149,7 @@ class CFX_QuartzDeviceDriver : public IFX_RenderDeviceDriver { uint32_t flags, void*& handle, int alpha_flag = 0, - void* pIccTransform = NULL, + void* pIccTransform = nullptr, int blend_type = FXDIB_BLEND_NORMAL) override { return FALSE; } @@ -161,7 +161,7 @@ class CFX_QuartzDeviceDriver : public IFX_RenderDeviceDriver { FX_FLOAT font_size, uint32_t color, int alpha_flag = 0, - void* pIccTransform = NULL) override; + void* pIccTransform = nullptr) override; void ClearDriver() override; protected: @@ -186,7 +186,7 @@ class CFX_QuartzDeviceDriver : public IFX_RenderDeviceDriver { int dest_top, int dest_width, int dest_height, - CGRect* rect = NULL); + CGRect* rect = nullptr); CGContextRef m_context; CGAffineTransform m_foxitDevice2User; diff --git a/core/fxge/apple/fx_apple_platform.cpp b/core/fxge/apple/fx_apple_platform.cpp index 7bedc678ac..b25bb5875d 100644 --- a/core/fxge/apple/fx_apple_platform.cpp +++ b/core/fxge/apple/fx_apple_platform.cpp @@ -31,7 +31,7 @@ void CFX_AggDeviceDriver::DestroyPlatform() { ->m_quartz2d; if (m_pPlatformGraphics) { quartz2d.destroyGraphics(m_pPlatformGraphics); - m_pPlatformGraphics = NULL; + m_pPlatformGraphics = nullptr; } } void CFX_FaceCache::InitPlatform() {} @@ -42,7 +42,7 @@ CFX_GlyphBitmap* CFX_FaceCache::RenderGlyph_Nativetext( const CFX_Matrix* pMatrix, int dest_width, int anti_alias) { - return NULL; + return nullptr; } static FX_BOOL _CGDrawGlyphRun(CGContextRef pContext, int nChars, @@ -100,7 +100,7 @@ static FX_BOOL _CGDrawGlyphRun(CGContextRef pContext, quartz2d.setGraphicsTextMatrix(pContext, &new_matrix); return quartz2d.drawGraphicsString(pContext, pFont->GetPlatformFont(), font_size, glyph_indices, glyph_positions, - nChars, argb, NULL); + nChars, argb, nullptr); } static void _DoNothing(void* info, const void* data, size_t size) {} FX_BOOL CFX_AggDeviceDriver::DrawDeviceText(int nChars, @@ -127,13 +127,13 @@ FX_BOOL CFX_AggDeviceDriver::DrawDeviceText(int nChars, } } CGContextRef ctx = CGContextRef(m_pPlatformGraphics); - if (NULL == ctx) { + if (!ctx) return FALSE; - } + CGContextSaveGState(ctx); CGContextSetTextDrawingMode(ctx, kCGTextFillClip); CGRect rect_cg; - CGImageRef pImageCG = NULL; + CGImageRef pImageCG = nullptr; if (m_pClipRgn) { rect_cg = CGRectMake(m_pClipRgn->GetBox().left, m_pClipRgn->GetBox().top, @@ -141,7 +141,7 @@ FX_BOOL CFX_AggDeviceDriver::DrawDeviceText(int nChars, const CFX_DIBitmap* pClipMask = m_pClipRgn->GetMask(); if (pClipMask) { CGDataProviderRef pClipMaskDataProvider = CGDataProviderCreateWithData( - NULL, pClipMask->GetBuffer(), + nullptr, pClipMask->GetBuffer(), pClipMask->GetPitch() * pClipMask->GetHeight(), _DoNothing); CGFloat decode_f[2] = {255.f, 0.f}; pImageCG = CGImageMaskCreate( @@ -173,7 +173,7 @@ void CFX_Font::ReleasePlatformResource() { static_cast(CFX_GEModule::Get()->GetPlatformData()) ->m_quartz2d; quartz2d.DestroyFont(m_pPlatformFont); - m_pPlatformFont = NULL; + m_pPlatformFont = nullptr; } } diff --git a/core/fxge/apple/fx_mac_imp.cpp b/core/fxge/apple/fx_mac_imp.cpp index 16dd4aef66..a0f2acb370 100644 --- a/core/fxge/apple/fx_mac_imp.cpp +++ b/core/fxge/apple/fx_mac_imp.cpp @@ -74,7 +74,7 @@ void* CFX_MacFontInfo::MapFont(int weight, return GetFont("Courier New"); } if (charset == FXFONT_ANSI_CHARSET || charset == FXFONT_SYMBOL_CHARSET) { - return NULL; + return nullptr; } switch (charset) { case FXFONT_SHIFTJIS_CHARSET: @@ -93,7 +93,7 @@ void* CFX_MacFontInfo::MapFont(int weight, if (it != m_FontList.end()) return it->second; - return NULL; + return nullptr; } std::unique_ptr IFX_SystemFontInfo::CreateDefault( @@ -111,6 +111,6 @@ void CFX_GEModule::InitPlatform() { } void CFX_GEModule::DestroyPlatform() { delete (CApplePlatform*)m_pPlatformData; - m_pPlatformData = NULL; + m_pPlatformData = nullptr; } #endif diff --git a/core/fxge/apple/fx_quartz_device.cpp b/core/fxge/apple/fx_quartz_device.cpp index 6fc22ffdf4..154910b69f 100644 --- a/core/fxge/apple/fx_quartz_device.cpp +++ b/core/fxge/apple/fx_quartz_device.cpp @@ -24,7 +24,7 @@ void* CQuartz2D::createGraphics(CFX_DIBitmap* pBitmap) { if (!pBitmap) { - return NULL; + return nullptr; } CGBitmapInfo bmpInfo = kCGBitmapByteOrder32Little; switch (pBitmap->GetFormat()) { @@ -33,7 +33,7 @@ void* CQuartz2D::createGraphics(CFX_DIBitmap* pBitmap) { break; case FXDIB_Argb: default: - return NULL; + return nullptr; } CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); CGContextRef context = CGBitmapContextCreate( @@ -48,11 +48,11 @@ void CQuartz2D::destroyGraphics(void* graphics) { } } void* CQuartz2D::CreateFont(const uint8_t* pFontData, uint32_t dwFontSize) { - CGDataProviderRef pDataProvider = - CGDataProviderCreateWithData(NULL, pFontData, (size_t)dwFontSize, NULL); - if (NULL == pDataProvider) { - return NULL; - } + CGDataProviderRef pDataProvider = CGDataProviderCreateWithData( + nullptr, pFontData, (size_t)dwFontSize, nullptr); + if (!pDataProvider) + return nullptr; + CGFontRef pCGFont = CGFontCreateWithDataProvider(pDataProvider); CGDataProviderRelease(pDataProvider); return pCGFont; @@ -124,7 +124,7 @@ void CQuartz2D::restoreGraphicsState(void* graphics) { } static CGContextRef createContextWithBitmap(CFX_DIBitmap* pBitmap) { if (!pBitmap || pBitmap->IsCmykImage() || pBitmap->GetBPP() < 32) { - return NULL; + return nullptr; } CGBitmapInfo bitmapInfo = kCGBitmapByteOrder32Little; if (pBitmap->HasAlpha()) { @@ -476,9 +476,9 @@ FX_BOOL CFX_QuartzDeviceDriver::GetDIBits(CFX_DIBitmap* bitmap, pt.x *= FXSYS_fabs(ctm.a); pt.y *= FXSYS_fabs(ctm.d); CGImageRef image = CGBitmapContextCreateImage(m_context); - if (NULL == image) { + if (!image) return FALSE; - } + CGFloat width = (CGFloat)bitmap->GetWidth(); CGFloat height = (CGFloat)bitmap->GetHeight(); if (width + pt.x > m_width) { @@ -547,26 +547,26 @@ FX_BOOL CFX_QuartzDeviceDriver::SetDIBits(const CFX_DIBSource* pBitmap, CGSizeMake(pBitmap->GetWidth() / scale_x, pBitmap->GetHeight() / scale_y); rect_usr = CGRectOffset(rect_usr, -src_left, -src_top); CG_SetImageTransform(dest_left, dest_top, src_width, src_height, &rect_usr); - CFX_DIBitmap* pBitmap1 = NULL; + CFX_DIBitmap* pBitmap1 = nullptr; if (pBitmap->IsAlphaMask()) { if (pBitmap->GetBuffer()) { pBitmap1 = (CFX_DIBitmap*)pBitmap; } else { pBitmap1 = pBitmap->Clone(); } - if (NULL == pBitmap1) { + if (!pBitmap1) { RestoreState(false); return FALSE; } CGDataProviderRef pBitmapProvider = CGDataProviderCreateWithData( - NULL, pBitmap1->GetBuffer(), - pBitmap1->GetPitch() * pBitmap1->GetHeight(), NULL); + nullptr, pBitmap1->GetBuffer(), + pBitmap1->GetPitch() * pBitmap1->GetHeight(), nullptr); CGColorSpaceRef pColorSpace = CGColorSpaceCreateDeviceGray(); CGBitmapInfo bitmapInfo = kCGImageAlphaNone | kCGBitmapByteOrderDefault; CGImageRef pImage = CGImageCreate( pBitmap1->GetWidth(), pBitmap1->GetHeight(), pBitmap1->GetBPP(), pBitmap1->GetBPP(), pBitmap1->GetPitch(), pColorSpace, bitmapInfo, - pBitmapProvider, NULL, true, kCGRenderingIntentDefault); + pBitmapProvider, nullptr, true, kCGRenderingIntentDefault); CGContextClipToMask(m_context, rect_usr, pImage); CGContextSetRGBFillColor(m_context, FXARGB_R(argb) / 255.f, FXARGB_G(argb) / 255.f, FXARGB_B(argb) / 255.f, @@ -590,7 +590,7 @@ FX_BOOL CFX_QuartzDeviceDriver::SetDIBits(const CFX_DIBSource* pBitmap, pBitmap1 = pBitmap->Clone(); } } - if (NULL == pBitmap1) { + if (!pBitmap1) { RestoreState(false); return FALSE; } @@ -665,26 +665,26 @@ FX_BOOL CFX_QuartzDeviceDriver::StretchDIBits(const CFX_DIBSource* pBitmap, CGContextSetInterpolationQuality(m_context, kCGInterpolationMedium); } CG_SetImageTransform(dest_left, dest_top, dest_width, dest_height); - CFX_DIBitmap* pBitmap1 = NULL; + CFX_DIBitmap* pBitmap1 = nullptr; if (pBitmap->IsAlphaMask()) { if (pBitmap->GetBuffer()) { pBitmap1 = (CFX_DIBitmap*)pBitmap; } else { pBitmap1 = pBitmap->Clone(); } - if (NULL == pBitmap1) { + if (!pBitmap1) { RestoreState(false); return FALSE; } CGDataProviderRef pBitmapProvider = CGDataProviderCreateWithData( - NULL, pBitmap1->GetBuffer(), - pBitmap1->GetPitch() * pBitmap1->GetHeight(), NULL); + nullptr, pBitmap1->GetBuffer(), + pBitmap1->GetPitch() * pBitmap1->GetHeight(), nullptr); CGColorSpaceRef pColorSpace = CGColorSpaceCreateDeviceGray(); CGBitmapInfo bitmapInfo = kCGImageAlphaNone | kCGBitmapByteOrderDefault; CGImageRef pImage = CGImageCreate( pBitmap1->GetWidth(), pBitmap1->GetHeight(), pBitmap1->GetBPP(), pBitmap1->GetBPP(), pBitmap1->GetPitch(), pColorSpace, bitmapInfo, - pBitmapProvider, NULL, true, kCGRenderingIntentDefault); + pBitmapProvider, nullptr, true, kCGRenderingIntentDefault); CGContextClipToMask(m_context, rect, pImage); CGContextSetRGBFillColor(m_context, FXARGB_R(argb) / 255.f, FXARGB_G(argb) / 255.f, FXARGB_B(argb) / 255.f, @@ -708,7 +708,7 @@ FX_BOOL CFX_QuartzDeviceDriver::StretchDIBits(const CFX_DIBSource* pBitmap, pBitmap1 = pBitmap->Clone(); } } - if (NULL == pBitmap1) { + if (!pBitmap1) { RestoreState(false); return FALSE; } @@ -817,7 +817,7 @@ FX_BOOL CFX_QuartzDeviceDriver::DrawDeviceText(int nChars, uint32_t color, int alpha_flag, void* pIccTransform) { - if (NULL == pFont || NULL == m_context) + if (!pFont || !m_context) return FALSE; FX_BOOL bBold = pFont->IsBold(); if (!bBold && pFont->GetSubstFont() && @@ -832,8 +832,9 @@ FX_BOOL CFX_QuartzDeviceDriver::DrawDeviceText(int nChars, while (i < nChars) { if (pCharPos[i].m_bGlyphAdjust || font_size < 0) { if (i > 0) { - ret = CG_DrawGlypRun(i, pCharPos, pFont, pCache, NULL, pObject2Device, - font_size, color, alpha_flag, pIccTransform); + ret = + CG_DrawGlypRun(i, pCharPos, pFont, pCache, nullptr, pObject2Device, + font_size, color, alpha_flag, pIccTransform); if (!ret) { RestoreState(false); return ret; @@ -865,7 +866,7 @@ FX_BOOL CFX_QuartzDeviceDriver::DrawDeviceText(int nChars, } } if (i > 0) { - ret = CG_DrawGlypRun(i, pCharPos, pFont, pCache, NULL, pObject2Device, + ret = CG_DrawGlypRun(i, pCharPos, pFont, pCache, nullptr, pObject2Device, font_size, color, alpha_flag, pIccTransform); } RestoreState(false); @@ -874,9 +875,9 @@ FX_BOOL CFX_QuartzDeviceDriver::DrawDeviceText(int nChars, void CFX_QuartzDeviceDriver::setStrokeInfo(const CFX_GraphStateData* graphState, FX_ARGB argb, FX_FLOAT lineWidth) { - if (NULL == graphState) { + if (!graphState) return; - } + CGContextSetLineWidth(m_context, lineWidth); CGLineCap cap; switch (graphState->m_LineCap) { @@ -989,9 +990,9 @@ void CFX_QuartzDeviceDriver::CG_SetImageTransform(int dest_left, } } void CFX_QuartzDeviceDriver::ClearDriver() { - if (NULL == m_context) { + if (!m_context) return; - } + for (int i = 0; i < m_saveCount; ++i) { CGContextRestoreGState(m_context); } @@ -1002,7 +1003,7 @@ void CFX_QuartzDeviceDriver::ClearDriver() { } CFX_QuartzDevice::CFX_QuartzDevice() { m_bOwnedBitmap = FALSE; - m_pContext = NULL; + m_pContext = nullptr; } CFX_QuartzDevice::~CFX_QuartzDevice() { if (m_pContext) { @@ -1029,9 +1030,9 @@ FX_BOOL CFX_QuartzDevice::Attach(CGContextRef context, int32_t nDeviceClass) { FX_BOOL CFX_QuartzDevice::Attach(CFX_DIBitmap* pBitmap) { SetBitmap(pBitmap); m_pContext = createContextWithBitmap(pBitmap); - if (NULL == m_pContext) { + if (!m_pContext) return FALSE; - } + IFX_RenderDeviceDriver* pDriver = new CFX_QuartzDeviceDriver(m_pContext, FXDC_DISPLAY); SetDeviceDriver(pDriver); diff --git a/core/fxge/dib/dib_int.h b/core/fxge/dib/dib_int.h index ebb1ddc0ed..415362d51d 100644 --- a/core/fxge/dib/dib_int.h +++ b/core/fxge/dib/dib_int.h @@ -42,10 +42,10 @@ struct PixelWeight { }; class CWeightTable { public: - CWeightTable() { m_pWeightTables = NULL; } + CWeightTable() { m_pWeightTables = nullptr; } ~CWeightTable() { FX_Free(m_pWeightTables); - m_pWeightTables = NULL; + m_pWeightTables = nullptr; } void Calc(int dest_len, int dest_min, diff --git a/core/fxge/dib/fx_dib_convert.cpp b/core/fxge/dib/fx_dib_convert.cpp index 8937816531..a1e6bb3e18 100644 --- a/core/fxge/dib/fx_dib_convert.cpp +++ b/core/fxge/dib/fx_dib_convert.cpp @@ -81,9 +81,9 @@ void _Obtain_Pal(uint32_t* aLut, } CFX_Palette::CFX_Palette() { - m_pPalette = NULL; - m_cLut = NULL; - m_aLut = NULL; + m_pPalette = nullptr; + m_cLut = nullptr; + m_aLut = nullptr; m_lut = 0; } CFX_Palette::~CFX_Palette() { @@ -102,9 +102,9 @@ FX_BOOL CFX_Palette::BuildPalette(const CFX_DIBSource* pBitmap) { int width = pBitmap->GetWidth(); int height = pBitmap->GetHeight(); FX_Free(m_cLut); - m_cLut = NULL; + m_cLut = nullptr; FX_Free(m_aLut); - m_aLut = NULL; + m_aLut = nullptr; m_cLut = FX_Alloc(uint32_t, 4096); m_aLut = FX_Alloc(uint32_t, 4096); int row, col; @@ -821,7 +821,7 @@ FX_BOOL ConvertBuffer(FXDIB_Format dest_format, FXDIB_Format src_format = pSrcBitmap->GetFormat(); if (!CFX_GEModule::Get()->GetCodecModule() || !CFX_GEModule::Get()->GetCodecModule()->GetIccModule()) { - pIccTransform = NULL; + pIccTransform = nullptr; } switch (dest_format) { case FXDIB_Invalid: @@ -958,26 +958,26 @@ CFX_DIBitmap* CFX_DIBSource::CloneConvert(FXDIB_Format dest_format, if (pClip) { CFX_DIBitmap* pClone = Clone(pClip); if (!pClone) { - return NULL; + return nullptr; } if (!pClone->ConvertFormat(dest_format, pIccTransform)) { delete pClone; - return NULL; + return nullptr; } return pClone; } CFX_DIBitmap* pClone = new CFX_DIBitmap; if (!pClone->Create(m_Width, m_Height, dest_format)) { delete pClone; - return NULL; + return nullptr; } FX_BOOL ret = TRUE; - CFX_DIBitmap* pSrcAlpha = NULL; + CFX_DIBitmap* pSrcAlpha = nullptr; if (HasAlpha()) { pSrcAlpha = (GetFormat() == FXDIB_Argb) ? GetAlphaMask() : m_pAlphaMask; if (!pSrcAlpha) { delete pClone; - return NULL; + return nullptr; } } if (dest_format & 0x0200) { @@ -990,24 +990,24 @@ CFX_DIBitmap* CFX_DIBSource::CloneConvert(FXDIB_Format dest_format, } if (pSrcAlpha && pSrcAlpha != m_pAlphaMask) { delete pSrcAlpha; - pSrcAlpha = NULL; + pSrcAlpha = nullptr; } if (!ret) { delete pClone; - return NULL; + return nullptr; } - uint32_t* pal_8bpp = NULL; + uint32_t* pal_8bpp = nullptr; ret = ConvertBuffer(dest_format, pClone->GetBuffer(), pClone->GetPitch(), m_Width, m_Height, this, 0, 0, pal_8bpp, pIccTransform); if (!ret) { FX_Free(pal_8bpp); delete pClone; - return NULL; + return nullptr; } if (pal_8bpp) { pClone->CopyPalette(pal_8bpp); FX_Free(pal_8bpp); - pal_8bpp = NULL; + pal_8bpp = nullptr; } return pClone; } @@ -1040,7 +1040,7 @@ FX_BOOL CFX_DIBitmap::ConvertFormat(FXDIB_Format dest_format, if (!dest_buf) { return FALSE; } - CFX_DIBitmap* pAlphaMask = NULL; + CFX_DIBitmap* pAlphaMask = nullptr; if (dest_format == FXDIB_Argb) { FXSYS_memset(dest_buf, 0xff, dest_pitch * m_Height + 4); if (m_pAlphaMask) { @@ -1067,14 +1067,14 @@ FX_BOOL CFX_DIBitmap::ConvertFormat(FXDIB_Format dest_format, return FALSE; } pAlphaMask = m_pAlphaMask; - m_pAlphaMask = NULL; + m_pAlphaMask = nullptr; } else { pAlphaMask = m_pAlphaMask; } } } FX_BOOL ret = FALSE; - uint32_t* pal_8bpp = NULL; + uint32_t* pal_8bpp = nullptr; ret = ConvertBuffer(dest_format, dest_buf, dest_pitch, m_Width, m_Height, this, 0, 0, pal_8bpp, pIccTransform); if (!ret) { diff --git a/core/fxge/dib/fx_dib_engine.cpp b/core/fxge/dib/fx_dib_engine.cpp index 3bdff23f1e..6df51d27c0 100644 --- a/core/fxge/dib/fx_dib_engine.cpp +++ b/core/fxge/dib/fx_dib_engine.cpp @@ -40,7 +40,7 @@ void CWeightTable::Calc(int dest_len, int src_max, int flags) { FX_Free(m_pWeightTables); - m_pWeightTables = NULL; + m_pWeightTables = nullptr; double scale, base; scale = (FX_FLOAT)src_len / (FX_FLOAT)dest_len; if (dest_len < 0) { @@ -249,9 +249,9 @@ CStretchEngine::CStretchEngine(IFX_ScanlineComposer* pDestBitmap, m_pDestBitmap = pDestBitmap; m_DestWidth = dest_width; m_DestHeight = dest_height; - m_pInterBuf = NULL; - m_pExtraAlphaBuf = NULL; - m_pDestMaskScanline = NULL; + m_pInterBuf = nullptr; + m_pExtraAlphaBuf = nullptr; + m_pDestMaskScanline = nullptr; m_DestClip = clip_rect; uint32_t size = clip_rect.Width(); if (size && m_DestBpp > (int)(INT_MAX / size)) { @@ -272,7 +272,7 @@ CStretchEngine::CStretchEngine(IFX_ScanlineComposer* pDestBitmap, } m_InterPitch = (m_DestClip.Width() * m_DestBpp + 31) / 32 * 4; m_ExtraMaskPitch = (m_DestClip.Width() * 8 + 31) / 32 * 4; - m_pInterBuf = NULL; + m_pInterBuf = nullptr; m_pSource = pSrcBitmap; m_SrcWidth = pSrcBitmap->GetWidth(); m_SrcHeight = pSrcBitmap->GetHeight(); @@ -408,8 +408,8 @@ FX_BOOL CStretchEngine::ContinueStretchHorz(IFX_Pause* pPause) { const uint8_t* src_scan = m_pSource->GetScanline(m_CurRow); uint8_t* dest_scan = m_pInterBuf + (m_CurRow - m_SrcClip.top) * m_InterPitch; - const uint8_t* src_scan_mask = NULL; - uint8_t* dest_scan_mask = NULL; + const uint8_t* src_scan_mask = nullptr; + uint8_t* dest_scan_mask = nullptr; if (m_pExtraAlphaBuf) { src_scan_mask = m_pSource->m_pAlphaMask->GetScanline(m_CurRow); dest_scan_mask = @@ -718,7 +718,7 @@ void CStretchEngine::StretchVert() { for (int col = m_DestClip.left; col < m_DestClip.right; col++) { unsigned char* src_scan = m_pInterBuf + (col - m_DestClip.left) * DestBpp; - unsigned char* src_scan_mask = NULL; + unsigned char* src_scan_mask = nullptr; if (m_DestFormat != FXDIB_Argb) { src_scan_mask = m_pExtraAlphaBuf + (col - m_DestClip.left); } diff --git a/core/fxge/dib/fx_dib_main.cpp b/core/fxge/dib/fx_dib_main.cpp index 896551401a..f4ea49b58f 100644 --- a/core/fxge/dib/fx_dib_main.cpp +++ b/core/fxge/dib/fx_dib_main.cpp @@ -48,8 +48,8 @@ CFX_DIBSource::CFX_DIBSource() { m_AlphaFlag = 0; m_Width = m_Height = 0; m_Pitch = 0; - m_pPalette = NULL; - m_pAlphaMask = NULL; + m_pPalette = nullptr; + m_pAlphaMask = nullptr; } CFX_DIBSource::~CFX_DIBSource() { @@ -58,7 +58,7 @@ CFX_DIBSource::~CFX_DIBSource() { } uint8_t* CFX_DIBSource::GetBuffer() const { - return NULL; + return nullptr; } FX_BOOL CFX_DIBSource::SkipToScanline(int line, IFX_Pause* pPause) const { @@ -67,8 +67,8 @@ FX_BOOL CFX_DIBSource::SkipToScanline(int line, IFX_Pause* pPause) const { CFX_DIBitmap::CFX_DIBitmap() { m_bExtBuf = FALSE; - m_pBuffer = NULL; - m_pPalette = NULL; + m_pBuffer = nullptr; + m_pPalette = nullptr; } #define _MAX_OOM_LIMIT_ 12000000 @@ -77,7 +77,7 @@ FX_BOOL CFX_DIBitmap::Create(int width, FXDIB_Format format, uint8_t* pBuffer, int pitch) { - m_pBuffer = NULL; + m_pBuffer = nullptr; m_bpp = (uint8_t)format; m_AlphaFlag = (uint8_t)(format >> 8); m_Width = m_Height = m_Pitch = 0; @@ -117,7 +117,7 @@ FX_BOOL CFX_DIBitmap::Create(int width, if (!ret) { if (!m_bExtBuf) { FX_Free(m_pBuffer); - m_pBuffer = NULL; + m_pBuffer = nullptr; m_Width = m_Height = m_Pitch = 0; return FALSE; } @@ -181,13 +181,13 @@ CFX_DIBitmap* CFX_DIBSource::Clone(const FX_RECT* pClip) const { if (pClip) { rect.Intersect(*pClip); if (rect.IsEmpty()) { - return NULL; + return nullptr; } } CFX_DIBitmap* pNewBitmap = new CFX_DIBitmap; if (!pNewBitmap->Create(rect.Width(), rect.Height(), GetFormat())) { delete pNewBitmap; - return NULL; + return nullptr; } pNewBitmap->CopyPalette(m_pPalette); pNewBitmap->CopyAlphaMask(m_pAlphaMask, pClip); @@ -249,7 +249,7 @@ FX_BOOL CFX_DIBSource::BuildAlphaMask() { m_pAlphaMask = new CFX_DIBitmap; if (!m_pAlphaMask->Create(m_Width, m_Height, FXDIB_8bppMask)) { delete m_pAlphaMask; - m_pAlphaMask = NULL; + m_pAlphaMask = nullptr; return FALSE; } FXSYS_memset(m_pAlphaMask->GetBuffer(), 0xff, @@ -410,7 +410,7 @@ FX_BOOL CFX_DIBitmap::TransferBitmap(int dest_left, return FALSE; } GetOverlapRect(dest_left, dest_top, width, height, pSrcBitmap->GetWidth(), - pSrcBitmap->GetHeight(), src_left, src_top, NULL); + pSrcBitmap->GetHeight(), src_left, src_top, nullptr); if (width == 0 || height == 0) { return TRUE; } @@ -451,7 +451,7 @@ FX_BOOL CFX_DIBitmap::TransferBitmap(int dest_left, } uint8_t* dest_buf = m_pBuffer + dest_top * m_Pitch + dest_left * GetBPP() / 8; - uint32_t* d_plt = NULL; + uint32_t* d_plt = nullptr; if (!ConvertBuffer(dest_format, dest_buf, m_Pitch, width, height, pSrcBitmap, src_left, src_top, d_plt, pIccTransform)) { return FALSE; @@ -478,7 +478,7 @@ FX_BOOL CFX_DIBitmap::TransferMask(int dest_left, return FALSE; } GetOverlapRect(dest_left, dest_top, width, height, pMask->GetWidth(), - pMask->GetHeight(), src_left, src_top, NULL); + pMask->GetHeight(), src_left, src_top, nullptr); if (width == 0 || height == 0) { return TRUE; } @@ -571,7 +571,7 @@ FX_BOOL CFX_DIBitmap::TransferMask(int dest_left, void CFX_DIBSource::CopyPalette(const uint32_t* pSrc, uint32_t size) { if (!pSrc || GetBPP() > 8) { FX_Free(m_pPalette); - m_pPalette = NULL; + m_pPalette = nullptr; } else { uint32_t pal_size = 1 << GetBPP(); if (!m_pPalette) { @@ -608,13 +608,13 @@ CFX_DIBitmap* CFX_DIBSource::GetAlphaMask(const FX_RECT* pClip) const { if (pClip) { rect.Intersect(*pClip); if (rect.IsEmpty()) { - return NULL; + return nullptr; } } CFX_DIBitmap* pMask = new CFX_DIBitmap; if (!pMask->Create(rect.Width(), rect.Height(), FXDIB_8bppMask)) { delete pMask; - return NULL; + return nullptr; } for (int row = rect.top; row < rect.bottom; row++) { const uint8_t* src_scan = GetScanline(row) + rect.left * 4 + 3; @@ -760,7 +760,7 @@ FX_BOOL CFX_DIBitmap::LoadChannel(FXDIB_Channel destChannel, } } if (pSrcClone != pSrcBitmap) { - pSrcClone->m_pAlphaMask = NULL; + pSrcClone->m_pAlphaMask = nullptr; delete pSrcClone; } pSrcClone = pAlphaMask; @@ -1381,7 +1381,7 @@ CFX_DIBitmap* CFX_DIBSource::FlipImage(FX_BOOL bXFlip, FX_BOOL bYFlip) const { CFX_DIBitmap* pFlipped = new CFX_DIBitmap; if (!pFlipped->Create(m_Width, m_Height, GetFormat())) { delete pFlipped; - return NULL; + return nullptr; } pFlipped->CopyPalette(m_pPalette); uint8_t* pDestBuffer = pFlipped->GetBuffer(); @@ -1449,13 +1449,13 @@ CFX_DIBitmap* CFX_DIBSource::FlipImage(FX_BOOL bXFlip, FX_BOOL bYFlip) const { return pFlipped; } CFX_DIBExtractor::CFX_DIBExtractor(const CFX_DIBSource* pSrc) { - m_pBitmap = NULL; + m_pBitmap = nullptr; if (pSrc->GetBuffer()) { m_pBitmap = new CFX_DIBitmap; if (!m_pBitmap->Create(pSrc->GetWidth(), pSrc->GetHeight(), pSrc->GetFormat(), pSrc->GetBuffer())) { delete m_pBitmap; - m_pBitmap = NULL; + m_pBitmap = nullptr; return; } m_pBitmap->CopyPalette(pSrc->GetPalette()); @@ -1468,8 +1468,8 @@ CFX_DIBExtractor::~CFX_DIBExtractor() { delete m_pBitmap; } CFX_FilteredDIB::CFX_FilteredDIB() { - m_pScanline = NULL; - m_pSrc = NULL; + m_pScanline = nullptr; + m_pSrc = nullptr; } CFX_FilteredDIB::~CFX_FilteredDIB() { if (m_bAutoDropSrc) { @@ -1506,7 +1506,7 @@ void CFX_FilteredDIB::DownSampleScanline(int line, } CFX_ImageRenderer::CFX_ImageRenderer() { m_Status = 0; - m_pTransformer = NULL; + m_pTransformer = nullptr; m_bRgbByteOrder = FALSE; m_BlendType = FXDIB_BLEND_NORMAL; } diff --git a/core/fxge/dib/fx_dib_transform.cpp b/core/fxge/dib/fx_dib_transform.cpp index 914ca58013..82b9cf781f 100644 --- a/core/fxge/dib/fx_dib_transform.cpp +++ b/core/fxge/dib/fx_dib_transform.cpp @@ -182,13 +182,13 @@ CFX_DIBitmap* CFX_DIBSource::SwapXY(FX_BOOL bXFlip, dest_clip.Intersect(*pDestClip); } if (dest_clip.IsEmpty()) { - return NULL; + return nullptr; } CFX_DIBitmap* pTransBitmap = new CFX_DIBitmap; int result_height = dest_clip.Height(), result_width = dest_clip.Width(); if (!pTransBitmap->Create(result_width, result_height, GetFormat())) { delete pTransBitmap; - return NULL; + return nullptr; } pTransBitmap->CopyPalette(m_pPalette); int dest_pitch = pTransBitmap->GetPitch(); diff --git a/core/fxge/freetype/fx_freetype.cpp b/core/fxge/freetype/fx_freetype.cpp index f60d0c64d0..295513d8b3 100644 --- a/core/fxge/freetype/fx_freetype.cpp +++ b/core/fxge/freetype/fx_freetype.cpp @@ -136,7 +136,7 @@ int FXFT_unicode_from_adobe_name(const char* glyph_name) { /* find variants like `A.swash', `e.final', etc. */ { const char* p = glyph_name; - const char* dot = NULL; + const char* dot = nullptr; for (; *p; p++) { if (*p == '.' && p > glyph_name) { diff --git a/core/fxge/ge/fx_ge.cpp b/core/fxge/ge/fx_ge.cpp index 9e45dc7434..360a4eb417 100644 --- a/core/fxge/ge/fx_ge.cpp +++ b/core/fxge/ge/fx_ge.cpp @@ -8,20 +8,20 @@ #include "core/fxge/ge/fx_text_int.h" -static CFX_GEModule* g_pGEModule = NULL; +static CFX_GEModule* g_pGEModule = nullptr; CFX_GEModule::CFX_GEModule(const char** pUserFontPaths) { - m_pFontCache = NULL; - m_pFontMgr = NULL; - m_FTLibrary = NULL; - m_pCodecModule = NULL; - m_pPlatformData = NULL; + m_pFontCache = nullptr; + m_pFontMgr = nullptr; + m_FTLibrary = nullptr; + m_pCodecModule = nullptr; + m_pPlatformData = nullptr; m_pUserFontPaths = pUserFontPaths; } CFX_GEModule::~CFX_GEModule() { delete m_pFontCache; - m_pFontCache = NULL; + m_pFontCache = nullptr; delete m_pFontMgr; - m_pFontMgr = NULL; + m_pFontMgr = nullptr; DestroyPlatform(); } CFX_GEModule* CFX_GEModule::Get() { @@ -38,7 +38,7 @@ void CFX_GEModule::Use(CFX_GEModule* pModule) { } void CFX_GEModule::Destroy() { delete g_pGEModule; - g_pGEModule = NULL; + g_pGEModule = nullptr; } CFX_FontCache* CFX_GEModule::GetFontCache() { if (!m_pFontCache) { diff --git a/core/fxge/ge/fx_ge_device.cpp b/core/fxge/ge/fx_ge_device.cpp index 96e0e55cd1..7763d91363 100644 --- a/core/fxge/ge/fx_ge_device.cpp +++ b/core/fxge/ge/fx_ge_device.cpp @@ -7,8 +7,8 @@ #include "core/fxge/include/fx_ge.h" CFX_RenderDevice::CFX_RenderDevice() { - m_pDeviceDriver = NULL; - m_pBitmap = NULL; + m_pDeviceDriver = nullptr; + m_pBitmap = nullptr; } CFX_RenderDevice::~CFX_RenderDevice() { delete m_pDeviceDriver; @@ -193,7 +193,7 @@ FX_BOOL CFX_RenderDevice::DrawPathWithBlend( if (bThin) { strokecolor = (((fill_alpha >> 2) << 24) | (strokecolor & 0x00ffffff)); } - CFX_Matrix* pMatrix = NULL; + CFX_Matrix* pMatrix = nullptr; if (pObject2Device && !pObject2Device->IsIdentity()) { pMatrix = (CFX_Matrix*)pObject2Device; } @@ -255,7 +255,7 @@ FX_BOOL CFX_RenderDevice::DrawFillStrokePath( bitmap.Clear(0); Backdrop.Copy(&bitmap); } else { - if (!m_pDeviceDriver->GetDIBits(&bitmap, rect.left, rect.top, NULL)) { + if (!m_pDeviceDriver->GetDIBits(&bitmap, rect.left, rect.top, nullptr)) { return FALSE; } Backdrop.Copy(&bitmap); diff --git a/core/fxge/ge/fx_ge_font.cpp b/core/fxge/ge/fx_ge_font.cpp index ba53be7ab5..22b7aa38bf 100644 --- a/core/fxge/ge/fx_ge_font.cpp +++ b/core/fxge/ge/fx_ge_font.cpp @@ -39,30 +39,30 @@ FXFT_Face FT_LoadFont(const uint8_t* pData, int size) { } // namespace CFX_Font::CFX_Font() { - m_pSubstFont = NULL; - m_Face = NULL; + m_pSubstFont = nullptr; + m_Face = nullptr; m_bEmbedded = FALSE; m_bVertical = FALSE; - m_pFontData = NULL; - m_pFontDataAllocation = NULL; + m_pFontData = nullptr; + m_pFontDataAllocation = nullptr; m_dwSize = 0; - m_pGsubData = NULL; - m_pPlatformFont = NULL; - m_pPlatformFontCollection = NULL; - m_pDwFont = NULL; - m_hHandle = NULL; + m_pGsubData = nullptr; + m_pPlatformFont = nullptr; + m_pPlatformFontCollection = nullptr; + m_pDwFont = nullptr; + m_hHandle = nullptr; m_bDwLoaded = FALSE; #ifdef PDF_ENABLE_XFA m_bLogic = FALSE; - m_pOwnedStream = NULL; + m_pOwnedStream = nullptr; #endif // PDF_ENABLE_XFA } #ifdef PDF_ENABLE_XFA FX_BOOL CFX_Font::LoadClone(const CFX_Font* pFont) { - if (pFont == NULL) { + if (!pFont) return FALSE; - } + m_bLogic = TRUE; if (pFont->m_pSubstFont) { m_pSubstFont = new CFX_SubstFont; @@ -124,7 +124,7 @@ CFX_Font::~CFX_Font() { } void CFX_Font::DeleteFace() { FXFT_Done_Face(m_Face); - m_Face = NULL; + m_Face = nullptr; } void CFX_Font::LoadSubst(const CFX_ByteString& face_name, FX_BOOL bTrueType, @@ -142,7 +142,7 @@ void CFX_Font::LoadSubst(const CFX_ByteString& face_name, #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ if (m_pSubstFont->m_ExtHandle) { m_pPlatformFont = m_pSubstFont->m_ExtHandle; - m_pSubstFont->m_ExtHandle = NULL; + m_pSubstFont->m_ExtHandle = nullptr; } #endif if (m_Face) { @@ -174,7 +174,7 @@ FX_BOOL _LoadFile(FXFT_Library library, FXFT_Stream* stream, int32_t faceIndex = 0) { FXFT_Stream stream1 = (FXFT_Stream)FX_Alloc(uint8_t, sizeof(FXFT_StreamRec)); - stream1->base = NULL; + stream1->base = nullptr; stream1->size = (unsigned long)pFile->GetSize(); stream1->pos = 0; stream1->descriptor.pointer = pFile; @@ -239,7 +239,7 @@ FX_BOOL CFX_Font::LoadEmbedded(const uint8_t* data, uint32_t size) { m_pFontData = m_pFontDataAllocation; m_bEmbedded = TRUE; m_dwSize = size; - return m_Face != NULL; + return !!m_Face; } FX_BOOL CFX_Font::IsTTFont() const { @@ -534,6 +534,6 @@ CFX_UnicodeEncodingEx* FX_CreateFontEncodingEx(CFX_Font* pFont, return pFontEncoding; } } - return NULL; + return nullptr; } #endif // PDF_ENABLE_XFA diff --git a/core/fxge/ge/fx_ge_fontmap.cpp b/core/fxge/ge/fx_ge_fontmap.cpp index 83690c7181..fa53898ecc 100644 --- a/core/fxge/ge/fx_ge_fontmap.cpp +++ b/core/fxge/ge/fx_ge_fontmap.cpp @@ -336,7 +336,7 @@ int32_t GetStyleType(const CFX_ByteString& bsStyle, FX_BOOL bRevert) { return -1; } int iSize = sizeof(g_FontStyles) / sizeof(FX_FontStyle); - const FX_FontStyle* pStyle = NULL; + const FX_FontStyle* pStyle = nullptr; for (int i = iSize - 1; i >= 0; --i) { pStyle = g_FontStyles + i; if (!pStyle || pStyle->len > iLen) { @@ -410,7 +410,7 @@ int32_t GetSimilarValue(int weight, } // namespace CFX_SubstFont::CFX_SubstFont() { - m_ExtHandle = NULL; + m_ExtHandle = nullptr; m_Charset = 0; m_SubstFlags = 0; m_Weight = 0; @@ -517,7 +517,7 @@ FXFT_Face CFX_FontMgr::AddCachedFace(const CFX_ByteString& face_name, int face_index) { CTTFontDesc* pFontDesc = new CTTFontDesc; pFontDesc->m_Type = 1; - pFontDesc->m_SingleFace.m_pFace = NULL; + pFontDesc->m_SingleFace.m_pFace = nullptr; pFontDesc->m_SingleFace.m_bBold = weight; pFontDesc->m_SingleFace.m_bItalic = bItalic; pFontDesc->m_pFontData = pData; @@ -529,12 +529,12 @@ FXFT_Face CFX_FontMgr::AddCachedFace(const CFX_ByteString& face_name, &pFontDesc->m_SingleFace.m_pFace); if (ret) { delete pFontDesc; - return NULL; + return nullptr; } ret = FXFT_Set_Pixel_Sizes(pFontDesc->m_SingleFace.m_pFace, 64, 64); if (ret) { delete pFontDesc; - return NULL; + return nullptr; } m_FaceMap[KeyNameFromFace(face_name, weight, bItalic)] = pFontDesc; return pFontDesc->m_SingleFace.m_pFace; @@ -587,7 +587,7 @@ FXFT_Face CFX_FontMgr::AddCachedTTCFace(int ttc_size, pFontDesc->m_Type = 2; pFontDesc->m_pFontData = pData; for (int i = 0; i < 16; i++) { - pFontDesc->m_TTCFace.m_pFaces[i] = NULL; + pFontDesc->m_TTCFace.m_pFaces[i] = nullptr; } pFontDesc->m_RefCount++; m_FaceMap[KeyNameFromSize(ttc_size, checksum)] = pFontDesc; @@ -815,7 +815,7 @@ FXFT_Face CFX_FontMapper::UseInternalSubst(CFX_SubstFont* pSubstFont, if (m_FoxitFaces[iBaseFont]) { return m_FoxitFaces[iBaseFont]; } - const uint8_t* pFontData = NULL; + const uint8_t* pFontData = nullptr; uint32_t size = 0; if (m_pFontMgr->GetBuiltinFont(iBaseFont, &pFontData, &size)) { m_FoxitFaces[iBaseFont] = m_pFontMgr->GetFixedFace(pFontData, size, 0); @@ -833,7 +833,7 @@ FXFT_Face CFX_FontMapper::UseInternalSubst(CFX_SubstFont* pSubstFont, if (m_MMFaces[1]) { return m_MMFaces[1]; } - const uint8_t* pFontData = NULL; + const uint8_t* pFontData = nullptr; uint32_t size = 0; m_pFontMgr->GetBuiltinFont(14, &pFontData, &size); m_MMFaces[1] = m_pFontMgr->GetFixedFace(pFontData, size, 0); @@ -843,7 +843,7 @@ FXFT_Face CFX_FontMapper::UseInternalSubst(CFX_SubstFont* pSubstFont, if (m_MMFaces[0]) { return m_MMFaces[0]; } - const uint8_t* pFontData = NULL; + const uint8_t* pFontData = nullptr; uint32_t size = 0; m_pFontMgr->GetBuiltinFont(15, &pFontData, &size); m_MMFaces[0] = m_pFontMgr->GetFixedFace(pFontData, size, 0); @@ -876,7 +876,7 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name, if (m_FoxitFaces[12]) { return m_FoxitFaces[12]; } - const uint8_t* pFontData = NULL; + const uint8_t* pFontData = nullptr; uint32_t size = 0; m_pFontMgr->GetBuiltinFont(12, &pFontData, &size); m_FoxitFaces[12] = m_pFontMgr->GetFixedFace(pFontData, size, 0); @@ -889,7 +889,7 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name, if (m_FoxitFaces[13]) { return m_FoxitFaces[13]; } - const uint8_t* pFontData = NULL; + const uint8_t* pFontData = nullptr; uint32_t size = 0; m_pFontMgr->GetBuiltinFont(13, &pFontData, &size); m_FoxitFaces[13] = m_pFontMgr->GetFixedFace(pFontData, size, 0); @@ -1106,7 +1106,7 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name, if (!hFont) { #ifdef PDF_ENABLE_XFA if (flags & FXFONT_EXACTMATCH) { - return NULL; + return nullptr; } #endif // PDF_ENABLE_XFA if (bCJK) { @@ -1134,7 +1134,7 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name, if (m_FoxitFaces[12]) { return m_FoxitFaces[12]; } - const uint8_t* pFontData = NULL; + const uint8_t* pFontData = nullptr; uint32_t size = 0; m_pFontMgr->GetBuiltinFont(12, &pFontData, &size); m_FoxitFaces[12] = m_pFontMgr->GetFixedFace(pFontData, size, 0); @@ -1207,7 +1207,7 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name, } if (!face) { m_pFontInfo->DeleteFont(hFont); - return NULL; + return nullptr; } pSubstFont->m_Family = SubstName; pSubstFont->m_Charset = Charset; @@ -1263,13 +1263,13 @@ FXFT_Face CFX_FontMapper::FindSubstFontByUnicode(uint32_t dwUnicode, if (!hFont) return nullptr; - uint32_t ttc_size = m_pFontInfo->GetFontData(hFont, 0x74746366, NULL, 0); - uint32_t font_size = m_pFontInfo->GetFontData(hFont, 0, NULL, 0); + uint32_t ttc_size = m_pFontInfo->GetFontData(hFont, 0x74746366, nullptr, 0); + uint32_t font_size = m_pFontInfo->GetFontData(hFont, 0, nullptr, 0); if (font_size == 0 && ttc_size == 0) { m_pFontInfo->DeleteFont(hFont); - return NULL; + return nullptr; } - FXFT_Face face = NULL; + FXFT_Face face = nullptr; if (ttc_size) { uint8_t temp[1024]; m_pFontInfo->GetFontData(hFont, 0x74746366, temp, 1024); @@ -1322,7 +1322,7 @@ int IFX_SystemFontInfo::GetFaceIndex(void* hFont) { } void* IFX_SystemFontInfo::RetainFont(void* hFont) { - return NULL; + return nullptr; } int CFX_FontMapper::GetFaceSize() const { @@ -1566,7 +1566,7 @@ void* CFX_FolderFontInfo::MapFont(int weight, int pitch_family, const FX_CHAR* family, int& iExact) { - return NULL; + return nullptr; } #ifdef PDF_ENABLE_XFA @@ -1574,7 +1574,7 @@ void* CFX_FolderFontInfo::MapFontByUnicode(uint32_t dwUnicode, int weight, FX_BOOL bItalic, int pitch_family) { - return NULL; + return nullptr; } #endif // PDF_ENABLE_XFA diff --git a/core/fxge/ge/fx_ge_linux.cpp b/core/fxge/ge/fx_ge_linux.cpp index 46d7146026..712d9e07b0 100644 --- a/core/fxge/ge/fx_ge_linux.cpp +++ b/core/fxge/ge/fx_ge_linux.cpp @@ -28,11 +28,11 @@ static const struct { } LinuxGpFontList[] = { {{"TakaoPGothic", "VL PGothic", "IPAPGothic", "VL Gothic", "Kochi Gothic", "VL Gothic regular"}}, - {{"TakaoGothic", "VL Gothic", "IPAGothic", "Kochi Gothic", NULL, + {{"TakaoGothic", "VL Gothic", "IPAGothic", "Kochi Gothic", nullptr, "VL Gothic regular"}}, - {{"TakaoPMincho", "IPAPMincho", "VL Gothic", "Kochi Mincho", NULL, + {{"TakaoPMincho", "IPAPMincho", "VL Gothic", "Kochi Mincho", nullptr, "VL Gothic regular"}}, - {{"TakaoMincho", "IPAMincho", "VL Gothic", "Kochi Mincho", NULL, + {{"TakaoMincho", "IPAMincho", "VL Gothic", "Kochi Mincho", nullptr, "VL Gothic regular"}}, }; static const FX_CHAR* const g_LinuxGbFontList[] = { diff --git a/core/fxge/ge/fx_ge_path.cpp b/core/fxge/ge/fx_ge_path.cpp index baa391fef2..2abc45f499 100644 --- a/core/fxge/ge/fx_ge_path.cpp +++ b/core/fxge/ge/fx_ge_path.cpp @@ -114,7 +114,7 @@ void CFX_ClipRgn::IntersectMaskF(int left, int top, CFX_DIBitmapRef Mask) { } CFX_PathData::CFX_PathData() { m_PointCount = m_AllocCount = 0; - m_pPoints = NULL; + m_pPoints = nullptr; } CFX_PathData::~CFX_PathData() { FX_Free(m_pPoints); @@ -460,7 +460,7 @@ FX_BOOL CFX_PathData::GetZeroAreaPath(CFX_PathData& NewPath, m_pPoints[mid - i - 1].m_PointY, FXPT_LINETO); } if (!bZeroArea) { - NewPath.Append(&t_path, NULL); + NewPath.Append(&t_path, nullptr); bThin = TRUE; return TRUE; } @@ -620,21 +620,21 @@ void CFX_PathData::Copy(const CFX_PathData& src) { CFX_GraphStateData::CFX_GraphStateData() { m_LineCap = LineCapButt; m_DashCount = 0; - m_DashArray = NULL; + m_DashArray = nullptr; m_DashPhase = 0; m_LineJoin = LineJoinMiter; m_MiterLimit = 10 * 1.0f; m_LineWidth = 1.0f; } CFX_GraphStateData::CFX_GraphStateData(const CFX_GraphStateData& src) { - m_DashArray = NULL; + m_DashArray = nullptr; Copy(src); } void CFX_GraphStateData::Copy(const CFX_GraphStateData& src) { m_LineCap = src.m_LineCap; m_DashCount = src.m_DashCount; FX_Free(m_DashArray); - m_DashArray = NULL; + m_DashArray = nullptr; m_DashPhase = src.m_DashPhase; m_LineJoin = src.m_LineJoin; m_MiterLimit = src.m_MiterLimit; @@ -649,7 +649,7 @@ CFX_GraphStateData::~CFX_GraphStateData() { } void CFX_GraphStateData::SetDashCount(int count) { FX_Free(m_DashArray); - m_DashArray = NULL; + m_DashArray = nullptr; m_DashCount = count; if (count == 0) { return; diff --git a/core/fxge/ge/fx_ge_text.cpp b/core/fxge/ge/fx_ge_text.cpp index 3243b505b1..c63b292435 100644 --- a/core/fxge/ge/fx_ge_text.cpp +++ b/core/fxge/ge/fx_ge_text.cpp @@ -374,7 +374,7 @@ void Color2Argb(FX_ARGB& argb, } if (!CFX_GEModule::Get()->GetCodecModule() || !CFX_GEModule::Get()->GetCodecModule()->GetIccModule()) { - pIccTransform = NULL; + pIccTransform = nullptr; } uint8_t bgra[4]; if (pIccTransform) { @@ -846,7 +846,7 @@ const CFX_GlyphBitmap* CFX_FaceCache::LoadGlyphBitmap(CFX_Font* pFont, int anti_alias, int& text_flags) { if (glyph_index == (uint32_t)-1) { - return NULL; + return nullptr; } _CFX_UniqueKeyGen keygen; #if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_ @@ -940,7 +940,7 @@ CFX_SizeGlyphCache::~CFX_SizeGlyphCache() { } #define CONTRAST_RAMP_STEP 1 void CFX_Font::AdjustMMParams(int glyph_index, int dest_width, int weight) { - FXFT_MM_Var pMasters = NULL; + FXFT_MM_Var pMasters = nullptr; FXFT_Get_MM_Var(m_Face, &pMasters); if (!pMasters) { return; @@ -1076,7 +1076,7 @@ CFX_GlyphBitmap* CFX_FaceCache::RenderGlyph(CFX_Font* pFont, int dest_width, int anti_alias) { if (!m_Face) { - return NULL; + return nullptr; } FXFT_Matrix ft_matrix; ft_matrix.xx = (signed long)(pMatrix->GetA() / 64 * 65536); @@ -1120,14 +1120,14 @@ CFX_GlyphBitmap* CFX_FaceCache::RenderGlyph(CFX_Font* pFont, if (error) { // if an error is returned, try to reload glyphs without hinting. if (load_flags & FT_LOAD_NO_HINTING || load_flags & FT_LOAD_NO_SCALE) { - return NULL; + return nullptr; } load_flags |= FT_LOAD_NO_HINTING; error = FXFT_Load_Glyph(m_Face, glyph_index, load_flags); if (error) { - return NULL; + return nullptr; } } int weight = 0; @@ -1140,7 +1140,7 @@ CFX_GlyphBitmap* CFX_FaceCache::RenderGlyph(CFX_Font* pFont, weight > 400) { uint32_t index = (weight - 400) / 10; if (index >= WEIGHTPOW_ARRAY_SIZE) - return NULL; + return nullptr; int level = 0; if (pSubstFont->m_Charset == FXFONT_SHIFTJIS_CHARSET) { level = @@ -1158,12 +1158,12 @@ CFX_GlyphBitmap* CFX_FaceCache::RenderGlyph(CFX_Font* pFont, FT_LCD_FILTER_DEFAULT); error = FXFT_Render_Glyph(m_Face, anti_alias); if (error) { - return NULL; + return nullptr; } int bmwidth = FXFT_Get_Bitmap_Width(FXFT_Get_Glyph_Bitmap(m_Face)); int bmheight = FXFT_Get_Bitmap_Rows(FXFT_Get_Glyph_Bitmap(m_Face)); if (bmwidth > 2048 || bmheight > 2048) { - return NULL; + return nullptr; } int dib_width = bmwidth; CFX_GlyphBitmap* pGlyphBitmap = new CFX_GlyphBitmap; @@ -1357,7 +1357,7 @@ static int _Outline_CubicTo(const FXFT_Vector* control1, }; CFX_PathData* CFX_Font::LoadGlyphPath(uint32_t glyph_index, int dest_width) { if (!m_Face) { - return NULL; + return nullptr; } FXFT_Set_Pixel_Sizes(m_Face, 0, 64); FXFT_Matrix ft_matrix = {65536, 0, 0, 65536}; @@ -1387,7 +1387,7 @@ CFX_PathData* CFX_Font::LoadGlyphPath(uint32_t glyph_index, int dest_width) { load_flags |= FT_LOAD_NO_HINTING; } if (FXFT_Load_Glyph(m_Face, glyph_index, load_flags)) - return NULL; + return nullptr; if (m_pSubstFont && !(m_pSubstFont->m_SubstFlags & FXFONT_SUBST_MM) && m_pSubstFont->m_Weight > 400) { uint32_t index = (m_pSubstFont->m_Weight - 400) / 10; @@ -1412,7 +1412,7 @@ CFX_PathData* CFX_Font::LoadGlyphPath(uint32_t glyph_index, int dest_width) { params.m_PointCount = 0; FXFT_Outline_Decompose(FXFT_Get_Glyph_Outline(m_Face), &funcs, ¶ms); if (params.m_PointCount == 0) { - return NULL; + return nullptr; } CFX_PathData* pPath = new CFX_PathData; pPath->SetPointCount(params.m_PointCount); diff --git a/core/fxge/ge/fx_text_int.h b/core/fxge/ge/fx_text_int.h index c3e9cd7679..2ca23217c7 100644 --- a/core/fxge/ge/fx_text_int.h +++ b/core/fxge/ge/fx_text_int.h @@ -27,7 +27,7 @@ class CTTFontDesc { public: CTTFontDesc() { m_Type = 0; - m_pFontData = NULL; + m_pFontData = nullptr; m_RefCount = 0; } ~CTTFontDesc(); diff --git a/core/fxge/include/fx_dib.h b/core/fxge/include/fx_dib.h index 12ed03c1d3..4919ba70fe 100644 --- a/core/fxge/include/fx_dib.h +++ b/core/fxge/include/fx_dib.h @@ -204,28 +204,28 @@ class CFX_DIBSource { void CopyPalette(const uint32_t* pSrcPal, uint32_t size = 256); - CFX_DIBitmap* Clone(const FX_RECT* pClip = NULL) const; + CFX_DIBitmap* Clone(const FX_RECT* pClip = nullptr) const; CFX_DIBitmap* CloneConvert(FXDIB_Format format, - const FX_RECT* pClip = NULL, - void* pIccTransform = NULL) const; + const FX_RECT* pClip = nullptr, + void* pIccTransform = nullptr) const; CFX_DIBitmap* StretchTo(int dest_width, int dest_height, uint32_t flags = 0, - const FX_RECT* pClip = NULL) const; + const FX_RECT* pClip = nullptr) const; CFX_DIBitmap* TransformTo(const CFX_Matrix* pMatrix, int& left, int& top, uint32_t flags = 0, - const FX_RECT* pClip = NULL) const; + const FX_RECT* pClip = nullptr) const; - CFX_DIBitmap* GetAlphaMask(const FX_RECT* pClip = NULL) const; + CFX_DIBitmap* GetAlphaMask(const FX_RECT* pClip = nullptr) const; FX_BOOL CopyAlphaMask(const CFX_DIBSource* pAlphaMask, - const FX_RECT* pClip = NULL); + const FX_RECT* pClip = nullptr); CFX_DIBitmap* SwapXY(FX_BOOL bXFlip, FX_BOOL bYFlip, - const FX_RECT* pClip = NULL) const; + const FX_RECT* pClip = nullptr) const; CFX_DIBitmap* FlipImage(FX_BOOL bXFlip, FX_BOOL bYFlip) const; @@ -266,7 +266,7 @@ class CFX_DIBitmap : public CFX_DIBSource { FX_BOOL Create(int width, int height, FXDIB_Format format, - uint8_t* pBuffer = NULL, + uint8_t* pBuffer = nullptr, int pitch = 0); FX_BOOL Copy(const CFX_DIBSource* pSrc); @@ -284,7 +284,7 @@ class CFX_DIBitmap : public CFX_DIBSource { void TakeOver(CFX_DIBitmap* pSrcBitmap); - FX_BOOL ConvertFormat(FXDIB_Format format, void* pIccTransform = NULL); + FX_BOOL ConvertFormat(FXDIB_Format format, void* pIccTransform = nullptr); void Clear(uint32_t color); @@ -309,7 +309,7 @@ class CFX_DIBitmap : public CFX_DIBSource { const CFX_DIBSource* pSrcBitmap, int src_left, int src_top, - void* pIccTransform = NULL); + void* pIccTransform = nullptr); FX_BOOL CompositeBitmap(int dest_left, int dest_top, @@ -319,9 +319,9 @@ class CFX_DIBitmap : public CFX_DIBSource { int src_left, int src_top, int blend_type = FXDIB_BLEND_NORMAL, - const CFX_ClipRgn* pClipRgn = NULL, + const CFX_ClipRgn* pClipRgn = nullptr, FX_BOOL bRgbByteOrder = FALSE, - void* pIccTransform = NULL); + void* pIccTransform = nullptr); FX_BOOL TransferMask(int dest_left, int dest_top, @@ -332,7 +332,7 @@ class CFX_DIBitmap : public CFX_DIBSource { int src_left, int src_top, int alpha_flag = 0, - void* pIccTransform = NULL); + void* pIccTransform = nullptr); FX_BOOL CompositeMask(int dest_left, int dest_top, @@ -343,10 +343,10 @@ class CFX_DIBitmap : public CFX_DIBSource { int src_left, int src_top, int blend_type = FXDIB_BLEND_NORMAL, - const CFX_ClipRgn* pClipRgn = NULL, + const CFX_ClipRgn* pClipRgn = nullptr, FX_BOOL bRgbByteOrder = FALSE, int alpha_flag = 0, - void* pIccTransform = NULL); + void* pIccTransform = nullptr); FX_BOOL CompositeRect(int dest_left, int dest_top, @@ -354,12 +354,12 @@ class CFX_DIBitmap : public CFX_DIBSource { int height, uint32_t color, int alpha_flag = 0, - void* pIccTransform = NULL); + void* pIccTransform = nullptr); FX_BOOL ConvertColorScale(uint32_t forecolor, uint32_t backcolor); protected: - FX_BOOL GetGrayData(void* pIccTransform = NULL); + FX_BOOL GetGrayData(void* pIccTransform = nullptr); uint8_t* m_pBuffer; FX_BOOL m_bExtBuf; @@ -421,7 +421,7 @@ class IFX_ScanlineComposer { virtual void ComposeScanline(int line, const uint8_t* scanline, - const uint8_t* scan_extra_alpha = NULL) = 0; + const uint8_t* scan_extra_alpha = nullptr) = 0; virtual FX_BOOL SetInfo(int width, int height, @@ -443,35 +443,35 @@ class CFX_ScanlineCompositor { FX_BOOL bClip, FX_BOOL bRgbByteOrder = FALSE, int alpha_flag = 0, - void* pIccTransform = NULL); + void* pIccTransform = nullptr); void CompositeRgbBitmapLine(uint8_t* dest_scan, const uint8_t* src_scan, int width, const uint8_t* clip_scan, - const uint8_t* src_extra_alpha = NULL, - uint8_t* dst_extra_alpha = NULL); + const uint8_t* src_extra_alpha = nullptr, + uint8_t* dst_extra_alpha = nullptr); void CompositePalBitmapLine(uint8_t* dest_scan, const uint8_t* src_scan, int src_left, int width, const uint8_t* clip_scan, - const uint8_t* src_extra_alpha = NULL, - uint8_t* dst_extra_alpha = NULL); + const uint8_t* src_extra_alpha = nullptr, + uint8_t* dst_extra_alpha = nullptr); void CompositeByteMaskLine(uint8_t* dest_scan, const uint8_t* src_scan, int width, const uint8_t* clip_scan, - uint8_t* dst_extra_alpha = NULL); + uint8_t* dst_extra_alpha = nullptr); void CompositeBitMaskLine(uint8_t* dest_scan, const uint8_t* src_scan, int src_left, int width, const uint8_t* clip_scan, - uint8_t* dst_extra_alpha = NULL); + uint8_t* dst_extra_alpha = nullptr); protected: int m_Transparency; @@ -501,7 +501,7 @@ class CFX_BitmapComposer : public IFX_ScanlineComposer { FX_BOOL bFlipY, FX_BOOL bRgbByteOrder = FALSE, int alpha_flag = 0, - void* pIccTransform = NULL, + void* pIccTransform = nullptr, int blend_type = FXDIB_BLEND_NORMAL); // IFX_ScanlineComposer @@ -519,8 +519,8 @@ class CFX_BitmapComposer : public IFX_ScanlineComposer { const uint8_t* src_scan, int dest_width, const uint8_t* clip_scan, - const uint8_t* src_extra_alpha = NULL, - uint8_t* dst_extra_alpha = NULL); + const uint8_t* src_extra_alpha = nullptr, + uint8_t* dst_extra_alpha = nullptr); CFX_DIBitmap* m_pBitmap; const CFX_ClipRgn* m_pClipRgn; FXDIB_Format m_SrcFormat; @@ -535,7 +535,7 @@ class CFX_BitmapComposer : public IFX_ScanlineComposer { int m_BlendType; void ComposeScanlineV(int line, const uint8_t* scanline, - const uint8_t* scan_extra_alpha = NULL); + const uint8_t* scan_extra_alpha = nullptr); uint8_t* m_pScanlineV; uint8_t* m_pClipScanV; uint8_t* m_pAddClipScan; @@ -642,7 +642,7 @@ class CFX_ImageRenderer { uint32_t dib_flags, FX_BOOL bRgbByteOrder = FALSE, int alpha_flag = 0, - void* pIccTransform = NULL, + void* pIccTransform = nullptr, int blend_type = FXDIB_BLEND_NORMAL); FX_BOOL Continue(IFX_Pause* pPause); diff --git a/core/fxge/include/fx_font.h b/core/fxge/include/fx_font.h index 023a6a0928..13143d518b 100644 --- a/core/fxge/include/fx_font.h +++ b/core/fxge/include/fx_font.h @@ -83,7 +83,7 @@ class CFX_Font { #ifdef PDF_ENABLE_XFA FX_BOOL LoadFile(IFX_FileRead* pFile, int nFaceIndex = 0, - int* pFaceCount = NULL); + int* pFaceCount = nullptr); FX_BOOL LoadClone(const CFX_Font* pFont); CFX_SubstFont* GetSubstFont() const { return m_pSubstFont; } diff --git a/core/fxge/include/fx_ge.h b/core/fxge/include/fx_ge.h index 1cbbc2cc97..040c16afa2 100644 --- a/core/fxge/include/fx_ge.h +++ b/core/fxge/include/fx_ge.h @@ -424,7 +424,7 @@ class IFX_RenderDeviceDriver { static IFX_RenderDeviceDriver* CreateFxgeDriver( CFX_DIBitmap* pBitmap, FX_BOOL bRgbByteOrder = FALSE, - CFX_DIBitmap* pOriDevice = NULL, + CFX_DIBitmap* pOriDevice = nullptr, FX_BOOL bGroupKnockout = FALSE); virtual ~IFX_RenderDeviceDriver() {} @@ -458,21 +458,21 @@ class IFX_RenderDeviceDriver { uint32_t stroke_color, int fill_mode, int alpha_flag = 0, - void* pIccTransform = NULL, + void* pIccTransform = nullptr, int blend_type = FXDIB_BLEND_NORMAL) = 0; virtual FX_BOOL SetPixel(int x, int y, uint32_t color, int alpha_flag = 0, - void* pIccTransform = NULL) { + void* pIccTransform = nullptr) { return FALSE; } virtual FX_BOOL FillRect(const FX_RECT* pRect, uint32_t fill_color, int alpha_flag = 0, - void* pIccTransform = NULL, + void* pIccTransform = nullptr, int blend_type = FXDIB_BLEND_NORMAL) { return FALSE; } @@ -483,7 +483,7 @@ class IFX_RenderDeviceDriver { FX_FLOAT y2, uint32_t color, int alpha_flag = 0, - void* pIccTransform = NULL, + void* pIccTransform = nullptr, int blend_type = FXDIB_BLEND_NORMAL) { return FALSE; } @@ -493,11 +493,11 @@ class IFX_RenderDeviceDriver { virtual FX_BOOL GetDIBits(CFX_DIBitmap* pBitmap, int left, int top, - void* pIccTransform = NULL, + void* pIccTransform = nullptr, FX_BOOL bDEdge = FALSE) { return FALSE; } - virtual CFX_DIBitmap* GetBackDrop() { return NULL; } + virtual CFX_DIBitmap* GetBackDrop() { return nullptr; } virtual FX_BOOL SetDIBits(const CFX_DIBSource* pBitmap, uint32_t color, @@ -506,7 +506,7 @@ class IFX_RenderDeviceDriver { int dest_top, int blend_type, int alpha_flag = 0, - void* pIccTransform = NULL) = 0; + void* pIccTransform = nullptr) = 0; virtual FX_BOOL StretchDIBits(const CFX_DIBSource* pBitmap, uint32_t color, @@ -517,7 +517,7 @@ class IFX_RenderDeviceDriver { const FX_RECT* pClipRect, uint32_t flags, int alpha_flag = 0, - void* pIccTransform = NULL, + void* pIccTransform = nullptr, int blend_type = FXDIB_BLEND_NORMAL) = 0; virtual FX_BOOL StartDIBits(const CFX_DIBSource* pBitmap, @@ -527,7 +527,7 @@ class IFX_RenderDeviceDriver { uint32_t flags, void*& handle, int alpha_flag = 0, - void* pIccTransform = NULL, + void* pIccTransform = nullptr, int blend_type = FXDIB_BLEND_NORMAL) = 0; virtual FX_BOOL ContinueDIBits(void* handle, IFX_Pause* pPause) { @@ -544,11 +544,11 @@ class IFX_RenderDeviceDriver { FX_FLOAT font_size, uint32_t color, int alpha_flag = 0, - void* pIccTransform = NULL) { + void* pIccTransform = nullptr) { return FALSE; } - virtual void* GetPlatformSurface() const { return NULL; } + virtual void* GetPlatformSurface() const { return nullptr; } virtual int GetDriverType() const { return 0; } virtual void ClearDriver() {} diff --git a/core/fxge/include/fx_ge_win32.h b/core/fxge/include/fx_ge_win32.h index a6d8fbb378..e7207a5f70 100644 --- a/core/fxge/include/fx_ge_win32.h +++ b/core/fxge/include/fx_ge_win32.h @@ -33,7 +33,7 @@ class CFX_WindowsDIB : public CFX_DIBitmap { static CFX_DIBitmap* LoadFromDDB(HDC hDC, HBITMAP hBitmap, - uint32_t* pPalette = NULL, + uint32_t* pPalette = nullptr, uint32_t size = 256); static CFX_DIBitmap* LoadFromFile(const FX_WCHAR* filename); diff --git a/core/fxge/skia/fx_skia_device.h b/core/fxge/skia/fx_skia_device.h index 085977b66e..c9ff9f1632 100644 --- a/core/fxge/skia/fx_skia_device.h +++ b/core/fxge/skia/fx_skia_device.h @@ -53,13 +53,13 @@ class CFX_SkiaDeviceDriver : public IFX_RenderDeviceDriver { uint32_t stroke_color, int fill_mode, int alpha_flag = 0, - void* pIccTransform = NULL, + void* pIccTransform = nullptr, int blend_type = FXDIB_BLEND_NORMAL) override; FX_BOOL FillRect(const FX_RECT* pRect, uint32_t fill_color, int alpha_flag = 0, - void* pIccTransform = NULL, + void* pIccTransform = nullptr, int blend_type = FXDIB_BLEND_NORMAL) override; /** Draw a single pixel (device dependant) line */ @@ -69,7 +69,7 @@ class CFX_SkiaDeviceDriver : public IFX_RenderDeviceDriver { FX_FLOAT y2, uint32_t color, int alpha_flag = 0, - void* pIccTransform = NULL, + void* pIccTransform = nullptr, int blend_type = FXDIB_BLEND_NORMAL) override { return FALSE; } @@ -80,7 +80,7 @@ class CFX_SkiaDeviceDriver : public IFX_RenderDeviceDriver { FX_BOOL GetDIBits(CFX_DIBitmap* pBitmap, int left, int top, - void* pIccTransform = NULL, + void* pIccTransform = nullptr, FX_BOOL bDEdge = FALSE) override; CFX_DIBitmap* GetBackDrop() override { return m_pOriDevice; } @@ -92,7 +92,7 @@ class CFX_SkiaDeviceDriver : public IFX_RenderDeviceDriver { int dest_top, int blend_type, int alpha_flag = 0, - void* pIccTransform = NULL) override; + void* pIccTransform = nullptr) override; FX_BOOL StretchDIBits(const CFX_DIBSource* pBitmap, uint32_t color, int dest_left, @@ -102,7 +102,7 @@ class CFX_SkiaDeviceDriver : public IFX_RenderDeviceDriver { const FX_RECT* pClipRect, uint32_t flags, int alpha_flag = 0, - void* pIccTransform = NULL, + void* pIccTransform = nullptr, int blend_type = FXDIB_BLEND_NORMAL) override; FX_BOOL StartDIBits(const CFX_DIBSource* pBitmap, @@ -112,7 +112,7 @@ class CFX_SkiaDeviceDriver : public IFX_RenderDeviceDriver { uint32_t flags, void*& handle, int alpha_flag = 0, - void* pIccTransform = NULL, + void* pIccTransform = nullptr, int blend_type = FXDIB_BLEND_NORMAL) override; FX_BOOL ContinueDIBits(void* handle, IFX_Pause* pPause) override { @@ -129,7 +129,7 @@ class CFX_SkiaDeviceDriver : public IFX_RenderDeviceDriver { FX_FLOAT font_size, uint32_t color, int alpha_flag = 0, - void* pIccTransform = NULL) override; + void* pIccTransform = nullptr) override; FX_BOOL DrawShading(const CPDF_ShadingPattern* pPattern, const CFX_Matrix* pMatrix, diff --git a/core/fxge/win32/dwrite_int.h b/core/fxge/win32/dwrite_int.h index 60cc981a48..f49fda44dd 100644 --- a/core/fxge/win32/dwrite_int.h +++ b/core/fxge/win32/dwrite_int.h @@ -34,7 +34,7 @@ class CDWriteExt { void Load(); void Unload(); - FX_BOOL IsAvailable() { return m_pDWriteFactory != NULL; } + FX_BOOL IsAvailable() { return !!m_pDWriteFactory; } void* DwCreateFontFaceFromStream(uint8_t* pData, uint32_t size, diff --git a/core/fxge/win32/fx_win32_dib.cpp b/core/fxge/win32/fx_win32_dib.cpp index eefa991eeb..7221d10536 100644 --- a/core/fxge/win32/fx_win32_dib.cpp +++ b/core/fxge/win32/fx_win32_dib.cpp @@ -69,7 +69,7 @@ CFX_DIBitmap* _FX_WindowsDIB_LoadFromBuf(BITMAPINFO* pbmi, FX_BOOL ret = pBitmap->Create(width, height, format); if (!ret) { delete pBitmap; - return NULL; + return nullptr; } FXSYS_memcpy(pBitmap->GetBuffer(), pData, pitch * height); if (bBottomUp) { @@ -84,7 +84,7 @@ CFX_DIBitmap* _FX_WindowsDIB_LoadFromBuf(BITMAPINFO* pbmi, bottom--; } FX_Free(temp_buf); - temp_buf = NULL; + temp_buf = nullptr; } if (pbmi->bmiHeader.biBitCount == 1) { for (int i = 0; i < 2; i++) { @@ -102,11 +102,9 @@ CFX_DIBitmap* CFX_WindowsDIB::LoadFromBuf(BITMAPINFO* pbmi, LPVOID pData) { } HBITMAP CFX_WindowsDIB::GetDDBitmap(const CFX_DIBitmap* pBitmap, HDC hDC) { CFX_ByteString info = GetBitmapInfo(pBitmap); - HBITMAP hBitmap = NULL; - hBitmap = CreateDIBitmap(hDC, (BITMAPINFOHEADER*)info.c_str(), CBM_INIT, - pBitmap->GetBuffer(), (BITMAPINFO*)info.c_str(), - DIB_RGB_COLORS); - return hBitmap; + return CreateDIBitmap(hDC, (BITMAPINFOHEADER*)info.c_str(), CBM_INIT, + pBitmap->GetBuffer(), (BITMAPINFO*)info.c_str(), + DIB_RGB_COLORS); } void GetBitmapSize(HBITMAP hBitmap, int& w, int& h) { BITMAP bmp; @@ -123,26 +121,26 @@ CFX_DIBitmap* CFX_WindowsDIB::LoadFromFile(const FX_WCHAR* filename) { args.path_name = filename; return pPlatform->m_GdiplusExt.LoadDIBitmap(args); } - HBITMAP hBitmap = (HBITMAP)LoadImageW(NULL, (wchar_t*)filename, IMAGE_BITMAP, - 0, 0, LR_LOADFROMFILE); + HBITMAP hBitmap = (HBITMAP)LoadImageW(nullptr, (wchar_t*)filename, + IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); if (!hBitmap) { - return NULL; + return nullptr; } - HDC hDC = CreateCompatibleDC(NULL); + HDC hDC = CreateCompatibleDC(nullptr); int width, height; GetBitmapSize(hBitmap, width, height); CFX_DIBitmap* pDIBitmap = new CFX_DIBitmap; if (!pDIBitmap->Create(width, height, FXDIB_Rgb)) { delete pDIBitmap; DeleteDC(hDC); - return NULL; + return nullptr; } CFX_ByteString info = GetBitmapInfo(pDIBitmap); int ret = GetDIBits(hDC, hBitmap, 0, height, pDIBitmap->GetBuffer(), (BITMAPINFO*)info.c_str(), DIB_RGB_COLORS); if (!ret) { delete pDIBitmap; - pDIBitmap = NULL; + pDIBitmap = nullptr; } DeleteDC(hDC); return pDIBitmap; @@ -154,28 +152,28 @@ CFX_DIBitmap* CFX_WindowsDIB::LoadDIBitmap(WINDIB_Open_Args_ args) { return pPlatform->m_GdiplusExt.LoadDIBitmap(args); } if (args.flags == WINDIB_OPEN_MEMORY) { - return NULL; + return nullptr; } - HBITMAP hBitmap = (HBITMAP)LoadImageW(NULL, (wchar_t*)args.path_name, + HBITMAP hBitmap = (HBITMAP)LoadImageW(nullptr, (wchar_t*)args.path_name, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); if (!hBitmap) { - return NULL; + return nullptr; } - HDC hDC = CreateCompatibleDC(NULL); + HDC hDC = CreateCompatibleDC(nullptr); int width, height; GetBitmapSize(hBitmap, width, height); CFX_DIBitmap* pDIBitmap = new CFX_DIBitmap; if (!pDIBitmap->Create(width, height, FXDIB_Rgb)) { delete pDIBitmap; DeleteDC(hDC); - return NULL; + return nullptr; } CFX_ByteString info = GetBitmapInfo(pDIBitmap); int ret = GetDIBits(hDC, hBitmap, 0, height, pDIBitmap->GetBuffer(), (BITMAPINFO*)info.c_str(), DIB_RGB_COLORS); if (!ret) { delete pDIBitmap; - pDIBitmap = NULL; + pDIBitmap = nullptr; } DeleteDC(hDC); return pDIBitmap; @@ -186,12 +184,12 @@ CFX_DIBitmap* CFX_WindowsDIB::LoadFromDDB(HDC hDC, uint32_t palsize) { FX_BOOL bCreatedDC = !hDC; if (bCreatedDC) { - hDC = CreateCompatibleDC(NULL); + hDC = CreateCompatibleDC(nullptr); } BITMAPINFOHEADER bmih; FXSYS_memset(&bmih, 0, sizeof bmih); bmih.biSize = sizeof bmih; - GetDIBits(hDC, hBitmap, 0, 0, NULL, (BITMAPINFO*)&bmih, DIB_RGB_COLORS); + GetDIBits(hDC, hBitmap, 0, 0, nullptr, (BITMAPINFO*)&bmih, DIB_RGB_COLORS); int width = bmih.biWidth; int height = abs(bmih.biHeight); bmih.biHeight = -height; @@ -218,12 +216,12 @@ CFX_DIBitmap* CFX_WindowsDIB::LoadFromDDB(HDC hDC, if (bCreatedDC) { DeleteDC(hDC); } - return NULL; + return nullptr; } ret = GetDIBits(hDC, hBitmap, 0, height, pDIBitmap->GetBuffer(), (BITMAPINFO*)pbmih, DIB_RGB_COLORS); FX_Free(pbmih); - pbmih = NULL; + pbmih = nullptr; pDIBitmap->CopyPalette(pPalette, palsize); } else { if (bmih.biBitCount <= 24) { @@ -237,7 +235,7 @@ CFX_DIBitmap* CFX_WindowsDIB::LoadFromDDB(HDC hDC, if (bCreatedDC) { DeleteDC(hDC); } - return NULL; + return nullptr; } ret = GetDIBits(hDC, hBitmap, 0, height, pDIBitmap->GetBuffer(), (BITMAPINFO*)&bmih, DIB_RGB_COLORS); @@ -254,7 +252,7 @@ CFX_DIBitmap* CFX_WindowsDIB::LoadFromDDB(HDC hDC, } if (ret == 0) { delete pDIBitmap; - pDIBitmap = NULL; + pDIBitmap = nullptr; } if (bCreatedDC) { DeleteDC(hDC); @@ -271,7 +269,7 @@ CFX_WindowsDIB::CFX_WindowsDIB(HDC hDC, int width, int height) { bmih.biPlanes = 1; bmih.biWidth = width; m_hBitmap = CreateDIBSection(hDC, (BITMAPINFO*)&bmih, DIB_RGB_COLORS, - (LPVOID*)&m_pBuffer, NULL, 0); + (LPVOID*)&m_pBuffer, nullptr, 0); m_hMemDC = CreateCompatibleDC(hDC); m_hOldBitmap = (HBITMAP)SelectObject(m_hMemDC, m_hBitmap); } diff --git a/core/fxge/win32/fx_win32_dwrite.cpp b/core/fxge/win32/fx_win32_dwrite.cpp index aa6ba9c8b9..5f620cba4c 100644 --- a/core/fxge/win32/fx_win32_dwrite.cpp +++ b/core/fxge/win32/fx_win32_dwrite.cpp @@ -20,7 +20,7 @@ template inline void SafeRelease(InterfaceType** currentObject) { if (*currentObject) { (*currentObject)->Release(); - *currentObject = NULL; + *currentObject = nullptr; } } template @@ -46,7 +46,7 @@ class CDwFontFileStream final : public IDWriteFontFileStream { virtual void STDMETHODCALLTYPE ReleaseFileFragment(void* fragmentContext); virtual HRESULT STDMETHODCALLTYPE GetFileSize(OUT UINT64* fileSize); virtual HRESULT STDMETHODCALLTYPE GetLastWriteTime(OUT UINT64* lastWriteTime); - bool IsInitialized() { return resourcePtr_ != NULL; } + bool IsInitialized() { return !!resourcePtr_; } private: ULONG refCount_; @@ -70,7 +70,7 @@ class CDwFontFileLoader final : public IDWriteFontFileLoader { } return instance_; } - static bool IsLoaderInitialized() { return instance_ != NULL; } + static bool IsLoaderInitialized() { return !!instance_; } private: CDwFontFileLoader(); @@ -110,16 +110,16 @@ class CDwGdiTextRenderer { IDWriteRenderingParams* pRenderingParams_; }; CDWriteExt::CDWriteExt() { - m_hModule = NULL; - m_pDWriteFactory = NULL; - m_pDwFontContext = NULL; - m_pDwTextRenderer = NULL; + m_hModule = nullptr; + m_pDWriteFactory = nullptr; + m_pDwFontContext = nullptr; + m_pDwTextRenderer = nullptr; } void CDWriteExt::Load() {} void CDWriteExt::Unload() { if (m_pDwFontContext) { delete (CDwFontContext*)m_pDwFontContext; - m_pDwFontContext = NULL; + m_pDwFontContext = nullptr; } SafeRelease((IDWriteFactory**)&m_pDWriteFactory); } @@ -130,8 +130,8 @@ LPVOID CDWriteExt::DwCreateFontFaceFromStream(uint8_t* pData, uint32_t size, int simulation_style) { IDWriteFactory* pDwFactory = (IDWriteFactory*)m_pDWriteFactory; - IDWriteFontFile* pDwFontFile = NULL; - IDWriteFontFace* pDwFontFace = NULL; + IDWriteFontFile* pDwFontFile = nullptr; + IDWriteFontFace* pDwFontFace = nullptr; BOOL isSupportedFontType = FALSE; DWRITE_FONT_FILE_TYPE fontFileType; DWRITE_FONT_FACE_TYPE fontFaceType; @@ -160,7 +160,7 @@ LPVOID CDWriteExt::DwCreateFontFaceFromStream(uint8_t* pData, return pDwFontFace; failed: SafeRelease(&pDwFontFile); - return NULL; + return nullptr; } FX_BOOL CDWriteExt::DwCreateRenderingTarget(CFX_DIBitmap* pBitmap, void** renderTarget) { @@ -168,16 +168,16 @@ FX_BOOL CDWriteExt::DwCreateRenderingTarget(CFX_DIBitmap* pBitmap, return FALSE; } IDWriteFactory* pDwFactory = (IDWriteFactory*)m_pDWriteFactory; - IDWriteGdiInterop* pGdiInterop = NULL; - IDWriteBitmapRenderTarget* pBitmapRenderTarget = NULL; - IDWriteRenderingParams* pRenderingParams = NULL; + IDWriteGdiInterop* pGdiInterop = nullptr; + IDWriteBitmapRenderTarget* pBitmapRenderTarget = nullptr; + IDWriteRenderingParams* pRenderingParams = nullptr; HRESULT hr = S_OK; hr = pDwFactory->GetGdiInterop(&pGdiInterop); if (FAILED(hr)) { goto failed; } hr = pGdiInterop->CreateBitmapRenderTarget( - NULL, pBitmap->GetWidth(), pBitmap->GetHeight(), &pBitmapRenderTarget); + nullptr, pBitmap->GetWidth(), pBitmap->GetHeight(), &pBitmapRenderTarget); if (FAILED(hr)) { goto failed; } @@ -240,7 +240,7 @@ FX_BOOL CDWriteExt::DwRendingString(void* renderTarget, glyphRun.isSideways = FALSE; glyphRun.bidiLevel = 0; hr = pTextRenderer->DrawGlyphRun( - stringRect, pClipRgn, pMatrix ? &transform : NULL, baselineOriginX, + stringRect, pClipRgn, pMatrix ? &transform : nullptr, baselineOriginX, baselineOriginY, DWRITE_MEASURING_MODE_NATURAL, &glyphRun, RGB(FXARGB_R(text_color), FXARGB_G(text_color), FXARGB_B(text_color))); return SUCCEEDED(hr); @@ -266,7 +266,7 @@ HRESULT STDMETHODCALLTYPE CDwFontFileStream::QueryInterface(REFIID iid, AddRef(); return S_OK; } - *ppvObject = NULL; + *ppvObject = nullptr; return E_NOINTERFACE; } ULONG STDMETHODCALLTYPE CDwFontFileStream::AddRef() { @@ -288,11 +288,11 @@ CDwFontFileStream::ReadFileFragment(void const** fragmentStart, fragmentSize <= resourceSize_ - fileOffset) { *fragmentStart = static_cast(resourcePtr_) + static_cast(fileOffset); - *fragmentContext = NULL; + *fragmentContext = nullptr; return S_OK; } - *fragmentStart = NULL; - *fragmentContext = NULL; + *fragmentStart = nullptr; + *fragmentContext = nullptr; return E_FAIL; } void STDMETHODCALLTYPE @@ -306,7 +306,7 @@ CDwFontFileStream::GetLastWriteTime(OUT UINT64* lastWriteTime) { *lastWriteTime = 0; return E_NOTIMPL; } -IDWriteFontFileLoader* CDwFontFileLoader::instance_ = NULL; +IDWriteFontFileLoader* CDwFontFileLoader::instance_ = nullptr; CDwFontFileLoader::CDwFontFileLoader() : refCount_(0) {} HRESULT STDMETHODCALLTYPE CDwFontFileLoader::QueryInterface(REFIID iid, void** ppvObject) { @@ -315,7 +315,7 @@ HRESULT STDMETHODCALLTYPE CDwFontFileLoader::QueryInterface(REFIID iid, AddRef(); return S_OK; } - *ppvObject = NULL; + *ppvObject = nullptr; return E_NOINTERFACE; } ULONG STDMETHODCALLTYPE CDwFontFileLoader::AddRef() { @@ -324,7 +324,7 @@ ULONG STDMETHODCALLTYPE CDwFontFileLoader::AddRef() { ULONG STDMETHODCALLTYPE CDwFontFileLoader::Release() { ULONG newCount = InterlockedDecrement((long*)(&refCount_)); if (newCount == 0) { - instance_ = NULL; + instance_ = nullptr; delete this; } return newCount; @@ -333,7 +333,7 @@ HRESULT STDMETHODCALLTYPE CDwFontFileLoader::CreateStreamFromKey( void const* fontFileReferenceKey, UINT32 fontFileReferenceKeySize, OUT IDWriteFontFileStream** fontFileStream) { - *fontFileStream = NULL; + *fontFileStream = nullptr; CDwFontFileStream* stream = new CDwFontFileStream(fontFileReferenceKey, fontFileReferenceKeySize); if (!stream->IsInitialized()) { @@ -395,7 +395,7 @@ STDMETHODIMP CDwGdiTextRenderer::DrawGlyphRun( (uint8_t*)bitmap.bmBits); dib.CompositeBitmap(text_bbox.left, text_bbox.top, text_bbox.Width(), text_bbox.Height(), pBitmap_, text_bbox.left, - text_bbox.top, FXDIB_BLEND_NORMAL, NULL); + text_bbox.top, FXDIB_BLEND_NORMAL, nullptr); hr = pRenderTarget_->DrawGlyphRun(baselineOriginX, baselineOriginY, measuringMode, glyphRun, pRenderingParams_, textColor); diff --git a/core/fxge/win32/fx_win32_gdipext.cpp b/core/fxge/win32/fx_win32_gdipext.cpp index eb24410900..68b9aaa80e 100644 --- a/core/fxge/win32/fx_win32_gdipext.cpp +++ b/core/fxge/win32/fx_win32_gdipext.cpp @@ -444,7 +444,7 @@ void* CGdiplusExt::GdiAddFontMemResourceEx(void* pFontdata, return ((FuncType_GdiAddFontMemResourceEx)m_pGdiAddFontMemResourceEx)( (PVOID)pFontdata, (DWORD)size, (PVOID)pdv, (DWORD*)num_face); } - return NULL; + return nullptr; } FX_BOOL CGdiplusExt::GdiRemoveFontMemResourceEx(void* handle) { if (m_pGdiRemoveFontMemResourseEx) { @@ -456,7 +456,7 @@ FX_BOOL CGdiplusExt::GdiRemoveFontMemResourceEx(void* handle) { static GpBrush* _GdipCreateBrush(DWORD argb) { CGdiplusExt& GdiplusExt = ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt; - GpSolidFill* solidBrush = NULL; + GpSolidFill* solidBrush = nullptr; CallFunc(GdipCreateSolidFill)((ARGB)argb, &solidBrush); return solidBrush; } @@ -478,7 +478,7 @@ static CFX_DIBitmap* _StretchMonoToGray(int dest_width, CFX_DIBitmap* pStretched = new CFX_DIBitmap; if (!pStretched->Create(result_width, result_height, FXDIB_8bppRgb)) { delete pStretched; - return NULL; + return nullptr; } LPBYTE dest_buf = pStretched->GetBuffer(); int src_width = pSource->GetWidth(); @@ -560,7 +560,7 @@ static void OutputImageMask(GpGraphics* pGraphics, return; } image_clip.Offset(-image_rect.left, -image_rect.top); - CFX_DIBitmap* pStretched = NULL; + CFX_DIBitmap* pStretched = nullptr; if (src_width * src_height > 10000) { pStretched = _StretchMonoToGray(dest_width, dest_height, pBitmap, &image_clip); @@ -624,7 +624,7 @@ static void OutputImage(GpGraphics* pGraphics, int src_pitch = pBitmap->GetPitch(); uint8_t* scan0 = pBitmap->GetBuffer() + pSrcRect->top * src_pitch + pBitmap->GetBPP() * pSrcRect->left / 8; - GpBitmap* bitmap = NULL; + GpBitmap* bitmap = nullptr; switch (pBitmap->GetFormat()) { case FXDIB_Argb: CallFunc(GdipCreateBitmapFromScan0)(src_width, src_height, src_pitch, @@ -671,13 +671,13 @@ static void OutputImage(GpGraphics* pGraphics, CallFunc(GdipDisposeImage)(bitmap); } CGdiplusExt::CGdiplusExt() { - m_hModule = NULL; - m_GdiModule = NULL; + m_hModule = nullptr; + m_GdiModule = nullptr; for (size_t i = 0; i < sizeof g_GdipFuncNames / sizeof(LPCSTR); i++) { - m_Functions[i] = NULL; + m_Functions[i] = nullptr; } - m_pGdiAddFontMemResourceEx = NULL; - m_pGdiRemoveFontMemResourseEx = NULL; + m_pGdiAddFontMemResourceEx = nullptr; + m_pGdiRemoveFontMemResourseEx = nullptr; } void CGdiplusExt::Load() { CFX_ByteString strPlusPath = ""; @@ -693,14 +693,14 @@ void CGdiplusExt::Load() { for (size_t i = 0; i < sizeof g_GdipFuncNames / sizeof(LPCSTR); i++) { m_Functions[i] = GetProcAddress(m_hModule, g_GdipFuncNames[i]); if (!m_Functions[i]) { - m_hModule = NULL; + m_hModule = nullptr; return; } } uintptr_t gdiplusToken; GdiplusStartupInput gdiplusStartupInput; ((FuncType_GdiplusStartup)m_Functions[FuncId_GdiplusStartup])( - &gdiplusToken, &gdiplusStartupInput, NULL); + &gdiplusToken, &gdiplusStartupInput, nullptr); m_GdiModule = LoadLibraryA("GDI32.DLL"); if (!m_GdiModule) { return; @@ -712,7 +712,7 @@ void CGdiplusExt::Load() { } CGdiplusExt::~CGdiplusExt() {} LPVOID CGdiplusExt::LoadMemFont(LPBYTE pData, uint32_t size) { - GpFontCollection* pCollection = NULL; + GpFontCollection* pCollection = nullptr; CGdiplusExt& GdiplusExt = ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt; CallFunc(GdipNewPrivateFontCollection)(&pCollection); @@ -722,7 +722,7 @@ LPVOID CGdiplusExt::LoadMemFont(LPBYTE pData, uint32_t size) { return pCollection; } CallFunc(GdipDeletePrivateFontCollection)(&pCollection); - return NULL; + return nullptr; } void CGdiplusExt::DeleteMemFont(LPVOID pCollection) { CGdiplusExt& GdiplusExt = @@ -852,19 +852,19 @@ void* CGdiplusExt::GdipCreateFontFromCollection(void* pFontCollection, GpStatus status = CallFunc(GdipGetFontCollectionFamilyCount)( (GpFontCollection*)pFontCollection, &numFamilies); if (status != Ok) { - return NULL; + return nullptr; } GpFontFamily* family_list[1]; status = CallFunc(GdipGetFontCollectionFamilyList)( (GpFontCollection*)pFontCollection, 1, family_list, &numFamilies); if (status != Ok) { - return NULL; + return nullptr; } - GpFont* pFont = NULL; + GpFont* pFont = nullptr; status = CallFunc(GdipCreateFont)(family_list[0], font_size, fontstyle, UnitPixel, &pFont); if (status != Ok) { - return NULL; + return nullptr; } return pFont; } @@ -922,7 +922,7 @@ FX_BOOL CGdiplusExt::StretchBitMask(HDC hDC, ASSERT(pBitmap->GetBPP() == 1); CGdiplusExt& GdiplusExt = ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt; - GpGraphics* pGraphics = NULL; + GpGraphics* pGraphics = nullptr; CallFunc(GdipCreateFromHDC)(hDC, &pGraphics); CallFunc(GdipSetPageUnit)(pGraphics, UnitPixel); if (flags & FXDIB_NOSMOOTH) { @@ -980,7 +980,7 @@ static GpPen* _GdipCreatePen(const CFX_GraphStateData* pGraphState, width = unit; } } - GpPen* pPen = NULL; + GpPen* pPen = nullptr; CallFunc(GdipCreatePen1)((ARGB)argb, width, UnitWorld, &pPen); LineCap lineCap = LineCapFlat; DashCap dashCap = DashCapFlat; @@ -1066,7 +1066,7 @@ static GpPen* _GdipCreatePen(const CFX_GraphStateData* pGraphState, } CallFunc(GdipSetPenDashOffset)(pPen, phase); FX_Free(pDashArray); - pDashArray = NULL; + pDashArray = nullptr; } CallFunc(GdipSetPenMiterLimit)(pPen, pGraphState->m_MiterLimit); return pPen; @@ -1108,13 +1108,13 @@ FX_BOOL CGdiplusExt::DrawPath(HDC hDC, return TRUE; } FX_PATHPOINT* pPoints = pPathData->GetPoints(); - GpGraphics* pGraphics = NULL; + GpGraphics* pGraphics = nullptr; CGdiplusExt& GdiplusExt = ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt; CallFunc(GdipCreateFromHDC)(hDC, &pGraphics); CallFunc(GdipSetPageUnit)(pGraphics, UnitPixel); CallFunc(GdipSetPixelOffsetMode)(pGraphics, PixelOffsetModeHalf); - GpMatrix* pMatrix = NULL; + GpMatrix* pMatrix = nullptr; if (pObject2Device) { CallFunc(GdipCreateMatrix2)(pObject2Device->a, pObject2Device->b, pObject2Device->c, pObject2Device->d, @@ -1201,7 +1201,7 @@ FX_BOOL CGdiplusExt::DrawPath(HDC hDC, if (nPoints == 4 && !pGraphState) { int v1, v2; if (IsSmallTriangle(points, pObject2Device, v1, v2)) { - GpPen* pPen = NULL; + GpPen* pPen = nullptr; CallFunc(GdipCreatePen1)(fill_argb, 1.0f, UnitPixel, &pPen); CallFunc(GdipDrawLineI)( pGraphics, pPen, FXSYS_round(points[v1].X), FXSYS_round(points[v1].Y), @@ -1210,7 +1210,7 @@ FX_BOOL CGdiplusExt::DrawPath(HDC hDC, return TRUE; } } - GpPath* pGpPath = NULL; + GpPath* pGpPath = nullptr; CallFunc(GdipCreatePath2)(points, types, nPoints, GdiFillType2Gdip(new_fill_mode), &pGpPath); if (!pGpPath) { @@ -1400,7 +1400,7 @@ typedef struct { } PREVIEW3_DIBITMAP; static PREVIEW3_DIBITMAP* LoadDIBitmap(WINDIB_Open_Args_ args) { GpBitmap* pBitmap; - GpStream* pStream = NULL; + GpStream* pStream = nullptr; CGdiplusExt& GdiplusExt = ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt; Status status = Ok; @@ -1409,17 +1409,17 @@ static PREVIEW3_DIBITMAP* LoadDIBitmap(WINDIB_Open_Args_ args) { &pBitmap); } else { if (args.memory_size == 0 || !args.memory_base) { - return NULL; + return nullptr; } pStream = new GpStream; - pStream->Write(args.memory_base, (ULONG)args.memory_size, NULL); + pStream->Write(args.memory_base, (ULONG)args.memory_size, nullptr); status = CallFunc(GdipCreateBitmapFromStreamICM)(pStream, &pBitmap); } if (status != Ok) { if (pStream) { pStream->Release(); } - return NULL; + return nullptr; } UINT height, width; CallFunc(GdipGetImageHeight)(pBitmap, &height); @@ -1495,7 +1495,7 @@ CFX_DIBitmap* _FX_WindowsDIB_LoadFromBuf(BITMAPINFO* pbmi, CFX_DIBitmap* CGdiplusExt::LoadDIBitmap(WINDIB_Open_Args_ args) { PREVIEW3_DIBITMAP* pInfo = ::LoadDIBitmap(args); if (!pInfo) { - return NULL; + return nullptr; } int height = abs(pInfo->pbmi->bmiHeader.biHeight); int width = pInfo->pbmi->bmiHeader.biWidth; diff --git a/core/fxge/win32/win32_int.h b/core/fxge/win32/win32_int.h index 08253b33de..2143b76250 100644 --- a/core/fxge/win32/win32_int.h +++ b/core/fxge/win32/win32_int.h @@ -16,7 +16,7 @@ class CGdiplusExt { CGdiplusExt(); ~CGdiplusExt(); void Load(); - FX_BOOL IsAvailable() { return m_hModule != NULL; } + FX_BOOL IsAvailable() { return !!m_hModule; } FX_BOOL StretchBitMask(HDC hDC, BOOL bMonoDevice, const CFX_DIBitmap* pBitmap, @@ -188,7 +188,7 @@ class CGdiDisplayDriver : public CGdiDeviceDriver { FX_BOOL GetDIBits(CFX_DIBitmap* pBitmap, int left, int top, - void* pIccTransform = NULL, + void* pIccTransform = nullptr, FX_BOOL bDEdge = FALSE) override; FX_BOOL SetDIBits(const CFX_DIBSource* pBitmap, uint32_t color, @@ -229,7 +229,7 @@ class CGdiDisplayDriver : public CGdiDeviceDriver { const FX_RECT* pClipRect, int render_flags, int alpha_flag = 0, - void* pIccTransform = NULL, + void* pIccTransform = nullptr, int blend_type = FXDIB_BLEND_NORMAL); }; diff --git a/fpdfsdk/fpdfdoc_embeddertest.cpp b/fpdfsdk/fpdfdoc_embeddertest.cpp index 2450b6aea6..e0880deca5 100644 --- a/fpdfsdk/fpdfdoc_embeddertest.cpp +++ b/fpdfsdk/fpdfdoc_embeddertest.cpp @@ -23,22 +23,22 @@ TEST_F(FPDFDocEmbeddertest, DestGetPageIndex) { // Page number directly in item from Dests NameTree. FPDF_DEST dest = FPDF_GetNamedDestByName(document(), "First"); - EXPECT_NE(nullptr, dest); + EXPECT_TRUE(dest); EXPECT_EQ(1U, FPDFDest_GetPageIndex(document(), dest)); // Page number via object reference in item from Dests NameTree. dest = FPDF_GetNamedDestByName(document(), "Next"); - EXPECT_NE(nullptr, dest); + EXPECT_TRUE(dest); EXPECT_EQ(1U, FPDFDest_GetPageIndex(document(), dest)); // Page number directly in item from Dests dictionary. dest = FPDF_GetNamedDestByName(document(), "FirstAlternate"); - EXPECT_NE(nullptr, dest); + EXPECT_TRUE(dest); EXPECT_EQ(11U, FPDFDest_GetPageIndex(document(), dest)); // Invalid object reference in item from Dests NameTree. dest = FPDF_GetNamedDestByName(document(), "LastAlternate"); - EXPECT_NE(nullptr, dest); + EXPECT_TRUE(dest); EXPECT_EQ(0U, FPDFDest_GetPageIndex(document(), dest)); } @@ -88,7 +88,7 @@ TEST_F(FPDFDocEmbeddertest, Bookmarks) { EXPECT_EQ(0u, FPDFBookmark_GetTitle(nullptr, buf, sizeof(buf))); FPDF_BOOKMARK child = FPDFBookmark_GetFirstChild(document(), nullptr); - EXPECT_NE(nullptr, child); + EXPECT_TRUE(child); EXPECT_EQ(34u, FPDFBookmark_GetTitle(child, buf, sizeof(buf))); EXPECT_EQ(CFX_WideString(L"A Good Beginning"), CFX_WideString::FromUTF16LE(buf, 16)); @@ -96,7 +96,7 @@ TEST_F(FPDFDocEmbeddertest, Bookmarks) { EXPECT_EQ(nullptr, FPDFBookmark_GetFirstChild(document(), child)); FPDF_BOOKMARK sibling = FPDFBookmark_GetNextSibling(document(), child); - EXPECT_NE(nullptr, sibling); + EXPECT_TRUE(sibling); EXPECT_EQ(28u, FPDFBookmark_GetTitle(sibling, buf, sizeof(buf))); EXPECT_EQ(CFX_WideString(L"A Good Ending"), CFX_WideString::FromUTF16LE(buf, 13)); @@ -112,7 +112,7 @@ TEST_F(FPDFDocEmbeddertest, FindBookmarks) { std::unique_ptr title = GetFPDFWideString(L"A Good Beginning"); FPDF_BOOKMARK child = FPDFBookmark_Find(document(), title.get()); - EXPECT_NE(nullptr, child); + EXPECT_TRUE(child); // Check that the string matches. unsigned short buf[128]; diff --git a/fpdfsdk/fpdftext_embeddertest.cpp b/fpdfsdk/fpdftext_embeddertest.cpp index a5215c20cc..3070c30771 100644 --- a/fpdfsdk/fpdftext_embeddertest.cpp +++ b/fpdfsdk/fpdftext_embeddertest.cpp @@ -32,10 +32,10 @@ class FPDFTextEmbeddertest : public EmbedderTest {}; TEST_F(FPDFTextEmbeddertest, Text) { EXPECT_TRUE(OpenDocument("hello_world.pdf")); FPDF_PAGE page = LoadPage(0); - EXPECT_NE(nullptr, page); + EXPECT_TRUE(page); FPDF_TEXTPAGE textpage = FPDFText_LoadPage(page); - EXPECT_NE(nullptr, textpage); + EXPECT_TRUE(textpage); static const char expected[] = "Hello, world!\r\nGoodbye, world!"; unsigned short fixed_buffer[128]; @@ -141,10 +141,10 @@ TEST_F(FPDFTextEmbeddertest, Text) { TEST_F(FPDFTextEmbeddertest, TextSearch) { EXPECT_TRUE(OpenDocument("hello_world.pdf")); FPDF_PAGE page = LoadPage(0); - EXPECT_NE(nullptr, page); + EXPECT_TRUE(page); FPDF_TEXTPAGE textpage = FPDFText_LoadPage(page); - EXPECT_NE(nullptr, textpage); + EXPECT_TRUE(textpage); std::unique_ptr nope = GetFPDFWideString(L"nope"); @@ -157,7 +157,7 @@ TEST_F(FPDFTextEmbeddertest, TextSearch) { // No occurences of "nope" in test page. FPDF_SCHHANDLE search = FPDFText_FindStart(textpage, nope.get(), 0, 0); - EXPECT_NE(nullptr, search); + EXPECT_TRUE(search); EXPECT_EQ(0, FPDFText_GetSchResultIndex(search)); EXPECT_EQ(0, FPDFText_GetSchCount(search)); @@ -174,7 +174,7 @@ TEST_F(FPDFTextEmbeddertest, TextSearch) { // Two occurences of "world" in test page. search = FPDFText_FindStart(textpage, world.get(), 0, 2); - EXPECT_NE(nullptr, search); + EXPECT_TRUE(search); // Remains not found until advanced. EXPECT_EQ(0, FPDFText_GetSchResultIndex(search)); @@ -209,7 +209,7 @@ TEST_F(FPDFTextEmbeddertest, TextSearch) { // Exact search unaffected by case sensitiity and whole word flags. search = FPDFText_FindStart(textpage, world.get(), FPDF_MATCHCASE | FPDF_MATCHWHOLEWORD, 0); - EXPECT_NE(nullptr, search); + EXPECT_TRUE(search); EXPECT_TRUE(FPDFText_FindNext(search)); EXPECT_EQ(7, FPDFText_GetSchResultIndex(search)); EXPECT_EQ(5, FPDFText_GetSchCount(search)); @@ -217,7 +217,7 @@ TEST_F(FPDFTextEmbeddertest, TextSearch) { // Default is case-insensitive, so matching agaist caps works. search = FPDFText_FindStart(textpage, world_caps.get(), 0, 0); - EXPECT_NE(nullptr, search); + EXPECT_TRUE(search); EXPECT_TRUE(FPDFText_FindNext(search)); EXPECT_EQ(7, FPDFText_GetSchResultIndex(search)); EXPECT_EQ(5, FPDFText_GetSchCount(search)); @@ -252,10 +252,10 @@ TEST_F(FPDFTextEmbeddertest, TextSearch) { TEST_F(FPDFTextEmbeddertest, StreamLengthPastEndOfFile) { EXPECT_TRUE(OpenDocument("bug_57.pdf")); FPDF_PAGE page = LoadPage(0); - EXPECT_NE(nullptr, page); + EXPECT_TRUE(page); FPDF_TEXTPAGE textpage = FPDFText_LoadPage(page); - EXPECT_NE(nullptr, textpage); + EXPECT_TRUE(textpage); EXPECT_EQ(13, FPDFText_CountChars(textpage)); FPDFText_ClosePage(textpage); @@ -265,13 +265,13 @@ TEST_F(FPDFTextEmbeddertest, StreamLengthPastEndOfFile) { TEST_F(FPDFTextEmbeddertest, WebLinks) { EXPECT_TRUE(OpenDocument("weblinks.pdf")); FPDF_PAGE page = LoadPage(0); - EXPECT_NE(nullptr, page); + EXPECT_TRUE(page); FPDF_TEXTPAGE textpage = FPDFText_LoadPage(page); - EXPECT_NE(nullptr, textpage); + EXPECT_TRUE(textpage); FPDF_PAGELINK pagelink = FPDFLink_LoadWebLinks(textpage); - EXPECT_NE(nullptr, pagelink); + EXPECT_TRUE(pagelink); // Page contains two HTTP-style URLs. EXPECT_EQ(2, FPDFLink_CountWebLinks(pagelink)); @@ -371,10 +371,10 @@ TEST_F(FPDFTextEmbeddertest, WebLinks) { TEST_F(FPDFTextEmbeddertest, GetFontSize) { EXPECT_TRUE(OpenDocument("hello_world.pdf")); FPDF_PAGE page = LoadPage(0); - EXPECT_NE(nullptr, page); + EXPECT_TRUE(page); FPDF_TEXTPAGE textpage = FPDFText_LoadPage(page); - EXPECT_NE(nullptr, textpage); + EXPECT_TRUE(textpage); const double kExpectedFontsSizes[] = {12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 1, 1, 16, 16, 16, 16, 16, diff --git a/fpdfsdk/fxedit/fxet_edit.cpp b/fpdfsdk/fxedit/fxet_edit.cpp index d2abb176eb..0124913c5f 100644 --- a/fpdfsdk/fxedit/fxet_edit.cpp +++ b/fpdfsdk/fxedit/fxet_edit.cpp @@ -756,7 +756,6 @@ CFX_Edit::CFX_Edit(CPDF_VariableText* pVT) m_ptScrollPos(0, 0), m_ptRefreshScrollPos(0, 0), m_bEnableScroll(FALSE), - m_pIterator(nullptr), m_ptCaret(0.0f, 0.0f), m_Undo(kEditUndoMaxItems), m_nAlignment(0), diff --git a/xfa/fde/cfde_txtedtpage.cpp b/xfa/fde/cfde_txtedtpage.cpp index cecbf73b25..406b19b386 100644 --- a/xfa/fde/cfde_txtedtpage.cpp +++ b/xfa/fde/cfde_txtedtpage.cpp @@ -29,8 +29,7 @@ IFDE_TxtEdtPage* IFDE_TxtEdtPage::Create(CFDE_TxtEdtEngine* pEngine, } CFDE_TxtEdtPage::CFDE_TxtEdtPage(CFDE_TxtEdtEngine* pEngine, int32_t nPageIndex) - : m_pIter(nullptr), - m_pTextSet(nullptr), + : m_pTextSet(nullptr), m_pBgnParag(nullptr), m_pEndParag(nullptr), m_nRefCount(0), diff --git a/xfa/fwl/basewidget/fwl_datetimepickerimp.cpp b/xfa/fwl/basewidget/fwl_datetimepickerimp.cpp index c6cef1c37d..6df6fb364e 100644 --- a/xfa/fwl/basewidget/fwl_datetimepickerimp.cpp +++ b/xfa/fwl/basewidget/fwl_datetimepickerimp.cpp @@ -426,10 +426,7 @@ CFWL_DateTimePickerImp::CFWL_DateTimePickerImp( m_iYear(-1), m_iMonth(-1), m_iDay(-1), - m_bLBtnDown(FALSE), - m_pEdit(nullptr), - m_pMonthCal(nullptr), - m_pForm(nullptr) { + m_bLBtnDown(FALSE) { m_rtBtn.Set(0, 0, 0, 0); } diff --git a/xfa/fwl/core/fwl_widgetimp.cpp b/xfa/fwl/core/fwl_widgetimp.cpp index 1c0d28379d..27f8a44c79 100644 --- a/xfa/fwl/core/fwl_widgetimp.cpp +++ b/xfa/fwl/core/fwl_widgetimp.cpp @@ -25,6 +25,8 @@ #define FWL_STYLEEXT_MNU_Vert (1L << 0) +IFWL_Widget::IFWL_Widget() {} + IFWL_Widget::~IFWL_Widget() {} FWL_Error IFWL_Widget::GetClassName(CFX_WideString& wsClass) const { diff --git a/xfa/fwl/core/ifwl_widget.h b/xfa/fwl/core/ifwl_widget.h index 0b864fee7d..90a484def2 100644 --- a/xfa/fwl/core/ifwl_widget.h +++ b/xfa/fwl/core/ifwl_widget.h @@ -59,7 +59,7 @@ class IFWL_WidgetDelegate; class IFWL_Widget { public: - IFWL_Widget() : m_pImpl(nullptr) {} + IFWL_Widget(); virtual ~IFWL_Widget(); FWL_Error GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE); diff --git a/xfa/fxfa/app/xfa_textlayout.cpp b/xfa/fxfa/app/xfa_textlayout.cpp index 3c7497c660..c40e29c04b 100644 --- a/xfa/fxfa/app/xfa_textlayout.cpp +++ b/xfa/fxfa/app/xfa_textlayout.cpp @@ -652,12 +652,8 @@ CXFA_TextLayout::CXFA_TextLayout(CXFA_TextProvider* pTextProvider) m_pTextProvider(pTextProvider), m_pTextDataNode(nullptr), m_bRichText(FALSE), - m_pAllocator(nullptr), - m_pBreak(nullptr), - m_pLoader(nullptr), m_iLines(0), m_fMaxWidth(0), - m_pTabstopContext(nullptr), m_bBlockContinue(TRUE) { ASSERT(m_pTextProvider); } diff --git a/xfa/fxfa/parser/cxfa_widgetdata.cpp b/xfa/fxfa/parser/cxfa_widgetdata.cpp index 33dcb475e7..5e64647788 100644 --- a/xfa/fxfa/parser/cxfa_widgetdata.cpp +++ b/xfa/fxfa/parser/cxfa_widgetdata.cpp @@ -1071,7 +1071,7 @@ int32_t CXFA_WidgetData::GetNumberOfCells() { CFX_WideString CXFA_WidgetData::GetBarcodeType() { CXFA_Node* pUIChild = GetUIChild(); return pUIChild ? CFX_WideString(pUIChild->GetCData(XFA_ATTRIBUTE_Type)) - : nullptr; + : CFX_WideString(); } FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_CharEncoding(int32_t& val) { -- cgit v1.2.3