summaryrefslogtreecommitdiff
path: root/fxjs
diff options
context:
space:
mode:
Diffstat (limited to 'fxjs')
-rw-r--r--fxjs/xfa/cjx_draw.cpp1
-rw-r--r--fxjs/xfa/cjx_exclgroup.cpp13
-rw-r--r--fxjs/xfa/cjx_field.cpp71
-rw-r--r--fxjs/xfa/cjx_hostpseudomodel.cpp3
-rw-r--r--fxjs/xfa/cjx_manifest.cpp3
-rw-r--r--fxjs/xfa/cjx_node.cpp9
-rw-r--r--fxjs/xfa/cjx_object.cpp7
-rw-r--r--fxjs/xfa/cjx_template.cpp9
8 files changed, 62 insertions, 54 deletions
diff --git a/fxjs/xfa/cjx_draw.cpp b/fxjs/xfa/cjx_draw.cpp
index a1baabfd2c..be9e430ae2 100644
--- a/fxjs/xfa/cjx_draw.cpp
+++ b/fxjs/xfa/cjx_draw.cpp
@@ -120,6 +120,7 @@ void CJX_Draw::defaultValue(CFXJSE_Value* pValue,
if (!pValue || !pValue->IsString())
return;
+ ASSERT(GetXFANode()->IsWidgetReady());
XFA_Element uiType = GetXFANode()->GetWidgetAcc()->GetUIType();
if (uiType != XFA_Element::Text)
return;
diff --git a/fxjs/xfa/cjx_exclgroup.cpp b/fxjs/xfa/cjx_exclgroup.cpp
index 8d814dc125..7daea71749 100644
--- a/fxjs/xfa/cjx_exclgroup.cpp
+++ b/fxjs/xfa/cjx_exclgroup.cpp
@@ -85,10 +85,11 @@ CJS_Return CJX_ExclGroup::selectedMember(
if (!params.empty())
return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- CXFA_WidgetAcc* pWidgetAcc = ToNode(GetXFAObject())->GetWidgetAcc();
- if (!pWidgetAcc)
+ CXFA_Node* node = GetXFANode();
+ if (!node->IsWidgetReady())
return CJS_Return(runtime->NewNull());
+ CXFA_WidgetAcc* pWidgetAcc = node->GetWidgetAcc();
CXFA_Node* pReturnNode = nullptr;
if (params.empty()) {
pReturnNode = pWidgetAcc->GetSelectedMember();
@@ -110,13 +111,13 @@ CJS_Return CJX_ExclGroup::selectedMember(
void CJX_ExclGroup::defaultValue(CFXJSE_Value* pValue,
bool bSetting,
XFA_Attribute eAttribute) {
- CXFA_WidgetAcc* pWidgetAcc = GetXFANode()->GetWidgetAcc();
- if (!pWidgetAcc)
+ CXFA_Node* node = GetXFANode();
+ if (!node->IsWidgetReady())
return;
if (bSetting) {
- pWidgetAcc->SetSelectedMemberByValue(pValue->ToWideString().AsStringView(),
- true, true, true);
+ node->GetWidgetAcc()->SetSelectedMemberByValue(
+ pValue->ToWideString().AsStringView(), true, true, true);
return;
}
diff --git a/fxjs/xfa/cjx_field.cpp b/fxjs/xfa/cjx_field.cpp
index 299c6ef3a4..03927cd02e 100644
--- a/fxjs/xfa/cjx_field.cpp
+++ b/fxjs/xfa/cjx_field.cpp
@@ -41,9 +41,9 @@ CJX_Field::~CJX_Field() {}
CJS_Return CJX_Field::clearItems(
CJS_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
- CXFA_WidgetAcc* pWidgetAcc = ToNode(GetXFAObject())->GetWidgetAcc();
- if (pWidgetAcc)
- pWidgetAcc->DeleteItem(-1, true, false);
+ CXFA_Node* node = GetXFANode();
+ if (node->IsWidgetReady())
+ node->GetWidgetAcc()->DeleteItem(-1, true, false);
return CJS_Return(true);
}
@@ -82,11 +82,12 @@ CJS_Return CJX_Field::deleteItem(
if (params.size() != 1)
return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- CXFA_WidgetAcc* pWidgetAcc = ToNode(GetXFAObject())->GetWidgetAcc();
- if (!pWidgetAcc)
+ CXFA_Node* node = GetXFANode();
+ if (!node->IsWidgetReady())
return CJS_Return(true);
- bool bValue = pWidgetAcc->DeleteItem(runtime->ToInt32(params[0]), true, true);
+ bool bValue =
+ node->GetWidgetAcc()->DeleteItem(runtime->ToInt32(params[0]), true, true);
return CJS_Return(runtime->NewBoolean(bValue));
}
@@ -100,11 +101,12 @@ CJS_Return CJX_Field::getSaveItem(
if (iIndex < 0)
return CJS_Return(runtime->NewNull());
- CXFA_WidgetAcc* pWidgetAcc = ToNode(GetXFAObject())->GetWidgetAcc();
- if (!pWidgetAcc)
+ CXFA_Node* node = GetXFANode();
+ if (!node->IsWidgetReady())
return CJS_Return(runtime->NewNull());
- Optional<WideString> value = pWidgetAcc->GetChoiceListItem(iIndex, true);
+ Optional<WideString> value =
+ node->GetWidgetAcc()->GetChoiceListItem(iIndex, true);
if (!value)
return CJS_Return(runtime->NewNull());
@@ -117,12 +119,13 @@ CJS_Return CJX_Field::boundItem(
if (params.size() != 1)
return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- CXFA_WidgetAcc* pWidgetAcc = ToNode(GetXFAObject())->GetWidgetAcc();
- if (!pWidgetAcc)
+ CXFA_Node* node = GetXFANode();
+ if (!node->IsWidgetReady())
return CJS_Return(true);
WideString value = runtime->ToWideString(params[0]);
- WideString boundValue = pWidgetAcc->GetItemValue(value.AsStringView());
+ WideString boundValue =
+ node->GetWidgetAcc()->GetItemValue(value.AsStringView());
return CJS_Return(runtime->NewString(boundValue.UTF8Encode().AsStringView()));
}
@@ -132,11 +135,12 @@ CJS_Return CJX_Field::getItemState(
if (params.size() != 1)
return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- CXFA_WidgetAcc* pWidgetAcc = ToNode(GetXFAObject())->GetWidgetAcc();
- if (!pWidgetAcc)
+ CXFA_Node* node = GetXFANode();
+ if (!node->IsWidgetReady())
return CJS_Return(true);
- int32_t state = pWidgetAcc->GetItemState(runtime->ToInt32(params[0]));
+ int32_t state =
+ node->GetWidgetAcc()->GetItemState(runtime->ToInt32(params[0]));
return CJS_Return(runtime->NewBoolean(state != 0));
}
@@ -164,11 +168,12 @@ CJS_Return CJX_Field::getDisplayItem(
if (iIndex < 0)
return CJS_Return(runtime->NewNull());
- CXFA_WidgetAcc* pWidgetAcc = ToNode(GetXFAObject())->GetWidgetAcc();
- if (!pWidgetAcc)
+ CXFA_Node* node = GetXFANode();
+ if (!node->IsWidgetReady())
return CJS_Return(runtime->NewNull());
- Optional<WideString> value = pWidgetAcc->GetChoiceListItem(iIndex, false);
+ Optional<WideString> value =
+ node->GetWidgetAcc()->GetChoiceListItem(iIndex, false);
if (!value)
return CJS_Return(runtime->NewNull());
@@ -181,10 +186,11 @@ CJS_Return CJX_Field::setItemState(
if (params.size() != 2)
return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- CXFA_WidgetAcc* pWidgetAcc = ToNode(GetXFAObject())->GetWidgetAcc();
- if (!pWidgetAcc)
+ CXFA_Node* node = GetXFANode();
+ if (!node->IsWidgetReady())
return CJS_Return(true);
+ CXFA_WidgetAcc* pWidgetAcc = node->GetWidgetAcc();
int32_t iIndex = runtime->ToInt32(params[0]);
if (runtime->ToInt32(params[1]) != 0) {
pWidgetAcc->SetItemState(iIndex, true, true, true, true);
@@ -201,8 +207,8 @@ CJS_Return CJX_Field::addItem(CJS_V8* runtime,
if (params.size() != 1 && params.size() != 2)
return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- CXFA_WidgetAcc* pWidgetAcc = ToNode(GetXFAObject())->GetWidgetAcc();
- if (!pWidgetAcc)
+ CXFA_Node* node = GetXFANode();
+ if (!node->IsWidgetReady())
return CJS_Return(true);
WideString label;
@@ -213,7 +219,7 @@ CJS_Return CJX_Field::addItem(CJS_V8* runtime,
if (params.size() >= 2)
value = runtime->ToWideString(params[1]);
- pWidgetAcc->InsertItem(label, value, true);
+ node->GetWidgetAcc()->InsertItem(label, value, true);
return CJS_Return(true);
}
@@ -236,10 +242,10 @@ void CJX_Field::defaultValue(CFXJSE_Value* pValue,
bool bSetting,
XFA_Attribute eAttribute) {
CXFA_Node* xfaNode = GetXFANode();
- CXFA_WidgetAcc* pWidgetAcc = xfaNode->GetWidgetAcc();
- if (!pWidgetAcc)
+ if (!xfaNode->IsWidgetReady())
return;
+ CXFA_WidgetAcc* pWidgetAcc = xfaNode->GetWidgetAcc();
if (bSetting) {
if (pValue) {
pWidgetAcc->SetPreNull(pWidgetAcc->IsNull());
@@ -297,10 +303,11 @@ void CJX_Field::defaultValue(CFXJSE_Value* pValue,
void CJX_Field::editValue(CFXJSE_Value* pValue,
bool bSetting,
XFA_Attribute eAttribute) {
- CXFA_WidgetAcc* pWidgetAcc = GetXFANode()->GetWidgetAcc();
- if (!pWidgetAcc)
+ CXFA_Node* node = GetXFANode();
+ if (!node->IsWidgetReady())
return;
+ CXFA_WidgetAcc* pWidgetAcc = node->GetWidgetAcc();
if (bSetting) {
pWidgetAcc->SetValue(XFA_VALUEPICTURE_Edit, pValue->ToWideString());
return;
@@ -318,10 +325,11 @@ void CJX_Field::formatMessage(CFXJSE_Value* pValue,
void CJX_Field::formattedValue(CFXJSE_Value* pValue,
bool bSetting,
XFA_Attribute eAttribute) {
- CXFA_WidgetAcc* pWidgetAcc = GetXFANode()->GetWidgetAcc();
- if (!pWidgetAcc)
+ CXFA_Node* node = GetXFANode();
+ if (!node->IsWidgetReady())
return;
+ CXFA_WidgetAcc* pWidgetAcc = node->GetWidgetAcc();
if (bSetting) {
pWidgetAcc->SetValue(XFA_VALUEPICTURE_Display, pValue->ToWideString());
return;
@@ -344,10 +352,11 @@ void CJX_Field::parentSubform(CFXJSE_Value* pValue,
void CJX_Field::selectedIndex(CFXJSE_Value* pValue,
bool bSetting,
XFA_Attribute eAttribute) {
- CXFA_WidgetAcc* pWidgetAcc = GetXFANode()->GetWidgetAcc();
- if (!pWidgetAcc)
+ CXFA_Node* node = GetXFANode();
+ if (!node->IsWidgetReady())
return;
+ CXFA_WidgetAcc* pWidgetAcc = node->GetWidgetAcc();
if (!bSetting) {
pValue->SetInteger(pWidgetAcc->GetSelectedItem(0));
return;
diff --git a/fxjs/xfa/cjx_hostpseudomodel.cpp b/fxjs/xfa/cjx_hostpseudomodel.cpp
index 12aa2bdb2b..c607325a90 100644
--- a/fxjs/xfa/cjx_hostpseudomodel.cpp
+++ b/fxjs/xfa/cjx_hostpseudomodel.cpp
@@ -394,7 +394,8 @@ CJS_Return CJX_HostPseudoModel::resetData(
continue;
pNode = resolveNodeRS.objects.front()->AsNode();
- pNotify->ResetData(pNode->GetWidgetAcc());
+ pNotify->ResetData(pNode->IsWidgetReady() ? pNode->GetWidgetAcc()
+ : nullptr);
}
if (!pNode)
pNotify->ResetData();
diff --git a/fxjs/xfa/cjx_manifest.cpp b/fxjs/xfa/cjx_manifest.cpp
index 0882238aba..86e2926ba6 100644
--- a/fxjs/xfa/cjx_manifest.cpp
+++ b/fxjs/xfa/cjx_manifest.cpp
@@ -27,8 +27,7 @@ CJS_Return CJX_Manifest::evaluate(
if (!params.empty())
return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- return CJS_Return(
- runtime->NewBoolean(!!ToNode(GetXFAObject())->GetWidgetAcc()));
+ return CJS_Return(runtime->NewBoolean(GetXFANode()->IsWidgetReady()));
}
void CJX_Manifest::defaultValue(CFXJSE_Value* pValue,
diff --git a/fxjs/xfa/cjx_node.cpp b/fxjs/xfa/cjx_node.cpp
index cf2642c8ad..3666a600b1 100644
--- a/fxjs/xfa/cjx_node.cpp
+++ b/fxjs/xfa/cjx_node.cpp
@@ -503,11 +503,10 @@ int32_t CJX_Node::execSingleEventByName(const WideStringView& wsEventName,
return pNotify->ExecEventByDeepFirst(
GetXFANode(), eventParaInfo->m_eventType, false, false);
case EventAppliesToo::kSignature: {
- CXFA_WidgetAcc* pWidgetAcc = GetXFANode()->GetWidgetAcc();
- if (!pWidgetAcc)
+ if (!GetXFANode()->IsWidgetReady())
return XFA_EVENTERROR_NotExist;
- CXFA_Node* pUINode = pWidgetAcc->GetUIChild();
+ CXFA_Node* pUINode = GetXFANode()->GetWidgetAcc()->GetUIChild();
if (pUINode->GetElementType() != XFA_Element::Signature)
return XFA_EVENTERROR_NotExist;
@@ -515,10 +514,10 @@ int32_t CJX_Node::execSingleEventByName(const WideStringView& wsEventName,
GetXFANode(), eventParaInfo->m_eventType, false, false);
}
case EventAppliesToo::kChoiceList: {
- CXFA_WidgetAcc* pWidgetAcc = GetXFANode()->GetWidgetAcc();
- if (!pWidgetAcc)
+ if (!GetXFANode()->IsWidgetReady())
return XFA_EVENTERROR_NotExist;
+ CXFA_WidgetAcc* pWidgetAcc = GetXFANode()->GetWidgetAcc();
CXFA_Node* pUINode = pWidgetAcc->GetUIChild();
if (pUINode->GetElementType() != XFA_Element::ChoiceList ||
pWidgetAcc->IsListBox()) {
diff --git a/fxjs/xfa/cjx_object.cpp b/fxjs/xfa/cjx_object.cpp
index 6408cf3eb9..4f3b6adbc8 100644
--- a/fxjs/xfa/cjx_object.cpp
+++ b/fxjs/xfa/cjx_object.cpp
@@ -1477,12 +1477,13 @@ void CJX_Object::Script_Field_Length(CFXJSE_Value* pValue,
ThrowInvalidPropertyException();
return;
}
- if (!ToNode(object_.Get())->GetWidgetAcc()) {
+
+ CXFA_Node* node = ToNode(object_.Get());
+ if (!node->IsWidgetReady()) {
pValue->SetInteger(0);
return;
}
- pValue->SetInteger(
- ToNode(object_.Get())->GetWidgetAcc()->CountChoiceListItems(true));
+ pValue->SetInteger(node->GetWidgetAcc()->CountChoiceListItems(true));
}
void CJX_Object::Script_Som_DefaultValue(CFXJSE_Value* pValue,
diff --git a/fxjs/xfa/cjx_template.cpp b/fxjs/xfa/cjx_template.cpp
index 816c9d487b..d909567c51 100644
--- a/fxjs/xfa/cjx_template.cpp
+++ b/fxjs/xfa/cjx_template.cpp
@@ -50,8 +50,7 @@ CJS_Return CJX_Template::execInitialize(
const std::vector<v8::Local<v8::Value>>& params) {
if (!params.empty())
return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- return CJS_Return(
- runtime->NewBoolean(!!ToNode(GetXFAObject())->GetWidgetAcc()));
+ return CJS_Return(runtime->NewBoolean(GetXFANode()->IsWidgetReady()));
}
CJS_Return CJX_Template::recalculate(
@@ -67,8 +66,7 @@ CJS_Return CJX_Template::execCalculate(
const std::vector<v8::Local<v8::Value>>& params) {
if (!params.empty())
return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- return CJS_Return(
- runtime->NewBoolean(!!ToNode(GetXFAObject())->GetWidgetAcc()));
+ return CJS_Return(runtime->NewBoolean(GetXFANode()->IsWidgetReady()));
}
CJS_Return CJX_Template::execValidate(
@@ -76,6 +74,5 @@ CJS_Return CJX_Template::execValidate(
const std::vector<v8::Local<v8::Value>>& params) {
if (!params.empty())
return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- return CJS_Return(
- runtime->NewBoolean(!!ToNode(GetXFAObject())->GetWidgetAcc()));
+ return CJS_Return(runtime->NewBoolean(GetXFANode()->IsWidgetReady()));
}