diff options
author | Lei Zhang <thestig@chromium.org> | 2015-12-14 18:34:00 -0800 |
---|---|---|
committer | Lei Zhang <thestig@chromium.org> | 2015-12-14 18:34:00 -0800 |
commit | 412e908082a361d0fd9591eab939e96a882212f1 (patch) | |
tree | 11726052ae08f13dc5a05a82cbce870758580aeb /core/src/fpdftext | |
parent | 96660d6f382204339d6b1aadc3913303d436e252 (diff) | |
download | pdfium-412e908082a361d0fd9591eab939e96a882212f1.tar.xz |
Merge to XFA: Get rid of most instance of 'foo == NULL'
TBR=tsepez@chromium.org
Review URL: https://codereview.chromium.org/1520063002 .
(cherry picked from commit e385244f8cd6ae376f6b3cf1265a0795d5d30eff)
Review URL: https://codereview.chromium.org/1528763003 .
Diffstat (limited to 'core/src/fpdftext')
-rw-r--r-- | core/src/fpdftext/fpdf_text.cpp | 18 | ||||
-rw-r--r-- | core/src/fpdftext/fpdf_text_int.cpp | 8 | ||||
-rw-r--r-- | core/src/fpdftext/fpdf_text_search.cpp | 9 |
3 files changed, 15 insertions, 20 deletions
diff --git a/core/src/fpdftext/fpdf_text.cpp b/core/src/fpdftext/fpdf_text.cpp index 9a967e62fd..1e56bf901d 100644 --- a/core/src/fpdftext/fpdf_text.cpp +++ b/core/src/fpdftext/fpdf_text.cpp @@ -168,7 +168,7 @@ CTextBaseLine* CTextPage::InsertTextBox(CTextBaseLine* pBaseLine, if (str.GetLength() == 0) { return NULL; } - if (pBaseLine == NULL) { + if (!pBaseLine) { int i; for (i = 0; i < m_BaseLines.GetSize(); i++) { CTextBaseLine* pExistLine = m_BaseLines.GetAt(i); @@ -180,7 +180,7 @@ CTextBaseLine* CTextPage::InsertTextBox(CTextBaseLine* pBaseLine, break; } } - if (pBaseLine == NULL) { + if (!pBaseLine) { pBaseLine = new CTextBaseLine; pBaseLine->m_BaseLine = basey; m_BaseLines.InsertAt(i, pBaseLine); @@ -448,17 +448,17 @@ void CTextPage::FindColumns() { for (int j = 0; j < pBaseLine->m_TextList.GetSize(); j++) { CTextBox* pTextBox = pBaseLine->m_TextList.GetAt(j); CTextColumn* pColumn = FindColumn(pTextBox->m_Right); - if (pColumn == NULL) { + if (pColumn) { + pColumn->m_AvgPos = + (pColumn->m_Count * pColumn->m_AvgPos + pTextBox->m_Right) / + (pColumn->m_Count + 1); + pColumn->m_Count++; + } else { pColumn = new CTextColumn; pColumn->m_Count = 1; pColumn->m_AvgPos = pTextBox->m_Right; pColumn->m_TextPos = -1; m_TextColumns.Add(pColumn); - } else { - pColumn->m_AvgPos = - (pColumn->m_Count * pColumn->m_AvgPos + pTextBox->m_Right) / - (pColumn->m_Count + 1); - pColumn->m_Count++; } } } @@ -726,7 +726,7 @@ void PDF_GetPageText_Unicode(CFX_WideStringArray& lines, int iMinWidth, FX_DWORD flags) { lines.RemoveAll(); - if (pPage == NULL) { + if (!pPage) { return; } CPDF_Page page; diff --git a/core/src/fpdftext/fpdf_text_int.cpp b/core/src/fpdftext/fpdf_text_int.cpp index 8a359fe9af..1e6d54d133 100644 --- a/core/src/fpdftext/fpdf_text_int.cpp +++ b/core/src/fpdftext/fpdf_text_int.cpp @@ -2464,12 +2464,12 @@ FX_BOOL CPDF_TextPageFind::ExtractSubString(CFX_WideString& rString, const FX_WCHAR* lpszFullString, int iSubString, FX_WCHAR chSep) { - if (lpszFullString == NULL) { + if (!lpszFullString) { return FALSE; } while (iSubString--) { lpszFullString = FXSYS_wcschr(lpszFullString, chSep); - if (lpszFullString == NULL) { + if (!lpszFullString) { rString.Empty(); return FALSE; } @@ -2479,8 +2479,8 @@ FX_BOOL CPDF_TextPageFind::ExtractSubString(CFX_WideString& rString, } } const FX_WCHAR* lpchEnd = FXSYS_wcschr(lpszFullString, chSep); - int nLen = (lpchEnd == NULL) ? (int)FXSYS_wcslen(lpszFullString) - : (int)(lpchEnd - lpszFullString); + int nLen = lpchEnd ? (int)(lpchEnd - lpszFullString) + : (int)FXSYS_wcslen(lpszFullString); ASSERT(nLen >= 0); FXSYS_memcpy(rString.GetBuffer(nLen), lpszFullString, nLen * sizeof(FX_WCHAR)); diff --git a/core/src/fpdftext/fpdf_text_search.cpp b/core/src/fpdftext/fpdf_text_search.cpp index 43486c7ab8..80bf5ec99a 100644 --- a/core/src/fpdftext/fpdf_text_search.cpp +++ b/core/src/fpdftext/fpdf_text_search.cpp @@ -303,13 +303,8 @@ void GetTextStream_Unicode(CFX_WideTextBuf& buffer, FX_POSITION pos = pPage->GetFirstObjectPosition(); while (pos) { CPDF_PageObject* pObject = pPage->GetNextObject(pos); - if (pObject == NULL) { - continue; - } - if (pObject->m_Type != PDFPAGE_TEXT) { - continue; - } - textstream.ProcessObject((CPDF_TextObject*)pObject, FALSE); + if (pObject && pObject->m_Type == PDFPAGE_TEXT) + textstream.ProcessObject((CPDF_TextObject*)pObject, FALSE); } } CFX_WideString PDF_GetFirstTextLine_Unicode(CPDF_Document* pDoc, |