OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "xfa/fxfa/fm2js/xfa_fm2jscontext.h" | 7 #include "xfa/fxfa/fm2js/xfa_fm2jscontext.h" |
8 | 8 |
9 #include <time.h> | 9 #include <time.h> |
10 | 10 |
(...skipping 4270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4281 return TRUE; | 4281 return TRUE; |
4282 } else if (iCode < htmlreservecode.m_uCode) { | 4282 } else if (iCode < htmlreservecode.m_uCode) { |
4283 iEnd = iMid - 1; | 4283 iEnd = iMid - 1; |
4284 } else { | 4284 } else { |
4285 iStart = iMid + 1; | 4285 iStart = iMid + 1; |
4286 } | 4286 } |
4287 } while (iStart <= iEnd); | 4287 } while (iStart <= iEnd); |
4288 return FALSE; | 4288 return FALSE; |
4289 } | 4289 } |
4290 static FX_BOOL XFA_PATTERN_STRING_Type(const CFX_ByteStringC& szPattern, | 4290 static FX_BOOL XFA_PATTERN_STRING_Type(const CFX_ByteStringC& szPattern, |
4291 FX_DWORD& patternType) { | 4291 uint32_t& patternType) { |
4292 CFX_WideString wsPattern = | 4292 CFX_WideString wsPattern = |
4293 CFX_WideString::FromUTF8(szPattern.GetCStr(), szPattern.GetLength()); | 4293 CFX_WideString::FromUTF8(szPattern.GetCStr(), szPattern.GetLength()); |
4294 if (FX_WSTRC(L"datetime") == wsPattern.Left(8)) { | 4294 if (FX_WSTRC(L"datetime") == wsPattern.Left(8)) { |
4295 patternType = XFA_VT_DATETIME; | 4295 patternType = XFA_VT_DATETIME; |
4296 return TRUE; | 4296 return TRUE; |
4297 } else if (FX_WSTRC(L"date") == wsPattern.Left(4)) { | 4297 } else if (FX_WSTRC(L"date") == wsPattern.Left(4)) { |
4298 patternType = wsPattern.Find(L"time") > 0 ? XFA_VT_DATETIME : XFA_VT_DATE; | 4298 patternType = wsPattern.Find(L"time") > 0 ? XFA_VT_DATETIME : XFA_VT_DATE; |
4299 return TRUE; | 4299 return TRUE; |
4300 } else if (FX_WSTRC(L"time") == wsPattern.Left(4)) { | 4300 } else if (FX_WSTRC(L"time") == wsPattern.Left(4)) { |
4301 patternType = XFA_VT_TIME; | 4301 patternType = XFA_VT_TIME; |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4384 CFX_ByteString szPattern; | 4384 CFX_ByteString szPattern; |
4385 HValueToUTF8String(argOne, szPattern); | 4385 HValueToUTF8String(argOne, szPattern); |
4386 CFX_ByteString szValue; | 4386 CFX_ByteString szValue; |
4387 HValueToUTF8String(argTwo, szValue); | 4387 HValueToUTF8String(argTwo, szValue); |
4388 CXFA_Document* pDoc = pContext->GetDocument(); | 4388 CXFA_Document* pDoc = pContext->GetDocument(); |
4389 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); | 4389 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); |
4390 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); | 4390 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); |
4391 FXSYS_assert(pThisNode); | 4391 FXSYS_assert(pThisNode); |
4392 CXFA_WidgetData widgetData(pThisNode); | 4392 CXFA_WidgetData widgetData(pThisNode); |
4393 IFX_Locale* pLocale = widgetData.GetLocal(); | 4393 IFX_Locale* pLocale = widgetData.GetLocal(); |
4394 FX_DWORD patternType; | 4394 uint32_t patternType; |
4395 FX_BOOL bCompelte = XFA_PATTERN_STRING_Type(szPattern, patternType); | 4395 FX_BOOL bCompelte = XFA_PATTERN_STRING_Type(szPattern, patternType); |
4396 CFX_WideString wsPattern = | 4396 CFX_WideString wsPattern = |
4397 CFX_WideString::FromUTF8(szPattern, szPattern.GetLength()); | 4397 CFX_WideString::FromUTF8(szPattern, szPattern.GetLength()); |
4398 CFX_WideString wsValue = | 4398 CFX_WideString wsValue = |
4399 CFX_WideString::FromUTF8(szValue, szValue.GetLength()); | 4399 CFX_WideString::FromUTF8(szValue, szValue.GetLength()); |
4400 if (!bCompelte) { | 4400 if (!bCompelte) { |
4401 switch (patternType) { | 4401 switch (patternType) { |
4402 case XFA_VT_DATETIME: { | 4402 case XFA_VT_DATETIME: { |
4403 FX_STRSIZE iTChar = wsPattern.Find(L'T'); | 4403 FX_STRSIZE iTChar = wsPattern.Find(L'T'); |
4404 CFX_WideString wsDatePattern = FX_WSTRC(L"date{"); | 4404 CFX_WideString wsDatePattern = FX_WSTRC(L"date{"); |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4596 CFX_ByteString szPattern; | 4596 CFX_ByteString szPattern; |
4597 HValueToUTF8String(argOne, szPattern); | 4597 HValueToUTF8String(argOne, szPattern); |
4598 CFX_ByteString szValue; | 4598 CFX_ByteString szValue; |
4599 HValueToUTF8String(argTwo, szValue); | 4599 HValueToUTF8String(argTwo, szValue); |
4600 CXFA_Document* pDoc = pContext->GetDocument(); | 4600 CXFA_Document* pDoc = pContext->GetDocument(); |
4601 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); | 4601 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); |
4602 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); | 4602 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); |
4603 FXSYS_assert(pThisNode); | 4603 FXSYS_assert(pThisNode); |
4604 CXFA_WidgetData widgetData(pThisNode); | 4604 CXFA_WidgetData widgetData(pThisNode); |
4605 IFX_Locale* pLocale = widgetData.GetLocal(); | 4605 IFX_Locale* pLocale = widgetData.GetLocal(); |
4606 FX_DWORD patternType; | 4606 uint32_t patternType; |
4607 FX_BOOL bCompletePattern = | 4607 FX_BOOL bCompletePattern = |
4608 XFA_PATTERN_STRING_Type(szPattern, patternType); | 4608 XFA_PATTERN_STRING_Type(szPattern, patternType); |
4609 CFX_WideString wsPattern = | 4609 CFX_WideString wsPattern = |
4610 CFX_WideString::FromUTF8(szPattern, szPattern.GetLength()); | 4610 CFX_WideString::FromUTF8(szPattern, szPattern.GetLength()); |
4611 CFX_WideString wsValue = | 4611 CFX_WideString wsValue = |
4612 CFX_WideString::FromUTF8(szValue, szValue.GetLength()); | 4612 CFX_WideString::FromUTF8(szValue, szValue.GetLength()); |
4613 CFX_ByteString szParsedValue; | 4613 CFX_ByteString szParsedValue; |
4614 if (bCompletePattern) { | 4614 if (bCompletePattern) { |
4615 CXFA_LocaleValue localeValue(patternType, wsValue, wsPattern, pLocale, | 4615 CXFA_LocaleValue localeValue(patternType, wsValue, wsPattern, pLocale, |
4616 (CXFA_LocaleMgr*)pMgr); | 4616 (CXFA_LocaleMgr*)pMgr); |
(...skipping 2213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6830 const CFX_ByteStringC& szAccessorName) { | 6830 const CFX_ByteStringC& szAccessorName) { |
6831 FX_BOOL bFlags = FALSE; | 6831 FX_BOOL bFlags = FALSE; |
6832 CXFA_FM2JSContext* pContext = | 6832 CXFA_FM2JSContext* pContext = |
6833 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 6833 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); |
6834 CXFA_Document* pDoc = pContext->GetDocument(); | 6834 CXFA_Document* pDoc = pContext->GetDocument(); |
6835 if (!pDoc) { | 6835 if (!pDoc) { |
6836 return bFlags; | 6836 return bFlags; |
6837 } | 6837 } |
6838 IXFA_ScriptContext* pScriptContext = pDoc->GetScriptContext(); | 6838 IXFA_ScriptContext* pScriptContext = pDoc->GetScriptContext(); |
6839 XFA_RESOLVENODE_RS resoveNodeRS; | 6839 XFA_RESOLVENODE_RS resoveNodeRS; |
6840 FX_DWORD dwFlags = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties | | 6840 uint32_t dwFlags = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties | |
6841 XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent; | 6841 XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent; |
6842 int32_t iRet = pScriptContext->ResolveObjects( | 6842 int32_t iRet = pScriptContext->ResolveObjects( |
6843 pScriptContext->GetThisObject(), | 6843 pScriptContext->GetThisObject(), |
6844 CFX_WideString::FromUTF8(szAccessorName.GetCStr(), | 6844 CFX_WideString::FromUTF8(szAccessorName.GetCStr(), |
6845 szAccessorName.GetLength()), | 6845 szAccessorName.GetLength()), |
6846 resoveNodeRS, dwFlags); | 6846 resoveNodeRS, dwFlags); |
6847 if (iRet >= 1 && resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) { | 6847 if (iRet >= 1 && resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) { |
6848 FXJSE_Value_Set(accessorValue, pScriptContext->GetJSValueFromMap( | 6848 FXJSE_Value_Set(accessorValue, pScriptContext->GetJSValueFromMap( |
6849 resoveNodeRS.nodes.GetAt(0))); | 6849 resoveNodeRS.nodes.GetAt(0))); |
6850 bFlags = TRUE; | 6850 bFlags = TRUE; |
(...skipping 10 matching lines...) Expand all Loading... |
6861 CFX_WideString::FromUTF8(bsSomExp.GetCStr(), bsSomExp.GetLength()); | 6861 CFX_WideString::FromUTF8(bsSomExp.GetCStr(), bsSomExp.GetLength()); |
6862 int32_t iRet = -1; | 6862 int32_t iRet = -1; |
6863 CXFA_FM2JSContext* pContext = | 6863 CXFA_FM2JSContext* pContext = |
6864 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); | 6864 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL); |
6865 CXFA_Document* pDoc = pContext->GetDocument(); | 6865 CXFA_Document* pDoc = pContext->GetDocument(); |
6866 if (!pDoc) { | 6866 if (!pDoc) { |
6867 return iRet; | 6867 return iRet; |
6868 } | 6868 } |
6869 IXFA_ScriptContext* pScriptContext = pDoc->GetScriptContext(); | 6869 IXFA_ScriptContext* pScriptContext = pDoc->GetScriptContext(); |
6870 CXFA_Object* pNode = NULL; | 6870 CXFA_Object* pNode = NULL; |
6871 FX_DWORD dFlags = 0UL; | 6871 uint32_t dFlags = 0UL; |
6872 if (bdotAccessor) { | 6872 if (bdotAccessor) { |
6873 if (FXJSE_Value_IsNull(hRefValue)) { | 6873 if (FXJSE_Value_IsNull(hRefValue)) { |
6874 pNode = pScriptContext->GetThisObject(); | 6874 pNode = pScriptContext->GetThisObject(); |
6875 dFlags = XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent; | 6875 dFlags = XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent; |
6876 } else { | 6876 } else { |
6877 pNode = (CXFA_Object*)FXJSE_Value_ToObject(hRefValue, NULL); | 6877 pNode = (CXFA_Object*)FXJSE_Value_ToObject(hRefValue, NULL); |
6878 FXSYS_assert(pNode); | 6878 FXSYS_assert(pNode); |
6879 if (bHasNoResolveName) { | 6879 if (bHasNoResolveName) { |
6880 CFX_WideString wsName; | 6880 CFX_WideString wsName; |
6881 if (CXFA_Node* pXFANode = pNode->AsNode()) { | 6881 if (CXFA_Node* pXFANode = pNode->AsNode()) { |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7215 FXSYS_assert(pAppProvider); | 7215 FXSYS_assert(pAppProvider); |
7216 CFX_WideString wsFormat; | 7216 CFX_WideString wsFormat; |
7217 pAppProvider->LoadString(iStringID, wsFormat); | 7217 pAppProvider->LoadString(iStringID, wsFormat); |
7218 CFX_WideString wsMessage; | 7218 CFX_WideString wsMessage; |
7219 va_list arg_ptr; | 7219 va_list arg_ptr; |
7220 va_start(arg_ptr, iStringID); | 7220 va_start(arg_ptr, iStringID); |
7221 wsMessage.FormatV((const FX_WCHAR*)wsFormat, arg_ptr); | 7221 wsMessage.FormatV((const FX_WCHAR*)wsFormat, arg_ptr); |
7222 va_end(arg_ptr); | 7222 va_end(arg_ptr); |
7223 FXJSE_ThrowMessage("", FX_UTF8Encode(wsMessage, wsMessage.GetLength())); | 7223 FXJSE_ThrowMessage("", FX_UTF8Encode(wsMessage, wsMessage.GetLength())); |
7224 } | 7224 } |
OLD | NEW |