OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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 "fpdfsdk/javascript/Annot.h" |
| 8 |
| 9 #include "fpdfsdk/javascript/JS_Define.h" |
| 10 #include "fpdfsdk/javascript/JS_Object.h" |
| 11 #include "fpdfsdk/javascript/JS_Value.h" |
| 12 #include "fpdfsdk/javascript/cjs_context.h" |
| 13 |
| 14 BEGIN_JS_STATIC_CONST(CJS_Annot) |
| 15 END_JS_STATIC_CONST() |
| 16 |
| 17 BEGIN_JS_STATIC_PROP(CJS_Annot) |
| 18 JS_STATIC_PROP_ENTRY(hidden) |
| 19 JS_STATIC_PROP_ENTRY(name) |
| 20 JS_STATIC_PROP_ENTRY(type) |
| 21 END_JS_STATIC_PROP() |
| 22 |
| 23 BEGIN_JS_STATIC_METHOD(CJS_Annot) |
| 24 END_JS_STATIC_METHOD() |
| 25 |
| 26 IMPLEMENT_JS_CLASS(CJS_Annot, Annot) |
| 27 |
| 28 Annot::Annot(CJS_Object* pJSObject) : CJS_EmbedObj(pJSObject) {} |
| 29 |
| 30 Annot::~Annot() {} |
| 31 |
| 32 FX_BOOL Annot::hidden(IJS_Context* cc, |
| 33 CJS_PropValue& vp, |
| 34 CFX_WideString& sError) { |
| 35 if (vp.IsGetting()) { |
| 36 CPDF_Annot* pPDFAnnot = m_BAAnnot->GetPDFAnnot(); |
| 37 vp << CPDF_Annot::IsAnnotationHidden(pPDFAnnot->GetAnnotDict()); |
| 38 return TRUE; |
| 39 } |
| 40 |
| 41 bool bHidden; |
| 42 vp >> bHidden; |
| 43 |
| 44 uint32_t flags = m_BAAnnot->GetFlags(); |
| 45 if (bHidden) { |
| 46 flags |= ANNOTFLAG_HIDDEN; |
| 47 flags |= ANNOTFLAG_INVISIBLE; |
| 48 flags |= ANNOTFLAG_NOVIEW; |
| 49 flags &= ~ANNOTFLAG_PRINT; |
| 50 } else { |
| 51 flags &= ~ANNOTFLAG_HIDDEN; |
| 52 flags &= ~ANNOTFLAG_INVISIBLE; |
| 53 flags &= ~ANNOTFLAG_NOVIEW; |
| 54 flags |= ANNOTFLAG_PRINT; |
| 55 } |
| 56 m_BAAnnot->SetFlags(flags); |
| 57 return TRUE; |
| 58 } |
| 59 |
| 60 FX_BOOL Annot::name(IJS_Context* cc, |
| 61 CJS_PropValue& vp, |
| 62 CFX_WideString& sError) { |
| 63 if (vp.IsGetting()) { |
| 64 vp << m_BAAnnot->GetAnnotName(); |
| 65 return TRUE; |
| 66 } |
| 67 |
| 68 CFX_WideString annotName; |
| 69 vp >> annotName; |
| 70 m_BAAnnot->SetAnnotName(annotName); |
| 71 return TRUE; |
| 72 } |
| 73 |
| 74 FX_BOOL Annot::type(IJS_Context* cc, |
| 75 CJS_PropValue& vp, |
| 76 CFX_WideString& sError) { |
| 77 if (vp.IsSetting()) { |
| 78 CJS_Context* pContext = static_cast<CJS_Context*>(cc); |
| 79 sError = JSGetStringFromID(pContext, IDS_STRING_JSREADONLY); |
| 80 return FALSE; |
| 81 } |
| 82 |
| 83 vp << m_BAAnnot->GetType(); |
| 84 return TRUE; |
| 85 } |
| 86 |
| 87 void Annot::SetSDKAnnot(CPDFSDK_BAAnnot* annot) { |
| 88 m_BAAnnot = annot; |
| 89 } |
OLD | NEW |