void PDF_GetPageText(CFX_ByteStringArray& lines, CPDF_Document* pDoc, CPDF_Dictionary* pPage, int iMinWidth, FX_DWORD flags) { lines.RemoveAll(); CFX_WideStringArray wlines; PDF_GetPageText_Unicode(wlines, pDoc, pPage, iMinWidth, flags); for (int i = 0; i < wlines.GetSize(); i ++) { CFX_WideString wstr = wlines[i]; CFX_ByteString str; for (int c = 0; c < wstr.GetLength(); c ++) { str += CharFromUnicodeAlt(wstr[c], FXSYS_GetACP(), "?"); } lines.Add(str); } }
CFX_WideString CBC_OnedCode128Writer::FilterContents( const CFX_WideStringC& contents) { CFX_WideString filterChineseChar; FX_WCHAR ch; for (int32_t i = 0; i < contents.GetLength(); i++) { ch = contents.GetAt(i); if (ch > 175) { i++; continue; } filterChineseChar += ch; } CFX_WideString filtercontents; if (m_codeFormat == BC_CODE128_B) { for (int32_t i = 0; i < filterChineseChar.GetLength(); i++) { ch = filterChineseChar.GetAt(i); if (ch >= 32 && ch <= 126) { filtercontents += ch; } else { continue; } } } else if (m_codeFormat == BC_CODE128_C) { for (int32_t i = 0; i < filterChineseChar.GetLength(); i++) { ch = filterChineseChar.GetAt(i); if (ch >= 32 && ch <= 106) { filtercontents += ch; } else { continue; } } } else { filtercontents = contents; } return filtercontents; }
void CPWL_ListBox::OnNotifySelChanged(bool bKeyDown, bool& bExit, uint32_t nFlag) { if (!m_pFillerNotify) return; bool bRC = true; CFX_WideString swChange = GetText(); CFX_WideString strChangeEx; int nSelStart = 0; int nSelEnd = swChange.GetLength(); m_pFillerNotify->OnBeforeKeyStroke(GetAttachedData(), swChange, strChangeEx, nSelStart, nSelEnd, bKeyDown, bRC, bExit, nFlag); }
void CScript_HostPseudoModel::ResetData(CFXJSE_Arguments* pArguments) { int32_t iLength = pArguments->GetLength(); if (iLength < 0 || iLength > 1) { ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"resetData"); return; } CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); if (!pNotify) { return; } CFX_WideString wsExpression; if (iLength >= 1) { CFX_ByteString bsExpression = pArguments->GetUTF8String(0); wsExpression = CFX_WideString::FromUTF8(bsExpression.AsStringC()); } if (wsExpression.IsEmpty()) { pNotify->ResetData(); return; } int32_t iStart = 0; CFX_WideString wsName; CXFA_Node* pNode = nullptr; int32_t iExpLength = wsExpression.GetLength(); while (iStart < iExpLength) { iStart = XFA_FilterName(wsExpression.AsStringC(), iStart, wsName); CXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext(); if (!pScriptContext) { return; } CXFA_Object* pObject = pScriptContext->GetThisObject(); if (!pObject) { return; } uint32_t dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings; XFA_RESOLVENODE_RS resoveNodeRS; int32_t iRet = pScriptContext->ResolveObjects(pObject, wsName.AsStringC(), resoveNodeRS, dwFlag); if (iRet < 1 || !resoveNodeRS.nodes[0]->IsNode()) { continue; } pNode = resoveNodeRS.nodes[0]->AsNode(); pNotify->ResetData(pNode->GetWidgetData()); } if (!pNode) { pNotify->ResetData(); } }
void CPDF_VariableText::SetText(const FX_WCHAR* text) { DeleteWords(CPVT_WordRange(GetBeginWordPlace(), GetEndWordPlace())); CFX_WideString swText = text; CPVT_WordPlace wp(0, 0, -1); CPVT_SectionInfo secinfo; if (CSection* pSection = m_SectionArray.GetAt(0)) pSection->m_SecInfo = secinfo; int32_t nCharCount = 0; for (int32_t i = 0, sz = swText.GetLength(); i < sz; i++) { if (m_nLimitChar > 0 && nCharCount >= m_nLimitChar) break; if (m_nCharArray > 0 && nCharCount >= m_nCharArray) break; uint16_t word = swText.GetAt(i); switch (word) { case 0x0D: if (m_bMultiLine) { if (swText.GetAt(i + 1) == 0x0A) i += 1; wp.nSecIndex++; wp.nLineIndex = 0; wp.nWordIndex = -1; AddSection(wp, secinfo); } break; case 0x0A: if (m_bMultiLine) { if (swText.GetAt(i + 1) == 0x0D) i += 1; wp.nSecIndex++; wp.nLineIndex = 0; wp.nWordIndex = -1; AddSection(wp, secinfo); } break; case 0x09: word = 0x20; default: wp = InsertWord(wp, word, FXFONT_DEFAULT_CHARSET, nullptr); break; } nCharCount++; } }
void CFFL_ComboBox::OnSetFocus(CPWL_Wnd* pWnd) { ASSERT(m_pFormFillEnv); if (pWnd->GetClassName() == PWL_CLASSNAME_EDIT) { CPWL_Edit* pEdit = (CPWL_Edit*)pWnd; pEdit->SetCharSet(FXFONT_GB2312_CHARSET); pEdit->SetCodePage(936); pEdit->SetReadyToInput(); CFX_WideString wsText = pEdit->GetText(); int nCharacters = wsText.GetLength(); CFX_ByteString bsUTFText = wsText.UTF16LE_Encode(); unsigned short* pBuffer = (unsigned short*)bsUTFText.c_str(); m_pFormFillEnv->OnSetFieldInputFocus(pBuffer, nCharacters, true); } }
CFX_WideString CBC_ErrorCorrection::encodeECC200(CFX_WideString codewords, CBC_SymbolInfo* symbolInfo, int32_t& e) { if (codewords.GetLength() != symbolInfo->m_dataCapacity) { e = BCExceptionIllegalArgument; return (FX_WCHAR*)""; } CFX_WideString sb; sb += codewords; int32_t blockCount = symbolInfo->getInterleavedBlockCount(); if (blockCount == 1) { CFX_WideString ecc = createECCBlock(codewords, symbolInfo->m_errorCodewords, e); BC_EXCEPTION_CHECK_ReturnValue(e, (FX_WCHAR*)""); sb += ecc; } else { CFX_Int32Array dataSizes; dataSizes.SetSize(blockCount); CFX_Int32Array errorSizes; errorSizes.SetSize(blockCount); CFX_Int32Array startPos; startPos.SetSize(blockCount); for (int32_t i = 0; i < blockCount; i++) { dataSizes[i] = symbolInfo->getDataLengthForInterleavedBlock(i + 1); errorSizes[i] = symbolInfo->getErrorLengthForInterleavedBlock(i + 1); startPos[i] = 0; if (i > 0) { startPos[i] = startPos[i - 1] + dataSizes[i]; } } for (int32_t block = 0; block < blockCount; block++) { CFX_WideString temp; for (int32_t d = block; d < symbolInfo->m_dataCapacity; d += blockCount) { temp += (FX_WCHAR)codewords.GetAt(d); } CFX_WideString ecc = createECCBlock(temp, errorSizes[block], e); BC_EXCEPTION_CHECK_ReturnValue(e, (FX_WCHAR*)""); int32_t pos = 0; for (int32_t l = block; l < errorSizes[block] * blockCount; l += blockCount) { sb.SetAt(symbolInfo->m_dataCapacity + l, ecc.GetAt(pos++)); } } } return sb; }
int32_t CBC_HighLevelEncoder::determineConsecutiveDigitCount(CFX_WideString msg, int32_t startpos) { int32_t count = 0; int32_t len = msg.GetLength(); int32_t idx = startpos; if (idx < len) { FX_WCHAR ch = msg.GetAt(idx); while (isDigit(ch) && idx < len) { count++; idx++; if (idx < len) { ch = msg.GetAt(idx); } } } return count; }
IFX_LocaleMgr* FX_LocaleMgr_Create(const FX_WCHAR* pszLocalPath, FX_WORD wDefaultLCID) { void* pPathHandle = FX_OpenFolder(pszLocalPath); if (!pPathHandle) { return NULL; } CFX_LocaleMgr* pLocaleMgr = new CFX_LocaleMgr(wDefaultLCID); CFX_WideString wsFileName; FX_BOOL bFolder = FALSE; while (FX_GetNextFile(pPathHandle, wsFileName, bFolder)) { if (!bFolder) { if (wsFileName.GetLength() < 4) { continue; } CFX_WideString wsExt = wsFileName.Right(4); wsExt.MakeLower(); if (wsExt != L".xml") { continue; } CFX_WideString wsFullPath(pszLocalPath); wsFullPath += L"\\" + wsFileName; IFX_FileRead* pRead = FX_CreateFileRead(wsFullPath); if (!pRead) { continue; } CXML_Element* pXmlLocale = CXML_Element::Parse(pRead); pRead->Release(); CFX_ByteString bssp = pXmlLocale->GetNamespace(); if (bssp == "http://www.foxitsoftware.com/localization") { CFX_WideString wsLCID = pXmlLocale->GetAttrValue("", "lcid"); wchar_t* pEnd = NULL; FX_DWORD dwLCID = wcstol(wsLCID, &pEnd, 16); if (pLocaleMgr->m_lcid2xml.GetValueAt((void*)(uintptr_t)dwLCID)) { delete pXmlLocale; } else { pLocaleMgr->m_lcid2xml.SetAt((void*)(uintptr_t)dwLCID, pXmlLocale); } } else { delete pXmlLocale; } } } FX_CloseFolder(pPathHandle); return pLocaleMgr; }
void CFDE_TxtEdtEngine::SetText(const CFX_WideString& wsText) { ResetEngine(); int32_t nLength = wsText.GetLength(); if (nLength > 0) { CFX_WideString wsTemp; FX_WCHAR* lpBuffer = wsTemp.GetBuffer(nLength); FXSYS_memcpy(lpBuffer, wsText.c_str(), nLength * sizeof(FX_WCHAR)); ReplaceParagEnd(lpBuffer, nLength, FALSE); wsTemp.ReleaseBuffer(nLength); if (m_nLimit > 0 && nLength > m_nLimit) { wsTemp.Delete(m_nLimit, nLength - m_nLimit); nLength = m_nLimit; } m_pTxtBuf->SetText(wsTemp); } m_pTxtBuf->Insert(nLength, &m_wLineEnd, 1); RebuildParagraphs(); }
FX_BOOL CPDF_TextPageFind::FindFirst(const CFX_WideString& findwhat, int flags, int startPos) { if (!m_pTextPage) return FALSE; if (m_strText.IsEmpty() || m_bMatchCase != (flags & FPDFTEXT_MATCHCASE)) m_strText = m_pTextPage->GetPageText(); CFX_WideString findwhatStr = findwhat; m_findWhat = findwhatStr; m_flags = flags; m_bMatchCase = flags & FPDFTEXT_MATCHCASE; if (m_strText.IsEmpty()) { m_IsFind = FALSE; return TRUE; } FX_STRSIZE len = findwhatStr.GetLength(); if (!m_bMatchCase) { findwhatStr.MakeLower(); m_strText.MakeLower(); } m_bMatchWholeWord = flags & FPDFTEXT_MATCHWHOLEWORD; m_findNextStart = startPos; if (startPos == -1) m_findPreStart = m_strText.GetLength() - 1; else m_findPreStart = startPos; m_csFindWhatArray.clear(); int i = 0; while (i < len) { if (findwhatStr.GetAt(i) != ' ') break; i++; } if (i < len) ExtractFindWhat(findwhatStr); else m_csFindWhatArray.push_back(findwhatStr); if (m_csFindWhatArray.empty()) return FALSE; m_IsFind = TRUE; m_resStart = 0; m_resEnd = -1; return TRUE; }
CFX_WideString CPDF_Bookmark::GetTitle() { if (!m_pDict) { return CFX_WideString(); } CPDF_String* pString = (CPDF_String*)m_pDict->GetElementValue("Title"); if (pString == NULL || pString->GetType() != PDFOBJ_STRING) { return CFX_WideString(); } CFX_WideString title = pString->GetUnicodeText(); FX_LPWSTR buf = title.LockBuffer(); int len = title.GetLength(), i; for (i = 0; i < len; i ++) if (buf[i] < 0x20) { buf[i] = 0x20; } title.ReleaseBuffer(len); return title; }
void CBC_PDF417::generateBarcodeLogic(CFX_WideString msg, int32_t errorCorrectionLevel, int32_t& e) { int32_t errorCorrectionCodeWords = CBC_PDF417ErrorCorrection::getErrorCorrectionCodewordCount( errorCorrectionLevel, e); if (e != BCExceptionNO) return; CFX_WideString highLevel = CBC_PDF417HighLevelEncoder::encodeHighLevel(msg, m_compaction, e); if (e != BCExceptionNO) return; int32_t sourceCodeWords = highLevel.GetLength(); CFX_ArrayTemplate<int32_t>* dimension = determineDimensions(sourceCodeWords, errorCorrectionCodeWords, e); if (e != BCExceptionNO) return; int32_t cols = dimension->GetAt(0); int32_t rows = dimension->GetAt(1); delete dimension; int32_t pad = getNumberOfPadCodewords(sourceCodeWords, errorCorrectionCodeWords, cols, rows); if (sourceCodeWords + errorCorrectionCodeWords + 1 > 929) { e = BCExceptionEncodedMessageContainsTooManyCodeWords; return; } int32_t n = sourceCodeWords + pad + 1; CFX_WideString sb; sb += (FX_WCHAR)n; sb += highLevel; for (int32_t i = 0; i < pad; i++) { sb += (FX_WCHAR)900; } CFX_WideString dataCodewords(sb); CFX_WideString ec = CBC_PDF417ErrorCorrection::generateErrorCorrection( dataCodewords, errorCorrectionLevel, e); if (e != BCExceptionNO) return; CFX_WideString fullCodewords = dataCodewords + ec; m_barcodeMatrix = pdfium::MakeUnique<CBC_BarcodeMatrix>(rows, cols); encodeLowLevel(fullCodewords, cols, rows, errorCorrectionLevel, m_barcodeMatrix.get()); }
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_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); }
uint8_t* CBC_DataMatrixWriter::Encode(const CFX_WideString& contents, int32_t& outWidth, int32_t& outHeight, int32_t& e) { if (outWidth < 0 || outHeight < 0) { e = BCExceptionHeightAndWidthMustBeAtLeast1; return nullptr; } CBC_SymbolShapeHint::SymbolShapeHint shape = CBC_SymbolShapeHint::FORCE_SQUARE; CBC_Dimension* minSize = nullptr; CBC_Dimension* maxSize = nullptr; CFX_WideString ecLevel; CFX_WideString encoded = CBC_HighLevelEncoder::encodeHighLevel( contents, ecLevel, shape, minSize, maxSize, e); if (e != BCExceptionNO) return nullptr; CBC_SymbolInfo* symbolInfo = CBC_SymbolInfo::lookup( encoded.GetLength(), shape, minSize, maxSize, true, e); if (e != BCExceptionNO) return nullptr; CFX_WideString codewords = CBC_ErrorCorrection::encodeECC200(encoded, symbolInfo, e); if (e != BCExceptionNO) return nullptr; CBC_DefaultPlacement* placement = new CBC_DefaultPlacement(codewords, symbolInfo->getSymbolDataWidth(e), symbolInfo->getSymbolDataHeight(e)); if (e != BCExceptionNO) return nullptr; placement->place(); CBC_CommonByteMatrix* bytematrix = encodeLowLevel(placement, symbolInfo, e); if (e != BCExceptionNO) return nullptr; outWidth = bytematrix->GetWidth(); outHeight = bytematrix->GetHeight(); uint8_t* result = FX_Alloc2D(uint8_t, outWidth, outHeight); FXSYS_memcpy(result, bytematrix->GetArray(), outWidth * outHeight); delete bytematrix; delete placement; return result; }
FX_BOOL CPDF_TextPageFind::IsMatchWholeWord(const CFX_WideString& csPageText, int startPos, int endPos) { FX_WCHAR char_left = 0; FX_WCHAR char_right = 0; int char_count = endPos - startPos + 1; if (char_count < 1) return FALSE; if (char_count == 1 && csPageText.GetAt(startPos) > 255) return TRUE; if (startPos - 1 >= 0) char_left = csPageText.GetAt(startPos - 1); if (startPos + char_count < csPageText.GetLength()) char_right = csPageText.GetAt(startPos + char_count); if ((char_left > 'A' && char_left < 'a') || (char_left > 'a' && char_left < 'z') || (char_left > 0xfb00 && char_left < 0xfb06) || std::iswdigit(char_left) || (char_right > 'A' && char_right < 'a') || (char_right > 'a' && char_right < 'z') || (char_right > 0xfb00 && char_right < 0xfb06) || std::iswdigit(char_right)) { return FALSE; } if (!(('A' > char_left || char_left > 'Z') && ('a' > char_left || char_left > 'z') && ('A' > char_right || char_right > 'Z') && ('a' > char_right || char_right > 'z'))) { return FALSE; } if (char_count > 0) { if (csPageText.GetAt(startPos) >= L'0' && csPageText.GetAt(startPos) <= L'9' && char_left >= L'0' && char_left <= L'9') { return FALSE; } if (csPageText.GetAt(endPos) >= L'0' && csPageText.GetAt(endPos) <= L'9' && char_right >= L'0' && char_right <= L'9') { return FALSE; } } return TRUE; }
int32_t CBC_PDF417HighLevelEncoder::determineConsecutiveBinaryCount( CFX_WideString msg, CFX_ByteArray* bytes, int32_t startpos, int32_t& e) { int32_t len = msg.GetLength(); int32_t idx = startpos; while (idx < len) { FX_WCHAR ch = msg.GetAt(idx); int32_t numericCount = 0; while (numericCount < 13 && isDigit(ch)) { numericCount++; int32_t i = idx + numericCount; if (i >= len) { break; } ch = msg.GetAt(i); } if (numericCount >= 13) { return idx - startpos; } int32_t textCount = 0; while (textCount < 5 && isText(ch)) { textCount++; int32_t i = idx + textCount; if (i >= len) { break; } ch = msg.GetAt(i); } if (textCount >= 5) { return idx - startpos; } ch = msg.GetAt(idx); if (bytes->GetAt(idx) == 63 && ch != '?') { e = BCExceptionNonEncodableCharacterDetected; return -1; } idx++; } return idx - startpos; }
int CPDF_FormField::InsertOption(CFX_WideString csOptLabel, int index, FX_BOOL bNotify) { if (csOptLabel.IsEmpty()) return -1; if (bNotify && m_pForm->m_pFormNotify) { int iRet = 0; if (GetType() == ListBox) iRet = m_pForm->m_pFormNotify->BeforeSelectionChange(this, csOptLabel); if (GetType() == ComboBox) iRet = m_pForm->m_pFormNotify->BeforeValueChange(this, csOptLabel); if (iRet < 0) return -1; } CFX_ByteString csStr = PDF_EncodeText(csOptLabel, csOptLabel.GetLength()); CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict, "Opt"); CPDF_Array* pOpt = ToArray(pValue); if (!pOpt) { pOpt = new CPDF_Array; m_pDict->SetAt("Opt", pOpt); } int iCount = (int)pOpt->GetCount(); if (index < 0 || index >= iCount) { pOpt->AddString(csStr); index = iCount; } else { CPDF_String* pString = new CPDF_String(csStr, FALSE); pOpt->InsertAt(index, pString); } if (bNotify && m_pForm->m_pFormNotify) { if (GetType() == ListBox) m_pForm->m_pFormNotify->AfterSelectionChange(this); if (GetType() == ComboBox) m_pForm->m_pFormNotify->AfterValueChange(this); } m_pForm->m_bUpdated = TRUE; return index; }
CFX_WideString Document::ReversalStr(CFX_WideString cbFrom) { size_t iLength = cbFrom.GetLength(); pdfium::base::CheckedNumeric<size_t> iSize = sizeof(wchar_t); iSize *= (iLength + 1); wchar_t* pResult = (wchar_t*)malloc(iSize.ValueOrDie()); wchar_t* pFrom = (wchar_t*)cbFrom.GetBuffer(iLength); for (size_t i = 0; i < iLength; i++) { pResult[i] = *(pFrom + iLength - i - 1); } pResult[iLength] = L'\0'; cbFrom.ReleaseBuffer(); CFX_WideString cbRet = CFX_WideString(pResult); free(pResult); pResult = NULL; return cbRet; }
CFX_WideString CPDF_Bookmark::GetTitle() const { if (!m_pDict) { return CFX_WideString(); } CPDF_String* pString = ToString(m_pDict->GetElementValue("Title")); if (!pString) return CFX_WideString(); CFX_WideString title = pString->GetUnicodeText(); int len = title.GetLength(); if (!len) { return CFX_WideString(); } nonstd::unique_ptr<FX_WCHAR[]> buf(new FX_WCHAR[len]); for (int i = 0; i < len; i++) { FX_WCHAR w = title[i]; buf[i] = w > 0x20 ? w : 0x20; } return CFX_WideString(buf.get(), len); }
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; }
void CFFL_ComboBox::OnSetFocus(CPWL_Wnd* pWnd) { ASSERT(m_pApp != NULL); ASSERT(pWnd != NULL); if (pWnd->GetClassName() == PWL_CLASSNAME_EDIT) { CPWL_Edit* pEdit = (CPWL_Edit*)pWnd; pEdit->SetCharSet(134); pEdit->SetCodePage(936); pEdit->SetReadyToInput(); CFX_WideString wsText = pEdit->GetText(); int nCharacters = wsText.GetLength(); CFX_ByteString bsUTFText = wsText.UTF16LE_Encode(); unsigned short* pBuffer = (unsigned short*)bsUTFText.c_str(); m_pApp->FFI_OnSetFieldInputFocus(m_pWidget->GetFormField(), pBuffer, nCharacters, TRUE); pEdit->SetEditNotify(this); } }
CFX_WideString Document::GetObjWordStr(CPDF_TextObject* pTextObj, int nWordIndex) { ASSERT(pTextObj != NULL); CFX_WideString swRet; CPDF_Font* pFont = pTextObj->GetFont(); if (!pFont) return L""; int nWords = 0; FX_BOOL bIsLatin = FALSE; for (int i=0, sz=pTextObj->CountChars(); i<sz; i++) { FX_DWORD charcode = -1; FX_FLOAT kerning; pTextObj->GetCharInfo(i, charcode, kerning); CFX_WideString swUnicode = pFont->UnicodeFromCharCode(charcode); FX_WORD unicode = 0; if (swUnicode.GetLength() > 0) unicode = swUnicode[0]; if (ISLATINWORD(unicode) && bIsLatin) { } else { bIsLatin = ISLATINWORD(unicode); if (unicode != 0x20) nWords++; } if (nWords-1 == nWordIndex) swRet += unicode; } return swRet; }
FX_BOOL CJS_Context::RunScript(const CFX_WideString& script, CFX_WideString* info) { v8::Isolate::Scope isolate_scope(m_pRuntime->GetIsolate()); v8::HandleScope handle_scope(m_pRuntime->GetIsolate()); v8::Local<v8::Context> context = m_pRuntime->NewLocalContext(); v8::Context::Scope context_scope(context); if (m_bBusy) { *info = JSGetStringFromID(this, IDS_STRING_JSBUSY); return FALSE; } m_bBusy = TRUE; ASSERT(m_pEventHandler->IsValid()); CJS_Runtime::FieldEvent event(m_pEventHandler->TargetName(), m_pEventHandler->EventType()); if (!m_pRuntime->AddEventToSet(event)) { *info = JSGetStringFromID(this, IDS_STRING_JSEVENT); return FALSE; } CFX_WideString sErrorMessage; int nRet = 0; if (script.GetLength() > 0) { nRet = m_pRuntime->ExecuteScript(script.c_str(), &sErrorMessage); } if (nRet < 0) { *info += sErrorMessage; } else { *info = JSGetStringFromID(this, IDS_STRING_RUN); } m_pRuntime->RemoveEventFromSet(event); m_pEventHandler->Destroy(); m_bBusy = FALSE; return nRet >= 0; }
void CBC_X12Encoder::Encode(CBC_EncoderContext& context, int32_t& e) { CFX_WideString buffer; while (context.hasMoreCharacters()) { FX_WCHAR c = context.getCurrentChar(); context.m_pos++; encodeChar(c, buffer, e); if (e != BCExceptionNO) { return; } int32_t count = buffer.GetLength(); if ((count % 3) == 0) { writeNextTriplet(context, buffer); int32_t newMode = CBC_HighLevelEncoder::lookAheadTest( context.m_msg, context.m_pos, getEncodingMode()); if (newMode != getEncodingMode()) { context.signalEncoderChange(newMode); break; } } } handleEOD(context, buffer, e); }
void CBC_X12Encoder::handleEOD(CBC_EncoderContext& context, CFX_WideString& buffer, int32_t& e) { context.updateSymbolInfo(e); if (e != BCExceptionNO) { return; } int32_t available = context.m_symbolInfo->m_dataCapacity - context.getCodewordCount(); int32_t count = buffer.GetLength(); if (count == 2) { context.writeCodeword(CBC_HighLevelEncoder::X12_UNLATCH); context.m_pos -= 2; context.signalEncoderChange(ASCII_ENCODATION); } else if (count == 1) { context.m_pos--; if (available > 1) { context.writeCodeword(CBC_HighLevelEncoder::X12_UNLATCH); } context.signalEncoderChange(ASCII_ENCODATION); } }
DLLEXPORT int STDCALL FPDFText_GetText(FPDF_TEXTPAGE text_page, int start, int count, unsigned short* result) { if (!text_page) return 0; CPDF_TextPage* textpage = CPDFTextPageFromFPDFTextPage(text_page); if (start >= textpage->CountChars()) return 0; CFX_WideString str = textpage->GetPageText(start, count); if (str.GetLength() > count) str = str.Left(count); CFX_ByteString cbUTF16str = str.UTF16LE_Encode(); FXSYS_memcpy(result, cbUTF16str.GetBuffer(cbUTF16str.GetLength()), cbUTF16str.GetLength()); cbUTF16str.ReleaseBuffer(cbUTF16str.GetLength()); return cbUTF16str.GetLength() / sizeof(unsigned short); }
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; }
CPVT_WordPlace CPDF_VariableText::InsertText(const CPVT_WordPlace& place, const FX_WCHAR* text, int32_t charset, const CPVT_SecProps* pSecProps, const CPVT_WordProps* pProps) { CFX_WideString swText = text; CPVT_WordPlace wp = place; for (int32_t i = 0, sz = swText.GetLength(); i < sz; i++) { CPVT_WordPlace oldwp = wp; uint16_t word = swText.GetAt(i); switch (word) { case 0x0D: if (m_bMultiLine) { if (swText.GetAt(i + 1) == 0x0A) i += 1; wp = InsertSection(wp, pSecProps, pProps); } break; case 0x0A: if (m_bMultiLine) { if (swText.GetAt(i + 1) == 0x0D) i += 1; wp = InsertSection(wp, pSecProps, pProps); } break; case 0x09: word = 0x20; default: wp = InsertWord(wp, word, charset, pProps); break; } if (wp == oldwp) break; } return wp; }