summaryrefslogtreecommitdiff
path: root/xfa/fxfa
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2018-01-03 11:25:05 -0500
committerChromium commit bot <commit-bot@chromium.org>2018-01-03 18:16:30 +0000
commit9647614a5dcd00d50aacf4e000fd23a5ebb13931 (patch)
tree2b05d094e17bde6a1464e92850dd67ef50e949f6 /xfa/fxfa
parentcbd4410908e2a4898fdd5e0d6d17591fc2c71f54 (diff)
downloadpdfium-9647614a5dcd00d50aacf4e000fd23a5ebb13931.tar.xz
Fold CXFA_OccurData into CXFA_Occur
This CL folds the CXFA_OccurData wrapper into CXFA_Occur. Change-Id: I52e237e4f6b76f6915c397e924037562fd9eda6a Reviewed-on: https://pdfium-review.googlesource.com/22130 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fxfa')
-rw-r--r--xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp6
-rw-r--r--xfa/fxfa/parser/cxfa_node.cpp3
-rw-r--r--xfa/fxfa/parser/cxfa_node.h3
-rw-r--r--xfa/fxfa/parser/cxfa_occur.cpp43
-rw-r--r--xfa/fxfa/parser/cxfa_occur.h10
-rw-r--r--xfa/fxfa/parser/cxfa_occurdata.cpp62
-rw-r--r--xfa/fxfa/parser/cxfa_occurdata.h30
-rw-r--r--xfa/fxfa/parser/xfa_document_datamerger_imp.cpp6
8 files changed, 60 insertions, 103 deletions
diff --git a/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp b/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp
index 0bf547a000..61863d13b4 100644
--- a/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp
+++ b/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp
@@ -27,7 +27,6 @@
#include "xfa/fxfa/parser/cxfa_node.h"
#include "xfa/fxfa/parser/cxfa_nodeiteratortemplate.h"
#include "xfa/fxfa/parser/cxfa_occur.h"
-#include "xfa/fxfa/parser/cxfa_occurdata.h"
#include "xfa/fxfa/parser/cxfa_para.h"
#include "xfa/fxfa/parser/cxfa_traversestrategy_xfanode.h"
#include "xfa/fxfa/parser/xfa_utils.h"
@@ -2851,9 +2850,8 @@ bool CXFA_ItemLayoutProcessor::JudgeLeaderOrTrailerForOccur(
if (!pTemplate)
pTemplate = pFormNode;
- int32_t iMax = CXFA_OccurData(pTemplate->GetFirstChildByClass<CXFA_Occur>(
- XFA_Element::Occur))
- .GetMax();
+ int32_t iMax =
+ pTemplate->GetFirstChildByClass<CXFA_Occur>(XFA_Element::Occur)->GetMax();
if (iMax < 0)
return true;
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp
index 3d05b53bfd..ac1398822d 100644
--- a/xfa/fxfa/parser/cxfa_node.cpp
+++ b/xfa/fxfa/parser/cxfa_node.cpp
@@ -35,7 +35,6 @@
#include "xfa/fxfa/parser/cxfa_measurement.h"
#include "xfa/fxfa/parser/cxfa_nodeiteratortemplate.h"
#include "xfa/fxfa/parser/cxfa_occur.h"
-#include "xfa/fxfa/parser/cxfa_occurdata.h"
#include "xfa/fxfa/parser/cxfa_simple_parser.h"
#include "xfa/fxfa/parser/cxfa_subform.h"
#include "xfa/fxfa/parser/cxfa_traversestrategy_xfacontainernode.h"
@@ -1067,7 +1066,7 @@ CXFA_Node* CXFA_Node::GetInstanceMgrOfSubform() {
return pInstanceMgr;
}
-CXFA_Node* CXFA_Node::GetOccurNode() {
+CXFA_Occur* CXFA_Node::GetOccur() {
return GetFirstChildByClass<CXFA_Occur>(XFA_Element::Occur);
}
diff --git a/xfa/fxfa/parser/cxfa_node.h b/xfa/fxfa/parser/cxfa_node.h
index c9f1505f2e..81d0bfc359 100644
--- a/xfa/fxfa/parser/cxfa_node.h
+++ b/xfa/fxfa/parser/cxfa_node.h
@@ -18,6 +18,7 @@
#include "xfa/fxfa/parser/cxfa_object.h"
class CFX_XMLNode;
+class CXFA_Occur;
class CXFA_WidgetData;
#define XFA_NODEFILTER_Children 0x01
@@ -204,7 +205,7 @@ class CXFA_Node : public CXFA_Object {
int32_t GetNodeSameClassIndex() const;
CXFA_Node* GetInstanceMgrOfSubform();
- CXFA_Node* GetOccurNode();
+ CXFA_Occur* GetOccur();
pdfium::Optional<bool> GetDefaultBoolean(XFA_Attribute attr) const;
pdfium::Optional<int32_t> GetDefaultInteger(XFA_Attribute attr) const;
diff --git a/xfa/fxfa/parser/cxfa_occur.cpp b/xfa/fxfa/parser/cxfa_occur.cpp
index 82424d6d6d..441394c567 100644
--- a/xfa/fxfa/parser/cxfa_occur.cpp
+++ b/xfa/fxfa/parser/cxfa_occur.cpp
@@ -38,3 +38,46 @@ CXFA_Occur::CXFA_Occur(CXFA_Document* doc, XFA_PacketType packet)
pdfium::MakeUnique<CJX_Occur>(this)) {}
CXFA_Occur::~CXFA_Occur() {}
+
+int32_t CXFA_Occur::GetMax() {
+ pdfium::Optional<int32_t> max =
+ JSObject()->TryInteger(XFA_Attribute::Max, true);
+ return max ? *max : GetMin();
+}
+
+int32_t CXFA_Occur::GetMin() {
+ pdfium::Optional<int32_t> min =
+ JSObject()->TryInteger(XFA_Attribute::Min, true);
+ return min && *min >= 0 ? *min : 1;
+}
+
+std::tuple<int32_t, int32_t, int32_t> CXFA_Occur::GetOccurInfo() {
+ int32_t iMin = GetMin();
+ int32_t iMax = GetMax();
+
+ pdfium::Optional<int32_t> init =
+ JSObject()->TryInteger(XFA_Attribute::Initial, false);
+ return {iMin, iMax, init && *init >= iMin ? *init : iMin};
+}
+
+void CXFA_Occur::SetMax(int32_t iMax) {
+ iMax = (iMax != -1 && iMax < 1) ? 1 : iMax;
+ JSObject()->SetInteger(XFA_Attribute::Max, iMax, false);
+
+ int32_t iMin = GetMin();
+ if (iMax != -1 && iMax < iMin) {
+ iMin = iMax;
+ JSObject()->SetInteger(XFA_Attribute::Min, iMin, false);
+ }
+}
+
+void CXFA_Occur::SetMin(int32_t iMin) {
+ iMin = (iMin < 0) ? 1 : iMin;
+ JSObject()->SetInteger(XFA_Attribute::Min, iMin, false);
+
+ int32_t iMax = GetMax();
+ if (iMax > 0 && iMax < iMin) {
+ iMax = iMin;
+ JSObject()->SetInteger(XFA_Attribute::Max, iMax, false);
+ }
+}
diff --git a/xfa/fxfa/parser/cxfa_occur.h b/xfa/fxfa/parser/cxfa_occur.h
index d7ed597095..3367b07ae5 100644
--- a/xfa/fxfa/parser/cxfa_occur.h
+++ b/xfa/fxfa/parser/cxfa_occur.h
@@ -7,12 +7,22 @@
#ifndef XFA_FXFA_PARSER_CXFA_OCCUR_H_
#define XFA_FXFA_PARSER_CXFA_OCCUR_H_
+#include <tuple>
+
#include "xfa/fxfa/parser/cxfa_node.h"
class CXFA_Occur : public CXFA_Node {
public:
CXFA_Occur(CXFA_Document* doc, XFA_PacketType packet);
~CXFA_Occur() override;
+
+ int32_t GetMax();
+ void SetMax(int32_t iMax);
+
+ int32_t GetMin();
+ void SetMin(int32_t iMin);
+
+ std::tuple<int32_t, int32_t, int32_t> GetOccurInfo();
};
#endif // XFA_FXFA_PARSER_CXFA_OCCUR_H_
diff --git a/xfa/fxfa/parser/cxfa_occurdata.cpp b/xfa/fxfa/parser/cxfa_occurdata.cpp
deleted file mode 100644
index 195dce719a..0000000000
--- a/xfa/fxfa/parser/cxfa_occurdata.cpp
+++ /dev/null
@@ -1,62 +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_occurdata.h"
-
-#include "xfa/fxfa/parser/cxfa_node.h"
-
-CXFA_OccurData::CXFA_OccurData(CXFA_Node* pNode) : CXFA_DataData(pNode) {}
-
-int32_t CXFA_OccurData::GetMax() const {
- if (!m_pNode)
- return 1;
-
- pdfium::Optional<int32_t> max =
- m_pNode->JSObject()->TryInteger(XFA_Attribute::Max, true);
- return max ? *max : GetMin();
-}
-
-int32_t CXFA_OccurData::GetMin() const {
- if (!m_pNode)
- return 1;
-
- pdfium::Optional<int32_t> min =
- m_pNode->JSObject()->TryInteger(XFA_Attribute::Min, true);
- return min && *min >= 0 ? *min : 1;
-}
-
-std::tuple<int32_t, int32_t, int32_t> CXFA_OccurData::GetOccurInfo() const {
- ASSERT(m_pNode);
-
- int32_t iMin = GetMin();
- int32_t iMax = GetMax();
-
- pdfium::Optional<int32_t> init =
- m_pNode->JSObject()->TryInteger(XFA_Attribute::Initial, false);
- return {iMin, iMax, init && *init >= iMin ? *init : iMin};
-}
-
-void CXFA_OccurData::SetMax(int32_t iMax) {
- iMax = (iMax != -1 && iMax < 1) ? 1 : iMax;
- m_pNode->JSObject()->SetInteger(XFA_Attribute::Max, iMax, false);
-
- int32_t iMin = GetMin();
- if (iMax != -1 && iMax < iMin) {
- iMin = iMax;
- m_pNode->JSObject()->SetInteger(XFA_Attribute::Min, iMin, false);
- }
-}
-
-void CXFA_OccurData::SetMin(int32_t iMin) {
- iMin = (iMin < 0) ? 1 : iMin;
- m_pNode->JSObject()->SetInteger(XFA_Attribute::Min, iMin, false);
-
- int32_t iMax = GetMax();
- if (iMax > 0 && iMax < iMin) {
- iMax = iMin;
- m_pNode->JSObject()->SetInteger(XFA_Attribute::Max, iMax, false);
- }
-}
diff --git a/xfa/fxfa/parser/cxfa_occurdata.h b/xfa/fxfa/parser/cxfa_occurdata.h
deleted file mode 100644
index 1b4d600875..0000000000
--- a/xfa/fxfa/parser/cxfa_occurdata.h
+++ /dev/null
@@ -1,30 +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_OCCURDATA_H_
-#define XFA_FXFA_PARSER_CXFA_OCCURDATA_H_
-
-#include <tuple>
-
-#include "core/fxcrt/fx_system.h"
-#include "xfa/fxfa/parser/cxfa_datadata.h"
-
-class CXFA_Occur;
-
-class CXFA_OccurData : public CXFA_DataData {
- public:
- explicit CXFA_OccurData(CXFA_Node* pNode);
-
- int32_t GetMax() const;
- void SetMax(int32_t iMax);
-
- int32_t GetMin() const;
- void SetMin(int32_t iMin);
-
- std::tuple<int32_t, int32_t, int32_t> GetOccurInfo() const;
-};
-
-#endif // XFA_FXFA_PARSER_CXFA_OCCURDATA_H_
diff --git a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp
index 551f9df3fa..5a36083e88 100644
--- a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp
+++ b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp
@@ -25,7 +25,6 @@
#include "xfa/fxfa/parser/cxfa_node.h"
#include "xfa/fxfa/parser/cxfa_nodeiteratortemplate.h"
#include "xfa/fxfa/parser/cxfa_occur.h"
-#include "xfa/fxfa/parser/cxfa_occurdata.h"
#include "xfa/fxfa/parser/cxfa_pageset.h"
#include "xfa/fxfa/parser/cxfa_subform.h"
#include "xfa/fxfa/parser/cxfa_template.h"
@@ -603,8 +602,7 @@ CXFA_Node* FindMatchingDataNode(
int32_t iMin;
int32_t iMax;
int32_t iInit;
- std::tie(iMin, iMax, iInit) =
- CXFA_OccurData(pTemplateNodeOccur).GetOccurInfo();
+ std::tie(iMin, iMax, iInit) = pTemplateNodeOccur->GetOccurInfo();
if (iMax == 0) {
pCurTemplateNode = pIterator->MoveToNext();
continue;
@@ -759,7 +757,7 @@ CXFA_Node* CopyContainer_SubformSet(CXFA_Document* pDocument,
int32_t iMin = 1;
if (!bOneInstance && pOccurNode) {
std::tie(iMin, iMax, iInit) =
- CXFA_OccurData(static_cast<CXFA_Occur*>(pOccurNode)).GetOccurInfo();
+ static_cast<CXFA_Occur*>(pOccurNode)->GetOccurInfo();
}
XFA_AttributeEnum eRelation =