From e64c3c60bdc1ca2e937e4317a9238ab4c210dfe5 Mon Sep 17 00:00:00 2001 From: tsepez Date: Thu, 9 Jun 2016 11:09:22 -0700 Subject: Remove C-style casts in xfa/fde. Review-Url: https://codereview.chromium.org/2040323004 --- xfa/fde/cfde_path.cpp | 9 ++++----- xfa/fde/cfde_txtedtengine.cpp | 4 ++-- xfa/fde/cfde_txtedtpage.cpp | 12 +++++++----- xfa/fde/css/fde_cssstyleselector.cpp | 29 +++++++++++++++++------------ xfa/fde/css/fde_cssstylesheet.cpp | 6 +++--- xfa/fde/fde_iterator.cpp | 2 +- xfa/fde/fde_render.cpp | 2 +- 7 files changed, 35 insertions(+), 29 deletions(-) diff --git a/xfa/fde/cfde_path.cpp b/xfa/fde/cfde_path.cpp index 7ea458d485..f18eab54d2 100644 --- a/xfa/fde/cfde_path.cpp +++ b/xfa/fde/cfde_path.cpp @@ -202,17 +202,16 @@ void CFDE_Path::AddLine(const CFX_PointF& pt1, const CFX_PointF& pt2) { } void CFDE_Path::AddPath(const CFDE_Path* pSrc, FX_BOOL bConnect) { - CFDE_Path* pPath = (CFDE_Path*)pSrc; - if (!pPath) + if (!pSrc) return; - int32_t iCount = pPath->m_Path.GetPointCount(); + int32_t iCount = pSrc->m_Path.GetPointCount(); if (iCount < 1) return; if (bConnect) - LineTo(pPath->m_Path.GetPointX(0), pPath->m_Path.GetPointY(0)); + LineTo(pSrc->m_Path.GetPointX(0), pSrc->m_Path.GetPointY(0)); - m_Path.Append(&pPath->m_Path, nullptr); + m_Path.Append(&pSrc->m_Path, nullptr); } void CFDE_Path::AddPolygon(const CFX_PointsF& points) { diff --git a/xfa/fde/cfde_txtedtengine.cpp b/xfa/fde/cfde_txtedtengine.cpp index 4a9aaa6eff..8980488abc 100644 --- a/xfa/fde/cfde_txtedtengine.cpp +++ b/xfa/fde/cfde_txtedtengine.cpp @@ -80,7 +80,7 @@ IFDE_TxtEdtPage* CFDE_TxtEdtEngine::GetPage(int32_t nIndex) { if (m_PagePtrArray.GetSize() <= nIndex) { return NULL; } - return (IFDE_TxtEdtPage*)m_PagePtrArray[nIndex]; + return m_PagePtrArray[nIndex]; } void CFDE_TxtEdtEngine::SetTextByStream(IFX_Stream* pStream) { @@ -734,7 +734,7 @@ IFX_CharIter* CFDE_TxtEdtEngine::CreateCharIter() { if (!m_pTxtBuf) { return NULL; } - return new CFDE_TxtEdtBufIter((CFDE_TxtEdtBuf*)m_pTxtBuf); + return new CFDE_TxtEdtBufIter(static_cast(m_pTxtBuf)); } int32_t CFDE_TxtEdtEngine::Line2Parag(int32_t nStartParag, diff --git a/xfa/fde/cfde_txtedtpage.cpp b/xfa/fde/cfde_txtedtpage.cpp index 406b19b386..3af29f26cd 100644 --- a/xfa/fde/cfde_txtedtpage.cpp +++ b/xfa/fde/cfde_txtedtpage.cpp @@ -25,7 +25,7 @@ const double kTolerance = 0.1f; IFDE_TxtEdtPage* IFDE_TxtEdtPage::Create(CFDE_TxtEdtEngine* pEngine, int32_t nIndex) { - return (IFDE_TxtEdtPage*)new CFDE_TxtEdtPage(pEngine, nIndex); + return new CFDE_TxtEdtPage(pEngine, nIndex); } CFDE_TxtEdtPage::CFDE_TxtEdtPage(CFDE_TxtEdtEngine* pEngine, int32_t nPageIndex) @@ -42,7 +42,7 @@ CFDE_TxtEdtPage::CFDE_TxtEdtPage(CFDE_TxtEdtEngine* pEngine, int32_t nPageIndex) FXSYS_memset(&m_rtPageMargin, 0, sizeof(CFX_RectF)); FXSYS_memset(&m_rtPageContents, 0, sizeof(CFX_RectF)); FXSYS_memset(&m_rtPageCanvas, 0, sizeof(CFX_RectF)); - m_pEditEngine = (CFDE_TxtEdtEngine*)pEngine; + m_pEditEngine = static_cast(pEngine); } CFDE_TxtEdtPage::~CFDE_TxtEdtPage() { @@ -251,7 +251,7 @@ int32_t CFDE_TxtEdtPage::SelectWord(const CFX_PointF& fPoint, int32_t& nCount) { return -1; } std::unique_ptr pIter(new CFX_WordBreak); - pIter->Attach(new CFDE_TxtEdtBufIter((CFDE_TxtEdtBuf*)pBuf)); + pIter->Attach(new CFDE_TxtEdtBufIter(pBuf)); pIter->SetAt(nIndex); nCount = pIter->GetWordLength(); return pIter->GetWordPos(); @@ -285,12 +285,14 @@ int32_t CFDE_TxtEdtPage::LoadPage(const CFX_RectF* pClipBox, int32_t nPageStart, nPageEnd, nTemp, nBgnParag, nStartLineInParag, nEndParag, nEndLineInParag; nBgnParag = m_pEditEngine->Line2Parag(0, 0, nStartLine, nStartLineInParag); - m_pBgnParag = (CFDE_TxtEdtParag*)m_pEditEngine->GetParag(nBgnParag); + m_pBgnParag = + static_cast(m_pEditEngine->GetParag(nBgnParag)); m_pBgnParag->LoadParag(); m_pBgnParag->GetLineRange(nStartLine - nStartLineInParag, nPageStart, nTemp); nEndParag = m_pEditEngine->Line2Parag(nBgnParag, nStartLineInParag, nEndLine, nEndLineInParag); - m_pEndParag = (CFDE_TxtEdtParag*)m_pEditEngine->GetParag(nEndParag); + m_pEndParag = + static_cast(m_pEditEngine->GetParag(nEndParag)); m_pEndParag->LoadParag(); m_pEndParag->GetLineRange(nEndLine - nEndLineInParag, nPageEnd, nTemp); nPageEnd += (nTemp - 1); diff --git a/xfa/fde/css/fde_cssstyleselector.cpp b/xfa/fde/css/fde_cssstyleselector.cpp index c684d0bece..12f6bc9879 100644 --- a/xfa/fde/css/fde_cssstyleselector.cpp +++ b/xfa/fde/css/fde_cssstyleselector.cpp @@ -39,13 +39,16 @@ void CFDE_CSSCounterStyle::DoUpdateIndex(IFDE_CSSValueList* pList) { bDefIncrement = FALSE; } for (int32_t i = 0; i < iCount; i++) { - IFDE_CSSValueList* pCounter = (IFDE_CSSValueList*)pList->GetValue(i); + IFDE_CSSValueList* pCounter = + static_cast(pList->GetValue(i)); int32_t iLen; const FX_WCHAR* pszIdentifier = - ((IFDE_CSSPrimitiveValue*)(pCounter->GetValue(0)))->GetString(iLen); + static_cast(pCounter->GetValue(0)) + ->GetString(iLen); FX_FLOAT fValue = fDefValue; if (pCounter->CountValues() > 1) { - fValue = ((IFDE_CSSPrimitiveValue*)(pCounter->GetValue(1)))->GetFloat(); + fValue = static_cast(pCounter->GetValue(1)) + ->GetFloat(); } int32_t iIndex = FindIndex(pszIdentifier); if (iIndex == -1) { @@ -123,7 +126,7 @@ void CFDE_CSSRuleCollection::AddRulesFrom(IFDE_CSSStyleSheet* pStyleSheet, IFGAS_FontMgr* pFontMgr) { switch (pRule->GetType()) { case FDE_CSSRULETYPE_Style: { - IFDE_CSSStyleRule* pStyleRule = (IFDE_CSSStyleRule*)pRule; + IFDE_CSSStyleRule* pStyleRule = static_cast(pRule); CFDE_CSSDeclaration* pDeclaration = pStyleRule->GetDeclaration(); int32_t iSelectors = pStyleRule->CountSelectorLists(); for (int32_t i = 0; i < iSelectors; ++i) { @@ -163,7 +166,7 @@ void CFDE_CSSRuleCollection::AddRulesFrom(IFDE_CSSStyleSheet* pStyleSheet, } } break; case FDE_CSSRULETYPE_Media: { - IFDE_CSSMediaRule* pMediaRule = (IFDE_CSSMediaRule*)pRule; + IFDE_CSSMediaRule* pMediaRule = static_cast(pRule); if (pMediaRule->GetMediaList() & dwMediaList) { int32_t iRules = pMediaRule->CountRules(); for (int32_t i = 0; i < iRules; ++i) { @@ -254,7 +257,7 @@ IFDE_CSSComputedStyle* CFDE_CSSStyleSelector::CreateComputedStyle( CFDE_CSSComputedStyle(m_pFixedStyleStore); if (pParentStyle) { pStyle->m_InheritedData = - ((CFDE_CSSComputedStyle*)pParentStyle)->m_InheritedData; + static_cast(pParentStyle)->m_InheritedData; } else { pStyle->m_InheritedData.Reset(); } @@ -475,7 +478,8 @@ void CFDE_CSSStyleSelector::ApplyDeclarations( const CFDE_CSSDeclaration** ppDeclArray, int32_t iDeclCount, IFDE_CSSComputedStyle* pDestStyle) { - CFDE_CSSComputedStyle* pComputedStyle = (CFDE_CSSComputedStyle*)pDestStyle; + CFDE_CSSComputedStyle* pComputedStyle = + static_cast(pDestStyle); IFDE_CSSValue* pVal; FX_BOOL bImportant; int32_t i; @@ -583,7 +587,8 @@ void CFDE_CSSStyleSelector::ApplyProperty( IFDE_CSSValue* pValue, CFDE_CSSComputedStyle* pComputedStyle) { if (pValue->GetType() == FDE_CSSVALUETYPE_Primitive) { - IFDE_CSSPrimitiveValue* pPrimitive = (IFDE_CSSPrimitiveValue*)pValue; + IFDE_CSSPrimitiveValue* pPrimitive = + static_cast(pValue); FDE_CSSPRIMITIVETYPE eType = pPrimitive->GetPrimitiveType(); switch (eProperty) { case FDE_CSSPROPERTY_Display: @@ -1030,7 +1035,7 @@ void CFDE_CSSStyleSelector::ApplyProperty( break; } } else if (pValue->GetType() == FDE_CSSVALUETYPE_List) { - IFDE_CSSValueList* pList = (IFDE_CSSValueList*)pValue; + IFDE_CSSValueList* pList = static_cast(pValue); int32_t iCount = pList->CountValues(); if (iCount > 0) { switch (eProperty) { @@ -1061,7 +1066,7 @@ void CFDE_CSSStyleSelector::ApplyProperty( case FDE_CSSPROPERTY_TextCombine: { for (int32_t i = 0; i < pList->CountValues(); i++) { IFDE_CSSPrimitiveValue* pVal = - (IFDE_CSSPrimitiveValue*)pList->GetValue(i); + static_cast(pList->GetValue(i)); switch (pVal->GetPrimitiveType()) { case FDE_CSSPRIMITIVETYPE_Enum: { switch (pVal->GetEnum()) { @@ -1091,7 +1096,7 @@ void CFDE_CSSStyleSelector::ApplyProperty( FDE_CSSTEXTEMPHASISMARK eMark; for (int32_t i = 0; i < pList->CountValues(); i++) { IFDE_CSSPrimitiveValue* pVal = - (IFDE_CSSPrimitiveValue*)pList->GetValue(i); + static_cast(pList->GetValue(i)); switch (pVal->GetPrimitiveType()) { case FDE_CSSPRIMITIVETYPE_Enum: { if (ToTextEmphasisFill(pVal->GetEnum(), eFill)) { @@ -1736,7 +1741,7 @@ uint32_t CFDE_CSSStyleSelector::ToTextDecoration(IFDE_CSSValueList* pValue) { uint32_t dwDecoration = 0; for (int32_t i = pValue->CountValues() - 1; i >= 0; --i) { IFDE_CSSPrimitiveValue* pPrimitive = - (IFDE_CSSPrimitiveValue*)pValue->GetValue(i); + static_cast(pValue->GetValue(i)); if (pPrimitive->GetPrimitiveType() == FDE_CSSPRIMITIVETYPE_Enum) { switch (pPrimitive->GetEnum()) { case FDE_CSSPROPERTYVALUE_Underline: diff --git a/xfa/fde/css/fde_cssstylesheet.cpp b/xfa/fde/css/fde_cssstylesheet.cpp index 5a3cc76f5b..1ea8d8061d 100644 --- a/xfa/fde/css/fde_cssstylesheet.cpp +++ b/xfa/fde/css/fde_cssstylesheet.cpp @@ -87,13 +87,13 @@ void CFDE_CSSStyleSheet::Reset() { IFDE_CSSRule* pRule = m_RuleArray.GetAt(i); switch (pRule->GetType()) { case FDE_CSSRULETYPE_Style: - ((CFDE_CSSStyleRule*)pRule)->~CFDE_CSSStyleRule(); + static_cast(pRule)->~CFDE_CSSStyleRule(); break; case FDE_CSSRULETYPE_Media: - ((CFDE_CSSMediaRule*)pRule)->~CFDE_CSSMediaRule(); + static_cast(pRule)->~CFDE_CSSMediaRule(); break; case FDE_CSSRULETYPE_FontFace: - ((CFDE_CSSFontFaceRule*)pRule)->~CFDE_CSSFontFaceRule(); + static_cast(pRule)->~CFDE_CSSFontFaceRule(); break; default: ASSERT(FALSE); diff --git a/xfa/fde/fde_iterator.cpp b/xfa/fde/fde_iterator.cpp index d04467f06f..6e8ca0061a 100644 --- a/xfa/fde/fde_iterator.cpp +++ b/xfa/fde/fde_iterator.cpp @@ -72,7 +72,7 @@ FDE_TEXTEDITPIECE* CFDE_VisualSetIterator::GetNext( if (eType == FDE_VISUALOBJ_Canvas) { FDE_CANVASITEM canvas; canvas.hCanvas = pObj; - canvas.pCanvas = (IFDE_CanvasSet*)pVisualSet; + canvas.pCanvas = static_cast(pVisualSet); canvas.hPos = canvas.pCanvas->GetFirstPosition(); m_CanvasStack.Push(canvas); break; diff --git a/xfa/fde/fde_render.cpp b/xfa/fde/fde_render.cpp index 04d52549c6..e2c395eeb5 100644 --- a/xfa/fde/fde_render.cpp +++ b/xfa/fde/fde_render.cpp @@ -78,7 +78,7 @@ FDE_RENDERSTATUS CFDE_RenderContext::DoRender(IFX_Pause* pPause) { switch (pVisualSet->GetType()) { case FDE_VISUALOBJ_Text: - RenderText((IFDE_TextSet*)pVisualSet, pPiece); + RenderText(static_cast(pVisualSet), pPiece); iCount += 5; break; case FDE_VISUALOBJ_Canvas: -- cgit v1.2.3