From 85d1f2c2f9f1e746bedb1b6f03576613f54fbc27 Mon Sep 17 00:00:00 2001 From: dsinclair Date: Thu, 23 Jun 2016 12:40:16 -0700 Subject: Remove NULL in xfa/ This CL converts all NULL's to nullptr. All instances of comparison to nullptr have been removed. Review-Url: https://codereview.chromium.org/2095653002 --- xfa/fgas/crt/fgas_codepage.cpp | 12 +-- xfa/fgas/crt/fgas_stream.cpp | 164 ++++++++++++++++---------------- xfa/fgas/crt/fgas_stream.h | 2 +- xfa/fgas/crt/fgas_system.cpp | 4 +- xfa/fgas/crt/fgas_system.h | 2 +- xfa/fgas/crt/fgas_utils.cpp | 24 ++--- xfa/fgas/crt/fgas_utils.h | 4 +- xfa/fgas/font/fgas_font.h | 26 ++--- xfa/fgas/font/fgas_fontutils.cpp | 2 +- xfa/fgas/font/fgas_gefont.cpp | 82 ++++++++-------- xfa/fgas/font/fgas_stdfontmgr.cpp | 104 ++++++++++---------- xfa/fgas/font/fgas_stdfontmgr.h | 38 ++++---- xfa/fgas/layout/fgas_rtfbreak.cpp | 82 +++++++--------- xfa/fgas/layout/fgas_rtfbreak.h | 20 ++-- xfa/fgas/layout/fgas_textbreak.cpp | 87 ++++++++--------- xfa/fgas/layout/fgas_textbreak.h | 10 +- xfa/fgas/localization/fgas_datetime.cpp | 4 +- xfa/fgas/localization/fgas_locale.cpp | 20 ++-- 18 files changed, 335 insertions(+), 352 deletions(-) (limited to 'xfa/fgas') diff --git a/xfa/fgas/crt/fgas_codepage.cpp b/xfa/fgas/crt/fgas_codepage.cpp index 2087cac138..834056eddd 100644 --- a/xfa/fgas/crt/fgas_codepage.cpp +++ b/xfa/fgas/crt/fgas_codepage.cpp @@ -272,7 +272,7 @@ const FX_STR2CPHASH g_FXCPHashTable[] = { }; uint16_t GetCodePageFromStringA(const FX_CHAR* pStr, int32_t iLength) { - ASSERT(pStr != NULL); + ASSERT(pStr); if (iLength < 0) { iLength = FXSYS_strlen(pStr); } @@ -370,7 +370,7 @@ uint16_t FX_GetCodePageFromStringW(const FX_WCHAR* pStr, int32_t iLength) { } void FX_SwapByteOrder(FX_WCHAR* pStr, int32_t iLength) { - ASSERT(pStr != NULL); + ASSERT(pStr); if (iLength < 0) { iLength = FXSYS_wcslen(pStr); } @@ -392,7 +392,7 @@ void FX_SwapByteOrder(FX_WCHAR* pStr, int32_t iLength) { } void FX_UTF16ToWChar(void* pBuffer, int32_t iLength) { - ASSERT(pBuffer != NULL && iLength > 0); + ASSERT(pBuffer && iLength > 0); if (sizeof(FX_WCHAR) == 2) { return; } @@ -404,7 +404,7 @@ void FX_UTF16ToWChar(void* pBuffer, int32_t iLength) { } void FX_WCharToUTF16(void* pBuffer, int32_t iLength) { - ASSERT(pBuffer != NULL && iLength > 0); + ASSERT(pBuffer && iLength > 0); if (sizeof(FX_WCHAR) == 2) { return; } @@ -430,7 +430,7 @@ int32_t FX_UTF8Decode(const FX_CHAR* pSrc, int32_t* pSrcLen, FX_WCHAR* pDst, int32_t* pDstLen) { - if (pSrcLen == NULL || pDstLen == NULL) { + if (!pSrcLen || !pDstLen) { return -1; } int32_t iSrcLen = *pSrcLen; @@ -439,7 +439,7 @@ int32_t FX_UTF8Decode(const FX_CHAR* pSrc, return 1; } int32_t iDstLen = *pDstLen; - FX_BOOL bValidDst = (pDst != NULL && iDstLen > 0); + FX_BOOL bValidDst = (pDst && iDstLen > 0); uint32_t dwCode = 0; int32_t iPending = 0; int32_t iSrcNum = 0, iDstNum = 0; diff --git a/xfa/fgas/crt/fgas_stream.cpp b/xfa/fgas/crt/fgas_stream.cpp index 458cf5edad..dd54fbed28 100644 --- a/xfa/fgas/crt/fgas_stream.cpp +++ b/xfa/fgas/crt/fgas_stream.cpp @@ -228,7 +228,7 @@ class CFX_Stream : public IFX_Stream { int32_t ReadString(FX_WCHAR* pStr, int32_t iMaxLength, FX_BOOL& bEOS, - int32_t const* pByteSize = NULL) override; + int32_t const* pByteSize = nullptr) override; int32_t WriteData(const uint8_t* pBuffer, int32_t iBufferSize) override; int32_t WriteString(const FX_WCHAR* pStr, int32_t iLength) override; void Flush() override; @@ -268,7 +268,7 @@ class CFX_TextStream : public IFX_Stream { int32_t ReadString(FX_WCHAR* pStr, int32_t iMaxLength, FX_BOOL& bEOS, - int32_t const* pByteSize = NULL) override; + int32_t const* pByteSize = nullptr) override; int32_t WriteData(const uint8_t* pBuffer, int32_t iBufferSize) override; int32_t WriteString(const FX_WCHAR* pStr, int32_t iLength) override; void Flush() override; @@ -308,7 +308,7 @@ class CFGAS_FileRead : public IFX_FileRead { }; int32_t FileLength(FXSYS_FILE* file) { - ASSERT(file != NULL); + ASSERT(file); #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_ return _filelength(_fileno(file)); #else @@ -321,7 +321,7 @@ int32_t FileLength(FXSYS_FILE* file) { } FX_BOOL FileSetSize(FXSYS_FILE* file, int32_t size) { - ASSERT(file != NULL); + ASSERT(file); #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_ return _chsize(_fileno(file), size) == 0; #elif _FX_OS_ == _FX_WIN32_MOBILE_ @@ -346,7 +346,7 @@ IFX_Stream* IFX_Stream::CreateStream(IFX_BufferRead* pBufferRead, if (!pSR->LoadBufferRead(pBufferRead, iFileSize, dwAccess, bReleaseBufferRead)) { pSR->Release(); - return NULL; + return nullptr; } if (dwAccess & FX_STREAMACCESS_Text) { return new CFX_TextStream(pSR, TRUE); @@ -358,7 +358,7 @@ IFX_Stream* IFX_Stream::CreateStream(IFX_FileRead* pFileRead, CFX_Stream* pSR = new CFX_Stream; if (!pSR->LoadFileRead(pFileRead, dwAccess)) { pSR->Release(); - return NULL; + return nullptr; } if (dwAccess & FX_STREAMACCESS_Text) { return new CFX_TextStream(pSR, TRUE); @@ -370,7 +370,7 @@ IFX_Stream* IFX_Stream::CreateStream(IFX_FileWrite* pFileWrite, CFX_Stream* pSR = new CFX_Stream; if (!pSR->LoadFileWrite(pFileWrite, dwAccess)) { pSR->Release(); - return NULL; + return nullptr; } if (dwAccess & FX_STREAMACCESS_Text) { return new CFX_TextStream(pSR, TRUE); @@ -382,7 +382,7 @@ IFX_Stream* IFX_Stream::CreateStream(const FX_WCHAR* pszFileName, CFX_Stream* pSR = new CFX_Stream; if (!pSR->LoadFile(pszFileName, dwAccess)) { pSR->Release(); - return NULL; + return nullptr; } if (dwAccess & FX_STREAMACCESS_Text) { return new CFX_TextStream(pSR, TRUE); @@ -395,7 +395,7 @@ IFX_Stream* IFX_Stream::CreateStream(uint8_t* pData, CFX_Stream* pSR = new CFX_Stream; if (!pSR->LoadBuffer(pData, length, dwAccess)) { pSR->Release(); - return NULL; + return nullptr; } if (dwAccess & FX_STREAMACCESS_Text) { return new CFX_TextStream(pSR, TRUE); @@ -414,8 +414,8 @@ CFX_FileStreamImp::~CFX_FileStreamImp() { FX_BOOL CFX_FileStreamImp::LoadFile(const FX_WCHAR* pszSrcFileName, uint32_t dwAccess) { - ASSERT(m_hFile == NULL); - ASSERT(pszSrcFileName != NULL && FXSYS_wcslen(pszSrcFileName) > 0); + ASSERT(!m_hFile); + ASSERT(pszSrcFileName && FXSYS_wcslen(pszSrcFileName) > 0); #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN32_MOBILE_ || \ _FX_OS_ == _FX_WIN64_ const FX_WCHAR* wsMode; @@ -462,14 +462,14 @@ FX_BOOL CFX_FileStreamImp::LoadFile(const FX_WCHAR* pszSrcFileName, } CFX_ByteString szFileName = CFX_ByteString::FromUnicode(pszSrcFileName); m_hFile = FXSYS_fopen(szFileName.c_str(), wsMode); - if (m_hFile == NULL) { + if (!m_hFile) { if (dwAccess & FX_STREAMACCESS_Write) { if (dwAccess & FX_STREAMACCESS_Create) { m_hFile = FXSYS_fopen(szFileName.c_str(), "w+b"); } - if (m_hFile == NULL) { + if (!m_hFile) { m_hFile = FXSYS_fopen(szFileName.c_str(), "r+b"); - if (m_hFile == NULL) { + if (!m_hFile) { return FALSE; } if (dwAccess & FX_STREAMACCESS_Truncate) { @@ -491,32 +491,32 @@ FX_BOOL CFX_FileStreamImp::LoadFile(const FX_WCHAR* pszSrcFileName, return TRUE; } int32_t CFX_FileStreamImp::GetLength() const { - ASSERT(m_hFile != NULL); + ASSERT(m_hFile); return m_iLength; } int32_t CFX_FileStreamImp::Seek(FX_STREAMSEEK eSeek, int32_t iOffset) { - ASSERT(m_hFile != NULL); + ASSERT(m_hFile); FXSYS_fseek(m_hFile, iOffset, eSeek); return FXSYS_ftell(m_hFile); } int32_t CFX_FileStreamImp::GetPosition() { - ASSERT(m_hFile != NULL); + ASSERT(m_hFile); return FXSYS_ftell(m_hFile); } FX_BOOL CFX_FileStreamImp::IsEOF() const { - ASSERT(m_hFile != NULL); + ASSERT(m_hFile); return FXSYS_ftell(m_hFile) >= m_iLength; } int32_t CFX_FileStreamImp::ReadData(uint8_t* pBuffer, int32_t iBufferSize) { - ASSERT(m_hFile != NULL); - ASSERT(pBuffer != NULL && iBufferSize > 0); + ASSERT(m_hFile); + ASSERT(pBuffer && iBufferSize > 0); return FXSYS_fread(pBuffer, 1, iBufferSize, m_hFile); } int32_t CFX_FileStreamImp::ReadString(FX_WCHAR* pStr, int32_t iMaxLength, FX_BOOL& bEOS) { - ASSERT(m_hFile != NULL); - ASSERT(pStr != NULL && iMaxLength > 0); + ASSERT(m_hFile); + ASSERT(pStr && iMaxLength > 0); if (m_iLength <= 0) { return 0; } @@ -573,10 +573,10 @@ FX_BOOL CFX_FileStreamImp::SetLength(int32_t iLength) { return bRet; } CFX_FileReadStreamImp::CFX_FileReadStreamImp() - : m_pFileRead(NULL), m_iPosition(0), m_iLength(0) {} + : m_pFileRead(nullptr), m_iPosition(0), m_iLength(0) {} FX_BOOL CFX_FileReadStreamImp::LoadFileRead(IFX_FileRead* pFileRead, uint32_t dwAccess) { - ASSERT(m_pFileRead == NULL && pFileRead != NULL); + ASSERT(!m_pFileRead && pFileRead); if (dwAccess & FX_STREAMACCESS_Write) { return FALSE; } @@ -610,8 +610,8 @@ FX_BOOL CFX_FileReadStreamImp::IsEOF() const { return m_iPosition >= m_iLength; } int32_t CFX_FileReadStreamImp::ReadData(uint8_t* pBuffer, int32_t iBufferSize) { - ASSERT(m_pFileRead != NULL); - ASSERT(pBuffer != NULL && iBufferSize > 0); + ASSERT(m_pFileRead); + ASSERT(pBuffer && iBufferSize > 0); if (iBufferSize > m_iLength - m_iPosition) { iBufferSize = m_iLength - m_iPosition; } @@ -624,8 +624,8 @@ int32_t CFX_FileReadStreamImp::ReadData(uint8_t* pBuffer, int32_t iBufferSize) { int32_t CFX_FileReadStreamImp::ReadString(FX_WCHAR* pStr, int32_t iMaxLength, FX_BOOL& bEOS) { - ASSERT(m_pFileRead != NULL); - ASSERT(pStr != NULL && iMaxLength > 0); + ASSERT(m_pFileRead); + ASSERT(pStr && iMaxLength > 0); iMaxLength = ReadData((uint8_t*)pStr, iMaxLength * 2) / 2; if (iMaxLength <= 0) { return 0; @@ -638,12 +638,12 @@ int32_t CFX_FileReadStreamImp::ReadString(FX_WCHAR* pStr, return i; } CFX_BufferReadStreamImp::CFX_BufferReadStreamImp() - : m_pBufferRead(NULL), + : m_pBufferRead(nullptr), m_bReleaseBufferRead(FALSE), m_iPosition(0), m_iBufferSize(0) {} CFX_BufferReadStreamImp::~CFX_BufferReadStreamImp() { - if (m_bReleaseBufferRead && m_pBufferRead != NULL) { + if (m_bReleaseBufferRead && m_pBufferRead) { m_pBufferRead->Release(); } } @@ -651,7 +651,7 @@ FX_BOOL CFX_BufferReadStreamImp::LoadBufferRead(IFX_BufferRead* pBufferRead, int32_t iFileSize, uint32_t dwAccess, FX_BOOL bReleaseBufferRead) { - ASSERT(m_pBufferRead == NULL && pBufferRead != NULL); + ASSERT(!m_pBufferRead && pBufferRead); if (dwAccess & FX_STREAMACCESS_Write) { return FALSE; } @@ -699,8 +699,8 @@ FX_BOOL CFX_BufferReadStreamImp::IsEOF() const { } int32_t CFX_BufferReadStreamImp::ReadData(uint8_t* pBuffer, int32_t iBufferSize) { - ASSERT(m_pBufferRead != NULL); - ASSERT(pBuffer != NULL && iBufferSize > 0); + ASSERT(m_pBufferRead); + ASSERT(pBuffer && iBufferSize > 0); int32_t iLength = GetLength(); if (m_iPosition >= iLength) { return 0; @@ -754,8 +754,8 @@ int32_t CFX_BufferReadStreamImp::ReadData(uint8_t* pBuffer, int32_t CFX_BufferReadStreamImp::ReadString(FX_WCHAR* pStr, int32_t iMaxLength, FX_BOOL& bEOS) { - ASSERT(m_pBufferRead != NULL); - ASSERT(pStr != NULL && iMaxLength > 0); + ASSERT(m_pBufferRead); + ASSERT(pStr && iMaxLength > 0); iMaxLength = ReadData((uint8_t*)pStr, iMaxLength * 2) / 2; if (iMaxLength <= 0) { return 0; @@ -768,10 +768,10 @@ int32_t CFX_BufferReadStreamImp::ReadString(FX_WCHAR* pStr, return i; } CFX_FileWriteStreamImp::CFX_FileWriteStreamImp() - : m_pFileWrite(NULL), m_iPosition(0) {} + : m_pFileWrite(nullptr), m_iPosition(0) {} FX_BOOL CFX_FileWriteStreamImp::LoadFileWrite(IFX_FileWrite* pFileWrite, uint32_t dwAccess) { - ASSERT(m_pFileWrite == NULL && pFileWrite != NULL); + ASSERT(!m_pFileWrite && pFileWrite); if (dwAccess & FX_STREAMACCESS_Read) { return FALSE; } @@ -844,11 +844,11 @@ FX_BOOL CFX_BufferStreamImp::LoadBuffer(uint8_t* pData, return TRUE; } int32_t CFX_BufferStreamImp::GetLength() const { - ASSERT(m_pData != NULL); + ASSERT(m_pData); return m_iLength; } int32_t CFX_BufferStreamImp::Seek(FX_STREAMSEEK eSeek, int32_t iOffset) { - ASSERT(m_pData != NULL); + ASSERT(m_pData); if (eSeek == FX_STREAMSEEK_Begin) { m_iPosition = iOffset; } else if (eSeek == FX_STREAMSEEK_Current) { @@ -865,16 +865,16 @@ int32_t CFX_BufferStreamImp::Seek(FX_STREAMSEEK eSeek, int32_t iOffset) { return m_iPosition; } int32_t CFX_BufferStreamImp::GetPosition() { - ASSERT(m_pData != NULL); + ASSERT(m_pData); return m_iPosition; } FX_BOOL CFX_BufferStreamImp::IsEOF() const { - ASSERT(m_pData != NULL); + ASSERT(m_pData); return m_iPosition >= m_iLength; } int32_t CFX_BufferStreamImp::ReadData(uint8_t* pBuffer, int32_t iBufferSize) { - ASSERT(m_pData != NULL); - ASSERT(pBuffer != NULL && iBufferSize > 0); + ASSERT(m_pData); + ASSERT(pBuffer && iBufferSize > 0); int32_t iLen = std::min(m_iLength - m_iPosition, iBufferSize); if (iLen <= 0) { return 0; @@ -886,8 +886,8 @@ int32_t CFX_BufferStreamImp::ReadData(uint8_t* pBuffer, int32_t iBufferSize) { int32_t CFX_BufferStreamImp::ReadString(FX_WCHAR* pStr, int32_t iMaxLength, FX_BOOL& bEOS) { - ASSERT(m_pData != NULL); - ASSERT(pStr != NULL && iMaxLength > 0); + ASSERT(m_pData); + ASSERT(pStr && iMaxLength > 0); int32_t iLen = std::min((m_iLength - m_iPosition) / 2, iMaxLength); if (iLen <= 0) { return 0; @@ -934,19 +934,19 @@ int32_t CFX_BufferStreamImp::WriteString(const FX_WCHAR* pStr, } IFX_Stream* IFX_Stream::CreateTextStream(IFX_Stream* pBaseStream, FX_BOOL bDeleteOnRelease) { - ASSERT(pBaseStream != NULL); + ASSERT(pBaseStream); return new CFX_TextStream(pBaseStream, bDeleteOnRelease); } CFX_TextStream::CFX_TextStream(IFX_Stream* pStream, FX_BOOL bDelStream) : m_wCodePage(FX_CODEPAGE_DefANSI), m_wBOMLength(0), m_dwBOM(0), - m_pBuf(NULL), + m_pBuf(nullptr), m_iBufSize(0), m_bDelStream(bDelStream), m_pStreamImp(pStream), m_iRefCount(1) { - ASSERT(m_pStreamImp != NULL); + ASSERT(m_pStreamImp); m_pStreamImp->Retain(); InitStream(); } @@ -955,7 +955,7 @@ CFX_TextStream::~CFX_TextStream() { if (m_bDelStream) { m_pStreamImp->Release(); } - if (m_pBuf != NULL) { + if (m_pBuf) { FX_Free(m_pBuf); } } @@ -1048,8 +1048,8 @@ IFX_Stream* CFX_TextStream::CreateSharedStream(uint32_t dwAccess, int32_t iLength) { IFX_Stream* pSR = m_pStreamImp->CreateSharedStream(dwAccess, iOffset, iLength); - if (pSR == NULL) { - return NULL; + if (!pSR) { + return nullptr; } if (dwAccess & FX_STREAMACCESS_Text) { return new CFX_TextStream(pSR, TRUE); @@ -1075,14 +1075,14 @@ int32_t CFX_TextStream::ReadString(FX_WCHAR* pStr, int32_t iMaxLength, FX_BOOL& bEOS, int32_t const* pByteSize) { - ASSERT(pStr != NULL && iMaxLength > 0); - if (m_pStreamImp == NULL) { + ASSERT(pStr && iMaxLength > 0); + if (!m_pStreamImp) { return -1; } int32_t iLen; if (m_wCodePage == FX_CODEPAGE_UTF16LE || m_wCodePage == FX_CODEPAGE_UTF16BE) { - int32_t iBytes = pByteSize == NULL ? iMaxLength * 2 : *pByteSize; + int32_t iBytes = pByteSize ? *pByteSize : iMaxLength * 2; iLen = m_pStreamImp->ReadData((uint8_t*)pStr, iBytes); iMaxLength = iLen / 2; if (sizeof(FX_WCHAR) > 2) { @@ -1099,10 +1099,10 @@ int32_t CFX_TextStream::ReadString(FX_WCHAR* pStr, #endif } else { int32_t pos = m_pStreamImp->GetPosition(); - int32_t iBytes = pByteSize == NULL ? iMaxLength : *pByteSize; + int32_t iBytes = pByteSize ? *pByteSize : iMaxLength; iBytes = std::min(iBytes, m_pStreamImp->GetLength() - pos); if (iBytes > 0) { - if (m_pBuf == NULL) { + if (!m_pBuf) { m_pBuf = FX_Alloc(uint8_t, iBytes); m_iBufSize = iBytes; } else if (iBytes > m_iBufSize) { @@ -1125,7 +1125,7 @@ int32_t CFX_TextStream::ReadString(FX_WCHAR* pStr, return iMaxLength; } int32_t CFX_TextStream::WriteString(const FX_WCHAR* pStr, int32_t iLength) { - ASSERT(pStr != NULL && iLength > 0); + ASSERT(pStr && iLength > 0); if ((m_pStreamImp->GetAccessModes() & FX_STREAMACCESS_Write) == 0) { return -1; } @@ -1143,7 +1143,7 @@ int32_t CFX_TextStream::WriteString(const FX_WCHAR* pStr, int32_t iLength) { } CFX_Stream::CFX_Stream() : m_eStreamType(FX_SREAMTYPE_Unknown), - m_pStreamImp(NULL), + m_pStreamImp(nullptr), m_dwAccess(0), m_iTotalSize(0), m_iPosition(0), @@ -1269,7 +1269,7 @@ uint32_t CFX_Stream::GetAccessModes() const { } int32_t CFX_Stream::GetLength() const { - if (m_pStreamImp == NULL) { + if (!m_pStreamImp) { return -1; } if (m_eStreamType == FX_STREAMTYPE_File || @@ -1279,7 +1279,7 @@ int32_t CFX_Stream::GetLength() const { return m_iLength; } int32_t CFX_Stream::Seek(FX_STREAMSEEK eSeek, int32_t iOffset) { - if (m_pStreamImp == NULL) { + if (!m_pStreamImp) { return -1; } if (m_eStreamType == FX_STREAMTYPE_File || @@ -1304,7 +1304,7 @@ int32_t CFX_Stream::Seek(FX_STREAMSEEK eSeek, int32_t iOffset) { return m_iPosition - m_iStart; } int32_t CFX_Stream::GetPosition() { - if (m_pStreamImp == NULL) { + if (!m_pStreamImp) { return -1; } if (m_eStreamType == FX_STREAMTYPE_File || @@ -1314,7 +1314,7 @@ int32_t CFX_Stream::GetPosition() { return m_iPosition - m_iStart; } FX_BOOL CFX_Stream::IsEOF() const { - if (m_pStreamImp == NULL) { + if (!m_pStreamImp) { return TRUE; } if (m_eStreamType == FX_STREAMTYPE_File || @@ -1324,8 +1324,8 @@ FX_BOOL CFX_Stream::IsEOF() const { return m_iPosition >= m_iStart + m_iLength; } int32_t CFX_Stream::ReadData(uint8_t* pBuffer, int32_t iBufferSize) { - ASSERT(pBuffer != NULL && iBufferSize > 0); - if (m_pStreamImp == NULL) { + ASSERT(pBuffer && iBufferSize > 0); + if (!m_pStreamImp) { return -1; } int32_t iLen = std::min(m_iStart + m_iLength - m_iPosition, iBufferSize); @@ -1343,13 +1343,13 @@ int32_t CFX_Stream::ReadString(FX_WCHAR* pStr, int32_t iMaxLength, FX_BOOL& bEOS, int32_t const* pByteSize) { - ASSERT(pStr != NULL && iMaxLength > 0); - if (m_pStreamImp == NULL) { + ASSERT(pStr && iMaxLength > 0); + if (!m_pStreamImp) { return -1; } int32_t iEnd = m_iStart + m_iLength; int32_t iLen = iEnd - m_iPosition; - if (pByteSize != NULL) { + if (pByteSize) { iLen = std::min(iLen, *pByteSize); } iLen = std::min(iEnd / 2, iMaxLength); @@ -1368,8 +1368,8 @@ int32_t CFX_Stream::ReadString(FX_WCHAR* pStr, } int32_t CFX_Stream::WriteData(const uint8_t* pBuffer, int32_t iBufferSize) { - ASSERT(pBuffer != NULL && iBufferSize > 0); - if (m_pStreamImp == NULL) { + ASSERT(pBuffer && iBufferSize > 0); + if (!m_pStreamImp) { return -1; } if ((m_dwAccess & FX_STREAMACCESS_Write) == 0) { @@ -1394,8 +1394,8 @@ int32_t CFX_Stream::WriteData(const uint8_t* pBuffer, int32_t iBufferSize) { return iLen; } int32_t CFX_Stream::WriteString(const FX_WCHAR* pStr, int32_t iLength) { - ASSERT(pStr != NULL && iLength > 0); - if (m_pStreamImp == NULL) { + ASSERT(pStr && iLength > 0); + if (!m_pStreamImp) { return -1; } if ((m_dwAccess & FX_STREAMACCESS_Write) == 0) { @@ -1420,7 +1420,7 @@ int32_t CFX_Stream::WriteString(const FX_WCHAR* pStr, int32_t iLength) { return iLen; } void CFX_Stream::Flush() { - if (m_pStreamImp == NULL) { + if (!m_pStreamImp) { return; } if ((m_dwAccess & FX_STREAMACCESS_Write) == 0) { @@ -1429,7 +1429,7 @@ void CFX_Stream::Flush() { m_pStreamImp->Flush(); } FX_BOOL CFX_Stream::SetLength(int32_t iLength) { - if (m_pStreamImp == NULL) { + if (!m_pStreamImp) { return FALSE; } if ((m_dwAccess & FX_STREAMACCESS_Write) == 0) { @@ -1438,7 +1438,7 @@ FX_BOOL CFX_Stream::SetLength(int32_t iLength) { return m_pStreamImp->SetLength(iLength); } int32_t CFX_Stream::GetBOM(uint8_t bom[4]) const { - if (m_pStreamImp == NULL) { + if (!m_pStreamImp) { return -1; } return 0; @@ -1461,25 +1461,25 @@ IFX_Stream* CFX_Stream::CreateSharedStream(uint32_t dwAccess, int32_t iOffset, int32_t iLength) { ASSERT(iLength > 0); - if (m_pStreamImp == NULL) { - return NULL; + if (!m_pStreamImp) { + return nullptr; } if ((m_dwAccess & FX_STREAMACCESS_Text) != 0 && (dwAccess & FX_STREAMACCESS_Text) == 0) { - return NULL; + return nullptr; } if ((m_dwAccess & FX_STREAMACCESS_Write) == 0 && (dwAccess & FX_STREAMACCESS_Write) != 0) { - return NULL; + return nullptr; } int32_t iStart = m_iStart + iOffset; int32_t iTotal = m_iStart + m_iLength; if (iStart < m_iStart || iStart >= iTotal) { - return NULL; + return nullptr; } int32_t iEnd = iStart + iLength; if (iEnd < iStart || iEnd > iTotal) { - return NULL; + return nullptr; } CFX_Stream* pShared = new CFX_Stream; pShared->m_eStreamType = FX_STREAMTYPE_Stream; @@ -1496,12 +1496,12 @@ IFX_Stream* CFX_Stream::CreateSharedStream(uint32_t dwAccess, } IFX_FileRead* FX_CreateFileRead(IFX_Stream* pBaseStream, FX_BOOL bReleaseStream) { - ASSERT(pBaseStream != NULL); + ASSERT(pBaseStream); return new CFGAS_FileRead(pBaseStream, bReleaseStream); } CFGAS_FileRead::CFGAS_FileRead(IFX_Stream* pStream, FX_BOOL bReleaseStream) : m_bReleaseStream(bReleaseStream), m_pStream(pStream) { - ASSERT(m_pStream != NULL); + ASSERT(m_pStream); } CFGAS_FileRead::~CFGAS_FileRead() { if (m_bReleaseStream) { diff --git a/xfa/fgas/crt/fgas_stream.h b/xfa/fgas/crt/fgas_stream.h index 2da06fc7ed..5cd2a3daa7 100644 --- a/xfa/fgas/crt/fgas_stream.h +++ b/xfa/fgas/crt/fgas_stream.h @@ -58,7 +58,7 @@ class IFX_Stream { virtual int32_t ReadString(FX_WCHAR* pStr, int32_t iMaxLength, FX_BOOL& bEOS, - int32_t const* pByteSize = NULL) = 0; + int32_t const* pByteSize = nullptr) = 0; virtual int32_t WriteData(const uint8_t* pBuffer, int32_t iBufferSize) = 0; virtual int32_t WriteString(const FX_WCHAR* pStr, int32_t iLength) = 0; virtual void Flush() = 0; diff --git a/xfa/fgas/crt/fgas_system.cpp b/xfa/fgas/crt/fgas_system.cpp index 43d55b108a..b5cabedec5 100644 --- a/xfa/fgas/crt/fgas_system.cpp +++ b/xfa/fgas/crt/fgas_system.cpp @@ -23,7 +23,7 @@ inline int32_t FX_tolower(int32_t ch) { } // namespace int32_t FX_wcsnicmp(const FX_WCHAR* s1, const FX_WCHAR* s2, size_t count) { - ASSERT(s1 != NULL && s2 != NULL && count > 0); + ASSERT(s1 && s2 && count > 0); FX_WCHAR wch1 = 0; FX_WCHAR wch2 = 0; while (count-- > 0) { @@ -37,7 +37,7 @@ int32_t FX_wcsnicmp(const FX_WCHAR* s1, const FX_WCHAR* s2, size_t count) { } FX_FLOAT FX_wcstof(const FX_WCHAR* pwsStr, int32_t iLength, int32_t* pUsedLen) { - ASSERT(pwsStr != NULL); + ASSERT(pwsStr); if (iLength < 0) { iLength = FXSYS_wcslen(pwsStr); } diff --git a/xfa/fgas/crt/fgas_system.h b/xfa/fgas/crt/fgas_system.h index a3215ffa37..83c67735dc 100644 --- a/xfa/fgas/crt/fgas_system.h +++ b/xfa/fgas/crt/fgas_system.h @@ -11,7 +11,7 @@ FX_FLOAT FX_wcstof(const FX_WCHAR* pwsStr, int32_t iLength = -1, - int32_t* pUsedLen = NULL); + int32_t* pUsedLen = nullptr); int32_t FX_wcsnicmp(const FX_WCHAR* s1, const FX_WCHAR* s2, size_t count); #endif // XFA_FGAS_CRT_FGAS_SYSTEM_H_ diff --git a/xfa/fgas/crt/fgas_utils.cpp b/xfa/fgas/crt/fgas_utils.cpp index 6db7aa35ab..7207f055e5 100644 --- a/xfa/fgas/crt/fgas_utils.cpp +++ b/xfa/fgas/crt/fgas_utils.cpp @@ -133,9 +133,9 @@ int32_t CFX_BaseArray::RemoveLast(int32_t iCount) { void CFX_BaseArray::RemoveAll(FX_BOOL bLeaveMemory) { if (!bLeaveMemory) { uint8_t*& pBuffer = m_pData->pBuffer; - if (pBuffer != NULL) { + if (pBuffer) { FX_Free(pBuffer); - pBuffer = NULL; + pBuffer = nullptr; } m_pData->iTotalCount = 0; } @@ -178,14 +178,14 @@ uint8_t* CFX_BaseMassArrayImp::AddSpaceTo(int32_t index) { } } } - ASSERT(pChunk != NULL); + ASSERT(pChunk); m_iBlockCount = index + 1; return pChunk + (index % m_iChunkSize) * m_iBlockSize; } uint8_t* CFX_BaseMassArrayImp::GetAt(int32_t index) const { ASSERT(index > -1 && index < m_iBlockCount); uint8_t* pChunk = (uint8_t*)m_pData->GetAt(index / m_iChunkSize); - ASSERT(pChunk != NULL); + ASSERT(pChunk); return pChunk + (index % m_iChunkSize) * m_iBlockSize; } int32_t CFX_BaseMassArrayImp::Append(const CFX_BaseMassArrayImp& src, @@ -258,7 +258,7 @@ void CFX_BaseMassArrayImp::Append(int32_t iDstStart, std::min(iSrcCount, std::min(iSrcChunkSize, iDstChunkSize)); int32_t iCopyBytes = iCopySize * m_iBlockSize; while (iSrcCount > 0) { - ASSERT(pDstChunk != NULL && pSrcChunk != NULL); + ASSERT(pDstChunk && pSrcChunk); FXSYS_memcpy(pDstChunk, pSrcChunk, iCopyBytes); iSrcCount -= iCopySize; iSrcChunkSize -= iCopySize; @@ -294,13 +294,9 @@ void CFX_BaseMassArrayImp::RemoveAll(FX_BOOL bLeaveMemory) { m_iBlockCount = 0; return; } - for (int32_t i = 0; i < m_iChunkCount; i++) { - void* p = m_pData->GetAt(i); - if (p == NULL) { - continue; - } - FX_Free(p); - } + for (int32_t i = 0; i < m_iChunkCount; i++) + FX_Free(m_pData->GetAt(i)); + m_pData->RemoveAll(); m_iChunkCount = 0; m_iBlockCount = 0; @@ -363,7 +359,7 @@ uint8_t* CFX_BaseDiscreteArray::AddSpaceTo(int32_t index) { FX_BASEDISCRETEARRAYDATA* pData = (FX_BASEDISCRETEARRAYDATA*)m_pData; int32_t& iChunkCount = pData->iChunkCount; int32_t iChunkSize = pData->iChunkSize; - uint8_t* pChunk = NULL; + uint8_t* pChunk = nullptr; int32_t iChunk = index / iChunkSize; if (iChunk < iChunkCount) { pChunk = pData->ChunkBuffer.GetAt(iChunk); @@ -421,7 +417,7 @@ void CFX_BaseStack::Pop() { uint8_t* CFX_BaseStack::GetTopElement() const { int32_t iSize = m_pData->m_iBlockCount; if (iSize < 1) { - return NULL; + return nullptr; } return m_pData->GetAt(iSize - 1); } diff --git a/xfa/fgas/crt/fgas_utils.h b/xfa/fgas/crt/fgas_utils.h index f01d115b3e..0cf853fa70 100644 --- a/xfa/fgas/crt/fgas_utils.h +++ b/xfa/fgas/crt/fgas_utils.h @@ -378,7 +378,7 @@ class CFX_DiscreteArrayTemplate : public CFX_BaseDiscreteArray { : CFX_BaseDiscreteArray(iChunkSize, sizeof(baseType)) {} baseType& GetAt(int32_t index, const baseType& defValue) const { baseType* p = (baseType*)CFX_BaseDiscreteArray::GetAt(index); - return p == NULL ? (baseType&)defValue : *p; + return p ? *p : (baseType&)defValue; } baseType* GetPtrAt(int32_t index) const { return (baseType*)CFX_BaseDiscreteArray::GetAt(index); @@ -447,7 +447,7 @@ class CFX_ObjectStackTemplate : public CFX_BaseStack { } void Pop() { baseType* p = (baseType*)CFX_BaseStack::GetTopElement(); - if (p != NULL) { + if (p) { p->~baseType(); } CFX_BaseStack::Pop(); diff --git a/xfa/fgas/font/fgas_font.h b/xfa/fgas/font/fgas_font.h index 89641d7c72..7fcfbd715b 100644 --- a/xfa/fgas/font/fgas_font.h +++ b/xfa/fgas/font/fgas_font.h @@ -88,25 +88,25 @@ class IFGAS_FontMgr { virtual CFGAS_GEFont* GetDefFontByCodePage( uint16_t wCodePage, uint32_t dwFontStyles, - const FX_WCHAR* pszFontFamily = NULL) = 0; + const FX_WCHAR* pszFontFamily = nullptr) = 0; virtual CFGAS_GEFont* GetDefFontByCharset( uint8_t nCharset, uint32_t dwFontStyles, - const FX_WCHAR* pszFontFamily = NULL) = 0; + const FX_WCHAR* pszFontFamily = nullptr) = 0; virtual CFGAS_GEFont* GetDefFontByUnicode( FX_WCHAR wUnicode, uint32_t dwFontStyles, - const FX_WCHAR* pszFontFamily = NULL) = 0; + const FX_WCHAR* pszFontFamily = nullptr) = 0; virtual CFGAS_GEFont* GetDefFontByLanguage( uint16_t wLanguage, uint32_t dwFontStyles, - const FX_WCHAR* pszFontFamily = NULL) = 0; + const FX_WCHAR* pszFontFamily = nullptr) = 0; virtual CFGAS_GEFont* LoadFont(const FX_WCHAR* pszFontFamily, uint32_t dwFontStyles, uint16_t wCodePage = 0xFFFF) = 0; virtual CFGAS_GEFont* LoadFont(const uint8_t* pBuffer, int32_t iLength) = 0; virtual CFGAS_GEFont* LoadFont(IFX_Stream* pFontStream, - const FX_WCHAR* pszFontAlias = NULL, + const FX_WCHAR* pszFontAlias = nullptr, uint32_t dwFontStyles = 0, uint16_t wCodePage = 0, FX_BOOL bSaveStream = FALSE) = 0; @@ -127,23 +127,23 @@ class IFGAS_FontMgr { virtual CFGAS_GEFont* GetDefFontByCodePage( uint16_t wCodePage, uint32_t dwFontStyles, - const FX_WCHAR* pszFontFamily = NULL) = 0; + const FX_WCHAR* pszFontFamily = nullptr) = 0; virtual CFGAS_GEFont* GetDefFontByCharset( uint8_t nCharset, uint32_t dwFontStyles, - const FX_WCHAR* pszFontFamily = NULL) = 0; + const FX_WCHAR* pszFontFamily = nullptr) = 0; virtual CFGAS_GEFont* GetDefFontByUnicode( FX_WCHAR wUnicode, uint32_t dwFontStyles, - const FX_WCHAR* pszFontFamily = NULL) = 0; + const FX_WCHAR* pszFontFamily = nullptr) = 0; virtual CFGAS_GEFont* GetDefFontByLanguage( uint16_t wLanguage, uint32_t dwFontStyles, - const FX_WCHAR* pszFontFamily = NULL) = 0; + const FX_WCHAR* pszFontFamily = nullptr) = 0; virtual CFGAS_GEFont* GetFontByCodePage( uint16_t wCodePage, uint32_t dwFontStyles, - const FX_WCHAR* pszFontFamily = NULL) = 0; + const FX_WCHAR* pszFontFamily = nullptr) = 0; inline CFGAS_GEFont* LoadFont(const FX_WCHAR* pszFontFamily, uint32_t dwFontStyles, uint16_t wCodePage) { @@ -152,15 +152,15 @@ class IFGAS_FontMgr { virtual CFGAS_GEFont* GetFontByCharset( uint8_t nCharset, uint32_t dwFontStyles, - const FX_WCHAR* pszFontFamily = NULL) = 0; + const FX_WCHAR* pszFontFamily = nullptr) = 0; virtual CFGAS_GEFont* GetFontByUnicode( FX_WCHAR wUnicode, uint32_t dwFontStyles, - const FX_WCHAR* pszFontFamily = NULL) = 0; + const FX_WCHAR* pszFontFamily = nullptr) = 0; virtual CFGAS_GEFont* GetFontByLanguage( uint16_t wLanguage, uint32_t dwFontStyles, - const FX_WCHAR* pszFontFamily = NULL) = 0; + const FX_WCHAR* pszFontFamily = nullptr) = 0; virtual void ClearFontCache() = 0; virtual void RemoveFont(CFGAS_GEFont* pFont) = 0; }; diff --git a/xfa/fgas/font/fgas_fontutils.cpp b/xfa/fgas/font/fgas_fontutils.cpp index bccaf2cdb6..c31e1e08ca 100644 --- a/xfa/fgas/font/fgas_fontutils.cpp +++ b/xfa/fgas/font/fgas_fontutils.cpp @@ -149,5 +149,5 @@ const FGAS_FONTUSB* FGAS_GetUnicodeBitField(FX_WCHAR wUnicode) { return &usb; } } while (iStart <= iEnd); - return NULL; + return nullptr; } diff --git a/xfa/fgas/font/fgas_gefont.cpp b/xfa/fgas/font/fgas_gefont.cpp index 7863ef715b..a7d8c49cbf 100644 --- a/xfa/fgas/font/fgas_gefont.cpp +++ b/xfa/fgas/font/fgas_gefont.cpp @@ -16,15 +16,15 @@ CFGAS_GEFont* CFGAS_GEFont::LoadFont(const FX_WCHAR* pszFontFamily, uint16_t wCodePage, IFGAS_FontMgr* pFontMgr) { #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ - if (NULL != pFontMgr) { + if (pFontMgr) { return pFontMgr->GetFontByCodePage(wCodePage, dwFontStyles, pszFontFamily); } - return NULL; + return nullptr; #else CFGAS_GEFont* pFont = new CFGAS_GEFont(pFontMgr); if (!pFont->LoadFontInternal(pszFontFamily, dwFontStyles, wCodePage)) { pFont->Release(); - return NULL; + return nullptr; } return pFont; #endif @@ -36,7 +36,7 @@ CFGAS_GEFont* CFGAS_GEFont::LoadFont(CFX_Font* pExtFont, CFGAS_GEFont* pFont = new CFGAS_GEFont(pFontMgr); if (!pFont->LoadFontInternal(pExtFont)) { pFont->Release(); - return NULL; + return nullptr; } return pFont; } @@ -73,17 +73,17 @@ CFGAS_GEFont::CFGAS_GEFont(IFGAS_FontMgr* pFontMgr) m_bUseLogFontStyle(FALSE), m_dwLogFontStyle(0), #endif - m_pFont(NULL), + m_pFont(nullptr), m_pFontMgr(pFontMgr), m_iRefCount(1), m_bExtFont(FALSE), - m_pStream(NULL), - m_pFileRead(NULL), - m_pFontEncoding(NULL), - m_pCharWidthMap(NULL), - m_pRectArray(NULL), - m_pBBoxMap(NULL), - m_pProvider(NULL) { + m_pStream(nullptr), + m_pFileRead(nullptr), + m_pFontEncoding(nullptr), + m_pCharWidthMap(nullptr), + m_pRectArray(nullptr), + m_pBBoxMap(nullptr), + m_pProvider(nullptr) { } CFGAS_GEFont::CFGAS_GEFont(const CFGAS_GEFont& src, uint32_t dwFontStyles) @@ -92,17 +92,17 @@ CFGAS_GEFont::CFGAS_GEFont(const CFGAS_GEFont& src, uint32_t dwFontStyles) m_bUseLogFontStyle(FALSE), m_dwLogFontStyle(0), #endif - m_pFont(NULL), + m_pFont(nullptr), m_pFontMgr(src.m_pFontMgr), m_iRefCount(1), m_bExtFont(FALSE), - m_pStream(NULL), - m_pFileRead(NULL), - m_pFontEncoding(NULL), - m_pCharWidthMap(NULL), - m_pRectArray(NULL), - m_pBBoxMap(NULL), - m_pProvider(NULL) { + m_pStream(nullptr), + m_pFileRead(nullptr), + m_pFontEncoding(nullptr), + m_pCharWidthMap(nullptr), + m_pRectArray(nullptr), + m_pBBoxMap(nullptr), + m_pProvider(nullptr) { ASSERT(src.m_pFont); m_pFont = new CFX_Font; m_pFont->LoadClone(src.m_pFont); @@ -141,7 +141,7 @@ CFGAS_GEFont::~CFGAS_GEFont() { void CFGAS_GEFont::Release() { if (--m_iRefCount < 1) { - if (m_pFontMgr != NULL) { + if (m_pFontMgr) { m_pFontMgr->RemoveFont(this); } delete this; @@ -160,7 +160,7 @@ FX_BOOL CFGAS_GEFont::LoadFontInternal(const FX_WCHAR* pszFontFamily, return FALSE; } CFX_ByteString csFontFamily; - if (pszFontFamily != NULL) { + if (pszFontFamily) { csFontFamily = CFX_ByteString::FromUnicode(pszFontFamily); } uint32_t dwFlags = 0; @@ -276,7 +276,7 @@ void CFGAS_GEFont::GetFamilyName(CFX_WideString& wsFamily) const { } uint32_t CFGAS_GEFont::GetFontStyles() const { - ASSERT(m_pFont != NULL); + ASSERT(m_pFont); #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ if (m_bUseLogFontStyle) { return m_dwLogFontStyle; @@ -309,14 +309,14 @@ FX_BOOL CFGAS_GEFont::GetCharWidthInternal(FX_WCHAR wUnicode, int32_t& iWidth, FX_BOOL bRecursive, FX_BOOL bCharCode) { - ASSERT(m_pCharWidthMap != NULL); + ASSERT(m_pCharWidthMap); iWidth = m_pCharWidthMap->GetAt(wUnicode, 0); if (iWidth < 1) { if (!m_pProvider || !m_pProvider->GetCharWidth(this, wUnicode, iWidth, bCharCode)) { - CFGAS_GEFont* pFont = NULL; + CFGAS_GEFont* pFont = nullptr; int32_t iGlyph = GetGlyphIndex(wUnicode, TRUE, &pFont, bCharCode); - if (iGlyph != 0xFFFF && pFont != NULL) { + if (iGlyph != 0xFFFF && pFont) { if (pFont == this) { iWidth = m_pFont->GetGlyphWidth(iGlyph); if (iWidth < 0) { @@ -345,13 +345,13 @@ FX_BOOL CFGAS_GEFont::GetCharBBoxInternal(FX_WCHAR wUnicode, CFX_Rect& bbox, FX_BOOL bRecursive, FX_BOOL bCharCode) { - ASSERT(m_pRectArray != NULL); - ASSERT(m_pBBoxMap != NULL); - void* pRect = NULL; + ASSERT(m_pRectArray); + ASSERT(m_pBBoxMap); + void* pRect = nullptr; if (!m_pBBoxMap->Lookup((void*)(uintptr_t)wUnicode, pRect)) { - CFGAS_GEFont* pFont = NULL; + CFGAS_GEFont* pFont = nullptr; int32_t iGlyph = GetGlyphIndex(wUnicode, TRUE, &pFont, bCharCode); - if (iGlyph != 0xFFFF && pFont != NULL) { + if (iGlyph != 0xFFFF && pFont) { if (pFont == this) { FX_RECT rtBBox; if (m_pFont->GetGlyphBBox(iGlyph, rtBBox)) { @@ -390,22 +390,22 @@ int32_t CFGAS_GEFont::GetItalicAngle() const { return m_pFont->GetSubstFont()->m_ItalicAngle; } int32_t CFGAS_GEFont::GetGlyphIndex(FX_WCHAR wUnicode, FX_BOOL bCharCode) { - return GetGlyphIndex(wUnicode, TRUE, NULL, bCharCode); + return GetGlyphIndex(wUnicode, TRUE, nullptr, bCharCode); } int32_t CFGAS_GEFont::GetGlyphIndex(FX_WCHAR wUnicode, FX_BOOL bRecursive, CFGAS_GEFont** ppFont, FX_BOOL bCharCode) { - ASSERT(m_pFontEncoding != NULL); + ASSERT(m_pFontEncoding); int32_t iGlyphIndex = m_pFontEncoding->GlyphFromCharCode(wUnicode); if (iGlyphIndex > 0) { - if (ppFont != NULL) { + if (ppFont) { *ppFont = this; } return iGlyphIndex; } const FGAS_FONTUSB* pFontUSB = FGAS_GetUnicodeBitField(wUnicode); - if (pFontUSB == NULL) { + if (!pFontUSB) { return 0xFFFF; } uint16_t wBitField = pFontUSB->wBitField; @@ -415,7 +415,7 @@ int32_t CFGAS_GEFont::GetGlyphIndex(FX_WCHAR wUnicode, auto it = m_FontMapper.find(wUnicode); CFGAS_GEFont* pFont = it != m_FontMapper.end() ? it->second : nullptr; if (pFont && pFont != this) { - iGlyphIndex = pFont->GetGlyphIndex(wUnicode, FALSE, NULL, bCharCode); + iGlyphIndex = pFont->GetGlyphIndex(wUnicode, FALSE, nullptr, bCharCode); if (iGlyphIndex != 0xFFFF) { int32_t i = m_SubstFonts.Find(pFont); if (i > -1) { @@ -436,7 +436,7 @@ int32_t CFGAS_GEFont::GetGlyphIndex(FX_WCHAR wUnicode, CFGAS_GEFont* pFont = m_pFontMgr->GetFontByUnicode( wUnicode, GetFontStyles(), wsFamily.c_str()); if (!pFont) - pFont = m_pFontMgr->GetFontByUnicode(wUnicode, GetFontStyles(), NULL); + pFont = m_pFontMgr->GetFontByUnicode(wUnicode, GetFontStyles(), nullptr); #endif if (pFont) { if (pFont == this) { @@ -446,7 +446,7 @@ int32_t CFGAS_GEFont::GetGlyphIndex(FX_WCHAR wUnicode, m_FontMapper[wUnicode] = pFont; int32_t i = m_SubstFonts.GetSize(); m_SubstFonts.Add(pFont); - iGlyphIndex = pFont->GetGlyphIndex(wUnicode, FALSE, NULL, bCharCode); + iGlyphIndex = pFont->GetGlyphIndex(wUnicode, FALSE, nullptr, bCharCode); if (iGlyphIndex != 0xFFFF) { iGlyphIndex |= ((i + 1) << 24); if (ppFont) @@ -466,13 +466,13 @@ int32_t CFGAS_GEFont::GetDescent() const { void CFGAS_GEFont::Reset() { for (int32_t i = 0; i < m_SubstFonts.GetSize(); i++) m_SubstFonts[i]->Reset(); - if (m_pCharWidthMap != NULL) { + if (m_pCharWidthMap) { m_pCharWidthMap->RemoveAll(); } - if (m_pBBoxMap != NULL) { + if (m_pBBoxMap) { m_pBBoxMap->RemoveAll(); } - if (m_pRectArray != NULL) { + if (m_pRectArray) { m_pRectArray->RemoveAll(); } } diff --git a/xfa/fgas/font/fgas_stdfontmgr.cpp b/xfa/fgas/font/fgas_stdfontmgr.cpp index 34f5078962..47ec72b807 100644 --- a/xfa/fgas/font/fgas_stdfontmgr.cpp +++ b/xfa/fgas/font/fgas_stdfontmgr.cpp @@ -28,7 +28,7 @@ CFGAS_StdFontMgrImp::CFGAS_StdFontMgrImp(FX_LPEnumAllFonts pEnumerator) m_StreamFonts(4), m_DeriveFonts(4) { if (m_pEnumerator) { - m_pEnumerator(m_FontFaces, NULL, 0xFEFF); + m_pEnumerator(m_FontFaces, nullptr, 0xFEFF); } } @@ -53,18 +53,19 @@ CFGAS_GEFont* CFGAS_StdFontMgrImp::GetDefFontByCodePage( uint32_t dwFontStyles, const FX_WCHAR* pszFontFamily) { uint32_t dwHash = FGAS_GetFontHashCode(wCodePage, dwFontStyles); - CFGAS_GEFont* pFont = NULL; + CFGAS_GEFont* pFont = nullptr; if (m_CPFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont)) { - return pFont ? LoadFont(pFont, dwFontStyles, wCodePage) : NULL; - } - FX_FONTDESCRIPTOR const* pFD; - if ((pFD = FindFont(pszFontFamily, dwFontStyles, TRUE, wCodePage)) == NULL) { - if ((pFD = FindFont(NULL, dwFontStyles, TRUE, wCodePage)) == NULL) { - if ((pFD = FindFont(NULL, dwFontStyles, FALSE, wCodePage)) == NULL) - return NULL; - } + return pFont ? LoadFont(pFont, dwFontStyles, wCodePage) : nullptr; } - ASSERT(pFD); + FX_FONTDESCRIPTOR const* pFD = + FindFont(pszFontFamily, dwFontStyles, TRUE, wCodePage); + if (!pFD) + pFD = FindFont(nullptr, dwFontStyles, TRUE, wCodePage); + if (!pFD) + pFD = FindFont(nullptr, dwFontStyles, FALSE, wCodePage); + if (!pFD) + return nullptr; + pFont = CFGAS_GEFont::LoadFont(pFD->wsFontFace, dwFontStyles, wCodePage, this); if (pFont) { @@ -74,7 +75,7 @@ CFGAS_GEFont* CFGAS_StdFontMgrImp::GetDefFontByCodePage( m_FamilyFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); return LoadFont(pFont, dwFontStyles, wCodePage); } - return NULL; + return nullptr; } CFGAS_GEFont* CFGAS_StdFontMgrImp::GetDefFontByCharset( @@ -137,18 +138,17 @@ CFGAS_GEFont* CFGAS_StdFontMgrImp::LoadFont(const FX_WCHAR* pszFontFamily, uint16_t wCodePage) { uint32_t dwHash = FGAS_GetFontFamilyHash(pszFontFamily, dwFontStyles, wCodePage); - CFGAS_GEFont* pFont = NULL; + CFGAS_GEFont* pFont = nullptr; if (m_FamilyFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont)) { - return pFont ? LoadFont(pFont, dwFontStyles, wCodePage) : NULL; + return pFont ? LoadFont(pFont, dwFontStyles, wCodePage) : nullptr; } - FX_FONTDESCRIPTOR const* pFD = NULL; - if ((pFD = FindFont(pszFontFamily, dwFontStyles, TRUE, wCodePage)) == NULL) { - if ((pFD = FindFont(pszFontFamily, dwFontStyles, FALSE, wCodePage)) == - NULL) { - return NULL; - } - } - ASSERT(pFD); + FX_FONTDESCRIPTOR const* pFD = + FindFont(pszFontFamily, dwFontStyles, TRUE, wCodePage); + if (!pFD) + pFD = FindFont(pszFontFamily, dwFontStyles, FALSE, wCodePage); + if (!pFD) + return nullptr; + if (wCodePage == 0xFFFF) { wCodePage = FX_GetCodePageFromCharset(pFD->uCharSet); } @@ -161,13 +161,13 @@ CFGAS_GEFont* CFGAS_StdFontMgrImp::LoadFont(const FX_WCHAR* pszFontFamily, m_CPFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); return LoadFont(pFont, dwFontStyles, wCodePage); } - return NULL; + return nullptr; } CFGAS_GEFont* CFGAS_StdFontMgrImp::LoadFont(const uint8_t* pBuffer, int32_t iLength) { ASSERT(pBuffer && iLength > 0); - CFGAS_GEFont* pFont = NULL; + CFGAS_GEFont* pFont = nullptr; if (m_BufferFonts.Lookup((void*)pBuffer, (void*&)pFont)) { if (pFont) { return pFont->Retain(); @@ -179,7 +179,7 @@ CFGAS_GEFont* CFGAS_StdFontMgrImp::LoadFont(const uint8_t* pBuffer, m_BufferFonts.SetAt((void*)pBuffer, pFont); return pFont->Retain(); } - return NULL; + return nullptr; } CFGAS_GEFont* CFGAS_StdFontMgrImp::LoadFont(IFX_Stream* pFontStream, @@ -188,7 +188,7 @@ CFGAS_GEFont* CFGAS_StdFontMgrImp::LoadFont(IFX_Stream* pFontStream, uint16_t wCodePage, FX_BOOL bSaveStream) { ASSERT(pFontStream && pFontStream->GetLength() > 0); - CFGAS_GEFont* pFont = NULL; + CFGAS_GEFont* pFont = nullptr; if (m_StreamFonts.Lookup((void*)pFontStream, (void*&)pFont)) { if (pFont) { if (pszFontAlias) { @@ -210,7 +210,7 @@ CFGAS_GEFont* CFGAS_StdFontMgrImp::LoadFont(IFX_Stream* pFontStream, } return LoadFont(pFont, dwFontStyles, wCodePage); } - return NULL; + return nullptr; } CFGAS_GEFont* CFGAS_StdFontMgrImp::LoadFont(CFGAS_GEFont* pSrcFont, @@ -224,7 +224,7 @@ CFGAS_GEFont* CFGAS_StdFontMgrImp::LoadFont(CFGAS_GEFont* pSrcFont, (void*)(uintptr_t)wCodePage}; uint32_t dwHash = FX_HashCode_GetA( CFX_ByteStringC((uint8_t*)buffer, sizeof(buffer)), false); - CFGAS_GEFont* pFont = NULL; + CFGAS_GEFont* pFont = nullptr; if (m_DeriveFonts.GetCount() > 0) { m_DeriveFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont); if (pFont) { @@ -241,7 +241,7 @@ CFGAS_GEFont* CFGAS_StdFontMgrImp::LoadFont(CFGAS_GEFont* pSrcFont, } return pFont; } - return NULL; + return nullptr; } void CFGAS_StdFontMgrImp::ClearFontCache() { @@ -255,7 +255,7 @@ void CFGAS_StdFontMgrImp::RemoveFont(CFX_MapPtrToPtr& fontMap, void* pKey; void* pFind; while (pos) { - pFind = NULL; + pFind = nullptr; fontMap.GetNextAssoc(pos, pKey, pFind); if (pFind != (void*)pFont) { continue; @@ -300,10 +300,10 @@ FX_FONTDESCRIPTOR const* CFGAS_StdFontMgrImp::FindFont( if (pszFontFamily && m_pEnumerator) { CFX_FontDescriptors namedFonts; m_pEnumerator(namedFonts, pszFontFamily, wUnicode); - params.pwsFamily = NULL; + params.pwsFamily = nullptr; pDesc = FX_DefFontMatcher(¶ms, namedFonts); - if (pDesc == NULL) { - return NULL; + if (!pDesc) { + return nullptr; } for (int32_t i = m_FontFaces.GetSize() - 1; i >= 0; i--) { FX_FONTDESCRIPTOR const* pMatch = m_FontFaces.GetPtrAt(i); @@ -314,12 +314,12 @@ FX_FONTDESCRIPTOR const* CFGAS_StdFontMgrImp::FindFont( int index = m_FontFaces.Add(*pDesc); return m_FontFaces.GetPtrAt(index); } - return NULL; + return nullptr; } FX_FONTDESCRIPTOR const* FX_DefFontMatcher(FX_LPFONTMATCHPARAMS pParams, const CFX_FontDescriptors& fonts) { - FX_FONTDESCRIPTOR const* pBestFont = NULL; + FX_FONTDESCRIPTOR const* pBestFont = nullptr; int32_t iBestSimilar = 0; FX_BOOL bMatchStyle = (pParams->dwMatchFlags & FX_FONTMATCHPARA_MacthStyle) > 0; @@ -370,7 +370,7 @@ FX_FONTDESCRIPTOR const* FX_DefFontMatcher(FX_LPFONTMATCHPARAMS pParams, pBestFont = pFont; } } - return iBestSimilar < 1 ? NULL : pBestFont; + return iBestSimilar < 1 ? nullptr : pBestFont; } int32_t FX_GetSimilarValue(FX_FONTDESCRIPTOR const* pFont, @@ -444,7 +444,7 @@ static int32_t CALLBACK FX_GdiFontEnumProc(ENUMLOGFONTEX* lpelfe, static void FX_EnumGdiFonts(CFX_FontDescriptors& fonts, const FX_WCHAR* pwsFaceName, FX_WCHAR wUnicode) { - HDC hDC = ::GetDC(NULL); + HDC hDC = ::GetDC(nullptr); LOGFONTW lfFind; FXSYS_memset(&lfFind, 0, sizeof(lfFind)); lfFind.lfCharSet = DEFAULT_CHARSET; @@ -454,7 +454,7 @@ static void FX_EnumGdiFonts(CFX_FontDescriptors& fonts, } EnumFontFamiliesExW(hDC, (LPLOGFONTW)&lfFind, (FONTENUMPROCW)FX_GdiFontEnumProc, (LPARAM)&fonts, 0); - ::ReleaseDC(NULL, hDC); + ::ReleaseDC(nullptr, hDC); } FX_LPEnumAllFonts FX_GetDefFontEnumerator() { @@ -488,10 +488,10 @@ CFX_FontSourceEnum_File::~CFX_FontSourceEnum_File() {} CFX_ByteString CFX_FontSourceEnum_File::GetNextFile() { Restart: void* pCurHandle = - m_FolderQueue.GetSize() == 0 - ? NULL - : m_FolderQueue.GetDataPtr(m_FolderQueue.GetSize() - 1)->pFileHandle; - if (NULL == pCurHandle) { + m_FolderQueue.GetSize() != 0 + ? m_FolderQueue.GetDataPtr(m_FolderQueue.GetSize() - 1)->pFileHandle + : nullptr; + if (!pCurHandle) { if (m_FolderPaths.GetSize() < 1) { return ""; } @@ -531,7 +531,7 @@ Restart: m_FolderQueue.GetDataPtr(m_FolderQueue.GetSize() - 1)->bsParentPath + bsFolderSpearator + bsName; hpp.pFileHandle = FX_OpenFolder(hpp.bsParentPath.c_str()); - if (hpp.pFileHandle == NULL) { + if (!hpp.pFileHandle) { continue; } m_FolderQueue.Add(hpp); @@ -548,7 +548,7 @@ Restart: FX_POSITION CFX_FontSourceEnum_File::GetStartPosition() { m_wsNext = GetNextFile().UTF8Decode(); - if (0 == m_wsNext.GetLength()) { + if (m_wsNext.GetLength() == 0) { return (FX_POSITION)0; } return (FX_POSITION)-1; @@ -557,7 +557,7 @@ FX_POSITION CFX_FontSourceEnum_File::GetStartPosition() { IFX_FileAccess* CFX_FontSourceEnum_File::GetNext(FX_POSITION& pos) { IFX_FileAccess* pAccess = FX_CreateDefaultFileAccess(m_wsNext.AsStringC()); m_wsNext = GetNextFile().UTF8Decode(); - pos = 0 != m_wsNext.GetLength() ? pAccess : NULL; + pos = m_wsNext.GetLength() != 0 ? pAccess : nullptr; return pAccess; } @@ -742,7 +742,7 @@ CFGAS_GEFont* CFGAS_FontMgrImp::GetFontByUnicode( uint32_t dwFontStyles, const FX_WCHAR* pszFontFamily) { CFGAS_GEFont* pFont = nullptr; - if (m_FailedUnicodes2NULL.Lookup(wUnicode, pFont)) + if (m_FailedUnicodes2Nullptr.Lookup(wUnicode, pFont)) return nullptr; const FGAS_FONTUSB* x = FGAS_GetUnicodeBitField(wUnicode); uint16_t wCodePage = x ? x->wCodePage : 0xFFFF; @@ -785,7 +785,7 @@ CFGAS_GEFont* CFGAS_FontMgrImp::GetFontByUnicode( return pFont; } if (!pszFontFamily) - m_FailedUnicodes2NULL.SetAt(wUnicode, nullptr); + m_FailedUnicodes2Nullptr.SetAt(wUnicode, nullptr); return nullptr; } @@ -1131,7 +1131,7 @@ void CFGAS_FontMgrImp::ClearFontCache() { } void CFGAS_FontMgrImp::RemoveFont(CFGAS_GEFont* pEFont) { - if (NULL == pEFont) { + if (!pEFont) { return; } IFX_FileRead* pFileRead; @@ -1145,10 +1145,10 @@ void CFGAS_FontMgrImp::RemoveFont(CFGAS_GEFont* pEFont) { uint32_t dwHash; CFX_ArrayTemplate* pFonts; m_Hash2Fonts.GetNextAssoc(pos, dwHash, pFonts); - if (NULL != pFonts) { + if (pFonts) { for (int32_t i = 0; i < pFonts->GetSize(); i++) { if (pFonts->GetAt(i) == pEFont) { - pFonts->SetAt(i, NULL); + pFonts->SetAt(i, nullptr); } } } else { @@ -1239,7 +1239,7 @@ uint32_t CFGAS_FontMgrImp::GetFlags(FXFT_Face pFace) { void CFGAS_FontMgrImp::GetNames(const uint8_t* name_table, CFX_WideStringArray& Names) { - if (NULL == name_table) { + if (!name_table) { return; } uint8_t* lpTable = (uint8_t*)name_table; @@ -1369,7 +1369,7 @@ void CFGAS_FontMgrImp::GetUSBCSB(FXFT_Face pFace, uint32_t* USB, uint32_t* CSB) { TT_OS2* pOS2 = (TT_OS2*)FT_Get_Sfnt_Table(pFace, ft_sfnt_os2); - if (NULL != pOS2) { + if (pOS2) { USB[0] = pOS2->ulUnicodeRange1; USB[1] = pOS2->ulUnicodeRange2; USB[2] = pOS2->ulUnicodeRange3; diff --git a/xfa/fgas/font/fgas_stdfontmgr.h b/xfa/fgas/font/fgas_stdfontmgr.h index f66729e21b..8c83884236 100644 --- a/xfa/fgas/font/fgas_stdfontmgr.h +++ b/xfa/fgas/font/fgas_stdfontmgr.h @@ -30,25 +30,25 @@ class CFGAS_StdFontMgrImp : public IFGAS_FontMgr { CFGAS_GEFont* GetDefFontByCodePage( uint16_t wCodePage, uint32_t dwFontStyles, - const FX_WCHAR* pszFontFamily = NULL) override; + const FX_WCHAR* pszFontFamily = nullptr) override; CFGAS_GEFont* GetDefFontByCharset( uint8_t nCharset, uint32_t dwFontStyles, - const FX_WCHAR* pszFontFamily = NULL) override; + const FX_WCHAR* pszFontFamily = nullptr) override; CFGAS_GEFont* GetDefFontByUnicode( FX_WCHAR wUnicode, uint32_t dwFontStyles, - const FX_WCHAR* pszFontFamily = NULL) override; + const FX_WCHAR* pszFontFamily = nullptr) override; CFGAS_GEFont* GetDefFontByLanguage( uint16_t wLanguage, uint32_t dwFontStyles, - const FX_WCHAR* pszFontFamily = NULL) override; + const FX_WCHAR* pszFontFamily = nullptr) override; CFGAS_GEFont* LoadFont(const FX_WCHAR* pszFontFamily, uint32_t dwFontStyles, uint16_t wCodePage = 0xFFFF) override; CFGAS_GEFont* LoadFont(const uint8_t* pBuffer, int32_t iLength) override; CFGAS_GEFont* LoadFont(IFX_Stream* pFontStream, - const FX_WCHAR* pszFontAlias = NULL, + const FX_WCHAR* pszFontAlias = nullptr, uint32_t dwFontStyles = 0, uint16_t wCodePage = 0, FX_BOOL bSaveStream = FALSE) override; @@ -152,33 +152,35 @@ class CFGAS_FontMgrImp : public IFGAS_FontMgr { CFGAS_GEFont* GetDefFontByCodePage( uint16_t wCodePage, uint32_t dwFontStyles, - const FX_WCHAR* pszFontFamily = NULL) override; + const FX_WCHAR* pszFontFamily = nullptr) override; CFGAS_GEFont* GetDefFontByCharset( uint8_t nCharset, uint32_t dwFontStyles, - const FX_WCHAR* pszFontFamily = NULL) override; + const FX_WCHAR* pszFontFamily = nullptr) override; CFGAS_GEFont* GetDefFontByUnicode( FX_WCHAR wUnicode, uint32_t dwFontStyles, - const FX_WCHAR* pszFontFamily = NULL) override; + const FX_WCHAR* pszFontFamily = nullptr) override; CFGAS_GEFont* GetDefFontByLanguage( uint16_t wLanguage, uint32_t dwFontStyles, - const FX_WCHAR* pszFontFamily = NULL) override; + const FX_WCHAR* pszFontFamily = nullptr) override; CFGAS_GEFont* GetFontByCodePage( uint16_t wCodePage, uint32_t dwFontStyles, - const FX_WCHAR* pszFontFamily = NULL) override; - CFGAS_GEFont* GetFontByCharset(uint8_t nCharset, - uint32_t dwFontStyles, - const FX_WCHAR* pszFontFamily = NULL) override; - CFGAS_GEFont* GetFontByUnicode(FX_WCHAR wUnicode, - uint32_t dwFontStyles, - const FX_WCHAR* pszFontFamily = NULL) override; + const FX_WCHAR* pszFontFamily = nullptr) override; + CFGAS_GEFont* GetFontByCharset( + uint8_t nCharset, + uint32_t dwFontStyles, + const FX_WCHAR* pszFontFamily = nullptr) override; + CFGAS_GEFont* GetFontByUnicode( + FX_WCHAR wUnicode, + uint32_t dwFontStyles, + const FX_WCHAR* pszFontFamily = nullptr) override; CFGAS_GEFont* GetFontByLanguage( uint16_t wLanguage, uint32_t dwFontStyles, - const FX_WCHAR* pszFontFamily = NULL) override; + const FX_WCHAR* pszFontFamily = nullptr) override; void ClearFontCache() override; void RemoveFont(CFGAS_GEFont* pFont) override; @@ -222,7 +224,7 @@ class CFGAS_FontMgrImp : public IFGAS_FontMgr { CFX_MapPtrTemplate m_Hash2CandidateList; CFX_MapPtrTemplate*> m_Hash2Fonts; CFX_MapPtrTemplate m_IFXFont2FileRead; - CFX_MapPtrTemplate m_FailedUnicodes2NULL; + CFX_MapPtrTemplate m_FailedUnicodes2Nullptr; CFX_FontSourceEnum_File* const m_pFontSource; }; #endif diff --git a/xfa/fgas/layout/fgas_rtfbreak.cpp b/xfa/fgas/layout/fgas_rtfbreak.cpp index 80591f1714..8a4f6eac2b 100644 --- a/xfa/fgas/layout/fgas_rtfbreak.cpp +++ b/xfa/fgas/layout/fgas_rtfbreak.cpp @@ -23,7 +23,7 @@ CFX_RTFBreak::CFX_RTFBreak(uint32_t dwPolicies) m_bVertical(FALSE), m_bSingleLine(FALSE), m_bCharCode(FALSE), - m_pFont(NULL), + m_pFont(nullptr), m_iFontHeight(240), m_iFontSize(240), m_iTabWidth(720000), @@ -42,12 +42,12 @@ CFX_RTFBreak::CFX_RTFBreak(uint32_t dwPolicies) m_iWordSpace(0), m_bRTL(FALSE), m_iAlignment(FX_RTFLINEALIGNMENT_Left), - m_pUserData(NULL), + m_pUserData(nullptr), m_eCharType(FX_CHARTYPE_Unknown), m_dwIdentity(0), m_RTFLine1(), m_RTFLine2(), - m_pCurLine(NULL), + m_pCurLine(nullptr), m_iReady(0), m_iTolerance(0) { m_pCurLine = &m_RTFLine1; @@ -55,7 +55,7 @@ CFX_RTFBreak::CFX_RTFBreak(uint32_t dwPolicies) CFX_RTFBreak::~CFX_RTFBreak() { Reset(); m_PositionedTabs.RemoveAll(); - if (m_pUserData != NULL) { + if (m_pUserData) { m_pUserData->Release(); } } @@ -88,7 +88,7 @@ void CFX_RTFBreak::SetLayoutStyles(uint32_t dwLayoutStyles) { m_iRotation %= 4; } void CFX_RTFBreak::SetFont(CFGAS_GEFont* pFont) { - if (pFont == NULL) { + if (!pFont) { return; } if (m_pFont == pFont) { @@ -97,7 +97,7 @@ void CFX_RTFBreak::SetFont(CFGAS_GEFont* pFont) { SetBreakStatus(); m_pFont = pFont; m_iDefChar = 0; - if (m_pFont != NULL) { + if (m_pFont) { m_iFontHeight = m_iFontSize; if (m_wDefChar != 0xFEFF) { m_pFont->GetCharWidth(m_wDefChar, m_iDefChar, FALSE); @@ -113,7 +113,7 @@ void CFX_RTFBreak::SetFontSize(FX_FLOAT fFontSize) { SetBreakStatus(); m_iFontSize = iFontSize; m_iDefChar = 0; - if (m_pFont != NULL) { + if (m_pFont) { m_iFontHeight = m_iFontSize; if (m_wDefChar != 0xFEFF) { m_pFont->GetCharWidth(m_wDefChar, m_iDefChar, FALSE); @@ -173,7 +173,7 @@ void CFX_RTFBreak::ClearPositionedTabs() { void CFX_RTFBreak::SetDefaultChar(FX_WCHAR wch) { m_wDefChar = wch; m_iDefChar = 0; - if (m_wDefChar != 0xFEFF && m_pFont != NULL) { + if (m_wDefChar != 0xFEFF && m_pFont) { m_pFont->GetCharWidth(m_wDefChar, m_iDefChar, FALSE); if (m_iDefChar < 0) { m_iDefChar = 0; @@ -245,11 +245,11 @@ void CFX_RTFBreak::SetUserData(IFX_Retainable* pUserData) { return; } SetBreakStatus(); - if (m_pUserData != NULL) { + if (m_pUserData) { m_pUserData->Release(); } m_pUserData = pUserData; - if (m_pUserData != NULL) { + if (m_pUserData) { m_pUserData->Retain(); } } @@ -272,7 +272,7 @@ CFX_RTFChar* CFX_RTFBreak::GetLastChar(int32_t index) const { CFX_RTFCharArray& tca = m_pCurLine->m_LineChars; int32_t iCount = tca.GetSize(); if (index < 0 || index >= iCount) { - return NULL; + return nullptr; } CFX_RTFChar* pTC; int32_t iStart = iCount - 1; @@ -285,7 +285,7 @@ CFX_RTFChar* CFX_RTFBreak::GetLastChar(int32_t index) const { } } } - return NULL; + return nullptr; } CFX_RTFLine* CFX_RTFBreak::GetRTFLine(FX_BOOL bReady) const { if (bReady) { @@ -294,18 +294,15 @@ CFX_RTFLine* CFX_RTFBreak::GetRTFLine(FX_BOOL bReady) const { } else if (m_iReady == 2) { return (CFX_RTFLine*)&m_RTFLine2; } else { - return NULL; + return nullptr; } } - ASSERT(m_pCurLine != NULL); + ASSERT(m_pCurLine); return m_pCurLine; } CFX_RTFPieceArray* CFX_RTFBreak::GetRTFPieces(FX_BOOL bReady) const { CFX_RTFLine* pRTFLine = GetRTFLine(bReady); - if (pRTFLine == NULL) { - return NULL; - } - return &pRTFLine->m_LinePieces; + return pRTFLine ? &pRTFLine->m_LinePieces : nullptr; } inline FX_CHARTYPE CFX_RTFBreak::GetUnifiedCharType( FX_CHARTYPE chartype) const { @@ -362,7 +359,7 @@ uint32_t CFX_RTFBreak::AppendChar(FX_WCHAR wch) { pCurChar->m_nRotation = m_iCharRotation; pCurChar->m_iCharWidth = 0; pCurChar->m_dwIdentity = m_dwIdentity; - if (m_pUserData != NULL) { + if (m_pUserData) { m_pUserData->Retain(); } pCurChar->m_pUserData = m_pUserData; @@ -392,7 +389,7 @@ uint32_t CFX_RTFBreak::AppendChar(FX_WCHAR wch) { return std::max(dwRet1, dwRet2); } uint32_t CFX_RTFBreak::AppendChar_CharCode(FX_WCHAR wch) { - ASSERT(m_pFont != NULL && m_pCurLine != NULL); + ASSERT(m_pFont && m_pCurLine); ASSERT(m_bCharCode); m_pCurLine->m_iMBCSChars++; CFX_RTFCharArray& tca = m_pCurLine->m_LineChars; @@ -409,7 +406,7 @@ uint32_t CFX_RTFBreak::AppendChar_CharCode(FX_WCHAR wch) { pCurChar->m_nRotation = m_iCharRotation; pCurChar->m_iCharWidth = 0; pCurChar->m_dwIdentity = m_dwIdentity; - if (m_pUserData != NULL) { + if (m_pUserData) { m_pUserData->Retain(); } pCurChar->m_pUserData = m_pUserData; @@ -447,7 +444,7 @@ uint32_t CFX_RTFBreak::AppendChar_Combination(CFX_RTFChar* pCurChar, iCharWidth *= m_iFontSize; iCharWidth = iCharWidth * m_iHorizontalScale / 100; CFX_RTFChar* pLastChar = GetLastChar(0); - if (pLastChar != NULL && pLastChar->GetCharType() > FX_CHARTYPE_Combination) { + if (pLastChar && pLastChar->GetCharType() > FX_CHARTYPE_Combination) { iCharWidth = -iCharWidth; } else { m_eCharType = FX_CHARTYPE_Combination; @@ -509,7 +506,7 @@ uint32_t CFX_RTFBreak::AppendChar_Control(CFX_RTFChar* pCurChar, } uint32_t CFX_RTFBreak::AppendChar_Arabic(CFX_RTFChar* pCurChar, int32_t iRotation) { - CFX_RTFChar* pLastChar = NULL; + CFX_RTFChar* pLastChar = nullptr; int32_t& iLineWidth = m_pCurLine->m_iWidth; int32_t iCharWidth = 0; FX_WCHAR wForm; @@ -517,7 +514,7 @@ uint32_t CFX_RTFBreak::AppendChar_Arabic(CFX_RTFChar* pCurChar, if (m_eCharType >= FX_CHARTYPE_ArabicAlef && m_eCharType <= FX_CHARTYPE_ArabicDistortion) { pLastChar = GetLastChar(1); - if (pLastChar != NULL) { + if (pLastChar) { iLineWidth -= pLastChar->m_iCharWidth; CFX_RTFChar* pPrevChar = GetLastChar(2); wForm = pdfium::arabic::GetFormChar(pLastChar, pPrevChar, pCurChar); @@ -621,7 +618,7 @@ uint32_t CFX_RTFBreak::EndBreak(uint32_t dwStatus) { return dwStatus; } else { CFX_RTFLine* pLastLine = GetRTFLine(TRUE); - if (pLastLine != NULL) { + if (pLastLine) { pCurPieces = &pLastLine->m_LinePieces; iCount = pCurPieces->GetSize(); if (iCount-- > 0) { @@ -1063,7 +1060,7 @@ int32_t CFX_RTFBreak::GetBreakPos(CFX_RTFCharArray& tca, void CFX_RTFBreak::SplitTextLine(CFX_RTFLine* pCurLine, CFX_RTFLine* pNextLine, FX_BOOL bAllChars) { - ASSERT(pCurLine != NULL && pNextLine != NULL); + ASSERT(pCurLine && pNextLine); int32_t iCount = pCurLine->CountChars(); if (iCount < 2) { return; @@ -1110,25 +1107,22 @@ void CFX_RTFBreak::SplitTextLine(CFX_RTFLine* pCurLine, } int32_t CFX_RTFBreak::CountBreakPieces() const { CFX_RTFPieceArray* pRTFPieces = GetRTFPieces(TRUE); - if (pRTFPieces == NULL) { - return 0; - } - return pRTFPieces->GetSize(); + return pRTFPieces ? pRTFPieces->GetSize() : 0; } const CFX_RTFPiece* CFX_RTFBreak::GetBreakPiece(int32_t index) const { CFX_RTFPieceArray* pRTFPieces = GetRTFPieces(TRUE); - if (pRTFPieces == NULL) { - return NULL; + if (!pRTFPieces) { + return nullptr; } if (index < 0 || index >= pRTFPieces->GetSize()) { - return NULL; + return nullptr; } return pRTFPieces->GetPtrAt(index); } void CFX_RTFBreak::GetLineRect(CFX_RectF& rect) const { rect.top = 0; CFX_RTFLine* pRTFLine = GetRTFLine(TRUE); - if (pRTFLine == NULL) { + if (!pRTFLine) { rect.left = ((FX_FLOAT)m_iBoundaryStart) / 20000.0f; rect.width = rect.height = 0; return; @@ -1158,7 +1152,7 @@ void CFX_RTFBreak::GetLineRect(CFX_RectF& rect) const { } void CFX_RTFBreak::ClearBreakPieces() { CFX_RTFLine* pRTFLine = GetRTFLine(TRUE); - if (pRTFLine != NULL) { + if (pRTFLine) { pRTFLine->RemoveAll(TRUE); } m_iReady = 0; @@ -1173,11 +1167,10 @@ int32_t CFX_RTFBreak::GetDisplayPos(const FX_RTFTEXTOBJ* pText, FX_BOOL bCharCode, CFX_WideString* pWSForms, FX_AdjustCharDisplayPos pAdjustPos) const { - if (pText == NULL || pText->iLength < 1) { + if (!pText || pText->iLength < 1) { return 0; } - ASSERT(pText->pStr != NULL && pText->pWidths != NULL && - pText->pFont != NULL && pText->pRect != NULL); + ASSERT(pText->pStr && pText->pWidths && pText->pFont && pText->pRect); const FX_WCHAR* pStr = pText->pStr; int32_t* pWidths = pText->pWidths; int32_t iLength = pText->iLength - 1; @@ -1248,7 +1241,7 @@ int32_t CFX_RTFBreak::GetDisplayPos(const FX_RTFTEXTOBJ* pText, if (!bEmptyChar) { iCount++; } - if (pCharPos != NULL) { + if (pCharPos) { iCharWidth /= iFontSize; wForm = wch; if (!bMBCSCode) { @@ -1416,11 +1409,10 @@ int32_t CFX_RTFBreak::GetDisplayPos(const FX_RTFTEXTOBJ* pText, int32_t CFX_RTFBreak::GetCharRects(const FX_RTFTEXTOBJ* pText, CFX_RectFArray& rtArray, FX_BOOL bCharBBox) const { - if (pText == NULL || pText->iLength < 1) { + if (!pText || pText->iLength < 1) { return 0; } - ASSERT(pText->pStr != NULL && pText->pWidths != NULL && - pText->pFont != NULL && pText->pRect != NULL); + ASSERT(pText->pStr && pText->pWidths && pText->pFont && pText->pRect); const FX_WCHAR* pStr = pText->pStr; int32_t* pWidths = pText->pWidths; int32_t iLength = pText->iLength; @@ -1430,7 +1422,7 @@ int32_t CFX_RTFBreak::GetCharRects(const FX_RTFTEXTOBJ* pText, int32_t iFontSize = FXSYS_round(fFontSize * 20.0f); FX_FLOAT fScale = fFontSize / 1000.0f; CFGAS_GEFont* pFont = pText->pFont; - if (pFont == NULL) { + if (!pFont) { bCharBBox = FALSE; } CFX_Rect bbox; @@ -1533,8 +1525,8 @@ CFX_RTFPiece::CFX_RTFPiece() m_iVerticalScale(100), m_dwLayoutStyles(0), m_dwIdentity(0), - m_pChars(NULL), - m_pUserData(NULL) {} + m_pChars(nullptr), + m_pUserData(nullptr) {} CFX_RTFPiece::~CFX_RTFPiece() { Reset(); diff --git a/xfa/fgas/layout/fgas_rtfbreak.h b/xfa/fgas/layout/fgas_rtfbreak.h index 993dc50f97..9d01809045 100644 --- a/xfa/fgas/layout/fgas_rtfbreak.h +++ b/xfa/fgas/layout/fgas_rtfbreak.h @@ -86,7 +86,7 @@ class CFX_RTFPiece : public CFX_Target { ~CFX_RTFPiece() override; void AppendChar(const CFX_RTFChar& tc) { - ASSERT(m_pChars != NULL); + ASSERT(m_pChars); m_pChars->Add(tc); if (m_iWidth < 0) { m_iWidth = tc.m_iCharWidth; @@ -101,15 +101,15 @@ class CFX_RTFPiece : public CFX_Target { int32_t GetLength() const { return m_iChars; } int32_t GetEndChar() const { return m_iStartChar + m_iChars; } CFX_RTFChar& GetChar(int32_t index) { - ASSERT(index > -1 && index < m_iChars && m_pChars != NULL); + ASSERT(index > -1 && index < m_iChars && m_pChars); return *m_pChars->GetDataPtr(m_iStartChar + index); } CFX_RTFChar* GetCharPtr(int32_t index) const { - ASSERT(index > -1 && index < m_iChars && m_pChars != NULL); + ASSERT(index > -1 && index < m_iChars && m_pChars); return m_pChars->GetDataPtr(m_iStartChar + index); } void GetString(FX_WCHAR* pText) const { - ASSERT(pText != NULL); + ASSERT(pText); int32_t iEndChar = m_iStartChar + m_iChars; CFX_RTFChar* pChar; for (int32_t i = m_iStartChar; i < iEndChar; i++) { @@ -123,7 +123,7 @@ class CFX_RTFPiece : public CFX_Target { wsText.ReleaseBuffer(m_iChars); } void GetWidths(int32_t* pWidths) const { - ASSERT(pWidths != NULL); + ASSERT(pWidths); int32_t iEndChar = m_iStartChar + m_iChars; CFX_RTFChar* pChar; for (int32_t i = m_iStartChar; i < iEndChar; i++) { @@ -190,13 +190,11 @@ class CFX_RTFLine { int32_t GetLineEnd() const { return m_iStart + m_iWidth; } void RemoveAll(FX_BOOL bLeaveMemory = FALSE) { CFX_RTFChar* pChar; - IFX_Retainable* pUnknown; int32_t iCount = m_LineChars.GetSize(); for (int32_t i = 0; i < iCount; i++) { pChar = m_LineChars.GetDataPtr(i); - if ((pUnknown = pChar->m_pUserData) != NULL) { - pUnknown->Release(); - } + if (pChar->m_pUserData) + pChar->m_pUserData->Release(); } m_LineChars.RemoveAll(); m_LinePieces.RemoveAll(bLeaveMemory); @@ -249,8 +247,8 @@ class CFX_RTFBreak { int32_t GetDisplayPos(const FX_RTFTEXTOBJ* pText, FXTEXT_CHARPOS* pCharPos, FX_BOOL bCharCode = FALSE, - CFX_WideString* pWSForms = NULL, - FX_AdjustCharDisplayPos pAdjustPos = NULL) const; + CFX_WideString* pWSForms = nullptr, + FX_AdjustCharDisplayPos pAdjustPos = nullptr) const; int32_t GetCharRects(const FX_RTFTEXTOBJ* pText, CFX_RectFArray& rtArray, FX_BOOL bCharBBox = FALSE) const; diff --git a/xfa/fgas/layout/fgas_textbreak.cpp b/xfa/fgas/layout/fgas_textbreak.cpp index a272d0cfc7..0c1c6a2202 100644 --- a/xfa/fgas/layout/fgas_textbreak.cpp +++ b/xfa/fgas/layout/fgas_textbreak.cpp @@ -45,7 +45,7 @@ CFX_TxtBreak::CFX_TxtBreak(uint32_t dwPolicies) m_bCombText(FALSE), m_iArabicContext(1), m_iCurArabicContext(1), - m_pFont(NULL), + m_pFont(nullptr), m_iFontSize(240), m_bEquidistant(TRUE), m_iTabWidth(720000), @@ -58,11 +58,11 @@ CFX_TxtBreak::CFX_TxtBreak(uint32_t dwPolicies) m_iAlignment(FX_TXTLINEALIGNMENT_Left), m_dwContextCharStyles(0), m_iCombWidth(360000), - m_pUserData(NULL), + m_pUserData(nullptr), m_eCharType(FX_CHARTYPE_Unknown), m_bArabicNumber(FALSE), m_bArabicComma(FALSE), - m_pCurLine(NULL), + m_pCurLine(nullptr), m_iReady(0), m_iTolerance(0), m_iHorScale(100), @@ -113,7 +113,7 @@ void CFX_TxtBreak::SetLayoutStyles(uint32_t dwLayoutStyles) { m_iRotation %= 4; } void CFX_TxtBreak::SetFont(CFGAS_GEFont* pFont) { - if (pFont == NULL) { + if (!pFont) { return; } if (m_pFont == pFont) { @@ -122,7 +122,7 @@ void CFX_TxtBreak::SetFont(CFGAS_GEFont* pFont) { SetBreakStatus(); m_pFont = pFont; m_iDefChar = 0; - if (m_wDefChar != 0xFEFF && m_pFont != NULL) { + if (m_wDefChar != 0xFEFF && m_pFont) { m_pFont->GetCharWidth(m_wDefChar, m_iDefChar, FALSE); m_iDefChar *= m_iFontSize; } @@ -135,7 +135,7 @@ void CFX_TxtBreak::SetFontSize(FX_FLOAT fFontSize) { SetBreakStatus(); m_iFontSize = iFontSize; m_iDefChar = 0; - if (m_wDefChar != 0xFEFF && m_pFont != NULL) { + if (m_wDefChar != 0xFEFF && m_pFont) { m_pFont->GetCharWidth(m_wDefChar, m_iDefChar, FALSE); m_iDefChar *= m_iFontSize; } @@ -150,7 +150,7 @@ void CFX_TxtBreak::SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant) { void CFX_TxtBreak::SetDefaultChar(FX_WCHAR wch) { m_wDefChar = wch; m_iDefChar = 0; - if (m_wDefChar != 0xFEFF && m_pFont != NULL) { + if (m_wDefChar != 0xFEFF && m_pFont) { m_pFont->GetCharWidth(m_wDefChar, m_iDefChar, FALSE); if (m_iDefChar < 0) { m_iDefChar = 0; @@ -266,7 +266,7 @@ CFX_TxtChar* CFX_TxtBreak::GetLastChar(int32_t index, FX_BOOL bOmitChar) const { CFX_TxtCharArray& ca = *m_pCurLine->m_pLineChars; int32_t iCount = ca.GetSize(); if (index < 0 || index >= iCount) { - return NULL; + return nullptr; } CFX_TxtChar* pTC; int32_t iStart = iCount - 1; @@ -279,24 +279,21 @@ CFX_TxtChar* CFX_TxtBreak::GetLastChar(int32_t index, FX_BOOL bOmitChar) const { return pTC; } } - return NULL; + return nullptr; } CFX_TxtLine* CFX_TxtBreak::GetTxtLine(FX_BOOL bReady) const { - if (!bReady) { + if (!bReady) return m_pCurLine; - } - if (m_iReady == 1) { + if (m_iReady == 1) return m_pTxtLine1; - } else if (m_iReady == 2) { + if (m_iReady == 2) return m_pTxtLine2; - } else { - return NULL; - } + return nullptr; } CFX_TxtPieceArray* CFX_TxtBreak::GetTxtPieces(FX_BOOL bReady) const { CFX_TxtLine* pTxtLine = GetTxtLine(bReady); - if (pTxtLine == NULL) { - return NULL; + if (!pTxtLine) { + return nullptr; } return pTxtLine->m_pLinePieces; } @@ -350,7 +347,7 @@ void CFX_TxtBreak::AppendChar_PageLoad(CFX_TxtChar* pCurChar, ResetArabicContext(); if (!m_bPagination) { CFX_TxtChar* pLastChar = GetLastChar(1, FALSE); - if (pLastChar != NULL && pLastChar->m_dwStatus < 1) { + if (pLastChar && pLastChar->m_dwStatus < 1) { pLastChar->m_dwStatus = FX_TXTBREAK_PieceBreak; } } @@ -468,12 +465,12 @@ uint32_t CFX_TxtBreak::AppendChar_Arabic(CFX_TxtChar* pCurChar, int32_t& iLineWidth = m_pCurLine->m_iWidth; FX_WCHAR wForm; int32_t iCharWidth = 0; - CFX_Char* pLastChar = NULL; + CFX_Char* pLastChar = nullptr; FX_BOOL bAlef = FALSE; if (!m_bCombText && m_eCharType >= FX_CHARTYPE_ArabicAlef && m_eCharType <= FX_CHARTYPE_ArabicDistortion) { pLastChar = GetLastChar(1); - if (pLastChar != NULL) { + if (pLastChar) { iCharWidth = pLastChar->m_iCharWidth; if (iCharWidth > 0) { iLineWidth -= iCharWidth; @@ -502,7 +499,8 @@ uint32_t CFX_TxtBreak::AppendChar_Arabic(CFX_TxtChar* pCurChar, } } m_eCharType = chartype; - wForm = pdfium::arabic::GetFormChar(pCurChar, bAlef ? NULL : pLastChar, NULL); + wForm = pdfium::arabic::GetFormChar(pCurChar, bAlef ? nullptr : pLastChar, + nullptr); if (m_bCombText) { iCharWidth = m_iCombWidth; } else { @@ -585,7 +583,7 @@ uint32_t CFX_TxtBreak::AppendChar(FX_WCHAR wch) { pCurChar->m_iBidiLevel = 0; pCurChar->m_iBidiPos = 0; pCurChar->m_iBidiOrder = 0; - pCurChar->m_pUserData = NULL; + pCurChar->m_pUserData = nullptr; AppendChar_PageLoad(pCurChar, dwProps); uint32_t dwRet1 = FX_TXTBREAK_None; if (chartype != FX_CHARTYPE_Combination && @@ -630,7 +628,7 @@ void CFX_TxtBreak::EndBreak_UpdateArabicShapes() { pNext = m_pCurLine->GetCharPtr(i); bNextNum = (pNext->m_dwCharStyles & FX_TXTCHARSTYLE_ArabicIndic) != 0; } else { - pNext = NULL; + pNext = nullptr; bNextNum = FALSE; } wch = pCur->m_wCharCode; @@ -923,7 +921,7 @@ uint32_t CFX_TxtBreak::EndBreak(uint32_t dwStatus) { return dwStatus; } else { CFX_TxtLine* pLastLine = GetTxtLine(TRUE); - if (pLastLine != NULL) { + if (pLastLine) { pCurPieces = pLastLine->m_pLinePieces; iCount = pCurPieces->GetSize(); if (iCount-- > 0) { @@ -1074,7 +1072,7 @@ int32_t CFX_TxtBreak::GetBreakPos(CFX_TxtCharArray& ca, void CFX_TxtBreak::SplitTextLine(CFX_TxtLine* pCurLine, CFX_TxtLine* pNextLine, FX_BOOL bAllChars) { - ASSERT(pCurLine != NULL && pNextLine != NULL); + ASSERT(pCurLine && pNextLine); int32_t iCount = pCurLine->CountChars(); if (iCount < 2) { return; @@ -1124,28 +1122,25 @@ void CFX_TxtBreak::SplitTextLine(CFX_TxtLine* pCurLine, } int32_t CFX_TxtBreak::CountBreakChars() const { CFX_TxtLine* pTxtLine = GetTxtLine(TRUE); - return pTxtLine == NULL ? 0 : pTxtLine->CountChars(); + return pTxtLine ? pTxtLine->CountChars() : 0; } int32_t CFX_TxtBreak::CountBreakPieces() const { CFX_TxtPieceArray* pTxtPieces = GetTxtPieces(TRUE); - if (pTxtPieces == NULL) { - return 0; - } - return pTxtPieces->GetSize(); + return pTxtPieces ? pTxtPieces->GetSize() : 0; } const CFX_TxtPiece* CFX_TxtBreak::GetBreakPiece(int32_t index) const { CFX_TxtPieceArray* pTxtPieces = GetTxtPieces(TRUE); - if (pTxtPieces == NULL) { - return NULL; + if (!pTxtPieces) { + return nullptr; } if (index < 0 || index >= pTxtPieces->GetSize()) { - return NULL; + return nullptr; } return pTxtPieces->GetPtrAt(index); } void CFX_TxtBreak::ClearBreakPieces() { CFX_TxtLine* pTxtLine = GetTxtLine(TRUE); - if (pTxtLine != NULL) { + if (pTxtLine) { pTxtLine->RemoveAll(TRUE); } m_iReady = 0; @@ -1169,7 +1164,7 @@ int32_t CFX_TxtBreak::GetDisplayPos(const FX_TXTRUN* pTxtRun, FX_BOOL bCharCode, CFX_WideString* pWSForms, FX_AdjustCharDisplayPos pAdjustPos) const { - if (pTxtRun == NULL || pTxtRun->iLength < 1) { + if (!pTxtRun || pTxtRun->iLength < 1) { return 0; } IFX_TxtAccess* pAccess = pTxtRun->pAccess; @@ -1226,7 +1221,7 @@ int32_t CFX_TxtBreak::GetDisplayPos(const FX_TXTRUN* pTxtRun, for (int32_t i = 0; i <= iLength; i++) { int32_t iWidth; FX_WCHAR wch; - if (pAccess != NULL) { + if (pAccess) { wch = pAccess->GetChar(pIdentity, i); iWidth = pAccess->GetWidth(pIdentity, i); } else { @@ -1242,7 +1237,7 @@ int32_t CFX_TxtBreak::GetDisplayPos(const FX_TXTRUN* pTxtRun, } if (chartype >= FX_CHARTYPE_ArabicAlef) { if (i < iLength) { - if (pAccess != NULL) { + if (pAccess) { iNext = i + 1; while (iNext <= iLength) { wNext = pAccess->GetChar(pIdentity, iNext); @@ -1282,7 +1277,7 @@ int32_t CFX_TxtBreak::GetDisplayPos(const FX_TXTRUN* pTxtRun, bShadda = FALSE; } else { wNext = 0xFEFF; - if (pAccess != NULL) { + if (pAccess) { iNext = i + 1; if (iNext <= iLength) { wNext = pAccess->GetChar(pIdentity, iNext); @@ -1316,7 +1311,7 @@ int32_t CFX_TxtBreak::GetDisplayPos(const FX_TXTRUN* pTxtRun, wForm = wch; if (bArabicNumber) { wNext = 0xFEFF; - if (pAccess != NULL) { + if (pAccess) { iNext = i + 1; if (iNext <= iLength) { wNext = pAccess->GetChar(pIdentity, iNext); @@ -1359,7 +1354,7 @@ int32_t CFX_TxtBreak::GetDisplayPos(const FX_TXTRUN* pTxtRun, } int32_t iForms = bLam ? 3 : 1; iCount += (bEmptyChar && bSkipSpace) ? 0 : iForms; - if (pCharPos == NULL) { + if (!pCharPos) { if (iWidth > 0) { wPrev = wch; } @@ -1556,7 +1551,7 @@ int32_t CFX_TxtBreak::GetDisplayPos(const FX_TXTRUN* pTxtRun, int32_t CFX_TxtBreak::GetCharRects(const FX_TXTRUN* pTxtRun, CFX_RectFArray& rtArray, FX_BOOL bCharBBox) const { - if (pTxtRun == NULL || pTxtRun->iLength < 1) { + if (!pTxtRun || pTxtRun->iLength < 1) { return 0; } IFX_TxtAccess* pAccess = pTxtRun->pAccess; @@ -1571,7 +1566,7 @@ int32_t CFX_TxtBreak::GetCharRects(const FX_TXTRUN* pTxtRun, int32_t iFontSize = FXSYS_round(fFontSize * 20.0f); FX_FLOAT fScale = fFontSize / 1000.0f; CFGAS_GEFont* pFont = pTxtRun->pFont; - if (pFont == NULL) { + if (!pFont) { bCharBBox = FALSE; } CFX_Rect bbox; @@ -1596,7 +1591,7 @@ int32_t CFX_TxtBreak::GetCharRects(const FX_TXTRUN* pTxtRun, fStart = bRTLPiece ? rect.right() : rect.left; } for (int32_t i = 0; i < iLength; i++) { - if (pAccess != NULL) { + if (pAccess) { wch = pAccess->GetChar(pIdentity, i); iCharSize = pAccess->GetWidth(pIdentity, i); } else { @@ -1696,8 +1691,8 @@ CFX_TxtPiece::CFX_TxtPiece() m_iHorizontalScale(100), m_iVerticalScale(100), m_dwCharStyles(0), - m_pChars(NULL), - m_pUserData(NULL) {} + m_pChars(nullptr), + m_pUserData(nullptr) {} CFX_TxtLine::CFX_TxtLine(int32_t iBlockSize) : m_iStart(0), m_iWidth(0), m_iArabicChars(0) { diff --git a/xfa/fgas/layout/fgas_textbreak.h b/xfa/fgas/layout/fgas_textbreak.h index 020fa1a3d3..3d8e3bdbb8 100644 --- a/xfa/fgas/layout/fgas_textbreak.h +++ b/xfa/fgas/layout/fgas_textbreak.h @@ -113,11 +113,11 @@ class CFX_TxtPiece : public CFX_Target { int32_t GetLength() const { return m_iChars; } int32_t GetEndChar() const { return m_iStartChar + m_iChars; } CFX_TxtChar* GetCharPtr(int32_t index) const { - ASSERT(index > -1 && index < m_iChars && m_pChars != NULL); + ASSERT(index > -1 && index < m_iChars && m_pChars); return m_pChars->GetDataPtr(m_iStartChar + index); } void GetString(FX_WCHAR* pText) const { - ASSERT(pText != NULL); + ASSERT(pText); int32_t iEndChar = m_iStartChar + m_iChars; CFX_Char* pChar; for (int32_t i = m_iStartChar; i < iEndChar; i++) { @@ -131,7 +131,7 @@ class CFX_TxtPiece : public CFX_Target { wsText.ReleaseBuffer(m_iChars); } void GetWidths(int32_t* pWidths) const { - ASSERT(pWidths != NULL); + ASSERT(pWidths); int32_t iEndChar = m_iStartChar + m_iChars; CFX_Char* pChar; for (int32_t i = m_iStartChar; i < iEndChar; i++) { @@ -229,8 +229,8 @@ class CFX_TxtBreak { int32_t GetDisplayPos(const FX_TXTRUN* pTxtRun, FXTEXT_CHARPOS* pCharPos, FX_BOOL bCharCode = FALSE, - CFX_WideString* pWSForms = NULL, - FX_AdjustCharDisplayPos pAdjustPos = NULL) const; + CFX_WideString* pWSForms = nullptr, + FX_AdjustCharDisplayPos pAdjustPos = nullptr) const; int32_t GetCharRects(const FX_TXTRUN* pTxtRun, CFX_RectFArray& rtArray, FX_BOOL bCharBBox = FALSE) const; diff --git a/xfa/fgas/localization/fgas_datetime.cpp b/xfa/fgas/localization/fgas_datetime.cpp index f3c560b823..f658d3597d 100644 --- a/xfa/fgas/localization/fgas_datetime.cpp +++ b/xfa/fgas/localization/fgas_datetime.cpp @@ -142,7 +142,7 @@ void CFX_Unitime::Now() { #elif _FX_OS_ != _FX_EMBEDDED_ #if 1 timeval curTime; - gettimeofday(&curTime, NULL); + gettimeofday(&curTime, nullptr); #else struct timespec curTime; clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &curTime); @@ -170,7 +170,7 @@ void CFX_Unitime::SetGMTime() { #elif _FX_OS_ != _FX_EMBEDDED_ #if 1 timeval curTime; - gettimeofday(&curTime, NULL); + gettimeofday(&curTime, nullptr); #else struct timespec curTime; clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &curTime); diff --git a/xfa/fgas/localization/fgas_locale.cpp b/xfa/fgas/localization/fgas_locale.cpp index ecd33e27cf..d61f6b53ed 100644 --- a/xfa/fgas/localization/fgas_locale.cpp +++ b/xfa/fgas/localization/fgas_locale.cpp @@ -478,7 +478,7 @@ CFX_WideString CFX_FormatString::GetLocaleName( IFX_Locale* CFX_FormatString::GetTextFormat(const CFX_WideString& wsPattern, const CFX_WideStringC& wsCategory, CFX_WideString& wsPurgePattern) { - IFX_Locale* pLocale = NULL; + IFX_Locale* pLocale = nullptr; int32_t ccf = 0; int32_t iLenf = wsPattern.GetLength(); const FX_WCHAR* pStr = wsPattern.c_str(); @@ -535,7 +535,7 @@ IFX_Locale* CFX_FormatString::GetNumericFormat(const CFX_WideString& wsPattern, uint32_t& dwStyle, CFX_WideString& wsPurgePattern) { dwStyle = 0; - IFX_Locale* pLocale = NULL; + IFX_Locale* pLocale = nullptr; int32_t ccf = 0; int32_t iLenf = wsPattern.GetLength(); const FX_WCHAR* pStr = wsPattern.c_str(); @@ -591,7 +591,7 @@ IFX_Locale* CFX_FormatString::GetNumericFormat(const CFX_WideString& wsPattern, if (!pLocale) { pLocale = m_pLocaleMgr->GetDefLocale(); } - ASSERT(pLocale != NULL); + ASSERT(pLocale); pLocale->GetNumPattern(eSubCategory, wsSubCategory); iDotIndex = wsSubCategory.Find('.'); if (iDotIndex > 0) { @@ -1922,7 +1922,7 @@ FX_DATETIMETYPE CFX_FormatString::GetDateTimeFormat( IFX_Locale*& pLocale, CFX_WideString& wsDatePattern, CFX_WideString& wsTimePattern) { - pLocale = NULL; + pLocale = nullptr; CFX_WideString wsTempPattern; FX_LOCALECATEGORY eCategory = FX_LOCALECATEGORY_Unknown; int32_t ccf = 0; @@ -2001,7 +2001,7 @@ FX_DATETIMETYPE CFX_FormatString::GetDateTimeFormat( if (!pLocale) { pLocale = m_pLocaleMgr->GetDefLocale(); } - ASSERT(pLocale != NULL); + ASSERT(pLocale); switch (eCategory) { case FX_LOCALECATEGORY_Date: pLocale->GetDatePattern(eSubCategory, wsDatePattern); @@ -2476,7 +2476,7 @@ FX_BOOL CFX_FormatString::ParseDateTime(const CFX_WideString& wsSrcDateTime, return FALSE; } CFX_WideString wsDatePattern, wsTimePattern; - IFX_Locale* pLocale = NULL; + IFX_Locale* pLocale = nullptr; FX_DATETIMETYPE eCategory = GetDateTimeFormat(wsPattern, pLocale, wsDatePattern, wsTimePattern); if (!pLocale) { @@ -3991,10 +3991,10 @@ FX_BOOL CFX_FormatString::FormatDateTime(const CFX_WideString& wsSrcDateTime, return FALSE; } CFX_WideString wsDatePattern, wsTimePattern; - IFX_Locale* pLocale = NULL; + IFX_Locale* pLocale = nullptr; FX_DATETIMETYPE eCategory = GetDateTimeFormat(wsPattern, pLocale, wsDatePattern, wsTimePattern); - if (pLocale == NULL || eCategory == FX_DATETIMETYPE_Unknown) { + if (!pLocale || eCategory == FX_DATETIMETYPE_Unknown) { return FALSE; } CFX_Unitime dt(0); @@ -4023,7 +4023,7 @@ FX_BOOL CFX_FormatString::FormatDateTime(const CFX_WideString& wsSrcDateTime, return FALSE; } CFX_WideString wsDatePattern, wsTimePattern; - IFX_Locale* pLocale = NULL; + IFX_Locale* pLocale = nullptr; FX_DATETIMETYPE eCategory = GetDateTimeFormat(wsPattern, pLocale, wsDatePattern, wsTimePattern); if (!pLocale) { @@ -4074,7 +4074,7 @@ FX_BOOL CFX_FormatString::FormatDateTime(const CFX_Unitime& dt, return FALSE; } CFX_WideString wsDatePattern, wsTimePattern; - IFX_Locale* pLocale = NULL; + IFX_Locale* pLocale = nullptr; FX_DATETIMETYPE eCategory = GetDateTimeFormat(wsPattern, pLocale, wsDatePattern, wsTimePattern); if (!pLocale) { -- cgit v1.2.3