diff options
Diffstat (limited to 'xfa/fxfa')
-rw-r--r-- | xfa/fxfa/fm2js/xfa_fm2jscontext.cpp | 73 | ||||
-rw-r--r-- | xfa/fxfa/parser/cscript_eventpseudomodel.cpp | 2 | ||||
-rw-r--r-- | xfa/fxfa/parser/cscript_hostpseudomodel.cpp | 13 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_node.cpp | 88 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_object.cpp | 7 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_scriptcontext.cpp | 8 |
6 files changed, 71 insertions, 120 deletions
diff --git a/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp b/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp index ba65beffc4..e8cb2d0279 100644 --- a/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp +++ b/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp @@ -2026,7 +2026,7 @@ bool CXFA_FM2JSContext::IsoDate2Local(CFXJSE_Value* pThis, CFX_WideString wsRet; widgetValue.FormatPatterns(wsRet, wsFormat, pLocale, XFA_VALUEPICTURE_Display); - strLocalDate = FX_UTF8Encode(wsRet.c_str(), wsRet.GetLength()); + strLocalDate = wsRet.UTF8Encode(); return true; } @@ -2065,7 +2065,7 @@ bool CXFA_FM2JSContext::IsoTime2Local(CFXJSE_Value* pThis, CFX_WideString wsRet; widgetValue.FormatPatterns(wsRet, wsFormat, pLocale, XFA_VALUEPICTURE_Display); - strLocalTime = FX_UTF8Encode(wsRet.c_str(), wsRet.GetLength()); + strLocalTime = wsRet.UTF8Encode(); return true; } @@ -2104,7 +2104,7 @@ bool CXFA_FM2JSContext::GetGMTTime(CFXJSE_Value* pThis, CFX_WideString wsRet; widgetValue.FormatPatterns(wsRet, wsFormat, pLocale, XFA_VALUEPICTURE_Display); - strGMTTime = FX_UTF8Encode(wsRet.c_str(), wsRet.GetLength()); + strGMTTime = wsRet.UTF8Encode(); return true; } @@ -2213,7 +2213,7 @@ void CXFA_FM2JSContext::GetLocalDateFormat(CFXJSE_Value* pThis, pLocale->GetDateTimeSymbols(wsSymbols); AlternateDateTimeSymbols(strRet, wsSymbols, g_sAltTable_Date); } - strFormat = FX_UTF8Encode(strRet.c_str(), strRet.GetLength()); + strFormat = strRet.UTF8Encode(); } // static @@ -2264,7 +2264,7 @@ void CXFA_FM2JSContext::GetLocalTimeFormat(CFXJSE_Value* pThis, pLocale->GetDateTimeSymbols(wsSymbols); AlternateDateTimeSymbols(strRet, wsSymbols, g_sAltTable_Time); } - strFormat = FX_UTF8Encode(strRet.c_str(), strRet.GetLength()); + strFormat = strRet.UTF8Encode(); } // static @@ -2959,10 +2959,8 @@ void CXFA_FM2JSContext::Eval(CFXJSE_Value* pThis, CFXJSE_Context::Create(pIsolate, nullptr, nullptr)); auto returnValue = pdfium::MakeUnique<CFXJSE_Value>(pIsolate); - CFX_WideString javaScript(wsJavaScriptBuf.AsStringC()); - pNewContext->ExecuteScript( - FX_UTF8Encode(javaScript.c_str(), javaScript.GetLength()).c_str(), - returnValue.get()); + pNewContext->ExecuteScript(FX_UTF8Encode(wsJavaScriptBuf.AsStringC()).c_str(), + returnValue.get()); args.GetReturnValue()->Assign(returnValue.get()); } @@ -3428,11 +3426,8 @@ void CXFA_FM2JSContext::DecodeURL(const CFX_ByteStringC& szURLString, ++i; } wsResultBuf.AppendChar(0); - szResultString.Clear(); - szResultString << FX_UTF8Encode(wsResultBuf.GetBuffer(), - wsResultBuf.GetLength()) - .AsStringC(); + szResultString << FX_UTF8Encode(wsResultBuf.AsStringC()); } // static @@ -3508,9 +3503,7 @@ void CXFA_FM2JSContext::DecodeHTML(const CFX_ByteStringC& szHTMLString, wsResultBuf.AppendChar(0); szResultString.Clear(); - szResultString << FX_UTF8Encode(wsResultBuf.GetBuffer(), - wsResultBuf.GetLength()) - .AsStringC(); + szResultString << FX_UTF8Encode(wsResultBuf.AsStringC()); } // static @@ -3610,10 +3603,8 @@ void CXFA_FM2JSContext::DecodeXML(const CFX_ByteStringC& szXMLString, iCode = 0; } wsXMLBuf.AppendChar(0); - szResultString.Clear(); - szResultString << FX_UTF8Encode(wsXMLBuf.GetBuffer(), wsXMLBuf.GetLength()) - .AsStringC(); + szResultString << FX_UTF8Encode(wsXMLBuf.AsStringC()); } // static @@ -3761,9 +3752,7 @@ void CXFA_FM2JSContext::EncodeURL(const CFX_ByteStringC& szURLString, } wsResultBuf.AppendChar(0); szResultBuf.Clear(); - - szResultBuf << FX_UTF8Encode(wsResultBuf.GetBuffer(), wsResultBuf.GetLength()) - .AsStringC(); + szResultBuf << FX_UTF8Encode(wsResultBuf.AsStringC()); } // static @@ -3813,9 +3802,7 @@ void CXFA_FM2JSContext::EncodeHTML(const CFX_ByteStringC& szHTMLString, } wsResultBuf.AppendChar(0); szResultBuf.Clear(); - - szResultBuf << FX_UTF8Encode(wsResultBuf.GetBuffer(), wsResultBuf.GetLength()) - .AsStringC(); + szResultBuf << FX_UTF8Encode(wsResultBuf.AsStringC()); } // static @@ -3886,9 +3873,7 @@ void CXFA_FM2JSContext::EncodeXML(const CFX_ByteStringC& szXMLString, } wsResultBuf.AppendChar(0); szResultBuf.Clear(); - - szResultBuf << FX_UTF8Encode(wsResultBuf.GetBuffer(), wsResultBuf.GetLength()) - .AsStringC(); + szResultBuf << FX_UTF8Encode(wsResultBuf.AsStringC()); } // static @@ -4009,8 +3994,7 @@ void CXFA_FM2JSContext::Format(CFXJSE_Value* pThis, return; } - args.GetReturnValue()->SetString( - FX_UTF8Encode(wsRet.c_str(), wsRet.GetLength()).AsStringC()); + args.GetReturnValue()->SetString(wsRet.UTF8Encode().AsStringC()); } // static @@ -4091,8 +4075,7 @@ void CXFA_FM2JSContext::Lower(CFXJSE_Value* pThis, lowStringBuf.AppendChar(0); args.GetReturnValue()->SetString( - FX_UTF8Encode(lowStringBuf.GetBuffer(), lowStringBuf.GetLength()) - .AsStringC()); + FX_UTF8Encode(lowStringBuf.AsStringC()).AsStringC()); } // static @@ -4156,7 +4139,7 @@ void CXFA_FM2JSContext::Parse(CFXJSE_Value* pThis, return; } args.GetReturnValue()->SetString( - FX_UTF8Encode(localeValue.GetValue()).AsStringC()); + localeValue.GetValue().UTF8Encode().AsStringC()); return; } @@ -4173,7 +4156,7 @@ void CXFA_FM2JSContext::Parse(CFXJSE_Value* pThis, return; } args.GetReturnValue()->SetString( - FX_UTF8Encode(localeValue.GetValue()).AsStringC()); + localeValue.GetValue().UTF8Encode().AsStringC()); return; } case XFA_VT_DATE: { @@ -4185,7 +4168,7 @@ void CXFA_FM2JSContext::Parse(CFXJSE_Value* pThis, return; } args.GetReturnValue()->SetString( - FX_UTF8Encode(localeValue.GetValue()).AsStringC()); + localeValue.GetValue().UTF8Encode().AsStringC()); return; } case XFA_VT_TIME: { @@ -4197,7 +4180,7 @@ void CXFA_FM2JSContext::Parse(CFXJSE_Value* pThis, return; } args.GetReturnValue()->SetString( - FX_UTF8Encode(localeValue.GetValue()).AsStringC()); + localeValue.GetValue().UTF8Encode().AsStringC()); return; } case XFA_VT_TEXT: { @@ -4209,7 +4192,7 @@ void CXFA_FM2JSContext::Parse(CFXJSE_Value* pThis, return; } args.GetReturnValue()->SetString( - FX_UTF8Encode(localeValue.GetValue()).AsStringC()); + localeValue.GetValue().UTF8Encode().AsStringC()); return; } case XFA_VT_FLOAT: { @@ -4241,7 +4224,7 @@ void CXFA_FM2JSContext::Parse(CFXJSE_Value* pThis, return; } args.GetReturnValue()->SetString( - FX_UTF8Encode(localeValue2.GetValue()).AsStringC()); + localeValue2.GetValue().UTF8Encode().AsStringC()); return; } } @@ -4640,8 +4623,7 @@ void CXFA_FM2JSContext::Upper(CFXJSE_Value* pThis, upperStringBuf.AppendChar(0); args.GetReturnValue()->SetString( - FX_UTF8Encode(upperStringBuf.GetBuffer(), upperStringBuf.GetLength()) - .AsStringC()); + FX_UTF8Encode(upperStringBuf.AsStringC()).AsStringC()); } // static @@ -4931,10 +4913,7 @@ void CXFA_FM2JSContext::Post(CFXJSE_Value* pThis, pContext->ThrowServerDeniedException(); return; } - - args.GetReturnValue()->SetString( - FX_UTF8Encode(decodedResponse.c_str(), decodedResponse.GetLength()) - .AsStringC()); + args.GetReturnValue()->SetString(decodedResponse.UTF8Encode().AsStringC()); } // static @@ -5680,9 +5659,8 @@ void CXFA_FM2JSContext::eval_translation(CFXJSE_Value* pThis, return; } - CFX_WideString javaScript = wsJavaScriptBuf.MakeString(); args.GetReturnValue()->SetString( - FX_UTF8Encode(javaScript.c_str(), javaScript.GetLength()).AsStringC()); + FX_UTF8Encode(wsJavaScriptBuf.AsStringC()).AsStringC()); } // static @@ -6439,6 +6417,5 @@ void CXFA_FM2JSContext::ThrowException(const FX_WCHAR* str, ...) const { va_start(arg_ptr, str); wsMessage.FormatV(str, arg_ptr); va_end(arg_ptr); - FXJSE_ThrowMessage( - FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC()); + FXJSE_ThrowMessage(wsMessage.UTF8Encode().AsStringC()); } diff --git a/xfa/fxfa/parser/cscript_eventpseudomodel.cpp b/xfa/fxfa/parser/cscript_eventpseudomodel.cpp index 8a7d80b5d3..8cfedd2998 100644 --- a/xfa/fxfa/parser/cscript_eventpseudomodel.cpp +++ b/xfa/fxfa/parser/cscript_eventpseudomodel.cpp @@ -25,7 +25,7 @@ void StringProperty(CFXJSE_Value* pValue, wsValue = pValue->ToWideString(); return; } - pValue->SetString(FX_UTF8Encode(wsValue).AsStringC()); + pValue->SetString(wsValue.UTF8Encode().AsStringC()); } void InterProperty(CFXJSE_Value* pValue, int32_t& iValue, bool bSetting) { diff --git a/xfa/fxfa/parser/cscript_hostpseudomodel.cpp b/xfa/fxfa/parser/cscript_hostpseudomodel.cpp index eb8177ebf6..a06e02f56d 100644 --- a/xfa/fxfa/parser/cscript_hostpseudomodel.cpp +++ b/xfa/fxfa/parser/cscript_hostpseudomodel.cpp @@ -89,7 +89,7 @@ void CScript_HostPseudoModel::Language(CFXJSE_Value* pValue, return; } pValue->SetString( - FX_UTF8Encode(pNotify->GetAppProvider()->GetLanguage()).AsStringC()); + pNotify->GetAppProvider()->GetLanguage().UTF8Encode().AsStringC()); } void CScript_HostPseudoModel::NumPages(CFXJSE_Value* pValue, @@ -118,8 +118,9 @@ void CScript_HostPseudoModel::Platform(CFXJSE_Value* pValue, return; } pValue->SetString( - FX_UTF8Encode(pNotify->GetAppProvider()->GetPlatform()).AsStringC()); + pNotify->GetAppProvider()->GetPlatform().UTF8Encode().AsStringC()); } + void CScript_HostPseudoModel::Title(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { @@ -137,7 +138,7 @@ void CScript_HostPseudoModel::Title(CFXJSE_Value* pValue, } CFX_WideString wsTitle; pNotify->GetDocEnvironment()->GetTitle(hDoc, wsTitle); - pValue->SetString(FX_UTF8Encode(wsTitle).AsStringC()); + pValue->SetString(wsTitle.UTF8Encode().AsStringC()); } void CScript_HostPseudoModel::ValidationsEnabled(CFXJSE_Value* pValue, @@ -199,7 +200,7 @@ void CScript_HostPseudoModel::Name(CFXJSE_Value* pValue, return; } pValue->SetString( - FX_UTF8Encode(pNotify->GetAppProvider()->GetAppName()).AsStringC()); + pNotify->GetAppProvider()->GetAppName().UTF8Encode().AsStringC()); } void CScript_HostPseudoModel::GotoURL(CFXJSE_Arguments* pArguments) { @@ -306,7 +307,7 @@ void CScript_HostPseudoModel::Response(CFXJSE_Arguments* pArguments) { wsQuestion, wsTitle, wsDefaultAnswer, bMark); CFXJSE_Value* pValue = pArguments->GetReturnValue(); if (pValue) - pValue->SetString(FX_UTF8Encode(wsAnswer).AsStringC()); + pValue->SetString(wsAnswer.UTF8Encode().AsStringC()); } void CScript_HostPseudoModel::DocumentInBatch(CFXJSE_Arguments* pArguments) { @@ -674,7 +675,7 @@ void CScript_HostPseudoModel::CurrentDateTime(CFXJSE_Arguments* pArguments) { CFX_WideString wsDataTime = pNotify->GetCurrentDateTime(); CFXJSE_Value* pValue = pArguments->GetReturnValue(); if (pValue) - pValue->SetString(FX_UTF8Encode(wsDataTime).AsStringC()); + pValue->SetString(wsDataTime.UTF8Encode().AsStringC()); } void CScript_HostPseudoModel::ThrowSetLanguageException() const { diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp index 0fc114be10..1e508969d1 100644 --- a/xfa/fxfa/parser/cxfa_node.cpp +++ b/xfa/fxfa/parser/cxfa_node.cpp @@ -1109,8 +1109,7 @@ void CXFA_Node::Script_TreeClass_Nodes(CFXJSE_Value* pValue, return; if (bSetting) { CFX_WideString wsMessage = L"Unable to set "; - FXJSE_ThrowMessage( - FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC()); + FXJSE_ThrowMessage(wsMessage.UTF8Encode().AsStringC()); } else { CXFA_AttachNodeList* pNodeList = new CXFA_AttachNodeList(m_pDocument, this); pValue->SetObject(pNodeList, pScriptContext->GetJseNormalClass()); @@ -1124,7 +1123,6 @@ void CXFA_Node::Script_TreeClass_ClassAll(CFXJSE_Value* pValue, ThrowInvalidPropertyException(); return; } - uint32_t dwFlag = XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_ALL; CFX_WideString wsExpression = L"#" + GetClassName() + L"[*]"; Script_Som_ResolveNodeList(pValue, wsExpression, dwFlag); @@ -1174,7 +1172,7 @@ void CXFA_Node::Script_TreeClass_SomExpression(CFXJSE_Value* pValue, } CFX_WideString wsSOMExpression; GetSOMExpression(wsSOMExpression); - pValue->SetString(FX_UTF8Encode(wsSOMExpression).AsStringC()); + pValue->SetString(wsSOMExpression.UTF8Encode().AsStringC()); } void CXFA_Node::Script_NodeClass_ApplyXSL(CFXJSE_Arguments* pArguments) { @@ -1238,7 +1236,7 @@ void CXFA_Node::Script_NodeClass_GetAttribute(CFXJSE_Arguments* pArguments) { GetAttribute(wsExpression.AsStringC(), wsValue); CFXJSE_Value* pValue = pArguments->GetReturnValue(); if (pValue) - pValue->SetString(FX_UTF8Encode(wsValue).AsStringC()); + pValue->SetString(wsValue.UTF8Encode().AsStringC()); } void CXFA_Node::Script_NodeClass_GetElement(CFXJSE_Arguments* pArguments) { @@ -1508,7 +1506,7 @@ void CXFA_Node::Script_NodeClass_Ns(CFXJSE_Value* pValue, CFX_WideString wsNameSpace; TryNamespace(wsNameSpace); - pValue->SetString(FX_UTF8Encode(wsNameSpace).AsStringC()); + pValue->SetString(wsNameSpace.UTF8Encode().AsStringC()); } void CXFA_Node::Script_NodeClass_Model(CFXJSE_Value* pValue, @@ -1858,8 +1856,7 @@ void CXFA_Node::Script_Attribute_String(CFXJSE_Value* pValue, } else { CFX_WideString wsValue; GetAttribute(eAttribute, wsValue); - pValue->SetString( - FX_UTF8Encode(wsValue.c_str(), wsValue.GetLength()).AsStringC()); + pValue->SetString(wsValue.UTF8Encode().AsStringC()); } } @@ -1873,8 +1870,7 @@ void CXFA_Node::Script_Attribute_StringRead(CFXJSE_Value* pValue, CFX_WideString wsValue; GetAttribute(eAttribute, wsValue); - pValue->SetString( - FX_UTF8Encode(wsValue.c_str(), wsValue.GetLength()).AsStringC()); + pValue->SetString(wsValue.UTF8Encode().AsStringC()); } void CXFA_Node::Script_WsdlConnection_Execute(CFXJSE_Arguments* pArguments) { @@ -1952,7 +1948,7 @@ void CXFA_Node::Script_Som_Message(CFXJSE_Value* pValue, default: break; } - pValue->SetString(FX_UTF8Encode(wsMessage).AsStringC()); + pValue->SetString(wsMessage.UTF8Encode().AsStringC()); } } @@ -2038,8 +2034,7 @@ void CXFA_Node::Script_Som_DefaultValue(CFXJSE_Value* pValue, CFX_Decimal decimal(content.AsStringC()); pValue->SetFloat((FX_FLOAT)(double)decimal); } else { - pValue->SetString( - FX_UTF8Encode(content.c_str(), content.GetLength()).AsStringC()); + pValue->SetString(content.UTF8Encode().AsStringC()); } } } @@ -2057,8 +2052,7 @@ void CXFA_Node::Script_Som_DefaultValue_Read(CFXJSE_Value* pValue, pValue->SetNull(); return; } - pValue->SetString( - FX_UTF8Encode(content.c_str(), content.GetLength()).AsStringC()); + pValue->SetString(content.UTF8Encode().AsStringC()); } void CXFA_Node::Script_Boolean_Value(CFXJSE_Value* pValue, @@ -2109,7 +2103,7 @@ void CXFA_Node::Script_Som_BorderColor(CFXJSE_Value* pValue, ArgbDecode(color, a, r, g, b); CFX_WideString strColor; strColor.Format(L"%d,%d,%d", r, g, b); - pValue->SetString(FX_UTF8Encode(strColor).AsStringC()); + pValue->SetString(strColor.UTF8Encode().AsStringC()); } } @@ -2134,7 +2128,7 @@ void CXFA_Node::Script_Som_BorderWidth(CFXJSE_Value* pValue, CXFA_Edge edge = border.GetEdge(0); CXFA_Measurement thickness = edge.GetMSThickness(); thickness.ToString(wsThickness); - pValue->SetString(FX_UTF8Encode(wsThickness).AsStringC()); + pValue->SetString(wsThickness.UTF8Encode().AsStringC()); } } @@ -2167,7 +2161,7 @@ void CXFA_Node::Script_Som_FillColor(CFXJSE_Value* pValue, ArgbDecode(color, a, r, g, b); CFX_WideString wsColor; wsColor.Format(L"%d,%d,%d", r, g, b); - pValue->SetString(FX_UTF8Encode(wsColor).AsStringC()); + pValue->SetString(wsColor.UTF8Encode().AsStringC()); } } @@ -2204,12 +2198,10 @@ void CXFA_Node::Script_Draw_DefaultValue(CFXJSE_Value* pValue, } } else { CFX_WideString content = GetScriptContent(true); - if (content.IsEmpty()) { + if (content.IsEmpty()) pValue->SetNull(); - } else { - pValue->SetString( - FX_UTF8Encode(content.c_str(), content.GetLength()).AsStringC()); - } + else + pValue->SetString(content.UTF8Encode().AsStringC()); } } @@ -2258,8 +2250,7 @@ void CXFA_Node::Script_Field_DefaultValue(CFXJSE_Value* pValue, if (pNode && pNode->GetElementType() == XFA_Element::Decimal) { if (pUIChild->GetElementType() == XFA_Element::NumericEdit && (pNode->GetInteger(XFA_ATTRIBUTE_FracDigits) == -1)) { - pValue->SetString( - FX_UTF8Encode(content.c_str(), content.GetLength()).AsStringC()); + pValue->SetString(content.UTF8Encode().AsStringC()); } else { CFX_Decimal decimal(content.AsStringC()); pValue->SetFloat((FX_FLOAT)(double)decimal); @@ -2272,8 +2263,7 @@ void CXFA_Node::Script_Field_DefaultValue(CFXJSE_Value* pValue, CFX_Decimal decimal(content.AsStringC()); pValue->SetFloat((FX_FLOAT)(double)decimal); } else { - pValue->SetString( - FX_UTF8Encode(content.c_str(), content.GetLength()).AsStringC()); + pValue->SetString(content.UTF8Encode().AsStringC()); } } } @@ -2291,7 +2281,7 @@ void CXFA_Node::Script_Field_EditValue(CFXJSE_Value* pValue, } else { CFX_WideString wsValue; pWidgetData->GetValue(wsValue, XFA_VALUEPICTURE_Edit); - pValue->SetString(FX_UTF8Encode(wsValue).AsStringC()); + pValue->SetString(wsValue.UTF8Encode().AsStringC()); } } @@ -2323,7 +2313,7 @@ void CXFA_Node::Script_Som_FontColor(CFXJSE_Value* pValue, ArgbDecode(color, a, r, g, b); CFX_WideString wsColor; wsColor.Format(L"%d,%d,%d", r, g, b); - pValue->SetString(FX_UTF8Encode(wsColor).AsStringC()); + pValue->SetString(wsColor.UTF8Encode().AsStringC()); } } @@ -2345,7 +2335,7 @@ void CXFA_Node::Script_Field_FormattedValue(CFXJSE_Value* pValue, } else { CFX_WideString wsValue; pWidgetData->GetValue(wsValue, XFA_VALUEPICTURE_Display); - pValue->SetString(FX_UTF8Encode(wsValue).AsStringC()); + pValue->SetString(wsValue.UTF8Encode().AsStringC()); } } @@ -2366,7 +2356,7 @@ void CXFA_Node::Script_Som_Mandatory(CFXJSE_Value* pValue, CFX_WideString wsValue; if (pInfo) wsValue = pInfo->pName; - pValue->SetString(FX_UTF8Encode(wsValue).AsStringC()); + pValue->SetString(wsValue.UTF8Encode().AsStringC()); } } @@ -2477,13 +2467,11 @@ void CXFA_Node::Script_Field_GetSaveItem(CFXJSE_Arguments* pArguments) { return; } CFX_WideString wsValue; - bool bHasItem = pWidgetData->GetChoiceListItem(wsValue, iIndex, true); - if (bHasItem) { - pArguments->GetReturnValue()->SetString( - FX_UTF8Encode(wsValue.c_str(), wsValue.GetLength()).AsStringC()); - } else { + if (!pWidgetData->GetChoiceListItem(wsValue, iIndex, true)) { pArguments->GetReturnValue()->SetNull(); + return; } + pArguments->GetReturnValue()->SetString(wsValue.UTF8Encode().AsStringC()); } void CXFA_Node::Script_Field_BoundItem(CFXJSE_Arguments* pArguments) { @@ -2502,7 +2490,7 @@ void CXFA_Node::Script_Field_BoundItem(CFXJSE_Arguments* pArguments) { pWidgetData->GetItemValue(wsValue.AsStringC(), wsBoundValue); CFXJSE_Value* pValue = pArguments->GetReturnValue(); if (pValue) - pValue->SetString(FX_UTF8Encode(wsBoundValue).AsStringC()); + pValue->SetString(wsBoundValue.UTF8Encode().AsStringC()); } void CXFA_Node::Script_Field_GetItemState(CFXJSE_Arguments* pArguments) { @@ -2554,13 +2542,11 @@ void CXFA_Node::Script_Field_GetDisplayItem(CFXJSE_Arguments* pArguments) { return; } CFX_WideString wsValue; - bool bHasItem = pWidgetData->GetChoiceListItem(wsValue, iIndex, false); - if (bHasItem) { - pArguments->GetReturnValue()->SetString( - FX_UTF8Encode(wsValue.c_str(), wsValue.GetLength()).AsStringC()); - } else { + if (!pWidgetData->GetChoiceListItem(wsValue, iIndex, false)) { pArguments->GetReturnValue()->SetNull(); + return; } + pArguments->GetReturnValue()->SetString(wsValue.UTF8Encode().AsStringC()); } void CXFA_Node::Script_Field_SetItemState(CFXJSE_Arguments* pArguments) { @@ -2646,7 +2632,7 @@ void CXFA_Node::Script_ExclGroup_DefaultAndRawValue(CFXJSE_Value* pValue, if (wsValue.IsEmpty() && curVersion >= XFA_VERSION_300) { pValue->SetNull(); } else { - pValue->SetString(FX_UTF8Encode(wsValue).AsStringC()); + pValue->SetString(wsValue.UTF8Encode().AsStringC()); } } } @@ -2814,9 +2800,7 @@ void CXFA_Node::Script_Subform_Locale(CFXJSE_Value* pValue, } else { CFX_WideString wsLocaleName; GetLocaleName(wsLocaleName); - pValue->SetString( - FX_UTF8Encode(wsLocaleName.c_str(), wsLocaleName.GetLength()) - .AsStringC()); + pValue->SetString(wsLocaleName.UTF8Encode().AsStringC()); } } @@ -3415,11 +3399,9 @@ void CXFA_Node::Script_Form_Checksum(CFXJSE_Value* pValue, SetAttribute(XFA_ATTRIBUTE_Checksum, pValue->ToWideString().AsStringC()); return; } - CFX_WideString wsChecksum; GetAttribute(XFA_ATTRIBUTE_Checksum, wsChecksum, false); - pValue->SetString( - FX_UTF8Encode(wsChecksum.c_str(), wsChecksum.GetLength()).AsStringC()); + pValue->SetString(wsChecksum.UTF8Encode().AsStringC()); } void CXFA_Node::Script_Packet_GetAttribute(CFXJSE_Arguments* pArguments) { @@ -3427,7 +3409,6 @@ void CXFA_Node::Script_Packet_GetAttribute(CFXJSE_Arguments* pArguments) { ThrowParamCountMismatchException(L"getAttribute"); return; } - CFX_ByteString bsAttributeName = pArguments->GetUTF8String(0); CFX_WideString wsAttributeValue; CFDE_XMLNode* pXMLNode = GetXMLMappingNode(); @@ -3437,8 +3418,7 @@ void CXFA_Node::Script_Packet_GetAttribute(CFXJSE_Arguments* pArguments) { wsAttributeValue); } pArguments->GetReturnValue()->SetString( - FX_UTF8Encode(wsAttributeValue.c_str(), wsAttributeValue.GetLength()) - .AsStringC()); + wsAttributeValue.UTF8Encode().AsStringC()); } void CXFA_Node::Script_Packet_SetAttribute(CFXJSE_Arguments* pArguments) { @@ -3446,7 +3426,6 @@ void CXFA_Node::Script_Packet_SetAttribute(CFXJSE_Arguments* pArguments) { ThrowParamCountMismatchException(L"setAttribute"); return; } - CFX_ByteString bsValue = pArguments->GetUTF8String(0); CFX_ByteString bsName = pArguments->GetUTF8String(1); CFDE_XMLNode* pXMLNode = GetXMLMappingNode(); @@ -3492,8 +3471,7 @@ void CXFA_Node::Script_Packet_Content(CFXJSE_Value* pValue, CFDE_XMLElement* pXMLElement = static_cast<CFDE_XMLElement*>(pXMLNode); pXMLElement->GetTextData(wsTextData); } - pValue->SetString( - FX_UTF8Encode(wsTextData.c_str(), wsTextData.GetLength()).AsStringC()); + pValue->SetString(wsTextData.UTF8Encode().AsStringC()); } } diff --git a/xfa/fxfa/parser/cxfa_object.cpp b/xfa/fxfa/parser/cxfa_object.cpp index 45e34424aa..c8cd354b48 100644 --- a/xfa/fxfa/parser/cxfa_object.cpp +++ b/xfa/fxfa/parser/cxfa_object.cpp @@ -42,9 +42,7 @@ void CXFA_Object::Script_ObjectClass_ClassName(CFXJSE_Value* pValue, ThrowInvalidPropertyException(); return; } - CFX_WideStringC className = GetClassName(); - pValue->SetString( - FX_UTF8Encode(className.c_str(), className.GetLength()).AsStringC()); + pValue->SetString(FX_UTF8Encode(GetClassName()).AsStringC()); } void CXFA_Object::ThrowInvalidPropertyException() const { @@ -71,6 +69,5 @@ void CXFA_Object::ThrowException(const FX_WCHAR* str, ...) const { va_start(arg_ptr, str); wsMessage.FormatV(str, arg_ptr); va_end(arg_ptr); - FXJSE_ThrowMessage( - FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC()); + FXJSE_ThrowMessage(wsMessage.UTF8Encode().AsStringC()); } diff --git a/xfa/fxfa/parser/cxfa_scriptcontext.cpp b/xfa/fxfa/parser/cxfa_scriptcontext.cpp index a54ef99af5..584cd76bed 100644 --- a/xfa/fxfa/parser/cxfa_scriptcontext.cpp +++ b/xfa/fxfa/parser/cxfa_scriptcontext.cpp @@ -161,10 +161,9 @@ bool CXFA_ScriptContext::RunScript(XFA_SCRIPTLANGTYPE eScriptType, hRetValue->SetUndefined(); return false; } - btScript = - FX_UTF8Encode(wsJavaScript.GetBuffer(), wsJavaScript.GetLength()); + btScript = FX_UTF8Encode(wsJavaScript.AsStringC()); } else { - btScript = FX_UTF8Encode(wsScript.c_str(), wsScript.GetLength()); + btScript = FX_UTF8Encode(wsScript); } CXFA_Object* pOriginalObject = m_pThisObject; m_pThisObject = pThisObject; @@ -491,8 +490,7 @@ bool CXFA_ScriptContext::RunVariablesScript(CXFA_Node* pScriptNode) { if (!pTextNode->TryCData(XFA_ATTRIBUTE_Value, wsScript)) return false; - CFX_ByteString btScript = - FX_UTF8Encode(wsScript.c_str(), wsScript.GetLength()); + CFX_ByteString btScript = FX_UTF8Encode(wsScript); std::unique_ptr<CFXJSE_Value> hRetValue(new CFXJSE_Value(m_pIsolate)); CXFA_Node* pThisObject = pParent->GetNodeItem(XFA_NODEITEM_Parent); CFXJSE_Context* pVariablesContext = |