summaryrefslogtreecommitdiff
path: root/fpdfsdk/src/formfiller/FFL_FormFiller.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_FormFiller.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_FormFiller.cpp')
-rw-r--r--fpdfsdk/src/formfiller/FFL_FormFiller.cpp106
1 files changed, 43 insertions, 63 deletions
diff --git a/fpdfsdk/src/formfiller/FFL_FormFiller.cpp b/fpdfsdk/src/formfiller/FFL_FormFiller.cpp
index 540619692b..7a70493d4c 100644
--- a/fpdfsdk/src/formfiller/FFL_FormFiller.cpp
+++ b/fpdfsdk/src/formfiller/FFL_FormFiller.cpp
@@ -28,23 +28,14 @@ CFFL_FormFiller::CFFL_FormFiller(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pAnno
CFFL_FormFiller::~CFFL_FormFiller()
{
- FX_POSITION pos = m_Maps.GetStartPosition();
- while (pos)
- {
- CPDFSDK_PageView * pPageView = NULL;
- CPWL_Wnd* pWnd = NULL;
- m_Maps.GetNextAssoc(pos, pPageView, pWnd);
-
- if (pWnd)
- {
- CFFL_PrivateData* pData = (CFFL_PrivateData*)pWnd->GetAttachedData();
- pWnd->Destroy();
- delete pWnd;
- delete pData;
- }
- }
- m_Maps.RemoveAll();
-
+ for (auto& it : m_Maps) {
+ CPWL_Wnd* pWnd = it.second;
+ CFFL_PrivateData* pData = (CFFL_PrivateData*)pWnd->GetAttachedData();
+ pWnd->Destroy();
+ delete pWnd;
+ delete pData;
+ }
+ m_Maps.clear();
}
void CFFL_FormFiller::SetWindowRect(CPDFSDK_PageView* pPageView, const CPDF_Rect& rcWindow)
@@ -430,64 +421,53 @@ PWL_CREATEPARAM CFFL_FormFiller::GetCreateParam()
CPWL_Wnd* CFFL_FormFiller::GetPDFWindow(CPDFSDK_PageView* pPageView, FX_BOOL bNew)
{
- ASSERT(pPageView != NULL);
- ASSERT(m_pWidget != NULL);
+ ASSERT(pPageView);
- CPWL_Wnd* pWnd = NULL;
- m_Maps.Lookup(pPageView, pWnd);
+ auto it = m_Maps.find(pPageView);
+ const bool found = it != m_Maps.end();
+ CPWL_Wnd* pWnd = found ? it->second : nullptr;
+ if (!bNew)
+ return pWnd;
- if (bNew)
- {
- if (pWnd)
- {
- CFFL_PrivateData* pPrivateData = (CFFL_PrivateData*)pWnd->GetAttachedData();
- ASSERT(pPrivateData != NULL);
+ if (found) {
+ CFFL_PrivateData* pPrivateData =
+ (CFFL_PrivateData*)pWnd->GetAttachedData();
+ if (pPrivateData->nWidgetAge != m_pWidget->GetAppearanceAge()) {
+ return ResetPDFWindow(
+ pPageView, m_pWidget->GetValueAge() == pPrivateData->nValueAge);
+ }
+ } else {
+ PWL_CREATEPARAM cp = GetCreateParam();
+ cp.hAttachedWnd = (FX_HWND)m_pWidget;
- if (pPrivateData->nWidgetAge != m_pWidget->GetAppearanceAge())
- {
- return ResetPDFWindow(pPageView, m_pWidget->GetValueAge() == pPrivateData->nValueAge);
- }
- }
- else
- {
- PWL_CREATEPARAM cp = GetCreateParam();
- cp.hAttachedWnd = (FX_HWND)m_pWidget;
+ CFFL_PrivateData* pPrivateData = new CFFL_PrivateData;
+ pPrivateData->pWidget = m_pWidget;
+ pPrivateData->pPageView = pPageView;
+ pPrivateData->nWidgetAge = m_pWidget->GetAppearanceAge();
+ pPrivateData->nValueAge = 0;
- CFFL_PrivateData* pPrivateData = new CFFL_PrivateData;
- pPrivateData->pWidget = m_pWidget;
- pPrivateData->pPageView = pPageView;
- pPrivateData->nWidgetAge = m_pWidget->GetAppearanceAge();
- pPrivateData->nValueAge = 0;
+ cp.pAttachedData = pPrivateData;
- cp.pAttachedData = pPrivateData;
+ pWnd = NewPDFWindow(cp, pPageView);
+ m_Maps[pPageView] = pWnd;
+ }
- pWnd = NewPDFWindow(cp, pPageView);
-
- if (pWnd)
- {
- m_Maps.SetAt(pPageView, pWnd);
- }
- }
- }
-
- return pWnd;
+ return pWnd;
}
void CFFL_FormFiller::DestroyPDFWindow(CPDFSDK_PageView* pPageView)
{
- CPWL_Wnd* pWnd = NULL;
- m_Maps.Lookup(pPageView, pWnd);
+ auto it = m_Maps.find(pPageView);
+ if (it == m_Maps.end())
+ return;
- if (pWnd)
- {
- CFFL_PrivateData* pData = (CFFL_PrivateData*)pWnd->GetAttachedData();
- pData->pPageView = NULL;
- pWnd->Destroy();
- delete pWnd;
- delete pData;
- }
+ CPWL_Wnd* pWnd = it->second;
+ CFFL_PrivateData* pData = (CFFL_PrivateData*)pWnd->GetAttachedData();
+ pWnd->Destroy();
+ delete pWnd;
+ delete pData;
- m_Maps.RemoveKey(pPageView);
+ m_Maps.erase(it);
}
CPDF_Matrix CFFL_FormFiller::GetWindowMatrix(void* pAttachedData)