diff options
author | thestig <thestig@chromium.org> | 2016-06-10 12:21:53 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-06-10 12:21:53 -0700 |
commit | cfb77ccb1c057d6beb73f0043e42eee8c4822f84 (patch) | |
tree | c71d7097de50879080a237f47b42e22e1d6784db /xfa/fde/tto | |
parent | 7f3a15f714c8311b1adb7bdce1ac83c7113af598 (diff) | |
download | pdfium-cfb77ccb1c057d6beb73f0043e42eee8c4822f84.tar.xz |
Get rid of NULLs in xfa/fde/
Review-Url: https://codereview.chromium.org/2039923004
Diffstat (limited to 'xfa/fde/tto')
-rw-r--r-- | xfa/fde/tto/fde_textout.cpp | 45 |
1 files changed, 22 insertions, 23 deletions
diff --git a/xfa/fde/tto/fde_textout.cpp b/xfa/fde/tto/fde_textout.cpp index 6b9f8522b5..b0c4bdd234 100644 --- a/xfa/fde/tto/fde_textout.cpp +++ b/xfa/fde/tto/fde_textout.cpp @@ -18,16 +18,16 @@ #include "xfa/fgas/layout/fgas_textbreak.h" CFDE_TextOut::CFDE_TextOut() - : m_pFont(NULL), + : m_pFont(nullptr), m_fFontSize(12.0f), m_fLineSpace(m_fFontSize), m_fLinePos(0.0f), m_fTolerance(0.0f), m_iAlignment(0), m_iTxtBkAlignment(0), - m_pCharWidths(NULL), + m_pCharWidths(nullptr), m_iChars(0), - m_pEllCharWidths(NULL), + m_pEllCharWidths(nullptr), m_iEllChars(0), m_wParagraphBkChar(L'\n'), m_TxtColor(0xFF000000), @@ -39,7 +39,7 @@ CFDE_TextOut::CFDE_TextOut() m_iCurLine(0), m_iCurPiece(0), m_iTotalLines(0), - m_pCharPos(NULL), + m_pCharPos(nullptr), m_iCharPosSize(0) { m_pTxtBreak = new CFX_TxtBreak(FX_TXTBREAKPOLICY_None); m_Matrix.SetIdentity(); @@ -191,7 +191,7 @@ void CFDE_TextOut::CalcSize(const FX_WCHAR* pwsStr, void CFDE_TextOut::CalcSize(const FX_WCHAR* pwsStr, int32_t iLength, CFX_RectF& rect) { - if (pwsStr == NULL || iLength < 1) { + if (!pwsStr || iLength < 1) { rect.width = 0.0f; rect.height = 0.0f; } else { @@ -214,7 +214,7 @@ void CFDE_TextOut::CalcLogicSize(const FX_WCHAR* pwsStr, void CFDE_TextOut::CalcLogicSize(const FX_WCHAR* pwsStr, int32_t iLength, CFX_RectF& rect) { - if (pwsStr == NULL || iLength < 1) { + if (!pwsStr || iLength < 1) { rect.width = 0.0f; rect.height = 0.0f; } else { @@ -224,7 +224,7 @@ void CFDE_TextOut::CalcLogicSize(const FX_WCHAR* pwsStr, void CFDE_TextOut::CalcTextSize(const FX_WCHAR* pwsStr, int32_t iLength, CFX_RectF& rect) { - ASSERT(m_pFont != NULL && m_fFontSize >= 1.0f); + ASSERT(m_pFont && m_fFontSize >= 1.0f); SetLineWidth(rect); m_iTotalLines = 0; const FX_WCHAR* pStr = pwsStr; @@ -386,10 +386,10 @@ void CFDE_TextOut::DrawText(const FX_WCHAR* pwsStr, int32_t iLength, const CFX_RectF& rect, const CFX_RectF& rtClip) { - ASSERT(m_pFont != NULL && m_fFontSize >= 1.0f); - if (pwsStr == NULL || iLength < 1) { + ASSERT(m_pFont && m_fFontSize >= 1.0f); + if (!pwsStr || iLength < 1) return; - } + if (rect.width < m_fFontSize || rect.height < m_fFontSize) { return; } @@ -431,7 +431,7 @@ void CFDE_TextOut::ExpandBuffer(int32_t iSize, int32_t iType) { FXSYS_memset(m_pEllCharWidths, 0, iSize * sizeof(int32_t)); break; case 2: - if (m_pCharPos == NULL) { + if (!m_pCharPos) { m_pCharPos = FX_Alloc(FXTEXT_CHARPOS, iSize); m_iCharPosSize = iSize; } else if (m_iCharPosSize < iSize) { @@ -513,10 +513,9 @@ void CFDE_TextOut::LoadText(const FX_WCHAR* pwsStr, FX_BOOL bRet = FALSE; while (iTxtLength-- > 0) { wch = *pwsStr++; - if (wch == L'&' && bHotKey && (pStr - 1) != NULL && *(pStr - 1) != L'&') { - if (iTxtLength > 0) { + if (bHotKey && wch == L'&' && *(pStr - 1) != L'&') { + if (iTxtLength > 0) m_hotKeys.Add(iChars); - } continue; } *pStr++ = wch; @@ -565,7 +564,7 @@ FX_BOOL CFDE_TextOut::RetriecePieces(uint32_t dwBreakStatus, if (bVertical) { fLineStep = -fLineStep; } - CFX_Char* pTC = NULL; + CFX_Char* pTC = nullptr; FX_BOOL bNeedReload = FALSE; FX_FLOAT fLineWidth = bVertical ? rect.Height() : rect.Width(); int32_t iLineWidth = FXSYS_round(fLineWidth * 20000.0f); @@ -663,9 +662,9 @@ void CFDE_TextOut::ReplaceWidthEllipsis() { int32_t iPiece = pLine->GetSize(); while (iPiece-- > 0) { FDE_TTOPIECE* pPiece = pLine->GetPtrAt(iPiece); - if (pPiece == NULL) { + if (!pPiece) break; - } + for (int32_t j = pPiece->iChars - 1; j >= 0; j--) { if (iEllipsisCharIndex < 0) { break; @@ -692,9 +691,9 @@ void CFDE_TextOut::Reload(const CFX_RectF& rect) { int32_t iCount = m_ttoLines.GetSize(); for (int32_t i = 0; i < iCount; i++) { CFDE_TTOLine* pLine = m_ttoLines.GetPtrAt(i); - if (pLine == NULL || !pLine->m_bNewReload) { + if (!pLine || !pLine->m_bNewReload) continue; - } + m_iCurLine = i; m_iCurPiece = 0; ReloadLinePiece(pLine, rect); @@ -774,7 +773,7 @@ void CFDE_TextOut::OnDraw(const CFX_RectF& rtClip) { CFDE_Brush* pBrush = new CFDE_Brush; pBrush->SetColor(m_TxtColor); - CFDE_Pen* pPen = NULL; + CFDE_Pen* pPen = nullptr; m_pRenderDevice->SaveState(); if (rtClip.Width() > 0.0f && rtClip.Height() > 0.0f) { m_pRenderDevice->SetClipRect(rtClip); @@ -784,9 +783,9 @@ void CFDE_TextOut::OnDraw(const CFX_RectF& rtClip) { int32_t iPieces = pLine->GetSize(); for (int32_t j = 0; j < iPieces; j++) { FDE_TTOPIECE* pPiece = pLine->GetPtrAt(j); - if (pPiece == NULL) { + if (!pPiece) continue; - } + int32_t iCount = GetDisplayPos(pPiece); if (iCount > 0) { m_pRenderDevice->DrawString(pBrush, m_pFont, m_pCharPos, iCount, @@ -928,7 +927,7 @@ int32_t CFDE_TTOLine::GetSize() const { } FDE_TTOPIECE* CFDE_TTOLine::GetPtrAt(int32_t index) { if (index >= m_iPieceCount) { - return NULL; + return nullptr; } return m_pieces.GetPtrAt(index); } |