Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
cjx_model.cpp
Go to the documentation of this file.
1
// Copyright 2017 The PDFium Authors
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_model.h"
8
9
#
include
"core/fxcrt/span.h"
10
#
include
"fxjs/js_resources.h"
11
#
include
"fxjs/xfa/cfxjse_engine.h"
12
#
include
"fxjs/xfa/cfxjse_value.h"
13
#
include
"v8/include/v8-object.h"
14
#
include
"xfa/fxfa/parser/cxfa_delta.h"
15
#
include
"xfa/fxfa/parser/cxfa_document.h"
16
#
include
"xfa/fxfa/parser/xfa_basic_data.h"
17
18
const
CJX_MethodSpec
CJX_Model
::MethodSpecs[] = {
19
{
"clearErrorList"
, clearErrorList_static},
20
{
"createNode"
, createNode_static},
21
{
"isCompatibleNS"
, isCompatibleNS_static}};
22
23
CJX_Model
::
CJX_Model
(
CXFA_Node
* node) :
CJX_Node
(
node
)
{
24
DefineMethods(MethodSpecs);
25
}
26
27
CJX_Model
::~
CJX_Model
() =
default
;
28
29
bool
CJX_Model
::
DynamicTypeIs
(
TypeTag
eType)
const
{
30
return
eType == static_type__ || ParentType__
::
DynamicTypeIs
(eType);
31
}
32
33
CJS_Result
CJX_Model
::clearErrorList(
34
CFXJSE_Engine
* runtime,
35
pdfium::span<v8::Local<v8::Value>> params) {
36
return
CJS_Result
::
Success
(
)
;
37
}
38
39
CJS_Result
CJX_Model
::createNode(
CFXJSE_Engine
* runtime,
40
pdfium::span<v8::Local<v8::Value>> params) {
41
if
(params.empty() || params.size() > 3)
42
return
CJS_Result
::
Failure
(
JSMessage
::
kParamError
)
;
43
44
WideString
name;
45
if
(params.size() > 1)
46
name = runtime->ToWideString(params[1]);
47
48
WideString
nameSpace;
49
if
(params.size() == 3)
50
nameSpace = runtime->ToWideString(params[2]);
51
52
WideString
tagName = runtime->ToWideString(params[0]);
53
XFA_Element
eType = XFA_GetElementByName(tagName.AsStringView());
54
CXFA_Node
* pNewNode =
GetXFANode
()->CreateSamePacketNode(eType);
55
if
(!pNewNode)
56
return
CJS_Result
::
Success
(
runtime->NewNull()
)
;
57
58
if
(!name.IsEmpty()) {
59
if
(!pNewNode
->
HasAttribute
(
XFA_Attribute
::Name
)
)
60
return
CJS_Result
::
Failure
(
JSMessage
::
kParamError
)
;
61
62
pNewNode->JSObject()->SetAttributeByEnum(
XFA_Attribute
::Name, name,
true
);
63
if
(pNewNode
->
GetPacketType
(
)
==
XFA_PacketType
::Datasets)
64
pNewNode
->
CreateXMLMappingNode
(
)
;
65
}
66
return
CJS_Result
::
Success
(
runtime->GetOrCreateJSBindingFromMap(pNewNode)
)
;
67
}
68
69
CJS_Result
CJX_Model
::isCompatibleNS(
70
CFXJSE_Engine
* runtime,
71
pdfium::span<v8::Local<v8::Value>> params) {
72
if
(params.empty())
73
return
CJS_Result
::
Failure
(
JSMessage
::
kParamError
)
;
74
75
WideString
nameSpace;
76
if
(params.size() >= 1)
77
nameSpace = runtime->ToWideString(params[0]);
78
79
return
CJS_Result
::
Success
(
80
runtime->NewBoolean(
TryNamespace
().value_or(
WideString
(
)
) == nameSpace)
)
;
81
}
82
83
void
CJX_Model
::context(
v8
::Isolate* pIsolate,
84
v8::Local<v8::Value>* pValue,
85
bool
bSetting,
86
XFA_Attribute
eAttribute) {}
87
88
void
CJX_Model
::aliasNode(
v8
::Isolate* pIsolate,
89
v8::Local<v8::Value>* pValue,
90
bool
bSetting,
91
XFA_Attribute
eAttribute) {}
CFXJSE_Engine::EventParamScope
friend class EventParamScope
Definition
cfxjse_engine.h:127
CJS_Result
Definition
cjs_result.h:15
CJS_Result::Success
static CJS_Result Success()
Definition
cjs_result.h:28
CJS_Result::Failure
static CJS_Result Failure(JSMessage id)
Definition
cjs_result.h:35
CJX_Model
Definition
cjx_model.h:15
CJX_Model::~CJX_Model
~CJX_Model() override
CJX_Model::CJX_Model
CJX_Model(CXFA_Node *obj)
Definition
cjx_model.cpp:23
CJX_Model::DynamicTypeIs
bool DynamicTypeIs(TypeTag eType) const override
Definition
cjx_model.cpp:29
CJX_Node
Definition
cjx_node.h:17
CJX_Node::DynamicTypeIs
bool DynamicTypeIs(TypeTag eType) const override
Definition
cjx_node.cpp:112
CJX_Node::CJX_Node
CJX_Node(CXFA_Node *node)
Definition
cjx_node.cpp:106
CJX_Object::TypeTag
TypeTag
Definition
cjx_object.h:49
CJX_Object::GetXFANode
CXFA_Node * GetXFANode() const
Definition
cjx_object.cpp:136
CJX_Object::TryNamespace
std::optional< WideString > TryNamespace() const
Definition
cjx_object.cpp:760
CXFA_Node
Definition
cxfa_node.h:94
CXFA_Node::HasAttribute
bool HasAttribute(XFA_Attribute attr) const
Definition
cxfa_node.cpp:1188
CXFA_Node::CreateXMLMappingNode
CFX_XMLNode * CreateXMLMappingNode()
Definition
cxfa_node.cpp:1848
CXFA_Node::GetPacketType
XFA_PacketType GetPacketType() const
Definition
cxfa_node.h:147
fxcrt::WideString::WideString
WideString()=default
XFA_Attribute
XFA_Attribute
Definition
fxfa_basic.h:67
XFA_Element
XFA_Element
Definition
fxfa_basic.h:75
XFA_PacketType
XFA_PacketType
Definition
fxfa_basic.h:44
JSMessage
JSMessage
Definition
js_resources.h:12
JSMessage::kParamError
@ kParamError
Definition
js_resources.h:14
v8
Definition
fxv8_unittest.h:15
CJX_MethodSpec
Definition
cjx_object.h:40
WideString
fxcrt::WideString WideString
Definition
widestring.h:207
qtwebengine
src
3rdparty
chromium
third_party
pdfium
fxjs
xfa
cjx_model.cpp
Generated on
for Qt by
1.18.0