1 // Copyright 2017 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 
7 #include "fxjs/xfa/cjx_source.h"
8 
9 #include <vector>
10 
11 #include "fxjs/js_resources.h"
12 #include "fxjs/xfa/cfxjse_value.h"
13 #include "xfa/fxfa/parser/cxfa_source.h"
14 
15 const CJX_MethodSpec CJX_Source::MethodSpecs[] = {
16     {"addNew", addNew_static},
17     {"cancel", cancel_static},
18     {"cancelBatch", cancelBatch_static},
19     {"close", close_static},
20     {"delete", deleteItem_static},
21     {"first", first_static},
22     {"hasDataChanged", hasDataChanged_static},
23     {"isBOF", isBOF_static},
24     {"isEOF", isEOF_static},
25     {"last", last_static},
26     {"next", next_static},
27     {"open", open_static},
28     {"previous", previous_static},
29     {"requery", requery_static},
30     {"resync", resync_static},
31     {"update", update_static},
32     {"updateBatch", updateBatch_static}};
33 
CJX_Source(CXFA_Source * src)34 CJX_Source::CJX_Source(CXFA_Source* src) : CJX_Node(src) {
35   DefineMethods(MethodSpecs);
36 }
37 
~CJX_Source()38 CJX_Source::~CJX_Source() {}
39 
DynamicTypeIs(TypeTag eType) const40 bool CJX_Source::DynamicTypeIs(TypeTag eType) const {
41   return eType == static_type__ || ParentType__::DynamicTypeIs(eType);
42 }
43 
next(CFX_V8 * runtime,const std::vector<v8::Local<v8::Value>> & params)44 CJS_Result CJX_Source::next(CFX_V8* runtime,
45                             const std::vector<v8::Local<v8::Value>>& params) {
46   if (!params.empty())
47     return CJS_Result::Failure(JSMessage::kParamError);
48 
49   return CJS_Result::Success();
50 }
51 
cancelBatch(CFX_V8 * runtime,const std::vector<v8::Local<v8::Value>> & params)52 CJS_Result CJX_Source::cancelBatch(
53     CFX_V8* runtime,
54     const std::vector<v8::Local<v8::Value>>& params) {
55   if (!params.empty())
56     return CJS_Result::Failure(JSMessage::kParamError);
57 
58   return CJS_Result::Success();
59 }
60 
first(CFX_V8 * runtime,const std::vector<v8::Local<v8::Value>> & params)61 CJS_Result CJX_Source::first(CFX_V8* runtime,
62                              const std::vector<v8::Local<v8::Value>>& params) {
63   if (!params.empty())
64     return CJS_Result::Failure(JSMessage::kParamError);
65 
66   return CJS_Result::Success();
67 }
68 
updateBatch(CFX_V8 * runtime,const std::vector<v8::Local<v8::Value>> & params)69 CJS_Result CJX_Source::updateBatch(
70     CFX_V8* runtime,
71     const std::vector<v8::Local<v8::Value>>& params) {
72   if (!params.empty())
73     return CJS_Result::Failure(JSMessage::kParamError);
74 
75   return CJS_Result::Success();
76 }
77 
previous(CFX_V8 * runtime,const std::vector<v8::Local<v8::Value>> & params)78 CJS_Result CJX_Source::previous(
79     CFX_V8* runtime,
80     const std::vector<v8::Local<v8::Value>>& params) {
81   if (!params.empty())
82     return CJS_Result::Failure(JSMessage::kParamError);
83 
84   return CJS_Result::Success();
85 }
86 
isBOF(CFX_V8 * runtime,const std::vector<v8::Local<v8::Value>> & params)87 CJS_Result CJX_Source::isBOF(CFX_V8* runtime,
88                              const std::vector<v8::Local<v8::Value>>& params) {
89   if (!params.empty())
90     return CJS_Result::Failure(JSMessage::kParamError);
91 
92   return CJS_Result::Success();
93 }
94 
isEOF(CFX_V8 * runtime,const std::vector<v8::Local<v8::Value>> & params)95 CJS_Result CJX_Source::isEOF(CFX_V8* runtime,
96                              const std::vector<v8::Local<v8::Value>>& params) {
97   if (!params.empty())
98     return CJS_Result::Failure(JSMessage::kParamError);
99 
100   return CJS_Result::Success();
101 }
102 
cancel(CFX_V8 * runtime,const std::vector<v8::Local<v8::Value>> & params)103 CJS_Result CJX_Source::cancel(CFX_V8* runtime,
104                               const std::vector<v8::Local<v8::Value>>& params) {
105   if (!params.empty())
106     return CJS_Result::Failure(JSMessage::kParamError);
107 
108   return CJS_Result::Success();
109 }
110 
update(CFX_V8 * runtime,const std::vector<v8::Local<v8::Value>> & params)111 CJS_Result CJX_Source::update(CFX_V8* runtime,
112                               const std::vector<v8::Local<v8::Value>>& params) {
113   if (!params.empty())
114     return CJS_Result::Failure(JSMessage::kParamError);
115 
116   return CJS_Result::Success();
117 }
118 
open(CFX_V8 * runtime,const std::vector<v8::Local<v8::Value>> & params)119 CJS_Result CJX_Source::open(CFX_V8* runtime,
120                             const std::vector<v8::Local<v8::Value>>& params) {
121   if (!params.empty())
122     return CJS_Result::Failure(JSMessage::kParamError);
123 
124   return CJS_Result::Success();
125 }
126 
deleteItem(CFX_V8 * runtime,const std::vector<v8::Local<v8::Value>> & params)127 CJS_Result CJX_Source::deleteItem(
128     CFX_V8* runtime,
129     const std::vector<v8::Local<v8::Value>>& params) {
130   if (!params.empty())
131     return CJS_Result::Failure(JSMessage::kParamError);
132 
133   return CJS_Result::Success();
134 }
135 
addNew(CFX_V8 * runtime,const std::vector<v8::Local<v8::Value>> & params)136 CJS_Result CJX_Source::addNew(CFX_V8* runtime,
137                               const std::vector<v8::Local<v8::Value>>& params) {
138   if (!params.empty())
139     return CJS_Result::Failure(JSMessage::kParamError);
140 
141   return CJS_Result::Success();
142 }
143 
requery(CFX_V8 * runtime,const std::vector<v8::Local<v8::Value>> & params)144 CJS_Result CJX_Source::requery(
145     CFX_V8* runtime,
146     const std::vector<v8::Local<v8::Value>>& params) {
147   if (!params.empty())
148     return CJS_Result::Failure(JSMessage::kParamError);
149 
150   return CJS_Result::Success();
151 }
152 
resync(CFX_V8 * runtime,const std::vector<v8::Local<v8::Value>> & params)153 CJS_Result CJX_Source::resync(CFX_V8* runtime,
154                               const std::vector<v8::Local<v8::Value>>& params) {
155   if (!params.empty())
156     return CJS_Result::Failure(JSMessage::kParamError);
157 
158   return CJS_Result::Success();
159 }
160 
close(CFX_V8 * runtime,const std::vector<v8::Local<v8::Value>> & params)161 CJS_Result CJX_Source::close(CFX_V8* runtime,
162                              const std::vector<v8::Local<v8::Value>>& params) {
163   if (!params.empty())
164     return CJS_Result::Failure(JSMessage::kParamError);
165 
166   return CJS_Result::Success();
167 }
168 
last(CFX_V8 * runtime,const std::vector<v8::Local<v8::Value>> & params)169 CJS_Result CJX_Source::last(CFX_V8* runtime,
170                             const std::vector<v8::Local<v8::Value>>& params) {
171   if (!params.empty())
172     return CJS_Result::Failure(JSMessage::kParamError);
173 
174   return CJS_Result::Success();
175 }
176 
hasDataChanged(CFX_V8 * runtime,const std::vector<v8::Local<v8::Value>> & params)177 CJS_Result CJX_Source::hasDataChanged(
178     CFX_V8* runtime,
179     const std::vector<v8::Local<v8::Value>>& params) {
180   if (!params.empty())
181     return CJS_Result::Failure(JSMessage::kParamError);
182 
183   return CJS_Result::Success();
184 }
185 
db(CFXJSE_Value * pValue,bool bSetting,XFA_Attribute eAttribute)186 void CJX_Source::db(CFXJSE_Value* pValue,
187                     bool bSetting,
188                     XFA_Attribute eAttribute) {}
189