summaryrefslogtreecommitdiff
path: root/xfa/fxfa/parser
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fxfa/parser')
-rw-r--r--xfa/fxfa/parser/cxfa_datadata.cpp75
-rw-r--r--xfa/fxfa/parser/cxfa_datadata.h33
-rw-r--r--xfa/fxfa/parser/cxfa_fill.cpp10
-rw-r--r--xfa/fxfa/parser/cxfa_fill.h1
-rw-r--r--xfa/fxfa/parser/cxfa_font.h1
-rw-r--r--xfa/fxfa/parser/cxfa_stroke.cpp2
-rw-r--r--xfa/fxfa/parser/cxfa_value.h1
-rw-r--r--xfa/fxfa/parser/cxfa_widgetdata.cpp97
-rw-r--r--xfa/fxfa/parser/cxfa_widgetdata.h10
9 files changed, 66 insertions, 164 deletions
diff --git a/xfa/fxfa/parser/cxfa_datadata.cpp b/xfa/fxfa/parser/cxfa_datadata.cpp
deleted file mode 100644
index 76a4651d0d..0000000000
--- a/xfa/fxfa/parser/cxfa_datadata.cpp
+++ /dev/null
@@ -1,75 +0,0 @@
-// Copyright 2016 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#include "xfa/fxfa/parser/cxfa_datadata.h"
-
-#include "core/fxcrt/fx_extension.h"
-#include "xfa/fxfa/parser/cxfa_measurement.h"
-#include "xfa/fxfa/parser/cxfa_node.h"
-
-// Static.
-FX_ARGB CXFA_DataData::ToColor(const WideStringView& wsValue) {
- uint8_t r = 0, g = 0, b = 0;
- if (wsValue.GetLength() == 0)
- return 0xff000000;
-
- int cc = 0;
- const wchar_t* str = wsValue.unterminated_c_str();
- int len = wsValue.GetLength();
- while (FXSYS_iswspace(str[cc]) && cc < len)
- cc++;
-
- if (cc >= len)
- return 0xff000000;
-
- while (cc < len) {
- if (str[cc] == ',' || !FXSYS_isDecimalDigit(str[cc]))
- break;
-
- r = r * 10 + str[cc] - '0';
- cc++;
- }
- if (cc < len && str[cc] == ',') {
- cc++;
- while (FXSYS_iswspace(str[cc]) && cc < len)
- cc++;
-
- while (cc < len) {
- if (str[cc] == ',' || !FXSYS_isDecimalDigit(str[cc]))
- break;
-
- g = g * 10 + str[cc] - '0';
- cc++;
- }
- if (cc < len && str[cc] == ',') {
- cc++;
- while (FXSYS_iswspace(str[cc]) && cc < len)
- cc++;
-
- while (cc < len) {
- if (str[cc] == ',' || !FXSYS_isDecimalDigit(str[cc]))
- break;
-
- b = b * 10 + str[cc] - '0';
- cc++;
- }
- }
- }
- return (0xff << 24) | (r << 16) | (g << 8) | b;
-}
-
-CXFA_DataData::CXFA_DataData(CXFA_Node* pNode) : m_pNode(pNode) {}
-
-CXFA_DataData::~CXFA_DataData() {}
-
-XFA_Element CXFA_DataData::GetElementType() const {
- return m_pNode ? m_pNode->GetElementType() : XFA_Element::Unknown;
-}
-
-pdfium::Optional<float> CXFA_DataData::TryMeasureAsFloat(
- XFA_Attribute attr) const {
- return m_pNode->JSObject()->TryMeasureAsFloat(attr);
-}
diff --git a/xfa/fxfa/parser/cxfa_datadata.h b/xfa/fxfa/parser/cxfa_datadata.h
deleted file mode 100644
index a77e4512cb..0000000000
--- a/xfa/fxfa/parser/cxfa_datadata.h
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright 2016 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FXFA_PARSER_CXFA_DATADATA_H_
-#define XFA_FXFA_PARSER_CXFA_DATADATA_H_
-
-#include "core/fxcrt/fx_system.h"
-#include "core/fxge/fx_dib.h"
-#include "xfa/fxfa/fxfa_basic.h"
-
-class CXFA_Node;
-
-class CXFA_DataData {
- public:
- static FX_ARGB ToColor(const WideStringView& wsValue);
-
- explicit CXFA_DataData(CXFA_Node* pNode);
- virtual ~CXFA_DataData();
-
- bool HasValidNode() const { return !!m_pNode; }
- CXFA_Node* GetNode() const { return m_pNode; }
- XFA_Element GetElementType() const;
-
- protected:
- pdfium::Optional<float> TryMeasureAsFloat(XFA_Attribute attr) const;
-
- CXFA_Node* m_pNode;
-};
-
-#endif // XFA_FXFA_PARSER_CXFA_DATADATA_H_
diff --git a/xfa/fxfa/parser/cxfa_fill.cpp b/xfa/fxfa/parser/cxfa_fill.cpp
index e4bde509c9..f5138d5e2e 100644
--- a/xfa/fxfa/parser/cxfa_fill.cpp
+++ b/xfa/fxfa/parser/cxfa_fill.cpp
@@ -77,7 +77,7 @@ FX_ARGB CXFA_Fill::GetColor(bool bText) {
pdfium::Optional<WideString> wsColor =
pNode->JSObject()->TryCData(XFA_Attribute::Value, false);
if (wsColor)
- return CXFA_DataData::ToColor(wsColor->AsStringView());
+ return StringToFXARGB(wsColor->AsStringView());
}
if (bText)
return 0xFF000000;
@@ -106,7 +106,7 @@ FX_ARGB CXFA_Fill::GetPatternColor() {
pdfium::Optional<WideString> wsColor =
pColor->JSObject()->TryCData(XFA_Attribute::Value, false);
if (wsColor)
- return CXFA_DataData::ToColor(wsColor->AsStringView());
+ return StringToFXARGB(wsColor->AsStringView());
}
return 0xFF000000;
}
@@ -124,7 +124,7 @@ FX_ARGB CXFA_Fill::GetStippleColor() {
pdfium::Optional<WideString> wsColor =
pColor->JSObject()->TryCData(XFA_Attribute::Value, false);
if (wsColor)
- return CXFA_DataData::ToColor(wsColor->AsStringView());
+ return StringToFXARGB(wsColor->AsStringView());
}
return 0xFF000000;
}
@@ -142,7 +142,7 @@ FX_ARGB CXFA_Fill::GetLinearColor() {
pdfium::Optional<WideString> wsColor =
pColor->JSObject()->TryCData(XFA_Attribute::Value, false);
if (wsColor)
- return CXFA_DataData::ToColor(wsColor->AsStringView());
+ return StringToFXARGB(wsColor->AsStringView());
}
return 0xFF000000;
}
@@ -160,7 +160,7 @@ FX_ARGB CXFA_Fill::GetRadialColor() {
pdfium::Optional<WideString> wsColor =
pColor->JSObject()->TryCData(XFA_Attribute::Value, false);
if (wsColor)
- return CXFA_DataData::ToColor(wsColor->AsStringView());
+ return StringToFXARGB(wsColor->AsStringView());
}
return 0xFF000000;
}
diff --git a/xfa/fxfa/parser/cxfa_fill.h b/xfa/fxfa/parser/cxfa_fill.h
index a5ee7609ee..a713047c5d 100644
--- a/xfa/fxfa/parser/cxfa_fill.h
+++ b/xfa/fxfa/parser/cxfa_fill.h
@@ -7,6 +7,7 @@
#ifndef XFA_FXFA_PARSER_CXFA_FILL_H_
#define XFA_FXFA_PARSER_CXFA_FILL_H_
+#include "core/fxge/fx_dib.h"
#include "xfa/fxfa/parser/cxfa_node.h"
class CXFA_Linear;
diff --git a/xfa/fxfa/parser/cxfa_font.h b/xfa/fxfa/parser/cxfa_font.h
index 833c29a530..346be76720 100644
--- a/xfa/fxfa/parser/cxfa_font.h
+++ b/xfa/fxfa/parser/cxfa_font.h
@@ -7,6 +7,7 @@
#ifndef XFA_FXFA_PARSER_CXFA_FONT_H_
#define XFA_FXFA_PARSER_CXFA_FONT_H_
+#include "core/fxge/fx_dib.h"
#include "xfa/fxfa/parser/cxfa_node.h"
class CXFA_Font : public CXFA_Node {
diff --git a/xfa/fxfa/parser/cxfa_stroke.cpp b/xfa/fxfa/parser/cxfa_stroke.cpp
index 3b8e37a728..caa7ef655a 100644
--- a/xfa/fxfa/parser/cxfa_stroke.cpp
+++ b/xfa/fxfa/parser/cxfa_stroke.cpp
@@ -66,7 +66,7 @@ FX_ARGB CXFA_Stroke::GetColor() {
if (!pNode)
return 0xFF000000;
- return CXFA_DataData::ToColor(
+ return StringToFXARGB(
pNode->JSObject()->GetCData(XFA_Attribute::Value).AsStringView());
}
diff --git a/xfa/fxfa/parser/cxfa_value.h b/xfa/fxfa/parser/cxfa_value.h
index 92400aa380..5067b715db 100644
--- a/xfa/fxfa/parser/cxfa_value.h
+++ b/xfa/fxfa/parser/cxfa_value.h
@@ -8,7 +8,6 @@
#define XFA_FXFA_PARSER_CXFA_VALUE_H_
#include "core/fxcrt/fx_string.h"
-#include "xfa/fxfa/parser/cxfa_datadata.h"
#include "xfa/fxfa/parser/cxfa_node.h"
#include "xfa/fxfa/parser/cxfa_text.h"
diff --git a/xfa/fxfa/parser/cxfa_widgetdata.cpp b/xfa/fxfa/parser/cxfa_widgetdata.cpp
index 5833655156..7771d33d01 100644
--- a/xfa/fxfa/parser/cxfa_widgetdata.cpp
+++ b/xfa/fxfa/parser/cxfa_widgetdata.cpp
@@ -223,12 +223,14 @@ CXFA_Node* CreateUIChild(CXFA_Node* pNode, XFA_Element& eWidgetType) {
} // namespace
CXFA_WidgetData::CXFA_WidgetData(CXFA_Node* pNode)
- : CXFA_DataData(pNode),
+ : m_pNode(pNode),
m_bIsNull(true),
m_bPreNull(true),
m_pUiChildNode(nullptr),
m_eUIType(XFA_Element::Unknown) {}
+CXFA_WidgetData::~CXFA_WidgetData() = default;
+
CXFA_Node* CXFA_WidgetData::GetUIChild() {
if (m_eUIType == XFA_Element::Unknown)
m_pUiChildNode = CreateUIChild(m_pNode, m_eUIType);
@@ -338,27 +340,27 @@ CXFA_Bind* CXFA_WidgetData::GetBind() {
}
pdfium::Optional<float> CXFA_WidgetData::TryWidth() {
- return TryMeasureAsFloat(XFA_Attribute::W);
+ return m_pNode->JSObject()->TryMeasureAsFloat(XFA_Attribute::W);
}
pdfium::Optional<float> CXFA_WidgetData::TryHeight() {
- return TryMeasureAsFloat(XFA_Attribute::H);
+ return m_pNode->JSObject()->TryMeasureAsFloat(XFA_Attribute::H);
}
pdfium::Optional<float> CXFA_WidgetData::TryMinWidth() {
- return TryMeasureAsFloat(XFA_Attribute::MinW);
+ return m_pNode->JSObject()->TryMeasureAsFloat(XFA_Attribute::MinW);
}
pdfium::Optional<float> CXFA_WidgetData::TryMinHeight() {
- return TryMeasureAsFloat(XFA_Attribute::MinH);
+ return m_pNode->JSObject()->TryMeasureAsFloat(XFA_Attribute::MinH);
}
pdfium::Optional<float> CXFA_WidgetData::TryMaxWidth() {
- return TryMeasureAsFloat(XFA_Attribute::MaxW);
+ return m_pNode->JSObject()->TryMeasureAsFloat(XFA_Attribute::MaxW);
}
pdfium::Optional<float> CXFA_WidgetData::TryMaxHeight() {
- return TryMeasureAsFloat(XFA_Attribute::MaxH);
+ return m_pNode->JSObject()->TryMeasureAsFloat(XFA_Attribute::MaxH);
}
CXFA_Border* CXFA_WidgetData::GetUIBorder() {
@@ -502,46 +504,8 @@ XFA_CHECKSTATE CXFA_WidgetData::GetCheckState() {
}
void CXFA_WidgetData::SetCheckState(XFA_CHECKSTATE eCheckState, bool bNotify) {
- CXFA_WidgetData exclGroup(GetExclGroupNode());
- if (exclGroup.HasValidNode()) {
- WideString wsValue;
- if (eCheckState != XFA_CHECKSTATE_Off) {
- if (CXFA_Items* pItems =
- m_pNode->GetChild<CXFA_Items>(0, XFA_Element::Items, false)) {
- CXFA_Node* pText = pItems->GetNodeItem(XFA_NODEITEM_FirstChild);
- if (pText)
- wsValue = pText->JSObject()->GetContent(false);
- }
- }
- CXFA_Node* pChild =
- exclGroup.GetNode()->GetNodeItem(XFA_NODEITEM_FirstChild);
- for (; pChild; pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling)) {
- if (pChild->GetElementType() != XFA_Element::Field)
- continue;
-
- CXFA_Items* pItem =
- pChild->GetChild<CXFA_Items>(0, XFA_Element::Items, false);
- if (!pItem)
- continue;
-
- CXFA_Node* pItemchild = pItem->GetNodeItem(XFA_NODEITEM_FirstChild);
- if (!pItemchild)
- continue;
-
- WideString text = pItemchild->JSObject()->GetContent(false);
- WideString wsChildValue = text;
- if (wsValue != text) {
- pItemchild = pItemchild->GetNodeItem(XFA_NODEITEM_NextSibling);
- if (pItemchild)
- wsChildValue = pItemchild->JSObject()->GetContent(false);
- else
- wsChildValue.clear();
- }
- CXFA_WidgetData ch(pChild);
- ch.SyncValue(wsChildValue, bNotify);
- }
- exclGroup.SyncValue(wsValue, bNotify);
- } else {
+ CXFA_Node* node = GetExclGroupNode();
+ if (!node) {
CXFA_Items* pItems =
m_pNode->GetChild<CXFA_Items>(0, XFA_Element::Items, false);
if (!pItems)
@@ -559,7 +523,46 @@ void CXFA_WidgetData::SetCheckState(XFA_CHECKSTATE eCheckState, bool bNotify) {
pText = pText->GetNodeItem(XFA_NODEITEM_NextSibling);
}
SyncValue(wsContent, bNotify);
+ return;
+ }
+
+ CXFA_WidgetData exclGroup(node);
+ WideString wsValue;
+ if (eCheckState != XFA_CHECKSTATE_Off) {
+ if (CXFA_Items* pItems =
+ m_pNode->GetChild<CXFA_Items>(0, XFA_Element::Items, false)) {
+ CXFA_Node* pText = pItems->GetNodeItem(XFA_NODEITEM_FirstChild);
+ if (pText)
+ wsValue = pText->JSObject()->GetContent(false);
+ }
+ }
+ CXFA_Node* pChild = exclGroup.GetNode()->GetNodeItem(XFA_NODEITEM_FirstChild);
+ for (; pChild; pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling)) {
+ if (pChild->GetElementType() != XFA_Element::Field)
+ continue;
+
+ CXFA_Items* pItem =
+ pChild->GetChild<CXFA_Items>(0, XFA_Element::Items, false);
+ if (!pItem)
+ continue;
+
+ CXFA_Node* pItemchild = pItem->GetNodeItem(XFA_NODEITEM_FirstChild);
+ if (!pItemchild)
+ continue;
+
+ WideString text = pItemchild->JSObject()->GetContent(false);
+ WideString wsChildValue = text;
+ if (wsValue != text) {
+ pItemchild = pItemchild->GetNodeItem(XFA_NODEITEM_NextSibling);
+ if (pItemchild)
+ wsChildValue = pItemchild->JSObject()->GetContent(false);
+ else
+ wsChildValue.clear();
+ }
+ CXFA_WidgetData ch(pChild);
+ ch.SyncValue(wsChildValue, bNotify);
}
+ exclGroup.SyncValue(wsValue, bNotify);
}
CXFA_Node* CXFA_WidgetData::GetExclGroupNode() {
diff --git a/xfa/fxfa/parser/cxfa_widgetdata.h b/xfa/fxfa/parser/cxfa_widgetdata.h
index 57e6939f37..941eead3fd 100644
--- a/xfa/fxfa/parser/cxfa_widgetdata.h
+++ b/xfa/fxfa/parser/cxfa_widgetdata.h
@@ -14,7 +14,7 @@
#include "core/fxcrt/fx_string.h"
#include "core/fxcrt/fx_system.h"
#include "fxbarcode/BC_Library.h"
-#include "xfa/fxfa/parser/cxfa_datadata.h"
+#include "xfa/fxfa/fxfa_basic.h"
enum XFA_CHECKSTATE {
XFA_CHECKSTATE_On = 0,
@@ -42,9 +42,12 @@ class CXFA_Value;
class CXFA_Validate;
class IFX_Locale;
-class CXFA_WidgetData : public CXFA_DataData {
+class CXFA_WidgetData {
public:
explicit CXFA_WidgetData(CXFA_Node* pNode);
+ virtual ~CXFA_WidgetData();
+
+ CXFA_Node* GetNode() const { return m_pNode; }
CXFA_Node* GetUIChild();
XFA_Element GetUIType();
@@ -174,6 +177,9 @@ class CXFA_WidgetData : public CXFA_DataData {
bool IsNull() const { return m_bIsNull; }
void SetIsNull(bool val) { m_bIsNull = val; }
+ protected:
+ CXFA_Node* m_pNode;
+
private:
CXFA_Bind* GetBind();
void SyncValue(const WideString& wsValue, bool bNotify);