summaryrefslogtreecommitdiff
path: root/xfa/fxfa
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fxfa')
-rw-r--r--xfa/fxfa/app/xfa_ffwidgetacc.cpp9
-rw-r--r--xfa/fxfa/fm2js/xfa_fm2jscontext.cpp147
-rw-r--r--xfa/fxfa/parser/xfa_object_imp.cpp140
-rw-r--r--xfa/fxfa/parser/xfa_script_eventpseudomodel.cpp4
-rw-r--r--xfa/fxfa/parser/xfa_script_hostpseudomodel.cpp21
5 files changed, 105 insertions, 216 deletions
diff --git a/xfa/fxfa/app/xfa_ffwidgetacc.cpp b/xfa/fxfa/app/xfa_ffwidgetacc.cpp
index 3301bed50e..59e3805991 100644
--- a/xfa/fxfa/app/xfa_ffwidgetacc.cpp
+++ b/xfa/fxfa/app/xfa_ffwidgetacc.cpp
@@ -659,12 +659,9 @@ int32_t CXFA_WidgetAcc::ExecuteScript(CXFA_Script script,
if (pEventParam->m_eType == XFA_EVENT_Calculate ||
pEventParam->m_eType == XFA_EVENT_InitCalculate) {
if (!pTmpRetValue->IsUndefined()) {
- if (!pTmpRetValue->IsNull()) {
- CFX_ByteString bsString;
- pTmpRetValue->ToString(bsString);
- pEventParam->m_wsResult =
- CFX_WideString::FromUTF8(bsString.AsStringC());
- }
+ if (!pTmpRetValue->IsNull())
+ pEventParam->m_wsResult = pTmpRetValue->ToWideString();
+
iRet = XFA_EVENTERROR_Success;
} else {
iRet = XFA_EVENTERROR_Error;
diff --git a/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp b/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp
index fded5eed85..42aa5279b7 100644
--- a/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp
+++ b/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp
@@ -575,14 +575,12 @@ void CXFA_FM2JSContext::Avg(CFXJSE_Value* pThis,
uCount++;
}
} else {
- CFX_ByteString propertyStr;
- propertyValue->ToString(propertyStr);
for (int32_t j = 2; j < iLength; j++) {
argValue->GetObjectPropertyByIdx(j, jsObjectValue.get());
std::unique_ptr<CFXJSE_Value> newPropertyValue(
new CFXJSE_Value(pIsolate));
- jsObjectValue->GetObjectProperty(propertyStr.AsStringC(),
- newPropertyValue.get());
+ jsObjectValue->GetObjectProperty(
+ propertyValue->ToString().AsStringC(), newPropertyValue.get());
if (newPropertyValue->IsNull())
continue;
@@ -656,12 +654,10 @@ void CXFA_FM2JSContext::Count(CFXJSE_Value* pThis,
iCount++;
}
} else {
- CFX_ByteString propertyStr;
- propertyValue->ToString(propertyStr);
for (int32_t j = 2; j < iLength; j++) {
argValue->GetObjectPropertyByIdx(j, jsObjectValue.get());
- jsObjectValue->GetObjectProperty(propertyStr.AsStringC(),
- newPropertyValue.get());
+ jsObjectValue->GetObjectProperty(
+ propertyValue->ToString().AsStringC(), newPropertyValue.get());
iCount += newPropertyValue->IsNull() ? 0 : 1;
}
}
@@ -738,12 +734,10 @@ void CXFA_FM2JSContext::Max(CFXJSE_Value* pThis,
dMaxValue = (uCount == 1) ? dValue : std::max(dMaxValue, dValue);
}
} else {
- CFX_ByteString propertyStr;
- propertyValue->ToString(propertyStr);
for (int32_t j = 2; j < iLength; j++) {
argValue->GetObjectPropertyByIdx(j, jsObjectValue.get());
- jsObjectValue->GetObjectProperty(propertyStr.AsStringC(),
- newPropertyValue.get());
+ jsObjectValue->GetObjectProperty(
+ propertyValue->ToString().AsStringC(), newPropertyValue.get());
if (newPropertyValue->IsNull())
continue;
@@ -816,12 +810,10 @@ void CXFA_FM2JSContext::Min(CFXJSE_Value* pThis,
dMinValue = uCount == 1 ? dValue : std::min(dMinValue, dValue);
}
} else {
- CFX_ByteString propertyStr;
- propertyValue->ToString(propertyStr);
for (int32_t j = 2; j < iLength; j++) {
argValue->GetObjectPropertyByIdx(j, jsObjectValue.get());
- jsObjectValue->GetObjectProperty(propertyStr.AsStringC(),
- newPropertyValue.get());
+ jsObjectValue->GetObjectProperty(
+ propertyValue->ToString().AsStringC(), newPropertyValue.get());
if (newPropertyValue->IsNull())
continue;
@@ -981,12 +973,10 @@ void CXFA_FM2JSContext::Sum(CFXJSE_Value* pThis,
uCount++;
}
} else {
- CFX_ByteString propertyStr;
- propertyValue->ToString(propertyStr);
for (int32_t j = 2; j < iLength; j++) {
argValue->GetObjectPropertyByIdx(j, jsObjectValue.get());
- jsObjectValue->GetObjectProperty(propertyStr.AsStringC(),
- newPropertyValue.get());
+ jsObjectValue->GetObjectProperty(
+ propertyValue->ToString().AsStringC(), newPropertyValue.get());
if (newPropertyValue->IsNull())
continue;
@@ -2834,10 +2824,8 @@ void CXFA_FM2JSContext::Choose(CFXJSE_Value* pThis,
if (propertyValue->IsNull()) {
GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get());
} else {
- CFX_ByteString propStr;
- propertyValue->ToString(propStr);
- jsObjectValue->GetObjectProperty(propStr.AsStringC(),
- newPropertyValue.get());
+ jsObjectValue->GetObjectProperty(
+ propertyValue->ToString().AsStringC(), newPropertyValue.get());
}
CFX_ByteString bsChoosed;
ValueToUTF8String(newPropertyValue.get(), bsChoosed);
@@ -2888,8 +2876,7 @@ void CXFA_FM2JSContext::HasValue(CFXJSE_Value* pThis,
return;
}
- CFX_ByteString valueStr;
- argOne->ToString(valueStr);
+ CFX_ByteString valueStr = argOne->ToString();
valueStr.TrimLeft();
args.GetReturnValue()->SetInteger(!valueStr.IsEmpty());
}
@@ -5084,11 +5071,10 @@ void CXFA_FM2JSContext::assign_value_operator(CFXJSE_Value* pThis,
}
}
} else {
- CFX_ByteString propertyStr;
- propertyValue->ToString(propertyStr);
for (int32_t i = 2; i < iLeftLength; i++) {
lValue->GetObjectPropertyByIdx(i, jsObjectValue.get());
- jsObjectValue->SetObjectProperty(propertyStr.AsStringC(), rValue.get());
+ jsObjectValue->SetObjectProperty(propertyValue->ToString().AsStringC(),
+ rValue.get());
}
}
} else if (lValue->IsObject()) {
@@ -5165,11 +5151,8 @@ void CXFA_FM2JSContext::equality_operator(CFXJSE_Value* pThis,
}
if (argFirst->IsString() && argSecond->IsString()) {
- CFX_ByteString firstOutput;
- CFX_ByteString secondOutput;
- argFirst->ToString(firstOutput);
- argSecond->ToString(secondOutput);
- args.GetReturnValue()->SetInteger(firstOutput == secondOutput);
+ args.GetReturnValue()->SetInteger(argFirst->ToString() ==
+ argSecond->ToString());
return;
}
@@ -5201,11 +5184,8 @@ void CXFA_FM2JSContext::notequality_operator(CFXJSE_Value* pThis,
}
if (argFirst->IsString() && argSecond->IsString()) {
- CFX_ByteString firstOutput;
- CFX_ByteString secondOutput;
- argFirst->ToString(firstOutput);
- argSecond->ToString(secondOutput);
- args.GetReturnValue()->SetInteger(firstOutput != secondOutput);
+ args.GetReturnValue()->SetInteger(argFirst->ToString() !=
+ argSecond->ToString());
return;
}
@@ -5258,12 +5238,8 @@ void CXFA_FM2JSContext::less_operator(CFXJSE_Value* pThis,
}
if (argFirst->IsString() && argSecond->IsString()) {
- CFX_ByteString firstOutput;
- CFX_ByteString secondOutput;
- argFirst->ToString(firstOutput);
- argSecond->ToString(secondOutput);
args.GetReturnValue()->SetInteger(
- firstOutput.Compare(secondOutput.AsStringC()) == -1);
+ argFirst->ToString().Compare(argSecond->ToString().AsStringC()) == -1);
return;
}
@@ -5290,12 +5266,8 @@ void CXFA_FM2JSContext::lessequal_operator(CFXJSE_Value* pThis,
}
if (argFirst->IsString() && argSecond->IsString()) {
- CFX_ByteString firstOutput;
- CFX_ByteString secondOutput;
- argFirst->ToString(firstOutput);
- argSecond->ToString(secondOutput);
args.GetReturnValue()->SetInteger(
- firstOutput.Compare(secondOutput.AsStringC()) != 1);
+ argFirst->ToString().Compare(argSecond->ToString().AsStringC()) != 1);
return;
}
@@ -5321,12 +5293,8 @@ void CXFA_FM2JSContext::greater_operator(CFXJSE_Value* pThis,
}
if (argFirst->IsString() && argSecond->IsString()) {
- CFX_ByteString firstOutput;
- CFX_ByteString secondOutput;
- argFirst->ToString(firstOutput);
- argSecond->ToString(secondOutput);
args.GetReturnValue()->SetInteger(
- firstOutput.Compare(secondOutput.AsStringC()) == 1);
+ argFirst->ToString().Compare(argSecond->ToString().AsStringC()) == 1);
return;
}
@@ -5353,12 +5321,8 @@ void CXFA_FM2JSContext::greaterequal_operator(CFXJSE_Value* pThis,
}
if (argFirst->IsString() && argSecond->IsString()) {
- CFX_ByteString firstOutput;
- CFX_ByteString secondOutput;
- argFirst->ToString(firstOutput);
- argSecond->ToString(secondOutput);
args.GetReturnValue()->SetInteger(
- firstOutput.Compare(secondOutput.AsStringC()) != -1);
+ argFirst->ToString().Compare(argSecond->ToString().AsStringC()) != -1);
return;
}
@@ -5876,9 +5840,7 @@ void CXFA_FM2JSContext::get_fm_value(CFXJSE_Value* pThis,
return;
}
- CFX_ByteString propertyStr;
- propertyValue->ToString(propertyStr);
- jsObjectValue->GetObjectProperty(propertyStr.AsStringC(),
+ jsObjectValue->GetObjectProperty(propertyValue->ToString().AsStringC(),
args.GetReturnValue());
return;
}
@@ -6049,9 +6011,7 @@ std::unique_ptr<CFXJSE_Value> CXFA_FM2JSContext::GetSimpleValue(
return simpleValue;
}
- CFX_ByteString propertyStr;
- propertyValue->ToString(propertyStr);
- jsObjectValue->GetObjectProperty(propertyStr.AsStringC(),
+ jsObjectValue->GetObjectProperty(propertyValue->ToString().AsStringC(),
simpleValue.get());
return simpleValue;
}
@@ -6085,10 +6045,8 @@ FX_BOOL CXFA_FM2JSContext::ValueIsNull(CFXJSE_Value* pThis, CFXJSE_Value* arg) {
return defaultValue->IsNull();
}
- CFX_ByteString propertyStr;
- propertyValue->ToString(propertyStr);
std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate));
- jsObjectValue->GetObjectProperty(propertyStr.AsStringC(),
+ jsObjectValue->GetObjectProperty(propertyValue->ToString().AsStringC(),
newPropertyValue.get());
return newPropertyValue->IsNull();
}
@@ -6179,12 +6137,10 @@ void CXFA_FM2JSContext::unfoldArgs(CFXJSE_Value* pThis,
index++;
}
} else {
- CFX_ByteString propertyString;
- propertyValue->ToString(propertyString);
for (int32_t j = 2; j < iLength; j++) {
argsValue[i]->GetObjectPropertyByIdx(j, jsObjectValue.get());
- jsObjectValue->GetObjectProperty(propertyString.AsStringC(),
- resultValues[index]);
+ jsObjectValue->GetObjectProperty(
+ propertyValue->ToString().AsStringC(), resultValues[index]);
index++;
}
}
@@ -6391,9 +6347,7 @@ int32_t CXFA_FM2JSContext::ValueToInteger(CFXJSE_Value* pThis,
return ValueToInteger(pThis, newPropertyValue.get());
}
- CFX_ByteString propertyStr;
- propertyValue->ToString(propertyStr);
- jsObjectValue->GetObjectProperty(propertyStr.AsStringC(),
+ jsObjectValue->GetObjectProperty(propertyValue->ToString().AsStringC(),
newPropertyValue.get());
return ValueToInteger(pThis, newPropertyValue.get());
}
@@ -6402,11 +6356,8 @@ int32_t CXFA_FM2JSContext::ValueToInteger(CFXJSE_Value* pThis,
GetObjectDefaultValue(pValue, newPropertyValue.get());
return ValueToInteger(pThis, newPropertyValue.get());
}
- if (pValue->IsString()) {
- CFX_ByteString szValue;
- pValue->ToString(szValue);
- return FXSYS_atoi(szValue.c_str());
- }
+ if (pValue->IsString())
+ return FXSYS_atoi(pValue->ToString().c_str());
return pValue->ToInteger();
}
@@ -6427,9 +6378,7 @@ FX_FLOAT CXFA_FM2JSContext::ValueToFloat(CFXJSE_Value* pThis,
GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get());
return ValueToFloat(pThis, newPropertyValue.get());
}
- CFX_ByteString propertyStr;
- propertyValue->ToString(propertyStr);
- jsObjectValue->GetObjectProperty(propertyStr.AsStringC(),
+ jsObjectValue->GetObjectProperty(propertyValue->ToString().AsStringC(),
newPropertyValue.get());
return ValueToFloat(pThis, newPropertyValue.get());
}
@@ -6438,11 +6387,8 @@ FX_FLOAT CXFA_FM2JSContext::ValueToFloat(CFXJSE_Value* pThis,
GetObjectDefaultValue(arg, newPropertyValue.get());
return ValueToFloat(pThis, newPropertyValue.get());
}
- if (arg->IsString()) {
- CFX_ByteString bsOutput;
- arg->ToString(bsOutput);
- return (FX_FLOAT)XFA_ByteStringToDouble(bsOutput.AsStringC());
- }
+ if (arg->IsString())
+ return (FX_FLOAT)XFA_ByteStringToDouble(arg->ToString().AsStringC());
if (arg->IsUndefined())
return 0;
@@ -6466,9 +6412,7 @@ FX_DOUBLE CXFA_FM2JSContext::ValueToDouble(CFXJSE_Value* pThis,
GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get());
return ValueToDouble(pThis, newPropertyValue.get());
}
- CFX_ByteString propertyStr;
- propertyValue->ToString(propertyStr);
- jsObjectValue->GetObjectProperty(propertyStr.AsStringC(),
+ jsObjectValue->GetObjectProperty(propertyValue->ToString().AsStringC(),
newPropertyValue.get());
return ValueToDouble(pThis, newPropertyValue.get());
}
@@ -6477,11 +6421,8 @@ FX_DOUBLE CXFA_FM2JSContext::ValueToDouble(CFXJSE_Value* pThis,
GetObjectDefaultValue(arg, newPropertyValue.get());
return ValueToDouble(pThis, newPropertyValue.get());
}
- if (arg->IsString()) {
- CFX_ByteString bsOutput;
- arg->ToString(bsOutput);
- return XFA_ByteStringToDouble(bsOutput.AsStringC());
- }
+ if (arg->IsString())
+ return XFA_ByteStringToDouble(arg->ToString().AsStringC());
if (arg->IsUndefined())
return 0;
return arg->ToDouble();
@@ -6516,10 +6457,8 @@ double CXFA_FM2JSContext::ExtractDouble(CFXJSE_Value* pThis,
if (propertyValue->IsNull())
return ValueToDouble(pThis, jsObjectValue.get());
- CFX_ByteString propertyStr;
- propertyValue->ToString(propertyStr);
std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate));
- jsObjectValue->GetObjectProperty(propertyStr.AsStringC(),
+ jsObjectValue->GetObjectProperty(propertyValue->ToString().AsStringC(),
newPropertyValue.get());
return ValueToDouble(pThis, newPropertyValue.get());
}
@@ -6530,14 +6469,12 @@ void CXFA_FM2JSContext::ValueToUTF8String(CFXJSE_Value* arg,
if (!arg)
return;
- if (arg->IsNull() || arg->IsUndefined()) {
+ if (arg->IsNull() || arg->IsUndefined())
szOutputString = "";
- } else if (arg->IsBoolean()) {
+ else if (arg->IsBoolean())
szOutputString = arg->ToBoolean() ? "1" : "0";
- } else {
- szOutputString = "";
- arg->ToString(szOutputString);
- }
+ else
+ szOutputString = arg->ToString();
}
// static.
diff --git a/xfa/fxfa/parser/xfa_object_imp.cpp b/xfa/fxfa/parser/xfa_object_imp.cpp
index d3d076d302..fe08c0e42b 100644
--- a/xfa/fxfa/parser/xfa_object_imp.cpp
+++ b/xfa/fxfa/parser/xfa_object_imp.cpp
@@ -1430,22 +1430,22 @@ void CXFA_Node::Script_Attribute_String(CFXJSE_Value* pValue,
FX_BOOL bSetting,
XFA_ATTRIBUTE eAttribute) {
if (bSetting) {
- CFX_ByteString szValue;
- pValue->ToString(szValue);
- CFX_WideString wsValue = CFX_WideString::FromUTF8(szValue.AsStringC());
+ CFX_WideString wsValue = pValue->ToWideString();
SetAttribute(eAttribute, wsValue.AsStringC(), true);
if (eAttribute == XFA_ATTRIBUTE_Use && GetClassID() == XFA_ELEMENT_Desc) {
- CFX_WideString wsUseVal = wsValue, wsID, wsSOM;
CXFA_Node* pTemplateNode =
ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Template));
CXFA_Node* pProtoRoot =
pTemplateNode->GetFirstChildByClass(XFA_ELEMENT_Subform)
->GetFirstChildByClass(XFA_ELEMENT_Proto);
- if (!wsUseVal.IsEmpty()) {
- if (wsUseVal[0] == '#') {
- wsID = CFX_WideString(wsUseVal.c_str() + 1, wsUseVal.GetLength() - 1);
+
+ CFX_WideString wsID;
+ CFX_WideString wsSOM;
+ if (!wsValue.IsEmpty()) {
+ if (wsValue[0] == '#') {
+ wsID = CFX_WideString(wsValue.c_str() + 1, wsValue.GetLength() - 1);
} else {
- wsSOM = wsUseVal;
+ wsSOM = wsValue;
}
}
CXFA_Node* pProtoNode = nullptr;
@@ -1541,20 +1541,15 @@ void CXFA_Node::Script_Som_Message(CFXJSE_Value* pValue,
bNew = TRUE;
}
if (bSetting) {
- CFX_ByteString bsMessage;
- pValue->ToString(bsMessage);
switch (iMessageType) {
case XFA_SOM_ValidationMessage:
- validate.SetScriptMessageText(
- CFX_WideString::FromUTF8(bsMessage.AsStringC()));
+ validate.SetScriptMessageText(pValue->ToWideString());
break;
case XFA_SOM_FormatMessage:
- validate.SetFormatMessageText(
- CFX_WideString::FromUTF8(bsMessage.AsStringC()));
+ validate.SetFormatMessageText(pValue->ToWideString());
break;
case XFA_SOM_MandatoryMessage:
- validate.SetNullMessageText(
- CFX_WideString::FromUTF8(bsMessage.AsStringC()));
+ validate.SetNullMessageText(pValue->ToWideString());
break;
default:
break;
@@ -1618,11 +1613,10 @@ void CXFA_Node::Script_Som_DefaultValue(CFXJSE_Value* pValue,
return;
}
if (bSetting) {
- CFX_ByteString newValue;
+ CFX_WideString wsNewValue;
if (!(pValue && (pValue->IsNull() || pValue->IsUndefined())))
- pValue->ToString(newValue);
+ wsNewValue = pValue->ToWideString();
- CFX_WideString wsNewValue = CFX_WideString::FromUTF8(newValue.AsStringC());
CFX_WideString wsFormatValue(wsNewValue);
CXFA_WidgetData* pContainerWidgetData = nullptr;
if (GetPacketID() == XFA_XDPPACKET_Datasets) {
@@ -1688,7 +1682,7 @@ void CXFA_Node::Script_Boolean_Value(CFXJSE_Value* pValue,
if (bSetting) {
CFX_ByteString newValue;
if (!(pValue && (pValue->IsNull() || pValue->IsUndefined())))
- pValue->ToString(newValue);
+ newValue = pValue->ToString();
int32_t iValue = FXSYS_atoi(newValue.c_str());
CFX_WideString wsNewValue(iValue == 0 ? L"0" : L"1");
@@ -1756,13 +1750,14 @@ const XFA_ExecEventParaInfo* GetEventParaInfoByName(
} while (iStart <= iEnd);
return nullptr;
}
-void XFA_STRING_TO_RGB(CFX_WideString& strRGB,
+void XFA_STRING_TO_RGB(const CFX_WideString& strRGB,
int32_t& r,
int32_t& g,
int32_t& b) {
r = 0;
g = 0;
b = 0;
+
FX_WCHAR zero = '0';
int32_t iIndex = 0;
int32_t iLen = strRGB.GetLength();
@@ -1799,13 +1794,11 @@ void CXFA_Node::Script_Som_BorderColor(CFXJSE_Value* pValue,
}
CXFA_Border border = pWidgetData->GetBorder(TRUE);
int32_t iSize = border.CountEdges();
- CFX_WideString strColor;
if (bSetting) {
- CFX_ByteString bsValue;
- pValue->ToString(bsValue);
- strColor = CFX_WideString::FromUTF8(bsValue.AsStringC());
- int32_t r = 0, g = 0, b = 0;
- XFA_STRING_TO_RGB(strColor, r, g, b);
+ int32_t r = 0;
+ int32_t g = 0;
+ int32_t b = 0;
+ XFA_STRING_TO_RGB(pValue->ToWideString(), r, g, b);
FX_ARGB rgb = ArgbEncode(100, r, g, b);
for (int32_t i = 0; i < iSize; ++i) {
CXFA_Edge edge = border.GetEdge(i);
@@ -1816,6 +1809,7 @@ void CXFA_Node::Script_Som_BorderColor(CFXJSE_Value* pValue,
FX_ARGB color = edge.GetColor();
int32_t a, r, g, b;
ArgbDecode(color, a, r, g, b);
+ CFX_WideString strColor;
strColor.Format(L"%d,%d,%d", r, g, b);
pValue->SetString(FX_UTF8Encode(strColor).AsStringC());
}
@@ -1831,9 +1825,7 @@ void CXFA_Node::Script_Som_BorderWidth(CFXJSE_Value* pValue,
int32_t iSize = border.CountEdges();
CFX_WideString wsThickness;
if (bSetting) {
- CFX_ByteString bsValue;
- pValue->ToString(bsValue);
- wsThickness = CFX_WideString::FromUTF8(bsValue.AsStringC());
+ wsThickness = pValue->ToWideString();
for (int32_t i = 0; i < iSize; ++i) {
CXFA_Edge edge = border.GetEdge(i);
CXFA_Measurement thickness(wsThickness.AsStringC());
@@ -1859,19 +1851,21 @@ void CXFA_Node::Script_Som_FillColor(CFXJSE_Value* pValue,
if (!pNode) {
return;
}
- CFX_WideString wsColor;
if (bSetting) {
- CFX_ByteString bsValue;
- pValue->ToString(bsValue);
- wsColor = CFX_WideString::FromUTF8(bsValue.AsStringC());
- int32_t r, g, b;
- XFA_STRING_TO_RGB(wsColor, r, g, b);
+ int32_t r;
+ int32_t g;
+ int32_t b;
+ XFA_STRING_TO_RGB(pValue->ToWideString(), r, g, b);
FX_ARGB color = ArgbEncode(0xff, r, g, b);
borderfill.SetColor(color);
} else {
FX_ARGB color = borderfill.GetColor();
- int32_t a, r, g, b;
+ int32_t a;
+ int32_t r;
+ int32_t g;
+ int32_t b;
ArgbDecode(color, a, r, g, b);
+ CFX_WideString wsColor;
wsColor.Format(L"%d,%d,%d", r, g, b);
pValue->SetString(FX_UTF8Encode(wsColor).AsStringC());
}
@@ -1900,10 +1894,7 @@ void CXFA_Node::Script_Draw_DefaultValue(CFXJSE_Value* pValue,
ASSERT(pWidgetData);
XFA_ELEMENT uiType = pWidgetData->GetUIType();
if (uiType == XFA_ELEMENT_Text) {
- CFX_ByteString newValue;
- pValue->ToString(newValue);
- CFX_WideString wsNewValue =
- CFX_WideString::FromUTF8(newValue.AsStringC());
+ CFX_WideString wsNewValue = pValue->ToWideString();
CFX_WideString wsFormatValue(wsNewValue);
SetScriptContent(wsNewValue, wsFormatValue, true, TRUE);
}
@@ -1933,11 +1924,10 @@ void CXFA_Node::Script_Field_DefaultValue(CFXJSE_Value* pValue,
pWidgetData->m_bPreNull = pWidgetData->m_bIsNull;
pWidgetData->m_bIsNull = FALSE;
}
- CFX_ByteString newValue;
+ CFX_WideString wsNewText;
if (!(pValue && (pValue->IsNull() || pValue->IsUndefined())))
- pValue->ToString(newValue);
+ wsNewText = pValue->ToWideString();
- CFX_WideString wsNewText = CFX_WideString::FromUTF8(newValue.AsStringC());
CXFA_Node* pUIChild = pWidgetData->GetUIChild();
if (pUIChild->GetClassID() == XFA_ELEMENT_NumericEdit) {
int32_t iLeadDigits = 0;
@@ -1992,13 +1982,10 @@ void CXFA_Node::Script_Field_EditValue(CFXJSE_Value* pValue,
if (!pWidgetData) {
return;
}
- CFX_WideString wsValue;
if (bSetting) {
- CFX_ByteString bsValue;
- pValue->ToString(bsValue);
- wsValue = CFX_WideString::FromUTF8(bsValue.AsStringC());
- pWidgetData->SetValue(wsValue, XFA_VALUEPICTURE_Edit);
+ pWidgetData->SetValue(pValue->ToWideString(), XFA_VALUEPICTURE_Edit);
} else {
+ CFX_WideString wsValue;
pWidgetData->GetValue(wsValue, XFA_VALUEPICTURE_Edit);
pValue->SetString(FX_UTF8Encode(wsValue).AsStringC());
}
@@ -2015,19 +2002,21 @@ void CXFA_Node::Script_Som_FontColor(CFXJSE_Value* pValue,
if (!pNode) {
return;
}
- CFX_WideString wsColor;
if (bSetting) {
- CFX_ByteString bsValue;
- pValue->ToString(bsValue);
- wsColor = CFX_WideString::FromUTF8(bsValue.AsStringC());
- int32_t r, g, b;
- XFA_STRING_TO_RGB(wsColor, r, g, b);
+ int32_t r;
+ int32_t g;
+ int32_t b;
+ XFA_STRING_TO_RGB(pValue->ToWideString(), r, g, b);
FX_ARGB color = ArgbEncode(0xff, r, g, b);
font.SetColor(color);
} else {
FX_ARGB color = font.GetColor();
- int32_t a, r, g, b;
+ int32_t a;
+ int32_t r;
+ int32_t g;
+ int32_t b;
ArgbDecode(color, a, r, g, b);
+ CFX_WideString wsColor;
wsColor.Format(L"%d,%d,%d", r, g, b);
pValue->SetString(FX_UTF8Encode(wsColor).AsStringC());
}
@@ -2044,13 +2033,10 @@ void CXFA_Node::Script_Field_FormattedValue(CFXJSE_Value* pValue,
if (!pWidgetData) {
return;
}
- CFX_WideString wsValue;
if (bSetting) {
- CFX_ByteString bsValue;
- pValue->ToString(bsValue);
- wsValue = CFX_WideString::FromUTF8(bsValue.AsStringC());
- pWidgetData->SetValue(wsValue, XFA_VALUEPICTURE_Display);
+ pWidgetData->SetValue(pValue->ToWideString(), XFA_VALUEPICTURE_Display);
} else {
+ CFX_WideString wsValue;
pWidgetData->GetValue(wsValue, XFA_VALUEPICTURE_Display);
pValue->SetString(FX_UTF8Encode(wsValue).AsStringC());
}
@@ -2063,19 +2049,15 @@ void CXFA_Node::Script_Som_Mandatory(CFXJSE_Value* pValue,
return;
}
CXFA_Validate validate = pWidgetData->GetValidate(TRUE);
- CFX_WideString wsValue;
if (bSetting) {
- CFX_ByteString bsValue;
- pValue->ToString(bsValue);
- wsValue = CFX_WideString::FromUTF8(bsValue.AsStringC());
- validate.SetNullTest(wsValue);
+ validate.SetNullTest(pValue->ToWideString());
} else {
int32_t iValue = validate.GetNullTest();
const XFA_ATTRIBUTEENUMINFO* pInfo =
XFA_GetAttributeEnumByID((XFA_ATTRIBUTEENUM)iValue);
- if (pInfo) {
+ CFX_WideString wsValue;
+ if (pInfo)
wsValue = pInfo->pName;
- }
pValue->SetString(FX_UTF8Encode(wsValue).AsStringC());
}
}
@@ -2330,11 +2312,8 @@ void CXFA_Node::Script_ExclGroup_DefaultAndRawValue(CFXJSE_Value* pValue,
return;
}
if (bSetting) {
- CFX_ByteString bsValue;
- pValue->ToString(bsValue);
- pWidgetData->SetSelectedMemberByValue(
- CFX_WideString::FromUTF8(bsValue.AsStringC()).AsStringC(), true, TRUE,
- TRUE);
+ pWidgetData->SetSelectedMemberByValue(pValue->ToWideString().AsStringC(),
+ true, TRUE, TRUE);
} else {
CFX_WideString wsValue = GetScriptContent(TRUE);
XFA_VERSION curVersion = GetDocument()->GetCurVersionMode();
@@ -2529,10 +2508,7 @@ void CXFA_Node::Script_Subform_Locale(CFXJSE_Value* pValue,
FX_BOOL bSetting,
XFA_ATTRIBUTE eAttribute) {
if (bSetting) {
- CFX_ByteString bsLocaleName;
- pValue->ToString(bsLocaleName);
- SetCData(XFA_ATTRIBUTE_Locale,
- CFX_WideString::FromUTF8(bsLocaleName.AsStringC()), true, TRUE);
+ SetCData(XFA_ATTRIBUTE_Locale, pValue->ToWideString(), true, TRUE);
} else {
CFX_WideString wsLocaleName;
GetLocaleName(wsLocaleName);
@@ -3386,10 +3362,7 @@ void CXFA_Node::Script_Form_Checksum(CFXJSE_Value* pValue,
FX_BOOL bSetting,
XFA_ATTRIBUTE eAttribute) {
if (bSetting) {
- CFX_ByteString bsChecksum;
- pValue->ToString(bsChecksum);
- SetAttribute(XFA_ATTRIBUTE_Checksum,
- CFX_WideString::FromUTF8(bsChecksum.AsStringC()).AsStringC());
+ SetAttribute(XFA_ATTRIBUTE_Checksum, pValue->ToWideString().AsStringC());
} else {
CFX_WideString wsChecksum;
GetAttribute(XFA_ATTRIBUTE_Checksum, wsChecksum, FALSE);
@@ -3452,13 +3425,10 @@ void CXFA_Node::Script_Packet_Content(CFXJSE_Value* pValue,
FX_BOOL bSetting,
XFA_ATTRIBUTE eAttribute) {
if (bSetting) {
- CFX_ByteString bsNewContent;
- pValue->ToString(bsNewContent);
CFDE_XMLNode* pXMLNode = GetXMLMappingNode();
if (pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element) {
CFDE_XMLElement* pXMLElement = static_cast<CFDE_XMLElement*>(pXMLNode);
- pXMLElement->SetTextData(
- CFX_WideString::FromUTF8(bsNewContent.AsStringC()));
+ pXMLElement->SetTextData(pValue->ToWideString());
}
} else {
CFX_WideString wsTextData;
diff --git a/xfa/fxfa/parser/xfa_script_eventpseudomodel.cpp b/xfa/fxfa/parser/xfa_script_eventpseudomodel.cpp
index b494a91478..2a0c291e16 100644
--- a/xfa/fxfa/parser/xfa_script_eventpseudomodel.cpp
+++ b/xfa/fxfa/parser/xfa_script_eventpseudomodel.cpp
@@ -28,9 +28,7 @@ void Script_EventPseudoModel_StringProperty(CFXJSE_Value* pValue,
CFX_WideString& wsValue,
FX_BOOL bSetting) {
if (bSetting) {
- CFX_ByteString bsValue;
- pValue->ToString(bsValue);
- wsValue = CFX_WideString::FromUTF8(bsValue.AsStringC());
+ wsValue = pValue->ToWideString();
} else {
pValue->SetString(FX_UTF8Encode(wsValue).AsStringC());
}
diff --git a/xfa/fxfa/parser/xfa_script_hostpseudomodel.cpp b/xfa/fxfa/parser/xfa_script_hostpseudomodel.cpp
index 1a3ef8f151..ef2bafb81e 100644
--- a/xfa/fxfa/parser/xfa_script_hostpseudomodel.cpp
+++ b/xfa/fxfa/parser/xfa_script_hostpseudomodel.cpp
@@ -163,10 +163,7 @@ void CScript_HostPseudoModel::Script_HostPseudoModel_Title(
}
CXFA_FFDoc* hDoc = pNotify->GetHDOC();
if (bSetting) {
- CFX_ByteString bsValue;
- pValue->ToString(bsValue);
- pNotify->GetDocProvider()->SetTitle(
- hDoc, CFX_WideString::FromUTF8(bsValue.AsStringC()));
+ pNotify->GetDocProvider()->SetTitle(hDoc, pValue->ToWideString());
return;
}
CFX_WideString wsTitle;
@@ -314,10 +311,6 @@ void CScript_HostPseudoModel::Script_HostPseudoModel_OpenList(
if (pValue->IsObject()) {
pNode = ToNode(pValue.get(), nullptr);
} else if (pValue->IsString()) {
- CFX_ByteString bsString;
- pValue->ToString(bsString);
- CFX_WideString wsExpression =
- CFX_WideString::FromUTF8(bsString.AsStringC());
CXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext();
if (!pScriptContext)
return;
@@ -330,7 +323,7 @@ void CScript_HostPseudoModel::Script_HostPseudoModel_OpenList(
XFA_RESOLVENODE_Siblings;
XFA_RESOLVENODE_RS resoveNodeRS;
int32_t iRet = pScriptContext->ResolveObjects(
- pObject, wsExpression.AsStringC(), resoveNodeRS, dwFlag);
+ pObject, pValue->ToWideString().AsStringC(), resoveNodeRS, dwFlag);
if (iRet < 1 || !resoveNodeRS.nodes[0]->IsNode())
return;
@@ -509,10 +502,6 @@ void CScript_HostPseudoModel::Script_HostPseudoModel_SetFocus(
if (pValue->IsObject()) {
pNode = ToNode(pValue.get(), nullptr);
} else if (pValue->IsString()) {
- CFX_ByteString bsString;
- pValue->ToString(bsString);
- CFX_WideString wsExpression =
- CFX_WideString::FromUTF8(bsString.AsStringC());
CXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext();
if (!pScriptContext)
return;
@@ -525,7 +514,7 @@ void CScript_HostPseudoModel::Script_HostPseudoModel_SetFocus(
XFA_RESOLVENODE_Siblings;
XFA_RESOLVENODE_RS resoveNodeRS;
int32_t iRet = pScriptContext->ResolveObjects(
- pObject, wsExpression.AsStringC(), resoveNodeRS, dwFlag);
+ pObject, pValue->ToWideString().AsStringC(), resoveNodeRS, dwFlag);
if (iRet < 1 || !resoveNodeRS.nodes[0]->IsNode())
return;
@@ -613,9 +602,7 @@ FX_BOOL CScript_HostPseudoModel::Script_HostPseudoModel_ValidateArgsForMsg(
if (pValueArg->IsNull()) {
wsValue = FX_WSTRC(L"");
} else {
- CFX_ByteString byMessage;
- pValueArg->ToString(byMessage);
- wsValue = CFX_WideString::FromUTF8(byMessage.AsStringC());
+ wsValue = pValueArg->ToWideString();
}
return TRUE;
}