Home | History | Annotate | Download | only in javascript
      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)
     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 
     31 Icon::~Icon() {}
     32 
     33 void Icon::SetStream(CPDF_Stream* pIconStream) {
     34   if (pIconStream)
     35     m_pIconStream = pIconStream;
     36 }
     37 
     38 CPDF_Stream* Icon::GetStream() {
     39   return m_pIconStream;
     40 }
     41 
     42 void Icon::SetIconName(CFX_WideString name) {
     43   m_swIconName = name;
     44 }
     45 
     46 CFX_WideString Icon::GetIconName() {
     47   return m_swIconName;
     48 }
     49 
     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