blob: 05be2599aac5ed925668f25e600ed5903a6aee5b [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
Tom Sepez04557b82017-02-16 09:43:10 -080013JSConstSpec CJS_Icon::ConstSpecs[] = {{0, JSConstSpec::Number, 0, 0}};
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070014
Tom Sepez04557b82017-02-16 09:43:10 -080015JSPropertySpec CJS_Icon::PropertySpecs[] = {
16 {L"name", get_name_static, set_name_static},
17 {0, 0, 0}};
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070018
Tom Sepez04557b82017-02-16 09:43:10 -080019JSMethodSpec CJS_Icon::MethodSpecs[] = {{0, 0}};
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070020
Nico Weber9d8ec5a2015-08-04 13:00:21 -070021IMPLEMENT_JS_CLASS(CJS_Icon, Icon)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070022
Nico Weber9d8ec5a2015-08-04 13:00:21 -070023Icon::Icon(CJS_Object* pJSObject)
thestig1cd352e2016-06-07 17:53:06 -070024 : CJS_EmbedObj(pJSObject), m_pIconStream(nullptr), m_swIconName(L"") {}
Nico Weber9d8ec5a2015-08-04 13:00:21 -070025
26Icon::~Icon() {}
27
28void Icon::SetStream(CPDF_Stream* pIconStream) {
29 if (pIconStream)
30 m_pIconStream = pIconStream;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070031}
32
Nico Weber9d8ec5a2015-08-04 13:00:21 -070033CPDF_Stream* Icon::GetStream() {
34 return m_pIconStream;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070035}
36
Nico Weber9d8ec5a2015-08-04 13:00:21 -070037void Icon::SetIconName(CFX_WideString name) {
38 m_swIconName = name;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070039}
40
Nico Weber9d8ec5a2015-08-04 13:00:21 -070041CFX_WideString Icon::GetIconName() {
42 return m_swIconName;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070043}
44
Tom Sepezb1670b52017-02-16 17:01:00 -080045bool Icon::name(CJS_Runtime* pRuntime,
Tom Sepezd6ae2af2017-02-16 11:49:55 -080046 CJS_PropValue& vp,
47 CFX_WideString& sError) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -070048 if (!vp.IsGetting())
tsepez4cf55152016-11-02 14:37:54 -070049 return false;
Nico Weber9d8ec5a2015-08-04 13:00:21 -070050
51 vp << m_swIconName;
tsepez4cf55152016-11-02 14:37:54 -070052 return true;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070053}