// static void CPDF_TextRenderer::DrawTextString(CFX_RenderDevice* pDevice, FX_FLOAT origin_x, FX_FLOAT origin_y, CPDF_Font* pFont, FX_FLOAT font_size, const CFX_Matrix* pMatrix, const CFX_ByteString& str, FX_ARGB fill_argb, FX_ARGB stroke_argb, const CFX_GraphStateData* pGraphState, const CPDF_RenderOptions* pOptions) { if (pFont->IsType3Font()) return; int nChars = pFont->CountChar(str.c_str(), str.GetLength()); if (nChars <= 0) return; int offset = 0; uint32_t* pCharCodes; FX_FLOAT* pCharPos; std::vector<uint32_t> codes; std::vector<FX_FLOAT> positions; if (nChars == 1) { pCharCodes = reinterpret_cast<uint32_t*>( pFont->GetNextChar(str.c_str(), str.GetLength(), offset)); pCharPos = nullptr; } else { codes.resize(nChars); positions.resize(nChars - 1); FX_FLOAT cur_pos = 0; for (int i = 0; i < nChars; i++) { codes[i] = pFont->GetNextChar(str.c_str(), str.GetLength(), offset); if (i) positions[i - 1] = cur_pos; cur_pos += pFont->GetCharWidthF(codes[i]) * font_size / 1000; } pCharCodes = codes.data(); pCharPos = positions.data(); } CFX_Matrix matrix; if (pMatrix) matrix = *pMatrix; matrix.e = origin_x; matrix.f = origin_y; if (stroke_argb == 0) { DrawNormalText(pDevice, nChars, pCharCodes, pCharPos, pFont, font_size, &matrix, fill_argb, pOptions); } else { DrawTextPath(pDevice, nChars, pCharCodes, pCharPos, pFont, font_size, &matrix, nullptr, pGraphState, fill_argb, stroke_argb, nullptr, 0); } }
CPDF_Font* CPDF_FormControl::GetDefaultControlFont() { CPDF_DefaultAppearance cDA = GetDefaultAppearance(); CFX_ByteString csFontNameTag; FX_FLOAT fFontSize; cDA.GetFont(csFontNameTag, fFontSize); if (csFontNameTag.IsEmpty()) return nullptr; CPDF_Object* pObj = FPDF_GetFieldAttr(m_pWidgetDict, "DR"); if (CPDF_Dictionary* pDict = ToDictionary(pObj)) { CPDF_Dictionary* pFonts = pDict->GetDictBy("Font"); if (pFonts) { CPDF_Dictionary* pElement = pFonts->GetDictBy(csFontNameTag); if (pElement) { CPDF_Font* pFont = m_pField->m_pForm->m_pDocument->LoadFont(pElement); if (pFont) return pFont; } } } if (CPDF_Font* pFormFont = m_pField->m_pForm->GetFormFont(csFontNameTag)) return pFormFont; CPDF_Dictionary* pPageDict = m_pWidgetDict->GetDictBy("P"); pObj = FPDF_GetFieldAttr(pPageDict, "Resources"); if (CPDF_Dictionary* pDict = ToDictionary(pObj)) { CPDF_Dictionary* pFonts = pDict->GetDictBy("Font"); if (pFonts) { CPDF_Dictionary* pElement = pFonts->GetDictBy(csFontNameTag); if (pElement) { CPDF_Font* pFont = m_pField->m_pForm->m_pDocument->LoadFont(pElement); if (pFont) return pFont; } } } return nullptr; }
CPDF_Font* CPDF_FormControl::GetDefaultControlFont() { CPDF_DefaultAppearance cDA = GetDefaultAppearance(); CFX_ByteString csFontNameTag; FX_FLOAT fFontSize; cDA.GetFont(csFontNameTag, fFontSize); if (csFontNameTag.IsEmpty()) { return NULL; } CPDF_Object* pObj = FPDF_GetFieldAttr(m_pWidgetDict, "DR"); if (pObj != NULL && pObj->GetType() == PDFOBJ_DICTIONARY) { CPDF_Dictionary* pFonts = ((CPDF_Dictionary*)pObj)->GetDict("Font"); if (pFonts != NULL) { CPDF_Dictionary *pElement = pFonts->GetDict(csFontNameTag); CPDF_Font *pFont = m_pField->m_pForm->m_pDocument->LoadFont(pElement); if (pFont != NULL) { return pFont; } } } CPDF_Font *pFont = m_pField->m_pForm->GetFormFont(csFontNameTag); if (pFont != NULL) { return pFont; } CPDF_Dictionary *pPageDict = m_pWidgetDict->GetDict("P"); pObj = FPDF_GetFieldAttr(pPageDict, "Resources"); if (pObj != NULL && pObj->GetType() == PDFOBJ_DICTIONARY) { CPDF_Dictionary* pFonts = ((CPDF_Dictionary*)pObj)->GetDict("Font"); if (pFonts != NULL) { CPDF_Dictionary *pElement = pFonts->GetDict(csFontNameTag); CPDF_Font *pFont = m_pField->m_pForm->m_pDocument->LoadFont(pElement); if (pFont != NULL) { return pFont; } } } return NULL; }
void CScript_HostPseudoModel::Script_HostPseudoModel_ExportData( CFXJSE_Arguments* pArguments) { int32_t iLength = pArguments->GetLength(); if (iLength < 0 || iLength > 2) { ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"exportData"); return; } IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); if (!pNotify) { return; } IXFA_Doc* hDoc = pNotify->GetHDOC(); CFX_WideString wsFilePath; FX_BOOL bXDP = TRUE; if (iLength >= 1) { CFX_ByteString bsFilePath = pArguments->GetUTF8String(0); wsFilePath = CFX_WideString::FromUTF8(bsFilePath, bsFilePath.GetLength()); } if (iLength >= 2) { bXDP = pArguments->GetInt32(1) == 0 ? FALSE : TRUE; } pNotify->GetDocProvider()->ExportData(hDoc, wsFilePath, bXDP); }
void CJS_GlobalData::SetGlobalVariableString(const FX_CHAR* propname, const CFX_ByteString& sData) { ASSERT(propname); CFX_ByteString sPropName = propname; sPropName.TrimLeft(); sPropName.TrimRight(); if (sPropName.GetLength() == 0) return; if (CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName)) { pData->data.nType = JS_GLOBALDATA_TYPE_STRING; pData->data.sData = sData; } else { CJS_GlobalData_Element* pNewData = new CJS_GlobalData_Element; pNewData->data.sKey = sPropName; pNewData->data.nType = JS_GLOBALDATA_TYPE_STRING; pNewData->data.sData = sData; m_arrayGlobalData.Add(pNewData); } }
CPDF_Font* GetInterFormFont(CPDF_Dictionary* pFormDict, CPDF_Document* pDocument, CFX_ByteString csNameTag) { CFX_ByteString csAlias = PDF_NameDecode(csNameTag); if (pFormDict == NULL || csAlias.IsEmpty()) { return NULL; } CPDF_Dictionary* pDR = pFormDict->GetDict("DR"); if (pDR == NULL) { return NULL; } CPDF_Dictionary* pFonts = pDR->GetDict("Font"); if (pFonts == NULL) { return NULL; } CPDF_Dictionary* pElement = pFonts->GetDict(csAlias); if (pElement == NULL) { return NULL; } if (pElement->GetString("Type") == "Font") { return pDocument->LoadFont(pElement); } return NULL; }
CPDF_Font* AddNativeInterFormFont(CPDF_Dictionary*& pFormDict, CPDF_Document* pDocument, FX_BYTE charSet, CFX_ByteString& csNameTag) { if (pFormDict == NULL) { InitInterFormDict(pFormDict, pDocument); } CFX_ByteString csTemp; CPDF_Font* pFont = GetNativeInterFormFont(pFormDict, pDocument, charSet, csTemp); if (pFont != NULL) { csNameTag = csTemp; return pFont; } CFX_ByteString csFontName = CPDF_InterForm::GetNativeFont(charSet); if (!csFontName.IsEmpty()) { if (FindInterFormFont(pFormDict, pDocument, csFontName, pFont, csNameTag)) { return pFont; } } pFont = CPDF_InterForm::AddNativeFont(charSet, pDocument); if (pFont != NULL) { AddInterFormFont(pFormDict, pDocument, pFont, csNameTag); } return pFont; }
void CFFL_TextField::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); //pUndo->BeginEdit(pDocument); } }
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; } }
CBC_EncoderContext::CBC_EncoderContext(const CFX_WideString msg, CFX_WideString ecLevel, int32_t& e) { CFX_ByteString dststr; CBC_UtilCodingConvert::UnicodeToUTF8(msg, dststr); CFX_WideString sb; int32_t c = dststr.GetLength(); for (int32_t i = 0; i < c; i++) { FX_WCHAR ch = (FX_WCHAR)(dststr.GetAt(i) & 0xff); if (ch == '?' && dststr.GetAt(i) != '?') { e = BCExceptionCharactersOutsideISO88591Encoding; } sb += ch; } m_msg = sb; m_shape = FORCE_NONE; m_newEncoding = -1; m_pos = 0; m_symbolInfo = NULL; m_skipAtEnd = 0; m_maxSize = NULL; m_minSize = NULL; }
void RemoveInterFormFont(CPDF_Dictionary* pFormDict, CFX_ByteString csNameTag) { if (!pFormDict || csNameTag.IsEmpty()) { return; } CPDF_Dictionary* pDR = pFormDict->GetDict("DR"); if (!pDR) { return; } CPDF_Dictionary* pFonts = pDR->GetDict("Font"); if (!pFonts) { return; } pFonts->RemoveAt(csNameTag); }
void CScript_HostPseudoModel::Script_HostPseudoModel_Title( FXJSE_HVALUE hValue, FX_BOOL bSetting, XFA_ATTRIBUTE eAttribute) { if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { return; } IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); if (!pNotify) { return; } IXFA_Doc* hDoc = pNotify->GetHDOC(); if (bSetting) { CFX_ByteString bsValue; FXJSE_Value_ToUTF8String(hValue, bsValue); pNotify->GetDocProvider()->SetTitle( hDoc, CFX_WideString::FromUTF8(bsValue, bsValue.GetLength())); return; } CFX_WideString wsTitle; pNotify->GetDocProvider()->GetTitle(hDoc, wsTitle); FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsTitle)); }
CPDF_Stream* FPDFDOC_GetAnnotAP(CPDF_Dictionary* pAnnotDict, CPDF_Annot::AppearanceMode mode) { CPDF_Dictionary* pAP = pAnnotDict->GetDictBy("AP"); if (!pAP) { return nullptr; } const FX_CHAR* ap_entry = "N"; if (mode == CPDF_Annot::Down) ap_entry = "D"; else if (mode == CPDF_Annot::Rollover) ap_entry = "R"; if (!pAP->KeyExist(ap_entry)) ap_entry = "N"; CPDF_Object* psub = pAP->GetDirectObjectBy(ap_entry); if (!psub) return nullptr; if (CPDF_Stream* pStream = psub->AsStream()) return pStream; if (CPDF_Dictionary* pDict = psub->AsDictionary()) { CFX_ByteString as = pAnnotDict->GetStringBy("AS"); if (as.IsEmpty()) { CFX_ByteString value = pAnnotDict->GetStringBy("V"); if (value.IsEmpty()) { CPDF_Dictionary* pParentDict = pAnnotDict->GetDictBy("Parent"); value = pParentDict ? pParentDict->GetStringBy("V") : CFX_ByteString(); } if (value.IsEmpty() || !pDict->KeyExist(value)) as = "Off"; else as = value; } return pDict->GetStreamBy(as); } return nullptr; }
void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_PageContent( CFXJSE_Arguments* pArguments) { int32_t iLength = pArguments->GetLength(); if (iLength < 1 || iLength > 3) { ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"pageContent"); return; } int32_t iIndex = 0; CFX_WideString wsType; FX_BOOL bOnPageArea = FALSE; if (iLength >= 1) { iIndex = pArguments->GetInt32(0); } if (iLength >= 2) { CFX_ByteString bsType = pArguments->GetUTF8String(1); wsType = CFX_WideString::FromUTF8(bsType, bsType.GetLength()); } if (iLength >= 3) { bOnPageArea = pArguments->GetInt32(2) == 0 ? FALSE : TRUE; } IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); if (!pNotify) { return; } IXFA_DocLayout* pDocLayout = m_pDocument->GetDocLayout(); if (!pDocLayout) { return; } CXFA_NodeArray retArray; Script_LayoutPseudoModel_GetObjArray(pDocLayout, iIndex, wsType, bOnPageArea, retArray); CXFA_ArrayNodeList* pArrayNodeList = new CXFA_ArrayNodeList(m_pDocument); pArrayNodeList->SetArrayNodeList(retArray); FXJSE_Value_SetObject(pArguments->GetReturnValue(), (CXFA_Object*)pArrayNodeList, m_pDocument->GetScriptContext()->GetJseNormalClass()); }
void CFX_FontMapper::AddInstalledFont(const CFX_ByteString& name, int charset) { if (!m_pFontInfo) return; m_FaceArray.push_back({name, static_cast<uint32_t>(charset)}); if (name == m_LastFamily) return; const uint8_t* ptr = name.raw_str(); FX_BOOL bLocalized = FALSE; for (int i = 0; i < name.GetLength(); i++) { if (ptr[i] > 0x80) { bLocalized = TRUE; break; } } if (bLocalized) { void* hFont = m_pFontInfo->GetFont(name.c_str()); if (!hFont) { int iExact; hFont = m_pFontInfo->MapFont(0, 0, FXFONT_DEFAULT_CHARSET, 0, name.c_str(), iExact); if (!hFont) return; } CFX_ByteString new_name = GetPSNameFromTT(hFont); if (!new_name.IsEmpty()) { new_name.Insert(0, ' '); m_InstalledTTFonts.push_back(new_name); } m_pFontInfo->DeleteFont(hFont); } m_InstalledTTFonts.push_back(name); m_LastFamily = name; }
void CalcEncryptKey(CPDF_Dictionary* pEncrypt, FX_LPCBYTE password, FX_DWORD pass_size, FX_LPBYTE key, int keylen, FX_BOOL bIgnoreMeta, CPDF_Array* pIdArray) { int revision = pEncrypt->GetInteger(FX_BSTRC("R")); FX_BYTE passcode[32]; for (FX_DWORD i = 0; i < 32; i ++) { passcode[i] = i < pass_size ? password[i] : defpasscode[i - pass_size]; } FX_BYTE md5[100]; CRYPT_MD5Start(md5); CRYPT_MD5Update(md5, passcode, 32); CFX_ByteString okey = pEncrypt->GetString(FX_BSTRC("O")); CRYPT_MD5Update(md5, (FX_LPBYTE)(FX_LPCSTR)okey, okey.GetLength()); FX_DWORD perm = pEncrypt->GetInteger(FX_BSTRC("P")); CRYPT_MD5Update(md5, (FX_LPBYTE)&perm, 4); if (pIdArray) { CFX_ByteString id = pIdArray->GetString(0); CRYPT_MD5Update(md5, (FX_LPBYTE)(FX_LPCSTR)id, id.GetLength()); } if (!bIgnoreMeta && revision >= 3 && !pEncrypt->GetInteger(FX_BSTRC("EncryptMetadata"), 1)) { FX_DWORD tag = (FX_DWORD) - 1; CRYPT_MD5Update(md5, (FX_LPBYTE)&tag, 4); } FX_BYTE digest[16]; CRYPT_MD5Finish(md5, digest); FX_DWORD copy_len = keylen; if (copy_len > sizeof(digest)) { copy_len = sizeof(digest); } if (revision >= 3) { for (int i = 0; i < 50; i ++) { CRYPT_MD5Generate(digest, copy_len, digest); } } FXSYS_memset32(key, 0, keylen); FXSYS_memcpy32(key, digest, copy_len); }
void AddInterFormFont(CPDF_Dictionary*& pFormDict, CPDF_Document* pDocument, const CPDF_Font* pFont, CFX_ByteString& csNameTag) { if (!pFont) { return; } if (!pFormDict) { InitInterFormDict(pFormDict, pDocument); } CFX_ByteString csTag; if (FindInterFormFont(pFormDict, pFont, csTag)) { csNameTag = csTag; return; } if (!pFormDict) { InitInterFormDict(pFormDict, pDocument); } CPDF_Dictionary* pDR = pFormDict->GetDict("DR"); if (!pDR) { pDR = new CPDF_Dictionary; pFormDict->SetAt("DR", pDR); } CPDF_Dictionary* pFonts = pDR->GetDict("Font"); if (!pFonts) { pFonts = new CPDF_Dictionary; pDR->SetAt("Font", pFonts); } if (csNameTag.IsEmpty()) { csNameTag = pFont->GetBaseFont(); } csNameTag.Remove(' '); csNameTag = CPDF_InterForm::GenerateNewResourceName(pDR, "Font", 4, csNameTag); pFonts->SetAtReference(csNameTag, pDocument, pFont->GetFontDict()); }
void CPDF_DefaultAppearance::GetFont(CFX_ByteString& csFontNameTag, FX_FLOAT& fFontSize) { csFontNameTag = ""; fFontSize = 0; if (m_csDA.IsEmpty()) { return; } CPDF_SimpleParser syntax(m_csDA); if (syntax.FindTagParam("Tf", 2)) { csFontNameTag = (CFX_ByteString)syntax.GetWord(); csFontNameTag.Delete(0, 1); fFontSize = FX_atof((CFX_ByteString)syntax.GetWord()); } csFontNameTag = PDF_NameDecode(csFontNameTag); }
size_t CPDF_Document::CalculateEncodingDict(int charset, CPDF_Dictionary* pBaseDict) { size_t i; for (i = 0; i < FX_ArraySize(g_FX_CharsetUnicodes); ++i) { if (g_FX_CharsetUnicodes[i].m_Charset == charset) break; } if (i == FX_ArraySize(g_FX_CharsetUnicodes)) return i; CPDF_Dictionary* pEncodingDict = new CPDF_Dictionary(m_pByteStringPool); pEncodingDict->SetNameFor("BaseEncoding", "WinAnsiEncoding"); CPDF_Array* pArray = new CPDF_Array; pArray->AddInteger(128); const uint16_t* pUnicodes = g_FX_CharsetUnicodes[i].m_pUnicodes; for (int j = 0; j < 128; j++) { CFX_ByteString name = PDF_AdobeNameFromUnicode(pUnicodes[j]); pArray->AddName(name.IsEmpty() ? ".notdef" : name); } pEncodingDict->SetFor("Differences", pArray); pBaseDict->SetReferenceFor("Encoding", this, AddIndirectObject(pEncodingDict)); return i; }
CPDF_Font* GetInterFormFont(CPDF_Dictionary* pFormDict, CPDF_Document* pDocument, CFX_ByteString csNameTag) { CFX_ByteString csAlias = PDF_NameDecode(csNameTag); if (!pFormDict || csAlias.IsEmpty()) { return nullptr; } CPDF_Dictionary* pDR = pFormDict->GetDictBy("DR"); if (!pDR) { return nullptr; } CPDF_Dictionary* pFonts = pDR->GetDictBy("Font"); if (!pFonts) { return nullptr; } CPDF_Dictionary* pElement = pFonts->GetDictBy(csAlias); if (!pElement) { return nullptr; } if (pElement->GetStringBy("Type") == "Font") { return pDocument->LoadFont(pElement); } return nullptr; }
DLLEXPORT void STDCALL FPDF_Widget_Copy(FPDF_DOCUMENT document, FPDF_WIDGET hWidget, FPDF_WIDESTRING wsText, FPDF_DWORD* size) { if (NULL == hWidget || NULL == document) return; CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document; if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && pDocument->GetDocType() != XFA_DOCTYPE_Static) return; IXFA_MenuHandler* pXFAMenuHander = CPDFXFA_App::GetInstance()->GetXFAApp()->GetMenuHandler(); if (pXFAMenuHander == NULL) return; CFX_WideString wsCpText; pXFAMenuHander->Copy((IXFA_Widget*)hWidget, wsCpText); CFX_ByteString bsCpText = wsCpText.UTF16LE_Encode(); int len = bsCpText.GetLength() / sizeof(unsigned short); if (wsText == NULL) { *size = len; return; } int real_size = len < *size ? len : *size; if (real_size > 0) { FXSYS_memcpy((void*)wsText, bsCpText.GetBuffer(real_size * sizeof(unsigned short)), real_size * sizeof(unsigned short)); bsCpText.ReleaseBuffer(real_size * sizeof(unsigned short)); } *size = real_size; }
void FXJS_DefineGlobalConst(v8::Isolate* pIsolate, const wchar_t* sConstName, v8::Local<v8::Value> pDefault) { v8::Isolate::Scope isolate_scope(pIsolate); v8::HandleScope handle_scope(pIsolate); CFX_WideString ws = CFX_WideString(sConstName); CFX_ByteString bsConst = ws.UTF8Encode(); v8::Local<v8::ObjectTemplate> objTemp; v8::Global<v8::ObjectTemplate>& globalObjTemp = _getGlobalObjectTemplate(pIsolate); if (globalObjTemp.IsEmpty()) objTemp = v8::ObjectTemplate::New(pIsolate); else objTemp = v8::Local<v8::ObjectTemplate>::New(pIsolate, globalObjTemp); objTemp->Set( v8::String::NewFromUtf8(pIsolate, bsConst.c_str(), v8::NewStringType::kNormal).ToLocalChecked(), pDefault, v8::ReadOnly); globalObjTemp.Reset(pIsolate, objTemp); }
int32_t CPDF_PageLabel::GetPageByLabel(const CFX_ByteStringC& bsLabel) const { if (!m_pDocument) { return -1; } CPDF_Dictionary* pPDFRoot = m_pDocument->GetRoot(); if (!pPDFRoot) { return -1; } int nPages = m_pDocument->GetPageCount(); CFX_ByteString bsLbl; CFX_ByteString bsOrig = bsLabel; for (int i = 0; i < nPages; i++) { bsLbl = PDF_EncodeText(GetLabel(i)); if (!bsLbl.Compare(bsOrig)) { return i; } } bsLbl = bsOrig; int nPage = FXSYS_atoi(bsLbl); if (nPage > 0 && nPage <= nPages) { return nPage; } return -1; }
void CJS_GlobalData::SetGlobalVariableObject( const FX_CHAR* propname, const CJS_GlobalVariableArray& array) { ASSERT(propname); CFX_ByteString sPropName = propname; sPropName.TrimLeft(); sPropName.TrimRight(); if (sPropName.GetLength() == 0) return; if (CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName)) { pData->data.nType = JS_GLOBALDATA_TYPE_OBJECT; pData->data.objData.Copy(array); } else { CJS_GlobalData_Element* pNewData = new CJS_GlobalData_Element; pNewData->data.sKey = sPropName; pNewData->data.nType = JS_GLOBALDATA_TYPE_OBJECT; pNewData->data.objData.Copy(array); m_arrayGlobalData.Add(pNewData); } }
void FXJS_DefineGlobalMethod(v8::Isolate* pIsolate, const wchar_t* sMethodName, v8::FunctionCallback pMethodCall) { v8::Isolate::Scope isolate_scope(pIsolate); v8::HandleScope handle_scope(pIsolate); CFX_ByteString bsMethodName = CFX_WideString(sMethodName).UTF8Encode(); v8::Local<v8::FunctionTemplate> funTempl = v8::FunctionTemplate::New(pIsolate, pMethodCall); v8::Local<v8::ObjectTemplate> objTemp; v8::Global<v8::ObjectTemplate>& globalObjTemp = _getGlobalObjectTemplate(pIsolate); if (globalObjTemp.IsEmpty()) objTemp = v8::ObjectTemplate::New(pIsolate); else objTemp = v8::Local<v8::ObjectTemplate>::New(pIsolate, globalObjTemp); objTemp->Set( v8::String::NewFromUtf8(pIsolate, bsMethodName.c_str(), v8::NewStringType::kNormal).ToLocalChecked(), funTempl, v8::ReadOnly); globalObjTemp.Reset(pIsolate, objTemp); }
static int32_t GetJapanesePreference(const FX_CHAR* facearr, int weight, int picth_family) { CFX_ByteString face = facearr; if (face.Find("Gothic") >= 0 || face.Find("\x83\x53\x83\x56\x83\x62\x83\x4e") >= 0) { if (face.Find("PGothic") >= 0 || face.Find("\x82\x6f\x83\x53\x83\x56\x83\x62\x83\x4e") >= 0) { return 0; } else { return 1; } } else if (face.Find("Mincho") >= 0 || face.Find("\x96\xbe\x92\xa9") >= 0) { if (face.Find("PMincho") >= 0 || face.Find("\x82\x6f\x96\xbe\x92\xa9") >= 0) { return 2; } else { return 3; } } if (!(picth_family & FXFONT_FF_ROMAN) && weight > 400) { return 0; } return 2; }
int32_t CPWL_FontMap::FindFont(const CFX_ByteString& sFontName, int32_t nCharset) { for (int32_t i=0,sz=m_aData.GetSize(); i<sz; i++) { if (CPWL_FontMap_Data* pData = m_aData.GetAt(i)) { if (nCharset == DEFAULT_CHARSET || nCharset == pData->nCharset) { if (sFontName.IsEmpty() || pData->sFontName == sFontName) return i; } } } return -1; }
int CPDFDoc_Environment::JS_appAlert(const FX_WCHAR* Msg, const FX_WCHAR* Title, FX_UINT Type, FX_UINT Icon) { if (m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->app_alert) { CFX_ByteString bsMsg = CFX_WideString(Msg).UTF16LE_Encode(); CFX_ByteString bsTitle = CFX_WideString(Title).UTF16LE_Encode(); FPDF_WIDESTRING pMsg = (FPDF_WIDESTRING)bsMsg.GetBuffer(bsMsg.GetLength()); FPDF_WIDESTRING pTitle = (FPDF_WIDESTRING)bsTitle.GetBuffer(bsTitle.GetLength()); int ret = m_pInfo->m_pJsPlatform->app_alert(m_pInfo->m_pJsPlatform, pMsg, pTitle, Type, Icon); bsMsg.ReleaseBuffer(); bsTitle.ReleaseBuffer(); return ret; } return -1; }
FX_BOOL CPDF_SecurityHandler::CheckSecurity(int32_t key_len) { CFX_ByteString password = m_pParser->GetPassword(); if (!password.IsEmpty() && CheckPassword(password.raw_str(), password.GetLength(), TRUE, m_EncryptKey, key_len)) { m_bOwnerUnlocked = true; return TRUE; } return CheckPassword(password.raw_str(), password.GetLength(), FALSE, m_EncryptKey, key_len); }
void CPDF_TextRenderer::DrawTextString(CFX_RenderDevice* pDevice, FX_FLOAT origin_x, FX_FLOAT origin_y, CPDF_Font* pFont, FX_FLOAT font_size, const CFX_AffineMatrix* pMatrix, const CFX_ByteString& str, FX_ARGB fill_argb, FX_ARGB stroke_argb, const CFX_GraphStateData* pGraphState, const CPDF_RenderOptions* pOptions) { int nChars = pFont->CountChar(str, str.GetLength()); if (nChars == 0) { return; } FX_DWORD charcode; int offset = 0; FX_DWORD* pCharCodes; FX_FLOAT* pCharPos; if (nChars == 1) { charcode = pFont->GetNextChar(str, offset); pCharCodes = (FX_DWORD*)(FX_UINTPTR)charcode; pCharPos = NULL; } else { pCharCodes = FX_Alloc(FX_DWORD, nChars); pCharPos = FX_Alloc(FX_FLOAT, nChars - 1); FX_FLOAT cur_pos = 0; for (int i = 0; i < nChars; i ++) { pCharCodes[i] = pFont->GetNextChar(str, offset); if (i) { pCharPos[i - 1] = cur_pos; } cur_pos += pFont->GetCharWidthF(pCharCodes[i]) * font_size / 1000; } } CFX_AffineMatrix matrix; if (pMatrix) { matrix = *pMatrix; } matrix.e = origin_x; matrix.f = origin_y; if (pFont->GetFontType() == PDFFONT_TYPE3) ; else if (stroke_argb == 0) { DrawNormalText(pDevice, nChars, pCharCodes, pCharPos, pFont, font_size, &matrix, fill_argb, pOptions); } else DrawTextPath(pDevice, nChars, pCharCodes, pCharPos, pFont, font_size, &matrix, NULL, pGraphState, fill_argb, stroke_argb, NULL); if (nChars > 1) { FX_Free(pCharCodes); FX_Free(pCharPos); } }