summaryrefslogtreecommitdiff
path: root/core/fpdfapi/parser
diff options
context:
space:
mode:
Diffstat (limited to 'core/fpdfapi/parser')
-rw-r--r--core/fpdfapi/parser/cfdf_document.cpp15
-rw-r--r--core/fpdfapi/parser/cfdf_document.h8
-rw-r--r--core/fpdfapi/parser/cpdf_array.cpp2
-rw-r--r--core/fpdfapi/parser/cpdf_crypto_handler.cpp99
-rw-r--r--core/fpdfapi/parser/cpdf_crypto_handler.h44
-rw-r--r--core/fpdfapi/parser/cpdf_data_avail.cpp560
-rw-r--r--core/fpdfapi/parser/cpdf_data_avail.h138
-rw-r--r--core/fpdfapi/parser/cpdf_dictionary.cpp2
-rw-r--r--core/fpdfapi/parser/cpdf_document.cpp18
-rw-r--r--core/fpdfapi/parser/cpdf_document.h12
-rw-r--r--core/fpdfapi/parser/cpdf_object.cpp2
-rw-r--r--core/fpdfapi/parser/cpdf_parser.cpp164
-rw-r--r--core/fpdfapi/parser/cpdf_parser.h23
-rw-r--r--core/fpdfapi/parser/cpdf_parser_unittest.cpp8
-rw-r--r--core/fpdfapi/parser/cpdf_security_handler.cpp158
-rw-r--r--core/fpdfapi/parser/cpdf_security_handler.h62
-rw-r--r--core/fpdfapi/parser/cpdf_stream.cpp12
-rw-r--r--core/fpdfapi/parser/cpdf_stream.h6
-rw-r--r--core/fpdfapi/parser/cpdf_stream_acc.cpp12
-rw-r--r--core/fpdfapi/parser/cpdf_stream_acc.h6
-rw-r--r--core/fpdfapi/parser/cpdf_string.cpp6
-rw-r--r--core/fpdfapi/parser/cpdf_string.h6
-rw-r--r--core/fpdfapi/parser/cpdf_syntax_parser.cpp74
-rw-r--r--core/fpdfapi/parser/cpdf_syntax_parser.h22
-rw-r--r--core/fpdfapi/parser/cpdf_syntax_parser_unittest.cpp26
-rw-r--r--core/fpdfapi/parser/fpdf_parser_decode.cpp42
-rw-r--r--core/fpdfapi/parser/fpdf_parser_decode.h23
-rw-r--r--core/fpdfapi/parser/fpdf_parser_utility.cpp4
28 files changed, 774 insertions, 780 deletions
diff --git a/core/fpdfapi/parser/cfdf_document.cpp b/core/fpdfapi/parser/cfdf_document.cpp
index 3bafdda9f2..d39ec31d3c 100644
--- a/core/fpdfapi/parser/cfdf_document.cpp
+++ b/core/fpdfapi/parser/cfdf_document.cpp
@@ -15,7 +15,7 @@ CFDF_Document::CFDF_Document()
: CPDF_IndirectObjectHolder(),
m_pRootDict(nullptr),
m_pFile(nullptr),
- m_bOwnFile(FALSE),
+ m_bOwnFile(false),
m_pByteStringPool(pdfium::MakeUnique<CFX_ByteStringPool>()) {}
CFDF_Document::~CFDF_Document() {
@@ -34,7 +34,7 @@ CFDF_Document* CFDF_Document::CreateNewDoc() {
}
CFDF_Document* CFDF_Document::ParseFile(IFX_SeekableReadStream* pFile,
- FX_BOOL bOwnFile) {
+ bool bOwnFile) {
if (!pFile)
return nullptr;
@@ -45,11 +45,10 @@ CFDF_Document* CFDF_Document::ParseFile(IFX_SeekableReadStream* pFile,
CFDF_Document* CFDF_Document::ParseMemory(const uint8_t* pData, uint32_t size) {
return CFDF_Document::ParseFile(FX_CreateMemoryStream((uint8_t*)pData, size),
- TRUE);
+ true);
}
-void CFDF_Document::ParseStream(IFX_SeekableReadStream* pFile,
- FX_BOOL bOwnFile) {
+void CFDF_Document::ParseStream(IFX_SeekableReadStream* pFile, bool bOwnFile) {
m_pFile = pFile;
m_bOwnFile = bOwnFile;
CPDF_SyntaxParser parser;
@@ -89,9 +88,9 @@ void CFDF_Document::ParseStream(IFX_SeekableReadStream* pFile,
}
}
-FX_BOOL CFDF_Document::WriteBuf(CFX_ByteTextBuf& buf) const {
+bool CFDF_Document::WriteBuf(CFX_ByteTextBuf& buf) const {
if (!m_pRootDict)
- return FALSE;
+ return false;
buf << "%FDF-1.2\r\n";
for (const auto& pair : *this)
@@ -100,5 +99,5 @@ FX_BOOL CFDF_Document::WriteBuf(CFX_ByteTextBuf& buf) const {
buf << "trailer\r\n<</Root " << m_pRootDict->GetObjNum()
<< " 0 R>>\r\n%%EOF\r\n";
- return TRUE;
+ return true;
}
diff --git a/core/fpdfapi/parser/cfdf_document.h b/core/fpdfapi/parser/cfdf_document.h
index 32d0aab422..181c4697e2 100644
--- a/core/fpdfapi/parser/cfdf_document.h
+++ b/core/fpdfapi/parser/cfdf_document.h
@@ -19,11 +19,11 @@ class CFDF_Document : public CPDF_IndirectObjectHolder {
public:
static CFDF_Document* CreateNewDoc();
static CFDF_Document* ParseFile(IFX_SeekableReadStream* pFile,
- FX_BOOL bOwnFile = FALSE);
+ bool bOwnFile = false);
static CFDF_Document* ParseMemory(const uint8_t* pData, uint32_t size);
~CFDF_Document() override;
- FX_BOOL WriteBuf(CFX_ByteTextBuf& buf) const;
+ bool WriteBuf(CFX_ByteTextBuf& buf) const;
CPDF_Dictionary* GetRoot() const { return m_pRootDict; }
CFX_WeakPtr<CFX_ByteStringPool> GetByteStringPool() const {
return m_pByteStringPool;
@@ -31,11 +31,11 @@ class CFDF_Document : public CPDF_IndirectObjectHolder {
protected:
CFDF_Document();
- void ParseStream(IFX_SeekableReadStream* pFile, FX_BOOL bOwnFile);
+ void ParseStream(IFX_SeekableReadStream* pFile, bool bOwnFile);
CPDF_Dictionary* m_pRootDict;
IFX_SeekableReadStream* m_pFile;
- FX_BOOL m_bOwnFile;
+ bool m_bOwnFile;
CFX_WeakPtr<CFX_ByteStringPool> m_pByteStringPool;
};
diff --git a/core/fpdfapi/parser/cpdf_array.cpp b/core/fpdfapi/parser/cpdf_array.cpp
index 1aec3e06f3..e118fd66e6 100644
--- a/core/fpdfapi/parser/cpdf_array.cpp
+++ b/core/fpdfapi/parser/cpdf_array.cpp
@@ -196,7 +196,7 @@ void CPDF_Array::AddName(const CFX_ByteString& str) {
}
void CPDF_Array::AddString(const CFX_ByteString& str) {
- Add(new CPDF_String(str, FALSE));
+ Add(new CPDF_String(str, false));
}
void CPDF_Array::AddInteger(int i) {
diff --git a/core/fpdfapi/parser/cpdf_crypto_handler.cpp b/core/fpdfapi/parser/cpdf_crypto_handler.cpp
index f7dc19e243..5918754c5c 100644
--- a/core/fpdfapi/parser/cpdf_crypto_handler.cpp
+++ b/core/fpdfapi/parser/cpdf_crypto_handler.cpp
@@ -13,7 +13,7 @@
#include "core/fpdfapi/parser/cpdf_security_handler.h"
#include "core/fpdfapi/parser/cpdf_simple_parser.h"
-void CPDF_CryptoHandler::CryptBlock(FX_BOOL bEncrypt,
+void CPDF_CryptoHandler::CryptBlock(bool bEncrypt,
uint32_t objnum,
uint32_t gennum,
const uint8_t* src_buf,
@@ -76,20 +76,20 @@ void CPDF_CryptoHandler::CryptBlock(FX_BOOL bEncrypt,
struct AESCryptContext {
uint8_t m_Context[2048];
- FX_BOOL m_bIV;
+ bool m_bIV;
uint8_t m_Block[16];
uint32_t m_BlockOffset;
};
void* CPDF_CryptoHandler::CryptStart(uint32_t objnum,
uint32_t gennum,
- FX_BOOL bEncrypt) {
+ 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) {
@@ -115,7 +115,7 @@ void* CPDF_CryptoHandler::CryptStart(uint32_t objnum,
}
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) {
@@ -131,28 +131,28 @@ void* CPDF_CryptoHandler::CryptStart(uint32_t objnum,
return pContext;
}
-FX_BOOL CPDF_CryptoHandler::CryptStream(void* context,
- const uint8_t* src_buf,
- uint32_t src_size,
- CFX_BinaryBuf& dest_buf,
- FX_BOOL bEncrypt) {
+bool CPDF_CryptoHandler::CryptStream(void* context,
+ const uint8_t* src_buf,
+ uint32_t 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;
}
uint32_t src_off = 0;
uint32_t src_left = src_size;
@@ -169,7 +169,7 @@ FX_BOOL CPDF_CryptoHandler::CryptStream(void* context,
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];
@@ -188,20 +188,20 @@ FX_BOOL CPDF_CryptoHandler::CryptStream(void* context,
break;
}
}
- return TRUE;
+ return true;
}
-FX_BOOL CPDF_CryptoHandler::CryptFinish(void* context,
- CFX_BinaryBuf& dest_buf,
- FX_BOOL bEncrypt) {
+bool CPDF_CryptoHandler::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) {
@@ -224,7 +224,7 @@ FX_BOOL CPDF_CryptoHandler::CryptFinish(void* context,
}
}
FX_Free(pContext);
- return TRUE;
+ return true;
}
void CPDF_CryptoHandler::Decrypt(uint32_t objnum,
@@ -238,20 +238,20 @@ void CPDF_CryptoHandler::Decrypt(uint32_t objnum,
}
void* CPDF_CryptoHandler::DecryptStart(uint32_t objnum, uint32_t gennum) {
- return CryptStart(objnum, gennum, FALSE);
+ return CryptStart(objnum, gennum, false);
}
uint32_t CPDF_CryptoHandler::DecryptGetSize(uint32_t src_size) {
return m_Cipher == FXCIPHER_AES ? src_size - 16 : src_size;
}
-FX_BOOL CPDF_CryptoHandler::Init(CPDF_Dictionary* pEncryptDict,
- CPDF_SecurityHandler* pSecurityHandler) {
+bool CPDF_CryptoHandler::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);
@@ -259,10 +259,10 @@ FX_BOOL CPDF_CryptoHandler::Init(CPDF_Dictionary* pEncryptDict,
if (m_Cipher == FXCIPHER_AES) {
m_pAESContext = FX_Alloc(uint8_t, 2048);
}
- return TRUE;
+ return true;
}
-FX_BOOL CPDF_CryptoHandler::Init(int cipher, const uint8_t* key, int keylen) {
+bool CPDF_CryptoHandler::Init(int cipher, const uint8_t* key, int keylen) {
if (cipher == FXCIPHER_AES) {
switch (keylen) {
case 16:
@@ -270,15 +270,15 @@ FX_BOOL CPDF_CryptoHandler::Init(int cipher, const uint8_t* key, int keylen) {
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) {
@@ -291,17 +291,16 @@ FX_BOOL CPDF_CryptoHandler::Init(int cipher, const uint8_t* key, int keylen) {
if (m_Cipher == FXCIPHER_AES) {
m_pAESContext = FX_Alloc(uint8_t, 2048);
}
- return TRUE;
+ return true;
}
-FX_BOOL CPDF_CryptoHandler::DecryptStream(void* context,
- const uint8_t* src_buf,
- uint32_t src_size,
- CFX_BinaryBuf& dest_buf) {
- return CryptStream(context, src_buf, src_size, dest_buf, FALSE);
+bool CPDF_CryptoHandler::DecryptStream(void* context,
+ const uint8_t* src_buf,
+ uint32_t src_size,
+ CFX_BinaryBuf& dest_buf) {
+ return CryptStream(context, src_buf, src_size, dest_buf, false);
}
-FX_BOOL CPDF_CryptoHandler::DecryptFinish(void* context,
- CFX_BinaryBuf& dest_buf) {
- return CryptFinish(context, dest_buf, FALSE);
+bool CPDF_CryptoHandler::DecryptFinish(void* context, CFX_BinaryBuf& dest_buf) {
+ return CryptFinish(context, dest_buf, false);
}
uint32_t CPDF_CryptoHandler::EncryptGetSize(uint32_t objnum,
uint32_t version,
@@ -312,14 +311,14 @@ uint32_t CPDF_CryptoHandler::EncryptGetSize(uint32_t objnum,
}
return src_size;
}
-FX_BOOL CPDF_CryptoHandler::EncryptContent(uint32_t objnum,
- uint32_t gennum,
- const uint8_t* src_buf,
- uint32_t src_size,
- uint8_t* dest_buf,
- uint32_t& dest_size) {
- CryptBlock(TRUE, objnum, gennum, src_buf, src_size, dest_buf, dest_size);
- return TRUE;
+bool CPDF_CryptoHandler::EncryptContent(uint32_t objnum,
+ uint32_t gennum,
+ const uint8_t* src_buf,
+ uint32_t src_size,
+ uint8_t* dest_buf,
+ uint32_t& dest_size) {
+ CryptBlock(true, objnum, gennum, src_buf, src_size, dest_buf, dest_size);
+ return true;
}
CPDF_CryptoHandler::CPDF_CryptoHandler() {
m_pAESContext = nullptr;
diff --git a/core/fpdfapi/parser/cpdf_crypto_handler.h b/core/fpdfapi/parser/cpdf_crypto_handler.h
index 37612f9ef0..63a2590950 100644
--- a/core/fpdfapi/parser/cpdf_crypto_handler.h
+++ b/core/fpdfapi/parser/cpdf_crypto_handler.h
@@ -19,44 +19,44 @@ class CPDF_CryptoHandler {
CPDF_CryptoHandler();
~CPDF_CryptoHandler();
- FX_BOOL Init(CPDF_Dictionary* pEncryptDict,
- CPDF_SecurityHandler* pSecurityHandler);
+ bool Init(CPDF_Dictionary* pEncryptDict,
+ CPDF_SecurityHandler* pSecurityHandler);
uint32_t DecryptGetSize(uint32_t src_size);
void* DecryptStart(uint32_t objnum, uint32_t gennum);
void Decrypt(uint32_t objnum, uint32_t gennum, CFX_ByteString& str);
- FX_BOOL DecryptStream(void* context,
- const uint8_t* src_buf,
- uint32_t src_size,
- CFX_BinaryBuf& dest_buf);
- FX_BOOL DecryptFinish(void* context, CFX_BinaryBuf& dest_buf);
+ bool DecryptStream(void* context,
+ const uint8_t* src_buf,
+ uint32_t src_size,
+ CFX_BinaryBuf& dest_buf);
+ bool DecryptFinish(void* context, CFX_BinaryBuf& dest_buf);
uint32_t EncryptGetSize(uint32_t objnum,
uint32_t version,
const uint8_t* src_buf,
uint32_t src_size);
- FX_BOOL EncryptContent(uint32_t objnum,
- uint32_t version,
- const uint8_t* src_buf,
- uint32_t src_size,
- uint8_t* dest_buf,
- uint32_t& dest_size);
+ bool EncryptContent(uint32_t objnum,
+ uint32_t version,
+ const uint8_t* src_buf,
+ uint32_t src_size,
+ uint8_t* dest_buf,
+ uint32_t& dest_size);
- FX_BOOL Init(int cipher, const uint8_t* key, int keylen);
+ bool Init(int cipher, const uint8_t* key, int keylen);
protected:
- void CryptBlock(FX_BOOL bEncrypt,
+ void CryptBlock(bool bEncrypt,
uint32_t objnum,
uint32_t gennum,
const uint8_t* src_buf,
uint32_t src_size,
uint8_t* dest_buf,
uint32_t& dest_size);
- void* CryptStart(uint32_t objnum, uint32_t gennum, FX_BOOL bEncrypt);
- FX_BOOL CryptStream(void* context,
- const uint8_t* src_buf,
- uint32_t src_size,
- CFX_BinaryBuf& dest_buf,
- FX_BOOL bEncrypt);
- FX_BOOL CryptFinish(void* context, CFX_BinaryBuf& dest_buf, FX_BOOL bEncrypt);
+ void* CryptStart(uint32_t objnum, uint32_t gennum, bool bEncrypt);
+ bool CryptStream(void* context,
+ const uint8_t* src_buf,
+ uint32_t src_size,
+ CFX_BinaryBuf& dest_buf,
+ bool bEncrypt);
+ bool CryptFinish(void* context, CFX_BinaryBuf& dest_buf, bool bEncrypt);
uint8_t m_EncryptKey[32];
int m_KeyLen;
diff --git a/core/fpdfapi/parser/cpdf_data_avail.cpp b/core/fpdfapi/parser/cpdf_data_avail.cpp
index 318f2cf54d..a077ebb715 100644
--- a/core/fpdfapi/parser/cpdf_data_avail.cpp
+++ b/core/fpdfapi/parser/cpdf_data_avail.cpp
@@ -33,7 +33,7 @@ int CPDF_DataAvail::s_CurrentDataAvailRecursionDepth = 0;
CPDF_DataAvail::CPDF_DataAvail(FileAvail* pFileAvail,
IFX_SeekableReadStream* pFileRead,
- FX_BOOL bSupportHintTable)
+ bool bSupportHintTable)
: m_pFileAvail(pFileAvail), m_pFileRead(pFileRead) {
m_Pos = 0;
m_dwFileLen = 0;
@@ -53,19 +53,19 @@ CPDF_DataAvail::CPDF_DataAvail(FileAvail* pFileAvail,
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 = nullptr;
m_pRoot = nullptr;
m_pTrailer = nullptr;
@@ -75,9 +75,9 @@ CPDF_DataAvail::CPDF_DataAvail(FileAvail* pFileAvail,
m_pPageResource = nullptr;
m_docStatus = PDF_DATAAVAIL_HEADER;
m_parser.m_bOwnFileRead = false;
- m_bTotalLoadPageTree = FALSE;
- m_bCurPageDictLoadOK = FALSE;
- m_bLinearedDataOK = FALSE;
+ m_bTotalLoadPageTree = false;
+ m_bCurPageDictLoadOK = false;
+ m_bLinearedDataOK = false;
m_bSupportHintTable = bSupportHintTable;
}
@@ -125,13 +125,12 @@ uint32_t CPDF_DataAvail::GetObjectSize(uint32_t objnum, FX_FILESIZE& offset) {
return *it - offset;
}
-FX_BOOL CPDF_DataAvail::AreObjectsAvailable(
- std::vector<CPDF_Object*>& obj_array,
- FX_BOOL bParsePage,
- DownloadHints* pHints,
- std::vector<CPDF_Object*>& ret_array) {
+bool CPDF_DataAvail::AreObjectsAvailable(std::vector<CPDF_Object*>& obj_array,
+ bool bParsePage,
+ DownloadHints* pHints,
+ std::vector<CPDF_Object*>& ret_array) {
if (obj_array.empty())
- return TRUE;
+ return true;
uint32_t count = 0;
std::vector<CPDF_Object*> new_obj_array;
@@ -190,11 +189,11 @@ FX_BOOL CPDF_DataAvail::AreObjectsAvailable(
continue;
ret_array.push_back(pObj);
}
- return FALSE;
+ return false;
}
obj_array = new_obj_array;
- return AreObjectsAvailable(obj_array, FALSE, pHints, ret_array);
+ return AreObjectsAvailable(obj_array, false, pHints, ret_array);
}
CPDF_DataAvail::DocAvailStatus CPDF_DataAvail::IsDocAvail(
@@ -213,52 +212,52 @@ CPDF_DataAvail::DocAvailStatus CPDF_DataAvail::IsDocAvail(
return DataAvailable;
}
-FX_BOOL CPDF_DataAvail::CheckAcroFormSubObject(DownloadHints* pHints) {
+bool CPDF_DataAvail::CheckAcroFormSubObject(DownloadHints* pHints) {
if (m_objs_array.empty()) {
m_ObjectSet.clear();
std::vector<CPDF_Object*> obj_array = m_arrayAcroforms;
- if (!AreObjectsAvailable(obj_array, FALSE, pHints, m_objs_array))
- return FALSE;
+ if (!AreObjectsAvailable(obj_array, false, pHints, m_objs_array))
+ return false;
m_objs_array.clear();
- return TRUE;
+ return true;
}
std::vector<CPDF_Object*> new_objs_array;
- if (!AreObjectsAvailable(m_objs_array, FALSE, pHints, new_objs_array)) {
+ if (!AreObjectsAvailable(m_objs_array, false, pHints, new_objs_array)) {
m_objs_array = new_objs_array;
- return FALSE;
+ return false;
}
for (CPDF_Object* pObject : m_arrayAcroforms)
pObject->Release();
m_arrayAcroforms.clear();
- return TRUE;
+ return true;
}
-FX_BOOL CPDF_DataAvail::CheckAcroForm(DownloadHints* pHints) {
- FX_BOOL bExist = FALSE;
+bool CPDF_DataAvail::CheckAcroForm(DownloadHints* pHints) {
+ 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.push_back(m_pAcroForm);
m_docStatus = PDF_DATAAVAIL_PAGETREE;
- return TRUE;
+ return true;
}
-FX_BOOL CPDF_DataAvail::CheckDocStatus(DownloadHints* pHints) {
+bool CPDF_DataAvail::CheckDocStatus(DownloadHints* pHints) {
switch (m_docStatus) {
case PDF_DATAAVAIL_HEADER:
return CheckHeader(pHints);
@@ -297,18 +296,18 @@ FX_BOOL CPDF_DataAvail::CheckDocStatus(DownloadHints* pHints) {
if (m_bTotalLoadPageTree)
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(DownloadHints* pHints) {
+bool CPDF_DataAvail::CheckPageStatus(DownloadHints* pHints) {
switch (m_docStatus) {
case PDF_DATAAVAIL_PAGETREE:
return CheckPages(pHints);
@@ -317,48 +316,48 @@ FX_BOOL CPDF_DataAvail::CheckPageStatus(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(DownloadHints* pHints) {
+bool CPDF_DataAvail::LoadAllFile(DownloadHints* pHints) {
if (m_pFileAvail->IsDataAvail(0, (uint32_t)m_dwFileLen)) {
m_docStatus = PDF_DATAAVAIL_DONE;
- return TRUE;
+ return true;
}
pHints->AddSegment(0, (uint32_t)m_dwFileLen);
- return FALSE;
+ return false;
}
-FX_BOOL CPDF_DataAvail::LoadAllXref(DownloadHints* pHints) {
+bool CPDF_DataAvail::LoadAllXref(DownloadHints* pHints) {
m_parser.m_pSyntax->InitParser(m_pFileRead, (uint32_t)m_dwHeaderOffset);
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;
}
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(uint32_t objnum,
DownloadHints* pHints,
- FX_BOOL* pExistInFile) {
+ bool* pExistInFile) {
CPDF_Object* pRet = nullptr;
uint32_t size = 0;
FX_FILESIZE offset = 0;
CPDF_Parser* pParser = nullptr;
if (pExistInFile)
- *pExistInFile = TRUE;
+ *pExistInFile = true;
if (m_pDocument) {
size = GetObjectSize(objnum, offset);
@@ -376,29 +375,29 @@ CPDF_Object* CPDF_DataAvail::GetObject(uint32_t objnum,
pRet = pParser->ParseIndirectObject(nullptr, objnum);
if (!pRet && pExistInFile)
- *pExistInFile = FALSE;
+ *pExistInFile = false;
return pRet;
}
-FX_BOOL CPDF_DataAvail::CheckInfo(DownloadHints* pHints) {
- FX_BOOL bExist = FALSE;
+bool CPDF_DataAvail::CheckInfo(DownloadHints* pHints) {
+ bool bExist = false;
CPDF_Object* pInfo = GetObject(m_dwInfoObjNum, pHints, &bExist);
if (!bExist) {
m_docStatus =
(m_bHaveAcroForm ? PDF_DATAAVAIL_ACROFORM : 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)
@@ -407,42 +406,42 @@ FX_BOOL CPDF_DataAvail::CheckInfo(DownloadHints* pHints) {
m_docStatus =
(m_bHaveAcroForm ? PDF_DATAAVAIL_ACROFORM : PDF_DATAAVAIL_PAGETREE);
- return TRUE;
+ return true;
}
-FX_BOOL CPDF_DataAvail::CheckRoot(DownloadHints* pHints) {
- FX_BOOL bExist = FALSE;
+bool CPDF_DataAvail::CheckRoot(DownloadHints* pHints) {
+ 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 = ToReference(pDict->GetObjectFor("Pages"));
if (!pRef) {
m_docStatus = PDF_DATAAVAIL_ERROR;
- return FALSE;
+ return false;
}
m_PagesObjNum = pRef->GetRefObjNum();
CPDF_Reference* pAcroFormRef =
ToReference(m_pRoot->GetDict()->GetObjectFor("AcroForm"));
if (pAcroFormRef) {
- m_bHaveAcroForm = TRUE;
+ m_bHaveAcroForm = true;
m_dwAcroFormObjNum = pAcroFormRef->GetRefObjNum();
}
@@ -452,22 +451,22 @@ FX_BOOL CPDF_DataAvail::CheckRoot(DownloadHints* pHints) {
m_docStatus =
m_bHaveAcroForm ? PDF_DATAAVAIL_ACROFORM : 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 =
ToReference(pRoot ? pRoot->GetObjectFor("Pages") : nullptr);
if (!pRef) {
m_docStatus = PDF_DATAAVAIL_ERROR;
- return FALSE;
+ return false;
}
m_PagesObjNum = pRef->GetRefObjNum();
m_pCurrentParser = m_pDocument->GetParser();
m_docStatus = PDF_DATAAVAIL_PAGETREE;
- return TRUE;
+ return true;
}
bool CPDF_DataAvail::IsFirstCheck(uint32_t dwPage) {
@@ -478,12 +477,12 @@ void CPDF_DataAvail::ResetFirstCheck(uint32_t dwPage) {
m_pageMapCheckState.erase(dwPage);
}
-FX_BOOL CPDF_DataAvail::CheckPage(DownloadHints* pHints) {
+bool CPDF_DataAvail::CheckPage(DownloadHints* pHints) {
uint32_t iPageObjs = m_PageObjList.GetSize();
CFX_ArrayTemplate<uint32_t> UnavailObjList;
for (uint32_t i = 0; i < iPageObjs; ++i) {
uint32_t dwPageObjNum = m_PageObjList.GetAt(i);
- FX_BOOL bExist = FALSE;
+ bool bExist = false;
CPDF_Object* pObj = GetObject(dwPageObjNum, pHints, &bExist);
if (!pObj) {
if (bExist)
@@ -515,7 +514,7 @@ FX_BOOL CPDF_DataAvail::CheckPage(DownloadHints* pHints) {
m_PageObjList.RemoveAll();
if (UnavailObjList.GetSize()) {
m_PageObjList.Append(UnavailObjList);
- return FALSE;
+ return false;
}
uint32_t iPages = m_PagesArray.size();
@@ -531,7 +530,7 @@ FX_BOOL CPDF_DataAvail::CheckPage(DownloadHints* pHints) {
m_PagesArray.clear();
m_docStatus = PDF_DATAAVAIL_ERROR;
- return FALSE;
+ return false;
}
pPages->Release();
}
@@ -539,19 +538,19 @@ FX_BOOL CPDF_DataAvail::CheckPage(DownloadHints* pHints) {
m_PagesArray.clear();
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->GetObjectFor("Kids") : nullptr;
if (!pKids)
- return TRUE;
+ return true;
switch (pKids->GetType()) {
case CPDF_Object::REFERENCE:
@@ -566,39 +565,39 @@ 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(DownloadHints* pHints) {
- FX_BOOL bExist = FALSE;
+bool CPDF_DataAvail::CheckPages(DownloadHints* pHints) {
+ 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(DownloadHints* pHints) {
+bool CPDF_DataAvail::CheckHeader(DownloadHints* pHints) {
ASSERT(m_dwFileLen >= 0);
const uint32_t kReqSize = std::min(static_cast<uint32_t>(m_dwFileLen), 1024U);
@@ -610,37 +609,37 @@ FX_BOOL CPDF_DataAvail::CheckHeader(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, kReqSize);
- return FALSE;
+ return false;
}
-FX_BOOL CPDF_DataAvail::CheckFirstPage(DownloadHints* pHints) {
+bool CPDF_DataAvail::CheckFirstPage(DownloadHints* pHints) {
CPDF_Dictionary* pDict = m_pLinearized->GetDict();
CPDF_Object* pEndOffSet = pDict ? pDict->GetObjectFor("E") : nullptr;
if (!pEndOffSet) {
m_docStatus = PDF_DATAAVAIL_ERROR;
- return FALSE;
+ return false;
}
CPDF_Object* pXRefOffset = pDict ? pDict->GetObjectFor("T") : nullptr;
if (!pXRefOffset) {
m_docStatus = PDF_DATAAVAIL_ERROR;
- return FALSE;
+ return false;
}
CPDF_Object* pFileLen = pDict ? pDict->GetObjectFor("L") : nullptr;
if (!pFileLen) {
m_docStatus = PDF_DATAAVAIL_ERROR;
- return FALSE;
+ return false;
}
- FX_BOOL bNeedDownLoad = FALSE;
+ bool bNeedDownLoad = false;
if (pEndOffSet->IsNumber()) {
uint32_t dwEnd = pEndOffSet->GetInteger();
dwEnd += 512;
@@ -651,7 +650,7 @@ FX_BOOL CPDF_DataAvail::CheckFirstPage(DownloadHints* pHints) {
int32_t iSize = dwEnd > 1024 ? dwEnd - 1024 : 0;
if (!m_pFileAvail->IsDataAvail(iStartPos, iSize)) {
pHints->AddSegment(iStartPos, iSize);
- bNeedDownLoad = TRUE;
+ bNeedDownLoad = true;
}
}
@@ -680,19 +679,19 @@ FX_BOOL CPDF_DataAvail::CheckFirstPage(DownloadHints* pHints) {
if (bNeedDownLoad || m_docStatus != PDF_DATAAVAIL_FIRSTPAGE_PREPARE) {
m_docStatus = PDF_DATAAVAIL_FIRSTPAGE_PREPARE;
- return FALSE;
+ return false;
}
m_docStatus =
m_bSupportHintTable ? PDF_DATAAVAIL_HINTTABLE : PDF_DATAAVAIL_DONE;
- return TRUE;
+ return true;
}
-FX_BOOL CPDF_DataAvail::IsDataAvail(FX_FILESIZE offset,
- uint32_t size,
- DownloadHints* pHints) {
+bool CPDF_DataAvail::IsDataAvail(FX_FILESIZE offset,
+ uint32_t size,
+ DownloadHints* pHints) {
if (offset < 0 || offset > m_dwFileLen)
- return TRUE;
+ return true;
FX_SAFE_FILESIZE safeSize = offset;
safeSize += size;
@@ -704,49 +703,49 @@ FX_BOOL CPDF_DataAvail::IsDataAvail(FX_FILESIZE offset,
if (!m_pFileAvail->IsDataAvail(offset, size)) {
pHints->AddSegment(offset, size);
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
-FX_BOOL CPDF_DataAvail::CheckHintTables(DownloadHints* pHints) {
+bool CPDF_DataAvail::CheckHintTables(DownloadHints* pHints) {
CPDF_Dictionary* pDict = m_pLinearized->GetDict();
if (!pDict) {
m_docStatus = PDF_DATAAVAIL_ERROR;
- return FALSE;
+ return false;
}
// The actual value is not required here, but validate its existence and type.
CPDF_Number* pFirstPage = ToNumber(pDict->GetDirectObjectFor("O"));
if (!pFirstPage || !pFirstPage->IsInteger()) {
m_docStatus = PDF_DATAAVAIL_ERROR;
- return FALSE;
+ return false;
}
CPDF_Number* pPageCount = ToNumber(pDict->GetDirectObjectFor("N"));
if (!pPageCount || !pPageCount->IsInteger()) {
m_docStatus = PDF_DATAAVAIL_ERROR;
- return FALSE;
+ return false;
}
int nPageCount = pPageCount->GetInteger();
if (nPageCount <= 1) {
m_docStatus = PDF_DATAAVAIL_DONE;
- return TRUE;
+ return true;
}
CPDF_Array* pHintStreamRange = pDict->GetArrayFor("H");
size_t nHintStreamSize = pHintStreamRange ? pHintStreamRange->GetCount() : 0;
if (nHintStreamSize != 2 && nHintStreamSize != 4) {
m_docStatus = PDF_DATAAVAIL_ERROR;
- return FALSE;
+ return false;
}
for (const CPDF_Object* pArrayObject : *pHintStreamRange) {
const CPDF_Number* pNumber = ToNumber(pArrayObject->GetDirect());
if (!pNumber || !pNumber->IsInteger()) {
m_docStatus = PDF_DATAAVAIL_ERROR;
- return FALSE;
+ return false;
}
}
@@ -754,11 +753,11 @@ FX_BOOL CPDF_DataAvail::CheckHintTables(DownloadHints* pHints) {
FX_FILESIZE szHintLength = pHintStreamRange->GetIntegerAt(1);
if (szHintStart < 0 || szHintLength <= 0) {
m_docStatus = PDF_DATAAVAIL_ERROR;
- return FALSE;
+ return false;
}
if (!IsDataAvail(szHintStart, szHintLength, pHints))
- return FALSE;
+ return false;
m_syntaxParser.InitParser(m_pFileRead, m_dwHeaderOffset);
@@ -771,7 +770,7 @@ FX_BOOL CPDF_DataAvail::CheckHintTables(DownloadHints* pHints) {
m_pHintTables = std::move(pHintTables);
m_docStatus = PDF_DATAAVAIL_DONE;
- return TRUE;
+ return true;
}
CPDF_Object* CPDF_DataAvail::ParseIndirectObjectAt(
@@ -826,20 +825,20 @@ CPDF_DataAvail::DocLinearizationStatus CPDF_DataAvail::IsLinearizedPDF() {
return NotLinearized;
}
-FX_BOOL CPDF_DataAvail::IsLinearized() {
+bool CPDF_DataAvail::IsLinearized() {
return m_bLinearized;
}
-FX_BOOL CPDF_DataAvail::IsLinearizedFile(uint8_t* pData, uint32_t dwLen) {
+bool CPDF_DataAvail::IsLinearizedFile(uint8_t* pData, uint32_t dwLen) {
if (m_pLinearized)
return m_bLinearized;
- ScopedFileStream file(FX_CreateMemoryStream(pData, (size_t)dwLen, FALSE));
+ ScopedFileStream 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;
@@ -849,34 +848,34 @@ FX_BOOL CPDF_DataAvail::IsLinearizedFile(uint8_t* pData, uint32_t dwLen) {
bool bNumber;
CFX_ByteString wordObjNum = m_syntaxParser.GetNextWord(&bNumber);
if (!bNumber)
- return FALSE;
+ return false;
uint32_t objnum = FXSYS_atoui(wordObjNum.c_str());
m_pLinearized =
ParseIndirectObjectAt(m_syntaxParser.m_HeaderOffset + 9, objnum);
if (!m_pLinearized)
- return FALSE;
+ return false;
CPDF_Dictionary* pDict = m_pLinearized->GetDict();
if (!pDict || !pDict->GetObjectFor("Linearized"))
- return FALSE;
+ return false;
CPDF_Object* pLen = pDict->GetObjectFor("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;
if (CPDF_Number* pNo = ToNumber(pDict->GetObjectFor("P")))
m_dwFirstPageNo = pNo->GetInteger();
- return TRUE;
+ return true;
}
-FX_BOOL CPDF_DataAvail::CheckEnd(DownloadHints* pHints) {
+bool CPDF_DataAvail::CheckEnd(DownloadHints* pHints) {
uint32_t req_pos = (uint32_t)(m_dwFileLen > 1024 ? m_dwFileLen - 1024 : 0);
uint32_t dwSize = (uint32_t)(m_dwFileLen - req_pos);
@@ -884,38 +883,38 @@ FX_BOOL CPDF_DataAvail::CheckEnd(DownloadHints* pHints) {
uint8_t buffer[1024];
m_pFileRead->ReadBlock(buffer, req_pos, dwSize);
- ScopedFileStream file(FX_CreateMemoryStream(buffer, (size_t)dwSize, FALSE));
+ ScopedFileStream file(FX_CreateMemoryStream(buffer, (size_t)dwSize, false));
m_syntaxParser.InitParser(file.get(), 0);
m_syntaxParser.RestorePos(dwSize - 1);
- if (m_syntaxParser.SearchWord("startxref", TRUE, FALSE, dwSize)) {
+ if (m_syntaxParser.SearchWord("startxref", true, false, dwSize)) {
m_syntaxParser.GetNextWord(nullptr);
bool 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.c_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(DownloadHints* pHints,
@@ -931,7 +930,7 @@ int32_t CPDF_DataAvail::CheckCrossRefStream(DownloadHints* pHints,
m_pFileRead->ReadBlock(pBuf, m_dwCurrentXRefSteam, iSize);
- ScopedFileStream file(FX_CreateMemoryStream(pBuf, (size_t)iSize, FALSE));
+ ScopedFileStream file(FX_CreateMemoryStream(pBuf, (size_t)iSize, false));
m_parser.m_pSyntax->InitParser(file.get(), 0);
bool bNumber;
@@ -967,15 +966,15 @@ void CPDF_DataAvail::SetStartOffset(FX_FILESIZE dwOffset) {
m_Pos = dwOffset;
}
-FX_BOOL CPDF_DataAvail::GetNextToken(CFX_ByteString& token) {
+bool CPDF_DataAvail::GetNextToken(CFX_ByteString& token) {
uint8_t ch;
if (!GetNextChar(ch))
- return FALSE;
+ return false;
while (1) {
while (PDFCharIsWhitespace(ch)) {
if (!GetNextChar(ch))
- return FALSE;
+ return false;
}
if (ch != '%')
@@ -983,7 +982,7 @@ FX_BOOL CPDF_DataAvail::GetNextToken(CFX_ByteString& token) {
while (1) {
if (!GetNextChar(ch))
- return FALSE;
+ return false;
if (PDFCharIsLineEnding(ch))
break;
}
@@ -996,13 +995,13 @@ FX_BOOL CPDF_DataAvail::GetNextToken(CFX_ByteString& token) {
if (ch == '/') {
while (1) {
if (!GetNextChar(ch))
- return FALSE;
+ return false;
if (!PDFCharIsOther(ch) && !PDFCharIsNumeric(ch)) {
m_Pos--;
CFX_ByteString ret(buffer, index);
token = ret;
- return TRUE;
+ return true;
}
if (index < sizeof(buffer))
@@ -1010,7 +1009,7 @@ FX_BOOL CPDF_DataAvail::GetNextToken(CFX_ByteString& token) {
}
} else if (ch == '<') {
if (!GetNextChar(ch))
- return FALSE;
+ return false;
if (ch == '<')
buffer[index++] = ch;
@@ -1018,7 +1017,7 @@ FX_BOOL CPDF_DataAvail::GetNextToken(CFX_ByteString& token) {
m_Pos--;
} else if (ch == '>') {
if (!GetNextChar(ch))
- return FALSE;
+ return false;
if (ch == '>')
buffer[index++] = ch;
@@ -1028,7 +1027,7 @@ FX_BOOL CPDF_DataAvail::GetNextToken(CFX_ByteString& token) {
CFX_ByteString ret(buffer, index);
token = ret;
- return TRUE;
+ return true;
}
while (1) {
@@ -1036,7 +1035,7 @@ FX_BOOL CPDF_DataAvail::GetNextToken(CFX_ByteString& token) {
buffer[index++] = ch;
if (!GetNextChar(ch))
- return FALSE;
+ return false;
if (PDFCharIsDelimiter(ch) || PDFCharIsWhitespace(ch)) {
m_Pos--;
@@ -1045,13 +1044,13 @@ FX_BOOL CPDF_DataAvail::GetNextToken(CFX_ByteString& token) {
}
token = CFX_ByteString(buffer, index);
- 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) {
@@ -1064,35 +1063,35 @@ 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(DownloadHints* pHints) {
+bool CPDF_DataAvail::CheckCrossRefItem(DownloadHints* pHints) {
int32_t iSize = 0;
CFX_ByteString token;
while (1) {
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(DownloadHints* pHints) {
+bool CPDF_DataAvail::CheckAllCrossRefStream(DownloadHints* pHints) {
FX_FILESIZE xref_offset = 0;
int32_t nRet = CheckCrossRefStream(pHints, xref_offset);
@@ -1103,21 +1102,21 @@ FX_BOOL CPDF_DataAvail::CheckAllCrossRefStream(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(DownloadHints* pHints) {
+bool CPDF_DataAvail::CheckCrossRef(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") {
@@ -1127,23 +1126,23 @@ FX_BOOL CPDF_DataAvail::CheckCrossRef(DownloadHints* pHints) {
(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(DownloadHints* pHints) {
+bool CPDF_DataAvail::CheckTrailerAppend(DownloadHints* pHints) {
if (m_Pos < m_dwFileLen) {
FX_FILESIZE dwAppendPos = m_Pos + m_syntaxParser.SavePos();
int32_t iSize = (int32_t)(
@@ -1151,7 +1150,7 @@ FX_BOOL CPDF_DataAvail::CheckTrailerAppend(DownloadHints* pHints) {
if (!m_pFileAvail->IsDataAvail(dwAppendPos, iSize)) {
pHints->AddSegment(dwAppendPos, iSize);
- return FALSE;
+ return false;
}
}
@@ -1161,10 +1160,10 @@ FX_BOOL CPDF_DataAvail::CheckTrailerAppend(DownloadHints* pHints) {
} else {
m_docStatus = PDF_DATAAVAIL_LOADALLCROSSREF;
}
- return TRUE;
+ return true;
}
-FX_BOOL CPDF_DataAvail::CheckTrailer(DownloadHints* pHints) {
+bool CPDF_DataAvail::CheckTrailer(DownloadHints* pHints) {
int32_t iTrailerSize =
(int32_t)(m_Pos + 512 > m_dwFileLen ? m_dwFileLen - m_Pos : 512);
if (m_pFileAvail->IsDataAvail(m_Pos, iTrailerSize)) {
@@ -1173,13 +1172,13 @@ FX_BOOL CPDF_DataAvail::CheckTrailer(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;
- ScopedFileStream file(FX_CreateMemoryStream(pBuf, (size_t)iSize, FALSE));
+ ScopedFileStream file(FX_CreateMemoryStream(pBuf, (size_t)iSize, false));
m_syntaxParser.InitParser(file.get(), 0);
std::unique_ptr<CPDF_Object, ReleaseDeleter<CPDF_Object>> pTrailer(
@@ -1187,17 +1186,17 @@ FX_BOOL CPDF_DataAvail::CheckTrailer(DownloadHints* pHints) {
if (!pTrailer) {
m_Pos += m_syntaxParser.SavePos();
pHints->AddSegment(m_Pos, iTrailerSize);
- return FALSE;
+ return false;
}
if (!pTrailer->IsDictionary())
- return FALSE;
+ return false;
CPDF_Dictionary* pTrailerDict = pTrailer->GetDict();
CPDF_Object* pEncrypt = pTrailerDict->GetObjectFor("Encrypt");
if (ToReference(pEncrypt)) {
m_docStatus = PDF_DATAAVAIL_LOADALLFILE;
- return TRUE;
+ return true;
}
uint32_t xrefpos = GetDirectInteger(pTrailerDict, "Prev");
@@ -1214,62 +1213,62 @@ FX_BOOL CPDF_DataAvail::CheckTrailer(DownloadHints* pHints) {
m_docStatus = PDF_DATAAVAIL_TRAILER_APPEND;
}
}
- return TRUE;
+ return true;
}
m_dwPrevXRefOffset = 0;
m_docStatus = PDF_DATAAVAIL_TRAILER_APPEND;
- return TRUE;
+ return true;
}
pHints->AddSegment(m_Pos, iTrailerSize);
- return FALSE;
+ return false;
}
-FX_BOOL CPDF_DataAvail::CheckPage(uint32_t dwPage, DownloadHints* pHints) {
- while (TRUE) {
+bool CPDF_DataAvail::CheckPage(uint32_t dwPage, DownloadHints* pHints) {
+ while (true) {
switch (m_docStatus) {
case PDF_DATAAVAIL_PAGETREE:
if (!LoadDocPages(pHints))
- return FALSE;
+ return false;
break;
case PDF_DATAAVAIL_PAGE:
if (!LoadDocPage(dwPage, 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(uint32_t dwPageNo,
- PageNode* pPageNode,
- DownloadHints* pHints) {
- FX_BOOL bExist = FALSE;
+bool CPDF_DataAvail::CheckArrayPageNode(uint32_t dwPageNo,
+ PageNode* pPageNode,
+ DownloadHints* pHints) {
+ 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;
}
CPDF_Array* pArray = pPages->AsArray();
if (!pArray) {
pPages->Release();
m_docStatus = PDF_DATAAVAIL_ERROR;
- return FALSE;
+ return false;
}
pPageNode->m_type = PDF_PAGENODE_PAGES;
@@ -1283,36 +1282,36 @@ FX_BOOL CPDF_DataAvail::CheckArrayPageNode(uint32_t dwPageNo,
pNode->m_dwPageNo = pKid->GetRefObjNum();
}
pPages->Release();
- return TRUE;
+ return true;
}
-FX_BOOL CPDF_DataAvail::CheckUnkownPageNode(uint32_t dwPageNo,
- PageNode* pPageNode,
- DownloadHints* pHints) {
- FX_BOOL bExist = FALSE;
+bool CPDF_DataAvail::CheckUnkownPageNode(uint32_t dwPageNo,
+ PageNode* pPageNode,
+ DownloadHints* pHints) {
+ 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;
}
if (pPage->IsArray()) {
pPageNode->m_dwPageNo = dwPageNo;
pPageNode->m_type = PDF_PAGENODE_ARRAY;
pPage->Release();
- return TRUE;
+ return true;
}
if (!pPage->IsDictionary()) {
pPage->Release();
m_docStatus = PDF_DATAAVAIL_ERROR;
- return FALSE;
+ return false;
}
pPageNode->m_dwPageNo = dwPageNo;
@@ -1323,7 +1322,7 @@ FX_BOOL CPDF_DataAvail::CheckUnkownPageNode(uint32_t dwPageNo,
CPDF_Object* pKids = pDict->GetObjectFor("Kids");
if (!pKids) {
m_docStatus = PDF_DATAAVAIL_PAGE;
- return TRUE;
+ return true;
}
switch (pKids->GetType()) {
@@ -1353,24 +1352,24 @@ FX_BOOL CPDF_DataAvail::CheckUnkownPageNode(uint32_t dwPageNo,
} else {
pPage->Release();
m_docStatus = PDF_DATAAVAIL_ERROR;
- return FALSE;
+ return false;
}
pPage->Release();
- return TRUE;
+ return true;
}
-FX_BOOL CPDF_DataAvail::CheckPageNode(CPDF_DataAvail::PageNode& pageNodes,
- int32_t iPage,
- int32_t& iCount,
- DownloadHints* pHints,
- int level) {
+bool CPDF_DataAvail::CheckPageNode(CPDF_DataAvail::PageNode& pageNodes,
+ int32_t iPage,
+ int32_t& iCount,
+ DownloadHints* pHints,
+ int level) {
if (level >= kMaxPageRecursionDepth)
- return FALSE;
+ return false;
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) {
@@ -1381,7 +1380,7 @@ FX_BOOL CPDF_DataAvail::CheckPageNode(CPDF_DataAvail::PageNode& pageNodes,
switch (pNode->m_type) {
case PDF_PAGENODE_UNKNOWN:
if (!CheckUnkownPageNode(pNode->m_dwPageNo, pNode, pHints)) {
- return FALSE;
+ return false;
}
--i;
break;
@@ -1392,101 +1391,101 @@ FX_BOOL CPDF_DataAvail::CheckPageNode(CPDF_DataAvail::PageNode& pageNodes,
break;
case PDF_PAGENODE_PAGES:
if (!CheckPageNode(*pNode, iPage, iCount, pHints, level + 1))
- 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(uint32_t dwPage, DownloadHints* pHints) {
+bool CPDF_DataAvail::LoadDocPage(uint32_t dwPage, DownloadHints* pHints) {
FX_SAFE_INT32 safePage = pdfium::base::checked_cast<int32_t>(dwPage);
int32_t iPage = safePage.ValueOrDie();
if (m_pDocument->GetPageCount() <= iPage ||
m_pDocument->IsPageLoaded(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, 0);
}
-FX_BOOL CPDF_DataAvail::CheckPageCount(DownloadHints* pHints) {
- FX_BOOL bExist = FALSE;
+bool CPDF_DataAvail::CheckPageCount(DownloadHints* pHints) {
+ 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("Kids")) {
pPages->Release();
- return TRUE;
+ return true;
}
int count = pPagesDict->GetIntegerFor("Count");
if (count > 0) {
pPages->Release();
- return TRUE;
+ return true;
}
pPages->Release();
- return FALSE;
+ return false;
}
-FX_BOOL CPDF_DataAvail::LoadDocPages(DownloadHints* pHints) {
+bool CPDF_DataAvail::LoadDocPages(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(DownloadHints* pHints) {
+bool CPDF_DataAvail::LoadPages(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;
}
CPDF_DataAvail::DocAvailStatus CPDF_DataAvail::CheckLinearizedData(
@@ -1508,50 +1507,49 @@ CPDF_DataAvail::DocAvailStatus CPDF_DataAvail::CheckLinearizedData(
CPDF_Parser::Error eRet =
m_pDocument->GetParser()->LoadLinearizedMainXRefTable();
- m_bMainXRefLoadTried = TRUE;
+ m_bMainXRefLoadTried = true;
if (eRet != CPDF_Parser::SUCCESS)
return DataError;
if (!PreparePageItem())
return DataNotAvailable;
- m_bMainXRefLoadedOK = TRUE;
- m_bLinearedDataOK = TRUE;
+ m_bMainXRefLoadedOK = true;
+ m_bLinearedDataOK = true;
}
return m_bLinearedDataOK ? DataAvailable : DataNotAvailable;
}
-FX_BOOL CPDF_DataAvail::CheckPageAnnots(uint32_t dwPage,
- DownloadHints* pHints) {
+bool CPDF_DataAvail::CheckPageAnnots(uint32_t dwPage, DownloadHints* pHints) {
if (m_objs_array.empty()) {
m_ObjectSet.clear();
FX_SAFE_INT32 safePage = pdfium::base::checked_cast<int32_t>(dwPage);
CPDF_Dictionary* pPageDict = m_pDocument->GetPage(safePage.ValueOrDie());
if (!pPageDict)
- return TRUE;
+ return true;
CPDF_Object* pAnnots = pPageDict->GetObjectFor("Annots");
if (!pAnnots)
- return TRUE;
+ return true;
std::vector<CPDF_Object*> obj_array;
obj_array.push_back(pAnnots);
- if (!AreObjectsAvailable(obj_array, FALSE, pHints, m_objs_array))
- return FALSE;
+ if (!AreObjectsAvailable(obj_array, false, pHints, m_objs_array))
+ return false;
m_objs_array.clear();
- return TRUE;
+ return true;
}
std::vector<CPDF_Object*> new_objs_array;
- if (!AreObjectsAvailable(m_objs_array, FALSE, pHints, new_objs_array)) {
+ if (!AreObjectsAvailable(m_objs_array, false, pHints, new_objs_array)) {
m_objs_array = new_objs_array;
- return FALSE;
+ return false;
}
m_objs_array.clear();
- return TRUE;
+ return true;
}
CPDF_DataAvail::DocAvailStatus CPDF_DataAvail::CheckLinearizedFirstPage(
@@ -1560,32 +1558,32 @@ CPDF_DataAvail::DocAvailStatus CPDF_DataAvail::CheckLinearizedFirstPage(
if (!m_bAnnotsLoad) {
if (!CheckPageAnnots(dwPage, pHints))
return DataNotAvailable;
- m_bAnnotsLoad = TRUE;
+ m_bAnnotsLoad = true;
}
DocAvailStatus nRet = CheckLinearizedData(pHints);
if (nRet == DataAvailable)
- m_bPageLoadedOK = FALSE;
+ m_bPageLoadedOK = false;
return nRet;
}
-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->GetObjectFor("Parent");
if (!pParent)
- return FALSE;
+ return false;
CPDF_Dictionary* pParentDict = pParent->GetDict();
if (!pParentDict)
- return FALSE;
+ return false;
CPDF_Object* pRet = pParentDict->GetObjectFor("Resources");
if (pRet) {
m_pPageResource = pRet;
- return TRUE;
+ return true;
}
return HaveResourceAncestor(pParentDict);
@@ -1598,10 +1596,10 @@ CPDF_DataAvail::DocAvailStatus CPDF_DataAvail::IsPageAvail(
return DataError;
if (IsFirstCheck(dwPage)) {
- 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.clear();
m_ObjectSet.clear();
}
@@ -1654,7 +1652,7 @@ CPDF_DataAvail::DocAvailStatus CPDF_DataAvail::IsPageAvail(
if (m_bHaveAcroForm && !m_bAcroFormLoad) {
if (!CheckAcroFormSubObject(pHints))
return DataNotAvailable;
- m_bAcroFormLoad = TRUE;
+ m_bAcroFormLoad = true;
}
if (!m_bPageLoadedOK) {
@@ -1670,25 +1668,25 @@ CPDF_DataAvail::DocAvailStatus CPDF_DataAvail::IsPageAvail(
std::vector<CPDF_Object*> obj_array;
obj_array.push_back(m_pPageDict);
- if (!AreObjectsAvailable(obj_array, TRUE, pHints, m_objs_array))
+ if (!AreObjectsAvailable(obj_array, true, pHints, m_objs_array))
return DataNotAvailable;
m_objs_array.clear();
} else {
std::vector<CPDF_Object*> new_objs_array;
- if (!AreObjectsAvailable(m_objs_array, FALSE, pHints, new_objs_array)) {
+ if (!AreObjectsAvailable(m_objs_array, false, pHints, new_objs_array)) {
m_objs_array = new_objs_array;
return DataNotAvailable;
}
}
m_objs_array.clear();
- m_bPageLoadedOK = TRUE;
+ m_bPageLoadedOK = true;
}
if (!m_bAnnotsLoad) {
if (!CheckPageAnnots(dwPage, pHints))
return DataNotAvailable;
- m_bAnnotsLoad = TRUE;
+ m_bAnnotsLoad = true;
}
if (m_pPageDict && !m_bNeedDownLoadResource) {
@@ -1700,35 +1698,35 @@ CPDF_DataAvail::DocAvailStatus CPDF_DataAvail::IsPageAvail(
if (m_bNeedDownLoadResource) {
if (!CheckResources(pHints))
return DataNotAvailable;
- 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(dwPage);
m_pagesLoadState.insert(dwPage);
return DataAvailable;
}
-FX_BOOL CPDF_DataAvail::CheckResources(DownloadHints* pHints) {
+bool CPDF_DataAvail::CheckResources(DownloadHints* pHints) {
if (m_objs_array.empty()) {
std::vector<CPDF_Object*> obj_array;
obj_array.push_back(m_pPageResource);
- if (!AreObjectsAvailable(obj_array, TRUE, pHints, m_objs_array))
- return FALSE;
+ if (!AreObjectsAvailable(obj_array, true, pHints, m_objs_array))
+ return false;
m_objs_array.clear();
- return TRUE;
+ return true;
}
std::vector<CPDF_Object*> new_objs_array;
- if (!AreObjectsAvailable(m_objs_array, FALSE, pHints, new_objs_array)) {
+ if (!AreObjectsAvailable(m_objs_array, false, pHints, new_objs_array)) {
m_objs_array = new_objs_array;
- return FALSE;
+ return false;
}
m_objs_array.clear();
- return TRUE;
+ return true;
}
void CPDF_DataAvail::GetLinearizedMainXRefInfo(FX_FILESIZE* pPos,
@@ -1805,11 +1803,11 @@ CPDF_DataAvail::DocFormStatus CPDF_DataAvail::IsFormAvail(
if (m_objs_array.empty())
m_objs_array.push_back(pAcroForm->GetDict());
- m_bLinearizedFormParamLoad = TRUE;
+ m_bLinearizedFormParamLoad = true;
}
std::vector<CPDF_Object*> new_objs_array;
- if (!AreObjectsAvailable(m_objs_array, FALSE, pHints, new_objs_array)) {
+ if (!AreObjectsAvailable(m_objs_array, false, pHints, new_objs_array)) {
m_objs_array = new_objs_array;
return FormNotAvailable;
}
diff --git a/core/fpdfapi/parser/cpdf_data_avail.h b/core/fpdfapi/parser/cpdf_data_avail.h
index 138fe1e3d8..0a8716a498 100644
--- a/core/fpdfapi/parser/cpdf_data_avail.h
+++ b/core/fpdfapi/parser/cpdf_data_avail.h
@@ -83,7 +83,7 @@ class CPDF_DataAvail final {
class FileAvail {
public:
virtual ~FileAvail();
- virtual FX_BOOL IsDataAvail(FX_FILESIZE offset, uint32_t size) = 0;
+ virtual bool IsDataAvail(FX_FILESIZE offset, uint32_t size) = 0;
};
class DownloadHints {
@@ -94,7 +94,7 @@ class CPDF_DataAvail final {
CPDF_DataAvail(FileAvail* pFileAvail,
IFX_SeekableReadStream* pFileRead,
- FX_BOOL bSupportHintTable);
+ bool bSupportHintTable);
~CPDF_DataAvail();
DocAvailStatus IsDocAvail(DownloadHints* pHints);
@@ -102,7 +102,7 @@ class CPDF_DataAvail final {
DocAvailStatus IsPageAvail(uint32_t dwPage, DownloadHints* pHints);
DocFormStatus IsFormAvail(DownloadHints* pHints);
DocLinearizationStatus IsLinearizedPDF();
- FX_BOOL IsLinearized();
+ bool IsLinearized();
void GetLinearizedMainXRefInfo(FX_FILESIZE* pPos, uint32_t* pSize);
IFX_SeekableReadStream* GetFileRead() const { return m_pFileRead; }
int GetPageCount() const;
@@ -126,71 +126,71 @@ class CPDF_DataAvail final {
static const int kMaxPageRecursionDepth = 1024;
uint32_t GetObjectSize(uint32_t objnum, FX_FILESIZE& offset);
- FX_BOOL AreObjectsAvailable(std::vector<CPDF_Object*>& obj_array,
- FX_BOOL bParsePage,
- DownloadHints* pHints,
- std::vector<CPDF_Object*>& ret_array);
- FX_BOOL CheckDocStatus(DownloadHints* pHints);
- FX_BOOL CheckHeader(DownloadHints* pHints);
- FX_BOOL CheckFirstPage(DownloadHints* pHints);
- FX_BOOL CheckHintTables(DownloadHints* pHints);
- FX_BOOL CheckEnd(DownloadHints* pHints);
- FX_BOOL CheckCrossRef(DownloadHints* pHints);
- FX_BOOL CheckCrossRefItem(DownloadHints* pHints);
- FX_BOOL CheckTrailer(DownloadHints* pHints);
- FX_BOOL CheckRoot(DownloadHints* pHints);
- FX_BOOL CheckInfo(DownloadHints* pHints);
- FX_BOOL CheckPages(DownloadHints* pHints);
- FX_BOOL CheckPage(DownloadHints* pHints);
- FX_BOOL CheckResources(DownloadHints* pHints);
- FX_BOOL CheckAnnots(DownloadHints* pHints);
- FX_BOOL CheckAcroForm(DownloadHints* pHints);
- FX_BOOL CheckAcroFormSubObject(DownloadHints* pHints);
- FX_BOOL CheckTrailerAppend(DownloadHints* pHints);
- FX_BOOL CheckPageStatus(DownloadHints* pHints);
- FX_BOOL CheckAllCrossRefStream(DownloadHints* pHints);
+ bool AreObjectsAvailable(std::vector<CPDF_Object*>& obj_array,
+ bool bParsePage,
+ DownloadHints* pHints,
+ std::vector<CPDF_Object*>& ret_array);
+ bool CheckDocStatus(DownloadHints* pHints);
+ bool CheckHeader(DownloadHints* pHints);
+ bool CheckFirstPage(DownloadHints* pHints);
+ bool CheckHintTables(DownloadHints* pHints);
+ bool CheckEnd(DownloadHints* pHints);
+ bool CheckCrossRef(DownloadHints* pHints);
+ bool CheckCrossRefItem(DownloadHints* pHints);
+ bool CheckTrailer(DownloadHints* pHints);
+ bool CheckRoot(DownloadHints* pHints);
+ bool CheckInfo(DownloadHints* pHints);
+ bool CheckPages(DownloadHints* pHints);
+ bool CheckPage(DownloadHints* pHints);
+ bool CheckResources(DownloadHints* pHints);
+ bool CheckAnnots(DownloadHints* pHints);
+ bool CheckAcroForm(DownloadHints* pHints);
+ bool CheckAcroFormSubObject(DownloadHints* pHints);
+ bool CheckTrailerAppend(DownloadHints* pHints);
+ bool CheckPageStatus(DownloadHints* pHints);
+ bool CheckAllCrossRefStream(DownloadHints* pHints);
int32_t CheckCrossRefStream(DownloadHints* pHints, FX_FILESIZE& xref_offset);
- FX_BOOL IsLinearizedFile(uint8_t* pData, uint32_t dwLen);
+ bool IsLinearizedFile(uint8_t* pData, uint32_t 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,
uint32_t objnum,
CPDF_IndirectObjectHolder* pObjList = nullptr);
CPDF_Object* GetObject(uint32_t objnum,
DownloadHints* pHints,
- FX_BOOL* pExistInFile);
- FX_BOOL GetPageKids(CPDF_Parser* pParser, CPDF_Object* pPages);
- FX_BOOL PreparePageItem();
- FX_BOOL LoadPages(DownloadHints* pHints);
- FX_BOOL LoadAllXref(DownloadHints* pHints);
- FX_BOOL LoadAllFile(DownloadHints* pHints);
+ bool* pExistInFile);
+ bool GetPageKids(CPDF_Parser* pParser, CPDF_Object* pPages);
+ bool PreparePageItem();
+ bool LoadPages(DownloadHints* pHints);
+ bool LoadAllXref(DownloadHints* pHints);
+ bool LoadAllFile(DownloadHints* pHints);
DocAvailStatus CheckLinearizedData(DownloadHints* pHints);
- FX_BOOL CheckPageAnnots(uint32_t dwPage, DownloadHints* pHints);
+ bool CheckPageAnnots(uint32_t dwPage, DownloadHints* pHints);
DocAvailStatus CheckLinearizedFirstPage(uint32_t dwPage,
DownloadHints* pHints);
- FX_BOOL HaveResourceAncestor(CPDF_Dictionary* pDict);
- FX_BOOL CheckPage(uint32_t dwPage, DownloadHints* pHints);
- FX_BOOL LoadDocPages(DownloadHints* pHints);
- FX_BOOL LoadDocPage(uint32_t dwPage, DownloadHints* pHints);
- FX_BOOL CheckPageNode(PageNode& pageNodes,
- int32_t iPage,
- int32_t& iCount,
- DownloadHints* pHints,
- int level);
- FX_BOOL CheckUnkownPageNode(uint32_t dwPageNo,
- PageNode* pPageNode,
- DownloadHints* pHints);
- FX_BOOL CheckArrayPageNode(uint32_t dwPageNo,
- PageNode* pPageNode,
- DownloadHints* pHints);
- FX_BOOL CheckPageCount(DownloadHints* pHints);
+ bool HaveResourceAncestor(CPDF_Dictionary* pDict);
+ bool CheckPage(uint32_t dwPage, DownloadHints* pHints);
+ bool LoadDocPages(DownloadHints* pHints);
+ bool LoadDocPage(uint32_t dwPage, DownloadHints* pHints);
+ bool CheckPageNode(PageNode& pageNodes,
+ int32_t iPage,
+ int32_t& iCount,
+ DownloadHints* pHints,
+ int level);
+ bool CheckUnkownPageNode(uint32_t dwPageNo,
+ PageNode* pPageNode,
+ DownloadHints* pHints);
+ bool CheckArrayPageNode(uint32_t dwPageNo,
+ PageNode* pPageNode,
+ DownloadHints* pHints);
+ bool CheckPageCount(DownloadHints* pHints);
bool IsFirstCheck(uint32_t dwPage);
void ResetFirstCheck(uint32_t dwPage);
- FX_BOOL IsDataAvail(FX_FILESIZE offset, uint32_t size, DownloadHints* pHints);
+ bool IsDataAvail(FX_FILESIZE offset, uint32_t size, DownloadHints* pHints);
FileAvail* const m_pFileAvail;
IFX_SeekableReadStream* const m_pFileRead;
@@ -201,7 +201,7 @@ class CPDF_DataAvail final {
uint32_t m_dwInfoObjNum;
CPDF_Object* m_pLinearized;
CPDF_Object* m_pTrailer;
- FX_BOOL m_bDocAvail;
+ bool m_bDocAvail;
FX_FILESIZE m_dwHeaderOffset;
FX_FILESIZE m_dwLastXRefOffset;
FX_FILESIZE m_dwXRefOffset;
@@ -220,36 +220,36 @@ class CPDF_DataAvail final {
CFX_ArrayTemplate<uint32_t> m_XRefStreamList;
CFX_ArrayTemplate<uint32_t> m_PageObjList;
uint32_t m_PagesObjNum;
- FX_BOOL m_bLinearized;
+ bool m_bLinearized;
uint32_t m_dwFirstPageNo;
- FX_BOOL m_bLinearedDataOK;
- FX_BOOL m_bMainXRefLoadTried;
- FX_BOOL m_bMainXRefLoadedOK;
- FX_BOOL m_bPagesTreeLoad;
- FX_BOOL m_bPagesLoad;
+ bool m_bLinearedDataOK;
+ bool m_bMainXRefLoadTried;
+ bool m_bMainXRefLoadedOK;
+ bool m_bPagesTreeLoad;
+ bool m_bPagesLoad;
CPDF_Parser* m_pCurrentParser;
FX_FILESIZE m_dwCurrentXRefSteam;
- FX_BOOL m_bAnnotsLoad;
- FX_BOOL m_bHaveAcroForm;
+ bool m_bAnnotsLoad;
+ bool m_bHaveAcroForm;
uint32_t m_dwAcroFormObjNum;
- FX_BOOL m_bAcroFormLoad;
+ bool m_bAcroFormLoad;
CPDF_Object* m_pAcroForm;
std::vector<CPDF_Object*> m_arrayAcroforms;
CPDF_Dictionary* m_pPageDict;
CPDF_Object* m_pPageResource;
- FX_BOOL m_bNeedDownLoadResource;
- FX_BOOL m_bPageLoadedOK;
- FX_BOOL m_bLinearizedFormParamLoad;
+ bool m_bNeedDownLoadResource;
+ bool m_bPageLoadedOK;
+ bool m_bLinearizedFormParamLoad;
std::vector<CPDF_Object*> m_PagesArray;
uint32_t m_dwEncryptObjNum;
FX_FILESIZE m_dwPrevXRefOffset;
- FX_BOOL m_bTotalLoadPageTree;
- FX_BOOL m_bCurPageDictLoadOK;
+ bool m_bTotalLoadPageTree;
+ bool m_bCurPageDictLoadOK;
PageNode m_pageNodes;
std::set<uint32_t> m_pageMapCheckState;
std::set<uint32_t> m_pagesLoadState;
std::unique_ptr<CPDF_HintTables> m_pHintTables;
- FX_BOOL m_bSupportHintTable;
+ bool m_bSupportHintTable;
};
#endif // CORE_FPDFAPI_PARSER_CPDF_DATA_AVAIL_H_
diff --git a/core/fpdfapi/parser/cpdf_dictionary.cpp b/core/fpdfapi/parser/cpdf_dictionary.cpp
index aab7422b3c..75cb1e859c 100644
--- a/core/fpdfapi/parser/cpdf_dictionary.cpp
+++ b/core/fpdfapi/parser/cpdf_dictionary.cpp
@@ -242,7 +242,7 @@ void CPDF_Dictionary::SetNameFor(const CFX_ByteString& key,
void CPDF_Dictionary::SetStringFor(const CFX_ByteString& key,
const CFX_ByteString& str) {
- SetFor(key, new CPDF_String(MaybeIntern(str), FALSE));
+ SetFor(key, new CPDF_String(MaybeIntern(str), false));
}
void CPDF_Dictionary::SetReferenceFor(const CFX_ByteString& key,
diff --git a/core/fpdfapi/parser/cpdf_document.cpp b/core/fpdfapi/parser/cpdf_document.cpp
index c5f64a790c..1794288e62 100644
--- a/core/fpdfapi/parser/cpdf_document.cpp
+++ b/core/fpdfapi/parser/cpdf_document.cpp
@@ -244,7 +244,7 @@ int InsertDeletePDFPage(CPDF_Document* pDoc,
CPDF_Dictionary* pPages,
int nPagesToGo,
CPDF_Dictionary* pPage,
- FX_BOOL bInsert,
+ bool bInsert,
std::set<CPDF_Dictionary*>* pVisited) {
CPDF_Array* pKidList = pPages->GetArrayFor("Kids");
if (!pKidList)
@@ -310,7 +310,7 @@ int InsertNewPage(CPDF_Document* pDoc,
pPageDict->SetReferenceFor("Parent", pDoc, pPages->GetObjNum());
} else {
std::set<CPDF_Dictionary*> stack = {pPages};
- if (InsertDeletePDFPage(pDoc, pPages, iPage, pPageDict, TRUE, &stack) < 0)
+ if (InsertDeletePDFPage(pDoc, pPages, iPage, pPageDict, true, &stack) < 0)
return -1;
}
pageList.InsertAt(iPage, pPageDict->GetObjNum());
@@ -727,7 +727,7 @@ void CPDF_Document::DeletePage(int iPage) {
return;
std::set<CPDF_Dictionary*> stack = {pPages};
- if (InsertDeletePDFPage(this, pPages, iPage, nullptr, FALSE, &stack) < 0)
+ if (InsertDeletePDFPage(this, pPages, iPage, nullptr, false, &stack) < 0)
return;
m_PageList.RemoveAt(iPage);
@@ -769,7 +769,7 @@ size_t CPDF_Document::CalculateEncodingDict(int charset,
CPDF_Dictionary* CPDF_Document::ProcessbCJK(
CPDF_Dictionary* pBaseDict,
int charset,
- FX_BOOL bVert,
+ bool bVert,
CFX_ByteString basefont,
std::function<void(FX_WCHAR, FX_WCHAR, CPDF_Array*)> Insert) {
CPDF_Dictionary* pFontDict = new CPDF_Dictionary(m_pByteStringPool);
@@ -833,7 +833,7 @@ CPDF_Dictionary* CPDF_Document::ProcessbCJK(
return pFontDict;
}
-CPDF_Font* CPDF_Document::AddFont(CFX_Font* pFont, int charset, FX_BOOL bVert) {
+CPDF_Font* CPDF_Document::AddFont(CFX_Font* pFont, int charset, bool bVert) {
if (!pFont)
return nullptr;
@@ -923,8 +923,8 @@ CPDF_Font* CPDF_Document::AddFont(CFX_Font* pFont, int charset, FX_BOOL bVert) {
#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
CPDF_Font* CPDF_Document::AddWindowsFont(LOGFONTW* pLogFont,
- FX_BOOL bVert,
- FX_BOOL bTranslateName) {
+ bool bVert,
+ bool bTranslateName) {
LOGFONTA lfa;
FXSYS_memcpy(&lfa, pLogFont, (char*)lfa.lfFaceName - (char*)&lfa);
CFX_ByteString face = CFX_ByteString::FromUnicode(pLogFont->lfFaceName);
@@ -936,8 +936,8 @@ CPDF_Font* CPDF_Document::AddWindowsFont(LOGFONTW* pLogFont,
}
CPDF_Font* CPDF_Document::AddWindowsFont(LOGFONTA* pLogFont,
- FX_BOOL bVert,
- FX_BOOL bTranslateName) {
+ bool bVert,
+ bool bTranslateName) {
pLogFont->lfHeight = -1000;
pLogFont->lfWidth = 0;
HGDIOBJ hFont = CreateFontIndirectA(pLogFont);
diff --git a/core/fpdfapi/parser/cpdf_document.h b/core/fpdfapi/parser/cpdf_document.h
index ea7bd328aa..d8e5cb977e 100644
--- a/core/fpdfapi/parser/cpdf_document.h
+++ b/core/fpdfapi/parser/cpdf_document.h
@@ -92,14 +92,14 @@ class CPDF_Document : public CPDF_IndirectObjectHolder {
CPDF_Dictionary* CreateNewPage(int iPage);
CPDF_Font* AddStandardFont(const FX_CHAR* font, CPDF_FontEncoding* pEncoding);
- CPDF_Font* AddFont(CFX_Font* pFont, int charset, FX_BOOL bVert);
+ CPDF_Font* AddFont(CFX_Font* pFont, int charset, bool bVert);
#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
CPDF_Font* AddWindowsFont(LOGFONTA* pLogFont,
- FX_BOOL bVert,
- FX_BOOL bTranslateName = FALSE);
+ bool bVert,
+ bool bTranslateName = false);
CPDF_Font* AddWindowsFont(LOGFONTW* pLogFont,
- FX_BOOL bVert,
- FX_BOOL bTranslateName = FALSE);
+ bool bVert,
+ bool bTranslateName = false);
#endif
protected:
@@ -121,7 +121,7 @@ class CPDF_Document : public CPDF_IndirectObjectHolder {
CPDF_Dictionary* ProcessbCJK(
CPDF_Dictionary* pBaseDict,
int charset,
- FX_BOOL bVert,
+ bool bVert,
CFX_ByteString basefont,
std::function<void(FX_WCHAR, FX_WCHAR, CPDF_Array*)> Insert);
diff --git a/core/fpdfapi/parser/cpdf_object.cpp b/core/fpdfapi/parser/cpdf_object.cpp
index 5c407336e2..cc410d10c8 100644
--- a/core/fpdfapi/parser/cpdf_object.cpp
+++ b/core/fpdfapi/parser/cpdf_object.cpp
@@ -63,7 +63,7 @@ CPDF_Dictionary* CPDF_Object::GetDict() const {
}
void CPDF_Object::SetString(const CFX_ByteString& str) {
- ASSERT(FALSE);
+ ASSERT(false);
}
bool CPDF_Object::IsArray() const {
diff --git a/core/fpdfapi/parser/cpdf_parser.cpp b/core/fpdfapi/parser/cpdf_parser.cpp
index c2748882cf..cff0f77b32 100644
--- a/core/fpdfapi/parser/cpdf_parser.cpp
+++ b/core/fpdfapi/parser/cpdf_parser.cpp
@@ -144,7 +144,7 @@ CPDF_Parser::Error CPDF_Parser::StartParse(IFX_SeekableReadStream* pFileAccess,
ASSERT(!m_bHasParsed);
m_bHasParsed = true;
- m_bXRefStream = FALSE;
+ m_bXRefStream = false;
m_LastXRefOffset = 0;
m_bOwnFileRead = true;
@@ -173,8 +173,8 @@ CPDF_Parser::Error CPDF_Parser::StartParse(IFX_SeekableReadStream* pFileAccess,
m_pSyntax->RestorePos(m_pSyntax->m_FileLen - m_pSyntax->m_HeaderOffset - 9);
m_pDocument = pDocument;
- FX_BOOL bXRefRebuilt = FALSE;
- if (m_pSyntax->SearchWord("startxref", TRUE, FALSE, 4096)) {
+ bool bXRefRebuilt = false;
+ if (m_pSyntax->SearchWord("startxref", true, false, 4096)) {
m_SortedOffset.insert(m_pSyntax->SavePos());
m_pSyntax->GetKeyword();
@@ -189,14 +189,14 @@ CPDF_Parser::Error CPDF_Parser::StartParse(IFX_SeekableReadStream* pFileAccess,
if (!RebuildCrossRef())
return FORMAT_ERROR;
- bXRefRebuilt = TRUE;
+ bXRefRebuilt = true;
m_LastXRefOffset = 0;
}
} else {
if (!RebuildCrossRef())
return FORMAT_ERROR;
- bXRefRebuilt = TRUE;
+ bXRefRebuilt = true;
}
Error eRet = SetEncryptHandler();
if (eRet != SUCCESS)
@@ -323,13 +323,13 @@ bool CPDF_Parser::VerifyCrossRefV4() {
return true;
}
-FX_BOOL CPDF_Parser::LoadAllCrossRefV4(FX_FILESIZE xrefpos) {
- if (!LoadCrossRefV4(xrefpos, 0, TRUE))
- return FALSE;
+bool CPDF_Parser::LoadAllCrossRefV4(FX_FILESIZE xrefpos) {
+ if (!LoadCrossRefV4(xrefpos, 0, true))
+ return false;
m_pTrailer = LoadTrailerV4();
if (!m_pTrailer)
- return FALSE;
+ return false;
int32_t xrefsize = GetDirectInteger(m_pTrailer, "Size");
if (xrefsize > 0 && xrefsize <= kMaxXRefSize)
@@ -349,18 +349,18 @@ FX_BOOL CPDF_Parser::LoadAllCrossRefV4(FX_FILESIZE xrefpos) {
while (xrefpos) {
// Check for circular references.
if (pdfium::ContainsKey(seen_xrefpos, xrefpos))
- return FALSE;
+ return false;
seen_xrefpos.insert(xrefpos);
// SLOW ...
CrossRefList.insert(CrossRefList.begin(), xrefpos);
- LoadCrossRefV4(xrefpos, 0, TRUE);
+ LoadCrossRefV4(xrefpos, 0, true);
std::unique_ptr<CPDF_Dictionary, ReleaseDeleter<CPDF_Dictionary>> pDict(
LoadTrailerV4());
if (!pDict)
- return FALSE;
+ return false;
xrefpos = GetDirectInteger(pDict.get(), "Prev");
@@ -371,26 +371,26 @@ FX_BOOL CPDF_Parser::LoadAllCrossRefV4(FX_FILESIZE xrefpos) {
}
for (size_t i = 0; i < CrossRefList.size(); ++i) {
- if (!LoadCrossRefV4(CrossRefList[i], XRefStreamList[i], FALSE))
- return FALSE;
+ if (!LoadCrossRefV4(CrossRefList[i], XRefStreamList[i], false))
+ return false;
if (i == 0 && !VerifyCrossRefV4())
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
-FX_BOOL CPDF_Parser::LoadLinearizedAllCrossRefV4(FX_FILESIZE xrefpos,
- uint32_t dwObjCount) {
+bool CPDF_Parser::LoadLinearizedAllCrossRefV4(FX_FILESIZE xrefpos,
+ uint32_t dwObjCount) {
if (!LoadLinearizedCrossRefV4(xrefpos, dwObjCount))
- return FALSE;
+ return false;
m_pTrailer = LoadTrailerV4();
if (!m_pTrailer)
- return FALSE;
+ return false;
int32_t xrefsize = GetDirectInteger(m_pTrailer, "Size");
if (xrefsize == 0)
- return FALSE;
+ return false;
std::vector<FX_FILESIZE> CrossRefList;
std::vector<FX_FILESIZE> XRefStreamList;
@@ -404,18 +404,18 @@ FX_BOOL CPDF_Parser::LoadLinearizedAllCrossRefV4(FX_FILESIZE xrefpos,
while (xrefpos) {
// Check for circular references.
if (pdfium::ContainsKey(seen_xrefpos, xrefpos))
- return FALSE;
+ return false;
seen_xrefpos.insert(xrefpos);
// SLOW ...
CrossRefList.insert(CrossRefList.begin(), xrefpos);
- LoadCrossRefV4(xrefpos, 0, TRUE);
+ LoadCrossRefV4(xrefpos, 0, true);
std::unique_ptr<CPDF_Dictionary, ReleaseDeleter<CPDF_Dictionary>> pDict(
LoadTrailerV4());
if (!pDict)
- return FALSE;
+ return false;
xrefpos = GetDirectInteger(pDict.get(), "Prev");
@@ -426,14 +426,14 @@ FX_BOOL CPDF_Parser::LoadLinearizedAllCrossRefV4(FX_FILESIZE xrefpos,
}
for (size_t i = 1; i < CrossRefList.size(); ++i) {
- if (!LoadCrossRefV4(CrossRefList[i], XRefStreamList[i], FALSE))
- return FALSE;
+ if (!LoadCrossRefV4(CrossRefList[i], XRefStreamList[i], false))
+ return false;
}
- return TRUE;
+ return true;
}
-FX_BOOL CPDF_Parser::LoadLinearizedCrossRefV4(FX_FILESIZE pos,
- uint32_t dwObjCount) {
+bool CPDF_Parser::LoadLinearizedCrossRefV4(FX_FILESIZE pos,
+ uint32_t dwObjCount) {
FX_FILESIZE dwStartPos = pos - m_pSyntax->m_HeaderOffset;
m_pSyntax->RestorePos(dwStartPos);
@@ -452,11 +452,11 @@ FX_BOOL CPDF_Parser::LoadLinearizedCrossRefV4(FX_FILESIZE pos,
int32_t block_size = block == nBlocks - 1 ? count % 1024 : 1024;
uint32_t dwReadSize = block_size * recordsize;
if ((FX_FILESIZE)(dwStartPos + dwReadSize) > m_pSyntax->m_FileLen)
- return FALSE;
+ return false;
if (!m_pSyntax->ReadBlock(reinterpret_cast<uint8_t*>(buf.data()),
dwReadSize)) {
- return FALSE;
+ return false;
}
for (int32_t i = 0; i < block_size; i++) {
@@ -470,7 +470,7 @@ FX_BOOL CPDF_Parser::LoadLinearizedCrossRefV4(FX_FILESIZE pos,
if (offset == 0) {
for (int32_t c = 0; c < 10; c++) {
if (!std::isdigit(pEntry[c]))
- return FALSE;
+ return false;
}
}
@@ -488,12 +488,12 @@ FX_BOOL CPDF_Parser::LoadLinearizedCrossRefV4(FX_FILESIZE pos,
}
}
m_pSyntax->RestorePos(SavedPos + count * recordsize);
- return TRUE;
+ return true;
}
bool CPDF_Parser::LoadCrossRefV4(FX_FILESIZE pos,
FX_FILESIZE streampos,
- FX_BOOL bSkip) {
+ bool bSkip) {
m_pSyntax->RestorePos(pos);
if (m_pSyntax->GetKeyword() != "xref")
return false;
@@ -565,29 +565,29 @@ bool CPDF_Parser::LoadCrossRefV4(FX_FILESIZE pos,
}
m_pSyntax->RestorePos(SavedPos + count * recordsize);
}
- return !streampos || LoadCrossRefV5(&streampos, FALSE);
+ return !streampos || LoadCrossRefV5(&streampos, false);
}
-FX_BOOL CPDF_Parser::LoadAllCrossRefV5(FX_FILESIZE xrefpos) {
- if (!LoadCrossRefV5(&xrefpos, TRUE))
- return FALSE;
+bool CPDF_Parser::LoadAllCrossRefV5(FX_FILESIZE xrefpos) {
+ if (!LoadCrossRefV5(&xrefpos, true))
+ return false;
std::set<FX_FILESIZE> seen_xrefpos;
while (xrefpos) {
seen_xrefpos.insert(xrefpos);
- if (!LoadCrossRefV5(&xrefpos, FALSE))
- return FALSE;
+ if (!LoadCrossRefV5(&xrefpos, false))
+ return false;
// Check for circular references.
if (pdfium::ContainsKey(seen_xrefpos, xrefpos))
- return FALSE;
+ return false;
}
m_ObjectStreamMap.clear();
- m_bXRefStream = TRUE;
- return TRUE;
+ m_bXRefStream = true;
+ return true;
}
-FX_BOOL CPDF_Parser::RebuildCrossRef() {
+bool CPDF_Parser::RebuildCrossRef() {
m_ObjectInfo.clear();
m_SortedOffset.clear();
if (m_pTrailer) {
@@ -954,35 +954,35 @@ FX_BOOL CPDF_Parser::RebuildCrossRef() {
return m_pTrailer && !m_ObjectInfo.empty();
}
-FX_BOOL CPDF_Parser::LoadCrossRefV5(FX_FILESIZE* pos, FX_BOOL bMainXRef) {
+bool CPDF_Parser::LoadCrossRefV5(FX_FILESIZE* pos, bool bMainXRef) {
std::unique_ptr<CPDF_Object> pObject(
ParseIndirectObjectAt(m_pDocument, *pos, 0));
if (!pObject)
- return FALSE;
+ return false;
CPDF_Object* pUnownedObject = pObject.get();
if (m_pDocument) {
CPDF_Dictionary* pRootDict = m_pDocument->GetRoot();
if (pRootDict && pRootDict->GetObjNum() == pObject->m_ObjNum)
- return FALSE;
+ return false;
// Takes ownership of object (std::move someday).
uint32_t objnum = pObject->m_ObjNum;
if (!m_pDocument->ReplaceIndirectObjectIfHigherGeneration(
objnum, pObject.release())) {
- return FALSE;
+ return false;
}
}
CPDF_Stream* pStream = pUnownedObject->AsStream();
if (!pStream)
- return FALSE;
+ return false;
CPDF_Dictionary* pDict = pStream->GetDict();
*pos = pDict->GetIntegerFor("Prev");
int32_t size = pDict->GetIntegerFor("Size");
if (size < 0)
- return FALSE;
+ return false;
CPDF_Dictionary* pNewTrailer = ToDictionary(pDict->Clone());
if (bMainXRef) {
@@ -1015,7 +1015,7 @@ FX_BOOL CPDF_Parser::LoadCrossRefV5(FX_FILESIZE* pos, FX_BOOL bMainXRef) {
pArray = pDict->GetArrayFor("W");
if (!pArray)
- return FALSE;
+ return false;
CFX_ArrayTemplate<uint32_t> WidthArray;
FX_SAFE_UINT32 dwAccWidth = 0;
@@ -1025,7 +1025,7 @@ FX_BOOL CPDF_Parser::LoadCrossRefV5(FX_FILESIZE* pos, FX_BOOL bMainXRef) {
}
if (!dwAccWidth.IsValid() || WidthArray.GetSize() < 3)
- return FALSE;
+ return false;
uint32_t totalWidth = dwAccWidth.ValueOrDie();
CPDF_StreamAcc acc;
@@ -1086,14 +1086,14 @@ FX_BOOL CPDF_Parser::LoadCrossRefV5(FX_FILESIZE* pos, FX_BOOL bMainXRef) {
m_SortedOffset.insert(offset);
} else {
if (offset < 0 || !IsValidObjectNumber(offset))
- return FALSE;
+ return false;
m_ObjectInfo[offset].type = 255;
}
}
}
segindex += count;
}
- return TRUE;
+ return true;
}
CPDF_Array* CPDF_Parser::GetIDArray() {
@@ -1145,7 +1145,7 @@ CPDF_Object* CPDF_Parser::ParseIndirectObject(
return nullptr;
ScopedFileStream file(FX_CreateMemoryStream(
- (uint8_t*)pObjStream->GetData(), (size_t)pObjStream->GetSize(), FALSE));
+ (uint8_t*)pObjStream->GetData(), (size_t)pObjStream->GetSize(), false));
CPDF_SyntaxParser syntax;
syntax.InitParser(file.get(), 0);
const int32_t offset = GetStreamFirst(pObjStream);
@@ -1224,7 +1224,7 @@ void CPDF_Parser::GetIndirectBinary(uint32_t objnum,
const uint8_t* pData = pObjStream->GetData();
uint32_t totalsize = pObjStream->GetSize();
ScopedFileStream file(
- FX_CreateMemoryStream((uint8_t*)pData, (size_t)totalsize, FALSE));
+ FX_CreateMemoryStream((uint8_t*)pData, (size_t)totalsize, false));
CPDF_SyntaxParser syntax;
syntax.InitParser(file.get(), 0);
@@ -1290,16 +1290,16 @@ void CPDF_Parser::GetIndirectBinary(uint32_t objnum,
}
FX_FILESIZE nextoff = *it;
- FX_BOOL bNextOffValid = FALSE;
+ bool bNextOffValid = false;
if (nextoff != pos) {
m_pSyntax->RestorePos(nextoff);
word = m_pSyntax->GetNextWord(&bIsNumber);
if (word == "xref") {
- bNextOffValid = TRUE;
+ bNextOffValid = true;
} else if (bIsNumber) {
word = m_pSyntax->GetNextWord(&bIsNumber);
if (bIsNumber && m_pSyntax->GetKeyword() == "obj") {
- bNextOffValid = TRUE;
+ bNextOffValid = true;
}
}
}
@@ -1438,8 +1438,8 @@ uint32_t CPDF_Parser::GetPermissions() const {
return dwPermission;
}
-FX_BOOL CPDF_Parser::IsLinearizedFile(IFX_SeekableReadStream* pFileAccess,
- uint32_t offset) {
+bool CPDF_Parser::IsLinearizedFile(IFX_SeekableReadStream* pFileAccess,
+ uint32_t offset) {
m_pSyntax->InitParser(pFileAccess, offset);
m_pSyntax->RestorePos(m_pSyntax->m_HeaderOffset + 9);
@@ -1447,22 +1447,22 @@ FX_BOOL CPDF_Parser::IsLinearizedFile(IFX_SeekableReadStream* pFileAccess,
bool bIsNumber;
CFX_ByteString word = m_pSyntax->GetNextWord(&bIsNumber);
if (!bIsNumber)
- return FALSE;
+ return false;
uint32_t objnum = FXSYS_atoui(word.c_str());
word = m_pSyntax->GetNextWord(&bIsNumber);
if (!bIsNumber)
- return FALSE;
+ return false;
uint32_t gennum = FXSYS_atoui(word.c_str());
if (m_pSyntax->GetKeyword() != "obj") {
m_pSyntax->RestorePos(SavedPos);
- return FALSE;
+ return false;
}
m_pLinearized = m_pSyntax->GetObject(nullptr, objnum, gennum, true);
if (!m_pLinearized)
- return FALSE;
+ return false;
CPDF_Dictionary* pDict = m_pLinearized->GetDict();
if (pDict && pDict->GetObjectFor("Linearized")) {
@@ -1472,11 +1472,11 @@ FX_BOOL CPDF_Parser::IsLinearizedFile(IFX_SeekableReadStream* pFileAccess,
if (!pLen) {
m_pLinearized->Release();
m_pLinearized = nullptr;
- return FALSE;
+ return false;
}
if (pLen->GetInteger() != (int)pFileAccess->GetSize())
- return FALSE;
+ return false;
if (CPDF_Number* pNo = ToNumber(pDict->GetObjectFor("P")))
m_dwFirstPageNo = pNo->GetInteger();
@@ -1484,11 +1484,11 @@ FX_BOOL CPDF_Parser::IsLinearizedFile(IFX_SeekableReadStream* pFileAccess,
if (CPDF_Number* pTable = ToNumber(pDict->GetObjectFor("T")))
m_LastXRefOffset = pTable->GetInteger();
- return TRUE;
+ return true;
}
m_pLinearized->Release();
m_pLinearized = nullptr;
- return FALSE;
+ return false;
}
CPDF_Parser::Error CPDF_Parser::StartLinearizedParse(
@@ -1496,7 +1496,7 @@ CPDF_Parser::Error CPDF_Parser::StartLinearizedParse(
CPDF_Document* pDocument) {
ASSERT(!m_bHasParsed);
- m_bXRefStream = FALSE;
+ m_bXRefStream = false;
m_LastXRefOffset = 0;
m_bOwnFileRead = true;
@@ -1513,13 +1513,13 @@ CPDF_Parser::Error CPDF_Parser::StartLinearizedParse(
FX_FILESIZE dwFirstXRefOffset = m_pSyntax->SavePos();
- FX_BOOL bXRefRebuilt = FALSE;
- FX_BOOL bLoadV4 = LoadCrossRefV4(dwFirstXRefOffset, 0, FALSE);
- if (!bLoadV4 && !LoadCrossRefV5(&dwFirstXRefOffset, TRUE)) {
+ bool bXRefRebuilt = false;
+ bool bLoadV4 = LoadCrossRefV4(dwFirstXRefOffset, 0, false);
+ if (!bLoadV4 && !LoadCrossRefV5(&dwFirstXRefOffset, true)) {
if (!RebuildCrossRef())
return FORMAT_ERROR;
- bXRefRebuilt = TRUE;
+ bXRefRebuilt = true;
m_LastXRefOffset = 0;
}
@@ -1573,23 +1573,23 @@ CPDF_Parser::Error CPDF_Parser::StartLinearizedParse(
return SUCCESS;
}
-FX_BOOL CPDF_Parser::LoadLinearizedAllCrossRefV5(FX_FILESIZE xrefpos) {
- if (!LoadCrossRefV5(&xrefpos, FALSE))
- return FALSE;
+bool CPDF_Parser::LoadLinearizedAllCrossRefV5(FX_FILESIZE xrefpos) {
+ if (!LoadCrossRefV5(&xrefpos, false))
+ return false;
std::set<FX_FILESIZE> seen_xrefpos;
while (xrefpos) {
seen_xrefpos.insert(xrefpos);
- if (!LoadCrossRefV5(&xrefpos, FALSE))
- return FALSE;
+ if (!LoadCrossRefV5(&xrefpos, false))
+ return false;
// Check for circular references.
if (pdfium::ContainsKey(seen_xrefpos, xrefpos))
- return FALSE;
+ return false;
}
m_ObjectStreamMap.clear();
- m_bXRefStream = TRUE;
- return TRUE;
+ m_bXRefStream = true;
+ return true;
}
CPDF_Parser::Error CPDF_Parser::LoadLinearizedMainXRefTable() {
diff --git a/core/fpdfapi/parser/cpdf_parser.h b/core/fpdfapi/parser/cpdf_parser.h
index 887857628a..3be157a1a2 100644
--- a/core/fpdfapi/parser/cpdf_parser.h
+++ b/core/fpdfapi/parser/cpdf_parser.h
@@ -76,7 +76,7 @@ class CPDF_Parser {
void GetIndirectBinary(uint32_t objnum, uint8_t*& pBuffer, uint32_t& size);
int GetFileVersion() const { return m_FileVersion; }
- FX_BOOL IsXRefStream() const { return m_bXRefStream; }
+ bool IsXRefStream() const { return m_bXRefStream; }
CPDF_Object* ParseIndirectObjectAt(CPDF_IndirectObjectHolder* pObjList,
FX_FILESIZE pos,
@@ -102,8 +102,8 @@ class CPDF_Parser {
std::unique_ptr<CPDF_SyntaxParser> m_pSyntax;
std::map<uint32_t, ObjectInfo> m_ObjectInfo;
- bool LoadCrossRefV4(FX_FILESIZE pos, FX_FILESIZE streampos, FX_BOOL bSkip);
- FX_BOOL RebuildCrossRef();
+ bool LoadCrossRefV4(FX_FILESIZE pos, FX_FILESIZE streampos, bool bSkip);
+ bool RebuildCrossRef();
private:
friend class CPDF_DataAvail;
@@ -126,19 +126,18 @@ class CPDF_Parser {
};
CPDF_Object* ParseDirect(CPDF_Object* pObj);
- FX_BOOL LoadAllCrossRefV4(FX_FILESIZE pos);
- FX_BOOL LoadAllCrossRefV5(FX_FILESIZE pos);
- FX_BOOL LoadCrossRefV5(FX_FILESIZE* pos, FX_BOOL bMainXRef);
+ bool LoadAllCrossRefV4(FX_FILESIZE pos);
+ bool LoadAllCrossRefV5(FX_FILESIZE pos);
+ bool LoadCrossRefV5(FX_FILESIZE* pos, bool bMainXRef);
CPDF_Dictionary* LoadTrailerV4();
Error SetEncryptHandler();
void ReleaseEncryptHandler();
- FX_BOOL LoadLinearizedAllCrossRefV4(FX_FILESIZE pos, uint32_t dwObjCount);
- FX_BOOL LoadLinearizedCrossRefV4(FX_FILESIZE pos, uint32_t dwObjCount);
- FX_BOOL LoadLinearizedAllCrossRefV5(FX_FILESIZE pos);
+ bool LoadLinearizedAllCrossRefV4(FX_FILESIZE pos, uint32_t dwObjCount);
+ bool LoadLinearizedCrossRefV4(FX_FILESIZE pos, uint32_t dwObjCount);
+ bool LoadLinearizedAllCrossRefV5(FX_FILESIZE pos);
Error LoadLinearizedMainXRefTable();
CPDF_StreamAcc* GetObjectStream(uint32_t number);
- FX_BOOL IsLinearizedFile(IFX_SeekableReadStream* pFileAccess,
- uint32_t offset);
+ bool IsLinearizedFile(IFX_SeekableReadStream* pFileAccess, uint32_t offset);
void SetEncryptDictionary(CPDF_Dictionary* pDict);
void ShrinkObjectMap(uint32_t size);
// A simple check whether the cross reference table matches with
@@ -152,7 +151,7 @@ class CPDF_Parser {
CPDF_Dictionary* m_pTrailer;
CPDF_Dictionary* m_pEncryptDict;
FX_FILESIZE m_LastXRefOffset;
- FX_BOOL m_bXRefStream;
+ bool m_bXRefStream;
std::unique_ptr<CPDF_SecurityHandler> m_pSecurityHandler;
CFX_ByteString m_Password;
std::set<FX_FILESIZE> m_SortedOffset;
diff --git a/core/fpdfapi/parser/cpdf_parser_unittest.cpp b/core/fpdfapi/parser/cpdf_parser_unittest.cpp
index 239332784e..7148c54f30 100644
--- a/core/fpdfapi/parser/cpdf_parser_unittest.cpp
+++ b/core/fpdfapi/parser/cpdf_parser_unittest.cpp
@@ -115,7 +115,7 @@ TEST(cpdf_parser, LoadCrossRefV4) {
ASSERT_TRUE(
parser.InitTestFromBuffer(xref_table, FX_ArraySize(xref_table)));
- ASSERT_TRUE(parser.LoadCrossRefV4(0, 0, FALSE));
+ ASSERT_TRUE(parser.LoadCrossRefV4(0, 0, false));
const FX_FILESIZE offsets[] = {0, 17, 81, 0, 331, 409};
const uint8_t types[] = {0, 1, 1, 0, 1, 1};
for (size_t i = 0; i < FX_ArraySize(offsets); ++i) {
@@ -140,7 +140,7 @@ TEST(cpdf_parser, LoadCrossRefV4) {
ASSERT_TRUE(
parser.InitTestFromBuffer(xref_table, FX_ArraySize(xref_table)));
- ASSERT_TRUE(parser.LoadCrossRefV4(0, 0, FALSE));
+ ASSERT_TRUE(parser.LoadCrossRefV4(0, 0, false));
const FX_FILESIZE offsets[] = {0, 0, 0, 25325, 0, 0, 0,
0, 25518, 25635, 0, 0, 25777};
const uint8_t types[] = {0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1};
@@ -166,7 +166,7 @@ TEST(cpdf_parser, LoadCrossRefV4) {
ASSERT_TRUE(
parser.InitTestFromBuffer(xref_table, FX_ArraySize(xref_table)));
- ASSERT_TRUE(parser.LoadCrossRefV4(0, 0, FALSE));
+ ASSERT_TRUE(parser.LoadCrossRefV4(0, 0, false));
const FX_FILESIZE offsets[] = {0, 0, 0, 25325, 0, 0, 0,
0, 0, 25635, 0, 0, 25777};
const uint8_t types[] = {0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1};
@@ -191,7 +191,7 @@ TEST(cpdf_parser, LoadCrossRefV4) {
ASSERT_TRUE(
parser.InitTestFromBuffer(xref_table, FX_ArraySize(xref_table)));
- ASSERT_TRUE(parser.LoadCrossRefV4(0, 0, FALSE));
+ ASSERT_TRUE(parser.LoadCrossRefV4(0, 0, false));
const FX_FILESIZE offsets[] = {0, 23, 0, 0, 0, 45, 179};
const uint8_t types[] = {0, 1, 0, 0, 0, 1, 1};
for (size_t i = 0; i < FX_ArraySize(offsets); ++i) {
diff --git a/core/fpdfapi/parser/cpdf_security_handler.cpp b/core/fpdfapi/parser/cpdf_security_handler.cpp
index 80a1f08f94..bebda4ded8 100644
--- a/core/fpdfapi/parser/cpdf_security_handler.cpp
+++ b/core/fpdfapi/parser/cpdf_security_handler.cpp
@@ -27,7 +27,7 @@ void CalcEncryptKey(CPDF_Dictionary* pEncrypt,
uint32_t pass_size,
uint8_t* key,
int keylen,
- FX_BOOL bIgnoreMeta,
+ bool bIgnoreMeta,
CPDF_Array* pIdArray) {
int revision = pEncrypt->GetIntegerFor("R");
uint8_t passcode[32];
@@ -83,27 +83,27 @@ CPDF_CryptoHandler* CPDF_SecurityHandler::CreateCryptoHandler() {
return new CPDF_CryptoHandler;
}
-FX_BOOL CPDF_SecurityHandler::OnInit(CPDF_Parser* pParser,
- CPDF_Dictionary* pEncryptDict) {
+bool CPDF_SecurityHandler::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_SecurityHandler::CheckSecurity(int32_t key_len) {
+bool CPDF_SecurityHandler::CheckSecurity(int32_t key_len) {
CFX_ByteString password = m_pParser->GetPassword();
if (!password.IsEmpty() &&
- CheckPassword(password.raw_str(), password.GetLength(), TRUE,
+ CheckPassword(password.raw_str(), password.GetLength(), true,
m_EncryptKey, key_len)) {
m_bOwnerUnlocked = true;
- return TRUE;
+ return true;
}
- return CheckPassword(password.raw_str(), password.GetLength(), FALSE,
+ return CheckPassword(password.raw_str(), password.GetLength(), false,
m_EncryptKey, key_len);
}
@@ -111,24 +111,24 @@ uint32_t CPDF_SecurityHandler::GetPermissions() {
return m_bOwnerUnlocked ? 0xFFFFFFFF : m_Permissions;
}
-static FX_BOOL LoadCryptInfo(CPDF_Dictionary* pEncryptDict,
- const CFX_ByteString& name,
- int& cipher,
- int& keylen) {
+static bool LoadCryptInfo(CPDF_Dictionary* pEncryptDict,
+ const CFX_ByteString& name,
+ int& cipher,
+ int& keylen) {
int Version = pEncryptDict->GetIntegerFor("V");
cipher = FXCIPHER_RC4;
keylen = 0;
if (Version >= 4) {
CPDF_Dictionary* pCryptFilters = pEncryptDict->GetDictFor("CF");
if (!pCryptFilters) {
- return FALSE;
+ return false;
}
if (name == "Identity") {
cipher = FXCIPHER_NONE;
} else {
CPDF_Dictionary* pDefFilter = pCryptFilters->GetDictFor(name);
if (!pDefFilter) {
- return FALSE;
+ return false;
}
int nKeyBits = 0;
if (Version == 4) {
@@ -152,12 +152,12 @@ static FX_BOOL LoadCryptInfo(CPDF_Dictionary* pEncryptDict,
keylen = Version > 1 ? pEncryptDict->GetIntegerFor("Length", 40) / 8 : 5;
}
if (keylen > 32 || keylen < 0) {
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
-FX_BOOL CPDF_SecurityHandler::LoadDict(CPDF_Dictionary* pEncryptDict) {
+bool CPDF_SecurityHandler::LoadDict(CPDF_Dictionary* pEncryptDict) {
m_pEncryptDict = pEncryptDict;
m_Version = pEncryptDict->GetIntegerFor("V");
m_Revision = pEncryptDict->GetIntegerFor("R");
@@ -168,15 +168,15 @@ FX_BOOL CPDF_SecurityHandler::LoadDict(CPDF_Dictionary* pEncryptDict) {
CFX_ByteString stmf_name = pEncryptDict->GetStringFor("StmF");
CFX_ByteString strf_name = pEncryptDict->GetStringFor("StrF");
if (stmf_name != strf_name)
- return FALSE;
+ return false;
return LoadCryptInfo(pEncryptDict, strf_name, m_Cipher, m_KeyLen);
}
-FX_BOOL CPDF_SecurityHandler::LoadDict(CPDF_Dictionary* pEncryptDict,
- uint32_t type,
- int& cipher,
- int& key_len) {
+bool CPDF_SecurityHandler::LoadDict(CPDF_Dictionary* pEncryptDict,
+ uint32_t type,
+ int& cipher,
+ int& key_len) {
m_pEncryptDict = pEncryptDict;
m_Version = pEncryptDict->GetIntegerFor("V");
m_Revision = pEncryptDict->GetIntegerFor("R");
@@ -188,23 +188,23 @@ FX_BOOL CPDF_SecurityHandler::LoadDict(CPDF_Dictionary* pEncryptDict,
stmf_name = pEncryptDict->GetStringFor("StmF");
strf_name = pEncryptDict->GetStringFor("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;
}
-FX_BOOL CPDF_SecurityHandler::GetCryptInfo(int& cipher,
- const uint8_t*& buffer,
- int& keylen) {
+bool CPDF_SecurityHandler::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) \
{ \
@@ -263,7 +263,7 @@ void Revision6_Hash(const uint8_t* password,
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;
@@ -299,19 +299,19 @@ void Revision6_Hash(const uint8_t* password,
FXSYS_memcpy(hash, input, 32);
}
}
-FX_BOOL CPDF_SecurityHandler::AES256_CheckPassword(const uint8_t* password,
- uint32_t size,
- FX_BOOL bOwner,
- uint8_t* key) {
+bool CPDF_SecurityHandler::AES256_CheckPassword(const uint8_t* password,
+ uint32_t size,
+ bool bOwner,
+ uint8_t* key) {
CFX_ByteString okey =
m_pEncryptDict ? m_pEncryptDict->GetStringFor("O") : CFX_ByteString();
if (okey.GetLength() < 48) {
- return FALSE;
+ return false;
}
CFX_ByteString ukey =
m_pEncryptDict ? m_pEncryptDict->GetStringFor("U") : CFX_ByteString();
if (ukey.GetLength() < 48) {
- return FALSE;
+ return false;
}
const uint8_t* pkey = (bOwner ? okey : ukey).raw_str();
uint8_t sha[128];
@@ -329,10 +329,10 @@ FX_BOOL CPDF_SecurityHandler::AES256_CheckPassword(const uint8_t* password,
CRYPT_SHA256Finish(sha, digest);
}
if (FXSYS_memcmp(digest, pkey, 32) != 0) {
- return FALSE;
+ return false;
}
if (!key) {
- return TRUE;
+ return true;
}
if (m_Revision >= 6) {
Revision6_Hash(password, size, (const uint8_t*)pkey + 40,
@@ -350,19 +350,19 @@ FX_BOOL CPDF_SecurityHandler::AES256_CheckPassword(const uint8_t* password,
? m_pEncryptDict->GetStringFor(bOwner ? "OE" : "UE")
: CFX_ByteString();
if (ekey.GetLength() < 32)
- return FALSE;
+ return false;
std::vector<uint8_t> aes(2048);
- CRYPT_AESSetKey(aes.data(), 16, digest, 32, FALSE);
+ CRYPT_AESSetKey(aes.data(), 16, digest, 32, false);
uint8_t iv[16];
FXSYS_memset(iv, 0, 16);
CRYPT_AESSetIV(aes.data(), iv);
CRYPT_AESDecrypt(aes.data(), key, ekey.raw_str(), 32);
- CRYPT_AESSetKey(aes.data(), 16, key, 32, FALSE);
+ CRYPT_AESSetKey(aes.data(), 16, key, 32, false);
CRYPT_AESSetIV(aes.data(), iv);
CFX_ByteString perms = m_pEncryptDict->GetStringFor("Perms");
if (perms.IsEmpty())
- return FALSE;
+ return false;
uint8_t perms_buf[16];
FXSYS_memset(perms_buf, 0, sizeof(perms_buf));
@@ -372,22 +372,22 @@ FX_BOOL CPDF_SecurityHandler::AES256_CheckPassword(const uint8_t* password,
uint8_t buf[16];
CRYPT_AESDecrypt(aes.data(), buf, perms_buf, 16);
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;
bool encrypted = IsMetadataEncrypted();
if ((buf[8] == 'T' && !encrypted) || (buf[8] == 'F' && encrypted))
- return FALSE;
- return TRUE;
+ return false;
+ return true;
}
-FX_BOOL CPDF_SecurityHandler::CheckPassword(const uint8_t* password,
- uint32_t size,
- FX_BOOL bOwner,
- uint8_t* key,
- int32_t key_len) {
+bool CPDF_SecurityHandler::CheckPassword(const uint8_t* password,
+ uint32_t size,
+ bool bOwner,
+ uint8_t* key,
+ int32_t key_len) {
if (m_Revision >= 5)
return AES256_CheckPassword(password, size, bOwner, key);
@@ -398,20 +398,20 @@ FX_BOOL CPDF_SecurityHandler::CheckPassword(const uint8_t* password,
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_SecurityHandler::CheckUserPassword(const uint8_t* password,
- uint32_t pass_size,
- FX_BOOL bIgnoreEncryptMeta,
- uint8_t* key,
- int32_t key_len) {
+bool CPDF_SecurityHandler::CheckUserPassword(const uint8_t* password,
+ uint32_t 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->GetStringFor("U") : CFX_ByteString();
if (ukey.GetLength() < 16) {
- return FALSE;
+ return false;
}
uint8_t ukeybuf[32];
if (m_Revision == 2) {
@@ -443,9 +443,9 @@ FX_BOOL CPDF_SecurityHandler::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_SecurityHandler::GetUserPassword(const uint8_t* owner_pass,
uint32_t pass_size,
@@ -493,16 +493,16 @@ CFX_ByteString CPDF_SecurityHandler::GetUserPassword(const uint8_t* owner_pass,
}
return CFX_ByteString(okeybuf, len);
}
-FX_BOOL CPDF_SecurityHandler::CheckOwnerPassword(const uint8_t* password,
- uint32_t pass_size,
- uint8_t* key,
- int32_t key_len) {
+bool CPDF_SecurityHandler::CheckOwnerPassword(const uint8_t* password,
+ uint32_t pass_size,
+ uint8_t* key,
+ int32_t key_len) {
CFX_ByteString user_pass = GetUserPassword(password, pass_size, key_len);
- if (CheckUserPassword(user_pass.raw_str(), user_pass.GetLength(), FALSE, key,
+ if (CheckUserPassword(user_pass.raw_str(), user_pass.GetLength(), false, key,
key_len)) {
- return TRUE;
+ return true;
}
- return CheckUserPassword(user_pass.raw_str(), user_pass.GetLength(), TRUE,
+ return CheckUserPassword(user_pass.raw_str(), user_pass.GetLength(), true,
key, key_len);
}
@@ -516,7 +516,7 @@ void CPDF_SecurityHandler::OnCreate(CPDF_Dictionary* pEncryptDict,
uint32_t user_size,
const uint8_t* owner_pass,
uint32_t owner_size,
- FX_BOOL bDefault,
+ bool bDefault,
uint32_t type) {
int cipher = 0, key_len = 0;
if (!LoadDict(pEncryptDict, type, cipher, key_len)) {
@@ -534,9 +534,9 @@ void CPDF_SecurityHandler::OnCreate(CPDF_Dictionary* pEncryptDict,
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,
+ AES256_SetPassword(pEncryptDict, owner_pass, owner_size, true,
m_EncryptKey);
AES256_SetPerms(pEncryptDict, m_Permissions,
pEncryptDict->GetBooleanFor("EncryptMetadata", true),
@@ -573,7 +573,7 @@ void CPDF_SecurityHandler::OnCreate(CPDF_Dictionary* pEncryptDict,
pEncryptDict->SetStringFor("O", CFX_ByteString(passcode, 32));
}
CalcEncryptKey(m_pEncryptDict, (uint8_t*)user_pass, user_size, m_EncryptKey,
- key_len, FALSE, pIdArray);
+ key_len, false, pIdArray);
if (m_Revision < 3) {
uint8_t tempbuf[32];
FXSYS_memcpy(tempbuf, defpasscode, 32);
@@ -609,20 +609,20 @@ void CPDF_SecurityHandler::OnCreate(CPDF_Dictionary* pEncryptDict,
uint32_t owner_size,
uint32_t type) {
OnCreate(pEncryptDict, pIdArray, user_pass, user_size, owner_pass, owner_size,
- TRUE, type);
+ true, type);
}
void CPDF_SecurityHandler::OnCreate(CPDF_Dictionary* pEncryptDict,
CPDF_Array* pIdArray,
const uint8_t* user_pass,
uint32_t user_size,
uint32_t type) {
- OnCreate(pEncryptDict, pIdArray, user_pass, user_size, nullptr, 0, FALSE,
+ OnCreate(pEncryptDict, pIdArray, user_pass, user_size, nullptr, 0, false,
type);
}
void CPDF_SecurityHandler::AES256_SetPassword(CPDF_Dictionary* pEncryptDict,
const uint8_t* password,
uint32_t size,
- FX_BOOL bOwner,
+ bool bOwner,
const uint8_t* key) {
uint8_t sha[128];
CRYPT_SHA1Start(sha);
@@ -659,7 +659,7 @@ void CPDF_SecurityHandler::AES256_SetPassword(CPDF_Dictionary* pEncryptDict,
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);
@@ -669,7 +669,7 @@ void CPDF_SecurityHandler::AES256_SetPassword(CPDF_Dictionary* pEncryptDict,
}
void CPDF_SecurityHandler::AES256_SetPerms(CPDF_Dictionary* pEncryptDict,
uint32_t permissions,
- FX_BOOL bEncryptMetadata,
+ bool bEncryptMetadata,
const uint8_t* key) {
uint8_t buf[16];
buf[0] = (uint8_t)permissions;
@@ -685,7 +685,7 @@ void CPDF_SecurityHandler::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);
diff --git a/core/fpdfapi/parser/cpdf_security_handler.h b/core/fpdfapi/parser/cpdf_security_handler.h
index 9132fd9a46..1a41b67195 100644
--- a/core/fpdfapi/parser/cpdf_security_handler.h
+++ b/core/fpdfapi/parser/cpdf_security_handler.h
@@ -27,9 +27,9 @@ class CPDF_SecurityHandler {
CPDF_SecurityHandler();
~CPDF_SecurityHandler();
- FX_BOOL OnInit(CPDF_Parser* pParser, CPDF_Dictionary* pEncryptDict);
+ bool OnInit(CPDF_Parser* pParser, CPDF_Dictionary* pEncryptDict);
uint32_t GetPermissions();
- FX_BOOL GetCryptInfo(int& cipher, const uint8_t*& buffer, int& keylen);
+ bool GetCryptInfo(int& cipher, const uint8_t*& buffer, int& keylen);
bool IsMetadataEncrypted() const;
CPDF_CryptoHandler* CreateCryptoHandler();
@@ -50,41 +50,41 @@ class CPDF_SecurityHandler {
CFX_ByteString GetUserPassword(const uint8_t* owner_pass,
uint32_t pass_size,
int32_t key_len);
- FX_BOOL CheckPassword(const uint8_t* password,
- uint32_t pass_size,
- FX_BOOL bOwner,
- uint8_t* key,
- int key_len);
+ bool CheckPassword(const uint8_t* password,
+ uint32_t pass_size,
+ bool bOwner,
+ uint8_t* key,
+ int key_len);
private:
- FX_BOOL LoadDict(CPDF_Dictionary* pEncryptDict);
- FX_BOOL LoadDict(CPDF_Dictionary* pEncryptDict,
- uint32_t type,
- int& cipher,
- int& key_len);
-
- FX_BOOL CheckUserPassword(const uint8_t* password,
- uint32_t pass_size,
- FX_BOOL bIgnoreEncryptMeta,
- uint8_t* key,
- int32_t key_len);
-
- FX_BOOL CheckOwnerPassword(const uint8_t* password,
- uint32_t pass_size,
- uint8_t* key,
- int32_t key_len);
- FX_BOOL AES256_CheckPassword(const uint8_t* password,
- uint32_t size,
- FX_BOOL bOwner,
- uint8_t* key);
+ bool LoadDict(CPDF_Dictionary* pEncryptDict);
+ bool LoadDict(CPDF_Dictionary* pEncryptDict,
+ uint32_t type,
+ int& cipher,
+ int& key_len);
+
+ bool CheckUserPassword(const uint8_t* password,
+ uint32_t pass_size,
+ bool bIgnoreEncryptMeta,
+ uint8_t* key,
+ int32_t key_len);
+
+ bool CheckOwnerPassword(const uint8_t* password,
+ uint32_t pass_size,
+ uint8_t* key,
+ int32_t key_len);
+ bool AES256_CheckPassword(const uint8_t* password,
+ uint32_t size,
+ bool bOwner,
+ uint8_t* key);
void AES256_SetPassword(CPDF_Dictionary* pEncryptDict,
const uint8_t* password,
uint32_t size,
- FX_BOOL bOwner,
+ bool bOwner,
const uint8_t* key);
void AES256_SetPerms(CPDF_Dictionary* pEncryptDict,
uint32_t permission,
- FX_BOOL bEncryptMetadata,
+ bool bEncryptMetadata,
const uint8_t* key);
void OnCreate(CPDF_Dictionary* pEncryptDict,
CPDF_Array* pIdArray,
@@ -92,9 +92,9 @@ class CPDF_SecurityHandler {
uint32_t user_size,
const uint8_t* owner_pass,
uint32_t owner_size,
- FX_BOOL bDefault,
+ bool bDefault,
uint32_t type);
- FX_BOOL CheckSecurity(int32_t key_len);
+ bool CheckSecurity(int32_t key_len);
int m_Version;
int m_Revision;
diff --git a/core/fpdfapi/parser/cpdf_stream.cpp b/core/fpdfapi/parser/cpdf_stream.cpp
index 93899db24e..c6e99c84b5 100644
--- a/core/fpdfapi/parser/cpdf_stream.cpp
+++ b/core/fpdfapi/parser/cpdf_stream.cpp
@@ -77,7 +77,7 @@ CPDF_Object* CPDF_Stream::CloneNonCyclic(
std::set<const CPDF_Object*>* pVisited) const {
pVisited->insert(this);
CPDF_StreamAcc acc;
- acc.LoadAllData(this, TRUE);
+ acc.LoadAllData(this, true);
uint32_t streamSize = acc.GetSize();
CPDF_Dictionary* pDict = GetDict();
if (pDict && !pdfium::ContainsKey(*pVisited, pDict)) {
@@ -101,20 +101,20 @@ void CPDF_Stream::SetData(const uint8_t* pData, uint32_t size) {
m_pDict->RemoveFor("DecodeParms");
}
-FX_BOOL CPDF_Stream::ReadRawData(FX_FILESIZE offset,
- uint8_t* buf,
- uint32_t size) const {
+bool CPDF_Stream::ReadRawData(FX_FILESIZE offset,
+ uint8_t* buf,
+ uint32_t size) const {
if (m_bMemoryBased && m_pFile)
return m_pFile->ReadBlock(buf, offset, size);
if (m_pDataBuf)
FXSYS_memcpy(buf, m_pDataBuf.get() + offset, size);
- return TRUE;
+ return true;
}
CFX_WideString CPDF_Stream::GetUnicodeText() const {
CPDF_StreamAcc stream;
- stream.LoadAllData(this, FALSE);
+ stream.LoadAllData(this, false);
return PDF_DecodeText(stream.GetData(), stream.GetSize());
}
diff --git a/core/fpdfapi/parser/cpdf_stream.h b/core/fpdfapi/parser/cpdf_stream.h
index 588714eadc..73484d8335 100644
--- a/core/fpdfapi/parser/cpdf_stream.h
+++ b/core/fpdfapi/parser/cpdf_stream.h
@@ -40,9 +40,9 @@ class CPDF_Stream : public CPDF_Object {
void InitStreamFromFile(IFX_SeekableReadStream* pFile,
CPDF_Dictionary* pDict);
- FX_BOOL ReadRawData(FX_FILESIZE start_pos,
- uint8_t* pBuf,
- uint32_t buf_size) const;
+ bool ReadRawData(FX_FILESIZE start_pos,
+ uint8_t* pBuf,
+ uint32_t buf_size) const;
bool IsMemoryBased() const { return m_bMemoryBased; }
diff --git a/core/fpdfapi/parser/cpdf_stream_acc.cpp b/core/fpdfapi/parser/cpdf_stream_acc.cpp
index e8bf6d7e15..81439bc677 100644
--- a/core/fpdfapi/parser/cpdf_stream_acc.cpp
+++ b/core/fpdfapi/parser/cpdf_stream_acc.cpp
@@ -11,15 +11,15 @@
CPDF_StreamAcc::CPDF_StreamAcc()
: m_pData(nullptr),
m_dwSize(0),
- m_bNewBuf(FALSE),
+ m_bNewBuf(false),
m_pImageParam(nullptr),
m_pStream(nullptr),
m_pSrcData(nullptr) {}
void CPDF_StreamAcc::LoadAllData(const CPDF_Stream* pStream,
- FX_BOOL bRawAccess,
+ bool bRawAccess,
uint32_t estimated_size,
- FX_BOOL bImageAcc) {
+ bool bImageAcc) {
if (!pStream)
return;
@@ -46,9 +46,9 @@ void CPDF_StreamAcc::LoadAllData(const CPDF_Stream* pStream,
m_pData = pSrcData;
m_dwSize = dwSrcSize;
} else {
- FX_BOOL bRet = PDF_DataDecode(pSrcData, dwSrcSize, m_pStream->GetDict(),
- m_pData, m_dwSize, m_ImageDecoder,
- m_pImageParam, estimated_size, bImageAcc);
+ bool bRet = PDF_DataDecode(pSrcData, dwSrcSize, m_pStream->GetDict(),
+ m_pData, m_dwSize, m_ImageDecoder, m_pImageParam,
+ estimated_size, bImageAcc);
if (!bRet) {
m_pData = pSrcData;
m_dwSize = dwSrcSize;
diff --git a/core/fpdfapi/parser/cpdf_stream_acc.h b/core/fpdfapi/parser/cpdf_stream_acc.h
index c4f312a113..654055f96b 100644
--- a/core/fpdfapi/parser/cpdf_stream_acc.h
+++ b/core/fpdfapi/parser/cpdf_stream_acc.h
@@ -18,9 +18,9 @@ class CPDF_StreamAcc {
~CPDF_StreamAcc();
void LoadAllData(const CPDF_Stream* pStream,
- FX_BOOL bRawAccess = FALSE,
+ bool bRawAccess = false,
uint32_t estimated_size = 0,
- FX_BOOL bImageAcc = FALSE);
+ bool bImageAcc = false);
const CPDF_Stream* GetStream() const { return m_pStream; }
CPDF_Dictionary* GetDict() const {
@@ -36,7 +36,7 @@ class CPDF_StreamAcc {
protected:
uint8_t* m_pData;
uint32_t m_dwSize;
- FX_BOOL m_bNewBuf;
+ bool m_bNewBuf;
CFX_ByteString m_ImageDecoder;
CPDF_Dictionary* m_pImageParam;
const CPDF_Stream* m_pStream;
diff --git a/core/fpdfapi/parser/cpdf_string.cpp b/core/fpdfapi/parser/cpdf_string.cpp
index 73c7d4cf69..f4fa956280 100644
--- a/core/fpdfapi/parser/cpdf_string.cpp
+++ b/core/fpdfapi/parser/cpdf_string.cpp
@@ -8,12 +8,12 @@
#include "core/fpdfapi/parser/fpdf_parser_decode.h"
-CPDF_String::CPDF_String() : m_bHex(FALSE) {}
+CPDF_String::CPDF_String() : m_bHex(false) {}
-CPDF_String::CPDF_String(const CFX_ByteString& str, FX_BOOL bHex)
+CPDF_String::CPDF_String(const CFX_ByteString& str, bool bHex)
: m_String(str), m_bHex(bHex) {}
-CPDF_String::CPDF_String(const CFX_WideString& str) : m_bHex(FALSE) {
+CPDF_String::CPDF_String(const CFX_WideString& str) : m_bHex(false) {
m_String = PDF_EncodeText(str);
}
diff --git a/core/fpdfapi/parser/cpdf_string.h b/core/fpdfapi/parser/cpdf_string.h
index 01ea8224d4..efc6d076c7 100644
--- a/core/fpdfapi/parser/cpdf_string.h
+++ b/core/fpdfapi/parser/cpdf_string.h
@@ -14,7 +14,7 @@
class CPDF_String : public CPDF_Object {
public:
CPDF_String();
- CPDF_String(const CFX_ByteString& str, FX_BOOL bHex);
+ CPDF_String(const CFX_ByteString& str, bool bHex);
explicit CPDF_String(const CFX_WideString& str);
// CPDF_Object.
@@ -27,13 +27,13 @@ class CPDF_String : public CPDF_Object {
CPDF_String* AsString() override;
const CPDF_String* AsString() const override;
- FX_BOOL IsHex() const { return m_bHex; }
+ bool IsHex() const { return m_bHex; }
protected:
~CPDF_String() override;
CFX_ByteString m_String;
- FX_BOOL m_bHex;
+ bool m_bHex;
};
inline CPDF_String* ToString(CPDF_Object* obj) {
diff --git a/core/fpdfapi/parser/cpdf_syntax_parser.cpp b/core/fpdfapi/parser/cpdf_syntax_parser.cpp
index 3b1df94503..c1ab1cf768 100644
--- a/core/fpdfapi/parser/cpdf_syntax_parser.cpp
+++ b/core/fpdfapi/parser/cpdf_syntax_parser.cpp
@@ -51,16 +51,16 @@ 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) {
CFX_AutoRestorer<FX_FILESIZE> save_pos(&m_Pos);
m_Pos = pos;
return GetNextChar(ch);
}
-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;
@@ -78,19 +78,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;
@@ -110,19 +110,19 @@ 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, uint32_t size) {
+bool CPDF_SyntaxParser::ReadBlock(uint8_t* pBuf, uint32_t size) {
if (!m_pFileAccess->ReadBlock(pBuf, m_Pos + m_HeaderOffset, size))
- return FALSE;
+ return false;
m_Pos += size;
- return TRUE;
+ return true;
}
void CPDF_SyntaxParser::GetNextWordInternal(bool* bIsNumber) {
@@ -381,7 +381,7 @@ CFX_ByteString CPDF_SyntaxParser::GetKeyword() {
CPDF_Object* CPDF_SyntaxParser::GetObject(CPDF_IndirectObjectHolder* pObjList,
uint32_t objnum,
uint32_t gennum,
- FX_BOOL bDecrypt) {
+ bool bDecrypt) {
CFX_AutoRestorer<int> restorer(&s_CurrentRecursionDepth);
if (++s_CurrentRecursionDepth > kParserMaxRecursionDepth)
return nullptr;
@@ -414,14 +414,14 @@ CPDF_Object* CPDF_SyntaxParser::GetObject(CPDF_IndirectObjectHolder* pObjList,
CFX_ByteString str = ReadString();
if (m_pCryptoHandler && bDecrypt)
m_pCryptoHandler->Decrypt(objnum, gennum, str);
- return new CPDF_String(MaybeIntern(str), FALSE);
+ return new CPDF_String(MaybeIntern(str), false);
}
if (word == "<") {
CFX_ByteString str = ReadHexString();
if (m_pCryptoHandler && bDecrypt)
m_pCryptoHandler->Decrypt(objnum, gennum, str);
- return new CPDF_String(MaybeIntern(str), TRUE);
+ return new CPDF_String(MaybeIntern(str), true);
}
if (word == "[") {
@@ -535,14 +535,14 @@ CPDF_Object* CPDF_SyntaxParser::GetObjectForStrict(
CFX_ByteString str = ReadString();
if (m_pCryptoHandler)
m_pCryptoHandler->Decrypt(objnum, gennum, str);
- return new CPDF_String(MaybeIntern(str), FALSE);
+ return new CPDF_String(MaybeIntern(str), false);
}
if (word == "<") {
CFX_ByteString str = ReadHexString();
if (m_pCryptoHandler)
m_pCryptoHandler->Decrypt(objnum, gennum, str);
- return new CPDF_String(MaybeIntern(str), TRUE);
+ return new CPDF_String(MaybeIntern(str), true);
}
if (word == "[") {
@@ -650,7 +650,7 @@ CPDF_Stream* CPDF_SyntaxParser::ReadStream(CPDF_Dictionary* pDict,
CPDF_CryptoHandler* pCryptoHandler =
objnum == (uint32_t)m_MetadataObjnum ? nullptr : m_pCryptoHandler.get();
if (!pCryptoHandler) {
- FX_BOOL bSearchForKeyword = TRUE;
+ bool bSearchForKeyword = true;
if (len >= 0) {
pdfium::base::CheckedNumeric<FX_FILESIZE> pos = m_Pos;
pos += len;
@@ -665,7 +665,7 @@ CPDF_Stream* CPDF_SyntaxParser::ReadStream(CPDF_Dictionary* pDict,
// specified length, it signals the end of stream.
if (FXSYS_memcmp(m_WordBuffer, kEndStreamStr.raw_str(),
kEndStreamStr.GetLength()) == 0) {
- bSearchForKeyword = FALSE;
+ bSearchForKeyword = false;
}
}
@@ -683,7 +683,7 @@ CPDF_Stream* CPDF_SyntaxParser::ReadStream(CPDF_Dictionary* pDict,
// Stop searching when "endstream" is found.
if (IsWholeWord(m_Pos - kEndStreamStr.GetLength(), m_FileLen,
- kEndStreamStr, TRUE)) {
+ kEndStreamStr, true)) {
endStreamOffset = m_Pos - streamStartPos - kEndStreamStr.GetLength();
break;
}
@@ -700,7 +700,7 @@ CPDF_Stream* CPDF_SyntaxParser::ReadStream(CPDF_Dictionary* pDict,
// Stop searching when "endobj" is found.
if (IsWholeWord(m_Pos - kEndObjStr.GetLength(), m_FileLen, kEndObjStr,
- TRUE)) {
+ true)) {
endObjOffset = m_Pos - streamStartPos - kEndObjStr.GetLength();
break;
}
@@ -810,7 +810,7 @@ uint32_t CPDF_SyntaxParser::GetDirectNum() {
bool CPDF_SyntaxParser::IsWholeWord(FX_FILESIZE startpos,
FX_FILESIZE limit,
const CFX_ByteStringC& tag,
- FX_BOOL checkKeyword) {
+ bool checkKeyword) {
const uint32_t taglen = tag.GetLength();
bool bCheckLeft = !PDFCharIsDelimiter(tag[0]) && !PDFCharIsWhitespace(tag[0]);
@@ -837,13 +837,13 @@ bool CPDF_SyntaxParser::IsWholeWord(FX_FILESIZE startpos,
// TODO(dsinclair): Split into a SearchWordForward and SearchWordBackwards
// and drop the bool.
-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;
@@ -855,17 +855,17 @@ FX_BOOL CPDF_SyntaxParser::SearchWord(const CFX_ByteStringC& tag,
while (1) {
if (bForward) {
if (limit && pos >= m_Pos + limit)
- return FALSE;
+ return false;
if (!GetCharAt(pos, byte))
- return FALSE;
+ return false;
} else {
if (limit && pos <= m_Pos - limit)
- return FALSE;
+ return false;
if (!GetCharAtBackward(pos, byte))
- return FALSE;
+ return false;
}
if (byte == tag_data[offset]) {
@@ -884,9 +884,9 @@ FX_BOOL CPDF_SyntaxParser::SearchWord(const CFX_ByteStringC& tag,
}
FX_FILESIZE startpos = bForward ? pos - taglen + 1 : pos;
- if (!bWholeWord || IsWholeWord(startpos, limit, tag, FALSE)) {
+ if (!bWholeWord || IsWholeWord(startpos, limit, tag, false)) {
m_Pos = startpos;
- return TRUE;
+ return true;
}
}
@@ -899,14 +899,14 @@ FX_BOOL CPDF_SyntaxParser::SearchWord(const CFX_ByteStringC& tag,
}
if (pos < 0)
- return FALSE;
+ return false;
}
- return FALSE;
+ return false;
}
int32_t CPDF_SyntaxParser::SearchMultiWord(const CFX_ByteStringC& tags,
- FX_BOOL bWholeWord,
+ bool bWholeWord,
FX_FILESIZE limit) {
int32_t ntags = 1;
for (int i = 0; i < tags.GetLength(); ++i) {
@@ -951,7 +951,7 @@ int32_t CPDF_SyntaxParser::SearchMultiWord(const CFX_ByteStringC& tags,
continue;
if (!bWholeWord || IsWholeWord(pos - pat.m_bsTag.GetLength(), limit,
- pat.m_bsTag, FALSE)) {
+ pat.m_bsTag, false)) {
return i;
}
diff --git a/core/fpdfapi/parser/cpdf_syntax_parser.h b/core/fpdfapi/parser/cpdf_syntax_parser.h
index 5694d233e1..eae5a00a41 100644
--- a/core/fpdfapi/parser/cpdf_syntax_parser.h
+++ b/core/fpdfapi/parser/cpdf_syntax_parser.h
@@ -34,7 +34,7 @@ class CPDF_SyntaxParser {
CPDF_Object* GetObject(CPDF_IndirectObjectHolder* pObjList,
uint32_t objnum,
uint32_t gennum,
- FX_BOOL bDecrypt);
+ bool bDecrypt);
CPDF_Object* GetObjectForStrict(CPDF_IndirectObjectHolder* pObjList,
uint32_t objnum,
uint32_t gennum);
@@ -43,19 +43,19 @@ class CPDF_SyntaxParser {
void ToNextLine();
void ToNextWord();
- FX_BOOL SearchWord(const CFX_ByteStringC& word,
- FX_BOOL bWholeWord,
- FX_BOOL bForward,
- FX_FILESIZE limit);
+ bool SearchWord(const CFX_ByteStringC& word,
+ bool bWholeWord,
+ bool bForward,
+ FX_FILESIZE limit);
int SearchMultiWord(const CFX_ByteStringC& words,
- FX_BOOL bWholeWord,
+ bool bWholeWord,
FX_FILESIZE limit);
FX_FILESIZE FindTag(const CFX_ByteStringC& tag, FX_FILESIZE limit);
void SetEncrypt(std::unique_ptr<CPDF_CryptoHandler> pCryptoHandler);
- FX_BOOL ReadBlock(uint8_t* pBuf, uint32_t size);
- FX_BOOL GetCharAt(FX_FILESIZE pos, uint8_t& ch);
+ bool ReadBlock(uint8_t* pBuf, uint32_t size);
+ bool GetCharAt(FX_FILESIZE pos, uint8_t& ch);
CFX_ByteString GetNextWord(bool* bIsNumber);
private:
@@ -67,13 +67,13 @@ class CPDF_SyntaxParser {
static int s_CurrentRecursionDepth;
uint32_t GetDirectNum();
- FX_BOOL GetNextChar(uint8_t& ch);
- FX_BOOL GetCharAtBackward(FX_FILESIZE pos, uint8_t& ch);
+ bool GetNextChar(uint8_t& ch);
+ bool GetCharAtBackward(FX_FILESIZE pos, uint8_t& ch);
void GetNextWordInternal(bool* bIsNumber);
bool IsWholeWord(FX_FILESIZE startpos,
FX_FILESIZE limit,
const CFX_ByteStringC& tag,
- FX_BOOL checkKeyword);
+ bool checkKeyword);
CFX_ByteString ReadString();
CFX_ByteString ReadHexString();
diff --git a/core/fpdfapi/parser/cpdf_syntax_parser_unittest.cpp b/core/fpdfapi/parser/cpdf_syntax_parser_unittest.cpp
index 45a0698078..a23c0ed64e 100644
--- a/core/fpdfapi/parser/cpdf_syntax_parser_unittest.cpp
+++ b/core/fpdfapi/parser/cpdf_syntax_parser_unittest.cpp
@@ -16,7 +16,7 @@ TEST(cpdf_syntax_parser, ReadHexString) {
{
// Empty string.
uint8_t data[] = "";
- ScopedFileStream stream(FX_CreateMemoryStream(data, 0, FALSE));
+ ScopedFileStream stream(FX_CreateMemoryStream(data, 0, false));
CPDF_SyntaxParser parser;
parser.InitParser(stream.get(), 0);
@@ -27,7 +27,7 @@ TEST(cpdf_syntax_parser, ReadHexString) {
{
// Blank string.
uint8_t data[] = " ";
- ScopedFileStream stream(FX_CreateMemoryStream(data, 2, FALSE));
+ ScopedFileStream stream(FX_CreateMemoryStream(data, 2, false));
CPDF_SyntaxParser parser;
parser.InitParser(stream.get(), 0);
@@ -38,7 +38,7 @@ TEST(cpdf_syntax_parser, ReadHexString) {
{
// Skips unknown characters.
uint8_t data[] = "z12b";
- ScopedFileStream stream(FX_CreateMemoryStream(data, 4, FALSE));
+ ScopedFileStream stream(FX_CreateMemoryStream(data, 4, false));
CPDF_SyntaxParser parser;
parser.InitParser(stream.get(), 0);
@@ -49,7 +49,7 @@ TEST(cpdf_syntax_parser, ReadHexString) {
{
// Skips unknown characters.
uint8_t data[] = "*<&*#$^&@1";
- ScopedFileStream stream(FX_CreateMemoryStream(data, 10, FALSE));
+ ScopedFileStream stream(FX_CreateMemoryStream(data, 10, false));
CPDF_SyntaxParser parser;
parser.InitParser(stream.get(), 0);
@@ -60,7 +60,7 @@ TEST(cpdf_syntax_parser, ReadHexString) {
{
// Skips unknown characters.
uint8_t data[] = "\x80zab";
- ScopedFileStream stream(FX_CreateMemoryStream(data, 4, FALSE));
+ ScopedFileStream stream(FX_CreateMemoryStream(data, 4, false));
CPDF_SyntaxParser parser;
parser.InitParser(stream.get(), 0);
@@ -71,7 +71,7 @@ TEST(cpdf_syntax_parser, ReadHexString) {
{
// Skips unknown characters.
uint8_t data[] = "\xffzab";
- ScopedFileStream stream(FX_CreateMemoryStream(data, 4, FALSE));
+ ScopedFileStream stream(FX_CreateMemoryStream(data, 4, false));
CPDF_SyntaxParser parser;
parser.InitParser(stream.get(), 0);
@@ -82,7 +82,7 @@ TEST(cpdf_syntax_parser, ReadHexString) {
{
// Regular conversion.
uint8_t data[] = "1A2b>abcd";
- ScopedFileStream stream(FX_CreateMemoryStream(data, 9, FALSE));
+ ScopedFileStream stream(FX_CreateMemoryStream(data, 9, false));
CPDF_SyntaxParser parser;
parser.InitParser(stream.get(), 0);
@@ -93,7 +93,7 @@ TEST(cpdf_syntax_parser, ReadHexString) {
{
// Position out of bounds.
uint8_t data[] = "12ab>";
- ScopedFileStream stream(FX_CreateMemoryStream(data, 5, FALSE));
+ ScopedFileStream stream(FX_CreateMemoryStream(data, 5, false));
CPDF_SyntaxParser parser;
parser.InitParser(stream.get(), 0);
@@ -117,7 +117,7 @@ TEST(cpdf_syntax_parser, ReadHexString) {
{
// Missing ending >.
uint8_t data[] = "1A2b";
- ScopedFileStream stream(FX_CreateMemoryStream(data, 4, FALSE));
+ ScopedFileStream stream(FX_CreateMemoryStream(data, 4, false));
CPDF_SyntaxParser parser;
parser.InitParser(stream.get(), 0);
@@ -128,7 +128,7 @@ TEST(cpdf_syntax_parser, ReadHexString) {
{
// Missing ending >.
uint8_t data[] = "12abz";
- ScopedFileStream stream(FX_CreateMemoryStream(data, 5, FALSE));
+ ScopedFileStream stream(FX_CreateMemoryStream(data, 5, false));
CPDF_SyntaxParser parser;
parser.InitParser(stream.get(), 0);
@@ -139,7 +139,7 @@ TEST(cpdf_syntax_parser, ReadHexString) {
{
// Uneven number of bytes.
uint8_t data[] = "1A2>asdf";
- ScopedFileStream stream(FX_CreateMemoryStream(data, 8, FALSE));
+ ScopedFileStream stream(FX_CreateMemoryStream(data, 8, false));
CPDF_SyntaxParser parser;
parser.InitParser(stream.get(), 0);
@@ -150,7 +150,7 @@ TEST(cpdf_syntax_parser, ReadHexString) {
{
// Uneven number of bytes.
uint8_t data[] = "1A2zasdf";
- ScopedFileStream stream(FX_CreateMemoryStream(data, 8, FALSE));
+ ScopedFileStream stream(FX_CreateMemoryStream(data, 8, false));
CPDF_SyntaxParser parser;
parser.InitParser(stream.get(), 0);
@@ -161,7 +161,7 @@ TEST(cpdf_syntax_parser, ReadHexString) {
{
// Just ending character.
uint8_t data[] = ">";
- ScopedFileStream stream(FX_CreateMemoryStream(data, 1, FALSE));
+ ScopedFileStream stream(FX_CreateMemoryStream(data, 1, false));
CPDF_SyntaxParser parser;
parser.InitParser(stream.get(), 0);
diff --git a/core/fpdfapi/parser/fpdf_parser_decode.cpp b/core/fpdfapi/parser/fpdf_parser_decode.cpp
index ed379c7028..6398c71835 100644
--- a/core/fpdfapi/parser/fpdf_parser_decode.cpp
+++ b/core/fpdfapi/parser/fpdf_parser_decode.cpp
@@ -297,7 +297,7 @@ CCodec_ScanlineDecoder* FPDFAPI_CreateFlateDecoder(
BitsPerComponent, Columns);
}
-uint32_t FPDFAPI_FlateOrLZWDecode(FX_BOOL bLZW,
+uint32_t FPDFAPI_FlateOrLZWDecode(bool bLZW,
const uint8_t* src_buf,
uint32_t src_size,
CPDF_Dictionary* pParams,
@@ -308,7 +308,7 @@ uint32_t FPDFAPI_FlateOrLZWDecode(FX_BOOL bLZW,
int Colors = 0;
int BitsPerComponent = 0;
int Columns = 0;
- FX_BOOL bEarlyChange = TRUE;
+ bool bEarlyChange = true;
if (pParams) {
predictor = pParams->GetIntegerFor("Predictor");
bEarlyChange = !!pParams->GetIntegerFor("EarlyChange", 1);
@@ -323,18 +323,18 @@ uint32_t FPDFAPI_FlateOrLZWDecode(FX_BOOL bLZW,
BitsPerComponent, Columns, estimated_size, dest_buf, dest_size);
}
-FX_BOOL PDF_DataDecode(const uint8_t* src_buf,
- uint32_t src_size,
- const CPDF_Dictionary* pDict,
- uint8_t*& dest_buf,
- uint32_t& dest_size,
- CFX_ByteString& ImageEncoding,
- CPDF_Dictionary*& pImageParms,
- uint32_t last_estimated_size,
- FX_BOOL bImageAcc) {
+bool PDF_DataDecode(const uint8_t* src_buf,
+ uint32_t src_size,
+ const CPDF_Dictionary* pDict,
+ uint8_t*& dest_buf,
+ uint32_t& dest_size,
+ CFX_ByteString& ImageEncoding,
+ CPDF_Dictionary*& pImageParms,
+ uint32_t last_estimated_size,
+ bool bImageAcc) {
CPDF_Object* pDecoder = pDict ? pDict->GetDirectObjectFor("Filter") : nullptr;
if (!pDecoder || (!pDecoder->IsArray() && !pDecoder->IsName()))
- return FALSE;
+ return false;
CPDF_Object* pParams =
pDict ? pDict->GetDirectObjectFor("DecodeParms") : nullptr;
@@ -367,12 +367,12 @@ FX_BOOL PDF_DataDecode(const uint8_t* src_buf,
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,
+ offset = FPDFAPI_FlateOrLZWDecode(false, last_buf, last_size, pParam,
estimated_size, new_buf, new_size);
} else if (decoder == "LZWDecode" || decoder == "LZW") {
- offset = FPDFAPI_FlateOrLZWDecode(TRUE, last_buf, last_size, pParam,
+ offset = FPDFAPI_FlateOrLZWDecode(true, last_buf, last_size, pParam,
estimated_size, new_buf, new_size);
} else if (decoder == "ASCII85Decode" || decoder == "A85") {
offset = A85Decode(last_buf, last_size, new_buf, new_size);
@@ -384,7 +384,7 @@ FX_BOOL PDF_DataDecode(const uint8_t* src_buf,
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 if (decoder == "Crypt") {
@@ -402,14 +402,14 @@ FX_BOOL PDF_DataDecode(const uint8_t* src_buf,
dest_size = last_size;
if (CPDF_Array* pDecoders = pDecoder->AsArray())
pDecoders->RemoveAt(i + 1, pDecoders->GetCount() - i - 1);
- return TRUE;
+ return true;
}
if (last_buf != src_buf) {
FX_Free(last_buf);
}
if (offset == -1) {
FX_Free(new_buf);
- return FALSE;
+ return false;
}
last_buf = new_buf;
last_size = new_size;
@@ -418,7 +418,7 @@ FX_BOOL PDF_DataDecode(const uint8_t* src_buf,
pImageParms = nullptr;
dest_buf = last_buf;
dest_size = last_size;
- return TRUE;
+ return true;
}
CFX_WideString PDF_DecodeText(const uint8_t* src_data, uint32_t src_len) {
@@ -512,7 +512,7 @@ CFX_ByteString PDF_EncodeText(const CFX_WideString& str) {
return PDF_EncodeText(str.c_str(), str.GetLength());
}
-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();
if (bHex) {
@@ -570,7 +570,7 @@ uint32_t FlateDecode(const uint8_t* src_buf,
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);
+ false, src_buf, src_size, false, 0, 0, 0, 0, 0, dest_buf, dest_size);
}
return 0;
}
diff --git a/core/fpdfapi/parser/fpdf_parser_decode.h b/core/fpdfapi/parser/fpdf_parser_decode.h
index 3a5d532831..4d99f1559d 100644
--- a/core/fpdfapi/parser/fpdf_parser_decode.h
+++ b/core/fpdfapi/parser/fpdf_parser_decode.h
@@ -17,8 +17,7 @@ extern const uint16_t PDFDocEncoding[256];
CFX_ByteString PDF_NameDecode(const CFX_ByteStringC& orig);
CFX_ByteString PDF_NameDecode(const CFX_ByteString& orig);
CFX_ByteString PDF_NameEncode(const CFX_ByteString& orig);
-CFX_ByteString PDF_EncodeString(const CFX_ByteString& src,
- FX_BOOL bHex = FALSE);
+CFX_ByteString PDF_EncodeString(const CFX_ByteString& src, bool bHex = false);
CFX_WideString PDF_DecodeText(const uint8_t* pData, uint32_t size);
CFX_WideString PDF_DecodeText(const CFX_ByteString& bstr);
CFX_ByteString PDF_EncodeText(const FX_WCHAR* pString, int len = -1);
@@ -57,21 +56,21 @@ uint32_t HexDecode(const uint8_t* src_buf,
uint8_t*& dest_buf,
uint32_t& dest_size);
// Public for testing.
-uint32_t FPDFAPI_FlateOrLZWDecode(FX_BOOL bLZW,
+uint32_t FPDFAPI_FlateOrLZWDecode(bool bLZW,
const uint8_t* src_buf,
uint32_t src_size,
CPDF_Dictionary* pParams,
uint32_t estimated_size,
uint8_t*& dest_buf,
uint32_t& dest_size);
-FX_BOOL PDF_DataDecode(const uint8_t* src_buf,
- uint32_t src_size,
- const CPDF_Dictionary* pDict,
- uint8_t*& dest_buf,
- uint32_t& dest_size,
- CFX_ByteString& ImageEncoding,
- CPDF_Dictionary*& pImageParms,
- uint32_t estimated_size,
- FX_BOOL bImageAcc);
+bool PDF_DataDecode(const uint8_t* src_buf,
+ uint32_t src_size,
+ const CPDF_Dictionary* pDict,
+ uint8_t*& dest_buf,
+ uint32_t& dest_size,
+ CFX_ByteString& ImageEncoding,
+ CPDF_Dictionary*& pImageParms,
+ uint32_t estimated_size,
+ bool bImageAcc);
#endif // CORE_FPDFAPI_PARSER_FPDF_PARSER_DECODE_H_
diff --git a/core/fpdfapi/parser/fpdf_parser_utility.cpp b/core/fpdfapi/parser/fpdf_parser_utility.cpp
index 8fdef1eb11..630754a23b 100644
--- a/core/fpdfapi/parser/fpdf_parser_utility.cpp
+++ b/core/fpdfapi/parser/fpdf_parser_utility.cpp
@@ -208,13 +208,13 @@ CFX_ByteTextBuf& operator<<(CFX_ByteTextBuf& buf, const CPDF_Object* pObj) {
const CPDF_Stream* p = pObj->AsStream();
buf << p->GetDict() << "stream\r\n";
CPDF_StreamAcc acc;
- acc.LoadAllData(p, TRUE);
+ acc.LoadAllData(p, true);
buf.AppendBlock(acc.GetData(), acc.GetSize());
buf << "\r\nendstream";
break;
}
default:
- ASSERT(FALSE);
+ ASSERT(false);
break;
}
return buf;