Chromium Code Reviews| 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 bool bHidden = CPDF_Annot::IsAnnotationHidden(pPDFAnnot->GetAnnotDict()); | |
|
Tom Sepez
2016/08/18 21:45:06
nit: Local not needed.
tonikitoo
2016/08/19 02:39:31
Done.
| |
| 38 vp << bHidden; | |
| 39 return TRUE; | |
| 40 } | |
| 41 | |
| 42 bool bHidden; | |
| 43 vp >> bHidden; | |
| 44 | |
| 45 uint32_t flags = m_BAAnnot->GetFlags(); | |
| 46 if (bHidden) { | |
| 47 flags |= ANNOTFLAG_HIDDEN; | |
| 48 flags |= ANNOTFLAG_INVISIBLE; | |
| 49 flags |= ANNOTFLAG_NOVIEW; | |
| 50 flags &= ~ANNOTFLAG_PRINT; | |
| 51 } else { | |
| 52 flags &= ~ANNOTFLAG_HIDDEN; | |
| 53 flags &= ~ANNOTFLAG_INVISIBLE; | |
| 54 flags &= ~ANNOTFLAG_NOVIEW; | |
| 55 flags |= ANNOTFLAG_PRINT; | |
| 56 } | |
| 57 m_BAAnnot->SetFlags(flags); | |
| 58 return TRUE; | |
| 59 } | |
| 60 | |
| 61 FX_BOOL Annot::name(IJS_Context* cc, | |
| 62 CJS_PropValue& vp, | |
| 63 CFX_WideString& sError) { | |
| 64 if (vp.IsGetting()) { | |
| 65 vp << m_BAAnnot->GetAnnotName(); | |
| 66 return TRUE; | |
| 67 } | |
| 68 | |
| 69 CFX_WideString annotName; | |
| 70 vp >> annotName; | |
| 71 m_BAAnnot->SetAnnotName(annotName); | |
| 72 return TRUE; | |
| 73 } | |
| 74 | |
| 75 FX_BOOL Annot::type(IJS_Context* cc, | |
| 76 CJS_PropValue& vp, | |
| 77 CFX_WideString& sError) { | |
| 78 if (vp.IsSetting()) { | |
| 79 CJS_Context* pContext = static_cast<CJS_Context*>(cc); | |
| 80 sError = JSGetStringFromID(pContext, IDS_STRING_JSREADONLY); | |
| 81 return FALSE; | |
| 82 } | |
| 83 | |
| 84 vp << m_BAAnnot->GetType(); | |
| 85 return TRUE; | |
| 86 } | |
| 87 | |
| 88 void Annot::SetData(CPDFSDK_BAAnnot* annot) { | |
| 89 m_BAAnnot = annot; | |
| 90 } | |
| OLD | NEW |