From bb0d446df18ee34504a165f3fc96fbb81b274f31 Mon Sep 17 00:00:00 2001 From: tsepez Date: Wed, 27 Apr 2016 16:59:30 -0700 Subject: Replace CFX_PtrArray with typesafe CFX_ArrayTemplate<>, part 3 Review-Url: https://codereview.chromium.org/1924093003 --- xfa/fxfa/app/xfa_ffdocview.cpp | 2 +- xfa/fxfa/app/xfa_fontmgr.cpp | 7 ++----- xfa/fxfa/include/xfa_ffwidget.h | 5 ++++- xfa/fxfa/include/xfa_fontmgr.h | 2 +- xfa/fxfa/parser/xfa_localemgr.cpp | 34 ++++++++++++++++++---------------- xfa/fxfa/parser/xfa_localemgr.h | 4 ++-- xfa/fxfa/parser/xfa_script_imp.cpp | 6 ++---- xfa/fxfa/parser/xfa_script_imp.h | 2 +- 8 files changed, 31 insertions(+), 31 deletions(-) (limited to 'xfa/fxfa') diff --git a/xfa/fxfa/app/xfa_ffdocview.cpp b/xfa/fxfa/app/xfa_ffdocview.cpp index c168e4b63d..d58b594e27 100644 --- a/xfa/fxfa/app/xfa_ffdocview.cpp +++ b/xfa/fxfa/app/xfa_ffdocview.cpp @@ -651,7 +651,7 @@ void CXFA_FFDocView::AddCalculateNodeNotify(CXFA_Node* pNodeChange) { (CXFA_CalcData*)pNodeChange->GetUserData(XFA_CalcData); int32_t iCount = pGlobalData ? pGlobalData->m_Globals.GetSize() : 0; for (int32_t i = 0; i < iCount; i++) { - CXFA_WidgetAcc* pResultAcc = (CXFA_WidgetAcc*)pGlobalData->m_Globals[i]; + CXFA_WidgetAcc* pResultAcc = pGlobalData->m_Globals[i]; if (pResultAcc->GetNode()->HasFlag(XFA_NODEFLAG_HasRemoved)) { continue; } diff --git a/xfa/fxfa/app/xfa_fontmgr.cpp b/xfa/fxfa/app/xfa_fontmgr.cpp index 69883674e5..608c9073c3 100644 --- a/xfa/fxfa/app/xfa_fontmgr.cpp +++ b/xfa/fxfa/app/xfa_fontmgr.cpp @@ -1737,11 +1737,8 @@ const XFA_FONTINFO* XFA_GetFontINFOByFontName( } CXFA_DefFontMgr::~CXFA_DefFontMgr() { - int32_t iCounts = m_CacheFonts.GetSize(); - for (int32_t i = 0; i < iCounts; i++) { - ((IFX_Font*)m_CacheFonts[i])->Release(); - } - m_CacheFonts.RemoveAll(); + for (int32_t i = 0; i < m_CacheFonts.GetSize(); i++) + m_CacheFonts[i]->Release(); } IFX_Font* CXFA_DefFontMgr::GetFont(CXFA_FFDoc* hDoc, diff --git a/xfa/fxfa/include/xfa_ffwidget.h b/xfa/fxfa/include/xfa_ffwidget.h index 0c0ba75791..a6ab999485 100644 --- a/xfa/fxfa/include/xfa_ffwidget.h +++ b/xfa/fxfa/include/xfa_ffwidget.h @@ -29,13 +29,16 @@ enum XFA_WIDGETITEM { XFA_WIDGETITEM_NextSibling, XFA_WIDGETITEM_PrevSibling, }; + class CXFA_CalcData { public: CXFA_CalcData() : m_iRefCount(0) {} ~CXFA_CalcData() { m_Globals.RemoveAll(); } - CFX_PtrArray m_Globals; + + CFX_ArrayTemplate m_Globals; int32_t m_iRefCount; }; + class CXFA_FFWidget : public CFX_PrivateData, public CXFA_ContentLayoutItem { public: CXFA_FFWidget(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc); diff --git a/xfa/fxfa/include/xfa_fontmgr.h b/xfa/fxfa/include/xfa_fontmgr.h index 8b3e20f5e3..c7358a4c2a 100644 --- a/xfa/fxfa/include/xfa_fontmgr.h +++ b/xfa/fxfa/include/xfa_fontmgr.h @@ -39,7 +39,7 @@ class CXFA_DefFontMgr { uint16_t wCodePage = 0xFFFF); protected: - CFX_PtrArray m_CacheFonts; + CFX_ArrayTemplate m_CacheFonts; }; class CXFA_PDFFontMgr { diff --git a/xfa/fxfa/parser/xfa_localemgr.cpp b/xfa/fxfa/parser/xfa_localemgr.cpp index 069279cdc5..519c4819bd 100644 --- a/xfa/fxfa/parser/xfa_localemgr.cpp +++ b/xfa/fxfa/parser/xfa_localemgr.cpp @@ -1134,14 +1134,11 @@ CXFA_LocaleMgr::CXFA_LocaleMgr(CXFA_Node* pLocaleSet, CFX_WideString wsDeflcid) m_pDefLocale = GetLocaleByName(wsDeflcid.AsStringC()); } CXFA_LocaleMgr::~CXFA_LocaleMgr() { - int32_t iCount = m_LocaleArray.GetSize(); - for (int32_t i = 0; i < iCount; i++) { - ((IFX_Locale*)m_LocaleArray[i])->Release(); - } - int32_t iXmls = m_XMLLocaleArray.GetSize(); - for (int32_t j = 0; j < iXmls; j++) { - ((IFX_Locale*)m_XMLLocaleArray[j])->Release(); - } + for (int32_t i = 0; i < m_LocaleArray.GetSize(); i++) + m_LocaleArray[i]->Release(); + + for (int32_t j = 0; j < m_XMLLocaleArray.GetSize(); j++) + m_XMLLocaleArray[j]->Release(); } void CXFA_LocaleMgr::Release() { delete this; @@ -1149,19 +1146,24 @@ void CXFA_LocaleMgr::Release() { uint16_t CXFA_LocaleMgr::GetDefLocaleID() { return m_dwDeflcid; } + IFX_Locale* CXFA_LocaleMgr::GetDefLocale() { - if (m_pDefLocale) { + if (m_pDefLocale) return m_pDefLocale; - } else if (m_LocaleArray.GetSize()) { - return (IFX_Locale*)m_LocaleArray[0]; - } else if (m_XMLLocaleArray.GetSize()) { - return (IFX_Locale*)m_XMLLocaleArray[0]; - } + + if (m_LocaleArray.GetSize()) + return m_LocaleArray[0]; + + if (m_XMLLocaleArray.GetSize()) + return m_XMLLocaleArray[0]; + m_pDefLocale = GetLocale(m_dwDeflcid); if (m_pDefLocale) m_XMLLocaleArray.Add(m_pDefLocale); + return m_pDefLocale; } + IFX_Locale* CXFA_LocaleMgr::GetLocale(uint16_t lcid) { IFX_Locale* pLocal = NULL; switch (lcid) { @@ -1219,7 +1221,7 @@ IFX_Locale* CXFA_LocaleMgr::GetLocaleByName( int32_t iCount = m_LocaleArray.GetSize(); int32_t i = 0; for (i = 0; i < iCount; i++) { - IFX_Locale* pLocale = ((IFX_Locale*)m_LocaleArray[i]); + IFX_Locale* pLocale = m_LocaleArray[i]; if (pLocale->GetName() == wsLocaleName) { return pLocale; } @@ -1230,7 +1232,7 @@ IFX_Locale* CXFA_LocaleMgr::GetLocaleByName( } iCount = m_XMLLocaleArray.GetSize(); for (i = 0; i < iCount; i++) { - IFX_Locale* pLocale = ((IFX_Locale*)m_XMLLocaleArray[i]); + IFX_Locale* pLocale = m_XMLLocaleArray[i]; if (pLocale->GetName() == wsLocaleName) { return pLocale; } diff --git a/xfa/fxfa/parser/xfa_localemgr.h b/xfa/fxfa/parser/xfa_localemgr.h index 2bdd1dd504..c82c47c7f3 100644 --- a/xfa/fxfa/parser/xfa_localemgr.h +++ b/xfa/fxfa/parser/xfa_localemgr.h @@ -43,8 +43,8 @@ class CXFA_LocaleMgr : public IFX_LocaleMgr { CFX_WideStringC GetConfigLocaleName(CXFA_Node* pConfig); protected: - CFX_PtrArray m_LocaleArray; - CFX_PtrArray m_XMLLocaleArray; + CFX_ArrayTemplate m_LocaleArray; + CFX_ArrayTemplate m_XMLLocaleArray; IFX_Locale* m_pDefLocale; CFX_WideString m_wsConfigLocale; uint16_t m_dwDeflcid; diff --git a/xfa/fxfa/parser/xfa_script_imp.cpp b/xfa/fxfa/parser/xfa_script_imp.cpp index 0c8aa1a838..ea16fd1e7c 100644 --- a/xfa/fxfa/parser/xfa_script_imp.cpp +++ b/xfa/fxfa/parser/xfa_script_imp.cpp @@ -58,10 +58,8 @@ CXFA_ScriptContext::~CXFA_ScriptContext() { m_pResolveProcessor = NULL; } m_upObjectArray.RemoveAll(); - for (int32_t i = 0; i < m_CacheListArray.GetSize(); i++) { - delete ((CXFA_NodeList*)m_CacheListArray[i]); - } - m_CacheListArray.RemoveAll(); + for (int32_t i = 0; i < m_CacheListArray.GetSize(); i++) + delete m_CacheListArray[i]; } void CXFA_ScriptContext::Initialize(FXJSE_HRUNTIME hRuntime) { m_hJsRuntime = hRuntime; diff --git a/xfa/fxfa/parser/xfa_script_imp.h b/xfa/fxfa/parser/xfa_script_imp.h index 414e403d19..1ff8f76745 100644 --- a/xfa/fxfa/parser/xfa_script_imp.h +++ b/xfa/fxfa/parser/xfa_script_imp.h @@ -113,7 +113,7 @@ class CXFA_ScriptContext { CFX_MapPtrTemplate m_mapVariableToHValue; CXFA_EventParam m_eventParam; CXFA_NodeArray m_upObjectArray; - CFX_PtrArray m_CacheListArray; + CFX_ArrayTemplate m_CacheListArray; CXFA_NodeArray* m_pScriptNodeArray; CXFA_ResolveProcessor* m_pResolveProcessor; XFA_HFM2JSCONTEXT m_hFM2JSContext; -- cgit v1.2.3