diff options
Diffstat (limited to 'core/fpdfapi')
75 files changed, 1950 insertions, 1964 deletions
diff --git a/core/fpdfapi/edit/cpdf_creator.h b/core/fpdfapi/edit/cpdf_creator.h index 8b0efdd309..f462115cf7 100644 --- a/core/fpdfapi/edit/cpdf_creator.h +++ b/core/fpdfapi/edit/cpdf_creator.h @@ -34,7 +34,7 @@ class CPDF_Creator { void RemoveSecurity(); bool Create(IFX_WriteStream* pFile, uint32_t flags = 0); int32_t Continue(IFX_Pause* pPause = nullptr); - FX_BOOL SetFileVersion(int32_t fileVersion = 17); + bool SetFileVersion(int32_t fileVersion = 17); private: friend class CPDF_ObjectStream; @@ -46,7 +46,7 @@ class CPDF_Creator { void InitOldObjNumOffsets(); void InitNewObjNumOffsets(); - void InitID(FX_BOOL bDefault = TRUE); + void InitID(bool bDefault = true); void AppendNewObjNum(uint32_t objbum); int32_t AppendObjectNumberToXRef(uint32_t objnum); @@ -58,11 +58,11 @@ class CPDF_Creator { int32_t WriteOldIndirectObject(uint32_t objnum); int32_t WriteOldObjs(IFX_Pause* pPause); - int32_t WriteNewObjs(FX_BOOL bIncremental, IFX_Pause* pPause); + int32_t WriteNewObjs(bool bIncremental, IFX_Pause* pPause); int32_t WriteIndirectObj(const CPDF_Object* pObj); int32_t WriteDirectObj(uint32_t objnum, const CPDF_Object* pObj, - FX_BOOL bEncrypt = TRUE); + bool bEncrypt = true); int32_t WriteIndirectObjectToStream(const CPDF_Object* pObj); int32_t WriteIndirectObj(uint32_t objnum, const CPDF_Object* pObj); int32_t WriteIndirectObjectToStream(uint32_t objnum, @@ -75,13 +75,13 @@ class CPDF_Creator { CPDF_Document* const m_pDocument; CPDF_Parser* const m_pParser; - FX_BOOL m_bSecurityChanged; + bool m_bSecurityChanged; CPDF_Dictionary* m_pEncryptDict; uint32_t m_dwEncryptObjNum; - FX_BOOL m_bEncryptCloned; + bool m_bEncryptCloned; CPDF_CryptoHandler* m_pCryptoHandler; // Whether this owns the crypto handler |m_pCryptoHandler|. - FX_BOOL m_bLocalCryptoHandler; + bool m_bLocalCryptoHandler; CPDF_Object* m_pMetadata; std::unique_ptr<CPDF_XRefStream> m_pXRefStream; int32_t m_ObjectStreamSize; diff --git a/core/fpdfapi/edit/editint.h b/core/fpdfapi/edit/editint.h index f1f88f8b09..881c2cca36 100644 --- a/core/fpdfapi/edit/editint.h +++ b/core/fpdfapi/edit/editint.h @@ -49,7 +49,7 @@ class CPDF_XRefStream { CPDF_XRefStream(); ~CPDF_XRefStream(); - FX_BOOL Start(); + bool Start(); int32_t CompressIndirectObject(uint32_t dwObjNum, const CPDF_Object* pObj, CPDF_Creator* pCreator); @@ -57,17 +57,17 @@ class CPDF_XRefStream { const uint8_t* pBuffer, uint32_t dwSize, CPDF_Creator* pCreator); - FX_BOOL End(CPDF_Creator* pCreator, FX_BOOL bEOF = FALSE); + bool End(CPDF_Creator* pCreator, bool bEOF = false); void AddObjectNumberToIndexArray(uint32_t objnum); - FX_BOOL EndXRefStream(CPDF_Creator* pCreator); + bool EndXRefStream(CPDF_Creator* pCreator); std::vector<Index> m_IndexArray; FX_FILESIZE m_PrevOffset; uint32_t m_dwTempObjNum; protected: - int32_t EndObjectStream(CPDF_Creator* pCreator, FX_BOOL bEOF = TRUE); - FX_BOOL GenerateXRefStream(CPDF_Creator* pCreator, FX_BOOL bEOF); + int32_t EndObjectStream(CPDF_Creator* pCreator, bool bEOF = true); + bool GenerateXRefStream(CPDF_Creator* pCreator, bool bEOF); size_t m_iSeg; CPDF_ObjectStream m_ObjStream; diff --git a/core/fpdfapi/edit/fpdf_edit_create.cpp b/core/fpdfapi/edit/fpdf_edit_create.cpp index b4e1157d9e..ed638d4c40 100644 --- a/core/fpdfapi/edit/fpdf_edit_create.cpp +++ b/core/fpdfapi/edit/fpdf_edit_create.cpp @@ -60,7 +60,7 @@ int32_t PDF_CreatorAppendObject(const CPDF_Object* pObj, break; case CPDF_Object::STRING: { CFX_ByteString str = pObj->GetString(); - FX_BOOL bHex = pObj->AsString()->IsHex(); + bool bHex = pObj->AsString()->IsHex(); if ((len = pFile->AppendString(PDF_EncodeString(str, bHex).AsStringC())) < 0) { return -1; @@ -169,7 +169,7 @@ int32_t PDF_CreatorAppendObject(const CPDF_Object* pObj, } offset += 8; CPDF_StreamAcc acc; - acc.LoadAllData(p, TRUE); + acc.LoadAllData(p, true); if (pFile->AppendBlock(acc.GetData(), acc.GetSize()) < 0) { return -1; } @@ -181,7 +181,7 @@ int32_t PDF_CreatorAppendObject(const CPDF_Object* pObj, break; } default: - ASSERT(FALSE); + ASSERT(false); break; } return 1; @@ -385,7 +385,7 @@ int32_t OutputIndex(CFX_FileBufferArchive* pFile, FX_FILESIZE offset) { class CPDF_FlateEncoder { public: - CPDF_FlateEncoder(CPDF_Stream* pStream, FX_BOOL bFlateEncode); + CPDF_FlateEncoder(CPDF_Stream* pStream, bool bFlateEncode); CPDF_FlateEncoder(const uint8_t* pBuffer, uint32_t size, bool bFlateEncode, @@ -397,8 +397,8 @@ class CPDF_FlateEncoder { uint8_t* m_pData; uint32_t m_dwSize; CPDF_Dictionary* m_pDict; - FX_BOOL m_bCloned; - FX_BOOL m_bNewData; + bool m_bCloned; + bool m_bNewData; CPDF_StreamAcc m_Acc; }; @@ -406,17 +406,17 @@ void CPDF_FlateEncoder::CloneDict() { if (!m_bCloned) { m_pDict = ToDictionary(m_pDict->Clone()); ASSERT(m_pDict); - m_bCloned = TRUE; + m_bCloned = true; } } -CPDF_FlateEncoder::CPDF_FlateEncoder(CPDF_Stream* pStream, FX_BOOL bFlateEncode) +CPDF_FlateEncoder::CPDF_FlateEncoder(CPDF_Stream* pStream, bool bFlateEncode) : m_pData(nullptr), m_dwSize(0), m_pDict(nullptr), - m_bCloned(FALSE), - m_bNewData(FALSE) { - m_Acc.LoadAllData(pStream, TRUE); + m_bCloned(false), + m_bNewData(false) { + m_Acc.LoadAllData(pStream, true); if ((pStream && pStream->GetDict() && pStream->GetDict()->KeyExist("Filter")) || !bFlateEncode) { @@ -427,8 +427,8 @@ CPDF_FlateEncoder::CPDF_FlateEncoder(CPDF_Stream* pStream, FX_BOOL bFlateEncode) m_pData = (uint8_t*)destAcc.DetachData(); m_pDict = ToDictionary(pStream->GetDict()->Clone()); m_pDict->RemoveFor("Filter"); - m_bNewData = TRUE; - m_bCloned = TRUE; + m_bNewData = true; + m_bCloned = true; } else { m_pData = (uint8_t*)m_Acc.GetData(); m_dwSize = m_Acc.GetSize(); @@ -437,8 +437,8 @@ CPDF_FlateEncoder::CPDF_FlateEncoder(CPDF_Stream* pStream, FX_BOOL bFlateEncode) return; } - m_bNewData = TRUE; - m_bCloned = TRUE; + m_bNewData = true; + m_bCloned = true; // TODO(thestig): Move to Init() and check return value. ::FlateEncode(m_Acc.GetData(), m_Acc.GetSize(), &m_pData, &m_dwSize); m_pDict = ToDictionary(pStream->GetDict()->Clone()); @@ -454,14 +454,14 @@ CPDF_FlateEncoder::CPDF_FlateEncoder(const uint8_t* pBuffer, : m_pData(nullptr), m_dwSize(0), m_pDict(nullptr), - m_bCloned(FALSE), - m_bNewData(FALSE) { + m_bCloned(false), + m_bNewData(false) { if (!bFlateEncode) { m_pData = (uint8_t*)pBuffer; m_dwSize = size; return; } - m_bNewData = TRUE; + m_bNewData = true; // TODO(thestig): Move to Init() and check return value. if (bXRefStream) ::PngEncode(pBuffer, size, &m_pData, &m_dwSize); @@ -486,14 +486,14 @@ class CPDF_Encryptor { uint8_t* m_pData; uint32_t m_dwSize; - FX_BOOL m_bNewBuf; + bool m_bNewBuf; }; CPDF_Encryptor::CPDF_Encryptor(CPDF_CryptoHandler* pHandler, int objnum, uint8_t* src_data, uint32_t src_size) - : m_pData(nullptr), m_dwSize(0), m_bNewBuf(FALSE) { + : m_pData(nullptr), m_dwSize(0), m_bNewBuf(false) { if (src_size == 0) return; @@ -505,7 +505,7 @@ CPDF_Encryptor::CPDF_Encryptor(CPDF_CryptoHandler* pHandler, m_dwSize = pHandler->EncryptGetSize(objnum, 0, src_data, src_size); m_pData = FX_Alloc(uint8_t, m_dwSize); pHandler->EncryptContent(objnum, 0, src_data, src_size, m_pData, m_dwSize); - m_bNewBuf = TRUE; + m_bNewBuf = true; } CPDF_Encryptor::~CPDF_Encryptor() { @@ -611,11 +611,11 @@ CPDF_XRefStream::CPDF_XRefStream() CPDF_XRefStream::~CPDF_XRefStream() {} -FX_BOOL CPDF_XRefStream::Start() { +bool CPDF_XRefStream::Start() { m_IndexArray.clear(); m_Buffer.Clear(); m_iSeg = 0; - return TRUE; + return true; } int32_t CPDF_XRefStream::CompressIndirectObject(uint32_t dwObjNum, const CPDF_Object* pObj, @@ -647,7 +647,7 @@ int32_t CPDF_XRefStream::CompressIndirectObject(uint32_t dwObjNum, return EndObjectStream(pCreator); } -int32_t CPDF_XRefStream::EndObjectStream(CPDF_Creator* pCreator, FX_BOOL bEOF) { +int32_t CPDF_XRefStream::EndObjectStream(CPDF_Creator* pCreator, bool bEOF) { FX_FILESIZE objOffset = 0; if (bEOF) { objOffset = m_ObjStream.End(pCreator); @@ -713,12 +713,11 @@ int32_t CPDF_XRefStream::EndObjectStream(CPDF_Creator* pCreator, FX_BOOL bEOF) { } return 1; } -FX_BOOL CPDF_XRefStream::GenerateXRefStream(CPDF_Creator* pCreator, - FX_BOOL bEOF) { +bool CPDF_XRefStream::GenerateXRefStream(CPDF_Creator* pCreator, bool bEOF) { FX_FILESIZE offset_tmp = pCreator->m_Offset; uint32_t objnum = ++pCreator->m_dwLastObjNum; CFX_FileBufferArchive* pFile = &pCreator->m_File; - FX_BOOL bIncremental = (pCreator->m_dwFlags & FPDFCREATE_INCREMENTAL) != 0; + bool bIncremental = (pCreator->m_dwFlags & FPDFCREATE_INCREMENTAL) != 0; if (bIncremental) { AddObjectNumberToIndexArray(objnum); } else { @@ -735,87 +734,87 @@ FX_BOOL CPDF_XRefStream::GenerateXRefStream(CPDF_Creator* pCreator, FX_FILESIZE& offset = pCreator->m_Offset; int32_t len = pFile->AppendDWord(objnum); if (len < 0) { - return FALSE; + return false; } offset += len; if ((len = pFile->AppendString(" 0 obj\r\n<</Type /XRef/W[1 4 2]/Index[")) < 0) { - return FALSE; + return false; } offset += len; if (!bIncremental) { if ((len = pFile->AppendDWord(0)) < 0) { - return FALSE; + return false; } if ((len = pFile->AppendString(" ")) < 0) { - return FALSE; + return false; } offset += len + 1; if ((len = pFile->AppendDWord(objnum + 1)) < 0) { - return FALSE; + return false; } offset += len; } else { for (const auto& pair : m_IndexArray) { if ((len = pFile->AppendDWord(pair.objnum)) < 0) { - return FALSE; + return false; } if (pFile->AppendString(" ") < 0) { - return FALSE; + return false; } offset += len + 1; if ((len = pFile->AppendDWord(pair.count)) < 0) { - return FALSE; + return false; } if (pFile->AppendString(" ") < 0) { - return FALSE; + return false; } offset += len + 1; } } if (pFile->AppendString("]/Size ") < 0) { - return FALSE; + return false; } if ((len = pFile->AppendDWord(objnum + 1)) < 0) { - return FALSE; + return false; } offset += len + 7; if (m_PrevOffset > 0) { if (pFile->AppendString("/Prev ") < 0) { - return FALSE; + return false; } FX_CHAR offset_buf[20]; FXSYS_memset(offset_buf, 0, sizeof(offset_buf)); FXSYS_i64toa(m_PrevOffset, offset_buf, 10); int32_t offset_len = (int32_t)FXSYS_strlen(offset_buf); if (pFile->AppendBlock(offset_buf, offset_len) < 0) { - return FALSE; + return false; } offset += offset_len + 6; } - CPDF_FlateEncoder encoder(m_Buffer.GetBuffer(), m_Buffer.GetLength(), TRUE, - TRUE); + CPDF_FlateEncoder encoder(m_Buffer.GetBuffer(), m_Buffer.GetLength(), true, + true); if (pFile->AppendString("/Filter /FlateDecode") < 0) - return FALSE; + return false; offset += 20; if ((len = pFile->AppendString("/DecodeParms<</Columns 7/Predictor 12>>")) < 0) { - return FALSE; + return false; } offset += len; if (pFile->AppendString("/Length ") < 0) - return FALSE; + return false; if ((len = pFile->AppendDWord(encoder.m_dwSize)) < 0) - return FALSE; + return false; offset += len + 8; if (bEOF) { if ((len = PDF_CreatorWriteTrailer(pCreator->m_pDocument, pFile, pCreator->m_pIDArray.get())) < 0) { - return FALSE; + return false; } offset += len; if (pCreator->m_pEncryptDict) { @@ -825,32 +824,32 @@ FX_BOOL CPDF_XRefStream::GenerateXRefStream(CPDF_Creator* pCreator, } if ((len = PDF_CreatorWriteEncrypt(pCreator->m_pEncryptDict, dwEncryptObjNum, pFile)) < 0) { - return FALSE; + return false; } offset += len; } } if ((len = pFile->AppendString(">>stream\r\n")) < 0) { - return FALSE; + return false; } offset += len; if (pFile->AppendBlock(encoder.m_pData, encoder.m_dwSize) < 0) { - return FALSE; + return false; } if ((len = pFile->AppendString("\r\nendstream\r\nendobj\r\n")) < 0) { - return FALSE; + return false; } offset += encoder.m_dwSize + len; m_PrevOffset = offset_tmp; - return TRUE; + return true; } -FX_BOOL CPDF_XRefStream::End(CPDF_Creator* pCreator, FX_BOOL bEOF) { +bool CPDF_XRefStream::End(CPDF_Creator* pCreator, bool bEOF) { if (EndObjectStream(pCreator, bEOF) < 0) { - return FALSE; + return false; } return GenerateXRefStream(pCreator, bEOF); } -FX_BOOL CPDF_XRefStream::EndXRefStream(CPDF_Creator* pCreator) { +bool CPDF_XRefStream::EndXRefStream(CPDF_Creator* pCreator) { if (!(pCreator->m_dwFlags & FPDFCREATE_INCREMENTAL)) { AppendIndex0(m_Buffer, true); for (uint32_t i = 1; i < pCreator->m_dwLastObjNum + 1; i++) { @@ -867,7 +866,7 @@ FX_BOOL CPDF_XRefStream::EndXRefStream(CPDF_Creator* pCreator) { AppendIndex1(m_Buffer, pCreator->m_ObjectOffset[j]); } } - return GenerateXRefStream(pCreator, FALSE); + return GenerateXRefStream(pCreator, false); } void CPDF_XRefStream::AddObjectNumberToIndexArray(uint32_t objnum) { if (m_IndexArray.empty()) { @@ -884,12 +883,12 @@ void CPDF_XRefStream::AddObjectNumberToIndexArray(uint32_t objnum) { CPDF_Creator::CPDF_Creator(CPDF_Document* pDoc) : m_pDocument(pDoc), m_pParser(pDoc->GetParser()), - m_bSecurityChanged(FALSE), + m_bSecurityChanged(false), m_pEncryptDict(m_pParser ? m_pParser->GetEncryptDict() : nullptr), m_dwEncryptObjNum(0), - m_bEncryptCloned(FALSE), + m_bEncryptCloned(false), m_pCryptoHandler(m_pParser ? m_pParser->GetCryptoHandler() : nullptr), - m_bLocalCryptoHandler(FALSE), + m_bLocalCryptoHandler(false), m_pMetadata(nullptr), m_ObjectStreamSize(200), m_dwLastObjNum(m_pDocument->GetLastObjNum()), @@ -1053,7 +1052,7 @@ int32_t CPDF_Creator::WriteIndirectObj(const CPDF_Object* pObj) { } int32_t CPDF_Creator::WriteDirectObj(uint32_t objnum, const CPDF_Object* pObj, - FX_BOOL bEncrypt) { + bool bEncrypt) { int32_t len = 0; if (!pObj) { if (m_File.AppendString(" null") < 0) { @@ -1081,7 +1080,7 @@ int32_t CPDF_Creator::WriteDirectObj(uint32_t objnum, break; case CPDF_Object::STRING: { CFX_ByteString str = pObj->GetString(); - FX_BOOL bHex = pObj->AsString()->IsHex(); + bool bHex = pObj->AsString()->IsHex(); if (!m_pCryptoHandler || !bEncrypt) { CFX_ByteString content = PDF_EncodeString(str, bHex); if ((len = m_File.AppendString(content.AsStringC())) < 0) { @@ -1103,7 +1102,7 @@ int32_t CPDF_Creator::WriteDirectObj(uint32_t objnum, } case CPDF_Object::STREAM: { CPDF_FlateEncoder encoder(const_cast<CPDF_Stream*>(pObj->AsStream()), - TRUE); + true); CPDF_Encryptor encryptor(m_pCryptoHandler, objnum, encoder.m_pData, encoder.m_dwSize); if ((uint32_t)encoder.m_pDict->GetIntegerFor("Length") != @@ -1190,7 +1189,7 @@ int32_t CPDF_Creator::WriteDirectObj(uint32_t objnum, const CPDF_Dictionary* p = pObj->AsDictionary(); bool bSignDict = p->IsSignatureDict(); for (const auto& it : *p) { - FX_BOOL bSignValue = FALSE; + bool bSignValue = false; const CFX_ByteString& key = it.first; CPDF_Object* pValue = it.second; if (m_File.AppendString("/") < 0) { @@ -1201,7 +1200,7 @@ int32_t CPDF_Creator::WriteDirectObj(uint32_t objnum, } m_Offset += len + 1; if (bSignDict && key == "Contents") { - bSignValue = TRUE; + bSignValue = true; } if (!pValue->IsInline()) { if (m_File.AppendString(" ") < 0) { @@ -1234,7 +1233,7 @@ int32_t CPDF_Creator::WriteOldIndirectObject(uint32_t objnum) { return 0; m_ObjectOffset[objnum] = m_Offset; - FX_BOOL bExistInMap = !!m_pDocument->GetIndirectObject(objnum); + bool bExistInMap = !!m_pDocument->GetIndirectObject(objnum); const uint8_t object_type = m_pParser->GetObjectType(objnum); bool bObjStm = (object_type == 2) && m_pEncryptDict && !m_pXRefStream; if (m_pParser->IsVersionUpdated() || m_bSecurityChanged || bExistInMap || @@ -1315,7 +1314,7 @@ int32_t CPDF_Creator::WriteOldObjs(IFX_Pause* pPause) { } return 0; } -int32_t CPDF_Creator::WriteNewObjs(FX_BOOL bIncremental, IFX_Pause* pPause) { +int32_t CPDF_Creator::WriteNewObjs(bool bIncremental, IFX_Pause* pPause) { int32_t iCount = m_NewObjNumArray.GetSize(); int32_t index = (int32_t)(uintptr_t)m_Pos; while (index < iCount) { @@ -1361,8 +1360,8 @@ void CPDF_Creator::InitOldObjNumOffsets() { } void CPDF_Creator::InitNewObjNumOffsets() { - FX_BOOL bIncremental = (m_dwFlags & FPDFCREATE_INCREMENTAL) != 0; - FX_BOOL bNoOriginal = (m_dwFlags & FPDFCREATE_NO_ORIGINAL) != 0; + bool bIncremental = (m_dwFlags & FPDFCREATE_INCREMENTAL) != 0; + bool bNoOriginal = (m_dwFlags & FPDFCREATE_NO_ORIGINAL) != 0; for (const auto& pair : *m_pDocument) { const uint32_t objnum = pair.first; const CPDF_Object* pObj = pair.second.get(); @@ -1381,7 +1380,7 @@ void CPDF_Creator::InitNewObjNumOffsets() { int32_t i = 0; uint32_t dwStartObjNum = 0; - FX_BOOL bCrossRefValid = m_pParser && m_pParser->GetLastXRefOffset() > 0; + bool bCrossRefValid = m_pParser && m_pParser->GetLastXRefOffset() > 0; while (i < iCount) { dwStartObjNum = m_NewObjNumArray.ElementAt(i); if ((bIncremental && (bNoOriginal || bCrossRefValid)) || @@ -1585,7 +1584,7 @@ int32_t CPDF_Creator::WriteDoc_Stage3(IFX_Pause* pPause) { if (m_iStage == 80) { m_XrefStart = m_Offset; if (m_dwFlags & FPDFCREATE_OBJECTSTREAM) { - m_pXRefStream->End(this, TRUE); + m_pXRefStream->End(this, true); m_XrefStart = m_pXRefStream->m_PrevOffset; m_iStage = 90; } else if ((m_dwFlags & FPDFCREATE_INCREMENTAL) == 0 || @@ -1696,7 +1695,7 @@ int32_t CPDF_Creator::WriteDoc_Stage3(IFX_Pause* pPause) { int32_t CPDF_Creator::WriteDoc_Stage4(IFX_Pause* pPause) { ASSERT(m_iStage >= 90); if ((m_dwFlags & FPDFCREATE_OBJECTSTREAM) == 0) { - FX_BOOL bXRefStream = + bool bXRefStream = (m_dwFlags & FPDFCREATE_INCREMENTAL) != 0 && m_pParser->IsXRefStream(); if (!bXRefStream) { if (m_File.AppendString("trailer\r\n<<") < 0) { @@ -1925,9 +1924,9 @@ bool CPDF_Creator::Create(uint32_t flags) { return Continue(nullptr) > -1; } -void CPDF_Creator::InitID(FX_BOOL bDefault) { +void CPDF_Creator::InitID(bool bDefault) { CPDF_Array* pOldIDArray = m_pParser ? m_pParser->GetIDArray() : nullptr; - FX_BOOL bNewId = !m_pIDArray; + bool bNewId = !m_pIDArray; if (bNewId) { m_pIDArray.reset(new CPDF_Array); CPDF_Object* pID1 = pOldIDArray ? pOldIDArray->GetObjectAt(0) : nullptr; @@ -1937,7 +1936,7 @@ void CPDF_Creator::InitID(FX_BOOL bDefault) { std::vector<uint8_t> buffer = PDF_GenerateFileID((uint32_t)(uintptr_t)this, m_dwLastObjNum); CFX_ByteString bsBuffer(buffer.data(), buffer.size()); - m_pIDArray->Add(new CPDF_String(bsBuffer, TRUE)); + m_pIDArray->Add(new CPDF_String(bsBuffer, true)); } } if (!bDefault) { @@ -1952,7 +1951,7 @@ void CPDF_Creator::InitID(FX_BOOL bDefault) { std::vector<uint8_t> buffer = PDF_GenerateFileID((uint32_t)(uintptr_t)this, m_dwLastObjNum); CFX_ByteString bsBuffer(buffer.data(), buffer.size()); - m_pIDArray->Add(new CPDF_String(bsBuffer, TRUE)); + m_pIDArray->Add(new CPDF_String(bsBuffer, true)); return; } m_pIDArray->Add(m_pIDArray->GetObjectAt(0)->Clone()); @@ -1968,8 +1967,8 @@ void CPDF_Creator::InitID(FX_BOOL bDefault) { delete m_pCryptoHandler; m_pCryptoHandler = new CPDF_CryptoHandler; m_pCryptoHandler->Init(m_pEncryptDict, &handler); - m_bLocalCryptoHandler = TRUE; - m_bSecurityChanged = TRUE; + m_bLocalCryptoHandler = true; + m_bSecurityChanged = true; } } } @@ -1999,16 +1998,16 @@ int32_t CPDF_Creator::Continue(IFX_Pause* pPause) { } return m_iStage; } -FX_BOOL CPDF_Creator::SetFileVersion(int32_t fileVersion) { +bool CPDF_Creator::SetFileVersion(int32_t fileVersion) { if (fileVersion < 10 || fileVersion > 17) { - return FALSE; + return false; } m_FileVersion = fileVersion; - return TRUE; + return true; } void CPDF_Creator::RemoveSecurity() { ResetStandardSecurity(); - m_bSecurityChanged = TRUE; + m_bSecurityChanged = true; m_pEncryptDict = nullptr; m_pCryptoHandler = nullptr; } @@ -2018,5 +2017,5 @@ void CPDF_Creator::ResetStandardSecurity() { delete m_pCryptoHandler; m_pCryptoHandler = nullptr; - m_bLocalCryptoHandler = FALSE; + m_bLocalCryptoHandler = false; } diff --git a/core/fpdfapi/font/cpdf_cidfont.cpp b/core/fpdfapi/font/cpdf_cidfont.cpp index 00c8a3662b..0217391c12 100644 --- a/core/fpdfapi/font/cpdf_cidfont.cpp +++ b/core/fpdfapi/font/cpdf_cidfont.cpp @@ -362,7 +362,7 @@ bool CPDF_CIDFont::Load() { m_pCMap = new CPDF_CMap; m_pAllocatedCMap.reset(m_pCMap); CPDF_StreamAcc acc; - acc.LoadAllData(pStream, FALSE); + acc.LoadAllData(pStream, false); m_pCMap->LoadEmbedded(acc.GetData(), acc.GetSize()); } else { return false; @@ -399,7 +399,7 @@ bool CPDF_CIDFont::Load() { if (pmap) { if (CPDF_Stream* pStream = pmap->AsStream()) { m_pStreamAcc.reset(new CPDF_StreamAcc); - m_pStreamAcc->LoadAllData(pStream, FALSE); + m_pStreamAcc->LoadAllData(pStream, false); } else if (pmap->GetString() == "Identity") { #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ if (m_pFontFile) @@ -600,7 +600,7 @@ int CPDF_CIDFont::GetVerticalGlyph(int index, bool* pVertGlyph) { int CPDF_CIDFont::GlyphFromCharCode(uint32_t charcode, bool* pVertGlyph) { if (pVertGlyph) - *pVertGlyph = FALSE; + *pVertGlyph = false; if (!m_pFontFile && !m_pStreamAcc) { uint16_t cid = CIDFromCharCode(charcode); diff --git a/core/fpdfapi/font/fpdf_font.cpp b/core/fpdfapi/font/fpdf_font.cpp index 056204ad7e..c827ea5793 100644 --- a/core/fpdfapi/font/fpdf_font.cpp +++ b/core/fpdfapi/font/fpdf_font.cpp @@ -208,7 +208,7 @@ uint32_t CPDF_ToUnicodeMap::GetUnicode() { void CPDF_ToUnicodeMap::Load(CPDF_Stream* pStream) { CIDSet cid_set = CIDSET_UNKNOWN; CPDF_StreamAcc stream; - stream.LoadAllData(pStream, FALSE); + stream.LoadAllData(pStream, false); CPDF_SimpleParser parser(stream.GetData(), stream.GetSize()); while (1) { CFX_ByteStringC word = parser.GetWord(); @@ -307,7 +307,7 @@ void CPDF_ToUnicodeMap::Load(CPDF_Stream* pStream) { m_pBaseMap = CPDF_ModuleMgr::Get() ->GetPageModule() ->GetFontGlobals() - ->m_CMapManager.GetCID2UnicodeMap(cid_set, FALSE); + ->m_CMapManager.GetCID2UnicodeMap(cid_set, false); } else { m_pBaseMap = nullptr; } diff --git a/core/fpdfapi/page/cpdf_allstates.cpp b/core/fpdfapi/page/cpdf_allstates.cpp index 70de98e3f0..012c1349c0 100644 --- a/core/fpdfapi/page/cpdf_allstates.cpp +++ b/core/fpdfapi/page/cpdf_allstates.cpp @@ -109,7 +109,7 @@ void CPDF_AllStates::ProcessExtGS(CPDF_Dictionary* pGS, m_GeneralState.SetBlendMode(pArray ? pArray->GetStringAt(0) : pObject->GetString()); if (m_GeneralState.GetBlendType() > FXDIB_BLEND_MULTIPLY) - pParser->GetPageObjectHolder()->SetBackgroundAlphaNeeded(TRUE); + pParser->GetPageObjectHolder()->SetBackgroundAlphaNeeded(true); break; } case FXBSTR_ID('S', 'M', 'a', 's'): diff --git a/core/fpdfapi/page/cpdf_clippath.cpp b/core/fpdfapi/page/cpdf_clippath.cpp index 9d4b737d33..465a1c7997 100644 --- a/core/fpdfapi/page/cpdf_clippath.cpp +++ b/core/fpdfapi/page/cpdf_clippath.cpp @@ -42,7 +42,7 @@ CPDF_TextObject* CPDF_ClipPath::GetText(size_t i) const { CFX_FloatRect CPDF_ClipPath::GetClipBox() const { CFX_FloatRect rect; - FX_BOOL bStarted = FALSE; + bool bStarted = false; int count = GetPathCount(); if (count) { rect = GetPath(0).GetBoundingBox(); @@ -50,26 +50,26 @@ CFX_FloatRect CPDF_ClipPath::GetClipBox() const { CFX_FloatRect path_rect = GetPath(i).GetBoundingBox(); rect.Intersect(path_rect); } - bStarted = TRUE; + bStarted = true; } count = GetTextCount(); if (count) { CFX_FloatRect layer_rect; - FX_BOOL bLayerStarted = FALSE; + bool bLayerStarted = false; for (int i = 0; i < count; i++) { CPDF_TextObject* pTextObj = GetText(i); if (!pTextObj) { if (!bStarted) { rect = layer_rect; - bStarted = TRUE; + bStarted = true; } else { rect.Intersect(layer_rect); } - bLayerStarted = FALSE; + bLayerStarted = false; } else { if (!bLayerStarted) { layer_rect = CFX_FloatRect(pTextObj->GetBBox(nullptr)); - bLayerStarted = TRUE; + bLayerStarted = true; } else { layer_rect.Union(CFX_FloatRect(pTextObj->GetBBox(nullptr))); } diff --git a/core/fpdfapi/page/cpdf_color.cpp b/core/fpdfapi/page/cpdf_color.cpp index 68fa0edacf..4ba28ce314 100644 --- a/core/fpdfapi/page/cpdf_color.cpp +++ b/core/fpdfapi/page/cpdf_color.cpp @@ -132,18 +132,18 @@ void CPDF_Color::Copy(const CPDF_Color* pSrc) { } } -FX_BOOL CPDF_Color::GetRGB(int& R, int& G, int& B) const { +bool CPDF_Color::GetRGB(int& R, int& G, int& B) const { if (!m_pCS || !m_pBuffer) - return FALSE; + return false; FX_FLOAT r = 0.0f, g = 0.0f, b = 0.0f; if (!m_pCS->GetRGB(m_pBuffer, r, g, b)) - return FALSE; + return false; R = (int32_t)(r * 255 + 0.5f); G = (int32_t)(g * 255 + 0.5f); B = (int32_t)(b * 255 + 0.5f); - return TRUE; + return true; } CPDF_Pattern* CPDF_Color::GetPattern() const { diff --git a/core/fpdfapi/page/cpdf_color.h b/core/fpdfapi/page/cpdf_color.h index 3eb839a684..e81b531055 100644 --- a/core/fpdfapi/page/cpdf_color.h +++ b/core/fpdfapi/page/cpdf_color.h @@ -26,7 +26,7 @@ class CPDF_Color { void SetValue(FX_FLOAT* comp); void SetValue(CPDF_Pattern* pPattern, FX_FLOAT* comp, int ncomps); - FX_BOOL GetRGB(int& R, int& G, int& B) const; + bool GetRGB(int& R, int& G, int& B) const; CPDF_Pattern* GetPattern() const; const CPDF_ColorSpace* GetColorSpace() const { return m_pCS; } diff --git a/core/fpdfapi/page/cpdf_colorspace.cpp b/core/fpdfapi/page/cpdf_colorspace.cpp index e43bacc079..2740169d04 100644 --- a/core/fpdfapi/page/cpdf_colorspace.cpp +++ b/core/fpdfapi/page/cpdf_colorspace.cpp @@ -60,23 +60,23 @@ class CPDF_CalGray : public CPDF_ColorSpace { public: explicit CPDF_CalGray(CPDF_Document* pDoc); - FX_BOOL v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) override; + bool v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) override; - FX_BOOL GetRGB(FX_FLOAT* pBuf, - FX_FLOAT& R, - FX_FLOAT& G, - FX_FLOAT& B) const override; - FX_BOOL SetRGB(FX_FLOAT* pBuf, - FX_FLOAT R, - FX_FLOAT G, - FX_FLOAT B) const override; + bool GetRGB(FX_FLOAT* pBuf, + FX_FLOAT& R, + FX_FLOAT& G, + FX_FLOAT& B) const override; + bool SetRGB(FX_FLOAT* pBuf, + FX_FLOAT R, + FX_FLOAT G, + FX_FLOAT B) const override; void TranslateImageLine(uint8_t* pDestBuf, const uint8_t* pSrcBuf, int pixels, int image_width, int image_height, - FX_BOOL bTransMask = FALSE) const override; + bool bTransMask = false) const override; private: FX_FLOAT m_WhitePoint[3]; @@ -88,57 +88,57 @@ class CPDF_CalRGB : public CPDF_ColorSpace { public: explicit CPDF_CalRGB(CPDF_Document* pDoc); - FX_BOOL v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) override; + bool v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) override; - FX_BOOL GetRGB(FX_FLOAT* pBuf, - FX_FLOAT& R, - FX_FLOAT& G, - FX_FLOAT& B) const override; - FX_BOOL SetRGB(FX_FLOAT* pBuf, - FX_FLOAT R, - FX_FLOAT G, - FX_FLOAT B) const override; + bool GetRGB(FX_FLOAT* pBuf, + FX_FLOAT& R, + FX_FLOAT& G, + FX_FLOAT& B) const override; + bool SetRGB(FX_FLOAT* pBuf, + FX_FLOAT R, + FX_FLOAT G, + FX_FLOAT B) const override; void TranslateImageLine(uint8_t* pDestBuf, const uint8_t* pSrcBuf, int pixels, int image_width, int image_height, - FX_BOOL bTransMask = FALSE) const override; + bool bTransMask = false) const override; FX_FLOAT m_WhitePoint[3]; FX_FLOAT m_BlackPoint[3]; FX_FLOAT m_Gamma[3]; FX_FLOAT m_Matrix[9]; - FX_BOOL m_bGamma; - FX_BOOL m_bMatrix; + bool m_bGamma; + bool m_bMatrix; }; class CPDF_LabCS : public CPDF_ColorSpace { public: explicit CPDF_LabCS(CPDF_Document* pDoc); - FX_BOOL v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) override; + bool v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) override; void GetDefaultValue(int iComponent, FX_FLOAT& value, FX_FLOAT& min, FX_FLOAT& max) const override; - FX_BOOL GetRGB(FX_FLOAT* pBuf, - FX_FLOAT& R, - FX_FLOAT& G, - FX_FLOAT& B) const override; - FX_BOOL SetRGB(FX_FLOAT* pBuf, - FX_FLOAT R, - FX_FLOAT G, - FX_FLOAT B) const override; + bool GetRGB(FX_FLOAT* pBuf, + FX_FLOAT& R, + FX_FLOAT& G, + FX_FLOAT& B) const override; + bool SetRGB(FX_FLOAT* pBuf, + FX_FLOAT R, + FX_FLOAT G, + FX_FLOAT B) const override; void TranslateImageLine(uint8_t* pDestBuf, const uint8_t* pSrcBuf, int pixels, int image_width, int image_height, - FX_BOOL bTransMask = FALSE) const override; + bool bTransMask = false) const override; FX_FLOAT m_WhitePoint[3]; FX_FLOAT m_BlackPoint[3]; @@ -150,36 +150,36 @@ class CPDF_ICCBasedCS : public CPDF_ColorSpace { explicit CPDF_ICCBasedCS(CPDF_Document* pDoc); ~CPDF_ICCBasedCS() override; - FX_BOOL v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) override; + bool v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) override; - FX_BOOL GetRGB(FX_FLOAT* pBuf, - FX_FLOAT& R, - FX_FLOAT& G, - FX_FLOAT& B) const override; - FX_BOOL SetRGB(FX_FLOAT* pBuf, - FX_FLOAT R, - FX_FLOAT G, - FX_FLOAT B) const override; - - FX_BOOL v_GetCMYK(FX_FLOAT* pBuf, - FX_FLOAT& c, - FX_FLOAT& m, - FX_FLOAT& y, - FX_FLOAT& k) const override; - - void EnableStdConversion(FX_BOOL bEnabled) override; + bool GetRGB(FX_FLOAT* pBuf, + FX_FLOAT& R, + FX_FLOAT& G, + FX_FLOAT& B) const override; + bool SetRGB(FX_FLOAT* pBuf, + FX_FLOAT R, + FX_FLOAT G, + FX_FLOAT B) const override; + + bool v_GetCMYK(FX_FLOAT* pBuf, + FX_FLOAT& c, + FX_FLOAT& m, + FX_FLOAT& y, + FX_FLOAT& k) const override; + + void EnableStdConversion(bool bEnabled) override; void TranslateImageLine(uint8_t* pDestBuf, const uint8_t* pSrcBuf, int pixels, int image_width, int image_height, - FX_BOOL bTransMask = FALSE) const override; + bool bTransMask = false) const override; CPDF_ColorSpace* m_pAlterCS; CPDF_IccProfile* m_pProfile; uint8_t* m_pCache; FX_FLOAT* m_pRanges; - FX_BOOL m_bOwn; + bool m_bOwn; }; class CPDF_IndexedCS : public CPDF_ColorSpace { @@ -187,15 +187,15 @@ class CPDF_IndexedCS : public CPDF_ColorSpace { explicit CPDF_IndexedCS(CPDF_Document* pDoc); ~CPDF_IndexedCS() override; - FX_BOOL v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) override; + bool v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) override; - FX_BOOL GetRGB(FX_FLOAT* pBuf, - FX_FLOAT& R, - FX_FLOAT& G, - FX_FLOAT& B) const override; + bool GetRGB(FX_FLOAT* pBuf, + FX_FLOAT& R, + FX_FLOAT& G, + FX_FLOAT& B) const override; CPDF_ColorSpace* GetBaseCS() const override; - void EnableStdConversion(FX_BOOL bEnabled) override; + void EnableStdConversion(bool bEnabled) override; CPDF_ColorSpace* m_pBaseCS; CPDF_CountedColorSpace* m_pCountedBaseCS; @@ -215,12 +215,12 @@ class CPDF_SeparationCS : public CPDF_ColorSpace { FX_FLOAT& value, FX_FLOAT& min, FX_FLOAT& max) const override; - FX_BOOL v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) override; - FX_BOOL GetRGB(FX_FLOAT* pBuf, - FX_FLOAT& R, - FX_FLOAT& G, - FX_FLOAT& B) const override; - void EnableStdConversion(FX_BOOL bEnabled) override; + bool v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) override; + bool GetRGB(FX_FLOAT* pBuf, + FX_FLOAT& R, + FX_FLOAT& G, + FX_FLOAT& B) const override; + void EnableStdConversion(bool bEnabled) override; std::unique_ptr<CPDF_ColorSpace> m_pAltCS; std::unique_ptr<CPDF_Function> m_pFunc; @@ -237,12 +237,12 @@ class CPDF_DeviceNCS : public CPDF_ColorSpace { FX_FLOAT& value, FX_FLOAT& min, FX_FLOAT& max) const override; - FX_BOOL v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) override; - FX_BOOL GetRGB(FX_FLOAT* pBuf, - FX_FLOAT& R, - FX_FLOAT& G, - FX_FLOAT& B) const override; - void EnableStdConversion(FX_BOOL bEnabled) override; + bool v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) override; + bool GetRGB(FX_FLOAT* pBuf, + FX_FLOAT& R, + FX_FLOAT& G, + FX_FLOAT& B) const override; + void EnableStdConversion(bool bEnabled) override; std::unique_ptr<CPDF_ColorSpace> m_pAltCS; std::unique_ptr<CPDF_Function> m_pFunc; @@ -418,47 +418,47 @@ FX_FLOAT* CPDF_ColorSpace::CreateBuf() { return (FX_FLOAT*)pBuf; } -FX_BOOL CPDF_ColorSpace::sRGB() const { +bool CPDF_ColorSpace::sRGB() const { if (m_Family == PDFCS_DEVICERGB) { - return TRUE; + return true; } if (m_Family != PDFCS_ICCBASED) { - return FALSE; + return false; } CPDF_ICCBasedCS* pCS = (CPDF_ICCBasedCS*)this; return pCS->m_pProfile->m_bsRGB; } -FX_BOOL CPDF_ColorSpace::SetRGB(FX_FLOAT* pBuf, - FX_FLOAT R, - FX_FLOAT G, - FX_FLOAT B) const { - return FALSE; +bool CPDF_ColorSpace::SetRGB(FX_FLOAT* pBuf, + FX_FLOAT R, + FX_FLOAT G, + FX_FLOAT B) const { + return false; } -FX_BOOL CPDF_ColorSpace::GetCMYK(FX_FLOAT* pBuf, - FX_FLOAT& c, - FX_FLOAT& m, - FX_FLOAT& y, - FX_FLOAT& k) const { +bool CPDF_ColorSpace::GetCMYK(FX_FLOAT* pBuf, + FX_FLOAT& c, + FX_FLOAT& m, + FX_FLOAT& y, + FX_FLOAT& k) const { if (v_GetCMYK(pBuf, c, m, y, k)) { - return TRUE; + return true; } FX_FLOAT R, G, B; if (!GetRGB(pBuf, R, G, B)) { - return FALSE; + return false; } sRGB_to_AdobeCMYK(R, G, B, c, m, y, k); - return TRUE; + return true; } -FX_BOOL CPDF_ColorSpace::SetCMYK(FX_FLOAT* pBuf, - FX_FLOAT c, - FX_FLOAT m, - FX_FLOAT y, - FX_FLOAT k) const { +bool CPDF_ColorSpace::SetCMYK(FX_FLOAT* pBuf, + FX_FLOAT c, + FX_FLOAT m, + FX_FLOAT y, + FX_FLOAT k) const { if (v_SetCMYK(pBuf, c, m, y, k)) { - return TRUE; + return true; } FX_FLOAT R, G, B; AdobeCMYK_to_sRGB(c, m, y, k, R, G, B); @@ -493,7 +493,7 @@ void CPDF_ColorSpace::TranslateImageLine(uint8_t* dest_buf, int pixels, int image_width, int image_height, - FX_BOOL bTransMask) const { + bool bTransMask) const { CFX_FixedBufGrow<FX_FLOAT, 16> srcbuf(m_nComponents); FX_FLOAT* src = srcbuf; FX_FLOAT R, G, B; @@ -515,7 +515,7 @@ CPDF_ColorSpace* CPDF_ColorSpace::GetBaseCS() const { return nullptr; } -void CPDF_ColorSpace::EnableStdConversion(FX_BOOL bEnabled) { +void CPDF_ColorSpace::EnableStdConversion(bool bEnabled) { if (bEnabled) m_dwStdConversion++; else if (m_dwStdConversion) @@ -533,33 +533,33 @@ CPDF_ColorSpace::CPDF_ColorSpace(CPDF_Document* pDoc, CPDF_ColorSpace::~CPDF_ColorSpace() {} -FX_BOOL CPDF_ColorSpace::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) { - return TRUE; +bool CPDF_ColorSpace::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) { + return true; } -FX_BOOL CPDF_ColorSpace::v_GetCMYK(FX_FLOAT* pBuf, - FX_FLOAT& c, - FX_FLOAT& m, - FX_FLOAT& y, - FX_FLOAT& k) const { - return FALSE; +bool CPDF_ColorSpace::v_GetCMYK(FX_FLOAT* pBuf, + FX_FLOAT& c, + FX_FLOAT& m, + FX_FLOAT& y, + FX_FLOAT& k) const { + return false; } -FX_BOOL CPDF_ColorSpace::v_SetCMYK(FX_FLOAT* pBuf, - FX_FLOAT c, - FX_FLOAT m, - FX_FLOAT y, - FX_FLOAT k) const { - return FALSE; +bool CPDF_ColorSpace::v_SetCMYK(FX_FLOAT* pBuf, + FX_FLOAT c, + FX_FLOAT m, + FX_FLOAT y, + FX_FLOAT k) const { + return false; } CPDF_CalGray::CPDF_CalGray(CPDF_Document* pDoc) : CPDF_ColorSpace(pDoc, PDFCS_CALGRAY, 1) {} -FX_BOOL CPDF_CalGray::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) { +bool CPDF_CalGray::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) { CPDF_Dictionary* pDict = pArray->GetDictAt(1); if (!pDict) - return FALSE; + return false; CPDF_Array* pParam = pDict->GetArrayFor("WhitePoint"); int i; @@ -573,26 +573,26 @@ FX_BOOL CPDF_CalGray::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) { m_Gamma = pDict->GetNumberFor("Gamma"); if (m_Gamma == 0) m_Gamma = 1.0f; - return TRUE; + return true; } -FX_BOOL CPDF_CalGray::GetRGB(FX_FLOAT* pBuf, - FX_FLOAT& R, - FX_FLOAT& G, - FX_FLOAT& B) const { +bool CPDF_CalGray::GetRGB(FX_FLOAT* pBuf, + FX_FLOAT& R, + FX_FLOAT& G, + FX_FLOAT& B) const { R = G = B = *pBuf; - return TRUE; + return true; } -FX_BOOL CPDF_CalGray::SetRGB(FX_FLOAT* pBuf, - FX_FLOAT R, - FX_FLOAT G, - FX_FLOAT B) const { +bool CPDF_CalGray::SetRGB(FX_FLOAT* pBuf, + FX_FLOAT R, + FX_FLOAT G, + FX_FLOAT B) const { if (R == G && R == B) { *pBuf = R; - return TRUE; + return true; } - return FALSE; + return false; } void CPDF_CalGray::TranslateImageLine(uint8_t* pDestBuf, @@ -600,7 +600,7 @@ void CPDF_CalGray::TranslateImageLine(uint8_t* pDestBuf, int pixels, int image_width, int image_height, - FX_BOOL bTransMask) const { + bool bTransMask) const { for (int i = 0; i < pixels; i++) { *pDestBuf++ = pSrcBuf[i]; *pDestBuf++ = pSrcBuf[i]; @@ -611,10 +611,10 @@ void CPDF_CalGray::TranslateImageLine(uint8_t* pDestBuf, CPDF_CalRGB::CPDF_CalRGB(CPDF_Document* pDoc) : CPDF_ColorSpace(pDoc, PDFCS_CALRGB, 3) {} -FX_BOOL CPDF_CalRGB::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) { +bool CPDF_CalRGB::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) { CPDF_Dictionary* pDict = pArray->GetDictAt(1); if (!pDict) - return FALSE; + return false; CPDF_Array* pParam = pDict->GetArrayFor("WhitePoint"); int i; @@ -627,28 +627,28 @@ FX_BOOL CPDF_CalRGB::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) { pParam = pDict->GetArrayFor("Gamma"); if (pParam) { - m_bGamma = TRUE; + m_bGamma = true; for (i = 0; i < 3; i++) m_Gamma[i] = pParam->GetNumberAt(i); } else { - m_bGamma = FALSE; + m_bGamma = false; } pParam = pDict->GetArrayFor("Matrix"); if (pParam) { - m_bMatrix = TRUE; + m_bMatrix = true; for (i = 0; i < 9; i++) m_Matrix[i] = pParam->GetNumberAt(i); } else { - m_bMatrix = FALSE; + m_bMatrix = false; } - return TRUE; + return true; } -FX_BOOL CPDF_CalRGB::GetRGB(FX_FLOAT* pBuf, - FX_FLOAT& R, - FX_FLOAT& G, - FX_FLOAT& B) const { +bool CPDF_CalRGB::GetRGB(FX_FLOAT* pBuf, + FX_FLOAT& R, + FX_FLOAT& G, + FX_FLOAT& B) const { FX_FLOAT A_ = pBuf[0]; FX_FLOAT B_ = pBuf[1]; FX_FLOAT C_ = pBuf[2]; @@ -672,17 +672,17 @@ FX_BOOL CPDF_CalRGB::GetRGB(FX_FLOAT* pBuf, } XYZ_to_sRGB_WhitePoint(X, Y, Z, R, G, B, m_WhitePoint[0], m_WhitePoint[1], m_WhitePoint[2]); - return TRUE; + return true; } -FX_BOOL CPDF_CalRGB::SetRGB(FX_FLOAT* pBuf, - FX_FLOAT R, - FX_FLOAT G, - FX_FLOAT B) const { +bool CPDF_CalRGB::SetRGB(FX_FLOAT* pBuf, + FX_FLOAT R, + FX_FLOAT G, + FX_FLOAT B) const { pBuf[0] = R; pBuf[1] = G; pBuf[2] = B; - return TRUE; + return true; } void CPDF_CalRGB::TranslateImageLine(uint8_t* pDestBuf, @@ -690,7 +690,7 @@ void CPDF_CalRGB::TranslateImageLine(uint8_t* pDestBuf, int pixels, int image_width, int image_height, - FX_BOOL bTransMask) const { + bool bTransMask) const { if (bTransMask) { FX_FLOAT Cal[3]; FX_FLOAT R; @@ -733,10 +733,10 @@ void CPDF_LabCS::GetDefaultValue(int iComponent, } } -FX_BOOL CPDF_LabCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) { +bool CPDF_LabCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) { CPDF_Dictionary* pDict = pArray->GetDictAt(1); if (!pDict) - return FALSE; + return false; CPDF_Array* pParam = pDict->GetArrayFor("WhitePoint"); int i; @@ -752,13 +752,13 @@ FX_BOOL CPDF_LabCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) { 100 * 1.0f}; for (i = 0; i < 4; i++) m_Ranges[i] = pParam ? pParam->GetNumberAt(i) : def_ranges[i]; - return TRUE; + return true; } -FX_BOOL CPDF_LabCS::GetRGB(FX_FLOAT* pBuf, - FX_FLOAT& R, - FX_FLOAT& G, - FX_FLOAT& B) const { +bool CPDF_LabCS::GetRGB(FX_FLOAT* pBuf, + FX_FLOAT& R, + FX_FLOAT& G, + FX_FLOAT& B) const { FX_FLOAT Lstar = pBuf[0]; FX_FLOAT astar = pBuf[1]; FX_FLOAT bstar = pBuf[2]; @@ -782,14 +782,14 @@ FX_BOOL CPDF_LabCS::GetRGB(FX_FLOAT* pBuf, Z = 1.0889f * N * N * N; XYZ_to_sRGB(X, Y, Z, R, G, B); - return TRUE; + return true; } -FX_BOOL CPDF_LabCS::SetRGB(FX_FLOAT* pBuf, - FX_FLOAT R, - FX_FLOAT G, - FX_FLOAT B) const { - return FALSE; +bool CPDF_LabCS::SetRGB(FX_FLOAT* pBuf, + FX_FLOAT R, + FX_FLOAT G, + FX_FLOAT B) const { + return false; } void CPDF_LabCS::TranslateImageLine(uint8_t* pDestBuf, @@ -797,7 +797,7 @@ void CPDF_LabCS::TranslateImageLine(uint8_t* pDestBuf, int pixels, int image_width, int image_height, - FX_BOOL bTransMask) const { + bool bTransMask) const { for (int i = 0; i < pixels; i++) { FX_FLOAT lab[3]; FX_FLOAT R, G, B; @@ -819,7 +819,7 @@ CPDF_ICCBasedCS::CPDF_ICCBasedCS(CPDF_Document* pDoc) m_pProfile(nullptr), m_pCache(nullptr), m_pRanges(nullptr), - m_bOwn(FALSE) {} + m_bOwn(false) {} CPDF_ICCBasedCS::~CPDF_ICCBasedCS() { FX_Free(m_pCache); @@ -830,14 +830,14 @@ CPDF_ICCBasedCS::~CPDF_ICCBasedCS() { m_pDocument->GetPageData()->ReleaseIccProfile(m_pProfile); } -FX_BOOL CPDF_ICCBasedCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) { +bool CPDF_ICCBasedCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) { CPDF_Stream* pStream = pArray->GetStreamAt(1); if (!pStream) - return FALSE; + return false; m_pProfile = pDoc->LoadIccProfile(pStream); if (!m_pProfile) - return FALSE; + return false; m_nComponents = m_pProfile @@ -854,19 +854,19 @@ FX_BOOL CPDF_ICCBasedCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) { if (pAlterCS->CountComponents() > 0) { // Use Alternative colorspace m_nComponents = pAlterCS->CountComponents(); m_pAlterCS = pAlterCS.release(); - m_bOwn = TRUE; + m_bOwn = true; } else { // No valid alternative colorspace int32_t nDictComponents = pDict ? pDict->GetIntegerFor("N") : 0; if (nDictComponents != 1 && nDictComponents != 3 && nDictComponents != 4) { - return FALSE; + return false; } m_nComponents = nDictComponents; } } else { // Using sRGB if (pAlterCS->CountComponents() == m_nComponents) { m_pAlterCS = pAlterCS.release(); - m_bOwn = TRUE; + m_bOwn = true; } } } @@ -890,18 +890,18 @@ FX_BOOL CPDF_ICCBasedCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) { else m_pRanges[i] = 0; } - return TRUE; + return true; } -FX_BOOL CPDF_ICCBasedCS::GetRGB(FX_FLOAT* pBuf, - FX_FLOAT& R, - FX_FLOAT& G, - FX_FLOAT& B) const { +bool CPDF_ICCBasedCS::GetRGB(FX_FLOAT* pBuf, + FX_FLOAT& R, + FX_FLOAT& G, + FX_FLOAT& B) const { if (m_pProfile && m_pProfile->m_bsRGB) { R = pBuf[0]; G = pBuf[1]; B = pBuf[2]; - return TRUE; + return true; } CCodec_IccModule* pIccModule = CPDF_ModuleMgr::Get()->GetIccModule(); if (!m_pProfile->m_pTransform || !pIccModule) { @@ -911,7 +911,7 @@ FX_BOOL CPDF_ICCBasedCS::GetRGB(FX_FLOAT* pBuf, R = 0.0f; G = 0.0f; B = 0.0f; - return TRUE; + return true; } FX_FLOAT rgb[3]; pIccModule->SetComponents(m_nComponents); @@ -919,32 +919,32 @@ FX_BOOL CPDF_ICCBasedCS::GetRGB(FX_FLOAT* pBuf, R = rgb[0]; G = rgb[1]; B = rgb[2]; - return TRUE; + return true; } -FX_BOOL CPDF_ICCBasedCS::SetRGB(FX_FLOAT* pBuf, - FX_FLOAT R, - FX_FLOAT G, - FX_FLOAT B) const { - return FALSE; +bool CPDF_ICCBasedCS::SetRGB(FX_FLOAT* pBuf, + FX_FLOAT R, + FX_FLOAT G, + FX_FLOAT B) const { + return false; } -FX_BOOL CPDF_ICCBasedCS::v_GetCMYK(FX_FLOAT* pBuf, - FX_FLOAT& c, - FX_FLOAT& m, - FX_FLOAT& y, - FX_FLOAT& k) const { +bool CPDF_ICCBasedCS::v_GetCMYK(FX_FLOAT* pBuf, + FX_FLOAT& c, + FX_FLOAT& m, + FX_FLOAT& y, + FX_FLOAT& k) const { if (m_nComponents != 4) - return FALSE; + return false; c = pBuf[0]; m = pBuf[1]; y = pBuf[2]; k = pBuf[3]; - return TRUE; + return true; } -void CPDF_ICCBasedCS::EnableStdConversion(FX_BOOL bEnabled) { +void CPDF_ICCBasedCS::EnableStdConversion(bool bEnabled) { CPDF_ColorSpace::EnableStdConversion(bEnabled); if (m_pAlterCS) m_pAlterCS->EnableStdConversion(bEnabled); @@ -955,7 +955,7 @@ void CPDF_ICCBasedCS::TranslateImageLine(uint8_t* pDestBuf, int pixels, int image_width, int image_height, - FX_BOOL bTransMask) const { + bool bTransMask) const { if (m_pProfile->m_bsRGB) { ReverseRGB(pDestBuf, pSrcBuf, pixels); } else if (m_pProfile->m_pTransform) { @@ -1016,18 +1016,18 @@ CPDF_IndexedCS::~CPDF_IndexedCS() { } } -FX_BOOL CPDF_IndexedCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) { +bool CPDF_IndexedCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) { if (pArray->GetCount() < 4) { - return FALSE; + return false; } CPDF_Object* pBaseObj = pArray->GetDirectObjectAt(1); if (pBaseObj == m_pArray) { - return FALSE; + return false; } CPDF_DocPageData* pDocPageData = pDoc->GetPageData(); m_pBaseCS = pDocPageData->GetColorSpace(pBaseObj, nullptr); if (!m_pBaseCS) { - return FALSE; + return false; } m_pCountedBaseCS = pDocPageData->FindColorSpacePtr(m_pBaseCS->GetArray()); m_nBaseComponents = m_pBaseCS->CountComponents(); @@ -1042,31 +1042,31 @@ FX_BOOL CPDF_IndexedCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) { CPDF_Object* pTableObj = pArray->GetDirectObjectAt(3); if (!pTableObj) - return FALSE; + return false; if (CPDF_String* pString = pTableObj->AsString()) { m_Table = pString->GetString(); } else if (CPDF_Stream* pStream = pTableObj->AsStream()) { CPDF_StreamAcc acc; - acc.LoadAllData(pStream, FALSE); + acc.LoadAllData(pStream, false); m_Table = CFX_ByteStringC(acc.GetData(), acc.GetSize()); } - return TRUE; + return true; } -FX_BOOL CPDF_IndexedCS::GetRGB(FX_FLOAT* pBuf, - FX_FLOAT& R, - FX_FLOAT& G, - FX_FLOAT& B) const { +bool CPDF_IndexedCS::GetRGB(FX_FLOAT* pBuf, + FX_FLOAT& R, + FX_FLOAT& G, + FX_FLOAT& B) const { int index = (int32_t)(*pBuf); if (index < 0 || index > m_MaxIndex) { - return FALSE; + return false; } if (m_nBaseComponents) { if (index == INT_MAX || (index + 1) > INT_MAX / m_nBaseComponents || (index + 1) * m_nBaseComponents > (int)m_Table.GetLength()) { R = G = B = 0; - return FALSE; + return false; } } CFX_FixedBufGrow<FX_FLOAT, 16> Comps(m_nBaseComponents); @@ -1084,7 +1084,7 @@ CPDF_ColorSpace* CPDF_IndexedCS::GetBaseCS() const { return m_pBaseCS; } -void CPDF_IndexedCS::EnableStdConversion(FX_BOOL bEnabled) { +void CPDF_IndexedCS::EnableStdConversion(bool bEnabled) { CPDF_ColorSpace::EnableStdConversion(bEnabled); if (m_pBaseCS) { m_pBaseCS->EnableStdConversion(bEnabled); @@ -1103,41 +1103,41 @@ CPDF_PatternCS::~CPDF_PatternCS() { } } -FX_BOOL CPDF_PatternCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) { +bool CPDF_PatternCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) { CPDF_Object* pBaseCS = pArray->GetDirectObjectAt(1); if (pBaseCS == m_pArray) { - return FALSE; + return false; } CPDF_DocPageData* pDocPageData = pDoc->GetPageData(); m_pBaseCS = pDocPageData->GetColorSpace(pBaseCS, nullptr); if (m_pBaseCS) { if (m_pBaseCS->GetFamily() == PDFCS_PATTERN) { - return FALSE; + return false; } m_pCountedBaseCS = pDocPageData->FindColorSpacePtr(m_pBaseCS->GetArray()); m_nComponents = m_pBaseCS->CountComponents() + 1; if (m_pBaseCS->CountComponents() > MAX_PATTERN_COLORCOMPS) { - return FALSE; + return false; } } else { m_nComponents = 1; } - return TRUE; + return true; } -FX_BOOL CPDF_PatternCS::GetRGB(FX_FLOAT* pBuf, - FX_FLOAT& R, - FX_FLOAT& G, - FX_FLOAT& B) const { +bool CPDF_PatternCS::GetRGB(FX_FLOAT* pBuf, + FX_FLOAT& R, + FX_FLOAT& G, + FX_FLOAT& B) const { if (m_pBaseCS) { ASSERT(m_pBaseCS->GetFamily() != PDFCS_PATTERN); PatternValue* pvalue = (PatternValue*)pBuf; if (m_pBaseCS->GetRGB(pvalue->m_Comps, R, G, B)) { - return TRUE; + return true; } } R = G = B = 0.75f; - return FALSE; + return false; } CPDF_ColorSpace* CPDF_PatternCS::GetBaseCS() const { @@ -1158,21 +1158,21 @@ void CPDF_SeparationCS::GetDefaultValue(int iComponent, max = 1.0f; } -FX_BOOL CPDF_SeparationCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) { +bool CPDF_SeparationCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) { CFX_ByteString name = pArray->GetStringAt(1); if (name == "None") { m_Type = None; - return TRUE; + return true; } m_Type = Colorant; CPDF_Object* pAltCS = pArray->GetDirectObjectAt(2); if (pAltCS == m_pArray) - return FALSE; + return false; m_pAltCS = Load(pDoc, pAltCS); if (!m_pAltCS) - return FALSE; + return false; CPDF_Object* pFuncObj = pArray->GetDirectObjectAt(3); if (pFuncObj && !pFuncObj->IsName()) @@ -1180,19 +1180,19 @@ FX_BOOL CPDF_SeparationCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) { if (m_pFunc && m_pFunc->CountOutputs() < m_pAltCS->CountComponents()) m_pFunc.reset(); - return TRUE; + return true; } -FX_BOOL CPDF_SeparationCS::GetRGB(FX_FLOAT* pBuf, - FX_FLOAT& R, - FX_FLOAT& G, - FX_FLOAT& B) const { +bool CPDF_SeparationCS::GetRGB(FX_FLOAT* pBuf, + FX_FLOAT& R, + FX_FLOAT& G, + FX_FLOAT& B) const { if (m_Type == None) - return FALSE; + return false; if (!m_pFunc) { if (!m_pAltCS) - return FALSE; + return false; int nComps = m_pAltCS->CountComponents(); CFX_FixedBufGrow<FX_FLOAT, 16> results(nComps); @@ -1205,7 +1205,7 @@ FX_BOOL CPDF_SeparationCS::GetRGB(FX_FLOAT* pBuf, int nresults = 0; m_pFunc->Call(pBuf, 1, results, nresults); if (nresults == 0) - return FALSE; + return false; if (m_pAltCS) return m_pAltCS->GetRGB(results, R, G, B); @@ -1213,10 +1213,10 @@ FX_BOOL CPDF_SeparationCS::GetRGB(FX_FLOAT* pBuf, R = 0; G = 0; B = 0; - return FALSE; + return false; } -void CPDF_SeparationCS::EnableStdConversion(FX_BOOL bEnabled) { +void CPDF_SeparationCS::EnableStdConversion(bool bEnabled) { CPDF_ColorSpace::EnableStdConversion(bEnabled); if (m_pAltCS) m_pAltCS->EnableStdConversion(bEnabled); @@ -1236,41 +1236,41 @@ void CPDF_DeviceNCS::GetDefaultValue(int iComponent, max = 1.0f; } -FX_BOOL CPDF_DeviceNCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) { +bool CPDF_DeviceNCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) { CPDF_Array* pObj = ToArray(pArray->GetDirectObjectAt(1)); if (!pObj) - return FALSE; + return false; m_nComponents = pObj->GetCount(); CPDF_Object* pAltCS = pArray->GetDirectObjectAt(2); if (!pAltCS || pAltCS == m_pArray) - return FALSE; + return false; m_pAltCS = Load(pDoc, pAltCS); m_pFunc = CPDF_Function::Load(pArray->GetDirectObjectAt(3)); if (!m_pAltCS || !m_pFunc) - return FALSE; + return false; return m_pFunc->CountOutputs() >= m_pAltCS->CountComponents(); } -FX_BOOL CPDF_DeviceNCS::GetRGB(FX_FLOAT* pBuf, - FX_FLOAT& R, - FX_FLOAT& G, - FX_FLOAT& B) const { +bool CPDF_DeviceNCS::GetRGB(FX_FLOAT* pBuf, + FX_FLOAT& R, + FX_FLOAT& G, + FX_FLOAT& B) const { if (!m_pFunc) - return FALSE; + return false; CFX_FixedBufGrow<FX_FLOAT, 16> results(m_pFunc->CountOutputs()); int nresults = 0; m_pFunc->Call(pBuf, m_nComponents, results, nresults); if (nresults == 0) - return FALSE; + return false; return m_pAltCS->GetRGB(results, R, G, B); } -void CPDF_DeviceNCS::EnableStdConversion(FX_BOOL bEnabled) { +void CPDF_DeviceNCS::EnableStdConversion(bool bEnabled) { CPDF_ColorSpace::EnableStdConversion(bEnabled); if (m_pAltCS) { m_pAltCS->EnableStdConversion(bEnabled); diff --git a/core/fpdfapi/page/cpdf_colorspace.h b/core/fpdfapi/page/cpdf_colorspace.h index 78311ce195..c4d62ed849 100644 --- a/core/fpdfapi/page/cpdf_colorspace.h +++ b/core/fpdfapi/page/cpdf_colorspace.h @@ -47,38 +47,35 @@ class CPDF_ColorSpace { FX_FLOAT& min, FX_FLOAT& max) const; - FX_BOOL sRGB() const; - virtual FX_BOOL GetRGB(FX_FLOAT* pBuf, - FX_FLOAT& R, - FX_FLOAT& G, - FX_FLOAT& B) const = 0; - virtual FX_BOOL SetRGB(FX_FLOAT* pBuf, - FX_FLOAT R, - FX_FLOAT G, - FX_FLOAT B) const; - - FX_BOOL GetCMYK(FX_FLOAT* pBuf, - FX_FLOAT& c, - FX_FLOAT& m, - FX_FLOAT& y, - FX_FLOAT& k) const; - FX_BOOL SetCMYK(FX_FLOAT* pBuf, - FX_FLOAT c, - FX_FLOAT m, - FX_FLOAT y, - FX_FLOAT k) const; + bool sRGB() const; + virtual bool GetRGB(FX_FLOAT* pBuf, + FX_FLOAT& R, + FX_FLOAT& G, + FX_FLOAT& B) const = 0; + virtual bool SetRGB(FX_FLOAT* pBuf, FX_FLOAT R, FX_FLOAT G, FX_FLOAT B) const; + + bool GetCMYK(FX_FLOAT* pBuf, + FX_FLOAT& c, + FX_FLOAT& m, + FX_FLOAT& y, + FX_FLOAT& k) const; + bool SetCMYK(FX_FLOAT* pBuf, + FX_FLOAT c, + FX_FLOAT m, + FX_FLOAT y, + FX_FLOAT k) const; virtual void TranslateImageLine(uint8_t* dest_buf, const uint8_t* src_buf, int pixels, int image_width, int image_height, - FX_BOOL bTransMask = FALSE) const; + bool bTransMask = false) const; CPDF_Array*& GetArray() { return m_pArray; } virtual CPDF_ColorSpace* GetBaseCS() const; - virtual void EnableStdConversion(FX_BOOL bEnabled); + virtual void EnableStdConversion(bool bEnabled); CPDF_Document* const m_pDocument; @@ -86,17 +83,17 @@ class CPDF_ColorSpace { CPDF_ColorSpace(CPDF_Document* pDoc, int family, uint32_t nComponents); virtual ~CPDF_ColorSpace(); - virtual FX_BOOL v_Load(CPDF_Document* pDoc, CPDF_Array* pArray); - virtual FX_BOOL v_GetCMYK(FX_FLOAT* pBuf, - FX_FLOAT& c, - FX_FLOAT& m, - FX_FLOAT& y, - FX_FLOAT& k) const; - virtual FX_BOOL v_SetCMYK(FX_FLOAT* pBuf, - FX_FLOAT c, - FX_FLOAT m, - FX_FLOAT y, - FX_FLOAT k) const; + virtual bool v_Load(CPDF_Document* pDoc, CPDF_Array* pArray); + virtual bool v_GetCMYK(FX_FLOAT* pBuf, + FX_FLOAT& c, + FX_FLOAT& m, + FX_FLOAT& y, + FX_FLOAT& k) const; + virtual bool v_SetCMYK(FX_FLOAT* pBuf, + FX_FLOAT c, + FX_FLOAT m, + FX_FLOAT y, + FX_FLOAT k) const; int m_Family; uint32_t m_nComponents; diff --git a/core/fpdfapi/page/cpdf_colorstate.cpp b/core/fpdfapi/page/cpdf_colorstate.cpp index da583122af..c43a331c64 100644 --- a/core/fpdfapi/page/cpdf_colorstate.cpp +++ b/core/fpdfapi/page/cpdf_colorstate.cpp @@ -89,7 +89,7 @@ void CPDF_ColorState::SetFillPattern(CPDF_Pattern* pPattern, ColorData* pData = m_Ref.GetPrivateCopy(); pData->m_FillColor.SetValue(pPattern, pValue, nValues); int R, G, B; - FX_BOOL ret = pData->m_FillColor.GetRGB(R, G, B); + bool ret = pData->m_FillColor.GetRGB(R, G, B); if (CPDF_TilingPattern* pTilingPattern = pPattern->AsTilingPattern()) { if (!ret && pTilingPattern->colored()) { pData->m_FillRGB = 0x00BFBFBF; @@ -105,7 +105,7 @@ void CPDF_ColorState::SetStrokePattern(CPDF_Pattern* pPattern, ColorData* pData = m_Ref.GetPrivateCopy(); pData->m_StrokeColor.SetValue(pPattern, pValue, nValues); int R, G, B; - FX_BOOL ret = pData->m_StrokeColor.GetRGB(R, G, B); + bool ret = pData->m_StrokeColor.GetRGB(R, G, B); if (CPDF_TilingPattern* pTilingPattern = pPattern->AsTilingPattern()) { if (!ret && pTilingPattern->colored()) { pData->m_StrokeRGB = 0x00BFBFBF; diff --git a/core/fpdfapi/page/cpdf_contentmark.cpp b/core/fpdfapi/page/cpdf_contentmark.cpp index 4e8625b940..d60e144d6e 100644 --- a/core/fpdfapi/page/cpdf_contentmark.cpp +++ b/core/fpdfapi/page/cpdf_contentmark.cpp @@ -35,7 +35,7 @@ int CPDF_ContentMark::GetMCID() const { void CPDF_ContentMark::AddMark(const CFX_ByteString& name, CPDF_Dictionary* pDict, - FX_BOOL bDirect) { + bool bDirect) { m_Ref.GetPrivateCopy()->AddMark(name, pDict, bDirect); } @@ -104,7 +104,7 @@ int CPDF_ContentMark::MarkData::GetMCID() const { void CPDF_ContentMark::MarkData::AddMark(const CFX_ByteString& name, CPDF_Dictionary* pDict, - FX_BOOL bDirect) { + bool bDirect) { CPDF_ContentMarkItem item; item.SetName(name); if (pDict) { diff --git a/core/fpdfapi/page/cpdf_contentmark.h b/core/fpdfapi/page/cpdf_contentmark.h index 485fe3b4c6..154f19d529 100644 --- a/core/fpdfapi/page/cpdf_contentmark.h +++ b/core/fpdfapi/page/cpdf_contentmark.h @@ -32,7 +32,7 @@ class CPDF_ContentMark { bool LookupMark(const CFX_ByteStringC& mark, CPDF_Dictionary*& pDict) const; void AddMark(const CFX_ByteString& name, CPDF_Dictionary* pDict, - FX_BOOL bDirect); + bool bDirect); void DeleteLastMark(); explicit operator bool() const { return !!m_Ref; } @@ -51,7 +51,7 @@ class CPDF_ContentMark { int GetMCID() const; void AddMark(const CFX_ByteString& name, CPDF_Dictionary* pDict, - FX_BOOL bDictNeedClone); + bool bDictNeedClone); void DeleteLastMark(); private: diff --git a/core/fpdfapi/page/cpdf_contentmarkitem.cpp b/core/fpdfapi/page/cpdf_contentmarkitem.cpp index 507dc22d9a..597f8a595c 100644 --- a/core/fpdfapi/page/cpdf_contentmarkitem.cpp +++ b/core/fpdfapi/page/cpdf_contentmarkitem.cpp @@ -33,7 +33,7 @@ CPDF_Dictionary* CPDF_ContentMarkItem::GetParam() const { } } -FX_BOOL CPDF_ContentMarkItem::HasMCID() const { +bool CPDF_ContentMarkItem::HasMCID() const { CPDF_Dictionary* pDict = GetParam(); return pDict && pDict->KeyExist("MCID"); } diff --git a/core/fpdfapi/page/cpdf_contentmarkitem.h b/core/fpdfapi/page/cpdf_contentmarkitem.h index ef691e252c..f1f06c3a38 100644 --- a/core/fpdfapi/page/cpdf_contentmarkitem.h +++ b/core/fpdfapi/page/cpdf_contentmarkitem.h @@ -28,7 +28,7 @@ class CPDF_ContentMarkItem { CFX_ByteString GetName() const { return m_MarkName; } ParamType GetParamType() const { return m_ParamType; } CPDF_Dictionary* GetParam() const; - FX_BOOL HasMCID() const; + bool HasMCID() const; void SetName(const CFX_ByteString& name) { m_MarkName = name; } void SetDirectDict( diff --git a/core/fpdfapi/page/cpdf_docpagedata.cpp b/core/fpdfapi/page/cpdf_docpagedata.cpp index 5f1f561ebb..c4dc050215 100644 --- a/core/fpdfapi/page/cpdf_docpagedata.cpp +++ b/core/fpdfapi/page/cpdf_docpagedata.cpp @@ -445,7 +445,7 @@ CPDF_IccProfile* CPDF_DocPageData::GetIccProfile( return it->second->AddRef(); CPDF_StreamAcc stream; - stream.LoadAllData(pIccProfileStream, FALSE); + stream.LoadAllData(pIccProfileStream, false); uint8_t digest[20]; CRYPT_SHA1Generate(stream.GetData(), stream.GetSize(), digest); CFX_ByteString bsDigest(digest, 20); @@ -497,7 +497,7 @@ CPDF_StreamAcc* CPDF_DocPageData::GetFontFileStreamAcc( org_size = std::max(org_size, 0); CPDF_StreamAcc* pFontFile = new CPDF_StreamAcc; - pFontFile->LoadAllData(pFontStream, FALSE, org_size); + pFontFile->LoadAllData(pFontStream, false, org_size); CPDF_CountedStreamAcc* pCountedFont = new CPDF_CountedStreamAcc(pFontFile); m_FontFileMap[pFontStream] = pCountedFont; diff --git a/core/fpdfapi/page/cpdf_docpagedata.h b/core/fpdfapi/page/cpdf_docpagedata.h index 64c0444a5e..bf2b80498d 100644 --- a/core/fpdfapi/page/cpdf_docpagedata.h +++ b/core/fpdfapi/page/cpdf_docpagedata.h @@ -29,7 +29,7 @@ class CPDF_DocPageData { explicit CPDF_DocPageData(CPDF_Document* pPDFDoc); ~CPDF_DocPageData(); - void Clear(bool bRelease = FALSE); + void Clear(bool bRelease = false); CPDF_Font* GetFont(CPDF_Dictionary* pFontDict); CPDF_Font* GetStandardFont(const CFX_ByteString& fontName, CPDF_FontEncoding* pEncoding); diff --git a/core/fpdfapi/page/cpdf_image.cpp b/core/fpdfapi/page/cpdf_image.cpp index b40bc3ca8e..23c6e4f786 100644 --- a/core/fpdfapi/page/cpdf_image.cpp +++ b/core/fpdfapi/page/cpdf_image.cpp @@ -115,7 +115,7 @@ CPDF_Dictionary* CPDF_Image::InitJPEG(uint8_t* pData, uint32_t size) { pDict->SetFor("DecodeParms", pParms); pParms->SetIntegerFor("ColorTransform", 0); } - m_bIsMask = FALSE; + m_bIsMask = false; m_Width = width; m_Height = height; if (!m_pStream) @@ -170,7 +170,7 @@ void CPDF_Image::SetImage(const CFX_DIBitmap* pBitmap, int32_t iCompress) { ArgbDecode(pBitmap->GetPaletteArgb(1), set_a, set_r, set_g, set_b); } if (set_a == 0 || reset_a == 0) { - pDict->SetFor("ImageMask", new CPDF_Boolean(TRUE)); + pDict->SetFor("ImageMask", new CPDF_Boolean(true)); if (reset_a == 0) { CPDF_Array* pArray = new CPDF_Array; pArray->AddInteger(1); @@ -191,7 +191,7 @@ void CPDF_Image::SetImage(const CFX_DIBitmap* pBitmap, int32_t iCompress) { pBuf[4] = (FX_CHAR)set_g; pBuf[5] = (FX_CHAR)set_b; ct.ReleaseBuffer(6); - pCS->Add(new CPDF_String(ct, TRUE)); + pCS->Add(new CPDF_String(ct, true)); pDict->SetFor("ColorSpace", pCS); } pDict->SetIntegerFor("BitsPerComponent", 1); @@ -244,10 +244,10 @@ void CPDF_Image::SetImage(const CFX_DIBitmap* pBitmap, int32_t iCompress) { } } const CFX_DIBitmap* pMaskBitmap = nullptr; - FX_BOOL bDeleteMask = FALSE; + bool bDeleteMask = false; if (pBitmap->HasAlpha()) { pMaskBitmap = pBitmap->GetAlphaMask(); - bDeleteMask = TRUE; + bDeleteMask = true; } if (pMaskBitmap) { int32_t maskWidth = pMaskBitmap->GetWidth(); @@ -348,9 +348,9 @@ void CPDF_Image::ResetCache(CPDF_Page* pPage, const CFX_DIBitmap* pBitmap) { CFX_DIBSource* CPDF_Image::LoadDIBSource(CFX_DIBSource** ppMask, uint32_t* pMatteColor, - FX_BOOL bStdCS, + bool bStdCS, uint32_t GroupFamily, - FX_BOOL bLoadMask) const { + bool bLoadMask) const { std::unique_ptr<CPDF_DIBSource> source(new CPDF_DIBSource); if (source->Load(m_pDocument, m_pStream, reinterpret_cast<CPDF_DIBSource**>(ppMask), pMatteColor, @@ -372,41 +372,41 @@ CFX_DIBSource* CPDF_Image::DetachMask() { return pBitmap; } -FX_BOOL CPDF_Image::StartLoadDIBSource(CPDF_Dictionary* pFormResource, - CPDF_Dictionary* pPageResource, - FX_BOOL bStdCS, - uint32_t GroupFamily, - FX_BOOL bLoadMask) { +bool CPDF_Image::StartLoadDIBSource(CPDF_Dictionary* pFormResource, + CPDF_Dictionary* pPageResource, + bool bStdCS, + uint32_t GroupFamily, + bool bLoadMask) { std::unique_ptr<CPDF_DIBSource> source(new CPDF_DIBSource); int ret = - source->StartLoadDIBSource(m_pDocument, m_pStream, TRUE, pFormResource, + source->StartLoadDIBSource(m_pDocument, m_pStream, true, pFormResource, pPageResource, bStdCS, GroupFamily, bLoadMask); if (ret == 2) { m_pDIBSource = source.release(); - return TRUE; + return true; } if (!ret) { m_pDIBSource = nullptr; - return FALSE; + return false; } m_pMask = source->DetachMask(); m_MatteColor = source->GetMatteColor(); m_pDIBSource = source.release(); - return FALSE; + return false; } -FX_BOOL CPDF_Image::Continue(IFX_Pause* pPause) { +bool CPDF_Image::Continue(IFX_Pause* pPause) { CPDF_DIBSource* pSource = static_cast<CPDF_DIBSource*>(m_pDIBSource); int ret = pSource->ContinueLoadDIBSource(pPause); if (ret == 2) { - return TRUE; + return true; } if (!ret) { delete m_pDIBSource; m_pDIBSource = nullptr; - return FALSE; + return false; } m_pMask = pSource->DetachMask(); m_MatteColor = pSource->GetMatteColor(); - return FALSE; + return false; } diff --git a/core/fpdfapi/page/cpdf_image.h b/core/fpdfapi/page/cpdf_image.h index 1e6f70fa33..f619845597 100644 --- a/core/fpdfapi/page/cpdf_image.h +++ b/core/fpdfapi/page/cpdf_image.h @@ -51,21 +51,21 @@ class CPDF_Image { CFX_DIBSource* LoadDIBSource(CFX_DIBSource** ppMask = nullptr, uint32_t* pMatteColor = nullptr, - FX_BOOL bStdCS = FALSE, + bool bStdCS = false, uint32_t GroupFamily = 0, - FX_BOOL bLoadMask = FALSE) const; + bool bLoadMask = false) const; void SetImage(const CFX_DIBitmap* pDIBitmap, int32_t iCompress); void SetJpegImage(IFX_SeekableReadStream* pFile); void ResetCache(CPDF_Page* pPage, const CFX_DIBitmap* pDIBitmap); - FX_BOOL StartLoadDIBSource(CPDF_Dictionary* pFormResource, - CPDF_Dictionary* pPageResource, - FX_BOOL bStdCS = FALSE, - uint32_t GroupFamily = 0, - FX_BOOL bLoadMask = FALSE); - FX_BOOL Continue(IFX_Pause* pPause); + bool StartLoadDIBSource(CPDF_Dictionary* pFormResource, + CPDF_Dictionary* pPageResource, + bool bStdCS = false, + uint32_t GroupFamily = 0, + bool bLoadMask = false); + bool Continue(IFX_Pause* pPause); CFX_DIBSource* DetachBitmap(); CFX_DIBSource* DetachMask(); diff --git a/core/fpdfapi/page/cpdf_meshstream.cpp b/core/fpdfapi/page/cpdf_meshstream.cpp index c3bfcb4ab5..8bc2a851cc 100644 --- a/core/fpdfapi/page/cpdf_meshstream.cpp +++ b/core/fpdfapi/page/cpdf_meshstream.cpp @@ -201,17 +201,17 @@ uint32_t CPDF_MeshStream::GetVertex(CPDF_MeshVertex& vertex, return flag; } -FX_BOOL CPDF_MeshStream::GetVertexRow(CPDF_MeshVertex* vertex, - int count, - CFX_Matrix* pObject2Bitmap) { +bool CPDF_MeshStream::GetVertexRow(CPDF_MeshVertex* vertex, + int count, + CFX_Matrix* pObject2Bitmap) { for (int i = 0; i < count; i++) { if (m_BitStream.IsEOF()) - return FALSE; + return false; GetCoords(vertex[i].x, vertex[i].y); pObject2Bitmap->Transform(vertex[i].x, vertex[i].y); GetColor(vertex[i].r, vertex[i].g, vertex[i].b); m_BitStream.ByteAlign(); } - return TRUE; + return true; } diff --git a/core/fpdfapi/page/cpdf_meshstream.h b/core/fpdfapi/page/cpdf_meshstream.h index 4d37f17889..21a6c2fa8c 100644 --- a/core/fpdfapi/page/cpdf_meshstream.h +++ b/core/fpdfapi/page/cpdf_meshstream.h @@ -42,9 +42,9 @@ class CPDF_MeshStream { void GetColor(FX_FLOAT& r, FX_FLOAT& g, FX_FLOAT& b); uint32_t GetVertex(CPDF_MeshVertex& vertex, CFX_Matrix* pObject2Bitmap); - FX_BOOL GetVertexRow(CPDF_MeshVertex* vertex, - int count, - CFX_Matrix* pObject2Bitmap); + bool GetVertexRow(CPDF_MeshVertex* vertex, + int count, + CFX_Matrix* pObject2Bitmap); CFX_BitStream* BitStream() { return &m_BitStream; } uint32_t ComponentBits() const { return m_nComponentBits; } diff --git a/core/fpdfapi/page/cpdf_pageobjectholder.cpp b/core/fpdfapi/page/cpdf_pageobjectholder.cpp index 885d9639bd..a52d97f27e 100644 --- a/core/fpdfapi/page/cpdf_pageobjectholder.cpp +++ b/core/fpdfapi/page/cpdf_pageobjectholder.cpp @@ -17,8 +17,8 @@ CPDF_PageObjectHolder::CPDF_PageObjectHolder() m_pPageResources(nullptr), m_pResources(nullptr), m_Transparency(0), - m_bBackgroundAlphaNeeded(FALSE), - m_bHasImageMask(FALSE), + m_bBackgroundAlphaNeeded(false), + m_bHasImageMask(false), m_ParseState(CONTENT_NOT_PARSED) {} CPDF_PageObjectHolder::~CPDF_PageObjectHolder() {} diff --git a/core/fpdfapi/page/cpdf_pageobjectholder.h b/core/fpdfapi/page/cpdf_pageobjectholder.h index 96a0a80838..ce5424e009 100644 --- a/core/fpdfapi/page/cpdf_pageobjectholder.h +++ b/core/fpdfapi/page/cpdf_pageobjectholder.h @@ -34,13 +34,13 @@ class CPDF_PageObjectHolder { return &m_PageObjectList; } - FX_BOOL BackgroundAlphaNeeded() const { return m_bBackgroundAlphaNeeded; } - void SetBackgroundAlphaNeeded(FX_BOOL needed) { + bool BackgroundAlphaNeeded() const { return m_bBackgroundAlphaNeeded; } + void SetBackgroundAlphaNeeded(bool needed) { m_bBackgroundAlphaNeeded = needed; } - FX_BOOL HasImageMask() const { return m_bHasImageMask; } - void SetHasImageMask(FX_BOOL value) { m_bHasImageMask = value; } + bool HasImageMask() const { return m_bHasImageMask; } + void SetHasImageMask(bool value) { m_bHasImageMask = value; } void Transform(const CFX_Matrix& matrix); CFX_FloatRect CalcBoundingBox() const; @@ -58,8 +58,8 @@ class CPDF_PageObjectHolder { void LoadTransInfo(); - FX_BOOL m_bBackgroundAlphaNeeded; - FX_BOOL m_bHasImageMask; + bool m_bBackgroundAlphaNeeded; + bool m_bHasImageMask; ParseState m_ParseState; std::unique_ptr<CPDF_ContentParser> m_pParser; CPDF_PageObjectList m_PageObjectList; diff --git a/core/fpdfapi/page/cpdf_path.cpp b/core/fpdfapi/page/cpdf_path.cpp index e80edf798e..2bfda75f56 100644 --- a/core/fpdfapi/page/cpdf_path.cpp +++ b/core/fpdfapi/page/cpdf_path.cpp @@ -49,7 +49,7 @@ CFX_FloatRect CPDF_Path::GetBoundingBox(FX_FLOAT line_width, return m_Ref.GetObject()->GetBoundingBox(line_width, miter_limit); } -FX_BOOL CPDF_Path::IsRect() const { +bool CPDF_Path::IsRect() const { return m_Ref.GetObject()->IsRect(); } diff --git a/core/fpdfapi/page/cpdf_path.h b/core/fpdfapi/page/cpdf_path.h index d69672a4de..407905e429 100644 --- a/core/fpdfapi/page/cpdf_path.h +++ b/core/fpdfapi/page/cpdf_path.h @@ -33,7 +33,7 @@ class CPDF_Path { CFX_FloatRect GetBoundingBox() const; CFX_FloatRect GetBoundingBox(FX_FLOAT line_width, FX_FLOAT miter_limit) const; - FX_BOOL IsRect() const; + bool IsRect() const; void Transform(const CFX_Matrix* pMatrix); void Append(const CPDF_Path& other, const CFX_Matrix* pMatrix); diff --git a/core/fpdfapi/page/cpdf_pathobject.h b/core/fpdfapi/page/cpdf_pathobject.h index 65578a1bab..d5ce5c0d02 100644 --- a/core/fpdfapi/page/cpdf_pathobject.h +++ b/core/fpdfapi/page/cpdf_pathobject.h @@ -29,7 +29,7 @@ class CPDF_PathObject : public CPDF_PageObject { CPDF_Path m_Path; int m_FillType; - FX_BOOL m_bStroke; + bool m_bStroke; CFX_Matrix m_Matrix; }; diff --git a/core/fpdfapi/page/cpdf_psengine.h b/core/fpdfapi/page/cpdf_psengine.h index d3eec6629c..9bdaa67464 100644 --- a/core/fpdfapi/page/cpdf_psengine.h +++ b/core/fpdfapi/page/cpdf_psengine.h @@ -70,8 +70,8 @@ class CPDF_PSProc { CPDF_PSProc(); ~CPDF_PSProc(); - FX_BOOL Parse(CPDF_SimpleParser* parser, int depth); - FX_BOOL Execute(CPDF_PSEngine* pEngine); + bool Parse(CPDF_SimpleParser* parser, int depth); + bool Execute(CPDF_PSEngine* pEngine); private: static const int kMaxDepth = 128; @@ -83,9 +83,9 @@ class CPDF_PSEngine { CPDF_PSEngine(); ~CPDF_PSEngine(); - FX_BOOL Parse(const FX_CHAR* str, int size); - FX_BOOL Execute(); - FX_BOOL DoOperator(PDF_PSOP op); + bool Parse(const FX_CHAR* str, int size); + bool Execute(); + bool DoOperator(PDF_PSOP op); void Reset() { m_StackCount = 0; } void Push(FX_FLOAT value); void Push(int value) { Push((FX_FLOAT)value); } diff --git a/core/fpdfapi/page/cpdf_shadingpattern.cpp b/core/fpdfapi/page/cpdf_shadingpattern.cpp index d2736870e1..3b0b439a31 100644 --- a/core/fpdfapi/page/cpdf_shadingpattern.cpp +++ b/core/fpdfapi/page/cpdf_shadingpattern.cpp @@ -62,12 +62,12 @@ CPDF_ShadingPattern* CPDF_ShadingPattern::AsShadingPattern() { bool CPDF_ShadingPattern::Load() { if (m_ShadingType != kInvalidShading) - return TRUE; + return true; CPDF_Dictionary* pShadingDict = m_pShadingObj ? m_pShadingObj->GetDict() : nullptr; if (!pShadingDict) - return FALSE; + return false; m_pFunctions.clear(); CPDF_Object* pFunc = pShadingDict->GetDirectObjectFor("Function"); @@ -82,7 +82,7 @@ bool CPDF_ShadingPattern::Load() { } CPDF_Object* pCSObj = pShadingDict->GetDirectObjectFor("ColorSpace"); if (!pCSObj) - return FALSE; + return false; CPDF_DocPageData* pDocPageData = m_pDocument->GetPageData(); m_pCS = pDocPageData->GetColorSpace(pCSObj, nullptr); @@ -93,7 +93,7 @@ bool CPDF_ShadingPattern::Load() { // We expect to have a stream if our shading type is a mesh. if (IsMeshShading() && !ToStream(m_pShadingObj)) - return FALSE; + return false; - return TRUE; + return true; } diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.cpp b/core/fpdfapi/page/cpdf_streamcontentparser.cpp index 4ad763e3b2..ed6701382c 100644 --- a/core/fpdfapi/page/cpdf_streamcontentparser.cpp +++ b/core/fpdfapi/page/cpdf_streamcontentparser.cpp @@ -285,7 +285,7 @@ CPDF_Object* CPDF_StreamContentParser::GetObject(uint32_t index) { if (param.m_Type == ContentParam::OBJECT) { return param.m_pObject; } - ASSERT(FALSE); + ASSERT(false); return nullptr; } @@ -587,7 +587,7 @@ void CPDF_StreamContentParser::Handle_BeginImage() { } void CPDF_StreamContentParser::Handle_BeginMarkedContent() { - m_CurContentMark.AddMark(GetString(0), nullptr, FALSE); + m_CurContentMark.AddMark(GetString(0), nullptr, false); } void CPDF_StreamContentParser::Handle_BeginText() { @@ -697,7 +697,7 @@ void CPDF_StreamContentParser::AddForm(CPDF_Stream* pStream) { pFormObj->m_pForm->ParseContent(&status, nullptr, nullptr, m_Level + 1); if (!m_pObjectHolder->BackgroundAlphaNeeded() && pFormObj->m_pForm->BackgroundAlphaNeeded()) { - m_pObjectHolder->SetBackgroundAlphaNeeded(TRUE); + m_pObjectHolder->SetBackgroundAlphaNeeded(true); } pFormObj->CalcBoundingBox(); SetGraphicStates(pFormObj.get(), true, true, true); @@ -1410,7 +1410,7 @@ void CPDF_StreamContentParser::AddPathObject(int FillType, bool bStroke) { if (PathPointCount && PathClipType) { CPDF_Path path; path.AppendRect(0, 0, 0, 0); - m_pCurStates->m_ClipPath.AppendPath(path, FXFILL_WINDING, TRUE); + m_pCurStates->m_ClipPath.AppendPath(path, FXFILL_WINDING, true); } return; } @@ -1439,7 +1439,7 @@ void CPDF_StreamContentParser::AddPathObject(int FillType, bool bStroke) { Path.Transform(&matrix); matrix.SetIdentity(); } - m_pCurStates->m_ClipPath.AppendPath(Path, PathClipType, TRUE); + m_pCurStates->m_ClipPath.AppendPath(Path, PathClipType, true); } } @@ -1484,7 +1484,7 @@ void CPDF_StreamContentParser::ParsePathObject() { int last_pos = m_pSyntax->GetPos(); while (1) { CPDF_StreamParser::SyntaxType type = m_pSyntax->ParseNextElement(); - FX_BOOL bProcessed = TRUE; + bool bProcessed = true; switch (type) { case CPDF_StreamParser::EndOfData: return; @@ -1523,7 +1523,7 @@ void CPDF_StreamContentParser::ParsePathObject() { nParams = 0; break; default: - bProcessed = FALSE; + bProcessed = false; break; } } else if (len == 2) { @@ -1532,10 +1532,10 @@ void CPDF_StreamContentParser::ParsePathObject() { AddPathRect(params[0], params[1], params[2], params[3]); nParams = 0; } else { - bProcessed = FALSE; + bProcessed = false; } } else { - bProcessed = FALSE; + bProcessed = false; } if (bProcessed) { last_pos = m_pSyntax->GetPos(); @@ -1554,7 +1554,7 @@ void CPDF_StreamContentParser::ParsePathObject() { break; } default: - bProcessed = FALSE; + bProcessed = false; } if (!bProcessed) { m_pSyntax->SetPos(last_pos); diff --git a/core/fpdfapi/page/cpdf_textobject.cpp b/core/fpdfapi/page/cpdf_textobject.cpp index 0b44522835..d5a2ea6d29 100644 --- a/core/fpdfapi/page/cpdf_textobject.cpp +++ b/core/fpdfapi/page/cpdf_textobject.cpp @@ -211,7 +211,7 @@ void CPDF_TextObject::SetText(const CFX_ByteString& str) { FX_FLOAT CPDF_TextObject::GetCharWidth(uint32_t charcode) const { FX_FLOAT fontsize = m_TextState.GetFontSize() / 1000; CPDF_Font* pFont = m_TextState.GetFont(); - FX_BOOL bVertWriting = FALSE; + bool bVertWriting = false; CPDF_CIDFont* pCIDFont = pFont->AsCIDFont(); if (pCIDFont) { bVertWriting = pCIDFont->IsVertWriting(); @@ -248,7 +248,7 @@ void CPDF_TextObject::CalcPositionData(FX_FLOAT* pTextAdvanceX, FX_FLOAT min_y = 10000 * 1.0f; FX_FLOAT max_y = -10000 * 1.0f; CPDF_Font* pFont = m_TextState.GetFont(); - FX_BOOL bVertWriting = FALSE; + bool bVertWriting = false; CPDF_CIDFont* pCIDFont = pFont->AsCIDFont(); if (pCIDFont) { bVertWriting = pCIDFont->IsVertWriting(); diff --git a/core/fpdfapi/page/cpdf_tilingpattern.cpp b/core/fpdfapi/page/cpdf_tilingpattern.cpp index eb51fbac63..1b7bee4366 100644 --- a/core/fpdfapi/page/cpdf_tilingpattern.cpp +++ b/core/fpdfapi/page/cpdf_tilingpattern.cpp @@ -31,13 +31,13 @@ CPDF_ShadingPattern* CPDF_TilingPattern::AsShadingPattern() { return nullptr; } -FX_BOOL CPDF_TilingPattern::Load() { +bool CPDF_TilingPattern::Load() { if (m_pForm) - return TRUE; + return true; CPDF_Dictionary* pDict = m_pPatternObj->GetDict(); if (!pDict) - return FALSE; + return false; m_bColored = pDict->GetIntegerFor("PaintType") == 1; m_XStep = (FX_FLOAT)FXSYS_fabs(pDict->GetNumberFor("XStep")); @@ -45,10 +45,10 @@ FX_BOOL CPDF_TilingPattern::Load() { CPDF_Stream* pStream = m_pPatternObj->AsStream(); if (!pStream) - return FALSE; + return false; m_pForm.reset(new CPDF_Form(m_pDocument, nullptr, pStream)); m_pForm->ParseContent(nullptr, &m_ParentMatrix, nullptr); m_BBox = pDict->GetRectFor("BBox"); - return TRUE; + return true; } diff --git a/core/fpdfapi/page/cpdf_tilingpattern.h b/core/fpdfapi/page/cpdf_tilingpattern.h index 3c9ffb206d..3f0851aa7e 100644 --- a/core/fpdfapi/page/cpdf_tilingpattern.h +++ b/core/fpdfapi/page/cpdf_tilingpattern.h @@ -27,7 +27,7 @@ class CPDF_TilingPattern : public CPDF_Pattern { CPDF_TilingPattern* AsTilingPattern() override; CPDF_ShadingPattern* AsShadingPattern() override; - FX_BOOL Load(); + bool Load(); bool colored() const { return m_bColored; } const CFX_FloatRect& bbox() const { return m_BBox; } diff --git a/core/fpdfapi/page/fpdf_page_colors.cpp b/core/fpdfapi/page/fpdf_page_colors.cpp index e42b695c6c..3ee5328dbc 100644 --- a/core/fpdfapi/page/fpdf_page_colors.cpp +++ b/core/fpdfapi/page/fpdf_page_colors.cpp @@ -71,10 +71,10 @@ void ReverseRGB(uint8_t* pDestBuf, const uint8_t* pSrcBuf, int pixels) { CPDF_DeviceCS::CPDF_DeviceCS(CPDF_Document* pDoc, int family) : CPDF_ColorSpace(pDoc, family, ComponentsForFamily(family)) {} -FX_BOOL CPDF_DeviceCS::GetRGB(FX_FLOAT* pBuf, - FX_FLOAT& R, - FX_FLOAT& G, - FX_FLOAT& B) const { +bool CPDF_DeviceCS::GetRGB(FX_FLOAT* pBuf, + FX_FLOAT& R, + FX_FLOAT& G, + FX_FLOAT& B) const { if (m_Family == PDFCS_DEVICERGB) { R = pBuf[0]; if (R < 0) { @@ -114,64 +114,64 @@ FX_BOOL CPDF_DeviceCS::GetRGB(FX_FLOAT* pBuf, } else { ASSERT(m_Family == PDFCS_PATTERN); R = G = B = 0; - return FALSE; + return false; } - return TRUE; + return true; } -FX_BOOL CPDF_DeviceCS::v_GetCMYK(FX_FLOAT* pBuf, - FX_FLOAT& c, - FX_FLOAT& m, - FX_FLOAT& y, - FX_FLOAT& k) const { +bool CPDF_DeviceCS::v_GetCMYK(FX_FLOAT* pBuf, + FX_FLOAT& c, + FX_FLOAT& m, + FX_FLOAT& y, + FX_FLOAT& k) const { if (m_Family != PDFCS_DEVICECMYK) { - return FALSE; + return false; } c = pBuf[0]; m = pBuf[1]; y = pBuf[2]; k = pBuf[3]; - return TRUE; + return true; } -FX_BOOL CPDF_DeviceCS::SetRGB(FX_FLOAT* pBuf, - FX_FLOAT R, - FX_FLOAT G, - FX_FLOAT B) const { +bool CPDF_DeviceCS::SetRGB(FX_FLOAT* pBuf, + FX_FLOAT R, + FX_FLOAT G, + FX_FLOAT B) const { if (m_Family == PDFCS_DEVICERGB) { pBuf[0] = R; pBuf[1] = G; pBuf[2] = B; - return TRUE; + return true; } if (m_Family == PDFCS_DEVICEGRAY) { if (R == G && R == B) { *pBuf = R; - return TRUE; + return true; } - return FALSE; + return false; } if (m_Family == PDFCS_DEVICECMYK) { sRGB_to_AdobeCMYK(R, G, B, pBuf[0], pBuf[1], pBuf[2], pBuf[3]); - return TRUE; + return true; } - return FALSE; + return false; } -FX_BOOL CPDF_DeviceCS::v_SetCMYK(FX_FLOAT* pBuf, - FX_FLOAT c, - FX_FLOAT m, - FX_FLOAT y, - FX_FLOAT k) const { +bool CPDF_DeviceCS::v_SetCMYK(FX_FLOAT* pBuf, + FX_FLOAT c, + FX_FLOAT m, + FX_FLOAT y, + FX_FLOAT k) const { if (m_Family == PDFCS_DEVICERGB) { AdobeCMYK_to_sRGB(c, m, y, k, pBuf[0], pBuf[1], pBuf[2]); - return TRUE; + return true; } if (m_Family == PDFCS_DEVICECMYK) { pBuf[0] = c; pBuf[1] = m; pBuf[2] = y; pBuf[3] = k; - return TRUE; + return true; } - return FALSE; + return false; } void CPDF_DeviceCS::TranslateImageLine(uint8_t* pDestBuf, @@ -179,7 +179,7 @@ void CPDF_DeviceCS::TranslateImageLine(uint8_t* pDestBuf, int pixels, int image_width, int image_height, - FX_BOOL bTransMask) const { + bool bTransMask) const { if (bTransMask && m_Family == PDFCS_DEVICECMYK) { for (int i = 0; i < pixels; i++) { int k = 255 - pSrcBuf[3]; @@ -217,10 +217,10 @@ void CPDF_DeviceCS::TranslateImageLine(uint8_t* pDestBuf, } CPDF_IccProfile::CPDF_IccProfile(const uint8_t* pData, uint32_t dwSize) - : m_bsRGB(FALSE), m_pTransform(nullptr), m_nSrcComponents(0) { + : m_bsRGB(false), m_pTransform(nullptr), m_nSrcComponents(0) { if (dwSize == 3144 && FXSYS_memcmp(pData + 0x190, "sRGB IEC61966-2.1", 17) == 0) { - m_bsRGB = TRUE; + m_bsRGB = true; m_nSrcComponents = 3; } else if (CPDF_ModuleMgr::Get()->GetIccModule()) { m_pTransform = CPDF_ModuleMgr::Get()->GetIccModule()->CreateTransform_sRGB( diff --git a/core/fpdfapi/page/fpdf_page_func.cpp b/core/fpdfapi/page/fpdf_page_func.cpp index df658844cd..a6c73b0e5f 100644 --- a/core/fpdfapi/page/fpdf_page_func.cpp +++ b/core/fpdfapi/page/fpdf_page_func.cpp @@ -84,31 +84,31 @@ class CPDF_PSFunc : public CPDF_Function { ~CPDF_PSFunc() override {} // CPDF_Function - FX_BOOL v_Init(CPDF_Object* pObj) override; - FX_BOOL v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const override; + bool v_Init(CPDF_Object* pObj) override; + bool v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const override; private: CPDF_PSEngine m_PS; }; -FX_BOOL CPDF_PSFunc::v_Init(CPDF_Object* pObj) { +bool CPDF_PSFunc::v_Init(CPDF_Object* pObj) { CPDF_StreamAcc acc; - acc.LoadAllData(pObj->AsStream(), FALSE); + acc.LoadAllData(pObj->AsStream(), false); return m_PS.Parse(reinterpret_cast<const FX_CHAR*>(acc.GetData()), acc.GetSize()); } -FX_BOOL CPDF_PSFunc::v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const { +bool CPDF_PSFunc::v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const { CPDF_PSEngine& PS = const_cast<CPDF_PSEngine&>(m_PS); PS.Reset(); for (uint32_t i = 0; i < m_nInputs; i++) PS.Push(inputs[i]); PS.Execute(); if (PS.GetStackSize() < m_nOutputs) - return FALSE; + return false; for (uint32_t i = 0; i < m_nOutputs; i++) results[m_nOutputs - i - 1] = PS.Pop(); - return TRUE; + return true; } } // namespace @@ -145,14 +145,14 @@ class CPDF_PSOP { std::unique_ptr<CPDF_PSProc> m_proc; }; -FX_BOOL CPDF_PSEngine::Execute() { +bool CPDF_PSEngine::Execute() { return m_MainProc.Execute(this); } CPDF_PSProc::CPDF_PSProc() {} CPDF_PSProc::~CPDF_PSProc() {} -FX_BOOL CPDF_PSProc::Execute(CPDF_PSEngine* pEngine) { +bool CPDF_PSProc::Execute(CPDF_PSEngine* pEngine) { for (size_t i = 0; i < m_Operators.size(); ++i) { const PDF_PSOP op = m_Operators[i]->GetOp(); if (op == PSOP_PROC) @@ -165,14 +165,14 @@ FX_BOOL CPDF_PSProc::Execute(CPDF_PSEngine* pEngine) { if (op == PSOP_IF) { if (i == 0 || m_Operators[i - 1]->GetOp() != PSOP_PROC) - return FALSE; + return false; if (static_cast<int>(pEngine->Pop())) m_Operators[i - 1]->GetProc()->Execute(pEngine); } else if (op == PSOP_IFELSE) { if (i < 2 || m_Operators[i - 1]->GetOp() != PSOP_PROC || m_Operators[i - 2]->GetOp() != PSOP_PROC) { - return FALSE; + return false; } size_t offset = static_cast<int>(pEngine->Pop()) ? 2 : 1; m_Operators[i - offset]->GetProc()->Execute(pEngine); @@ -180,7 +180,7 @@ FX_BOOL CPDF_PSProc::Execute(CPDF_PSEngine* pEngine) { pEngine->DoOperator(op); } } - return TRUE; + return true; } CPDF_PSEngine::CPDF_PSEngine() { @@ -199,33 +199,33 @@ FX_FLOAT CPDF_PSEngine::Pop() { } return m_Stack[--m_StackCount]; } -FX_BOOL CPDF_PSEngine::Parse(const FX_CHAR* str, int size) { +bool CPDF_PSEngine::Parse(const FX_CHAR* str, int size) { CPDF_SimpleParser parser((uint8_t*)str, size); CFX_ByteStringC word = parser.GetWord(); if (word != "{") { - return FALSE; + return false; } return m_MainProc.Parse(&parser, 0); } -FX_BOOL CPDF_PSProc::Parse(CPDF_SimpleParser* parser, int depth) { +bool CPDF_PSProc::Parse(CPDF_SimpleParser* parser, int depth) { if (depth > kMaxDepth) - return FALSE; + return false; while (1) { CFX_ByteStringC word = parser->GetWord(); if (word.IsEmpty()) { - return FALSE; + return false; } if (word == "}") { - return TRUE; + return true; } if (word == "{") { std::unique_ptr<CPDF_PSProc> proc(new CPDF_PSProc); std::unique_ptr<CPDF_PSOP> op(new CPDF_PSOP(std::move(proc))); m_Operators.push_back(std::move(op)); if (!m_Operators.back()->GetProc()->Parse(parser, depth + 1)) { - return FALSE; + return false; } } else { bool found = false; @@ -245,7 +245,7 @@ FX_BOOL CPDF_PSProc::Parse(CPDF_SimpleParser* parser, int depth) { } } -FX_BOOL CPDF_PSEngine::DoOperator(PDF_PSOP op) { +bool CPDF_PSEngine::DoOperator(PDF_PSOP op) { int i1; int i2; FX_FLOAT d1; @@ -474,14 +474,14 @@ FX_BOOL CPDF_PSEngine::DoOperator(PDF_PSOP op) { default: break; } - return TRUE; + return true; } CPDF_SampledFunc::CPDF_SampledFunc() : CPDF_Function(Type::kType0Sampled) {} CPDF_SampledFunc::~CPDF_SampledFunc() {} -FX_BOOL CPDF_SampledFunc::v_Init(CPDF_Object* pObj) { +bool CPDF_SampledFunc::v_Init(CPDF_Object* pObj) { CPDF_Stream* pStream = pObj->AsStream(); if (!pStream) return false; @@ -492,11 +492,11 @@ FX_BOOL CPDF_SampledFunc::v_Init(CPDF_Object* pObj) { CPDF_Array* pDecode = pDict->GetArrayFor("Decode"); m_nBitsPerSample = pDict->GetIntegerFor("BitsPerSample"); if (!IsValidBitsPerSample(m_nBitsPerSample)) - return FALSE; + return false; m_SampleMax = 0xffffffff >> (32 - m_nBitsPerSample); m_pSampleStream.reset(new CPDF_StreamAcc); - m_pSampleStream->LoadAllData(pStream, FALSE); + m_pSampleStream->LoadAllData(pStream, false); FX_SAFE_UINT32 nTotalSampleBits = 1; m_EncodeInfo.resize(m_nInputs); for (uint32_t i = 0; i < m_nInputs; i++) { @@ -520,7 +520,7 @@ FX_BOOL CPDF_SampledFunc::v_Init(CPDF_Object* pObj) { nTotalSampleBytes /= 8; if (!nTotalSampleBytes.IsValid() || nTotalSampleBytes.ValueOrDie() == 0 || nTotalSampleBytes.ValueOrDie() > m_pSampleStream->GetSize()) { - return FALSE; + return false; } m_DecodeInfo.resize(m_nOutputs); for (uint32_t i = 0; i < m_nOutputs; i++) { @@ -532,10 +532,10 @@ FX_BOOL CPDF_SampledFunc::v_Init(CPDF_Object* pObj) { m_DecodeInfo[i].decode_max = m_pRanges[i * 2 + 1]; } } - return TRUE; + return true; } -FX_BOOL CPDF_SampledFunc::v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const { +bool CPDF_SampledFunc::v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const { int pos = 0; CFX_FixedBufGrow<FX_FLOAT, 16> encoded_input_buf(m_nInputs); FX_FLOAT* encoded_input = encoded_input_buf; @@ -557,21 +557,21 @@ FX_BOOL CPDF_SampledFunc::v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const { FX_SAFE_INT32 bits_to_output = m_nOutputs; bits_to_output *= m_nBitsPerSample; if (!bits_to_output.IsValid()) - return FALSE; + return false; FX_SAFE_INT32 bitpos = pos; bitpos *= bits_to_output.ValueOrDie(); if (!bitpos.IsValid()) - return FALSE; + return false; FX_SAFE_INT32 range_check = bitpos; range_check += bits_to_output.ValueOrDie(); if (!range_check.IsValid()) - return FALSE; + return false; const uint8_t* pSampleData = m_pSampleStream->GetData(); if (!pSampleData) - return FALSE; + return false; for (uint32_t j = 0; j < m_nOutputs; j++) { uint32_t sample = @@ -589,7 +589,7 @@ FX_BOOL CPDF_SampledFunc::v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const { bitpos2 += j; bitpos2 *= m_nBitsPerSample; if (!bitpos2.IsValid()) - return FALSE; + return false; uint32_t sample1 = GetBits32(pSampleData, bitpos2.ValueOrDie(), m_nBitsPerSample); encoded += (encoded_input[i] - index[i]) * @@ -600,7 +600,7 @@ FX_BOOL CPDF_SampledFunc::v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const { PDF_Interpolate(encoded, 0, (FX_FLOAT)m_SampleMax, m_DecodeInfo[j].decode_min, m_DecodeInfo[j].decode_max); } - return TRUE; + return true; } CPDF_ExpIntFunc::CPDF_ExpIntFunc() @@ -612,10 +612,10 @@ CPDF_ExpIntFunc::~CPDF_ExpIntFunc() { FX_Free(m_pBeginValues); FX_Free(m_pEndValues); } -FX_BOOL CPDF_ExpIntFunc::v_Init(CPDF_Object* pObj) { +bool CPDF_ExpIntFunc::v_Init(CPDF_Object* pObj) { CPDF_Dictionary* pDict = pObj->GetDict(); if (!pDict) { - return FALSE; + return false; } CPDF_Array* pArray0 = pDict->GetArrayFor("C0"); if (m_nOutputs == 0) { @@ -634,12 +634,12 @@ FX_BOOL CPDF_ExpIntFunc::v_Init(CPDF_Object* pObj) { m_Exponent = pDict->GetFloatFor("N"); m_nOrigOutputs = m_nOutputs; if (m_nOutputs && m_nInputs > INT_MAX / m_nOutputs) { - return FALSE; + return false; } m_nOutputs *= m_nInputs; - return TRUE; + return true; } -FX_BOOL CPDF_ExpIntFunc::v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const { +bool CPDF_ExpIntFunc::v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const { for (uint32_t i = 0; i < m_nInputs; i++) for (uint32_t j = 0; j < m_nOrigOutputs; j++) { results[i * m_nOrigOutputs + j] = @@ -647,7 +647,7 @@ FX_BOOL CPDF_ExpIntFunc::v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const { (FX_FLOAT)FXSYS_pow(inputs[i], m_Exponent) * (m_pEndValues[j] - m_pBeginValues[j]); } - return TRUE; + return true; } CPDF_StitchFunc::CPDF_StitchFunc() @@ -660,36 +660,36 @@ CPDF_StitchFunc::~CPDF_StitchFunc() { FX_Free(m_pEncode); } -FX_BOOL CPDF_StitchFunc::v_Init(CPDF_Object* pObj) { +bool CPDF_StitchFunc::v_Init(CPDF_Object* pObj) { CPDF_Dictionary* pDict = pObj->GetDict(); if (!pDict) { - return FALSE; + return false; } if (m_nInputs != kRequiredNumInputs) { - return FALSE; + return false; } CPDF_Array* pArray = pDict->GetArrayFor("Functions"); if (!pArray) { - return FALSE; + return false; } uint32_t nSubs = pArray->GetCount(); if (nSubs == 0) - return FALSE; + return false; m_nOutputs = 0; for (uint32_t i = 0; i < nSubs; i++) { CPDF_Object* pSub = pArray->GetDirectObjectAt(i); if (pSub == pObj) - return FALSE; + return false; std::unique_ptr<CPDF_Function> pFunc(CPDF_Function::Load(pSub)); if (!pFunc) - return FALSE; + return false; // Check that the input dimensionality is 1, and that all output // dimensionalities are the same. if (pFunc->CountInputs() != kRequiredNumInputs) - return FALSE; + return false; if (pFunc->CountOutputs() != m_nOutputs) { if (m_nOutputs) - return FALSE; + return false; m_nOutputs = pFunc->CountOutputs(); } @@ -700,21 +700,21 @@ FX_BOOL CPDF_StitchFunc::v_Init(CPDF_Object* pObj) { m_pBounds[0] = m_pDomains[0]; pArray = pDict->GetArrayFor("Bounds"); if (!pArray) - return FALSE; + return false; for (uint32_t i = 0; i < nSubs - 1; i++) m_pBounds[i + 1] = pArray->GetFloatAt(i); m_pBounds[nSubs] = m_pDomains[1]; m_pEncode = FX_Alloc2D(FX_FLOAT, nSubs, 2); pArray = pDict->GetArrayFor("Encode"); if (!pArray) - return FALSE; + return false; for (uint32_t i = 0; i < nSubs * 2; i++) m_pEncode[i] = pArray->GetFloatAt(i); - return TRUE; + return true; } -FX_BOOL CPDF_StitchFunc::v_Call(FX_FLOAT* inputs, FX_FLOAT* outputs) const { +bool CPDF_StitchFunc::v_Call(FX_FLOAT* inputs, FX_FLOAT* outputs) const { FX_FLOAT input = inputs[0]; size_t i; for (i = 0; i < m_pSubFunctions.size() - 1; i++) { @@ -725,7 +725,7 @@ FX_BOOL CPDF_StitchFunc::v_Call(FX_FLOAT* inputs, FX_FLOAT* outputs) const { m_pEncode[i * 2], m_pEncode[i * 2 + 1]); int nresults; m_pSubFunctions[i]->Call(&input, kRequiredNumInputs, outputs, nresults); - return TRUE; + return true; } // static @@ -777,17 +777,17 @@ CPDF_Function::~CPDF_Function() { FX_Free(m_pRanges); } -FX_BOOL CPDF_Function::Init(CPDF_Object* pObj) { +bool CPDF_Function::Init(CPDF_Object* pObj) { CPDF_Stream* pStream = pObj->AsStream(); CPDF_Dictionary* pDict = pStream ? pStream->GetDict() : pObj->AsDictionary(); CPDF_Array* pDomains = pDict->GetArrayFor("Domain"); if (!pDomains) - return FALSE; + return false; m_nInputs = pDomains->GetCount() / 2; if (m_nInputs == 0) - return FALSE; + return false; m_pDomains = FX_Alloc2D(FX_FLOAT, m_nInputs, 2); for (uint32_t i = 0; i < m_nInputs * 2; i++) { @@ -803,7 +803,7 @@ FX_BOOL CPDF_Function::Init(CPDF_Object* pObj) { } uint32_t old_outputs = m_nOutputs; if (!v_Init(pObj)) - return FALSE; + return false; if (m_pRanges && m_nOutputs > old_outputs) { m_pRanges = FX_Realloc(FX_FLOAT, m_pRanges, m_nOutputs * 2); if (m_pRanges) { @@ -811,15 +811,15 @@ FX_BOOL CPDF_Function::Init(CPDF_Object* pObj) { sizeof(FX_FLOAT) * (m_nOutputs - old_outputs) * 2); } } - return TRUE; + return true; } -FX_BOOL CPDF_Function::Call(FX_FLOAT* inputs, - uint32_t ninputs, - FX_FLOAT* results, - int& nresults) const { +bool CPDF_Function::Call(FX_FLOAT* inputs, + uint32_t ninputs, + FX_FLOAT* results, + int& nresults) const { if (m_nInputs != ninputs) { - return FALSE; + return false; } nresults = m_nOutputs; for (uint32_t i = 0; i < m_nInputs; i++) { @@ -837,7 +837,7 @@ FX_BOOL CPDF_Function::Call(FX_FLOAT* inputs, results[i] = m_pRanges[i * 2 + 1]; } } - return TRUE; + return true; } const CPDF_SampledFunc* CPDF_Function::ToSampledFunc() const { diff --git a/core/fpdfapi/page/fpdf_page_parser_old.cpp b/core/fpdfapi/page/fpdf_page_parser_old.cpp index ccee12dd03..0d1db43825 100644 --- a/core/fpdfapi/page/fpdf_page_parser_old.cpp +++ b/core/fpdfapi/page/fpdf_page_parser_old.cpp @@ -96,11 +96,11 @@ uint32_t PDF_DecodeInlineStream(const uint8_t* src_buf, return HexDecode(src_buf, limit, dest_buf, dest_size); } if (decoder == "FlateDecode" || decoder == "Fl") { - return FPDFAPI_FlateOrLZWDecode(FALSE, src_buf, limit, pParam, dest_size, + return FPDFAPI_FlateOrLZWDecode(false, src_buf, limit, pParam, dest_size, dest_buf, dest_size); } if (decoder == "LZWDecode" || decoder == "LZW") { - return FPDFAPI_FlateOrLZWDecode(TRUE, src_buf, limit, pParam, 0, dest_buf, + return FPDFAPI_FlateOrLZWDecode(true, src_buf, limit, pParam, 0, dest_buf, dest_size); } if (decoder == "DCTDecode" || decoder == "DCT") { @@ -317,7 +317,7 @@ CPDF_StreamParser::SyntaxType CPDF_StreamParser::ParseNextElement() { if (m_WordSize == 4) { if (memcmp(m_WordBuffer, "true", 4) == 0) { - m_pLastObj = new CPDF_Boolean(TRUE); + m_pLastObj = new CPDF_Boolean(true); return Others; } if (memcmp(m_WordBuffer, "null", 4) == 0) { @@ -326,7 +326,7 @@ CPDF_StreamParser::SyntaxType CPDF_StreamParser::ParseNextElement() { } } else if (m_WordSize == 5) { if (memcmp(m_WordBuffer, "false", 5) == 0) { - m_pLastObj = new CPDF_Boolean(FALSE); + m_pLastObj = new CPDF_Boolean(false); return Others; } } @@ -360,12 +360,12 @@ CPDF_Object* CPDF_StreamParser::ReadNextObject(bool bAllowNestedArray, if (first_char == '(') { CFX_ByteString str = ReadString(); - return new CPDF_String(m_pPool ? m_pPool->Intern(str) : str, FALSE); + return new CPDF_String(m_pPool ? m_pPool->Intern(str) : str, false); } if (first_char == '<') { if (m_WordSize == 1) - return new CPDF_String(ReadHexString(), TRUE); + return new CPDF_String(ReadHexString(), true); CPDF_Dictionary* pDict = new CPDF_Dictionary(m_pPool); while (1) { @@ -415,11 +415,11 @@ CPDF_Object* CPDF_StreamParser::ReadNextObject(bool bAllowNestedArray, } if (m_WordSize == 5 && !memcmp(m_WordBuffer, "false", 5)) - return new CPDF_Boolean(FALSE); + return new CPDF_Boolean(false); if (m_WordSize == 4) { if (memcmp(m_WordBuffer, "true", 4) == 0) - return new CPDF_Boolean(TRUE); + return new CPDF_Boolean(true); if (memcmp(m_WordBuffer, "null", 4) == 0) return new CPDF_Null; @@ -679,7 +679,7 @@ void CPDF_ContentParser::Start(CPDF_Page* pPage) { if (CPDF_Stream* pStream = pContent->AsStream()) { m_nStreams = 0; m_pSingleStream.reset(new CPDF_StreamAcc); - m_pSingleStream->LoadAllData(pStream, FALSE); + m_pSingleStream->LoadAllData(pStream, false); } else if (CPDF_Array* pArray = pContent->AsArray()) { m_nStreams = pArray->GetCount(); if (m_nStreams) @@ -728,7 +728,7 @@ void CPDF_ContentParser::Start(CPDF_Form* pForm, m_pParser->GetCurStates()->m_ParentMatrix = form_matrix; if (ClipPath) { m_pParser->GetCurStates()->m_ClipPath.AppendPath(ClipPath, FXFILL_WINDING, - TRUE); + true); } if (pForm->m_Transparency & PDFTRANS_GROUP) { CPDF_GeneralState* pState = &m_pParser->GetCurStates()->m_GeneralState; @@ -739,7 +739,7 @@ void CPDF_ContentParser::Start(CPDF_Form* pForm, } m_nStreams = 0; m_pSingleStream.reset(new CPDF_StreamAcc); - m_pSingleStream->LoadAllData(pForm->m_pFormStream, FALSE); + m_pSingleStream->LoadAllData(pForm->m_pFormStream, false); m_pData = (uint8_t*)m_pSingleStream->GetData(); m_Size = m_pSingleStream->GetSize(); m_Status = ToBeContinued; @@ -783,7 +783,7 @@ void CPDF_ContentParser::Continue(IFX_Pause* pPause) { m_StreamArray[m_CurrentOffset].reset(new CPDF_StreamAcc); CPDF_Stream* pStreamObj = ToStream( pContent ? pContent->GetDirectObjectAt(m_CurrentOffset) : nullptr); - m_StreamArray[m_CurrentOffset]->LoadAllData(pStreamObj, FALSE); + m_StreamArray[m_CurrentOffset]->LoadAllData(pStreamObj, false); m_CurrentOffset++; } } diff --git a/core/fpdfapi/page/pageint.h b/core/fpdfapi/page/pageint.h index d70ecf1a6e..a96216bbb6 100644 --- a/core/fpdfapi/page/pageint.h +++ b/core/fpdfapi/page/pageint.h @@ -133,10 +133,10 @@ class CPDF_Function { static Type IntegerToFunctionType(int iType); virtual ~CPDF_Function(); - FX_BOOL Call(FX_FLOAT* inputs, - uint32_t ninputs, - FX_FLOAT* results, - int& nresults) const; + bool Call(FX_FLOAT* inputs, + uint32_t ninputs, + FX_FLOAT* results, + int& nresults) const; uint32_t CountInputs() const { return m_nInputs; } uint32_t CountOutputs() const { return m_nOutputs; } FX_FLOAT GetDomain(int i) const { return m_pDomains[i]; } @@ -149,9 +149,9 @@ class CPDF_Function { protected: explicit CPDF_Function(Type type); - FX_BOOL Init(CPDF_Object* pObj); - virtual FX_BOOL v_Init(CPDF_Object* pObj) = 0; - virtual FX_BOOL v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const = 0; + bool Init(CPDF_Object* pObj); + virtual bool v_Init(CPDF_Object* pObj) = 0; + virtual bool v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const = 0; uint32_t m_nInputs; uint32_t m_nOutputs; @@ -166,8 +166,8 @@ class CPDF_ExpIntFunc : public CPDF_Function { ~CPDF_ExpIntFunc() override; // CPDF_Function - FX_BOOL v_Init(CPDF_Object* pObj) override; - FX_BOOL v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const override; + bool v_Init(CPDF_Object* pObj) override; + bool v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const override; uint32_t m_nOrigOutputs; FX_FLOAT m_Exponent; @@ -192,8 +192,8 @@ class CPDF_SampledFunc : public CPDF_Function { ~CPDF_SampledFunc() override; // CPDF_Function - FX_BOOL v_Init(CPDF_Object* pObj) override; - FX_BOOL v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const override; + bool v_Init(CPDF_Object* pObj) override; + bool v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const override; const std::vector<SampleEncodeInfo>& GetEncodeInfo() const { return m_EncodeInfo; @@ -217,8 +217,8 @@ class CPDF_StitchFunc : public CPDF_Function { ~CPDF_StitchFunc() override; // CPDF_Function - FX_BOOL v_Init(CPDF_Object* pObj) override; - FX_BOOL v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const override; + bool v_Init(CPDF_Object* pObj) override; + bool v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const override; const std::vector<std::unique_ptr<CPDF_Function>>& GetSubFunctions() const { return m_pSubFunctions; @@ -249,41 +249,41 @@ class CPDF_DeviceCS : public CPDF_ColorSpace { public: CPDF_DeviceCS(CPDF_Document* pDoc, int family); - FX_BOOL GetRGB(FX_FLOAT* pBuf, - FX_FLOAT& R, - FX_FLOAT& G, - FX_FLOAT& B) const override; - FX_BOOL SetRGB(FX_FLOAT* pBuf, - FX_FLOAT R, - FX_FLOAT G, - FX_FLOAT B) const override; - FX_BOOL v_GetCMYK(FX_FLOAT* pBuf, - FX_FLOAT& c, - FX_FLOAT& m, - FX_FLOAT& y, - FX_FLOAT& k) const override; - FX_BOOL v_SetCMYK(FX_FLOAT* pBuf, - FX_FLOAT c, - FX_FLOAT m, - FX_FLOAT y, - FX_FLOAT k) const override; + bool GetRGB(FX_FLOAT* pBuf, + FX_FLOAT& R, + FX_FLOAT& G, + FX_FLOAT& B) const override; + bool SetRGB(FX_FLOAT* pBuf, + FX_FLOAT R, + FX_FLOAT G, + FX_FLOAT B) const override; + bool v_GetCMYK(FX_FLOAT* pBuf, + FX_FLOAT& c, + FX_FLOAT& m, + FX_FLOAT& y, + FX_FLOAT& k) const override; + bool v_SetCMYK(FX_FLOAT* pBuf, + FX_FLOAT c, + FX_FLOAT m, + FX_FLOAT y, + FX_FLOAT k) const override; void TranslateImageLine(uint8_t* pDestBuf, const uint8_t* pSrcBuf, int pixels, int image_width, int image_height, - FX_BOOL bTransMask = FALSE) const override; + bool bTransMask = false) const override; }; class CPDF_PatternCS : public CPDF_ColorSpace { public: explicit CPDF_PatternCS(CPDF_Document* pDoc); ~CPDF_PatternCS() override; - FX_BOOL v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) override; - FX_BOOL GetRGB(FX_FLOAT* pBuf, - FX_FLOAT& R, - FX_FLOAT& G, - FX_FLOAT& B) const override; + bool v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) override; + bool GetRGB(FX_FLOAT* pBuf, + FX_FLOAT& R, + FX_FLOAT& G, + FX_FLOAT& B) const override; CPDF_ColorSpace* GetBaseCS() const override; private: 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; diff --git a/core/fpdfapi/render/cpdf_pagerendercache.h b/core/fpdfapi/render/cpdf_pagerendercache.h index 37d092062d..0156416d47 100644 --- a/core/fpdfapi/render/cpdf_pagerendercache.h +++ b/core/fpdfapi/render/cpdf_pagerendercache.h @@ -33,9 +33,9 @@ class CPDF_PageRenderCache { CFX_DIBSource*& pBitmap, CFX_DIBSource*& pMask, uint32_t& MatteColor, - FX_BOOL bStdCS = FALSE, + bool bStdCS = false, uint32_t GroupFamily = 0, - FX_BOOL bLoadMask = FALSE, + bool bLoadMask = false, CPDF_RenderStatus* pRenderStatus = nullptr, int32_t downsampleWidth = 0, int32_t downsampleHeight = 0); @@ -47,15 +47,15 @@ class CPDF_PageRenderCache { return m_pCurImageCacheEntry; } - FX_BOOL StartGetCachedBitmap(CPDF_Stream* pStream, - FX_BOOL bStdCS = FALSE, - uint32_t GroupFamily = 0, - FX_BOOL bLoadMask = FALSE, - CPDF_RenderStatus* pRenderStatus = nullptr, - int32_t downsampleWidth = 0, - int32_t downsampleHeight = 0); + bool StartGetCachedBitmap(CPDF_Stream* pStream, + bool bStdCS = false, + uint32_t GroupFamily = 0, + bool bLoadMask = false, + CPDF_RenderStatus* pRenderStatus = nullptr, + int32_t downsampleWidth = 0, + int32_t downsampleHeight = 0); - FX_BOOL Continue(IFX_Pause* pPause); + bool Continue(IFX_Pause* pPause); protected: friend class CPDF_Page; @@ -65,7 +65,7 @@ class CPDF_PageRenderCache { std::map<CPDF_Stream*, CPDF_ImageCacheEntry*> m_ImageCache; uint32_t m_nTimeCount; uint32_t m_nCacheSize; - FX_BOOL m_bCurFindCache; + bool m_bCurFindCache; }; #endif // CORE_FPDFAPI_RENDER_CPDF_PAGERENDERCACHE_H_ diff --git a/core/fpdfapi/render/cpdf_textrenderer.h b/core/fpdfapi/render/cpdf_textrenderer.h index a179fd7c8c..82cc2cf8e6 100644 --- a/core/fpdfapi/render/cpdf_textrenderer.h +++ b/core/fpdfapi/render/cpdf_textrenderer.h @@ -32,29 +32,29 @@ class CPDF_TextRenderer { const CFX_GraphStateData* pGraphState, const CPDF_RenderOptions* pOptions); - static FX_BOOL DrawTextPath(CFX_RenderDevice* pDevice, - int nChars, - uint32_t* pCharCodes, - FX_FLOAT* pCharPos, - CPDF_Font* pFont, - FX_FLOAT font_size, - const CFX_Matrix* pText2User, - const CFX_Matrix* pUser2Device, - const CFX_GraphStateData* pGraphState, - FX_ARGB fill_argb, - FX_ARGB stroke_argb, - CFX_PathData* pClippingPath, - int nFlag); - - static FX_BOOL DrawNormalText(CFX_RenderDevice* pDevice, - int nChars, - uint32_t* pCharCodes, - FX_FLOAT* pCharPos, - CPDF_Font* pFont, - FX_FLOAT font_size, - const CFX_Matrix* pText2Device, - FX_ARGB fill_argb, - const CPDF_RenderOptions* pOptions); + static bool DrawTextPath(CFX_RenderDevice* pDevice, + int nChars, + uint32_t* pCharCodes, + FX_FLOAT* pCharPos, + CPDF_Font* pFont, + FX_FLOAT font_size, + const CFX_Matrix* pText2User, + const CFX_Matrix* pUser2Device, + const CFX_GraphStateData* pGraphState, + FX_ARGB fill_argb, + FX_ARGB stroke_argb, + CFX_PathData* pClippingPath, + int nFlag); + + static bool DrawNormalText(CFX_RenderDevice* pDevice, + int nChars, + uint32_t* pCharCodes, + FX_FLOAT* pCharPos, + CPDF_Font* pFont, + FX_FLOAT font_size, + const CFX_Matrix* pText2Device, + FX_ARGB fill_argb, + const CPDF_RenderOptions* pOptions); }; #endif // CORE_FPDFAPI_RENDER_CPDF_TEXTRENDERER_H_ diff --git a/core/fpdfapi/render/cpdf_type3cache.cpp b/core/fpdfapi/render/cpdf_type3cache.cpp index 7fe552108d..ba92142dbf 100644 --- a/core/fpdfapi/render/cpdf_type3cache.cpp +++ b/core/fpdfapi/render/cpdf_type3cache.cpp @@ -34,24 +34,24 @@ void CPDF_UniqueKeyGen::Generate(int count, ...) { m_KeyLen = count * sizeof(uint32_t); } -FX_BOOL IsScanLine1bpp(uint8_t* pBuf, int width) { +bool IsScanLine1bpp(uint8_t* pBuf, int width) { int size = width / 8; for (int i = 0; i < size; i++) { if (pBuf[i]) - return TRUE; + return true; } return (width % 8) && (pBuf[width / 8] & (0xff << (8 - width % 8))); } -FX_BOOL IsScanLine8bpp(uint8_t* pBuf, int width) { +bool IsScanLine8bpp(uint8_t* pBuf, int width) { for (int i = 0; i < width; i++) { if (pBuf[i] > 0x40) - return TRUE; + return true; } - return FALSE; + return false; } -int DetectFirstLastScan(const CFX_DIBitmap* pBitmap, FX_BOOL bFirst) { +int DetectFirstLastScan(const CFX_DIBitmap* pBitmap, bool bFirst) { int height = pBitmap->GetHeight(); int pitch = pBitmap->GetPitch(); int width = pBitmap->GetWidth(); @@ -131,12 +131,12 @@ CFX_GlyphBitmap* CPDF_Type3Cache::RenderGlyph(CPDF_Type3Glyphs* pSize, int top = 0; if (FXSYS_fabs(image_matrix.b) < FXSYS_fabs(image_matrix.a) / 100 && FXSYS_fabs(image_matrix.c) < FXSYS_fabs(image_matrix.d) / 100) { - int top_line = DetectFirstLastScan(pBitmap, TRUE); - int bottom_line = DetectFirstLastScan(pBitmap, FALSE); + int top_line = DetectFirstLastScan(pBitmap, true); + int bottom_line = DetectFirstLastScan(pBitmap, false); if (top_line == 0 && bottom_line == pBitmap->GetHeight() - 1) { FX_FLOAT top_y = image_matrix.d + image_matrix.f; FX_FLOAT bottom_y = image_matrix.f; - FX_BOOL bFlipped = top_y > bottom_y; + bool bFlipped = top_y > bottom_y; if (bFlipped) { FX_FLOAT temp = top_y; top_y = bottom_y; diff --git a/core/fpdfapi/render/fpdf_render.cpp b/core/fpdfapi/render/fpdf_render.cpp index 4dcad15949..a431aa9486 100644 --- a/core/fpdfapi/render/fpdf_render.cpp +++ b/core/fpdfapi/render/fpdf_render.cpp @@ -40,10 +40,10 @@ CPDF_DocRenderData::CPDF_DocRenderData(CPDF_Document* pPDFDoc) : m_pPDFDoc(pPDFDoc) {} CPDF_DocRenderData::~CPDF_DocRenderData() { - Clear(TRUE); + Clear(true); } -void CPDF_DocRenderData::Clear(FX_BOOL bRelease) { +void CPDF_DocRenderData::Clear(bool bRelease) { for (auto it = m_Type3FaceMap.begin(); it != m_Type3FaceMap.end();) { auto curr_it = it++; CPDF_CountedObject<CPDF_Type3Cache>* cache = curr_it->second; @@ -146,38 +146,38 @@ CPDF_RenderStatus::CPDF_RenderStatus() : m_pFormResource(nullptr), m_pPageResource(nullptr), m_pContext(nullptr), - m_bStopped(FALSE), + m_bStopped(false), m_pDevice(nullptr), m_pCurObj(nullptr), m_pStopObj(nullptr), m_HalftoneLimit(0), - m_bPrint(FALSE), + m_bPrint(false), m_Transparency(0), - m_bDropObjects(FALSE), - m_bStdCS(FALSE), + m_bDropObjects(false), + m_bStdCS(false), m_GroupFamily(0), - m_bLoadMask(FALSE), + m_bLoadMask(false), m_pType3Char(nullptr), m_T3FillColor(0), m_curBlend(FXDIB_BLEND_NORMAL) {} CPDF_RenderStatus::~CPDF_RenderStatus() {} -FX_BOOL CPDF_RenderStatus::Initialize(CPDF_RenderContext* pContext, - CFX_RenderDevice* pDevice, - const CFX_Matrix* pDeviceMatrix, - const CPDF_PageObject* pStopObj, - const CPDF_RenderStatus* pParentState, - const CPDF_GraphicStates* pInitialStates, - const CPDF_RenderOptions* pOptions, - int transparency, - FX_BOOL bDropObjects, - CPDF_Dictionary* pFormResource, - FX_BOOL bStdCS, - CPDF_Type3Char* pType3Char, - FX_ARGB fill_color, - uint32_t GroupFamily, - FX_BOOL bLoadMask) { +bool CPDF_RenderStatus::Initialize(CPDF_RenderContext* pContext, + CFX_RenderDevice* pDevice, + const CFX_Matrix* pDeviceMatrix, + const CPDF_PageObject* pStopObj, + const CPDF_RenderStatus* pParentState, + const CPDF_GraphicStates* pInitialStates, + const CPDF_RenderOptions* pOptions, + int transparency, + bool bDropObjects, + CPDF_Dictionary* pFormResource, + bool bStdCS, + CPDF_Type3Char* pType3Char, + FX_ARGB fill_color, + uint32_t GroupFamily, + bool bLoadMask) { m_pContext = pContext; m_pDevice = pDevice; m_bPrint = m_pDevice->GetDeviceClass() != FXDC_DISPLAY; @@ -217,7 +217,7 @@ FX_BOOL CPDF_RenderStatus::Initialize(CPDF_RenderContext* pContext, } m_pImageRenderer.reset(); m_Transparency = transparency; - return TRUE; + return true; } void CPDF_RenderStatus::RenderObjectList( const CPDF_PageObjectHolder* pObjectHolder, @@ -232,7 +232,7 @@ void CPDF_RenderStatus::RenderObjectList( for (const auto& pCurObj : *pObjectHolder->GetPageObjectList()) { if (pCurObj.get() == m_pStopObj) { - m_bStopped = TRUE; + m_bStopped = true; return; } if (!pCurObj) @@ -278,48 +278,48 @@ void CPDF_RenderStatus::RenderSingleObject(CPDF_PageObject* pObj, #endif } -FX_BOOL CPDF_RenderStatus::ContinueSingleObject(CPDF_PageObject* pObj, - const CFX_Matrix* pObj2Device, - IFX_Pause* pPause) { +bool CPDF_RenderStatus::ContinueSingleObject(CPDF_PageObject* pObj, + const CFX_Matrix* pObj2Device, + IFX_Pause* pPause) { if (m_pImageRenderer) { if (m_pImageRenderer->Continue(pPause)) - return TRUE; + return true; if (!m_pImageRenderer->m_Result) DrawObjWithBackground(pObj, pObj2Device); m_pImageRenderer.reset(); - return FALSE; + return false; } m_pCurObj = pObj; if (m_Options.m_pOCContext && pObj->m_ContentMark && !m_Options.m_pOCContext->CheckObjectVisible(pObj)) { - return FALSE; + return false; } ProcessClipPath(pObj->m_ClipPath, pObj2Device); if (ProcessTransparency(pObj, pObj2Device)) - return FALSE; + return false; if (pObj->IsImage()) { m_pImageRenderer.reset(new CPDF_ImageRenderer); - if (!m_pImageRenderer->Start(this, pObj, pObj2Device, FALSE)) { + if (!m_pImageRenderer->Start(this, pObj, pObj2Device, false)) { if (!m_pImageRenderer->m_Result) DrawObjWithBackground(pObj, pObj2Device); m_pImageRenderer.reset(); - return FALSE; + return false; } return ContinueSingleObject(pObj, pObj2Device, pPause); } ProcessObjectNoClip(pObj, pObj2Device); - return FALSE; + return false; } -FX_BOOL CPDF_RenderStatus::GetObjectClippedRect(const CPDF_PageObject* pObj, - const CFX_Matrix* pObj2Device, - FX_BOOL bLogical, - FX_RECT& rect) const { +bool CPDF_RenderStatus::GetObjectClippedRect(const CPDF_PageObject* pObj, + const CFX_Matrix* pObj2Device, + bool bLogical, + FX_RECT& rect) const { rect = pObj->GetBBox(pObj2Device); FX_RECT rtClip = m_pDevice->GetClipBox(); if (!bLogical) { @@ -344,7 +344,7 @@ void CPDF_RenderStatus::ProcessObjectNoClip(CPDF_PageObject* pObj, #if defined _SKIA_SUPPORT_ DebugVerifyDeviceIsPreMultiplied(); #endif - FX_BOOL bRet = FALSE; + bool bRet = false; switch (pObj->GetType()) { case CPDF_PageObject::TEXT: bRet = ProcessText(pObj->AsText(), pObj2Device, nullptr); @@ -369,9 +369,9 @@ void CPDF_RenderStatus::ProcessObjectNoClip(CPDF_PageObject* pObj, #endif } -FX_BOOL CPDF_RenderStatus::DrawObjWithBlend(CPDF_PageObject* pObj, - const CFX_Matrix* pObj2Device) { - FX_BOOL bRet = FALSE; +bool CPDF_RenderStatus::DrawObjWithBlend(CPDF_PageObject* pObj, + const CFX_Matrix* pObj2Device) { + bool bRet = false; switch (pObj->GetType()) { case CPDF_PageObject::PATH: bRet = ProcessPath(pObj->AsPath(), pObj2Device); @@ -396,7 +396,7 @@ void CPDF_RenderStatus::GetScaledMatrix(CFX_Matrix& matrix) const { void CPDF_RenderStatus::DrawObjWithBackground(CPDF_PageObject* pObj, const CFX_Matrix* pObj2Device) { FX_RECT rect; - if (GetObjectClippedRect(pObj, pObj2Device, FALSE, rect)) { + if (GetObjectClippedRect(pObj, pObj2Device, false, rect)) { return; } int res = 300; @@ -426,15 +426,15 @@ void CPDF_RenderStatus::DrawObjWithBackground(CPDF_PageObject* pObj, buffer.OutputToDevice(); } -FX_BOOL CPDF_RenderStatus::ProcessForm(const CPDF_FormObject* pFormObj, - const CFX_Matrix* pObj2Device) { +bool CPDF_RenderStatus::ProcessForm(const CPDF_FormObject* pFormObj, + const CFX_Matrix* pObj2Device) { #if defined _SKIA_SUPPORT_ DebugVerifyDeviceIsPreMultiplied(); #endif CPDF_Dictionary* pOC = pFormObj->m_pForm->m_pFormDict->GetDictFor("OC"); if (pOC && m_Options.m_pOCContext && !m_Options.m_pOCContext->CheckOCGVisible(pOC)) { - return TRUE; + return true; } CFX_Matrix matrix = pFormObj->m_FormMatrix; matrix.Concat(*pObj2Device); @@ -445,7 +445,7 @@ FX_BOOL CPDF_RenderStatus::ProcessForm(const CPDF_FormObject* pFormObj, CPDF_RenderStatus status; status.Initialize(m_pContext, m_pDevice, nullptr, m_pStopObj, this, pFormObj, &m_Options, m_Transparency, m_bDropObjects, pResources, - FALSE); + false); status.m_curBlend = m_curBlend; m_pDevice->SaveState(); status.RenderObjectList(pFormObj->m_pForm.get(), &matrix); @@ -454,33 +454,33 @@ FX_BOOL CPDF_RenderStatus::ProcessForm(const CPDF_FormObject* pFormObj, #if defined _SKIA_SUPPORT_ DebugVerifyDeviceIsPreMultiplied(); #endif - return TRUE; + return true; } -FX_BOOL IsAvailableMatrix(const CFX_Matrix& matrix) { +bool IsAvailableMatrix(const CFX_Matrix& matrix) { if (matrix.a == 0 || matrix.d == 0) { return matrix.b != 0 && matrix.c != 0; } if (matrix.b == 0 || matrix.c == 0) { return matrix.a != 0 && matrix.d != 0; } - return TRUE; + return true; } -FX_BOOL CPDF_RenderStatus::ProcessPath(CPDF_PathObject* pPathObj, - const CFX_Matrix* pObj2Device) { +bool CPDF_RenderStatus::ProcessPath(CPDF_PathObject* pPathObj, + const CFX_Matrix* pObj2Device) { int FillType = pPathObj->m_FillType; - FX_BOOL bStroke = pPathObj->m_bStroke; + bool bStroke = pPathObj->m_bStroke; ProcessPathPattern(pPathObj, pObj2Device, FillType, bStroke); if (FillType == 0 && !bStroke) - return TRUE; + return true; uint32_t fill_argb = FillType ? GetFillArgb(pPathObj) : 0; uint32_t stroke_argb = bStroke ? GetStrokeArgb(pPathObj) : 0; CFX_Matrix path_matrix = pPathObj->m_Matrix; path_matrix.Concat(*pObj2Device); if (!IsAvailableMatrix(path_matrix)) - return TRUE; + return true; if (FillType && (m_Options.m_Flags & RENDER_RECT_AA)) FillType |= FXFILL_RECT_AA; @@ -513,7 +513,7 @@ CPDF_TransferFunc* CPDF_RenderStatus::GetTransferFunc(CPDF_Object* pObj) const { } FX_ARGB CPDF_RenderStatus::GetFillArgb(CPDF_PageObject* pObj, - FX_BOOL bType3) const { + bool bType3) const { const CPDF_ColorState* pColorState = &pObj->m_ColorState; if (m_pType3Char && !bType3 && (!m_pType3Char->m_bColored || @@ -652,9 +652,9 @@ void CPDF_RenderStatus::DrawClipPath(CPDF_ClipPath ClipPath, fill_mode); } } -FX_BOOL CPDF_RenderStatus::SelectClipPath(const CPDF_PathObject* pPathObj, - const CFX_Matrix* pObj2Device, - FX_BOOL bStroke) { +bool CPDF_RenderStatus::SelectClipPath(const CPDF_PathObject* pPathObj, + const CFX_Matrix* pObj2Device, + bool bStroke) { CFX_Matrix path_matrix = pPathObj->m_Matrix; path_matrix.Concat(*pObj2Device); if (bStroke) { @@ -671,14 +671,14 @@ FX_BOOL CPDF_RenderStatus::SelectClipPath(const CPDF_PathObject* pPathObj, return m_pDevice->SetClip_PathFill(pPathObj->m_Path.GetObject(), &path_matrix, fill_mode); } -FX_BOOL CPDF_RenderStatus::ProcessTransparency(CPDF_PageObject* pPageObj, - const CFX_Matrix* pObj2Device) { +bool CPDF_RenderStatus::ProcessTransparency(CPDF_PageObject* pPageObj, + const CFX_Matrix* pObj2Device) { #if defined _SKIA_SUPPORT_ DebugVerifyDeviceIsPreMultiplied(); #endif int blend_type = pPageObj->m_GeneralState.GetBlendType(); if (blend_type == FXDIB_BLEND_UNSUPPORTED) - return TRUE; + return true; CPDF_Dictionary* pSMaskDict = ToDictionary(pPageObj->m_GeneralState.GetSoftMask()); @@ -691,7 +691,7 @@ FX_BOOL CPDF_RenderStatus::ProcessTransparency(CPDF_PageObject* pPageObj, CPDF_Dictionary* pFormResource = nullptr; FX_FLOAT group_alpha = 1.0f; int Transparency = m_Transparency; - FX_BOOL bGroupTransparent = FALSE; + bool bGroupTransparent = false; if (pPageObj->IsForm()) { const CPDF_FormObject* pFormObj = pPageObj->AsForm(); group_alpha = pFormObj->m_GeneralState.GetFillAlpha(); @@ -735,11 +735,11 @@ FX_BOOL CPDF_RenderStatus::ProcessTransparency(CPDF_PageObject* pPageObj, } if (!pSMaskDict && group_alpha == 1.0f && blend_type == FXDIB_BLEND_NORMAL && !bTextClip && !bGroupTransparent) { - return FALSE; + return false; } bool isolated = !!(Transparency & PDFTRANS_ISOLATED); if (m_bPrint) { - FX_BOOL bRet = FALSE; + bool bRet = false; int rendCaps = m_pDevice->GetRenderCaps(); if (!((Transparency & PDFTRANS_ISOLATED) || pSMaskDict || bTextClip) && (rendCaps & FXRC_BLEND_MODE)) { @@ -751,12 +751,12 @@ FX_BOOL CPDF_RenderStatus::ProcessTransparency(CPDF_PageObject* pPageObj, if (!bRet) { DrawObjWithBackground(pPageObj, pObj2Device); } - return TRUE; + return true; } FX_RECT rect = pPageObj->GetBBox(pObj2Device); rect.Intersect(m_pDevice->GetClipBox()); if (rect.IsEmpty()) { - return TRUE; + return true; } CFX_Matrix deviceCTM = m_pDevice->GetCTM(); FX_FLOAT scaleX = FXSYS_fabs(deviceCTM.a); @@ -768,11 +768,11 @@ FX_BOOL CPDF_RenderStatus::ProcessTransparency(CPDF_PageObject* pPageObj, if (!isolated && (m_pDevice->GetRenderCaps() & FXRC_GET_BITS)) { oriDevice.reset(new CFX_DIBitmap); if (!m_pDevice->CreateCompatibleBitmap(oriDevice.get(), width, height)) - return TRUE; + return true; m_pDevice->GetDIBits(oriDevice.get(), rect.left, rect.top); } if (!bitmap_device.Create(width, height, FXDIB_Argb, oriDevice.get())) - return TRUE; + return true; CFX_DIBitmap* bitmap = bitmap_device.GetBitmap(); bitmap->Clear(0); CFX_Matrix new_matrix = *pObj2Device; @@ -782,7 +782,7 @@ FX_BOOL CPDF_RenderStatus::ProcessTransparency(CPDF_PageObject* pPageObj, if (bTextClip) { pTextMask.reset(new CFX_DIBitmap); if (!pTextMask->Create(width, height, FXDIB_8bppMask)) - return TRUE; + return true; pTextMask->Clear(0); CFX_FxgeDevice text_device; @@ -804,7 +804,7 @@ FX_BOOL CPDF_RenderStatus::ProcessTransparency(CPDF_PageObject* pPageObj, CPDF_RenderStatus bitmap_render; bitmap_render.Initialize(m_pContext, &bitmap_device, nullptr, m_pStopObj, nullptr, nullptr, &m_Options, 0, m_bDropObjects, - pFormResource, TRUE); + pFormResource, true); bitmap_render.ProcessObjectNoClip(pPageObj, &new_matrix); m_bStopped = bitmap_render.m_bStopped; if (pSMaskDict) { @@ -836,14 +836,14 @@ FX_BOOL CPDF_RenderStatus::ProcessTransparency(CPDF_PageObject* pPageObj, #if defined _SKIA_SUPPORT_ DebugVerifyDeviceIsPreMultiplied(); #endif - return TRUE; + return true; } CFX_DIBitmap* CPDF_RenderStatus::GetBackdrop(const CPDF_PageObject* pObj, const FX_RECT& rect, int& left, int& top, - FX_BOOL bBackAlphaRequired) { + bool bBackAlphaRequired) { FX_RECT bbox = rect; bbox.Intersect(m_pDevice->GetClipBox()); left = bbox.left; @@ -862,7 +862,7 @@ CFX_DIBitmap* CPDF_RenderStatus::GetBackdrop(const CPDF_PageObject* pObj, if (!pBackdrop->GetBuffer()) return nullptr; - FX_BOOL bNeedDraw; + bool bNeedDraw; if (pBackdrop->HasAlpha()) bNeedDraw = !(m_pDevice->GetRenderCaps() & FXRC_ALPHA_OUTPUT); else @@ -896,7 +896,7 @@ void CPDF_RenderContext::GetBackground(CFX_DIBitmap* pBuffer, } CPDF_GraphicStates* CPDF_RenderStatus::CloneObjStates( const CPDF_GraphicStates* pSrcStates, - FX_BOOL bStroke) { + bool bStroke) { if (!pSrcStates) return nullptr; @@ -954,7 +954,7 @@ void CPDF_RenderContext::Render(CFX_RenderDevice* pDevice, CPDF_RenderStatus status; status.Initialize(this, pDevice, pLastMatrix, pStopObj, nullptr, nullptr, pOptions, pLayer->m_pObjectHolder->m_Transparency, - FALSE, nullptr); + false, nullptr); status.RenderObjectList(pLayer->m_pObjectHolder, &FinalMatrix); if (status.m_Options.m_Flags & RENDER_LIMITEDIMAGECACHE) { m_pPageCache->CacheOptimization(status.m_Options.m_dwLimitCacheSize); @@ -967,7 +967,7 @@ void CPDF_RenderContext::Render(CFX_RenderDevice* pDevice, CPDF_RenderStatus status; status.Initialize(this, pDevice, nullptr, pStopObj, nullptr, nullptr, pOptions, pLayer->m_pObjectHolder->m_Transparency, - FALSE, nullptr); + false, nullptr); status.RenderObjectList(pLayer->m_pObjectHolder, &pLayer->m_Matrix); if (status.m_Options.m_Flags & RENDER_LIMITEDIMAGECACHE) { m_pPageCache->CacheOptimization(status.m_Options.m_dwLimitCacheSize); @@ -1019,7 +1019,7 @@ void CPDF_ProgressiveRenderer::Continue(IFX_Pause* pPause) { m_pRenderStatus.reset(new CPDF_RenderStatus()); m_pRenderStatus->Initialize( m_pContext, m_pDevice, nullptr, nullptr, nullptr, nullptr, m_pOptions, - m_pCurrentLayer->m_pObjectHolder->m_Transparency, FALSE, nullptr); + m_pCurrentLayer->m_pObjectHolder->m_Transparency, false, nullptr); m_pDevice->SaveState(); m_ClipRect = CFX_FloatRect(m_pDevice->GetClipBox()); CFX_Matrix device2object; @@ -1092,10 +1092,10 @@ CPDF_TransferFunc* CPDF_DocRenderData::GetTransferFunc(CPDF_Object* pObj) { } std::unique_ptr<CPDF_Function> pFuncs[3]; - FX_BOOL bUniTransfer = TRUE; - FX_BOOL bIdentity = TRUE; + bool bUniTransfer = true; + bool bIdentity = true; if (CPDF_Array* pArray = pObj->AsArray()) { - bUniTransfer = FALSE; + bUniTransfer = false; if (pArray->GetCount() < 3) return nullptr; @@ -1125,7 +1125,7 @@ CPDF_TransferFunc* CPDF_DocRenderData::GetTransferFunc(CPDF_Object* pObj) { pFuncs[0]->Call(&input, 1, output, noutput); int o = FXSYS_round(output[0] * 255); if (o != v) - bIdentity = FALSE; + bIdentity = false; for (int i = 0; i < 3; ++i) { pTransfer->m_Samples[i * 256 + v] = o; } @@ -1135,7 +1135,7 @@ CPDF_TransferFunc* CPDF_DocRenderData::GetTransferFunc(CPDF_Object* pObj) { pFuncs[i]->Call(&input, 1, output, noutput); int o = FXSYS_round(output[0] * 255); if (o != v) - bIdentity = FALSE; + bIdentity = false; pTransfer->m_Samples[i * 256 + v] = o; } else { pTransfer->m_Samples[i * 256 + v] = v; @@ -1159,11 +1159,11 @@ CPDF_DeviceBuffer::CPDF_DeviceBuffer() CPDF_DeviceBuffer::~CPDF_DeviceBuffer() {} -FX_BOOL CPDF_DeviceBuffer::Initialize(CPDF_RenderContext* pContext, - CFX_RenderDevice* pDevice, - FX_RECT* pRect, - const CPDF_PageObject* pObj, - int max_dpi) { +bool CPDF_DeviceBuffer::Initialize(CPDF_RenderContext* pContext, + CFX_RenderDevice* pDevice, + FX_RECT* pRect, + const CPDF_PageObject* pObj, + int max_dpi) { m_pDevice = pDevice; m_pContext = pContext; m_Rect = *pRect; @@ -1194,7 +1194,7 @@ FX_BOOL CPDF_DeviceBuffer::Initialize(CPDF_RenderContext* pContext, FX_RECT bitmap_rect = rect.GetOuterRect(); m_pBitmap.reset(new CFX_DIBitmap); m_pBitmap->Create(bitmap_rect.Width(), bitmap_rect.Height(), FXDIB_Argb); - return TRUE; + return true; } void CPDF_DeviceBuffer::OutputToDevice() { if (m_pDevice->GetDeviceCaps(FXDC_RENDER_CAPS) & FXRC_GET_BITS) { @@ -1221,15 +1221,15 @@ CPDF_ScaledRenderBuffer::CPDF_ScaledRenderBuffer() {} CPDF_ScaledRenderBuffer::~CPDF_ScaledRenderBuffer() {} #define _FPDFAPI_IMAGESIZE_LIMIT_ (30 * 1024 * 1024) -FX_BOOL CPDF_ScaledRenderBuffer::Initialize(CPDF_RenderContext* pContext, - CFX_RenderDevice* pDevice, - const FX_RECT& pRect, - const CPDF_PageObject* pObj, - const CPDF_RenderOptions* pOptions, - int max_dpi) { +bool CPDF_ScaledRenderBuffer::Initialize(CPDF_RenderContext* pContext, + CFX_RenderDevice* pDevice, + const FX_RECT& pRect, + const CPDF_PageObject* pObj, + const CPDF_RenderOptions* pOptions, + int max_dpi) { m_pDevice = pDevice; if (m_pDevice->GetDeviceCaps(FXDC_RENDER_CAPS) & FXRC_GET_BITS) { - return TRUE; + return true; } m_pContext = pContext; m_Rect = pRect; @@ -1264,7 +1264,7 @@ FX_BOOL CPDF_ScaledRenderBuffer::Initialize(CPDF_RenderContext* pContext, int32_t iHeight = bitmap_rect.Height(); int32_t iPitch = (iWidth * bpp + 31) / 32 * 4; if (iWidth * iHeight < 1) - return FALSE; + return false; if (iPitch * iHeight <= _FPDFAPI_IMAGESIZE_LIMIT_ && m_pBitmapDevice->Create(iWidth, iHeight, dibFormat, nullptr)) { @@ -1274,7 +1274,7 @@ FX_BOOL CPDF_ScaledRenderBuffer::Initialize(CPDF_RenderContext* pContext, } m_pContext->GetBackground(m_pBitmapDevice->GetBitmap(), m_pObject, pOptions, &m_Matrix); - return TRUE; + return true; } void CPDF_ScaledRenderBuffer::OutputToDevice() { if (m_pBitmapDevice) { diff --git a/core/fpdfapi/render/fpdf_render_cache.cpp b/core/fpdfapi/render/fpdf_render_cache.cpp index 67dd953752..2f342f0689 100644 --- a/core/fpdfapi/render/fpdf_render_cache.cpp +++ b/core/fpdfapi/render/fpdf_render_cache.cpp @@ -28,7 +28,7 @@ CPDF_PageRenderCache::CPDF_PageRenderCache(CPDF_Page* pPage) m_pCurImageCacheEntry(nullptr), m_nTimeCount(0), m_nCacheSize(0), - m_bCurFindCache(FALSE) {} + m_bCurFindCache(false) {} CPDF_PageRenderCache::~CPDF_PageRenderCache() { for (const auto& it : m_ImageCache) @@ -86,22 +86,22 @@ void CPDF_PageRenderCache::GetCachedBitmap(CPDF_Stream* pStream, CFX_DIBSource*& pBitmap, CFX_DIBSource*& pMask, uint32_t& MatteColor, - FX_BOOL bStdCS, + bool bStdCS, uint32_t GroupFamily, - FX_BOOL bLoadMask, + bool bLoadMask, CPDF_RenderStatus* pRenderStatus, int32_t downsampleWidth, int32_t downsampleHeight) { CPDF_ImageCacheEntry* pEntry; const auto it = m_ImageCache.find(pStream); - FX_BOOL bFound = it != m_ImageCache.end(); + bool bFound = it != m_ImageCache.end(); if (bFound) pEntry = it->second; else pEntry = new CPDF_ImageCacheEntry(m_pPage->m_pDocument, pStream); m_nTimeCount++; - FX_BOOL bAlreadyCached = pEntry->GetCachedBitmap( + bool bAlreadyCached = pEntry->GetCachedBitmap( pBitmap, pMask, MatteColor, m_pPage->m_pPageResources, bStdCS, GroupFamily, bLoadMask, pRenderStatus, downsampleWidth, downsampleHeight); @@ -111,11 +111,11 @@ void CPDF_PageRenderCache::GetCachedBitmap(CPDF_Stream* pStream, if (!bAlreadyCached) m_nCacheSize += pEntry->EstimateSize(); } -FX_BOOL CPDF_PageRenderCache::StartGetCachedBitmap( +bool CPDF_PageRenderCache::StartGetCachedBitmap( CPDF_Stream* pStream, - FX_BOOL bStdCS, + bool bStdCS, uint32_t GroupFamily, - FX_BOOL bLoadMask, + bool bLoadMask, CPDF_RenderStatus* pRenderStatus, int32_t downsampleWidth, int32_t downsampleHeight) { @@ -131,7 +131,7 @@ FX_BOOL CPDF_PageRenderCache::StartGetCachedBitmap( pRenderStatus->m_pFormResource, m_pPage->m_pPageResources, bStdCS, GroupFamily, bLoadMask, pRenderStatus, downsampleWidth, downsampleHeight); if (ret == 2) - return TRUE; + return true; m_nTimeCount++; if (!m_bCurFindCache) @@ -140,18 +140,18 @@ FX_BOOL CPDF_PageRenderCache::StartGetCachedBitmap( if (!ret) m_nCacheSize += m_pCurImageCacheEntry->EstimateSize(); - return FALSE; + return false; } -FX_BOOL CPDF_PageRenderCache::Continue(IFX_Pause* pPause) { +bool CPDF_PageRenderCache::Continue(IFX_Pause* pPause) { int ret = m_pCurImageCacheEntry->Continue(pPause); if (ret == 2) - return TRUE; + return true; m_nTimeCount++; if (!m_bCurFindCache) m_ImageCache[m_pCurImageCacheEntry->GetStream()] = m_pCurImageCacheEntry; if (!ret) m_nCacheSize += m_pCurImageCacheEntry->EstimateSize(); - return FALSE; + return false; } void CPDF_PageRenderCache::ResetBitmap(CPDF_Stream* pStream, const CFX_DIBitmap* pBitmap) { @@ -200,24 +200,24 @@ static uint32_t FPDF_ImageCache_EstimateImageSize(const CFX_DIBSource* pDIB) { (uint32_t)pDIB->GetPaletteSize() * 4 : 0; } -FX_BOOL CPDF_ImageCacheEntry::GetCachedBitmap(CFX_DIBSource*& pBitmap, - CFX_DIBSource*& pMask, - uint32_t& MatteColor, - CPDF_Dictionary* pPageResources, - FX_BOOL bStdCS, - uint32_t GroupFamily, - FX_BOOL bLoadMask, - CPDF_RenderStatus* pRenderStatus, - int32_t downsampleWidth, - int32_t downsampleHeight) { +bool CPDF_ImageCacheEntry::GetCachedBitmap(CFX_DIBSource*& pBitmap, + CFX_DIBSource*& pMask, + uint32_t& MatteColor, + CPDF_Dictionary* pPageResources, + bool bStdCS, + uint32_t GroupFamily, + bool bLoadMask, + CPDF_RenderStatus* pRenderStatus, + int32_t downsampleWidth, + int32_t downsampleHeight) { if (m_pCachedBitmap) { pBitmap = m_pCachedBitmap; pMask = m_pCachedMask; MatteColor = m_MatteColor; - return TRUE; + return true; } if (!pRenderStatus) { - return FALSE; + return false; } CPDF_RenderContext* pContext = pRenderStatus->GetContext(); CPDF_PageRenderCache* pPageRenderCache = pContext->GetPageCache(); @@ -229,7 +229,7 @@ FX_BOOL CPDF_ImageCacheEntry::GetCachedBitmap(CFX_DIBSource*& pBitmap, GroupFamily, bLoadMask)) { delete pSrc; pBitmap = nullptr; - return FALSE; + return false; } m_MatteColor = MatteColor; if (pSrc->GetPitch() * pSrc->GetHeight() < FPDF_HUGE_IMAGE_SIZE) { @@ -246,7 +246,7 @@ FX_BOOL CPDF_ImageCacheEntry::GetCachedBitmap(CFX_DIBSource*& pBitmap, pBitmap = m_pCachedBitmap; pMask = m_pCachedMask; CalcSize(); - return FALSE; + return false; } CFX_DIBSource* CPDF_ImageCacheEntry::DetachBitmap() { CFX_DIBSource* pDIBSource = m_pCurBitmap; @@ -260,9 +260,9 @@ CFX_DIBSource* CPDF_ImageCacheEntry::DetachMask() { } int CPDF_ImageCacheEntry::StartGetCachedBitmap(CPDF_Dictionary* pFormResources, CPDF_Dictionary* pPageResources, - FX_BOOL bStdCS, + bool bStdCS, uint32_t GroupFamily, - FX_BOOL bLoadMask, + bool bLoadMask, CPDF_RenderStatus* pRenderStatus, int32_t downsampleWidth, int32_t downsampleHeight) { @@ -278,7 +278,7 @@ int CPDF_ImageCacheEntry::StartGetCachedBitmap(CPDF_Dictionary* pFormResources, m_pCurBitmap = new CPDF_DIBSource; int ret = ((CPDF_DIBSource*)m_pCurBitmap) - ->StartLoadDIBSource(m_pDocument, m_pStream, TRUE, pFormResources, + ->StartLoadDIBSource(m_pDocument, m_pStream, true, pFormResources, pPageResources, bStdCS, GroupFamily, bLoadMask); if (ret == 2) { return ret; diff --git a/core/fpdfapi/render/fpdf_render_image.cpp b/core/fpdfapi/render/fpdf_render_image.cpp index 049eff30c0..1133f67a9a 100644 --- a/core/fpdfapi/render/fpdf_render_image.cpp +++ b/core/fpdfapi/render/fpdf_render_image.cpp @@ -34,8 +34,8 @@ #include "core/fxge/skia/fx_skia_device.h" #endif -FX_BOOL CPDF_RenderStatus::ProcessImage(CPDF_ImageObject* pImageObj, - const CFX_Matrix* pObj2Device) { +bool CPDF_RenderStatus::ProcessImage(CPDF_ImageObject* pImageObj, + const CFX_Matrix* pObj2Device) { CPDF_ImageRenderer render; if (render.Start(this, pImageObj, pObj2Device, m_bStdCS, m_curBlend)) { render.Continue(nullptr); @@ -100,9 +100,9 @@ void CPDF_RenderStatus::CompositeDIBitmap(CFX_DIBitmap* pDIBitmap, top + pDIBitmap->GetHeight()); rect.Intersect(m_pDevice->GetClipBox()); CFX_DIBitmap* pClone = nullptr; - FX_BOOL bClone = FALSE; + bool bClone = false; if (m_pDevice->GetBackDrop() && m_pDevice->GetBitmap()) { - bClone = TRUE; + bClone = true; pClone = m_pDevice->GetBackDrop()->Clone(&rect); CFX_DIBitmap* pForeBitmap = m_pDevice->GetBitmap(); pClone->CompositeBitmap(0, 0, pClone->GetWidth(), pClone->GetHeight(), @@ -171,7 +171,7 @@ FX_COLORREF CPDF_TransferFunc::TranslateColor(FX_COLORREF rgb) const { } CFX_DIBSource* CPDF_TransferFunc::TranslateImage(const CFX_DIBSource* pSrc, - FX_BOOL bAutoDropSrc) { + bool bAutoDropSrc) { CPDF_DIBTransferFunc* pDest = new CPDF_DIBTransferFunc(this); pDest->LoadSrc(pSrc, bAutoDropSrc); return pDest; @@ -204,7 +204,7 @@ CPDF_DIBTransferFunc::CPDF_DIBTransferFunc( void CPDF_DIBTransferFunc::TranslateScanline( const uint8_t* src_buf, std::vector<uint8_t>* dest_buf) const { - FX_BOOL bSkip = FALSE; + bool bSkip = false; switch (m_pSrc->GetFormat()) { case FXDIB_1bppRgb: { int r0 = m_RampR[0]; @@ -284,7 +284,7 @@ void CPDF_DIBTransferFunc::TranslateScanline( break; } case FXDIB_Rgb32: - bSkip = TRUE; + bSkip = true; case FXDIB_Argb: { int index = 0; for (int i = 0; i < m_Width; i++) { @@ -348,11 +348,11 @@ void CPDF_DIBTransferFunc::TranslateDownSamples(uint8_t* dest_buf, CPDF_ImageRenderer::CPDF_ImageRenderer() { m_pRenderStatus = nullptr; m_pImageObject = nullptr; - m_Result = TRUE; + m_Result = true; m_Status = 0; m_DeviceHandle = nullptr; - m_bStdCS = FALSE; - m_bPatternColor = FALSE; + m_bStdCS = false; + m_bPatternColor = false; m_BlendType = FXDIB_BLEND_NORMAL; m_pPattern = nullptr; m_pObj2Device = nullptr; @@ -364,11 +364,11 @@ CPDF_ImageRenderer::~CPDF_ImageRenderer() { } } -FX_BOOL CPDF_ImageRenderer::StartLoadDIBSource() { +bool CPDF_ImageRenderer::StartLoadDIBSource() { CFX_FloatRect image_rect_f = m_ImageMatrix.GetUnitRect(); FX_RECT image_rect = image_rect_f.GetOuterRect(); if (!image_rect.Valid()) - return FALSE; + return false; int dest_width = image_rect.Width(); int dest_height = image_rect.Height(); @@ -385,15 +385,15 @@ FX_BOOL CPDF_ImageRenderer::StartLoadDIBSource() { dest_height)) { if (m_LoadHandle) { m_Status = 4; - return TRUE; + return true; } } - return FALSE; + return false; } -FX_BOOL CPDF_ImageRenderer::StartRenderDIBSource() { +bool CPDF_ImageRenderer::StartRenderDIBSource() { if (!m_Loader.m_pBitmap) - return FALSE; + return false; m_BitmapAlpha = FXSYS_round(255 * m_pImageObject->m_GeneralState.GetFillAlpha()); @@ -416,18 +416,18 @@ FX_BOOL CPDF_ImageRenderer::StartRenderDIBSource() { if (m_Loader.m_bCached && m_Loader.m_pMask) { m_Loader.m_pMask = m_Loader.m_pMask->Clone(); } - m_Loader.m_bCached = FALSE; + m_Loader.m_bCached = false; } } m_FillArgb = 0; - m_bPatternColor = FALSE; + m_bPatternColor = false; m_pPattern = nullptr; if (m_pDIBSource->IsAlphaMask()) { const CPDF_Color* pColor = m_pImageObject->m_ColorState.GetFillColor(); if (pColor && pColor->IsPattern()) { m_pPattern = pColor->GetPattern(); if (m_pPattern) { - m_bPatternColor = TRUE; + m_bPatternColor = true; } } m_FillArgb = m_pRenderStatus->GetFillArgb(m_pImageObject); @@ -507,11 +507,11 @@ FX_BOOL CPDF_ImageRenderer::StartRenderDIBSource() { return StartDIBSource(); } -FX_BOOL CPDF_ImageRenderer::Start(CPDF_RenderStatus* pStatus, - CPDF_PageObject* pObj, - const CFX_Matrix* pObj2Device, - FX_BOOL bStdCS, - int blendType) { +bool CPDF_ImageRenderer::Start(CPDF_RenderStatus* pStatus, + CPDF_PageObject* pObj, + const CFX_Matrix* pObj2Device, + bool bStdCS, + int blendType) { m_pRenderStatus = pStatus; m_bStdCS = bStdCS; m_pImageObject = pObj->AsImage(); @@ -520,24 +520,24 @@ FX_BOOL CPDF_ImageRenderer::Start(CPDF_RenderStatus* pStatus, CPDF_Dictionary* pOC = m_pImageObject->GetImage()->GetOC(); if (pOC && m_pRenderStatus->m_Options.m_pOCContext && !m_pRenderStatus->m_Options.m_pOCContext->CheckOCGVisible(pOC)) { - return FALSE; + return false; } m_ImageMatrix = m_pImageObject->m_Matrix; m_ImageMatrix.Concat(*pObj2Device); if (StartLoadDIBSource()) { - return TRUE; + return true; } return StartRenderDIBSource(); } -FX_BOOL CPDF_ImageRenderer::Start(CPDF_RenderStatus* pStatus, - const CFX_DIBSource* pDIBSource, - FX_ARGB bitmap_argb, - int bitmap_alpha, - const CFX_Matrix* pImage2Device, - uint32_t flags, - FX_BOOL bStdCS, - int blendType) { +bool CPDF_ImageRenderer::Start(CPDF_RenderStatus* pStatus, + const CFX_DIBSource* pDIBSource, + FX_ARGB bitmap_argb, + int bitmap_alpha, + const CFX_Matrix* pImage2Device, + uint32_t flags, + bool bStdCS, + int blendType) { m_pRenderStatus = pStatus; m_pDIBSource = pDIBSource; m_FillArgb = bitmap_argb; @@ -549,16 +549,16 @@ FX_BOOL CPDF_ImageRenderer::Start(CPDF_RenderStatus* pStatus, return StartDIBSource(); } -FX_BOOL CPDF_ImageRenderer::DrawPatternImage(const CFX_Matrix* pObj2Device) { +bool CPDF_ImageRenderer::DrawPatternImage(const CFX_Matrix* pObj2Device) { if (m_pRenderStatus->m_bPrint && !(m_pRenderStatus->m_pDevice->GetRenderCaps() & FXRC_BLEND_MODE)) { - m_Result = FALSE; - return FALSE; + m_Result = false; + return false; } FX_RECT rect = m_ImageMatrix.GetUnitRect().GetOuterRect(); rect.Intersect(m_pRenderStatus->m_pDevice->GetClipBox()); if (rect.IsEmpty()) { - return FALSE; + return false; } CFX_Matrix new_matrix = m_ImageMatrix; new_matrix.TranslateI(-rect.left, -rect.top); @@ -566,7 +566,7 @@ FX_BOOL CPDF_ImageRenderer::DrawPatternImage(const CFX_Matrix* pObj2Device) { int height = rect.Height(); CFX_FxgeDevice bitmap_device1; if (!bitmap_device1.Create(rect.Width(), rect.Height(), FXDIB_Rgb32, nullptr)) - return TRUE; + return true; bitmap_device1.GetBitmap()->Clear(0xffffff); { @@ -574,32 +574,32 @@ FX_BOOL CPDF_ImageRenderer::DrawPatternImage(const CFX_Matrix* pObj2Device) { bitmap_render.Initialize(m_pRenderStatus->m_pContext, &bitmap_device1, nullptr, nullptr, nullptr, nullptr, &m_pRenderStatus->m_Options, 0, - m_pRenderStatus->m_bDropObjects, nullptr, TRUE); + m_pRenderStatus->m_bDropObjects, nullptr, true); CFX_Matrix patternDevice = *pObj2Device; patternDevice.Translate((FX_FLOAT)-rect.left, (FX_FLOAT)-rect.top); if (CPDF_TilingPattern* pTilingPattern = m_pPattern->AsTilingPattern()) { bitmap_render.DrawTilingPattern(pTilingPattern, m_pImageObject, - &patternDevice, FALSE); + &patternDevice, false); } else if (CPDF_ShadingPattern* pShadingPattern = m_pPattern->AsShadingPattern()) { bitmap_render.DrawShadingPattern(pShadingPattern, m_pImageObject, - &patternDevice, FALSE); + &patternDevice, false); } } { CFX_FxgeDevice bitmap_device2; if (!bitmap_device2.Create(rect.Width(), rect.Height(), FXDIB_8bppRgb, nullptr)) { - return TRUE; + return true; } bitmap_device2.GetBitmap()->Clear(0); CPDF_RenderStatus bitmap_render; bitmap_render.Initialize(m_pRenderStatus->m_pContext, &bitmap_device2, nullptr, nullptr, nullptr, nullptr, nullptr, 0, - m_pRenderStatus->m_bDropObjects, nullptr, TRUE); + m_pRenderStatus->m_bDropObjects, nullptr, true); CPDF_ImageRenderer image_render; if (image_render.Start(&bitmap_render, m_pDIBSource, 0xffffffff, 255, - &new_matrix, m_Flags, TRUE)) { + &new_matrix, m_Flags, true)) { image_render.Continue(nullptr); } if (m_Loader.m_MatteColor != 0xffffffff) { @@ -647,19 +647,19 @@ FX_BOOL CPDF_ImageRenderer::DrawPatternImage(const CFX_Matrix* pObj2Device) { } m_pRenderStatus->m_pDevice->SetDIBitsWithBlend( bitmap_device1.GetBitmap(), rect.left, rect.top, m_BlendType); - return FALSE; + return false; } -FX_BOOL CPDF_ImageRenderer::DrawMaskedImage() { +bool CPDF_ImageRenderer::DrawMaskedImage() { if (m_pRenderStatus->m_bPrint && !(m_pRenderStatus->m_pDevice->GetRenderCaps() & FXRC_BLEND_MODE)) { - m_Result = FALSE; - return FALSE; + m_Result = false; + return false; } FX_RECT rect = m_ImageMatrix.GetUnitRect().GetOuterRect(); rect.Intersect(m_pRenderStatus->m_pDevice->GetClipBox()); if (rect.IsEmpty()) { - return FALSE; + return false; } CFX_Matrix new_matrix = m_ImageMatrix; new_matrix.TranslateI(-rect.left, -rect.top); @@ -667,7 +667,7 @@ FX_BOOL CPDF_ImageRenderer::DrawMaskedImage() { int height = rect.Height(); CFX_FxgeDevice bitmap_device1; if (!bitmap_device1.Create(width, height, FXDIB_Rgb32, nullptr)) - return TRUE; + return true; #if defined _SKIA_SUPPORT_ bitmap_device1.Clear(0xffffff); @@ -678,17 +678,17 @@ FX_BOOL CPDF_ImageRenderer::DrawMaskedImage() { CPDF_RenderStatus bitmap_render; bitmap_render.Initialize(m_pRenderStatus->m_pContext, &bitmap_device1, nullptr, nullptr, nullptr, nullptr, nullptr, 0, - m_pRenderStatus->m_bDropObjects, nullptr, TRUE); + m_pRenderStatus->m_bDropObjects, nullptr, true); CPDF_ImageRenderer image_render; if (image_render.Start(&bitmap_render, m_pDIBSource, 0, 255, &new_matrix, - m_Flags, TRUE)) { + m_Flags, true)) { image_render.Continue(nullptr); } } { CFX_FxgeDevice bitmap_device2; if (!bitmap_device2.Create(width, height, FXDIB_8bppRgb, nullptr)) - return TRUE; + return true; #if defined _SKIA_SUPPORT_ bitmap_device2.Clear(0); @@ -698,10 +698,10 @@ FX_BOOL CPDF_ImageRenderer::DrawMaskedImage() { CPDF_RenderStatus bitmap_render; bitmap_render.Initialize(m_pRenderStatus->m_pContext, &bitmap_device2, nullptr, nullptr, nullptr, nullptr, nullptr, 0, - m_pRenderStatus->m_bDropObjects, nullptr, TRUE); + m_pRenderStatus->m_bDropObjects, nullptr, true); CPDF_ImageRenderer image_render; if (image_render.Start(&bitmap_render, m_Loader.m_pMask, 0xffffffff, 255, - &new_matrix, m_Flags, TRUE)) { + &new_matrix, m_Flags, true)) { image_render.Continue(nullptr); } if (m_Loader.m_MatteColor != 0xffffffff) { @@ -758,17 +758,17 @@ FX_BOOL CPDF_ImageRenderer::DrawMaskedImage() { m_pRenderStatus->m_pDevice->SetDIBitsWithBlend( bitmap_device1.GetBitmap(), rect.left, rect.top, m_BlendType); #endif // _SKIA_SUPPORT_ - return FALSE; + return false; } -FX_BOOL CPDF_ImageRenderer::StartDIBSource() { +bool CPDF_ImageRenderer::StartDIBSource() { if (!(m_Flags & RENDER_FORCE_DOWNSAMPLE) && m_pDIBSource->GetBPP() > 1) { FX_SAFE_SIZE_T image_size = m_pDIBSource->GetBPP(); image_size /= 8; image_size *= m_pDIBSource->GetWidth(); image_size *= m_pDIBSource->GetHeight(); if (!image_size.IsValid()) { - return FALSE; + return false; } if (image_size.ValueOrDie() > FPDF_HUGE_IMAGE_SIZE && @@ -785,9 +785,9 @@ FX_BOOL CPDF_ImageRenderer::StartDIBSource() { m_DeviceHandle, m_BlendType)) { if (m_DeviceHandle) { m_Status = 3; - return TRUE; + return true; } - return FALSE; + return false; } #else if (m_pRenderStatus->m_pDevice->StartDIBitsWithBlend( @@ -795,9 +795,9 @@ FX_BOOL CPDF_ImageRenderer::StartDIBSource() { m_DeviceHandle, m_BlendType)) { if (m_DeviceHandle) { m_Status = 3; - return TRUE; + return true; } - return FALSE; + return false; } #endif CFX_FloatRect image_rect_f = m_ImageMatrix.GetUnitRect(); @@ -808,8 +808,8 @@ FX_BOOL CPDF_ImageRenderer::StartDIBSource() { (FXSYS_fabs(m_ImageMatrix.c) >= 0.5f || m_ImageMatrix.d == 0)) { if (m_pRenderStatus->m_bPrint && !(m_pRenderStatus->m_pDevice->GetRenderCaps() & FXRC_BLEND_MODE)) { - m_Result = FALSE; - return FALSE; + m_Result = false; + return false; } FX_RECT clip_box = m_pRenderStatus->m_pDevice->GetClipBox(); clip_box.Intersect(image_rect); @@ -817,7 +817,7 @@ FX_BOOL CPDF_ImageRenderer::StartDIBSource() { m_pTransformer.reset(new CFX_ImageTransformer(m_pDIBSource, &m_ImageMatrix, m_Flags, &clip_box)); m_pTransformer->Start(); - return TRUE; + return true; } if (m_ImageMatrix.a < 0) dest_width = -dest_width; @@ -831,7 +831,7 @@ FX_BOOL CPDF_ImageRenderer::StartDIBSource() { if (m_pRenderStatus->m_pDevice->StretchDIBitsWithFlagsAndBlend( m_pDIBSource, dest_left, dest_top, dest_width, dest_height, m_Flags, m_BlendType)) { - return FALSE; + return false; } } if (m_pDIBSource->IsAlphaMask()) { @@ -840,13 +840,13 @@ FX_BOOL CPDF_ImageRenderer::StartDIBSource() { if (m_pRenderStatus->m_pDevice->StretchBitMaskWithFlags( m_pDIBSource, dest_left, dest_top, dest_width, dest_height, m_FillArgb, m_Flags)) { - return FALSE; + return false; } } if (m_pRenderStatus->m_bPrint && !(m_pRenderStatus->m_pDevice->GetRenderCaps() & FXRC_BLEND_MODE)) { - m_Result = FALSE; - return TRUE; + m_Result = false; + return true; } FX_RECT clip_box = m_pRenderStatus->m_pDevice->GetClipBox(); @@ -860,12 +860,12 @@ FX_BOOL CPDF_ImageRenderer::StartDIBSource() { if (pStretched) { m_pRenderStatus->CompositeDIBitmap(pStretched.get(), dest_rect.left, dest_rect.top, m_FillArgb, m_BitmapAlpha, - m_BlendType, FALSE); + m_BlendType, false); } - return FALSE; + return false; } -FX_BOOL CPDF_ImageRenderer::StartBitmapAlpha() { +bool CPDF_ImageRenderer::StartBitmapAlpha() { if (m_pDIBSource->IsOpaqueImage()) { CFX_PathData path; path.AppendRect(0, 0, 1, 1); @@ -884,7 +884,7 @@ FX_BOOL CPDF_ImageRenderer::StartBitmapAlpha() { std::unique_ptr<CFX_DIBitmap> pTransformed( pAlphaMask->TransformTo(&m_ImageMatrix, left, top)); if (!pTransformed) - return TRUE; + return true; m_pRenderStatus->m_pDevice->SetBitMask( pTransformed.get(), left, top, @@ -906,17 +906,17 @@ FX_BOOL CPDF_ImageRenderer::StartBitmapAlpha() { delete pAlphaMask; } } - return FALSE; + return false; } -FX_BOOL CPDF_ImageRenderer::Continue(IFX_Pause* pPause) { +bool CPDF_ImageRenderer::Continue(IFX_Pause* pPause) { if (m_Status == 2) { if (m_pTransformer->Continue(pPause)) - return TRUE; + return true; std::unique_ptr<CFX_DIBitmap> pBitmap(m_pTransformer->DetachBitmap()); if (!pBitmap) - return FALSE; + return false; if (pBitmap->IsAlphaMask()) { if (m_BitmapAlpha != 255) @@ -931,19 +931,19 @@ FX_BOOL CPDF_ImageRenderer::Continue(IFX_Pause* pPause) { pBitmap.get(), m_pTransformer->result().left, m_pTransformer->result().top, m_BlendType); } - return FALSE; + return false; } if (m_Status == 3) return m_pRenderStatus->m_pDevice->ContinueDIBits(m_DeviceHandle, pPause); if (m_Status == 4) { if (m_Loader.Continue(m_LoadHandle.get(), pPause)) - return TRUE; + return true; if (StartRenderDIBSource()) return Continue(pPause); } - return FALSE; + return false; } CCodec_ScanlineDecoder* FPDFAPI_CreateFlateDecoder( @@ -978,7 +978,7 @@ CFX_DIBitmap* CPDF_RenderStatus::LoadSMask(CPDF_Dictionary* pSMaskDict, form.ParseContent(nullptr, nullptr, nullptr); CFX_FxgeDevice bitmap_device; - FX_BOOL bLuminosity = pSMaskDict->GetStringFor("S") != "Alpha"; + bool bLuminosity = pSMaskDict->GetStringFor("S") != "Alpha"; int width = pClipRect->right - pClipRect->left; int height = pClipRect->bottom - pClipRect->top; FXDIB_Format format; @@ -1042,7 +1042,7 @@ CFX_DIBitmap* CPDF_RenderStatus::LoadSMask(CPDF_Dictionary* pSMaskDict, options.m_ColorMode = bLuminosity ? RENDER_COLOR_NORMAL : RENDER_COLOR_ALPHA; CPDF_RenderStatus status; status.Initialize(m_pContext, &bitmap_device, nullptr, nullptr, nullptr, - nullptr, &options, 0, m_bDropObjects, pFormResource, TRUE, + nullptr, &options, 0, m_bDropObjects, pFormResource, true, nullptr, 0, color_space_family, bLuminosity); status.RenderObjectList(&form, &matrix); std::unique_ptr<CFX_DIBitmap> pMask(new CFX_DIBitmap); diff --git a/core/fpdfapi/render/fpdf_render_loadimage.cpp b/core/fpdfapi/render/fpdf_render_loadimage.cpp index 553481db60..c3fe99018c 100644 --- a/core/fpdfapi/render/fpdf_render_loadimage.cpp +++ b/core/fpdfapi/render/fpdf_render_loadimage.cpp @@ -102,13 +102,13 @@ CPDF_DIBSource::CPDF_DIBSource() m_nComponents(0), m_GroupFamily(0), m_MatteColor(0), - m_bLoadMask(FALSE), - m_bDefaultDecode(TRUE), - m_bImageMask(FALSE), - m_bDoBpcCheck(TRUE), - m_bColorKey(FALSE), - m_bHasMask(FALSE), - m_bStdCS(FALSE), + m_bLoadMask(false), + m_bDefaultDecode(true), + m_bImageMask(false), + m_bDoBpcCheck(true), + m_bColorKey(false), + m_bHasMask(false), + m_bStdCS(false), m_pCompData(nullptr), m_pLineBuf(nullptr), m_pMaskedLine(nullptr), @@ -137,51 +137,51 @@ void CPDF_DIBSource::ReleaseBitmap(CFX_DIBitmap* pBitmap) const { } } -FX_BOOL CPDF_DIBSource::Load(CPDF_Document* pDoc, - const CPDF_Stream* pStream, - CPDF_DIBSource** ppMask, - uint32_t* pMatteColor, - CPDF_Dictionary* pFormResources, - CPDF_Dictionary* pPageResources, - FX_BOOL bStdCS, - uint32_t GroupFamily, - FX_BOOL bLoadMask) { +bool CPDF_DIBSource::Load(CPDF_Document* pDoc, + const CPDF_Stream* pStream, + CPDF_DIBSource** ppMask, + uint32_t* pMatteColor, + CPDF_Dictionary* pFormResources, + CPDF_Dictionary* pPageResources, + bool bStdCS, + uint32_t GroupFamily, + bool bLoadMask) { if (!pStream) { - return FALSE; + return false; } m_pDocument = pDoc; m_pDict = pStream->GetDict(); if (!m_pDict) { - return FALSE; + return false; } m_pStream = pStream; m_Width = m_pDict->GetIntegerFor("Width"); m_Height = m_pDict->GetIntegerFor("Height"); if (m_Width <= 0 || m_Height <= 0 || m_Width > kMaxImageDimension || m_Height > kMaxImageDimension) { - return FALSE; + return false; } m_GroupFamily = GroupFamily; m_bLoadMask = bLoadMask; if (!LoadColorInfo(m_pStream->IsInline() ? pFormResources : nullptr, pPageResources)) { - return FALSE; + return false; } if (m_bDoBpcCheck && (m_bpc == 0 || m_nComponents == 0)) { - return FALSE; + return false; } FX_SAFE_UINT32 src_size = CalculatePitch8(m_bpc, m_nComponents, m_Width) * m_Height; if (!src_size.IsValid()) { - return FALSE; + return false; } m_pStreamAcc.reset(new CPDF_StreamAcc); - m_pStreamAcc->LoadAllData(pStream, FALSE, src_size.ValueOrDie(), TRUE); + m_pStreamAcc->LoadAllData(pStream, false, src_size.ValueOrDie(), true); if (m_pStreamAcc->GetSize() == 0 || !m_pStreamAcc->GetData()) { - return FALSE; + return false; } if (!CreateDecoder()) { - return FALSE; + return false; } if (m_bImageMask) { m_bpp = 1; @@ -197,11 +197,11 @@ FX_BOOL CPDF_DIBSource::Load(CPDF_Document* pDoc, } FX_SAFE_UINT32 pitch = CalculatePitch32(m_bpp, m_Width); if (!pitch.IsValid()) { - return FALSE; + return false; } m_pLineBuf = FX_Alloc(uint8_t, pitch.ValueOrDie()); if (m_pColorSpace && bStdCS) { - m_pColorSpace->EnableStdConversion(TRUE); + m_pColorSpace->EnableStdConversion(true); } LoadPalette(); if (m_bColorKey) { @@ -209,7 +209,7 @@ FX_BOOL CPDF_DIBSource::Load(CPDF_Document* pDoc, m_AlphaFlag = 2; pitch = CalculatePitch32(m_bpp, m_Width); if (!pitch.IsValid()) { - return FALSE; + return false; } m_pMaskedLine = FX_Alloc(uint8_t, pitch.ValueOrDie()); } @@ -218,9 +218,9 @@ FX_BOOL CPDF_DIBSource::Load(CPDF_Document* pDoc, *ppMask = LoadMask(*pMatteColor); } if (m_pColorSpace && bStdCS) { - m_pColorSpace->EnableStdConversion(FALSE); + m_pColorSpace->EnableStdConversion(false); } - return TRUE; + return true; } int CPDF_DIBSource::ContinueToLoadMask() { @@ -245,7 +245,7 @@ int CPDF_DIBSource::ContinueToLoadMask() { } m_pLineBuf = FX_Alloc(uint8_t, pitch.ValueOrDie()); if (m_pColorSpace && m_bStdCS) { - m_pColorSpace->EnableStdConversion(TRUE); + m_pColorSpace->EnableStdConversion(true); } LoadPalette(); if (m_bColorKey) { @@ -263,12 +263,12 @@ int CPDF_DIBSource::ContinueToLoadMask() { int CPDF_DIBSource::StartLoadDIBSource(CPDF_Document* pDoc, const CPDF_Stream* pStream, - FX_BOOL bHasMask, + bool bHasMask, CPDF_Dictionary* pFormResources, CPDF_Dictionary* pPageResources, - FX_BOOL bStdCS, + bool bStdCS, uint32_t GroupFamily, - FX_BOOL bLoadMask) { + bool bLoadMask) { if (!pStream) { return 0; } @@ -298,7 +298,7 @@ int CPDF_DIBSource::StartLoadDIBSource(CPDF_Document* pDoc, return 0; } m_pStreamAcc.reset(new CPDF_StreamAcc); - m_pStreamAcc->LoadAllData(pStream, FALSE, src_size.ValueOrDie(), TRUE); + m_pStreamAcc->LoadAllData(pStream, false, src_size.ValueOrDie(), true); if (m_pStreamAcc->GetSize() == 0 || !m_pStreamAcc->GetData()) { return 0; } @@ -325,7 +325,7 @@ int CPDF_DIBSource::StartLoadDIBSource(CPDF_Document* pDoc, return ret; } if (m_pColorSpace && m_bStdCS) { - m_pColorSpace->EnableStdConversion(FALSE); + m_pColorSpace->EnableStdConversion(false); } return ret; } @@ -345,7 +345,7 @@ int CPDF_DIBSource::ContinueLoadDIBSource(IFX_Pause* pPause) { m_pStreamAcc->GetImageParam()->GetStreamFor("JBIG2Globals"); if (pGlobals) { m_pGlobalStream.reset(new CPDF_StreamAcc); - m_pGlobalStream->LoadAllData(pGlobals, FALSE); + m_pGlobalStream->LoadAllData(pGlobals, false); } } ret = pJbig2Module->StartDecode( @@ -370,7 +370,7 @@ int CPDF_DIBSource::ContinueLoadDIBSource(IFX_Pause* pPause) { return ret1; } if (m_pColorSpace && m_bStdCS) { - m_pColorSpace->EnableStdConversion(FALSE); + m_pColorSpace->EnableStdConversion(false); } return ret1; } @@ -393,7 +393,7 @@ int CPDF_DIBSource::ContinueLoadDIBSource(IFX_Pause* pPause) { return ret1; } if (m_pColorSpace && m_bStdCS) { - m_pColorSpace->EnableStdConversion(FALSE); + m_pColorSpace->EnableStdConversion(false); } return ret1; } @@ -407,7 +407,7 @@ bool CPDF_DIBSource::LoadColorInfo(const CPDF_Dictionary* pFormResources, const CPDF_Dictionary* pPageResources) { m_bpc_orig = m_pDict->GetIntegerFor("BitsPerComponent"); if (m_pDict->GetIntegerFor("ImageMask")) - m_bImageMask = TRUE; + m_bImageMask = true; if (m_bImageMask || !m_pDict->KeyExist("ColorSpace")) { if (!m_bImageMask) { @@ -421,12 +421,12 @@ bool CPDF_DIBSource::LoadColorInfo(const CPDF_Dictionary* pFormResources, } if (filter == "JPXDecode") { - m_bDoBpcCheck = FALSE; + m_bDoBpcCheck = false; return true; } } } - m_bImageMask = TRUE; + m_bImageMask = true; m_bpc = m_nComponents = 1; CPDF_Array* pDecode = m_pDict->GetArrayFor("Decode"); m_bDefaultDecode = !pDecode || !pDecode->GetIntegerAt(0); @@ -462,8 +462,8 @@ bool CPDF_DIBSource::LoadColorInfo(const CPDF_Dictionary* pFormResources, return !!m_pCompData; } -DIB_COMP_DATA* CPDF_DIBSource::GetDecodeAndMaskArray(FX_BOOL& bDefaultDecode, - FX_BOOL& bColorKey) { +DIB_COMP_DATA* CPDF_DIBSource::GetDecodeAndMaskArray(bool& bDefaultDecode, + bool& bColorKey) { if (!m_pColorSpace) { return nullptr; } @@ -483,7 +483,7 @@ DIB_COMP_DATA* CPDF_DIBSource::GetDecodeAndMaskArray(FX_BOOL& bDefaultDecode, def_max = max_data; } if (def_min != pCompData[i].m_DecodeMin || def_max != max) { - bDefaultDecode = FALSE; + bDefaultDecode = false; } } } else { @@ -512,7 +512,7 @@ DIB_COMP_DATA* CPDF_DIBSource::GetDecodeAndMaskArray(FX_BOOL& bDefaultDecode, pCompData[i].m_ColorKeyMax = std::min(max_num, max_data); } } - bColorKey = TRUE; + bColorKey = true; } } return pCompData; @@ -635,18 +635,18 @@ void CPDF_DIBSource::LoadJpxBitmap() { if (static_cast<int>(width) < m_Width || static_cast<int>(height) < m_Height) return; - FX_BOOL bSwapRGB = FALSE; + bool bSwapRGB = false; if (m_pColorSpace) { if (components != m_pColorSpace->CountComponents()) return; if (m_pColorSpace == CPDF_ColorSpace::GetStockCS(PDFCS_DEVICERGB)) { - bSwapRGB = TRUE; + bSwapRGB = true; m_pColorSpace = nullptr; } } else { if (components == 3) { - bSwapRGB = TRUE; + bSwapRGB = true; } else if (components == 4) { m_pColorSpace = CPDF_ColorSpace::GetStockCS(PDFCS_DEVICECMYK); } @@ -755,7 +755,7 @@ int CPDF_DIBSource::ContinueLoadMaskDIB(IFX_Pause* pPause) { return ret; } if (m_pColorSpace && m_bStdCS) { - m_pColorSpace->EnableStdConversion(FALSE); + m_pColorSpace->EnableStdConversion(false); } if (!ret) { delete m_pMask; @@ -774,7 +774,7 @@ CPDF_DIBSource* CPDF_DIBSource::DetachMask() { CPDF_DIBSource* CPDF_DIBSource::LoadMaskDIB(CPDF_Stream* pMask) { CPDF_DIBSource* pMaskSource = new CPDF_DIBSource; if (!pMaskSource->Load(m_pDocument, pMask, nullptr, nullptr, nullptr, nullptr, - TRUE)) { + true)) { delete pMaskSource; return nullptr; } @@ -783,8 +783,8 @@ CPDF_DIBSource* CPDF_DIBSource::LoadMaskDIB(CPDF_Stream* pMask) { int CPDF_DIBSource::StartLoadMaskDIB() { m_pMask = new CPDF_DIBSource; - int ret = m_pMask->StartLoadDIBSource(m_pDocument, m_pMaskStream, FALSE, - nullptr, nullptr, TRUE); + int ret = m_pMask->StartLoadDIBSource(m_pDocument, m_pMaskStream, false, + nullptr, nullptr, true); if (ret == 2) { if (m_Status == 0) m_Status = 2; @@ -1152,7 +1152,7 @@ const uint8_t* CPDF_DIBSource::GetScanline(int line) const { return pSrcLine; } -FX_BOOL CPDF_DIBSource::SkipToScanline(int line, IFX_Pause* pPause) const { +bool CPDF_DIBSource::SkipToScanline(int line, IFX_Pause* pPause) const { return m_pDecoder && m_pDecoder->SkipToScanline(line, pPause); } @@ -1160,7 +1160,7 @@ void CPDF_DIBSource::DownSampleScanline(int line, uint8_t* dest_scan, int dest_bpp, int dest_width, - FX_BOOL bFlipX, + bool bFlipX, int clip_left, int clip_width) const { if (line < 0 || !dest_scan || dest_bpp <= 0 || dest_width <= 0 || @@ -1221,7 +1221,7 @@ void CPDF_DIBSource::DownSampleScanline1Bit(int orig_Bpp, const uint8_t* pSrcLine, uint8_t* dest_scan, int dest_width, - FX_BOOL bFlipX, + bool bFlipX, int clip_left, int clip_width) const { uint32_t set_argb = (uint32_t)-1; @@ -1300,7 +1300,7 @@ void CPDF_DIBSource::DownSampleScanline8Bit(int orig_Bpp, const uint8_t* pSrcLine, uint8_t* dest_scan, int dest_width, - FX_BOOL bFlipX, + bool bFlipX, int clip_left, int clip_width) const { if (m_bpc < 8) { @@ -1366,7 +1366,7 @@ void CPDF_DIBSource::DownSampleScanline32Bit(int orig_Bpp, const uint8_t* pSrcLine, uint8_t* dest_scan, int dest_width, - FX_BOOL bFlipX, + bool bFlipX, int clip_left, int clip_width) const { // last_src_x used to store the last seen src_x position which should be @@ -1411,7 +1411,7 @@ void CPDF_DIBSource::DownSampleScanline32Bit(int orig_Bpp, if (m_pColorSpace) { uint8_t color[4]; - const FX_BOOL bTransMask = TransMask(); + const bool bTransMask = TransMask(); if (m_bDefaultDecode) { m_pColorSpace->TranslateImageLine(color, pSrcPixel, 1, 0, 0, bTransMask); @@ -1462,7 +1462,7 @@ void CPDF_DIBSource::DownSampleScanline32Bit(int orig_Bpp, } } -FX_BOOL CPDF_DIBSource::TransMask() const { +bool CPDF_DIBSource::TransMask() const { return m_bLoadMask && m_GroupFamily == PDFCS_DEVICECMYK && m_Family == PDFCS_DEVICECMYK; } @@ -1475,21 +1475,21 @@ CPDF_ImageLoaderHandle::CPDF_ImageLoaderHandle() { CPDF_ImageLoaderHandle::~CPDF_ImageLoaderHandle() {} -FX_BOOL CPDF_ImageLoaderHandle::Start(CPDF_ImageLoader* pImageLoader, - const CPDF_ImageObject* pImage, - CPDF_PageRenderCache* pCache, - FX_BOOL bStdCS, - uint32_t GroupFamily, - FX_BOOL bLoadMask, - CPDF_RenderStatus* pRenderStatus, - int32_t nDownsampleWidth, - int32_t nDownsampleHeight) { +bool CPDF_ImageLoaderHandle::Start(CPDF_ImageLoader* pImageLoader, + const CPDF_ImageObject* pImage, + CPDF_PageRenderCache* pCache, + bool bStdCS, + uint32_t GroupFamily, + bool bLoadMask, + CPDF_RenderStatus* pRenderStatus, + int32_t nDownsampleWidth, + int32_t nDownsampleHeight) { m_pImageLoader = pImageLoader; m_pCache = pCache; m_pImage = const_cast<CPDF_ImageObject*>(pImage); m_nDownsampleWidth = nDownsampleWidth; m_nDownsampleHeight = nDownsampleHeight; - FX_BOOL ret; + bool ret; if (pCache) { ret = pCache->StartGetCachedBitmap( m_pImage->GetImage()->GetStream(), bStdCS, GroupFamily, bLoadMask, @@ -1504,9 +1504,9 @@ FX_BOOL CPDF_ImageLoaderHandle::Start(CPDF_ImageLoader* pImageLoader, return ret; } -FX_BOOL CPDF_ImageLoaderHandle::Continue(IFX_Pause* pPause) { - FX_BOOL ret = m_pCache ? m_pCache->Continue(pPause) - : m_pImage->GetImage()->Continue(pPause); +bool CPDF_ImageLoaderHandle::Continue(IFX_Pause* pPause) { + bool ret = m_pCache ? m_pCache->Continue(pPause) + : m_pImage->GetImage()->Continue(pPause); if (!ret) HandleFailure(); return ret; @@ -1515,26 +1515,26 @@ FX_BOOL CPDF_ImageLoaderHandle::Continue(IFX_Pause* pPause) { void CPDF_ImageLoaderHandle::HandleFailure() { if (m_pCache) { CPDF_ImageCacheEntry* entry = m_pCache->GetCurImageCacheEntry(); - m_pImageLoader->m_bCached = TRUE; + m_pImageLoader->m_bCached = true; m_pImageLoader->m_pBitmap = entry->DetachBitmap(); m_pImageLoader->m_pMask = entry->DetachMask(); m_pImageLoader->m_MatteColor = entry->m_MatteColor; } else { CPDF_Image* pImage = m_pImage->GetImage(); - m_pImageLoader->m_bCached = FALSE; + m_pImageLoader->m_bCached = false; m_pImageLoader->m_pBitmap = pImage->DetachBitmap(); m_pImageLoader->m_pMask = pImage->DetachMask(); m_pImageLoader->m_MatteColor = pImage->m_MatteColor; } } -FX_BOOL CPDF_ImageLoader::Start( +bool CPDF_ImageLoader::Start( const CPDF_ImageObject* pImage, CPDF_PageRenderCache* pCache, std::unique_ptr<CPDF_ImageLoaderHandle>* pLoadHandle, - FX_BOOL bStdCS, + bool bStdCS, uint32_t GroupFamily, - FX_BOOL bLoadMask, + bool bLoadMask, CPDF_RenderStatus* pRenderStatus, int32_t nDownsampleWidth, int32_t nDownsampleHeight) { @@ -1546,8 +1546,8 @@ FX_BOOL CPDF_ImageLoader::Start( pRenderStatus, m_nDownsampleWidth, m_nDownsampleHeight); } -FX_BOOL CPDF_ImageLoader::Continue(CPDF_ImageLoaderHandle* LoadHandle, - IFX_Pause* pPause) { +bool CPDF_ImageLoader::Continue(CPDF_ImageLoaderHandle* LoadHandle, + IFX_Pause* pPause) { return LoadHandle->Continue(pPause); } diff --git a/core/fpdfapi/render/fpdf_render_pattern.cpp b/core/fpdfapi/render/fpdf_render_pattern.cpp index 5238550bf5..695c4d91d9 100644 --- a/core/fpdfapi/render/fpdf_render_pattern.cpp +++ b/core/fpdfapi/render/fpdf_render_pattern.cpp @@ -61,8 +61,8 @@ void DrawAxialShading(CFX_DIBitmap* pBitmap, t_min = pArray->GetNumberAt(0); t_max = pArray->GetNumberAt(1); } - FX_BOOL bStartExtend = FALSE; - FX_BOOL bEndExtend = FALSE; + bool bStartExtend = false; + bool bEndExtend = false; pArray = pDict->GetArrayFor("Extend"); if (pArray) { bStartExtend = !!pArray->GetIntegerAt(0); @@ -148,8 +148,8 @@ void DrawRadialShading(CFX_DIBitmap* pBitmap, t_min = pArray->GetNumberAt(0); t_max = pArray->GetNumberAt(1); } - FX_BOOL bStartExtend = FALSE; - FX_BOOL bEndExtend = FALSE; + bool bStartExtend = false; + bool bEndExtend = false; pArray = pDict->GetArrayFor("Extend"); if (pArray) { bStartExtend = !!pArray->GetIntegerAt(0); @@ -183,12 +183,12 @@ void DrawRadialShading(CFX_DIBitmap* pBitmap, int width = pBitmap->GetWidth(); int height = pBitmap->GetHeight(); int pitch = pBitmap->GetPitch(); - FX_BOOL bDecreasing = FALSE; + bool bDecreasing = false; if (start_r > end_r) { int length = (int)FXSYS_sqrt((((start_x - end_x) * (start_x - end_x)) + ((start_y - end_y) * (start_y - end_y)))); if (length < start_r - end_r) { - bDecreasing = TRUE; + bDecreasing = true; } } for (int row = 0; row < height; row++) { @@ -315,17 +315,17 @@ bool GetScanlineIntersect(int y, FX_FLOAT y2, FX_FLOAT* x) { if (y1 == y2) - return FALSE; + return false; if (y1 < y2) { if (y < y1 || y > y2) - return FALSE; + return false; } else { if (y < y2 || y > y1) - return FALSE; + return false; } *x = x1 + ((x2 - x1) * (y - y1) / (y2 - y1)); - return TRUE; + return true; } void DrawGouraud(CFX_DIBitmap* pBitmap, @@ -650,8 +650,8 @@ struct CPDF_PatchDrawer { Coon_Bezier C2, Coon_Bezier D1, Coon_Bezier D2) { - FX_BOOL bSmall = C1.Distance() < 2 && C2.Distance() < 2 && - D1.Distance() < 2 && D2.Distance() < 2; + bool bSmall = C1.Distance() < 2 && C2.Distance() < 2 && D1.Distance() < 2 && + D2.Distance() < 2; Coon_Color div_colors[4]; int d_bottom = 0; int d_left = 0; @@ -850,7 +850,7 @@ void CPDF_RenderStatus::DrawShading(CPDF_ShadingPattern* pPattern, CFX_Matrix* pMatrix, FX_RECT& clip_rect, int alpha, - FX_BOOL bAlphaMode) { + bool bAlphaMode) { const auto& funcs = pPattern->GetFuncs(); CPDF_Dictionary* pDict = pPattern->GetShadingObject()->GetDict(); CPDF_ColorSpace* pColorSpace = pPattern->GetCS(); @@ -942,7 +942,7 @@ void CPDF_RenderStatus::DrawShading(CPDF_ShadingPattern* pPattern, void CPDF_RenderStatus::DrawShadingPattern(CPDF_ShadingPattern* pattern, const CPDF_PageObject* pPageObj, const CFX_Matrix* pObj2Device, - FX_BOOL bStroke) { + bool bStroke) { if (!pattern->Load()) return; @@ -958,7 +958,7 @@ void CPDF_RenderStatus::DrawShadingPattern(CPDF_ShadingPattern* pattern, return; } FX_RECT rect; - if (GetObjectClippedRect(pPageObj, pObj2Device, FALSE, rect)) { + if (GetObjectClippedRect(pPageObj, pObj2Device, false, rect)) { m_pDevice->RestoreState(false); return; } @@ -991,7 +991,7 @@ void CPDF_RenderStatus::ProcessShading(const CPDF_ShadingObject* pShadingObj, void CPDF_RenderStatus::DrawTilingPattern(CPDF_TilingPattern* pPattern, CPDF_PageObject* pPageObj, const CFX_Matrix* pObj2Device, - FX_BOOL bStroke) { + bool bStroke) { if (!pPattern->Load()) { return; } @@ -1019,12 +1019,12 @@ void CPDF_RenderStatus::DrawTilingPattern(CPDF_TilingPattern* pPattern, CFX_Matrix mtPattern2Device = *pPattern->pattern_to_form(); mtPattern2Device.Concat(*pObj2Device); GetScaledMatrix(mtPattern2Device); - FX_BOOL bAligned = FALSE; + bool bAligned = false; if (pPattern->bbox().left == 0 && pPattern->bbox().bottom == 0 && pPattern->bbox().right == pPattern->x_step() && pPattern->bbox().top == pPattern->y_step() && (mtPattern2Device.IsScaled() || mtPattern2Device.Is90Rotated())) { - bAligned = TRUE; + bAligned = true; } CFX_FloatRect cell_bbox = pPattern->bbox(); mtPattern2Device.TransformRect(cell_bbox); @@ -1180,14 +1180,14 @@ void CPDF_RenderStatus::DrawTilingPattern(CPDF_TilingPattern* pPattern, } } CompositeDIBitmap(&screen, clip_box.left, clip_box.top, 0, 255, - FXDIB_BLEND_NORMAL, FALSE); + FXDIB_BLEND_NORMAL, false); m_pDevice->RestoreState(false); } void CPDF_RenderStatus::DrawPathWithPattern(CPDF_PathObject* pPathObj, const CFX_Matrix* pObj2Device, const CPDF_Color* pColor, - FX_BOOL bStroke) { + bool bStroke) { CPDF_Pattern* pattern = pColor->GetPattern(); if (!pattern) return; @@ -1201,19 +1201,19 @@ void CPDF_RenderStatus::DrawPathWithPattern(CPDF_PathObject* pPathObj, void CPDF_RenderStatus::ProcessPathPattern(CPDF_PathObject* pPathObj, const CFX_Matrix* pObj2Device, int& filltype, - FX_BOOL& bStroke) { + bool& bStroke) { if (filltype) { const CPDF_Color& FillColor = *pPathObj->m_ColorState.GetFillColor(); if (FillColor.IsPattern()) { - DrawPathWithPattern(pPathObj, pObj2Device, &FillColor, FALSE); + DrawPathWithPattern(pPathObj, pObj2Device, &FillColor, false); filltype = 0; } } if (bStroke) { const CPDF_Color& StrokeColor = *pPathObj->m_ColorState.GetStrokeColor(); if (StrokeColor.IsPattern()) { - DrawPathWithPattern(pPathObj, pObj2Device, &StrokeColor, TRUE); - bStroke = FALSE; + DrawPathWithPattern(pPathObj, pObj2Device, &StrokeColor, true); + bStroke = false; } } } diff --git a/core/fpdfapi/render/fpdf_render_text.cpp b/core/fpdfapi/render/fpdf_render_text.cpp index 7d29f5c87f..86fac2d90f 100644 --- a/core/fpdfapi/render/fpdf_render_text.cpp +++ b/core/fpdfapi/render/fpdf_render_text.cpp @@ -31,15 +31,15 @@ #include "core/fxge/cfx_renderdevice.h" #include "third_party/base/numerics/safe_math.h" -FX_BOOL CPDF_RenderStatus::ProcessText(CPDF_TextObject* textobj, - const CFX_Matrix* pObj2Device, - CFX_PathData* pClippingPath) { +bool CPDF_RenderStatus::ProcessText(CPDF_TextObject* textobj, + const CFX_Matrix* pObj2Device, + CFX_PathData* pClippingPath) { if (textobj->m_nChars == 0) - return TRUE; + return true; const TextRenderingMode text_render_mode = textobj->m_TextState.GetTextMode(); if (text_render_mode == TextRenderingMode::MODE_INVISIBLE) - return TRUE; + return true; CPDF_Font* pFont = textobj->m_TextState.GetFont(); if (pFont->IsType3Font()) @@ -74,7 +74,7 @@ FX_BOOL CPDF_RenderStatus::ProcessText(CPDF_TextObject* textobj, // realize it. Fall through. ASSERT(false); case TextRenderingMode::MODE_CLIP: - return TRUE; + return true; } } FX_ARGB stroke_argb = 0; @@ -97,13 +97,13 @@ FX_BOOL CPDF_RenderStatus::ProcessText(CPDF_TextObject* textobj, CFX_Matrix text_matrix; textobj->GetTextMatrix(&text_matrix); if (!IsAvailableMatrix(text_matrix)) - return TRUE; + return true; FX_FLOAT font_size = textobj->m_TextState.GetFontSize(); if (bPattern) { DrawTextPathWithPattern(textobj, pObj2Device, pFont, font_size, &text_matrix, bFill, bStroke); - return TRUE; + return true; } if (bClip || bStroke) { const CFX_Matrix* pDeviceMatrix = pObj2Device; @@ -168,12 +168,12 @@ class CPDF_RefType3Cache { }; // TODO(npm): Font fallback for type 3 fonts? (Completely separate code!!) -FX_BOOL CPDF_RenderStatus::ProcessType3Text(CPDF_TextObject* textobj, - const CFX_Matrix* pObj2Device) { +bool CPDF_RenderStatus::ProcessType3Text(CPDF_TextObject* textobj, + const CFX_Matrix* pObj2Device) { CPDF_Type3Font* pType3Font = textobj->m_TextState.GetFont()->AsType3Font(); for (int i = 0; i < m_Type3FontCache.GetSize(); ++i) { if (m_Type3FontCache.GetAt(i) == pType3Font) - return TRUE; + return true; } CFX_Matrix dCTM = m_pDevice->GetCTM(); @@ -184,14 +184,14 @@ FX_BOOL CPDF_RenderStatus::ProcessType3Text(CPDF_TextObject* textobj, CFX_Matrix char_matrix = pType3Font->GetFontMatrix(); FX_FLOAT font_size = textobj->m_TextState.GetFontSize(); char_matrix.Scale(font_size, font_size); - FX_ARGB fill_argb = GetFillArgb(textobj, TRUE); + FX_ARGB fill_argb = GetFillArgb(textobj, true); int fill_alpha = FXARGB_A(fill_argb); int device_class = m_pDevice->GetDeviceClass(); std::vector<FXTEXT_GLYPHPOS> glyphs; if (device_class == FXDC_DISPLAY) glyphs.resize(textobj->m_nChars); else if (fill_alpha < 255) - return FALSE; + return false; CPDF_RefType3Cache refTypeCache(pType3Font); uint32_t* pChars = textobj->m_pCharCodes; @@ -225,7 +225,7 @@ FX_BOOL CPDF_RenderStatus::ProcessType3Text(CPDF_TextObject* textobj, } glyphs.clear(); } - CPDF_GraphicStates* pStates = CloneObjStates(textobj, FALSE); + CPDF_GraphicStates* pStates = CloneObjStates(textobj, false); CPDF_RenderOptions Options = m_Options; Options.m_Flags |= RENDER_FORCE_HALFTONE | RENDER_RECT_AA; Options.m_Flags &= ~RENDER_FORCE_DOWNSAMPLE; @@ -239,7 +239,7 @@ FX_BOOL CPDF_RenderStatus::ProcessType3Text(CPDF_TextObject* textobj, status.Initialize(m_pContext, m_pDevice, nullptr, nullptr, this, pStates, &Options, pType3Char->m_pForm->m_Transparency, m_bDropObjects, - pFormResource, FALSE, pType3Char, fill_argb); + pFormResource, false, pType3Char, fill_argb); status.m_Type3FontCache.Append(m_Type3FontCache); status.m_Type3FontCache.Add(pType3Font); m_pDevice->SaveState(); @@ -253,14 +253,14 @@ FX_BOOL CPDF_RenderStatus::ProcessType3Text(CPDF_TextObject* textobj, if (!bitmap_device.Create((int)(rect.Width() * sa), (int)(rect.Height() * sd), FXDIB_Argb, nullptr)) { - return TRUE; + return true; } bitmap_device.GetBitmap()->Clear(0); CPDF_RenderStatus status; status.Initialize(m_pContext, &bitmap_device, nullptr, nullptr, this, pStates, &Options, pType3Char->m_pForm->m_Transparency, m_bDropObjects, - pFormResource, FALSE, pType3Char, fill_argb); + pFormResource, false, pType3Char, fill_argb); status.m_Type3FontCache.Append(m_Type3FontCache); status.m_Type3FontCache.Add(pType3Font); matrix.TranslateI(-rect.left, -rect.top); @@ -292,23 +292,23 @@ FX_BOOL CPDF_RenderStatus::ProcessType3Text(CPDF_TextObject* textobj, image_matrix.Concat(matrix); CPDF_ImageRenderer renderer; if (renderer.Start(this, pType3Char->m_pBitmap.get(), fill_argb, 255, - &image_matrix, 0, FALSE)) { + &image_matrix, 0, false)) { renderer.Continue(nullptr); } if (!renderer.m_Result) - return FALSE; + return false; } } } if (glyphs.empty()) - return TRUE; + return true; FX_RECT rect = FXGE_GetGlyphsBBox(glyphs, 0, sa, sd); CFX_DIBitmap bitmap; if (!bitmap.Create(static_cast<int>(rect.Width() * sa), static_cast<int>(rect.Height() * sd), FXDIB_8bppMask)) { - return TRUE; + return true; } bitmap.Clear(0); for (const FXTEXT_GLYPHPOS& glyph : glyphs) { @@ -333,10 +333,10 @@ FX_BOOL CPDF_RenderStatus::ProcessType3Text(CPDF_TextObject* textobj, glyph.m_pGlyph->m_Bitmap.GetWidth(), glyph.m_pGlyph->m_Bitmap.GetHeight(), &glyph.m_pGlyph->m_Bitmap, fill_argb, 0, 0, - FXDIB_BLEND_NORMAL, nullptr, FALSE, 0, nullptr); + FXDIB_BLEND_NORMAL, nullptr, false, 0, nullptr); } m_pDevice->SetBitMask(&bitmap, rect.left, rect.top, fill_argb); - return TRUE; + return true; } class CPDF_CharPosList { @@ -368,7 +368,7 @@ void CPDF_CharPosList::Load(int nChars, m_pCharPos = FX_Alloc(FXTEXT_CHARPOS, nChars); m_nChars = 0; CPDF_CIDFont* pCIDFont = pFont->AsCIDFont(); - FX_BOOL bVertWriting = pCIDFont && pCIDFont->IsVertWriting(); + bool bVertWriting = pCIDFont && pCIDFont->IsVertWriting(); for (int iChar = 0; iChar < nChars; iChar++) { uint32_t CharCode = nChars == 1 ? (uint32_t)(uintptr_t)pCharCodes : pCharCodes[iChar]; @@ -400,7 +400,7 @@ void CPDF_CharPosList::Load(int nChars, } charpos.m_OriginX = iChar ? pCharPos[iChar - 1] : 0; charpos.m_OriginY = 0; - charpos.m_bGlyphAdjust = FALSE; + charpos.m_bGlyphAdjust = false; if (!pCIDFont) { continue; } @@ -423,29 +423,29 @@ void CPDF_CharPosList::Load(int nChars, pCIDFont->CIDTransformToFloat(pTransform[4]) * FontSize; charpos.m_OriginY += pCIDFont->CIDTransformToFloat(pTransform[5]) * FontSize; - charpos.m_bGlyphAdjust = TRUE; + charpos.m_bGlyphAdjust = true; } } } // static -FX_BOOL CPDF_TextRenderer::DrawTextPath(CFX_RenderDevice* pDevice, - int nChars, - uint32_t* pCharCodes, - FX_FLOAT* pCharPos, - CPDF_Font* pFont, - FX_FLOAT font_size, - const CFX_Matrix* pText2User, - const CFX_Matrix* pUser2Device, - const CFX_GraphStateData* pGraphState, - FX_ARGB fill_argb, - FX_ARGB stroke_argb, - CFX_PathData* pClippingPath, - int nFlag) { +bool CPDF_TextRenderer::DrawTextPath(CFX_RenderDevice* pDevice, + int nChars, + uint32_t* pCharCodes, + FX_FLOAT* pCharPos, + CPDF_Font* pFont, + FX_FLOAT font_size, + const CFX_Matrix* pText2User, + const CFX_Matrix* pUser2Device, + const CFX_GraphStateData* pGraphState, + FX_ARGB fill_argb, + FX_ARGB stroke_argb, + CFX_PathData* pClippingPath, + int nFlag) { CPDF_CharPosList CharPosList; CharPosList.Load(nChars, pCharCodes, pCharPos, pFont, font_size); if (CharPosList.m_nChars == 0) - return TRUE; + return true; bool bDraw = true; int32_t fontPosition = CharPosList.m_pCharPos[0].m_FallbackFontPosition; uint32_t startIndex = 0; @@ -535,19 +535,19 @@ void CPDF_TextRenderer::DrawTextString(CFX_RenderDevice* pDevice, } // static -FX_BOOL CPDF_TextRenderer::DrawNormalText(CFX_RenderDevice* pDevice, - int nChars, - uint32_t* pCharCodes, - FX_FLOAT* pCharPos, - CPDF_Font* pFont, - FX_FLOAT font_size, - const CFX_Matrix* pText2Device, - FX_ARGB fill_argb, - const CPDF_RenderOptions* pOptions) { +bool CPDF_TextRenderer::DrawNormalText(CFX_RenderDevice* pDevice, + int nChars, + uint32_t* pCharCodes, + FX_FLOAT* pCharPos, + CPDF_Font* pFont, + FX_FLOAT font_size, + const CFX_Matrix* pText2Device, + FX_ARGB fill_argb, + const CPDF_RenderOptions* pOptions) { CPDF_CharPosList CharPosList; CharPosList.Load(nChars, pCharCodes, pCharPos, pFont, font_size); if (CharPosList.m_nChars == 0) - return TRUE; + return true; int FXGE_flags = 0; if (pOptions) { uint32_t dwFlags = pOptions->m_Flags; @@ -609,13 +609,13 @@ void CPDF_RenderStatus::DrawTextPathWithPattern(const CPDF_TextObject* textobj, CPDF_Font* pFont, FX_FLOAT font_size, const CFX_Matrix* pTextMatrix, - FX_BOOL bFill, - FX_BOOL bStroke) { + bool bFill, + bool bStroke) { if (!bStroke) { CPDF_PathObject path; std::vector<std::unique_ptr<CPDF_TextObject>> pCopy; pCopy.push_back(std::unique_ptr<CPDF_TextObject>(textobj->Clone())); - path.m_bStroke = FALSE; + path.m_bStroke = false; path.m_FillType = FXFILL_WINDING; path.m_ClipPath.AppendTexts(&pCopy); path.m_ColorState = textobj->m_ColorState; diff --git a/core/fpdfapi/render/render_int.h b/core/fpdfapi/render/render_int.h index 9c5a7e919b..e6090e8ebe 100644 --- a/core/fpdfapi/render/render_int.h +++ b/core/fpdfapi/render/render_int.h @@ -49,18 +49,17 @@ class CPDF_Type3Glyphs; class CPDF_Type3Char; class CPDF_Type3Font; -FX_BOOL IsAvailableMatrix(const CFX_Matrix& matrix); +bool IsAvailableMatrix(const CFX_Matrix& matrix); class CPDF_TransferFunc { public: explicit CPDF_TransferFunc(CPDF_Document* pDoc); FX_COLORREF TranslateColor(FX_COLORREF src) const; - CFX_DIBSource* TranslateImage(const CFX_DIBSource* pSrc, - FX_BOOL bAutoDropSrc); + CFX_DIBSource* TranslateImage(const CFX_DIBSource* pSrc, bool bAutoDropSrc); CPDF_Document* const m_pPDFDoc; - FX_BOOL m_bIdentity; + bool m_bIdentity; uint8_t m_Samples[256 * 3]; }; @@ -70,7 +69,7 @@ class CPDF_DocRenderData { ~CPDF_DocRenderData(); CPDF_Type3Cache* GetCachedType3(CPDF_Type3Font* pFont); CPDF_TransferFunc* GetTransferFunc(CPDF_Object* pObj); - void Clear(FX_BOOL bRelease = FALSE); + void Clear(bool bRelease = false); void ReleaseCachedType3(CPDF_Type3Font* pFont); void ReleaseTransferFunc(CPDF_Object* pObj); @@ -90,27 +89,27 @@ class CPDF_RenderStatus { CPDF_RenderStatus(); ~CPDF_RenderStatus(); - FX_BOOL Initialize(class CPDF_RenderContext* pContext, - CFX_RenderDevice* pDevice, - const CFX_Matrix* pDeviceMatrix, - const CPDF_PageObject* pStopObj, - const CPDF_RenderStatus* pParentStatus, - const CPDF_GraphicStates* pInitialStates, - const CPDF_RenderOptions* pOptions, - int transparency, - FX_BOOL bDropObjects, - CPDF_Dictionary* pFormResource = nullptr, - FX_BOOL bStdCS = FALSE, - CPDF_Type3Char* pType3Char = nullptr, - FX_ARGB fill_color = 0, - uint32_t GroupFamily = 0, - FX_BOOL bLoadMask = FALSE); + bool Initialize(class CPDF_RenderContext* pContext, + CFX_RenderDevice* pDevice, + const CFX_Matrix* pDeviceMatrix, + const CPDF_PageObject* pStopObj, + const CPDF_RenderStatus* pParentStatus, + const CPDF_GraphicStates* pInitialStates, + const CPDF_RenderOptions* pOptions, + int transparency, + bool bDropObjects, + CPDF_Dictionary* pFormResource = nullptr, + bool bStdCS = false, + CPDF_Type3Char* pType3Char = nullptr, + FX_ARGB fill_color = 0, + uint32_t GroupFamily = 0, + bool bLoadMask = false); void RenderObjectList(const CPDF_PageObjectHolder* pObjectHolder, const CFX_Matrix* pObj2Device); void RenderSingleObject(CPDF_PageObject* pObj, const CFX_Matrix* pObj2Device); - FX_BOOL ContinueSingleObject(CPDF_PageObject* pObj, - const CFX_Matrix* pObj2Device, - IFX_Pause* pPause); + bool ContinueSingleObject(CPDF_PageObject* pObj, + const CFX_Matrix* pObj2Device, + IFX_Pause* pPause); CPDF_RenderContext* GetContext() { return m_pContext; } #if defined _SKIA_SUPPORT_ @@ -128,46 +127,44 @@ class CPDF_RenderStatus { void ProcessClipPath(CPDF_ClipPath ClipPath, const CFX_Matrix* pObj2Device); void DrawClipPath(CPDF_ClipPath ClipPath, const CFX_Matrix* pObj2Device); - FX_BOOL ProcessTransparency(CPDF_PageObject* PageObj, - const CFX_Matrix* pObj2Device); + bool ProcessTransparency(CPDF_PageObject* PageObj, + const CFX_Matrix* pObj2Device); void ProcessObjectNoClip(CPDF_PageObject* PageObj, const CFX_Matrix* pObj2Device); void DrawObjWithBackground(CPDF_PageObject* pObj, const CFX_Matrix* pObj2Device); - FX_BOOL DrawObjWithBlend(CPDF_PageObject* pObj, - const CFX_Matrix* pObj2Device); - FX_BOOL ProcessPath(CPDF_PathObject* pPathObj, const CFX_Matrix* pObj2Device); + bool DrawObjWithBlend(CPDF_PageObject* pObj, const CFX_Matrix* pObj2Device); + bool ProcessPath(CPDF_PathObject* pPathObj, const CFX_Matrix* pObj2Device); void ProcessPathPattern(CPDF_PathObject* pPathObj, const CFX_Matrix* pObj2Device, int& filltype, - FX_BOOL& bStroke); + bool& bStroke); void DrawPathWithPattern(CPDF_PathObject* pPathObj, const CFX_Matrix* pObj2Device, const CPDF_Color* pColor, - FX_BOOL bStroke); + bool bStroke); void DrawTilingPattern(CPDF_TilingPattern* pPattern, CPDF_PageObject* pPageObj, const CFX_Matrix* pObj2Device, - FX_BOOL bStroke); + bool bStroke); void DrawShadingPattern(CPDF_ShadingPattern* pPattern, const CPDF_PageObject* pPageObj, const CFX_Matrix* pObj2Device, - FX_BOOL bStroke); - FX_BOOL SelectClipPath(const CPDF_PathObject* pPathObj, - const CFX_Matrix* pObj2Device, - FX_BOOL bStroke); - FX_BOOL ProcessImage(CPDF_ImageObject* pImageObj, - const CFX_Matrix* pObj2Device); - FX_BOOL OutputBitmapAlpha(CPDF_ImageObject* pImageObj, - const CFX_Matrix* pImage2Device); - FX_BOOL OutputImage(CPDF_ImageObject* pImageObj, - const CFX_Matrix* pImage2Device); - FX_BOOL OutputDIBSource(const CFX_DIBSource* pOutputBitmap, - FX_ARGB fill_argb, - int bitmap_alpha, - const CFX_Matrix* pImage2Device, - CPDF_ImageCacheEntry* pImageCache, - uint32_t flags); + bool bStroke); + bool SelectClipPath(const CPDF_PathObject* pPathObj, + const CFX_Matrix* pObj2Device, + bool bStroke); + bool ProcessImage(CPDF_ImageObject* pImageObj, const CFX_Matrix* pObj2Device); + bool OutputBitmapAlpha(CPDF_ImageObject* pImageObj, + const CFX_Matrix* pImage2Device); + bool OutputImage(CPDF_ImageObject* pImageObj, + const CFX_Matrix* pImage2Device); + bool OutputDIBSource(const CFX_DIBSource* pOutputBitmap, + FX_ARGB fill_argb, + int bitmap_alpha, + const CFX_Matrix* pImage2Device, + CPDF_ImageCacheEntry* pImageCache, + uint32_t flags); void CompositeDIBitmap(CFX_DIBitmap* pDIBitmap, int left, int top, @@ -181,47 +178,47 @@ class CPDF_RenderStatus { CFX_Matrix* pMatrix, FX_RECT& clip_rect, int alpha, - FX_BOOL bAlphaMode); - FX_BOOL ProcessType3Text(CPDF_TextObject* textobj, - const CFX_Matrix* pObj2Device); - FX_BOOL ProcessText(CPDF_TextObject* textobj, - const CFX_Matrix* pObj2Device, - CFX_PathData* pClippingPath); + bool bAlphaMode); + bool ProcessType3Text(CPDF_TextObject* textobj, + const CFX_Matrix* pObj2Device); + bool ProcessText(CPDF_TextObject* textobj, + const CFX_Matrix* pObj2Device, + CFX_PathData* pClippingPath); void DrawTextPathWithPattern(const CPDF_TextObject* textobj, const CFX_Matrix* pObj2Device, CPDF_Font* pFont, FX_FLOAT font_size, const CFX_Matrix* pTextMatrix, - FX_BOOL bFill, - FX_BOOL bStroke); - FX_BOOL ProcessForm(const CPDF_FormObject* pFormObj, - const CFX_Matrix* pObj2Device); + bool bFill, + bool bStroke); + bool ProcessForm(const CPDF_FormObject* pFormObj, + const CFX_Matrix* pObj2Device); CFX_DIBitmap* GetBackdrop(const CPDF_PageObject* pObj, const FX_RECT& rect, int& left, int& top, - FX_BOOL bBackAlphaRequired); + bool bBackAlphaRequired); CFX_DIBitmap* LoadSMask(CPDF_Dictionary* pSMaskDict, FX_RECT* pClipRect, const CFX_Matrix* pMatrix); void Init(CPDF_RenderContext* pParent); static class CPDF_Type3Cache* GetCachedType3(CPDF_Type3Font* pFont); static CPDF_GraphicStates* CloneObjStates(const CPDF_GraphicStates* pPathObj, - FX_BOOL bStroke); + bool bStroke); CPDF_TransferFunc* GetTransferFunc(CPDF_Object* pObject) const; - FX_ARGB GetFillArgb(CPDF_PageObject* pObj, FX_BOOL bType3 = FALSE) const; + FX_ARGB GetFillArgb(CPDF_PageObject* pObj, bool bType3 = false) const; FX_ARGB GetStrokeArgb(CPDF_PageObject* pObj) const; - FX_BOOL GetObjectClippedRect(const CPDF_PageObject* pObj, - const CFX_Matrix* pObj2Device, - FX_BOOL bLogical, - FX_RECT& rect) const; + bool GetObjectClippedRect(const CPDF_PageObject* pObj, + const CFX_Matrix* pObj2Device, + bool bLogical, + FX_RECT& rect) const; void GetScaledMatrix(CFX_Matrix& matrix) const; static const int kRenderMaxRecursionDepth = 64; static int s_CurrentRecursionDepth; CPDF_RenderContext* m_pContext; - FX_BOOL m_bStopped; + bool m_bStopped; CFX_RenderDevice* m_pDevice; CFX_Matrix m_DeviceMatrix; CPDF_ClipPath m_LastClipPath; @@ -230,12 +227,12 @@ class CPDF_RenderStatus { CPDF_GraphicStates m_InitialStates; int m_HalftoneLimit; std::unique_ptr<CPDF_ImageRenderer> m_pImageRenderer; - FX_BOOL m_bPrint; + bool m_bPrint; int m_Transparency; - FX_BOOL m_bDropObjects; - FX_BOOL m_bStdCS; + bool m_bDropObjects; + bool m_bStdCS; uint32_t m_GroupFamily; - FX_BOOL m_bLoadMask; + bool m_bLoadMask; CPDF_Type3Char* m_pType3Char; FX_ARGB m_T3FillColor; int m_curBlend; @@ -247,26 +244,26 @@ class CPDF_ImageLoader { : m_pBitmap(nullptr), m_pMask(nullptr), m_MatteColor(0), - m_bCached(FALSE), + m_bCached(false), m_nDownsampleWidth(0), m_nDownsampleHeight(0) {} ~CPDF_ImageLoader(); - FX_BOOL Start(const CPDF_ImageObject* pImage, - CPDF_PageRenderCache* pCache, - std::unique_ptr<CPDF_ImageLoaderHandle>* pLoadHandle, - FX_BOOL bStdCS = FALSE, - uint32_t GroupFamily = 0, - FX_BOOL bLoadMask = FALSE, - CPDF_RenderStatus* pRenderStatus = nullptr, - int32_t nDownsampleWidth = 0, - int32_t nDownsampleHeight = 0); - FX_BOOL Continue(CPDF_ImageLoaderHandle* LoadHandle, IFX_Pause* pPause); + bool Start(const CPDF_ImageObject* pImage, + CPDF_PageRenderCache* pCache, + std::unique_ptr<CPDF_ImageLoaderHandle>* pLoadHandle, + bool bStdCS = false, + uint32_t GroupFamily = 0, + bool bLoadMask = false, + CPDF_RenderStatus* pRenderStatus = nullptr, + int32_t nDownsampleWidth = 0, + int32_t nDownsampleHeight = 0); + bool Continue(CPDF_ImageLoaderHandle* LoadHandle, IFX_Pause* pPause); CFX_DIBSource* m_pBitmap; CFX_DIBSource* m_pMask; uint32_t m_MatteColor; - FX_BOOL m_bCached; + bool m_bCached; protected: int32_t m_nDownsampleWidth; @@ -278,16 +275,16 @@ class CPDF_ImageLoaderHandle { CPDF_ImageLoaderHandle(); ~CPDF_ImageLoaderHandle(); - FX_BOOL Start(CPDF_ImageLoader* pImageLoader, - const CPDF_ImageObject* pImage, - CPDF_PageRenderCache* pCache, - FX_BOOL bStdCS = FALSE, - uint32_t GroupFamily = 0, - FX_BOOL bLoadMask = FALSE, - CPDF_RenderStatus* pRenderStatus = nullptr, - int32_t nDownsampleWidth = 0, - int32_t nDownsampleHeight = 0); - FX_BOOL Continue(IFX_Pause* pPause); + bool Start(CPDF_ImageLoader* pImageLoader, + const CPDF_ImageObject* pImage, + CPDF_PageRenderCache* pCache, + bool bStdCS = false, + uint32_t GroupFamily = 0, + bool bLoadMask = false, + CPDF_RenderStatus* pRenderStatus = nullptr, + int32_t nDownsampleWidth = 0, + int32_t nDownsampleHeight = 0); + bool Continue(IFX_Pause* pPause); protected: void HandleFailure(); @@ -304,31 +301,31 @@ class CPDF_ImageRenderer { CPDF_ImageRenderer(); ~CPDF_ImageRenderer(); - FX_BOOL Start(CPDF_RenderStatus* pStatus, - CPDF_PageObject* pObj, - const CFX_Matrix* pObj2Device, - FX_BOOL bStdCS, - int blendType = FXDIB_BLEND_NORMAL); - FX_BOOL Continue(IFX_Pause* pPause); + bool Start(CPDF_RenderStatus* pStatus, + CPDF_PageObject* pObj, + const CFX_Matrix* pObj2Device, + bool bStdCS, + int blendType = FXDIB_BLEND_NORMAL); + bool Continue(IFX_Pause* pPause); - FX_BOOL Start(CPDF_RenderStatus* pStatus, - const CFX_DIBSource* pDIBSource, - FX_ARGB bitmap_argb, - int bitmap_alpha, - const CFX_Matrix* pImage2Device, - uint32_t flags, - FX_BOOL bStdCS, - int blendType = FXDIB_BLEND_NORMAL); + bool Start(CPDF_RenderStatus* pStatus, + const CFX_DIBSource* pDIBSource, + FX_ARGB bitmap_argb, + int bitmap_alpha, + const CFX_Matrix* pImage2Device, + uint32_t flags, + bool bStdCS, + int blendType = FXDIB_BLEND_NORMAL); - FX_BOOL m_Result; + bool m_Result; protected: - FX_BOOL StartBitmapAlpha(); - FX_BOOL StartDIBSource(); - FX_BOOL StartRenderDIBSource(); - FX_BOOL StartLoadDIBSource(); - FX_BOOL DrawMaskedImage(); - FX_BOOL DrawPatternImage(const CFX_Matrix* pObj2Device); + bool StartBitmapAlpha(); + bool StartDIBSource(); + bool StartRenderDIBSource(); + bool StartLoadDIBSource(); + bool DrawMaskedImage(); + bool DrawPatternImage(const CFX_Matrix* pObj2Device); CPDF_RenderStatus* m_pRenderStatus; CPDF_ImageObject* m_pImageObject; @@ -339,14 +336,14 @@ class CPDF_ImageRenderer { const CFX_DIBSource* m_pDIBSource; std::unique_ptr<CFX_DIBitmap> m_pClone; int m_BitmapAlpha; - FX_BOOL m_bPatternColor; + bool m_bPatternColor; CPDF_Pattern* m_pPattern; FX_ARGB m_FillArgb; uint32_t m_Flags; std::unique_ptr<CFX_ImageTransformer> m_pTransformer; void* m_DeviceHandle; std::unique_ptr<CPDF_ImageLoaderHandle> m_LoadHandle; - FX_BOOL m_bStdCS; + bool m_bStdCS; int m_BlendType; }; @@ -355,12 +352,12 @@ class CPDF_ScaledRenderBuffer { CPDF_ScaledRenderBuffer(); ~CPDF_ScaledRenderBuffer(); - FX_BOOL Initialize(CPDF_RenderContext* pContext, - CFX_RenderDevice* pDevice, - const FX_RECT& pRect, - const CPDF_PageObject* pObj, - const CPDF_RenderOptions* pOptions = nullptr, - int max_dpi = 0); + bool Initialize(CPDF_RenderContext* pContext, + CFX_RenderDevice* pDevice, + const FX_RECT& pRect, + const CPDF_PageObject* pObj, + const CPDF_RenderOptions* pOptions = nullptr, + int max_dpi = 0); CFX_RenderDevice* GetDevice() { return m_pBitmapDevice ? m_pBitmapDevice.get() : m_pDevice; } @@ -380,11 +377,11 @@ class CPDF_DeviceBuffer { public: CPDF_DeviceBuffer(); ~CPDF_DeviceBuffer(); - FX_BOOL Initialize(CPDF_RenderContext* pContext, - CFX_RenderDevice* pDevice, - FX_RECT* pRect, - const CPDF_PageObject* pObj, - int max_dpi = 0); + bool Initialize(CPDF_RenderContext* pContext, + CFX_RenderDevice* pDevice, + FX_RECT* pRect, + const CPDF_PageObject* pObj, + int max_dpi = 0); void OutputToDevice(); CFX_DIBitmap* GetBitmap() const { return m_pBitmap.get(); } const CFX_Matrix* GetMatrix() const { return &m_Matrix; } @@ -404,16 +401,16 @@ class CPDF_ImageCacheEntry { ~CPDF_ImageCacheEntry(); void Reset(const CFX_DIBitmap* pBitmap); - FX_BOOL GetCachedBitmap(CFX_DIBSource*& pBitmap, - CFX_DIBSource*& pMask, - uint32_t& MatteColor, - CPDF_Dictionary* pPageResources, - FX_BOOL bStdCS = FALSE, - uint32_t GroupFamily = 0, - FX_BOOL bLoadMask = FALSE, - CPDF_RenderStatus* pRenderStatus = nullptr, - int32_t downsampleWidth = 0, - int32_t downsampleHeight = 0); + bool GetCachedBitmap(CFX_DIBSource*& pBitmap, + CFX_DIBSource*& pMask, + uint32_t& MatteColor, + CPDF_Dictionary* pPageResources, + bool bStdCS = false, + uint32_t GroupFamily = 0, + bool bLoadMask = false, + CPDF_RenderStatus* pRenderStatus = nullptr, + int32_t downsampleWidth = 0, + int32_t downsampleHeight = 0); uint32_t EstimateSize() const { return m_dwCacheSize; } uint32_t GetTimeCount() const { return m_dwTimeCount; } CPDF_Stream* GetStream() const { return m_pStream; } @@ -423,9 +420,9 @@ class CPDF_ImageCacheEntry { public: int StartGetCachedBitmap(CPDF_Dictionary* pFormResources, CPDF_Dictionary* pPageResources, - FX_BOOL bStdCS = FALSE, + bool bStdCS = false, uint32_t GroupFamily = 0, - FX_BOOL bLoadMask = FALSE, + bool bLoadMask = false, CPDF_RenderStatus* pRenderStatus = nullptr, int32_t downsampleWidth = 0, int32_t downsampleHeight = 0); @@ -459,25 +456,25 @@ class CPDF_DIBSource : public CFX_DIBSource { CPDF_DIBSource(); ~CPDF_DIBSource() override; - FX_BOOL Load(CPDF_Document* pDoc, - const CPDF_Stream* pStream, - CPDF_DIBSource** ppMask, - uint32_t* pMatteColor, - CPDF_Dictionary* pFormResources, - CPDF_Dictionary* pPageResources, - FX_BOOL bStdCS = FALSE, - uint32_t GroupFamily = 0, - FX_BOOL bLoadMask = FALSE); + bool Load(CPDF_Document* pDoc, + const CPDF_Stream* pStream, + CPDF_DIBSource** ppMask, + uint32_t* pMatteColor, + CPDF_Dictionary* pFormResources, + CPDF_Dictionary* pPageResources, + bool bStdCS = false, + uint32_t GroupFamily = 0, + bool bLoadMask = false); // CFX_DIBSource - FX_BOOL SkipToScanline(int line, IFX_Pause* pPause) const override; + bool SkipToScanline(int line, IFX_Pause* pPause) const override; uint8_t* GetBuffer() const override; const uint8_t* GetScanline(int line) const override; void DownSampleScanline(int line, uint8_t* dest_scan, int dest_bpp, int dest_width, - FX_BOOL bFlipX, + bool bFlipX, int clip_left, int clip_width) const override; @@ -487,12 +484,12 @@ class CPDF_DIBSource : public CFX_DIBSource { int StartLoadDIBSource(CPDF_Document* pDoc, const CPDF_Stream* pStream, - FX_BOOL bHasMask, + bool bHasMask, CPDF_Dictionary* pFormResources, CPDF_Dictionary* pPageResources, - FX_BOOL bStdCS = FALSE, + bool bStdCS = false, uint32_t GroupFamily = 0, - FX_BOOL bLoadMask = FALSE); + bool bLoadMask = false); int ContinueLoadDIBSource(IFX_Pause* pPause); int StratLoadMask(); int StartLoadMaskDIB(); @@ -503,8 +500,7 @@ class CPDF_DIBSource : public CFX_DIBSource { private: bool LoadColorInfo(const CPDF_Dictionary* pFormResources, const CPDF_Dictionary* pPageResources); - DIB_COMP_DATA* GetDecodeAndMaskArray(FX_BOOL& bDefaultDecode, - FX_BOOL& bColorKey); + DIB_COMP_DATA* GetDecodeAndMaskArray(bool& bDefaultDecode, bool& bColorKey); CPDF_DIBSource* LoadMask(uint32_t& MatteColor); CPDF_DIBSource* LoadMaskDIB(CPDF_Stream* pMask); void LoadJpxBitmap(); @@ -519,7 +515,7 @@ class CPDF_DIBSource : public CFX_DIBSource { const uint8_t* pSrcLine, uint8_t* dest_scan, int dest_width, - FX_BOOL bFlipX, + bool bFlipX, int clip_left, int clip_width) const; void DownSampleScanline8Bit(int orig_Bpp, @@ -528,7 +524,7 @@ class CPDF_DIBSource : public CFX_DIBSource { const uint8_t* pSrcLine, uint8_t* dest_scan, int dest_width, - FX_BOOL bFlipX, + bool bFlipX, int clip_left, int clip_width) const; void DownSampleScanline32Bit(int orig_Bpp, @@ -537,10 +533,10 @@ class CPDF_DIBSource : public CFX_DIBSource { const uint8_t* pSrcLine, uint8_t* dest_scan, int dest_width, - FX_BOOL bFlipX, + bool bFlipX, int clip_left, int clip_width) const; - FX_BOOL TransMask() const; + bool TransMask() const; CPDF_Document* m_pDocument; const CPDF_Stream* m_pStream; @@ -553,13 +549,13 @@ class CPDF_DIBSource : public CFX_DIBSource { uint32_t m_nComponents; uint32_t m_GroupFamily; uint32_t m_MatteColor; - FX_BOOL m_bLoadMask; - FX_BOOL m_bDefaultDecode; - FX_BOOL m_bImageMask; - FX_BOOL m_bDoBpcCheck; - FX_BOOL m_bColorKey; - FX_BOOL m_bHasMask; - FX_BOOL m_bStdCS; + bool m_bLoadMask; + bool m_bDefaultDecode; + bool m_bImageMask; + bool m_bDoBpcCheck; + bool m_bColorKey; + bool m_bHasMask; + bool m_bStdCS; DIB_COMP_DATA* m_pCompData; uint8_t* m_pLineBuf; uint8_t* m_pMaskedLine; |