blob: bce66c0d99cbb9b0b0c4c407f8707ab966c0fa1f [file] [log] [blame]
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001// Copyright 2014 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.
Lei Zhanga6d9f0e2015-06-13 00:48:38 -07004
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07005// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
Tom Sepez37458412015-10-06 11:33:46 -07007#include "Icon.h"
8
Tom Sepez37458412015-10-06 11:33:46 -07009#include "JS_Define.h"
10#include "JS_Object.h"
11#include "JS_Value.h"
Lei Zhangbde53d22015-11-12 22:21:30 -080012#include "fpdfsdk/include/javascript/IJavaScript.h"
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070013
14/* ---------------------- Icon ---------------------- */
15
16BEGIN_JS_STATIC_CONST(CJS_Icon)
17END_JS_STATIC_CONST()
18
19BEGIN_JS_STATIC_PROP(CJS_Icon)
Nico Weber9d8ec5a2015-08-04 13:00:21 -070020JS_STATIC_PROP_ENTRY(name)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070021END_JS_STATIC_PROP()
22
Lei Zhanga6d9f0e2015-06-13 00:48:38 -070023BEGIN_JS_STATIC_METHOD(CJS_Icon)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070024END_JS_STATIC_METHOD()
25
Nico Weber9d8ec5a2015-08-04 13:00:21 -070026IMPLEMENT_JS_CLASS(CJS_Icon, Icon)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070027
Nico Weber9d8ec5a2015-08-04 13:00:21 -070028Icon::Icon(CJS_Object* pJSObject)
29 : CJS_EmbedObj(pJSObject), m_pIconStream(NULL), m_swIconName(L"") {}
30
31Icon::~Icon() {}
32
33void Icon::SetStream(CPDF_Stream* pIconStream) {
34 if (pIconStream)
35 m_pIconStream = pIconStream;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070036}
37
Nico Weber9d8ec5a2015-08-04 13:00:21 -070038CPDF_Stream* Icon::GetStream() {
39 return m_pIconStream;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070040}
41
Nico Weber9d8ec5a2015-08-04 13:00:21 -070042void Icon::SetIconName(CFX_WideString name) {
43 m_swIconName = name;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070044}
45
Nico Weber9d8ec5a2015-08-04 13:00:21 -070046CFX_WideString Icon::GetIconName() {
47 return m_swIconName;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070048}
49
Tom Sepezba038bc2015-10-08 12:03:00 -070050FX_BOOL Icon::name(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -070051 if (!vp.IsGetting())
52 return FALSE;
53
54 vp << m_swIconName;
55 return TRUE;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070056}