Keep the declaration of FPDF_HasXFAField consistent with other XFA APIs
[pdfium.git] / fpdfsdk / src / fpdfxfa / fpdfxfa_util.cpp
1 // Copyright 2014 PDFium Authors. All rights reserved.\r
2 // Use of this source code is governed by a BSD-style license that can be\r
3 // found in the LICENSE file.\r
4  \r
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com\r
6 \r
7 #include "../../include/fsdk_define.h"\r
8 #include "../../include/fsdk_mgr.h"\r
9 #include "../../include/fpdfxfa/fpdfxfa_util.h"\r
10 \r
11 CFX_PtrArray CXFA_FWLAdapterTimerMgr::ms_timerArray;\r
12 \r
13 FWL_ERR CXFA_FWLAdapterTimerMgr::Start(IFWL_Timer *pTimer, FX_DWORD dwElapse, FWL_HTIMER &hTimer, FX_BOOL bImmediately /* = TRUE */)\r
14 {\r
15         if (m_pEnv)\r
16         {\r
17                 FX_UINT32 uIDEvent = m_pEnv->FFI_SetTimer(dwElapse, TimerProc);\r
18                 CFWL_TimerInfo *pInfo = FX_NEW CFWL_TimerInfo;\r
19                 pInfo->uIDEvent = uIDEvent;\r
20                 pInfo->pTimer = pTimer;\r
21                 ms_timerArray.Add(pInfo);\r
22 \r
23                 hTimer = (FWL_HTIMER)pInfo;\r
24                 return FWL_ERR_Succeeded;\r
25         }\r
26         \r
27         return FWL_ERR_Indefinite;\r
28 }\r
29 \r
30 FWL_ERR CXFA_FWLAdapterTimerMgr::Stop(FWL_HTIMER hTimer)\r
31 {\r
32         if (!hTimer) return FWL_ERR_Indefinite;\r
33 \r
34         if (m_pEnv)\r
35         {\r
36                 CFWL_TimerInfo *pInfo = (CFWL_TimerInfo*)hTimer;\r
37 \r
38                 m_pEnv->FFI_KillTimer(pInfo->uIDEvent);\r
39 \r
40                 FX_INT32 index = ms_timerArray.Find(pInfo);\r
41                 if (index >= 0)\r
42                 {\r
43                         ms_timerArray.RemoveAt(index);\r
44                         delete pInfo;\r
45                 }\r
46                 return FWL_ERR_Succeeded;\r
47         }\r
48 \r
49         return FWL_ERR_Indefinite;\r
50 }\r
51 \r
52 void CXFA_FWLAdapterTimerMgr::TimerProc(FX_INT32 idEvent)\r
53 {\r
54         CFWL_TimerInfo *pInfo = NULL;\r
55         FX_INT32 iCount = CXFA_FWLAdapterTimerMgr::ms_timerArray.GetSize();\r
56         for (FX_INT32 i = 0; i < iCount; i++)\r
57         {\r
58                 CFWL_TimerInfo *pTemp = (CFWL_TimerInfo*)CXFA_FWLAdapterTimerMgr::ms_timerArray.GetAt(i);\r
59                 if (pTemp->uIDEvent == idEvent)\r
60                 {\r
61                         pInfo = pTemp; break;\r
62                 }\r
63         }\r
64         if (pInfo)\r
65         {\r
66                 pInfo->pTimer->Run((FWL_HTIMER)pInfo);\r
67         }\r
68 }\r