From 16a2033b3b7e2e348509c9938d77268e85e2b763 Mon Sep 17 00:00:00 2001 From: tsepez Date: Fri, 22 Apr 2016 14:00:47 -0700 Subject: Remove CFX_MapPtrTemplate usage in fsdk_baseform.cpp Replace one instance with std::map. Remove another instance that is never inserted into. Review URL: https://codereview.chromium.org/1919433002 --- fpdfsdk/fsdk_baseform.cpp | 22 +++++++++------------- fpdfsdk/include/fsdk_baseform.h | 6 +----- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/fpdfsdk/fsdk_baseform.cpp b/fpdfsdk/fsdk_baseform.cpp index 4a2540093f..6693de1250 100644 --- a/fpdfsdk/fsdk_baseform.cpp +++ b/fpdfsdk/fsdk_baseform.cpp @@ -7,6 +7,7 @@ #include "fpdfsdk/include/fsdk_baseform.h" #include +#include #include #include @@ -1997,7 +1998,7 @@ CPDFSDK_InterForm::~CPDFSDK_InterForm() { m_pInterForm = nullptr; m_Map.clear(); #ifdef PDF_ENABLE_XFA - m_XFAMap.RemoveAll(); + m_XFAMap.clear(); #endif // PDF_ENABLE_XFA } @@ -2114,18 +2115,19 @@ FX_BOOL CPDFSDK_InterForm::IsCalculateEnabled() const { #ifdef PDF_ENABLE_XFA void CPDFSDK_InterForm::AddXFAMap(CXFA_FFWidget* hWidget, CPDFSDK_XFAWidget* pWidget) { - m_XFAMap.SetAt(hWidget, pWidget); + FXSYS_assert(hWidget); + m_XFAMap[hWidget] = pWidget; } void CPDFSDK_InterForm::RemoveXFAMap(CXFA_FFWidget* hWidget) { - m_XFAMap.RemoveKey(hWidget); + FXSYS_assert(hWidget); + m_XFAMap.erase(hWidget); } CPDFSDK_XFAWidget* CPDFSDK_InterForm::GetXFAWidget(CXFA_FFWidget* hWidget) { - CPDFSDK_XFAWidget* pWidget = NULL; - m_XFAMap.Lookup(hWidget, pWidget); - - return pWidget; + FXSYS_assert(hWidget); + auto it = m_XFAMap.find(hWidget); + return it != m_XFAMap.end() ? it->second : nullptr; } void CPDFSDK_InterForm::XfaEnableCalculate(FX_BOOL bEnabled) { @@ -2454,14 +2456,8 @@ FX_BOOL CPDFSDK_InterForm::ExportFieldsToFDFTextBuf( #ifdef PDF_ENABLE_XFA void CPDFSDK_InterForm::SynchronizeField(CPDF_FormField* pFormField, FX_BOOL bSynchronizeElse) { - int x = 0; - if (m_FieldSynchronizeMap.Lookup(pFormField, x)) - return; - for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) { CPDF_FormControl* pFormCtrl = pFormField->GetControl(i); - ASSERT(pFormCtrl); - ASSERT(m_pInterForm); if (CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl)) { pWidget->Synchronize(bSynchronizeElse); } diff --git a/fpdfsdk/include/fsdk_baseform.h b/fpdfsdk/include/fsdk_baseform.h index fbe9a41c84..fa19c75a6b 100644 --- a/fpdfsdk/include/fsdk_baseform.h +++ b/fpdfsdk/include/fsdk_baseform.h @@ -243,9 +243,6 @@ class CPDFSDK_XFAWidget : public CPDFSDK_Annot { CPDFSDK_InterForm* m_pInterForm; CXFA_FFWidget* m_hXFAWidget; }; -#define CPDFSDK_XFAWidgetMap \ - CFX_MapPtrTemplate -#define CPDFSDK_FieldSynchronizeMap CFX_MapPtrTemplate #endif // PDF_ENABLE_XFA class CPDFSDK_InterForm : public CPDF_FormNotify { @@ -341,8 +338,7 @@ class CPDFSDK_InterForm : public CPDF_FormNotify { CPDF_InterForm* m_pInterForm; CPDFSDK_WidgetMap m_Map; #ifdef PDF_ENABLE_XFA - CPDFSDK_XFAWidgetMap m_XFAMap; - CPDFSDK_FieldSynchronizeMap m_FieldSynchronizeMap; + std::map m_XFAMap; FX_BOOL m_bXfaCalculate; FX_BOOL m_bXfaValidationsEnabled; #endif // PDF_ENABLE_XFA -- cgit v1.2.3