diff options
Diffstat (limited to 'core/src/fpdfapi/fpdf_parser')
-rw-r--r-- | core/src/fpdfapi/fpdf_parser/filters_int.h | 14 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp | 50 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_parser/fpdf_parser_document.cpp | 30 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_parser/fpdf_parser_encrypt.cpp | 210 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_parser/fpdf_parser_fdf.cpp | 16 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_parser/fpdf_parser_filters.cpp | 60 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp | 112 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp | 1056 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp | 38 |
9 files changed, 793 insertions, 793 deletions
diff --git a/core/src/fpdfapi/fpdf_parser/filters_int.h b/core/src/fpdfapi/fpdf_parser/filters_int.h index 2ec54fb1f5..c27ade8a70 100644 --- a/core/src/fpdfapi/fpdf_parser/filters_int.h +++ b/core/src/fpdfapi/fpdf_parser/filters_int.h @@ -31,11 +31,11 @@ public: class CPDF_LzwFilter : public CFX_DataFilter { public: - CPDF_LzwFilter(FX_BOOL bEarlyChange); + CPDF_LzwFilter(bool bEarlyChange); virtual ~CPDF_LzwFilter() {} virtual void v_FilterIn(const uint8_t* src_buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf); virtual void v_FilterFinish(CFX_BinaryBuf& dest_buf) {} - FX_BOOL m_bEarlyChange; + bool m_bEarlyChange; FX_DWORD m_CodeArray[5021]; FX_DWORD m_nCodes; FX_DWORD m_CodeLen; @@ -54,7 +54,7 @@ public: virtual ~CPDF_PredictorFilter(); virtual void v_FilterIn(const uint8_t* src_buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf); virtual void v_FilterFinish(CFX_BinaryBuf& dest_buf) {} - FX_BOOL m_bTiff; + bool m_bTiff; FX_DWORD m_Pitch, m_Bpp; uint8_t* m_pRefLine; uint8_t* m_pCurLine; @@ -102,14 +102,14 @@ public: CFX_BinaryBuf m_InputBuf; uint8_t* m_pScanline; int m_Pitch, m_Height, m_Width, m_nComps, m_iLine; - FX_BOOL m_bGotHeader; + bool m_bGotHeader; }; class CPDF_FaxFilter : public CFX_DataFilter { public: CPDF_FaxFilter(); virtual ~CPDF_FaxFilter(); - FX_BOOL Initialize(int Encoding, int bEndOfLine, int bByteAlign, int bBlack, int nRows, int nColumns); + bool Initialize(int Encoding, int bEndOfLine, int bByteAlign, int bBlack, int nRows, int nColumns); virtual void v_FilterIn(const uint8_t* src_buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf); virtual void v_FilterFinish(CFX_BinaryBuf& dest_buf); int m_Encoding, m_bEndOfLine, m_bByteAlign, m_bBlack; @@ -118,9 +118,9 @@ public: uint8_t* m_pRefBuf; CFX_BinaryBuf m_InputBuf; int m_InputBitPos; - void ProcessData(const uint8_t* src_buf, FX_DWORD src_size, int& bitpos, FX_BOOL bFinish, + void ProcessData(const uint8_t* src_buf, FX_DWORD src_size, int& bitpos, bool bFinish, CFX_BinaryBuf& dest_buf); - FX_BOOL ReadLine(const uint8_t* src_buf, int bitsize, int& bitpos); + bool ReadLine(const uint8_t* src_buf, int bitsize, int& bitpos); }; #endif // CORE_SRC_FPDFAPI_FPDF_PARSER_FILTERS_INT_H_ diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp index 47c08fb4a3..e60888a292 100644 --- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp +++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp @@ -91,7 +91,7 @@ FX_DWORD _HexDecode(const uint8_t* src_buf, FX_DWORD src_size, uint8_t*& dest_bu } dest_buf = FX_Alloc( uint8_t, i / 2 + 1); dest_size = 0; - FX_BOOL bFirstDigit = TRUE; + bool bFirstDigit = true; for (i = 0; i < src_size; i ++) { uint8_t ch = src_buf[i]; if (ch == ' ' || ch == '\n' || ch == '\t' || ch == '\r') { @@ -186,9 +186,9 @@ ICodec_ScanlineDecoder* FPDFAPI_CreateFaxDecoder(const uint8_t* src_buf, FX_DWOR const CPDF_Dictionary* pParams) { int K = 0; - FX_BOOL EndOfLine = FALSE; - FX_BOOL ByteAlign = FALSE; - FX_BOOL BlackIs1 = FALSE; + bool EndOfLine = false; + bool ByteAlign = false; + bool BlackIs1 = false; int Columns = 1728; int Rows = 0; if (pParams) { @@ -208,25 +208,25 @@ ICodec_ScanlineDecoder* FPDFAPI_CreateFaxDecoder(const uint8_t* src_buf, FX_DWOR return CPDF_ModuleMgr::Get()->GetFaxModule()->CreateDecoder(src_buf, src_size, width, height, K, EndOfLine, ByteAlign, BlackIs1, Columns, Rows); } -static FX_BOOL CheckFlateDecodeParams(int Colors, int BitsPerComponent, int Columns) +static bool CheckFlateDecodeParams(int Colors, int BitsPerComponent, int Columns) { if (Columns < 0) { - return FALSE; + return false; } int check = Columns; if (Colors < 0 || (check > 0 && Colors > INT_MAX / check)) { - return FALSE; + return false; } check *= Colors; if (BitsPerComponent < 0 || (check > 0 && BitsPerComponent > INT_MAX / check)) { - return FALSE; + return false; } check *= BitsPerComponent; if (check > INT_MAX - 7) { - return FALSE; + return false; } - return TRUE; + return true; } ICodec_ScanlineDecoder* FPDFAPI_CreateFlateDecoder(const uint8_t* src_buf, FX_DWORD src_size, int width, int height, int nComps, int bpc, const CPDF_Dictionary* pParams) @@ -245,11 +245,11 @@ ICodec_ScanlineDecoder* FPDFAPI_CreateFlateDecoder(const uint8_t* src_buf, FX_DW return CPDF_ModuleMgr::Get()->GetFlateModule()->CreateDecoder(src_buf, src_size, width, height, nComps, bpc, predictor, Colors, BitsPerComponent, Columns); } -FX_DWORD FPDFAPI_FlateOrLZWDecode(FX_BOOL bLZW, const uint8_t* src_buf, FX_DWORD src_size, CPDF_Dictionary* pParams, +FX_DWORD FPDFAPI_FlateOrLZWDecode(bool bLZW, const uint8_t* src_buf, FX_DWORD src_size, CPDF_Dictionary* pParams, FX_DWORD estimated_size, uint8_t*& dest_buf, FX_DWORD& dest_size) { int predictor = 0; - FX_BOOL bEarlyChange = TRUE; + bool bEarlyChange = true; int Colors = 0, BitsPerComponent = 0, Columns = 0; if (pParams) { predictor = ((CPDF_Dictionary*)pParams)->GetInteger(FX_BSTRC("Predictor")); @@ -265,14 +265,14 @@ FX_DWORD FPDFAPI_FlateOrLZWDecode(FX_BOOL bLZW, const uint8_t* src_buf, FX_DWORD bEarlyChange, predictor, Colors, BitsPerComponent, Columns, estimated_size, dest_buf, dest_size); } -FX_BOOL PDF_DataDecode(const uint8_t* src_buf, FX_DWORD src_size, const CPDF_Dictionary* pDict, +bool PDF_DataDecode(const uint8_t* src_buf, FX_DWORD src_size, const CPDF_Dictionary* pDict, uint8_t*& dest_buf, FX_DWORD& dest_size, CFX_ByteString& ImageEncoding, - CPDF_Dictionary*& pImageParms, FX_DWORD last_estimated_size, FX_BOOL bImageAcc) + CPDF_Dictionary*& pImageParms, FX_DWORD last_estimated_size, bool bImageAcc) { CPDF_Object* pDecoder = pDict ? pDict->GetElementValue(FX_BSTRC("Filter")) : NULL; if (pDecoder == NULL || (pDecoder->GetType() != PDFOBJ_ARRAY && pDecoder->GetType() != PDFOBJ_NAME)) { - return FALSE; + return false; } CPDF_Object* pParams = pDict ? pDict->GetElementValue(FX_BSTRC("DecodeParms")) : NULL; CFX_ByteStringArray DecoderList; @@ -310,11 +310,11 @@ FX_BOOL PDF_DataDecode(const uint8_t* src_buf, FX_DWORD src_size, const CPDF_Dic dest_buf = (uint8_t*)last_buf; dest_size = last_size; pImageParms = pParam; - return TRUE; + return true; } - offset = FPDFAPI_FlateOrLZWDecode(FALSE, last_buf, last_size, pParam, estimated_size, new_buf, new_size); + offset = FPDFAPI_FlateOrLZWDecode(false, last_buf, last_size, pParam, estimated_size, new_buf, new_size); } else if (decoder == FX_BSTRC("LZWDecode") || decoder == FX_BSTRC("LZW")) { - offset = FPDFAPI_FlateOrLZWDecode(TRUE, last_buf, last_size, pParam, estimated_size, new_buf, new_size); + offset = FPDFAPI_FlateOrLZWDecode(true, last_buf, last_size, pParam, estimated_size, new_buf, new_size); } else if (decoder == FX_BSTRC("ASCII85Decode") || decoder == FX_BSTRC("A85")) { offset = _A85Decode(last_buf, last_size, new_buf, new_size); } else if (decoder == FX_BSTRC("ASCIIHexDecode") || decoder == FX_BSTRC("AHx")) { @@ -325,7 +325,7 @@ FX_BOOL PDF_DataDecode(const uint8_t* src_buf, FX_DWORD src_size, const CPDF_Dic dest_buf = (uint8_t*)last_buf; dest_size = last_size; pImageParms = pParam; - return TRUE; + return true; } offset = RunLengthDecode(last_buf, last_size, new_buf, new_size); } else { @@ -340,13 +340,13 @@ FX_BOOL PDF_DataDecode(const uint8_t* src_buf, FX_DWORD src_size, const CPDF_Dic pImageParms = pParam; dest_buf = (uint8_t*)last_buf; dest_size = last_size; - return TRUE; + return true; } if (last_buf != src_buf) { FX_Free(last_buf); } if (offset == -1) { - return FALSE; + return false; } last_buf = new_buf; last_size = new_size; @@ -355,7 +355,7 @@ FX_BOOL PDF_DataDecode(const uint8_t* src_buf, FX_DWORD src_size, const CPDF_Dic pImageParms = NULL; dest_buf = last_buf; dest_size = last_size; - return TRUE; + return true; } extern const FX_WORD PDFDocEncoding[256] = { 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008, 0x0009, @@ -389,7 +389,7 @@ CFX_WideString PDF_DecodeText(const uint8_t* src_data, FX_DWORD src_len, CFX_Cha { CFX_WideString result; if (src_len >= 2 && ((src_data[0] == 0xfe && src_data[1] == 0xff) || (src_data[0] == 0xff && src_data[1] == 0xfe))) { - FX_BOOL bBE = src_data[0] == 0xfe; + bool bBE = src_data[0] == 0xfe; FX_DWORD max_chars = (src_len - 2) / 2; if (!max_chars) { return result; @@ -472,7 +472,7 @@ CFX_ByteString PDF_EncodeText(const FX_WCHAR* pString, int len, CFX_CharMap* pCh result.ReleaseBuffer(encLen); return result; } -CFX_ByteString PDF_EncodeString(const CFX_ByteString& src, FX_BOOL bHex) +CFX_ByteString PDF_EncodeString(const CFX_ByteString& src, bool bHex) { CFX_ByteTextBuf result; int srclen = src.GetLength(); @@ -521,7 +521,7 @@ FX_DWORD FlateDecode(const uint8_t* src_buf, FX_DWORD src_size, uint8_t*& dest_b { CCodec_ModuleMgr* pEncoders = CPDF_ModuleMgr::Get()->GetCodecModule(); if (pEncoders) { - return pEncoders->GetFlateModule()->FlateOrLZWDecode(FALSE, src_buf, src_size, FALSE, 0, 0, 0, 0, 0, dest_buf, dest_size); + return pEncoders->GetFlateModule()->FlateOrLZWDecode(false, src_buf, src_size, false, 0, 0, 0, 0, 0, dest_buf, dest_size); } return 0; } diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_document.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_document.cpp index c0f45c5379..0ea692ed4d 100644 --- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_document.cpp +++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_document.cpp @@ -12,7 +12,7 @@ CPDF_Document::CPDF_Document(CPDF_Parser* pParser) : CPDF_IndirectObjects(pParse ASSERT(pParser != NULL); m_pRootDict = NULL; m_pInfoDict = NULL; - m_bLinearized = FALSE; + m_bLinearized = false; m_dwFirstPageNo = 0; m_dwFirstPageObjNum = 0; m_pDocPage = CPDF_ModuleMgr::Get()->GetPageModule()->CreateDocData(this); @@ -58,7 +58,7 @@ void CPDF_Document::LoadDoc() } void CPDF_Document::LoadAsynDoc(CPDF_Dictionary *pLinearized) { - m_bLinearized = TRUE; + m_bLinearized = true; m_LastObjNum = m_pParser->GetLastObjNum(); CPDF_Object* indirectObj = GetIndirectObject(m_pParser->GetRootObjNum()); m_pRootDict = indirectObj ? indirectObj->GetDict() : NULL; @@ -228,7 +228,7 @@ int CPDF_Document::GetPageIndex(FX_DWORD objnum) { FX_DWORD nPages = m_PageList.GetSize(); FX_DWORD skip_count = 0; - FX_BOOL bSkipped = FALSE; + bool bSkipped = false; for (FX_DWORD i = 0; i < nPages; i ++) { FX_DWORD objnum1 = m_PageList.GetAt(i); if (objnum1 == objnum) { @@ -236,7 +236,7 @@ int CPDF_Document::GetPageIndex(FX_DWORD objnum) } if (!bSkipped && objnum1 == 0) { skip_count = i; - bSkipped = TRUE; + bSkipped = true; } } CPDF_Dictionary* pRoot = GetRoot(); @@ -297,7 +297,7 @@ int CPDF_Document::_GetPageCount() const } return _CountPages(pPages, 0); } -FX_BOOL CPDF_Document::IsContentUsedElsewhere(FX_DWORD objnum, CPDF_Dictionary* pThisPageDict) +bool CPDF_Document::IsContentUsedElsewhere(FX_DWORD objnum, CPDF_Dictionary* pThisPageDict) { for (int i = 0; i < m_PageList.GetSize(); i ++) { CPDF_Dictionary* pPageDict = GetPage(i); @@ -316,42 +316,42 @@ FX_BOOL CPDF_Document::IsContentUsedElsewhere(FX_DWORD objnum, CPDF_Dictionary* continue; } if (((CPDF_Reference*) pRef)->GetRefObjNum() == objnum) { - return TRUE; + return true; } } } else if (pContents->GetObjNum() == objnum) { - return TRUE; + return true; } } - return FALSE; + return false; } -FX_DWORD CPDF_Document::GetUserPermissions(FX_BOOL bCheckRevision) const +FX_DWORD CPDF_Document::GetUserPermissions(bool bCheckRevision) const { if (m_pParser == NULL) { return (FX_DWORD) - 1; } return m_pParser->GetPermissions(bCheckRevision); } -FX_BOOL CPDF_Document::IsOwner() const +bool CPDF_Document::IsOwner() const { if (m_pParser == NULL) { - return TRUE; + return true; } return m_pParser->IsOwner(); } -FX_BOOL CPDF_Document::IsFormStream(FX_DWORD objnum, FX_BOOL& bForm) const +bool CPDF_Document::IsFormStream(FX_DWORD objnum, bool& bForm) const { { CPDF_Object* pObj; if (m_IndirectObjs.Lookup((void*)(uintptr_t)objnum, (void*&)pObj)) { bForm = pObj->GetType() == PDFOBJ_STREAM && ((CPDF_Stream*)pObj)->GetDict()->GetString(FX_BSTRC("Subtype")) == FX_BSTRC("Form"); - return TRUE; + return true; } } if (m_pParser == NULL) { - bForm = FALSE; - return TRUE; + bForm = false; + return true; } return m_pParser->IsFormStream(objnum, bForm); } diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_encrypt.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_encrypt.cpp index 9f356a4748..ff6f0e12bd 100644 --- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_encrypt.cpp +++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_encrypt.cpp @@ -14,7 +14,7 @@ const uint8_t defpasscode[32] = { 0x2f, 0x0c, 0xa9, 0xfe, 0x64, 0x53, 0x69, 0x7a }; void CalcEncryptKey(CPDF_Dictionary* pEncrypt, const uint8_t* password, FX_DWORD pass_size, - uint8_t* key, int keylen, FX_BOOL bIgnoreMeta, CPDF_Array* pIdArray) + uint8_t* key, int keylen, bool bIgnoreMeta, CPDF_Array* pIdArray) { int revision = pEncrypt->GetInteger(FX_BSTRC("R")); uint8_t passcode[32]; @@ -57,7 +57,7 @@ CPDF_CryptoHandler* CPDF_StandardSecurityHandler::CreateCryptoHandler() typedef struct _PDF_CRYPTOITEM { int32_t m_Cipher; int32_t m_KeyLen; - FX_BOOL m_bChecked; + bool m_bChecked; CPDF_StandardCryptoHandler* m_pCryptoHandler; } PDF_CRYPTOITEM; CPDF_StandardSecurityHandler::CPDF_StandardSecurityHandler() @@ -66,7 +66,7 @@ CPDF_StandardSecurityHandler::CPDF_StandardSecurityHandler() m_Revision = 0; m_pParser = NULL; m_pEncryptDict = NULL; - m_bOwner = FALSE; + m_bOwner = false; m_Permissions = 0; m_Cipher = FXCIPHER_NONE; m_KeyLen = 0; @@ -74,36 +74,36 @@ CPDF_StandardSecurityHandler::CPDF_StandardSecurityHandler() CPDF_StandardSecurityHandler::~CPDF_StandardSecurityHandler() { } -FX_BOOL CPDF_StandardSecurityHandler::OnInit(CPDF_Parser* pParser, CPDF_Dictionary* pEncryptDict) +bool CPDF_StandardSecurityHandler::OnInit(CPDF_Parser* pParser, CPDF_Dictionary* pEncryptDict) { m_pParser = pParser; if (!LoadDict(pEncryptDict)) { - return FALSE; + return false; } if (m_Cipher == FXCIPHER_NONE) { - return TRUE; + return true; } return CheckSecurity(m_KeyLen); } -FX_BOOL CPDF_StandardSecurityHandler::CheckSecurity(int32_t key_len) +bool CPDF_StandardSecurityHandler::CheckSecurity(int32_t key_len) { CFX_ByteString password = m_pParser->GetPassword(); - if (CheckPassword(password, password.GetLength(), TRUE, m_EncryptKey, key_len)) { + if (CheckPassword(password, password.GetLength(), true, m_EncryptKey, key_len)) { if (password.IsEmpty()) { - if (!CheckPassword(password, password.GetLength(), FALSE, m_EncryptKey, key_len)) { - return FALSE; + if (!CheckPassword(password, password.GetLength(), false, m_EncryptKey, key_len)) { + return false; } } - m_bOwner = TRUE; - return TRUE; + m_bOwner = true; + return true; } - return CheckPassword(password, password.GetLength(), FALSE, m_EncryptKey, key_len); + return CheckPassword(password, password.GetLength(), false, m_EncryptKey, key_len); } FX_DWORD CPDF_StandardSecurityHandler::GetPermissions() { return m_Permissions; } -static FX_BOOL _LoadCryptInfo(CPDF_Dictionary* pEncryptDict, const CFX_ByteStringC& name, int& cipher, int& keylen) +static bool _LoadCryptInfo(CPDF_Dictionary* pEncryptDict, const CFX_ByteStringC& name, int& cipher, int& keylen) { int Version = pEncryptDict->GetInteger(FX_BSTRC("V")); cipher = FXCIPHER_RC4; @@ -111,14 +111,14 @@ static FX_BOOL _LoadCryptInfo(CPDF_Dictionary* pEncryptDict, const CFX_ByteStrin if (Version >= 4) { CPDF_Dictionary* pCryptFilters = pEncryptDict->GetDict(FX_BSTRC("CF")); if (pCryptFilters == NULL) { - return FALSE; + return false; } if (name == FX_BSTRC("Identity")) { cipher = FXCIPHER_NONE; } else { CPDF_Dictionary* pDefFilter = pCryptFilters->GetDict(name); if (pDefFilter == NULL) { - return FALSE; + return false; } int nKeyBits = 0; if (Version == 4) { @@ -142,14 +142,14 @@ static FX_BOOL _LoadCryptInfo(CPDF_Dictionary* pEncryptDict, const CFX_ByteStrin keylen = Version > 1 ? pEncryptDict->GetInteger(FX_BSTRC("Length"), 40) / 8 : 5; } if (keylen > 32 || keylen < 0) { - return FALSE; + return false; } - return TRUE; + return true; } -FX_BOOL CPDF_StandardSecurityHandler::LoadDict(CPDF_Dictionary* pEncryptDict) +bool CPDF_StandardSecurityHandler::LoadDict(CPDF_Dictionary* pEncryptDict) { m_pEncryptDict = pEncryptDict; - m_bOwner = FALSE; + m_bOwner = false; m_Version = pEncryptDict->GetInteger(FX_BSTRC("V")); m_Revision = pEncryptDict->GetInteger(FX_BSTRC("R")); m_Permissions = pEncryptDict->GetInteger(FX_BSTRC("P"), -1); @@ -159,17 +159,17 @@ FX_BOOL CPDF_StandardSecurityHandler::LoadDict(CPDF_Dictionary* pEncryptDict) CFX_ByteString stmf_name = pEncryptDict->GetString(FX_BSTRC("StmF")); CFX_ByteString strf_name = pEncryptDict->GetString(FX_BSTRC("StrF")); if (stmf_name != strf_name) { - return FALSE; + return false; } if (!_LoadCryptInfo(pEncryptDict, strf_name, m_Cipher, m_KeyLen)) { - return FALSE; + return false; } - return TRUE; + return true; } -FX_BOOL CPDF_StandardSecurityHandler::LoadDict(CPDF_Dictionary* pEncryptDict, FX_DWORD type, int& cipher, int& key_len) +bool CPDF_StandardSecurityHandler::LoadDict(CPDF_Dictionary* pEncryptDict, FX_DWORD type, int& cipher, int& key_len) { m_pEncryptDict = pEncryptDict; - m_bOwner = FALSE; + m_bOwner = false; m_Version = pEncryptDict->GetInteger(FX_BSTRC("V")); m_Revision = pEncryptDict->GetInteger(FX_BSTRC("R")); m_Permissions = pEncryptDict->GetInteger(FX_BSTRC("P"), -1); @@ -178,23 +178,23 @@ FX_BOOL CPDF_StandardSecurityHandler::LoadDict(CPDF_Dictionary* pEncryptDict, FX stmf_name = pEncryptDict->GetString(FX_BSTRC("StmF")); strf_name = pEncryptDict->GetString(FX_BSTRC("StrF")); if (stmf_name != strf_name) { - return FALSE; + return false; } } if (!_LoadCryptInfo(pEncryptDict, strf_name, cipher, key_len)) { - return FALSE; + return false; } m_Cipher = cipher; m_KeyLen = key_len; - return TRUE; - return TRUE; + return true; + return true; } -FX_BOOL CPDF_StandardSecurityHandler::GetCryptInfo(int& cipher, const uint8_t*& buffer, int& keylen) +bool CPDF_StandardSecurityHandler::GetCryptInfo(int& cipher, const uint8_t*& buffer, int& keylen) { cipher = m_Cipher; buffer = m_EncryptKey; keylen = m_KeyLen; - return TRUE; + return true; } #define FX_GET_32WORD(n,b,i) \ { \ @@ -252,7 +252,7 @@ void Revision6_Hash(const uint8_t* password, FX_DWORD size, const uint8_t* salt, content.AppendBlock(vector, 48); } } - CRYPT_AESSetKey(aes, 16, key, 16, TRUE); + CRYPT_AESSetKey(aes, 16, key, 16, true); CRYPT_AESSetIV(aes, iv); CRYPT_AESEncrypt(aes, E, content.GetBuffer(), iBufLen); int iHash = 0; @@ -288,16 +288,16 @@ void Revision6_Hash(const uint8_t* password, FX_DWORD size, const uint8_t* salt, FXSYS_memcpy(hash, input, 32); } } -FX_BOOL CPDF_StandardSecurityHandler::AES256_CheckPassword(const uint8_t* password, FX_DWORD size, - FX_BOOL bOwner, uint8_t* key) +bool CPDF_StandardSecurityHandler::AES256_CheckPassword(const uint8_t* password, FX_DWORD size, + bool bOwner, uint8_t* key) { CFX_ByteString okey = m_pEncryptDict ? m_pEncryptDict->GetString(FX_BSTRC("O")) : CFX_ByteString(); if (okey.GetLength() < 48) { - return FALSE; + return false; } CFX_ByteString ukey = m_pEncryptDict ? m_pEncryptDict->GetString(FX_BSTRC("U")) : CFX_ByteString(); if (ukey.GetLength() < 48) { - return FALSE; + return false; } const uint8_t* pkey = bOwner ? (const uint8_t*)okey : (const uint8_t*)ukey; uint8_t sha[128]; @@ -314,10 +314,10 @@ FX_BOOL CPDF_StandardSecurityHandler::AES256_CheckPassword(const uint8_t* passwo CRYPT_SHA256Finish(sha, digest); } if (FXSYS_memcmp(digest, pkey, 32) != 0) { - return FALSE; + return false; } if (key == NULL) { - return TRUE; + return true; } if (m_Revision >= 6) { Revision6_Hash(password, size, (const uint8_t*)pkey + 40, (bOwner ? (const uint8_t*)ukey : NULL), digest); @@ -332,19 +332,19 @@ FX_BOOL CPDF_StandardSecurityHandler::AES256_CheckPassword(const uint8_t* passwo } CFX_ByteString ekey = m_pEncryptDict ? m_pEncryptDict->GetString(bOwner ? FX_BSTRC("OE") : FX_BSTRC("UE")) : CFX_ByteString(); if (ekey.GetLength() < 32) { - return FALSE; + return false; } uint8_t* aes = FX_Alloc(uint8_t, 2048); - CRYPT_AESSetKey(aes, 16, digest, 32, FALSE); + CRYPT_AESSetKey(aes, 16, digest, 32, false); uint8_t iv[16]; FXSYS_memset(iv, 0, 16); CRYPT_AESSetIV(aes, iv); CRYPT_AESDecrypt(aes, key, ekey, 32); - CRYPT_AESSetKey(aes, 16, key, 32, FALSE); + CRYPT_AESSetKey(aes, 16, key, 32, false); CRYPT_AESSetIV(aes, iv); CFX_ByteString perms = m_pEncryptDict->GetString(FX_BSTRC("Perms")); if (perms.IsEmpty()) { - return FALSE; + return false; } uint8_t perms_buf[16]; FXSYS_memset(perms_buf, 0, sizeof(perms_buf)); @@ -357,21 +357,21 @@ FX_BOOL CPDF_StandardSecurityHandler::AES256_CheckPassword(const uint8_t* passwo CRYPT_AESDecrypt(aes, buf, perms_buf, 16); FX_Free(aes); if (buf[9] != 'a' || buf[10] != 'd' || buf[11] != 'b') { - return FALSE; + return false; } if (FXDWORD_GET_LSBFIRST(buf) != m_Permissions) { - return FALSE; + return false; } if ((buf[8] == 'T' && !IsMetadataEncrypted()) || (buf[8] == 'F' && IsMetadataEncrypted())) { - return FALSE; + return false; } - return TRUE; + return true; } -int CPDF_StandardSecurityHandler::CheckPassword(const uint8_t* password, FX_DWORD pass_size, FX_BOOL bOwner, uint8_t* key) +int CPDF_StandardSecurityHandler::CheckPassword(const uint8_t* password, FX_DWORD pass_size, bool bOwner, uint8_t* key) { return CheckPassword(password, pass_size, bOwner, key, m_KeyLen); } -int CPDF_StandardSecurityHandler::CheckPassword(const uint8_t* password, FX_DWORD size, FX_BOOL bOwner, uint8_t* key, int32_t key_len) +int CPDF_StandardSecurityHandler::CheckPassword(const uint8_t* password, FX_DWORD size, bool bOwner, uint8_t* key, int32_t key_len) { if (m_Revision >= 5) { return AES256_CheckPassword(password, size, bOwner, key); @@ -383,16 +383,16 @@ int CPDF_StandardSecurityHandler::CheckPassword(const uint8_t* password, FX_DWOR if (bOwner) { return CheckOwnerPassword(password, size, key, key_len); } - return CheckUserPassword(password, size, FALSE, key, key_len) || CheckUserPassword(password, size, TRUE, key, key_len); + return CheckUserPassword(password, size, false, key, key_len) || CheckUserPassword(password, size, true, key, key_len); } -FX_BOOL CPDF_StandardSecurityHandler::CheckUserPassword(const uint8_t* password, FX_DWORD pass_size, - FX_BOOL bIgnoreEncryptMeta, uint8_t* key, int32_t key_len) +bool CPDF_StandardSecurityHandler::CheckUserPassword(const uint8_t* password, FX_DWORD pass_size, + bool bIgnoreEncryptMeta, uint8_t* key, int32_t key_len) { CalcEncryptKey(m_pEncryptDict, password, pass_size, key, key_len, bIgnoreEncryptMeta, m_pParser->GetIDArray()); CFX_ByteString ukey = m_pEncryptDict ? m_pEncryptDict->GetString(FX_BSTRC("U")) : CFX_ByteString(); if (ukey.GetLength() < 16) { - return FALSE; + return false; } uint8_t ukeybuf[32]; if (m_Revision == 2) { @@ -425,9 +425,9 @@ FX_BOOL CPDF_StandardSecurityHandler::CheckUserPassword(const uint8_t* password, return FXSYS_memcmp(test, ukeybuf, 16) == 0; } if (FXSYS_memcmp((void*)ukey.c_str(), ukeybuf, 16) == 0) { - return TRUE; + return true; } - return FALSE; + return false; } CFX_ByteString CPDF_StandardSecurityHandler::GetUserPassword(const uint8_t* owner_pass, FX_DWORD pass_size) { @@ -480,18 +480,18 @@ CFX_ByteString CPDF_StandardSecurityHandler::GetUserPassword(const uint8_t* owne } return CFX_ByteString(okeybuf, len); } -FX_BOOL CPDF_StandardSecurityHandler::CheckOwnerPassword(const uint8_t* password, FX_DWORD pass_size, +bool CPDF_StandardSecurityHandler::CheckOwnerPassword(const uint8_t* password, FX_DWORD pass_size, uint8_t* key, int32_t key_len) { CFX_ByteString user_pass = GetUserPassword(password, pass_size, key_len); - if (CheckUserPassword(user_pass, user_pass.GetLength(), FALSE, key, key_len)) { - return TRUE; + if (CheckUserPassword(user_pass, user_pass.GetLength(), false, key, key_len)) { + return true; } - return CheckUserPassword(user_pass, user_pass.GetLength(), TRUE, key, key_len); + return CheckUserPassword(user_pass, user_pass.GetLength(), true, key, key_len); } -FX_BOOL CPDF_StandardSecurityHandler::IsMetadataEncrypted() +bool CPDF_StandardSecurityHandler::IsMetadataEncrypted() { - return m_pEncryptDict->GetBoolean(FX_BSTRC("EncryptMetadata"), TRUE); + return m_pEncryptDict->GetBoolean(FX_BSTRC("EncryptMetadata"), true); } CPDF_SecurityHandler* FPDF_CreateStandardSecurityHandler() { @@ -499,7 +499,7 @@ CPDF_SecurityHandler* FPDF_CreateStandardSecurityHandler() } void CPDF_StandardSecurityHandler::OnCreate(CPDF_Dictionary* pEncryptDict, CPDF_Array* pIdArray, const uint8_t* user_pass, FX_DWORD user_size, - const uint8_t* owner_pass, FX_DWORD owner_size, FX_BOOL bDefault, FX_DWORD type) + const uint8_t* owner_pass, FX_DWORD owner_size, bool bDefault, FX_DWORD type) { int cipher = 0, key_len = 0; if (!LoadDict(pEncryptDict, type, cipher, key_len)) { @@ -517,10 +517,10 @@ void CPDF_StandardSecurityHandler::OnCreate(CPDF_Dictionary* pEncryptDict, CPDF_ CRYPT_SHA256Update(sha, m_EncryptKey, 32); CRYPT_SHA256Update(sha, (uint8_t*)"there", 5); CRYPT_SHA256Finish(sha, m_EncryptKey); - AES256_SetPassword(pEncryptDict, user_pass, user_size, FALSE, m_EncryptKey); + AES256_SetPassword(pEncryptDict, user_pass, user_size, false, m_EncryptKey); if (bDefault) { - AES256_SetPassword(pEncryptDict, owner_pass, owner_size, TRUE, m_EncryptKey); - AES256_SetPerms(pEncryptDict, m_Permissions, pEncryptDict->GetBoolean(FX_BSTRC("EncryptMetadata"), TRUE), m_EncryptKey); + AES256_SetPassword(pEncryptDict, owner_pass, owner_size, true, m_EncryptKey); + AES256_SetPerms(pEncryptDict, m_Permissions, pEncryptDict->GetBoolean(FX_BSTRC("EncryptMetadata"), true), m_EncryptKey); } return; } @@ -554,7 +554,7 @@ void CPDF_StandardSecurityHandler::OnCreate(CPDF_Dictionary* pEncryptDict, CPDF_ } pEncryptDict->SetAtString(FX_BSTRC("O"), CFX_ByteString(passcode, 32)); } - CalcEncryptKey(m_pEncryptDict, (uint8_t*)user_pass, user_size, m_EncryptKey, key_len, FALSE, pIdArray); + CalcEncryptKey(m_pEncryptDict, (uint8_t*)user_pass, user_size, m_EncryptKey, key_len, false, pIdArray); if (m_Revision < 3) { uint8_t tempbuf[32]; FXSYS_memcpy(tempbuf, defpasscode, 32); @@ -586,13 +586,13 @@ void CPDF_StandardSecurityHandler::OnCreate(CPDF_Dictionary* pEncryptDict, CPDF_ const uint8_t* user_pass, FX_DWORD user_size, const uint8_t* owner_pass, FX_DWORD owner_size, FX_DWORD type) { - OnCreate(pEncryptDict, pIdArray, user_pass, user_size, owner_pass, owner_size, TRUE, type); + OnCreate(pEncryptDict, pIdArray, user_pass, user_size, owner_pass, owner_size, true, type); } void CPDF_StandardSecurityHandler::OnCreate(CPDF_Dictionary* pEncryptDict, CPDF_Array* pIdArray, const uint8_t* user_pass, FX_DWORD user_size, FX_DWORD type) { - OnCreate(pEncryptDict, pIdArray, user_pass, user_size, NULL, 0, FALSE, type); + OnCreate(pEncryptDict, pIdArray, user_pass, user_size, NULL, 0, false, type); } -void CPDF_StandardSecurityHandler::AES256_SetPassword(CPDF_Dictionary* pEncryptDict, const uint8_t* password, FX_DWORD size, FX_BOOL bOwner, const uint8_t* key) +void CPDF_StandardSecurityHandler::AES256_SetPassword(CPDF_Dictionary* pEncryptDict, const uint8_t* password, FX_DWORD size, bool bOwner, const uint8_t* key) { uint8_t sha[128]; CRYPT_SHA1Start(sha); @@ -627,7 +627,7 @@ void CPDF_StandardSecurityHandler::AES256_SetPassword(CPDF_Dictionary* pEncryptD CRYPT_SHA256Finish(sha, digest1); } uint8_t* aes = FX_Alloc(uint8_t, 2048); - CRYPT_AESSetKey(aes, 16, digest1, 32, TRUE); + CRYPT_AESSetKey(aes, 16, digest1, 32, true); uint8_t iv[16]; FXSYS_memset(iv, 0, 16); CRYPT_AESSetIV(aes, iv); @@ -636,7 +636,7 @@ void CPDF_StandardSecurityHandler::AES256_SetPassword(CPDF_Dictionary* pEncryptD pEncryptDict->SetAtString(bOwner ? FX_BSTRC("OE") : FX_BSTRC("UE"), CFX_ByteString(digest1, 32)); } void CPDF_StandardSecurityHandler::AES256_SetPerms(CPDF_Dictionary* pEncryptDict, FX_DWORD permissions, - FX_BOOL bEncryptMetadata, const uint8_t* key) + bool bEncryptMetadata, const uint8_t* key) { uint8_t buf[16]; buf[0] = (uint8_t)permissions; @@ -652,7 +652,7 @@ void CPDF_StandardSecurityHandler::AES256_SetPerms(CPDF_Dictionary* pEncryptDict buf[10] = 'd'; buf[11] = 'b'; uint8_t* aes = FX_Alloc(uint8_t, 2048); - CRYPT_AESSetKey(aes, 16, key, 32, TRUE); + CRYPT_AESSetKey(aes, 16, key, 32, true); uint8_t iv[16], buf1[16]; FXSYS_memset(iv, 0, 16); CRYPT_AESSetIV(aes, iv); @@ -660,7 +660,7 @@ void CPDF_StandardSecurityHandler::AES256_SetPerms(CPDF_Dictionary* pEncryptDict FX_Free(aes); pEncryptDict->SetAtString(FX_BSTRC("Perms"), CFX_ByteString(buf1, 16)); } -void CPDF_StandardCryptoHandler::CryptBlock(FX_BOOL bEncrypt, FX_DWORD objnum, FX_DWORD gennum, const uint8_t* src_buf, FX_DWORD src_size, +void CPDF_StandardCryptoHandler::CryptBlock(bool bEncrypt, FX_DWORD objnum, FX_DWORD gennum, const uint8_t* src_buf, FX_DWORD src_size, uint8_t* dest_buf, FX_DWORD& dest_size) { if (m_Cipher == FXCIPHER_NONE) { @@ -720,18 +720,18 @@ void CPDF_StandardCryptoHandler::CryptBlock(FX_BOOL bEncrypt, FX_DWORD objnum, F } typedef struct _AESCryptContext { uint8_t m_Context[2048]; - FX_BOOL m_bIV; + bool m_bIV; uint8_t m_Block[16]; FX_DWORD m_BlockOffset; } AESCryptContext; -void* CPDF_StandardCryptoHandler::CryptStart(FX_DWORD objnum, FX_DWORD gennum, FX_BOOL bEncrypt) +void* CPDF_StandardCryptoHandler::CryptStart(FX_DWORD objnum, FX_DWORD gennum, bool bEncrypt) { if (m_Cipher == FXCIPHER_NONE) { return this; } if (m_Cipher == FXCIPHER_AES && m_KeyLen == 32) { AESCryptContext* pContext = FX_Alloc(AESCryptContext, 1); - pContext->m_bIV = TRUE; + pContext->m_bIV = true; pContext->m_BlockOffset = 0; CRYPT_AESSetKey(pContext->m_Context, 16, m_EncryptKey, 32, bEncrypt); if (bEncrypt) { @@ -757,7 +757,7 @@ void* CPDF_StandardCryptoHandler::CryptStart(FX_DWORD objnum, FX_DWORD gennum, F } if (m_Cipher == FXCIPHER_AES) { AESCryptContext* pContext = FX_Alloc(AESCryptContext, 1); - pContext->m_bIV = TRUE; + pContext->m_bIV = true; pContext->m_BlockOffset = 0; CRYPT_AESSetKey(pContext->m_Context, 16, realkey, 16, bEncrypt); if (bEncrypt) { @@ -772,25 +772,25 @@ void* CPDF_StandardCryptoHandler::CryptStart(FX_DWORD objnum, FX_DWORD gennum, F CRYPT_ArcFourSetup(pContext, realkey, realkeylen); return pContext; } -FX_BOOL CPDF_StandardCryptoHandler::CryptStream(void* context, const uint8_t* src_buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf, FX_BOOL bEncrypt) +bool CPDF_StandardCryptoHandler::CryptStream(void* context, const uint8_t* src_buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf, bool bEncrypt) { if (!context) { - return FALSE; + return false; } if (m_Cipher == FXCIPHER_NONE) { dest_buf.AppendBlock(src_buf, src_size); - return TRUE; + return true; } if (m_Cipher == FXCIPHER_RC4) { int old_size = dest_buf.GetSize(); dest_buf.AppendBlock(src_buf, src_size); CRYPT_ArcFourCrypt(context, dest_buf.GetBuffer() + old_size, src_size); - return TRUE; + return true; } AESCryptContext* pContext = (AESCryptContext*)context; if (pContext->m_bIV && bEncrypt) { dest_buf.AppendBlock(pContext->m_Block, 16); - pContext->m_bIV = FALSE; + pContext->m_bIV = false; } FX_DWORD src_off = 0; FX_DWORD src_left = src_size; @@ -806,7 +806,7 @@ FX_BOOL CPDF_StandardCryptoHandler::CryptStream(void* context, const uint8_t* sr if (pContext->m_BlockOffset == 16) { if (!bEncrypt && pContext->m_bIV) { CRYPT_AESSetIV(pContext->m_Context, pContext->m_Block); - pContext->m_bIV = FALSE; + pContext->m_bIV = false; pContext->m_BlockOffset = 0; } else if (src_off < src_size) { uint8_t block_buf[16]; @@ -823,19 +823,19 @@ FX_BOOL CPDF_StandardCryptoHandler::CryptStream(void* context, const uint8_t* sr break; } } - return TRUE; + return true; } -FX_BOOL CPDF_StandardCryptoHandler::CryptFinish(void* context, CFX_BinaryBuf& dest_buf, FX_BOOL bEncrypt) +bool CPDF_StandardCryptoHandler::CryptFinish(void* context, CFX_BinaryBuf& dest_buf, bool bEncrypt) { if (!context) { - return FALSE; + return false; } if (m_Cipher == FXCIPHER_NONE) { - return TRUE; + return true; } if (m_Cipher == FXCIPHER_RC4) { FX_Free(context); - return TRUE; + return true; } AESCryptContext* pContext = (AESCryptContext*)context; if (bEncrypt) { @@ -856,24 +856,24 @@ FX_BOOL CPDF_StandardCryptoHandler::CryptFinish(void* context, CFX_BinaryBuf& de } } FX_Free(pContext); - return TRUE; + return true; } void* CPDF_StandardCryptoHandler::DecryptStart(FX_DWORD objnum, FX_DWORD gennum) { - return CryptStart(objnum, gennum, FALSE); + return CryptStart(objnum, gennum, false); } FX_DWORD CPDF_StandardCryptoHandler::DecryptGetSize(FX_DWORD src_size) { return m_Cipher == FXCIPHER_AES ? src_size - 16 : src_size; } -FX_BOOL CPDF_StandardCryptoHandler::Init(CPDF_Dictionary* pEncryptDict, CPDF_SecurityHandler* pSecurityHandler) +bool CPDF_StandardCryptoHandler::Init(CPDF_Dictionary* pEncryptDict, CPDF_SecurityHandler* pSecurityHandler) { const uint8_t* key; if (!pSecurityHandler->GetCryptInfo(m_Cipher, key, m_KeyLen)) { - return FALSE; + return false; } if (m_KeyLen > 32 || m_KeyLen < 0) { - return FALSE; + return false; } if (m_Cipher != FXCIPHER_NONE) { FXSYS_memcpy(m_EncryptKey, key, m_KeyLen); @@ -881,9 +881,9 @@ FX_BOOL CPDF_StandardCryptoHandler::Init(CPDF_Dictionary* pEncryptDict, CPDF_Sec if (m_Cipher == FXCIPHER_AES) { m_pAESContext = FX_Alloc(uint8_t, 2048); } - return TRUE; + return true; } -FX_BOOL CPDF_StandardCryptoHandler::Init(int cipher, const uint8_t* key, int keylen) +bool CPDF_StandardCryptoHandler::Init(int cipher, const uint8_t* key, int keylen) { if (cipher == FXCIPHER_AES) { switch(keylen) { @@ -892,15 +892,15 @@ FX_BOOL CPDF_StandardCryptoHandler::Init(int cipher, const uint8_t* key, int key case 32: break; default: - return FALSE; + return false; } } else if (cipher == FXCIPHER_AES2) { if (keylen != 32) { - return FALSE; + return false; } } else if (cipher == FXCIPHER_RC4) { if (keylen < 5 || keylen > 16) { - return FALSE; + return false; } } else { if (keylen > 32) { @@ -913,16 +913,16 @@ FX_BOOL CPDF_StandardCryptoHandler::Init(int cipher, const uint8_t* key, int key if (m_Cipher == FXCIPHER_AES) { m_pAESContext = FX_Alloc(uint8_t, 2048); } - return TRUE; + return true; } -FX_BOOL CPDF_StandardCryptoHandler::DecryptStream(void* context, const uint8_t* src_buf, FX_DWORD src_size, +bool CPDF_StandardCryptoHandler::DecryptStream(void* context, const uint8_t* src_buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf) { - return CryptStream(context, src_buf, src_size, dest_buf, FALSE); + return CryptStream(context, src_buf, src_size, dest_buf, false); } -FX_BOOL CPDF_StandardCryptoHandler::DecryptFinish(void* context, CFX_BinaryBuf& dest_buf) +bool CPDF_StandardCryptoHandler::DecryptFinish(void* context, CFX_BinaryBuf& dest_buf) { - return CryptFinish(context, dest_buf, FALSE); + return CryptFinish(context, dest_buf, false); } FX_DWORD CPDF_StandardCryptoHandler::EncryptGetSize(FX_DWORD objnum, FX_DWORD version, const uint8_t* src_buf, FX_DWORD src_size) { @@ -931,11 +931,11 @@ FX_DWORD CPDF_StandardCryptoHandler::EncryptGetSize(FX_DWORD objnum, FX_DWORD ve } return src_size; } -FX_BOOL CPDF_StandardCryptoHandler::EncryptContent(FX_DWORD objnum, FX_DWORD gennum, const uint8_t* src_buf, FX_DWORD src_size, +bool CPDF_StandardCryptoHandler::EncryptContent(FX_DWORD objnum, FX_DWORD gennum, const uint8_t* src_buf, FX_DWORD src_size, uint8_t* dest_buf, FX_DWORD& dest_size) { - CryptBlock(TRUE, objnum, gennum, src_buf, src_size, dest_buf, dest_size); - return TRUE; + CryptBlock(true, objnum, gennum, src_buf, src_size, dest_buf, dest_size); + return true; } void CPDF_CryptoHandler::Decrypt(FX_DWORD objnum, FX_DWORD gennum, CFX_ByteString& str) { diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_fdf.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_fdf.cpp index 1958fab280..ffce46bdd2 100644 --- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_fdf.cpp +++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_fdf.cpp @@ -9,7 +9,7 @@ CFDF_Document::CFDF_Document() : CPDF_IndirectObjects(NULL) { m_pRootDict = NULL; m_pFile = NULL; - m_bOwnFile = FALSE; + m_bOwnFile = false; } CFDF_Document::~CFDF_Document() { @@ -26,7 +26,7 @@ CFDF_Document* CFDF_Document::CreateNewDoc() pDoc->m_pRootDict->SetAt(FX_BSTRC("FDF"), pFDFDict); return pDoc; } -CFDF_Document* CFDF_Document::ParseFile(IFX_FileRead *pFile, FX_BOOL bOwnFile) +CFDF_Document* CFDF_Document::ParseFile(IFX_FileRead *pFile, bool bOwnFile) { if (!pFile) { return NULL; @@ -41,16 +41,16 @@ CFDF_Document* CFDF_Document::ParseFile(IFX_FileRead *pFile, FX_BOOL bOwnFile) } CFDF_Document* CFDF_Document::ParseMemory(const uint8_t* pData, FX_DWORD size) { - return CFDF_Document::ParseFile(FX_CreateMemoryStream((uint8_t*)pData, size), TRUE); + return CFDF_Document::ParseFile(FX_CreateMemoryStream((uint8_t*)pData, size), true); } -void CFDF_Document::ParseStream(IFX_FileRead *pFile, FX_BOOL bOwnFile) +void CFDF_Document::ParseStream(IFX_FileRead *pFile, bool bOwnFile) { m_pFile = pFile; m_bOwnFile = bOwnFile; CPDF_SyntaxParser parser; parser.InitParser(m_pFile, 0); while (1) { - FX_BOOL bNumber; + bool bNumber; CFX_ByteString word = parser.GetNextWord(bNumber); if (bNumber) { FX_DWORD objnum = FXSYS_atoi(word); @@ -85,10 +85,10 @@ void CFDF_Document::ParseStream(IFX_FileRead *pFile, FX_BOOL bOwnFile) } } } -FX_BOOL CFDF_Document::WriteBuf(CFX_ByteTextBuf& buf) const +bool CFDF_Document::WriteBuf(CFX_ByteTextBuf& buf) const { if (m_pRootDict == NULL) { - return FALSE; + return false; } buf << FX_BSTRC("%FDF-1.2\r\n"); FX_POSITION pos = m_IndirectObjs.GetStartPosition(); @@ -99,7 +99,7 @@ FX_BOOL CFDF_Document::WriteBuf(CFX_ByteTextBuf& buf) const buf << (FX_DWORD)objnum << FX_BSTRC(" 0 obj\r\n") << pObj << FX_BSTRC("\r\nendobj\r\n\r\n"); } buf << FX_BSTRC("trailer\r\n<</Root ") << m_pRootDict->GetObjNum() << FX_BSTRC(" 0 R>>\r\n%%EOF\r\n"); - return TRUE; + return true; } CFX_WideString CFDF_Document::GetWin32Path() const { diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_filters.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_filters.cpp index fed4546fab..f81aa73cb3 100644 --- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_filters.cpp +++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_filters.cpp @@ -25,7 +25,7 @@ static void my_free_func(void* opaque, void* address) CFX_DataFilter::CFX_DataFilter() { - m_bEOF = FALSE; + m_bEOF = false; m_pDestFilter = NULL; m_SrcPos = 0; } @@ -68,14 +68,14 @@ void CFX_DataFilter::FilterFinish(CFX_BinaryBuf& dest_buf) } else { v_FilterFinish(dest_buf); } - m_bEOF = TRUE; + m_bEOF = true; } void CFX_DataFilter::ReportEOF(FX_DWORD left_input) { if (m_bEOF) { return; } - m_bEOF = TRUE; + m_bEOF = true; m_SrcPos -= left_input; } CFX_DataFilter* FPDF_CreateFilter(const CFX_ByteStringC& name, const CPDF_Dictionary* pParam, int width, int height) @@ -113,9 +113,9 @@ CFX_DataFilter* FPDF_CreateFilter(const CFX_ByteStringC& name, const CPDF_Dictio return new CPDF_RunLenFilter; case FXBSTR_ID('C', 'C', 'I', 'T'): { int Encoding = 0; - int bEndOfLine = FALSE; - int bByteAlign = FALSE; - int bBlack = FALSE; + int bEndOfLine = false; + int bByteAlign = false; + int bBlack = false; int nRows = 0; int nColumns = 1728; if (pParam) { @@ -178,7 +178,7 @@ CFX_DataFilter* _FPDF_CreateFilterFromDict(CPDF_Dictionary* pDict) } return pFirstFilter; } -CPDF_StreamFilter* CPDF_Stream::GetStreamFilter(FX_BOOL bRaw) const +CPDF_StreamFilter* CPDF_Stream::GetStreamFilter(bool bRaw) const { CFX_DataFilter* pFirstFilter = NULL; if (m_pCryptoHandler) { @@ -294,7 +294,7 @@ void CPDF_DecryptFilter::v_FilterIn(const uint8_t* src_buf, FX_DWORD src_size, C } void CPDF_DecryptFilter::v_FilterFinish(CFX_BinaryBuf& dest_buf) { - m_bEOF = TRUE; + m_bEOF = true; if (m_pContext == NULL) { return; } @@ -330,7 +330,7 @@ void CPDF_FlateFilter::v_FilterIn(const uint8_t* src_buf, FX_DWORD src_size, CFX } } } -CPDF_LzwFilter::CPDF_LzwFilter(FX_BOOL bEarlyChange) +CPDF_LzwFilter::CPDF_LzwFilter(bool bEarlyChange) { m_bEarlyChange = bEarlyChange ? 1 : 0; m_CodeLen = 9; @@ -697,7 +697,7 @@ void CPDF_RunLenFilter::v_FilterIn(const uint8_t* src_buf, FX_DWORD src_size, CF CPDF_JpegFilter::CPDF_JpegFilter() { m_pContext = NULL; - m_bGotHeader = FALSE; + m_bGotHeader = false; m_pScanline = NULL; m_iLine = 0; } @@ -742,7 +742,7 @@ void CPDF_JpegFilter::v_FilterIn(const uint8_t* src_buf, FX_DWORD src_size, CFX_ return; } CPDF_ModuleMgr::Get()->GetJpegModule()->StartScanline(m_pContext, 1); - m_bGotHeader = TRUE; + m_bGotHeader = true; m_Pitch = m_Width * m_nComps; } if (m_pScanline == NULL) { @@ -765,9 +765,9 @@ void CPDF_JpegFilter::v_FilterIn(const uint8_t* src_buf, FX_DWORD src_size, CFX_ CPDF_FaxFilter::CPDF_FaxFilter() { m_Encoding = 0; - m_bEndOfLine = FALSE; - m_bByteAlign = FALSE; - m_bBlack = FALSE; + m_bEndOfLine = false; + m_bByteAlign = false; + m_bBlack = false; m_nRows = 0; m_nColumns = 0; m_Pitch = 0; @@ -785,7 +785,7 @@ CPDF_FaxFilter::~CPDF_FaxFilter() FX_Free(m_pRefBuf); } } -FX_BOOL CPDF_FaxFilter::Initialize(int Encoding, int bEndOfLine, int bByteAlign, int bBlack, int nRows, int nColumns) +bool CPDF_FaxFilter::Initialize(int Encoding, int bEndOfLine, int bByteAlign, int bBlack, int nRows, int nColumns) { m_Encoding = Encoding; m_bEndOfLine = bEndOfLine; @@ -800,7 +800,7 @@ FX_BOOL CPDF_FaxFilter::Initialize(int Encoding, int bEndOfLine, int bByteAlign, FXSYS_memset(m_pRefBuf, 0xff, m_Pitch); m_iRow = 0; m_InputBitPos = 0; - return TRUE; + return true; } void CPDF_FaxFilter::v_FilterIn(const uint8_t* src_buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf) { @@ -821,19 +821,19 @@ void CPDF_FaxFilter::v_FilterIn(const uint8_t* src_buf, FX_DWORD src_size, CFX_B fax_src_size = src_size; bitpos = 0; } - ProcessData(fax_src_buf, fax_src_size, bitpos, FALSE, dest_buf); + ProcessData(fax_src_buf, fax_src_size, bitpos, false, dest_buf); int left_bits = fax_src_size * 8 - bitpos; m_InputBuf.AppendBlock(fax_src_buf + bitpos / 8, (left_bits + 7) / 8); m_InputBitPos = bitpos % 8; } void CPDF_FaxFilter::v_FilterFinish(CFX_BinaryBuf& dest_buf) { - ProcessData(m_InputBuf.GetBuffer(), m_InputBuf.GetSize(), m_InputBitPos, TRUE, dest_buf); + ProcessData(m_InputBuf.GetBuffer(), m_InputBuf.GetSize(), m_InputBitPos, true, dest_buf); } -FX_BOOL _FaxSkipEOL(const uint8_t* src_buf, int bitsize, int& bitpos); -FX_BOOL _FaxG4GetRow(const uint8_t* src_buf, int bitsize, int& bitpos, uint8_t* dest_buf, const uint8_t* ref_buf, int columns); -FX_BOOL _FaxGet1DLine(const uint8_t* src_buf, int bitsize, int& bitpos, uint8_t* dest_buf, int columns); -void CPDF_FaxFilter::ProcessData(const uint8_t* src_buf, FX_DWORD src_size, int& bitpos, FX_BOOL bFinish, +bool _FaxSkipEOL(const uint8_t* src_buf, int bitsize, int& bitpos); +bool _FaxG4GetRow(const uint8_t* src_buf, int bitsize, int& bitpos, uint8_t* dest_buf, const uint8_t* ref_buf, int columns); +bool _FaxGet1DLine(const uint8_t* src_buf, int bitsize, int& bitpos, uint8_t* dest_buf, int columns); +void CPDF_FaxFilter::ProcessData(const uint8_t* src_buf, FX_DWORD src_size, int& bitpos, bool bFinish, CFX_BinaryBuf& dest_buf) { int bitsize = src_size * 8; @@ -863,21 +863,21 @@ void CPDF_FaxFilter::ProcessData(const uint8_t* src_buf, FX_DWORD src_size, int& } } } -FX_BOOL CPDF_FaxFilter::ReadLine(const uint8_t* src_buf, int bitsize, int& bitpos) +bool CPDF_FaxFilter::ReadLine(const uint8_t* src_buf, int bitsize, int& bitpos) { if (!_FaxSkipEOL(src_buf, bitsize, bitpos)) { - return FALSE; + return false; } - FX_BOOL ret; + bool ret; if (m_Encoding < 0) { ret = _FaxG4GetRow(src_buf, bitsize, bitpos, m_pScanlineBuf, m_pRefBuf, m_nColumns); } else if (m_Encoding == 0) { ret = _FaxGet1DLine(src_buf, bitsize, bitpos, m_pScanlineBuf, m_nColumns); } else { if (bitpos == bitsize) { - return FALSE; + return false; } - FX_BOOL bNext1D = src_buf[bitpos / 8] & (1 << (7 - bitpos % 8)); + bool bNext1D = src_buf[bitpos / 8] & (1 << (7 - bitpos % 8)); bitpos ++; if (bNext1D) { ret = _FaxGet1DLine(src_buf, bitsize, bitpos, m_pScanlineBuf, m_nColumns); @@ -886,14 +886,14 @@ FX_BOOL CPDF_FaxFilter::ReadLine(const uint8_t* src_buf, int bitsize, int& bitpo } } if (!ret) { - return FALSE; + return false; } if (m_bEndOfLine) if (!_FaxSkipEOL(src_buf, bitsize, bitpos)) { - return FALSE; + return false; } if (m_bByteAlign) { bitpos = (bitpos + 7) / 8 * 8; } - return TRUE; + return true; } diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp index c7d1dece25..96e6807102 100644 --- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp +++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp @@ -180,7 +180,7 @@ void CPDF_Object::SetString(const CFX_ByteString& str) ((CPDF_Name*)this)->m_Name = str; return; } - ASSERT(FALSE); + ASSERT(false); } int CPDF_Object::GetDirectType() const { @@ -190,13 +190,13 @@ int CPDF_Object::GetDirectType() const CPDF_Reference* pRef = (CPDF_Reference*)this; return pRef->m_pObjList->GetIndirectType(pRef->m_RefObjNum); } -FX_BOOL CPDF_Object::IsIdentical(CPDF_Object* pOther) const +bool CPDF_Object::IsIdentical(CPDF_Object* pOther) const { if (this == pOther) { - return TRUE; + return true; } if (pOther == NULL) { - return FALSE; + return false; } if (pOther->m_Type != m_Type) { if (m_Type == PDFOBJ_REFERENCE && GetDirect()) { @@ -205,7 +205,7 @@ FX_BOOL CPDF_Object::IsIdentical(CPDF_Object* pOther) const if (pOther->m_Type == PDFOBJ_REFERENCE) { return IsIdentical(pOther->GetDirect()); } - return FALSE; + return false; } switch (m_Type) { case PDFOBJ_BOOLEAN: @@ -221,13 +221,13 @@ FX_BOOL CPDF_Object::IsIdentical(CPDF_Object* pOther) const case PDFOBJ_DICTIONARY: return (((CPDF_Dictionary*)this)->Identical((CPDF_Dictionary*)pOther)); case PDFOBJ_NULL: - return TRUE; + return true; case PDFOBJ_STREAM: return (((CPDF_Stream*)this)->Identical((CPDF_Stream*)pOther)); case PDFOBJ_REFERENCE: return (((CPDF_Reference*)this)->Identical((CPDF_Reference*)pOther)); } - return FALSE; + return false; } CPDF_Object* CPDF_Object::GetDirect() const { @@ -240,12 +240,12 @@ CPDF_Object* CPDF_Object::GetDirect() const } return pRef->m_pObjList->GetIndirectObject(pRef->m_RefObjNum); } -CPDF_Object* CPDF_Object::Clone(FX_BOOL bDirect) const +CPDF_Object* CPDF_Object::Clone(bool bDirect) const { CFX_MapPtrToPtr visited; return CloneInternal(bDirect, &visited); } -CPDF_Object* CPDF_Object::CloneInternal(FX_BOOL bDirect, CFX_MapPtrToPtr* visited) const +CPDF_Object* CPDF_Object::CloneInternal(bool bDirect, CFX_MapPtrToPtr* visited) const { switch (m_Type) { case PDFOBJ_BOOLEAN: @@ -284,7 +284,7 @@ CPDF_Object* CPDF_Object::CloneInternal(FX_BOOL bDirect, CFX_MapPtrToPtr* visite case PDFOBJ_STREAM: { CPDF_Stream* pThis = (CPDF_Stream*)this; CPDF_StreamAcc acc; - acc.LoadAllData(pThis, TRUE); + acc.LoadAllData(pThis, true); FX_DWORD streamSize = acc.GetSize(); CPDF_Dictionary* pDict = pThis->GetDict(); if (pDict) @@ -299,7 +299,7 @@ CPDF_Object* CPDF_Object::CloneInternal(FX_BOOL bDirect, CFX_MapPtrToPtr* visite if (!pRef->GetDirect()) return nullptr; - return pRef->GetDirect()->CloneInternal(TRUE, visited); + return pRef->GetDirect()->CloneInternal(true, visited); } return new CPDF_Reference(pRef->m_pObjList, obj_num); } @@ -320,7 +320,7 @@ CFX_WideString CPDF_Object::GetUnicodeText(CFX_CharMap* pCharMap) const } if (m_Type == PDFOBJ_STREAM) { CPDF_StreamAcc stream; - stream.LoadAllData((CPDF_Stream*)this, FALSE); + stream.LoadAllData((CPDF_Stream*)this, false); CFX_WideString result = PDF_DecodeText(stream.GetData(), stream.GetSize(), pCharMap); return result; } @@ -335,19 +335,19 @@ void CPDF_Object::SetUnicodeText(const FX_WCHAR* pUnicodes, int len) ((CPDF_String*)this)->m_String = PDF_EncodeText(pUnicodes, len); } else if (m_Type == PDFOBJ_STREAM) { CFX_ByteString result = PDF_EncodeText(pUnicodes, len); - ((CPDF_Stream*)this)->SetData((uint8_t*)result.c_str(), result.GetLength(), FALSE, FALSE); + ((CPDF_Stream*)this)->SetData((uint8_t*)result.c_str(), result.GetLength(), false, false); } } CPDF_Number::CPDF_Number(int value) - : CPDF_Object(PDFOBJ_NUMBER), m_bInteger(TRUE), m_Integer(value) { + : CPDF_Object(PDFOBJ_NUMBER), m_bInteger(true), m_Integer(value) { } CPDF_Number::CPDF_Number(FX_FLOAT value) - : CPDF_Object(PDFOBJ_NUMBER), m_bInteger(FALSE), m_Float(value) { + : CPDF_Object(PDFOBJ_NUMBER), m_bInteger(false), m_Float(value) { } -CPDF_Number::CPDF_Number(FX_BOOL bInteger, void* pData) +CPDF_Number::CPDF_Number(bool bInteger, void* pData) : CPDF_Object(PDFOBJ_NUMBER), m_bInteger(bInteger), m_Integer(*(int*)pData) { } @@ -359,7 +359,7 @@ void CPDF_Number::SetString(const CFX_ByteStringC& str) { FX_atonum(str, m_bInteger, &m_Integer); } -FX_BOOL CPDF_Number::Identical(CPDF_Number* pOther) const +bool CPDF_Number::Identical(CPDF_Number* pOther) const { return m_bInteger == pOther->m_bInteger && m_Integer == pOther->m_Integer; } @@ -369,10 +369,10 @@ CFX_ByteString CPDF_Number::GetString() const } void CPDF_Number::SetNumber(FX_FLOAT value) { - m_bInteger = FALSE; + m_bInteger = false; m_Float = value; } -CPDF_String::CPDF_String(const CFX_WideString& str) : CPDF_Object(PDFOBJ_STRING), m_bHex(FALSE) { +CPDF_String::CPDF_String(const CFX_WideString& str) : CPDF_Object(PDFOBJ_STRING), m_bHex(false) { m_String = PDF_EncodeText(str); } CPDF_Array::~CPDF_Array() @@ -553,16 +553,16 @@ void CPDF_Array::AddReference(CPDF_IndirectObjects* pDoc, FX_DWORD objnum) ASSERT(m_Type == PDFOBJ_ARRAY); Add(new CPDF_Reference(pDoc, objnum)); } -FX_BOOL CPDF_Array::Identical(CPDF_Array* pOther) const +bool CPDF_Array::Identical(CPDF_Array* pOther) const { if (m_Objects.GetSize() != pOther->m_Objects.GetSize()) { - return FALSE; + return false; } for (int i = 0; i < m_Objects.GetSize(); i ++) if (!((CPDF_Object*)m_Objects[i])->IsIdentical((CPDF_Object*)pOther->m_Objects[i])) { - return FALSE; + return false; } - return TRUE; + return true; } CPDF_Dictionary::~CPDF_Dictionary() { @@ -677,7 +677,7 @@ FX_FLOAT CPDF_Dictionary::GetNumber(const CFX_ByteStringC& key) const } return 0; } -FX_BOOL CPDF_Dictionary::GetBoolean(const CFX_ByteStringC& key, FX_BOOL bDefault) const +bool CPDF_Dictionary::GetBoolean(const CFX_ByteStringC& key, bool bDefault) const { CPDF_Object* p = NULL; m_Map.Lookup(key, (void*&)p); @@ -734,7 +734,7 @@ CFX_AffineMatrix CPDF_Dictionary::GetMatrix(const CFX_ByteStringC& key) const } return matrix; } -FX_BOOL CPDF_Dictionary::KeyExist(const CFX_ByteStringC& key) const +bool CPDF_Dictionary::KeyExist(const CFX_ByteStringC& key) const { void* value; return m_Map.Lookup(key, value); @@ -786,13 +786,13 @@ void CPDF_Dictionary::ReplaceKey(const CFX_ByteStringC& oldkey, const CFX_ByteSt m_Map.RemoveKey(oldkey); m_Map.SetAt(newkey, p); } -FX_BOOL CPDF_Dictionary::Identical(CPDF_Dictionary* pOther) const +bool CPDF_Dictionary::Identical(CPDF_Dictionary* pOther) const { if (pOther == NULL) { - return FALSE; + return false; } if (m_Map.GetCount() != pOther->m_Map.GetCount()) { - return FALSE; + return false; } FX_POSITION pos = m_Map.GetStartPosition(); while (pos) { @@ -800,12 +800,12 @@ FX_BOOL CPDF_Dictionary::Identical(CPDF_Dictionary* pOther) const void* value; m_Map.GetNextAssoc(pos, key, value); if (!value) - return FALSE; + return false; if (!((CPDF_Object*)value)->IsIdentical(pOther->GetElement(key))) { - return FALSE; + return false; } } - return TRUE; + return true; } void CPDF_Dictionary::SetAtInteger(const CFX_ByteStringC& key, int i) { @@ -833,7 +833,7 @@ void CPDF_Dictionary::SetAtNumber(const CFX_ByteStringC& key, FX_FLOAT f) pNumber->SetNumber(f); SetAt(key, pNumber); } -void CPDF_Dictionary::SetAtBoolean(const CFX_ByteStringC& key, FX_BOOL bValue) +void CPDF_Dictionary::SetAtBoolean(const CFX_ByteStringC& key, bool bValue) { SetAt(key, new CPDF_Boolean(bValue)); } @@ -905,7 +905,7 @@ void CPDF_Stream::InitStream(uint8_t* pData, FX_DWORD size, CPDF_Dictionary* pDi m_pDict->SetAtInteger(FX_BSTRC("Length"), size); } } -void CPDF_Stream::SetData(const uint8_t* pData, FX_DWORD size, FX_BOOL bCompressed, FX_BOOL bKeepBuf) +void CPDF_Stream::SetData(const uint8_t* pData, FX_DWORD size, bool bCompressed, bool bKeepBuf) { if (m_GenNum == (FX_DWORD) - 1) { if (m_pDataBuf) { @@ -933,7 +933,7 @@ void CPDF_Stream::SetData(const uint8_t* pData, FX_DWORD size, FX_BOOL bCompress m_pDict->RemoveAt(FX_BSTRC("DecodeParms")); } } -FX_BOOL CPDF_Stream::ReadRawData(FX_FILESIZE offset, uint8_t* buf, FX_DWORD size) const +bool CPDF_Stream::ReadRawData(FX_FILESIZE offset, uint8_t* buf, FX_DWORD size) const { if ((m_GenNum != (FX_DWORD) - 1) && m_pFile) { return m_pFile->ReadBlock(buf, m_FileOffset + offset, size); @@ -941,7 +941,7 @@ FX_BOOL CPDF_Stream::ReadRawData(FX_FILESIZE offset, uint8_t* buf, FX_DWORD size if (m_pDataBuf) { FXSYS_memcpy(buf, m_pDataBuf + offset, size); } - return TRUE; + return true; } void CPDF_Stream::InitStream(IFX_FileRead *pFile, CPDF_Dictionary* pDict) { @@ -952,23 +952,23 @@ void CPDF_Stream::InitStream(IFX_FileRead *pFile, CPDF_Dictionary* pDict) m_pDict->SetAtInteger(FX_BSTRC("Length"), m_dwSize); } } -FX_BOOL CPDF_Stream::Identical(CPDF_Stream* pOther) const +bool CPDF_Stream::Identical(CPDF_Stream* pOther) const { if (!m_pDict) - return pOther->m_pDict ? FALSE : TRUE; + return pOther->m_pDict ? false : true; if (!m_pDict->Identical(pOther->m_pDict)) { - return FALSE; + return false; } if (m_dwSize != pOther->m_dwSize) { - return FALSE; + return false; } if (m_GenNum != (FX_DWORD) - 1 && pOther->m_GenNum != (FX_DWORD) - 1) { if (m_pFile == pOther->m_pFile && m_pFile == NULL) { - return TRUE; + return true; } if (!m_pFile || !pOther->m_pFile) { - return FALSE; + return false; } uint8_t srcBuf[1024]; uint8_t destBuf[1024]; @@ -976,20 +976,20 @@ FX_BOOL CPDF_Stream::Identical(CPDF_Stream* pOther) const FX_DWORD srcOffset = m_FileOffset; FX_DWORD destOffset = pOther->m_FileOffset; if (m_pFile == pOther->m_pFile && srcOffset == destOffset) { - return TRUE; + return true; } while (size > 0) { FX_DWORD actualSize = size > 1024 ? 1024 : size; m_pFile->ReadBlock(srcBuf, srcOffset, actualSize); pOther->m_pFile->ReadBlock(destBuf, destOffset, actualSize); if (FXSYS_memcmp(srcBuf, destBuf, actualSize) != 0) { - return FALSE; + return false; } size -= actualSize; srcOffset += actualSize; destOffset += actualSize; } - return TRUE; + return true; } if (m_GenNum != (FX_DWORD) - 1 || pOther->m_GenNum != (FX_DWORD) - 1) { IFX_FileRead* pFile = NULL; @@ -1005,7 +1005,7 @@ FX_BOOL CPDF_Stream::Identical(CPDF_Stream* pOther) const offset = m_FileOffset; } if (NULL == pBuf) { - return FALSE; + return false; } uint8_t srcBuf[1024]; FX_DWORD size = m_dwSize; @@ -1013,17 +1013,17 @@ FX_BOOL CPDF_Stream::Identical(CPDF_Stream* pOther) const FX_DWORD actualSize = std::min(size, 1024U); pFile->ReadBlock(srcBuf, offset, actualSize); if (FXSYS_memcmp(srcBuf, pBuf, actualSize) != 0) { - return FALSE; + return false; } pBuf += actualSize; size -= actualSize; offset += actualSize; } - return TRUE; + return true; } return FXSYS_memcmp(m_pDataBuf, pOther->m_pDataBuf, m_dwSize) == 0; } -CPDF_Stream* CPDF_Stream::Clone(FX_BOOL bDirect, FPDF_LPFCloneStreamCallback lpfCallback, void* pUserData) const +CPDF_Stream* CPDF_Stream::Clone(bool bDirect, FPDF_LPFCloneStreamCallback lpfCallback, void* pUserData) const { CPDF_Dictionary *pCloneDict = (CPDF_Dictionary*)m_pDict->Clone(bDirect); IFX_FileStream *pFS = NULL; @@ -1032,12 +1032,12 @@ CPDF_Stream* CPDF_Stream::Clone(FX_BOOL bDirect, FPDF_LPFCloneStreamCallback lpf } if (!pFS) { CPDF_StreamAcc acc; - acc.LoadAllData(this, TRUE); + acc.LoadAllData(this, true); FX_DWORD streamSize = acc.GetSize(); return new CPDF_Stream(acc.DetachData(), streamSize, pCloneDict); } CPDF_Stream* pObj = new CPDF_Stream(NULL, 0, NULL); - CPDF_StreamFilter *pSF = GetStreamFilter(TRUE); + CPDF_StreamFilter *pSF = GetStreamFilter(true); if (pSF) { uint8_t* pBuf = FX_Alloc(uint8_t, 4096); FX_DWORD dwRead; @@ -1054,20 +1054,20 @@ CPDF_Stream* CPDF_Stream::Clone(FX_BOOL bDirect, FPDF_LPFCloneStreamCallback lpf pObj->InitStream((IFX_FileRead*)pFS, pCloneDict); return pObj; } -extern FX_BOOL PDF_DataDecode(const uint8_t* src_buf, FX_DWORD src_size, const CPDF_Dictionary* pDict, +extern bool PDF_DataDecode(const uint8_t* src_buf, FX_DWORD src_size, const CPDF_Dictionary* pDict, uint8_t*& dest_buf, FX_DWORD& dest_size, CFX_ByteString& ImageEncoding, - CPDF_Dictionary*& pImageParms, FX_DWORD estimated_size, FX_BOOL bImageAcc); + CPDF_Dictionary*& pImageParms, FX_DWORD estimated_size, bool bImageAcc); CPDF_StreamAcc::CPDF_StreamAcc() { - m_bNewBuf = FALSE; + m_bNewBuf = false; m_pData = NULL; m_dwSize = 0; m_pImageParam = NULL; m_pStream = NULL; m_pSrcData = NULL; } -void CPDF_StreamAcc::LoadAllData(const CPDF_Stream* pStream, FX_BOOL bRawAccess, FX_DWORD estimated_size, - FX_BOOL bImageAcc) +void CPDF_StreamAcc::LoadAllData(const CPDF_Stream* pStream, bool bRawAccess, FX_DWORD estimated_size, + bool bImageAcc) { if (pStream == NULL || pStream->GetType() != PDFOBJ_STREAM) { return; @@ -1111,7 +1111,7 @@ void CPDF_StreamAcc::LoadAllData(const CPDF_Stream* pStream, FX_BOOL bRawAccess, m_pData = pDecryptedData; m_dwSize = dwDecryptedSize; } else { - FX_BOOL bRet = PDF_DataDecode(pDecryptedData, dwDecryptedSize, m_pStream->GetDict(), + bool bRet = PDF_DataDecode(pDecryptedData, dwDecryptedSize, m_pStream->GetDict(), m_pData, m_dwSize, m_ImageDecoder, m_pImageParam, estimated_size, bImageAcc); if (!bRet) { m_pData = pDecryptedData; diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp index 854be75ad4..07f6ca783c 100644 --- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp +++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp @@ -13,19 +13,19 @@ #include "../../../include/fxcrt/fx_safe_types.h" #include "../fpdf_page/pageint.h" -FX_BOOL IsSignatureDict(const CPDF_Dictionary* pDict) +bool IsSignatureDict(const CPDF_Dictionary* pDict) { CPDF_Object* pType = pDict->GetElementValue(FX_BSTRC("Type")); if (!pType) { pType = pDict->GetElementValue(FX_BSTRC("FT")); if (!pType) { - return FALSE; + return false; } } if (pType->GetString() == FX_BSTRC("Sig")) { - return TRUE; + return true; } - return FALSE; + return false; } static int _CompareFileSize(const void* p1, const void* p2) { @@ -48,13 +48,13 @@ CPDF_Parser::CPDF_Parser() m_pLinearized = NULL; m_dwFirstPageNo = 0; m_dwXrefStartObjNum = 0; - m_bOwnFileRead = TRUE; + m_bOwnFileRead = true; m_FileVersion = 0; - m_bForceUseSecurityHandler = FALSE; + m_bForceUseSecurityHandler = false; } CPDF_Parser::~CPDF_Parser() { - CloseParser(FALSE); + CloseParser(false); } FX_DWORD CPDF_Parser::GetLastObjNum() { @@ -65,9 +65,9 @@ void CPDF_Parser::SetEncryptDictionary(CPDF_Dictionary* pDict) { m_pEncryptDict = pDict; } -void CPDF_Parser::CloseParser(FX_BOOL bReParse) +void CPDF_Parser::CloseParser(bool bReParse) { - m_bVersionUpdated = FALSE; + m_bVersionUpdated = false; if (!bReParse) { delete m_pDocument; m_pDocument = NULL; @@ -124,7 +124,7 @@ static int32_t GetHeaderOffset(IFX_FileRead* pFile) } return -1; } -FX_DWORD CPDF_Parser::StartParse(const FX_CHAR* filename, FX_BOOL bReParse) +FX_DWORD CPDF_Parser::StartParse(const FX_CHAR* filename, bool bReParse) { IFX_FileRead* pFileAccess = FX_CreateFileRead(filename); if (!pFileAccess) { @@ -132,7 +132,7 @@ FX_DWORD CPDF_Parser::StartParse(const FX_CHAR* filename, FX_BOOL bReParse) } return StartParse(pFileAccess, bReParse); } -FX_DWORD CPDF_Parser::StartParse(const FX_WCHAR* filename, FX_BOOL bReParse) +FX_DWORD CPDF_Parser::StartParse(const FX_WCHAR* filename, bool bReParse) { IFX_FileRead* pFileAccess = FX_CreateFileRead(filename); if (!pFileAccess) { @@ -142,10 +142,10 @@ FX_DWORD CPDF_Parser::StartParse(const FX_WCHAR* filename, FX_BOOL bReParse) } CPDF_SecurityHandler* FPDF_CreateStandardSecurityHandler(); CPDF_SecurityHandler* FPDF_CreatePubKeyHandler(void*); -FX_DWORD CPDF_Parser::StartParse(IFX_FileRead* pFileAccess, FX_BOOL bReParse, FX_BOOL bOwnFileRead) +FX_DWORD CPDF_Parser::StartParse(IFX_FileRead* pFileAccess, bool bReParse, bool bOwnFileRead) { CloseParser(bReParse); - m_bXRefStream = FALSE; + m_bXRefStream = false; m_LastXRefOffset = 0; m_bOwnFileRead = bOwnFileRead; int32_t offset = GetHeaderOffset(pFileAccess); @@ -176,15 +176,15 @@ FX_DWORD CPDF_Parser::StartParse(IFX_FileRead* pFileAccess, FX_BOOL bReParse, FX if (!bReParse) { m_pDocument = new CPDF_Document(this); } - FX_BOOL bXRefRebuilt = FALSE; - if (m_Syntax.SearchWord(FX_BSTRC("startxref"), TRUE, FALSE, 4096)) { + bool bXRefRebuilt = false; + if (m_Syntax.SearchWord(FX_BSTRC("startxref"), true, false, 4096)) { FX_FILESIZE startxref_offset = m_Syntax.SavePos(); void* pResult = FXSYS_bsearch(&startxref_offset, m_SortedOffset.GetData(), m_SortedOffset.GetSize(), sizeof(FX_FILESIZE), _CompareFileSize); if (pResult == NULL) { m_SortedOffset.Add(startxref_offset); } m_Syntax.GetKeyword(); - FX_BOOL bNumber; + bool bNumber; CFX_ByteString xrefpos_str = m_Syntax.GetNextWord(bNumber); if (!bNumber) { return PDFPARSE_ERROR_FORMAT; @@ -194,14 +194,14 @@ FX_DWORD CPDF_Parser::StartParse(IFX_FileRead* pFileAccess, FX_BOOL bReParse, FX if (!RebuildCrossRef()) { return PDFPARSE_ERROR_FORMAT; } - bXRefRebuilt = TRUE; + bXRefRebuilt = true; m_LastXRefOffset = 0; } } else { if (!RebuildCrossRef()) { return PDFPARSE_ERROR_FORMAT; } - bXRefRebuilt = TRUE; + bXRefRebuilt = true; } FX_DWORD dwRet = SetEncryptHandler(); if (dwRet != PDFPARSE_ERROR_SUCCESS) { @@ -340,26 +340,26 @@ static int32_t GetDirectInteger(CPDF_Dictionary* pDict, const CFX_ByteStringC& k } return 0; } -static FX_BOOL CheckDirectType(CPDF_Dictionary* pDict, const CFX_ByteStringC& key, int32_t iType) +static bool CheckDirectType(CPDF_Dictionary* pDict, const CFX_ByteStringC& key, int32_t iType) { CPDF_Object* pObj = pDict->GetElement(key); if (!pObj) { - return TRUE; + return true; } return pObj->GetType() == iType; } -FX_BOOL CPDF_Parser::LoadAllCrossRefV4(FX_FILESIZE xrefpos) +bool CPDF_Parser::LoadAllCrossRefV4(FX_FILESIZE xrefpos) { - if (!LoadCrossRefV4(xrefpos, 0, TRUE, FALSE)) { - return FALSE; + if (!LoadCrossRefV4(xrefpos, 0, true, false)) { + return false; } m_pTrailer = LoadTrailerV4(); if (m_pTrailer == NULL) { - return FALSE; + return false; } int32_t xrefsize = GetDirectInteger(m_pTrailer, FX_BSTRC("Size")); if (xrefsize <= 0 || xrefsize > (1 << 20)) { - return FALSE; + return false; } m_CrossRef.SetSize(xrefsize); m_V5Type.SetSize(xrefsize); @@ -367,51 +367,51 @@ FX_BOOL CPDF_Parser::LoadAllCrossRefV4(FX_FILESIZE xrefpos) CrossRefList.Add(xrefpos); XRefStreamList.Add(GetDirectInteger(m_pTrailer, FX_BSTRC("XRefStm"))); if (!CheckDirectType(m_pTrailer, FX_BSTRC("Prev"), PDFOBJ_NUMBER)) { - return FALSE; + return false; } FX_FILESIZE newxrefpos = GetDirectInteger(m_pTrailer, FX_BSTRC("Prev")); if (newxrefpos == xrefpos) { - return FALSE; + return false; } xrefpos = newxrefpos; while (xrefpos) { CrossRefList.InsertAt(0, xrefpos); - LoadCrossRefV4(xrefpos, 0, TRUE, FALSE); + LoadCrossRefV4(xrefpos, 0, true, false); CPDF_Dictionary* pDict = LoadTrailerV4(); if (pDict == NULL) { - return FALSE; + return false; } if (!CheckDirectType(pDict, FX_BSTRC("Prev"), PDFOBJ_NUMBER)) { pDict->Release(); - return FALSE; + return false; } newxrefpos = GetDirectInteger(pDict, FX_BSTRC("Prev")); if (newxrefpos == xrefpos) { pDict->Release(); - return FALSE; + return false; } xrefpos = newxrefpos; XRefStreamList.InsertAt(0, pDict->GetInteger(FX_BSTRC("XRefStm"))); m_Trailers.Add(pDict); } for (int32_t i = 0; i < CrossRefList.GetSize(); i ++) - if (!LoadCrossRefV4(CrossRefList[i], XRefStreamList[i], FALSE, i == 0)) { - return FALSE; + if (!LoadCrossRefV4(CrossRefList[i], XRefStreamList[i], false, i == 0)) { + return false; } - return TRUE; + return true; } -FX_BOOL CPDF_Parser::LoadLinearizedAllCrossRefV4(FX_FILESIZE xrefpos, FX_DWORD dwObjCount) +bool CPDF_Parser::LoadLinearizedAllCrossRefV4(FX_FILESIZE xrefpos, FX_DWORD dwObjCount) { if (!LoadLinearizedCrossRefV4(xrefpos, dwObjCount)) { - return FALSE; + return false; } m_pTrailer = LoadTrailerV4(); if (m_pTrailer == NULL) { - return FALSE; + return false; } int32_t xrefsize = GetDirectInteger(m_pTrailer, FX_BSTRC("Size")); if (xrefsize == 0) { - return FALSE; + return false; } CFX_FileSizeArray CrossRefList, XRefStreamList; CrossRefList.Add(xrefpos); @@ -419,22 +419,22 @@ FX_BOOL CPDF_Parser::LoadLinearizedAllCrossRefV4(FX_FILESIZE xrefpos, FX_DWORD d xrefpos = GetDirectInteger(m_pTrailer, FX_BSTRC("Prev")); while (xrefpos) { CrossRefList.InsertAt(0, xrefpos); - LoadCrossRefV4(xrefpos, 0, TRUE, FALSE); + LoadCrossRefV4(xrefpos, 0, true, false); CPDF_Dictionary* pDict = LoadTrailerV4(); if (pDict == NULL) { - return FALSE; + return false; } xrefpos = GetDirectInteger(pDict, FX_BSTRC("Prev")); XRefStreamList.InsertAt(0, pDict->GetInteger(FX_BSTRC("XRefStm"))); m_Trailers.Add(pDict); } for (int32_t i = 1; i < CrossRefList.GetSize(); i ++) - if (!LoadCrossRefV4(CrossRefList[i], XRefStreamList[i], FALSE, i == 0)) { - return FALSE; + if (!LoadCrossRefV4(CrossRefList[i], XRefStreamList[i], false, i == 0)) { + return false; } - return TRUE; + return true; } -FX_BOOL CPDF_Parser::LoadLinearizedCrossRefV4(FX_FILESIZE pos, FX_DWORD dwObjCount) +bool CPDF_Parser::LoadLinearizedCrossRefV4(FX_FILESIZE pos, FX_DWORD dwObjCount) { FX_FILESIZE dwStartPos = pos - m_Syntax.m_HeaderOffset; m_Syntax.RestorePos(dwStartPos); @@ -454,11 +454,11 @@ FX_BOOL CPDF_Parser::LoadLinearizedCrossRefV4(FX_FILESIZE pos, FX_DWORD dwObjCou FX_DWORD dwReadSize = block_size * recordsize; if ((FX_FILESIZE)(dwStartPos + dwReadSize) > m_Syntax.m_FileLen) { FX_Free(pBuf); - return FALSE; + return false; } if (!m_Syntax.ReadBlock((uint8_t*)pBuf, dwReadSize)) { FX_Free(pBuf); - return FALSE; + return false; } for (int32_t i = 0; i < block_size; i ++) { FX_DWORD objnum = start_objnum + block * 1024 + i; @@ -472,14 +472,14 @@ FX_BOOL CPDF_Parser::LoadLinearizedCrossRefV4(FX_FILESIZE pos, FX_DWORD dwObjCou for (int32_t c = 0; c < 10; c ++) { if (pEntry[c] < '0' || pEntry[c] > '9') { FX_Free(pBuf); - return FALSE; + return false; } } } m_CrossRef.SetAtGrow(objnum, offset); int32_t version = FXSYS_atoi(pEntry + 11); if (version >= 1) { - m_bVersionUpdated = TRUE; + m_bVersionUpdated = true; } m_ObjVersion.SetAtGrow(objnum, version); if (m_CrossRef[objnum] < m_Syntax.m_FileLen) { @@ -494,13 +494,13 @@ FX_BOOL CPDF_Parser::LoadLinearizedCrossRefV4(FX_FILESIZE pos, FX_DWORD dwObjCou } FX_Free(pBuf); m_Syntax.RestorePos(SavedPos + count * recordsize); - return TRUE; + return true; } -FX_BOOL CPDF_Parser::LoadCrossRefV4(FX_FILESIZE pos, FX_FILESIZE streampos, FX_BOOL bSkip, FX_BOOL bFirst) +bool CPDF_Parser::LoadCrossRefV4(FX_FILESIZE pos, FX_FILESIZE streampos, bool bSkip, bool bFirst) { m_Syntax.RestorePos(pos); if (m_Syntax.GetKeyword() != FX_BSTRC("xref")) { - return FALSE; + return false; } void* pResult = FXSYS_bsearch(&pos, m_SortedOffset.GetData(), m_SortedOffset.GetSize(), sizeof(FX_FILESIZE), _CompareFileSize); if (pResult == NULL) { @@ -514,10 +514,10 @@ FX_BOOL CPDF_Parser::LoadCrossRefV4(FX_FILESIZE pos, FX_FILESIZE streampos, FX_B } while (1) { FX_FILESIZE SavedPos = m_Syntax.SavePos(); - FX_BOOL bIsNumber; + bool bIsNumber; CFX_ByteString word = m_Syntax.GetNextWord(bIsNumber); if (word.IsEmpty()) { - return FALSE; + return false; } if (!bIsNumber) { m_Syntax.RestorePos(SavedPos); @@ -525,22 +525,22 @@ FX_BOOL CPDF_Parser::LoadCrossRefV4(FX_FILESIZE pos, FX_FILESIZE streampos, FX_B } FX_DWORD start_objnum = FXSYS_atoi(word); if (start_objnum >= (1 << 20)) { - return FALSE; + return false; } FX_DWORD count = m_Syntax.GetDirectNum(); m_Syntax.ToNextWord(); SavedPos = m_Syntax.SavePos(); - FX_BOOL bFirstItem = FALSE; + bool bFirstItem = false; int32_t recordsize = 20; if (bFirst) { - bFirstItem = TRUE; + bFirstItem = true; } m_dwXrefStartObjNum = start_objnum; if (!bSkip) { char* pBuf = FX_Alloc(char, 1024 * recordsize + 1); pBuf[1024 * recordsize] = '\0'; int32_t nBlocks = count / 1024 + 1; - FX_BOOL bFirstBlock = TRUE; + bool bFirstBlock = true; for (int32_t block = 0; block < nBlocks; block ++) { int32_t block_size = block == nBlocks - 1 ? count % 1024 : 1024; m_Syntax.ReadBlock((uint8_t*)pBuf, block_size * recordsize); @@ -550,7 +550,7 @@ FX_BOOL CPDF_Parser::LoadCrossRefV4(FX_FILESIZE pos, FX_FILESIZE streampos, FX_B if (pEntry[17] == 'f') { if (bFirstItem) { objnum = 0; - bFirstItem = FALSE; + bFirstItem = false; } if (bFirstBlock) { FX_FILESIZE offset = (FX_FILESIZE)FXSYS_atoi64(pEntry); @@ -568,14 +568,14 @@ FX_BOOL CPDF_Parser::LoadCrossRefV4(FX_FILESIZE pos, FX_FILESIZE streampos, FX_B for (int32_t c = 0; c < 10; c ++) { if (pEntry[c] < '0' || pEntry[c] > '9') { FX_Free(pBuf); - return FALSE; + return false; } } } m_CrossRef.SetAtGrow(objnum, offset); int32_t version = FXSYS_atoi(pEntry + 11); if (version >= 1) { - m_bVersionUpdated = TRUE; + m_bVersionUpdated = true; } m_ObjVersion.SetAtGrow(objnum, version); if (m_CrossRef[objnum] < m_Syntax.m_FileLen) { @@ -587,7 +587,7 @@ FX_BOOL CPDF_Parser::LoadCrossRefV4(FX_FILESIZE pos, FX_FILESIZE streampos, FX_B m_V5Type.SetAtGrow(objnum, 1); } if (bFirstBlock) { - bFirstBlock = FALSE; + bFirstBlock = false; } } } @@ -596,25 +596,25 @@ FX_BOOL CPDF_Parser::LoadCrossRefV4(FX_FILESIZE pos, FX_FILESIZE streampos, FX_B m_Syntax.RestorePos(SavedPos + count * recordsize); } if (streampos) - if (!LoadCrossRefV5(streampos, streampos, FALSE)) { - return FALSE; + if (!LoadCrossRefV5(streampos, streampos, false)) { + return false; } - return TRUE; + return true; } -FX_BOOL CPDF_Parser::LoadAllCrossRefV5(FX_FILESIZE xrefpos) +bool CPDF_Parser::LoadAllCrossRefV5(FX_FILESIZE xrefpos) { - if (!LoadCrossRefV5(xrefpos, xrefpos, TRUE)) { - return FALSE; + if (!LoadCrossRefV5(xrefpos, xrefpos, true)) { + return false; } while (xrefpos) - if (!LoadCrossRefV5(xrefpos, xrefpos, FALSE)) { - return FALSE; + if (!LoadCrossRefV5(xrefpos, xrefpos, false)) { + return false; } - m_ObjectStreamMap.InitHashTable(101, FALSE); - m_bXRefStream = TRUE; - return TRUE; + m_ObjectStreamMap.InitHashTable(101, false); + m_bXRefStream = true; + return true; } -FX_BOOL CPDF_Parser::RebuildCrossRef() +bool CPDF_Parser::RebuildCrossRef() { m_CrossRef.RemoveAll(); m_V5Type.RemoveAll(); @@ -633,7 +633,7 @@ FX_BOOL CPDF_Parser::RebuildCrossRef() FX_FILESIZE start_pos = 0, start_pos1 = 0; FX_FILESIZE last_obj = -1, last_xref = -1, last_trailer = -1; while (pos < m_Syntax.m_FileLen) { - FX_BOOL bOverFlow = FALSE; + bool bOverFlow = false; FX_DWORD size = (FX_DWORD)(m_Syntax.m_FileLen - pos); if (size > 4096) { size = 4096; @@ -812,7 +812,7 @@ FX_BOOL CPDF_Parser::RebuildCrossRef() FX_FILESIZE nLen = obj_end - obj_pos - offset; if ((FX_DWORD)nLen > size - i) { pos = obj_end + m_Syntax.m_HeaderOffset; - bOverFlow = TRUE; + bOverFlow = true; } else { i += (FX_DWORD)nLen; } @@ -822,7 +822,7 @@ FX_BOOL CPDF_Parser::RebuildCrossRef() m_CrossRef[objnum] = obj_pos; m_ObjVersion.SetAt(objnum, (int16_t)gennum); if (oldgen != gennum) { - m_bVersionUpdated = TRUE; + m_bVersionUpdated = true; } } } else { @@ -881,7 +881,7 @@ FX_BOOL CPDF_Parser::RebuildCrossRef() FX_FILESIZE dwSavePos = m_Syntax.SavePos(); CFX_ByteString strWord = m_Syntax.GetKeyword(); if (!strWord.Compare(FX_BSTRC("startxref"))) { - FX_BOOL bNumber = FALSE; + bool bNumber = false; CFX_ByteString bsOffset = m_Syntax.GetNextWord(bNumber); if (bNumber) { m_LastXRefOffset = FXSYS_atoi(bsOffset); @@ -982,7 +982,7 @@ FX_BOOL CPDF_Parser::RebuildCrossRef() m_SortedOffset.Add(offset); } FX_Free(buffer); - return TRUE; + return true; } static FX_DWORD _GetVarInt(const uint8_t* p, int32_t n) { @@ -992,11 +992,11 @@ static FX_DWORD _GetVarInt(const uint8_t* p, int32_t n) } return result; } -FX_BOOL CPDF_Parser::LoadCrossRefV5(FX_FILESIZE pos, FX_FILESIZE& prev, FX_BOOL bMainXRef) +bool CPDF_Parser::LoadCrossRefV5(FX_FILESIZE pos, FX_FILESIZE& prev, bool bMainXRef) { CPDF_Stream* pStream = (CPDF_Stream*)ParseIndirectObjectAt(m_pDocument, pos, 0, NULL); if (!pStream) { - return FALSE; + return false; } if (m_pDocument) { CPDF_Dictionary * pDict = m_pDocument->GetRoot(); @@ -1006,17 +1006,17 @@ FX_BOOL CPDF_Parser::LoadCrossRefV5(FX_FILESIZE pos, FX_FILESIZE& prev, FX_BOOL if (pStream->GetType() == PDFOBJ_STREAM) { pStream->Release(); } - return FALSE; + return false; } } if (pStream->GetType() != PDFOBJ_STREAM) { - return FALSE; + return false; } prev = pStream->GetDict()->GetInteger(FX_BSTRC("Prev")); int32_t size = pStream->GetDict()->GetInteger(FX_BSTRC("Size")); if (size < 0) { pStream->Release(); - return FALSE; + return false; } if (bMainXRef) { m_pTrailer = (CPDF_Dictionary*)pStream->GetDict()->Clone(); @@ -1050,7 +1050,7 @@ FX_BOOL CPDF_Parser::LoadCrossRefV5(FX_FILESIZE pos, FX_FILESIZE& prev, FX_BOOL pArray = pStream->GetDict()->GetArray(FX_BSTRC("W")); if (pArray == NULL) { pStream->Release(); - return FALSE; + return false; } CFX_DWordArray WidthArray; FX_SAFE_DWORD dwAccWidth = 0; @@ -1060,7 +1060,7 @@ FX_BOOL CPDF_Parser::LoadCrossRefV5(FX_FILESIZE pos, FX_FILESIZE& prev, FX_BOOL } if (!dwAccWidth.IsValid() || WidthArray.GetSize() < 3) { pStream->Release(); - return FALSE; + return false; } FX_DWORD totalWidth = dwAccWidth.ValueOrDie(); CPDF_StreamAcc acc; @@ -1120,7 +1120,7 @@ FX_BOOL CPDF_Parser::LoadCrossRefV5(FX_FILESIZE pos, FX_FILESIZE& prev, FX_BOOL } else { if (offset < 0 || offset >= m_V5Type.GetSize()) { pStream->Release(); - return FALSE; + return false; } m_V5Type[offset] = 255; } @@ -1129,7 +1129,7 @@ FX_BOOL CPDF_Parser::LoadCrossRefV5(FX_FILESIZE pos, FX_FILESIZE& prev, FX_BOOL segindex += count; } pStream->Release(); - return TRUE; + return true; } CPDF_Array* CPDF_Parser::GetIDArray() { @@ -1162,32 +1162,32 @@ FX_DWORD CPDF_Parser::GetInfoObjNum() } return ((CPDF_Reference*) pRef)->GetRefObjNum(); } -FX_BOOL CPDF_Parser::IsFormStream(FX_DWORD objnum, FX_BOOL& bForm) +bool CPDF_Parser::IsFormStream(FX_DWORD objnum, bool& bForm) { - bForm = FALSE; + bForm = false; if (objnum >= (FX_DWORD)m_CrossRef.GetSize()) { - return TRUE; + return true; } if (m_V5Type[objnum] == 0) { - return TRUE; + return true; } if (m_V5Type[objnum] == 2) { - return TRUE; + return true; } FX_FILESIZE pos = m_CrossRef[objnum]; void* pResult = FXSYS_bsearch(&pos, m_SortedOffset.GetData(), m_SortedOffset.GetSize(), sizeof(FX_FILESIZE), _CompareFileSize); if (pResult == NULL) { - return TRUE; + return true; } if ((FX_FILESIZE*)pResult - (FX_FILESIZE*)m_SortedOffset.GetData() == m_SortedOffset.GetSize() - 1) { - return FALSE; + return false; } FX_FILESIZE size = ((FX_FILESIZE*)pResult)[1] - pos; FX_FILESIZE SavedPos = m_Syntax.SavePos(); m_Syntax.RestorePos(pos); - bForm = m_Syntax.SearchMultiWord(FX_BSTRC("/Form\0stream"), TRUE, size) == 0; + bForm = m_Syntax.SearchMultiWord(FX_BSTRC("/Form\0stream"), true, size) == 0; m_Syntax.RestorePos(SavedPos); - return TRUE; + return true; } CPDF_Object* CPDF_Parser::ParseIndirectObject(CPDF_IndirectObjects* pObjList, FX_DWORD objnum, PARSE_CONTEXT* pContext) { @@ -1209,7 +1209,7 @@ CPDF_Object* CPDF_Parser::ParseIndirectObject(CPDF_IndirectObjects* pObjList, FX int32_t n = pObjStream->GetDict()->GetInteger(FX_BSTRC("N")); int32_t offset = pObjStream->GetDict()->GetInteger(FX_BSTRC("First")); CPDF_SyntaxParser syntax; - CFX_SmartPointer<IFX_FileStream> file(FX_CreateMemoryStream((uint8_t*)pObjStream->GetData(), (size_t)pObjStream->GetSize(), FALSE)); + CFX_SmartPointer<IFX_FileStream> file(FX_CreateMemoryStream((uint8_t*)pObjStream->GetData(), (size_t)pObjStream->GetSize(), false)); syntax.InitParser(file.Get(), 0); CPDF_Object* pRet = NULL; while (n) { @@ -1282,7 +1282,7 @@ void CPDF_Parser::GetIndirectBinary(FX_DWORD objnum, uint8_t*& pBuffer, FX_DWORD CPDF_SyntaxParser syntax; const uint8_t* pData = pObjStream->GetData(); FX_DWORD totalsize = pObjStream->GetSize(); - CFX_SmartPointer<IFX_FileStream> file(FX_CreateMemoryStream((uint8_t*)pData, (size_t)totalsize, FALSE)); + CFX_SmartPointer<IFX_FileStream> file(FX_CreateMemoryStream((uint8_t*)pData, (size_t)totalsize, false)); syntax.InitParser(file.Get(), 0); while (n) { FX_DWORD thisnum = syntax.GetDirectNum(); @@ -1310,7 +1310,7 @@ void CPDF_Parser::GetIndirectBinary(FX_DWORD objnum, uint8_t*& pBuffer, FX_DWORD } FX_FILESIZE SavedPos = m_Syntax.SavePos(); m_Syntax.RestorePos(pos); - FX_BOOL bIsNumber; + bool bIsNumber; CFX_ByteString word = m_Syntax.GetNextWord(bIsNumber); if (!bIsNumber) { m_Syntax.RestorePos(SavedPos); @@ -1336,16 +1336,16 @@ void CPDF_Parser::GetIndirectBinary(FX_DWORD objnum, uint8_t*& pBuffer, FX_DWORD return; } FX_FILESIZE nextoff = ((FX_FILESIZE*)pResult)[1]; - FX_BOOL bNextOffValid = FALSE; + bool bNextOffValid = false; if (nextoff != pos) { m_Syntax.RestorePos(nextoff); word = m_Syntax.GetNextWord(bIsNumber); if (word == FX_BSTRC("xref")) { - bNextOffValid = TRUE; + bNextOffValid = true; } else if (bIsNumber) { word = m_Syntax.GetNextWord(bIsNumber); if (bIsNumber && m_Syntax.GetKeyword() == FX_BSTRC("obj")) { - bNextOffValid = TRUE; + bNextOffValid = true; } } } @@ -1373,7 +1373,7 @@ CPDF_Object* CPDF_Parser::ParseIndirectObjectAt(CPDF_IndirectObjects* pObjList, { FX_FILESIZE SavedPos = m_Syntax.SavePos(); m_Syntax.RestorePos(pos); - FX_BOOL bIsNumber; + bool bIsNumber; CFX_ByteString word = m_Syntax.GetNextWord(bIsNumber); if (!bIsNumber) { m_Syntax.RestorePos(SavedPos); @@ -1416,7 +1416,7 @@ CPDF_Object* CPDF_Parser::ParseIndirectObjectAtByStrict(CPDF_IndirectObjects* pO { FX_FILESIZE SavedPos = m_Syntax.SavePos(); m_Syntax.RestorePos(pos); - FX_BOOL bIsNumber; + bool bIsNumber; CFX_ByteString word = m_Syntax.GetNextWord(bIsNumber); if (!bIsNumber) { m_Syntax.RestorePos(SavedPos); @@ -1458,7 +1458,7 @@ CPDF_Dictionary* CPDF_Parser::LoadTrailerV4() } return (CPDF_Dictionary*)pObj; } -FX_DWORD CPDF_Parser::GetPermissions(FX_BOOL bCheckRevision) +FX_DWORD CPDF_Parser::GetPermissions(bool bCheckRevision) { if (m_pSecurityHandler == NULL) { return (FX_DWORD) - 1; @@ -1473,11 +1473,11 @@ FX_DWORD CPDF_Parser::GetPermissions(FX_BOOL bCheckRevision) } return dwPermission; } -FX_BOOL CPDF_Parser::IsOwner() +bool CPDF_Parser::IsOwner() { - return m_pSecurityHandler == NULL ? TRUE : m_pSecurityHandler->IsOwner(); + return m_pSecurityHandler == NULL ? true : m_pSecurityHandler->IsOwner(); } -void CPDF_Parser::SetSecurityHandler(CPDF_SecurityHandler* pSecurityHandler, FX_BOOL bForced) +void CPDF_Parser::SetSecurityHandler(CPDF_SecurityHandler* pSecurityHandler, bool bForced) { ASSERT(m_pSecurityHandler == NULL); if (!m_bForceUseSecurityHandler) { @@ -1492,29 +1492,29 @@ void CPDF_Parser::SetSecurityHandler(CPDF_SecurityHandler* pSecurityHandler, FX_ m_Syntax.m_pCryptoHandler = pSecurityHandler->CreateCryptoHandler(); m_Syntax.m_pCryptoHandler->Init(NULL, pSecurityHandler); } -FX_BOOL CPDF_Parser::IsLinearizedFile(IFX_FileRead* pFileAccess, FX_DWORD offset) +bool CPDF_Parser::IsLinearizedFile(IFX_FileRead* pFileAccess, FX_DWORD offset) { m_Syntax.InitParser(pFileAccess, offset); m_Syntax.RestorePos(m_Syntax.m_HeaderOffset + 9); FX_FILESIZE SavedPos = m_Syntax.SavePos(); - FX_BOOL bIsNumber; + bool bIsNumber; CFX_ByteString word = m_Syntax.GetNextWord(bIsNumber); if (!bIsNumber) { - return FALSE; + return false; } FX_DWORD objnum = FXSYS_atoi(word); word = m_Syntax.GetNextWord(bIsNumber); if (!bIsNumber) { - return FALSE; + return false; } FX_DWORD gennum = FXSYS_atoi(word); if (m_Syntax.GetKeyword() != FX_BSTRC("obj")) { m_Syntax.RestorePos(SavedPos); - return FALSE; + return false; } m_pLinearized = m_Syntax.GetObject(NULL, objnum, gennum, 0); if (!m_pLinearized) { - return FALSE; + return false; } if (m_pLinearized->GetDict() && m_pLinearized->GetDict()->GetElement(FX_BSTRC("Linearized"))) { m_Syntax.GetNextWord(bIsNumber); @@ -1522,10 +1522,10 @@ FX_BOOL CPDF_Parser::IsLinearizedFile(IFX_FileRead* pFileAccess, FX_DWORD offset if (!pLen) { m_pLinearized->Release(); m_pLinearized = NULL; - return FALSE; + return false; } if (pLen->GetInteger() != (int)pFileAccess->GetSize()) { - return FALSE; + return false; } CPDF_Object *pNo = m_pLinearized->GetDict()->GetElement(FX_BSTRC("P")); if (pNo && pNo->GetType() == PDFOBJ_NUMBER) { @@ -1535,16 +1535,16 @@ FX_BOOL CPDF_Parser::IsLinearizedFile(IFX_FileRead* pFileAccess, FX_DWORD offset if (pTable && pTable->GetType() == PDFOBJ_NUMBER) { m_LastXRefOffset = pTable->GetInteger(); } - return TRUE; + return true; } m_pLinearized->Release(); m_pLinearized = NULL; - return FALSE; + return false; } -FX_DWORD CPDF_Parser::StartAsynParse(IFX_FileRead* pFileAccess, FX_BOOL bReParse, FX_BOOL bOwnFileRead) +FX_DWORD CPDF_Parser::StartAsynParse(IFX_FileRead* pFileAccess, bool bReParse, bool bOwnFileRead) { CloseParser(bReParse); - m_bXRefStream = FALSE; + m_bXRefStream = false; m_LastXRefOffset = 0; m_bOwnFileRead = bOwnFileRead; int32_t offset = GetHeaderOffset(pFileAccess); @@ -1559,19 +1559,19 @@ FX_DWORD CPDF_Parser::StartAsynParse(IFX_FileRead* pFileAccess, FX_BOOL bReParse m_pDocument = new CPDF_Document(this); } FX_FILESIZE dwFirstXRefOffset = m_Syntax.SavePos(); - FX_BOOL bXRefRebuilt = FALSE; - FX_BOOL bLoadV4 = FALSE; - if (!(bLoadV4 = LoadCrossRefV4(dwFirstXRefOffset, 0, FALSE, FALSE)) && !LoadCrossRefV5(dwFirstXRefOffset, dwFirstXRefOffset, TRUE)) { + bool bXRefRebuilt = false; + bool bLoadV4 = false; + if (!(bLoadV4 = LoadCrossRefV4(dwFirstXRefOffset, 0, false, false)) && !LoadCrossRefV5(dwFirstXRefOffset, dwFirstXRefOffset, true)) { if (!RebuildCrossRef()) { return PDFPARSE_ERROR_FORMAT; } - bXRefRebuilt = TRUE; + bXRefRebuilt = true; m_LastXRefOffset = 0; } if (bLoadV4) { m_pTrailer = LoadTrailerV4(); if (m_pTrailer == NULL) { - return FALSE; + return false; } int32_t xrefsize = GetDirectInteger(m_pTrailer, FX_BSTRC("Size")); if (xrefsize > 0) { @@ -1623,18 +1623,18 @@ FX_DWORD CPDF_Parser::StartAsynParse(IFX_FileRead* pFileAccess, FX_BOOL bReParse } return PDFPARSE_ERROR_SUCCESS; } -FX_BOOL CPDF_Parser::LoadLinearizedAllCrossRefV5(FX_FILESIZE xrefpos) +bool CPDF_Parser::LoadLinearizedAllCrossRefV5(FX_FILESIZE xrefpos) { - if (!LoadCrossRefV5(xrefpos, xrefpos, FALSE)) { - return FALSE; + if (!LoadCrossRefV5(xrefpos, xrefpos, false)) { + return false; } while (xrefpos) - if (!LoadCrossRefV5(xrefpos, xrefpos, FALSE)) { - return FALSE; + if (!LoadCrossRefV5(xrefpos, xrefpos, false)) { + return false; } - m_ObjectStreamMap.InitHashTable(101, FALSE); - m_bXRefStream = TRUE; - return TRUE; + m_ObjectStreamMap.InitHashTable(101, false); + m_bXRefStream = true; + return true; } FX_DWORD CPDF_Parser::LoadLinearizedMainXRefTable() { @@ -1688,7 +1688,7 @@ CPDF_SyntaxParser::CPDF_SyntaxParser() m_pFileBuf = NULL; m_MetadataObjnum = 0; m_dwWordPos = 0; - m_bFileStream = FALSE; + m_bFileStream = false; } CPDF_SyntaxParser::~CPDF_SyntaxParser() { @@ -1696,19 +1696,19 @@ CPDF_SyntaxParser::~CPDF_SyntaxParser() FX_Free(m_pFileBuf); } } -FX_BOOL CPDF_SyntaxParser::GetCharAt(FX_FILESIZE pos, uint8_t& ch) +bool CPDF_SyntaxParser::GetCharAt(FX_FILESIZE pos, uint8_t& ch) { FX_FILESIZE save_pos = m_Pos; m_Pos = pos; - FX_BOOL ret = GetNextChar(ch); + bool ret = GetNextChar(ch); m_Pos = save_pos; return ret; } -FX_BOOL CPDF_SyntaxParser::GetNextChar(uint8_t& ch) +bool CPDF_SyntaxParser::GetNextChar(uint8_t& ch) { FX_FILESIZE pos = m_Pos + m_HeaderOffset; if (pos >= m_FileLen) { - return FALSE; + return false; } if (m_BufOffset >= pos || (FX_FILESIZE)(m_BufOffset + m_BufSize) <= pos) { FX_FILESIZE read_pos = pos; @@ -1725,19 +1725,19 @@ FX_BOOL CPDF_SyntaxParser::GetNextChar(uint8_t& ch) } } if (!m_pFileAccess->ReadBlock(m_pFileBuf, read_pos, read_size)) { - return FALSE; + return false; } m_BufOffset = read_pos; } ch = m_pFileBuf[pos - m_BufOffset]; m_Pos ++; - return TRUE; + return true; } -FX_BOOL CPDF_SyntaxParser::GetCharAtBackward(FX_FILESIZE pos, uint8_t& ch) +bool CPDF_SyntaxParser::GetCharAtBackward(FX_FILESIZE pos, uint8_t& ch) { pos += m_HeaderOffset; if (pos >= m_FileLen) { - return FALSE; + return false; } if (m_BufOffset >= pos || (FX_FILESIZE)(m_BufOffset + m_BufSize) <= pos) { FX_FILESIZE read_pos; @@ -1756,26 +1756,26 @@ FX_BOOL CPDF_SyntaxParser::GetCharAtBackward(FX_FILESIZE pos, uint8_t& ch) } } if (!m_pFileAccess->ReadBlock(m_pFileBuf, read_pos, read_size)) { - return FALSE; + return false; } m_BufOffset = read_pos; } ch = m_pFileBuf[pos - m_BufOffset]; - return TRUE; + return true; } -FX_BOOL CPDF_SyntaxParser::ReadBlock(uint8_t* pBuf, FX_DWORD size) +bool CPDF_SyntaxParser::ReadBlock(uint8_t* pBuf, FX_DWORD size) { if (!m_pFileAccess->ReadBlock(pBuf, m_Pos + m_HeaderOffset, size)) { - return FALSE; + return false; } m_Pos += size; - return TRUE; + return true; } #define MAX_WORD_BUFFER 256 void CPDF_SyntaxParser::GetNextWord() { m_WordSize = 0; - m_bIsNumber = TRUE; + m_bIsNumber = true; uint8_t ch; if (!GetNextChar(ch)) { return; @@ -1802,7 +1802,7 @@ void CPDF_SyntaxParser::GetNextWord() type = PDF_CharType[ch]; } if (type == 'D') { - m_bIsNumber = FALSE; + m_bIsNumber = false; m_WordBuffer[m_WordSize++] = ch; if (ch == '/') { while (1) { @@ -1844,7 +1844,7 @@ void CPDF_SyntaxParser::GetNextWord() m_WordBuffer[m_WordSize++] = ch; } if (type != 'N') { - m_bIsNumber = FALSE; + m_bIsNumber = false; } if (!GetNextChar(ch)) { return; @@ -1950,7 +1950,7 @@ CFX_ByteString CPDF_SyntaxParser::ReadHexString() return CFX_ByteString(); } CFX_BinaryBuf buf; - FX_BOOL bFirst = TRUE; + bool bFirst = true; uint8_t code = 0; while (1) { if (ch == '>') { @@ -2036,7 +2036,7 @@ void CPDF_SyntaxParser::ToNextWord() } m_Pos --; } -CFX_ByteString CPDF_SyntaxParser::GetNextWord(FX_BOOL& bIsNumber) +CFX_ByteString CPDF_SyntaxParser::GetNextWord(bool& bIsNumber) { GetNextWord(); bIsNumber = m_bIsNumber; @@ -2047,15 +2047,15 @@ CFX_ByteString CPDF_SyntaxParser::GetKeyword() GetNextWord(); return CFX_ByteString((const FX_CHAR*)m_WordBuffer, m_WordSize); } -CPDF_Object* CPDF_SyntaxParser::GetObject(CPDF_IndirectObjects* pObjList, FX_DWORD objnum, FX_DWORD gennum, PARSE_CONTEXT* pContext, FX_BOOL bDecrypt) +CPDF_Object* CPDF_SyntaxParser::GetObject(CPDF_IndirectObjects* pObjList, FX_DWORD objnum, FX_DWORD gennum, PARSE_CONTEXT* pContext, bool bDecrypt) { CFX_AutoRestorer<int> restorer(&s_CurrentRecursionDepth); if (++s_CurrentRecursionDepth > kParserMaxRecursionDepth) { return NULL; } FX_FILESIZE SavedPos = m_Pos; - FX_BOOL bTypeOnly = pContext && (pContext->m_Flags & PDFPARSE_TYPEONLY); - FX_BOOL bIsNumber; + bool bTypeOnly = pContext && (pContext->m_Flags & PDFPARSE_TYPEONLY); + bool bIsNumber; CFX_ByteString word = GetNextWord(bIsNumber); if (word.GetLength() == 0) { if (bTypeOnly) { @@ -2102,7 +2102,7 @@ CPDF_Object* CPDF_SyntaxParser::GetObject(CPDF_IndirectObjects* pObjList, FX_DWO if (m_pCryptoHandler && bDecrypt) { m_pCryptoHandler->Decrypt(objnum, gennum, str); } - return CPDF_String::Create(str, FALSE); + return CPDF_String::Create(str, false); } if (word == FX_BSTRC("<")) { if (bTypeOnly) { @@ -2112,7 +2112,7 @@ CPDF_Object* CPDF_SyntaxParser::GetObject(CPDF_IndirectObjects* pObjList, FX_DWO if (m_pCryptoHandler && bDecrypt) { m_pCryptoHandler->Decrypt(objnum, gennum, str); } - return CPDF_String::Create(str, TRUE); + return CPDF_String::Create(str, true); } if (word == FX_BSTRC("[")) { if (bTypeOnly) { @@ -2145,7 +2145,7 @@ CPDF_Object* CPDF_SyntaxParser::GetObject(CPDF_IndirectObjects* pObjList, FX_DWO int32_t nKeys = 0; FX_FILESIZE dwSignValuePos = 0; while (1) { - FX_BOOL bIsNumber; + bool bIsNumber; CFX_ByteString key = GetNextWord(bIsNumber); if (key.IsEmpty()) { if (pDict) @@ -2183,7 +2183,7 @@ CPDF_Object* CPDF_SyntaxParser::GetObject(CPDF_IndirectObjects* pObjList, FX_DWO if (IsSignatureDict(pDict)) { FX_FILESIZE dwSavePos = m_Pos; m_Pos = dwSignValuePos; - CPDF_Object* pObj = GetObject(pObjList, objnum, gennum, NULL, FALSE); + CPDF_Object* pObj = GetObject(pObjList, objnum, gennum, NULL, false); pDict->SetAt(FX_BSTRC("Contents"), pObj); m_Pos = dwSavePos; } @@ -2194,7 +2194,7 @@ CPDF_Object* CPDF_SyntaxParser::GetObject(CPDF_IndirectObjects* pObjList, FX_DWO } } FX_FILESIZE SavedPos = m_Pos; - FX_BOOL bIsNumber; + bool bIsNumber; CFX_ByteString nextword = GetNextWord(bIsNumber); if (nextword == FX_BSTRC("stream")) { CPDF_Stream* pStream = ReadStream(pDict, pContext, objnum, gennum); @@ -2225,8 +2225,8 @@ CPDF_Object* CPDF_SyntaxParser::GetObjectByStrict(CPDF_IndirectObjects* pObjList return NULL; } FX_FILESIZE SavedPos = m_Pos; - FX_BOOL bTypeOnly = pContext && (pContext->m_Flags & PDFPARSE_TYPEONLY); - FX_BOOL bIsNumber; + bool bTypeOnly = pContext && (pContext->m_Flags & PDFPARSE_TYPEONLY); + bool bIsNumber; CFX_ByteString word = GetNextWord(bIsNumber); if (word.GetLength() == 0) { if (bTypeOnly) { @@ -2273,7 +2273,7 @@ CPDF_Object* CPDF_SyntaxParser::GetObjectByStrict(CPDF_IndirectObjects* pObjList if (m_pCryptoHandler) { m_pCryptoHandler->Decrypt(objnum, gennum, str); } - return CPDF_String::Create(str, FALSE); + return CPDF_String::Create(str, false); } if (word == FX_BSTRC("<")) { if (bTypeOnly) { @@ -2283,7 +2283,7 @@ CPDF_Object* CPDF_SyntaxParser::GetObjectByStrict(CPDF_IndirectObjects* pObjList if (m_pCryptoHandler) { m_pCryptoHandler->Decrypt(objnum, gennum, str); } - return CPDF_String::Create(str, TRUE); + return CPDF_String::Create(str, true); } if (word == FX_BSTRC("[")) { if (bTypeOnly) { @@ -2319,7 +2319,7 @@ CPDF_Object* CPDF_SyntaxParser::GetObjectByStrict(CPDF_IndirectObjects* pObjList } CPDF_Dictionary* pDict = CPDF_Dictionary::Create(); while (1) { - FX_BOOL bIsNumber; + bool bIsNumber; FX_FILESIZE SavedPos = m_Pos; CFX_ByteString key = GetNextWord(bIsNumber); if (key.IsEmpty()) { @@ -2366,7 +2366,7 @@ CPDF_Object* CPDF_SyntaxParser::GetObjectByStrict(CPDF_IndirectObjects* pObjList } } FX_FILESIZE SavedPos = m_Pos; - FX_BOOL bIsNumber; + bool bIsNumber; CFX_ByteString nextword = GetNextWord(bIsNumber); if (nextword == FX_BSTRC("stream")) { CPDF_Stream* pStream = ReadStream(pDict, pContext, objnum, gennum); @@ -2495,32 +2495,32 @@ int32_t CPDF_SyntaxParser::GetDirectNum() m_WordBuffer[m_WordSize] = 0; return FXSYS_atoi((const FX_CHAR*)m_WordBuffer); } -FX_BOOL CPDF_SyntaxParser::IsWholeWord(FX_FILESIZE startpos, FX_FILESIZE limit, const uint8_t* tag, FX_DWORD taglen) +bool CPDF_SyntaxParser::IsWholeWord(FX_FILESIZE startpos, FX_FILESIZE limit, const uint8_t* tag, FX_DWORD taglen) { uint8_t type = PDF_CharType[tag[0]]; - FX_BOOL bCheckLeft = type != 'D' && type != 'W'; + bool bCheckLeft = type != 'D' && type != 'W'; type = PDF_CharType[tag[taglen - 1]]; - FX_BOOL bCheckRight = type != 'D' && type != 'W'; + bool bCheckRight = type != 'D' && type != 'W'; uint8_t ch; if (bCheckRight && startpos + (int32_t)taglen <= limit && GetCharAt(startpos + (int32_t)taglen, ch)) { uint8_t type = PDF_CharType[ch]; if (type == 'N' || type == 'R') { - return FALSE; + return false; } } if (bCheckLeft && startpos > 0 && GetCharAt(startpos - 1, ch)) { uint8_t type = PDF_CharType[ch]; if (type == 'N' || type == 'R') { - return FALSE; + return false; } } - return TRUE; + return true; } -FX_BOOL CPDF_SyntaxParser::SearchWord(const CFX_ByteStringC& tag, FX_BOOL bWholeWord, FX_BOOL bForward, FX_FILESIZE limit) +bool CPDF_SyntaxParser::SearchWord(const CFX_ByteStringC& tag, bool bWholeWord, bool bForward, FX_FILESIZE limit) { int32_t taglen = tag.GetLength(); if (taglen == 0) { - return FALSE; + return false; } FX_FILESIZE pos = m_Pos; int32_t offset = 0; @@ -2533,20 +2533,20 @@ FX_BOOL CPDF_SyntaxParser::SearchWord(const CFX_ByteStringC& tag, FX_BOOL bWhole if (bForward) { if (limit) { if (pos >= m_Pos + limit) { - return FALSE; + return false; } } if (!GetCharAt(pos, byte)) { - return FALSE; + return false; } } else { if (limit) { if (pos <= m_Pos - limit) { - return FALSE; + return false; } } if (!GetCharAtBackward(pos, byte)) { - return FALSE; + return false; } } if (byte == tag_data[offset]) { @@ -2566,7 +2566,7 @@ FX_BOOL CPDF_SyntaxParser::SearchWord(const CFX_ByteStringC& tag, FX_BOOL bWhole FX_FILESIZE startpos = bForward ? pos - taglen + 1 : pos; if (!bWholeWord || IsWholeWord(startpos, limit, tag.GetPtr(), taglen)) { m_Pos = startpos; - return TRUE; + return true; } } if (bForward) { @@ -2577,17 +2577,17 @@ FX_BOOL CPDF_SyntaxParser::SearchWord(const CFX_ByteStringC& tag, FX_BOOL bWhole pos --; } if (pos < 0) { - return FALSE; + return false; } } - return FALSE; + return false; } struct _SearchTagRecord { const uint8_t* m_pTag; FX_DWORD m_Len; FX_DWORD m_Offset; }; -int32_t CPDF_SyntaxParser::SearchMultiWord(const CFX_ByteStringC& tags, FX_BOOL bWholeWord, FX_FILESIZE limit) +int32_t CPDF_SyntaxParser::SearchMultiWord(const CFX_ByteStringC& tags, bool bWholeWord, FX_FILESIZE limit) { int32_t ntags = 1, i; for (i = 0; i < tags.GetLength(); i ++) @@ -2695,17 +2695,17 @@ public: CPDF_DataAvail(IFX_FileAvail* pFileAvail, IFX_FileRead* pFileRead); ~CPDF_DataAvail(); - virtual FX_BOOL IsDocAvail(IFX_DownloadHints* pHints) override; + virtual bool IsDocAvail(IFX_DownloadHints* pHints) override; virtual void SetDocument(CPDF_Document* pDoc) override; - virtual FX_BOOL IsPageAvail(int iPage, IFX_DownloadHints* pHints) override; + virtual bool IsPageAvail(int iPage, IFX_DownloadHints* pHints) override; virtual int32_t IsFormAvail(IFX_DownloadHints *pHints) override; virtual int32_t IsLinearizedPDF() override; - virtual FX_BOOL IsLinearized() override + virtual bool IsLinearized() override { return m_bLinearized; } @@ -2717,52 +2717,52 @@ protected: static int s_CurrentDataAvailRecursionDepth; FX_DWORD GetObjectSize(FX_DWORD objnum, FX_FILESIZE& offset); - FX_BOOL IsObjectsAvail(CFX_PtrArray& obj_array, FX_BOOL bParsePage, IFX_DownloadHints* pHints, CFX_PtrArray &ret_array); - FX_BOOL CheckDocStatus(IFX_DownloadHints *pHints); - FX_BOOL CheckHeader(IFX_DownloadHints* pHints); - FX_BOOL CheckFirstPage(IFX_DownloadHints *pHints); - FX_BOOL CheckEnd(IFX_DownloadHints *pHints); - FX_BOOL CheckCrossRef(IFX_DownloadHints* pHints); - FX_BOOL CheckCrossRefItem(IFX_DownloadHints *pHints); - FX_BOOL CheckTrailer(IFX_DownloadHints* pHints); - FX_BOOL CheckRoot(IFX_DownloadHints* pHints); - FX_BOOL CheckInfo(IFX_DownloadHints* pHints); - FX_BOOL CheckPages(IFX_DownloadHints* pHints); - FX_BOOL CheckPage(IFX_DownloadHints* pHints); - FX_BOOL CheckResources(IFX_DownloadHints* pHints); - FX_BOOL CheckAnnots(IFX_DownloadHints* pHints); - FX_BOOL CheckAcroForm(IFX_DownloadHints* pHints); - FX_BOOL CheckAcroFormSubObject(IFX_DownloadHints* pHints); - FX_BOOL CheckTrailerAppend(IFX_DownloadHints* pHints); - FX_BOOL CheckPageStatus(IFX_DownloadHints* pHints); - FX_BOOL CheckAllCrossRefStream(IFX_DownloadHints *pHints); + bool IsObjectsAvail(CFX_PtrArray& obj_array, bool bParsePage, IFX_DownloadHints* pHints, CFX_PtrArray &ret_array); + bool CheckDocStatus(IFX_DownloadHints *pHints); + bool CheckHeader(IFX_DownloadHints* pHints); + bool CheckFirstPage(IFX_DownloadHints *pHints); + bool CheckEnd(IFX_DownloadHints *pHints); + bool CheckCrossRef(IFX_DownloadHints* pHints); + bool CheckCrossRefItem(IFX_DownloadHints *pHints); + bool CheckTrailer(IFX_DownloadHints* pHints); + bool CheckRoot(IFX_DownloadHints* pHints); + bool CheckInfo(IFX_DownloadHints* pHints); + bool CheckPages(IFX_DownloadHints* pHints); + bool CheckPage(IFX_DownloadHints* pHints); + bool CheckResources(IFX_DownloadHints* pHints); + bool CheckAnnots(IFX_DownloadHints* pHints); + bool CheckAcroForm(IFX_DownloadHints* pHints); + bool CheckAcroFormSubObject(IFX_DownloadHints* pHints); + bool CheckTrailerAppend(IFX_DownloadHints* pHints); + bool CheckPageStatus(IFX_DownloadHints* pHints); + bool CheckAllCrossRefStream(IFX_DownloadHints *pHints); int32_t CheckCrossRefStream(IFX_DownloadHints *pHints, FX_FILESIZE &xref_offset); - FX_BOOL IsLinearizedFile(uint8_t* pData, FX_DWORD dwLen); + bool IsLinearizedFile(uint8_t* pData, FX_DWORD dwLen); void SetStartOffset(FX_FILESIZE dwOffset); - FX_BOOL GetNextToken(CFX_ByteString &token); - FX_BOOL GetNextChar(uint8_t &ch); + bool GetNextToken(CFX_ByteString &token); + bool GetNextChar(uint8_t &ch); CPDF_Object * ParseIndirectObjectAt(FX_FILESIZE pos, FX_DWORD objnum); - CPDF_Object * GetObject(FX_DWORD objnum, IFX_DownloadHints* pHints, FX_BOOL *pExistInFile); - FX_BOOL GetPageKids(CPDF_Parser *pParser, CPDF_Object *pPages); - FX_BOOL PreparePageItem(); - FX_BOOL LoadPages(IFX_DownloadHints* pHints); - FX_BOOL LoadAllXref(IFX_DownloadHints* pHints); - FX_BOOL LoadAllFile(IFX_DownloadHints* pHints); - FX_BOOL CheckLinearizedData(IFX_DownloadHints* pHints); - FX_BOOL CheckFileResources(IFX_DownloadHints* pHints); - FX_BOOL CheckPageAnnots(int iPage, IFX_DownloadHints* pHints); + CPDF_Object * GetObject(FX_DWORD objnum, IFX_DownloadHints* pHints, bool *pExistInFile); + bool GetPageKids(CPDF_Parser *pParser, CPDF_Object *pPages); + bool PreparePageItem(); + bool LoadPages(IFX_DownloadHints* pHints); + bool LoadAllXref(IFX_DownloadHints* pHints); + bool LoadAllFile(IFX_DownloadHints* pHints); + bool CheckLinearizedData(IFX_DownloadHints* pHints); + bool CheckFileResources(IFX_DownloadHints* pHints); + bool CheckPageAnnots(int iPage, IFX_DownloadHints* pHints); - FX_BOOL CheckLinearizedFirstPage(int iPage, IFX_DownloadHints* pHints); - FX_BOOL HaveResourceAncestor(CPDF_Dictionary *pDict); - FX_BOOL CheckPage(int32_t iPage, IFX_DownloadHints* pHints); - FX_BOOL LoadDocPages(IFX_DownloadHints* pHints); - FX_BOOL LoadDocPage(int32_t iPage, IFX_DownloadHints* pHints); - FX_BOOL CheckPageNode(CPDF_PageNode &pageNodes, int32_t iPage, int32_t &iCount, IFX_DownloadHints* pHints); - FX_BOOL CheckUnkownPageNode(FX_DWORD dwPageNo, CPDF_PageNode *pPageNode, IFX_DownloadHints* pHints); - FX_BOOL CheckArrayPageNode(FX_DWORD dwPageNo, CPDF_PageNode *pPageNode, IFX_DownloadHints* pHints); - FX_BOOL CheckPageCount(IFX_DownloadHints* pHints); - FX_BOOL IsFirstCheck(int iPage); + bool CheckLinearizedFirstPage(int iPage, IFX_DownloadHints* pHints); + bool HaveResourceAncestor(CPDF_Dictionary *pDict); + bool CheckPage(int32_t iPage, IFX_DownloadHints* pHints); + bool LoadDocPages(IFX_DownloadHints* pHints); + bool LoadDocPage(int32_t iPage, IFX_DownloadHints* pHints); + bool CheckPageNode(CPDF_PageNode &pageNodes, int32_t iPage, int32_t &iCount, IFX_DownloadHints* pHints); + bool CheckUnkownPageNode(FX_DWORD dwPageNo, CPDF_PageNode *pPageNode, IFX_DownloadHints* pHints); + bool CheckArrayPageNode(FX_DWORD dwPageNo, CPDF_PageNode *pPageNode, IFX_DownloadHints* pHints); + bool CheckPageCount(IFX_DownloadHints* pHints); + bool IsFirstCheck(int iPage); void ResetFirstCheck(int iPage); CPDF_Parser m_parser; @@ -2779,7 +2779,7 @@ protected: CPDF_Object *m_pTrailer; - FX_BOOL m_bDocAvail; + bool m_bDocAvail; FX_FILESIZE m_dwHeaderOffset; @@ -2823,31 +2823,31 @@ protected: FX_DWORD m_PagesObjNum; - FX_BOOL m_bLinearized; + bool m_bLinearized; FX_DWORD m_dwFirstPageNo; - FX_BOOL m_bLinearedDataOK; + bool m_bLinearedDataOK; - FX_BOOL m_bMainXRefLoadTried; + bool m_bMainXRefLoadTried; - FX_BOOL m_bMainXRefLoadedOK; + bool m_bMainXRefLoadedOK; - FX_BOOL m_bPagesTreeLoad; + bool m_bPagesTreeLoad; - FX_BOOL m_bPagesLoad; + bool m_bPagesLoad; CPDF_Parser * m_pCurrentParser; FX_FILESIZE m_dwCurrentXRefSteam; - FX_BOOL m_bAnnotsLoad; + bool m_bAnnotsLoad; - FX_BOOL m_bHaveAcroForm; + bool m_bHaveAcroForm; FX_DWORD m_dwAcroFormObjNum; - FX_BOOL m_bAcroFormLoad; + bool m_bAcroFormLoad; CPDF_Object * m_pAcroForm; @@ -2857,11 +2857,11 @@ protected: CPDF_Object * m_pPageResource; - FX_BOOL m_bNeedDownLoadResource; + bool m_bNeedDownLoadResource; - FX_BOOL m_bPageLoadedOK; + bool m_bPageLoadedOK; - FX_BOOL m_bLinearizedFormParamLoad; + bool m_bLinearizedFormParamLoad; CFX_PtrArray m_PagesArray; @@ -2869,9 +2869,9 @@ protected: FX_FILESIZE m_dwPrevXRefOffset; - FX_BOOL m_bTotalLoadPageTree; + bool m_bTotalLoadPageTree; - FX_BOOL m_bCurPageDictLoadOK; + bool m_bCurPageDictLoadOK; CPDF_PageNode m_pageNodes; @@ -2916,19 +2916,19 @@ CPDF_DataAvail::CPDF_DataAvail(IFX_FileAvail* pFileAvail, IFX_FileRead* pFileRea m_dwEncryptObjNum = 0; m_dwPrevXRefOffset = 0; m_dwLastXRefOffset = 0; - m_bDocAvail = FALSE; - m_bMainXRefLoadTried = FALSE; - m_bDocAvail = FALSE; - m_bLinearized = FALSE; - m_bPagesLoad = FALSE; - m_bPagesTreeLoad = FALSE; - m_bMainXRefLoadedOK = FALSE; - m_bAnnotsLoad = FALSE; - m_bHaveAcroForm = FALSE; - m_bAcroFormLoad = FALSE; - m_bPageLoadedOK = FALSE; - m_bNeedDownLoadResource = FALSE; - m_bLinearizedFormParamLoad = FALSE; + m_bDocAvail = false; + m_bMainXRefLoadTried = false; + m_bDocAvail = false; + m_bLinearized = false; + m_bPagesLoad = false; + m_bPagesTreeLoad = false; + m_bMainXRefLoadedOK = false; + m_bAnnotsLoad = false; + m_bHaveAcroForm = false; + m_bAcroFormLoad = false; + m_bPageLoadedOK = false; + m_bNeedDownLoadResource = false; + m_bLinearizedFormParamLoad = false; m_pLinearized = NULL; m_pRoot = NULL; m_pTrailer = NULL; @@ -2938,10 +2938,10 @@ CPDF_DataAvail::CPDF_DataAvail(IFX_FileAvail* pFileAvail, IFX_FileRead* pFileRea m_pPageResource = NULL; m_pageMapCheckState = NULL; m_docStatus = PDF_DATAAVAIL_HEADER; - m_parser.m_bOwnFileRead = FALSE; - m_bTotalLoadPageTree = FALSE; - m_bCurPageDictLoadOK = FALSE; - m_bLinearedDataOK = FALSE; + m_parser.m_bOwnFileRead = false; + m_bTotalLoadPageTree = false; + m_bCurPageDictLoadOK = false; + m_bLinearedDataOK = false; m_pagesLoadState = NULL; } CPDF_DataAvail::~CPDF_DataAvail() @@ -2995,10 +2995,10 @@ FX_DWORD CPDF_DataAvail::GetObjectSize(FX_DWORD objnum, FX_FILESIZE& offset) } return 0; } -FX_BOOL CPDF_DataAvail::IsObjectsAvail(CFX_PtrArray& obj_array, FX_BOOL bParsePage, IFX_DownloadHints* pHints, CFX_PtrArray &ret_array) +bool CPDF_DataAvail::IsObjectsAvail(CFX_PtrArray& obj_array, bool bParsePage, IFX_DownloadHints* pHints, CFX_PtrArray &ret_array) { if (!obj_array.GetSize()) { - return TRUE; + return true; } FX_DWORD count = 0; CFX_PtrArray new_obj_array; @@ -3088,42 +3088,42 @@ FX_BOOL CPDF_DataAvail::IsObjectsAvail(CFX_PtrArray& obj_array, FX_BOOL bParsePa ret_array.Add(pObj); } } - return FALSE; + return false; } obj_array.RemoveAll(); obj_array.Append(new_obj_array); - return IsObjectsAvail(obj_array, FALSE, pHints, ret_array); + return IsObjectsAvail(obj_array, false, pHints, ret_array); } -FX_BOOL CPDF_DataAvail::IsDocAvail(IFX_DownloadHints* pHints) +bool CPDF_DataAvail::IsDocAvail(IFX_DownloadHints* pHints) { if (!m_dwFileLen && m_pFileRead) { m_dwFileLen = (FX_DWORD)m_pFileRead->GetSize(); if (!m_dwFileLen) { - return TRUE; + return true; } } while (!m_bDocAvail) { if (!CheckDocStatus(pHints)) { - return FALSE; + return false; } } - return TRUE; + return true; } -FX_BOOL CPDF_DataAvail::CheckAcroFormSubObject(IFX_DownloadHints* pHints) +bool CPDF_DataAvail::CheckAcroFormSubObject(IFX_DownloadHints* pHints) { if (!m_objs_array.GetSize()) { m_objs_array.RemoveAll(); m_objnum_array.RemoveAll(); CFX_PtrArray obj_array; obj_array.Append(m_arrayAcroforms); - FX_BOOL bRet = IsObjectsAvail(obj_array, FALSE, pHints, m_objs_array); + bool bRet = IsObjectsAvail(obj_array, false, pHints, m_objs_array); if (bRet) { m_objs_array.RemoveAll(); } return bRet; } CFX_PtrArray new_objs_array; - FX_BOOL bRet = IsObjectsAvail(m_objs_array, FALSE, pHints, new_objs_array); + bool bRet = IsObjectsAvail(m_objs_array, false, pHints, new_objs_array); if (bRet) { int32_t iSize = m_arrayAcroforms.GetSize(); for (int32_t i = 0; i < iSize; ++i) { @@ -3136,26 +3136,26 @@ FX_BOOL CPDF_DataAvail::CheckAcroFormSubObject(IFX_DownloadHints* pHints) } return bRet; } -FX_BOOL CPDF_DataAvail::CheckAcroForm(IFX_DownloadHints* pHints) +bool CPDF_DataAvail::CheckAcroForm(IFX_DownloadHints* pHints) { - FX_BOOL bExist = FALSE; + bool bExist = false; m_pAcroForm = GetObject(m_dwAcroFormObjNum, pHints, &bExist); if (!bExist) { m_docStatus = PDF_DATAAVAIL_PAGETREE; - return TRUE; + return true; } if (!m_pAcroForm) { if (m_docStatus == PDF_DATAAVAIL_ERROR) { m_docStatus = PDF_DATAAVAIL_LOADALLFILE; - return TRUE; + return true; } - return FALSE; + return false; } m_arrayAcroforms.Add(m_pAcroForm); m_docStatus = PDF_DATAAVAIL_PAGETREE; - return TRUE; + return true; } -FX_BOOL CPDF_DataAvail::CheckDocStatus(IFX_DownloadHints *pHints) +bool CPDF_DataAvail::CheckDocStatus(IFX_DownloadHints *pHints) { switch (m_docStatus) { case PDF_DATAAVAIL_HEADER: @@ -3195,17 +3195,17 @@ FX_BOOL CPDF_DataAvail::CheckDocStatus(IFX_DownloadHints *pHints) return CheckPage(pHints); } m_docStatus = PDF_DATAAVAIL_PAGE_LATERLOAD; - return TRUE; + return true; case PDF_DATAAVAIL_ERROR: return LoadAllFile(pHints); case PDF_DATAAVAIL_PAGE_LATERLOAD: m_docStatus = PDF_DATAAVAIL_PAGE; default: - m_bDocAvail = TRUE; - return TRUE; + m_bDocAvail = true; + return true; } } -FX_BOOL CPDF_DataAvail::CheckPageStatus(IFX_DownloadHints* pHints) +bool CPDF_DataAvail::CheckPageStatus(IFX_DownloadHints* pHints) { switch (m_docStatus) { case PDF_DATAAVAIL_PAGETREE: @@ -3215,36 +3215,36 @@ FX_BOOL CPDF_DataAvail::CheckPageStatus(IFX_DownloadHints* pHints) case PDF_DATAAVAIL_ERROR: return LoadAllFile(pHints); default: - m_bPagesTreeLoad = TRUE; - m_bPagesLoad = TRUE; - return TRUE; + m_bPagesTreeLoad = true; + m_bPagesLoad = true; + return true; } } -FX_BOOL CPDF_DataAvail::LoadAllFile(IFX_DownloadHints* pHints) +bool CPDF_DataAvail::LoadAllFile(IFX_DownloadHints* pHints) { if (m_pFileAvail->IsDataAvail(0, (FX_DWORD)m_dwFileLen)) { m_docStatus = PDF_DATAAVAIL_DONE; - return TRUE; + return true; } pHints->AddSegment(0, (FX_DWORD)m_dwFileLen); - return FALSE; + return false; } -FX_BOOL CPDF_DataAvail::LoadAllXref(IFX_DownloadHints* pHints) +bool CPDF_DataAvail::LoadAllXref(IFX_DownloadHints* pHints) { m_parser.m_Syntax.InitParser(m_pFileRead, (FX_DWORD)m_dwHeaderOffset); - m_parser.m_bOwnFileRead = FALSE; + m_parser.m_bOwnFileRead = false; if (!m_parser.LoadAllCrossRefV4(m_dwLastXRefOffset) && !m_parser.LoadAllCrossRefV5(m_dwLastXRefOffset)) { m_docStatus = PDF_DATAAVAIL_LOADALLFILE; - return FALSE; + return false; } FXSYS_qsort(m_parser.m_SortedOffset.GetData(), m_parser.m_SortedOffset.GetSize(), sizeof(FX_FILESIZE), _CompareFileSize); m_dwRootObjNum = m_parser.GetRootObjNum(); m_dwInfoObjNum = m_parser.GetInfoObjNum(); m_pCurrentParser = &m_parser; m_docStatus = PDF_DATAAVAIL_ROOT; - return TRUE; + return true; } -CPDF_Object* CPDF_DataAvail::GetObject(FX_DWORD objnum, IFX_DownloadHints* pHints, FX_BOOL *pExistInFile) +CPDF_Object* CPDF_DataAvail::GetObject(FX_DWORD objnum, IFX_DownloadHints* pHints, bool *pExistInFile) { CPDF_Object *pRet = NULL; FX_DWORD original_size = 0; @@ -3252,7 +3252,7 @@ CPDF_Object* CPDF_DataAvail::GetObject(FX_DWORD objnum, IFX_DownloadHints* pHint CPDF_Parser *pParser = NULL; if (pExistInFile) { - *pExistInFile = TRUE; + *pExistInFile = true; } if (m_pDocument == NULL) { @@ -3267,7 +3267,7 @@ CPDF_Object* CPDF_DataAvail::GetObject(FX_DWORD objnum, IFX_DownloadHints* pHint pdfium::base::CheckedNumeric<FX_DWORD> size = original_size; if (size.ValueOrDefault(0) == 0 || offset < 0 || offset >= m_dwFileLen) { if (pExistInFile) - *pExistInFile = FALSE; + *pExistInFile = false; return NULL; } @@ -3298,15 +3298,15 @@ CPDF_Object* CPDF_DataAvail::GetObject(FX_DWORD objnum, IFX_DownloadHints* pHint } if (!pRet && pExistInFile) { - *pExistInFile = FALSE; + *pExistInFile = false; } return pRet; } -FX_BOOL CPDF_DataAvail::CheckInfo(IFX_DownloadHints* pHints) +bool CPDF_DataAvail::CheckInfo(IFX_DownloadHints* pHints) { - FX_BOOL bExist = FALSE; + bool bExist = false; CPDF_Object *pInfo = GetObject(m_dwInfoObjNum, pHints, &bExist); if (!bExist) { if (m_bHaveAcroForm) { @@ -3314,17 +3314,17 @@ FX_BOOL CPDF_DataAvail::CheckInfo(IFX_DownloadHints* pHints) } else { m_docStatus = PDF_DATAAVAIL_PAGETREE; } - return TRUE; + return true; } if (!pInfo) { if (m_docStatus == PDF_DATAAVAIL_ERROR) { m_docStatus = PDF_DATAAVAIL_LOADALLFILE; - return TRUE; + return true; } if (m_Pos == m_dwFileLen) { m_docStatus = PDF_DATAAVAIL_ERROR; } - return FALSE; + return false; } if (pInfo) { pInfo->Release(); @@ -3334,37 +3334,37 @@ FX_BOOL CPDF_DataAvail::CheckInfo(IFX_DownloadHints* pHints) } else { m_docStatus = PDF_DATAAVAIL_PAGETREE; } - return TRUE; + return true; } -FX_BOOL CPDF_DataAvail::CheckRoot(IFX_DownloadHints* pHints) +bool CPDF_DataAvail::CheckRoot(IFX_DownloadHints* pHints) { - FX_BOOL bExist = FALSE; + bool bExist = false; m_pRoot = GetObject(m_dwRootObjNum, pHints, &bExist); if (!bExist) { m_docStatus = PDF_DATAAVAIL_LOADALLFILE; - return TRUE; + return true; } if (!m_pRoot) { if (m_docStatus == PDF_DATAAVAIL_ERROR) { m_docStatus = PDF_DATAAVAIL_LOADALLFILE; - return TRUE; + return true; } - return FALSE; + return false; } CPDF_Dictionary* pDict = m_pRoot->GetDict(); if (!pDict) { m_docStatus = PDF_DATAAVAIL_ERROR; - return FALSE; + return false; } CPDF_Reference* pRef = (CPDF_Reference*)pDict->GetElement(FX_BSTRC("Pages")); if (pRef == NULL || pRef->GetType() != PDFOBJ_REFERENCE) { m_docStatus = PDF_DATAAVAIL_ERROR; - return FALSE; + return false; } m_PagesObjNum = pRef->GetRefObjNum(); CPDF_Reference* pAcroFormRef = (CPDF_Reference*)m_pRoot->GetDict()->GetElement(FX_BSTRC("AcroForm")); if (pAcroFormRef && pAcroFormRef->GetType() == PDFOBJ_REFERENCE) { - m_bHaveAcroForm = TRUE; + m_bHaveAcroForm = true; m_dwAcroFormObjNum = pAcroFormRef->GetRefObjNum(); } if (m_dwInfoObjNum) { @@ -3376,22 +3376,22 @@ FX_BOOL CPDF_DataAvail::CheckRoot(IFX_DownloadHints* pHints) m_docStatus = PDF_DATAAVAIL_PAGETREE; } } - return TRUE; + return true; } -FX_BOOL CPDF_DataAvail::PreparePageItem() +bool CPDF_DataAvail::PreparePageItem() { CPDF_Dictionary *pRoot = m_pDocument->GetRoot(); CPDF_Reference* pRef = pRoot ? (CPDF_Reference*)pRoot->GetElement(FX_BSTRC("Pages")) : NULL; if (pRef == NULL || pRef->GetType() != PDFOBJ_REFERENCE) { m_docStatus = PDF_DATAAVAIL_ERROR; - return FALSE; + return false; } m_PagesObjNum = pRef->GetRefObjNum(); m_pCurrentParser = (CPDF_Parser *)m_pDocument->GetParser(); m_docStatus = PDF_DATAAVAIL_PAGETREE; - return TRUE; + return true; } -FX_BOOL CPDF_DataAvail::IsFirstCheck(int iPage) +bool CPDF_DataAvail::IsFirstCheck(int iPage) { if (NULL == m_pageMapCheckState) { m_pageMapCheckState = new CFX_CMapDWordToDWord(); @@ -3399,13 +3399,13 @@ FX_BOOL CPDF_DataAvail::IsFirstCheck(int iPage) FX_DWORD dwValue = 0; if (!m_pageMapCheckState->Lookup(iPage, dwValue)) { m_pageMapCheckState->SetAt(iPage, 1); - return TRUE; + return true; } if (dwValue != 0) { - return FALSE; + return false; } m_pageMapCheckState->SetAt(iPage, 1); - return TRUE; + return true; } void CPDF_DataAvail::ResetFirstCheck(int iPage) { @@ -3418,13 +3418,13 @@ void CPDF_DataAvail::ResetFirstCheck(int iPage) } m_pageMapCheckState->SetAt(iPage, 0); } -FX_BOOL CPDF_DataAvail::CheckPage(IFX_DownloadHints* pHints) +bool CPDF_DataAvail::CheckPage(IFX_DownloadHints* pHints) { FX_DWORD iPageObjs = m_PageObjList.GetSize(); CFX_DWordArray UnavailObjList; for (FX_DWORD i = 0; i < iPageObjs; ++i) { FX_DWORD dwPageObjNum = m_PageObjList.GetAt(i); - FX_BOOL bExist = FALSE; + bool bExist = false; CPDF_Object *pObj = GetObject(dwPageObjNum, pHints, &bExist); if (!pObj) { if (bExist) { @@ -3459,7 +3459,7 @@ FX_BOOL CPDF_DataAvail::CheckPage(IFX_DownloadHints* pHints) m_PageObjList.RemoveAll(); if (UnavailObjList.GetSize()) { m_PageObjList.Append(UnavailObjList); - return FALSE; + return false; } FX_DWORD iPages = m_PagesArray.GetSize(); for (FX_DWORD i = 0; i < iPages; i++) { @@ -3475,7 +3475,7 @@ FX_BOOL CPDF_DataAvail::CheckPage(IFX_DownloadHints* pHints) } m_PagesArray.RemoveAll(); m_docStatus = PDF_DATAAVAIL_ERROR; - return FALSE; + return false; } pPages->Release(); } @@ -3483,18 +3483,18 @@ FX_BOOL CPDF_DataAvail::CheckPage(IFX_DownloadHints* pHints) if (!m_PageObjList.GetSize()) { m_docStatus = PDF_DATAAVAIL_DONE; } - return TRUE; + return true; } -FX_BOOL CPDF_DataAvail::GetPageKids(CPDF_Parser *pParser, CPDF_Object *pPages) +bool CPDF_DataAvail::GetPageKids(CPDF_Parser *pParser, CPDF_Object *pPages) { if (!pParser) { m_docStatus = PDF_DATAAVAIL_ERROR; - return FALSE; + return false; } CPDF_Dictionary* pDict = pPages->GetDict(); CPDF_Object *pKids = pDict ? pDict->GetElement(FX_BSTRC("Kids")) : NULL; if (!pKids) { - return TRUE; + return true; } switch (pKids->GetType()) { case PDFOBJ_REFERENCE: { @@ -3514,35 +3514,35 @@ FX_BOOL CPDF_DataAvail::GetPageKids(CPDF_Parser *pParser, CPDF_Object *pPages) break; default: m_docStatus = PDF_DATAAVAIL_ERROR; - return FALSE; + return false; } - return TRUE; + return true; } -FX_BOOL CPDF_DataAvail::CheckPages(IFX_DownloadHints* pHints) +bool CPDF_DataAvail::CheckPages(IFX_DownloadHints* pHints) { - FX_BOOL bExist = FALSE; + bool bExist = false; CPDF_Object *pPages = GetObject(m_PagesObjNum, pHints, &bExist); if (!bExist) { m_docStatus = PDF_DATAAVAIL_LOADALLFILE; - return TRUE; + return true; } if (!pPages) { if (m_docStatus == PDF_DATAAVAIL_ERROR) { m_docStatus = PDF_DATAAVAIL_LOADALLFILE; - return TRUE; + return true; } - return FALSE; + return false; } if (!GetPageKids(m_pCurrentParser, pPages)) { pPages->Release(); m_docStatus = PDF_DATAAVAIL_ERROR; - return FALSE; + return false; } pPages->Release(); m_docStatus = PDF_DATAAVAIL_PAGE; - return TRUE; + return true; } -FX_BOOL CPDF_DataAvail::CheckHeader(IFX_DownloadHints* pHints) +bool CPDF_DataAvail::CheckHeader(IFX_DownloadHints* pHints) { FX_DWORD req_size = 1024; if ((FX_FILESIZE)req_size > m_dwFileLen) { @@ -3555,34 +3555,34 @@ FX_BOOL CPDF_DataAvail::CheckHeader(IFX_DownloadHints* pHints) m_docStatus = PDF_DATAAVAIL_FIRSTPAGE; } else { if (m_docStatus == PDF_DATAAVAIL_ERROR) { - return FALSE; + return false; } m_docStatus = PDF_DATAAVAIL_END; } - return TRUE; + return true; } pHints->AddSegment(0, req_size); - return FALSE; + return false; } -FX_BOOL CPDF_DataAvail::CheckFirstPage(IFX_DownloadHints *pHints) +bool CPDF_DataAvail::CheckFirstPage(IFX_DownloadHints *pHints) { CPDF_Dictionary* pDict = m_pLinearized->GetDict(); CPDF_Object *pEndOffSet = pDict ? pDict->GetElement(FX_BSTRC("E")) : NULL; if (!pEndOffSet) { m_docStatus = PDF_DATAAVAIL_ERROR; - return FALSE; + return false; } CPDF_Object *pXRefOffset = pDict ? pDict->GetElement(FX_BSTRC("T")) : NULL; if (!pXRefOffset) { m_docStatus = PDF_DATAAVAIL_ERROR; - return FALSE; + return false; } CPDF_Object *pFileLen = pDict ? pDict->GetElement(FX_BSTRC("L")) : NULL; if (!pFileLen) { m_docStatus = PDF_DATAAVAIL_ERROR; - return FALSE; + return false; } - FX_BOOL bNeedDownLoad = FALSE; + bool bNeedDownLoad = false; if (pEndOffSet->GetType() == PDFOBJ_NUMBER) { FX_DWORD dwEnd = pEndOffSet->GetInteger(); dwEnd += 512; @@ -3593,7 +3593,7 @@ FX_BOOL CPDF_DataAvail::CheckFirstPage(IFX_DownloadHints *pHints) int32_t iSize = dwEnd > 1024 ? dwEnd - 1024 : 0; if (!m_pFileAvail->IsDataAvail(iStartPos, iSize)) { pHints->AddSegment(iStartPos, iSize); - bNeedDownLoad = TRUE; + bNeedDownLoad = true; } } m_dwLastXRefOffset = 0; @@ -3619,16 +3619,16 @@ FX_BOOL CPDF_DataAvail::CheckFirstPage(IFX_DownloadHints *pHints) } if (!bNeedDownLoad && m_docStatus == PDF_DATAAVAIL_FIRSTPAGE_PREPARE) { m_docStatus = PDF_DATAAVAIL_DONE; - return TRUE; + return true; } m_docStatus = PDF_DATAAVAIL_FIRSTPAGE_PREPARE; - return FALSE; + return false; } CPDF_Object * CPDF_DataAvail::ParseIndirectObjectAt(FX_FILESIZE pos, FX_DWORD objnum) { FX_FILESIZE SavedPos = m_syntaxParser.SavePos(); m_syntaxParser.RestorePos(pos); - FX_BOOL bIsNumber; + bool bIsNumber; CFX_ByteString word = m_syntaxParser.GetNextWord(bIsNumber); if (!bIsNumber) { return NULL; @@ -3670,21 +3670,21 @@ int32_t CPDF_DataAvail::IsLinearizedPDF() } return PDF_NOT_LINEARIZED; } -FX_BOOL CPDF_DataAvail::IsLinearizedFile(uint8_t* pData, FX_DWORD dwLen) +bool CPDF_DataAvail::IsLinearizedFile(uint8_t* pData, FX_DWORD dwLen) { - CFX_SmartPointer<IFX_FileStream> file(FX_CreateMemoryStream(pData, (size_t)dwLen, FALSE)); + CFX_SmartPointer<IFX_FileStream> file(FX_CreateMemoryStream(pData, (size_t)dwLen, false)); int32_t offset = GetHeaderOffset(file.Get()); if (offset == -1) { m_docStatus = PDF_DATAAVAIL_ERROR; - return FALSE; + return false; } m_dwHeaderOffset = offset; m_syntaxParser.InitParser(file.Get(), offset); m_syntaxParser.RestorePos(m_syntaxParser.m_HeaderOffset + 9); - FX_BOOL bNumber = FALSE; + bool bNumber = false; CFX_ByteString wordObjNum = m_syntaxParser.GetNextWord(bNumber); if (!bNumber) { - return FALSE; + return false; } FX_DWORD objnum = FXSYS_atoi(wordObjNum); if (m_pLinearized) { @@ -3693,58 +3693,58 @@ FX_BOOL CPDF_DataAvail::IsLinearizedFile(uint8_t* pData, FX_DWORD dwLen) } m_pLinearized = ParseIndirectObjectAt(m_syntaxParser.m_HeaderOffset + 9, objnum); if (!m_pLinearized) { - return FALSE; + return false; } if (m_pLinearized->GetDict() && m_pLinearized->GetDict()->GetElement(FX_BSTRC("Linearized"))) { CPDF_Object *pLen = m_pLinearized->GetDict()->GetElement(FX_BSTRC("L")); if (!pLen) { - return FALSE; + return false; } if ((FX_FILESIZE)pLen->GetInteger() != m_pFileRead->GetSize()) { - return FALSE; + return false; } - m_bLinearized = TRUE; + m_bLinearized = true; CPDF_Object *pNo = m_pLinearized->GetDict()->GetElement(FX_BSTRC("P")); if (pNo && pNo->GetType() == PDFOBJ_NUMBER) { m_dwFirstPageNo = pNo->GetInteger(); } - return TRUE; + return true; } - return FALSE; + return false; } -FX_BOOL CPDF_DataAvail::CheckEnd(IFX_DownloadHints* pHints) +bool CPDF_DataAvail::CheckEnd(IFX_DownloadHints* pHints) { FX_DWORD req_pos = (FX_DWORD)(m_dwFileLen > 1024 ? m_dwFileLen - 1024 : 0); FX_DWORD dwSize = (FX_DWORD)(m_dwFileLen - req_pos); if (m_pFileAvail->IsDataAvail(req_pos, dwSize)) { uint8_t buffer[1024]; m_pFileRead->ReadBlock(buffer, req_pos, dwSize); - CFX_SmartPointer<IFX_FileStream> file(FX_CreateMemoryStream(buffer, (size_t)dwSize, FALSE)); + CFX_SmartPointer<IFX_FileStream> file(FX_CreateMemoryStream(buffer, (size_t)dwSize, false)); m_syntaxParser.InitParser(file.Get(), 0); m_syntaxParser.RestorePos(dwSize - 1); - if (m_syntaxParser.SearchWord(FX_BSTRC("startxref"), TRUE, FALSE, dwSize)) { - FX_BOOL bNumber; + if (m_syntaxParser.SearchWord(FX_BSTRC("startxref"), true, false, dwSize)) { + bool bNumber; m_syntaxParser.GetNextWord(bNumber); CFX_ByteString xrefpos_str = m_syntaxParser.GetNextWord(bNumber); if (!bNumber) { m_docStatus = PDF_DATAAVAIL_ERROR; - return FALSE; + return false; } m_dwXRefOffset = (FX_FILESIZE)FXSYS_atoi64(xrefpos_str); if (!m_dwXRefOffset || m_dwXRefOffset > m_dwFileLen) { m_docStatus = PDF_DATAAVAIL_LOADALLFILE; - return TRUE; + return true; } m_dwLastXRefOffset = m_dwXRefOffset; SetStartOffset(m_dwXRefOffset); m_docStatus = PDF_DATAAVAIL_CROSSREF; - return TRUE; + return true; } m_docStatus = PDF_DATAAVAIL_LOADALLFILE; - return TRUE; + return true; } pHints->AddSegment(req_pos, dwSize); - return FALSE; + return false; } int32_t CPDF_DataAvail::CheckCrossRefStream(IFX_DownloadHints* pHints, FX_FILESIZE &xref_offset) { @@ -3755,9 +3755,9 @@ int32_t CPDF_DataAvail::CheckCrossRefStream(IFX_DownloadHints* pHints, FX_FILESI CFX_BinaryBuf buf(iSize); uint8_t* pBuf = buf.GetBuffer(); m_pFileRead->ReadBlock(pBuf, m_dwCurrentXRefSteam, iSize); - CFX_SmartPointer<IFX_FileStream> file(FX_CreateMemoryStream(pBuf, (size_t)iSize, FALSE)); + CFX_SmartPointer<IFX_FileStream> file(FX_CreateMemoryStream(pBuf, (size_t)iSize, false)); m_parser.m_Syntax.InitParser(file.Get(), 0); - FX_BOOL bNumber = FALSE; + bool bNumber = false; CFX_ByteString objnum = m_parser.m_Syntax.GetNextWord(bNumber); if (!bNumber) { return -1; @@ -3789,18 +3789,18 @@ inline void CPDF_DataAvail::SetStartOffset(FX_FILESIZE dwOffset) m_Pos = dwOffset; } #define MAX_WORD_BUFFER 256 -FX_BOOL CPDF_DataAvail::GetNextToken(CFX_ByteString &token) +bool CPDF_DataAvail::GetNextToken(CFX_ByteString &token) { m_WordSize = 0; uint8_t ch; if (!GetNextChar(ch)) { - return FALSE; + return false; } uint8_t type = PDF_CharType[ch]; while (1) { while (type == 'W') { if (!GetNextChar(ch)) { - return FALSE; + return false; } type = PDF_CharType[ch]; } @@ -3809,7 +3809,7 @@ FX_BOOL CPDF_DataAvail::GetNextToken(CFX_ByteString &token) } while (1) { if (!GetNextChar(ch)) { - return FALSE; + return false; } if (ch == '\r' || ch == '\n') { break; @@ -3822,14 +3822,14 @@ FX_BOOL CPDF_DataAvail::GetNextToken(CFX_ByteString &token) if (ch == '/') { while (1) { if (!GetNextChar(ch)) { - return FALSE; + return false; } type = PDF_CharType[ch]; if (type != 'R' && type != 'N') { m_Pos --; CFX_ByteString ret(m_WordBuffer, m_WordSize); token = ret; - return TRUE; + return true; } if (m_WordSize < MAX_WORD_BUFFER) { m_WordBuffer[m_WordSize++] = ch; @@ -3837,7 +3837,7 @@ FX_BOOL CPDF_DataAvail::GetNextToken(CFX_ByteString &token) } } else if (ch == '<') { if (!GetNextChar(ch)) { - return FALSE; + return false; } if (ch == '<') { m_WordBuffer[m_WordSize++] = ch; @@ -3846,7 +3846,7 @@ FX_BOOL CPDF_DataAvail::GetNextToken(CFX_ByteString &token) } } else if (ch == '>') { if (!GetNextChar(ch)) { - return FALSE; + return false; } if (ch == '>') { m_WordBuffer[m_WordSize++] = ch; @@ -3856,14 +3856,14 @@ FX_BOOL CPDF_DataAvail::GetNextToken(CFX_ByteString &token) } CFX_ByteString ret(m_WordBuffer, m_WordSize); token = ret; - return TRUE; + return true; } while (1) { if (m_WordSize < MAX_WORD_BUFFER) { m_WordBuffer[m_WordSize++] = ch; } if (!GetNextChar(ch)) { - return FALSE; + return false; } type = PDF_CharType[ch]; if (type == 'D' || type == 'W') { @@ -3873,13 +3873,13 @@ FX_BOOL CPDF_DataAvail::GetNextToken(CFX_ByteString &token) } CFX_ByteString ret(m_WordBuffer, m_WordSize); token = ret; - return TRUE; + return true; } -FX_BOOL CPDF_DataAvail::GetNextChar(uint8_t &ch) +bool CPDF_DataAvail::GetNextChar(uint8_t &ch) { FX_FILESIZE pos = m_Pos; if (pos >= m_dwFileLen) { - return FALSE; + return false; } if (m_bufferOffset >= pos || (FX_FILESIZE)(m_bufferOffset + m_bufferSize) <= pos) { FX_FILESIZE read_pos = pos; @@ -3891,16 +3891,16 @@ FX_BOOL CPDF_DataAvail::GetNextChar(uint8_t &ch) read_pos = m_dwFileLen - read_size; } if (!m_pFileRead->ReadBlock(m_bufferData, read_pos, read_size)) { - return FALSE; + return false; } m_bufferOffset = read_pos; m_bufferSize = read_size; } ch = m_bufferData[pos - m_bufferOffset]; m_Pos ++; - return TRUE; + return true; } -FX_BOOL CPDF_DataAvail::CheckCrossRefItem(IFX_DownloadHints *pHints) +bool CPDF_DataAvail::CheckCrossRefItem(IFX_DownloadHints *pHints) { int32_t iSize = 0; CFX_ByteString token; @@ -3908,16 +3908,16 @@ FX_BOOL CPDF_DataAvail::CheckCrossRefItem(IFX_DownloadHints *pHints) if (!GetNextToken(token)) { iSize = (int32_t)(m_Pos + 512 > m_dwFileLen ? m_dwFileLen - m_Pos : 512); pHints->AddSegment(m_Pos, iSize); - return FALSE; + return false; } if (token == "trailer") { m_dwTrailerOffset = m_Pos; m_docStatus = PDF_DATAAVAIL_TRAILER; - return TRUE; + return true; } } } -FX_BOOL CPDF_DataAvail::CheckAllCrossRefStream(IFX_DownloadHints *pHints) +bool CPDF_DataAvail::CheckAllCrossRefStream(IFX_DownloadHints *pHints) { FX_FILESIZE xref_offset = 0; int32_t nRet = CheckCrossRefStream(pHints, xref_offset); @@ -3928,21 +3928,21 @@ FX_BOOL CPDF_DataAvail::CheckAllCrossRefStream(IFX_DownloadHints *pHints) m_dwCurrentXRefSteam = xref_offset; m_Pos = xref_offset; } - return TRUE; + return true; } if (nRet == -1) { m_docStatus = PDF_DATAAVAIL_ERROR; } - return FALSE; + return false; } -FX_BOOL CPDF_DataAvail::CheckCrossRef(IFX_DownloadHints* pHints) +bool CPDF_DataAvail::CheckCrossRef(IFX_DownloadHints* pHints) { int32_t iSize = 0; CFX_ByteString token; if (!GetNextToken(token)) { iSize = (int32_t)(m_Pos + 512 > m_dwFileLen ? m_dwFileLen - m_Pos : 512); pHints->AddSegment(m_Pos, iSize); - return FALSE; + return false; } if (token == "xref") { m_CrossOffset.InsertAt(0, m_dwXRefOffset); @@ -3951,28 +3951,28 @@ FX_BOOL CPDF_DataAvail::CheckCrossRef(IFX_DownloadHints* pHints) iSize = (int32_t)(m_Pos + 512 > m_dwFileLen ? m_dwFileLen - m_Pos : 512); pHints->AddSegment(m_Pos, iSize); m_docStatus = PDF_DATAAVAIL_CROSSREF_ITEM; - return FALSE; + return false; } if (token == "trailer") { m_dwTrailerOffset = m_Pos; m_docStatus = PDF_DATAAVAIL_TRAILER; - return TRUE; + return true; } } } else { m_docStatus = PDF_DATAAVAIL_LOADALLFILE; - return TRUE; + return true; } - return FALSE; + return false; } -FX_BOOL CPDF_DataAvail::CheckTrailerAppend(IFX_DownloadHints* pHints) +bool CPDF_DataAvail::CheckTrailerAppend(IFX_DownloadHints* pHints) { if (m_Pos < m_dwFileLen) { FX_FILESIZE dwAppendPos = m_Pos + m_syntaxParser.SavePos(); int32_t iSize = (int32_t)(dwAppendPos + 512 > m_dwFileLen ? m_dwFileLen - dwAppendPos : 512); if (!m_pFileAvail->IsDataAvail(dwAppendPos, iSize)) { pHints->AddSegment(dwAppendPos, iSize); - return FALSE; + return false; } } if (m_dwPrevXRefOffset) { @@ -3981,9 +3981,9 @@ FX_BOOL CPDF_DataAvail::CheckTrailerAppend(IFX_DownloadHints* pHints) } else { m_docStatus = PDF_DATAAVAIL_LOADALLCRSOSSREF; } - return TRUE; + return true; } -FX_BOOL CPDF_DataAvail::CheckTrailer(IFX_DownloadHints* pHints) +bool CPDF_DataAvail::CheckTrailer(IFX_DownloadHints* pHints) { int32_t iTrailerSize = (int32_t)(m_Pos + 512 > m_dwFileLen ? m_dwFileLen - m_Pos : 512); if (m_pFileAvail->IsDataAvail(m_Pos, iTrailerSize)) { @@ -3992,21 +3992,21 @@ FX_BOOL CPDF_DataAvail::CheckTrailer(IFX_DownloadHints* pHints) uint8_t* pBuf = buf.GetBuffer(); if (!pBuf) { m_docStatus = PDF_DATAAVAIL_ERROR; - return FALSE; + return false; } if (!m_pFileRead->ReadBlock(pBuf, m_dwTrailerOffset, iSize)) { - return FALSE; + return false; } - CFX_SmartPointer<IFX_FileStream> file(FX_CreateMemoryStream(pBuf, (size_t)iSize, FALSE)); + CFX_SmartPointer<IFX_FileStream> file(FX_CreateMemoryStream(pBuf, (size_t)iSize, false)); m_syntaxParser.InitParser(file.Get(), 0); CPDF_Object *pTrailer = m_syntaxParser.GetObject(NULL, 0, 0, 0); if (!pTrailer) { m_Pos += m_syntaxParser.SavePos(); pHints->AddSegment(m_Pos, iTrailerSize); - return FALSE; + return false; } if (pTrailer->GetType() != PDFOBJ_DICTIONARY) { - return FALSE; + return false; } CPDF_Dictionary *pTrailerDict = pTrailer->GetDict(); if (pTrailerDict) { @@ -4014,7 +4014,7 @@ FX_BOOL CPDF_DataAvail::CheckTrailer(IFX_DownloadHints* pHints) if (pEncrypt && pEncrypt->GetType() == PDFOBJ_REFERENCE) { m_docStatus = PDF_DATAAVAIL_LOADALLFILE; pTrailer->Release(); - return TRUE; + return true; } } FX_DWORD xrefpos = GetDirectInteger(pTrailer->GetDict(), FX_BSTRC("Prev")); @@ -4032,60 +4032,60 @@ FX_BOOL CPDF_DataAvail::CheckTrailer(IFX_DownloadHints* pHints) m_docStatus = PDF_DATAAVAIL_TRAILER_APPEND; } } - return TRUE; + return true; } m_dwPrevXRefOffset = 0; m_docStatus = PDF_DATAAVAIL_TRAILER_APPEND; pTrailer->Release(); - return TRUE; + return true; } pHints->AddSegment(m_Pos, iTrailerSize); - return FALSE; + return false; } -FX_BOOL CPDF_DataAvail::CheckPage(int32_t iPage, IFX_DownloadHints* pHints) +bool CPDF_DataAvail::CheckPage(int32_t iPage, IFX_DownloadHints* pHints) { - while (TRUE) { + while (true) { switch (m_docStatus) { case PDF_DATAAVAIL_PAGETREE: if (!LoadDocPages(pHints)) { - return FALSE; + return false; } break; case PDF_DATAAVAIL_PAGE: if (!LoadDocPage(iPage, pHints)) { - return FALSE; + return false; } break; case PDF_DATAAVAIL_ERROR: return LoadAllFile(pHints); default: - m_bPagesTreeLoad = TRUE; - m_bPagesLoad = TRUE; - m_bCurPageDictLoadOK = TRUE; + m_bPagesTreeLoad = true; + m_bPagesLoad = true; + m_bCurPageDictLoadOK = true; m_docStatus = PDF_DATAAVAIL_PAGE; - return TRUE; + return true; } } } -FX_BOOL CPDF_DataAvail::CheckArrayPageNode(FX_DWORD dwPageNo, CPDF_PageNode *pPageNode, IFX_DownloadHints* pHints) +bool CPDF_DataAvail::CheckArrayPageNode(FX_DWORD dwPageNo, CPDF_PageNode *pPageNode, IFX_DownloadHints* pHints) { - FX_BOOL bExist = FALSE; + bool bExist = false; CPDF_Object *pPages = GetObject(dwPageNo, pHints, &bExist); if (!bExist) { m_docStatus = PDF_DATAAVAIL_ERROR; - return FALSE; + return false; } if (!pPages) { if (m_docStatus == PDF_DATAAVAIL_ERROR) { m_docStatus = PDF_DATAAVAIL_ERROR; - return FALSE; + return false; } - return FALSE; + return false; } if (pPages->GetType() != PDFOBJ_ARRAY) { pPages->Release(); m_docStatus = PDF_DATAAVAIL_ERROR; - return FALSE; + return false; } pPageNode->m_type = PDF_PAGENODE_PAGES; CPDF_Array* pArray = (CPDF_Array*)pPages; @@ -4099,33 +4099,33 @@ FX_BOOL CPDF_DataAvail::CheckArrayPageNode(FX_DWORD dwPageNo, CPDF_PageNode *pPa pNode->m_dwPageNo = ((CPDF_Reference*)pKid)->GetRefObjNum(); } pPages->Release(); - return TRUE; + return true; } -FX_BOOL CPDF_DataAvail::CheckUnkownPageNode(FX_DWORD dwPageNo, CPDF_PageNode *pPageNode, IFX_DownloadHints* pHints) +bool CPDF_DataAvail::CheckUnkownPageNode(FX_DWORD dwPageNo, CPDF_PageNode *pPageNode, IFX_DownloadHints* pHints) { - FX_BOOL bExist = FALSE; + bool bExist = false; CPDF_Object *pPage = GetObject(dwPageNo, pHints, &bExist); if (!bExist) { m_docStatus = PDF_DATAAVAIL_ERROR; - return FALSE; + return false; } if (!pPage) { if (m_docStatus == PDF_DATAAVAIL_ERROR) { m_docStatus = PDF_DATAAVAIL_ERROR; - return FALSE; + return false; } - return FALSE; + return false; } if (pPage->GetType() == PDFOBJ_ARRAY) { pPageNode->m_dwPageNo = dwPageNo; pPageNode->m_type = PDF_PAGENODE_ARRAY; pPage->Release(); - return TRUE; + return true; } if (pPage->GetType() != PDFOBJ_DICTIONARY) { pPage->Release(); m_docStatus = PDF_DATAAVAIL_ERROR; - return FALSE; + return false; } pPageNode->m_dwPageNo = dwPageNo; CPDF_Dictionary* pDict = pPage->GetDict(); @@ -4135,7 +4135,7 @@ FX_BOOL CPDF_DataAvail::CheckUnkownPageNode(FX_DWORD dwPageNo, CPDF_PageNode *pP CPDF_Object *pKids = pDict->GetElement(FX_BSTRC("Kids")); if (!pKids) { m_docStatus = PDF_DATAAVAIL_PAGE; - return TRUE; + return true; } switch (pKids->GetType()) { case PDFOBJ_REFERENCE: { @@ -4166,17 +4166,17 @@ FX_BOOL CPDF_DataAvail::CheckUnkownPageNode(FX_DWORD dwPageNo, CPDF_PageNode *pP } else { pPage->Release(); m_docStatus = PDF_DATAAVAIL_ERROR; - return FALSE; + return false; } pPage->Release(); - return TRUE; + return true; } -FX_BOOL CPDF_DataAvail::CheckPageNode(CPDF_PageNode &pageNodes, int32_t iPage, int32_t &iCount, IFX_DownloadHints* pHints) +bool CPDF_DataAvail::CheckPageNode(CPDF_PageNode &pageNodes, int32_t iPage, int32_t &iCount, IFX_DownloadHints* pHints) { int32_t iSize = pageNodes.m_childNode.GetSize(); if (iSize <= 0 || iPage >= iSize) { m_docStatus = PDF_DATAAVAIL_ERROR; - return FALSE; + return false; } for (int32_t i = 0; i < iSize; ++i) { CPDF_PageNode *pNode = (CPDF_PageNode*)pageNodes.m_childNode.GetAt(i); @@ -4186,7 +4186,7 @@ FX_BOOL CPDF_DataAvail::CheckPageNode(CPDF_PageNode &pageNodes, int32_t iPage, i switch (pNode->m_type) { case PDF_PAGENODE_UNKOWN: if (!CheckUnkownPageNode(pNode->m_dwPageNo, pNode, pHints)) { - return FALSE; + return false; } --i; break; @@ -4198,199 +4198,199 @@ FX_BOOL CPDF_DataAvail::CheckPageNode(CPDF_PageNode &pageNodes, int32_t iPage, i break; case PDF_PAGENODE_PAGES: if (!CheckPageNode(*pNode, iPage, iCount, pHints)) { - return FALSE; + return false; } break; case PDF_PAGENODE_ARRAY: if (!CheckArrayPageNode(pNode->m_dwPageNo, pNode, pHints)) { - return FALSE; + return false; } --i; break; } if (iPage == iCount) { m_docStatus = PDF_DATAAVAIL_DONE; - return TRUE; + return true; } } - return TRUE; + return true; } -FX_BOOL CPDF_DataAvail::LoadDocPage(int32_t iPage, IFX_DownloadHints* pHints) +bool CPDF_DataAvail::LoadDocPage(int32_t iPage, IFX_DownloadHints* pHints) { if (m_pDocument->GetPageCount() <= iPage || m_pDocument->m_PageList.GetAt(iPage)) { m_docStatus = PDF_DATAAVAIL_DONE; - return TRUE; + return true; } if (m_pageNodes.m_type == PDF_PAGENODE_PAGE) { if (iPage == 0) { m_docStatus = PDF_DATAAVAIL_DONE; - return TRUE; + return true; } m_docStatus = PDF_DATAAVAIL_ERROR; - return TRUE; + return true; } int32_t iCount = -1; return CheckPageNode(m_pageNodes, iPage, iCount, pHints); } -FX_BOOL CPDF_DataAvail::CheckPageCount(IFX_DownloadHints* pHints) +bool CPDF_DataAvail::CheckPageCount(IFX_DownloadHints* pHints) { - FX_BOOL bExist = FALSE; + bool bExist = false; CPDF_Object *pPages = GetObject(m_PagesObjNum, pHints, &bExist); if (!bExist) { m_docStatus = PDF_DATAAVAIL_ERROR; - return FALSE; + return false; } if (!pPages) { - return FALSE; + return false; } CPDF_Dictionary* pPagesDict = pPages->GetDict(); if (!pPagesDict) { pPages->Release(); m_docStatus = PDF_DATAAVAIL_ERROR; - return FALSE; + return false; } if (!pPagesDict->KeyExist(FX_BSTRC("Kids"))) { pPages->Release(); - return TRUE; + return true; } int count = pPagesDict->GetInteger(FX_BSTRC("Count")); if (count > 0) { pPages->Release(); - return TRUE; + return true; } pPages->Release(); - return FALSE; + return false; } -FX_BOOL CPDF_DataAvail::LoadDocPages(IFX_DownloadHints* pHints) +bool CPDF_DataAvail::LoadDocPages(IFX_DownloadHints* pHints) { if (!CheckUnkownPageNode(m_PagesObjNum, &m_pageNodes, pHints)) { - return FALSE; + return false; } if (CheckPageCount(pHints)) { m_docStatus = PDF_DATAAVAIL_PAGE; - return TRUE; + return true; } - m_bTotalLoadPageTree = TRUE; - return FALSE; + m_bTotalLoadPageTree = true; + return false; } -FX_BOOL CPDF_DataAvail::LoadPages(IFX_DownloadHints* pHints) +bool CPDF_DataAvail::LoadPages(IFX_DownloadHints* pHints) { while (!m_bPagesTreeLoad) { if (!CheckPageStatus(pHints)) { - return FALSE; + return false; } } if (m_bPagesLoad) { - return TRUE; + return true; } m_pDocument->LoadPages(); - return FALSE; + return false; } -FX_BOOL CPDF_DataAvail::CheckLinearizedData(IFX_DownloadHints* pHints) +bool CPDF_DataAvail::CheckLinearizedData(IFX_DownloadHints* pHints) { if (m_bLinearedDataOK) { - return TRUE; + return true; } if (!m_bMainXRefLoadTried) { FX_SAFE_DWORD data_size = m_dwFileLen; data_size -= m_dwLastXRefOffset; if (!data_size.IsValid()) { - return FALSE; + return false; } if (!m_pFileAvail->IsDataAvail(m_dwLastXRefOffset, data_size.ValueOrDie())) { pHints->AddSegment(m_dwLastXRefOffset, data_size.ValueOrDie()); - return FALSE; + return false; } FX_DWORD dwRet = ((CPDF_Parser *)m_pDocument->GetParser())->LoadLinearizedMainXRefTable(); - m_bMainXRefLoadTried = TRUE; + m_bMainXRefLoadTried = true; if (dwRet != PDFPARSE_ERROR_SUCCESS) { - return FALSE; + return false; } if (!PreparePageItem()) { - return FALSE; + return false; } - m_bMainXRefLoadedOK = TRUE; - m_bLinearedDataOK = TRUE; + m_bMainXRefLoadedOK = true; + m_bLinearedDataOK = true; } return m_bLinearedDataOK; } -FX_BOOL CPDF_DataAvail::CheckPageAnnots(int32_t iPage, IFX_DownloadHints* pHints) +bool CPDF_DataAvail::CheckPageAnnots(int32_t iPage, IFX_DownloadHints* pHints) { if (!m_objs_array.GetSize()) { m_objs_array.RemoveAll(); m_objnum_array.RemoveAll(); CPDF_Dictionary *pPageDict = m_pDocument->GetPage(iPage); if (!pPageDict) { - return TRUE; + return true; } CPDF_Object *pAnnots = pPageDict->GetElement(FX_BSTRC("Annots")); if (!pAnnots) { - return TRUE; + return true; } CFX_PtrArray obj_array; obj_array.Add(pAnnots); - FX_BOOL bRet = IsObjectsAvail(obj_array, FALSE, pHints, m_objs_array); + bool bRet = IsObjectsAvail(obj_array, false, pHints, m_objs_array); if (bRet) { m_objs_array.RemoveAll(); } return bRet; } CFX_PtrArray new_objs_array; - FX_BOOL bRet = IsObjectsAvail(m_objs_array, FALSE, pHints, new_objs_array); + bool bRet = IsObjectsAvail(m_objs_array, false, pHints, new_objs_array); m_objs_array.RemoveAll(); if (!bRet) { m_objs_array.Append(new_objs_array); } return bRet; } -FX_BOOL CPDF_DataAvail::CheckLinearizedFirstPage(int32_t iPage, IFX_DownloadHints* pHints) +bool CPDF_DataAvail::CheckLinearizedFirstPage(int32_t iPage, IFX_DownloadHints* pHints) { if (!m_bAnnotsLoad) { if (!CheckPageAnnots(iPage, pHints)) { - return FALSE; + return false; } - m_bAnnotsLoad = TRUE; + m_bAnnotsLoad = true; } if (m_bAnnotsLoad) { if (!CheckLinearizedData(pHints)) - return FALSE; + return false; } - m_bPageLoadedOK = FALSE; - return TRUE; + m_bPageLoadedOK = false; + return true; } -FX_BOOL CPDF_DataAvail::HaveResourceAncestor(CPDF_Dictionary *pDict) +bool CPDF_DataAvail::HaveResourceAncestor(CPDF_Dictionary *pDict) { CFX_AutoRestorer<int> restorer(&s_CurrentDataAvailRecursionDepth); if (++s_CurrentDataAvailRecursionDepth > kMaxDataAvailRecursionDepth) { - return FALSE; + return false; } CPDF_Object *pParent = pDict->GetElement("Parent"); if (!pParent) { - return FALSE; + return false; } CPDF_Dictionary *pParentDict = pParent->GetDict(); if (!pParentDict) { - return FALSE; + return false; } CPDF_Object *pRet = pParentDict->GetElement("Resources"); if (pRet) { m_pPageResource = pRet; - return TRUE; + return true; } return HaveResourceAncestor(pParentDict); } -FX_BOOL CPDF_DataAvail::IsPageAvail(int32_t iPage, IFX_DownloadHints* pHints) +bool CPDF_DataAvail::IsPageAvail(int32_t iPage, IFX_DownloadHints* pHints) { if (!m_pDocument) { - return FALSE; + return false; } if (IsFirstCheck(iPage)) { - m_bCurPageDictLoadOK = FALSE; - m_bPageLoadedOK = FALSE; - m_bAnnotsLoad = FALSE; - m_bNeedDownLoadResource = FALSE; + m_bCurPageDictLoadOK = false; + m_bPageLoadedOK = false; + m_bAnnotsLoad = false; + m_bNeedDownLoadResource = false; m_objs_array.RemoveAll(); m_objnum_array.RemoveAll(); } @@ -4399,46 +4399,46 @@ FX_BOOL CPDF_DataAvail::IsPageAvail(int32_t iPage, IFX_DownloadHints* pHints) } FX_DWORD dwPageLoad = 0; if (m_pagesLoadState->Lookup(iPage, dwPageLoad) && dwPageLoad != 0) { - return TRUE; + return true; } if (m_bLinearized) { if ((FX_DWORD)iPage == m_dwFirstPageNo) { - m_pagesLoadState->SetAt(iPage, TRUE); - return TRUE; + m_pagesLoadState->SetAt(iPage, true); + return true; } if (!CheckLinearizedData(pHints)) { - return FALSE; + return false; } if (m_bMainXRefLoadedOK) { if (m_bTotalLoadPageTree) { if (!LoadPages(pHints)) { - return FALSE; + return false; } } else { if (!m_bCurPageDictLoadOK && !CheckPage(iPage, pHints)) { - return FALSE; + return false; } } } else { if (!LoadAllFile(pHints)) { - return FALSE; + return false; } ((CPDF_Parser *)m_pDocument->GetParser())->RebuildCrossRef(); ResetFirstCheck(iPage); - return TRUE; + return true; } } else { if (!m_bTotalLoadPageTree) { if (!m_bCurPageDictLoadOK && !CheckPage(iPage, pHints)) { - return FALSE; + return false; } } } if (m_bHaveAcroForm && !m_bAcroFormLoad) { if (!CheckAcroFormSubObject(pHints)) { - return FALSE; + return false; } - m_bAcroFormLoad = TRUE; + m_bAcroFormLoad = true; } if (!m_bPageLoadedOK) { if (!m_objs_array.GetSize()) { @@ -4447,23 +4447,23 @@ FX_BOOL CPDF_DataAvail::IsPageAvail(int32_t iPage, IFX_DownloadHints* pHints) m_pPageDict = m_pDocument->GetPage(iPage); if (!m_pPageDict) { ResetFirstCheck(iPage); - return TRUE; + return true; } CFX_PtrArray obj_array; obj_array.Add(m_pPageDict); - FX_BOOL bRet = IsObjectsAvail(obj_array, TRUE, pHints, m_objs_array); + bool bRet = IsObjectsAvail(obj_array, true, pHints, m_objs_array); if (bRet) { m_objs_array.RemoveAll(); - m_bPageLoadedOK = TRUE; + m_bPageLoadedOK = true; } else { return bRet; } } else { CFX_PtrArray new_objs_array; - FX_BOOL bRet = IsObjectsAvail(m_objs_array, FALSE, pHints, new_objs_array); + bool bRet = IsObjectsAvail(m_objs_array, false, pHints, new_objs_array); m_objs_array.RemoveAll(); if (bRet) { - m_bPageLoadedOK = TRUE; + m_bPageLoadedOK = true; } else { m_objs_array.Append(new_objs_array); return bRet; @@ -4473,9 +4473,9 @@ FX_BOOL CPDF_DataAvail::IsPageAvail(int32_t iPage, IFX_DownloadHints* pHints) if (m_bPageLoadedOK) { if (!m_bAnnotsLoad) { if (!CheckPageAnnots(iPage, pHints)) { - return FALSE; + return false; } - m_bAnnotsLoad = TRUE; + m_bAnnotsLoad = true; } } if (m_pPageDict && !m_bNeedDownLoadResource) { @@ -4483,37 +4483,37 @@ FX_BOOL CPDF_DataAvail::IsPageAvail(int32_t iPage, IFX_DownloadHints* pHints) if (!m_pPageResource) { m_bNeedDownLoadResource = HaveResourceAncestor(m_pPageDict); } else { - m_bNeedDownLoadResource = TRUE; + m_bNeedDownLoadResource = true; } } if (m_bNeedDownLoadResource) { - FX_BOOL bRet = CheckResources(pHints); + bool bRet = CheckResources(pHints); if (!bRet) { - return FALSE; + return false; } - m_bNeedDownLoadResource = FALSE; + m_bNeedDownLoadResource = false; } - m_bPageLoadedOK = FALSE; - m_bAnnotsLoad = FALSE; - m_bCurPageDictLoadOK = FALSE; + m_bPageLoadedOK = false; + m_bAnnotsLoad = false; + m_bCurPageDictLoadOK = false; ResetFirstCheck(iPage); - m_pagesLoadState->SetAt(iPage, TRUE); - return TRUE; + m_pagesLoadState->SetAt(iPage, true); + return true; } -FX_BOOL CPDF_DataAvail::CheckResources(IFX_DownloadHints* pHints) +bool CPDF_DataAvail::CheckResources(IFX_DownloadHints* pHints) { if (!m_objs_array.GetSize()) { m_objs_array.RemoveAll(); CFX_PtrArray obj_array; obj_array.Add(m_pPageResource); - FX_BOOL bRet = IsObjectsAvail(obj_array, TRUE, pHints, m_objs_array); + bool bRet = IsObjectsAvail(obj_array, true, pHints, m_objs_array); if (bRet) { m_objs_array.RemoveAll(); } return bRet; } CFX_PtrArray new_objs_array; - FX_BOOL bRet = IsObjectsAvail(m_objs_array, FALSE, pHints, new_objs_array); + bool bRet = IsObjectsAvail(m_objs_array, false, pHints, new_objs_array); m_objs_array.RemoveAll(); if (!bRet) { m_objs_array.Append(new_objs_array); @@ -4549,10 +4549,10 @@ int32_t CPDF_DataAvail::IsFormAvail(IFX_DownloadHints *pHints) if (!m_objs_array.GetSize()) { m_objs_array.Add(pAcroForm->GetDict()); } - m_bLinearizedFormParamLoad = TRUE; + m_bLinearizedFormParamLoad = true; } CFX_PtrArray new_objs_array; - FX_BOOL bRet = IsObjectsAvail(m_objs_array, FALSE, pHints, new_objs_array); + bool bRet = IsObjectsAvail(m_objs_array, false, pHints, new_objs_array); m_objs_array.RemoveAll(); if (!bRet) { m_objs_array.Append(new_objs_array); @@ -4568,12 +4568,12 @@ void CPDF_SortObjNumArray::AddObjNum(FX_DWORD dwObjNum) } m_number_array.InsertAt(iNext, dwObjNum); } -FX_BOOL CPDF_SortObjNumArray::Find(FX_DWORD dwObjNum) +bool CPDF_SortObjNumArray::Find(FX_DWORD dwObjNum) { int32_t iNext = 0; return BinarySearch(dwObjNum, iNext); } -FX_BOOL CPDF_SortObjNumArray::BinarySearch(FX_DWORD value, int32_t &iNext) +bool CPDF_SortObjNumArray::BinarySearch(FX_DWORD value, int32_t &iNext) { int32_t iLow = 0; int32_t iHigh = m_number_array.GetSize() - 1; @@ -4581,7 +4581,7 @@ FX_BOOL CPDF_SortObjNumArray::BinarySearch(FX_DWORD value, int32_t &iNext) int32_t iMid = (iLow + iHigh) / 2; if (m_number_array.GetAt(iMid) == value) { iNext = iMid; - return TRUE; + return true; } if (m_number_array.GetAt(iMid) > value) { iHigh = iMid - 1; @@ -4590,7 +4590,7 @@ FX_BOOL CPDF_SortObjNumArray::BinarySearch(FX_DWORD value, int32_t &iNext) } } iNext = iLow; - return FALSE; + return false; } CPDF_PageNode::~CPDF_PageNode() { diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp index 4903312645..76e245ad92 100644 --- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp +++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp @@ -195,7 +195,7 @@ CFX_ByteStringC CPDF_SimpleParser::GetWord() } return CFX_ByteStringC(pStart, dwSize); } -FX_BOOL CPDF_SimpleParser::SearchToken(const CFX_ByteStringC& token) +bool CPDF_SimpleParser::SearchToken(const CFX_ByteStringC& token) { int token_len = token.GetLength(); while (m_dwCurPos < m_dwSize - token_len) { @@ -205,30 +205,30 @@ FX_BOOL CPDF_SimpleParser::SearchToken(const CFX_ByteStringC& token) m_dwCurPos ++; } if (m_dwCurPos == m_dwSize - token_len) { - return FALSE; + return false; } m_dwCurPos += token_len; - return TRUE; + return true; } -FX_BOOL CPDF_SimpleParser::SkipWord(const CFX_ByteStringC& token) +bool CPDF_SimpleParser::SkipWord(const CFX_ByteStringC& token) { while (1) { CFX_ByteStringC word = GetWord(); if (word.IsEmpty()) { - return FALSE; + return false; } if (word == token) { - return TRUE; + return true; } } - return FALSE; + return false; } -FX_BOOL CPDF_SimpleParser::FindTagPair(const CFX_ByteStringC& start_token, const CFX_ByteStringC& end_token, +bool CPDF_SimpleParser::FindTagPair(const CFX_ByteStringC& start_token, const CFX_ByteStringC& end_token, FX_DWORD& start_pos, FX_DWORD& end_pos) { if (!start_token.IsEmpty()) { if (!SkipWord(start_token)) { - return FALSE; + return false; } start_pos = m_dwCurPos; } @@ -236,15 +236,15 @@ FX_BOOL CPDF_SimpleParser::FindTagPair(const CFX_ByteStringC& start_token, const end_pos = m_dwCurPos; CFX_ByteStringC word = GetWord(); if (word.IsEmpty()) { - return FALSE; + return false; } if (word == end_token) { - return TRUE; + return true; } } - return FALSE; + return false; } -FX_BOOL CPDF_SimpleParser::FindTagParam(const CFX_ByteStringC& token, int nParams) +bool CPDF_SimpleParser::FindTagParam(const CFX_ByteStringC& token, int nParams) { nParams ++; FX_DWORD* pBuf = FX_Alloc(FX_DWORD, nParams); @@ -262,7 +262,7 @@ FX_BOOL CPDF_SimpleParser::FindTagParam(const CFX_ByteStringC& token, int nParam CFX_ByteStringC word = GetWord(); if (word.IsEmpty()) { FX_Free(pBuf); - return FALSE; + return false; } if (word == token) { if (buf_count < nParams) { @@ -270,10 +270,10 @@ FX_BOOL CPDF_SimpleParser::FindTagParam(const CFX_ByteStringC& token, int nParam } m_dwCurPos = pBuf[buf_index]; FX_Free(pBuf); - return TRUE; + return true; } } - return FALSE; + return false; } static int _hex2dec(char ch) { @@ -368,7 +368,7 @@ CFX_ByteTextBuf& operator << (CFX_ByteTextBuf& buf, const CPDF_Object* pObj) break; case PDFOBJ_STRING: { CFX_ByteString str = pObj->GetString(); - FX_BOOL bHex = ((CPDF_String*)pObj)->IsHex(); + bool bHex = ((CPDF_String*)pObj)->IsHex(); buf << PDF_EncodeString(str, bHex); break; } @@ -417,13 +417,13 @@ CFX_ByteTextBuf& operator << (CFX_ByteTextBuf& buf, const CPDF_Object* pObj) CPDF_Stream* p = (CPDF_Stream*)pObj; buf << p->GetDict() << FX_BSTRC("stream\r\n"); CPDF_StreamAcc acc; - acc.LoadAllData(p, TRUE); + acc.LoadAllData(p, true); buf.AppendBlock(acc.GetData(), acc.GetSize()); buf << FX_BSTRC("\r\nendstream"); break; } default: - ASSERT(FALSE); + ASSERT(false); break; } return buf; |