summaryrefslogtreecommitdiff
path: root/fpdfsdk/src
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk/src')
-rw-r--r--fpdfsdk/src/formfiller/FFL_FormFiller.cpp106
-rw-r--r--fpdfsdk/src/formfiller/FFL_IFormFiller.cpp106
-rw-r--r--fpdfsdk/src/formfiller/FFL_ListBox.cpp52
-rw-r--r--fpdfsdk/src/fpdfformfill.cpp1
-rw-r--r--fpdfsdk/src/fsdk_baseform.cpp70
-rw-r--r--fpdfsdk/src/fsdk_mgr.cpp98
-rw-r--r--fpdfsdk/src/pdfwindow/PWL_Wnd.cpp44
7 files changed, 201 insertions, 276 deletions
diff --git a/fpdfsdk/src/formfiller/FFL_FormFiller.cpp b/fpdfsdk/src/formfiller/FFL_FormFiller.cpp
index 7f5ee2ffec..6b211f3b8f 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)
diff --git a/fpdfsdk/src/formfiller/FFL_IFormFiller.cpp b/fpdfsdk/src/formfiller/FFL_IFormFiller.cpp
index 464ff3ce6b..62090a5c08 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)
@@ -645,53 +639,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)
@@ -704,11 +691,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)
diff --git a/fpdfsdk/src/formfiller/FFL_ListBox.cpp b/fpdfsdk/src/formfiller/FFL_ListBox.cpp
index 4622d4fcef..28dcf340ad 100644
--- a/fpdfsdk/src/formfiller/FFL_ListBox.cpp
+++ b/fpdfsdk/src/formfiller/FFL_ListBox.cpp
@@ -75,7 +75,7 @@ CPWL_Wnd* CFFL_ListBox::NewPDFWindow(const PWL_CREATEPARAM& cp, CPDFSDK_PageView
if (pWnd->HasFlag(PLBS_MULTIPLESEL))
{
- m_OriginSelections.RemoveAll();
+ m_OriginSelections.clear();
FX_BOOL bSetCaret = FALSE;
for (int32_t i=0,sz=m_pWidget->CountOptions(); i<sz; i++)
@@ -88,7 +88,7 @@ CPWL_Wnd* CFFL_ListBox::NewPDFWindow(const PWL_CREATEPARAM& cp, CPDFSDK_PageView
bSetCaret = TRUE;
}
pWnd->Select(i);
- m_OriginSelections.SetAt(i, NULL);
+ m_OriginSelections.insert(i);
}
}
}
@@ -115,36 +115,26 @@ FX_BOOL CFFL_ListBox::OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT nFlag
return CFFL_FormFiller::OnChar(pAnnot, nChar, nFlags);
}
-FX_BOOL CFFL_ListBox::IsDataChanged(CPDFSDK_PageView* pPageView)
+FX_BOOL CFFL_ListBox::IsDataChanged(CPDFSDK_PageView* pPageView)
{
- ASSERT(m_pWidget != NULL);
-
- if (CPWL_ListBox* pListBox = (CPWL_ListBox*)GetPDFWindow(pPageView, FALSE))
- {
- if (m_pWidget->GetFieldFlags() & FIELDFLAG_MULTISELECT)
- {
- int nSelCount = 0;
- for (int32_t i=0,sz=pListBox->GetCount(); i<sz; i++)
- {
- if (pListBox->IsItemSelected(i))
- {
- void* p = NULL;
- if (!m_OriginSelections.Lookup(i, p))
- return TRUE;
-
- nSelCount++;
- }
- }
-
- return nSelCount != m_OriginSelections.GetCount();
- }
- else
- {
- return pListBox->GetCurSel() != m_pWidget->GetSelectedIndex(0);
- }
- }
-
- return FALSE;
+ CPWL_ListBox* pListBox = (CPWL_ListBox*)GetPDFWindow(pPageView, FALSE);
+ if (!pListBox)
+ return FALSE;
+
+ if (m_pWidget->GetFieldFlags() & FIELDFLAG_MULTISELECT) {
+ int nSelCount = 0;
+ for (int32_t i = 0, sz = pListBox->GetCount(); i < sz; ++i) {
+ if (pListBox->IsItemSelected(i)) {
+ if (m_OriginSelections.count(i) == 0)
+ return TRUE;
+
+ nSelCount++;
+ }
+ }
+
+ return nSelCount != m_OriginSelections.size();
+ }
+ return pListBox->GetCurSel() != m_pWidget->GetSelectedIndex(0);
}
void CFFL_ListBox::SaveData(CPDFSDK_PageView* pPageView)
diff --git a/fpdfsdk/src/fpdfformfill.cpp b/fpdfsdk/src/fpdfformfill.cpp
index a8dfe7f7d7..9358c9e194 100644
--- a/fpdfsdk/src/fpdfformfill.cpp
+++ b/fpdfsdk/src/fpdfformfill.cpp
@@ -339,7 +339,6 @@ DLLEXPORT void STDCALL FORM_DoDocumentJSAction(FPDF_FORMHANDLE hHandle)
return;
if( CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetCurrentDoc())
{
- pSDKDoc->InitPageView();
if(((CPDFDoc_Environment*)hHandle)->IsJSInitiated())
pSDKDoc->ProcJavascriptFun();
}
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)
diff --git a/fpdfsdk/src/fsdk_mgr.cpp b/fpdfsdk/src/fsdk_mgr.cpp
index 5d4680d978..003753223f 100644
--- a/fpdfsdk/src/fsdk_mgr.cpp
+++ b/fpdfsdk/src/fsdk_mgr.cpp
@@ -317,14 +317,9 @@ CPDFSDK_Document::CPDFSDK_Document(CPDF_Document* pDoc,CPDFDoc_Environment* pEnv
CPDFSDK_Document::~CPDFSDK_Document()
{
- FX_POSITION pos = m_pageMap.GetStartPosition();
- while (pos) {
- CPDF_Page* pPage = NULL;
- CPDFSDK_PageView* pPageView = NULL;
- m_pageMap.GetNextAssoc(pos, pPage, pPageView);
- delete pPageView;
- }
- m_pageMap.RemoveAll();
+ for (auto& it : m_pageMap)
+ delete it.second;
+ m_pageMap.clear();
delete m_pInterForm;
m_pInterForm = nullptr;
@@ -333,36 +328,20 @@ CPDFSDK_Document::~CPDFSDK_Document()
m_pOccontent = nullptr;
}
-void CPDFSDK_Document::InitPageView()
-{
- int nCount = m_pDoc->GetPageCount();
- for(int i=0; i<nCount; i++)
- {
- // To do
-// CPDF_Dictionary* pDic = m_pDoc->GetPage(i);
-// m_pageMap.SetAt(pDic, pPageView);
- }
-}
-
-void CPDFSDK_Document::AddPageView(CPDF_Page* pPDFPage, CPDFSDK_PageView* pPageView)
-{
- m_pageMap.SetAt(pPDFPage, pPageView);
-}
-
CPDFSDK_PageView* CPDFSDK_Document::GetPageView(CPDF_Page* pPDFPage, FX_BOOL ReNew)
{
- CPDFSDK_PageView* pPageView = (CPDFSDK_PageView*)m_pageMap.GetValueAt(pPDFPage);
- if(pPageView != NULL)
- return pPageView;
- if(ReNew)
- {
- pPageView = new CPDFSDK_PageView(this,pPDFPage);
- m_pageMap.SetAt(pPDFPage, pPageView);
- //Delay to load all the annotations, to avoid endless loop.
- pPageView->LoadFXAnnots();
- }
- return pPageView;
+ auto it = m_pageMap.find(pPDFPage);
+ if (it != m_pageMap.end())
+ return it->second;
+ if (!ReNew)
+ return nullptr;
+
+ CPDFSDK_PageView* pPageView = new CPDFSDK_PageView(this, pPDFPage);
+ m_pageMap[pPDFPage] = pPageView;
+ // Delay to load all the annotations, to avoid endless loop.
+ pPageView->LoadFXAnnots();
+ return pPageView;
}
CPDFSDK_PageView* CPDFSDK_Document::GetCurrentView()
@@ -373,16 +352,12 @@ CPDFSDK_PageView* CPDFSDK_Document::GetCurrentView()
CPDFSDK_PageView* CPDFSDK_Document::GetPageView(int nIndex)
{
- CPDFSDK_PageView * pTempPageView = NULL;
- CPDF_Page * pTempPage = (CPDF_Page*)m_pEnv->FFI_GetPage(m_pDoc,nIndex);
- if(!pTempPage)
- return NULL;
-
- m_pageMap.Lookup(pTempPage, pTempPageView);
+ CPDF_Page* pTempPage = (CPDF_Page*)m_pEnv->FFI_GetPage(m_pDoc, nIndex);
+ if (!pTempPage)
+ return nullptr;
- ASSERT(pTempPageView != NULL);
-
- return pTempPageView;
+ auto it = m_pageMap.find(pTempPage);
+ return it->second;
}
void CPDFSDK_Document:: ProcJavascriptFun()
@@ -440,12 +415,16 @@ CPDF_OCContext* CPDFSDK_Document::GetOCContext()
void CPDFSDK_Document::ReMovePageView(CPDF_Page* pPDFPage)
{
- CPDFSDK_PageView* pPageView = (CPDFSDK_PageView*)m_pageMap.GetValueAt(pPDFPage);
- if(pPageView && !pPageView->IsLocked())
- {
- delete pPageView;
- m_pageMap.RemoveKey(pPDFPage);
- }
+ auto it = m_pageMap.find(pPDFPage);
+ if (it == m_pageMap.end())
+ return;
+
+ CPDFSDK_PageView* pPageView = it->second;
+ if (pPageView->IsLocked())
+ return;
+
+ delete pPageView;
+ m_pageMap.erase(it);
}
CPDF_Page * CPDFSDK_Document::GetPage(int nIndex)
@@ -465,19 +444,12 @@ CPDFSDK_InterForm* CPDFSDK_Document::GetInterForm()
void CPDFSDK_Document::UpdateAllViews(CPDFSDK_PageView* pSender, CPDFSDK_Annot* pAnnot)
{
-
- FX_POSITION pos = m_pageMap.GetStartPosition();
- CPDF_Page * pPage = NULL;
- CPDFSDK_PageView * pPageView = NULL;
- while(pos)
- {
- m_pageMap.GetNextAssoc(pos, pPage, pPageView);
-
- if(pPageView != pSender)
- {
- pPageView->UpdateView(pAnnot);
- }
- }
+ for (const auto& it : m_pageMap) {
+ CPDFSDK_PageView* pPageView = it.second;
+ if (pPageView != pSender) {
+ pPageView->UpdateView(pAnnot);
+ }
+ }
}
CPDFSDK_Annot* CPDFSDK_Document::GetFocusAnnot()
diff --git a/fpdfsdk/src/pdfwindow/PWL_Wnd.cpp b/fpdfsdk/src/pdfwindow/PWL_Wnd.cpp
index dcc6e409a4..89d4babcd7 100644
--- a/fpdfsdk/src/pdfwindow/PWL_Wnd.cpp
+++ b/fpdfsdk/src/pdfwindow/PWL_Wnd.cpp
@@ -4,6 +4,8 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+#include <map>
+
#include "../../include/pdfwindow/PDFWindow.h"
#include "../../include/pdfwindow/PWL_Wnd.h"
#include "../../include/pdfwindow/PWL_Utils.h"
@@ -11,10 +13,10 @@
/* -------------------------- CPWL_Timer -------------------------- */
-static CFX_MapPtrTemplate<int32_t, CPWL_Timer*>& GetPWLTimeMap()
+static std::map<int32_t, CPWL_Timer*>& GetPWLTimeMap()
{
// Leak the object at shutdown.
- static auto timeMap = new CFX_MapPtrTemplate<int32_t, CPWL_Timer*>;
+ static auto timeMap = new std::map<int32_t, CPWL_Timer*>;
return *timeMap;
}
@@ -34,33 +36,33 @@ CPWL_Timer::~CPWL_Timer()
int32_t CPWL_Timer::SetPWLTimer(int32_t nElapse)
{
- if (m_nTimerID != 0) KillPWLTimer();
- m_nTimerID = m_pSystemHandler->SetTimer(nElapse, TimerProc);
- GetPWLTimeMap().SetAt(m_nTimerID, this);
- return m_nTimerID;
+ if (m_nTimerID != 0)
+ KillPWLTimer();
+ m_nTimerID = m_pSystemHandler->SetTimer(nElapse, TimerProc);
+
+ GetPWLTimeMap()[m_nTimerID] = this;
+ return m_nTimerID;
}
void CPWL_Timer::KillPWLTimer()
{
- if (m_nTimerID != 0)
- {
- m_pSystemHandler->KillTimer(m_nTimerID);
- GetPWLTimeMap().RemoveKey(m_nTimerID);
- m_nTimerID = 0;
- }
+ if (m_nTimerID == 0)
+ return;
+
+ m_pSystemHandler->KillTimer(m_nTimerID);
+ GetPWLTimeMap().erase(m_nTimerID);
+ m_nTimerID = 0;
}
void CPWL_Timer::TimerProc(int32_t idEvent)
{
- CPWL_Timer* pTimer = NULL;
- if (GetPWLTimeMap().Lookup(idEvent, pTimer))
- {
- if (pTimer)
- {
- if (pTimer->m_pAttached)
- pTimer->m_pAttached->TimerProc();
- }
- }
+ auto it = GetPWLTimeMap().find(idEvent);
+ if (it == GetPWLTimeMap().end())
+ return;
+
+ CPWL_Timer* pTimer = it->second;
+ if (pTimer->m_pAttached)
+ pTimer->m_pAttached->TimerProc();
}
/* -------------------------- CPWL_TimerHandler -------------------------- */