| OLD | NEW |
| 1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "fpdfsdk/javascript/Annot.h" | 7 #include "fpdfsdk/javascript/Annot.h" |
| 8 | 8 |
| 9 #include "fpdfsdk/javascript/JS_Define.h" | 9 #include "fpdfsdk/javascript/JS_Define.h" |
| 10 #include "fpdfsdk/javascript/JS_Object.h" | 10 #include "fpdfsdk/javascript/JS_Object.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 BEGIN_JS_STATIC_METHOD(CJS_Annot) | 31 BEGIN_JS_STATIC_METHOD(CJS_Annot) |
| 32 END_JS_STATIC_METHOD() | 32 END_JS_STATIC_METHOD() |
| 33 | 33 |
| 34 IMPLEMENT_JS_CLASS(CJS_Annot, Annot) | 34 IMPLEMENT_JS_CLASS(CJS_Annot, Annot) |
| 35 | 35 |
| 36 Annot::Annot(CJS_Object* pJSObject) : CJS_EmbedObj(pJSObject) {} | 36 Annot::Annot(CJS_Object* pJSObject) : CJS_EmbedObj(pJSObject) {} |
| 37 | 37 |
| 38 Annot::~Annot() {} | 38 Annot::~Annot() {} |
| 39 | 39 |
| 40 FX_BOOL Annot::hidden(IJS_Context* cc, | 40 bool Annot::hidden(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { |
| 41 CJS_PropValue& vp, | |
| 42 CFX_WideString& sError) { | |
| 43 CPDFSDK_BAAnnot* baAnnot = ToBAAnnot(m_pAnnot.Get()); | 41 CPDFSDK_BAAnnot* baAnnot = ToBAAnnot(m_pAnnot.Get()); |
| 44 if (!baAnnot) | 42 if (!baAnnot) |
| 45 return FALSE; | 43 return false; |
| 46 | 44 |
| 47 if (vp.IsGetting()) { | 45 if (vp.IsGetting()) { |
| 48 CPDF_Annot* pPDFAnnot = baAnnot->GetPDFAnnot(); | 46 CPDF_Annot* pPDFAnnot = baAnnot->GetPDFAnnot(); |
| 49 vp << CPDF_Annot::IsAnnotationHidden(pPDFAnnot->GetAnnotDict()); | 47 vp << CPDF_Annot::IsAnnotationHidden(pPDFAnnot->GetAnnotDict()); |
| 50 return TRUE; | 48 return true; |
| 51 } | 49 } |
| 52 | 50 |
| 53 bool bHidden; | 51 bool bHidden; |
| 54 vp >> bHidden; | 52 vp >> bHidden; |
| 55 | 53 |
| 56 uint32_t flags = baAnnot->GetFlags(); | 54 uint32_t flags = baAnnot->GetFlags(); |
| 57 if (bHidden) { | 55 if (bHidden) { |
| 58 flags |= ANNOTFLAG_HIDDEN; | 56 flags |= ANNOTFLAG_HIDDEN; |
| 59 flags |= ANNOTFLAG_INVISIBLE; | 57 flags |= ANNOTFLAG_INVISIBLE; |
| 60 flags |= ANNOTFLAG_NOVIEW; | 58 flags |= ANNOTFLAG_NOVIEW; |
| 61 flags &= ~ANNOTFLAG_PRINT; | 59 flags &= ~ANNOTFLAG_PRINT; |
| 62 } else { | 60 } else { |
| 63 flags &= ~ANNOTFLAG_HIDDEN; | 61 flags &= ~ANNOTFLAG_HIDDEN; |
| 64 flags &= ~ANNOTFLAG_INVISIBLE; | 62 flags &= ~ANNOTFLAG_INVISIBLE; |
| 65 flags &= ~ANNOTFLAG_NOVIEW; | 63 flags &= ~ANNOTFLAG_NOVIEW; |
| 66 flags |= ANNOTFLAG_PRINT; | 64 flags |= ANNOTFLAG_PRINT; |
| 67 } | 65 } |
| 68 baAnnot->SetFlags(flags); | 66 baAnnot->SetFlags(flags); |
| 69 return TRUE; | 67 return true; |
| 70 } | 68 } |
| 71 | 69 |
| 72 FX_BOOL Annot::name(IJS_Context* cc, | 70 bool Annot::name(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { |
| 73 CJS_PropValue& vp, | |
| 74 CFX_WideString& sError) { | |
| 75 CPDFSDK_BAAnnot* baAnnot = ToBAAnnot(m_pAnnot.Get()); | 71 CPDFSDK_BAAnnot* baAnnot = ToBAAnnot(m_pAnnot.Get()); |
| 76 if (!baAnnot) | 72 if (!baAnnot) |
| 77 return FALSE; | 73 return false; |
| 78 | 74 |
| 79 if (vp.IsGetting()) { | 75 if (vp.IsGetting()) { |
| 80 vp << baAnnot->GetAnnotName(); | 76 vp << baAnnot->GetAnnotName(); |
| 81 return TRUE; | 77 return true; |
| 82 } | 78 } |
| 83 | 79 |
| 84 CFX_WideString annotName; | 80 CFX_WideString annotName; |
| 85 vp >> annotName; | 81 vp >> annotName; |
| 86 baAnnot->SetAnnotName(annotName); | 82 baAnnot->SetAnnotName(annotName); |
| 87 return TRUE; | 83 return true; |
| 88 } | 84 } |
| 89 | 85 |
| 90 FX_BOOL Annot::type(IJS_Context* cc, | 86 bool Annot::type(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { |
| 91 CJS_PropValue& vp, | |
| 92 CFX_WideString& sError) { | |
| 93 if (vp.IsSetting()) { | 87 if (vp.IsSetting()) { |
| 94 sError = JSGetStringFromID(IDS_STRING_JSREADONLY); | 88 sError = JSGetStringFromID(IDS_STRING_JSREADONLY); |
| 95 return FALSE; | 89 return false; |
| 96 } | 90 } |
| 97 | 91 |
| 98 CPDFSDK_BAAnnot* baAnnot = ToBAAnnot(m_pAnnot.Get()); | 92 CPDFSDK_BAAnnot* baAnnot = ToBAAnnot(m_pAnnot.Get()); |
| 99 if (!baAnnot) | 93 if (!baAnnot) |
| 100 return FALSE; | 94 return false; |
| 101 | 95 |
| 102 vp << CPDF_Annot::AnnotSubtypeToString(baAnnot->GetAnnotSubtype()); | 96 vp << CPDF_Annot::AnnotSubtypeToString(baAnnot->GetAnnotSubtype()); |
| 103 return TRUE; | 97 return true; |
| 104 } | 98 } |
| 105 | 99 |
| 106 void Annot::SetSDKAnnot(CPDFSDK_BAAnnot* annot) { | 100 void Annot::SetSDKAnnot(CPDFSDK_BAAnnot* annot) { |
| 107 m_pAnnot.Reset(annot); | 101 m_pAnnot.Reset(annot); |
| 108 } | 102 } |
| OLD | NEW |