summaryrefslogtreecommitdiff
path: root/fpdfsdk/src/fsdk_baseform.cpp
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2015-06-19 15:09:45 -0700
committerLei Zhang <thestig@chromium.org>2015-06-19 15:09:45 -0700
commite8d3691c82d1be805ffdce3329d00313af7ce0ab (patch)
tree39c6aeb956cc865e8f0b88ddcd80d1dd9e4285f7 /fpdfsdk/src/fsdk_baseform.cpp
parentcfac954abcab7caf47d3fa3d641c553cba998271 (diff)
downloadpdfium-e8d3691c82d1be805ffdce3329d00313af7ce0ab.tar.xz
Replace CFX_MapPtrTemplate with std::map.
R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1181593003.
Diffstat (limited to 'fpdfsdk/src/fsdk_baseform.cpp')
-rw-r--r--fpdfsdk/src/fsdk_baseform.cpp70
1 files changed, 32 insertions, 38 deletions
diff --git a/fpdfsdk/src/fsdk_baseform.cpp b/fpdfsdk/src/fsdk_baseform.cpp
index 312d323581..d3742520fa 100644
--- a/fpdfsdk/src/fsdk_baseform.cpp
+++ b/fpdfsdk/src/fsdk_baseform.cpp
@@ -1666,10 +1666,9 @@ CPDFSDK_InterForm::CPDFSDK_InterForm(CPDFSDK_Document* pDocument)
CPDFSDK_InterForm::~CPDFSDK_InterForm()
{
- delete m_pInterForm;
- m_pInterForm = NULL;
-
- m_Map.RemoveAll();
+ delete m_pInterForm;
+ m_pInterForm = nullptr;
+ m_Map.clear();
}
FX_BOOL CPDFSDK_InterForm::HighlightWidgets()
@@ -1688,45 +1687,40 @@ CPDFSDK_Widget* CPDFSDK_InterForm::GetSibling(CPDFSDK_Widget* pWidget, FX_BOOL b
return (CPDFSDK_Widget*)pIterator->GetPrevAnnot(pWidget);
}
-CPDFSDK_Widget* CPDFSDK_InterForm::GetWidget(CPDF_FormControl* pControl) const
+CPDFSDK_Widget* CPDFSDK_InterForm::GetWidget(CPDF_FormControl* pControl) const
{
- if(!pControl || !m_pInterForm) return NULL;
-
- CPDFSDK_Widget* pWidget = NULL;
- m_Map.Lookup(pControl, pWidget);
-
- if (pWidget) return pWidget;
+ if (!pControl || !m_pInterForm)
+ return nullptr;
- CPDF_Dictionary* pControlDict = pControl->GetWidget();
- ASSERT(pControlDict != NULL);
+ CPDFSDK_Widget* pWidget = nullptr;
+ const auto it = m_Map.find(pControl);
+ if (it != m_Map.end())
+ pWidget = it->second;
- ASSERT(m_pDocument != NULL);
- CPDF_Document* pDocument = m_pDocument->GetDocument();
+ if (pWidget)
+ return pWidget;
- CPDFSDK_PageView* pPage = NULL;
+ CPDF_Dictionary* pControlDict = pControl->GetWidget();
+ CPDF_Document* pDocument = m_pDocument->GetDocument();
+ CPDFSDK_PageView* pPage = nullptr;
- if (CPDF_Dictionary* pPageDict = pControlDict->GetDict("P"))
- {
- int nPageIndex = pDocument->GetPageIndex(pPageDict->GetObjNum());
- if (nPageIndex >= 0)
- {
- pPage = m_pDocument->GetPageView(nPageIndex);
- }
- }
-
- if (!pPage)
- {
- int nPageIndex = GetPageIndexByAnnotDict(pDocument, pControlDict);
- if (nPageIndex >= 0)
- {
- pPage = m_pDocument->GetPageView(nPageIndex);
- }
- }
+ if (CPDF_Dictionary* pPageDict = pControlDict->GetDict("P")) {
+ int nPageIndex = pDocument->GetPageIndex(pPageDict->GetObjNum());
+ if (nPageIndex >= 0) {
+ pPage = m_pDocument->GetPageView(nPageIndex);
+ }
+ }
- if (pPage)
- return (CPDFSDK_Widget*)pPage->GetAnnotByDict(pControlDict);
+ if (!pPage) {
+ int nPageIndex = GetPageIndexByAnnotDict(pDocument, pControlDict);
+ if (nPageIndex >= 0) {
+ pPage = m_pDocument->GetPageView(nPageIndex);
+ }
+ }
- return NULL;
+ if (!pPage)
+ return nullptr;
+ return (CPDFSDK_Widget*)pPage->GetAnnotByDict(pControlDict);
}
void CPDFSDK_InterForm::GetWidgets(const CFX_WideString& sFieldName, CFX_PtrArray& widgets)
@@ -1786,12 +1780,12 @@ int CPDFSDK_InterForm::GetPageIndexByAnnotDict(CPDF_Document* pDocument, CPDF_Di
void CPDFSDK_InterForm::AddMap(CPDF_FormControl* pControl, CPDFSDK_Widget* pWidget)
{
- m_Map.SetAt(pControl, pWidget);
+ m_Map[pControl] = pWidget;
}
void CPDFSDK_InterForm::RemoveMap(CPDF_FormControl* pControl)
{
- m_Map.RemoveKey(pControl);
+ m_Map.erase(pControl);
}
void CPDFSDK_InterForm::EnableCalculate(FX_BOOL bEnabled)