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 <vector>
10
11#include "fxjs/js_resources.h"
12#include "fxjs/xfa/cfxjse_engine.h"
13#include "fxjs/xfa/cfxjse_value.h"
14#include "third_party/base/containers/span.h"
15#include "v8/include/v8-object.h"
16#include "xfa/fxfa/parser/cxfa_delta.h"
17#include "xfa/fxfa/parser/cxfa_document.h"
18#include "xfa/fxfa/parser/xfa_basic_data.h"
19
20const CJX_MethodSpec CJX_Model::MethodSpecs[] = {
21 {"clearErrorList", clearErrorList_static},
22 {"createNode", createNode_static},
23 {"isCompatibleNS", isCompatibleNS_static}};
24
26 DefineMethods(MethodSpecs);
27}
28
29CJX_Model::~CJX_Model() = default;
30
31bool CJX_Model::DynamicTypeIs(TypeTag eType) const {
32 return eType == static_type__ || ParentType__::DynamicTypeIs(eType);
33}
34
35CJS_Result CJX_Model::clearErrorList(
36 CFXJSE_Engine* runtime,
37 pdfium::span<v8::Local<v8::Value>> params) {
39}
40
41CJS_Result CJX_Model::createNode(CFXJSE_Engine* runtime,
42 pdfium::span<v8::Local<v8::Value>> params) {
43 if (params.empty() || params.size() > 3)
45
46 WideString name;
47 if (params.size() > 1)
48 name = runtime->ToWideString(params[1]);
49
50 WideString nameSpace;
51 if (params.size() == 3)
52 nameSpace = runtime->ToWideString(params[2]);
53
54 WideString tagName = runtime->ToWideString(params[0]);
55 XFA_Element eType = XFA_GetElementByName(tagName.AsStringView());
56 CXFA_Node* pNewNode = GetXFANode()->CreateSamePacketNode(eType);
57 if (!pNewNode)
58 return CJS_Result::Success(runtime->NewNull());
59
60 if (!name.IsEmpty()) {
61 if (!pNewNode->HasAttribute(XFA_Attribute::Name))
63
64 pNewNode->JSObject()->SetAttributeByEnum(XFA_Attribute::Name, name, true);
65 if (pNewNode->GetPacketType() == XFA_PacketType::Datasets)
67 }
68 return CJS_Result::Success(runtime->GetOrCreateJSBindingFromMap(pNewNode));
69}
70
71CJS_Result CJX_Model::isCompatibleNS(
72 CFXJSE_Engine* runtime,
73 pdfium::span<v8::Local<v8::Value>> params) {
74 if (params.empty())
76
77 WideString nameSpace;
78 if (params.size() >= 1)
79 nameSpace = runtime->ToWideString(params[0]);
80
81 return CJS_Result::Success(
82 runtime->NewBoolean(TryNamespace().value_or(WideString()) == nameSpace));
83}
84
85void CJX_Model::context(v8::Isolate* pIsolate,
86 v8::Local<v8::Value>* pValue,
87 bool bSetting,
88 XFA_Attribute eAttribute) {}
89
90void CJX_Model::aliasNode(v8::Isolate* pIsolate,
91 v8::Local<v8::Value>* pValue,
92 bool bSetting,
93 XFA_Attribute eAttribute) {}
friend class EventParamScope
static CJS_Result Success()
Definition cjs_result.h:27
static CJS_Result Failure(JSMessage id)
Definition cjs_result.h:34
~CJX_Model() override
CJX_Model(CXFA_Node *obj)
Definition cjx_model.cpp:25
bool DynamicTypeIs(TypeTag eType) const override
Definition cjx_model.cpp:31
bool DynamicTypeIs(TypeTag eType) const override
Definition cjx_node.cpp:112
CJX_Node(CXFA_Node *node)
Definition cjx_node.cpp:106
void DefineMethods(pdfium::span< const CJX_MethodSpec > methods)
CXFA_Node * GetXFANode() const
bool HasAttribute(XFA_Attribute attr) const
CFX_XMLNode * CreateXMLMappingNode()
XFA_PacketType GetPacketType() const
Definition cxfa_node.h:146
bool IsEmpty() const
Definition widestring.h:118
XFA_Attribute
Definition fxfa_basic.h:67
XFA_Element
Definition fxfa_basic.h:75
XFA_PacketType
Definition fxfa_basic.h:44
JSMessage