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.
4 
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 
7 #include "Icon.h"
8 
9 #include "JS_Define.h"
10 #include "JS_Object.h"
11 #include "JS_Value.h"
12 #include "fpdfsdk/include/javascript/IJavaScript.h"
13 
14 /* ---------------------- Icon ---------------------- */
15 
16 BEGIN_JS_STATIC_CONST(CJS_Icon)
END_JS_STATIC_CONST()17 END_JS_STATIC_CONST()
18 
19 BEGIN_JS_STATIC_PROP(CJS_Icon)
20 JS_STATIC_PROP_ENTRY(name)
21 END_JS_STATIC_PROP()
22 
23 BEGIN_JS_STATIC_METHOD(CJS_Icon)
24 END_JS_STATIC_METHOD()
25 
26 IMPLEMENT_JS_CLASS(CJS_Icon, Icon)
27 
28 Icon::Icon(CJS_Object* pJSObject)
29     : CJS_EmbedObj(pJSObject), m_pIconStream(NULL), m_swIconName(L"") {}
30 
~Icon()31 Icon::~Icon() {}
32 
SetStream(CPDF_Stream * pIconStream)33 void Icon::SetStream(CPDF_Stream* pIconStream) {
34   if (pIconStream)
35     m_pIconStream = pIconStream;
36 }
37 
GetStream()38 CPDF_Stream* Icon::GetStream() {
39   return m_pIconStream;
40 }
41 
SetIconName(CFX_WideString name)42 void Icon::SetIconName(CFX_WideString name) {
43   m_swIconName = name;
44 }
45 
GetIconName()46 CFX_WideString Icon::GetIconName() {
47   return m_swIconName;
48 }
49 
name(IJS_Context * cc,CJS_PropValue & vp,CFX_WideString & sError)50 FX_BOOL Icon::name(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) {
51   if (!vp.IsGetting())
52     return FALSE;
53 
54   vp << m_swIconName;
55   return TRUE;
56 }
57