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_draw.h"
8
9 #include "fxjs/xfa/cfxjse_value.h"
10 #include "xfa/fxfa/parser/cxfa_draw.h"
11
CJX_Draw(CXFA_Draw * node)12 CJX_Draw::CJX_Draw(CXFA_Draw* node) : CJX_Container(node) {}
13
14 CJX_Draw::~CJX_Draw() = default;
15
DynamicTypeIs(TypeTag eType) const16 bool CJX_Draw::DynamicTypeIs(TypeTag eType) const {
17 return eType == static_type__ || ParentType__::DynamicTypeIs(eType);
18 }
19
rawValue(CFXJSE_Value * pValue,bool bSetting,XFA_Attribute eAttribute)20 void CJX_Draw::rawValue(CFXJSE_Value* pValue,
21 bool bSetting,
22 XFA_Attribute eAttribute) {
23 defaultValue(pValue, bSetting, eAttribute);
24 }
25
defaultValue(CFXJSE_Value * pValue,bool bSetting,XFA_Attribute eAttribute)26 void CJX_Draw::defaultValue(CFXJSE_Value* pValue,
27 bool bSetting,
28 XFA_Attribute eAttribute) {
29 if (!bSetting) {
30 WideString content = GetContent(true);
31 if (content.IsEmpty())
32 pValue->SetNull();
33 else
34 pValue->SetString(content.ToUTF8().AsStringView());
35
36 return;
37 }
38
39 if (!pValue || !pValue->IsString())
40 return;
41
42 ASSERT(GetXFANode()->IsWidgetReady());
43 if (GetXFANode()->GetFFWidgetType() != XFA_FFWidgetType::kText)
44 return;
45
46 WideString wsNewValue = pValue->ToWideString();
47 SetContent(wsNewValue, wsNewValue, true, true, true);
48 }
49