summaryrefslogtreecommitdiff
path: root/fpdfsdk
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk')
-rw-r--r--fpdfsdk/include/fpdfxfa/fpdfxfa_util.h11
-rw-r--r--fpdfsdk/src/fpdfxfa/fpdfxfa_util.cpp56
2 files changed, 28 insertions, 39 deletions
diff --git a/fpdfsdk/include/fpdfxfa/fpdfxfa_util.h b/fpdfsdk/include/fpdfxfa/fpdfxfa_util.h
index ca675bf27a..6cb07915ed 100644
--- a/fpdfsdk/include/fpdfxfa/fpdfxfa_util.h
+++ b/fpdfsdk/include/fpdfxfa/fpdfxfa_util.h
@@ -7,6 +7,8 @@
#ifndef FPDFSDK_INCLUDE_FPDFXFA_FPDFXFA_UTIL_H_
#define FPDFSDK_INCLUDE_FPDFXFA_FPDFXFA_UTIL_H_
+#include <vector>
+
#include "xfa/include/fwl/adapter/fwl_adaptertimermgr.h"
#define JS_STR_VIEWERTYPE_STANDARD L"Exchange"
@@ -14,6 +16,8 @@
#define JS_STR_VIEWERVARIATION L"Full"
#define JS_STR_VIEWERVERSION_XFA L"11"
+class CFWL_TimerInfo;
+
class CXFA_FWLAdapterTimerMgr : public IFWL_AdapterTimerMgr {
public:
CXFA_FWLAdapterTimerMgr(CPDFDoc_Environment* pEnv) : m_pEnv(pEnv) {}
@@ -26,13 +30,16 @@ class CXFA_FWLAdapterTimerMgr : public IFWL_AdapterTimerMgr {
protected:
static void TimerProc(int32_t idEvent);
- static CFX_PtrArray ms_timerArray;
- CPDFDoc_Environment* m_pEnv;
+ static std::vector<CFWL_TimerInfo*> s_TimerArray;
+ CPDFDoc_Environment* const m_pEnv;
};
class CFWL_TimerInfo {
public:
CFWL_TimerInfo() : pTimer(nullptr) {}
+ CFWL_TimerInfo(uint32_t event, IFWL_Timer* timer)
+ : uIDEvent(event), pTimer(timer) {}
+
uint32_t uIDEvent;
IFWL_Timer* pTimer;
};
diff --git a/fpdfsdk/src/fpdfxfa/fpdfxfa_util.cpp b/fpdfsdk/src/fpdfxfa/fpdfxfa_util.cpp
index 5f8a9f01c5..bd817a45df 100644
--- a/fpdfsdk/src/fpdfxfa/fpdfxfa_util.cpp
+++ b/fpdfsdk/src/fpdfxfa/fpdfxfa_util.cpp
@@ -8,58 +8,40 @@
#include "fpdfsdk/include/fsdk_mgr.h"
#include "fpdfsdk/include/fpdfxfa/fpdfxfa_util.h"
-CFX_PtrArray CXFA_FWLAdapterTimerMgr::ms_timerArray;
+std::vector<CFWL_TimerInfo*> CXFA_FWLAdapterTimerMgr::s_TimerArray;
FWL_ERR CXFA_FWLAdapterTimerMgr::Start(IFWL_Timer* pTimer,
FX_DWORD dwElapse,
FWL_HTIMER& hTimer,
- FX_BOOL bImmediately /* = TRUE */) {
- if (m_pEnv) {
- uint32_t uIDEvent = m_pEnv->FFI_SetTimer(dwElapse, TimerProc);
- CFWL_TimerInfo* pInfo = new CFWL_TimerInfo;
- pInfo->uIDEvent = uIDEvent;
- pInfo->pTimer = pTimer;
- ms_timerArray.Add(pInfo);
-
- hTimer = (FWL_HTIMER)pInfo;
- return FWL_ERR_Succeeded;
- }
+ FX_BOOL bImmediately) {
+ if (!m_pEnv)
+ return FWL_ERR_Indefinite;
- return FWL_ERR_Indefinite;
+ uint32_t uIDEvent = m_pEnv->FFI_SetTimer(dwElapse, TimerProc);
+ s_TimerArray.push_back(new CFWL_TimerInfo(uIDEvent, pTimer));
+ hTimer = reinterpret_cast<FWL_HTIMER>(s_TimerArray.back());
+ return FWL_ERR_Succeeded;
}
FWL_ERR CXFA_FWLAdapterTimerMgr::Stop(FWL_HTIMER hTimer) {
- if (!hTimer)
+ if (!hTimer || !m_pEnv)
return FWL_ERR_Indefinite;
- if (m_pEnv) {
- CFWL_TimerInfo* pInfo = (CFWL_TimerInfo*)hTimer;
-
- m_pEnv->FFI_KillTimer(pInfo->uIDEvent);
-
- int32_t index = ms_timerArray.Find(pInfo);
- if (index >= 0) {
- ms_timerArray.RemoveAt(index);
- delete pInfo;
- }
- return FWL_ERR_Succeeded;
+ CFWL_TimerInfo* pInfo = reinterpret_cast<CFWL_TimerInfo*>(hTimer);
+ m_pEnv->FFI_KillTimer(pInfo->uIDEvent);
+ auto it = std::find(s_TimerArray.begin(), s_TimerArray.end(), pInfo);
+ if (it != s_TimerArray.end()) {
+ s_TimerArray.erase(it);
+ delete pInfo;
}
-
- return FWL_ERR_Indefinite;
+ return FWL_ERR_Succeeded;
}
void CXFA_FWLAdapterTimerMgr::TimerProc(int32_t idEvent) {
- CFWL_TimerInfo* pInfo = NULL;
- int32_t iCount = CXFA_FWLAdapterTimerMgr::ms_timerArray.GetSize();
- for (int32_t i = 0; i < iCount; i++) {
- CFWL_TimerInfo* pTemp =
- (CFWL_TimerInfo*)CXFA_FWLAdapterTimerMgr::ms_timerArray.GetAt(i);
- if (pTemp->uIDEvent == idEvent) {
- pInfo = pTemp;
+ for (CFWL_TimerInfo* pInfo : s_TimerArray) {
+ if (pInfo->uIDEvent == idEvent) {
+ pInfo->pTimer->Run(reinterpret_cast<FWL_HTIMER>(pInfo));
break;
}
}
- if (pInfo) {
- pInfo->pTimer->Run((FWL_HTIMER)pInfo);
- }
}