diff options
Diffstat (limited to 'core/src/fpdfapi')
-rw-r--r-- | core/src/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp | 3 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_font/fpdf_font.cpp | 11 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp | 33 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_page/fpdf_page.cpp | 7 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp | 22 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp | 3 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp | 20 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp | 3 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_parser/fpdf_parser_fdf.cpp | 9 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp | 89 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp | 150 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp | 3 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_render/fpdf_render.cpp | 6 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp | 10 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp | 18 |
15 files changed, 202 insertions, 185 deletions
diff --git a/core/src/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp b/core/src/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp index 5a5fb94ef3..c37e92d832 100644 --- a/core/src/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp +++ b/core/src/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp @@ -521,8 +521,7 @@ static FX_WORD FX_GetCsFromLangCode(uint32_t uCode) const FX_LANG2CS &charset = gs_FXLang2CharsetTable[iMid]; if (uCode == charset.uLang) { return charset.uCharset; - } - if (uCode < charset.uLang) { + } else if (uCode < charset.uLang) { iEnd = iMid - 1; } else { iStart = iMid + 1; diff --git a/core/src/fpdfapi/fpdf_font/fpdf_font.cpp b/core/src/fpdfapi/fpdf_font/fpdf_font.cpp index 8037a8c674..9ed5d8ff1c 100644 --- a/core/src/fpdfapi/fpdf_font/fpdf_font.cpp +++ b/core/src/fpdfapi/fpdf_font/fpdf_font.cpp @@ -555,12 +555,13 @@ static FX_DWORD _StringToCode(const CFX_ByteStringC& str) result = result * 16 + digit; } return result; - } - for (int i = 0; i < len; i ++) { - if (buf[i] < '0' || buf[i] > '9') { - break; + } else { + for (int i = 0; i < len; i ++) { + if (buf[i] < '0' || buf[i] > '9') { + break; + } + result = result * 10 + buf[i] - '0'; } - result = result * 10 + buf[i] - '0'; } return result; } diff --git a/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp b/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp index f70b9ecfc4..7a01bba97a 100644 --- a/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp +++ b/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp @@ -641,23 +641,22 @@ int CPDF_CMap::AppendChar(FX_CHAR* str, FX_DWORD charcode) const } str[iSize - 1] = (uint8_t)charcode; return iSize; - } - if (charcode < 0x10000) { + } else if (charcode < 0x10000) { str[0] = (uint8_t)(charcode >> 8); str[1] = (uint8_t)charcode; return 2; - } - if (charcode < 0x1000000) { + } else if (charcode < 0x1000000) { str[0] = (uint8_t)(charcode >> 16); str[1] = (uint8_t)(charcode >> 8); str[2] = (uint8_t)charcode; return 3; + } else { + str[0] = (uint8_t)(charcode >> 24); + str[1] = (uint8_t)(charcode >> 16); + str[2] = (uint8_t)(charcode >> 8); + str[3] = (uint8_t)charcode; + return 4; } - str[0] = (uint8_t)(charcode >> 24); - str[1] = (uint8_t)(charcode >> 16); - str[2] = (uint8_t)(charcode >> 8); - str[3] = (uint8_t)charcode; - return 4; } return 0; } @@ -795,8 +794,9 @@ FX_WCHAR CPDF_CIDFont::_UnicodeFromCharCode(FX_DWORD charcode) const #endif if (m_pCMap->m_pEmbedMap) { return _EmbeddedUnicodeFromCharcode(m_pCMap->m_pEmbedMap, m_pCMap->m_Charset, charcode); + } else { + return 0; } - return 0; } return m_pCID2UnicodeMap->UnicodeFromCID(CIDFromCharCode(charcode)); } @@ -826,8 +826,7 @@ FX_DWORD CPDF_CIDFont::_CharCodeFromUnicode(FX_WCHAR unicode) const if (unicode < 0x80) { return static_cast<FX_DWORD>(unicode); - } - if (m_pCMap->m_Coding == CIDCODING_CID) { + } else if (m_pCMap->m_Coding == CIDCODING_CID) { return 0; } #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ @@ -835,15 +834,14 @@ FX_DWORD CPDF_CIDFont::_CharCodeFromUnicode(FX_WCHAR unicode) const int ret = FXSYS_WideCharToMultiByte(g_CharsetCPs[m_pCMap->m_Coding], 0, &unicode, 1, (char*)buffer, 4, NULL, NULL); if (ret == 1) { return buffer[0]; - } - if (ret == 2) { + } else if (ret == 2) { return buffer[0] * 256 + buffer[1]; } -#else + return 0; +#endif if (m_pCMap->m_pEmbedMap) { return _EmbeddedCharcodeFromUnicode(m_pCMap->m_pEmbedMap, m_pCMap->m_Charset, unicode); } -#endif return 0; } static void FT_UseCIDCharmap(FXFT_Face face, int coding) @@ -1236,8 +1234,9 @@ int CPDF_CIDFont::GlyphFromCharCode(FX_DWORD charcode, FX_BOOL *pVertGlyph) } if (index == 0 || index == 0xffff) { return charcode == 0 ? -1 : (int)charcode; + } else { + return index; } - return index; } if (m_Charset == CIDSET_JAPAN1) { if (unicode == '\\') { diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page.cpp index c0cdb228f4..db3966ec17 100644 --- a/core/src/fpdfapi/fpdf_page/fpdf_page.cpp +++ b/core/src/fpdfapi/fpdf_page/fpdf_page.cpp @@ -754,17 +754,18 @@ void CPDF_PageObjects::ContinueParse(IFX_Pause* pPause) } int CPDF_PageObjects::EstimateParseProgress() const { - if (!m_pParser) { + if (m_pParser == NULL) { return m_ParseState == PDF_CONTENT_PARSED ? 100 : 0; } return m_pParser->EstimateProgress(); } FX_POSITION CPDF_PageObjects::InsertObject(FX_POSITION posInsertAfter, CPDF_PageObject* pNewObject) { - if (!posInsertAfter) { + if (posInsertAfter == NULL) { return m_ObjectList.AddHead(pNewObject); + } else { + return m_ObjectList.InsertAfter(posInsertAfter, pNewObject); } - return m_ObjectList.InsertAfter(posInsertAfter, pNewObject); } int CPDF_PageObjects::GetObjectIndex(CPDF_PageObject* pObj) const { diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp index 198054ef7e..101a197968 100644 --- a/core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp +++ b/core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp @@ -103,15 +103,14 @@ FX_BOOL CPDF_DeviceCS::SetRGB(FX_FLOAT* pBuf, FX_FLOAT R, FX_FLOAT G, FX_FLOAT B pBuf[1] = G; pBuf[2] = B; return TRUE; - } - if (m_Family == PDFCS_DEVICEGRAY) { + } else if (m_Family == PDFCS_DEVICEGRAY) { if (R == G && R == B) { *pBuf = R; return TRUE; + } else { + return FALSE; } - return FALSE; - } - if (m_Family == PDFCS_DEVICECMYK) { + } else if (m_Family == PDFCS_DEVICECMYK) { sRGB_to_AdobeCMYK(R, G, B, pBuf[0], pBuf[1], pBuf[2], pBuf[3]); return TRUE; } @@ -122,8 +121,9 @@ FX_BOOL CPDF_DeviceCS::v_SetCMYK(FX_FLOAT* pBuf, FX_FLOAT c, FX_FLOAT m, FX_FLOA if (m_Family == PDFCS_DEVICERGB) { AdobeCMYK_to_sRGB(c, m, y, k, pBuf[0], pBuf[1], pBuf[2]); return TRUE; - } - if (m_Family == PDFCS_DEVICECMYK) { + } else if (m_Family == PDFCS_DEVICEGRAY) { + return FALSE; + } else if (m_Family == PDFCS_DEVICECMYK) { pBuf[0] = c; pBuf[1] = m; pBuf[2] = y; @@ -314,8 +314,9 @@ FX_BOOL CPDF_CalGray::SetRGB(FX_FLOAT* pBuf, FX_FLOAT R, FX_FLOAT G, FX_FLOAT B) if (R == G && R == B) { *pBuf = R; return TRUE; + } else { + return FALSE; } - return FALSE; } void CPDF_CalGray::TranslateImageLine(uint8_t* pDestBuf, const uint8_t* pSrcBuf, int pixels, int image_width, int image_height, FX_BOOL bTransMask) const { @@ -992,9 +993,10 @@ FX_BOOL CPDF_SeparationCS::GetRGB(FX_FLOAT* pBuf, FX_FLOAT& R, FX_FLOAT& G, FX_F if (m_pAltCS) { m_pAltCS->GetRGB(results, R, G, B); return TRUE; + } else { + R = G = B = 0; + return FALSE; } - R = G = B = 0; - return FALSE; } void CPDF_SeparationCS::EnableStdConversion(FX_BOOL bEnabled) { diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp index 892e2153b7..5b5703b868 100644 --- a/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp +++ b/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp @@ -337,8 +337,7 @@ FX_BOOL CPDF_StreamContentParser::OnOperator(const FX_CHAR* op) if (compare == 0) { (this->*g_OpCodes[middle].m_OpHandler)(); return TRUE; - } - if (compare < 0) { + } else if (compare < 0) { high = middle - 1; } else { low = middle + 1; 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 37ffea9742..ebd4d83310 100644 --- a/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp +++ b/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp @@ -288,25 +288,19 @@ FX_DWORD PDF_DecodeInlineStream(const uint8_t* src_buf, FX_DWORD limit, if (decoder == FX_BSTRC("CCITTFaxDecode") || decoder == FX_BSTRC("CCF")) { ICodec_ScanlineDecoder* pDecoder = FPDFAPI_CreateFaxDecoder(src_buf, limit, width, height, pParam); return _DecodeAllScanlines(pDecoder, dest_buf, dest_size); - } - if (decoder == FX_BSTRC("ASCII85Decode") || decoder == FX_BSTRC("A85")) { + } else if (decoder == FX_BSTRC("ASCII85Decode") || decoder == FX_BSTRC("A85")) { return _A85Decode(src_buf, limit, dest_buf, dest_size); - } - if (decoder == FX_BSTRC("ASCIIHexDecode") || decoder == FX_BSTRC("AHx")) { + } else if (decoder == FX_BSTRC("ASCIIHexDecode") || decoder == FX_BSTRC("AHx")) { return _HexDecode(src_buf, limit, dest_buf, dest_size); - } - if (decoder == FX_BSTRC("FlateDecode") || decoder == FX_BSTRC("Fl")) { + } else if (decoder == FX_BSTRC("FlateDecode") || decoder == FX_BSTRC("Fl")) { return FPDFAPI_FlateOrLZWDecode(FALSE, src_buf, limit, pParam, dest_size, dest_buf, dest_size); - } - if (decoder == FX_BSTRC("LZWDecode") || decoder == FX_BSTRC("LZW")) { + } else if (decoder == FX_BSTRC("LZWDecode") || decoder == FX_BSTRC("LZW")) { return FPDFAPI_FlateOrLZWDecode(TRUE, src_buf, limit, pParam, 0, dest_buf, dest_size); - } - if (decoder == FX_BSTRC("DCTDecode") || decoder == FX_BSTRC("DCT")) { + } else if (decoder == FX_BSTRC("DCTDecode") || decoder == FX_BSTRC("DCT")) { ICodec_ScanlineDecoder* pDecoder = CPDF_ModuleMgr::Get()->GetJpegModule()->CreateDecoder( - src_buf, limit, width, height, 0, pParam ? pParam->GetInteger(FX_BSTRC("ColorTransform"), 1) : 1); + src_buf, limit, width, height, 0, pParam ? pParam->GetInteger(FX_BSTRC("ColorTransform"), 1) : 1); return _DecodeAllScanlines(pDecoder, dest_buf, dest_size); - } - if (decoder == FX_BSTRC("RunLengthDecode") || decoder == FX_BSTRC("RL")) { + } else if (decoder == FX_BSTRC("RunLengthDecode") || decoder == FX_BSTRC("RL")) { return RunLengthDecode(src_buf, limit, dest_buf, dest_size); } dest_size = 0; diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp index 47c08fb4a3..9736c3dc8e 100644 --- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp +++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp @@ -311,8 +311,9 @@ FX_BOOL PDF_DataDecode(const uint8_t* src_buf, FX_DWORD src_size, const CPDF_Dic dest_size = last_size; pImageParms = pParam; return TRUE; + } else { + offset = FPDFAPI_FlateOrLZWDecode(FALSE, last_buf, last_size, pParam, estimated_size, new_buf, new_size); } - offset = FPDFAPI_FlateOrLZWDecode(FALSE, last_buf, last_size, pParam, estimated_size, new_buf, new_size); } else if (decoder == FX_BSTRC("LZWDecode") || decoder == FX_BSTRC("LZW")) { offset = FPDFAPI_FlateOrLZWDecode(TRUE, last_buf, last_size, pParam, estimated_size, new_buf, new_size); } else if (decoder == FX_BSTRC("ASCII85Decode") || decoder == FX_BSTRC("A85")) { diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_fdf.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_fdf.cpp index f630ea52da..0471250fd9 100644 --- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_fdf.cpp +++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_fdf.cpp @@ -181,9 +181,10 @@ CFX_WideString FPDF_FileSpec_GetWin32Path(const CPDF_Object* pFileSpec) result += ':'; result += ChangeSlash(wsFileName.c_str() + 2); return result; + } else { + CFX_WideString result; + result += '\\'; + result += ChangeSlash(wsFileName.c_str()); + return result; } - CFX_WideString result; - result += '\\'; - result += ChangeSlash(wsFileName.c_str()); - return result; } diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp index c7d1dece25..a3e409df57 100644 --- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp +++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp @@ -160,8 +160,8 @@ CPDF_Array* CPDF_Object::GetArray() const { if (m_Type == PDFOBJ_ARRAY) return (CPDF_Array*)this; - - return NULL; + else + return NULL; } void CPDF_Object::SetString(const CFX_ByteString& str) { @@ -201,8 +201,7 @@ FX_BOOL CPDF_Object::IsIdentical(CPDF_Object* pOther) const if (pOther->m_Type != m_Type) { if (m_Type == PDFOBJ_REFERENCE && GetDirect()) { return GetDirect()->IsIdentical(pOther); - } - if (pOther->m_Type == PDFOBJ_REFERENCE) { + } else if (pOther->m_Type == PDFOBJ_REFERENCE) { return IsIdentical(pOther->GetDirect()); } return FALSE; @@ -286,22 +285,27 @@ CPDF_Object* CPDF_Object::CloneInternal(FX_BOOL bDirect, CFX_MapPtrToPtr* visite CPDF_StreamAcc acc; acc.LoadAllData(pThis, TRUE); FX_DWORD streamSize = acc.GetSize(); - CPDF_Dictionary* pDict = pThis->GetDict(); - if (pDict) - pDict = (CPDF_Dictionary*)((CPDF_Object*)pDict)->CloneInternal(bDirect, visited); - return new CPDF_Stream(acc.DetachData(), streamSize, pDict); + CPDF_Stream* pObj; + if (pThis->GetDict()) + pObj = new CPDF_Stream(acc.DetachData(), streamSize, (CPDF_Dictionary*)((CPDF_Object*)pThis->GetDict())->CloneInternal(bDirect, visited)); + else + pObj = new CPDF_Stream(acc.DetachData(), streamSize, NULL); + return pObj; } case PDFOBJ_REFERENCE: { CPDF_Reference* pRef = (CPDF_Reference*)this; FX_DWORD obj_num = pRef->m_RefObjNum; if (bDirect && !visited->GetValueAt((void*)(uintptr_t)obj_num)) { visited->SetAt((void*)(uintptr_t)obj_num, (void*)1); - if (!pRef->GetDirect()) - return nullptr; - - return pRef->GetDirect()->CloneInternal(TRUE, visited); + CPDF_Object* ret; + if (pRef->GetDirect()) + ret = pRef->GetDirect()->CloneInternal(TRUE, visited); + else + ret = NULL; + return ret; + } else { + return new CPDF_Reference(pRef->m_pObjList, obj_num); } - return new CPDF_Reference(pRef->m_pObjList, obj_num); } } return NULL; @@ -317,14 +321,12 @@ CFX_WideString CPDF_Object::GetUnicodeText(CFX_CharMap* pCharMap) const { if (m_Type == PDFOBJ_STRING) { return PDF_DecodeText(((CPDF_String*)this)->m_String, pCharMap); - } - if (m_Type == PDFOBJ_STREAM) { + } else if (m_Type == PDFOBJ_STREAM) { CPDF_StreamAcc stream; stream.LoadAllData((CPDF_Stream*)this, FALSE); CFX_WideString result = PDF_DecodeText(stream.GetData(), stream.GetSize(), pCharMap); return result; - } - if (m_Type == PDFOBJ_NAME) { + } else if (m_Type == PDFOBJ_NAME) { return PDF_DecodeText(((CPDF_Name*)this)->m_Name, pCharMap); } return CFX_WideString(); @@ -425,7 +427,8 @@ CFX_ByteString CPDF_Array::GetString(FX_DWORD i) const CPDF_Object* p = (CPDF_Object*)m_Objects.GetAt(i); return p->GetString(); } - return CFX_ByteString(); + else + return CFX_ByteString(); } CFX_ByteStringC CPDF_Array::GetConstString(FX_DWORD i) const { @@ -433,7 +436,8 @@ CFX_ByteStringC CPDF_Array::GetConstString(FX_DWORD i) const CPDF_Object* p = (CPDF_Object*)m_Objects.GetAt(i); return p->GetConstString(); } - return CFX_ByteStringC(); + else + return CFX_ByteStringC(); } int CPDF_Array::GetInteger(FX_DWORD i) const { @@ -454,13 +458,11 @@ FX_FLOAT CPDF_Array::GetNumber(FX_DWORD i) const CPDF_Dictionary* CPDF_Array::GetDict(FX_DWORD i) const { CPDF_Object* p = GetElementValue(i); - if (!p) { + if (p == NULL) { return NULL; - } - if (p->GetType() == PDFOBJ_DICTIONARY) { + } else if (p->GetType() == PDFOBJ_DICTIONARY) { return (CPDF_Dictionary*)p; - } - if (p->GetType() == PDFOBJ_STREAM) { + } else if (p->GetType() == PDFOBJ_STREAM) { return ((CPDF_Stream*)p)->GetDict(); } return NULL; @@ -602,19 +604,19 @@ CFX_ByteString CPDF_Dictionary::GetString(const CFX_ByteStringC& key) const { CPDF_Object* p = NULL; m_Map.Lookup(key, (void*&)p); - if (p) { + if (p) return p->GetString(); - } - return CFX_ByteString(); + else + return CFX_ByteString(); } CFX_ByteStringC CPDF_Dictionary::GetConstString(const CFX_ByteStringC& key) const { CPDF_Object* p = NULL; m_Map.Lookup(key, (void*&)p); - if (p) { + if (p) return p->GetConstString(); - } - return CFX_ByteStringC(); + else + return CFX_ByteStringC(); } CFX_WideString CPDF_Dictionary::GetUnicodeText(const CFX_ByteStringC& key, CFX_CharMap* pCharMap) const { @@ -645,10 +647,10 @@ CFX_ByteStringC CPDF_Dictionary::GetConstString(const CFX_ByteStringC& key, cons { CPDF_Object* p = NULL; m_Map.Lookup(key, (void*&)p); - if (p) { + if (p) return p->GetConstString(); - } - return CFX_ByteStringC(def); + else + return CFX_ByteStringC(def); } int CPDF_Dictionary::GetInteger(const CFX_ByteStringC& key) const { @@ -689,16 +691,14 @@ FX_BOOL CPDF_Dictionary::GetBoolean(const CFX_ByteStringC& key, FX_BOOL bDefault CPDF_Dictionary* CPDF_Dictionary::GetDict(const CFX_ByteStringC& key) const { CPDF_Object* p = GetElementValue(key); - if (!p) { - return nullptr; - } - if (p->GetType() == PDFOBJ_DICTIONARY) { + if (p == NULL) { + return NULL; + } else if (p->GetType() == PDFOBJ_DICTIONARY) { return (CPDF_Dictionary*)p; - } - if (p->GetType() == PDFOBJ_STREAM) { + } else if (p->GetType() == PDFOBJ_STREAM) { return ((CPDF_Stream*)p)->GetDict(); } - return nullptr; + return NULL; } CPDF_Array* CPDF_Dictionary::GetArray(const CFX_ByteStringC& key) const { @@ -1269,11 +1269,12 @@ void CPDF_IndirectObjects::InsertIndirectObject(FX_DWORD objnum, CPDF_Object* pO } void* value = NULL; if (m_IndirectObjs.Lookup((void*)(uintptr_t)objnum, value)) { - if (value) { - if (pObj->GetGenNum() <= ((CPDF_Object*)value)->GetGenNum()) { + if (value) + { + if (pObj->GetGenNum() <= ((CPDF_Object*)value)->GetGenNum()) return; - } - ((CPDF_Object*)value)->Destroy(); + else + ((CPDF_Object*)value)->Destroy(); } } pObj->m_ObjNum = objnum; diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp index 854be75ad4..f7174f7a72 100644 --- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp +++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp @@ -1993,16 +1993,21 @@ CFX_ByteString CPDF_SyntaxParser::ReadHexString() void CPDF_SyntaxParser::ToNextLine() { uint8_t ch; - while (GetNextChar(ch)) { + while (1) { + if (!GetNextChar(ch)) { + return; + } if (ch == '\n') { - break; + return; } if (ch == '\r') { GetNextChar(ch); - if (ch != '\n') { - --m_Pos; + if (ch == '\n') { + return; + } else { + m_Pos --; + return; } - break; } } } @@ -2074,13 +2079,20 @@ CPDF_Object* CPDF_SyntaxParser::GetObject(CPDF_IndirectObjects* pObjList, FX_DWO return (CPDF_Object*)PDFOBJ_REFERENCE; } return new CPDF_Reference(pObjList, objnum); + } else { + m_Pos = SavedPos; + if (bTypeOnly) { + return (CPDF_Object*)PDFOBJ_NUMBER; + } + return CPDF_Number::Create(word); } + } else { + m_Pos = SavedPos; + if (bTypeOnly) { + return (CPDF_Object*)PDFOBJ_NUMBER; + } + return CPDF_Number::Create(word); } - m_Pos = SavedPos; - if (bTypeOnly) { - return (CPDF_Object*)PDFOBJ_NUMBER; - } - return CPDF_Number::Create(word); } if (word == FX_BSTRC("true") || word == FX_BSTRC("false")) { if (bTypeOnly) { @@ -2240,18 +2252,25 @@ CPDF_Object* CPDF_SyntaxParser::GetObjectByStrict(CPDF_IndirectObjects* pObjList if (bIsNumber) { CFX_ByteString nextword2 = GetNextWord(bIsNumber); if (nextword2 == FX_BSTRC("R")) { + FX_DWORD objnum = FXSYS_atoi(word); if (bTypeOnly) { return (CPDF_Object*)PDFOBJ_REFERENCE; } - FX_DWORD objnum = FXSYS_atoi(word); return new CPDF_Reference(pObjList, objnum); + } else { + m_Pos = SavedPos; + if (bTypeOnly) { + return (CPDF_Object*)PDFOBJ_NUMBER; + } + return CPDF_Number::Create(word); } + } else { + m_Pos = SavedPos; + if (bTypeOnly) { + return (CPDF_Object*)PDFOBJ_NUMBER; + } + return CPDF_Number::Create(word); } - m_Pos = SavedPos; - if (bTypeOnly) { - return (CPDF_Object*)PDFOBJ_NUMBER; - } - return CPDF_Number::Create(word); } if (word == FX_BSTRC("true") || word == FX_BSTRC("false")) { if (bTypeOnly) { @@ -3121,20 +3140,21 @@ FX_BOOL CPDF_DataAvail::CheckAcroFormSubObject(IFX_DownloadHints* pHints) m_objs_array.RemoveAll(); } return bRet; - } - CFX_PtrArray new_objs_array; - FX_BOOL bRet = IsObjectsAvail(m_objs_array, FALSE, pHints, new_objs_array); - if (bRet) { - int32_t iSize = m_arrayAcroforms.GetSize(); - for (int32_t i = 0; i < iSize; ++i) { - ((CPDF_Object *)m_arrayAcroforms.GetAt(i))->Release(); - } - m_arrayAcroforms.RemoveAll(); } else { - m_objs_array.RemoveAll(); - m_objs_array.Append(new_objs_array); + CFX_PtrArray new_objs_array; + FX_BOOL bRet = IsObjectsAvail(m_objs_array, FALSE, pHints, new_objs_array); + if (bRet) { + int32_t iSize = m_arrayAcroforms.GetSize(); + for (int32_t i = 0; i < iSize; ++i) { + ((CPDF_Object *)m_arrayAcroforms.GetAt(i))->Release(); + } + m_arrayAcroforms.RemoveAll(); + } else { + m_objs_array.RemoveAll(); + m_objs_array.Append(new_objs_array); + } + return bRet; } - return bRet; } FX_BOOL CPDF_DataAvail::CheckAcroForm(IFX_DownloadHints* pHints) { @@ -3188,14 +3208,16 @@ FX_BOOL CPDF_DataAvail::CheckDocStatus(IFX_DownloadHints *pHints) case PDF_DATAAVAIL_PAGETREE: if (m_bTotalLoadPageTree) { return CheckPages(pHints); + } else { + return LoadDocPages(pHints); } - return LoadDocPages(pHints); case PDF_DATAAVAIL_PAGE: if (m_bTotalLoadPageTree) { return CheckPage(pHints); + } else { + m_docStatus = PDF_DATAAVAIL_PAGE_LATERLOAD; + return TRUE; } - m_docStatus = PDF_DATAAVAIL_PAGE_LATERLOAD; - return TRUE; case PDF_DATAAVAIL_ERROR: return LoadAllFile(pHints); case PDF_DATAAVAIL_PAGE_LATERLOAD: @@ -3739,9 +3761,10 @@ FX_BOOL CPDF_DataAvail::CheckEnd(IFX_DownloadHints* pHints) SetStartOffset(m_dwXRefOffset); m_docStatus = PDF_DATAAVAIL_CROSSREF; return TRUE; + } else { + m_docStatus = PDF_DATAAVAIL_LOADALLFILE; + return TRUE; } - m_docStatus = PDF_DATAAVAIL_LOADALLFILE; - return TRUE; } pHints->AddSegment(req_pos, dwSize); return FALSE; @@ -3776,6 +3799,9 @@ int32_t CPDF_DataAvail::CheckCrossRefStream(IFX_DownloadHints* pHints, FX_FILESI xref_offset = pObj->GetDict()->GetInteger(FX_BSTRC("Prev")); pObj->Release(); return 1; + } else { + pObj->Release(); + return -1; } } pObj->Release(); @@ -3929,8 +3955,7 @@ FX_BOOL CPDF_DataAvail::CheckAllCrossRefStream(IFX_DownloadHints *pHints) m_Pos = xref_offset; } return TRUE; - } - if (nRet == -1) { + } else if (nRet == -1) { m_docStatus = PDF_DATAAVAIL_ERROR; } return FALSE; @@ -4033,10 +4058,11 @@ FX_BOOL CPDF_DataAvail::CheckTrailer(IFX_DownloadHints* pHints) } } return TRUE; + } else { + m_dwPrevXRefOffset = 0; + m_docStatus = PDF_DATAAVAIL_TRAILER_APPEND; + pTrailer->Release(); } - m_dwPrevXRefOffset = 0; - m_docStatus = PDF_DATAAVAIL_TRAILER_APPEND; - pTrailer->Release(); return TRUE; } pHints->AddSegment(m_Pos, iTrailerSize); @@ -4269,8 +4295,9 @@ FX_BOOL CPDF_DataAvail::LoadDocPages(IFX_DownloadHints* pHints) if (CheckPageCount(pHints)) { m_docStatus = PDF_DATAAVAIL_PAGE; return TRUE; + } else { + m_bTotalLoadPageTree = TRUE; } - m_bTotalLoadPageTree = TRUE; return FALSE; } FX_BOOL CPDF_DataAvail::LoadPages(IFX_DownloadHints* pHints) @@ -4336,14 +4363,15 @@ FX_BOOL CPDF_DataAvail::CheckPageAnnots(int32_t iPage, IFX_DownloadHints* pHints m_objs_array.RemoveAll(); } return bRet; + } else { + CFX_PtrArray new_objs_array; + FX_BOOL bRet = IsObjectsAvail(m_objs_array, FALSE, pHints, new_objs_array); + m_objs_array.RemoveAll(); + if (!bRet) { + m_objs_array.Append(new_objs_array); + } + return bRet; } - CFX_PtrArray new_objs_array; - FX_BOOL bRet = IsObjectsAvail(m_objs_array, FALSE, pHints, new_objs_array); - m_objs_array.RemoveAll(); - if (!bRet) { - m_objs_array.Append(new_objs_array); - } - return bRet; } FX_BOOL CPDF_DataAvail::CheckLinearizedFirstPage(int32_t iPage, IFX_DownloadHints* pHints) { @@ -4353,10 +4381,10 @@ FX_BOOL CPDF_DataAvail::CheckLinearizedFirstPage(int32_t iPage, IFX_DownloadHint } m_bAnnotsLoad = TRUE; } - if (m_bAnnotsLoad) { - if (!CheckLinearizedData(pHints)) + if (m_bAnnotsLoad) + if (!CheckLinearizedData(pHints)) { return FALSE; - } + } m_bPageLoadedOK = FALSE; return TRUE; } @@ -4511,14 +4539,15 @@ FX_BOOL CPDF_DataAvail::CheckResources(IFX_DownloadHints* pHints) m_objs_array.RemoveAll(); } return bRet; + } else { + CFX_PtrArray new_objs_array; + FX_BOOL bRet = IsObjectsAvail(m_objs_array, FALSE, pHints, new_objs_array); + m_objs_array.RemoveAll(); + if (!bRet) { + m_objs_array.Append(new_objs_array); + } + return bRet; } - CFX_PtrArray new_objs_array; - FX_BOOL bRet = IsObjectsAvail(m_objs_array, FALSE, pHints, new_objs_array); - m_objs_array.RemoveAll(); - if (!bRet) { - m_objs_array.Append(new_objs_array); - } - return bRet; } void CPDF_DataAvail::GetLinearizedMainXRefInfo(FX_FILESIZE *pPos, FX_DWORD *pSize) { @@ -4575,15 +4604,16 @@ FX_BOOL CPDF_SortObjNumArray::Find(FX_DWORD dwObjNum) } FX_BOOL CPDF_SortObjNumArray::BinarySearch(FX_DWORD value, int32_t &iNext) { + int32_t iLen = m_number_array.GetSize(); int32_t iLow = 0; - int32_t iHigh = m_number_array.GetSize() - 1; + int32_t iHigh = iLen - 1; + int32_t iMid = 0; while (iLow <= iHigh) { - int32_t iMid = (iLow + iHigh) / 2; + iMid = (iLow + iHigh) / 2; if (m_number_array.GetAt(iMid) == value) { iNext = iMid; return TRUE; - } - if (m_number_array.GetAt(iMid) > value) { + } else if (m_number_array.GetAt(iMid) > value) { iHigh = iMid - 1; } else if (m_number_array.GetAt(iMid) < value) { iLow = iMid + 1; diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp index 4903312645..6d425de6f8 100644 --- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp +++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp @@ -165,8 +165,7 @@ CFX_ByteStringC CPDF_SimpleParser::GetWord() m_dwCurPos ++; } return CFX_ByteStringC(pStart, (FX_STRSIZE)(m_dwCurPos - (pStart - m_pData))); - } - if (dwSize == 1 && pStart[0] == '(') { + } else if (dwSize == 1 && pStart[0] == '(') { int level = 1; while (m_dwCurPos < m_dwSize) { if (m_pData[m_dwCurPos] == ')') { diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render.cpp index f8b59913e4..12f60632fc 100644 --- a/core/src/fpdfapi/fpdf_render/fpdf_render.cpp +++ b/core/src/fpdfapi/fpdf_render/fpdf_render.cpp @@ -551,8 +551,7 @@ FX_ARGB CPDF_RenderStatus::GetFillArgb(const CPDF_PageObject* pObj, FX_BOOL bTyp CPDF_ColorStateData* pColorData = (CPDF_ColorStateData*)(const CPDF_ColorStateData*)pObj->m_ColorState; if (m_pType3Char && !bType3 && (!m_pType3Char->m_bColored || (m_pType3Char->m_bColored && (!pColorData || pColorData->m_FillColor.IsNull())))) { return m_T3FillColor; - } - if (!pColorData || pColorData->m_FillColor.IsNull()) { + } else if (!pColorData || pColorData->m_FillColor.IsNull()) { pColorData = (CPDF_ColorStateData*)(const CPDF_ColorStateData*)m_InitialStates.m_ColorState; } FX_COLORREF rgb = pColorData->m_FillRGB; @@ -581,8 +580,7 @@ FX_ARGB CPDF_RenderStatus::GetStrokeArgb(const CPDF_PageObject* pObj) const CPDF_ColorStateData* pColorData = (CPDF_ColorStateData*)(const CPDF_ColorStateData*)pObj->m_ColorState; if (m_pType3Char && (!m_pType3Char->m_bColored || (m_pType3Char->m_bColored && (!pColorData || pColorData->m_StrokeColor.IsNull())))) { return m_T3FillColor; - } - if (!pColorData || pColorData->m_StrokeColor.IsNull()) { + } else if (!pColorData || pColorData->m_StrokeColor.IsNull()) { pColorData = (CPDF_ColorStateData*)(const CPDF_ColorStateData*)m_InitialStates.m_ColorState; } FX_COLORREF rgb = pColorData->m_StrokeRGB; diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp index fa9325a4d2..0730206e23 100644 --- a/core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp +++ b/core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp @@ -761,8 +761,7 @@ FX_BOOL CPDF_ImageRenderer::Continue(IFX_Pause* pPause) m_pRenderStatus->m_pDevice->SetDIBits(m_pQuickStretcher->m_pBitmap, m_pQuickStretcher->m_ResultLeft, m_pQuickStretcher->m_ResultTop, m_BlendType); return FALSE; - } - if (m_Status == 2) { + } else if (m_Status == 2) { if (m_pTransformer->Continue(pPause)) { return TRUE; } @@ -785,17 +784,16 @@ FX_BOOL CPDF_ImageRenderer::Continue(IFX_Pause* pPause) } delete pBitmap; return FALSE; - } - if (m_Status == 3) { + } else if (m_Status == 3) { return m_pRenderStatus->m_pDevice->ContinueDIBits(m_DeviceHandle, pPause); - } - if (m_Status == 4) { + } else if (m_Status == 4) { if (m_Loader.Continue(m_LoadHandle, pPause)) { return TRUE; } if (StartRenderDIBSource()) { return Continue(pPause); } + return FALSE; } return FALSE; } diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp index 7d17e78e24..ce29baf738 100644 --- a/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp +++ b/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp @@ -21,17 +21,13 @@ unsigned int _GetBits8(const uint8_t* pData, int bitpos, int nbits) unsigned int byte = pData[bitpos / 8]; if (nbits == 8) { return byte; - } - if (nbits == 4) { + } else if (nbits == 4) { return (bitpos % 8) ? (byte & 0x0f) : (byte >> 4); - } - if (nbits == 2) { + } else if (nbits == 2) { return (byte >> (6 - bitpos % 8)) & 0x03; - } - if (nbits == 1) { + } else if (nbits == 1) { return (byte >> (7 - bitpos % 8)) & 0x01; - } - if (nbits == 16) { + } else if (nbits == 16) { return byte * 256 + pData[bitpos / 8 + 1]; } return 0; @@ -466,8 +462,7 @@ int CPDF_DIBSource::ContinueLoadDIBSource(IFX_Pause* pPause) m_pColorSpace->EnableStdConversion(FALSE); } return ret1; - } - if (m_Status == 2) { + } else if (m_Status == 2) { return ContinueLoadMaskDIB(pPause); } return 0; @@ -1013,8 +1008,7 @@ void CPDF_DIBSource::TranslateScanline24bpp(uint8_t* dest_scan, const uint8_t* s break; } return; - } - if (m_bpc == 8) { + } else if (m_bpc == 8) { if (m_nComponents == m_pColorSpace->CountComponents()) m_pColorSpace->TranslateImageLine(dest_scan, src_scan, m_Width, m_Width, m_Height, m_bLoadMask && m_GroupFamily == PDFCS_DEVICECMYK && m_Family == PDFCS_DEVICECMYK); |