From bb17868d736f698d5217c30d52c5bbfed62c5936 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Tue, 9 Jun 2015 11:30:25 -0700 Subject: Use stdint.h types throughout PDFium. It's redundant nowadays to provide our own equivalents, now that this is done for us by the system header. R=thestig@chromium.org Review URL: https://codereview.chromium.org/1177483002 --- core/src/fpdftext/fpdf_text.cpp | 10 ++--- core/src/fpdftext/fpdf_text_int.cpp | 78 +++++++++++++++++----------------- core/src/fpdftext/fpdf_text_search.cpp | 4 +- core/src/fpdftext/text_int.h | 14 +++--- 4 files changed, 53 insertions(+), 53 deletions(-) (limited to 'core/src/fpdftext') diff --git a/core/src/fpdftext/fpdf_text.cpp b/core/src/fpdftext/fpdf_text.cpp index e58b50d182..fbd6860afb 100644 --- a/core/src/fpdftext/fpdf_text.cpp +++ b/core/src/fpdftext/fpdf_text.cpp @@ -75,7 +75,7 @@ void CTextPage::ProcessObject(CPDF_PageObject* pObject) CFX_AffineMatrix matrix; pText->GetTextMatrix(&matrix); for (int i = 0; i < pText->m_nChars; i ++) { - FX_DWORD charcode = pText->m_nChars == 1 ? (FX_DWORD)(FX_UINTPTR)pText->m_pCharCodes : pText->m_pCharCodes[i]; + FX_DWORD charcode = pText->m_nChars == 1 ? (FX_DWORD)(uintptr_t)pText->m_pCharCodes : pText->m_pCharCodes[i]; if (charcode == (FX_DWORD) - 1) { continue; } @@ -113,7 +113,7 @@ void CTextPage::ProcessObject(CPDF_PageObject* pObject) int space_count = 0; FX_FLOAT last_left = 0, last_right = 0, segment_left = 0, segment_right = 0; for (int i = 0; i < pText->m_nChars; i ++) { - FX_DWORD charcode = pText->m_nChars == 1 ? (FX_DWORD)(FX_UINTPTR)pText->m_pCharCodes : pText->m_pCharCodes[i]; + FX_DWORD charcode = pText->m_nChars == 1 ? (FX_DWORD)(uintptr_t)pText->m_pCharCodes : pText->m_pCharCodes[i]; if (charcode == (FX_DWORD) - 1) { continue; } @@ -311,11 +311,11 @@ void NormalizeString(CFX_WideString& str) } CFX_WordArray order; FX_BOOL bR2L = FALSE; - FX_INT32 start = 0, count = 0, i = 0; + int32_t start = 0, count = 0, i = 0; int nR2L = 0, nL2R = 0; for (i = 0; i < str.GetLength(); i++) { if(BidiChar->AppendChar(str.GetAt(i))) { - FX_INT32 ret = BidiChar->GetBidiInfo(start, count); + int32_t ret = BidiChar->GetBidiInfo(start, count); order.Add(start); order.Add(count); order.Add(ret); @@ -329,7 +329,7 @@ void NormalizeString(CFX_WideString& str) } } if(BidiChar->EndChar()) { - FX_INT32 ret = BidiChar->GetBidiInfo(start, count); + int32_t ret = BidiChar->GetBidiInfo(start, count); order.Add(start); order.Add(count); order.Add(ret); diff --git a/core/src/fpdftext/fpdf_text_int.cpp b/core/src/fpdftext/fpdf_text_int.cpp index 69d0bc574f..f5fa3d4921 100644 --- a/core/src/fpdftext/fpdf_text_int.cpp +++ b/core/src/fpdftext/fpdf_text_int.cpp @@ -649,7 +649,7 @@ void CPDF_TextPage::GetCharInfo(int index, FPDF_CHAR_INFO & info) const info.m_Matrix.Copy(charinfo.m_Matrix); return; } -void CPDF_TextPage::CheckMarkedContentObject(FX_INT32& start, FX_INT32& nCount) const +void CPDF_TextPage::CheckMarkedContentObject(int32_t& start, int32_t& nCount) const { PAGECHAR_INFO charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(start); PAGECHAR_INFO charinfo2 = *(PAGECHAR_INFO*)m_charList.GetAt(start + nCount - 1); @@ -960,24 +960,24 @@ int CPDF_TextPage::GetWordBreak(int index, int direction) const } return breakPos; } -FX_INT32 CPDF_TextPage::FindTextlineFlowDirection() +int32_t CPDF_TextPage::FindTextlineFlowDirection() { if (!m_pPage) { return -1; } - const FX_INT32 nPageWidth = (FX_INT32)((CPDF_Page*)m_pPage)->GetPageWidth(); - const FX_INT32 nPageHeight = (FX_INT32)((CPDF_Page*)m_pPage)->GetPageHeight(); + const int32_t nPageWidth = (int32_t)((CPDF_Page*)m_pPage)->GetPageWidth(); + const int32_t nPageHeight = (int32_t)((CPDF_Page*)m_pPage)->GetPageHeight(); CFX_ByteArray nHorizontalMask; if (!nHorizontalMask.SetSize(nPageWidth)) { return -1; } - FX_BYTE* pDataH = nHorizontalMask.GetData(); + uint8_t* pDataH = nHorizontalMask.GetData(); CFX_ByteArray nVerticalMask; if (!nVerticalMask.SetSize(nPageHeight)) { return -1; } - FX_BYTE* pDataV = nVerticalMask.GetData(); - FX_INT32 index = 0; + uint8_t* pDataV = nVerticalMask.GetData(); + int32_t index = 0; FX_FLOAT fLineHeight = 0.0f; CPDF_PageObject* pPageObj = NULL; FX_POSITION pos = NULL; @@ -993,10 +993,10 @@ FX_INT32 CPDF_TextPage::FindTextlineFlowDirection() if(PDFPAGE_TEXT != pPageObj->m_Type) { continue; } - FX_INT32 minH = (FX_INT32)pPageObj->m_Left < 0 ? 0 : (FX_INT32)pPageObj->m_Left; - FX_INT32 maxH = (FX_INT32)pPageObj->m_Right > nPageWidth ? nPageWidth : (FX_INT32)pPageObj->m_Right; - FX_INT32 minV = (FX_INT32)pPageObj->m_Bottom < 0 ? 0 : (FX_INT32)pPageObj->m_Bottom; - FX_INT32 maxV = (FX_INT32)pPageObj->m_Top > nPageHeight ? nPageHeight : (FX_INT32)pPageObj->m_Top; + int32_t minH = (int32_t)pPageObj->m_Left < 0 ? 0 : (int32_t)pPageObj->m_Left; + int32_t maxH = (int32_t)pPageObj->m_Right > nPageWidth ? nPageWidth : (int32_t)pPageObj->m_Right; + int32_t minV = (int32_t)pPageObj->m_Bottom < 0 ? 0 : (int32_t)pPageObj->m_Bottom; + int32_t maxV = (int32_t)pPageObj->m_Top > nPageHeight ? nPageHeight : (int32_t)pPageObj->m_Top; if (minH >= maxH || minV >= maxV) { continue; } @@ -1007,8 +1007,8 @@ FX_INT32 CPDF_TextPage::FindTextlineFlowDirection() } pPageObj = NULL; } - FX_INT32 nStartH = 0; - FX_INT32 nEndH = 0; + int32_t nStartH = 0; + int32_t nEndH = 0; FX_FLOAT nSumH = 0.0f; for (index = 0; index < nPageWidth; index++) if(1 == nHorizontalMask[index]) { @@ -1024,8 +1024,8 @@ FX_INT32 CPDF_TextPage::FindTextlineFlowDirection() nSumH += nHorizontalMask[index]; } nSumH /= nEndH - nStartH; - FX_INT32 nStartV = 0; - FX_INT32 nEndV = 0; + int32_t nStartV = 0; + int32_t nEndV = 0; FX_FLOAT nSumV = 0.0f; for (index = 0; index < nPageHeight; index++) if(1 == nVerticalMask[index]) { @@ -1041,10 +1041,10 @@ FX_INT32 CPDF_TextPage::FindTextlineFlowDirection() nSumV += nVerticalMask[index]; } nSumV /= nEndV - nStartV; - if ((nEndV - nStartV) < (FX_INT32)(2 * fLineHeight)) { + if ((nEndV - nStartV) < (int32_t)(2 * fLineHeight)) { return 0; } - if ((nEndH - nStartH) < (FX_INT32)(2 * fLineHeight)) { + if ((nEndH - nStartH) < (int32_t)(2 * fLineHeight)) { return 1; } if (nSumH > 0.8f) { @@ -1138,8 +1138,8 @@ int CPDF_TextPage::GetCharWidth(FX_DWORD charCode, CPDF_Font* pFont) const } void CPDF_TextPage::OnPiece(IFX_BidiChar* pBidi, CFX_WideString& str) { - FX_INT32 start, count; - FX_INT32 ret = pBidi->GetBidiInfo(start, count); + int32_t start, count; + int32_t ret = pBidi->GetBidiInfo(start, count); if(ret == 2) { for(int i = start + count - 1; i >= start; i--) { m_TextBuf.AppendChar(str.GetAt(i)); @@ -1229,7 +1229,7 @@ void CPDF_TextPage::CloseTempLine() CFX_WideString str = m_TempTextBuf.GetWideString(); CFX_WordArray order; FX_BOOL bR2L = FALSE; - FX_INT32 start = 0, count = 0; + int32_t start = 0, count = 0; int nR2L = 0, nL2R = 0; FX_BOOL bPrevSpace = FALSE; for (int i = 0; i < str.GetLength(); i++) { @@ -1247,7 +1247,7 @@ void CPDF_TextPage::CloseTempLine() bPrevSpace = FALSE; } if(BidiChar && BidiChar->AppendChar(str.GetAt(i))) { - FX_INT32 ret = BidiChar->GetBidiInfo(start, count); + int32_t ret = BidiChar->GetBidiInfo(start, count); order.Add(start); order.Add(count); order.Add(ret); @@ -1261,7 +1261,7 @@ void CPDF_TextPage::CloseTempLine() } } if(BidiChar && BidiChar->EndChar()) { - FX_INT32 ret = BidiChar->GetBidiInfo(start, count); + int32_t ret = BidiChar->GetBidiInfo(start, count); order.Add(start); order.Add(count); order.Add(ret); @@ -1435,7 +1435,7 @@ void CPDF_TextPage::ProcessTextObject(CPDF_TextObject* pTextObj, const CFX_Affin m_LineObj.Add(Obj); } } -FX_INT32 CPDF_TextPage::PreMarkedContent(PDFTEXT_Obj Obj) +int32_t CPDF_TextPage::PreMarkedContent(PDFTEXT_Obj Obj) { CPDF_TextObject* pTextObj = Obj.m_pTextObj; CPDF_ContentMarkData* pMarkData = (CPDF_ContentMarkData*)pTextObj->m_ContentMark.GetObject(); @@ -1595,7 +1595,7 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) CFX_AffineMatrix matrix; pTextObj->GetTextMatrix(&matrix); matrix.Concat(formMatrix); - FX_INT32 bPreMKC = PreMarkedContent(Obj); + int32_t bPreMKC = PreMarkedContent(Obj); if (FPDFTEXT_MC_DONE == bPreMKC) { m_pPreTextObj = pTextObj; m_perMatrix.Copy(formMatrix); @@ -1642,7 +1642,7 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) } } } else if (result == 3 && !m_ParseOptions.m_bOutputHyphen) { - FX_INT32 nChars = pTextObj->CountChars(); + int32_t nChars = pTextObj->CountChars(); if (nChars == 1) { CPDF_TextObjectItem item; pTextObj->GetCharInfo(0, &item); @@ -1682,8 +1682,8 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) const FX_BOOL bR2L = IsRightToLeft(pTextObj, pFont, nItems); const FX_BOOL bIsBidiAndMirrorInverse = bR2L && (matrix.a * matrix.d - matrix.b * matrix.c) < 0; - FX_INT32 iBufStartAppend = m_TempTextBuf.GetLength(); - FX_INT32 iCharListStartAppend = m_TempCharList.GetSize(); + int32_t iBufStartAppend = m_TempTextBuf.GetLength(); + int32_t iCharListStartAppend = m_TempCharList.GetSize(); FX_FLOAT spacing = 0; for (int i = 0; i < nItems; i++) { @@ -1830,10 +1830,10 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) SwapTempTextBuf(iCharListStartAppend, iBufStartAppend); } } -void CPDF_TextPage::SwapTempTextBuf(FX_INT32 iCharListStartAppend, - FX_INT32 iBufStartAppend) +void CPDF_TextPage::SwapTempTextBuf(int32_t iCharListStartAppend, + int32_t iBufStartAppend) { - FX_INT32 i, j; + int32_t i, j; i = iCharListStartAppend; j = m_TempCharList.GetSize() - 1; for (; i < j; i++, j--) { @@ -1852,11 +1852,11 @@ FX_BOOL CPDF_TextPage::IsRightToLeft(const CPDF_TextObject* pTextObj, int nItems) const { IFX_BidiChar* BidiChar = IFX_BidiChar::Create(); - FX_INT32 nR2L = 0; - FX_INT32 nL2R = 0; - FX_INT32 start = 0, count = 0; + int32_t nR2L = 0; + int32_t nL2R = 0; + int32_t start = 0, count = 0; CPDF_TextObjectItem item; - for (FX_INT32 i = 0; i < nItems; i++) { + for (int32_t i = 0; i < nItems; i++) { pTextObj->GetItemInfo(i, &item); if (item.m_CharCode == (FX_DWORD)-1) { continue; @@ -1870,7 +1870,7 @@ FX_BOOL CPDF_TextPage::IsRightToLeft(const CPDF_TextObject* pTextObj, continue; } if (BidiChar && BidiChar->AppendChar(wChar)) { - FX_INT32 ret = BidiChar->GetBidiInfo(start, count); + int32_t ret = BidiChar->GetBidiInfo(start, count); if (ret == 2) { nR2L++; } @@ -1880,7 +1880,7 @@ FX_BOOL CPDF_TextPage::IsRightToLeft(const CPDF_TextObject* pTextObj, } } if (BidiChar && BidiChar->EndChar()) { - FX_INT32 ret = BidiChar->GetBidiInfo(start, count); + int32_t ret = BidiChar->GetBidiInfo(start, count); if (ret == 2) { nR2L++; } @@ -1892,9 +1892,9 @@ FX_BOOL CPDF_TextPage::IsRightToLeft(const CPDF_TextObject* pTextObj, BidiChar->Release(); return (nR2L > 0 && nR2L >= nL2R); } -FX_INT32 CPDF_TextPage::GetTextObjectWritingMode(const CPDF_TextObject* pTextObj) +int32_t CPDF_TextPage::GetTextObjectWritingMode(const CPDF_TextObject* pTextObj) { - FX_INT32 nChars = pTextObj->CountChars(); + int32_t nChars = pTextObj->CountChars(); if (nChars == 1) { return m_TextlineDir; } @@ -2058,7 +2058,7 @@ int CPDF_TextPage::ProcessInsertObject(const CPDF_TextObject* pObj, const CFX_Af } return 2; } - FX_INT32 nChars = pObj->CountChars(); + int32_t nChars = pObj->CountChars(); if (nChars == 1 && ( 0x2D == curChar || 0xAD == curChar)) if (IsHyphen(curChar)) { return 3; diff --git a/core/src/fpdftext/fpdf_text_search.cpp b/core/src/fpdftext/fpdf_text_search.cpp index bfd742f1ab..89e132991d 100644 --- a/core/src/fpdftext/fpdf_text_search.cpp +++ b/core/src/fpdftext/fpdf_text_search.cpp @@ -266,14 +266,14 @@ FX_BOOL CPDF_TextStream::ProcessObject(const CPDF_TextObject* pObj, FX_BOOL bFir m_Buffer.AppendChar((FX_WCHAR)item.m_CharCode); if (m_pObjArray) { m_pObjArray->Add((void*)pObj); - m_pObjArray->Add((void*)(FX_INTPTR)item_index); + m_pObjArray->Add((void*)(intptr_t)item_index); } } else { m_Buffer << unicode_str; if (m_pObjArray) { for (int i = 0; i < unicode_str.GetLength(); i ++) { m_pObjArray->Add((void*)pObj); - m_pObjArray->Add((void*)(FX_INTPTR)item_index); + m_pObjArray->Add((void*)(intptr_t)item_index); } } } diff --git a/core/src/fpdftext/text_int.h b/core/src/fpdftext/text_int.h index 01d10236fc..70c53d909f 100644 --- a/core/src/fpdftext/text_int.h +++ b/core/src/fpdftext/text_int.h @@ -33,7 +33,7 @@ typedef struct _PAGECHAR_INFO { FX_WCHAR m_Unicode; FX_FLOAT m_OriginX; FX_FLOAT m_OriginY; - FX_INT32 m_Flag; + int32_t m_Flag; CFX_FloatRect m_CharBox; CPDF_TextObject* m_pTextObj; CFX_AffineMatrix m_Matrix; @@ -108,16 +108,16 @@ private: int GetCharWidth(FX_DWORD charCode, CPDF_Font* pFont) const; void CloseTempLine(); void OnPiece(IFX_BidiChar* pBidi, CFX_WideString& str); - FX_INT32 PreMarkedContent(PDFTEXT_Obj pObj); + int32_t PreMarkedContent(PDFTEXT_Obj pObj); void ProcessMarkedContent(PDFTEXT_Obj pObj); - void CheckMarkedContentObject(FX_INT32& start, FX_INT32& nCount) const; + void CheckMarkedContentObject(int32_t& start, int32_t& nCount) const; void FindPreviousTextObject(void); void AddCharInfoByLRDirection(CFX_WideString& str, int i); void AddCharInfoByRLDirection(CFX_WideString& str, int i); - FX_INT32 GetTextObjectWritingMode(const CPDF_TextObject* pTextObj); - FX_INT32 FindTextlineFlowDirection(); - void SwapTempTextBuf(FX_INT32 iCharListStartAppend, - FX_INT32 iBufStartAppend); + int32_t GetTextObjectWritingMode(const CPDF_TextObject* pTextObj); + int32_t FindTextlineFlowDirection(); + void SwapTempTextBuf(int32_t iCharListStartAppend, + int32_t iBufStartAppend); FX_BOOL IsRightToLeft(const CPDF_TextObject* pTextObj, const CPDF_Font* pFont, int nItems) const; -- cgit v1.2.3