int32_t CXFA_FFDocView::ProcessWidgetEvent(CXFA_EventParam* pParam, CXFA_WidgetAcc* pWidgetAcc) { if (pParam == NULL) { return XFA_EVENTERROR_Error; } if (pParam->m_eType == XFA_EVENT_Validate) { CFX_WideString wsValidateStr = FX_WSTRC(L"preSubmit"); CXFA_Node* pConfigItem = ToNode(m_pDoc->GetXFADoc()->GetXFAObject(XFA_HASHCODE_Config)); if (pConfigItem) { CXFA_Node* pValidateNode = NULL; CXFA_Node* pAcrobatNode = pConfigItem->GetChild(0, XFA_ELEMENT_Acrobat); pValidateNode = pAcrobatNode ? pAcrobatNode->GetChild(0, XFA_ELEMENT_Validate) : NULL; if (!pValidateNode) { CXFA_Node* pPresentNode = pConfigItem->GetChild(0, XFA_ELEMENT_Present); pValidateNode = pPresentNode ? pPresentNode->GetChild(0, XFA_ELEMENT_Validate) : NULL; } if (pValidateNode) { wsValidateStr = pValidateNode->GetContent(); } } FX_BOOL bValidate = FALSE; switch (pParam->m_iValidateActivities) { case XFA_VALIDATE_preSubmit: bValidate = wsValidateStr.Find(L"preSubmit") != -1; break; case XFA_VALIDATE_prePrint: bValidate = wsValidateStr.Find(L"prePrint") != -1; break; case XFA_VALIDATE_preExecute: bValidate = wsValidateStr.Find(L"preExecute") != -1; break; case XFA_VALIDATE_preSave: bValidate = wsValidateStr.Find(L"preSave") != -1; break; } if (!bValidate) { return XFA_EVENTERROR_Sucess; } } CXFA_Node* pNode = pWidgetAcc ? pWidgetAcc->GetNode() : NULL; if (!pNode) { CXFA_Node* pRootItem = ToNode(m_pDoc->GetXFADoc()->GetXFAObject(XFA_HASHCODE_Form)); if (!pRootItem) { return XFA_EVENTERROR_Error; } pNode = pRootItem->GetChild(0, XFA_ELEMENT_Subform); } ExecEventActivityByDeepFirst(pNode, pParam->m_eType, pParam->m_bIsFormReady); return XFA_EVENTERROR_Sucess; }
FX_BOOL CXFA_LocaleValue::ValidateCanonicalDateTime( const CFX_WideString& wsDateTime) { CFX_WideString wsDate, wsTime; if (wsDateTime.IsEmpty()) { return FALSE; } int nSplitIndex = -1; nSplitIndex = wsDateTime.Find('T'); if (nSplitIndex < 0) { nSplitIndex = wsDateTime.Find(' '); } if (nSplitIndex < 0) { return FALSE; } wsDate = wsDateTime.Left(nSplitIndex); wsTime = wsDateTime.Right(wsDateTime.GetLength() - nSplitIndex - 1); CFX_Unitime dt; return ValidateCanonicalDate(wsDate, dt) && ValidateCanonicalTime(wsTime); }
static FX_BOOL XFA_ValueSplitDateTime(const CFX_WideString& wsDateTime, CFX_WideString& wsDate, CFX_WideString& wsTime) { wsDate = L""; wsTime = L""; if (wsDateTime.IsEmpty()) { return FALSE; } int nSplitIndex = -1; nSplitIndex = wsDateTime.Find('T'); if (nSplitIndex < 0) { nSplitIndex = wsDateTime.Find(' '); } if (nSplitIndex < 0) { return FALSE; } wsDate = wsDateTime.Left(nSplitIndex); wsTime = wsDateTime.Right(wsDateTime.GetLength() - nSplitIndex - 1); return TRUE; }
int32_t CFWL_ComboList::MatchItem(const CFX_WideString& wsMatch) { if (wsMatch.IsEmpty()) return -1; int32_t iCount = CountItems(this); for (int32_t i = 0; i < iCount; i++) { CFWL_ListItem* hItem = GetItem(this, i); CFX_WideString wsText = hItem ? hItem->GetText() : L""; FX_STRSIZE pos = wsText.Find(wsMatch.c_str()); if (!pos) return i; } return -1; }
int32_t IFWL_ComboList::MatchItem(const CFX_WideString& wsMatch) { if (wsMatch.IsEmpty()) return -1; if (!m_pProperties->m_pDataProvider) return -1; IFWL_ListBoxDP* pData = static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); int32_t iCount = pData->CountItems(this); for (int32_t i = 0; i < iCount; i++) { CFWL_ListItem* hItem = pData->GetItem(this, i); CFX_WideString wsText; pData->GetItemText(this, hItem, wsText); FX_STRSIZE pos = wsText.Find(wsMatch.c_str()); if (!pos) return i; } return -1; }
void CPDFXFA_DocEnvironment::ToXFAContentFlags(CFX_WideString csSrcContent, FPDF_DWORD& flag) { if (csSrcContent.Find(L" config ", 0) != -1) flag |= FXFA_CONFIG; if (csSrcContent.Find(L" template ", 0) != -1) flag |= FXFA_TEMPLATE; if (csSrcContent.Find(L" localeSet ", 0) != -1) flag |= FXFA_LOCALESET; if (csSrcContent.Find(L" datasets ", 0) != -1) flag |= FXFA_DATASETS; if (csSrcContent.Find(L" xmpmeta ", 0) != -1) flag |= FXFA_XMPMETA; if (csSrcContent.Find(L" xfdf ", 0) != -1) flag |= FXFA_XFDF; if (csSrcContent.Find(L" form ", 0) != -1) flag |= FXFA_FORM; if (flag == 0) { flag = FXFA_CONFIG | FXFA_TEMPLATE | FXFA_LOCALESET | FXFA_DATASETS | FXFA_XMPMETA | FXFA_XFDF | FXFA_FORM; } }
int32_t CFGAS_FontMgr::IsPartName(const CFX_WideString& Name1, const CFX_WideString& Name2) { if (Name1.Find(Name2.c_str()) != -1) return 1; return 0; }
bool CPDFXFA_DocEnvironment::MailToInfo(CFX_WideString& csURL, CFX_WideString& csToAddress, CFX_WideString& csCCAddress, CFX_WideString& csBCCAddress, CFX_WideString& csSubject, CFX_WideString& csMsg) { CFX_WideString srcURL = csURL; srcURL.TrimLeft(); if (srcURL.Left(7).CompareNoCase(L"mailto:") != 0) return false; int pos = srcURL.Find(L'?', 0); CFX_WideString tmp; if (pos == -1) { pos = srcURL.Find(L'@', 0); if (pos == -1) return false; tmp = srcURL.Right(csURL.GetLength() - 7); } else { tmp = srcURL.Left(pos); tmp = tmp.Right(tmp.GetLength() - 7); } tmp.TrimLeft(); tmp.TrimRight(); csToAddress = tmp; srcURL = srcURL.Right(srcURL.GetLength() - (pos + 1)); while (!srcURL.IsEmpty()) { srcURL.TrimLeft(); srcURL.TrimRight(); pos = srcURL.Find(L'&', 0); tmp = (pos == -1) ? srcURL : srcURL.Left(pos); tmp.TrimLeft(); tmp.TrimRight(); if (tmp.GetLength() >= 3 && tmp.Left(3).CompareNoCase(L"cc=") == 0) { tmp = tmp.Right(tmp.GetLength() - 3); if (!csCCAddress.IsEmpty()) csCCAddress += L';'; csCCAddress += tmp; } else if (tmp.GetLength() >= 4 && tmp.Left(4).CompareNoCase(L"bcc=") == 0) { tmp = tmp.Right(tmp.GetLength() - 4); if (!csBCCAddress.IsEmpty()) csBCCAddress += L';'; csBCCAddress += tmp; } else if (tmp.GetLength() >= 8 && tmp.Left(8).CompareNoCase(L"subject=") == 0) { tmp = tmp.Right(tmp.GetLength() - 8); csSubject += tmp; } else if (tmp.GetLength() >= 5 && tmp.Left(5).CompareNoCase(L"body=") == 0) { tmp = tmp.Right(tmp.GetLength() - 5); csMsg += tmp; } srcURL = (pos == -1) ? L"" : srcURL.Right(csURL.GetLength() - (pos + 1)); } csToAddress.Replace(L",", L";"); csCCAddress.Replace(L",", L";"); csBCCAddress.Replace(L",", L";"); return true; }
FX_BOOL CXFA_LocaleValue::ValidateCanonicalTime(const CFX_WideString& wsTime) { int nLen = wsTime.GetLength(); if (nLen < 2) return FALSE; const uint16_t wCountH = 2; const uint16_t wCountM = 2; const uint16_t wCountS = 2; const uint16_t wCountF = 3; const bool bSymbol = wsTime.Find(':') != -1; uint16_t wHour = 0; uint16_t wMinute = 0; uint16_t wSecond = 0; uint16_t wFraction = 0; const FX_WCHAR* pTime = wsTime.c_str(); int nIndex = 0; int nStart = 0; while (nIndex - nStart < wCountH && pTime[nIndex]) { if (!FXSYS_isDecimalDigit(pTime[nIndex])) return FALSE; wHour = pTime[nIndex] - '0' + wHour * 10; nIndex++; } if (bSymbol) { if (nIndex < nLen && pTime[nIndex] != ':') return FALSE; nIndex++; } nStart = nIndex; while (nIndex - nStart < wCountM && nIndex < nLen && pTime[nIndex]) { if (!FXSYS_isDecimalDigit(pTime[nIndex])) return FALSE; wMinute = pTime[nIndex] - '0' + wMinute * 10; nIndex++; } if (bSymbol) { if (nIndex < nLen && pTime[nIndex] != ':') return FALSE; nIndex++; } nStart = nIndex; while (nIndex - nStart < wCountS && nIndex < nLen && pTime[nIndex]) { if (!FXSYS_isDecimalDigit(pTime[nIndex])) return FALSE; wSecond = pTime[nIndex] - '0' + wSecond * 10; nIndex++; } if (wsTime.Find('.') > 0) { if (pTime[nIndex] != '.') return FALSE; nIndex++; nStart = nIndex; while (nIndex - nStart < wCountF && nIndex < nLen && pTime[nIndex]) { if (!FXSYS_isDecimalDigit(pTime[nIndex])) return FALSE; wFraction = pTime[nIndex] - '0' + wFraction * 10; nIndex++; } } if (nIndex < nLen) { if (pTime[nIndex] == 'Z') { nIndex++; } else if (pTime[nIndex] == '-' || pTime[nIndex] == '+') { int16_t nOffsetH = 0; int16_t nOffsetM = 0; nIndex++; nStart = nIndex; while (nIndex - nStart < wCountH && nIndex < nLen && pTime[nIndex]) { if (!FXSYS_isDecimalDigit(pTime[nIndex])) return FALSE; nOffsetH = pTime[nIndex] - '0' + nOffsetH * 10; nIndex++; } if (bSymbol) { if (nIndex < nLen && pTime[nIndex] != ':') return FALSE; nIndex++; } nStart = nIndex; while (nIndex - nStart < wCountM && nIndex < nLen && pTime[nIndex]) { if (!FXSYS_isDecimalDigit(pTime[nIndex])) return FALSE; nOffsetM = pTime[nIndex] - '0' + nOffsetM * 10; nIndex++; } if (nOffsetH > 12 || nOffsetM >= 60) return FALSE; } } return nIndex == nLen && wHour < 24 && wMinute < 60 && wSecond < 60 && wFraction <= 999; }
FX_BOOL CXFA_LocaleValue::ValidateCanonicalDate(const CFX_WideString& wsDate, CFX_Unitime& unDate) { const uint16_t LastDay[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; const uint16_t wCountY = 4, wCountM = 2, wCountD = 2; int nLen = wsDate.GetLength(); if (nLen < wCountY || nLen > wCountY + wCountM + wCountD + 2) { return FALSE; } const bool bSymbol = wsDate.Find(0x2D) != -1; uint16_t wYear = 0; uint16_t wMonth = 0; uint16_t wDay = 0; const FX_WCHAR* pDate = wsDate.c_str(); int nIndex = 0, nStart = 0; while (pDate[nIndex] != '\0' && nIndex < wCountY) { if (!FXSYS_isDecimalDigit(pDate[nIndex])) { return FALSE; } wYear = (pDate[nIndex] - '0') + wYear * 10; nIndex++; } if (bSymbol) { if (pDate[nIndex] != 0x2D) { return FALSE; } nIndex++; } nStart = nIndex; while (pDate[nIndex] != '\0' && nIndex - nStart < wCountM && nIndex < nLen) { if (!FXSYS_isDecimalDigit(pDate[nIndex])) { return FALSE; } wMonth = (pDate[nIndex] - '0') + wMonth * 10; nIndex++; } if (bSymbol) { if (pDate[nIndex] != 0x2D) { return FALSE; } nIndex++; } nStart = nIndex; while (pDate[nIndex] != '\0' && nIndex - nStart < wCountD && nIndex < nLen) { if (!FXSYS_isDecimalDigit(pDate[nIndex])) { return FALSE; } wDay = (pDate[nIndex] - '0') + wDay * 10; nIndex++; } if (nIndex != nLen) { return FALSE; } if (wYear < 1900 || wYear > 2029) { return FALSE; } if (wMonth < 1 || wMonth > 12) { if (wMonth == 0 && nLen == wCountY) { return TRUE; } return FALSE; } if (wDay < 1) { if (wDay == 0 && (nLen == wCountY + wCountM)) { return TRUE; } return FALSE; } if (wMonth == 2) { if (wYear % 400 == 0 || (wYear % 100 != 0 && wYear % 4 == 0)) { if (wDay > 29) { return FALSE; } } else { if (wDay > 28) { return FALSE; } } } else if (wDay > LastDay[wMonth - 1]) { return FALSE; } CFX_Unitime ut; ut.Set(wYear, static_cast<uint8_t>(wMonth), static_cast<uint8_t>(wDay)); unDate = unDate + ut; return TRUE; }