John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1 | // 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 Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 4 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 5 | // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | |
Dan Sinclair | f766ad2 | 2016-03-14 13:51:24 -0400 | [diff] [blame] | 7 | #include "fpdfsdk/javascript/Icon.h" |
Tom Sepez | 3745841 | 2015-10-06 11:33:46 -0700 | [diff] [blame] | 8 | |
Dan Sinclair | f766ad2 | 2016-03-14 13:51:24 -0400 | [diff] [blame] | 9 | #include "fpdfsdk/javascript/JS_Define.h" |
| 10 | #include "fpdfsdk/javascript/JS_Object.h" |
| 11 | #include "fpdfsdk/javascript/JS_Value.h" |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 12 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 13 | BEGIN_JS_STATIC_CONST(CJS_Icon) |
| 14 | END_JS_STATIC_CONST() |
| 15 | |
| 16 | BEGIN_JS_STATIC_PROP(CJS_Icon) |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 17 | JS_STATIC_PROP_ENTRY(name) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 18 | END_JS_STATIC_PROP() |
| 19 | |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 20 | BEGIN_JS_STATIC_METHOD(CJS_Icon) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 21 | END_JS_STATIC_METHOD() |
| 22 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 23 | IMPLEMENT_JS_CLASS(CJS_Icon, Icon) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 24 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 25 | Icon::Icon(CJS_Object* pJSObject) |
| 26 | : CJS_EmbedObj(pJSObject), m_pIconStream(NULL), m_swIconName(L"") {} |
| 27 | |
| 28 | Icon::~Icon() {} |
| 29 | |
| 30 | void Icon::SetStream(CPDF_Stream* pIconStream) { |
| 31 | if (pIconStream) |
| 32 | m_pIconStream = pIconStream; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 33 | } |
| 34 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 35 | CPDF_Stream* Icon::GetStream() { |
| 36 | return m_pIconStream; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 37 | } |
| 38 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 39 | void Icon::SetIconName(CFX_WideString name) { |
| 40 | m_swIconName = name; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 41 | } |
| 42 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 43 | CFX_WideString Icon::GetIconName() { |
| 44 | return m_swIconName; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 45 | } |
| 46 | |
Tom Sepez | ba038bc | 2015-10-08 12:03:00 -0700 | [diff] [blame] | 47 | FX_BOOL Icon::name(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 48 | if (!vp.IsGetting()) |
| 49 | return FALSE; |
| 50 | |
| 51 | vp << m_swIconName; |
| 52 | return TRUE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 53 | } |