summaryrefslogtreecommitdiff
path: root/fpdfsdk/src/fsdk_baseform.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/fsdk_baseform.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/fsdk_baseform.cpp')
-rw-r--r--fpdfsdk/src/fsdk_baseform.cpp71
1 files changed, 33 insertions, 38 deletions
diff --git a/fpdfsdk/src/fsdk_baseform.cpp b/fpdfsdk/src/fsdk_baseform.cpp
index 262e5f8c7b..cff6a38c14 100644
--- a/fpdfsdk/src/fsdk_baseform.cpp
+++ b/fpdfsdk/src/fsdk_baseform.cpp
@@ -2397,11 +2397,11 @@ CPDFSDK_InterForm::CPDFSDK_InterForm(CPDFSDK_Document* pDocument)
CPDFSDK_InterForm::~CPDFSDK_InterForm()
{
- delete m_pInterForm;
- m_pInterForm = NULL;
+ delete m_pInterForm;
+ m_pInterForm = nullptr;
- m_Map.RemoveAll();
- m_XFAMap.RemoveAll();
+ m_Map.clear();
+ m_XFAMap.RemoveAll();
}
FX_BOOL CPDFSDK_InterForm::HighlightWidgets()
@@ -2420,45 +2420,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;
+ if (!pControl || !m_pInterForm)
+ return nullptr;
- CPDFSDK_Widget* pWidget = NULL;
- m_Map.Lookup(pControl, pWidget);
+ CPDFSDK_Widget* pWidget = nullptr;
+ const auto it = m_Map.find(pControl);
+ if (it != m_Map.end())
+ pWidget = it->second;
- if (pWidget) return pWidget;
+ if (pWidget)
+ return pWidget;
- CPDF_Dictionary* pControlDict = pControl->GetWidget();
- ASSERT(pControlDict != NULL);
+ CPDF_Dictionary* pControlDict = pControl->GetWidget();
+ CPDF_Document* pDocument = m_pDocument->GetDocument()->GetPDFDoc();
+ CPDFSDK_PageView* pPage = nullptr;
- ASSERT(m_pDocument != NULL);
- CPDF_Document* pDocument = m_pDocument->GetDocument()->GetPDFDoc();
-
- CPDFSDK_PageView* pPage = NULL;
-
- 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)
@@ -2518,12 +2513,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::AddXFAMap(IXFA_Widget* hWidget, CPDFSDK_XFAWidget* pWidget)