summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fxjs/cfxjse_engine.cpp8
-rw-r--r--fxjs/cfxjse_resolveprocessor.cpp12
-rw-r--r--fxjs/xfa/cjx_node.cpp8
-rw-r--r--fxjs/xfa/cjx_object.cpp67
-rw-r--r--fxjs/xfa/cjx_object.h17
-rw-r--r--xfa/fxfa/cxfa_ffdocview.cpp2
-rw-r--r--xfa/fxfa/cxfa_ffpushbutton.cpp2
-rw-r--r--xfa/fxfa/cxfa_ffwidget.cpp10
-rw-r--r--xfa/fxfa/cxfa_ffwidgethandler.cpp2
-rw-r--r--xfa/fxfa/cxfa_textprovider.cpp4
-rw-r--r--xfa/fxfa/cxfa_widgetacc.cpp21
-rw-r--r--xfa/fxfa/parser/cxfa_box.cpp32
-rw-r--r--xfa/fxfa/parser/cxfa_box.h3
-rw-r--r--xfa/fxfa/parser/cxfa_fill.cpp10
-rw-r--r--xfa/fxfa/parser/cxfa_font.cpp2
-rw-r--r--xfa/fxfa/parser/cxfa_layoutpagemgr.cpp5
-rw-r--r--xfa/fxfa/parser/cxfa_node.cpp68
-rw-r--r--xfa/fxfa/parser/cxfa_node.h29
-rw-r--r--xfa/fxfa/parser/cxfa_stroke.cpp2
-rw-r--r--xfa/fxfa/parser/cxfa_validate.cpp4
-rw-r--r--xfa/fxfa/parser/xfa_document_datamerger_imp.cpp18
21 files changed, 191 insertions, 135 deletions
diff --git a/fxjs/cfxjse_engine.cpp b/fxjs/cfxjse_engine.cpp
index 179866b555..535ec41160 100644
--- a/fxjs/cfxjse_engine.cpp
+++ b/fxjs/cfxjse_engine.cpp
@@ -351,10 +351,12 @@ void CFXJSE_Engine::NormalPropertySetter(CFXJSE_Value* pOriginalValue,
CXFA_Node* pNode = ToNode(pObject);
CXFA_Node* pPropOrChild = nullptr;
XFA_Element eType = CXFA_Node::NameToElement(wsPropName);
- if (eType != XFA_Element::Unknown)
- pPropOrChild = pNode->JSObject()->GetProperty<CXFA_Node>(0, eType, true);
- else
+ if (eType != XFA_Element::Unknown) {
+ pPropOrChild =
+ pNode->JSObject()->GetOrCreateProperty<CXFA_Node>(0, eType);
+ } else {
pPropOrChild = pNode->GetFirstChildByName(wsPropName.AsStringView());
+ }
if (pPropOrChild) {
const XFA_SCRIPTATTRIBUTEINFO* lpAttrInfo = XFA_GetScriptAttributeByName(
diff --git a/fxjs/cfxjse_resolveprocessor.cpp b/fxjs/cfxjse_resolveprocessor.cpp
index beb0541a49..b602db24ec 100644
--- a/fxjs/cfxjse_resolveprocessor.cpp
+++ b/fxjs/cfxjse_resolveprocessor.cpp
@@ -346,14 +346,16 @@ bool CFXJSE_ResolveProcessor::ResolveNormal(CFXJSE_ResolveNodeData& rnd) {
CXFA_Node* pInstanceManager =
curNode->AsNode()->GetInstanceMgrOfSubform();
if (pInstanceManager) {
- pProp = pInstanceManager->JSObject()->GetProperty<CXFA_Occur>(
- 0, XFA_Element::Occur, true);
+ pProp = pInstanceManager->JSObject()->GetOrCreateProperty<CXFA_Occur>(
+ 0, XFA_Element::Occur);
}
} else {
XFA_Element eType = CXFA_Node::NameToElement(wsName);
- if (eType != XFA_Element::Unknown) {
- pProp = curNode->AsNode()->JSObject()->GetProperty<CXFA_Node>(
- 0, eType, eType != XFA_Element::PageSet);
+ if (eType == XFA_Element::PageSet) {
+ pProp = curNode->AsNode()->JSObject()->GetProperty<CXFA_Node>(0, eType);
+ } else if (eType != XFA_Element::Unknown) {
+ pProp = curNode->AsNode()->JSObject()->GetOrCreateProperty<CXFA_Node>(
+ 0, eType);
}
}
if (pProp) {
diff --git a/fxjs/xfa/cjx_node.cpp b/fxjs/xfa/cjx_node.cpp
index c0634767cf..581d3281ef 100644
--- a/fxjs/xfa/cjx_node.cpp
+++ b/fxjs/xfa/cjx_node.cpp
@@ -163,8 +163,8 @@ CJS_Return CJX_Node::getElement(
WideString expression = runtime->ToWideString(params[0]);
int32_t iValue = params.size() >= 2 ? runtime->ToInt32(params[1]) : 0;
- CXFA_Node* pNode = GetProperty<CXFA_Node>(
- iValue, CXFA_Node::NameToElement(expression), true);
+ CXFA_Node* pNode = GetOrCreateProperty<CXFA_Node>(
+ iValue, CXFA_Node::NameToElement(expression));
CFXJSE_Value* value =
GetDocument()->GetScriptContext()->GetJSValueFromMap(pNode);
if (!value)
@@ -186,12 +186,12 @@ CJS_Return CJX_Node::isPropertySpecified(
bool bParent = params.size() < 2 || runtime->ToBoolean(params[1]);
int32_t iIndex = params.size() == 3 ? runtime->ToInt32(params[2]) : 0;
XFA_Element eType = CXFA_Node::NameToElement(expression);
- bool bHas = !!GetProperty<CXFA_Node>(iIndex, eType, true);
+ bool bHas = !!GetOrCreateProperty<CXFA_Node>(iIndex, eType);
if (!bHas && bParent && GetXFANode()->GetParent()) {
// Also check on the parent.
auto* jsnode = GetXFANode()->GetParent()->JSObject();
bHas = jsnode->HasAttribute(attr) ||
- !!jsnode->GetProperty<CXFA_Node>(iIndex, eType, true);
+ !!jsnode->GetOrCreateProperty<CXFA_Node>(iIndex, eType);
}
return CJS_Return(runtime->NewBoolean(bHas));
}
diff --git a/fxjs/xfa/cjx_object.cpp b/fxjs/xfa/cjx_object.cpp
index 0528bd5edd..45089f68da 100644
--- a/fxjs/xfa/cjx_object.cpp
+++ b/fxjs/xfa/cjx_object.cpp
@@ -629,7 +629,7 @@ bool CJX_Object::SetContent(const WideString& wsContent,
case XFA_ObjectType::ContainerNode: {
if (XFA_FieldIsMultiListBox(ToNode(GetXFAObject()))) {
CXFA_Value* pValue =
- GetProperty<CXFA_Value>(0, XFA_Element::Value, true);
+ GetOrCreateProperty<CXFA_Value>(0, XFA_Element::Value);
if (!pValue)
break;
@@ -714,7 +714,7 @@ bool CJX_Object::SetContent(const WideString& wsContent,
pNode = ToNode(GetXFAObject());
} else {
CXFA_Value* pValue =
- GetProperty<CXFA_Value>(0, XFA_Element::Value, true);
+ GetOrCreateProperty<CXFA_Value>(0, XFA_Element::Value);
if (!pValue)
break;
@@ -908,33 +908,42 @@ Optional<WideString> CJX_Object::TryNamespace() {
return {static_cast<CFX_XMLElement*>(pXMLNode)->GetNamespaceURI()};
}
-CXFA_Node* CJX_Object::GetPropertyInternal(int32_t index,
- XFA_Element eProperty,
- bool bCreateProperty) {
- if (index < 0 ||
- index >= ToNode(GetXFAObject())->PropertyOccuranceCount(eProperty)) {
- return nullptr;
- }
+std::pair<CXFA_Node*, int32_t> CJX_Object::GetPropertyInternal(
+ int32_t index,
+ XFA_Element eProperty) const {
+ const CXFA_Node* xfaNode = ToNode(GetXFAObject());
+ if (index < 0 || index >= xfaNode->PropertyOccuranceCount(eProperty))
+ return {nullptr, 0};
int32_t iCount = 0;
- for (CXFA_Node* pNode = ToNode(GetXFAObject())->GetChildNode(); pNode;
+ for (CXFA_Node* pNode = xfaNode->GetChildNode(); pNode;
pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) {
if (pNode->GetElementType() == eProperty) {
iCount++;
if (iCount > index)
- return pNode;
+ return {pNode, iCount};
}
}
- if (!bCreateProperty)
+ return {nullptr, iCount};
+}
+
+CXFA_Node* CJX_Object::GetOrCreatePropertyInternal(int32_t index,
+ XFA_Element eProperty) {
+ CXFA_Node* xfaNode = ToNode(GetXFAObject());
+ if (index < 0 || index >= xfaNode->PropertyOccuranceCount(eProperty))
return nullptr;
- if (ToNode(GetXFAObject())
- ->HasPropertyFlags(eProperty, XFA_PROPERTYFLAG_OneOf)) {
- for (CXFA_Node* pNode = ToNode(GetXFAObject())->GetChildNode(); pNode;
+ int32_t iCount = 0;
+ CXFA_Node* node;
+ std::tie(node, iCount) = GetPropertyInternal(index, eProperty);
+ if (node)
+ return node;
+
+ if (xfaNode->HasPropertyFlags(eProperty, XFA_PROPERTYFLAG_OneOf)) {
+ for (CXFA_Node* pNode = xfaNode->GetChildNode(); pNode;
pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) {
- if (ToNode(GetXFAObject())
- ->HasPropertyFlags(pNode->GetElementType(),
- XFA_PROPERTYFLAG_OneOf)) {
+ if (xfaNode->HasPropertyFlags(pNode->GetElementType(),
+ XFA_PROPERTYFLAG_OneOf)) {
return nullptr;
}
}
@@ -942,11 +951,11 @@ CXFA_Node* CJX_Object::GetPropertyInternal(int32_t index,
CXFA_Node* pNewNode = nullptr;
for (; iCount <= index; ++iCount) {
- pNewNode = GetDocument()->CreateNode(
- ToNode(GetXFAObject())->GetPacketType(), eProperty);
+ pNewNode = GetDocument()->CreateNode(xfaNode->GetPacketType(), eProperty);
if (!pNewNode)
return nullptr;
- ToNode(GetXFAObject())->InsertChild(pNewNode, nullptr);
+
+ xfaNode->InsertChild(pNewNode, nullptr);
pNewNode->SetFlag(XFA_NodeFlag_Initialized, true);
}
return pNewNode;
@@ -1304,7 +1313,7 @@ void CJX_Object::Script_Attribute_Integer(CFXJSE_Value* pValue,
void CJX_Object::Script_Som_FontColor(CFXJSE_Value* pValue,
bool bSetting,
XFA_Attribute eAttribute) {
- CXFA_Font* font = ToNode(object_.Get())->GetFont(true);
+ CXFA_Font* font = ToNode(object_.Get())->GetOrCreateFont();
if (!font)
return;
@@ -1329,8 +1338,8 @@ void CJX_Object::Script_Som_FontColor(CFXJSE_Value* pValue,
void CJX_Object::Script_Som_FillColor(CFXJSE_Value* pValue,
bool bSetting,
XFA_Attribute eAttribute) {
- CXFA_Border* border = ToNode(object_.Get())->GetBorder(true);
- CXFA_Fill* borderfill = border->GetFill(true);
+ CXFA_Border* border = ToNode(object_.Get())->GetOrCreateBorder();
+ CXFA_Fill* borderfill = border->GetOrCreateFill();
if (!borderfill)
return;
@@ -1357,7 +1366,7 @@ void CJX_Object::Script_Som_FillColor(CFXJSE_Value* pValue,
void CJX_Object::Script_Som_BorderColor(CFXJSE_Value* pValue,
bool bSetting,
XFA_Attribute eAttribute) {
- CXFA_Border* border = ToNode(object_.Get())->GetBorder(true);
+ CXFA_Border* border = ToNode(object_.Get())->GetOrCreateBorder();
int32_t iSize = border->CountEdges();
if (bSetting) {
int32_t r = 0;
@@ -1384,7 +1393,7 @@ void CJX_Object::Script_Som_BorderColor(CFXJSE_Value* pValue,
void CJX_Object::Script_Som_BorderWidth(CFXJSE_Value* pValue,
bool bSetting,
XFA_Attribute eAttribute) {
- CXFA_Border* border = ToNode(object_.Get())->GetBorder(true);
+ CXFA_Border* border = ToNode(object_.Get())->GetOrCreateBorder();
if (bSetting) {
CXFA_Measurement thickness = border->GetEdge(0)->GetMSThickness();
pValue->SetString(thickness.ToString().UTF8Encode().AsStringView());
@@ -1402,9 +1411,9 @@ void CJX_Object::Script_Som_Message(CFXJSE_Value* pValue,
bool bSetting,
XFA_SOM_MESSAGETYPE iMessageType) {
bool bNew = false;
- CXFA_Validate* validate = ToNode(object_.Get())->GetValidate(false);
+ CXFA_Validate* validate = ToNode(object_.Get())->GetValidate();
if (!validate) {
- validate = ToNode(object_.Get())->GetValidate(true);
+ validate = ToNode(object_.Get())->GetOrCreateValidate();
bNew = true;
}
@@ -1586,7 +1595,7 @@ void CJX_Object::Script_Som_DataNode(CFXJSE_Value* pValue,
void CJX_Object::Script_Som_Mandatory(CFXJSE_Value* pValue,
bool bSetting,
XFA_Attribute eAttribute) {
- CXFA_Validate* validate = ToNode(object_.Get())->GetValidate(true);
+ CXFA_Validate* validate = ToNode(object_.Get())->GetOrCreateValidate();
if (!validate)
return;
diff --git a/fxjs/xfa/cjx_object.h b/fxjs/xfa/cjx_object.h
index 87a164ff8b..c252b45036 100644
--- a/fxjs/xfa/cjx_object.h
+++ b/fxjs/xfa/cjx_object.h
@@ -96,8 +96,15 @@ class CJX_Object {
WideString GetContent(bool bScriptModify);
template <typename T>
- T* GetProperty(int32_t index, XFA_Element eType, bool bCreateProperty) {
- return static_cast<T*>(GetPropertyInternal(index, eType, bCreateProperty));
+ T* GetProperty(int32_t index, XFA_Element eType) const {
+ CXFA_Node* node;
+ int32_t count;
+ std::tie(node, count) = GetPropertyInternal(index, eType);
+ return static_cast<T*>(node);
+ }
+ template <typename T>
+ T* GetOrCreateProperty(int32_t index, XFA_Element eType) {
+ return static_cast<T*>(GetOrCreatePropertyInternal(index, eType));
}
void SetAttributeValue(const WideString& wsValue,
@@ -227,9 +234,9 @@ class CJX_Object {
bool bSetting,
XFA_Attribute eAttribute);
- CXFA_Node* GetPropertyInternal(int32_t index,
- XFA_Element eType,
- bool bCreateProperty);
+ std::pair<CXFA_Node*, int32_t> GetPropertyInternal(int32_t index,
+ XFA_Element eType) const;
+ CXFA_Node* GetOrCreatePropertyInternal(int32_t index, XFA_Element eType);
void OnChanged(XFA_Attribute eAttr, bool bNotify, bool bScriptModify);
void OnChanging(XFA_Attribute eAttr, bool bNotify);
diff --git a/xfa/fxfa/cxfa_ffdocview.cpp b/xfa/fxfa/cxfa_ffdocview.cpp
index 80d40d15f6..52c4f0cb15 100644
--- a/xfa/fxfa/cxfa_ffdocview.cpp
+++ b/xfa/fxfa/cxfa_ffdocview.cpp
@@ -228,7 +228,7 @@ bool CXFA_FFDocView::ResetSingleWidgetAccData(CXFA_WidgetAcc* pWidgetAcc) {
pWidgetAcc->ResetData();
pWidgetAcc->UpdateUIDisplay(this, nullptr);
- CXFA_Validate* validate = pNode->GetValidate(false);
+ CXFA_Validate* validate = pNode->GetValidate();
if (!validate)
return true;
diff --git a/xfa/fxfa/cxfa_ffpushbutton.cpp b/xfa/fxfa/cxfa_ffpushbutton.cpp
index c494a3dd82..690a7163a0 100644
--- a/xfa/fxfa/cxfa_ffpushbutton.cpp
+++ b/xfa/fxfa/cxfa_ffpushbutton.cpp
@@ -118,7 +118,7 @@ bool CXFA_FFPushButton::PerformLayout() {
return true;
}
float CXFA_FFPushButton::GetLineWidth() {
- CXFA_Border* border = m_pNode->GetBorder(false);
+ CXFA_Border* border = m_pNode->GetBorder();
if (border && border->GetPresence() == XFA_AttributeEnum::Visible)
return border->GetEdge(0)->GetThickness();
return 0;
diff --git a/xfa/fxfa/cxfa_ffwidget.cpp b/xfa/fxfa/cxfa_ffwidget.cpp
index 47c34b0302..10ea64fd15 100644
--- a/xfa/fxfa/cxfa_ffwidget.cpp
+++ b/xfa/fxfa/cxfa_ffwidget.cpp
@@ -396,7 +396,7 @@ void XFA_BOX_Fill_Radial(CXFA_Box* box,
CXFA_GEPath& fillPath,
CFX_RectF rtFill,
const CFX_Matrix& matrix) {
- CXFA_Fill* fill = box->GetFill(false);
+ CXFA_Fill* fill = box->GetFill();
FX_ARGB crStart = fill->GetColor(false);
FX_ARGB crEnd = fill->GetRadialColor();
if (!fill->IsRadialToEdge())
@@ -416,7 +416,7 @@ void XFA_BOX_Fill_Pattern(CXFA_Box* box,
CXFA_GEPath& fillPath,
CFX_RectF rtFill,
const CFX_Matrix& matrix) {
- CXFA_Fill* fill = box->GetFill(false);
+ CXFA_Fill* fill = box->GetFill();
FX_ARGB crStart = fill->GetColor(false);
FX_ARGB crEnd = fill->GetPatternColor();
FX_HatchStyle iHatch = FX_HatchStyle::Cross;
@@ -450,7 +450,7 @@ void XFA_BOX_Fill_Linear(CXFA_Box* box,
CXFA_GEPath& fillPath,
CFX_RectF rtFill,
const CFX_Matrix& matrix) {
- CXFA_Fill* fill = box->GetFill(false);
+ CXFA_Fill* fill = box->GetFill();
FX_ARGB crStart = fill->GetColor(false);
FX_ARGB crEnd = fill->GetLinearColor();
@@ -488,7 +488,7 @@ void XFA_BOX_Fill(CXFA_Box* box,
const CFX_RectF& rtWidget,
const CFX_Matrix& matrix,
uint32_t dwFlags) {
- CXFA_Fill* fill = box->GetFill(false);
+ CXFA_Fill* fill = box->GetFill();
if (!fill || !fill->IsVisible())
return;
@@ -982,7 +982,7 @@ void CXFA_FFWidget::RenderWidget(CXFA_Graphics* pGS,
if (!IsMatchVisibleStatus(dwStatus))
return;
- CXFA_Border* border = m_pNode->GetBorder(false);
+ CXFA_Border* border = m_pNode->GetBorder();
if (!border)
return;
diff --git a/xfa/fxfa/cxfa_ffwidgethandler.cpp b/xfa/fxfa/cxfa_ffwidgethandler.cpp
index b70facd3ed..aece6c8b00 100644
--- a/xfa/fxfa/cxfa_ffwidgethandler.cpp
+++ b/xfa/fxfa/cxfa_ffwidgethandler.cpp
@@ -198,7 +198,7 @@ bool CXFA_FFWidgetHandler::HasEvent(CXFA_WidgetAcc* pWidgetAcc,
return calc && calc->GetScript();
}
case XFA_EVENT_Validate: {
- CXFA_Validate* validate = node->GetValidate(false);
+ CXFA_Validate* validate = node->GetValidate();
return validate && validate->GetScript();
}
default:
diff --git a/xfa/fxfa/cxfa_textprovider.cpp b/xfa/fxfa/cxfa_textprovider.cpp
index e9ed0330a1..1007c6d646 100644
--- a/xfa/fxfa/cxfa_textprovider.cpp
+++ b/xfa/fxfa/cxfa_textprovider.cpp
@@ -126,12 +126,12 @@ CXFA_Para* CXFA_TextProvider::GetPara() {
CXFA_Font* CXFA_TextProvider::GetFont() {
if (m_eType == XFA_TEXTPROVIDERTYPE_Text)
- return m_pWidgetAcc->GetNode()->GetFont(false);
+ return m_pWidgetAcc->GetNode()->GetFont();
CXFA_Caption* pNode = m_pWidgetAcc->GetNode()->GetChild<CXFA_Caption>(
0, XFA_Element::Caption, false);
CXFA_Font* font = pNode->GetChild<CXFA_Font>(0, XFA_Element::Font, false);
- return font ? font : m_pWidgetAcc->GetNode()->GetFont(false);
+ return font ? font : m_pWidgetAcc->GetNode()->GetFont();
}
bool CXFA_TextProvider::IsCheckButtonAndAutoWidth() {
diff --git a/xfa/fxfa/cxfa_widgetacc.cpp b/xfa/fxfa/cxfa_widgetacc.cpp
index 0531c0fcb0..11b7e23d5c 100644
--- a/xfa/fxfa/cxfa_widgetacc.cpp
+++ b/xfa/fxfa/cxfa_widgetacc.cpp
@@ -219,7 +219,7 @@ std::pair<XFA_Element, CXFA_Node*> CreateUIChild(CXFA_Node* pNode) {
eWidgetType = XFA_Element::Unknown;
XFA_Element eUIType = XFA_Element::Unknown;
auto* defValue =
- pNode->JSObject()->GetProperty<CXFA_Value>(0, XFA_Element::Value, true);
+ pNode->JSObject()->GetOrCreateProperty<CXFA_Value>(0, XFA_Element::Value);
XFA_Element eValueType =
defValue ? defValue->GetChildValueClassID() : XFA_Element::Unknown;
switch (eValueType) {
@@ -257,7 +257,7 @@ std::pair<XFA_Element, CXFA_Node*> CreateUIChild(CXFA_Node* pNode) {
CXFA_Node* pUIChild = nullptr;
CXFA_Ui* pUI =
- pNode->JSObject()->GetProperty<CXFA_Ui>(0, XFA_Element::Ui, true);
+ pNode->JSObject()->GetOrCreateProperty<CXFA_Ui>(0, XFA_Element::Ui);
CXFA_Node* pChild = pUI->GetNodeItem(XFA_NODEITEM_FirstChild);
for (; pChild; pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling)) {
XFA_Element eChildType = pChild->GetElementType();
@@ -303,10 +303,11 @@ std::pair<XFA_Element, CXFA_Node*> CreateUIChild(CXFA_Node* pNode) {
if (!pUIChild) {
if (eUIType == XFA_Element::Unknown) {
eUIType = XFA_Element::TextEdit;
- defValue->JSObject()->GetProperty<CXFA_Text>(0, XFA_Element::Text, true);
+ defValue->JSObject()->GetOrCreateProperty<CXFA_Text>(0,
+ XFA_Element::Text);
}
return {eWidgetType,
- pUI->JSObject()->GetProperty<CXFA_Node>(0, eUIType, true)};
+ pUI->JSObject()->GetOrCreateProperty<CXFA_Node>(0, eUIType)};
}
if (eUIType != XFA_Element::Unknown)
@@ -349,7 +350,7 @@ std::pair<XFA_Element, CXFA_Node*> CreateUIChild(CXFA_Node* pNode) {
eValueType = XFA_Element::Text;
break;
}
- defValue->JSObject()->GetProperty<CXFA_Node>(0, eValueType, true);
+ defValue->JSObject()->GetOrCreateProperty<CXFA_Node>(0, eValueType);
return {eWidgetType, pUIChild};
}
@@ -510,7 +511,7 @@ void CXFA_WidgetAcc::CalcCaptionSize(CXFA_FFDoc* doc, CFX_SizeF& szCap) {
if (font) {
fFontSize = font->GetFontSize();
} else {
- CXFA_Font* widgetfont = m_pNode->GetFont(false);
+ CXFA_Font* widgetfont = m_pNode->GetFont();
if (widgetfont)
fFontSize = widgetfont->GetFontSize();
}
@@ -1284,7 +1285,7 @@ void CXFA_WidgetAcc::SetImageEditImage(
RetainPtr<CFGAS_GEFont> CXFA_WidgetAcc::GetFDEFont(CXFA_FFDoc* doc) {
WideString wsFontName = L"Courier";
uint32_t dwFontStyle = 0;
- CXFA_Font* font = m_pNode->GetFont(false);
+ CXFA_Font* font = m_pNode->GetFont();
if (font) {
if (font->IsBold())
dwFontStyle |= FXFONT_BOLD;
@@ -1339,7 +1340,7 @@ std::vector<CXFA_Event*> CXFA_WidgetAcc::GetEventByActivity(
CXFA_Border* CXFA_WidgetAcc::GetUIBorder() {
CXFA_Node* pUIChild = GetUIChild();
return pUIChild ? pUIChild->JSObject()->GetProperty<CXFA_Border>(
- 0, XFA_Element::Border, false)
+ 0, XFA_Element::Border)
: nullptr;
}
@@ -1347,8 +1348,8 @@ CFX_RectF CXFA_WidgetAcc::GetUIMargin() {
CXFA_Node* pUIChild = GetUIChild();
CXFA_Margin* mgUI = nullptr;
if (pUIChild) {
- mgUI = pUIChild->JSObject()->GetProperty<CXFA_Margin>(
- 0, XFA_Element::Margin, false);
+ mgUI =
+ pUIChild->JSObject()->GetProperty<CXFA_Margin>(0, XFA_Element::Margin);
}
if (!mgUI)
diff --git a/xfa/fxfa/parser/cxfa_box.cpp b/xfa/fxfa/parser/cxfa_box.cpp
index 3bc641bbcd..443362f449 100644
--- a/xfa/fxfa/parser/cxfa_box.cpp
+++ b/xfa/fxfa/parser/cxfa_box.cpp
@@ -82,8 +82,10 @@ int32_t CXFA_Box::CountEdges() {
}
CXFA_Edge* CXFA_Box::GetEdge(int32_t nIndex) {
- return JSObject()->GetProperty<CXFA_Edge>(nIndex, XFA_Element::Edge,
- nIndex == 0);
+ if (nIndex == 0)
+ return JSObject()->GetOrCreateProperty<CXFA_Edge>(nIndex,
+ XFA_Element::Edge);
+ return JSObject()->GetProperty<CXFA_Edge>(nIndex, XFA_Element::Edge);
}
std::vector<CXFA_Stroke*> CXFA_Box::GetStrokes() {
@@ -102,8 +104,12 @@ Optional<int32_t> CXFA_Box::GetSweepAngle() {
return JSObject()->TryInteger(XFA_Attribute::SweepAngle, false);
}
-CXFA_Fill* CXFA_Box::GetFill(bool bModified) {
- return JSObject()->GetProperty<CXFA_Fill>(0, XFA_Element::Fill, bModified);
+CXFA_Fill* CXFA_Box::GetFill() const {
+ return JSObject()->GetProperty<CXFA_Fill>(0, XFA_Element::Fill);
+}
+
+CXFA_Fill* CXFA_Box::GetOrCreateFill() {
+ return JSObject()->GetOrCreateProperty<CXFA_Fill>(0, XFA_Element::Fill);
}
CXFA_Margin* CXFA_Box::GetMargin() {
@@ -130,8 +136,14 @@ std::vector<CXFA_Stroke*> CXFA_Box::GetStrokesInternal(bool bNull) {
strokes.resize(8);
for (int32_t i = 0, j = 0; i < 4; i++) {
- CXFA_Corner* corner =
- JSObject()->GetProperty<CXFA_Corner>(i, XFA_Element::Corner, i == 0);
+ CXFA_Corner* corner;
+ if (i == 0) {
+ corner =
+ JSObject()->GetOrCreateProperty<CXFA_Corner>(i, XFA_Element::Corner);
+ } else {
+ corner = JSObject()->GetProperty<CXFA_Corner>(i, XFA_Element::Corner);
+ }
+
if (corner || i == 0) {
strokes[j] = corner;
} else if (!bNull) {
@@ -142,8 +154,12 @@ std::vector<CXFA_Stroke*> CXFA_Box::GetStrokesInternal(bool bNull) {
}
j++;
- CXFA_Edge* edge =
- JSObject()->GetProperty<CXFA_Edge>(i, XFA_Element::Edge, i == 0);
+ CXFA_Edge* edge;
+ if (i == 0)
+ edge = JSObject()->GetOrCreateProperty<CXFA_Edge>(i, XFA_Element::Edge);
+ else
+ edge = JSObject()->GetProperty<CXFA_Edge>(i, XFA_Element::Edge);
+
if (edge || i == 0) {
strokes[j] = edge;
} else if (!bNull) {
diff --git a/xfa/fxfa/parser/cxfa_box.h b/xfa/fxfa/parser/cxfa_box.h
index f995f5bb09..c85d0164af 100644
--- a/xfa/fxfa/parser/cxfa_box.h
+++ b/xfa/fxfa/parser/cxfa_box.h
@@ -31,7 +31,8 @@ class CXFA_Box : public CXFA_Node {
int32_t CountEdges();
CXFA_Edge* GetEdge(int32_t nIndex);
- CXFA_Fill* GetFill(bool bModified);
+ CXFA_Fill* GetFill() const;
+ CXFA_Fill* GetOrCreateFill();
CXFA_Margin* GetMargin();
std::vector<CXFA_Stroke*> GetStrokes();
diff --git a/xfa/fxfa/parser/cxfa_fill.cpp b/xfa/fxfa/parser/cxfa_fill.cpp
index 5b6c69eb24..c55dd7e0e1 100644
--- a/xfa/fxfa/parser/cxfa_fill.cpp
+++ b/xfa/fxfa/parser/cxfa_fill.cpp
@@ -61,7 +61,7 @@ bool CXFA_Fill::IsVisible() {
void CXFA_Fill::SetColor(FX_ARGB color) {
CXFA_Color* pNode =
- JSObject()->GetProperty<CXFA_Color>(0, XFA_Element::Color, true);
+ JSObject()->GetOrCreateProperty<CXFA_Color>(0, XFA_Element::Color);
int a;
int r;
int g;
@@ -166,17 +166,17 @@ FX_ARGB CXFA_Fill::GetRadialColor() {
}
CXFA_Stipple* CXFA_Fill::GetStipple() {
- return JSObject()->GetProperty<CXFA_Stipple>(0, XFA_Element::Stipple, true);
+ return JSObject()->GetOrCreateProperty<CXFA_Stipple>(0, XFA_Element::Stipple);
}
CXFA_Radial* CXFA_Fill::GetRadial() {
- return JSObject()->GetProperty<CXFA_Radial>(0, XFA_Element::Radial, true);
+ return JSObject()->GetOrCreateProperty<CXFA_Radial>(0, XFA_Element::Radial);
}
CXFA_Linear* CXFA_Fill::GetLinear() {
- return JSObject()->GetProperty<CXFA_Linear>(0, XFA_Element::Linear, true);
+ return JSObject()->GetOrCreateProperty<CXFA_Linear>(0, XFA_Element::Linear);
}
CXFA_Pattern* CXFA_Fill::GetPattern() {
- return JSObject()->GetProperty<CXFA_Pattern>(0, XFA_Element::Pattern, true);
+ return JSObject()->GetOrCreateProperty<CXFA_Pattern>(0, XFA_Element::Pattern);
}
diff --git a/xfa/fxfa/parser/cxfa_font.cpp b/xfa/fxfa/parser/cxfa_font.cpp
index c78cbd14b8..c78e926b27 100644
--- a/xfa/fxfa/parser/cxfa_font.cpp
+++ b/xfa/fxfa/parser/cxfa_font.cpp
@@ -125,7 +125,7 @@ bool CXFA_Font::IsItalic() {
void CXFA_Font::SetColor(FX_ARGB color) {
JSObject()
- ->GetProperty<CXFA_Fill>(0, XFA_Element::Fill, true)
+ ->GetOrCreateProperty<CXFA_Fill>(0, XFA_Element::Fill)
->SetColor(color);
}
diff --git a/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp b/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp
index 20902906f0..93822521ef 100644
--- a/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp
+++ b/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp
@@ -287,8 +287,9 @@ bool CXFA_LayoutPageMgr::InitLayoutPage(CXFA_Node* pFormNode) {
if (!pTemplateNode)
return false;
- m_pTemplatePageSetRoot = pTemplateNode->JSObject()->GetProperty<CXFA_PageSet>(
- 0, XFA_Element::PageSet, true);
+ m_pTemplatePageSetRoot =
+ pTemplateNode->JSObject()->GetOrCreateProperty<CXFA_PageSet>(
+ 0, XFA_Element::PageSet);
ASSERT(m_pTemplatePageSetRoot);
if (m_pPageSetLayoutItemRoot) {
m_pPageSetLayoutItemRoot->m_pParent = nullptr;
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp
index 1da6f56781..e3ece5d57a 100644
--- a/xfa/fxfa/parser/cxfa_node.cpp
+++ b/xfa/fxfa/parser/cxfa_node.cpp
@@ -1556,46 +1556,54 @@ int32_t CXFA_Node::GetRotate() {
return degrees ? XFA_MapRotation(*degrees) / 90 * 90 : 0;
}
-CXFA_Border* CXFA_Node::GetBorder(bool bModified) {
- return JSObject()->GetProperty<CXFA_Border>(0, XFA_Element::Border,
- bModified);
+CXFA_Border* CXFA_Node::GetBorder() const {
+ return JSObject()->GetProperty<CXFA_Border>(0, XFA_Element::Border);
}
-CXFA_Caption* CXFA_Node::GetCaption() {
- return JSObject()->GetProperty<CXFA_Caption>(0, XFA_Element::Caption, false);
+CXFA_Border* CXFA_Node::GetOrCreateBorder() {
+ return JSObject()->GetOrCreateProperty<CXFA_Border>(0, XFA_Element::Border);
}
-CXFA_Font* CXFA_Node::GetFont(bool bModified) {
- return JSObject()->GetProperty<CXFA_Font>(0, XFA_Element::Font, bModified);
+CXFA_Caption* CXFA_Node::GetCaption() const {
+ return JSObject()->GetProperty<CXFA_Caption>(0, XFA_Element::Caption);
}
-float CXFA_Node::GetFontSize() {
- CXFA_Font* font = GetFont(false);
+CXFA_Font* CXFA_Node::GetOrCreateFont() {
+ return JSObject()->GetOrCreateProperty<CXFA_Font>(0, XFA_Element::Font);
+}
+
+CXFA_Font* CXFA_Node::GetFont() const {
+ return JSObject()->GetProperty<CXFA_Font>(0, XFA_Element::Font);
+}
+
+float CXFA_Node::GetFontSize() const {
+ CXFA_Font* font = GetFont();
float fFontSize = font ? font->GetFontSize() : 10.0f;
return fFontSize < 0.1f ? 10.0f : fFontSize;
}
-float CXFA_Node::GetLineHeight() {
+float CXFA_Node::GetLineHeight() const {
float fLineHeight = 0;
CXFA_Para* para = GetPara();
if (para)
fLineHeight = para->GetLineHeight();
+
if (fLineHeight < 1)
fLineHeight = GetFontSize() * 1.2f;
return fLineHeight;
}
-FX_ARGB CXFA_Node::GetTextColor() {
- CXFA_Font* font = GetFont(false);
+FX_ARGB CXFA_Node::GetTextColor() const {
+ CXFA_Font* font = GetFont();
return font ? font->GetColor() : 0xFF000000;
}
-CXFA_Margin* CXFA_Node::GetMargin() {
- return JSObject()->GetProperty<CXFA_Margin>(0, XFA_Element::Margin, false);
+CXFA_Margin* CXFA_Node::GetMargin() const {
+ return JSObject()->GetProperty<CXFA_Margin>(0, XFA_Element::Margin);
}
-CXFA_Para* CXFA_Node::GetPara() {
- return JSObject()->GetProperty<CXFA_Para>(0, XFA_Element::Para, false);
+CXFA_Para* CXFA_Node::GetPara() const {
+ return JSObject()->GetProperty<CXFA_Para>(0, XFA_Element::Para);
}
bool CXFA_Node::IsOpenAccess() {
@@ -1611,26 +1619,28 @@ bool CXFA_Node::IsOpenAccess() {
CXFA_Value* CXFA_Node::GetDefaultValue() {
CXFA_Node* pTemNode = GetTemplateNode();
- return pTemNode->JSObject()->GetProperty<CXFA_Value>(0, XFA_Element::Value,
- false);
+ return pTemNode->JSObject()->GetProperty<CXFA_Value>(0, XFA_Element::Value);
+}
+
+CXFA_Value* CXFA_Node::GetFormValue() const {
+ return JSObject()->GetProperty<CXFA_Value>(0, XFA_Element::Value);
}
-CXFA_Value* CXFA_Node::GetFormValue() {
- return JSObject()->GetProperty<CXFA_Value>(0, XFA_Element::Value, false);
+CXFA_Calculate* CXFA_Node::GetCalculate() const {
+ return JSObject()->GetProperty<CXFA_Calculate>(0, XFA_Element::Calculate);
}
-CXFA_Calculate* CXFA_Node::GetCalculate() {
- return JSObject()->GetProperty<CXFA_Calculate>(0, XFA_Element::Calculate,
- false);
+CXFA_Validate* CXFA_Node::GetValidate() const {
+ return JSObject()->GetProperty<CXFA_Validate>(0, XFA_Element::Validate);
}
-CXFA_Validate* CXFA_Node::GetValidate(bool bModified) {
- return JSObject()->GetProperty<CXFA_Validate>(0, XFA_Element::Validate,
- bModified);
+CXFA_Validate* CXFA_Node::GetOrCreateValidate() {
+ return JSObject()->GetOrCreateProperty<CXFA_Validate>(0,
+ XFA_Element::Validate);
}
-CXFA_Bind* CXFA_Node::GetBind() {
- return JSObject()->GetProperty<CXFA_Bind>(0, XFA_Element::Bind, false);
+CXFA_Bind* CXFA_Node::GetBind() const {
+ return JSObject()->GetProperty<CXFA_Bind>(0, XFA_Element::Bind);
}
Optional<float> CXFA_Node::TryWidth() {
@@ -1890,7 +1900,7 @@ int32_t CXFA_Node::ProcessValidate(CXFA_FFDocView* docView, int32_t iFlags) {
if (GetElementType() == XFA_Element::Draw)
return XFA_EVENTERROR_NotExist;
- CXFA_Validate* validate = GetValidate(false);
+ CXFA_Validate* validate = GetValidate();
if (!validate)
return XFA_EVENTERROR_NotExist;
diff --git a/xfa/fxfa/parser/cxfa_node.h b/xfa/fxfa/parser/cxfa_node.h
index 1f11a2372f..374e8e55bf 100644
--- a/xfa/fxfa/parser/cxfa_node.h
+++ b/xfa/fxfa/parser/cxfa_node.h
@@ -110,7 +110,7 @@ class CXFA_Node : public CXFA_Object {
void ClearFlag(uint32_t dwFlag);
CXFA_Node* GetParent() { return m_pParent; }
- CXFA_Node* GetChildNode() { return m_pChild; }
+ CXFA_Node* GetChildNode() const { return m_pChild; }
CXFA_Node* CreateInstance(bool bDataMerge);
int32_t GetCount();
@@ -235,25 +235,28 @@ class CXFA_Node : public CXFA_Object {
bool IsOpenAccess();
- CXFA_Border* GetBorder(bool bModified);
- CXFA_Caption* GetCaption();
+ CXFA_Border* GetBorder() const;
+ CXFA_Border* GetOrCreateBorder();
+ CXFA_Caption* GetCaption() const;
- CXFA_Font* GetFont(bool bModified);
- float GetFontSize();
- FX_ARGB GetTextColor();
- float GetLineHeight();
+ CXFA_Font* GetFont() const;
+ CXFA_Font* GetOrCreateFont();
+ float GetFontSize() const;
+ FX_ARGB GetTextColor() const;
+ float GetLineHeight() const;
- CXFA_Margin* GetMargin();
- CXFA_Para* GetPara();
- CXFA_Calculate* GetCalculate();
- CXFA_Validate* GetValidate(bool bModified);
+ CXFA_Margin* GetMargin() const;
+ CXFA_Para* GetPara() const;
+ CXFA_Calculate* GetCalculate() const;
+ CXFA_Validate* GetValidate() const;
+ CXFA_Validate* GetOrCreateValidate();
CXFA_Value* GetDefaultValue();
- CXFA_Value* GetFormValue();
+ CXFA_Value* GetFormValue() const;
WideString GetRawValue();
int32_t GetRotate();
- CXFA_Bind* GetBind();
+ CXFA_Bind* GetBind() const;
Optional<float> TryWidth();
Optional<float> TryHeight();
diff --git a/xfa/fxfa/parser/cxfa_stroke.cpp b/xfa/fxfa/parser/cxfa_stroke.cpp
index caa7ef655a..8085d3e489 100644
--- a/xfa/fxfa/parser/cxfa_stroke.cpp
+++ b/xfa/fxfa/parser/cxfa_stroke.cpp
@@ -72,7 +72,7 @@ FX_ARGB CXFA_Stroke::GetColor() {
void CXFA_Stroke::SetColor(FX_ARGB argb) {
CXFA_Color* pNode =
- JSObject()->GetProperty<CXFA_Color>(0, XFA_Element::Color, true);
+ JSObject()->GetOrCreateProperty<CXFA_Color>(0, XFA_Element::Color);
int a;
int r;
int g;
diff --git a/xfa/fxfa/parser/cxfa_validate.cpp b/xfa/fxfa/parser/cxfa_validate.cpp
index 35479ca1f5..c124c3052a 100644
--- a/xfa/fxfa/parser/cxfa_validate.cpp
+++ b/xfa/fxfa/parser/cxfa_validate.cpp
@@ -75,7 +75,7 @@ XFA_AttributeEnum CXFA_Validate::GetScriptTest() {
WideString CXFA_Validate::GetMessageText(const WideString& wsMessageType) {
CXFA_Message* pNode =
- JSObject()->GetProperty<CXFA_Message>(0, XFA_Element::Message, false);
+ JSObject()->GetProperty<CXFA_Message>(0, XFA_Element::Message);
if (!pNode)
return L"";
@@ -119,7 +119,7 @@ void CXFA_Validate::SetScriptMessageText(const WideString& wsMessage) {
void CXFA_Validate::SetMessageText(const WideString& wsMessageType,
const WideString& wsMessage) {
CXFA_Message* pNode =
- JSObject()->GetProperty<CXFA_Message>(0, XFA_Element::Message, true);
+ JSObject()->GetOrCreateProperty<CXFA_Message>(0, XFA_Element::Message);
if (!pNode)
return;
diff --git a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp
index 192a7f2fe5..c8de462e0a 100644
--- a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp
+++ b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp
@@ -61,7 +61,9 @@ CXFA_Node* FormValueNode_CreateChild(CXFA_Node* pValueNode, XFA_Element iType) {
if (!pChildNode) {
if (iType == XFA_Element::Unknown)
return nullptr;
- pChildNode = pValueNode->JSObject()->GetProperty<CXFA_Node>(0, iType, true);
+
+ pChildNode =
+ pValueNode->JSObject()->GetOrCreateProperty<CXFA_Node>(0, iType);
}
return pChildNode;
}
@@ -133,8 +135,8 @@ void CreateDataBinding(CXFA_Node* pFormNode,
CXFA_WidgetAcc* pWidgetAcc = pFormNode->GetWidgetAcc();
ASSERT(pWidgetAcc);
XFA_Element eUIType = pWidgetAcc->GetUIType();
- auto* defValue = pFormNode->JSObject()->GetProperty<CXFA_Value>(
- 0, XFA_Element::Value, true);
+ auto* defValue = pFormNode->JSObject()->GetOrCreateProperty<CXFA_Value>(
+ 0, XFA_Element::Value);
if (!bDataToForm) {
WideString wsValue;
switch (eUIType) {
@@ -240,8 +242,9 @@ void CreateDataBinding(CXFA_Node* pFormNode,
if (pChild->GetElementType() != XFA_Element::Field)
continue;
- CXFA_Value* pValue = pChild->JSObject()->GetProperty<CXFA_Value>(
- 0, XFA_Element::Value, true);
+ CXFA_Value* pValue =
+ pChild->JSObject()->GetOrCreateProperty<CXFA_Value>(
+ 0, XFA_Element::Value);
CXFA_Items* pItems =
pChild->GetChild<CXFA_Items>(0, XFA_Element::Items, false);
CXFA_Node* pText =
@@ -265,8 +268,9 @@ void CreateDataBinding(CXFA_Node* pFormNode,
wsValue = pWidgetAcc->NormalizeNumStr(wsValue);
pDataNode->JSObject()->SetAttributeValue(
wsValue, pWidgetAcc->GetFormatDataValue(wsValue), false, false);
- CXFA_Value* pValue = pFormNode->JSObject()->GetProperty<CXFA_Value>(
- 0, XFA_Element::Value, true);
+ CXFA_Value* pValue =
+ pFormNode->JSObject()->GetOrCreateProperty<CXFA_Value>(
+ 0, XFA_Element::Value);
FormValueNode_SetChildContent(pValue, wsValue, XFA_Element::Float);
break;
}