summaryrefslogtreecommitdiff
path: root/xfa/fxfa/parser
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fxfa/parser')
-rw-r--r--xfa/fxfa/parser/cxfa_filldata.cpp96
-rw-r--r--xfa/fxfa/parser/cxfa_filldata.h30
2 files changed, 83 insertions, 43 deletions
diff --git a/xfa/fxfa/parser/cxfa_filldata.cpp b/xfa/fxfa/parser/cxfa_filldata.cpp
index 9f57b8de7d..0bbb36a891 100644
--- a/xfa/fxfa/parser/cxfa_filldata.cpp
+++ b/xfa/fxfa/parser/cxfa_filldata.cpp
@@ -12,8 +12,9 @@ CXFA_FillData::CXFA_FillData(CXFA_Node* pNode) : CXFA_DataData(pNode) {}
CXFA_FillData::~CXFA_FillData() {}
-int32_t CXFA_FillData::GetPresence() {
- return m_pNode->JSNode()->GetEnum(XFA_Attribute::Presence);
+bool CXFA_FillData::IsVisible() const {
+ return m_pNode->JSNode()->GetEnum(XFA_Attribute::Presence) ==
+ XFA_ATTRIBUTEENUM_Visible;
}
void CXFA_FillData::SetColor(FX_ARGB color) {
@@ -29,7 +30,7 @@ void CXFA_FillData::SetColor(FX_ARGB color) {
false);
}
-FX_ARGB CXFA_FillData::GetColor(bool bText) {
+FX_ARGB CXFA_FillData::GetColor(bool bText) const {
if (CXFA_Node* pNode = m_pNode->GetChild(0, XFA_Element::Color, false)) {
pdfium::Optional<WideString> wsColor =
pNode->JSNode()->TryCData(XFA_Attribute::Value, false);
@@ -41,7 +42,7 @@ FX_ARGB CXFA_FillData::GetColor(bool bText) {
return 0xFFFFFFFF;
}
-XFA_Element CXFA_FillData::GetFillType() {
+XFA_Element CXFA_FillData::GetFillType() const {
CXFA_Node* pChild = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild);
while (pChild) {
XFA_Element eType = pChild->GetElementType();
@@ -53,62 +54,85 @@ XFA_Element CXFA_FillData::GetFillType() {
return XFA_Element::Solid;
}
-int32_t CXFA_FillData::GetPattern(FX_ARGB& foreColor) {
- foreColor = 0xFF000000;
+XFA_ATTRIBUTEENUM CXFA_FillData::GetPatternType() const {
+ return GetPattern()->JSNode()->GetEnum(XFA_Attribute::Type);
+}
- CXFA_Node* pNode =
- m_pNode->JSNode()->GetProperty(0, XFA_Element::Pattern, true);
- if (CXFA_Node* pColor = pNode->GetChild(0, XFA_Element::Color, false)) {
+FX_ARGB CXFA_FillData::GetPatternColor() const {
+ if (CXFA_Node* pColor =
+ GetPattern()->GetChild(0, XFA_Element::Color, false)) {
pdfium::Optional<WideString> wsColor =
pColor->JSNode()->TryCData(XFA_Attribute::Value, false);
if (wsColor)
- foreColor = CXFA_DataData::ToColor(wsColor->AsStringView());
+ return CXFA_DataData::ToColor(wsColor->AsStringView());
}
- return pNode->JSNode()->GetEnum(XFA_Attribute::Type);
+ return 0xFF000000;
}
-int32_t CXFA_FillData::GetStipple(FX_ARGB& stippleColor) {
- stippleColor = 0xFF000000;
+int32_t CXFA_FillData::GetStippleRate() const {
+ return GetStipple()
+ ->JSNode()
+ ->TryInteger(XFA_Attribute::Rate, true)
+ .value_or(50);
+}
- CXFA_Node* pNode =
- m_pNode->JSNode()->GetProperty(0, XFA_Element::Stipple, true);
- if (CXFA_Node* pColor = pNode->GetChild(0, XFA_Element::Color, false)) {
+FX_ARGB CXFA_FillData::GetStippleColor() const {
+ if (CXFA_Node* pColor =
+ GetStipple()->GetChild(0, XFA_Element::Color, false)) {
pdfium::Optional<WideString> wsColor =
pColor->JSNode()->TryCData(XFA_Attribute::Value, false);
if (wsColor)
- stippleColor = CXFA_DataData::ToColor(wsColor->AsStringView());
+ return CXFA_DataData::ToColor(wsColor->AsStringView());
}
- return pNode->JSNode()->TryInteger(XFA_Attribute::Rate, true).value_or(50);
+ return 0xFF000000;
}
-int32_t CXFA_FillData::GetLinear(FX_ARGB& endColor) {
- endColor = 0xFF000000;
+XFA_ATTRIBUTEENUM CXFA_FillData::GetLinearType() const {
+ return GetLinear()
+ ->JSNode()
+ ->TryEnum(XFA_Attribute::Type, true)
+ .value_or(XFA_ATTRIBUTEENUM_ToRight);
+}
- CXFA_Node* pNode =
- m_pNode->JSNode()->GetProperty(0, XFA_Element::Linear, true);
- if (CXFA_Node* pColor = pNode->GetChild(0, XFA_Element::Color, false)) {
+FX_ARGB CXFA_FillData::GetLinearColor() const {
+ if (CXFA_Node* pColor = GetLinear()->GetChild(0, XFA_Element::Color, false)) {
pdfium::Optional<WideString> wsColor =
pColor->JSNode()->TryCData(XFA_Attribute::Value, false);
if (wsColor)
- endColor = CXFA_DataData::ToColor(wsColor->AsStringView());
+ return CXFA_DataData::ToColor(wsColor->AsStringView());
}
- return pNode->JSNode()
- ->TryEnum(XFA_Attribute::Type, true)
- .value_or(XFA_ATTRIBUTEENUM_ToRight);
+ return 0xFF000000;
}
-int32_t CXFA_FillData::GetRadial(FX_ARGB& endColor) {
- endColor = 0xFF000000;
+bool CXFA_FillData::IsRadialToEdge() const {
+ return GetRadial()
+ ->JSNode()
+ ->TryEnum(XFA_Attribute::Type, true)
+ .value_or(XFA_ATTRIBUTEENUM_ToEdge) == XFA_ATTRIBUTEENUM_ToEdge;
+}
- CXFA_Node* pNode =
- m_pNode->JSNode()->GetProperty(0, XFA_Element::Radial, true);
- if (CXFA_Node* pColor = pNode->GetChild(0, XFA_Element::Color, false)) {
+FX_ARGB CXFA_FillData::GetRadialColor() const {
+ if (CXFA_Node* pColor = GetRadial()->GetChild(0, XFA_Element::Color, false)) {
pdfium::Optional<WideString> wsColor =
pColor->JSNode()->TryCData(XFA_Attribute::Value, false);
if (wsColor)
- endColor = CXFA_DataData::ToColor(wsColor->AsStringView());
+ return CXFA_DataData::ToColor(wsColor->AsStringView());
}
- return pNode->JSNode()
- ->TryEnum(XFA_Attribute::Type, true)
- .value_or(XFA_ATTRIBUTEENUM_ToEdge);
+ return 0xFF000000;
+}
+
+CXFA_Node* CXFA_FillData::GetStipple() const {
+ return m_pNode->JSNode()->GetProperty(0, XFA_Element::Stipple, true);
+}
+
+CXFA_Node* CXFA_FillData::GetRadial() const {
+ return m_pNode->JSNode()->GetProperty(0, XFA_Element::Radial, true);
+}
+
+CXFA_Node* CXFA_FillData::GetLinear() const {
+ return m_pNode->JSNode()->GetProperty(0, XFA_Element::Linear, true);
+}
+
+CXFA_Node* CXFA_FillData::GetPattern() const {
+ return m_pNode->JSNode()->GetProperty(0, XFA_Element::Pattern, true);
}
diff --git a/xfa/fxfa/parser/cxfa_filldata.h b/xfa/fxfa/parser/cxfa_filldata.h
index 7faca4a95a..6890952c25 100644
--- a/xfa/fxfa/parser/cxfa_filldata.h
+++ b/xfa/fxfa/parser/cxfa_filldata.h
@@ -18,14 +18,30 @@ class CXFA_FillData : public CXFA_DataData {
explicit CXFA_FillData(CXFA_Node* pNode);
~CXFA_FillData() override;
- int32_t GetPresence();
- FX_ARGB GetColor(bool bText = false);
- XFA_Element GetFillType();
- int32_t GetPattern(FX_ARGB& foreColor);
- int32_t GetStipple(FX_ARGB& stippleColor);
- int32_t GetLinear(FX_ARGB& endColor);
- int32_t GetRadial(FX_ARGB& endColor);
+ bool IsVisible() const;
+
+ FX_ARGB GetColor(bool bText) const;
void SetColor(FX_ARGB color);
+
+ XFA_Element GetFillType() const;
+
+ XFA_ATTRIBUTEENUM GetPatternType() const;
+ FX_ARGB GetPatternColor() const;
+
+ XFA_ATTRIBUTEENUM GetLinearType() const;
+ FX_ARGB GetLinearColor() const;
+
+ int32_t GetStippleRate() const;
+ FX_ARGB GetStippleColor() const;
+
+ bool IsRadialToEdge() const;
+ FX_ARGB GetRadialColor() const;
+
+ private:
+ CXFA_Node* GetStipple() const;
+ CXFA_Node* GetRadial() const;
+ CXFA_Node* GetLinear() const;
+ CXFA_Node* GetPattern() const;
};
#endif // XFA_FXFA_PARSER_CXFA_FILLDATA_H_