Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
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
18const CJX_MethodSpec CJX_Model::MethodSpecs[] = {
19 {"clearErrorList", clearErrorList_static},
20 {"createNode", createNode_static},
21 {"isCompatibleNS", isCompatibleNS_static}};
22
24 DefineMethods(MethodSpecs);
25}
26
27CJX_Model::~CJX_Model() = default;
28
29bool CJX_Model::DynamicTypeIs(TypeTag eType) const {
30 return eType == static_type__ || ParentType__::DynamicTypeIs(eType);
31}
32
33CJS_Result CJX_Model::clearErrorList(
34 CFXJSE_Engine* runtime,
35 pdfium::span<v8::Local<v8::Value>> params) {
37}
38
39CJS_Result CJX_Model::createNode(CFXJSE_Engine* runtime,
40 pdfium::span<v8::Local<v8::Value>> params) {
41 if (params.empty() || params.size() > 3)
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))
61
62 pNewNode->JSObject()->SetAttributeByEnum(XFA_Attribute::Name, name, true);
63 if (pNewNode->GetPacketType() == XFA_PacketType::Datasets)
65 }
66 return CJS_Result::Success(runtime->GetOrCreateJSBindingFromMap(pNewNode));
67}
68
69CJS_Result CJX_Model::isCompatibleNS(
70 CFXJSE_Engine* runtime,
71 pdfium::span<v8::Local<v8::Value>> params) {
72 if (params.empty())
74
75 WideString nameSpace;
76 if (params.size() >= 1)
77 nameSpace = runtime->ToWideString(params[0]);
78
80 runtime->NewBoolean(TryNamespace().value_or(WideString()) == nameSpace));
81}
82
83void CJX_Model::context(v8::Isolate* pIsolate,
84 v8::Local<v8::Value>* pValue,
85 bool bSetting,
86 XFA_Attribute eAttribute) {}
87
88void CJX_Model::aliasNode(v8::Isolate* pIsolate,
89 v8::Local<v8::Value>* pValue,
90 bool bSetting,
91 XFA_Attribute eAttribute) {}
friend class EventParamScope
static CJS_Result Success()
Definition cjs_result.h:28
static CJS_Result Failure(JSMessage id)
Definition cjs_result.h:35
~CJX_Model() override
CJX_Model(CXFA_Node *obj)
Definition cjx_model.cpp:23
bool DynamicTypeIs(TypeTag eType) const override
Definition cjx_model.cpp:29
bool DynamicTypeIs(TypeTag eType) const override
Definition cjx_node.cpp:112
CJX_Node(CXFA_Node *node)
Definition cjx_node.cpp:106
CXFA_Node * GetXFANode() const
std::optional< WideString > TryNamespace() const
bool HasAttribute(XFA_Attribute attr) const
CFX_XMLNode * CreateXMLMappingNode()
XFA_PacketType GetPacketType() const
Definition cxfa_node.h:147
WideString()=default
XFA_Attribute
Definition fxfa_basic.h:67
XFA_Element
Definition fxfa_basic.h:75
XFA_PacketType
Definition fxfa_basic.h:44
JSMessage
fxcrt::WideString WideString
Definition widestring.h:207