summaryrefslogtreecommitdiff
path: root/xfa/fxfa/parser/cxfa_node.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fxfa/parser/cxfa_node.cpp')
-rw-r--r--xfa/fxfa/parser/cxfa_node.cpp88
1 files changed, 33 insertions, 55 deletions
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());
}
}