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