summaryrefslogtreecommitdiff
path: root/core/src/fpdfapi
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2015-07-22 14:59:55 -0700
committerTom Sepez <tsepez@chromium.org>2015-07-22 14:59:55 -0700
commit7cc97521db1e52d5927f5605de5f9a7102f8af40 (patch)
treedf96cf98cd470e794c7817f347511f3c554c96e4 /core/src/fpdfapi
parentb05f1fd710496dea44b001bb905fa1c16a39bb28 (diff)
downloadpdfium-7cc97521db1e52d5927f5605de5f9a7102f8af40.tar.xz
Fix else-after-returns throughout pdfium.
Driven by CS search for pcre:yes file:third_party/pdfium/ -file:pdfium/third_party/ \breturn\b[^;]*;\s*\n*\s*\}*\s*\n*\r*else Note: Care is required to ensure the preceding block is not an else-if. As usual, removed any tabs I saw. R=thestig@chromium.org Review URL: https://codereview.chromium.org/1243883003 .
Diffstat (limited to 'core/src/fpdfapi')
-rw-r--r--core/src/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp3
-rw-r--r--core/src/fpdfapi/fpdf_font/fpdf_font.cpp11
-rw-r--r--core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp33
-rw-r--r--core/src/fpdfapi/fpdf_page/fpdf_page.cpp7
-rw-r--r--core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp22
-rw-r--r--core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp3
-rw-r--r--core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp20
-rw-r--r--core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp3
-rw-r--r--core/src/fpdfapi/fpdf_parser/fpdf_parser_fdf.cpp9
-rw-r--r--core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp89
-rw-r--r--core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp150
-rw-r--r--core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp3
-rw-r--r--core/src/fpdfapi/fpdf_render/fpdf_render.cpp6
-rw-r--r--core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp10
-rw-r--r--core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp18
15 files changed, 185 insertions, 202 deletions
diff --git a/core/src/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp b/core/src/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp
index c37e92d832..5a5fb94ef3 100644
--- a/core/src/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp
+++ b/core/src/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp
@@ -521,7 +521,8 @@ static FX_WORD FX_GetCsFromLangCode(uint32_t uCode)
const FX_LANG2CS &charset = gs_FXLang2CharsetTable[iMid];
if (uCode == charset.uLang) {
return charset.uCharset;
- } else if (uCode < charset.uLang) {
+ }
+ 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 9ed5d8ff1c..8037a8c674 100644
--- a/core/src/fpdfapi/fpdf_font/fpdf_font.cpp
+++ b/core/src/fpdfapi/fpdf_font/fpdf_font.cpp
@@ -555,13 +555,12 @@ static FX_DWORD _StringToCode(const CFX_ByteStringC& str)
result = result * 16 + digit;
}
return result;
- } else {
- for (int i = 0; i < len; i ++) {
- if (buf[i] < '0' || buf[i] > '9') {
- break;
- }
- result = result * 10 + buf[i] - '0';
+ }
+ for (int i = 0; i < len; i ++) {
+ if (buf[i] < '0' || buf[i] > '9') {
+ break;
}
+ 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 7a01bba97a..f70b9ecfc4 100644
--- a/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp
+++ b/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp
@@ -641,22 +641,23 @@ int CPDF_CMap::AppendChar(FX_CHAR* str, FX_DWORD charcode) const
}
str[iSize - 1] = (uint8_t)charcode;
return iSize;
- } else if (charcode < 0x10000) {
+ }
+ if (charcode < 0x10000) {
str[0] = (uint8_t)(charcode >> 8);
str[1] = (uint8_t)charcode;
return 2;
- } else if (charcode < 0x1000000) {
+ }
+ 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;
}
@@ -794,9 +795,8 @@ 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,7 +826,8 @@ FX_DWORD CPDF_CIDFont::_CharCodeFromUnicode(FX_WCHAR unicode) const
if (unicode < 0x80) {
return static_cast<FX_DWORD>(unicode);
- } else if (m_pCMap->m_Coding == CIDCODING_CID) {
+ }
+ if (m_pCMap->m_Coding == CIDCODING_CID) {
return 0;
}
#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
@@ -834,14 +835,15 @@ 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];
- } else if (ret == 2) {
+ }
+ if (ret == 2) {
return buffer[0] * 256 + buffer[1];
}
- return 0;
-#endif
+#else
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)
@@ -1234,9 +1236,8 @@ 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 db3966ec17..c0cdb228f4 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page.cpp
@@ -754,18 +754,17 @@ void CPDF_PageObjects::ContinueParse(IFX_Pause* pPause)
}
int CPDF_PageObjects::EstimateParseProgress() const
{
- if (m_pParser == NULL) {
+ if (!m_pParser) {
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 == NULL) {
+ if (!posInsertAfter) {
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 101a197968..198054ef7e 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp
@@ -103,14 +103,15 @@ 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;
- } else if (m_Family == PDFCS_DEVICEGRAY) {
+ }
+ if (m_Family == PDFCS_DEVICEGRAY) {
if (R == G && R == B) {
*pBuf = R;
return TRUE;
- } else {
- return FALSE;
}
- } else if (m_Family == PDFCS_DEVICECMYK) {
+ return FALSE;
+ }
+ if (m_Family == PDFCS_DEVICECMYK) {
sRGB_to_AdobeCMYK(R, G, B, pBuf[0], pBuf[1], pBuf[2], pBuf[3]);
return TRUE;
}
@@ -121,9 +122,8 @@ 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;
- } else if (m_Family == PDFCS_DEVICEGRAY) {
- return FALSE;
- } else if (m_Family == PDFCS_DEVICECMYK) {
+ }
+ if (m_Family == PDFCS_DEVICECMYK) {
pBuf[0] = c;
pBuf[1] = m;
pBuf[2] = y;
@@ -314,9 +314,8 @@ 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
{
@@ -993,10 +992,9 @@ 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 5b5703b868..892e2153b7 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp
@@ -337,7 +337,8 @@ FX_BOOL CPDF_StreamContentParser::OnOperator(const FX_CHAR* op)
if (compare == 0) {
(this->*g_OpCodes[middle].m_OpHandler)();
return TRUE;
- } else if (compare < 0) {
+ }
+ 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 ebd4d83310..37ffea9742 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp
@@ -288,19 +288,25 @@ 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);
- } else if (decoder == FX_BSTRC("ASCII85Decode") || decoder == FX_BSTRC("A85")) {
+ }
+ if (decoder == FX_BSTRC("ASCII85Decode") || decoder == FX_BSTRC("A85")) {
return _A85Decode(src_buf, limit, dest_buf, dest_size);
- } else if (decoder == FX_BSTRC("ASCIIHexDecode") || decoder == FX_BSTRC("AHx")) {
+ }
+ if (decoder == FX_BSTRC("ASCIIHexDecode") || decoder == FX_BSTRC("AHx")) {
return _HexDecode(src_buf, limit, dest_buf, dest_size);
- } else if (decoder == FX_BSTRC("FlateDecode") || decoder == FX_BSTRC("Fl")) {
+ }
+ if (decoder == FX_BSTRC("FlateDecode") || decoder == FX_BSTRC("Fl")) {
return FPDFAPI_FlateOrLZWDecode(FALSE, src_buf, limit, pParam, dest_size, dest_buf, dest_size);
- } else if (decoder == FX_BSTRC("LZWDecode") || decoder == FX_BSTRC("LZW")) {
+ }
+ if (decoder == FX_BSTRC("LZWDecode") || decoder == FX_BSTRC("LZW")) {
return FPDFAPI_FlateOrLZWDecode(TRUE, src_buf, limit, pParam, 0, dest_buf, dest_size);
- } else if (decoder == FX_BSTRC("DCTDecode") || decoder == FX_BSTRC("DCT")) {
+ }
+ 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);
- } else if (decoder == FX_BSTRC("RunLengthDecode") || decoder == FX_BSTRC("RL")) {
+ }
+ 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 9736c3dc8e..47c08fb4a3 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp
@@ -311,9 +311,8 @@ 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 0471250fd9..f630ea52da 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_fdf.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_fdf.cpp
@@ -181,10 +181,9 @@ 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 a3e409df57..c7d1dece25 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;
- else
- return NULL;
+
+ return NULL;
}
void CPDF_Object::SetString(const CFX_ByteString& str)
{
@@ -201,7 +201,8 @@ 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);
- } else if (pOther->m_Type == PDFOBJ_REFERENCE) {
+ }
+ if (pOther->m_Type == PDFOBJ_REFERENCE) {
return IsIdentical(pOther->GetDirect());
}
return FALSE;
@@ -285,27 +286,22 @@ CPDF_Object* CPDF_Object::CloneInternal(FX_BOOL bDirect, CFX_MapPtrToPtr* visite
CPDF_StreamAcc acc;
acc.LoadAllData(pThis, TRUE);
FX_DWORD streamSize = acc.GetSize();
- 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;
+ CPDF_Dictionary* pDict = pThis->GetDict();
+ if (pDict)
+ pDict = (CPDF_Dictionary*)((CPDF_Object*)pDict)->CloneInternal(bDirect, visited);
+ return new CPDF_Stream(acc.DetachData(), streamSize, pDict);
}
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);
- 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);
+ if (!pRef->GetDirect())
+ return nullptr;
+
+ return pRef->GetDirect()->CloneInternal(TRUE, visited);
}
+ return new CPDF_Reference(pRef->m_pObjList, obj_num);
}
}
return NULL;
@@ -321,12 +317,14 @@ CFX_WideString CPDF_Object::GetUnicodeText(CFX_CharMap* pCharMap) const
{
if (m_Type == PDFOBJ_STRING) {
return PDF_DecodeText(((CPDF_String*)this)->m_String, pCharMap);
- } else if (m_Type == PDFOBJ_STREAM) {
+ }
+ 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;
- } else if (m_Type == PDFOBJ_NAME) {
+ }
+ if (m_Type == PDFOBJ_NAME) {
return PDF_DecodeText(((CPDF_Name*)this)->m_Name, pCharMap);
}
return CFX_WideString();
@@ -427,8 +425,7 @@ CFX_ByteString CPDF_Array::GetString(FX_DWORD i) const
CPDF_Object* p = (CPDF_Object*)m_Objects.GetAt(i);
return p->GetString();
}
- else
- return CFX_ByteString();
+ return CFX_ByteString();
}
CFX_ByteStringC CPDF_Array::GetConstString(FX_DWORD i) const
{
@@ -436,8 +433,7 @@ CFX_ByteStringC CPDF_Array::GetConstString(FX_DWORD i) const
CPDF_Object* p = (CPDF_Object*)m_Objects.GetAt(i);
return p->GetConstString();
}
- else
- return CFX_ByteStringC();
+ return CFX_ByteStringC();
}
int CPDF_Array::GetInteger(FX_DWORD i) const
{
@@ -458,11 +454,13 @@ 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 == NULL) {
+ if (!p) {
return NULL;
- } else if (p->GetType() == PDFOBJ_DICTIONARY) {
+ }
+ if (p->GetType() == PDFOBJ_DICTIONARY) {
return (CPDF_Dictionary*)p;
- } else if (p->GetType() == PDFOBJ_STREAM) {
+ }
+ if (p->GetType() == PDFOBJ_STREAM) {
return ((CPDF_Stream*)p)->GetDict();
}
return NULL;
@@ -604,19 +602,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();
- else
- return CFX_ByteString();
+ }
+ 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();
- else
- return CFX_ByteStringC();
+ }
+ return CFX_ByteStringC();
}
CFX_WideString CPDF_Dictionary::GetUnicodeText(const CFX_ByteStringC& key, CFX_CharMap* pCharMap) const
{
@@ -647,10 +645,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();
- else
- return CFX_ByteStringC(def);
+ }
+ return CFX_ByteStringC(def);
}
int CPDF_Dictionary::GetInteger(const CFX_ByteStringC& key) const
{
@@ -691,14 +689,16 @@ 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 == NULL) {
- return NULL;
- } else if (p->GetType() == PDFOBJ_DICTIONARY) {
+ if (!p) {
+ return nullptr;
+ }
+ if (p->GetType() == PDFOBJ_DICTIONARY) {
return (CPDF_Dictionary*)p;
- } else if (p->GetType() == PDFOBJ_STREAM) {
+ }
+ if (p->GetType() == PDFOBJ_STREAM) {
return ((CPDF_Stream*)p)->GetDict();
}
- return NULL;
+ return nullptr;
}
CPDF_Array* CPDF_Dictionary::GetArray(const CFX_ByteStringC& key) const
{
@@ -1269,12 +1269,11 @@ 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;
- else
- ((CPDF_Object*)value)->Destroy();
+ }
+ ((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 f7174f7a72..854be75ad4 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
@@ -1993,21 +1993,16 @@ CFX_ByteString CPDF_SyntaxParser::ReadHexString()
void CPDF_SyntaxParser::ToNextLine()
{
uint8_t ch;
- while (1) {
- if (!GetNextChar(ch)) {
- return;
- }
+ while (GetNextChar(ch)) {
if (ch == '\n') {
- return;
+ break;
}
if (ch == '\r') {
GetNextChar(ch);
- if (ch == '\n') {
- return;
- } else {
- m_Pos --;
- return;
+ if (ch != '\n') {
+ --m_Pos;
}
+ break;
}
}
}
@@ -2079,20 +2074,13 @@ 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) {
@@ -2252,25 +2240,18 @@ 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) {
@@ -3140,21 +3121,20 @@ FX_BOOL CPDF_DataAvail::CheckAcroFormSubObject(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);
- 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();
}
- return bRet;
+ m_arrayAcroforms.RemoveAll();
+ } else {
+ m_objs_array.RemoveAll();
+ m_objs_array.Append(new_objs_array);
}
+ return bRet;
}
FX_BOOL CPDF_DataAvail::CheckAcroForm(IFX_DownloadHints* pHints)
{
@@ -3208,16 +3188,14 @@ 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:
@@ -3761,10 +3739,9 @@ 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;
@@ -3799,9 +3776,6 @@ 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();
@@ -3955,7 +3929,8 @@ FX_BOOL CPDF_DataAvail::CheckAllCrossRefStream(IFX_DownloadHints *pHints)
m_Pos = xref_offset;
}
return TRUE;
- } else if (nRet == -1) {
+ }
+ if (nRet == -1) {
m_docStatus = PDF_DATAAVAIL_ERROR;
}
return FALSE;
@@ -4058,11 +4033,10 @@ 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);
@@ -4295,9 +4269,8 @@ 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)
@@ -4363,15 +4336,14 @@ 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)
{
@@ -4381,10 +4353,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;
}
@@ -4539,15 +4511,14 @@ 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)
{
@@ -4604,16 +4575,15 @@ 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 = iLen - 1;
- int32_t iMid = 0;
+ int32_t iHigh = m_number_array.GetSize() - 1;
while (iLow <= iHigh) {
- iMid = (iLow + iHigh) / 2;
+ int32_t iMid = (iLow + iHigh) / 2;
if (m_number_array.GetAt(iMid) == value) {
iNext = iMid;
return TRUE;
- } else if (m_number_array.GetAt(iMid) > value) {
+ }
+ 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 6d425de6f8..4903312645 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp
@@ -165,7 +165,8 @@ CFX_ByteStringC CPDF_SimpleParser::GetWord()
m_dwCurPos ++;
}
return CFX_ByteStringC(pStart, (FX_STRSIZE)(m_dwCurPos - (pStart - m_pData)));
- } else if (dwSize == 1 && pStart[0] == '(') {
+ }
+ 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 12f60632fc..f8b59913e4 100644
--- a/core/src/fpdfapi/fpdf_render/fpdf_render.cpp
+++ b/core/src/fpdfapi/fpdf_render/fpdf_render.cpp
@@ -551,7 +551,8 @@ 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;
- } else if (!pColorData || pColorData->m_FillColor.IsNull()) {
+ }
+ if (!pColorData || pColorData->m_FillColor.IsNull()) {
pColorData = (CPDF_ColorStateData*)(const CPDF_ColorStateData*)m_InitialStates.m_ColorState;
}
FX_COLORREF rgb = pColorData->m_FillRGB;
@@ -580,7 +581,8 @@ 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;
- } else if (!pColorData || pColorData->m_StrokeColor.IsNull()) {
+ }
+ 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 0730206e23..fa9325a4d2 100644
--- a/core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp
+++ b/core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp
@@ -761,7 +761,8 @@ 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;
- } else if (m_Status == 2) {
+ }
+ if (m_Status == 2) {
if (m_pTransformer->Continue(pPause)) {
return TRUE;
}
@@ -784,16 +785,17 @@ FX_BOOL CPDF_ImageRenderer::Continue(IFX_Pause* pPause)
}
delete pBitmap;
return FALSE;
- } else if (m_Status == 3) {
+ }
+ if (m_Status == 3) {
return m_pRenderStatus->m_pDevice->ContinueDIBits(m_DeviceHandle, pPause);
- } else if (m_Status == 4) {
+ }
+ 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 ce29baf738..7d17e78e24 100644
--- a/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp
+++ b/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp
@@ -21,13 +21,17 @@ unsigned int _GetBits8(const uint8_t* pData, int bitpos, int nbits)
unsigned int byte = pData[bitpos / 8];
if (nbits == 8) {
return byte;
- } else if (nbits == 4) {
+ }
+ if (nbits == 4) {
return (bitpos % 8) ? (byte & 0x0f) : (byte >> 4);
- } else if (nbits == 2) {
+ }
+ if (nbits == 2) {
return (byte >> (6 - bitpos % 8)) & 0x03;
- } else if (nbits == 1) {
+ }
+ if (nbits == 1) {
return (byte >> (7 - bitpos % 8)) & 0x01;
- } else if (nbits == 16) {
+ }
+ if (nbits == 16) {
return byte * 256 + pData[bitpos / 8 + 1];
}
return 0;
@@ -462,7 +466,8 @@ int CPDF_DIBSource::ContinueLoadDIBSource(IFX_Pause* pPause)
m_pColorSpace->EnableStdConversion(FALSE);
}
return ret1;
- } else if (m_Status == 2) {
+ }
+ if (m_Status == 2) {
return ContinueLoadMaskDIB(pPause);
}
return 0;
@@ -1008,7 +1013,8 @@ void CPDF_DIBSource::TranslateScanline24bpp(uint8_t* dest_scan, const uint8_t* s
break;
}
return;
- } else if (m_bpc == 8) {
+ }
+ 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);