summaryrefslogtreecommitdiff
path: root/fpdfsdk/src/formfiller/FFL_IFormFiller.cpp
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2015-06-19 18:11:07 -0700
committerLei Zhang <thestig@chromium.org>2015-06-19 18:11:07 -0700
commit606346f584700bdae0741066f2e6d2481744032c (patch)
tree8f6afe79644cc515795af83dc8a06b207afb1bd6 /fpdfsdk/src/formfiller/FFL_IFormFiller.cpp
parent6d8b1c2c7b1cbada20109f70ae971a4192330bb5 (diff)
downloadpdfium-606346f584700bdae0741066f2e6d2481744032c.tar.xz
Merge to XFA: Replace some CFX_MapPtrTemplates with std::map.
There are more CFX_MapPtrTemplate usage on the XFA branch, so it is not removed. R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1181593003. (cherry picked from commit e8d3691c82d1be805ffdce3329d00313af7ce0ab) Review URL: https://codereview.chromium.org/1198663004.
Diffstat (limited to 'fpdfsdk/src/formfiller/FFL_IFormFiller.cpp')
-rw-r--r--fpdfsdk/src/formfiller/FFL_IFormFiller.cpp106
1 files changed, 47 insertions, 59 deletions
diff --git a/fpdfsdk/src/formfiller/FFL_IFormFiller.cpp b/fpdfsdk/src/formfiller/FFL_IFormFiller.cpp
index d4ca0235b3..66ae237a31 100644
--- a/fpdfsdk/src/formfiller/FFL_IFormFiller.cpp
+++ b/fpdfsdk/src/formfiller/FFL_IFormFiller.cpp
@@ -28,15 +28,9 @@ CFFL_IFormFiller::CFFL_IFormFiller(CPDFDoc_Environment* pApp) :
CFFL_IFormFiller::~CFFL_IFormFiller()
{
- FX_POSITION pos = m_Maps.GetStartPosition();
- while (pos)
- {
- CPDFSDK_Annot * pAnnot = NULL;
- CFFL_FormFiller * pFormFiller = NULL;
- m_Maps.GetNextAssoc(pos,pAnnot,pFormFiller);
- delete pFormFiller;
- }
- m_Maps.RemoveAll();
+ for (auto& it : m_Maps)
+ delete it.second;
+ m_Maps.clear();
}
FX_BOOL CFFL_IFormFiller::Annot_HitTest(CPDFSDK_PageView* pPageView,CPDFSDK_Annot* pAnnot, CPDF_Point point)
@@ -648,53 +642,46 @@ FX_BOOL CFFL_IFormFiller::IsFillingAllowed(CPDFSDK_Widget* pWidget)
CFFL_FormFiller* CFFL_IFormFiller::GetFormFiller(CPDFSDK_Annot* pAnnot, FX_BOOL bRegister)
{
-// ASSERT(pAnnot != NULL);
-// ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
-
- CFFL_FormFiller * pFormFiller = NULL;
- m_Maps.Lookup(pAnnot, pFormFiller);
-
- if (pFormFiller)
- return pFormFiller;
-
- if (bRegister)
- {
- CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
-
- int nFieldType = pWidget->GetFieldType();
- switch(nFieldType)
- {
- case FIELDTYPE_PUSHBUTTON:
- pFormFiller = new CFFL_PushButton(m_pApp, pWidget);
- break;
- case FIELDTYPE_CHECKBOX:
- pFormFiller = new CFFL_CheckBox(m_pApp, pWidget);
- break;
- case FIELDTYPE_RADIOBUTTON:
- pFormFiller = new CFFL_RadioButton(m_pApp, pWidget);
- break;
- case FIELDTYPE_TEXTFIELD:
- pFormFiller = new CFFL_TextField(m_pApp, pWidget);
- break;
- case FIELDTYPE_LISTBOX:
- pFormFiller = new CFFL_ListBox(m_pApp, pWidget);
- break;
- case FIELDTYPE_COMBOBOX:
- pFormFiller = new CFFL_ComboBox(m_pApp, pWidget);
- break;
- case FIELDTYPE_UNKNOWN:
- default:
- pFormFiller = NULL;
- break;
- }
+ auto it = m_Maps.find(pAnnot);
+ if (it != m_Maps.end())
+ return it->second;
+
+ if (!bRegister)
+ return nullptr;
+
+ CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
+ int nFieldType = pWidget->GetFieldType();
+ CFFL_FormFiller* pFormFiller;
+ switch (nFieldType) {
+ case FIELDTYPE_PUSHBUTTON:
+ pFormFiller = new CFFL_PushButton(m_pApp, pWidget);
+ break;
+ case FIELDTYPE_CHECKBOX:
+ pFormFiller = new CFFL_CheckBox(m_pApp, pWidget);
+ break;
+ case FIELDTYPE_RADIOBUTTON:
+ pFormFiller = new CFFL_RadioButton(m_pApp, pWidget);
+ break;
+ case FIELDTYPE_TEXTFIELD:
+ pFormFiller = new CFFL_TextField(m_pApp, pWidget);
+ break;
+ case FIELDTYPE_LISTBOX:
+ pFormFiller = new CFFL_ListBox(m_pApp, pWidget);
+ break;
+ case FIELDTYPE_COMBOBOX:
+ pFormFiller = new CFFL_ComboBox(m_pApp, pWidget);
+ break;
+ case FIELDTYPE_UNKNOWN:
+ default:
+ pFormFiller = nullptr;
+ break;
+ }
- if (pFormFiller)
- {
- m_Maps.SetAt(pAnnot, pFormFiller);
- }
- }
+ if (!pFormFiller)
+ return nullptr;
- return pFormFiller;
+ m_Maps[pAnnot] = pFormFiller;
+ return pFormFiller;
}
void CFFL_IFormFiller::RemoveFormFiller(CPDFSDK_Annot* pAnnot)
@@ -707,11 +694,12 @@ void CFFL_IFormFiller::RemoveFormFiller(CPDFSDK_Annot* pAnnot)
void CFFL_IFormFiller::UnRegisterFormFiller(CPDFSDK_Annot* pAnnot)
{
- CFFL_FormFiller* pFormFiller = nullptr;
- if (m_Maps.Lookup(pAnnot,pFormFiller)) {
- delete pFormFiller;
- m_Maps.RemoveKey(pAnnot);
- }
+ auto it = m_Maps.find(pAnnot);
+ if (it == m_Maps.end())
+ return;
+
+ delete it->second;
+ m_Maps.erase(it);
}
void CFFL_IFormFiller::SetFocusAnnotTab(CPDFSDK_Annot* pWidget, FX_BOOL bSameField, FX_BOOL bNext)