summaryrefslogtreecommitdiff
path: root/xfa/fxfa
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2018-01-03 10:43:51 -0500
committerChromium commit bot <commit-bot@chromium.org>2018-01-03 17:21:30 +0000
commitcf3d40d10276686f972761bafd005a7715f6eb1c (patch)
treed183076a13b494f0cd003c28eb13f3e12b0c5810 /xfa/fxfa
parent05dcbc931eacb72f1a11835ae282fc8434b7a434 (diff)
downloadpdfium-cf3d40d10276686f972761bafd005a7715f6eb1c.tar.xz
Fold CXFA_CalculateData into CXFA_Calculate
This CL folds CXFA_CalculateData into CXFA_Calculate as it is just a thin wrapper. Change-Id: I35efbee6c0244139a7ece19f3e8ee18bfb931dda Reviewed-on: https://pdfium-review.googlesource.com/22090 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fxfa')
-rw-r--r--xfa/fxfa/cxfa_ffdocview.cpp7
-rw-r--r--xfa/fxfa/cxfa_fffield.cpp11
-rw-r--r--xfa/fxfa/cxfa_ffwidgethandler.cpp11
-rw-r--r--xfa/fxfa/cxfa_widgetacc.cpp7
-rw-r--r--xfa/fxfa/parser/cxfa_calculate.cpp22
-rw-r--r--xfa/fxfa/parser/cxfa_calculate.h6
-rw-r--r--xfa/fxfa/parser/cxfa_calculatedata.cpp35
-rw-r--r--xfa/fxfa/parser/cxfa_calculatedata.h25
-rw-r--r--xfa/fxfa/parser/cxfa_widgetdata.cpp6
-rw-r--r--xfa/fxfa/parser/cxfa_widgetdata.h4
10 files changed, 53 insertions, 81 deletions
diff --git a/xfa/fxfa/cxfa_ffdocview.cpp b/xfa/fxfa/cxfa_ffdocview.cpp
index 3fea83c0e7..bd2b70920d 100644
--- a/xfa/fxfa/cxfa_ffdocview.cpp
+++ b/xfa/fxfa/cxfa_ffdocview.cpp
@@ -31,6 +31,7 @@
#include "xfa/fxfa/cxfa_widgetacciterator.h"
#include "xfa/fxfa/parser/cxfa_acrobat.h"
#include "xfa/fxfa/parser/cxfa_binditemsdata.h"
+#include "xfa/fxfa/parser/cxfa_calculate.h"
#include "xfa/fxfa/parser/cxfa_layoutprocessor.h"
#include "xfa/fxfa/parser/cxfa_pageset.h"
#include "xfa/fxfa/parser/cxfa_present.h"
@@ -416,13 +417,13 @@ static int32_t XFA_ProcessEvent(CXFA_FFDocView* pDocView,
}
return XFA_EVENTERROR_Disabled;
case XFA_EVENT_InitCalculate: {
- CXFA_CalculateData calcData = pWidgetAcc->GetCalculateData();
- if (!calcData.HasValidNode())
+ CXFA_Calculate* calc = pWidgetAcc->GetCalculate();
+ if (!calc)
return XFA_EVENTERROR_NotExist;
if (pWidgetAcc->GetNode()->IsUserInteractive())
return XFA_EVENTERROR_Disabled;
- return pWidgetAcc->ExecuteScript(calcData.GetScript(), pParam);
+ return pWidgetAcc->ExecuteScript(calc->GetScript(), pParam);
}
default:
break;
diff --git a/xfa/fxfa/cxfa_fffield.cpp b/xfa/fxfa/cxfa_fffield.cpp
index 2b4748771e..827d38d8c3 100644
--- a/xfa/fxfa/cxfa_fffield.cpp
+++ b/xfa/fxfa/cxfa_fffield.cpp
@@ -22,6 +22,7 @@
#include "xfa/fxfa/cxfa_ffwidget.h"
#include "xfa/fxfa/cxfa_fwltheme.h"
#include "xfa/fxfa/cxfa_textlayout.h"
+#include "xfa/fxfa/parser/cxfa_calculate.h"
#include "xfa/fxfa/parser/cxfa_node.h"
#include "xfa/fxfa/parser/cxfa_script.h"
#include "xfa/fxgraphics/cxfa_gecolor.h"
@@ -661,12 +662,12 @@ int32_t CXFA_FFField::CalculateOverride() {
}
int32_t CXFA_FFField::CalculateWidgetAcc(CXFA_WidgetAcc* pAcc) {
- CXFA_CalculateData calcData = pAcc->GetCalculateData();
- if (!calcData.HasValidNode())
+ CXFA_Calculate* calc = pAcc->GetCalculate();
+ if (!calc)
return 1;
XFA_VERSION version = pAcc->GetDoc()->GetXFADoc()->GetCurVersionMode();
- switch (calcData.GetOverride()) {
+ switch (calc->GetOverride()) {
case XFA_AttributeEnum::Error: {
if (version <= XFA_VERSION_204)
return 1;
@@ -681,7 +682,7 @@ int32_t CXFA_FFField::CalculateWidgetAcc(CXFA_WidgetAcc* pAcc) {
}
case XFA_AttributeEnum::Warning: {
if (version <= XFA_VERSION_204) {
- CXFA_Script* script = calcData.GetScript();
+ CXFA_Script* script = calc->GetScript();
if (!script)
return 1;
if (script->GetExpression().IsEmpty())
@@ -695,7 +696,7 @@ int32_t CXFA_FFField::CalculateWidgetAcc(CXFA_WidgetAcc* pAcc) {
if (!pAppProvider)
return 0;
- WideString wsMessage = calcData.GetMessageText();
+ WideString wsMessage = calc->GetMessageText();
if (!wsMessage.IsEmpty())
wsMessage += L"\r\n";
diff --git a/xfa/fxfa/cxfa_ffwidgethandler.cpp b/xfa/fxfa/cxfa_ffwidgethandler.cpp
index 7fe3c17ff5..b65321f379 100644
--- a/xfa/fxfa/cxfa_ffwidgethandler.cpp
+++ b/xfa/fxfa/cxfa_ffwidgethandler.cpp
@@ -13,6 +13,7 @@
#include "xfa/fxfa/cxfa_fffield.h"
#include "xfa/fxfa/cxfa_ffwidget.h"
#include "xfa/fxfa/cxfa_fwladapterwidgetmgr.h"
+#include "xfa/fxfa/parser/cxfa_calculate.h"
#include "xfa/fxfa/parser/cxfa_checkbutton.h"
#include "xfa/fxfa/parser/cxfa_layoutprocessor.h"
#include "xfa/fxfa/parser/cxfa_measurement.h"
@@ -192,8 +193,8 @@ bool CXFA_FFWidgetHandler::HasEvent(CXFA_WidgetAcc* pWidgetAcc,
switch (eEventType) {
case XFA_EVENT_Calculate: {
- CXFA_CalculateData calcData = pWidgetAcc->GetCalculateData();
- return calcData.HasValidNode() && calcData.GetScript();
+ CXFA_Calculate* calc = pWidgetAcc->GetCalculate();
+ return calc && calc->GetScript();
}
case XFA_EVENT_Validate: {
CXFA_Validate* validate = pWidgetAcc->GetValidate(false);
@@ -223,12 +224,12 @@ int32_t CXFA_FFWidgetHandler::ProcessEvent(CXFA_WidgetAcc* pWidgetAcc,
}
return XFA_EVENTERROR_Disabled;
case XFA_EVENT_InitCalculate: {
- CXFA_CalculateData calcData = pWidgetAcc->GetCalculateData();
- if (!calcData.HasValidNode())
+ CXFA_Calculate* calc = pWidgetAcc->GetCalculate();
+ if (!calc)
return XFA_EVENTERROR_NotExist;
if (pWidgetAcc->GetNode()->IsUserInteractive())
return XFA_EVENTERROR_Disabled;
- return pWidgetAcc->ExecuteScript(calcData.GetScript(), pParam);
+ return pWidgetAcc->ExecuteScript(calc->GetScript(), pParam);
}
default:
break;
diff --git a/xfa/fxfa/cxfa_widgetacc.cpp b/xfa/fxfa/cxfa_widgetacc.cpp
index 63f59dcc28..dcf621f442 100644
--- a/xfa/fxfa/cxfa_widgetacc.cpp
+++ b/xfa/fxfa/cxfa_widgetacc.cpp
@@ -21,6 +21,7 @@
#include "xfa/fxfa/cxfa_fontmgr.h"
#include "xfa/fxfa/cxfa_textlayout.h"
#include "xfa/fxfa/cxfa_textprovider.h"
+#include "xfa/fxfa/parser/cxfa_calculate.h"
#include "xfa/fxfa/parser/cxfa_items.h"
#include "xfa/fxfa/parser/cxfa_layoutprocessor.h"
#include "xfa/fxfa/parser/cxfa_localevalue.h"
@@ -328,15 +329,15 @@ int32_t CXFA_WidgetAcc::ProcessCalculate() {
if (GetElementType() == XFA_Element::Draw)
return XFA_EVENTERROR_NotExist;
- CXFA_CalculateData calcData = GetCalculateData();
- if (!calcData.HasValidNode())
+ CXFA_Calculate* calc = GetCalculate();
+ if (!calc)
return XFA_EVENTERROR_NotExist;
if (GetNode()->IsUserInteractive())
return XFA_EVENTERROR_Disabled;
CXFA_EventParam EventParam;
EventParam.m_eType = XFA_EVENT_Calculate;
- int32_t iRet = ExecuteScript(calcData.GetScript(), &EventParam);
+ int32_t iRet = ExecuteScript(calc->GetScript(), &EventParam);
if (iRet != XFA_EVENTERROR_Success)
return iRet;
diff --git a/xfa/fxfa/parser/cxfa_calculate.cpp b/xfa/fxfa/parser/cxfa_calculate.cpp
index 714dfdecd7..cacb326f0f 100644
--- a/xfa/fxfa/parser/cxfa_calculate.cpp
+++ b/xfa/fxfa/parser/cxfa_calculate.cpp
@@ -8,6 +8,9 @@
#include "fxjs/xfa/cjx_calculate.h"
#include "third_party/base/ptr_util.h"
+#include "xfa/fxfa/parser/cxfa_message.h"
+#include "xfa/fxfa/parser/cxfa_script.h"
+#include "xfa/fxfa/parser/cxfa_text.h"
namespace {
@@ -39,3 +42,22 @@ CXFA_Calculate::CXFA_Calculate(CXFA_Document* doc, XFA_PacketType packet)
pdfium::MakeUnique<CJX_Calculate>(this)) {}
CXFA_Calculate::~CXFA_Calculate() {}
+
+XFA_AttributeEnum CXFA_Calculate::GetOverride() {
+ return JSObject()
+ ->TryEnum(XFA_Attribute::Override, false)
+ .value_or(XFA_AttributeEnum::Error);
+}
+
+CXFA_Script* CXFA_Calculate::GetScript() {
+ return GetChild<CXFA_Script>(0, XFA_Element::Script, false);
+}
+
+WideString CXFA_Calculate::GetMessageText() {
+ CXFA_Message* pNode = GetChild<CXFA_Message>(0, XFA_Element::Message, false);
+ if (!pNode)
+ return L"";
+
+ CXFA_Text* text = pNode->GetChild<CXFA_Text>(0, XFA_Element::Text, false);
+ return text ? text->GetContent() : L"";
+}
diff --git a/xfa/fxfa/parser/cxfa_calculate.h b/xfa/fxfa/parser/cxfa_calculate.h
index 01fe853d4b..3f6ca6a8c7 100644
--- a/xfa/fxfa/parser/cxfa_calculate.h
+++ b/xfa/fxfa/parser/cxfa_calculate.h
@@ -9,10 +9,16 @@
#include "xfa/fxfa/parser/cxfa_node.h"
+class CXFA_Script;
+
class CXFA_Calculate : public CXFA_Node {
public:
CXFA_Calculate(CXFA_Document* doc, XFA_PacketType packet);
~CXFA_Calculate() override;
+
+ XFA_AttributeEnum GetOverride();
+ CXFA_Script* GetScript();
+ WideString GetMessageText();
};
#endif // XFA_FXFA_PARSER_CXFA_CALCULATE_H_
diff --git a/xfa/fxfa/parser/cxfa_calculatedata.cpp b/xfa/fxfa/parser/cxfa_calculatedata.cpp
deleted file mode 100644
index f919224687..0000000000
--- a/xfa/fxfa/parser/cxfa_calculatedata.cpp
+++ /dev/null
@@ -1,35 +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_calculatedata.h"
-
-#include "xfa/fxfa/parser/cxfa_message.h"
-#include "xfa/fxfa/parser/cxfa_node.h"
-#include "xfa/fxfa/parser/cxfa_script.h"
-#include "xfa/fxfa/parser/cxfa_text.h"
-
-CXFA_CalculateData::CXFA_CalculateData(CXFA_Node* pNode)
- : CXFA_DataData(pNode) {}
-
-XFA_AttributeEnum CXFA_CalculateData::GetOverride() const {
- return m_pNode->JSObject()
- ->TryEnum(XFA_Attribute::Override, false)
- .value_or(XFA_AttributeEnum::Error);
-}
-
-CXFA_Script* CXFA_CalculateData::GetScript() const {
- return m_pNode->GetChild<CXFA_Script>(0, XFA_Element::Script, false);
-}
-
-WideString CXFA_CalculateData::GetMessageText() const {
- CXFA_Message* pNode =
- m_pNode->GetChild<CXFA_Message>(0, XFA_Element::Message, false);
- if (!pNode)
- return L"";
-
- CXFA_Text* text = pNode->GetChild<CXFA_Text>(0, XFA_Element::Text, false);
- return text ? text->GetContent() : L"";
-}
diff --git a/xfa/fxfa/parser/cxfa_calculatedata.h b/xfa/fxfa/parser/cxfa_calculatedata.h
deleted file mode 100644
index 3e0802e6c4..0000000000
--- a/xfa/fxfa/parser/cxfa_calculatedata.h
+++ /dev/null
@@ -1,25 +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_CALCULATEDATA_H_
-#define XFA_FXFA_PARSER_CXFA_CALCULATEDATA_H_
-
-#include "core/fxcrt/fx_string.h"
-#include "xfa/fxfa/parser/cxfa_datadata.h"
-
-class CXFA_Node;
-class CXFA_Script;
-
-class CXFA_CalculateData : public CXFA_DataData {
- public:
- explicit CXFA_CalculateData(CXFA_Node* pNode);
-
- XFA_AttributeEnum GetOverride() const;
- CXFA_Script* GetScript() const;
- WideString GetMessageText() const;
-};
-
-#endif // XFA_FXFA_PARSER_CXFA_CALCULATEDATA_H_
diff --git a/xfa/fxfa/parser/cxfa_widgetdata.cpp b/xfa/fxfa/parser/cxfa_widgetdata.cpp
index 6e68ee356b..ba10f244d3 100644
--- a/xfa/fxfa/parser/cxfa_widgetdata.cpp
+++ b/xfa/fxfa/parser/cxfa_widgetdata.cpp
@@ -324,9 +324,9 @@ CXFA_Value* CXFA_WidgetData::GetFormValue() {
false);
}
-CXFA_CalculateData CXFA_WidgetData::GetCalculateData() {
- return CXFA_CalculateData(m_pNode->JSObject()->GetProperty<CXFA_Calculate>(
- 0, XFA_Element::Calculate, false));
+CXFA_Calculate* CXFA_WidgetData::GetCalculate() {
+ return m_pNode->JSObject()->GetProperty<CXFA_Calculate>(
+ 0, XFA_Element::Calculate, false);
}
CXFA_Validate* CXFA_WidgetData::GetValidate(bool bModified) {
diff --git a/xfa/fxfa/parser/cxfa_widgetdata.h b/xfa/fxfa/parser/cxfa_widgetdata.h
index 2873ff9bc1..e7016bda91 100644
--- a/xfa/fxfa/parser/cxfa_widgetdata.h
+++ b/xfa/fxfa/parser/cxfa_widgetdata.h
@@ -16,7 +16,6 @@
#include "fxbarcode/BC_Library.h"
#include "xfa/fxfa/parser/cxfa_binddata.h"
#include "xfa/fxfa/parser/cxfa_borderdata.h"
-#include "xfa/fxfa/parser/cxfa_calculatedata.h"
#include "xfa/fxfa/parser/cxfa_captiondata.h"
#include "xfa/fxfa/parser/cxfa_datadata.h"
#include "xfa/fxfa/parser/cxfa_fontdata.h"
@@ -35,6 +34,7 @@ enum XFA_VALUEPICTURE {
XFA_VALUEPICTURE_DataBind,
};
+class CXFA_Calculate;
class CXFA_Node;
class CXFA_Para;
class CXFA_Validate;
@@ -65,7 +65,7 @@ class CXFA_WidgetData : public CXFA_DataData {
CXFA_Para* GetPara();
CXFA_Value* GetDefaultValue();
CXFA_Value* GetFormValue();
- CXFA_CalculateData GetCalculateData();
+ CXFA_Calculate* GetCalculate();
CXFA_Validate* GetValidate(bool bModified);
CXFA_BorderData GetUIBorderData();