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_boolean.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_boolean.h"
8
9#include "fxjs/fxv8.h"
10#include "fxjs/xfa/cfxjse_value.h"
11#include "v8/include/v8-primitive.h"
12#include "xfa/fxfa/parser/cxfa_boolean.h"
13
14CJX_Boolean::CJX_Boolean(CXFA_Boolean* node) : CJX_Object(node) {}
15
16CJX_Boolean::~CJX_Boolean() = default;
17
18bool CJX_Boolean::DynamicTypeIs(TypeTag eType) const {
19 return eType == static_type__ || ParentType__::DynamicTypeIs(eType);
20}
21
22void CJX_Boolean::defaultValue(v8::Isolate* pIsolate,
23 v8::Local<v8::Value>* pValue,
24 bool bSetting,
25 XFA_Attribute eAttribute) {
26 if (!bSetting) {
27 *pValue =
28 fxv8::NewBooleanHelper(pIsolate, GetContent(true).EqualsASCII("1"));
29 return;
30 }
31
32 ByteString newValue;
33 if (pValue && !(fxv8::IsNull(*pValue) || fxv8::IsUndefined(*pValue)))
34 newValue = fxv8::ReentrantToByteStringHelper(pIsolate, *pValue);
35
36 int32_t iValue = FXSYS_atoi(newValue.c_str());
37 WideString wsNewValue(iValue == 0 ? L"0" : L"1");
38 WideString wsFormatValue(wsNewValue);
39 CXFA_Node* pContainerNode = GetXFANode()->GetContainerNode();
40 if (pContainerNode)
41 wsFormatValue = pContainerNode->GetFormatDataValue(wsNewValue);
42
43 SetContent(wsNewValue, wsFormatValue, true, true, true);
44}
45
46void CJX_Boolean::value(v8::Isolate* pIsolate,
47 v8::Local<v8::Value>* pValue,
48 bool bSetting,
49 XFA_Attribute eAttribute) {
50 defaultValue(pIsolate, pValue, bSetting, eAttribute);
51}
bool DynamicTypeIs(TypeTag eType) const override
~CJX_Boolean() override
WideString GetContent(bool bScriptModify) const
virtual bool DynamicTypeIs(TypeTag eType) const
CXFA_Node * GetXFANode() const
void SetContent(const WideString &wsContent, const WideString &wsXMLValue, bool bNotify, bool bScriptModify, bool bSyncData)
WideString GetFormatDataValue(const WideString &wsValue)
const char * c_str() const
Definition bytestring.h:76
WideString & operator=(WideString &&that) noexcept
WideString(const WideString &other)
WideString(const wchar_t *ptr)
int32_t FXSYS_atoi(const char *str)
XFA_Attribute
Definition fxfa_basic.h:67
Definition fxv8.h:22
bool IsUndefined(v8::Local< v8::Value > value)
Definition fxv8.cpp:19
bool IsNull(v8::Local< v8::Value > value)
Definition fxv8.cpp:23