From 20d6b76d82a762e75e8c2a89976f93acd9af7467 Mon Sep 17 00:00:00 2001 From: tsepez Date: Thu, 9 Jun 2016 11:46:16 -0700 Subject: Use static_cast in xfa. Remove a few other unused casts, simplify. Review-Url: https://codereview.chromium.org/2052593003 --- xfa/fgas/font/fgas_stdfontmgr.cpp | 2 +- xfa/fxfa/app/xfa_ffdocview.cpp | 8 +++++--- xfa/fxfa/app/xfa_fffield.cpp | 2 +- xfa/fxfa/app/xfa_ffimageedit.cpp | 2 +- xfa/fxfa/app/xfa_ffpageview.cpp | 12 ++++++------ xfa/fxfa/app/xfa_ffpushbutton.cpp | 2 +- xfa/fxfa/app/xfa_fftextedit.cpp | 6 +++--- xfa/fxfa/app/xfa_ffwidget.cpp | 4 ++-- xfa/fxfa/app/xfa_ffwidgetacc.cpp | 12 +++++++----- xfa/fxfa/app/xfa_ffwidgethandler.cpp | 19 ++++++++----------- xfa/fxfa/app/xfa_fontmgr.cpp | 10 +++------- xfa/fxfa/parser/xfa_layout_appadapter.h | 12 ++++++------ xfa/fxfa/parser/xfa_script_layoutpseudomodel.cpp | 3 +-- 13 files changed, 45 insertions(+), 49 deletions(-) diff --git a/xfa/fgas/font/fgas_stdfontmgr.cpp b/xfa/fgas/font/fgas_stdfontmgr.cpp index 4e5095048b..c6c1b19ef7 100644 --- a/xfa/fgas/font/fgas_stdfontmgr.cpp +++ b/xfa/fgas/font/fgas_stdfontmgr.cpp @@ -530,7 +530,7 @@ IFX_FileAccess* CFX_FontSourceEnum_File::GetNext(FX_POSITION& pos) { IFX_FileAccess* pAccess = FX_CreateDefaultFileAccess(m_wsNext.AsStringC()); m_wsNext = GetNextFile().UTF8Decode(); pos = 0 != m_wsNext.GetLength() ? pAccess : NULL; - return (IFX_FileAccess*)pAccess; + return pAccess; } IFGAS_FontMgr* IFGAS_FontMgr::Create(CFX_FontSourceEnum_File* pFontEnum) { diff --git a/xfa/fxfa/app/xfa_ffdocview.cpp b/xfa/fxfa/app/xfa_ffdocview.cpp index d8b65c4c5b..90ab7cd81f 100644 --- a/xfa/fxfa/app/xfa_ffdocview.cpp +++ b/xfa/fxfa/app/xfa_ffdocview.cpp @@ -581,7 +581,8 @@ void CXFA_FFDocView::RunSubformIndexChange() { int32_t iSubforms = m_IndexChangedSubforms.GetSize(); for (int32_t i = 0; i < iSubforms; i++) { CXFA_Node* pSubformNode = m_IndexChangedSubforms[i]; - CXFA_WidgetAcc* pWidgetAcc = (CXFA_WidgetAcc*)pSubformNode->GetWidgetData(); + CXFA_WidgetAcc* pWidgetAcc = + static_cast(pSubformNode->GetWidgetData()); if (!pWidgetAcc) { continue; } @@ -726,7 +727,8 @@ void CXFA_FFDocView::RunBindItems() { continue; CXFA_Node* pWidgetNode = m_BindItems[i]->GetNodeItem(XFA_NODEITEM_Parent); - CXFA_WidgetAcc* pAcc = (CXFA_WidgetAcc*)pWidgetNode->GetWidgetData(); + CXFA_WidgetAcc* pAcc = + static_cast(pWidgetNode->GetWidgetData()); if (!pAcc) continue; @@ -824,7 +826,7 @@ CXFA_WidgetAcc* CXFA_WidgetAccIterator::MoveToNext() { CXFA_Node* pItem = m_pCurWidgetAcc ? m_ContentIterator.MoveToNext() : m_ContentIterator.GetCurrent(); while (pItem) { - m_pCurWidgetAcc = (CXFA_WidgetAcc*)pItem->GetWidgetData(); + m_pCurWidgetAcc = static_cast(pItem->GetWidgetData()); if (m_pCurWidgetAcc) return m_pCurWidgetAcc; pItem = m_ContentIterator.MoveToNext(); diff --git a/xfa/fxfa/app/xfa_fffield.cpp b/xfa/fxfa/app/xfa_fffield.cpp index 72fb14380f..df366217b0 100644 --- a/xfa/fxfa/app/xfa_fffield.cpp +++ b/xfa/fxfa/app/xfa_fffield.cpp @@ -692,7 +692,7 @@ int32_t CXFA_FFField::CalculateOverride() { } CXFA_WidgetAcc* pWidgetAcc = NULL; while (pNode) { - pWidgetAcc = (CXFA_WidgetAcc*)pNode->GetWidgetData(); + pWidgetAcc = static_cast(pNode->GetWidgetData()); if (!pWidgetAcc) { return 1; } diff --git a/xfa/fxfa/app/xfa_ffimageedit.cpp b/xfa/fxfa/app/xfa_ffimageedit.cpp index bda281f744..f58bea1c54 100644 --- a/xfa/fxfa/app/xfa_ffimageedit.cpp +++ b/xfa/fxfa/app/xfa_ffimageedit.cpp @@ -27,7 +27,7 @@ FX_BOOL CXFA_FFImageEdit::LoadWidget() { if (pPictureBox) { pPictureBox->Initialize(); } - m_pNormalWidget = (CFWL_Widget*)pPictureBox; + m_pNormalWidget = pPictureBox; m_pNormalWidget->SetLayoutItem(this); IFWL_Widget* pWidget = m_pNormalWidget->GetWidget(); CFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver(); diff --git a/xfa/fxfa/app/xfa_ffpageview.cpp b/xfa/fxfa/app/xfa_ffpageview.cpp index bb277f46f0..ce30d199d5 100644 --- a/xfa/fxfa/app/xfa_ffpageview.cpp +++ b/xfa/fxfa/app/xfa_ffpageview.cpp @@ -134,9 +134,9 @@ CXFA_FFPageWidgetIterator::CXFA_FFPageWidgetIterator(CXFA_FFPageView* pPageView, m_pPageView = pPageView; m_dwFilter = dwFilter; m_sIterator.Init(pPageView); - m_bIgnorerelevant = ((CXFA_FFDoc*)m_pPageView->GetDocView()->GetDoc()) - ->GetXFADoc() - ->GetCurVersionMode() < XFA_VERSION_205; + m_bIgnorerelevant = + m_pPageView->GetDocView()->GetDoc()->GetXFADoc()->GetCurVersionMode() < + XFA_VERSION_205; } CXFA_FFPageWidgetIterator::~CXFA_FFPageWidgetIterator() {} void CXFA_FFPageWidgetIterator::Reset() { @@ -200,9 +200,9 @@ CXFA_FFTabOrderPageWidgetIterator::CXFA_FFTabOrderPageWidgetIterator( CXFA_FFPageView* pPageView, uint32_t dwFilter) : m_pPageView(pPageView), m_dwFilter(dwFilter), m_iCurWidget(-1) { - m_bIgnorerelevant = ((CXFA_FFDoc*)m_pPageView->GetDocView()->GetDoc()) - ->GetXFADoc() - ->GetCurVersionMode() < XFA_VERSION_205; + m_bIgnorerelevant = + m_pPageView->GetDocView()->GetDoc()->GetXFADoc()->GetCurVersionMode() < + XFA_VERSION_205; Reset(); } diff --git a/xfa/fxfa/app/xfa_ffpushbutton.cpp b/xfa/fxfa/app/xfa_ffpushbutton.cpp index 6c161b064b..168e8a1535 100644 --- a/xfa/fxfa/app/xfa_ffpushbutton.cpp +++ b/xfa/fxfa/app/xfa_ffpushbutton.cpp @@ -58,7 +58,7 @@ FX_BOOL CXFA_FFPushButton::LoadWidget() { pPushButton->Initialize(); } m_pOldDelegate = pPushButton->SetDelegate(this); - m_pNormalWidget = (CFWL_Widget*)pPushButton; + m_pNormalWidget = pPushButton; m_pNormalWidget->SetLayoutItem(this); IFWL_Widget* pWidget = m_pNormalWidget->GetWidget(); CFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver(); diff --git a/xfa/fxfa/app/xfa_fftextedit.cpp b/xfa/fxfa/app/xfa_fftextedit.cpp index ad1a508a16..35ed84810f 100644 --- a/xfa/fxfa/app/xfa_fftextedit.cpp +++ b/xfa/fxfa/app/xfa_fftextedit.cpp @@ -448,7 +448,7 @@ CXFA_FFNumericEdit::~CXFA_FFNumericEdit() {} FX_BOOL CXFA_FFNumericEdit::LoadWidget() { CFWL_Edit* pWidget = CFWL_Edit::Create(); pWidget->Initialize(); - m_pNormalWidget = (CFWL_Widget*)pWidget; + m_pNormalWidget = pWidget; IFWL_Widget* pIWidget = m_pNormalWidget->GetWidget(); m_pNormalWidget->SetLayoutItem(this); CFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver(); @@ -522,7 +522,7 @@ CXFA_FFPasswordEdit::~CXFA_FFPasswordEdit() {} FX_BOOL CXFA_FFPasswordEdit::LoadWidget() { CFWL_Edit* pWidget = CFWL_Edit::Create(); pWidget->Initialize(); - m_pNormalWidget = (CFWL_Widget*)pWidget; + m_pNormalWidget = pWidget; m_pNormalWidget->SetLayoutItem(this); IFWL_Widget* pIWidget = m_pNormalWidget->GetWidget(); CFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver(); @@ -588,7 +588,7 @@ FX_BOOL CXFA_FFDateTimeEdit::PtInActiveRect(FX_FLOAT fx, FX_FLOAT fy) { FX_BOOL CXFA_FFDateTimeEdit::LoadWidget() { CFWL_DateTimePicker* pWidget = CFWL_DateTimePicker::Create(); pWidget->Initialize(); - m_pNormalWidget = (CFWL_Widget*)pWidget; + m_pNormalWidget = pWidget; m_pNormalWidget->SetLayoutItem(this); IFWL_Widget* pIWidget = m_pNormalWidget->GetWidget(); CFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver(); diff --git a/xfa/fxfa/app/xfa_ffwidget.cpp b/xfa/fxfa/app/xfa_ffwidget.cpp index 8e10189f8c..8925cd35cf 100644 --- a/xfa/fxfa/app/xfa_ffwidget.cpp +++ b/xfa/fxfa/app/xfa_ffwidget.cpp @@ -345,7 +345,7 @@ CXFA_FFWidget* CXFA_FFWidget::GetParent() { m_pDataAcc->GetNode()->GetNodeItem(XFA_NODEITEM_Parent); if (pParentNode) { CXFA_WidgetAcc* pParentWidgetAcc = - (CXFA_WidgetAcc*)pParentNode->GetWidgetData(); + static_cast(pParentNode->GetWidgetData()); if (pParentWidgetAcc) { return pParentWidgetAcc->GetNextWidget(NULL); } @@ -378,7 +378,7 @@ CXFA_FFDocView* CXFA_FFWidget::GetDocView() { return m_pDocView; } CXFA_FFDoc* CXFA_FFWidget::GetDoc() { - return (CXFA_FFDoc*)m_pDocView->GetDoc(); + return m_pDocView->GetDoc(); } CXFA_FFApp* CXFA_FFWidget::GetApp() { return GetDoc()->GetApp(); diff --git a/xfa/fxfa/app/xfa_ffwidgetacc.cpp b/xfa/fxfa/app/xfa_ffwidgetacc.cpp index ce378df222..3301bed50e 100644 --- a/xfa/fxfa/app/xfa_ffwidgetacc.cpp +++ b/xfa/fxfa/app/xfa_ffwidgetacc.cpp @@ -216,7 +216,8 @@ void CXFA_WidgetAcc::ResetData() { XFA_NODEITEM_FirstChild, XFA_OBJECTTYPE_ContainerNode); while (pNextChild) { CXFA_Node* pChild = pNextChild; - CXFA_WidgetAcc* pAcc = (CXFA_WidgetAcc*)pChild->GetWidgetData(); + CXFA_WidgetAcc* pAcc = + static_cast(pChild->GetWidgetData()); if (!pAcc) { continue; } @@ -282,13 +283,13 @@ CXFA_WidgetAcc* CXFA_WidgetAcc::GetExclGroup() { if (!pExcl || pExcl->GetClassID() != XFA_ELEMENT_ExclGroup) { return NULL; } - return (CXFA_WidgetAcc*)pExcl->GetWidgetData(); + return static_cast(pExcl->GetWidgetData()); } CXFA_FFDocView* CXFA_WidgetAcc::GetDocView() { return m_pDocView; } CXFA_FFDoc* CXFA_WidgetAcc::GetDoc() { - return (CXFA_FFDoc*)m_pDocView->GetDoc(); + return m_pDocView->GetDoc(); } CXFA_FFApp* CXFA_WidgetAcc::GetApp() { return GetDoc()->GetApp(); @@ -677,7 +678,8 @@ int32_t CXFA_WidgetAcc::ExecuteScript(CXFA_Script script, } int32_t iRefs = refNodes.GetSize(); for (int32_t r = 0; r < iRefs; r++) { - CXFA_WidgetAcc* pRefAcc = (CXFA_WidgetAcc*)refNodes[r]->GetWidgetData(); + CXFA_WidgetAcc* pRefAcc = + static_cast(refNodes[r]->GetWidgetData()); if (pRefAcc && pRefAcc == this) { continue; } @@ -1688,7 +1690,7 @@ FX_BOOL CXFA_TextProvider::GetEmbbedObj(FX_BOOL bURI, wsAttr.AsStringC()); } if (pIDNode) { - pEmbAcc = (CXFA_WidgetAcc*)pIDNode->GetWidgetData(); + pEmbAcc = static_cast(pIDNode->GetWidgetData()); } if (pEmbAcc) { pEmbAcc->GetValue(wsValue, XFA_VALUEPICTURE_Display); diff --git a/xfa/fxfa/app/xfa_ffwidgethandler.cpp b/xfa/fxfa/app/xfa_ffwidgethandler.cpp index 027c3d9fa8..534a08a4e3 100644 --- a/xfa/fxfa/app/xfa_ffwidgethandler.cpp +++ b/xfa/fxfa/app/xfa_ffwidgethandler.cpp @@ -47,9 +47,8 @@ FX_BOOL CXFA_FFWidgetHandler::OnLButtonDown(CXFA_FFWidget* hWidget, hWidget->Rotate2Normal(fx, fy); FX_BOOL bRet = hWidget->OnLButtonDown(dwFlags, fx, fy); if (bRet && m_pDocView->SetFocus(hWidget)) { - ((CXFA_FFDoc*)m_pDocView->GetDoc()) - ->GetDocProvider() - ->SetFocusWidget(m_pDocView->GetDoc(), (CXFA_FFWidget*)hWidget); + m_pDocView->GetDoc()->GetDocProvider()->SetFocusWidget(m_pDocView->GetDoc(), + hWidget); } m_pDocView->UnlockUpdate(); m_pDocView->UpdateDocView(); @@ -107,9 +106,8 @@ FX_BOOL CXFA_FFWidgetHandler::OnRButtonDown(CXFA_FFWidget* hWidget, hWidget->Rotate2Normal(fx, fy); FX_BOOL bRet = hWidget->OnRButtonDown(dwFlags, fx, fy); if (bRet && m_pDocView->SetFocus(hWidget)) { - ((CXFA_FFDoc*)m_pDocView->GetDoc()) - ->GetDocProvider() - ->SetFocusWidget(m_pDocView->GetDoc(), (CXFA_FFWidget*)hWidget); + m_pDocView->GetDoc()->GetDocProvider()->SetFocusWidget(m_pDocView->GetDoc(), + hWidget); } m_pDocView->RunInvalidate(); return bRet; @@ -228,9 +226,8 @@ int32_t CXFA_FFWidgetHandler::ProcessEvent(CXFA_WidgetAcc* pWidgetAcc, case XFA_EVENT_Calculate: return pWidgetAcc->ProcessCalculate(); case XFA_EVENT_Validate: - if (((CXFA_FFDoc*)m_pDocView->GetDoc()) - ->GetDocProvider() - ->IsValidationsEnabled(m_pDocView->GetDoc())) { + if (m_pDocView->GetDoc()->GetDocProvider()->IsValidationsEnabled( + m_pDocView->GetDoc())) { return pWidgetAcc->ProcessValidate(); } return XFA_EVENTERROR_Disabled; @@ -269,7 +266,7 @@ CXFA_FFWidget* CXFA_FFWidgetHandler::CreateWidget(CXFA_FFWidget* hParent, m_pDocView->RunLayout(); CXFA_LayoutItem* pLayout = m_pDocView->GetXFALayout()->GetLayoutItem(pNewFormItem); - return (CXFA_FFWidget*)pLayout; + return static_cast(pLayout); } CXFA_Node* CXFA_FFWidgetHandler::CreateWidgetFormItem( @@ -550,6 +547,6 @@ CXFA_Document* CXFA_FFWidgetHandler::GetObjFactory() const { } CXFA_Document* CXFA_FFWidgetHandler::GetXFADoc() const { - return ((CXFA_FFDoc*)(m_pDocView->GetDoc()))->GetXFADoc(); + return m_pDocView->GetDoc()->GetXFADoc(); } diff --git a/xfa/fxfa/app/xfa_fontmgr.cpp b/xfa/fxfa/app/xfa_fontmgr.cpp index 17d600dfa0..f50bf5bf86 100644 --- a/xfa/fxfa/app/xfa_fontmgr.cpp +++ b/xfa/fxfa/app/xfa_fontmgr.cpp @@ -1840,7 +1840,7 @@ CFGAS_GEFont* CXFA_PDFFontMgr::FindFont(CFX_ByteString strPsName, if (!pFontSetDict) { return NULL; } - pFontSetDict = (CPDF_Dictionary*)pFontSetDict->GetDictBy("Font"); + pFontSetDict = pFontSetDict->GetDictBy("Font"); if (!pFontSetDict) { return NULL; } @@ -1853,12 +1853,8 @@ CFGAS_GEFont* CXFA_PDFFontMgr::FindFont(CFX_ByteString strPsName, bStrictMatch)) { continue; } - CPDF_Object* pDirect = pObj->GetDirect(); - if (!pDirect || !pDirect->IsDictionary()) { - return NULL; - } - CPDF_Dictionary* pFontDict = (CPDF_Dictionary*)pDirect; - if (pFontDict->GetStringBy("Type") != "Font") { + CPDF_Dictionary* pFontDict = ToDictionary(pObj->GetDirect()); + if (!pFontDict || pFontDict->GetStringBy("Type") != "Font") { return NULL; } CPDF_Font* pPDFFont = pDoc->LoadFont(pFontDict); diff --git a/xfa/fxfa/parser/xfa_layout_appadapter.h b/xfa/fxfa/parser/xfa_layout_appadapter.h index be7072b704..1bae22ee32 100644 --- a/xfa/fxfa/parser/xfa_layout_appadapter.h +++ b/xfa/fxfa/parser/xfa_layout_appadapter.h @@ -14,7 +14,7 @@ class CXFA_TraverseStrategy_PageAreaContainerLayoutItem { static inline CXFA_ContainerLayoutItem* GetFirstChild( CXFA_ContainerLayoutItem* pLayoutItem) { if (pLayoutItem->m_pFormNode->GetClassID() == XFA_ELEMENT_PageSet) { - return (CXFA_ContainerLayoutItem*)pLayoutItem->m_pFirstChild; + return static_cast(pLayoutItem->m_pFirstChild); } return NULL; } @@ -24,7 +24,7 @@ class CXFA_TraverseStrategy_PageAreaContainerLayoutItem { } static inline CXFA_ContainerLayoutItem* GetParent( CXFA_ContainerLayoutItem* pLayoutItem) { - return (CXFA_ContainerLayoutItem*)pLayoutItem->m_pParent; + return static_cast(pLayoutItem->m_pParent); } }; class CXFA_TraverseStrategy_ContentAreaContainerLayoutItem { @@ -53,22 +53,22 @@ class CXFA_TraverseStrategy_ContentAreaContainerLayoutItem { } static inline CXFA_ContainerLayoutItem* GetParent( CXFA_ContainerLayoutItem* pLayoutItem) { - return (CXFA_ContainerLayoutItem*)pLayoutItem->m_pParent; + return static_cast(pLayoutItem->m_pParent); } }; class CXFA_TraverseStrategy_ContentLayoutItem { public: static inline CXFA_ContentLayoutItem* GetFirstChild( CXFA_ContentLayoutItem* pLayoutItem) { - return (CXFA_ContentLayoutItem*)pLayoutItem->m_pFirstChild; + return static_cast(pLayoutItem->m_pFirstChild); } static inline CXFA_ContentLayoutItem* GetNextSibling( CXFA_ContentLayoutItem* pLayoutItem) { - return (CXFA_ContentLayoutItem*)pLayoutItem->m_pNextSibling; + return static_cast(pLayoutItem->m_pNextSibling); } static inline CXFA_ContentLayoutItem* GetParent( CXFA_ContentLayoutItem* pLayoutItem) { - return (CXFA_ContentLayoutItem*)pLayoutItem->m_pParent; + return static_cast(pLayoutItem->m_pParent); } }; diff --git a/xfa/fxfa/parser/xfa_script_layoutpseudomodel.cpp b/xfa/fxfa/parser/xfa_script_layoutpseudomodel.cpp index 4ec6c14dfd..37c64b6b05 100644 --- a/xfa/fxfa/parser/xfa_script_layoutpseudomodel.cpp +++ b/xfa/fxfa/parser/xfa_script_layoutpseudomodel.cpp @@ -211,8 +211,7 @@ void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_GetObjArray( const CFX_WideString& wsType, FX_BOOL bOnPageArea, CXFA_NodeArray& retArray) { - CXFA_ContainerLayoutItem* pLayoutPage = - (CXFA_ContainerLayoutItem*)pDocLayout->GetPage(iPageNo); + CXFA_ContainerLayoutItem* pLayoutPage = pDocLayout->GetPage(iPageNo); if (!pLayoutPage) { return; } -- cgit v1.2.3