diff options
Diffstat (limited to 'fpdfsdk/fpdfxfa')
-rw-r--r-- | fpdfsdk/fpdfxfa/cxfa_fwladaptertimermgr.cpp | 46 | ||||
-rw-r--r-- | fpdfsdk/fpdfxfa/cxfa_fwladaptertimermgr.h | 19 |
2 files changed, 38 insertions, 27 deletions
diff --git a/fpdfsdk/fpdfxfa/cxfa_fwladaptertimermgr.cpp b/fpdfsdk/fpdfxfa/cxfa_fwladaptertimermgr.cpp index 5a9ae95be7..39aa72be87 100644 --- a/fpdfsdk/fpdfxfa/cxfa_fwladaptertimermgr.cpp +++ b/fpdfsdk/fpdfxfa/cxfa_fwladaptertimermgr.cpp @@ -6,17 +6,33 @@ #include "fpdfsdk/fpdfxfa/cxfa_fwladaptertimermgr.h" +#include <utility> #include <vector> #include "fpdfsdk/cpdfsdk_formfillenvironment.h" #include "fpdfsdk/fsdk_define.h" +namespace { + +class CFWL_FWLAdapterTimerInfo : public CFWL_TimerInfo { + public: + CFWL_FWLAdapterTimerInfo(IFWL_AdapterTimerMgr* mgr, + int32_t event, + CFWL_Timer* timer) + : CFWL_TimerInfo(mgr), idEvent(event), pTimer(timer) {} + + int32_t idEvent; + CFWL_Timer* pTimer; +}; + +} // namespace + std::vector<CFWL_TimerInfo*>* CXFA_FWLAdapterTimerMgr::s_TimerArray = nullptr; -void CXFA_FWLAdapterTimerMgr::Start(IFWL_Timer* pTimer, +void CXFA_FWLAdapterTimerMgr::Start(CFWL_Timer* pTimer, uint32_t dwElapse, bool bImmediately, - IFWL_TimerInfo** pTimerInfo) { + CFWL_TimerInfo** pTimerInfo) { if (!m_pFormFillEnv) return; @@ -24,22 +40,24 @@ void CXFA_FWLAdapterTimerMgr::Start(IFWL_Timer* pTimer, if (!s_TimerArray) s_TimerArray = new std::vector<CFWL_TimerInfo*>; - s_TimerArray->push_back(new CFWL_TimerInfo(this, id_event, pTimer)); - *pTimerInfo = s_TimerArray->back(); + *pTimerInfo = new CFWL_FWLAdapterTimerInfo(this, id_event, pTimer); + s_TimerArray->push_back(*pTimerInfo); } -void CXFA_FWLAdapterTimerMgr::Stop(IFWL_TimerInfo* pTimerInfo) { +void CXFA_FWLAdapterTimerMgr::Stop(CFWL_TimerInfo* pTimerInfo) { if (!pTimerInfo || !m_pFormFillEnv) return; - CFWL_TimerInfo* pInfo = static_cast<CFWL_TimerInfo*>(pTimerInfo); + CFWL_FWLAdapterTimerInfo* pInfo = + static_cast<CFWL_FWLAdapterTimerInfo*>(pTimerInfo); m_pFormFillEnv->KillTimer(pInfo->idEvent); - if (s_TimerArray) { - auto it = std::find(s_TimerArray->begin(), s_TimerArray->end(), pInfo); - if (it != s_TimerArray->end()) { - s_TimerArray->erase(it); - delete pInfo; - } + if (!s_TimerArray) + return; + + auto it = std::find(s_TimerArray->begin(), s_TimerArray->end(), pInfo); + if (it != s_TimerArray->end()) { + s_TimerArray->erase(it); + delete pInfo; } } @@ -48,7 +66,9 @@ void CXFA_FWLAdapterTimerMgr::TimerProc(int32_t idEvent) { if (!s_TimerArray) return; - for (CFWL_TimerInfo* pInfo : *s_TimerArray) { + for (const auto info : *s_TimerArray) { + CFWL_FWLAdapterTimerInfo* pInfo = + static_cast<CFWL_FWLAdapterTimerInfo*>(info); if (pInfo->idEvent == idEvent) { pInfo->pTimer->Run(pInfo); break; diff --git a/fpdfsdk/fpdfxfa/cxfa_fwladaptertimermgr.h b/fpdfsdk/fpdfxfa/cxfa_fwladaptertimermgr.h index 9f529fcbc8..3904ba5300 100644 --- a/fpdfsdk/fpdfxfa/cxfa_fwladaptertimermgr.h +++ b/fpdfsdk/fpdfxfa/cxfa_fwladaptertimermgr.h @@ -7,24 +7,23 @@ #ifndef FPDFSDK_FPDFXFA_CXFA_FWLADAPTERTIMERMGR_H_ #define FPDFSDK_FPDFXFA_CXFA_FWLADAPTERTIMERMGR_H_ +#include <memory> #include <vector> #include "fpdfsdk/fpdfxfa/cpdfxfa_context.h" +#include "xfa/fwl/core/cfwl_timerinfo.h" #include "xfa/fwl/core/ifwl_adaptertimermgr.h" -#include "xfa/fwl/core/ifwl_timerinfo.h" - -struct CFWL_TimerInfo; class CXFA_FWLAdapterTimerMgr : public IFWL_AdapterTimerMgr { public: explicit CXFA_FWLAdapterTimerMgr(CPDFSDK_FormFillEnvironment* pFormFillEnv) : m_pFormFillEnv(pFormFillEnv) {} - void Start(IFWL_Timer* pTimer, + void Start(CFWL_Timer* pTimer, uint32_t dwElapse, bool bImmediately, - IFWL_TimerInfo** pTimerInfo) override; - void Stop(IFWL_TimerInfo* pTimerInfo) override; + CFWL_TimerInfo** pTimerInfo) override; + void Stop(CFWL_TimerInfo* pTimerInfo) override; protected: static void TimerProc(int32_t idEvent); @@ -33,12 +32,4 @@ class CXFA_FWLAdapterTimerMgr : public IFWL_AdapterTimerMgr { CPDFSDK_FormFillEnvironment* const m_pFormFillEnv; }; -struct CFWL_TimerInfo : public IFWL_TimerInfo { - CFWL_TimerInfo(IFWL_AdapterTimerMgr* mgr, int32_t event, IFWL_Timer* timer) - : IFWL_TimerInfo(mgr), idEvent(event), pTimer(timer) {} - - int32_t idEvent; - IFWL_Timer* pTimer; -}; - #endif // FPDFSDK_FPDFXFA_CXFA_FWLADAPTERTIMERMGR_H_ |