summaryrefslogtreecommitdiff
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
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>
-rw-r--r--BUILD.gn2
-rw-r--r--fxjs/xfa/cjx_instancemanager.cpp18
-rw-r--r--fxjs/xfa/cjx_object.cpp1
-rw-r--r--fxjs/xfa/cjx_occur.cpp13
-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
12 files changed, 75 insertions, 122 deletions
diff --git a/BUILD.gn b/BUILD.gn
index 453354414e..cb0f52dc63 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -2486,8 +2486,6 @@ if (pdf_enable_xfa) {
"xfa/fxfa/parser/cxfa_object.h",
"xfa/fxfa/parser/cxfa_occur.cpp",
"xfa/fxfa/parser/cxfa_occur.h",
- "xfa/fxfa/parser/cxfa_occurdata.cpp",
- "xfa/fxfa/parser/cxfa_occurdata.h",
"xfa/fxfa/parser/cxfa_oid.cpp",
"xfa/fxfa/parser/cxfa_oid.h",
"xfa/fxfa/parser/cxfa_oids.cpp",
diff --git a/fxjs/xfa/cjx_instancemanager.cpp b/fxjs/xfa/cjx_instancemanager.cpp
index 86f8cf3e88..4bb09dfd9f 100644
--- a/fxjs/xfa/cjx_instancemanager.cpp
+++ b/fxjs/xfa/cjx_instancemanager.cpp
@@ -16,7 +16,7 @@
#include "xfa/fxfa/parser/cxfa_document.h"
#include "xfa/fxfa/parser/cxfa_instancemanager.h"
#include "xfa/fxfa/parser/cxfa_layoutprocessor.h"
-#include "xfa/fxfa/parser/cxfa_occurdata.h"
+#include "xfa/fxfa/parser/cxfa_occur.h"
const CJX_MethodSpec CJX_InstanceManager::MethodSpecs[] = {
{"addInstance", addInstance_static},
@@ -33,13 +33,13 @@ CJX_InstanceManager::CJX_InstanceManager(CXFA_InstanceManager* mgr)
CJX_InstanceManager::~CJX_InstanceManager() {}
int32_t CJX_InstanceManager::SetInstances(int32_t iDesired) {
- CXFA_OccurData occurData(GetXFANode()->GetOccurNode());
- if (iDesired < occurData.GetMin()) {
+ CXFA_Occur* occur = GetXFANode()->GetOccur();
+ if (iDesired < occur->GetMin()) {
ThrowTooManyOccurancesException(L"min");
return 1;
}
- int32_t iMax = occurData.GetMax();
+ int32_t iMax = occur->GetMax();
if (iMax >= 0 && iDesired > iMax) {
ThrowTooManyOccurancesException(L"max");
return 2;
@@ -154,7 +154,7 @@ CJS_Return CJX_InstanceManager::removeInstance(
if (iIndex < 0 || iIndex >= iCount)
return CJS_Return(JSGetStringFromID(JSMessage::kInvalidInputError));
- int32_t iMin = CXFA_OccurData(GetXFANode()->GetOccurNode()).GetMin();
+ int32_t iMin = GetXFANode()->GetOccur()->GetMin();
if (iCount - 1 < iMin)
return CJS_Return(JSGetStringFromID(JSMessage::kTooManyOccurances));
@@ -200,7 +200,7 @@ CJS_Return CJX_InstanceManager::addInstance(
fFlags = runtime->ToBoolean(params[0]);
int32_t iCount = GetXFANode()->GetCount();
- int32_t iMax = CXFA_OccurData(GetXFANode()->GetOccurNode()).GetMax();
+ int32_t iMax = GetXFANode()->GetOccur()->GetMax();
if (iMax >= 0 && iCount >= iMax)
return CJS_Return(JSGetStringFromID(JSMessage::kTooManyOccurances));
@@ -241,7 +241,7 @@ CJS_Return CJX_InstanceManager::insertInstance(
if (iIndex < 0 || iIndex > iCount)
return CJS_Return(JSGetStringFromID(JSMessage::kInvalidInputError));
- int32_t iMax = CXFA_OccurData(GetXFANode()->GetOccurNode()).GetMax();
+ int32_t iMax = GetXFANode()->GetOccur()->GetMax();
if (iMax >= 0 && iCount >= iMax)
return CJS_Return(JSGetStringFromID(JSMessage::kInvalidInputError));
@@ -273,7 +273,7 @@ void CJX_InstanceManager::max(CFXJSE_Value* pValue,
ThrowInvalidPropertyException();
return;
}
- pValue->SetInteger(CXFA_OccurData(GetXFANode()->GetOccurNode()).GetMax());
+ pValue->SetInteger(GetXFANode()->GetOccur()->GetMax());
}
void CJX_InstanceManager::min(CFXJSE_Value* pValue,
@@ -283,7 +283,7 @@ void CJX_InstanceManager::min(CFXJSE_Value* pValue,
ThrowInvalidPropertyException();
return;
}
- pValue->SetInteger(CXFA_OccurData(GetXFANode()->GetOccurNode()).GetMin());
+ pValue->SetInteger(GetXFANode()->GetOccur()->GetMin());
}
void CJX_InstanceManager::count(CFXJSE_Value* pValue,
diff --git a/fxjs/xfa/cjx_object.cpp b/fxjs/xfa/cjx_object.cpp
index b1e3030020..b1324f1d5f 100644
--- a/fxjs/xfa/cjx_object.cpp
+++ b/fxjs/xfa/cjx_object.cpp
@@ -27,7 +27,6 @@
#include "xfa/fxfa/parser/cxfa_node.h"
#include "xfa/fxfa/parser/cxfa_object.h"
#include "xfa/fxfa/parser/cxfa_occur.h"
-#include "xfa/fxfa/parser/cxfa_occurdata.h"
#include "xfa/fxfa/parser/cxfa_proto.h"
#include "xfa/fxfa/parser/cxfa_subform.h"
#include "xfa/fxfa/parser/cxfa_validate.h"
diff --git a/fxjs/xfa/cjx_occur.cpp b/fxjs/xfa/cjx_occur.cpp
index f5540c0c7a..f57cd96cb5 100644
--- a/fxjs/xfa/cjx_occur.cpp
+++ b/fxjs/xfa/cjx_occur.cpp
@@ -10,7 +10,6 @@
#include "fxjs/cfxjse_value.h"
#include "xfa/fxfa/parser/cxfa_occur.h"
-#include "xfa/fxfa/parser/cxfa_occurdata.h"
CJX_Occur::CJX_Occur(CXFA_Occur* node) : CJX_Node(node) {}
@@ -19,23 +18,23 @@ CJX_Occur::~CJX_Occur() = default;
void CJX_Occur::max(CFXJSE_Value* pValue,
bool bSetting,
XFA_Attribute eAttribute) {
- CXFA_OccurData occurData(GetXFANode());
+ CXFA_Occur* occur = static_cast<CXFA_Occur*>(GetXFANode());
if (!bSetting) {
- pValue->SetInteger(occurData.GetMax());
+ pValue->SetInteger(occur->GetMax());
return;
}
- occurData.SetMax(pValue->ToInteger());
+ occur->SetMax(pValue->ToInteger());
}
void CJX_Occur::min(CFXJSE_Value* pValue,
bool bSetting,
XFA_Attribute eAttribute) {
- CXFA_OccurData occurData(GetXFANode());
+ CXFA_Occur* occur = static_cast<CXFA_Occur*>(GetXFANode());
if (!bSetting) {
- pValue->SetInteger(occurData.GetMin());
+ pValue->SetInteger(occur->GetMin());
return;
}
- occurData.SetMin(pValue->ToInteger());
+ occur->SetMin(pValue->ToInteger());
}
void CJX_Occur::use(CFXJSE_Value* pValue,
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 =