void CXFA_ResolveProcessor::XFA_ResolveNode_DoPredicateFilter( int32_t iCurIndex, CFX_WideString wsCondition, int32_t iFoundCount, CXFA_ResolveNodesData& rnd) { CXFA_NodeArray& findNodes = (CXFA_NodeArray&)rnd.m_Nodes; FXSYS_assert(iFoundCount == findNodes.GetSize()); CFX_WideString wsExpression; IXFA_ScriptContext* pContext = NULL; XFA_SCRIPTLANGTYPE eLangType = XFA_SCRIPTLANGTYPE_Unkown; if (wsCondition.Left(2) == FX_WSTRC(L".[") && wsCondition.Right(1) == FX_WSTRC(L"]")) { eLangType = XFA_SCRIPTLANGTYPE_Formcalc; } else if (wsCondition.Left(2) == FX_WSTRC(L".(") && wsCondition.Right(1) == FX_WSTRC(L")")) { eLangType = XFA_SCRIPTLANGTYPE_Javascript; } else { return; } pContext = rnd.m_pSC; wsExpression = wsCondition.Mid(2, wsCondition.GetLength() - 3); for (int32_t i = iFoundCount - 1; i >= 0; i--) { CXFA_Object* node = findNodes[i]; FX_BOOL bRet = FALSE; FXJSE_HVALUE pRetValue = FXJSE_Value_Create(rnd.m_pSC->GetRuntime()); bRet = pContext->RunScript(eLangType, wsExpression, pRetValue, node); if (!bRet || !FXJSE_Value_ToBoolean(pRetValue)) { findNodes.RemoveAt(i); } FXJSE_Value_Release(pRetValue); } }
void CPDF_TextPageFind::ExtractFindWhat(const CFX_WideString& findwhat) { if (findwhat.IsEmpty()) return; int index = 0; while (1) { CFX_WideString csWord = TEXT_EMPTY; int ret = ExtractSubString(csWord, findwhat.c_str(), index, TEXT_SPACE_CHAR); if (csWord.IsEmpty()) { if (ret) { m_csFindWhatArray.push_back(L""); index++; continue; } else { break; } } int pos = 0; while (pos < csWord.GetLength()) { CFX_WideString curStr = csWord.Mid(pos, 1); FX_WCHAR curChar = csWord.GetAt(pos); if (IsIgnoreSpaceCharacter(curChar)) { if (pos > 0 && curChar == 0x2019) { pos++; continue; } if (pos > 0) m_csFindWhatArray.push_back(csWord.Mid(0, pos)); m_csFindWhatArray.push_back(curStr); if (pos == csWord.GetLength() - 1) { csWord.clear(); break; } csWord = csWord.Right(csWord.GetLength() - pos - 1); pos = 0; continue; } pos++; } if (!csWord.IsEmpty()) m_csFindWhatArray.push_back(csWord); index++; } }
CFX_WideString CBC_EAN8::Preprocess(const CFX_WideStringC& contents) { CFX_WideString encodeContents = static_cast<CBC_OnedEAN8Writer*>(m_pBCWriter.get()) ->FilterContents(contents); int32_t length = encodeContents.GetLength(); if (length <= 7) { for (int32_t i = 0; i < 7 - length; i++) encodeContents = FX_WCHAR('0') + encodeContents; CFX_ByteString byteString = encodeContents.UTF8Encode(); int32_t checksum = static_cast<CBC_OnedEAN8Writer*>(m_pBCWriter.get()) ->CalcChecksum(byteString); encodeContents += FX_WCHAR(checksum - 0 + '0'); } if (length > 8) encodeContents = encodeContents.Mid(0, 8); return encodeContents; }
FX_BOOL CXFA_NodeHelper::XFA_CreateNode_ForCondition( CFX_WideString& wsCondition) { int32_t iLen = wsCondition.GetLength(); CFX_WideString wsIndex = FX_WSTRC(L"0"); ; FX_BOOL bAll = FALSE; if (iLen == 0) { m_iCreateFlag = XFA_RESOLVENODE_RSTYPE_CreateNodeOne; return FALSE; } if (wsCondition.GetAt(0) == '[') { int32_t i = 1; for (; i < iLen; ++i) { FX_WCHAR ch = wsCondition[i]; if (ch == ' ') { continue; } if (ch == '+' || ch == '-') { break; } else if (ch == '*') { bAll = TRUE; break; } else { break; } } if (bAll) { wsIndex = FX_WSTRC(L"1"); m_iCreateFlag = XFA_RESOLVENODE_RSTYPE_CreateNodeAll; } else { m_iCreateFlag = XFA_RESOLVENODE_RSTYPE_CreateNodeOne; wsIndex = wsCondition.Mid(i, iLen - 1 - i); } int32_t iIndex = wsIndex.GetInteger(); m_iCreateCount = iIndex; return TRUE; } return FALSE; }
void CBC_PDF417HighLevelEncoder::encodeNumeric(CFX_WideString msg, int32_t startpos, int32_t count, CFX_WideString& sb) { int32_t idx = 0; BigInteger num900 = 900; while (idx < count) { CFX_WideString tmp; int32_t len = 44 < count - idx ? 44 : count - idx; CFX_ByteString part = ((FX_WCHAR)'1' + msg.Mid(startpos + idx, len)).UTF8Encode(); BigInteger bigint = stringToBigInteger(part.c_str()); do { int32_t c = (bigint % num900).toInt(); tmp += (FX_WCHAR)(c); bigint = bigint / num900; } while (!bigint.isZero()); for (int32_t i = tmp.GetLength() - 1; i >= 0; i--) { sb += tmp.GetAt(i); } idx += len; } }
void CXFA_ResolveProcessor::XFA_ResolveNode_ConditionArray( int32_t iCurIndex, CFX_WideString wsCondition, int32_t iFoundCount, CXFA_ResolveNodesData& rnd) { CXFA_NodeArray& findNodes = (CXFA_NodeArray&)rnd.m_Nodes; int32_t iLen = wsCondition.GetLength(); FX_BOOL bRelative = FALSE; FX_BOOL bAll = FALSE; int32_t i = 1; for (; i < iLen; ++i) { FX_WCHAR ch = wsCondition[i]; if (ch == ' ') { continue; } if (ch == '+' || ch == '-') { bRelative = TRUE; break; } else if (ch == '*') { bAll = TRUE; break; } else { break; } } if (bAll) { if (rnd.m_dwStyles & XFA_RESOLVENODE_CreateNode) { if (rnd.m_dwStyles & XFA_RESOLVENODE_Bind) { m_pNodeHelper->m_pCreateParent = ToNode(rnd.m_CurNode); m_pNodeHelper->m_iCreateCount = 1; findNodes.RemoveAll(); m_pNodeHelper->m_iCurAllStart = -1; m_pNodeHelper->m_pAllStartParent = NULL; } else { if (m_pNodeHelper->m_iCurAllStart == -1) { m_pNodeHelper->m_iCurAllStart = m_iCurStart; m_pNodeHelper->m_pAllStartParent = ToNode(rnd.m_CurNode); } } } else if (rnd.m_dwStyles & XFA_RESOLVENODE_BindNew) { if (m_pNodeHelper->m_iCurAllStart == -1) { m_pNodeHelper->m_iCurAllStart = m_iCurStart; } } return; } if (iFoundCount == 1 && !iLen) { return; } CFX_WideString wsIndex; wsIndex = wsCondition.Mid(i, iLen - 1 - i); int32_t iIndex = wsIndex.GetInteger(); if (bRelative) { iIndex += iCurIndex; } if (iFoundCount <= iIndex || iIndex < 0) { if (rnd.m_dwStyles & XFA_RESOLVENODE_CreateNode) { m_pNodeHelper->m_pCreateParent = ToNode(rnd.m_CurNode); m_pNodeHelper->m_iCreateCount = iIndex - iFoundCount + 1; } findNodes.RemoveAll(); } else { CXFA_Node* ret = findNodes[iIndex]; findNodes.RemoveAll(); findNodes.Add(ret); } }
CFX_WideString CBC_HighLevelEncoder::encodeHighLevel(CFX_WideString msg, CFX_WideString ecLevel, SymbolShapeHint shape, CBC_Dimension* minSize, CBC_Dimension* maxSize, int32_t& e) { CBC_EncoderContext context(msg, ecLevel, e); BC_EXCEPTION_CHECK_ReturnValue(e, (FX_WCHAR*)""); context.setSymbolShape(shape); context.setSizeConstraints(minSize, maxSize); if ((msg.Mid(0, 6) == MACRO_05_HEADER) && (msg.Mid(msg.GetLength() - 1, 1) == MACRO_TRAILER)) { context.writeCodeword(MACRO_05); context.setSkipAtEnd(2); context.m_pos += 6; } else if ((msg.Mid(0, 6) == MACRO_06_HEADER) && (msg.Mid(msg.GetLength() - 1, 1) == MACRO_TRAILER)) { context.writeCodeword(MACRO_06); context.setSkipAtEnd(2); context.m_pos += 6; } CFX_PtrArray encoders; encoders.Add(new CBC_ASCIIEncoder()); encoders.Add(new CBC_C40Encoder()); encoders.Add(new CBC_TextEncoder()); encoders.Add(new CBC_X12Encoder()); encoders.Add(new CBC_EdifactEncoder()); encoders.Add(new CBC_Base256Encoder()); int32_t encodingMode = ASCII_ENCODATION; while (context.hasMoreCharacters()) { ((CBC_Encoder*)encoders.GetAt(encodingMode))->Encode(context, e); if (e != BCExceptionNO) { for (int32_t i = 0; i < encoders.GetSize(); i++) { delete (CBC_Encoder*)encoders.GetAt(i); } encoders.RemoveAll(); return (FX_WCHAR*)""; } if (context.m_newEncoding >= 0) { encodingMode = context.m_newEncoding; context.resetEncoderSignal(); } } int32_t len = context.m_codewords.GetLength(); context.updateSymbolInfo(e); if (e != BCExceptionNO) { for (int32_t i = 0; i < encoders.GetSize(); i++) { delete (CBC_Encoder*)encoders.GetAt(i); } encoders.RemoveAll(); return (FX_WCHAR*)""; } int32_t capacity = context.m_symbolInfo->m_dataCapacity; if (len < capacity) { if (encodingMode != ASCII_ENCODATION && encodingMode != BASE256_ENCODATION) { context.writeCodeword(0x00fe); } } CFX_WideString codewords = context.m_codewords; if (codewords.GetLength() < capacity) { codewords += PAD; } while (codewords.GetLength() < capacity) { codewords += (randomize253State(PAD, codewords.GetLength() + 1)); } for (int32_t i = 0; i < encoders.GetSize(); i++) { delete (CBC_Encoder*)encoders.GetAt(i); } encoders.RemoveAll(); return codewords; }