diff options
Diffstat (limited to 'core/fpdfapi/fpdf_page')
-rw-r--r-- | core/fpdfapi/fpdf_page/cpdf_colorspace.cpp | 12 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_page/cpdf_textobject.cpp | 15 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp | 4 |
3 files changed, 16 insertions, 15 deletions
diff --git a/core/fpdfapi/fpdf_page/cpdf_colorspace.cpp b/core/fpdfapi/fpdf_page/cpdf_colorspace.cpp index 3add21cfed..213d777ecb 100644 --- a/core/fpdfapi/fpdf_page/cpdf_colorspace.cpp +++ b/core/fpdfapi/fpdf_page/cpdf_colorspace.cpp @@ -467,7 +467,7 @@ void CPDF_ColorSpace::GetDefaultColor(FX_FLOAT* buf) const { return; } FX_FLOAT min, max; - for (int i = 0; i < m_nComponents; i++) { + for (uint32_t i = 0; i < m_nComponents; i++) { GetDefaultValue(i, buf[i], min, max); } } @@ -490,7 +490,7 @@ void CPDF_ColorSpace::TranslateImageLine(uint8_t* dest_buf, FX_FLOAT* src = srcbuf; FX_FLOAT R, G, B; for (int i = 0; i < pixels; i++) { - for (int j = 0; j < m_nComponents; j++) + for (uint32_t j = 0; j < m_nComponents; j++) if (m_Family == PDFCS_INDEXED) { src[j] = (FX_FLOAT)(*src_buf++); } else { @@ -842,7 +842,7 @@ FX_BOOL CPDF_ICCBasedCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) { } CPDF_Array* pRanges = pDict->GetArrayBy("Range"); m_pRanges = FX_Alloc2D(FX_FLOAT, m_nComponents, 2); - for (int i = 0; i < m_nComponents * 2; i++) { + for (uint32_t i = 0; i < m_nComponents * 2; i++) { if (pRanges) m_pRanges[i] = pRanges->GetNumberAt(i); else if (i % 2) @@ -918,7 +918,7 @@ void CPDF_ICCBasedCS::TranslateImageLine(uint8_t* pDestBuf, ReverseRGB(pDestBuf, pSrcBuf, pixels); } else if (m_pProfile->m_pTransform) { int nMaxColors = 1; - for (int i = 0; i < m_nComponents; i++) { + for (uint32_t i = 0; i < m_nComponents; i++) { nMaxColors *= 52; } if (m_nComponents > 3 || image_width * image_height < nMaxColors * 3 / 2) { @@ -932,7 +932,7 @@ void CPDF_ICCBasedCS::TranslateImageLine(uint8_t* pDestBuf, for (int i = 0; i < nMaxColors; i++) { uint32_t color = i; uint32_t order = nMaxColors / 52; - for (int c = 0; c < m_nComponents; c++) { + for (uint32_t c = 0; c < m_nComponents; c++) { *pSrc++ = (uint8_t)(color / order * 5); color %= order; order /= 52; @@ -944,7 +944,7 @@ void CPDF_ICCBasedCS::TranslateImageLine(uint8_t* pDestBuf, } for (int i = 0; i < pixels; i++) { int index = 0; - for (int c = 0; c < m_nComponents; c++) { + for (uint32_t c = 0; c < m_nComponents; c++) { index = index * 52 + (*pSrcBuf) / 5; pSrcBuf++; } diff --git a/core/fpdfapi/fpdf_page/cpdf_textobject.cpp b/core/fpdfapi/fpdf_page/cpdf_textobject.cpp index 7ca03b4f05..444101fb9e 100644 --- a/core/fpdfapi/fpdf_page/cpdf_textobject.cpp +++ b/core/fpdfapi/fpdf_page/cpdf_textobject.cpp @@ -28,7 +28,7 @@ void CPDF_TextObject::GetItemInfo(int index, CPDF_TextObjectItem* pInfo) const { m_nChars == 1 ? (uint32_t)(uintptr_t)m_pCharCodes : m_pCharCodes[index]; pInfo->m_OriginX = index ? m_pCharPos[index - 1] : 0; pInfo->m_OriginY = 0; - if (pInfo->m_CharCode == -1) { + if (pInfo->m_CharCode == CPDF_Font::kInvalidCharCode) { return; } CPDF_Font* pFont = m_TextState.GetFont(); @@ -54,7 +54,7 @@ int CPDF_TextObject::CountChars() const { } int count = 0; for (int i = 0; i < m_nChars; ++i) - if (m_pCharCodes[i] != (uint32_t)-1) { + if (m_pCharCodes[i] != CPDF_Font::kInvalidCharCode) { ++count; } return count; @@ -70,10 +70,11 @@ void CPDF_TextObject::GetCharInfo(int index, } int count = 0; for (int i = 0; i < m_nChars; ++i) { - if (m_pCharCodes[i] != (uint32_t)-1) { + if (m_pCharCodes[i] != CPDF_Font::kInvalidCharCode) { if (count == index) { charcode = m_pCharCodes[i]; - if (i == m_nChars - 1 || m_pCharCodes[i + 1] != (uint32_t)-1) { + if (i == m_nChars - 1 || + m_pCharCodes[i + 1] != CPDF_Font::kInvalidCharCode) { kerning = 0; } else { kerning = m_pCharPos[i]; @@ -93,7 +94,7 @@ void CPDF_TextObject::GetCharInfo(int index, CPDF_TextObjectItem* pInfo) const { int count = 0; for (int i = 0; i < m_nChars; ++i) { uint32_t charcode = m_pCharCodes[i]; - if (charcode == (uint32_t)-1) { + if (charcode == CPDF_Font::kInvalidCharCode) { continue; } if (count == index) { @@ -156,7 +157,7 @@ void CPDF_TextObject::SetSegments(const CFX_ByteString* pStrs, } if (i != nsegs - 1) { m_pCharPos[index - 1] = pKerning[i]; - m_pCharCodes[index++] = (uint32_t)-1; + m_pCharCodes[index++] = CPDF_Font::kInvalidCharCode; } } } else { @@ -206,7 +207,7 @@ void CPDF_TextObject::CalcPositionData(FX_FLOAT* pTextAdvanceX, uint32_t charcode = m_nChars == 1 ? (uint32_t)(uintptr_t)m_pCharCodes : m_pCharCodes[i]; if (i > 0) { - if (charcode == (uint32_t)-1) { + if (charcode == CPDF_Font::kInvalidCharCode) { curpos -= (m_pCharPos[i - 1] * fontsize) / 1000; continue; } diff --git a/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp b/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp index f2b7582a01..8bff5445ff 100644 --- a/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp +++ b/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp @@ -48,7 +48,7 @@ uint32_t DecodeAllScanlines(ICodec_ScanlineDecoder* pDecoder, uint8_t*& dest_buf, uint32_t& dest_size) { if (!pDecoder) { - return static_cast<uint32_t>(-1); + return FX_INVALID_OFFSET; } int ncomps = pDecoder->CountComps(); int bpc = pDecoder->GetBPC(); @@ -57,7 +57,7 @@ uint32_t DecodeAllScanlines(ICodec_ScanlineDecoder* pDecoder, int pitch = (width * ncomps * bpc + 7) / 8; if (height == 0 || pitch > (1 << 30) / height) { delete pDecoder; - return static_cast<uint32_t>(-1); + return FX_INVALID_OFFSET; } dest_buf = FX_Alloc2D(uint8_t, pitch, height); dest_size = pitch * height; // Safe since checked alloc returned. |