diff options
author | Lei Zhang <thestig@chromium.org> | 2017-12-01 22:52:42 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-12-01 22:52:42 +0000 |
commit | b8d86800487df4021860f08407c323ed82243c79 (patch) | |
tree | ac91e7e9405cf47594316623b26a0aadd9544e79 | |
parent | dca380ffe0571be4023b11b06b8aecad9934bb06 (diff) | |
download | pdfium-chromium/3284.tar.xz |
Get rid of else after break/continue/return.chromium/3284chromium/3283
Change-Id: I3efc57cd7325d16e3ca8ebdeeaec06012b2c56e3
Reviewed-on: https://pdfium-review.googlesource.com/20110
Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
-rw-r--r-- | core/fpdfapi/edit/cpdf_creator.cpp | 5 | ||||
-rw-r--r-- | core/fpdfapi/page/cpdf_streamparser.cpp | 12 | ||||
-rw-r--r-- | core/fpdfapi/parser/cpdf_parser.cpp | 3 | ||||
-rw-r--r-- | core/fpdfapi/parser/cpdf_syntax_parser.cpp | 7 | ||||
-rw-r--r-- | core/fpdfapi/parser/fpdf_parser_decode.cpp | 4 | ||||
-rw-r--r-- | core/fpdfdoc/cpdf_variabletext.cpp | 10 | ||||
-rw-r--r-- | core/fpdftext/cpdf_textpage.cpp | 64 | ||||
-rw-r--r-- | core/fpdftext/cpdf_textpagefind.cpp | 11 | ||||
-rw-r--r-- | core/fxcodec/codec/fx_codec_flate.cpp | 5 | ||||
-rw-r--r-- | core/fxcodec/jbig2/JBig2_SddProc.cpp | 26 | ||||
-rw-r--r-- | core/fxcrt/xml/cfx_xmlnode.cpp | 6 | ||||
-rw-r--r-- | core/fxcrt/xml/cfx_xmlparser.cpp | 3 | ||||
-rw-r--r-- | core/fxcrt/xml/cfx_xmlsyntaxparser.cpp | 3 | ||||
-rw-r--r-- | fxbarcode/oned/BC_OnedCode39Writer.cpp | 3 | ||||
-rw-r--r-- | fxbarcode/pdf417/BC_PDF417HighLevelEncoder.cpp | 106 | ||||
-rw-r--r-- | fxjs/cfxjse_resolveprocessor.cpp | 9 | ||||
-rw-r--r-- | xfa/fgas/crt/cfgas_formatstring.cpp | 39 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp | 3 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_layoutpagemgr.cpp | 4 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_nodehelper.cpp | 62 |
20 files changed, 181 insertions, 204 deletions
diff --git a/core/fpdfapi/edit/cpdf_creator.cpp b/core/fpdfapi/edit/cpdf_creator.cpp index db5bd681d4..e31da13a4d 100644 --- a/core/fpdfapi/edit/cpdf_creator.cpp +++ b/core/fpdfapi/edit/cpdf_creator.cpp @@ -184,10 +184,7 @@ bool CPDF_Creator::WriteStream(const CPDF_Object* pStream, return false; } - if (!m_Archive->WriteString("\r\nendstream")) - return false; - - return true; + return m_Archive->WriteString("\r\nendstream"); } bool CPDF_Creator::WriteIndirectObj(uint32_t objnum, const CPDF_Object* pObj) { diff --git a/core/fpdfapi/page/cpdf_streamparser.cpp b/core/fpdfapi/page/cpdf_streamparser.cpp index aa1d227de0..2c7e0256f5 100644 --- a/core/fpdfapi/page/cpdf_streamparser.cpp +++ b/core/fpdfapi/page/cpdf_streamparser.cpp @@ -499,7 +499,13 @@ ByteString CPDF_StreamParser::ReadString() { status = 2; break; } - if (ch == 'n') { + if (ch == '\r') { + status = 4; + break; + } + if (ch == '\n') { + // Do nothing. + } else if (ch == 'n') { buf << '\n'; } else if (ch == 'r') { buf << '\r'; @@ -509,10 +515,6 @@ ByteString CPDF_StreamParser::ReadString() { buf << '\b'; } else if (ch == 'f') { buf << '\f'; - } else if (ch == '\r') { - status = 4; - break; - } else if (ch == '\n') { } else { buf << static_cast<char>(ch); } diff --git a/core/fpdfapi/parser/cpdf_parser.cpp b/core/fpdfapi/parser/cpdf_parser.cpp index 5b57b949ba..4e77773a3b 100644 --- a/core/fpdfapi/parser/cpdf_parser.cpp +++ b/core/fpdfapi/parser/cpdf_parser.cpp @@ -394,9 +394,8 @@ bool CPDF_Parser::VerifyCrossRefV4() { // If the object number read doesn't match the one stored, // something is wrong with the cross reference table. return false; - } else { - return true; } + return true; } return true; } diff --git a/core/fpdfapi/parser/cpdf_syntax_parser.cpp b/core/fpdfapi/parser/cpdf_syntax_parser.cpp index ddf420b34a..66ce1838f2 100644 --- a/core/fpdfapi/parser/cpdf_syntax_parser.cpp +++ b/core/fpdfapi/parser/cpdf_syntax_parser.cpp @@ -208,6 +208,10 @@ ByteString CPDF_SyntaxParser::ReadString() { break; } + if (ch == '\r') { + status = ReadStatus::CarriageReturn; + break; + } if (ch == 'n') { buf << '\n'; } else if (ch == 'r') { @@ -218,9 +222,6 @@ ByteString CPDF_SyntaxParser::ReadString() { buf << '\b'; } else if (ch == 'f') { buf << '\f'; - } else if (ch == '\r') { - status = ReadStatus::CarriageReturn; - break; } else if (ch != '\n') { buf << static_cast<char>(ch); } diff --git a/core/fpdfapi/parser/fpdf_parser_decode.cpp b/core/fpdfapi/parser/fpdf_parser_decode.cpp index 9532b8242d..3a8660f0a4 100644 --- a/core/fpdfapi/parser/fpdf_parser_decode.cpp +++ b/core/fpdfapi/parser/fpdf_parser_decode.cpp @@ -361,6 +361,8 @@ bool PDF_DataDecode(const uint8_t* src_buf, uint8_t* new_buf = nullptr; uint32_t new_size = 0xFFFFFFFF; int offset = -1; + if (decoder == "Crypt") + continue; if (decoder == "FlateDecode" || decoder == "Fl") { if (bImageAcc && i == nSize - 1) { *ImageEncoding = "FlateDecode"; @@ -387,8 +389,6 @@ bool PDF_DataDecode(const uint8_t* src_buf, return true; } offset = RunLengthDecode(last_buf, last_size, &new_buf, &new_size); - } else if (decoder == "Crypt") { - continue; } else { // If we get here, assume it's an image decoder. if (decoder == "DCT") diff --git a/core/fpdfdoc/cpdf_variabletext.cpp b/core/fpdfdoc/cpdf_variabletext.cpp index 18aa95793f..82a8d6757b 100644 --- a/core/fpdfdoc/cpdf_variabletext.cpp +++ b/core/fpdfdoc/cpdf_variabletext.cpp @@ -897,15 +897,11 @@ float CPDF_VariableText::GetAutoFontSize() { int32_t nRight = nTotal - 1; int32_t nMid = nTotal / 2; while (nLeft <= nRight) { - if (IsBigger(gFontSizeSteps[nMid])) { + if (IsBigger(gFontSizeSteps[nMid])) nRight = nMid - 1; - nMid = (nLeft + nRight) / 2; - continue; - } else { + else nLeft = nMid + 1; - nMid = (nLeft + nRight) / 2; - continue; - } + nMid = (nLeft + nRight) / 2; } return (float)gFontSizeSteps[nMid]; } diff --git a/core/fpdftext/cpdf_textpage.cpp b/core/fpdftext/cpdf_textpage.cpp index 8ef5522bae..98eacf3c14 100644 --- a/core/fpdftext/cpdf_textpage.cpp +++ b/core/fpdftext/cpdf_textpage.cpp @@ -1127,41 +1127,39 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) { m_TempCharList.push_back(charinfo); m_TempTextBuf.AppendChar(0xfffe); continue; - } else { - int nTotal = wstrItem.GetLength(); - bool bDel = false; - const int count = - std::min(pdfium::CollectionSize<int>(m_TempCharList), 7); - float threshold = charinfo.m_Matrix.TransformXDistance( - (float)TEXT_CHARRATIO_GAPDELTA * pTextObj->GetFontSize()); - for (int n = pdfium::CollectionSize<int>(m_TempCharList); - n > pdfium::CollectionSize<int>(m_TempCharList) - count; n--) { - const PAGECHAR_INFO& charinfo1 = m_TempCharList[n - 1]; - CFX_PointF diff = charinfo1.m_Origin - charinfo.m_Origin; - if (charinfo1.m_CharCode == charinfo.m_CharCode && - charinfo1.m_pTextObj->GetFont() == charinfo.m_pTextObj->GetFont() && - fabs(diff.x) < threshold && fabs(diff.y) < threshold) { - bDel = true; - break; - } + } + int nTotal = wstrItem.GetLength(); + bool bDel = false; + const int count = std::min(pdfium::CollectionSize<int>(m_TempCharList), 7); + float threshold = charinfo.m_Matrix.TransformXDistance( + (float)TEXT_CHARRATIO_GAPDELTA * pTextObj->GetFontSize()); + for (int n = pdfium::CollectionSize<int>(m_TempCharList); + n > pdfium::CollectionSize<int>(m_TempCharList) - count; n--) { + const PAGECHAR_INFO& charinfo1 = m_TempCharList[n - 1]; + CFX_PointF diff = charinfo1.m_Origin - charinfo.m_Origin; + if (charinfo1.m_CharCode == charinfo.m_CharCode && + charinfo1.m_pTextObj->GetFont() == charinfo.m_pTextObj->GetFont() && + fabs(diff.x) < threshold && fabs(diff.y) < threshold) { + bDel = true; + break; } - if (!bDel) { - for (int nIndex = 0; nIndex < nTotal; nIndex++) { - charinfo.m_Unicode = wstrItem[nIndex]; - if (charinfo.m_Unicode) { - charinfo.m_Index = m_TextBuf.GetLength(); - m_TempTextBuf.AppendChar(charinfo.m_Unicode); - } else { - m_TempTextBuf.AppendChar(0xfffe); - } - m_TempCharList.push_back(charinfo); - } - } else if (i == 0) { - WideString str = m_TempTextBuf.MakeString(); - if (!str.IsEmpty() && str[str.GetLength() - 1] == TEXT_SPACE_CHAR) { - m_TempTextBuf.Delete(m_TempTextBuf.GetLength() - 1, 1); - m_TempCharList.pop_back(); + } + if (!bDel) { + for (int nIndex = 0; nIndex < nTotal; nIndex++) { + charinfo.m_Unicode = wstrItem[nIndex]; + if (charinfo.m_Unicode) { + charinfo.m_Index = m_TextBuf.GetLength(); + m_TempTextBuf.AppendChar(charinfo.m_Unicode); + } else { + m_TempTextBuf.AppendChar(0xfffe); } + m_TempCharList.push_back(charinfo); + } + } else if (i == 0) { + WideString str = m_TempTextBuf.MakeString(); + if (!str.IsEmpty() && str[str.GetLength() - 1] == TEXT_SPACE_CHAR) { + m_TempTextBuf.Delete(m_TempTextBuf.GetLength() - 1, 1); + m_TempCharList.pop_back(); } } } diff --git a/core/fpdftext/cpdf_textpagefind.cpp b/core/fpdftext/cpdf_textpagefind.cpp index 9f243a0aee..97aa34fafe 100644 --- a/core/fpdftext/cpdf_textpagefind.cpp +++ b/core/fpdftext/cpdf_textpagefind.cpp @@ -283,13 +283,12 @@ void CPDF_TextPageFind::ExtractFindWhat(const WideString& findwhat) { int ret = ExtractSubString(csWord, findwhat.c_str(), index, TEXT_SPACE_CHAR); if (csWord.IsEmpty()) { - if (ret) { - m_csFindWhatArray.push_back(L""); - index++; - continue; - } else { + if (!ret) break; - } + + m_csFindWhatArray.push_back(L""); + index++; + continue; } size_t pos = 0; while (pos < csWord.GetLength()) { diff --git a/core/fxcodec/codec/fx_codec_flate.cpp b/core/fxcodec/codec/fx_codec_flate.cpp index 5b1df38913..95902bb699 100644 --- a/core/fxcodec/codec/fx_codec_flate.cpp +++ b/core/fxcodec/codec/fx_codec_flate.cpp @@ -190,6 +190,8 @@ int CLZWDecoder::Decode(uint8_t* dest_buf, } } m_InPos += m_CodeLen; + if (code == 257) + break; if (code < 256) { if (m_OutPos == dest_size) { return -5; @@ -206,9 +208,8 @@ int CLZWDecoder::Decode(uint8_t* dest_buf, m_CodeLen = 9; m_nCodes = 0; old_code = 0xFFFFFFFF; - } else if (code == 257) { - break; } else { + // Else 257 or greater. if (old_code == 0xFFFFFFFF) return 2; diff --git a/core/fxcodec/jbig2/JBig2_SddProc.cpp b/core/fxcodec/jbig2/JBig2_SddProc.cpp index 43768bd823..ee0c0f37f3 100644 --- a/core/fxcodec/jbig2/JBig2_SddProc.cpp +++ b/core/fxcodec/jbig2/JBig2_SddProc.cpp @@ -310,25 +310,23 @@ std::unique_ptr<CJBig2_SymbolDict> CJBig2_SDDProc::decode_Huffman( HCFIRSTSYM = NSYMSDECODED; for (;;) { nVal = pHuffmanDecoder->decodeAValue(SDHUFFDW, &DW); - if (nVal == JBIG2_OOB) { + if (nVal == JBIG2_OOB) break; - } else if (nVal != 0) { + if (nVal != 0) + return nullptr; + if (NSYMSDECODED >= SDNUMNEWSYMS) return nullptr; - } else { - if (NSYMSDECODED >= SDNUMNEWSYMS) - return nullptr; - SYMWIDTH = SYMWIDTH + DW; - if ((int)SYMWIDTH < 0 || (int)SYMWIDTH > JBIG2_MAX_IMAGE_SIZE) { - return nullptr; - } else if (HCHEIGHT == 0 || SYMWIDTH == 0) { - TOTWIDTH = TOTWIDTH + SYMWIDTH; - SDNEWSYMS[NSYMSDECODED] = nullptr; - NSYMSDECODED = NSYMSDECODED + 1; - continue; - } + SYMWIDTH = SYMWIDTH + DW; + if ((int)SYMWIDTH < 0 || (int)SYMWIDTH > JBIG2_MAX_IMAGE_SIZE) + return nullptr; + if (HCHEIGHT == 0 || SYMWIDTH == 0) { TOTWIDTH = TOTWIDTH + SYMWIDTH; + SDNEWSYMS[NSYMSDECODED] = nullptr; + NSYMSDECODED = NSYMSDECODED + 1; + continue; } + TOTWIDTH = TOTWIDTH + SYMWIDTH; if (SDREFAGG == 1) { if (pHuffmanDecoder->decodeAValue(SDHUFFAGGINST, (int*)&REFAGGNINST) != 0) { diff --git a/core/fxcrt/xml/cfx_xmlnode.cpp b/core/fxcrt/xml/cfx_xmlnode.cpp index f2b9006ebf..601999cbad 100644 --- a/core/fxcrt/xml/cfx_xmlnode.cpp +++ b/core/fxcrt/xml/cfx_xmlnode.cpp @@ -90,11 +90,9 @@ CFX_XMLNode* CFX_XMLNode::GetPath(const wchar_t* pPath, wchar_t ch; while (pStart < pEnd) { ch = *pStart++; - if (ch == L'/') { + if (ch == L'/') break; - } else { - csPath += ch; - } + csPath += ch; } iLength -= pStart - pPath; CFX_XMLNode* pFind = nullptr; diff --git a/core/fxcrt/xml/cfx_xmlparser.cpp b/core/fxcrt/xml/cfx_xmlparser.cpp index a8bb2c9565..0f08b06255 100644 --- a/core/fxcrt/xml/cfx_xmlparser.cpp +++ b/core/fxcrt/xml/cfx_xmlparser.cpp @@ -72,7 +72,8 @@ int32_t CFX_XMLParser::DoParser() { if (m_NodeStack.empty()) { m_syntaxParserResult = FX_XmlSyntaxResult::Error; break; - } else if (m_dwCurrentCheckStatus != 0 && m_NodeStack.size() == 2) { + } + if (m_dwCurrentCheckStatus != 0 && m_NodeStack.size() == 2) { m_nSize[m_dwCurrentCheckStatus - 1] = m_pParser->GetCurrentBinaryPos() - m_nStart[m_dwCurrentCheckStatus - 1]; diff --git a/core/fxcrt/xml/cfx_xmlsyntaxparser.cpp b/core/fxcrt/xml/cfx_xmlsyntaxparser.cpp index d72e7afa1d..c0cc1a6ac9 100644 --- a/core/fxcrt/xml/cfx_xmlsyntaxparser.cpp +++ b/core/fxcrt/xml/cfx_xmlsyntaxparser.cpp @@ -535,7 +535,8 @@ FX_XmlSyntaxResult CFX_XMLSyntaxParser::DoSyntaxParse() { if (m_BlockBuffer.IsEmpty()) { m_Start++; break; - } else if (m_wQuotationMark == 0) { + } + if (m_wQuotationMark == 0) { m_iTextDataLength = m_BlockBuffer.GetDataLength(); m_wQuotationMark = 0; m_BlockBuffer.Reset(true); diff --git a/fxbarcode/oned/BC_OnedCode39Writer.cpp b/fxbarcode/oned/BC_OnedCode39Writer.cpp index 8adef14765..4f25eb1570 100644 --- a/fxbarcode/oned/BC_OnedCode39Writer.cpp +++ b/fxbarcode/oned/BC_OnedCode39Writer.cpp @@ -72,9 +72,8 @@ WideString CBC_OnedCode39Writer::FilterContents( if (ch > 175) { i++; continue; - } else { - ch = Upper(ch); } + ch = Upper(ch); if ((ch >= L'0' && ch <= L'9') || (ch >= L'A' && ch <= L'Z') || ch == L'-' || ch == L'.' || ch == L' ' || ch == L'*' || ch == L'$' || ch == L'/' || ch == L'+' || ch == L'%') { diff --git a/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.cpp b/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.cpp index 1450b37ea9..059287a665 100644 --- a/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.cpp +++ b/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.cpp @@ -157,26 +157,24 @@ int32_t CBC_PDF417HighLevelEncoder::encodeText(WideString msg, switch (submode) { case SUBMODE_ALPHA: if (isAlphaUpper(ch)) { - if (ch == ' ') { + if (ch == ' ') tmp += (wchar_t)26; - } else { + else tmp += (wchar_t)(ch - 65); - } - } else { - if (isAlphaLower(ch)) { - submode = SUBMODE_LOWER; - tmp += (wchar_t)27; - continue; - } else if (isMixed(ch)) { - submode = SUBMODE_MIXED; - tmp += (wchar_t)28; - continue; - } else { - tmp += (wchar_t)29; - tmp += PUNCTUATION[ch]; - break; - } + break; + } + if (isAlphaLower(ch)) { + submode = SUBMODE_LOWER; + tmp += (wchar_t)27; + continue; } + if (isMixed(ch)) { + submode = SUBMODE_MIXED; + tmp += (wchar_t)28; + continue; + } + tmp += (wchar_t)29; + tmp += PUNCTUATION[ch]; break; case SUBMODE_LOWER: if (isAlphaLower(ch)) { @@ -185,56 +183,56 @@ int32_t CBC_PDF417HighLevelEncoder::encodeText(WideString msg, } else { tmp += (wchar_t)(ch - 97); } - } else { - if (isAlphaUpper(ch)) { - tmp += (wchar_t)27; - tmp += (wchar_t)(ch - 65); - break; - } else if (isMixed(ch)) { - submode = SUBMODE_MIXED; - tmp += (wchar_t)28; - continue; - } else { - tmp += (wchar_t)29; - tmp += PUNCTUATION[ch]; - break; - } + break; } + if (isAlphaUpper(ch)) { + tmp += (wchar_t)27; + tmp += (wchar_t)(ch - 65); + break; + } + if (isMixed(ch)) { + submode = SUBMODE_MIXED; + tmp += (wchar_t)28; + continue; + } + + tmp += (wchar_t)29; + tmp += PUNCTUATION[ch]; break; case SUBMODE_MIXED: if (isMixed(ch)) { tmp += MIXED[ch]; - } else { - if (isAlphaUpper(ch)) { - submode = SUBMODE_ALPHA; - tmp += (wchar_t)28; - continue; - } else if (isAlphaLower(ch)) { - submode = SUBMODE_LOWER; - tmp += (wchar_t)27; + break; + } + if (isAlphaUpper(ch)) { + submode = SUBMODE_ALPHA; + tmp += (wchar_t)28; + continue; + } + if (isAlphaLower(ch)) { + submode = SUBMODE_LOWER; + tmp += (wchar_t)27; + continue; + } + if (startpos + idx + 1 < count) { + wchar_t next = msg[startpos + idx + 1]; + if (isPunctuation(next)) { + submode = SUBMODE_PUNCTUATION; + tmp += (wchar_t)25; continue; - } else { - if (startpos + idx + 1 < count) { - wchar_t next = msg[startpos + idx + 1]; - if (isPunctuation(next)) { - submode = SUBMODE_PUNCTUATION; - tmp += (wchar_t)25; - continue; - } - } - tmp += (wchar_t)29; - tmp += PUNCTUATION[ch]; } } + tmp += (wchar_t)29; + tmp += PUNCTUATION[ch]; break; default: if (isPunctuation(ch)) { tmp += PUNCTUATION[ch]; - } else { - submode = SUBMODE_ALPHA; - tmp += (wchar_t)29; - continue; + break; } + submode = SUBMODE_ALPHA; + tmp += (wchar_t)29; + continue; } idx++; if (idx >= count) { diff --git a/fxjs/cfxjse_resolveprocessor.cpp b/fxjs/cfxjse_resolveprocessor.cpp index ef0fcbf174..5dba39b25d 100644 --- a/fxjs/cfxjse_resolveprocessor.cpp +++ b/fxjs/cfxjse_resolveprocessor.cpp @@ -584,6 +584,7 @@ int32_t CFXJSE_ResolveProcessor::GetFilter(const WideStringView& wsExpression, static_cast<XFA_HashCode>(FX_HashCode_GetW(wsName.AsStringView(), false)); return nStart; } + void CFXJSE_ResolveProcessor::ConditionArray(int32_t iCurIndex, WideString wsCondition, int32_t iFoundCount, @@ -594,18 +595,14 @@ void CFXJSE_ResolveProcessor::ConditionArray(int32_t iCurIndex, int32_t i = 1; for (; i < iLen; ++i) { wchar_t ch = wsCondition[i]; - if (ch == ' ') { + if (ch == ' ') continue; - } if (ch == '+' || ch == '-') { bRelative = true; - break; } else if (ch == '*') { bAll = true; - break; - } else { - break; } + break; } if (bAll) { if (rnd.m_dwStyles & XFA_RESOLVENODE_CreateNode) { diff --git a/xfa/fgas/crt/cfgas_formatstring.cpp b/xfa/fgas/crt/cfgas_formatstring.cpp index eaac969fd8..b8f6eeefca 100644 --- a/xfa/fgas/crt/cfgas_formatstring.cpp +++ b/xfa/fgas/crt/cfgas_formatstring.cpp @@ -246,7 +246,8 @@ bool ParseLocaleDate(const WideString& wsDate, *cc += iLiteralLen; ccf++; continue; - } else if (!wsDateSymbols.Contains(strf[ccf])) { + } + if (!wsDateSymbols.Contains(strf[ccf])) { if (strf[ccf] != str[*cc]) return false; (*cc)++; @@ -885,6 +886,16 @@ FX_LOCALECATEGORY CFGAS_FormatString::GetCategory(const WideString& wsPattern) { } uint32_t dwHash = FX_HashCode_GetW(wsCategory.AsStringView(), false); + if (dwHash == FX_LOCALECATEGORY_DateTimeHash) + return FX_LOCALECATEGORY_DateTime; + if (dwHash == FX_LOCALECATEGORY_TextHash) + return FX_LOCALECATEGORY_Text; + if (dwHash == FX_LOCALECATEGORY_NumHash) + return FX_LOCALECATEGORY_Num; + if (dwHash == FX_LOCALECATEGORY_ZeroHash) + return FX_LOCALECATEGORY_Zero; + if (dwHash == FX_LOCALECATEGORY_NullHash) + return FX_LOCALECATEGORY_Null; if (dwHash == FX_LOCALECATEGORY_DateHash) { if (eCategory == FX_LOCALECATEGORY_Time) return FX_LOCALECATEGORY_DateTime; @@ -893,16 +904,6 @@ FX_LOCALECATEGORY CFGAS_FormatString::GetCategory(const WideString& wsPattern) { if (eCategory == FX_LOCALECATEGORY_Date) return FX_LOCALECATEGORY_DateTime; eCategory = FX_LOCALECATEGORY_Time; - } else if (dwHash == FX_LOCALECATEGORY_DateTimeHash) { - return FX_LOCALECATEGORY_DateTime; - } else if (dwHash == FX_LOCALECATEGORY_TextHash) { - return FX_LOCALECATEGORY_Text; - } else if (dwHash == FX_LOCALECATEGORY_NumHash) { - return FX_LOCALECATEGORY_Num; - } else if (dwHash == FX_LOCALECATEGORY_ZeroHash) { - return FX_LOCALECATEGORY_Zero; - } else if (dwHash == FX_LOCALECATEGORY_NullHash) { - return FX_LOCALECATEGORY_Null; } } else if (pStr[ccf] == '}') { bBraceOpen = false; @@ -990,6 +991,10 @@ IFX_Locale* CFGAS_FormatString::GetNumericFormat(const WideString& wsPattern, continue; } while (ccf < iLenf) { + if (pStr[ccf] == '{') { + bBrackOpen = true; + break; + } if (pStr[ccf] == '(') { ccf++; WideString wsLCID; @@ -997,9 +1002,6 @@ IFX_Locale* CFGAS_FormatString::GetNumericFormat(const WideString& wsPattern, wsLCID += pStr[ccf++]; pLocale = m_pLocaleMgr->GetLocaleByName(wsLCID); - } else if (pStr[ccf] == '{') { - bBrackOpen = true; - break; } else if (pStr[ccf] == '.') { WideString wsSubCategory; ccf++; @@ -1593,6 +1595,10 @@ FX_DATETIMETYPE CFGAS_FormatString::GetDateTimeFormat( continue; } while (ccf < iLenf) { + if (pStr[ccf] == '{') { + bBraceOpen = true; + break; + } if (pStr[ccf] == '(') { ccf++; WideString wsLCID; @@ -1600,9 +1606,6 @@ FX_DATETIMETYPE CFGAS_FormatString::GetDateTimeFormat( wsLCID += pStr[ccf++]; *pLocale = m_pLocaleMgr->GetLocaleByName(wsLCID); - } else if (pStr[ccf] == '{') { - bBraceOpen = true; - break; } else if (pStr[ccf] == '.') { WideString wsSubCategory; ccf++; @@ -2314,10 +2317,8 @@ bool CFGAS_FormatString::FormatZero(const WideString& wsPattern, if (pStrPattern[iPattern] == '\'') { *wsOutput += GetLiteralText(pStrPattern, &iPattern, iLenPattern); iPattern++; - continue; } else { *wsOutput += pStrPattern[iPattern++]; - continue; } } return true; diff --git a/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp b/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp index cb52c9de08..05485d1951 100644 --- a/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp +++ b/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp @@ -2543,8 +2543,7 @@ XFA_ItemLayoutProcessorResult CXFA_ItemLayoutProcessor::DoLayoutFlowedContainer( true); if (bAddedItemInRow && eFlowStrategy == XFA_AttributeEnum::Tb) break; - else - continue; + continue; SuspendAndCreateNewRow: if (pProcessor) m_pCurChildPreprocessor = pProcessor.release(); diff --git a/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp b/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp index 90e0b15de6..1e8a77307f 100644 --- a/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp +++ b/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp @@ -1261,8 +1261,8 @@ bool CXFA_LayoutPageMgr::FindPageAreaFromPageSet_SimplexDuplex( eCurPagePosition == ePreferredPosition) { pPreferredPageArea = pCurrentNode; break; - } else if (eCurPagePosition == eFallbackPosition && - !pFallbackPageArea) { + } + if (eCurPagePosition == eFallbackPosition && !pFallbackPageArea) { pFallbackPageArea = pCurrentNode; } } else if (pTargetPageArea && !MatchPageAreaOddOrEven(pTargetPageArea)) { diff --git a/xfa/fxfa/parser/cxfa_nodehelper.cpp b/xfa/fxfa/parser/cxfa_nodehelper.cpp index 6428a3ca4a..f11472a112 100644 --- a/xfa/fxfa/parser/cxfa_nodehelper.cpp +++ b/xfa/fxfa/parser/cxfa_nodehelper.cpp @@ -267,16 +267,13 @@ void CXFA_NodeHelper::GetNameExpression(CXFA_Node* refNode, } bool CXFA_NodeHelper::NodeIsTransparent(CXFA_Node* refNode) { - if (!refNode) { + if (!refNode) return false; - } + XFA_Element refNodeType = refNode->GetElementType(); - if ((refNode->IsUnnamed() && refNode->IsContainerNode()) || - refNodeType == XFA_Element::SubformSet || - refNodeType == XFA_Element::Area || refNodeType == XFA_Element::Proto) { - return true; - } - return false; + return (refNode->IsUnnamed() && refNode->IsContainerNode()) || + refNodeType == XFA_Element::SubformSet || + refNodeType == XFA_Element::Area || refNodeType == XFA_Element::Proto; } bool CXFA_NodeHelper::CreateNode_ForCondition(WideString& wsCondition) { @@ -287,34 +284,29 @@ bool CXFA_NodeHelper::CreateNode_ForCondition(WideString& wsCondition) { m_iCreateFlag = XFA_RESOLVENODE_RSTYPE_CreateNodeOne; return false; } - if (wsCondition[0] == '[') { - int32_t i = 1; - for (; i < iLen; ++i) { - wchar_t ch = wsCondition[i]; - if (ch == ' ') { - continue; - } - if (ch == '+' || ch == '-') { - break; - } else if (ch == '*') { - bAll = true; - break; - } else { - break; - } - } - if (bAll) { - wsIndex = L"1"; - m_iCreateFlag = XFA_RESOLVENODE_RSTYPE_CreateNodeAll; - } else { - m_iCreateFlag = XFA_RESOLVENODE_RSTYPE_CreateNodeOne; - wsIndex = wsCondition.Mid(i, iLen - 1 - i); - } - int32_t iIndex = wsIndex.GetInteger(); - m_iCreateCount = iIndex; - return true; + if (wsCondition[0] != '[') + return false; + + int32_t i = 1; + for (; i < iLen; ++i) { + wchar_t ch = wsCondition[i]; + if (ch == ' ') + continue; + + if (ch == '*') + bAll = true; + break; + } + if (bAll) { + wsIndex = L"1"; + m_iCreateFlag = XFA_RESOLVENODE_RSTYPE_CreateNodeAll; + } else { + m_iCreateFlag = XFA_RESOLVENODE_RSTYPE_CreateNodeOne; + wsIndex = wsCondition.Mid(i, iLen - 1 - i); } - return false; + int32_t iIndex = wsIndex.GetInteger(); + m_iCreateCount = iIndex; + return true; } bool CXFA_NodeHelper::ResolveNodes_CreateNode(WideString wsName, |