summaryrefslogtreecommitdiff
path: root/xfa/fxfa/parser/cxfa_object.cpp
diff options
context:
space:
mode:
authordsinclair <dsinclair@chromium.org>2016-07-19 10:56:23 -0700
committerCommit bot <commit-bot@chromium.org>2016-07-19 10:56:24 -0700
commit5b36f0a0eff7f3666a0e642640db3c89e4bb6748 (patch)
tree1c9c719ea55062ac7bf36dbee7dfb9e9753471dc /xfa/fxfa/parser/cxfa_object.cpp
parenteea31b75a11215aa72a9845d47c38d2ce1edd4f7 (diff)
downloadpdfium-5b36f0a0eff7f3666a0e642640db3c89e4bb6748.tar.xz
Split xfa_object_imp into individual class files.
This CL splits the CXFA_Object, CXFA_NodeList, CXFA_ThisProxy, CXFA_ArrayNodeList and CXFA_AttachNodeList out of xfa_object_imp. xfa_object_imp is then renamed to CXFA_Node. Review-Url: https://codereview.chromium.org/2159973003
Diffstat (limited to 'xfa/fxfa/parser/cxfa_object.cpp')
-rw-r--r--xfa/fxfa/parser/cxfa_object.cpp62
1 files changed, 62 insertions, 0 deletions
diff --git a/xfa/fxfa/parser/cxfa_object.cpp b/xfa/fxfa/parser/cxfa_object.cpp
new file mode 100644
index 0000000000..fd553dd096
--- /dev/null
+++ b/xfa/fxfa/parser/cxfa_object.cpp
@@ -0,0 +1,62 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "xfa/fxfa/parser/xfa_object.h"
+
+#include "core/fxcrt/include/fx_ext.h"
+#include "fxjs/include/cfxjse_value.h"
+#include "xfa/fxfa/app/xfa_ffnotify.h"
+#include "xfa/fxfa/parser/xfa_document.h"
+
+CXFA_Object::CXFA_Object(CXFA_Document* pDocument,
+ XFA_ObjectType objectType,
+ XFA_Element elementType,
+ const CFX_WideStringC& elementName)
+ : m_pDocument(pDocument),
+ m_objectType(objectType),
+ m_elementType(elementType),
+ m_elementNameHash(FX_HashCode_GetW(elementName, false)),
+ m_elementName(elementName) {}
+
+CXFA_Object::~CXFA_Object() {}
+
+CFX_WideStringC CXFA_Object::GetClassName() const {
+ return m_elementName;
+}
+
+uint32_t CXFA_Object::GetClassHashCode() const {
+ return m_elementNameHash;
+}
+
+XFA_Element CXFA_Object::GetElementType() const {
+ return m_elementType;
+}
+
+void CXFA_Object::Script_ObjectClass_ClassName(CFXJSE_Value* pValue,
+ FX_BOOL bSetting,
+ XFA_ATTRIBUTE eAttribute) {
+ if (bSetting) {
+ ThrowException(XFA_IDS_INVAlID_PROP_SET);
+ return;
+ }
+ CFX_WideStringC className = GetClassName();
+ pValue->SetString(
+ FX_UTF8Encode(className.c_str(), className.GetLength()).AsStringC());
+}
+
+void CXFA_Object::ThrowException(int32_t iStringID, ...) {
+ IXFA_AppProvider* pAppProvider = m_pDocument->GetNotify()->GetAppProvider();
+ ASSERT(pAppProvider);
+ CFX_WideString wsFormat;
+ pAppProvider->LoadString(iStringID, wsFormat);
+ CFX_WideString wsMessage;
+ va_list arg_ptr;
+ va_start(arg_ptr, iStringID);
+ wsMessage.FormatV(wsFormat.c_str(), arg_ptr);
+ va_end(arg_ptr);
+ FXJSE_ThrowMessage(
+ FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC());
+}