diff options
Diffstat (limited to 'core/src/fpdfapi')
33 files changed, 505 insertions, 496 deletions
diff --git a/core/src/fpdfapi/fpdf_basic_module.cpp b/core/src/fpdfapi/fpdf_basic_module.cpp index d564bdb687..e3ec425ff6 100644 --- a/core/src/fpdfapi/fpdf_basic_module.cpp +++ b/core/src/fpdfapi/fpdf_basic_module.cpp @@ -50,18 +50,18 @@ CPDF_ModuleMgr::~CPDF_ModuleMgr() delete m_pRenderModule; } } -void CPDF_ModuleMgr::SetDownloadCallback(FX_BOOL (*callback)(FX_LPCSTR module_name)) +void CPDF_ModuleMgr::SetDownloadCallback(FX_BOOL (*callback)(const FX_CHAR* module_name)) { m_pDownloadCallback = callback; } -FX_BOOL CPDF_ModuleMgr::DownloadModule(FX_LPCSTR module_name) +FX_BOOL CPDF_ModuleMgr::DownloadModule(const FX_CHAR* module_name) { if (m_pDownloadCallback == NULL) { return FALSE; } return m_pDownloadCallback(module_name); } -void CPDF_ModuleMgr::NotifyModuleAvailable(FX_LPCSTR module_name) +void CPDF_ModuleMgr::NotifyModuleAvailable(const FX_CHAR* module_name) { if (FXSYS_strcmp(module_name, ADDIN_NAME_CJK) == 0) { m_pPageModule->NotifyCJKAvailable(); @@ -69,7 +69,7 @@ void CPDF_ModuleMgr::NotifyModuleAvailable(FX_LPCSTR module_name) m_pRenderModule->NotifyDecoderAvailable(); } } -void CPDF_ModuleMgr::RegisterSecurityHandler(FX_LPCSTR filter, CPDF_SecurityHandler * (*CreateHandler)(void* param), void* param) +void CPDF_ModuleMgr::RegisterSecurityHandler(const FX_CHAR* filter, CPDF_SecurityHandler * (*CreateHandler)(void* param), void* param) { if (CreateHandler == NULL) { m_SecurityHandlerMap.RemoveKey(filter); @@ -80,15 +80,15 @@ void CPDF_ModuleMgr::RegisterSecurityHandler(FX_LPCSTR filter, CPDF_SecurityHand m_SecurityHandlerMap.SetAt(FX_BSTRC("_param_") + filter, param); } } -void CPDF_ModuleMgr::SetPrivateData(FX_LPVOID module_id, FX_LPVOID pData, PD_CALLBACK_FREEDATA callback) +void CPDF_ModuleMgr::SetPrivateData(void* module_id, void* pData, PD_CALLBACK_FREEDATA callback) { m_privateData.SetPrivateData(module_id, pData, callback); } -FX_LPVOID CPDF_ModuleMgr::GetPrivateData(FX_LPVOID module_id) +void* CPDF_ModuleMgr::GetPrivateData(void* module_id) { return m_privateData.GetPrivateData(module_id); } -CPDF_SecurityHandler* CPDF_ModuleMgr::CreateSecurityHandler(FX_LPCSTR filter) +CPDF_SecurityHandler* CPDF_ModuleMgr::CreateSecurityHandler(const FX_CHAR* filter) { CPDF_SecurityHandler* (*CreateHandler)(void*) = NULL; if (!m_SecurityHandlerMap.Lookup(filter, (void*&)CreateHandler)) { diff --git a/core/src/fpdfapi/fpdf_edit/editint.h b/core/src/fpdfapi/fpdf_edit/editint.h index 38c33439ec..3a9d1588e0 100644 --- a/core/src/fpdfapi/fpdf_edit/editint.h +++ b/core/src/fpdfapi/fpdf_edit/editint.h @@ -15,7 +15,7 @@ public: FX_BOOL Start(); int32_t CompressIndirectObject(FX_DWORD dwObjNum, const CPDF_Object *pObj); - int32_t CompressIndirectObject(FX_DWORD dwObjNum, FX_LPCBYTE pBuffer, FX_DWORD dwSize); + int32_t CompressIndirectObject(FX_DWORD dwObjNum, const uint8_t* pBuffer, FX_DWORD dwSize); FX_FILESIZE End(CPDF_Creator* pCreator); @@ -38,7 +38,7 @@ public: int32_t CompressIndirectObject(FX_DWORD dwObjNum, const CPDF_Object *pObj, CPDF_Creator *pCreator); - int32_t CompressIndirectObject(FX_DWORD dwObjNum, FX_LPCBYTE pBuffer, FX_DWORD dwSize, CPDF_Creator *pCreator); + int32_t CompressIndirectObject(FX_DWORD dwObjNum, const uint8_t* pBuffer, FX_DWORD dwSize, CPDF_Creator *pCreator); FX_BOOL End(CPDF_Creator *pCreator, FX_BOOL bEOF = FALSE); FX_BOOL AddObjectNumberToIndexArray(FX_DWORD objnum); diff --git a/core/src/fpdfapi/fpdf_edit/fpdf_edit_content.cpp b/core/src/fpdfapi/fpdf_edit/fpdf_edit_content.cpp index 65b482bf30..717386041d 100644 --- a/core/src/fpdfapi/fpdf_edit/fpdf_edit_content.cpp +++ b/core/src/fpdfapi/fpdf_edit/fpdf_edit_content.cpp @@ -99,7 +99,7 @@ void CPDF_PageContentGenerate::ProcessImage(CFX_ByteTextBuf& buf, CPDF_ImageObje buf << "/" << PDF_NameEncode(name) << " Do Q\n"; } } -void CPDF_PageContentGenerate::ProcessForm(CFX_ByteTextBuf& buf, FX_LPCBYTE data, FX_DWORD size, CFX_Matrix& matrix) +void CPDF_PageContentGenerate::ProcessForm(CFX_ByteTextBuf& buf, const uint8_t* data, FX_DWORD size, CFX_Matrix& matrix) { if (!data || !size) { return; @@ -111,7 +111,7 @@ void CPDF_PageContentGenerate::ProcessForm(CFX_ByteTextBuf& buf, FX_LPCBYTE data CFX_FloatRect bbox = m_pPage->GetPageBBox(); matrix.TransformRect(bbox); pFormDict->SetAtRect(FX_BSTR("BBox"), bbox); - pStream->InitStream((FX_LPBYTE)data, size, pFormDict); + pStream->InitStream((uint8_t*)data, size, pFormDict); buf << "q " << matrix << " cm "; CFX_ByteString name = RealizeResource(pStream, "XObject"); buf << "/" << PDF_NameEncode(name) << " Do Q\n"; @@ -142,7 +142,7 @@ void CPDF_PageContentGenerate::TransformContent(CFX_Matrix& matrix) size += pContentArray[i]->GetSize() + 1; } int pos = 0; - FX_LPBYTE pBuf = FX_Alloc(uint8_t, size); + uint8_t* pBuf = FX_Alloc(uint8_t, size); for (i = 0; i < iCount; ++i) { FXSYS_memcpy32(pBuf + pos, pContentArray[i]->GetData(), pContentArray[i]->GetSize()); pos += pContentArray[i]->GetSize() + 1; diff --git a/core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp b/core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp index 035baa398f..0091613120 100644 --- a/core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp +++ b/core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp @@ -8,9 +8,9 @@ #include "editint.h" #define PDF_OBJECTSTREAM_MAXLENGTH (256 * 1024) #define PDF_XREFSTREAM_MAXSIZE 10000 -extern void FlateEncode(const uint8_t* src_buf, FX_DWORD src_data, FX_LPBYTE& dest_buf, FX_DWORD& dest_size); -extern void FlateEncode(FX_LPCBYTE src_buf, FX_DWORD src_size, int predictor, int Colors, int BitsPerComponent, int Columns, - FX_LPBYTE& dest_buf, FX_DWORD& dest_size); +extern void FlateEncode(const uint8_t* src_buf, FX_DWORD src_data, uint8_t*& dest_buf, FX_DWORD& dest_size); +extern void FlateEncode(const uint8_t* src_buf, FX_DWORD src_size, int predictor, int Colors, int BitsPerComponent, int Columns, + uint8_t*& dest_buf, FX_DWORD& dest_size); extern FX_BOOL IsSignatureDict(const CPDF_Dictionary* pDict); int32_t PDF_CreatorAppendObject(const CPDF_Object* pObj, CFX_FileBufferArchive *pFile, FX_FILESIZE& offset) { @@ -283,12 +283,12 @@ int32_t PDF_CreatorWriteEncrypt(const CPDF_Dictionary* pEncryptDict, FX_DWORD dw offset += len + 6; return offset; } -FX_BOOL PDF_GenerateFileID(FX_DWORD dwSeed1, FX_DWORD dwSeed2, FX_LPDWORD pBuffer) +FX_BOOL PDF_GenerateFileID(FX_DWORD dwSeed1, FX_DWORD dwSeed2, FX_DWORD* pBuffer) { if (!pBuffer) { return FALSE; } - FX_LPVOID pContext = FX_Random_MT_Start(dwSeed1); + void* pContext = FX_Random_MT_Start(dwSeed1); int32_t i = 0; for (i = 0; i < 2; i++) { *pBuffer++ = FX_Random_MT_Generate(pContext); @@ -307,9 +307,9 @@ public: CPDF_FlateEncoder(); ~CPDF_FlateEncoder(); FX_BOOL Initialize(CPDF_Stream* pStream, FX_BOOL bFlateEncode); - FX_BOOL Initialize(FX_LPCBYTE pBuffer, FX_DWORD size, FX_BOOL bFlateEncode, FX_BOOL bXRefStream = FALSE); + FX_BOOL Initialize(const uint8_t* pBuffer, FX_DWORD size, FX_BOOL bFlateEncode, FX_BOOL bXRefStream = FALSE); void CloneDict(); - FX_LPBYTE m_pData; + uint8_t* m_pData; FX_DWORD m_dwSize; CPDF_Dictionary* m_pDict; FX_BOOL m_bCloned; @@ -339,13 +339,13 @@ FX_BOOL CPDF_FlateEncoder::Initialize(CPDF_Stream* pStream, FX_BOOL bFlateEncode CPDF_StreamAcc destAcc; destAcc.LoadAllData(pStream); m_dwSize = destAcc.GetSize(); - m_pData = (FX_LPBYTE)destAcc.DetachData(); + m_pData = (uint8_t*)destAcc.DetachData(); m_pDict = (CPDF_Dictionary*)pStream->GetDict()->Clone(); m_pDict->RemoveAt(FX_BSTRC("Filter")); m_bNewData = TRUE; m_bCloned = TRUE; } else { - m_pData = (FX_LPBYTE)m_Acc.GetData(); + m_pData = (uint8_t*)m_Acc.GetData(); m_dwSize = m_Acc.GetSize(); m_pDict = pStream->GetDict(); } @@ -362,10 +362,10 @@ FX_BOOL CPDF_FlateEncoder::Initialize(CPDF_Stream* pStream, FX_BOOL bFlateEncode m_pDict->RemoveAt("DecodeParms"); return TRUE; } -FX_BOOL CPDF_FlateEncoder::Initialize(FX_LPCBYTE pBuffer, FX_DWORD size, FX_BOOL bFlateEncode, FX_BOOL bXRefStream) +FX_BOOL CPDF_FlateEncoder::Initialize(const uint8_t* pBuffer, FX_DWORD size, FX_BOOL bFlateEncode, FX_BOOL bXRefStream) { if (!bFlateEncode) { - m_pData = (FX_LPBYTE)pBuffer; + m_pData = (uint8_t*)pBuffer; m_dwSize = size; return TRUE; } @@ -391,8 +391,8 @@ class CPDF_Encryptor public: CPDF_Encryptor(); ~CPDF_Encryptor(); - FX_BOOL Initialize(CPDF_CryptoHandler* pHandler, int objnum, FX_LPBYTE src_data, FX_DWORD src_size); - FX_LPBYTE m_pData; + FX_BOOL Initialize(CPDF_CryptoHandler* pHandler, int objnum, uint8_t* src_data, FX_DWORD src_size); + uint8_t* m_pData; FX_DWORD m_dwSize; FX_BOOL m_bNewBuf; }; @@ -402,13 +402,13 @@ CPDF_Encryptor::CPDF_Encryptor() m_dwSize = 0; m_bNewBuf = FALSE; } -FX_BOOL CPDF_Encryptor::Initialize(CPDF_CryptoHandler* pHandler, int objnum, FX_LPBYTE src_data, FX_DWORD src_size) +FX_BOOL CPDF_Encryptor::Initialize(CPDF_CryptoHandler* pHandler, int objnum, uint8_t* src_data, FX_DWORD src_size) { if (src_size == 0) { return TRUE; } if (pHandler == NULL) { - m_pData = (FX_LPBYTE)src_data; + m_pData = (uint8_t*)src_data; m_dwSize = src_size; m_bNewBuf = FALSE; return TRUE; @@ -446,7 +446,7 @@ int32_t CPDF_ObjectStream::CompressIndirectObject(FX_DWORD dwObjNum, const CPDF_ m_Buffer << pObj; return 1; } -int32_t CPDF_ObjectStream::CompressIndirectObject(FX_DWORD dwObjNum, FX_LPCBYTE pBuffer, FX_DWORD dwSize) +int32_t CPDF_ObjectStream::CompressIndirectObject(FX_DWORD dwObjNum, const uint8_t* pBuffer, FX_DWORD dwSize) { m_ObjNumArray.Add(dwObjNum); m_OffsetArray.Add(m_Buffer.GetLength()); @@ -564,7 +564,7 @@ int32_t CPDF_XRefStream::CompressIndirectObject(FX_DWORD dwObjNum, const CPDF_Ob } return EndObjectStream(pCreator); } -int32_t CPDF_XRefStream::CompressIndirectObject(FX_DWORD dwObjNum, FX_LPCBYTE pBuffer, FX_DWORD dwSize, CPDF_Creator *pCreator) +int32_t CPDF_XRefStream::CompressIndirectObject(FX_DWORD dwObjNum, const uint8_t* pBuffer, FX_DWORD dwSize, CPDF_Creator *pCreator) { if (!pCreator) { return 0; @@ -958,7 +958,7 @@ int32_t CPDF_Creator::WriteIndirectObjectToStream(const CPDF_Object* pObj) } return 0; } -int32_t CPDF_Creator::WriteIndirectObjectToStream(FX_DWORD objnum, FX_LPCBYTE pBuffer, FX_DWORD dwSize) +int32_t CPDF_Creator::WriteIndirectObjectToStream(FX_DWORD objnum, const uint8_t* pBuffer, FX_DWORD dwSize) { if (!m_pXRefStream) { return 1; @@ -1104,8 +1104,8 @@ int32_t CPDF_Creator::WriteDirectObj(FX_DWORD objnum, const CPDF_Object* pObj, F break; } CPDF_Encryptor encryptor; - encryptor.Initialize(m_pCryptoHandler, objnum, (FX_LPBYTE)str.c_str(), str.GetLength()); - CFX_ByteString content = PDF_EncodeString(CFX_ByteString((FX_LPCSTR)encryptor.m_pData, encryptor.m_dwSize), bHex); + encryptor.Initialize(m_pCryptoHandler, objnum, (uint8_t*)str.c_str(), str.GetLength()); + CFX_ByteString content = PDF_EncodeString(CFX_ByteString((const FX_CHAR*)encryptor.m_pData, encryptor.m_dwSize), bHex); if ((len = m_File.AppendString(content)) < 0) { return -1; } @@ -1252,8 +1252,8 @@ int32_t CPDF_Creator::WriteOldIndirectObject(FX_DWORD objnum) return 0; } m_ObjectOffset[objnum] = m_Offset; - FX_LPVOID valuetemp = NULL; - FX_BOOL bExistInMap = m_pDocument->m_IndirectObjs.Lookup((FX_LPVOID)(uintptr_t)objnum, valuetemp); + void* valuetemp = NULL; + FX_BOOL bExistInMap = m_pDocument->m_IndirectObjs.Lookup((void*)(uintptr_t)objnum, valuetemp); FX_BOOL bObjStm = (m_pParser->m_V5Type[objnum] == 2) && m_pEncryptDict && !m_pXRefStream; if(m_pParser->m_bVersionUpdated || m_bSecurityChanged || bExistInMap || bObjStm) { CPDF_Object* pObj = m_pDocument->GetIndirectObject(objnum); @@ -1326,7 +1326,7 @@ int32_t CPDF_Creator::WriteOldObjs(IFX_Pause *pPause) } m_ObjectSize[objnum] = (FX_DWORD)(m_Offset - m_ObjectOffset[objnum]); if (pPause && pPause->NeedToPauseNow()) { - m_Pos = (FX_LPVOID)(uintptr_t)(objnum + 1); + m_Pos = (void*)(uintptr_t)(objnum + 1); return 1; } } @@ -1339,7 +1339,7 @@ int32_t CPDF_Creator::WriteNewObjs(FX_BOOL bIncremental, IFX_Pause *pPause) while (index < iCount) { FX_DWORD objnum = m_NewObjNumArray.ElementAt(index); CPDF_Object *pObj = NULL; - m_pDocument->m_IndirectObjs.Lookup((FX_LPVOID)(uintptr_t)objnum, (FX_LPVOID&)pObj); + m_pDocument->m_IndirectObjs.Lookup((void*)(uintptr_t)objnum, (void*&)pObj); if (NULL == pObj) { ++index; continue; @@ -1390,7 +1390,7 @@ void CPDF_Creator::InitNewObjNumOffsets() while (pos) { size_t key = 0; CPDF_Object* pObj; - m_pDocument->m_IndirectObjs.GetNextAssoc(pos, (FX_LPVOID&)key, (FX_LPVOID&)pObj); + m_pDocument->m_IndirectObjs.GetNextAssoc(pos, (void*&)key, (void*&)pObj); FX_DWORD objnum = (FX_DWORD)key; if (pObj->GetObjNum() == -1) { continue; @@ -1517,7 +1517,7 @@ int32_t CPDF_Creator::WriteDoc_Stage1(IFX_Pause *pPause) } else { IFX_FileRead* pSrcFile = m_pParser->GetFileAccess(); m_Offset = pSrcFile->GetSize(); - m_Pos = (FX_LPVOID)(uintptr_t)m_Offset; + m_Pos = (void*)(uintptr_t)m_Offset; m_iStage = 15; } } @@ -1536,7 +1536,7 @@ int32_t CPDF_Creator::WriteDoc_Stage1(IFX_Pause *pPause) } src_size -= block_size; if (pPause && pPause->NeedToPauseNow()) { - m_Pos = (FX_LPVOID)(uintptr_t)src_size; + m_Pos = (void*)(uintptr_t)src_size; return 1; } } @@ -1569,7 +1569,7 @@ int32_t CPDF_Creator::WriteDoc_Stage2(IFX_Pause *pPause) FXSYS_assert(m_iStage >= 20 || m_iStage < 30); if (m_iStage == 20) { if ((m_dwFlags & FPDFCREATE_INCREMENTAL) == 0 && m_pParser) { - m_Pos = (FX_LPVOID)(uintptr_t)0; + m_Pos = (void*)(uintptr_t)0; m_iStage = 21; } else { m_iStage = 25; @@ -1583,7 +1583,7 @@ int32_t CPDF_Creator::WriteDoc_Stage2(IFX_Pause *pPause) m_iStage = 25; } if (m_iStage == 25) { - m_Pos = (FX_LPVOID)(uintptr_t)0; + m_Pos = (void*)(uintptr_t)0; m_iStage = 26; } if (m_iStage == 26) { @@ -1630,13 +1630,13 @@ int32_t CPDF_Creator::WriteDoc_Stage3(IFX_Pause *pPause) if (m_File.AppendString(str) < 0) { return -1; } - m_Pos = (FX_LPVOID)(uintptr_t)1; + m_Pos = (void*)(uintptr_t)1; m_iStage = 81; } else { if (m_File.AppendString(FX_BSTRC("xref\r\n")) < 0) { return -1; } - m_Pos = (FX_LPVOID)(uintptr_t)0; + m_Pos = (void*)(uintptr_t)0; m_iStage = 82; } } else { @@ -1675,7 +1675,7 @@ int32_t CPDF_Creator::WriteDoc_Stage3(IFX_Pause *pPause) break; } if (pPause && pPause->NeedToPauseNow()) { - m_Pos = (FX_LPVOID)(uintptr_t)i; + m_Pos = (void*)(uintptr_t)i; return 1; } } @@ -1715,7 +1715,7 @@ int32_t CPDF_Creator::WriteDoc_Stage3(IFX_Pause *pPause) } } if (pPause && (i % 100) == 0 && pPause->NeedToPauseNow()) { - m_Pos = (FX_LPVOID)(uintptr_t)i; + m_Pos = (void*)(uintptr_t)i; return 1; } } @@ -1976,7 +1976,7 @@ void CPDF_Creator::Clear() m_pIDArray = NULL; } } -FX_BOOL CPDF_Creator::Create(FX_LPCSTR filename, FX_DWORD flags) +FX_BOOL CPDF_Creator::Create(const FX_CHAR* filename, FX_DWORD flags) { if (!m_File.AttachFile(filename)) { return FALSE; @@ -1987,7 +1987,7 @@ FX_BOOL CPDF_Creator::Create(FX_LPCSTR filename, FX_DWORD flags) } return bRet; } -FX_BOOL CPDF_Creator::Create(FX_LPCWSTR filename, FX_DWORD flags) +FX_BOOL CPDF_Creator::Create(const FX_WCHAR* filename, FX_DWORD flags) { if (!m_File.AttachFile(filename)) { return FALSE; @@ -2028,7 +2028,7 @@ void CPDF_Creator::InitID(FX_BOOL bDefault ) CPDF_Array* pOldIDArray = m_pParser ? m_pParser->GetIDArray() : NULL; FX_BOOL bNewId = !m_pIDArray; if (!m_pIDArray) { - FX_LPDWORD pBuffer = NULL; + FX_DWORD* pBuffer = NULL; m_pIDArray = CPDF_Array::Create(); CPDF_Object* pID1 = pOldIDArray ? pOldIDArray->GetElement(0) : NULL; if (pID1) { @@ -2036,7 +2036,7 @@ void CPDF_Creator::InitID(FX_BOOL bDefault ) } else { pBuffer = FX_Alloc(FX_DWORD, 4); PDF_GenerateFileID((FX_DWORD)(uintptr_t)this, m_dwLastObjNum, pBuffer); - CFX_ByteStringC bsBuffer((FX_LPCBYTE)pBuffer, 4 * sizeof(FX_DWORD)); + CFX_ByteStringC bsBuffer((const uint8_t*)pBuffer, 4 * sizeof(FX_DWORD)); m_pIDArray->Add(CPDF_String::Create(bsBuffer, TRUE), m_pDocument); } if (pBuffer) { @@ -2052,9 +2052,9 @@ void CPDF_Creator::InitID(FX_BOOL bDefault ) m_pIDArray->Add(pID2->Clone()); return; } - FX_LPDWORD pBuffer = FX_Alloc(FX_DWORD, 4); + FX_DWORD* pBuffer = FX_Alloc(FX_DWORD, 4); PDF_GenerateFileID((FX_DWORD)(uintptr_t)this, m_dwLastObjNum, pBuffer); - CFX_ByteStringC bsBuffer((FX_LPCBYTE)pBuffer, 4 * sizeof(FX_DWORD)); + CFX_ByteStringC bsBuffer((const uint8_t*)pBuffer, 4 * sizeof(FX_DWORD)); m_pIDArray->Add(CPDF_String::Create(bsBuffer, TRUE), m_pDocument); FX_Free(pBuffer); return; @@ -2065,7 +2065,7 @@ void CPDF_Creator::InitID(FX_BOOL bDefault ) CPDF_StandardSecurityHandler handler; CFX_ByteString user_pass = m_pParser->GetPassword(); FX_DWORD flag = PDF_ENCRYPT_CONTENT; - handler.OnCreate(m_pEncryptDict, m_pIDArray, (FX_LPCBYTE)user_pass, user_pass.GetLength(), flag); + handler.OnCreate(m_pEncryptDict, m_pIDArray, (const uint8_t*)user_pass, user_pass.GetLength(), flag); if (m_pCryptoHandler && m_bNewCrypto) { delete m_pCryptoHandler; } diff --git a/core/src/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp b/core/src/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp index d2d81d5566..7176a62435 100644 --- a/core/src/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp +++ b/core/src/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp @@ -226,7 +226,7 @@ CPDF_Font* CPDF_Document::AddWindowsFont(LOGFONTW* pLogFont, FX_BOOL bVert, FX_B FXSYS_strcpy(lfa.lfFaceName, face.c_str()); return AddWindowsFont(&lfa, bVert, bTranslateName); } -extern CFX_ByteString _FPDF_GetNameFromTT(FX_LPCBYTE name_table, FX_DWORD name); +extern CFX_ByteString _FPDF_GetNameFromTT(const uint8_t* name_table, FX_DWORD name); CFX_ByteString _FPDF_GetPSNameFromTT(HDC hDC) { CFX_ByteString result; @@ -429,11 +429,11 @@ CPDF_Font* CPDF_Document::AddWindowsFont(LOGFONTA* pLogFont, FX_BOOL bVert, FX_B } #endif #if (_FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_) -uint32_t FX_GetLangHashCode( FX_LPCSTR pStr) +uint32_t FX_GetLangHashCode( const FX_CHAR* pStr) { FXSYS_assert( pStr != NULL); int32_t iLength = FXSYS_strlen(pStr); - FX_LPCSTR pStrEnd = pStr + iLength; + const FX_CHAR* pStrEnd = pStr + iLength; uint32_t uHashCode = 0; while ( pStr < pStrEnd) { uHashCode = 31 * uHashCode + tolower(*pStr++); @@ -529,7 +529,7 @@ static FX_WORD FX_GetCsFromLangCode(uint32_t uCode) }; return 0; } -static FX_WORD FX_GetCharsetFromLang(FX_LPCSTR pLang, int32_t iLength) +static FX_WORD FX_GetCharsetFromLang(const FX_CHAR* pLang, int32_t iLength) { FXSYS_assert(pLang); if (iLength < 0) { @@ -545,7 +545,7 @@ static void _CFString2CFXByteString(CFStringRef src, CFX_ByteString &dest) CFIndex used = 0; UInt8* pBuffer = (UInt8*)calloc(len+1, sizeof(UInt8)); CFStringGetBytes(src, range, kCFStringEncodingASCII, 0, false, pBuffer, len, &used); - dest = (FX_LPSTR)pBuffer; + dest = (FX_CHAR*)pBuffer; free(pBuffer); } FX_BOOL IsHasCharSet(CFArrayRef languages, const CFX_DWordArray &charSets) @@ -1141,7 +1141,7 @@ CPDF_Dictionary* CPDF_Document::CreateNewPage(int iPage) return pDict; } int _PDF_GetStandardFontName(CFX_ByteString& name); -CPDF_Font* CPDF_Document::AddStandardFont(FX_LPCSTR font, CPDF_FontEncoding* pEncoding) +CPDF_Font* CPDF_Document::AddStandardFont(const FX_CHAR* font, CPDF_FontEncoding* pEncoding) { CFX_ByteString name(font, -1); if (_PDF_GetStandardFontName(name) < 0) { diff --git a/core/src/fpdfapi/fpdf_edit/fpdf_edit_image.cpp b/core/src/fpdfapi/fpdf_edit/fpdf_edit_image.cpp index 8d105a5bd8..fd715240a4 100644 --- a/core/src/fpdfapi/fpdf_edit/fpdf_edit_image.cpp +++ b/core/src/fpdfapi/fpdf_edit/fpdf_edit_image.cpp @@ -10,7 +10,7 @@ #include "../../../include/fpdfapi/fpdf_render.h" #include "../fpdf_page/pageint.h" #include "../fpdf_render/render_int.h" -CPDF_Dictionary* CPDF_Image::InitJPEG(FX_LPBYTE pData, FX_DWORD size) +CPDF_Dictionary* CPDF_Image::InitJPEG(uint8_t* pData, FX_DWORD size) { int32_t width, height, color_trans, num_comps, bits; if (!CPDF_ModuleMgr::Get()->GetJpegModule()-> @@ -22,7 +22,7 @@ CPDF_Dictionary* CPDF_Image::InitJPEG(FX_LPBYTE pData, FX_DWORD size) pDict->SetAtName("Subtype", "Image"); pDict->SetAtInteger("Width", width); pDict->SetAtInteger("Height", height); - FX_LPCSTR csname = NULL; + const FX_CHAR* csname = NULL; if (num_comps == 1) { csname = "DeviceGray"; } else if (num_comps == 3) { @@ -52,7 +52,7 @@ CPDF_Dictionary* CPDF_Image::InitJPEG(FX_LPBYTE pData, FX_DWORD size) } return pDict; } -void CPDF_Image::SetJpegImage(FX_LPBYTE pData, FX_DWORD size) +void CPDF_Image::SetJpegImage(uint8_t* pData, FX_DWORD size) { CPDF_Dictionary *pDict = InitJPEG(pData, size); if (!pDict) { @@ -70,7 +70,7 @@ void CPDF_Image::SetJpegImage(IFX_FileRead *pFile) if (dwEstimateSize > 8192) { dwEstimateSize = 8192; } - FX_LPBYTE pData = FX_Alloc(uint8_t, dwEstimateSize); + uint8_t* pData = FX_Alloc(uint8_t, dwEstimateSize); pFile->ReadBlock(pData, 0, dwEstimateSize); CPDF_Dictionary *pDict = InitJPEG(pData, dwEstimateSize); FX_Free(pData); @@ -85,10 +85,10 @@ void CPDF_Image::SetJpegImage(IFX_FileRead *pFile) } m_pStream->InitStream(pFile, pDict); } -void _DCTEncodeBitmap(CPDF_Dictionary *pBitmapDict, const CFX_DIBitmap* pBitmap, int quality, FX_LPBYTE &buf, FX_STRSIZE &size) +void _DCTEncodeBitmap(CPDF_Dictionary *pBitmapDict, const CFX_DIBitmap* pBitmap, int quality, uint8_t* &buf, FX_STRSIZE &size) { } -void _JBIG2EncodeBitmap(CPDF_Dictionary *pBitmapDict, const CFX_DIBitmap *pBitmap, CPDF_Document *pDoc, FX_LPBYTE &buf, FX_STRSIZE &size, FX_BOOL bLossLess) +void _JBIG2EncodeBitmap(CPDF_Dictionary *pBitmapDict, const CFX_DIBitmap *pBitmap, CPDF_Document *pDoc, uint8_t* &buf, FX_STRSIZE &size, FX_BOOL bLossLess) { } void CPDF_Image::SetImage(const CFX_DIBitmap* pBitmap, int32_t iCompress, IFX_FileWrite *pFileWrite, IFX_FileRead *pFileRead, const CFX_DIBitmap* pMask, const CPDF_ImageSetParam* pParam) @@ -98,7 +98,7 @@ void CPDF_Image::SetImage(const CFX_DIBitmap* pBitmap, int32_t iCompress, IFX_Fi if (BitmapWidth < 1 || BitmapHeight < 1) { return; } - FX_LPBYTE src_buf = pBitmap->GetBuffer(); + uint8_t* src_buf = pBitmap->GetBuffer(); int32_t src_pitch = pBitmap->GetPitch(); int32_t bpp = pBitmap->GetBPP(); FX_BOOL bUseMatte = pParam && pParam->pMatteColor && (pBitmap->GetFormat() == FXDIB_Argb); @@ -107,7 +107,7 @@ void CPDF_Image::SetImage(const CFX_DIBitmap* pBitmap, int32_t iCompress, IFX_Fi pDict->SetAtName(FX_BSTRC("Subtype"), FX_BSTRC("Image")); pDict->SetAtInteger(FX_BSTRC("Width"), BitmapWidth); pDict->SetAtInteger(FX_BSTRC("Height"), BitmapHeight); - FX_LPBYTE dest_buf = NULL; + uint8_t* dest_buf = NULL; FX_STRSIZE dest_pitch = 0, dest_size = 0, opType = -1; if (bpp == 1) { int32_t reset_a = 0, reset_r = 0, reset_g = 0, reset_b = 0; @@ -130,7 +130,7 @@ void CPDF_Image::SetImage(const CFX_DIBitmap* pBitmap, int32_t iCompress, IFX_Fi pCS->AddName(FX_BSTRC("DeviceRGB")); pCS->AddInteger(1); CFX_ByteString ct; - FX_LPSTR pBuf = ct.GetBuffer(6); + FX_CHAR* pBuf = ct.GetBuffer(6); pBuf[0] = (FX_CHAR)reset_r; pBuf[1] = (FX_CHAR)reset_g; pBuf[2] = (FX_CHAR)reset_b; @@ -156,8 +156,8 @@ void CPDF_Image::SetImage(const CFX_DIBitmap* pBitmap, int32_t iCompress, IFX_Fi pCS->AddName(FX_BSTRC("Indexed")); pCS->AddName(FX_BSTRC("DeviceRGB")); pCS->AddInteger(iPalette - 1); - FX_LPBYTE pColorTable = FX_Alloc2D(uint8_t, iPalette, 3); - FX_LPBYTE ptr = pColorTable; + uint8_t* pColorTable = FX_Alloc2D(uint8_t, iPalette, 3); + uint8_t* ptr = pColorTable; for (int32_t i = 0; i < iPalette; i ++) { FX_DWORD argb = pBitmap->GetPaletteArgb(i); ptr[0] = (uint8_t)(argb >> 16); @@ -204,7 +204,7 @@ void CPDF_Image::SetImage(const CFX_DIBitmap* pBitmap, int32_t iCompress, IFX_Fi if (pMaskBitmap) { int32_t maskWidth = pMaskBitmap->GetWidth(); int32_t maskHeight = pMaskBitmap->GetHeight(); - FX_LPBYTE mask_buf = NULL; + uint8_t* mask_buf = NULL; FX_STRSIZE mask_size; CPDF_Dictionary* pMaskDict = new CPDF_Dictionary; pMaskDict->SetAtName(FX_BSTRC("Type"), FX_BSTRC("XObject")); @@ -270,7 +270,7 @@ void CPDF_Image::SetImage(const CFX_DIBitmap* pBitmap, int32_t iCompress, IFX_Fi if (bUseMatte) { CFX_DIBitmap *pNewBitmap = new CFX_DIBitmap(); pNewBitmap->Create(BitmapWidth, BitmapHeight, FXDIB_Argb); - FX_LPBYTE dst_buf = pNewBitmap->GetBuffer(); + uint8_t* dst_buf = pNewBitmap->GetBuffer(); int32_t src_offset = 0; for (int32_t row = 0; row < BitmapHeight; row ++) { src_offset = row * src_pitch; @@ -300,7 +300,7 @@ void CPDF_Image::SetImage(const CFX_DIBitmap* pBitmap, int32_t iCompress, IFX_Fi dest_buf = FX_Alloc2D(uint8_t, dest_pitch, BitmapHeight); dest_size = dest_pitch * BitmapHeight; // Safe since checked alloc returned. } - FX_LPBYTE pDest = dest_buf; + uint8_t* pDest = dest_buf; for (int32_t i = 0; i < BitmapHeight; i ++) { if (!bStream) { FXSYS_memcpy32(pDest, src_buf, dest_pitch); @@ -317,7 +317,7 @@ void CPDF_Image::SetImage(const CFX_DIBitmap* pBitmap, int32_t iCompress, IFX_Fi } else { dest_buf = FX_Alloc(uint8_t, dest_pitch); } - FX_LPBYTE pDest = dest_buf; + uint8_t* pDest = dest_buf; int32_t src_offset = 0; int32_t dest_offset = 0; for (int32_t row = 0; row < BitmapHeight; row ++) { diff --git a/core/src/fpdfapi/fpdf_font/font_int.h b/core/src/fpdfapi/fpdf_font/font_int.h index 1e52607d98..6f32f4fa98 100644 --- a/core/src/fpdfapi/fpdf_font/font_int.h +++ b/core/src/fpdfapi/fpdf_font/font_int.h @@ -12,7 +12,7 @@ class CPDF_CMapManager public: CPDF_CMapManager(); ~CPDF_CMapManager(); - FX_LPVOID GetPackage(FX_BOOL bPrompt); + void* GetPackage(FX_BOOL bPrompt); CPDF_CMap* GetPredefinedCMap(const CFX_ByteString& name, FX_BOOL bPrompt); CPDF_CID2UnicodeMap* GetCID2UnicodeMap(int charset, FX_BOOL bPrompt); void ReloadAll(); @@ -44,7 +44,7 @@ public: } m_EmbeddedToUnicodes[NUMBER_OF_CIDSETS]; private: CFX_MapPtrToPtr m_pStockMap; - FX_LPBYTE m_pContrastRamps; + uint8_t* m_pContrastRamps; }; struct _CMap_CodeRange { int m_CharSize; @@ -81,7 +81,7 @@ class CPDF_CMap public: CPDF_CMap(); FX_BOOL LoadPredefined(CPDF_CMapManager* pMgr, const FX_CHAR* name, FX_BOOL bPromptCJK); - FX_BOOL LoadEmbedded(FX_LPCBYTE pData, FX_DWORD dwSize); + FX_BOOL LoadEmbedded(const uint8_t* pData, FX_DWORD dwSize); void Release(); FX_BOOL IsLoaded() const { @@ -98,9 +98,9 @@ public: FX_WORD CIDFromCharCode(FX_DWORD charcode) const; FX_DWORD CharCodeFromCID(FX_WORD CID) const; int GetCharSize(FX_DWORD charcode) const; - FX_DWORD GetNextChar(FX_LPCSTR pString, int nStrLen, int& offset) const; - int CountChar(FX_LPCSTR pString, int size) const; - int AppendChar(FX_LPSTR str, FX_DWORD charcode) const; + FX_DWORD GetNextChar(const FX_CHAR* pString, int nStrLen, int& offset) const; + int CountChar(const FX_CHAR* pString, int size) const; + int AppendChar(FX_CHAR* str, FX_DWORD charcode) const; typedef enum {OneByte, TwoBytes, MixedTwoBytes, MixedFourBytes} CodingScheme; protected: ~CPDF_CMap(); @@ -115,7 +115,7 @@ protected: int m_nCodeRanges; uint8_t* m_pLeadingBytes; FX_WORD* m_pMapping; - FX_LPBYTE m_pAddMapping; + uint8_t* m_pAddMapping; FX_BOOL m_bLoaded; const FXCMAP_CMap* m_pEmbedMap; CPDF_CMap* m_pUseMap; @@ -123,7 +123,7 @@ protected: class CPDF_PredefinedCMap { public: - FX_LPCSTR m_pName; + const FX_CHAR* m_pName; int m_Charset; int m_Coding; CPDF_CMap::CodingScheme m_CodingScheme; diff --git a/core/src/fpdfapi/fpdf_font/fpdf_font.cpp b/core/src/fpdfapi/fpdf_font/fpdf_font.cpp index 0058e140d4..c6922d11f8 100644 --- a/core/src/fpdfapi/fpdf_font/fpdf_font.cpp +++ b/core/src/fpdfapi/fpdf_font/fpdf_font.cpp @@ -205,7 +205,7 @@ CFX_WideString CPDF_Font::DecodeString(const CFX_ByteString& str) const CFX_WideString result; int src_len = str.GetLength(); result.Reserve(src_len); - FX_LPCSTR src_buf = str; + const FX_CHAR* src_buf = str; int src_pos = 0; while (src_pos < src_len) { FX_DWORD charcode = GetNextChar(src_buf, src_len, src_pos); @@ -222,8 +222,8 @@ CFX_ByteString CPDF_Font::EncodeString(const CFX_WideString& str) const { CFX_ByteString result; int src_len = str.GetLength(); - FX_LPSTR dest_buf = result.GetBuffer(src_len * 2); - FX_LPCWSTR src_buf = str.c_str(); + FX_CHAR* dest_buf = result.GetBuffer(src_len * 2); + const FX_WCHAR* src_buf = str.c_str(); int dest_pos = 0; for (int src_pos = 0; src_pos < src_len; src_pos ++) { FX_DWORD charcode = CharCodeFromUnicode(src_buf[src_pos]); @@ -289,7 +289,7 @@ void CPDF_Font::LoadFontDescriptor(CPDF_Dictionary* pFontDesc) if (m_pFontFile == NULL) { return; } - FX_LPCBYTE pFontData = m_pFontFile->GetData(); + const uint8_t* pFontData = m_pFontFile->GetData(); FX_DWORD dwFontSize = m_pFontFile->GetSize(); m_Font.LoadEmbedded(pFontData, dwFontSize); if (m_Font.m_Face == NULL) { @@ -369,7 +369,7 @@ void CPDF_Font::LoadUnicodeMap() m_pToUnicodeMap = new CPDF_ToUnicodeMap; m_pToUnicodeMap->Load(pStream); } -int CPDF_Font::GetStringWidth(FX_LPCSTR pString, int size) +int CPDF_Font::GetStringWidth(const FX_CHAR* pString, int size) { int offset = 0; int width = 0; @@ -431,7 +431,7 @@ CPDF_Font* CPDF_Font::CreateFontF(CPDF_Document* pDoc, CPDF_Dictionary* pFontDic int i; int count = sizeof(ChineseFontNames) / sizeof(ChineseFontNames[0]); for (i = 0; i < count; ++i) { - if (tag == CFX_ByteString((FX_LPCSTR)ChineseFontNames[i])) { + if (tag == CFX_ByteString((const FX_CHAR*)ChineseFontNames[i])) { break; } } @@ -500,7 +500,7 @@ CFX_WideString CPDF_ToUnicodeMap::Lookup(FX_DWORD charcode) if (unicode != 0xffff) { return unicode; } - FX_LPCWSTR buf = m_MultiCharBuf.GetBuffer(); + const FX_WCHAR* buf = m_MultiCharBuf.GetBuffer(); FX_DWORD buf_len = m_MultiCharBuf.GetLength(); if (buf == NULL || buf_len == 0) { return CFX_WideString(); @@ -534,7 +534,7 @@ FX_DWORD CPDF_ToUnicodeMap::ReverseLookup(FX_WCHAR unicode) } static FX_DWORD _StringToCode(FX_BSTR str) { - FX_LPCSTR buf = str.GetCStr(); + const FX_CHAR* buf = str.GetCStr(); int len = str.GetLength(); if (len == 0) { return 0; @@ -586,7 +586,7 @@ static CFX_WideString _StringDataAdd(CFX_WideString str) } static CFX_WideString _StringToWideString(FX_BSTR str) { - FX_LPCSTR buf = str.GetCStr(); + const FX_CHAR* buf = str.GetCStr(); int len = str.GetLength(); if (len == 0) { return CFX_WideString(); @@ -816,7 +816,7 @@ FX_BOOL CPDF_Font::IsStandardFont() const } return TRUE; } -extern FX_LPCSTR PDF_CharNameFromPredefinedCharSet(int encoding, uint8_t charcode); +extern const FX_CHAR* PDF_CharNameFromPredefinedCharSet(int encoding, uint8_t charcode); CPDF_SimpleFont::CPDF_SimpleFont(int fonttype) : CPDF_Font(fonttype) { FXSYS_memset8(m_CharBBox, 0xff, sizeof m_CharBBox); @@ -907,13 +907,13 @@ void CPDF_SimpleFont::GetCharBBox(FX_DWORD charcode, FX_RECT& rect, int level) rect.bottom = m_CharBBox[charcode].Bottom; rect.top = m_CharBBox[charcode].Top; } -FX_LPCSTR GetAdobeCharName(int iBaseEncoding, const CFX_ByteString* pCharNames, int charcode) +const FX_CHAR* GetAdobeCharName(int iBaseEncoding, const CFX_ByteString* pCharNames, int charcode) { ASSERT(charcode >= 0 && charcode < 256); if (charcode < 0 || charcode >= 256) { return NULL; } - FX_LPCSTR name = NULL; + const FX_CHAR* name = NULL; if (pCharNames) { name = pCharNames[charcode]; } @@ -1081,8 +1081,8 @@ int CPDF_Type1Font::GlyphFromCharCodeExt(FX_DWORD charcode) } #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ struct _GlyphNameMap { - FX_LPCSTR m_pStrAdobe; - FX_LPCSTR m_pStrUnicode; + const FX_CHAR* m_pStrAdobe; + const FX_CHAR* m_pStrUnicode; }; static const _GlyphNameMap g_GlyphNameSubsts[] = { {"ff", "uniFB00"}, @@ -1094,10 +1094,10 @@ static const _GlyphNameMap g_GlyphNameSubsts[] = { extern "C" { static int compareString(const void* key, const void* element) { - return FXSYS_stricmp((FX_LPCSTR)key, ((_GlyphNameMap*)element)->m_pStrAdobe); + return FXSYS_stricmp((const FX_CHAR*)key, ((_GlyphNameMap*)element)->m_pStrAdobe); } } -static FX_LPCSTR _GlyphNameRemap(FX_LPCSTR pStrAdobe) +static const FX_CHAR* _GlyphNameRemap(const FX_CHAR* pStrAdobe) { _GlyphNameMap* found = (_GlyphNameMap*)FXSYS_bsearch(pStrAdobe, g_GlyphNameSubsts, sizeof g_GlyphNameSubsts / sizeof(_GlyphNameMap), sizeof(_GlyphNameMap), @@ -1164,7 +1164,7 @@ void CPDF_Type1Font::LoadGlyphMap() m_BaseEncoding = PDFFONT_ENCODING_STANDARD; } for (int charcode = 0; charcode < 256; charcode ++) { - FX_LPCSTR name = GetAdobeCharName(m_BaseEncoding, m_pCharNames, charcode); + const FX_CHAR* name = GetAdobeCharName(m_BaseEncoding, m_pCharNames, charcode); if (name == NULL) { continue; } @@ -1207,7 +1207,7 @@ void CPDF_Type1Font::LoadGlyphMap() if (bCoreText) { if (m_Flags & PDFFONT_SYMBOLIC) { for (int charcode = 0; charcode < 256; charcode ++) { - FX_LPCSTR name = GetAdobeCharName(m_BaseEncoding, m_pCharNames, charcode); + const FX_CHAR* name = GetAdobeCharName(m_BaseEncoding, m_pCharNames, charcode); if (name) { m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name); m_GlyphIndex[charcode] = FXFT_Get_Name_Index(m_Font.m_Face, (char*)name); @@ -1244,12 +1244,12 @@ void CPDF_Type1Font::LoadGlyphMap() bUnicode = TRUE; } for (int charcode = 0; charcode < 256; charcode ++) { - FX_LPCSTR name = GetAdobeCharName(m_BaseEncoding, m_pCharNames, charcode); + const FX_CHAR* name = GetAdobeCharName(m_BaseEncoding, m_pCharNames, charcode); if (name == NULL) { continue; } m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name); - FX_LPCSTR pStrUnicode = _GlyphNameRemap(name); + const FX_CHAR* pStrUnicode = _GlyphNameRemap(name); if (pStrUnicode && 0 == FXFT_Get_Name_Index(m_Font.m_Face, (char*)name)) { name = pStrUnicode; } @@ -1289,7 +1289,7 @@ void CPDF_Type1Font::LoadGlyphMap() #endif if (m_Flags & PDFFONT_SYMBOLIC) { for (int charcode = 0; charcode < 256; charcode ++) { - FX_LPCSTR name = GetAdobeCharName(m_BaseEncoding, m_pCharNames, charcode); + const FX_CHAR* name = GetAdobeCharName(m_BaseEncoding, m_pCharNames, charcode); if (name) { m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name); m_GlyphIndex[charcode] = FXFT_Get_Name_Index(m_Font.m_Face, (char*)name); @@ -1322,7 +1322,7 @@ void CPDF_Type1Font::LoadGlyphMap() bUnicode = TRUE; } for (int charcode = 0; charcode < 256; charcode ++) { - FX_LPCSTR name = GetAdobeCharName(m_BaseEncoding, m_pCharNames, charcode); + const FX_CHAR* name = GetAdobeCharName(m_BaseEncoding, m_pCharNames, charcode); if (name == NULL) { continue; } @@ -1475,7 +1475,7 @@ void CPDF_TrueTypeFont::LoadGlyphMap() } FX_BOOL bToUnicode = m_pFontDict->KeyExist(FX_BSTRC("ToUnicode")); for (int charcode = 0; charcode < 256; charcode ++) { - FX_LPCSTR name = GetAdobeCharName(baseEncoding, m_pCharNames, charcode); + const FX_CHAR* name = GetAdobeCharName(baseEncoding, m_pCharNames, charcode); if (name == NULL) { m_GlyphIndex[charcode] = m_pFontFile ? FXFT_Get_Char_Index(m_Font.m_Face, charcode) : -1; continue; @@ -1540,7 +1540,7 @@ void CPDF_TrueTypeFont::LoadGlyphMap() if (bGotOne) { if (baseEncoding != PDFFONT_ENCODING_BUILTIN) { for (int charcode = 0; charcode < 256; charcode ++) { - FX_LPCSTR name = GetAdobeCharName(baseEncoding, m_pCharNames, charcode); + const FX_CHAR* name = GetAdobeCharName(baseEncoding, m_pCharNames, charcode); if (name == NULL) { continue; } @@ -1572,7 +1572,7 @@ void CPDF_TrueTypeFont::LoadGlyphMap() const FX_WORD* pUnicodes = PDF_UnicodesForPredefinedCharSet(baseEncoding); for (int charcode = 0; charcode < 256; charcode ++) { if (m_pFontFile == NULL) { - FX_LPCSTR name = GetAdobeCharName(0, m_pCharNames, charcode); + const FX_CHAR* name = GetAdobeCharName(0, m_pCharNames, charcode); if (name != NULL) { m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name); } else if (pUnicodes) { @@ -1603,14 +1603,16 @@ CPDF_Type3Font::~CPDF_Type3Font() { FX_POSITION pos = m_CacheMap.GetStartPosition(); while (pos) { - FX_LPVOID key, value; + void* key; + void* value; m_CacheMap.GetNextAssoc(pos, key, value); delete (CPDF_Type3Char*)value; } m_CacheMap.RemoveAll(); pos = m_DeletedMap.GetStartPosition(); while (pos) { - FX_LPVOID key, value; + void* key; + void* value; m_DeletedMap.GetNextAssoc(pos, key, value); delete (CPDF_Type3Char*)key; } @@ -1671,15 +1673,15 @@ CPDF_Type3Char* CPDF_Type3Font::LoadChar(FX_DWORD charcode, int level) return NULL; } CPDF_Type3Char* pChar = NULL; - if (m_CacheMap.Lookup((FX_LPVOID)(uintptr_t)charcode, (FX_LPVOID&)pChar)) { + if (m_CacheMap.Lookup((void*)(uintptr_t)charcode, (void*&)pChar)) { if (pChar->m_bPageRequired && m_pPageResources) { delete pChar; - m_CacheMap.RemoveKey((FX_LPVOID)(uintptr_t)charcode); + m_CacheMap.RemoveKey((void*)(uintptr_t)charcode); return LoadChar(charcode, level + 1); } return pChar; } - FX_LPCSTR name = GetAdobeCharName(m_BaseEncoding, m_pCharNames, charcode); + const FX_CHAR* name = GetAdobeCharName(m_BaseEncoding, m_pCharNames, charcode); if (name == NULL) { return NULL; } @@ -1703,7 +1705,7 @@ CPDF_Type3Char* CPDF_Type3Font::LoadChar(FX_DWORD charcode, int level) rcBBox.right = FXSYS_round(char_rect.right * 1000); rcBBox.top = FXSYS_round(char_rect.top * 1000); rcBBox.bottom = FXSYS_round(char_rect.bottom * 1000); - m_CacheMap.SetAt((FX_LPVOID)(uintptr_t)charcode, pChar); + m_CacheMap.SetAt((void*)(uintptr_t)charcode, pChar); if (pChar->m_pForm->CountObjects() == 0) { delete pChar->m_pForm; pChar->m_pForm = NULL; diff --git a/core/src/fpdfapi/fpdf_font/fpdf_font_charset.cpp b/core/src/fpdfapi/fpdf_font/fpdf_font_charset.cpp index 8e8fccd8a3..8d2f922fb1 100644 --- a/core/src/fpdfapi/fpdf_font/fpdf_font_charset.cpp +++ b/core/src/fpdfapi/fpdf_font/fpdf_font_charset.cpp @@ -264,7 +264,7 @@ const FX_WORD ZapfEncoding[256] = { 0x0000, 0x27B1, 0x27B2, 0x27B3, 0x27B4, 0x27B5, 0x27B6, 0x27B7, 0x27B8, 0x27B9, 0x27BA, 0x27BB, 0x27BC, 0x27BD, 0x27BE, 0x0000, }; -const FX_LPCSTR StandardEncodingNames[224] = { +const FX_CHAR* const StandardEncodingNames[224] = { "space", "exclam", "quotedbl", "numbersign", "dollar", "percent", "ampersand", "quoteright", "parenleft", "parenright", "asterisk", "plus", "comma", "hyphen", "period", "slash", "zero", "one", "two", "three", "four", "five", "six", "seven", @@ -294,7 +294,7 @@ const FX_LPCSTR StandardEncodingNames[224] = { NULL, "ae", NULL, NULL, NULL, "dotlessi", NULL, NULL, "lslash", "oslash", "oe", "germandbls", NULL, NULL, NULL, NULL, }; -const FX_LPCSTR AdobeWinAnsiEncodingNames[224] = { +const FX_CHAR* const AdobeWinAnsiEncodingNames[224] = { "space", "exclam", "quotedbl", "numbersign", "dollar", "percent", "ampersand", "quotesingle", "parenleft", "parenright", "asterisk", "plus", "comma", "hyphen", "period", "slash", "zero", "one", "two", "three", "four", "five", "six", "seven", @@ -324,7 +324,7 @@ const FX_LPCSTR AdobeWinAnsiEncodingNames[224] = { "eth", "ntilde", "ograve", "oacute", "ocircumflex", "otilde", "odieresis", "divide", "oslash", "ugrave", "uacute", "ucircumflex", "udieresis", "yacute", "thorn", "ydieresis", }; -const FX_LPCSTR MacRomanEncodingNames[224] = { +const FX_CHAR* const MacRomanEncodingNames[224] = { "space", "exclam", "quotedbl", "numbersign", "dollar", "percent", "ampersand", "quotesingle", "parenleft", "parenright", "asterisk", "plus", "comma", "hyphen", "period", "slash", "zero", "one", "two", "three", "four", "five", "six", "seven", @@ -354,7 +354,7 @@ const FX_LPCSTR MacRomanEncodingNames[224] = { "apple", "Ograve", "Uacute", "Ucircumflex", "Ugrave", "dotlessi", "circumflex", "tilde", "macron", "breve", "dotaccent", "ring", "cedilla", "hungarumlaut", "ogonek", "caron", }; -const FX_LPCSTR MacExpertEncodingNames[224] = { +const FX_CHAR* const MacExpertEncodingNames[224] = { "space", "exclamsmall", "Hungarumlautsmall", "centoldstyle", "dollaroldstyle", "dollarsuperior", "ampersandsmall", "Acutesmall", "parenleftsuperior", "parenrightsuperior", "twodotenleader", "onedotenleader", "comma", "hyphen", "period", "fraction", "zerooldstyle", "oneoldstyle", "twooldstyle", "threeoldstyle", "fouroldstyle", "fiveoldstyle", "sixoldstyle", "sevenoldstyle", @@ -384,7 +384,7 @@ const FX_LPCSTR MacExpertEncodingNames[224] = { NULL, "lsuperior", "Ogoneksmall", "Brevesmall", "Macronsmall", "bsuperior", "nsuperior", "msuperior", "commasuperior", "periodsuperior", "Dotaccentsmall", "Ringsmall", NULL, NULL, NULL, NULL, }; -const FX_LPCSTR PDFDocEncodingNames[232] = { +const FX_CHAR* const PDFDocEncodingNames[232] = { "breve", "caron", "circumflex", "dotaccent", "hungarumlaut", "ogonek", "ring", "tilde", "space", "exclam", "quotedbl", "numbersign", "dollar", "percent", "ampersand", "quotesingle", "parenleft", "parenright", "asterisk", "plus", "comma", "hyphen", "period", "slash", @@ -415,7 +415,7 @@ const FX_LPCSTR PDFDocEncodingNames[232] = { "eth", "ntilde", "ograve", "oacute", "ocircumflex", "otilde", "odieresis", "divide", "oslash", "ugrave", "uacute", "ucircumflex", "udieresis", "yacute", "thorn", "ydieresis", }; -const FX_LPCSTR AdobeSymbolEncodingNames[224] = { +const FX_CHAR* const AdobeSymbolEncodingNames[224] = { "space", "exclam", "universal", "numbersign", "existential", "percent", "ampersand", "suchthat", "parenleft", "parenright", "asteriskmath", "plus", "comma", "minus", "period", "slash", "zero", "one", "two", "three", "four", "five", "six", "seven", @@ -445,7 +445,7 @@ const FX_LPCSTR AdobeSymbolEncodingNames[224] = { NULL, "angleright", "integral", "integraltp", "integralex", "integralbt", "parenrighttp", "parenrightex", "parenrightbt", "bracketrighttp", "bracketrightex", "bracketrightbt", "bracerighttp", "bracerightmid", "bracerightbt", NULL, }; -const FX_LPCSTR ZapfEncodingNames[224] = { +const FX_CHAR* const ZapfEncodingNames[224] = { "space", "a1", "a2", "a202", "a3", "a4", "a5", "a119", "a118", "a117", "a11", "a12", "a13", "a14", "a15", "a16", "a105", "a17", "a18", "a19", "a20", "a21", "a22", "a23", diff --git a/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp b/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp index a6209cb536..bec2c90144 100644 --- a/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp +++ b/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp @@ -13,7 +13,7 @@ extern FX_DWORD FT_CharCodeFromUnicode(int encoding, FX_WCHAR unicode); extern short TT2PDF(int m, FXFT_Face face); extern FX_BOOL FT_UseTTCharmap(FXFT_Face face, int platform_id, int encoding_id); -extern FX_LPCSTR GetAdobeCharName(int iBaseEncoding, const CFX_ByteString* pCharNames, int charcode); +extern const FX_CHAR* GetAdobeCharName(int iBaseEncoding, const CFX_ByteString* pCharNames, int charcode); CPDF_CMapManager::CPDF_CMapManager() { m_bPrompted = FALSE; @@ -26,7 +26,7 @@ CPDF_CMapManager::~CPDF_CMapManager() CPDF_CMap* CPDF_CMapManager::GetPredefinedCMap(const CFX_ByteString& name, FX_BOOL bPromptCJK) { CPDF_CMap* pCMap; - if (m_CMaps.Lookup(name, (FX_LPVOID&)pCMap)) { + if (m_CMaps.Lookup(name, (void*&)pCMap)) { return pCMap; } pCMap = LoadPredefinedCMap(name, bPromptCJK); @@ -39,14 +39,14 @@ CPDF_CMap* CPDF_CMapManager::GetPredefinedCMap(const CFX_ByteString& name, FX_BO CPDF_CMap* CPDF_CMapManager::LoadPredefinedCMap(const CFX_ByteString& name, FX_BOOL bPromptCJK) { CPDF_CMap* pCMap = new CPDF_CMap; - FX_LPCSTR pname = name; + const FX_CHAR* pname = name; if (*pname == '/') { pname ++; } pCMap->LoadPredefined(this, pname, bPromptCJK); return pCMap; } -static const FX_LPCSTR g_CharsetNames[NUMBER_OF_CIDSETS] = {NULL, "GB1", "CNS1", "Japan1", "Korea1", "UCS" }; +static const FX_CHAR* const g_CharsetNames[NUMBER_OF_CIDSETS] = {NULL, "GB1", "CNS1", "Japan1", "Korea1", "UCS" }; static const int g_CharsetCPs[NUMBER_OF_CIDSETS] = {0, 936, 950, 932, 949, 1200 }; int _CharsetFromOrdering(const CFX_ByteString& Ordering) { @@ -66,7 +66,7 @@ void CPDF_CMapManager::DropAll(FX_BOOL bReload) while (pos) { CFX_ByteString name; CPDF_CMap* pCMap; - m_CMaps.GetNextAssoc(pos, name, (FX_LPVOID&)pCMap); + m_CMaps.GetNextAssoc(pos, name, (void*&)pCMap); if (pCMap == NULL) { continue; } @@ -347,7 +347,7 @@ const CPDF_PredefinedCMap g_PredefinedCMaps[] = { }; extern void FPDFAPI_FindEmbeddedCMap(const char* name, int charset, int coding, const FXCMAP_CMap*& pMap); extern FX_WORD FPDFAPI_CIDFromCharCode(const FXCMAP_CMap* pMap, FX_DWORD charcode); -FX_BOOL CPDF_CMap::LoadPredefined(CPDF_CMapManager* pMgr, FX_LPCSTR pName, FX_BOOL bPromptCJK) +FX_BOOL CPDF_CMap::LoadPredefined(CPDF_CMapManager* pMgr, const FX_CHAR* pName, FX_BOOL bPromptCJK) { m_PredefinedCMap = pName; if (m_PredefinedCMap == FX_BSTRC("Identity-H") || m_PredefinedCMap == FX_BSTRC("Identity-V")) { @@ -396,7 +396,7 @@ extern "C" { return (*(FX_DWORD*)data1) - (*(FX_DWORD*)data2); } }; -FX_BOOL CPDF_CMap::LoadEmbedded(FX_LPCBYTE pData, FX_DWORD size) +FX_BOOL CPDF_CMap::LoadEmbedded(const uint8_t* pData, FX_DWORD size) { m_pMapping = FX_Alloc(FX_WORD, 65536); CPDF_CMapParser parser; @@ -462,7 +462,7 @@ FX_WORD CPDF_CMap::CIDFromCharCode(FX_DWORD charcode) const } return (FX_WORD)CID; } -static int _CheckCodeRange(FX_LPBYTE codes, int size, _CMap_CodeRange* pRanges, int nRanges) +static int _CheckCodeRange(uint8_t* codes, int size, _CMap_CodeRange* pRanges, int nRanges) { int iSeg = nRanges - 1; while (iSeg >= 0) { @@ -491,26 +491,26 @@ static int _CheckCodeRange(FX_LPBYTE codes, int size, _CMap_CodeRange* pRanges, } return 0; } -FX_DWORD CPDF_CMap::GetNextChar(FX_LPCSTR pString, int nStrLen, int& offset) const +FX_DWORD CPDF_CMap::GetNextChar(const FX_CHAR* pString, int nStrLen, int& offset) const { switch (m_CodingScheme) { case OneByte: - return ((FX_LPBYTE)pString)[offset++]; + return ((uint8_t*)pString)[offset++]; case TwoBytes: offset += 2; - return ((FX_LPBYTE)pString)[offset - 2] * 256 + ((FX_LPBYTE)pString)[offset - 1]; + return ((uint8_t*)pString)[offset - 2] * 256 + ((uint8_t*)pString)[offset - 1]; case MixedTwoBytes: { - uint8_t byte1 = ((FX_LPBYTE)pString)[offset++]; + uint8_t byte1 = ((uint8_t*)pString)[offset++]; if (!m_pLeadingBytes[byte1]) { return byte1; } - uint8_t byte2 = ((FX_LPBYTE)pString)[offset++]; + uint8_t byte2 = ((uint8_t*)pString)[offset++]; return byte1 * 256 + byte2; } case MixedFourBytes: { uint8_t codes[4]; int char_size = 1; - codes[0] = ((FX_LPBYTE)pString)[offset++]; + codes[0] = ((uint8_t*)pString)[offset++]; _CMap_CodeRange* pRanges = (_CMap_CodeRange*)m_pLeadingBytes; while (1) { int ret = _CheckCodeRange(codes, char_size, pRanges, m_nCodeRanges); @@ -527,7 +527,7 @@ FX_DWORD CPDF_CMap::GetNextChar(FX_LPCSTR pString, int nStrLen, int& offset) con if (char_size == 4 || offset == nStrLen) { return 0; } - codes[char_size ++] = ((FX_LPBYTE)pString)[offset++]; + codes[char_size ++] = ((uint8_t*)pString)[offset++]; } break; } @@ -556,7 +556,7 @@ int CPDF_CMap::GetCharSize(FX_DWORD charcode) const } return 1; } -int CPDF_CMap::CountChar(FX_LPCSTR pString, int size) const +int CPDF_CMap::CountChar(const FX_CHAR* pString, int size) const { switch (m_CodingScheme) { case OneByte: @@ -567,7 +567,7 @@ int CPDF_CMap::CountChar(FX_LPCSTR pString, int size) const int count = 0; for (int i = 0; i < size; i ++) { count ++; - if (m_pLeadingBytes[((FX_LPBYTE)pString)[i]]) { + if (m_pLeadingBytes[((uint8_t*)pString)[i]]) { i ++; } } @@ -619,7 +619,7 @@ int _GetCharSize(FX_DWORD charcode, _CMap_CodeRange* pRanges, int iRangesSize) } return 1; } -int CPDF_CMap::AppendChar(FX_LPSTR str, FX_DWORD charcode) const +int CPDF_CMap::AppendChar(FX_CHAR* str, FX_DWORD charcode) const { switch (m_CodingScheme) { case OneByte: @@ -793,7 +793,7 @@ FX_WCHAR CPDF_CIDFont::_UnicodeFromCharCode(FX_DWORD charcode) const charcode = (charcode % 256) * 256 + (charcode / 256); charsize = 2; } - int ret = FXSYS_MultiByteToWideChar(g_CharsetCPs[m_pCMap->m_Coding], 0, (FX_LPCSTR)&charcode, charsize, &unicode, 1); + int ret = FXSYS_MultiByteToWideChar(g_CharsetCPs[m_pCMap->m_Coding], 0, (const FX_CHAR*)&charcode, charsize, &unicode, 1); if (ret != 1) { return 0; } @@ -1056,7 +1056,7 @@ void CPDF_CIDFont::GetCharBBox(FX_DWORD charcode, FX_RECT& rect, int level) } if (m_pFontFile == NULL && m_Charset == CIDSET_JAPAN1) { FX_WORD CID = CIDFromCharCode(charcode); - FX_LPCBYTE pTransform = GetCIDTransform(CID); + const uint8_t* pTransform = GetCIDTransform(CID); if (pTransform && !bVert) { CFX_AffineMatrix matrix(_CIDTransformToFloat(pTransform[0]), _CIDTransformToFloat(pTransform[1]), _CIDTransformToFloat(pTransform[2]), _CIDTransformToFloat(pTransform[3]), @@ -1222,7 +1222,7 @@ int CPDF_CIDFont::GlyphFromCharCode(FX_DWORD charcode, FX_BOOL *pVertGlyph) } else if (bMacRoman) { iBaseEncoding = PDFFONT_ENCODING_MACROMAN; } - FX_LPCSTR name = GetAdobeCharName(iBaseEncoding, NULL, charcode); + const FX_CHAR* name = GetAdobeCharName(iBaseEncoding, NULL, charcode); if (name == NULL) { return charcode == 0 ? -1 : (int)charcode; } @@ -1314,10 +1314,10 @@ int CPDF_CIDFont::GlyphFromCharCode(FX_DWORD charcode, FX_BOOL *pVertGlyph) if (byte_pos + 2 > m_pCIDToGIDMap->GetSize()) { return -1; } - FX_LPCBYTE pdata = m_pCIDToGIDMap->GetData() + byte_pos; + const uint8_t* pdata = m_pCIDToGIDMap->GetData() + byte_pos; return pdata[0] * 256 + pdata[1]; } -FX_DWORD CPDF_CIDFont::GetNextChar(FX_LPCSTR pString, int nStrLen, int& offset) const +FX_DWORD CPDF_CIDFont::GetNextChar(const FX_CHAR* pString, int nStrLen, int& offset) const { return m_pCMap->GetNextChar(pString, nStrLen, offset); } @@ -1325,11 +1325,11 @@ int CPDF_CIDFont::GetCharSize(FX_DWORD charcode) const { return m_pCMap->GetCharSize(charcode); } -int CPDF_CIDFont::CountChar(FX_LPCSTR pString, int size) const +int CPDF_CIDFont::CountChar(const FX_CHAR* pString, int size) const { return m_pCMap->CountChar(pString, size); } -int CPDF_CIDFont::AppendChar(FX_LPSTR str, FX_DWORD charcode) const +int CPDF_CIDFont::AppendChar(FX_CHAR* str, FX_DWORD charcode) const { return m_pCMap->AppendChar(str, charcode); } @@ -1579,7 +1579,7 @@ Japan1_VertCIDs[] = { {8818, 0, 129, 127, 0, 19, 114}, {8819, 0, 129, 127, 0, 218, 108}, }; -FX_LPCBYTE CPDF_CIDFont::GetCIDTransform(FX_WORD CID) const +const uint8_t* CPDF_CIDFont::GetCIDTransform(FX_WORD CID) const { if (m_Charset != CIDSET_JAPAN1 || m_pFontFile != NULL) { return NULL; diff --git a/core/src/fpdfapi/fpdf_font/ttgsubtable.cpp b/core/src/fpdfapi/fpdf_font/ttgsubtable.cpp index ab15c47cb3..b6b2f57c02 100644 --- a/core/src/fpdfapi/fpdf_font/ttgsubtable.cpp +++ b/core/src/fpdfapi/fpdf_font/ttgsubtable.cpp @@ -48,7 +48,7 @@ void CFX_GlyphMap::SetAt(int key, int value) } FX_BOOL CFX_GlyphMap::Lookup(int key, int &value) { - FX_LPVOID pResult = FXSYS_bsearch(&key, m_Buffer.GetBuffer(), m_Buffer.GetSize() / sizeof(_IntPair), + void* pResult = FXSYS_bsearch(&key, m_Buffer.GetBuffer(), m_Buffer.GetSize() / sizeof(_IntPair), sizeof(_IntPair), _CompareInt); if (pResult == NULL) { return FALSE; diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page.cpp index 82f90d17a6..046cebeb98 100644 --- a/core/src/fpdfapi/fpdf_page/fpdf_page.cpp +++ b/core/src/fpdfapi/fpdf_page/fpdf_page.cpp @@ -242,7 +242,7 @@ void CPDF_TextObject::SetSegments(const CFX_ByteString* pStrs, FX_FLOAT* pKernin m_pCharPos = FX_Alloc(FX_FLOAT, m_nChars - 1); int index = 0; for (int i = 0; i < nsegs; i ++) { - FX_LPCSTR segment = pStrs[i]; + const FX_CHAR* segment = pStrs[i]; int offset = 0, len = pStrs[i].GetLength(); while (offset < len) { m_pCharCodes[index++] = pFont->GetNextChar(segment, len, offset); diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp index ea61078209..1b989be040 100644 --- a/core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp +++ b/core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp @@ -125,7 +125,7 @@ FX_BOOL CPDF_DeviceCS::v_SetCMYK(FX_FLOAT* pBuf, FX_FLOAT c, FX_FLOAT m, FX_FLOA } return FALSE; } -static void ReverseRGB(FX_LPBYTE pDestBuf, FX_LPCBYTE pSrcBuf, int pixels) +static void ReverseRGB(uint8_t* pDestBuf, const uint8_t* pSrcBuf, int pixels) { if (pDestBuf == pSrcBuf) for (int i = 0; i < pixels; i ++) { @@ -142,7 +142,7 @@ static void ReverseRGB(FX_LPBYTE pDestBuf, FX_LPCBYTE pSrcBuf, int pixels) pSrcBuf += 3; } } -void CPDF_DeviceCS::TranslateImageLine(FX_LPBYTE pDestBuf, FX_LPCBYTE pSrcBuf, int pixels, int image_width, int image_height, FX_BOOL bTransMask) const +void CPDF_DeviceCS::TranslateImageLine(uint8_t* pDestBuf, const uint8_t* pSrcBuf, int pixels, int image_width, int image_height, FX_BOOL bTransMask) const { if (bTransMask && m_Family == PDFCS_DEVICECMYK) { for (int i = 0; i < pixels; i ++) { @@ -267,7 +267,7 @@ public: CPDF_CalGray(); virtual FX_BOOL v_Load(CPDF_Document* pDoc, CPDF_Array* pArray); virtual FX_BOOL GetRGB(FX_FLOAT* pBuf, FX_FLOAT& R, FX_FLOAT& G, FX_FLOAT& B) const; - virtual void TranslateImageLine(FX_LPBYTE pDestBuf, FX_LPCBYTE pSrcBuf, int pixels, int image_width, int image_height, FX_BOOL bTransMask = FALSE) const; + virtual void TranslateImageLine(uint8_t* pDestBuf, const uint8_t* pSrcBuf, int pixels, int image_width, int image_height, FX_BOOL bTransMask = FALSE) const; FX_BOOL SetRGB(FX_FLOAT* pBuf, FX_FLOAT R, FX_FLOAT G, FX_FLOAT B) const; FX_FLOAT m_WhitePoint[3]; FX_FLOAT m_BlackPoint[3]; @@ -310,7 +310,7 @@ FX_BOOL CPDF_CalGray::SetRGB(FX_FLOAT* pBuf, FX_FLOAT R, FX_FLOAT G, FX_FLOAT B) return FALSE; } } -void CPDF_CalGray::TranslateImageLine(FX_LPBYTE pDestBuf, FX_LPCBYTE pSrcBuf, int pixels, int image_width, int image_height, FX_BOOL bTransMask) const +void CPDF_CalGray::TranslateImageLine(uint8_t* pDestBuf, const uint8_t* pSrcBuf, int pixels, int image_width, int image_height, FX_BOOL bTransMask) const { for (int i = 0; i < pixels; i ++) { *pDestBuf ++ = pSrcBuf[i]; @@ -324,7 +324,7 @@ public: CPDF_CalRGB(); virtual FX_BOOL v_Load(CPDF_Document* pDoc, CPDF_Array* pArray); virtual FX_BOOL GetRGB(FX_FLOAT* pBuf, FX_FLOAT& R, FX_FLOAT& G, FX_FLOAT& B) const; - virtual void TranslateImageLine(FX_LPBYTE pDestBuf, FX_LPCBYTE pSrcBuf, int pixels, int image_width, int image_height, FX_BOOL bTransMask = FALSE) const; + virtual void TranslateImageLine(uint8_t* pDestBuf, const uint8_t* pSrcBuf, int pixels, int image_width, int image_height, FX_BOOL bTransMask = FALSE) const; FX_BOOL SetRGB(FX_FLOAT* pBuf, FX_FLOAT R, FX_FLOAT G, FX_FLOAT B) const; FX_FLOAT m_WhitePoint[3]; FX_FLOAT m_BlackPoint[3]; @@ -399,7 +399,7 @@ FX_BOOL CPDF_CalRGB::SetRGB(FX_FLOAT* pBuf, FX_FLOAT R, FX_FLOAT G, FX_FLOAT B) pBuf[2] = B; return TRUE; } -void CPDF_CalRGB::TranslateImageLine(FX_LPBYTE pDestBuf, FX_LPCBYTE pSrcBuf, int pixels, int image_width, int image_height, FX_BOOL bTransMask) const +void CPDF_CalRGB::TranslateImageLine(uint8_t* pDestBuf, const uint8_t* pSrcBuf, int pixels, int image_width, int image_height, FX_BOOL bTransMask) const { if (bTransMask) { FX_FLOAT Cal[3]; @@ -430,7 +430,7 @@ public: virtual void GetDefaultValue(int iComponent, FX_FLOAT& value, FX_FLOAT& min, FX_FLOAT& max) const; virtual FX_BOOL GetRGB(FX_FLOAT* pBuf, FX_FLOAT& R, FX_FLOAT& G, FX_FLOAT& B) const; FX_BOOL SetRGB(FX_FLOAT* pBuf, FX_FLOAT R, FX_FLOAT G, FX_FLOAT B) const; - virtual void TranslateImageLine(FX_LPBYTE pDestBuf, FX_LPCBYTE pSrcBuf, int pixels, int image_width, int image_height, FX_BOOL bTransMask = FALSE) const; + virtual void TranslateImageLine(uint8_t* pDestBuf, const uint8_t* pSrcBuf, int pixels, int image_width, int image_height, FX_BOOL bTransMask = FALSE) const; FX_FLOAT m_WhitePoint[3]; FX_FLOAT m_BlackPoint[3]; FX_FLOAT m_Ranges[4]; @@ -505,7 +505,7 @@ FX_BOOL CPDF_LabCS::SetRGB(FX_FLOAT* pBuf, FX_FLOAT R, FX_FLOAT G, FX_FLOAT B) c { return FALSE; } -void CPDF_LabCS::TranslateImageLine(FX_LPBYTE pDestBuf, FX_LPCBYTE pSrcBuf, int pixels, int image_width, int image_height, FX_BOOL bTransMask) const +void CPDF_LabCS::TranslateImageLine(uint8_t* pDestBuf, const uint8_t* pSrcBuf, int pixels, int image_width, int image_height, FX_BOOL bTransMask) const { for (int i = 0; i < pixels; i ++) { FX_FLOAT lab[3]; @@ -521,7 +521,7 @@ void CPDF_LabCS::TranslateImageLine(FX_LPBYTE pDestBuf, FX_LPCBYTE pSrcBuf, int pSrcBuf += 3; } } -CPDF_IccProfile::CPDF_IccProfile(FX_LPCBYTE pData, FX_DWORD dwSize): +CPDF_IccProfile::CPDF_IccProfile(const uint8_t* pData, FX_DWORD dwSize): m_bsRGB(FALSE), m_pTransform(NULL), m_nSrcComponents(0) @@ -555,11 +555,11 @@ public: FX_BOOL v_GetCMYK(FX_FLOAT* pBuf, FX_FLOAT& c, FX_FLOAT& m, FX_FLOAT& y, FX_FLOAT& k) const; FX_BOOL SetRGB(FX_FLOAT* pBuf, FX_FLOAT R, FX_FLOAT G, FX_FLOAT B) const; virtual void EnableStdConversion(FX_BOOL bEnabled); - virtual void TranslateImageLine(FX_LPBYTE pDestBuf, FX_LPCBYTE pSrcBuf, int pixels, int image_width, int image_height, FX_BOOL bTransMask = FALSE) const; + virtual void TranslateImageLine(uint8_t* pDestBuf, const uint8_t* pSrcBuf, int pixels, int image_width, int image_height, FX_BOOL bTransMask = FALSE) const; FX_FLOAT* m_pRanges; CPDF_IccProfile* m_pProfile; CPDF_ColorSpace* m_pAlterCS; - FX_LPBYTE m_pCache; + uint8_t* m_pCache; FX_BOOL m_bOwn; }; CPDF_ICCBasedCS::CPDF_ICCBasedCS() @@ -702,7 +702,7 @@ void CPDF_ICCBasedCS::EnableStdConversion(FX_BOOL bEnabled) m_pAlterCS->EnableStdConversion(bEnabled); } } -void CPDF_ICCBasedCS::TranslateImageLine(FX_LPBYTE pDestBuf, FX_LPCBYTE pSrcBuf, int pixels, int image_width, int image_height, FX_BOOL bTransMask) const +void CPDF_ICCBasedCS::TranslateImageLine(uint8_t* pDestBuf, const uint8_t* pSrcBuf, int pixels, int image_width, int image_height, FX_BOOL bTransMask) const { if (m_pProfile->m_bsRGB) { ReverseRGB(pDestBuf, pSrcBuf, pixels); @@ -716,8 +716,8 @@ void CPDF_ICCBasedCS::TranslateImageLine(FX_LPBYTE pDestBuf, FX_LPCBYTE pSrcBuf, } else { if (m_pCache == NULL) { ((CPDF_ICCBasedCS*)this)->m_pCache = FX_Alloc2D(uint8_t, nMaxColors, 3); - FX_LPBYTE temp_src = FX_Alloc2D(uint8_t, nMaxColors, m_nComponents); - FX_LPBYTE pSrc = temp_src; + uint8_t* temp_src = FX_Alloc2D(uint8_t, nMaxColors, m_nComponents); + uint8_t* pSrc = temp_src; for (int i = 0; i < nMaxColors; i ++) { FX_DWORD color = i; FX_DWORD order = nMaxColors / 52; @@ -839,7 +839,7 @@ FX_BOOL CPDF_IndexedCS::GetRGB(FX_FLOAT* pBuf, FX_FLOAT& R, FX_FLOAT& G, FX_FLOA } CFX_FixedBufGrow<FX_FLOAT, 16> Comps(m_nBaseComponents); FX_FLOAT* comps = Comps; - FX_LPCBYTE pTable = m_Table; + const uint8_t* pTable = m_Table; for (int i = 0; i < m_nBaseComponents; i ++) { comps[i] = m_pCompMinMax[i * 2] + m_pCompMinMax[i * 2 + 1] * pTable[index * m_nBaseComponents + i] / 255; } @@ -1257,7 +1257,7 @@ int CPDF_ColorSpace::GetMaxIndex() const CPDF_IndexedCS* pCS = (CPDF_IndexedCS*)this; return pCS->m_MaxIndex; } -void CPDF_ColorSpace::TranslateImageLine(FX_LPBYTE dest_buf, FX_LPCBYTE src_buf, int pixels, int image_width, int image_height, FX_BOOL bTransMask) const +void CPDF_ColorSpace::TranslateImageLine(uint8_t* dest_buf, const uint8_t* src_buf, int pixels, int image_width, int image_height, FX_BOOL bTransMask) const { CFX_FixedBufGrow<FX_FLOAT, 16> srcbuf(m_nComponents); FX_FLOAT* src = srcbuf; diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_func.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_func.cpp index dadf6bf9cb..2cfb02869c 100644 --- a/core/src/fpdfapi/fpdf_page/fpdf_page_func.cpp +++ b/core/src/fpdfapi/fpdf_page/fpdf_page_func.cpp @@ -64,10 +64,10 @@ CPDF_PSProc::~CPDF_PSProc() { int size = m_Operators.GetSize(); for (int i = 0; i < size; i ++) { - if (m_Operators[i] == (FX_LPVOID)PSOP_PROC) { + if (m_Operators[i] == (void*)PSOP_PROC) { delete (CPDF_PSProc*)m_Operators[i + 1]; i ++; - } else if (m_Operators[i] == (FX_LPVOID)PSOP_CONST) { + } else if (m_Operators[i] == (void*)PSOP_CONST) { FX_Free((FX_FLOAT*)m_Operators[i + 1]); i ++; } @@ -84,15 +84,15 @@ FX_BOOL CPDF_PSProc::Execute(CPDF_PSEngine* pEngine) pEngine->Push(*(FX_FLOAT*)m_Operators[i + 1]); i ++; } else if (op == PSOP_IF) { - if (i < 2 || m_Operators[i - 2] != (FX_LPVOID)PSOP_PROC) { + if (i < 2 || m_Operators[i - 2] != (void*)PSOP_PROC) { return FALSE; } if ((int)pEngine->Pop()) { ((CPDF_PSProc*)m_Operators[i - 1])->Execute(pEngine); } } else if (op == PSOP_IFELSE) { - if (i < 4 || m_Operators[i - 2] != (FX_LPVOID)PSOP_PROC || - m_Operators[i - 4] != (FX_LPVOID)PSOP_PROC) { + if (i < 4 || m_Operators[i - 2] != (void*)PSOP_PROC || + m_Operators[i - 4] != (void*)PSOP_PROC) { return FALSE; } if ((int)pEngine->Pop()) { @@ -147,7 +147,7 @@ const struct _PDF_PSOpName { }; FX_BOOL CPDF_PSEngine::Parse(const FX_CHAR* string, int size) { - CPDF_SimpleParser parser((FX_LPBYTE)string, size); + CPDF_SimpleParser parser((uint8_t*)string, size); CFX_ByteStringC word = parser.GetWord(); if (word != FX_BSTRC("{")) { return FALSE; @@ -166,7 +166,7 @@ FX_BOOL CPDF_PSProc::Parse(CPDF_SimpleParser& parser) } if (word == FX_BSTRC("{")) { CPDF_PSProc* pProc = new CPDF_PSProc; - m_Operators.Add((FX_LPVOID)PSOP_PROC); + m_Operators.Add((void*)PSOP_PROC); m_Operators.Add(pProc); if (!pProc->Parse(parser)) { return FALSE; @@ -175,7 +175,7 @@ FX_BOOL CPDF_PSProc::Parse(CPDF_SimpleParser& parser) int i = 0; while (_PDF_PSOpNames[i].name) { if (word == CFX_ByteStringC(_PDF_PSOpNames[i].name)) { - m_Operators.Add((FX_LPVOID)_PDF_PSOpNames[i].op); + m_Operators.Add((void*)_PDF_PSOpNames[i].op); break; } i ++; @@ -183,7 +183,7 @@ FX_BOOL CPDF_PSProc::Parse(CPDF_SimpleParser& parser) if (_PDF_PSOpNames[i].name == NULL) { FX_FLOAT* pd = FX_Alloc(FX_FLOAT, 1); *pd = FX_atof(word); - m_Operators.Add((FX_LPVOID)PSOP_CONST); + m_Operators.Add((void*)PSOP_CONST); m_Operators.Add(pd); } } @@ -424,7 +424,7 @@ static FX_FLOAT PDF_Interpolate(FX_FLOAT x, FX_FLOAT xmin, FX_FLOAT xmax, FX_FLO { return ((x - xmin) * (ymax - ymin) / (xmax - xmin)) + ymin; } -static FX_DWORD _GetBits32(FX_LPCBYTE pData, int bitpos, int nbits) +static FX_DWORD _GetBits32(const uint8_t* pData, int bitpos, int nbits) { int result = 0; for (int i = 0; i < nbits; i ++) @@ -561,7 +561,7 @@ FX_BOOL CPDF_SampledFunc::v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const if (!bitpos.IsValid()) { return FALSE; } - FX_LPCBYTE pSampleData = m_pSampleStream->GetData(); + const uint8_t* pSampleData = m_pSampleStream->GetData(); if (pSampleData == NULL) { return FALSE; } diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp index bb4b9dee23..3ce4baf20c 100644 --- a/core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp +++ b/core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp @@ -349,7 +349,7 @@ FX_FLOAT CPDF_TextState::GetShearAngle() const CPDF_GeneralStateData::CPDF_GeneralStateData() { FXSYS_memset32(this, 0, sizeof(CPDF_GeneralStateData)); - FXSYS_strcpy((FX_LPSTR)m_BlendMode, "Normal"); + FXSYS_strcpy((FX_CHAR*)m_BlendMode, "Normal"); m_StrokeAlpha = 1.0f; m_FillAlpha = 1.0f; m_Flatness = 1.0f; diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp index a92e9e783d..d898feecf4 100644 --- a/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp +++ b/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp @@ -113,7 +113,7 @@ int CPDF_StreamContentParser::GetNextParamPos() m_ParamCount ++; return index; } -void CPDF_StreamContentParser::AddNameParam(FX_LPCSTR name, int len) +void CPDF_StreamContentParser::AddNameParam(const FX_CHAR* name, int len) { int index = GetNextParamPos(); if (len > 32) { @@ -131,7 +131,7 @@ void CPDF_StreamContentParser::AddNameParam(FX_LPCSTR name, int len) } } } -void CPDF_StreamContentParser::AddNumberParam(FX_LPCSTR str, int len) +void CPDF_StreamContentParser::AddNumberParam(const FX_CHAR* str, int len) { int index = GetNextParamPos(); m_ParamBuf1[index].m_Type = PDFOBJ_NUMBER; @@ -321,7 +321,7 @@ const struct _OpCode { {FXBSTR_ID('w', 0, 0, 0), &CPDF_StreamContentParser::Handle_SetLineWidth}, {FXBSTR_ID('y', 0, 0, 0), &CPDF_StreamContentParser::Handle_CurveTo_13}, }; -FX_BOOL CPDF_StreamContentParser::OnOperator(FX_LPCSTR op) +FX_BOOL CPDF_StreamContentParser::OnOperator(const FX_CHAR* op) { int i = 0; FX_DWORD opid = 0; @@ -410,7 +410,7 @@ void CPDF_StreamContentParser::Handle_BeginMarkedContent() m_CurContentMark.GetModify()->AddMark(tag, NULL, FALSE); } struct _FX_BSTR { - FX_LPCSTR m_Ptr; + const FX_CHAR* m_Ptr; int m_Size; }; #define _FX_BSTRC(str) {str, sizeof(str)-1} @@ -1550,7 +1550,7 @@ CFX_ByteString _FPDF_ByteStringFromHex(CFX_BinaryBuf& src_buf) CFX_ByteTextBuf buf; FX_BOOL bFirst = TRUE; int code = 0; - FX_LPCBYTE str = src_buf.GetBuffer(); + const uint8_t* str = src_buf.GetBuffer(); FX_DWORD size = src_buf.GetSize(); for (FX_DWORD i = 0; i < size; i ++) { uint8_t ch = str[i]; diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp index bc2138e19e..ec2b69f70b 100644 --- a/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp +++ b/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp @@ -9,7 +9,7 @@ #include "../../../include/fxcodec/fx_codec.h" #include "pageint.h" #include <limits.h> -extern const FX_LPCSTR _PDF_OpCharType = +const FX_CHAR* const _PDF_OpCharType = "IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII" "IIVIIIIVIIVIIIIIVVIIIIIIIIIIIIII" "IIVVVVVVIVVVVVVIVVVVVIIVVIIIIIII" @@ -18,7 +18,7 @@ extern const FX_LPCSTR _PDF_OpCharType = "IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII" "IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII" "IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII"; -FX_BOOL _PDF_HasInvalidOpChar(FX_LPCSTR op) +FX_BOOL _PDF_HasInvalidOpChar(const FX_CHAR* op) { if(!op) { return FALSE; @@ -41,7 +41,7 @@ class CPDF_StreamParserAutoClearer { private: CPDF_StreamParser** scoped_variable_; }; -FX_DWORD CPDF_StreamContentParser::Parse(FX_LPCBYTE pData, FX_DWORD dwSize, FX_DWORD max_cost) +FX_DWORD CPDF_StreamContentParser::Parse(const uint8_t* pData, FX_DWORD dwSize, FX_DWORD max_cost) { if (m_Level > _FPDF_MAX_FORM_LEVEL_) { return dwSize; @@ -71,7 +71,7 @@ FX_DWORD CPDF_StreamContentParser::Parse(FX_LPCBYTE pData, FX_DWORD dwSize, FX_D AddNumberParam((char*)syntax.GetWordBuf(), syntax.GetWordSize()); break; case CPDF_StreamParser::Name: - AddNameParam((FX_LPCSTR)syntax.GetWordBuf() + 1, syntax.GetWordSize() - 1); + AddNameParam((const FX_CHAR*)syntax.GetWordBuf() + 1, syntax.GetWordSize() - 1); break; default: AddObjectParam(syntax.GetObject()); @@ -97,7 +97,7 @@ void CPDF_StreamContentParser::Handle_BeginImage() if (type != CPDF_StreamParser::Name) { break; } - CFX_ByteString key((FX_LPCSTR)m_pSyntax->GetWordBuf() + 1, m_pSyntax->GetWordSize() - 1); + CFX_ByteString key((const FX_CHAR*)m_pSyntax->GetWordBuf() + 1, m_pSyntax->GetWordSize() - 1); CPDF_Object* pObj = m_pSyntax->ReadNextObject(); if (!key.IsEmpty()) { pDict->SetAt(key, pObj, m_pDocument); @@ -248,7 +248,7 @@ CPDF_StreamParser::~CPDF_StreamParser() m_pLastObj->Release(); } } -FX_DWORD _DecodeAllScanlines(ICodec_ScanlineDecoder* pDecoder, FX_LPBYTE& dest_buf, FX_DWORD& dest_size) +FX_DWORD _DecodeAllScanlines(ICodec_ScanlineDecoder* pDecoder, uint8_t*& dest_buf, FX_DWORD& dest_size) { if (pDecoder == NULL) { return (FX_DWORD) - 1; @@ -265,7 +265,7 @@ FX_DWORD _DecodeAllScanlines(ICodec_ScanlineDecoder* pDecoder, FX_LPBYTE& dest_b dest_buf = FX_Alloc2D(uint8_t, pitch, height); dest_size = pitch * height; // Safe since checked alloc returned. for (int row = 0; row < height; row ++) { - FX_LPBYTE pLine = pDecoder->GetScanline(row); + uint8_t* pLine = pDecoder->GetScanline(row); if (pLine == NULL) { break; } @@ -275,15 +275,15 @@ FX_DWORD _DecodeAllScanlines(ICodec_ScanlineDecoder* pDecoder, FX_LPBYTE& dest_b delete pDecoder; return srcoff; } -ICodec_ScanlineDecoder* FPDFAPI_CreateFaxDecoder(FX_LPCBYTE src_buf, FX_DWORD src_size, int width, int height, +ICodec_ScanlineDecoder* FPDFAPI_CreateFaxDecoder(const uint8_t* src_buf, FX_DWORD src_size, int width, int height, const CPDF_Dictionary* pParams); -FX_DWORD _A85Decode(const uint8_t* src_buf, FX_DWORD src_size, FX_LPBYTE& dest_buf, FX_DWORD& dest_size); -FX_DWORD _HexDecode(const uint8_t* src_buf, FX_DWORD src_size, FX_LPBYTE& dest_buf, FX_DWORD& dest_size); +FX_DWORD _A85Decode(const uint8_t* src_buf, FX_DWORD src_size, uint8_t*& dest_buf, FX_DWORD& dest_size); +FX_DWORD _HexDecode(const uint8_t* src_buf, FX_DWORD src_size, uint8_t*& dest_buf, FX_DWORD& dest_size); FX_DWORD FPDFAPI_FlateOrLZWDecode(FX_BOOL bLZW, const uint8_t* src_buf, FX_DWORD src_size, CPDF_Dictionary* pParams, - FX_DWORD estimated_size, FX_LPBYTE& dest_buf, FX_DWORD& dest_size); + FX_DWORD estimated_size, uint8_t*& dest_buf, FX_DWORD& dest_size); FX_DWORD PDF_DecodeInlineStream(const uint8_t* src_buf, FX_DWORD limit, int width, int height, CFX_ByteString& decoder, - CPDF_Dictionary* pParam, FX_LPBYTE& dest_buf, FX_DWORD& dest_size) + CPDF_Dictionary* pParam, uint8_t*& dest_buf, FX_DWORD& dest_size) { if (decoder == FX_BSTRC("CCITTFaxDecode") || decoder == FX_BSTRC("CCF")) { ICodec_ScanlineDecoder* pDecoder = FPDFAPI_CreateFaxDecoder(src_buf, limit, width, height, pParam); @@ -367,7 +367,7 @@ CPDF_Stream* CPDF_StreamParser::ReadInlineStream(CPDF_Document* pDoc, CPDF_Dicti return NULL; } OrigSize *= height; - FX_LPBYTE pData = NULL; + uint8_t* pData = NULL; FX_DWORD dwStreamSize; if (Decoder.IsEmpty()) { if (OrigSize > m_Size - m_Pos) { @@ -1026,7 +1026,7 @@ void CPDF_ContentParser::Start(CPDF_Form* pForm, CPDF_AllStates* pGraphicStates, } else { m_pSingleStream->LoadAllData(pForm->m_pFormStream, FALSE); } - m_pData = (FX_LPBYTE)m_pSingleStream->GetData(); + m_pData = (uint8_t*)m_pSingleStream->GetData(); m_Size = m_pSingleStream->GetSize(); m_Status = ToBeContinued; m_InternalStage = PAGEPARSE_STAGE_PARSE; @@ -1060,7 +1060,7 @@ void CPDF_ContentParser::Continue(IFX_Pause* pPause) FX_Free(m_pStreamArray); m_pStreamArray = NULL; } else { - m_pData = (FX_LPBYTE)m_pSingleStream->GetData(); + m_pData = (uint8_t*)m_pSingleStream->GetData(); m_Size = m_pSingleStream->GetSize(); } m_InternalStage = PAGEPARSE_STAGE_PARSE; diff --git a/core/src/fpdfapi/fpdf_page/pageint.h b/core/src/fpdfapi/fpdf_page/pageint.h index 5c9312ea01..815e146ef8 100644 --- a/core/src/fpdfapi/fpdf_page/pageint.h +++ b/core/src/fpdfapi/fpdf_page/pageint.h @@ -25,7 +25,7 @@ public: typedef enum { EndOfData, Number, Keyword, Name, Others } SyntaxType; SyntaxType ParseNextElement(); - FX_LPBYTE GetWordBuf() + uint8_t* GetWordBuf() { return m_WordBuffer; } @@ -144,9 +144,9 @@ public: _ContentParam m_ParamBuf1[PARAM_BUF_SIZE]; FX_DWORD m_ParamStartPos; FX_DWORD m_ParamCount; - void AddNumberParam(FX_LPCSTR str, int len); + void AddNumberParam(const FX_CHAR* str, int len); void AddObjectParam(CPDF_Object* pObj); - void AddNameParam(FX_LPCSTR name, int size); + void AddNameParam(const FX_CHAR* name, int size); int GetNextParamPos(); void ClearAllParams(); CPDF_Object* GetObject(FX_DWORD index); @@ -157,7 +157,7 @@ public: { return (int32_t)(GetNumber(index)); } - FX_BOOL OnOperator(FX_LPCSTR op); + FX_BOOL OnOperator(const FX_CHAR* op); void BigCaseCaller(int index); FX_BOOL m_bAbort; CPDF_StreamParser* m_pSyntax; @@ -175,7 +175,7 @@ public: void ConvertUserSpace(FX_FLOAT& x, FX_FLOAT& y); void ConvertTextSpace(FX_FLOAT& x, FX_FLOAT& y); void OnChangeTextMatrix(); - FX_DWORD Parse(FX_LPCBYTE pData, FX_DWORD dwSize, FX_DWORD max_cost); + FX_DWORD Parse(const uint8_t* pData, FX_DWORD dwSize, FX_DWORD max_cost); void ParsePathObject(); int m_CompatCount; FX_PATHPOINT* m_pPathPoints; @@ -309,7 +309,7 @@ protected: CPDF_StreamAcc* m_pSingleStream; CPDF_StreamAcc** m_pStreamArray; FX_DWORD m_nStreams; - FX_LPBYTE m_pData; + uint8_t* m_pData; FX_DWORD m_Size; class CPDF_StreamContentParser* m_pParser; FX_DWORD m_CurrentOffset; @@ -429,11 +429,11 @@ protected: class CPDF_IccProfile { public: - CPDF_IccProfile(FX_LPCBYTE pData, FX_DWORD dwSize); + CPDF_IccProfile(const uint8_t* pData, FX_DWORD dwSize); ~CPDF_IccProfile(); int32_t GetComponents() const { return m_nSrcComponents; } FX_BOOL m_bsRGB; - FX_LPVOID m_pTransform; + void* m_pTransform; private: int32_t m_nSrcComponents; }; @@ -445,7 +445,7 @@ public: FX_BOOL SetRGB(FX_FLOAT* pBuf, FX_FLOAT R, FX_FLOAT G, FX_FLOAT B) const; FX_BOOL v_GetCMYK(FX_FLOAT* pBuf, FX_FLOAT& c, FX_FLOAT& m, FX_FLOAT& y, FX_FLOAT& k) const; FX_BOOL v_SetCMYK(FX_FLOAT* pBuf, FX_FLOAT c, FX_FLOAT m, FX_FLOAT y, FX_FLOAT k) const; - virtual void TranslateImageLine(FX_LPBYTE pDestBuf, FX_LPCBYTE pSrcBuf, int pixels, int image_width, int image_height, FX_BOOL bTransMask = FALSE) const; + virtual void TranslateImageLine(uint8_t* pDestBuf, const uint8_t* pSrcBuf, int pixels, int image_width, int image_height, FX_BOOL bTransMask = FALSE) const; }; class CPDF_PatternCS : public CPDF_ColorSpace { @@ -470,7 +470,7 @@ public: int m_nIndex; }; ~CPDF_ResourceNaming(); - CFX_ByteString GetName(const CPDF_Dictionary* pResList, FX_LPCSTR szType); + CFX_ByteString GetName(const CPDF_Dictionary* pResList, const FX_CHAR* szType); protected: CFX_MapByteStringToPtr m_NamingCache; }; diff --git a/core/src/fpdfapi/fpdf_parser/filters_int.h b/core/src/fpdfapi/fpdf_parser/filters_int.h index 6652cc0ccc..38dcb171f5 100644 --- a/core/src/fpdfapi/fpdf_parser/filters_int.h +++ b/core/src/fpdfapi/fpdf_parser/filters_int.h @@ -12,10 +12,10 @@ class CPDF_DecryptFilter : public CFX_DataFilter public: CPDF_DecryptFilter(CPDF_CryptoHandler* pCryptoHandler, FX_DWORD objnum, FX_DWORD gennum); virtual ~CPDF_DecryptFilter(); - virtual void v_FilterIn(FX_LPCBYTE src_buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf); + virtual void v_FilterIn(const uint8_t* src_buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf); virtual void v_FilterFinish(CFX_BinaryBuf& dest_buf); CPDF_CryptoHandler* m_pCryptoHandler; - FX_LPVOID m_pContext; + void* m_pContext; FX_DWORD m_ObjNum, m_GenNum; }; class CPDF_FlateFilter : public CFX_DataFilter @@ -23,7 +23,7 @@ class CPDF_FlateFilter : public CFX_DataFilter public: CPDF_FlateFilter(); virtual ~CPDF_FlateFilter(); - virtual void v_FilterIn(FX_LPCBYTE src_buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf); + virtual void v_FilterIn(const uint8_t* src_buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf); virtual void v_FilterFinish(CFX_BinaryBuf& dest_buf) {} void* m_pContext; uint8_t m_DestBuffer[FPDF_FILTER_BUFFER_SIZE]; @@ -33,7 +33,7 @@ class CPDF_LzwFilter : public CFX_DataFilter public: CPDF_LzwFilter(FX_BOOL bEarlyChange); virtual ~CPDF_LzwFilter() {} - virtual void v_FilterIn(FX_LPCBYTE src_buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf); + virtual void v_FilterIn(const uint8_t* src_buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf); virtual void v_FilterFinish(CFX_BinaryBuf& dest_buf) {} FX_BOOL m_bEarlyChange; FX_DWORD m_CodeArray[5021]; @@ -52,11 +52,12 @@ class CPDF_PredictorFilter : public CFX_DataFilter public: CPDF_PredictorFilter(int predictor, int colors, int bpc, int cols); virtual ~CPDF_PredictorFilter(); - virtual void v_FilterIn(FX_LPCBYTE src_buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf); + virtual void v_FilterIn(const uint8_t* src_buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf); virtual void v_FilterFinish(CFX_BinaryBuf& dest_buf) {} FX_BOOL m_bTiff; FX_DWORD m_Pitch, m_Bpp; - FX_LPBYTE m_pRefLine, m_pCurLine; + uint8_t* m_pRefLine; + uint8_t* m_pCurLine; FX_DWORD m_iLine, m_LineInSize; }; class CPDF_AsciiHexFilter : public CFX_DataFilter @@ -64,7 +65,7 @@ class CPDF_AsciiHexFilter : public CFX_DataFilter public: CPDF_AsciiHexFilter(); virtual ~CPDF_AsciiHexFilter() {} - virtual void v_FilterIn(FX_LPCBYTE src_buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf); + virtual void v_FilterIn(const uint8_t* src_buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf); virtual void v_FilterFinish(CFX_BinaryBuf& dest_buf) {} int m_State; int m_FirstDigit; @@ -74,7 +75,7 @@ class CPDF_Ascii85Filter : public CFX_DataFilter public: CPDF_Ascii85Filter(); virtual ~CPDF_Ascii85Filter() {} - virtual void v_FilterIn(FX_LPCBYTE src_buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf); + virtual void v_FilterIn(const uint8_t* src_buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf); virtual void v_FilterFinish(CFX_BinaryBuf& dest_buf) {} int m_State; int m_CharCount; @@ -85,7 +86,7 @@ class CPDF_RunLenFilter : public CFX_DataFilter public: CPDF_RunLenFilter(); virtual ~CPDF_RunLenFilter() {} - virtual void v_FilterIn(FX_LPCBYTE src_buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf); + virtual void v_FilterIn(const uint8_t* src_buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf); virtual void v_FilterFinish(CFX_BinaryBuf& dest_buf) {} int m_State; FX_DWORD m_Count; @@ -95,11 +96,11 @@ class CPDF_JpegFilter : public CFX_DataFilter public: CPDF_JpegFilter(); virtual ~CPDF_JpegFilter(); - virtual void v_FilterIn(FX_LPCBYTE src_buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf); + virtual void v_FilterIn(const uint8_t* src_buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf); virtual void v_FilterFinish(CFX_BinaryBuf& dest_buf) {} void* m_pContext; CFX_BinaryBuf m_InputBuf; - FX_LPBYTE m_pScanline; + uint8_t* m_pScanline; int m_Pitch, m_Height, m_Width, m_nComps, m_iLine; FX_BOOL m_bGotHeader; }; @@ -109,16 +110,17 @@ public: CPDF_FaxFilter(); virtual ~CPDF_FaxFilter(); FX_BOOL Initialize(int Encoding, int bEndOfLine, int bByteAlign, int bBlack, int nRows, int nColumns); - virtual void v_FilterIn(FX_LPCBYTE src_buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf); + virtual void v_FilterIn(const uint8_t* src_buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf); virtual void v_FilterFinish(CFX_BinaryBuf& dest_buf); int m_Encoding, m_bEndOfLine, m_bByteAlign, m_bBlack; int m_nRows, m_nColumns, m_Pitch, m_iRow; - FX_LPBYTE m_pScanlineBuf, m_pRefBuf; + uint8_t* m_pScanlineBuf; + uint8_t* m_pRefBuf; CFX_BinaryBuf m_InputBuf; int m_InputBitPos; - void ProcessData(FX_LPCBYTE src_buf, FX_DWORD src_size, int& bitpos, FX_BOOL bFinish, + void ProcessData(const uint8_t* src_buf, FX_DWORD src_size, int& bitpos, FX_BOOL bFinish, CFX_BinaryBuf& dest_buf); - FX_BOOL ReadLine(FX_LPCBYTE src_buf, int bitsize, int& bitpos); + FX_BOOL ReadLine(const uint8_t* src_buf, int bitsize, int& bitpos); }; #endif // CORE_SRC_FPDFAPI_FPDF_PARSER_FILTERS_INT_H_ diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp index b1fde0be71..bb490636a9 100644 --- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp +++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp @@ -9,7 +9,7 @@ #include "../../../include/fxcodec/fx_codec.h" #include <limits.h> #define _STREAM_MAX_SIZE_ 20 * 1024 * 1024 -FX_DWORD _A85Decode(const uint8_t* src_buf, FX_DWORD src_size, FX_LPBYTE& dest_buf, FX_DWORD& dest_size) +FX_DWORD _A85Decode(const uint8_t* src_buf, FX_DWORD src_size, uint8_t*& dest_buf, FX_DWORD& dest_size) { dest_size = 0; dest_buf = NULL; @@ -82,7 +82,7 @@ FX_DWORD _A85Decode(const uint8_t* src_buf, FX_DWORD src_size, FX_LPBYTE& dest_b } return pos; } -FX_DWORD _HexDecode(const uint8_t* src_buf, FX_DWORD src_size, FX_LPBYTE& dest_buf, FX_DWORD& dest_size) +FX_DWORD _HexDecode(const uint8_t* src_buf, FX_DWORD src_size, uint8_t*& dest_buf, FX_DWORD& dest_size) { FX_DWORD i; for (i = 0; i < src_size; i ++) @@ -122,7 +122,7 @@ FX_DWORD _HexDecode(const uint8_t* src_buf, FX_DWORD src_size, FX_LPBYTE& dest_b } return i; } -FX_DWORD RunLengthDecode(const uint8_t* src_buf, FX_DWORD src_size, FX_LPBYTE& dest_buf, FX_DWORD& dest_size) +FX_DWORD RunLengthDecode(const uint8_t* src_buf, FX_DWORD src_size, uint8_t*& dest_buf, FX_DWORD& dest_size) { FX_DWORD i = 0; FX_DWORD old; @@ -182,7 +182,7 @@ FX_DWORD RunLengthDecode(const uint8_t* src_buf, FX_DWORD src_size, FX_LPBYTE& d } return ret; } -ICodec_ScanlineDecoder* FPDFAPI_CreateFaxDecoder(FX_LPCBYTE src_buf, FX_DWORD src_size, int width, int height, +ICodec_ScanlineDecoder* FPDFAPI_CreateFaxDecoder(const uint8_t* src_buf, FX_DWORD src_size, int width, int height, const CPDF_Dictionary* pParams) { int K = 0; @@ -228,7 +228,7 @@ static FX_BOOL CheckFlateDecodeParams(int Colors, int BitsPerComponent, int Colu } return TRUE; } -ICodec_ScanlineDecoder* FPDFAPI_CreateFlateDecoder(FX_LPCBYTE src_buf, FX_DWORD src_size, int width, int height, +ICodec_ScanlineDecoder* FPDFAPI_CreateFlateDecoder(const uint8_t* src_buf, FX_DWORD src_size, int width, int height, int nComps, int bpc, const CPDF_Dictionary* pParams) { int predictor = 0; @@ -246,7 +246,7 @@ ICodec_ScanlineDecoder* FPDFAPI_CreateFlateDecoder(FX_LPCBYTE src_buf, FX_DWORD nComps, bpc, predictor, Colors, BitsPerComponent, Columns); } FX_DWORD FPDFAPI_FlateOrLZWDecode(FX_BOOL bLZW, const uint8_t* src_buf, FX_DWORD src_size, CPDF_Dictionary* pParams, - FX_DWORD estimated_size, FX_LPBYTE& dest_buf, FX_DWORD& dest_size) + FX_DWORD estimated_size, uint8_t*& dest_buf, FX_DWORD& dest_size) { int predictor = 0; FX_BOOL bEarlyChange = TRUE; @@ -265,8 +265,8 @@ FX_DWORD FPDFAPI_FlateOrLZWDecode(FX_BOOL bLZW, const uint8_t* src_buf, FX_DWORD bEarlyChange, predictor, Colors, BitsPerComponent, Columns, estimated_size, dest_buf, dest_size); } -FX_BOOL PDF_DataDecode(FX_LPCBYTE src_buf, FX_DWORD src_size, const CPDF_Dictionary* pDict, - FX_LPBYTE& dest_buf, FX_DWORD& dest_size, CFX_ByteString& ImageEncoding, +FX_BOOL PDF_DataDecode(const uint8_t* src_buf, FX_DWORD src_size, const CPDF_Dictionary* pDict, + uint8_t*& dest_buf, FX_DWORD& dest_size, CFX_ByteString& ImageEncoding, CPDF_Dictionary*& pImageParms, FX_DWORD last_estimated_size, FX_BOOL bImageAcc) { @@ -295,19 +295,19 @@ FX_BOOL PDF_DataDecode(FX_LPCBYTE src_buf, FX_DWORD src_size, const CPDF_Diction DecoderList.Add(pDecoder->GetConstString()); ParamList.Add(pParams ? pParams->GetDict() : NULL); } - FX_LPBYTE last_buf = (FX_LPBYTE)src_buf; + uint8_t* last_buf = (uint8_t*)src_buf; FX_DWORD last_size = src_size; for (int i = 0; i < DecoderList.GetSize(); i ++) { int estimated_size = i == DecoderList.GetSize() - 1 ? last_estimated_size : 0; CFX_ByteString decoder = DecoderList[i]; CPDF_Dictionary* pParam = (CPDF_Dictionary*)ParamList[i]; - FX_LPBYTE new_buf = NULL; + uint8_t* new_buf = NULL; FX_DWORD new_size = (FX_DWORD) - 1; int offset = -1; if (decoder == FX_BSTRC("FlateDecode") || decoder == FX_BSTRC("Fl")) { if (bImageAcc && i == DecoderList.GetSize() - 1) { ImageEncoding = FX_BSTRC("FlateDecode"); - dest_buf = (FX_LPBYTE)last_buf; + dest_buf = (uint8_t*)last_buf; dest_size = last_size; pImageParms = pParam; return TRUE; @@ -323,7 +323,7 @@ FX_BOOL PDF_DataDecode(FX_LPCBYTE src_buf, FX_DWORD src_size, const CPDF_Diction } else if (decoder == FX_BSTRC("RunLengthDecode") || decoder == FX_BSTRC("RL")) { if (bImageAcc && i == DecoderList.GetSize() - 1) { ImageEncoding = FX_BSTRC("RunLengthDecode"); - dest_buf = (FX_LPBYTE)last_buf; + dest_buf = (uint8_t*)last_buf; dest_size = last_size; pImageParms = pParam; return TRUE; @@ -339,7 +339,7 @@ FX_BOOL PDF_DataDecode(FX_LPCBYTE src_buf, FX_DWORD src_size, const CPDF_Diction } ImageEncoding = decoder; pImageParms = pParam; - dest_buf = (FX_LPBYTE)last_buf; + dest_buf = (uint8_t*)last_buf; dest_size = last_size; return TRUE; } @@ -386,7 +386,7 @@ extern const FX_WORD PDFDocEncoding[256] = { 0x00f0, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x00f7, 0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x00fd, 0x00fe, 0x00ff }; -CFX_WideString PDF_DecodeText(FX_LPCBYTE src_data, FX_DWORD src_len, CFX_CharMap* pCharMap) +CFX_WideString PDF_DecodeText(const uint8_t* src_data, FX_DWORD src_len, CFX_CharMap* pCharMap) { CFX_WideString result; if (src_len >= 2 && ((src_data[0] == 0xfe && src_data[1] == 0xff) || (src_data[0] == 0xff && src_data[1] == 0xfe))) { @@ -398,8 +398,8 @@ CFX_WideString PDF_DecodeText(FX_LPCBYTE src_data, FX_DWORD src_len, CFX_CharMap if (src_data[0] == 0xff) { bBE = !src_data[2]; } - FX_LPWSTR dest_buf = result.GetBuffer(max_chars); - FX_LPCBYTE uni_str = src_data + 2; + FX_WCHAR* dest_buf = result.GetBuffer(max_chars); + const uint8_t* uni_str = src_data + 2; int dest_pos = 0; for (FX_DWORD i = 0; i < max_chars * 2; i += 2) { FX_WORD unicode = bBE ? (uni_str[i] << 8 | uni_str[i + 1]) : (uni_str[i + 1] << 8 | uni_str[i]); @@ -418,24 +418,24 @@ CFX_WideString PDF_DecodeText(FX_LPCBYTE src_data, FX_DWORD src_len, CFX_CharMap } result.ReleaseBuffer(dest_pos); } else if (pCharMap == NULL) { - FX_LPWSTR dest_buf = result.GetBuffer(src_len); + FX_WCHAR* dest_buf = result.GetBuffer(src_len); for (FX_DWORD i = 0; i < src_len; i ++) { dest_buf[i] = PDFDocEncoding[src_data[i]]; } result.ReleaseBuffer(src_len); } else { - return (*pCharMap->m_GetWideString)(pCharMap, CFX_ByteString((FX_LPCSTR)src_data, src_len)); + return (*pCharMap->m_GetWideString)(pCharMap, CFX_ByteString((const FX_CHAR*)src_data, src_len)); } return result; } -CFX_ByteString PDF_EncodeText(FX_LPCWSTR pString, int len, CFX_CharMap* pCharMap) +CFX_ByteString PDF_EncodeText(const FX_WCHAR* pString, int len, CFX_CharMap* pCharMap) { if (len == -1) { len = FXSYS_wcslen(pString); } CFX_ByteString result; if (pCharMap == NULL) { - FX_LPSTR dest_buf1 = result.GetBuffer(len); + FX_CHAR* dest_buf1 = result.GetBuffer(len); int i; for (i = 0; i < len; i ++) { int code; @@ -462,7 +462,7 @@ CFX_ByteString PDF_EncodeText(FX_LPCWSTR pString, int len, CFX_CharMap* pCharMap int encLen = len * 2 + 2; - FX_LPBYTE dest_buf2 = (FX_LPBYTE)result.GetBuffer(encLen); + uint8_t* dest_buf2 = (uint8_t*)result.GetBuffer(encLen); dest_buf2[0] = 0xfe; dest_buf2[1] = 0xff; dest_buf2 += 2; @@ -503,22 +503,22 @@ CFX_ByteString PDF_EncodeString(const CFX_ByteString& src, FX_BOOL bHex) result.AppendChar(')'); return result.GetByteString(); } -void FlateEncode(const uint8_t* src_buf, FX_DWORD src_size, FX_LPBYTE& dest_buf, FX_DWORD& dest_size) +void FlateEncode(const uint8_t* src_buf, FX_DWORD src_size, uint8_t*& dest_buf, FX_DWORD& dest_size) { CCodec_ModuleMgr* pEncoders = CPDF_ModuleMgr::Get()->GetCodecModule(); if (pEncoders) { pEncoders->GetFlateModule()->Encode(src_buf, src_size, dest_buf, dest_size); } } -void FlateEncode(FX_LPCBYTE src_buf, FX_DWORD src_size, int predictor, int Colors, int BitsPerComponent, int Columns, - FX_LPBYTE& dest_buf, FX_DWORD& dest_size) +void FlateEncode(const uint8_t* src_buf, FX_DWORD src_size, int predictor, int Colors, int BitsPerComponent, int Columns, + uint8_t*& dest_buf, FX_DWORD& dest_size) { CCodec_ModuleMgr* pEncoders = CPDF_ModuleMgr::Get()->GetCodecModule(); if (pEncoders) { pEncoders->GetFlateModule()->Encode(src_buf, src_size, predictor, Colors, BitsPerComponent, Columns, dest_buf, dest_size); } } -FX_DWORD FlateDecode(const uint8_t* src_buf, FX_DWORD src_size, FX_LPBYTE& dest_buf, FX_DWORD& dest_size) +FX_DWORD FlateDecode(const uint8_t* src_buf, FX_DWORD src_size, uint8_t*& dest_buf, FX_DWORD& dest_size) { CCodec_ModuleMgr* pEncoders = CPDF_ModuleMgr::Get()->GetCodecModule(); if (pEncoders) { diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_document.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_document.cpp index f2643694ec..bd15c7587e 100644 --- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_document.cpp +++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_document.cpp @@ -343,7 +343,7 @@ FX_BOOL CPDF_Document::IsFormStream(FX_DWORD objnum, FX_BOOL& bForm) const { { CPDF_Object* pObj; - if (m_IndirectObjs.Lookup((FX_LPVOID)(uintptr_t)objnum, (FX_LPVOID&)pObj)) { + if (m_IndirectObjs.Lookup((void*)(uintptr_t)objnum, (void*&)pObj)) { bForm = pObj->GetType() == PDFOBJ_STREAM && ((CPDF_Stream*)pObj)->GetDict()->GetString(FX_BSTRC("Subtype")) == FX_BSTRC("Form"); return TRUE; diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_encrypt.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_encrypt.cpp index 4ca97fe9e8..973a14e33b 100644 --- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_encrypt.cpp +++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_encrypt.cpp @@ -13,8 +13,8 @@ const uint8_t defpasscode[32] = { 0x2e, 0x2e, 0x00, 0xb6, 0xd0, 0x68, 0x3e, 0x80, 0x2f, 0x0c, 0xa9, 0xfe, 0x64, 0x53, 0x69, 0x7a }; -void CalcEncryptKey(CPDF_Dictionary* pEncrypt, FX_LPCBYTE password, FX_DWORD pass_size, - FX_LPBYTE key, int keylen, FX_BOOL bIgnoreMeta, CPDF_Array* pIdArray) +void CalcEncryptKey(CPDF_Dictionary* pEncrypt, const uint8_t* password, FX_DWORD pass_size, + uint8_t* key, int keylen, FX_BOOL bIgnoreMeta, CPDF_Array* pIdArray) { int revision = pEncrypt->GetInteger(FX_BSTRC("R")); uint8_t passcode[32]; @@ -25,16 +25,16 @@ void CalcEncryptKey(CPDF_Dictionary* pEncrypt, FX_LPCBYTE password, FX_DWORD pas CRYPT_MD5Start(md5); CRYPT_MD5Update(md5, passcode, 32); CFX_ByteString okey = pEncrypt->GetString(FX_BSTRC("O")); - CRYPT_MD5Update(md5, (FX_LPBYTE)okey.c_str(), okey.GetLength()); + CRYPT_MD5Update(md5, (uint8_t*)okey.c_str(), okey.GetLength()); FX_DWORD perm = pEncrypt->GetInteger(FX_BSTRC("P")); - CRYPT_MD5Update(md5, (FX_LPBYTE)&perm, 4); + CRYPT_MD5Update(md5, (uint8_t*)&perm, 4); if (pIdArray) { CFX_ByteString id = pIdArray->GetString(0); - CRYPT_MD5Update(md5, (FX_LPBYTE)id.c_str(), id.GetLength()); + CRYPT_MD5Update(md5, (uint8_t*)id.c_str(), id.GetLength()); } if (!bIgnoreMeta && revision >= 3 && !pEncrypt->GetInteger(FX_BSTRC("EncryptMetadata"), 1)) { FX_DWORD tag = (FX_DWORD) - 1; - CRYPT_MD5Update(md5, (FX_LPBYTE)&tag, 4); + CRYPT_MD5Update(md5, (uint8_t*)&tag, 4); } uint8_t digest[16]; CRYPT_MD5Finish(md5, digest); @@ -189,7 +189,7 @@ FX_BOOL CPDF_StandardSecurityHandler::LoadDict(CPDF_Dictionary* pEncryptDict, FX return TRUE; return TRUE; } -FX_BOOL CPDF_StandardSecurityHandler::GetCryptInfo(int& cipher, FX_LPCBYTE& buffer, int& keylen) +FX_BOOL CPDF_StandardSecurityHandler::GetCryptInfo(int& cipher, const uint8_t*& buffer, int& keylen) { cipher = m_Cipher; buffer = m_EncryptKey; @@ -203,7 +203,7 @@ FX_BOOL CPDF_StandardSecurityHandler::GetCryptInfo(int& cipher, FX_LPCBYTE& buff | ( (uint64_t) (b)[(i) + 2] << 8 ) \ | ( (uint64_t) (b)[(i) + 3] )); \ } -int BigOrder64BitsMod3(FX_LPBYTE data) +int BigOrder64BitsMod3(uint8_t* data) { uint64_t ret = 0; for (int i = 0; i < 4; ++i) { @@ -215,7 +215,7 @@ int BigOrder64BitsMod3(FX_LPBYTE data) } return (int)ret; } -void Revision6_Hash(FX_LPCBYTE password, FX_DWORD size, FX_LPCBYTE salt, FX_LPCBYTE vector, FX_LPBYTE hash) +void Revision6_Hash(const uint8_t* password, FX_DWORD size, const uint8_t* salt, const uint8_t* vector, uint8_t* hash) { int iBlockSize = 32; uint8_t sha[128]; @@ -228,14 +228,14 @@ void Revision6_Hash(FX_LPCBYTE password, FX_DWORD size, FX_LPCBYTE salt, FX_LPCB uint8_t digest[32]; CRYPT_SHA256Finish(sha, digest); CFX_ByteTextBuf buf; - FX_LPBYTE input = digest; - FX_LPBYTE key = input; - FX_LPBYTE iv = input + 16; - FX_LPBYTE E = buf.GetBuffer(); + uint8_t* input = digest; + uint8_t* key = input; + uint8_t* iv = input + 16; + uint8_t* E = buf.GetBuffer(); int iBufLen = buf.GetLength(); CFX_ByteTextBuf interDigest; int i = 0; - FX_LPBYTE aes = FX_Alloc(uint8_t, 2048); + uint8_t* aes = FX_Alloc(uint8_t, 2048); while (i < 64 || i < E[iBufLen - 1] + 32) { int iRoundSize = size + iBlockSize; if (vector) { @@ -288,8 +288,8 @@ void Revision6_Hash(FX_LPCBYTE password, FX_DWORD size, FX_LPCBYTE salt, FX_LPCB FXSYS_memcpy32(hash, input, 32); } } -FX_BOOL CPDF_StandardSecurityHandler::AES256_CheckPassword(FX_LPCBYTE password, FX_DWORD size, - FX_BOOL bOwner, FX_LPBYTE key) +FX_BOOL CPDF_StandardSecurityHandler::AES256_CheckPassword(const uint8_t* password, FX_DWORD size, + FX_BOOL bOwner, uint8_t* key) { CFX_ByteString okey = m_pEncryptDict ? m_pEncryptDict->GetString(FX_BSTRC("O")) : CFX_ByteString(); if (okey.GetLength() < 48) { @@ -299,11 +299,11 @@ FX_BOOL CPDF_StandardSecurityHandler::AES256_CheckPassword(FX_LPCBYTE password, if (ukey.GetLength() < 48) { return FALSE; } - FX_LPCBYTE pkey = bOwner ? (FX_LPCBYTE)okey : (FX_LPCBYTE)ukey; + const uint8_t* pkey = bOwner ? (const uint8_t*)okey : (const uint8_t*)ukey; uint8_t sha[128]; uint8_t digest[32]; if (m_Revision >= 6) { - Revision6_Hash(password, size, (FX_LPCBYTE)pkey + 32, (bOwner ? (FX_LPCBYTE)ukey : NULL), digest); + Revision6_Hash(password, size, (const uint8_t*)pkey + 32, (bOwner ? (const uint8_t*)ukey : NULL), digest); } else { CRYPT_SHA256Start(sha); CRYPT_SHA256Update(sha, password, size); @@ -320,7 +320,7 @@ FX_BOOL CPDF_StandardSecurityHandler::AES256_CheckPassword(FX_LPCBYTE password, return TRUE; } if (m_Revision >= 6) { - Revision6_Hash(password, size, (FX_LPCBYTE)pkey + 40, (bOwner ? (FX_LPCBYTE)ukey : NULL), digest); + Revision6_Hash(password, size, (const uint8_t*)pkey + 40, (bOwner ? (const uint8_t*)ukey : NULL), digest); } else { CRYPT_SHA256Start(sha); CRYPT_SHA256Update(sha, password, size); @@ -352,7 +352,7 @@ FX_BOOL CPDF_StandardSecurityHandler::AES256_CheckPassword(FX_LPCBYTE password, if (copy_len > (FX_DWORD)perms.GetLength()) { copy_len = perms.GetLength(); } - FXSYS_memcpy32(perms_buf, (FX_LPCBYTE)perms, copy_len); + FXSYS_memcpy32(perms_buf, (const uint8_t*)perms, copy_len); uint8_t buf[16]; CRYPT_AESDecrypt(aes, buf, perms_buf, 16); FX_Free(aes); @@ -367,11 +367,11 @@ FX_BOOL CPDF_StandardSecurityHandler::AES256_CheckPassword(FX_LPCBYTE password, } return TRUE; } -int CPDF_StandardSecurityHandler::CheckPassword(FX_LPCBYTE password, FX_DWORD pass_size, FX_BOOL bOwner, FX_LPBYTE key) +int CPDF_StandardSecurityHandler::CheckPassword(const uint8_t* password, FX_DWORD pass_size, FX_BOOL bOwner, uint8_t* key) { return CheckPassword(password, pass_size, bOwner, key, m_KeyLen); } -int CPDF_StandardSecurityHandler::CheckPassword(FX_LPCBYTE password, FX_DWORD size, FX_BOOL bOwner, FX_LPBYTE key, int32_t key_len) +int CPDF_StandardSecurityHandler::CheckPassword(const uint8_t* password, FX_DWORD size, FX_BOOL bOwner, uint8_t* key, int32_t key_len) { if (m_Revision >= 5) { return AES256_CheckPassword(password, size, bOwner, key); @@ -385,8 +385,8 @@ int CPDF_StandardSecurityHandler::CheckPassword(FX_LPCBYTE password, FX_DWORD si } return CheckUserPassword(password, size, FALSE, key, key_len) || CheckUserPassword(password, size, TRUE, key, key_len); } -FX_BOOL CPDF_StandardSecurityHandler::CheckUserPassword(FX_LPCBYTE password, FX_DWORD pass_size, - FX_BOOL bIgnoreEncryptMeta, FX_LPBYTE key, int32_t key_len) +FX_BOOL CPDF_StandardSecurityHandler::CheckUserPassword(const uint8_t* password, FX_DWORD pass_size, + FX_BOOL bIgnoreEncryptMeta, uint8_t* key, int32_t key_len) { CalcEncryptKey(m_pEncryptDict, password, pass_size, key, key_len, bIgnoreEncryptMeta, m_pParser->GetIDArray()); @@ -419,21 +419,21 @@ FX_BOOL CPDF_StandardSecurityHandler::CheckUserPassword(FX_LPCBYTE password, FX_ CPDF_Array* pIdArray = m_pParser->GetIDArray(); if (pIdArray) { CFX_ByteString id = pIdArray->GetString(0); - CRYPT_MD5Update(md5, (FX_LPBYTE)id.c_str(), id.GetLength()); + CRYPT_MD5Update(md5, (uint8_t*)id.c_str(), id.GetLength()); } CRYPT_MD5Finish(md5, ukeybuf); return FXSYS_memcmp32(test, ukeybuf, 16) == 0; } - if (FXSYS_memcmp32((FX_LPVOID)ukey.c_str(), ukeybuf, 16) == 0) { + if (FXSYS_memcmp32((void*)ukey.c_str(), ukeybuf, 16) == 0) { return TRUE; } return FALSE; } -CFX_ByteString CPDF_StandardSecurityHandler::GetUserPassword(FX_LPCBYTE owner_pass, FX_DWORD pass_size) +CFX_ByteString CPDF_StandardSecurityHandler::GetUserPassword(const uint8_t* owner_pass, FX_DWORD pass_size) { return GetUserPassword(owner_pass, pass_size, m_KeyLen); } -CFX_ByteString CPDF_StandardSecurityHandler::GetUserPassword(FX_LPCBYTE owner_pass, FX_DWORD pass_size, int32_t key_len) +CFX_ByteString CPDF_StandardSecurityHandler::GetUserPassword(const uint8_t* owner_pass, FX_DWORD pass_size, int32_t key_len) { CFX_ByteString okey = m_pEncryptDict->GetString(FX_BSTRC("O")); uint8_t passcode[32]; @@ -480,8 +480,8 @@ CFX_ByteString CPDF_StandardSecurityHandler::GetUserPassword(FX_LPCBYTE owner_pa } return CFX_ByteString(okeybuf, len); } -FX_BOOL CPDF_StandardSecurityHandler::CheckOwnerPassword(FX_LPCBYTE password, FX_DWORD pass_size, - FX_LPBYTE key, int32_t key_len) +FX_BOOL CPDF_StandardSecurityHandler::CheckOwnerPassword(const uint8_t* password, FX_DWORD pass_size, + uint8_t* key, int32_t key_len) { CFX_ByteString user_pass = GetUserPassword(password, pass_size, key_len); if (CheckUserPassword(user_pass, user_pass.GetLength(), FALSE, key, key_len)) { @@ -498,8 +498,8 @@ CPDF_SecurityHandler* FPDF_CreateStandardSecurityHandler() return new CPDF_StandardSecurityHandler; } void CPDF_StandardSecurityHandler::OnCreate(CPDF_Dictionary* pEncryptDict, CPDF_Array* pIdArray, - FX_LPCBYTE user_pass, FX_DWORD user_size, - FX_LPCBYTE owner_pass, FX_DWORD owner_size, FX_BOOL bDefault, FX_DWORD type) + const uint8_t* user_pass, FX_DWORD user_size, + const uint8_t* owner_pass, FX_DWORD owner_size, FX_BOOL bDefault, FX_DWORD type) { int cipher = 0, key_len = 0; if (!LoadDict(pEncryptDict, type, cipher, key_len)) { @@ -554,7 +554,7 @@ void CPDF_StandardSecurityHandler::OnCreate(CPDF_Dictionary* pEncryptDict, CPDF_ } pEncryptDict->SetAtString(FX_BSTRC("O"), CFX_ByteString(passcode, 32)); } - CalcEncryptKey(m_pEncryptDict, (FX_LPBYTE)user_pass, user_size, m_EncryptKey, key_len, FALSE, pIdArray); + CalcEncryptKey(m_pEncryptDict, (uint8_t*)user_pass, user_size, m_EncryptKey, key_len, FALSE, pIdArray); if (m_Revision < 3) { uint8_t tempbuf[32]; FXSYS_memcpy32(tempbuf, defpasscode, 32); @@ -566,7 +566,7 @@ void CPDF_StandardSecurityHandler::OnCreate(CPDF_Dictionary* pEncryptDict, CPDF_ CRYPT_MD5Update(md5, defpasscode, 32); if (pIdArray) { CFX_ByteString id = pIdArray->GetString(0); - CRYPT_MD5Update(md5, (FX_LPBYTE)id.c_str(), id.GetLength()); + CRYPT_MD5Update(md5, (uint8_t*)id.c_str(), id.GetLength()); } uint8_t digest[32]; CRYPT_MD5Finish(md5, digest); @@ -583,16 +583,16 @@ void CPDF_StandardSecurityHandler::OnCreate(CPDF_Dictionary* pEncryptDict, CPDF_ } } void CPDF_StandardSecurityHandler::OnCreate(CPDF_Dictionary* pEncryptDict, CPDF_Array* pIdArray, - FX_LPCBYTE user_pass, FX_DWORD user_size, - FX_LPCBYTE owner_pass, FX_DWORD owner_size, FX_DWORD type) + const uint8_t* user_pass, FX_DWORD user_size, + const uint8_t* owner_pass, FX_DWORD owner_size, FX_DWORD type) { OnCreate(pEncryptDict, pIdArray, user_pass, user_size, owner_pass, owner_size, TRUE, type); } -void CPDF_StandardSecurityHandler::OnCreate(CPDF_Dictionary* pEncryptDict, CPDF_Array* pIdArray, FX_LPCBYTE user_pass, FX_DWORD user_size, FX_DWORD type) +void CPDF_StandardSecurityHandler::OnCreate(CPDF_Dictionary* pEncryptDict, CPDF_Array* pIdArray, const uint8_t* user_pass, FX_DWORD user_size, FX_DWORD type) { OnCreate(pEncryptDict, pIdArray, user_pass, user_size, NULL, 0, FALSE, type); } -void CPDF_StandardSecurityHandler::AES256_SetPassword(CPDF_Dictionary* pEncryptDict, FX_LPCBYTE password, FX_DWORD size, FX_BOOL bOwner, FX_LPCBYTE key) +void CPDF_StandardSecurityHandler::AES256_SetPassword(CPDF_Dictionary* pEncryptDict, const uint8_t* password, FX_DWORD size, FX_BOOL bOwner, const uint8_t* key) { uint8_t sha[128]; CRYPT_SHA1Start(sha); @@ -603,7 +603,7 @@ void CPDF_StandardSecurityHandler::AES256_SetPassword(CPDF_Dictionary* pEncryptD CFX_ByteString ukey = pEncryptDict->GetString(FX_BSTRC("U")); uint8_t digest1[48]; if (m_Revision >= 6) { - Revision6_Hash(password, size, digest, (bOwner ? (FX_LPCBYTE)ukey : NULL), digest1); + Revision6_Hash(password, size, digest, (bOwner ? (const uint8_t*)ukey : NULL), digest1); } else { CRYPT_SHA256Start(sha); CRYPT_SHA256Update(sha, password, size); @@ -616,7 +616,7 @@ void CPDF_StandardSecurityHandler::AES256_SetPassword(CPDF_Dictionary* pEncryptD FXSYS_memcpy32(digest1 + 32, digest, 16); pEncryptDict->SetAtString(bOwner ? FX_BSTRC("O") : FX_BSTRC("U"), CFX_ByteString(digest1, 48)); if (m_Revision >= 6) { - Revision6_Hash(password, size, digest + 8, (bOwner ? (FX_LPCBYTE)ukey : NULL), digest1); + Revision6_Hash(password, size, digest + 8, (bOwner ? (const uint8_t*)ukey : NULL), digest1); } else { CRYPT_SHA256Start(sha); CRYPT_SHA256Update(sha, password, size); @@ -636,7 +636,7 @@ void CPDF_StandardSecurityHandler::AES256_SetPassword(CPDF_Dictionary* pEncryptD pEncryptDict->SetAtString(bOwner ? FX_BSTRC("OE") : FX_BSTRC("UE"), CFX_ByteString(digest1, 32)); } void CPDF_StandardSecurityHandler::AES256_SetPerms(CPDF_Dictionary* pEncryptDict, FX_DWORD permissions, - FX_BOOL bEncryptMetadata, FX_LPCBYTE key) + FX_BOOL bEncryptMetadata, const uint8_t* key) { uint8_t buf[16]; buf[0] = (uint8_t)permissions; @@ -660,8 +660,8 @@ void CPDF_StandardSecurityHandler::AES256_SetPerms(CPDF_Dictionary* pEncryptDict FX_Free(aes); pEncryptDict->SetAtString(FX_BSTRC("Perms"), CFX_ByteString(buf1, 16)); } -void CPDF_StandardCryptoHandler::CryptBlock(FX_BOOL bEncrypt, FX_DWORD objnum, FX_DWORD gennum, FX_LPCBYTE src_buf, FX_DWORD src_size, - FX_LPBYTE dest_buf, FX_DWORD& dest_size) +void CPDF_StandardCryptoHandler::CryptBlock(FX_BOOL bEncrypt, FX_DWORD objnum, FX_DWORD gennum, const uint8_t* src_buf, FX_DWORD src_size, + uint8_t* dest_buf, FX_DWORD& dest_size) { if (m_Cipher == FXCIPHER_NONE) { FXSYS_memcpy32(dest_buf, src_buf, src_size); @@ -724,7 +724,7 @@ typedef struct _AESCryptContext { uint8_t m_Block[16]; FX_DWORD m_BlockOffset; } AESCryptContext; -FX_LPVOID CPDF_StandardCryptoHandler::CryptStart(FX_DWORD objnum, FX_DWORD gennum, FX_BOOL bEncrypt) +void* CPDF_StandardCryptoHandler::CryptStart(FX_DWORD objnum, FX_DWORD gennum, FX_BOOL bEncrypt) { if (m_Cipher == FXCIPHER_NONE) { return this; @@ -772,7 +772,7 @@ FX_LPVOID CPDF_StandardCryptoHandler::CryptStart(FX_DWORD objnum, FX_DWORD gennu CRYPT_ArcFourSetup(pContext, realkey, realkeylen); return pContext; } -FX_BOOL CPDF_StandardCryptoHandler::CryptStream(FX_LPVOID context, FX_LPCBYTE src_buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf, FX_BOOL bEncrypt) +FX_BOOL CPDF_StandardCryptoHandler::CryptStream(void* context, const uint8_t* src_buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf, FX_BOOL bEncrypt) { if (!context) { return FALSE; @@ -825,7 +825,7 @@ FX_BOOL CPDF_StandardCryptoHandler::CryptStream(FX_LPVOID context, FX_LPCBYTE sr } return TRUE; } -FX_BOOL CPDF_StandardCryptoHandler::CryptFinish(FX_LPVOID context, CFX_BinaryBuf& dest_buf, FX_BOOL bEncrypt) +FX_BOOL CPDF_StandardCryptoHandler::CryptFinish(void* context, CFX_BinaryBuf& dest_buf, FX_BOOL bEncrypt) { if (!context) { return FALSE; @@ -858,7 +858,7 @@ FX_BOOL CPDF_StandardCryptoHandler::CryptFinish(FX_LPVOID context, CFX_BinaryBuf FX_Free(pContext); return TRUE; } -FX_LPVOID CPDF_StandardCryptoHandler::DecryptStart(FX_DWORD objnum, FX_DWORD gennum) +void* CPDF_StandardCryptoHandler::DecryptStart(FX_DWORD objnum, FX_DWORD gennum) { return CryptStart(objnum, gennum, FALSE); } @@ -868,7 +868,7 @@ FX_DWORD CPDF_StandardCryptoHandler::DecryptGetSize(FX_DWORD src_size) } FX_BOOL CPDF_StandardCryptoHandler::Init(CPDF_Dictionary* pEncryptDict, CPDF_SecurityHandler* pSecurityHandler) { - FX_LPCBYTE key; + const uint8_t* key; if (!pSecurityHandler->GetCryptInfo(m_Cipher, key, m_KeyLen)) { return FALSE; } @@ -883,7 +883,7 @@ FX_BOOL CPDF_StandardCryptoHandler::Init(CPDF_Dictionary* pEncryptDict, CPDF_Sec } return TRUE; } -FX_BOOL CPDF_StandardCryptoHandler::Init(int cipher, FX_LPCBYTE key, int keylen) +FX_BOOL CPDF_StandardCryptoHandler::Init(int cipher, const uint8_t* key, int keylen) { if (cipher == FXCIPHER_AES) { switch(keylen) { @@ -915,24 +915,24 @@ FX_BOOL CPDF_StandardCryptoHandler::Init(int cipher, FX_LPCBYTE key, int keylen) } return TRUE; } -FX_BOOL CPDF_StandardCryptoHandler::DecryptStream(FX_LPVOID context, FX_LPCBYTE src_buf, FX_DWORD src_size, +FX_BOOL CPDF_StandardCryptoHandler::DecryptStream(void* context, const uint8_t* src_buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf) { return CryptStream(context, src_buf, src_size, dest_buf, FALSE); } -FX_BOOL CPDF_StandardCryptoHandler::DecryptFinish(FX_LPVOID context, CFX_BinaryBuf& dest_buf) +FX_BOOL CPDF_StandardCryptoHandler::DecryptFinish(void* context, CFX_BinaryBuf& dest_buf) { return CryptFinish(context, dest_buf, FALSE); } -FX_DWORD CPDF_StandardCryptoHandler::EncryptGetSize(FX_DWORD objnum, FX_DWORD version, FX_LPCBYTE src_buf, FX_DWORD src_size) +FX_DWORD CPDF_StandardCryptoHandler::EncryptGetSize(FX_DWORD objnum, FX_DWORD version, const uint8_t* src_buf, FX_DWORD src_size) { if (m_Cipher == FXCIPHER_AES) { return src_size + 32; } return src_size; } -FX_BOOL CPDF_StandardCryptoHandler::EncryptContent(FX_DWORD objnum, FX_DWORD gennum, FX_LPCBYTE src_buf, FX_DWORD src_size, - FX_LPBYTE dest_buf, FX_DWORD& dest_size) +FX_BOOL CPDF_StandardCryptoHandler::EncryptContent(FX_DWORD objnum, FX_DWORD gennum, const uint8_t* src_buf, FX_DWORD src_size, + uint8_t* dest_buf, FX_DWORD& dest_size) { CryptBlock(TRUE, objnum, gennum, src_buf, src_size, dest_buf, dest_size); return TRUE; @@ -940,8 +940,8 @@ FX_BOOL CPDF_StandardCryptoHandler::EncryptContent(FX_DWORD objnum, FX_DWORD gen void CPDF_CryptoHandler::Decrypt(FX_DWORD objnum, FX_DWORD gennum, CFX_ByteString& str) { CFX_BinaryBuf dest_buf; - FX_LPVOID context = DecryptStart(objnum, gennum); - DecryptStream(context, (FX_LPCBYTE)str, str.GetLength(), dest_buf); + void* context = DecryptStart(objnum, gennum); + DecryptStream(context, (const uint8_t*)str, str.GetLength(), dest_buf); DecryptFinish(context, dest_buf); str = dest_buf; } diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_fdf.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_fdf.cpp index 5bacfd7393..ceed675461 100644 --- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_fdf.cpp +++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_fdf.cpp @@ -39,9 +39,9 @@ CFDF_Document* CFDF_Document::ParseFile(IFX_FileRead *pFile, FX_BOOL bOwnFile) } return pDoc; } -CFDF_Document* CFDF_Document::ParseMemory(FX_LPCBYTE pData, FX_DWORD size) +CFDF_Document* CFDF_Document::ParseMemory(const uint8_t* pData, FX_DWORD size) { - return CFDF_Document::ParseFile(FX_CreateMemoryStream((FX_LPBYTE)pData, size), TRUE); + return CFDF_Document::ParseFile(FX_CreateMemoryStream((uint8_t*)pData, size), TRUE); } void CFDF_Document::ParseStream(IFX_FileRead *pFile, FX_BOOL bOwnFile) { @@ -95,7 +95,7 @@ FX_BOOL CFDF_Document::WriteBuf(CFX_ByteTextBuf& buf) const while(pos) { size_t objnum; CPDF_Object* pObj; - m_IndirectObjs.GetNextAssoc(pos, (FX_LPVOID&)objnum, (FX_LPVOID&)pObj); + m_IndirectObjs.GetNextAssoc(pos, (void*&)objnum, (void*&)pObj); buf << (FX_DWORD)objnum << FX_BSTRC(" 0 obj\r\n") << pObj << FX_BSTRC("\r\nendobj\r\n\r\n"); } buf << FX_BSTRC("trailer\r\n<</Root ") << m_pRootDict->GetObjNum() << FX_BSTRC(" 0 R>>\r\n%%EOF\r\n"); @@ -113,7 +113,7 @@ CFX_WideString CFDF_Document::GetWin32Path() const } return FPDF_FileSpec_GetWin32Path(pFileSpec); } -static CFX_WideString ChangeSlash(FX_LPCWSTR str) +static CFX_WideString ChangeSlash(const FX_WCHAR* str) { CFX_WideString result; while (*str) { diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_filters.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_filters.cpp index 8cb0cee82a..97e68b5c0c 100644 --- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_filters.cpp +++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_filters.cpp @@ -29,7 +29,7 @@ void CFX_DataFilter::SetDestFilter(CFX_DataFilter* pFilter) m_pDestFilter = pFilter; } } -void CFX_DataFilter::FilterIn(FX_LPCBYTE src_buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf) +void CFX_DataFilter::FilterIn(const uint8_t* src_buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf) { if (m_bEOF) { return; @@ -199,7 +199,7 @@ CPDF_StreamFilter::~CPDF_StreamFilter() } } #define FPDF_FILTER_BUFFER_IN_SIZE FPDF_FILTER_BUFFER_SIZE -FX_DWORD CPDF_StreamFilter::ReadBlock(FX_LPBYTE buffer, FX_DWORD buf_size) +FX_DWORD CPDF_StreamFilter::ReadBlock(uint8_t* buffer, FX_DWORD buf_size) { if (m_pFilter == NULL) { FX_DWORD read_size = m_pStream->GetRawSize() - m_SrcOffset; @@ -249,7 +249,7 @@ FX_DWORD CPDF_StreamFilter::ReadBlock(FX_LPBYTE buffer, FX_DWORD buf_size) } return read_size + ReadLeftOver(buffer, buf_size); } -FX_DWORD CPDF_StreamFilter::ReadLeftOver(FX_LPBYTE buffer, FX_DWORD buf_size) +FX_DWORD CPDF_StreamFilter::ReadLeftOver(uint8_t* buffer, FX_DWORD buf_size) { FX_DWORD read_size = m_pBuffer->GetSize() - m_BufOffset; if (read_size > buf_size) { @@ -277,7 +277,7 @@ CPDF_DecryptFilter::~CPDF_DecryptFilter() m_pCryptoHandler->DecryptFinish(m_pContext, buf); } } -void CPDF_DecryptFilter::v_FilterIn(FX_LPCBYTE src_buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf) +void CPDF_DecryptFilter::v_FilterIn(const uint8_t* src_buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf) { if (m_pContext == NULL) { m_pContext = m_pCryptoHandler->DecryptStart(m_ObjNum, m_GenNum); @@ -320,7 +320,7 @@ CPDF_FlateFilter::~CPDF_FlateFilter() FPDFAPI_FlateEnd(m_pContext); } } -void CPDF_FlateFilter::v_FilterIn(FX_LPCBYTE src_buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf) +void CPDF_FlateFilter::v_FilterIn(const uint8_t* src_buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf) { if (m_pContext == NULL) { m_pContext = FPDFAPI_FlateInit(my_alloc_func, my_free_func); @@ -348,7 +348,7 @@ CPDF_LzwFilter::CPDF_LzwFilter(FX_BOOL bEarlyChange) m_LeftBits = 0; m_OldCode = (FX_DWORD) - 1; } -void CPDF_LzwFilter::v_FilterIn(FX_LPCBYTE src_buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf) +void CPDF_LzwFilter::v_FilterIn(const uint8_t* src_buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf) { for (FX_DWORD i = 0; i < src_size; i ++) { if (m_nLeftBits + 8 < m_CodeLen) { @@ -389,7 +389,7 @@ void CPDF_LzwFilter::v_FilterIn(FX_LPCBYTE src_buf, FX_DWORD src_size, CFX_Binar DecodeString(code); } dest_buf.AppendBlock(NULL, m_StackLen); - FX_LPBYTE pOutput = dest_buf.GetBuffer() + dest_buf.GetSize() - m_StackLen; + uint8_t* pOutput = dest_buf.GetBuffer() + dest_buf.GetSize() - m_StackLen; for (FX_DWORD cc = 0; cc < m_StackLen; cc ++) { pOutput[cc] = m_DecodeStack[m_StackLen - cc - 1]; } @@ -475,7 +475,7 @@ static uint8_t PaethPredictor(int a, int b, int c) } return (uint8_t)c; } -static void PNG_PredictorLine(FX_LPBYTE cur_buf, FX_LPBYTE ref_buf, int pitch, int Bpp) +static void PNG_PredictorLine(uint8_t* cur_buf, uint8_t* ref_buf, int pitch, int Bpp) { uint8_t tag = cur_buf[0]; if (tag == 0) { @@ -535,7 +535,7 @@ static void PNG_PredictorLine(FX_LPBYTE cur_buf, FX_LPBYTE ref_buf, int pitch, i } } } -void CPDF_PredictorFilter::v_FilterIn(FX_LPCBYTE src_buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf) +void CPDF_PredictorFilter::v_FilterIn(const uint8_t* src_buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf) { if (m_pCurLine == NULL) { m_pCurLine = FX_Alloc(uint8_t, m_Pitch); @@ -564,7 +564,7 @@ void CPDF_PredictorFilter::v_FilterIn(FX_LPCBYTE src_buf, FX_DWORD src_size, CFX PNG_PredictorLine(m_pCurLine, m_iLine ? m_pRefLine : NULL, m_Pitch - 1, m_Bpp); dest_buf.AppendBlock(m_pCurLine + 1, m_Pitch - 1); m_iLine ++; - FX_LPBYTE temp = m_pCurLine; + uint8_t* temp = m_pCurLine; m_pCurLine = m_pRefLine; m_pRefLine = temp; } @@ -576,7 +576,7 @@ CPDF_Ascii85Filter::CPDF_Ascii85Filter() m_State = 0; m_CharCount = 0; } -void CPDF_Ascii85Filter::v_FilterIn(FX_LPCBYTE src_buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf) +void CPDF_Ascii85Filter::v_FilterIn(const uint8_t* src_buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf) { for (FX_DWORD i = 0; i < src_size; i ++) { uint8_t byte = src_buf[i]; @@ -635,7 +635,7 @@ CPDF_AsciiHexFilter::CPDF_AsciiHexFilter() { m_State = 0; } -void CPDF_AsciiHexFilter::v_FilterIn(FX_LPCBYTE src_buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf) +void CPDF_AsciiHexFilter::v_FilterIn(const uint8_t* src_buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf) { for (FX_DWORD i = 0; i < src_size; i ++) { uint8_t byte = src_buf[i]; @@ -670,7 +670,7 @@ CPDF_RunLenFilter::CPDF_RunLenFilter() m_State = 0; m_Count = 0; } -void CPDF_RunLenFilter::v_FilterIn(FX_LPCBYTE src_buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf) +void CPDF_RunLenFilter::v_FilterIn(const uint8_t* src_buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf) { for (FX_DWORD i = 0; i < src_size; i ++) { uint8_t byte = src_buf[i]; @@ -719,12 +719,12 @@ CPDF_JpegFilter::~CPDF_JpegFilter() CPDF_ModuleMgr::Get()->GetJpegModule()->Finish(m_pContext); } } -void CPDF_JpegFilter::v_FilterIn(FX_LPCBYTE src_buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf) +void CPDF_JpegFilter::v_FilterIn(const uint8_t* src_buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf) { if (m_pContext == NULL) { m_pContext = CPDF_ModuleMgr::Get()->GetJpegModule()->Start(); } - FX_LPCBYTE jpeg_src_buf; + const uint8_t* jpeg_src_buf; FX_DWORD jpeg_src_size; CFX_BinaryBuf temp_buf; if (m_InputBuf.GetSize()) { @@ -811,9 +811,9 @@ FX_BOOL CPDF_FaxFilter::Initialize(int Encoding, int bEndOfLine, int bByteAlign, m_InputBitPos = 0; return TRUE; } -void CPDF_FaxFilter::v_FilterIn(FX_LPCBYTE src_buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf) +void CPDF_FaxFilter::v_FilterIn(const uint8_t* src_buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf) { - FX_LPCBYTE fax_src_buf; + const uint8_t* fax_src_buf; FX_DWORD fax_src_size; CFX_BinaryBuf temp_buf; int bitpos; @@ -840,9 +840,9 @@ void CPDF_FaxFilter::v_FilterFinish(CFX_BinaryBuf& dest_buf) ProcessData(m_InputBuf.GetBuffer(), m_InputBuf.GetSize(), m_InputBitPos, TRUE, dest_buf); } FX_BOOL _FaxSkipEOL(const uint8_t* src_buf, int bitsize, int& bitpos); -FX_BOOL _FaxG4GetRow(const uint8_t* src_buf, int bitsize, int& bitpos, FX_LPBYTE dest_buf, const uint8_t* ref_buf, int columns); -FX_BOOL _FaxGet1DLine(const uint8_t* src_buf, int bitsize, int& bitpos, FX_LPBYTE dest_buf, int columns); -void CPDF_FaxFilter::ProcessData(FX_LPCBYTE src_buf, FX_DWORD src_size, int& bitpos, FX_BOOL bFinish, +FX_BOOL _FaxG4GetRow(const uint8_t* src_buf, int bitsize, int& bitpos, uint8_t* dest_buf, const uint8_t* ref_buf, int columns); +FX_BOOL _FaxGet1DLine(const uint8_t* src_buf, int bitsize, int& bitpos, uint8_t* dest_buf, int columns); +void CPDF_FaxFilter::ProcessData(const uint8_t* src_buf, FX_DWORD src_size, int& bitpos, FX_BOOL bFinish, CFX_BinaryBuf& dest_buf) { int bitsize = src_size * 8; @@ -872,7 +872,7 @@ void CPDF_FaxFilter::ProcessData(FX_LPCBYTE src_buf, FX_DWORD src_size, int& bit } } } -FX_BOOL CPDF_FaxFilter::ReadLine(FX_LPCBYTE src_buf, int bitsize, int& bitpos) +FX_BOOL CPDF_FaxFilter::ReadLine(const uint8_t* src_buf, int bitsize, int& bitpos) { if (!_FaxSkipEOL(src_buf, bitsize, bitpos)) { return FALSE; diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp index 8ecc0a5bf0..192be3a45c 100644 --- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp +++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp @@ -51,7 +51,7 @@ CFX_ByteString CPDF_Object::GetString() const case PDFOBJ_NAME: return ((CPDF_Name*)this)->m_Name; case PDFOBJ_REFERENCE: { - CPDF_Reference* pRef = (CPDF_Reference*)(FX_LPVOID)this; + CPDF_Reference* pRef = (CPDF_Reference*)(void*)this; if (pRef->m_pObjList == NULL) { break; } @@ -68,11 +68,11 @@ CFX_ByteStringC CPDF_Object::GetConstString() const { switch (m_Type) { case PDFOBJ_STRING: - return CFX_ByteStringC((FX_LPCBYTE)((CPDF_String*)this)->m_String, ((CPDF_String*)this)->m_String.GetLength()); + return CFX_ByteStringC((const uint8_t*)((CPDF_String*)this)->m_String, ((CPDF_String*)this)->m_String.GetLength()); case PDFOBJ_NAME: - return CFX_ByteStringC((FX_LPCBYTE)((CPDF_Name*)this)->m_Name, ((CPDF_Name*)this)->m_Name.GetLength()); + return CFX_ByteStringC((const uint8_t*)((CPDF_Name*)this)->m_Name, ((CPDF_Name*)this)->m_Name.GetLength()); case PDFOBJ_REFERENCE: { - CPDF_Reference* pRef = (CPDF_Reference*)(FX_LPVOID)this; + CPDF_Reference* pRef = (CPDF_Reference*)(void*)this; if (pRef->m_pObjList == NULL) { break; } @@ -91,7 +91,7 @@ FX_FLOAT CPDF_Object::GetNumber() const case PDFOBJ_NUMBER: return ((CPDF_Number*)this)->GetNumber(); case PDFOBJ_REFERENCE: { - CPDF_Reference* pRef = (CPDF_Reference*)(FX_LPVOID)this; + CPDF_Reference* pRef = (CPDF_Reference*)(void*)this; if (pRef->m_pObjList == NULL) { break; } @@ -120,7 +120,7 @@ int CPDF_Object::GetInteger() const case PDFOBJ_NUMBER: return ((CPDF_Number*)this)->GetInteger(); case PDFOBJ_REFERENCE: { - CPDF_Reference* pRef = (CPDF_Reference*)(FX_LPVOID)this; + CPDF_Reference* pRef = (CPDF_Reference*)(void*)this; PARSE_CONTEXT context; FXSYS_memset32(&context, 0, sizeof(PARSE_CONTEXT)); if (pRef->m_pObjList == NULL) { @@ -233,7 +233,7 @@ CPDF_Object* CPDF_Object::GetDirect() const if (m_Type != PDFOBJ_REFERENCE) { return (CPDF_Object*)this; } - CPDF_Reference* pRef = (CPDF_Reference*)(FX_LPVOID)this; + CPDF_Reference* pRef = (CPDF_Reference*)(void*)this; if (pRef->m_pObjList == NULL) { return NULL; } @@ -331,13 +331,13 @@ CFX_WideString CPDF_Object::GetUnicodeText(CFX_CharMap* pCharMap) const } return CFX_WideString(); } -void CPDF_Object::SetUnicodeText(FX_LPCWSTR pUnicodes, int len) +void CPDF_Object::SetUnicodeText(const FX_WCHAR* pUnicodes, int len) { if (m_Type == PDFOBJ_STRING) { ((CPDF_String*)this)->m_String = PDF_EncodeText(pUnicodes, len); } else if (m_Type == PDFOBJ_STREAM) { CFX_ByteString result = PDF_EncodeText(pUnicodes, len); - ((CPDF_Stream*)this)->SetData((FX_LPBYTE)result.c_str(), result.GetLength(), FALSE, FALSE); + ((CPDF_Stream*)this)->SetData((uint8_t*)result.c_str(), result.GetLength(), FALSE, FALSE); } } @@ -570,7 +570,7 @@ CPDF_Dictionary::~CPDF_Dictionary() { FX_POSITION pos = m_Map.GetStartPosition(); while (pos) { - FX_LPVOID value = m_Map.GetNextValue(pos); + void* value = m_Map.GetNextValue(pos); if (value) ((CPDF_Object*)value)->Release(); } @@ -585,7 +585,7 @@ CPDF_Object* CPDF_Dictionary::GetNextElement(FX_POSITION& pos, CFX_ByteString& k return NULL; } CPDF_Object* p; - m_Map.GetNextAssoc(pos, key, (FX_LPVOID&)p); + m_Map.GetNextAssoc(pos, key, (void*&)p); return p; } CPDF_Object* CPDF_Dictionary::GetElement(FX_BSTR key) const @@ -736,7 +736,7 @@ CFX_AffineMatrix CPDF_Dictionary::GetMatrix(FX_BSTR key) const } FX_BOOL CPDF_Dictionary::KeyExist(FX_BSTR key) const { - FX_LPVOID value; + void* value; return m_Map.Lookup(key, value); } void CPDF_Dictionary::SetAt(FX_BSTR key, CPDF_Object* pObj, CPDF_IndirectObjects* pObjs) @@ -797,7 +797,7 @@ FX_BOOL CPDF_Dictionary::Identical(CPDF_Dictionary* pOther) const FX_POSITION pos = m_Map.GetStartPosition(); while (pos) { CFX_ByteString key; - FX_LPVOID value; + void* value; m_Map.GetNextAssoc(pos, key, value); if (!value) return FALSE; @@ -857,7 +857,7 @@ void CPDF_Dictionary::SetAtMatrix(FX_BSTR key, const CFX_AffineMatrix& matrix) pArray->AddNumber(matrix.f); SetAt(key, pArray); } -CPDF_Stream::CPDF_Stream(FX_LPBYTE pData, FX_DWORD size, CPDF_Dictionary* pDict) +CPDF_Stream::CPDF_Stream(uint8_t* pData, FX_DWORD size, CPDF_Dictionary* pDict) : CPDF_Object(PDFOBJ_STREAM) { m_pDict = pDict; m_dwSize = size; @@ -892,7 +892,7 @@ void CPDF_Stream::InitStream(CPDF_Dictionary* pDict) m_pCryptoHandler = NULL; m_FileOffset = 0; } -void CPDF_Stream::InitStream(FX_LPBYTE pData, FX_DWORD size, CPDF_Dictionary* pDict) +void CPDF_Stream::InitStream(uint8_t* pData, FX_DWORD size, CPDF_Dictionary* pDict) { InitStream(pDict); m_GenNum = (FX_DWORD) - 1; @@ -905,7 +905,7 @@ void CPDF_Stream::InitStream(FX_LPBYTE pData, FX_DWORD size, CPDF_Dictionary* pD m_pDict->SetAtInteger(FX_BSTRC("Length"), size); } } -void CPDF_Stream::SetData(FX_LPCBYTE pData, FX_DWORD size, FX_BOOL bCompressed, FX_BOOL bKeepBuf) +void CPDF_Stream::SetData(const uint8_t* pData, FX_DWORD size, FX_BOOL bCompressed, FX_BOOL bKeepBuf) { if (m_GenNum == (FX_DWORD) - 1) { if (m_pDataBuf) { @@ -916,7 +916,7 @@ void CPDF_Stream::SetData(FX_LPCBYTE pData, FX_DWORD size, FX_BOOL bCompressed, m_pCryptoHandler = NULL; } if (bKeepBuf) { - m_pDataBuf = (FX_LPBYTE)pData; + m_pDataBuf = (uint8_t*)pData; } else { m_pDataBuf = FX_Alloc(uint8_t, size); if (pData) { @@ -933,7 +933,7 @@ void CPDF_Stream::SetData(FX_LPCBYTE pData, FX_DWORD size, FX_BOOL bCompressed, m_pDict->RemoveAt(FX_BSTRC("DecodeParms")); } } -FX_BOOL CPDF_Stream::ReadRawData(FX_FILESIZE offset, FX_LPBYTE buf, FX_DWORD size) const +FX_BOOL CPDF_Stream::ReadRawData(FX_FILESIZE offset, uint8_t* buf, FX_DWORD size) const { if ((m_GenNum != (FX_DWORD) - 1) && m_pFile) { return m_pFile->ReadBlock(buf, m_FileOffset + offset, size); @@ -993,7 +993,7 @@ FX_BOOL CPDF_Stream::Identical(CPDF_Stream* pOther) const } if (m_GenNum != (FX_DWORD) - 1 || pOther->m_GenNum != (FX_DWORD) - 1) { IFX_FileRead* pFile = NULL; - FX_LPBYTE pBuf = NULL; + uint8_t* pBuf = NULL; FX_DWORD offset = 0; if (pOther->m_GenNum != (FX_DWORD) - 1) { pFile = pOther->m_pFile; @@ -1023,7 +1023,7 @@ FX_BOOL CPDF_Stream::Identical(CPDF_Stream* pOther) const } return FXSYS_memcmp32(m_pDataBuf, pOther->m_pDataBuf, m_dwSize) == 0; } -CPDF_Stream* CPDF_Stream::Clone(FX_BOOL bDirect, FPDF_LPFCloneStreamCallback lpfCallback, FX_LPVOID pUserData) const +CPDF_Stream* CPDF_Stream::Clone(FX_BOOL bDirect, FPDF_LPFCloneStreamCallback lpfCallback, void* pUserData) const { CPDF_Dictionary *pCloneDict = (CPDF_Dictionary*)m_pDict->Clone(bDirect); IFX_FileStream *pFS = NULL; @@ -1039,7 +1039,7 @@ CPDF_Stream* CPDF_Stream::Clone(FX_BOOL bDirect, FPDF_LPFCloneStreamCallback lpf CPDF_Stream* pObj = new CPDF_Stream(NULL, 0, NULL); CPDF_StreamFilter *pSF = GetStreamFilter(TRUE); if (pSF) { - FX_LPBYTE pBuf = FX_Alloc(uint8_t, 4096); + uint8_t* pBuf = FX_Alloc(uint8_t, 4096); FX_DWORD dwRead; do { dwRead = pSF->ReadBlock(pBuf, 4096); @@ -1054,8 +1054,8 @@ CPDF_Stream* CPDF_Stream::Clone(FX_BOOL bDirect, FPDF_LPFCloneStreamCallback lpf pObj->InitStream((IFX_FileRead*)pFS, pCloneDict); return pObj; } -extern FX_BOOL PDF_DataDecode(FX_LPCBYTE src_buf, FX_DWORD src_size, const CPDF_Dictionary* pDict, - FX_LPBYTE& dest_buf, FX_DWORD& dest_size, CFX_ByteString& ImageEncoding, +extern FX_BOOL PDF_DataDecode(const uint8_t* src_buf, FX_DWORD src_size, const CPDF_Dictionary* pDict, + uint8_t*& dest_buf, FX_DWORD& dest_size, CFX_ByteString& ImageEncoding, CPDF_Dictionary*& pImageParms, FX_DWORD estimated_size, FX_BOOL bImageAcc); CPDF_StreamAcc::CPDF_StreamAcc() { @@ -1076,10 +1076,10 @@ void CPDF_StreamAcc::LoadAllData(const CPDF_Stream* pStream, FX_BOOL bRawAccess, if (pStream->IsMemoryBased() && (!pStream->GetDict()->KeyExist(FX_BSTRC("Filter")) || bRawAccess)) { m_dwSize = pStream->m_dwSize; - m_pData = (FX_LPBYTE)pStream->m_pDataBuf; + m_pData = (uint8_t*)pStream->m_pDataBuf; return; } - FX_LPBYTE pSrcData; + uint8_t* pSrcData; FX_DWORD dwSrcSize = pStream->m_dwSize; if (dwSrcSize == 0) { return; @@ -1092,12 +1092,12 @@ void CPDF_StreamAcc::LoadAllData(const CPDF_Stream* pStream, FX_BOOL bRawAccess, } else { pSrcData = pStream->m_pDataBuf; } - FX_LPBYTE pDecryptedData; + uint8_t* pDecryptedData; FX_DWORD dwDecryptedSize; if (pStream->m_pCryptoHandler) { CFX_BinaryBuf dest_buf; dest_buf.EstimateSize(pStream->m_pCryptoHandler->DecryptGetSize(dwSrcSize)); - FX_LPVOID context = pStream->m_pCryptoHandler->DecryptStart(pStream->GetObjNum(), pStream->m_GenNum); + void* context = pStream->m_pCryptoHandler->DecryptStart(pStream->GetObjNum(), pStream->m_GenNum); pStream->m_pCryptoHandler->DecryptStream(context, pSrcData, dwSrcSize, dest_buf); pStream->m_pCryptoHandler->DecryptFinish(context, dest_buf); pDecryptedData = dest_buf.GetBuffer(); @@ -1136,7 +1136,7 @@ CPDF_StreamAcc::~CPDF_StreamAcc() FX_Free(m_pSrcData); } } -FX_LPCBYTE CPDF_StreamAcc::GetData() const +const uint8_t* CPDF_StreamAcc::GetData() const { if (m_bNewBuf) { return m_pData; @@ -1156,15 +1156,15 @@ FX_DWORD CPDF_StreamAcc::GetSize() const } return m_pStream->m_dwSize; } -FX_LPBYTE CPDF_StreamAcc::DetachData() +uint8_t* CPDF_StreamAcc::DetachData() { if (m_bNewBuf) { - FX_LPBYTE p = m_pData; + uint8_t* p = m_pData; m_pData = NULL; m_dwSize = 0; return p; } - FX_LPBYTE p = FX_Alloc(uint8_t, m_dwSize); + uint8_t* p = FX_Alloc(uint8_t, m_dwSize); FXSYS_memcpy32(p, m_pData, m_dwSize); return p; } @@ -1187,7 +1187,8 @@ CPDF_IndirectObjects::~CPDF_IndirectObjects() { FX_POSITION pos = m_IndirectObjs.GetStartPosition(); while (pos) { - FX_LPVOID key, value; + void* key; + void* value; m_IndirectObjs.GetNextAssoc(pos, key, value); ((CPDF_Object*)value)->Destroy(); } @@ -1197,9 +1198,9 @@ CPDF_Object* CPDF_IndirectObjects::GetIndirectObject(FX_DWORD objnum, struct PAR if (objnum == 0) { return NULL; } - FX_LPVOID value; + void* value; { - if (m_IndirectObjs.Lookup((FX_LPVOID)(uintptr_t)objnum, value)) { + if (m_IndirectObjs.Lookup((void*)(uintptr_t)objnum, value)) { if (((CPDF_Object*)value)->GetObjNum() == -1) { return NULL; } @@ -1217,18 +1218,18 @@ CPDF_Object* CPDF_IndirectObjects::GetIndirectObject(FX_DWORD objnum, struct PAR if (m_LastObjNum < objnum) { m_LastObjNum = objnum; } - if (m_IndirectObjs.Lookup((FX_LPVOID)(uintptr_t)objnum, value)) { + if (m_IndirectObjs.Lookup((void*)(uintptr_t)objnum, value)) { if (value) { ((CPDF_Object *)value)->Destroy(); } } - m_IndirectObjs.SetAt((FX_LPVOID)(uintptr_t)objnum, pObj); + m_IndirectObjs.SetAt((void*)(uintptr_t)objnum, pObj); return pObj; } int CPDF_IndirectObjects::GetIndirectType(FX_DWORD objnum) { - FX_LPVOID value; - if (m_IndirectObjs.Lookup((FX_LPVOID)(uintptr_t)objnum, value)) { + void* value; + if (m_IndirectObjs.Lookup((void*)(uintptr_t)objnum, value)) { return ((CPDF_Object*)value)->GetType(); } if (m_pParser) { @@ -1245,29 +1246,29 @@ FX_DWORD CPDF_IndirectObjects::AddIndirectObject(CPDF_Object* pObj) return pObj->m_ObjNum; } m_LastObjNum ++; - m_IndirectObjs.SetAt((FX_LPVOID)(uintptr_t)m_LastObjNum, pObj); + m_IndirectObjs.SetAt((void*)(uintptr_t)m_LastObjNum, pObj); pObj->m_ObjNum = m_LastObjNum; return m_LastObjNum; } void CPDF_IndirectObjects::ReleaseIndirectObject(FX_DWORD objnum) { - FX_LPVOID value; - if (!m_IndirectObjs.Lookup((FX_LPVOID)(uintptr_t)objnum, value)) { + void* value; + if (!m_IndirectObjs.Lookup((void*)(uintptr_t)objnum, value)) { return; } if (((CPDF_Object*)value)->GetObjNum() == -1) { return; } ((CPDF_Object*)value)->Destroy(); - m_IndirectObjs.RemoveKey((FX_LPVOID)(uintptr_t)objnum); + m_IndirectObjs.RemoveKey((void*)(uintptr_t)objnum); } void CPDF_IndirectObjects::InsertIndirectObject(FX_DWORD objnum, CPDF_Object* pObj) { if (objnum == 0 || pObj == NULL) { return; } - FX_LPVOID value = NULL; - if (m_IndirectObjs.Lookup((FX_LPVOID)(uintptr_t)objnum, value)) { + void* value = NULL; + if (m_IndirectObjs.Lookup((void*)(uintptr_t)objnum, value)) { if (value) { if (pObj->GetGenNum() <= ((CPDF_Object*)value)->GetGenNum()) @@ -1277,7 +1278,7 @@ void CPDF_IndirectObjects::InsertIndirectObject(FX_DWORD objnum, CPDF_Object* pO } } pObj->m_ObjNum = objnum; - m_IndirectObjs.SetAt((FX_LPVOID)(uintptr_t)objnum, pObj); + m_IndirectObjs.SetAt((void*)(uintptr_t)objnum, pObj); if (m_LastObjNum < objnum) { m_LastObjNum = objnum; } diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp index a74d6a9841..3a03f33b29 100644 --- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp +++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp @@ -84,7 +84,7 @@ void CPDF_Parser::CloseParser(FX_BOOL bReParse) } FX_POSITION pos = m_ObjectStreamMap.GetStartPosition(); while (pos) { - FX_LPVOID objnum; + void* objnum; CPDF_StreamAcc* pStream; m_ObjectStreamMap.GetNextAssoc(pos, objnum, (void*&)pStream); delete pStream; @@ -124,7 +124,7 @@ static int32_t GetHeaderOffset(IFX_FileRead* pFile) } return -1; } -FX_DWORD CPDF_Parser::StartParse(FX_LPCSTR filename, FX_BOOL bReParse) +FX_DWORD CPDF_Parser::StartParse(const FX_CHAR* filename, FX_BOOL bReParse) { IFX_FileRead* pFileAccess = FX_CreateFileRead(filename); if (!pFileAccess) { @@ -132,7 +132,7 @@ FX_DWORD CPDF_Parser::StartParse(FX_LPCSTR filename, FX_BOOL bReParse) } return StartParse(pFileAccess, bReParse); } -FX_DWORD CPDF_Parser::StartParse(FX_LPCWSTR filename, FX_BOOL bReParse) +FX_DWORD CPDF_Parser::StartParse(const FX_WCHAR* filename, FX_BOOL bReParse) { IFX_FileRead* pFileAccess = FX_CreateFileRead(filename); if (!pFileAccess) { @@ -179,7 +179,7 @@ FX_DWORD CPDF_Parser::StartParse(IFX_FileRead* pFileAccess, FX_BOOL bReParse, FX FX_BOOL bXRefRebuilt = FALSE; if (m_Syntax.SearchWord(FX_BSTRC("startxref"), TRUE, FALSE, 4096)) { FX_FILESIZE startxref_offset = m_Syntax.SavePos(); - FX_LPVOID pResult = FXSYS_bsearch(&startxref_offset, m_SortedOffset.GetData(), m_SortedOffset.GetSize(), sizeof(FX_FILESIZE), _CompareFileSize); + void* pResult = FXSYS_bsearch(&startxref_offset, m_SortedOffset.GetData(), m_SortedOffset.GetSize(), sizeof(FX_FILESIZE), _CompareFileSize); if (pResult == NULL) { m_SortedOffset.Add(startxref_offset); } @@ -440,7 +440,7 @@ FX_BOOL CPDF_Parser::LoadLinearizedCrossRefV4(FX_FILESIZE pos, FX_DWORD dwObjCou { FX_FILESIZE dwStartPos = pos - m_Syntax.m_HeaderOffset; m_Syntax.RestorePos(dwStartPos); - FX_LPVOID pResult = FXSYS_bsearch(&pos, m_SortedOffset.GetData(), m_SortedOffset.GetSize(), sizeof(FX_FILESIZE), _CompareFileSize); + void* pResult = FXSYS_bsearch(&pos, m_SortedOffset.GetData(), m_SortedOffset.GetSize(), sizeof(FX_FILESIZE), _CompareFileSize); if (pResult == NULL) { m_SortedOffset.Add(pos); } @@ -458,7 +458,7 @@ FX_BOOL CPDF_Parser::LoadLinearizedCrossRefV4(FX_FILESIZE pos, FX_DWORD dwObjCou FX_Free(pBuf); return FALSE; } - if (!m_Syntax.ReadBlock((FX_LPBYTE)pBuf, dwReadSize)) { + if (!m_Syntax.ReadBlock((uint8_t*)pBuf, dwReadSize)) { FX_Free(pBuf); return FALSE; } @@ -485,7 +485,7 @@ FX_BOOL CPDF_Parser::LoadLinearizedCrossRefV4(FX_FILESIZE pos, FX_DWORD dwObjCou } m_ObjVersion.SetAtGrow(objnum, version); if (m_CrossRef[objnum] < m_Syntax.m_FileLen) { - FX_LPVOID pResult = FXSYS_bsearch(&m_CrossRef[objnum], m_SortedOffset.GetData(), m_SortedOffset.GetSize(), sizeof(FX_FILESIZE), _CompareFileSize); + void* pResult = FXSYS_bsearch(&m_CrossRef[objnum], m_SortedOffset.GetData(), m_SortedOffset.GetSize(), sizeof(FX_FILESIZE), _CompareFileSize); if (pResult == NULL) { m_SortedOffset.Add(m_CrossRef[objnum]); } @@ -504,12 +504,12 @@ FX_BOOL CPDF_Parser::LoadCrossRefV4(FX_FILESIZE pos, FX_FILESIZE streampos, FX_B if (m_Syntax.GetKeyword() != FX_BSTRC("xref")) { return FALSE; } - FX_LPVOID pResult = FXSYS_bsearch(&pos, m_SortedOffset.GetData(), m_SortedOffset.GetSize(), sizeof(FX_FILESIZE), _CompareFileSize); + void* pResult = FXSYS_bsearch(&pos, m_SortedOffset.GetData(), m_SortedOffset.GetSize(), sizeof(FX_FILESIZE), _CompareFileSize); if (pResult == NULL) { m_SortedOffset.Add(pos); } if (streampos) { - FX_LPVOID pResult = FXSYS_bsearch(&streampos, m_SortedOffset.GetData(), m_SortedOffset.GetSize(), sizeof(FX_FILESIZE), _CompareFileSize); + void* pResult = FXSYS_bsearch(&streampos, m_SortedOffset.GetData(), m_SortedOffset.GetSize(), sizeof(FX_FILESIZE), _CompareFileSize); if (pResult == NULL) { m_SortedOffset.Add(streampos); } @@ -545,7 +545,7 @@ FX_BOOL CPDF_Parser::LoadCrossRefV4(FX_FILESIZE pos, FX_FILESIZE streampos, FX_B FX_BOOL bFirstBlock = TRUE; for (int32_t block = 0; block < nBlocks; block ++) { int32_t block_size = block == nBlocks - 1 ? count % 1024 : 1024; - m_Syntax.ReadBlock((FX_LPBYTE)pBuf, block_size * recordsize); + m_Syntax.ReadBlock((uint8_t*)pBuf, block_size * recordsize); for (int32_t i = 0; i < block_size; i ++) { FX_DWORD objnum = start_objnum + block * 1024 + i; char* pEntry = pBuf + i * recordsize; @@ -581,7 +581,7 @@ FX_BOOL CPDF_Parser::LoadCrossRefV4(FX_FILESIZE pos, FX_FILESIZE streampos, FX_B } m_ObjVersion.SetAtGrow(objnum, version); if (m_CrossRef[objnum] < m_Syntax.m_FileLen) { - FX_LPVOID pResult = FXSYS_bsearch(&m_CrossRef[objnum], m_SortedOffset.GetData(), m_SortedOffset.GetSize(), sizeof(FX_FILESIZE), _CompareFileSize); + void* pResult = FXSYS_bsearch(&m_CrossRef[objnum], m_SortedOffset.GetData(), m_SortedOffset.GetSize(), sizeof(FX_FILESIZE), _CompareFileSize); if (pResult == NULL) { m_SortedOffset.Add(m_CrossRef[objnum]); } @@ -630,7 +630,7 @@ FX_BOOL CPDF_Parser::RebuildCrossRef() int32_t inside_index = 0; FX_DWORD objnum = 0, gennum = 0; int32_t depth = 0; - FX_LPBYTE buffer = FX_Alloc(uint8_t, 4096); + uint8_t* buffer = FX_Alloc(uint8_t, 4096); FX_FILESIZE pos = m_Syntax.m_HeaderOffset; FX_FILESIZE start_pos = 0, start_pos1 = 0; FX_FILESIZE last_obj = -1, last_xref = -1, last_trailer = -1; @@ -776,7 +776,7 @@ FX_BOOL CPDF_Parser::RebuildCrossRef() } FX_FILESIZE obj_pos = start_pos - m_Syntax.m_HeaderOffset; last_obj = start_pos; - FX_LPVOID pResult = FXSYS_bsearch(&obj_pos, m_SortedOffset.GetData(), m_SortedOffset.GetSize(), sizeof(FX_FILESIZE), _CompareFileSize); + void* pResult = FXSYS_bsearch(&obj_pos, m_SortedOffset.GetData(), m_SortedOffset.GetSize(), sizeof(FX_FILESIZE), _CompareFileSize); if (pResult == NULL) { m_SortedOffset.Add(obj_pos); } @@ -979,14 +979,14 @@ FX_BOOL CPDF_Parser::RebuildCrossRef() last_trailer = m_Syntax.m_FileLen; } FX_FILESIZE offset = last_trailer - m_Syntax.m_HeaderOffset; - FX_LPVOID pResult = FXSYS_bsearch(&offset, m_SortedOffset.GetData(), m_SortedOffset.GetSize(), sizeof(FX_FILESIZE), _CompareFileSize); + void* pResult = FXSYS_bsearch(&offset, m_SortedOffset.GetData(), m_SortedOffset.GetSize(), sizeof(FX_FILESIZE), _CompareFileSize); if (pResult == NULL) { m_SortedOffset.Add(offset); } FX_Free(buffer); return TRUE; } -static FX_DWORD _GetVarInt(FX_LPCBYTE p, int32_t n) +static FX_DWORD _GetVarInt(const uint8_t* p, int32_t n) { FX_DWORD result = 0; for (int32_t i = 0; i < n; i ++) { @@ -1067,7 +1067,7 @@ FX_BOOL CPDF_Parser::LoadCrossRefV5(FX_FILESIZE pos, FX_FILESIZE& prev, FX_BOOL FX_DWORD totalWidth = dwAccWidth.ValueOrDie(); CPDF_StreamAcc acc; acc.LoadAllData(pStream); - FX_LPCBYTE pData = acc.GetData(); + const uint8_t* pData = acc.GetData(); FX_DWORD dwTotalSize = acc.GetSize(); FX_DWORD segindex = 0; for (FX_DWORD i = 0; i < arrIndex.size(); i ++) { @@ -1083,7 +1083,7 @@ FX_BOOL CPDF_Parser::LoadCrossRefV5(FX_FILESIZE pos, FX_FILESIZE& prev, FX_BOOL if (!dwCaculatedSize.IsValid() || dwCaculatedSize.ValueOrDie() > dwTotalSize) { continue; } - FX_LPCBYTE segstart = pData + segindex * totalWidth; + const uint8_t* segstart = pData + segindex * totalWidth; FX_SAFE_DWORD dwMaxObjNum = startnum; dwMaxObjNum += count; FX_DWORD dwV5Size = pdfium::base::checked_cast<FX_DWORD, int32_t> (m_V5Type.GetSize()); @@ -1092,14 +1092,14 @@ FX_BOOL CPDF_Parser::LoadCrossRefV5(FX_FILESIZE pos, FX_FILESIZE& prev, FX_BOOL } for (FX_DWORD j = 0; j < count; j ++) { int32_t type = 1; - FX_LPCBYTE entrystart = segstart + j * totalWidth; + const uint8_t* entrystart = segstart + j * totalWidth; if (WidthArray[0]) { type = _GetVarInt(entrystart, WidthArray[0]); } if (m_V5Type[startnum + j] == 255) { FX_FILESIZE offset = _GetVarInt(entrystart + WidthArray[0], WidthArray[1]); m_CrossRef[startnum + j] = offset; - FX_LPVOID pResult = FXSYS_bsearch(&offset, m_SortedOffset.GetData(), m_SortedOffset.GetSize(), sizeof(FX_FILESIZE), _CompareFileSize); + void* pResult = FXSYS_bsearch(&offset, m_SortedOffset.GetData(), m_SortedOffset.GetSize(), sizeof(FX_FILESIZE), _CompareFileSize); if (pResult == NULL) { m_SortedOffset.Add(offset); } @@ -1115,7 +1115,7 @@ FX_BOOL CPDF_Parser::LoadCrossRefV5(FX_FILESIZE pos, FX_FILESIZE& prev, FX_BOOL FX_FILESIZE offset = _GetVarInt(entrystart + WidthArray[0], WidthArray[1]); m_CrossRef[startnum + j] = offset; if (type == 1) { - FX_LPVOID pResult = FXSYS_bsearch(&offset, m_SortedOffset.GetData(), m_SortedOffset.GetSize(), sizeof(FX_FILESIZE), _CompareFileSize); + void* pResult = FXSYS_bsearch(&offset, m_SortedOffset.GetData(), m_SortedOffset.GetSize(), sizeof(FX_FILESIZE), _CompareFileSize); if (pResult == NULL) { m_SortedOffset.Add(offset); } @@ -1177,7 +1177,7 @@ FX_BOOL CPDF_Parser::IsFormStream(FX_DWORD objnum, FX_BOOL& bForm) return TRUE; } FX_FILESIZE pos = m_CrossRef[objnum]; - FX_LPVOID pResult = FXSYS_bsearch(&pos, m_SortedOffset.GetData(), m_SortedOffset.GetSize(), sizeof(FX_FILESIZE), _CompareFileSize); + void* pResult = FXSYS_bsearch(&pos, m_SortedOffset.GetData(), m_SortedOffset.GetSize(), sizeof(FX_FILESIZE), _CompareFileSize); if (pResult == NULL) { return TRUE; } @@ -1211,7 +1211,7 @@ CPDF_Object* CPDF_Parser::ParseIndirectObject(CPDF_IndirectObjects* pObjList, FX int32_t n = pObjStream->GetDict()->GetInteger(FX_BSTRC("N")); int32_t offset = pObjStream->GetDict()->GetInteger(FX_BSTRC("First")); CPDF_SyntaxParser syntax; - CFX_SmartPointer<IFX_FileStream> file(FX_CreateMemoryStream((FX_LPBYTE)pObjStream->GetData(), (size_t)pObjStream->GetSize(), FALSE)); + CFX_SmartPointer<IFX_FileStream> file(FX_CreateMemoryStream((uint8_t*)pObjStream->GetData(), (size_t)pObjStream->GetSize(), FALSE)); syntax.InitParser(file.Get(), 0); CPDF_Object* pRet = NULL; while (n) { @@ -1256,7 +1256,7 @@ FX_FILESIZE CPDF_Parser::GetObjectSize(FX_DWORD objnum) if (offset == 0) { return 0; } - FX_LPVOID pResult = FXSYS_bsearch(&offset, m_SortedOffset.GetData(), m_SortedOffset.GetSize(), sizeof(FX_FILESIZE), _CompareFileSize); + void* pResult = FXSYS_bsearch(&offset, m_SortedOffset.GetData(), m_SortedOffset.GetSize(), sizeof(FX_FILESIZE), _CompareFileSize); if (pResult == NULL) { return 0; } @@ -1267,7 +1267,7 @@ FX_FILESIZE CPDF_Parser::GetObjectSize(FX_DWORD objnum) } return 0; } -void CPDF_Parser::GetIndirectBinary(FX_DWORD objnum, FX_LPBYTE& pBuffer, FX_DWORD& size) +void CPDF_Parser::GetIndirectBinary(FX_DWORD objnum, uint8_t*& pBuffer, FX_DWORD& size) { pBuffer = NULL; size = 0; @@ -1282,9 +1282,9 @@ void CPDF_Parser::GetIndirectBinary(FX_DWORD objnum, FX_LPBYTE& pBuffer, FX_DWOR int32_t n = pObjStream->GetDict()->GetInteger(FX_BSTRC("N")); int32_t offset = pObjStream->GetDict()->GetInteger(FX_BSTRC("First")); CPDF_SyntaxParser syntax; - FX_LPCBYTE pData = pObjStream->GetData(); + const uint8_t* pData = pObjStream->GetData(); FX_DWORD totalsize = pObjStream->GetSize(); - CFX_SmartPointer<IFX_FileStream> file(FX_CreateMemoryStream((FX_LPBYTE)pData, (size_t)totalsize, FALSE)); + CFX_SmartPointer<IFX_FileStream> file(FX_CreateMemoryStream((uint8_t*)pData, (size_t)totalsize, FALSE)); syntax.InitParser(file.Get(), 0); while (n) { FX_DWORD thisnum = syntax.GetDirectNum(); @@ -1332,7 +1332,7 @@ void CPDF_Parser::GetIndirectBinary(FX_DWORD objnum, FX_LPBYTE& pBuffer, FX_DWOR m_Syntax.RestorePos(SavedPos); return; } - FX_LPVOID pResult = FXSYS_bsearch(&pos, m_SortedOffset.GetData(), m_SortedOffset.GetSize(), sizeof(FX_FILESIZE), _CompareFileSize); + void* pResult = FXSYS_bsearch(&pos, m_SortedOffset.GetData(), m_SortedOffset.GetSize(), sizeof(FX_FILESIZE), _CompareFileSize); if (pResult == NULL) { m_Syntax.RestorePos(SavedPos); return; @@ -1662,7 +1662,7 @@ FX_DWORD CPDF_Parser::LoadLinearizedMainXRefTable() m_LastXRefOffset += dwCount; FX_POSITION pos = m_ObjectStreamMap.GetStartPosition(); while (pos) { - FX_LPVOID objnum; + void* objnum; CPDF_StreamAcc* pStream; m_ObjectStreamMap.GetNextAssoc(pos, objnum, (void*&)pStream); delete pStream; @@ -1765,7 +1765,7 @@ FX_BOOL CPDF_SyntaxParser::GetCharAtBackward(FX_FILESIZE pos, uint8_t& ch) ch = m_pFileBuf[pos - m_BufOffset]; return TRUE; } -FX_BOOL CPDF_SyntaxParser::ReadBlock(FX_LPBYTE pBuf, FX_DWORD size) +FX_BOOL CPDF_SyntaxParser::ReadBlock(uint8_t* pBuf, FX_DWORD size) { if (!m_pFileAccess->ReadBlock(pBuf, m_Pos + m_HeaderOffset, size)) { return FALSE; @@ -2047,12 +2047,12 @@ CFX_ByteString CPDF_SyntaxParser::GetNextWord(FX_BOOL& bIsNumber) { GetNextWord(); bIsNumber = m_bIsNumber; - return CFX_ByteString((FX_LPCSTR)m_WordBuffer, m_WordSize); + return CFX_ByteString((const FX_CHAR*)m_WordBuffer, m_WordSize); } CFX_ByteString CPDF_SyntaxParser::GetKeyword() { GetNextWord(); - return CFX_ByteString((FX_LPCSTR)m_WordBuffer, m_WordSize); + return CFX_ByteString((const FX_CHAR*)m_WordBuffer, m_WordSize); } CPDF_Object* CPDF_SyntaxParser::GetObject(CPDF_IndirectObjects* pObjList, FX_DWORD objnum, FX_DWORD gennum, PARSE_CONTEXT* pContext, FX_BOOL bDecrypt) { @@ -2477,12 +2477,12 @@ CPDF_Stream* CPDF_SyntaxParser::ReadStream(CPDF_Dictionary* pDict, PARSE_CONTEXT m_Pos = StreamStartPos; } CPDF_Stream* pStream; - FX_LPBYTE pData = FX_Alloc(uint8_t, len); + uint8_t* pData = FX_Alloc(uint8_t, len); ReadBlock(pData, len); if (pCryptoHandler) { CFX_BinaryBuf dest_buf; dest_buf.EstimateSize(pCryptoHandler->DecryptGetSize(len)); - FX_LPVOID context = pCryptoHandler->DecryptStart(objnum, gennum); + void* context = pCryptoHandler->DecryptStart(objnum, gennum); pCryptoHandler->DecryptStream(context, pData, len, dest_buf); pCryptoHandler->DecryptFinish(context, dest_buf); FX_Free(pData); @@ -2522,9 +2522,9 @@ int32_t CPDF_SyntaxParser::GetDirectNum() return 0; } m_WordBuffer[m_WordSize] = 0; - return FXSYS_atoi((FX_LPCSTR)m_WordBuffer); + return FXSYS_atoi((const FX_CHAR*)m_WordBuffer); } -FX_BOOL CPDF_SyntaxParser::IsWholeWord(FX_FILESIZE startpos, FX_FILESIZE limit, FX_LPCBYTE tag, FX_DWORD taglen) +FX_BOOL CPDF_SyntaxParser::IsWholeWord(FX_FILESIZE startpos, FX_FILESIZE limit, const uint8_t* tag, FX_DWORD taglen) { uint8_t type = PDF_CharType[tag[0]]; FX_BOOL bCheckLeft = type != 'D' && type != 'W'; @@ -2556,7 +2556,7 @@ FX_BOOL CPDF_SyntaxParser::SearchWord(FX_BSTR tag, FX_BOOL bWholeWord, FX_BOOL b if (!bForward) { offset = taglen - 1; } - FX_LPCBYTE tag_data = tag.GetPtr(); + const uint8_t* tag_data = tag.GetPtr(); uint8_t byte; while (1) { if (bForward) { @@ -2612,7 +2612,7 @@ FX_BOOL CPDF_SyntaxParser::SearchWord(FX_BSTR tag, FX_BOOL bWholeWord, FX_BOOL b return FALSE; } struct _SearchTagRecord { - FX_LPCBYTE m_pTag; + const uint8_t* m_pTag; FX_DWORD m_Len; FX_DWORD m_Offset; }; @@ -2767,7 +2767,7 @@ protected: FX_BOOL CheckAllCrossRefStream(IFX_DownloadHints *pHints); int32_t CheckCrossRefStream(IFX_DownloadHints *pHints, FX_FILESIZE &xref_offset); - FX_BOOL IsLinearizedFile(FX_LPBYTE pData, FX_DWORD dwLen); + FX_BOOL IsLinearizedFile(uint8_t* pData, FX_DWORD dwLen); void SetStartOffset(FX_FILESIZE dwOffset); FX_BOOL GetNextToken(CFX_ByteString &token); FX_BOOL GetNextChar(uint8_t &ch); @@ -3017,7 +3017,7 @@ FX_DWORD CPDF_DataAvail::GetObjectSize(FX_DWORD objnum, FX_FILESIZE& offset) if (offset == 0) { return 0; } - FX_LPVOID pResult = FXSYS_bsearch(&offset, pParser->m_SortedOffset.GetData(), pParser->m_SortedOffset.GetSize(), sizeof(FX_FILESIZE), _CompareFileSize); + void* pResult = FXSYS_bsearch(&offset, pParser->m_SortedOffset.GetData(), pParser->m_SortedOffset.GetSize(), sizeof(FX_FILESIZE), _CompareFileSize); if (pResult == NULL) { return 0; } @@ -3706,7 +3706,7 @@ int32_t CPDF_DataAvail::IsLinearizedPDF() } return PDF_NOT_LINEARIZED; } -FX_BOOL CPDF_DataAvail::IsLinearizedFile(FX_LPBYTE pData, FX_DWORD dwLen) +FX_BOOL CPDF_DataAvail::IsLinearizedFile(uint8_t* pData, FX_DWORD dwLen) { CFX_SmartPointer<IFX_FileStream> file(FX_CreateMemoryStream(pData, (size_t)dwLen, FALSE)); int32_t offset = GetHeaderOffset(file.Get()); @@ -3790,7 +3790,7 @@ int32_t CPDF_DataAvail::CheckCrossRefStream(IFX_DownloadHints* pHints, FX_FILESI if (m_pFileAvail->IsDataAvail(m_Pos, req_size)) { int32_t iSize = (int32_t)(m_Pos + req_size - m_dwCurrentXRefSteam); CFX_BinaryBuf buf(iSize); - FX_LPBYTE pBuf = buf.GetBuffer(); + uint8_t* pBuf = buf.GetBuffer(); m_pFileRead->ReadBlock(pBuf, m_dwCurrentXRefSteam, iSize); CFX_SmartPointer<IFX_FileStream> file(FX_CreateMemoryStream(pBuf, (size_t)iSize, FALSE)); m_parser.m_Syntax.InitParser(file.Get(), 0); @@ -4028,7 +4028,7 @@ FX_BOOL CPDF_DataAvail::CheckTrailer(IFX_DownloadHints* pHints) if (m_pFileAvail->IsDataAvail(m_Pos, iTrailerSize)) { int32_t iSize = (int32_t)(m_Pos + iTrailerSize - m_dwTrailerOffset); CFX_BinaryBuf buf(iSize); - FX_LPBYTE pBuf = buf.GetBuffer(); + uint8_t* pBuf = buf.GetBuffer(); if (!pBuf) { m_docStatus = PDF_DATAAVAIL_ERROR; return FALSE; diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp index b02139db0f..e6474550a2 100644 --- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp +++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp @@ -43,7 +43,7 @@ const char PDF_CharType[256] = { #ifndef MAX_PATH #define MAX_PATH 4096 #endif -CPDF_SimpleParser::CPDF_SimpleParser(FX_LPCBYTE pData, FX_DWORD dwSize) +CPDF_SimpleParser::CPDF_SimpleParser(const uint8_t* pData, FX_DWORD dwSize) { m_pData = pData; m_dwSize = dwSize; @@ -55,7 +55,7 @@ CPDF_SimpleParser::CPDF_SimpleParser(FX_BSTR str) m_dwSize = str.GetLength(); m_dwCurPos = 0; } -void CPDF_SimpleParser::ParseWord(FX_LPCBYTE& pStart, FX_DWORD& dwSize, int& type) +void CPDF_SimpleParser::ParseWord(const uint8_t*& pStart, FX_DWORD& dwSize, int& type) { pStart = NULL; dwSize = 0; @@ -153,7 +153,7 @@ void CPDF_SimpleParser::ParseWord(FX_LPCBYTE& pStart, FX_DWORD& dwSize, int& typ } CFX_ByteStringC CPDF_SimpleParser::GetWord() { - FX_LPCBYTE pStart; + const uint8_t* pStart; FX_DWORD dwSize; int type; ParseWord(pStart, dwSize, type); @@ -290,13 +290,13 @@ static int _hex2dec(char ch) CFX_ByteString PDF_NameDecode(FX_BSTR bstr) { int size = bstr.GetLength(); - FX_LPCSTR pSrc = bstr.GetCStr(); + const FX_CHAR* pSrc = bstr.GetCStr(); if (FXSYS_memchr(pSrc, '#', size) == NULL) { return bstr; } CFX_ByteString result; - FX_LPSTR pDestStart = result.GetBuffer(size); - FX_LPSTR pDest = pDestStart; + FX_CHAR* pDestStart = result.GetBuffer(size); + FX_CHAR* pDest = pDestStart; for (int i = 0; i < size; i ++) { if (pSrc[i] == '#' && i < size - 2) { *pDest ++ = _hex2dec(pSrc[i + 1]) * 16 + _hex2dec(pSrc[i + 2]); @@ -317,7 +317,7 @@ CFX_ByteString PDF_NameDecode(const CFX_ByteString& orig) } CFX_ByteString PDF_NameEncode(const CFX_ByteString& orig) { - FX_LPBYTE src_buf = (FX_LPBYTE)orig.c_str(); + uint8_t* src_buf = (uint8_t*)orig.c_str(); int src_len = orig.GetLength(); int dest_len = 0; int i; @@ -334,7 +334,7 @@ CFX_ByteString PDF_NameEncode(const CFX_ByteString& orig) return orig; } CFX_ByteString res; - FX_LPSTR dest_buf = res.GetBuffer(dest_len); + FX_CHAR* dest_buf = res.GetBuffer(dest_len); dest_len = 0; for (i = 0; i < src_len; i ++) { uint8_t ch = src_buf[i]; diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render_cache.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render_cache.cpp index d22bd4b760..46f1640793 100644 --- a/core/src/fpdfapi/fpdf_render/fpdf_render_cache.cpp +++ b/core/src/fpdfapi/fpdf_render/fpdf_render_cache.cpp @@ -29,7 +29,8 @@ void CPDF_PageRenderCache::ClearAll() { FX_POSITION pos = m_ImageCaches.GetStartPosition(); while (pos) { - FX_LPVOID key, value; + void* key; + void* value; m_ImageCaches.GetNextAssoc(pos, key, value); delete (CPDF_ImageCache*)value; } @@ -47,7 +48,8 @@ void CPDF_PageRenderCache::CacheOptimization(int32_t dwLimitCacheSize) FX_POSITION pos = m_ImageCaches.GetStartPosition(); int i = 0; while (pos) { - FX_LPVOID key, value; + void* key; + void* value; m_ImageCaches.GetNextAssoc(pos, key, value); pCACHEINFO[i].time = ((CPDF_ImageCache*)value)->GetTimeCount(); pCACHEINFO[i++].pStream = ((CPDF_ImageCache*)value)->GetStream(); @@ -72,7 +74,7 @@ void CPDF_PageRenderCache::CacheOptimization(int32_t dwLimitCacheSize) } void CPDF_PageRenderCache::ClearImageCache(CPDF_Stream* pStream) { - FX_LPVOID value = m_ImageCaches.GetValueAt(pStream); + void* value = m_ImageCaches.GetValueAt(pStream); if (value == NULL) { m_ImageCaches.RemoveKey(pStream); return; @@ -86,7 +88,8 @@ FX_DWORD CPDF_PageRenderCache::EstimateSize() FX_DWORD dwSize = 0; FX_POSITION pos = m_ImageCaches.GetStartPosition(); while (pos) { - FX_LPVOID key, value; + void* key; + void* value; m_ImageCaches.GetNextAssoc(pos, key, value); dwSize += ((CPDF_ImageCache*)value)->EstimateSize(); } @@ -99,7 +102,7 @@ FX_DWORD CPDF_PageRenderCache::GetCachedSize(CPDF_Stream* pStream) const return m_nCacheSize; } CPDF_ImageCache* pImageCache; - if (!m_ImageCaches.Lookup(pStream, (FX_LPVOID&)pImageCache)) { + if (!m_ImageCaches.Lookup(pStream, (void*&)pImageCache)) { return 0; } return pImageCache->EstimateSize(); @@ -109,7 +112,7 @@ void CPDF_PageRenderCache::GetCachedBitmap(CPDF_Stream* pStream, CFX_DIBSource*& int32_t downsampleWidth, int32_t downsampleHeight) { CPDF_ImageCache* pImageCache; - FX_BOOL bFind = m_ImageCaches.Lookup(pStream, (FX_LPVOID&)pImageCache); + FX_BOOL bFind = m_ImageCaches.Lookup(pStream, (void*&)pImageCache); if (!bFind) { pImageCache = new CPDF_ImageCache(m_pPage->m_pDocument, pStream); } @@ -124,7 +127,7 @@ void CPDF_PageRenderCache::GetCachedBitmap(CPDF_Stream* pStream, CFX_DIBSource*& } FX_BOOL CPDF_PageRenderCache::StartGetCachedBitmap(CPDF_Stream* pStream, FX_BOOL bStdCS, FX_DWORD GroupFamily, FX_BOOL bLoadMask, CPDF_RenderStatus* pRenderStatus, int32_t downsampleWidth, int32_t downsampleHeight) { - m_bCurFindCache = m_ImageCaches.Lookup(pStream, (FX_LPVOID&)m_pCurImageCache); + m_bCurFindCache = m_ImageCaches.Lookup(pStream, (void*&)m_pCurImageCache); if (!m_bCurFindCache) { m_pCurImageCache = new CPDF_ImageCache(m_pPage->m_pDocument, pStream); } @@ -159,7 +162,7 @@ FX_BOOL CPDF_PageRenderCache::Continue(IFX_Pause* pPause) void CPDF_PageRenderCache::ResetBitmap(CPDF_Stream* pStream, const CFX_DIBitmap* pBitmap) { CPDF_ImageCache* pImageCache; - if (!m_ImageCaches.Lookup(pStream, (FX_LPVOID&)pImageCache)) { + if (!m_ImageCaches.Lookup(pStream, (void*&)pImageCache)) { if (pBitmap == NULL) { return; } @@ -209,7 +212,8 @@ void CPDF_PageRenderCache::ClearImageData() { FX_POSITION pos = m_ImageCaches.GetStartPosition(); while (pos) { - FX_LPVOID key, value; + void* key; + void* value; m_ImageCaches.GetNextAssoc(pos, key, value); ((CPDF_ImageCache*)value)->ClearImageData(); } diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp index 699f84830f..669ba4da49 100644 --- a/core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp +++ b/core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp @@ -141,7 +141,7 @@ CPDF_DIBTransferFunc::CPDF_DIBTransferFunc(const CPDF_TransferFunc* pTransferFun m_RampG = &pTransferFunc->m_Samples[256]; m_RampB = &pTransferFunc->m_Samples[512]; } -void CPDF_DIBTransferFunc::TranslateScanline(FX_LPBYTE dest_buf, FX_LPCBYTE src_buf) const +void CPDF_DIBTransferFunc::TranslateScanline(uint8_t* dest_buf, const uint8_t* src_buf) const { int i; FX_BOOL bSkip = FALSE; @@ -234,7 +234,7 @@ void CPDF_DIBTransferFunc::TranslateScanline(FX_LPBYTE dest_buf, FX_LPCBYTE src_ break; } } -void CPDF_DIBTransferFunc::TranslateDownSamples(FX_LPBYTE dest_buf, FX_LPCBYTE src_buf, int pixels, int Bpp) const +void CPDF_DIBTransferFunc::TranslateDownSamples(uint8_t* dest_buf, const uint8_t* src_buf, int pixels, int Bpp) const { if (Bpp == 8) { for (int i = 0; i < pixels; i ++) { @@ -519,8 +519,8 @@ FX_BOOL CPDF_ImageRenderer::DrawPatternImage(const CFX_Matrix* pObj2Device) int matte_g = FXARGB_G(m_Loader.m_MatteColor); int matte_b = FXARGB_B(m_Loader.m_MatteColor); for (int row = 0; row < height; row ++) { - FX_LPBYTE dest_scan = (FX_LPBYTE)bitmap_device1.GetBitmap()->GetScanline(row); - FX_LPCBYTE mask_scan = bitmap_device2.GetBitmap()->GetScanline(row); + uint8_t* dest_scan = (uint8_t*)bitmap_device1.GetBitmap()->GetScanline(row); + const uint8_t* mask_scan = bitmap_device2.GetBitmap()->GetScanline(row); for (int col = 0; col < width; col ++) { int alpha = *mask_scan ++; if (alpha) { @@ -606,8 +606,8 @@ FX_BOOL CPDF_ImageRenderer::DrawMaskedImage() int matte_g = FXARGB_G(m_Loader.m_MatteColor); int matte_b = FXARGB_B(m_Loader.m_MatteColor); for (int row = 0; row < height; row ++) { - FX_LPBYTE dest_scan = (FX_LPBYTE)bitmap_device1.GetBitmap()->GetScanline(row); - FX_LPCBYTE mask_scan = bitmap_device2.GetBitmap()->GetScanline(row); + uint8_t* dest_scan = (uint8_t*)bitmap_device1.GetBitmap()->GetScanline(row); + const uint8_t* mask_scan = bitmap_device2.GetBitmap()->GetScanline(row); for (int col = 0; col < width; col ++) { int alpha = *mask_scan ++; if (alpha) { @@ -823,7 +823,7 @@ CPDF_QuickStretcher::~CPDF_QuickStretcher() delete m_pDecoder; } } -ICodec_ScanlineDecoder* FPDFAPI_CreateFlateDecoder(FX_LPCBYTE src_buf, FX_DWORD src_size, int width, int height, +ICodec_ScanlineDecoder* FPDFAPI_CreateFlateDecoder(const uint8_t* src_buf, FX_DWORD src_size, int width, int height, int nComps, int bpc, const CPDF_Dictionary* pParams); FX_BOOL CPDF_QuickStretcher::Start(CPDF_ImageObject* pImageObj, CFX_AffineMatrix* pImage2Device, const FX_RECT* pClipBox) { @@ -903,7 +903,7 @@ FX_BOOL CPDF_QuickStretcher::Start(CPDF_ImageObject* pImageObj, CFX_AffineMatrix } FX_BOOL CPDF_QuickStretcher::Continue(IFX_Pause* pPause) { - FX_LPBYTE result_buf = m_pBitmap->GetBuffer(); + uint8_t* result_buf = m_pBitmap->GetBuffer(); int src_width = m_pDecoder ? m_pDecoder->GetWidth() : m_SrcWidth; int src_height = m_pDecoder ? m_pDecoder->GetHeight() : m_SrcHeight; int src_pitch = src_width * m_Bpp; @@ -916,7 +916,7 @@ FX_BOOL CPDF_QuickStretcher::Continue(IFX_Pause* pPause) dest_y = m_LineIndex; src_y = (dest_y + m_ClipTop) * src_height / m_DestHeight; } - FX_LPCBYTE src_scan; + const uint8_t* src_scan; if (m_pDecoder) { src_scan = m_pDecoder->GetScanline(src_y); if (src_scan == NULL) { @@ -929,11 +929,11 @@ FX_BOOL CPDF_QuickStretcher::Continue(IFX_Pause* pPause) } src_scan += src_y * src_pitch; } - FX_LPBYTE result_scan = result_buf + dest_y * m_pBitmap->GetPitch(); + uint8_t* result_scan = result_buf + dest_y * m_pBitmap->GetPitch(); for (int x = 0; x < m_ResultWidth; x ++) { int dest_x = m_ClipLeft + x; int src_x = (m_bFlipX ? (m_DestWidth - dest_x - 1) : dest_x) * src_width / m_DestWidth; - FX_LPCBYTE src_pixel = src_scan + src_x * m_Bpp; + const uint8_t* src_pixel = src_scan + src_x * m_Bpp; if (m_pCS == NULL) { *result_scan = src_pixel[2]; result_scan ++; @@ -1049,11 +1049,11 @@ CFX_DIBitmap* CPDF_RenderStatus::LoadSMask(CPDF_Dictionary* pSMaskDict, delete pMask; return NULL; } - FX_LPBYTE dest_buf = pMask->GetBuffer(); + uint8_t* dest_buf = pMask->GetBuffer(); int dest_pitch = pMask->GetPitch(); - FX_LPBYTE src_buf = bitmap.GetBuffer(); + uint8_t* src_buf = bitmap.GetBuffer(); int src_pitch = bitmap.GetPitch(); - FX_LPBYTE pTransfer = FX_Alloc(uint8_t, 256); + uint8_t* pTransfer = FX_Alloc(uint8_t, 256); if (pFunc) { CFX_FixedBufGrow<FX_FLOAT, 16> results(pFunc->CountOutputs()); for (int i = 0; i < 256; i ++) { @@ -1070,8 +1070,8 @@ CFX_DIBitmap* CPDF_RenderStatus::LoadSMask(CPDF_Dictionary* pSMaskDict, if (bLuminosity) { int Bpp = bitmap.GetBPP() / 8; for (int row = 0; row < height; row ++) { - FX_LPBYTE dest_pos = dest_buf + row * dest_pitch; - FX_LPBYTE src_pos = src_buf + row * src_pitch; + uint8_t* dest_pos = dest_buf + row * dest_pitch; + uint8_t* src_pos = src_buf + row * src_pitch; for (int col = 0; col < width; col ++) { *dest_pos ++ = pTransfer[FXRGB2GRAY(src_pos[2], src_pos[1], *src_pos)]; src_pos += Bpp; diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp index d45cc1151f..2cbe2e8eb6 100644 --- a/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp +++ b/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp @@ -16,7 +16,7 @@ namespace { -unsigned int _GetBits8(FX_LPCBYTE pData, int bitpos, int nbits) +unsigned int _GetBits8(const uint8_t* pData, int bitpos, int nbits) { unsigned int byte = pData[bitpos / 8]; if (nbits == 8) { @@ -584,9 +584,9 @@ DIB_COMP_DATA* CPDF_DIBSource::GetDecodeAndMaskArray(FX_BOOL& bDefaultDecode, FX } return pCompData; } -ICodec_ScanlineDecoder* FPDFAPI_CreateFaxDecoder(FX_LPCBYTE src_buf, FX_DWORD src_size, int width, int height, +ICodec_ScanlineDecoder* FPDFAPI_CreateFaxDecoder(const uint8_t* src_buf, FX_DWORD src_size, int width, int height, const CPDF_Dictionary* pParams); -ICodec_ScanlineDecoder* FPDFAPI_CreateFlateDecoder(FX_LPCBYTE src_buf, FX_DWORD src_size, int width, int height, +ICodec_ScanlineDecoder* FPDFAPI_CreateFlateDecoder(const uint8_t* src_buf, FX_DWORD src_size, int width, int height, int nComps, int bpc, const CPDF_Dictionary* pParams); int CPDF_DIBSource::CreateDecoder() { @@ -597,7 +597,7 @@ int CPDF_DIBSource::CreateDecoder() if (m_bDoBpcCheck && m_bpc == 0) { return 0; } - FX_LPCBYTE src_data = m_pStreamAcc->GetData(); + const uint8_t* src_data = m_pStreamAcc->GetData(); FX_DWORD src_size = m_pStreamAcc->GetSize(); const CPDF_Dictionary* pParams = m_pStreamAcc->GetImageParam(); if (decoder == FX_BSTRC("CCITTFaxDecode")) { @@ -750,7 +750,7 @@ void CPDF_DIBSource::LoadJpxBitmap() m_bpc < 8) { int scale = 8 - m_bpc; for (FX_DWORD row = 0; row < height; ++row) { - FX_LPBYTE scanline = (FX_LPBYTE)m_pCachedBitmap->GetScanline(row); + uint8_t* scanline = (uint8_t*)m_pCachedBitmap->GetScanline(row); for (FX_DWORD col = 0; col < width; ++col) { *scanline = (*scanline) >> scale; ++scanline; @@ -960,7 +960,7 @@ void CPDF_DIBSource::ValidateDictParam() } } #define NORMALCOLOR_MAX(color, max) (color) > (max) ? (max) : (color) < 0 ? 0 : (color); -void CPDF_DIBSource::TranslateScanline24bpp(FX_LPBYTE dest_scan, FX_LPCBYTE src_scan) const +void CPDF_DIBSource::TranslateScanline24bpp(uint8_t* dest_scan, const uint8_t* src_scan) const { if (m_bpc == 0) { return; @@ -968,7 +968,7 @@ void CPDF_DIBSource::TranslateScanline24bpp(FX_LPBYTE dest_scan, FX_LPCBYTE src_ int max_data = (1 << m_bpc) - 1; if (m_bDefaultDecode) { if (m_Family == PDFCS_DEVICERGB || m_Family == PDFCS_CALRGB) { - FX_LPCBYTE src_pos = src_scan; + const uint8_t* src_pos = src_scan; switch (m_bpc) { case 16: for (int col = 0; col < m_Width; col ++) { @@ -1070,14 +1070,14 @@ void CPDF_DIBSource::TranslateScanline24bpp(FX_LPBYTE dest_scan, FX_LPCBYTE src_ } } } -FX_LPBYTE CPDF_DIBSource::GetBuffer() const +uint8_t* CPDF_DIBSource::GetBuffer() const { if (m_pCachedBitmap) { return m_pCachedBitmap->GetBuffer(); } return NULL; } -FX_LPCBYTE CPDF_DIBSource::GetScanline(int line) const +const uint8_t* CPDF_DIBSource::GetScanline(int line) const { if (m_bpc == 0) { return NULL; @@ -1086,7 +1086,7 @@ FX_LPCBYTE CPDF_DIBSource::GetScanline(int line) const if (!src_pitch.IsValid()) return NULL; FX_DWORD src_pitch_value = src_pitch.ValueOrDie(); - FX_LPCBYTE pSrcLine = NULL; + const uint8_t* pSrcLine = NULL; if (m_pCachedBitmap) { if (line >= m_pCachedBitmap->GetHeight()) { line = m_pCachedBitmap->GetHeight() - 1; @@ -1100,7 +1100,7 @@ FX_LPCBYTE CPDF_DIBSource::GetScanline(int line) const } } if (pSrcLine == NULL) { - FX_LPBYTE pLineBuf = m_pMaskedLine ? m_pMaskedLine : m_pLineBuf; + uint8_t* pLineBuf = m_pMaskedLine ? m_pMaskedLine : m_pLineBuf; FXSYS_memset8(pLineBuf, 0xff, m_Pitch); return pLineBuf; } @@ -1152,8 +1152,8 @@ FX_LPCBYTE CPDF_DIBSource::GetScanline(int line) const } } if (m_bColorKey) { - FX_LPBYTE pDestPixel = m_pMaskedLine; - FX_LPCBYTE pSrcPixel = m_pLineBuf; + uint8_t* pDestPixel = m_pMaskedLine; + const uint8_t* pSrcPixel = m_pLineBuf; for (int col = 0; col < m_Width; col ++) { uint8_t index = *pSrcPixel++; if (m_pPalette) { @@ -1174,9 +1174,9 @@ FX_LPCBYTE CPDF_DIBSource::GetScanline(int line) const } if (m_bColorKey) { if (m_nComponents == 3 && m_bpc == 8) { - FX_LPBYTE alpha_channel = m_pMaskedLine + 3; + uint8_t* alpha_channel = m_pMaskedLine + 3; for (int col = 0; col < m_Width; col ++) { - FX_LPCBYTE pPixel = pSrcLine + col * 3; + const uint8_t* pPixel = pSrcLine + col * 3; alpha_channel[col * 4] = (pPixel[0] < m_pCompData[0].m_ColorKeyMin || pPixel[0] > m_pCompData[0].m_ColorKeyMax || pPixel[1] < m_pCompData[1].m_ColorKeyMin || pPixel[1] > m_pCompData[1].m_ColorKeyMax || pPixel[2] < m_pCompData[2].m_ColorKeyMin || pPixel[2] > m_pCompData[2].m_ColorKeyMax) ? 0xff : 0; @@ -1190,8 +1190,8 @@ FX_LPCBYTE CPDF_DIBSource::GetScanline(int line) const pSrcLine = m_pLineBuf; } if (m_bColorKey) { - FX_LPCBYTE pSrcPixel = pSrcLine; - FX_LPBYTE pDestPixel = m_pMaskedLine; + const uint8_t* pSrcPixel = pSrcLine; + uint8_t* pDestPixel = m_pMaskedLine; for (int col = 0; col < m_Width; col ++) { *pDestPixel++ = *pSrcPixel++; *pDestPixel++ = *pSrcPixel++; @@ -1209,7 +1209,7 @@ FX_BOOL CPDF_DIBSource::SkipToScanline(int line, IFX_Pause* pPause) const } return FALSE; } -void CPDF_DIBSource::DownSampleScanline(int line, FX_LPBYTE dest_scan, int dest_bpp, +void CPDF_DIBSource::DownSampleScanline(int line, uint8_t* dest_scan, int dest_bpp, int dest_width, FX_BOOL bFlipX, int clip_left, int clip_width) const { if (line < 0 || dest_scan == NULL || dest_bpp <= 0 || @@ -1223,7 +1223,7 @@ void CPDF_DIBSource::DownSampleScanline(int line, FX_LPBYTE dest_scan, int dest_ return; } - FX_LPCBYTE pSrcLine = NULL; + const uint8_t* pSrcLine = NULL; if (m_pCachedBitmap) { pSrcLine = m_pCachedBitmap->GetScanline(line); } else if (m_pDecoder) { @@ -1344,7 +1344,7 @@ void CPDF_DIBSource::DownSampleScanline(int line, FX_LPBYTE dest_scan, int dest_ src_x = src_width - src_x - 1; } src_x %= src_width; - FX_LPBYTE pDestPixel = dest_scan + i * 4; + uint8_t* pDestPixel = dest_scan + i * 4; uint8_t index = pSrcLine[src_x]; if (m_pPalette) { *pDestPixel++ = FXARGB_B(m_pPalette[index]); @@ -1386,13 +1386,13 @@ void CPDF_DIBSource::DownSampleScanline(int line, FX_LPBYTE dest_scan, int dest_ int dest_x = clip_left + i; FX_DWORD src_x = (bFlipX ? (dest_width - dest_x - 1) : dest_x) * (int64_t)src_width / dest_width; src_x %= src_width; - FX_LPCBYTE pSrcPixel = NULL; + const uint8_t* pSrcPixel = NULL; if (m_bpc % 8 == 0) { pSrcPixel = pSrcLine + src_x * orig_Bpp; } else { pSrcPixel = pSrcLine + (int)(src_x * orig_Not8Bpp); } - FX_LPBYTE pDestPixel = dest_scan + i * dest_Bpp; + uint8_t* pDestPixel = dest_scan + i * dest_Bpp; FX_ARGB argb; if (src_x == last_src_x) { argb = last_argb; @@ -1536,7 +1536,7 @@ FX_BOOL CPDF_ImageLoader::Load(const CPDF_ImageObject* pImage, CPDF_PageRenderCa } return FALSE; } -FX_BOOL CPDF_ImageLoader::StartLoadImage(const CPDF_ImageObject* pImage, CPDF_PageRenderCache* pCache, FX_LPVOID& LoadHandle, FX_BOOL bStdCS, FX_DWORD GroupFamily, FX_BOOL bLoadMask, CPDF_RenderStatus* pRenderStatus, int32_t nDownsampleWidth, int32_t nDownsampleHeight) +FX_BOOL CPDF_ImageLoader::StartLoadImage(const CPDF_ImageObject* pImage, CPDF_PageRenderCache* pCache, void*& LoadHandle, FX_BOOL bStdCS, FX_DWORD GroupFamily, FX_BOOL bLoadMask, CPDF_RenderStatus* pRenderStatus, int32_t nDownsampleWidth, int32_t nDownsampleHeight) { m_nDownsampleWidth = nDownsampleWidth; m_nDownsampleHeight = nDownsampleHeight; @@ -1545,7 +1545,7 @@ FX_BOOL CPDF_ImageLoader::StartLoadImage(const CPDF_ImageObject* pImage, CPDF_Pa LoadHandle = pLoaderHandle; return ret; } -FX_BOOL CPDF_ImageLoader::Continue(FX_LPVOID LoadHandle, IFX_Pause* pPause) +FX_BOOL CPDF_ImageLoader::Continue(void* LoadHandle, IFX_Pause* pPause) { return ((CPDF_ProgressiveImageLoaderHandle*)LoadHandle)->Continue(pPause); } diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render_pattern.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render_pattern.cpp index e02cd421ff..2243bff979 100644 --- a/core/src/fpdfapi/fpdf_render/fpdf_render_pattern.cpp +++ b/core/src/fpdfapi/fpdf_render/fpdf_render_pattern.cpp @@ -357,7 +357,7 @@ static void _DrawGouraud(CFX_DIBitmap* pBitmap, int alpha, CPDF_MeshVertex trian if (end_x > pBitmap->GetWidth()) { end_x = pBitmap->GetWidth(); } - FX_LPBYTE dib_buf = pBitmap->GetBuffer() + y * pBitmap->GetPitch() + start_x * 4; + uint8_t* dib_buf = pBitmap->GetBuffer() + y * pBitmap->GetPitch() + start_x * 4; FX_FLOAT r_unit = (r[end_index] - r[start_index]) / (max_x - min_x); FX_FLOAT g_unit = (g[end_index] - g[start_index]) / (max_x - min_x); FX_FLOAT b_unit = (b[end_index] - b[start_index]) / (max_x - min_x); @@ -1066,7 +1066,7 @@ void CPDF_RenderStatus::DrawTilingPattern(CPDF_TilingPattern* pPattern, CPDF_Pag if (pPattern->m_bColored) { *dest_buf = *src_buf; } else { - *dest_buf = (*(FX_LPBYTE)src_buf << 24) | (fill_argb & 0xffffff); + *dest_buf = (*(uint8_t*)src_buf << 24) | (fill_argb & 0xffffff); } } else { if (pPattern->m_bColored) { diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render_text.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render_text.cpp index 410e78a67b..e8ef861ba1 100644 --- a/core/src/fpdfapi/fpdf_render/fpdf_render_text.cpp +++ b/core/src/fpdfapi/fpdf_render/fpdf_render_text.cpp @@ -33,17 +33,17 @@ CFX_GlyphBitmap* CPDF_Type3Cache::LoadGlyph(FX_DWORD charcode, const CFX_AffineM m_SizeMap.SetAt(FaceGlyphsKey, pSizeCache); } CFX_GlyphBitmap* pGlyphBitmap; - if(pSizeCache->m_GlyphMap.Lookup((FX_LPVOID)(uintptr_t)charcode, (void*&)pGlyphBitmap)) { + if(pSizeCache->m_GlyphMap.Lookup((void*)(uintptr_t)charcode, (void*&)pGlyphBitmap)) { return pGlyphBitmap; } pGlyphBitmap = RenderGlyph(pSizeCache, charcode, pMatrix, retinaScaleX, retinaScaleY); - pSizeCache->m_GlyphMap.SetAt((FX_LPVOID)(uintptr_t)charcode, pGlyphBitmap); + pSizeCache->m_GlyphMap.SetAt((void*)(uintptr_t)charcode, pGlyphBitmap); return pGlyphBitmap; } CPDF_Type3Glyphs::~CPDF_Type3Glyphs() { FX_POSITION pos = m_GlyphMap.GetStartPosition(); - FX_LPVOID Key; + void* Key; CFX_GlyphBitmap* pGlyphBitmap; while(pos) { m_GlyphMap.GetNextAssoc(pos, Key, (void*&)pGlyphBitmap); @@ -76,7 +76,7 @@ void CPDF_Type3Glyphs::AdjustBlue(FX_FLOAT top, FX_FLOAT bottom, int& top_line, top_line = _AdjustBlue(top, m_TopBlueCount, m_TopBlue); bottom_line = _AdjustBlue(bottom, m_BottomBlueCount, m_BottomBlue); } -static FX_BOOL _IsScanLine1bpp(FX_LPBYTE pBuf, int width) +static FX_BOOL _IsScanLine1bpp(uint8_t* pBuf, int width) { int size = width / 8; for (int i = 0; i < size; i ++) @@ -89,7 +89,7 @@ static FX_BOOL _IsScanLine1bpp(FX_LPBYTE pBuf, int width) } return FALSE; } -static FX_BOOL _IsScanLine8bpp(FX_LPBYTE pBuf, int width) +static FX_BOOL _IsScanLine8bpp(uint8_t* pBuf, int width) { for (int i = 0; i < width; i ++) if (pBuf[i] > 0x40) { @@ -104,7 +104,7 @@ static int _DetectFirstLastScan(const CFX_DIBitmap* pBitmap, FX_BOOL bFirst) if (bpp > 8) { width *= bpp / 8; } - FX_LPBYTE pBuf = pBitmap->GetBuffer(); + uint8_t* pBuf = pBitmap->GetBuffer(); int line = bFirst ? 0 : height - 1; int line_step = bFirst ? 1 : -1; int line_end = bFirst ? height : -1; @@ -564,7 +564,7 @@ void CPDF_CharPosList::Load(int nChars, FX_DWORD* pCharCodes, FX_FLOAT* pCharPos charpos.m_OriginX -= FontSize * vx / 1000; charpos.m_OriginY -= FontSize * vy / 1000; } - FX_LPCBYTE pTransform = pCIDFont->GetCIDTransform(CID); + const uint8_t* pTransform = pCIDFont->GetCIDTransform(CID); if (pTransform && !bVert) { charpos.m_AdjustMatrix[0] = _CIDTransformToFloat(pTransform[0]); charpos.m_AdjustMatrix[2] = _CIDTransformToFloat(pTransform[2]); diff --git a/core/src/fpdfapi/fpdf_render/render_int.h b/core/src/fpdfapi/fpdf_render/render_int.h index 0b6873409b..8d40b17f85 100644 --- a/core/src/fpdfapi/fpdf_render/render_int.h +++ b/core/src/fpdfapi/fpdf_render/render_int.h @@ -197,8 +197,8 @@ public: FX_BOOL Load(const CPDF_ImageObject* pImage, CPDF_PageRenderCache* pCache, FX_BOOL bStdCS = FALSE, FX_DWORD GroupFamily = 0, FX_BOOL bLoadMask = FALSE, CPDF_RenderStatus* pRenderStatus = NULL); - FX_BOOL StartLoadImage(const CPDF_ImageObject* pImage, CPDF_PageRenderCache* pCache, FX_LPVOID& LoadHandle, FX_BOOL bStdCS = FALSE, FX_DWORD GroupFamily = 0, FX_BOOL bLoadMask = FALSE, CPDF_RenderStatus* pRenderStatus = NULL, int32_t nDownsampleWidth = 0, int32_t nDownsampleHeight = 0); - FX_BOOL Continue(FX_LPVOID LoadHandle, IFX_Pause* pPause); + FX_BOOL StartLoadImage(const CPDF_ImageObject* pImage, CPDF_PageRenderCache* pCache, void*& LoadHandle, FX_BOOL bStdCS = FALSE, FX_DWORD GroupFamily = 0, FX_BOOL bLoadMask = FALSE, CPDF_RenderStatus* pRenderStatus = NULL, int32_t nDownsampleWidth = 0, int32_t nDownsampleHeight = 0); + FX_BOOL Continue(void* LoadHandle, IFX_Pause* pPause); ~CPDF_ImageLoader(); CFX_DIBSource* m_pBitmap; CFX_DIBSource* m_pMask; @@ -250,8 +250,8 @@ protected: CPDF_QuickStretcher* m_pQuickStretcher; CFX_ImageTransformer* m_pTransformer; CPDF_ImageRenderer* m_pRenderer2; - FX_LPVOID m_DeviceHandle; - FX_LPVOID m_LoadHandle; + void* m_DeviceHandle; + void* m_LoadHandle; FX_BOOL m_bStdCS; int m_BlendType; FX_BOOL StartBitmapAlpha(); @@ -390,9 +390,9 @@ public: CPDF_Dictionary* pFormResources, CPDF_Dictionary* pPageResources, FX_BOOL bStdCS = FALSE, FX_DWORD GroupFamily = 0, FX_BOOL bLoadMask = FALSE); virtual FX_BOOL SkipToScanline(int line, IFX_Pause* pPause) const; - virtual FX_LPBYTE GetBuffer() const; - virtual FX_LPCBYTE GetScanline(int line) const; - virtual void DownSampleScanline(int line, FX_LPBYTE dest_scan, int dest_bpp, + virtual uint8_t* GetBuffer() const; + virtual const uint8_t* GetScanline(int line) const; + virtual void DownSampleScanline(int line, uint8_t* dest_scan, int dest_bpp, int dest_width, FX_BOOL bFlipX, int clip_left, int clip_width) const; virtual void SetDownSampleSize(int dest_width, int dest_height) const; CFX_DIBitmap* GetBitmap() const; @@ -410,7 +410,7 @@ public: CPDF_DIBSource* DetachMask(); CPDF_DIBSource* m_pMask; FX_DWORD m_MatteColor; - FX_LPVOID m_pJbig2Context; + void* m_pJbig2Context; CPDF_StreamAcc* m_pGlobalStream; FX_BOOL m_bStdCS; int m_Status; @@ -424,7 +424,7 @@ protected: void LoadJpxBitmap(); void LoadPalette(); int CreateDecoder(); - void TranslateScanline24bpp(FX_LPBYTE dest_scan, FX_LPCBYTE src_scan) const; + void TranslateScanline24bpp(uint8_t* dest_scan, const uint8_t* src_scan) const; void ValidateDictParam(); CPDF_Document* m_pDocument; const CPDF_Stream* m_pStream; @@ -442,8 +442,8 @@ protected: FX_BOOL m_bDoBpcCheck; FX_BOOL m_bColorKey; DIB_COMP_DATA* m_pCompData; - FX_LPBYTE m_pLineBuf; - FX_LPBYTE m_pMaskedLine; + uint8_t* m_pLineBuf; + uint8_t* m_pMaskedLine; nonstd::unique_ptr<CFX_DIBitmap> m_pCachedBitmap; ICodec_ScanlineDecoder* m_pDecoder; }; @@ -457,11 +457,11 @@ public: { return NULL; } - virtual void TranslateScanline(FX_LPBYTE dest_buf, FX_LPCBYTE src_buf) const; - virtual void TranslateDownSamples(FX_LPBYTE dest_buf, FX_LPCBYTE src_buf, int pixels, int Bpp) const; - FX_LPCBYTE m_RampR; - FX_LPCBYTE m_RampG; - FX_LPCBYTE m_RampB; + virtual void TranslateScanline(uint8_t* dest_buf, const uint8_t* src_buf) const; + virtual void TranslateDownSamples(uint8_t* dest_buf, const uint8_t* src_buf, int pixels, int Bpp) const; + const uint8_t* m_RampR; + const uint8_t* m_RampG; + const uint8_t* m_RampB; }; struct _CPDF_UniqueKeyGen { void Generate(int count, ...); |