summaryrefslogtreecommitdiff
path: root/xfa/fxfa/parser
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fxfa/parser')
-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
10 files changed, 104 insertions, 69 deletions
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;
}