blob: 778c1edb10cf64939773899f52bf2bc3ef5feda5 [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
Dan Sinclairf766ad22016-03-14 13:51:24 -04007#include "fpdfsdk/javascript/Icon.h"
Tom Sepez37458412015-10-06 11:33:46 -07008
Dan Sinclairf766ad22016-03-14 13:51:24 -04009#include "fpdfsdk/javascript/JS_Define.h"
10#include "fpdfsdk/javascript/JS_Object.h"
11#include "fpdfsdk/javascript/JS_Value.h"
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070012
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070013BEGIN_JS_STATIC_CONST(CJS_Icon)
14END_JS_STATIC_CONST()
15
16BEGIN_JS_STATIC_PROP(CJS_Icon)
Nico Weber9d8ec5a2015-08-04 13:00:21 -070017JS_STATIC_PROP_ENTRY(name)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070018END_JS_STATIC_PROP()
19
Lei Zhanga6d9f0e2015-06-13 00:48:38 -070020BEGIN_JS_STATIC_METHOD(CJS_Icon)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070021END_JS_STATIC_METHOD()
22
Nico Weber9d8ec5a2015-08-04 13:00:21 -070023IMPLEMENT_JS_CLASS(CJS_Icon, Icon)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070024
Nico Weber9d8ec5a2015-08-04 13:00:21 -070025Icon::Icon(CJS_Object* pJSObject)
thestig1cd352e2016-06-07 17:53:06 -070026 : CJS_EmbedObj(pJSObject), m_pIconStream(nullptr), m_swIconName(L"") {}
Nico Weber9d8ec5a2015-08-04 13:00:21 -070027
28Icon::~Icon() {}
29
30void Icon::SetStream(CPDF_Stream* pIconStream) {
31 if (pIconStream)
32 m_pIconStream = pIconStream;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070033}
34
Nico Weber9d8ec5a2015-08-04 13:00:21 -070035CPDF_Stream* Icon::GetStream() {
36 return m_pIconStream;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070037}
38
Nico Weber9d8ec5a2015-08-04 13:00:21 -070039void Icon::SetIconName(CFX_WideString name) {
40 m_swIconName = name;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070041}
42
Nico Weber9d8ec5a2015-08-04 13:00:21 -070043CFX_WideString Icon::GetIconName() {
44 return m_swIconName;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070045}
46
Tom Sepezb1670b52017-02-16 17:01:00 -080047bool Icon::name(CJS_Runtime* pRuntime,
Tom Sepezd6ae2af2017-02-16 11:49:55 -080048 CJS_PropValue& vp,
49 CFX_WideString& sError) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -070050 if (!vp.IsGetting())
tsepez4cf55152016-11-02 14:37:54 -070051 return false;
Nico Weber9d8ec5a2015-08-04 13:00:21 -070052
53 vp << m_swIconName;
tsepez4cf55152016-11-02 14:37:54 -070054 return true;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070055}