summaryrefslogtreecommitdiff
path: root/fpdfsdk/src/fpdfxfa/fpdfxfa_util.cpp
diff options
context:
space:
mode:
authorBo Xu <bo_xu@foxitsoftware.com>2014-10-28 23:03:33 -0700
committerBo Xu <bo_xu@foxitsoftware.com>2014-11-03 11:10:11 -0800
commitfdc00a7042d912aafaabddae4d9c84199921ef23 (patch)
tree32ab8ac91cc68d2cd15b9168782a71b3f3f5e7b9 /fpdfsdk/src/fpdfxfa/fpdfxfa_util.cpp
parente9b38fa38de2c95d8260be31c57d9272c4d127ed (diff)
downloadpdfium-fdc00a7042d912aafaabddae4d9c84199921ef23.tar.xz
Merge XFA to PDFium master at 4dc95e7 on 10/28/2014
Diffstat (limited to 'fpdfsdk/src/fpdfxfa/fpdfxfa_util.cpp')
-rw-r--r--fpdfsdk/src/fpdfxfa/fpdfxfa_util.cpp96
1 files changed, 96 insertions, 0 deletions
diff --git a/fpdfsdk/src/fpdfxfa/fpdfxfa_util.cpp b/fpdfsdk/src/fpdfxfa/fpdfxfa_util.cpp
new file mode 100644
index 0000000000..9bf1b63c8f
--- /dev/null
+++ b/fpdfsdk/src/fpdfxfa/fpdfxfa_util.cpp
@@ -0,0 +1,96 @@
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "../../include/fsdk_define.h"
+#include "../../include/fsdk_mgr.h"
+#include "../../include/fpdfxfa/fpdfxfa_util.h"
+
+FX_BOOL FPDF_HasXFAField(CPDF_Document* pPDFDoc, int& docType)
+{
+ if (!pPDFDoc)
+ return FALSE;
+
+ CPDF_Dictionary* pRoot = pPDFDoc->GetRoot();
+ if (!pRoot)
+ return FALSE;
+
+ CPDF_Dictionary* pAcroForm = pRoot->GetDict("AcroForm");
+ if (!pAcroForm)
+ return FALSE;
+
+ CPDF_Object* pXFA = pAcroForm->GetElement("XFA");
+ if (!pXFA)
+ return FALSE;
+
+ FX_BOOL bDymasticXFA = FALSE;
+ bDymasticXFA = pRoot->GetBoolean("NeedsRendering", FALSE);
+
+ if(bDymasticXFA)
+ docType = DOCTYPE_DYNIMIC_XFA;
+ else
+ docType = DOCTYPE_STATIC_XFA;
+
+ return TRUE;
+}
+
+CFX_PtrArray CXFA_FWLAdapterTimerMgr::ms_timerArray;
+
+FWL_ERR CXFA_FWLAdapterTimerMgr::Start(IFWL_Timer *pTimer, FX_DWORD dwElapse, FWL_HTIMER &hTimer, FX_BOOL bImmediately /* = TRUE */)
+{
+ if (m_pEnv)
+ {
+ FX_UINT32 uIDEvent = m_pEnv->FFI_SetTimer(dwElapse, TimerProc);
+ CFWL_TimerInfo *pInfo = FX_NEW CFWL_TimerInfo;
+ pInfo->uIDEvent = uIDEvent;
+ pInfo->pTimer = pTimer;
+ ms_timerArray.Add(pInfo);
+
+ hTimer = (FWL_HTIMER)pInfo;
+ return FWL_ERR_Succeeded;
+ }
+
+ return FWL_ERR_Indefinite;
+}
+
+FWL_ERR CXFA_FWLAdapterTimerMgr::Stop(FWL_HTIMER hTimer)
+{
+ if (!hTimer) return FWL_ERR_Indefinite;
+
+ if (m_pEnv)
+ {
+ CFWL_TimerInfo *pInfo = (CFWL_TimerInfo*)hTimer;
+
+ m_pEnv->FFI_KillTimer(pInfo->uIDEvent);
+
+ FX_INT32 index = ms_timerArray.Find(pInfo);
+ if (index >= 0)
+ {
+ ms_timerArray.RemoveAt(index);
+ delete pInfo;
+ }
+ return FWL_ERR_Succeeded;
+ }
+
+ return FWL_ERR_Indefinite;
+}
+
+void CXFA_FWLAdapterTimerMgr::TimerProc(FX_INT32 idEvent)
+{
+ CFWL_TimerInfo *pInfo = NULL;
+ FX_INT32 iCount = CXFA_FWLAdapterTimerMgr::ms_timerArray.GetSize();
+ for (FX_INT32 i = 0; i < iCount; i++)
+ {
+ CFWL_TimerInfo *pTemp = (CFWL_TimerInfo*)CXFA_FWLAdapterTimerMgr::ms_timerArray.GetAt(i);
+ if (pTemp->uIDEvent == idEvent)
+ {
+ pInfo = pTemp; break;
+ }
+ }
+ if (pInfo)
+ {
+ pInfo->pTimer->Run((FWL_HTIMER)pInfo);
+ }
+}