Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1579)

Side by Side Diff: fpdfsdk/javascript/Annot.cpp

Issue 2306663002: Add observer for BAAnnots from Javascript (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« fpdfsdk/javascript/Annot.h ('K') | « fpdfsdk/javascript/Annot.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 14 matching lines...) Expand all
25 25
26 IMPLEMENT_JS_CLASS(CJS_Annot, Annot) 26 IMPLEMENT_JS_CLASS(CJS_Annot, Annot)
27 27
28 Annot::Annot(CJS_Object* pJSObject) : CJS_EmbedObj(pJSObject) {} 28 Annot::Annot(CJS_Object* pJSObject) : CJS_EmbedObj(pJSObject) {}
29 29
30 Annot::~Annot() {} 30 Annot::~Annot() {}
31 31
32 FX_BOOL Annot::hidden(IJS_Context* cc, 32 FX_BOOL Annot::hidden(IJS_Context* cc,
33 CJS_PropValue& vp, 33 CJS_PropValue& vp,
34 CFX_WideString& sError) { 34 CFX_WideString& sError) {
35 if (!m_BAAnnot)
36 return FALSE;
37
35 if (vp.IsGetting()) { 38 if (vp.IsGetting()) {
36 CPDF_Annot* pPDFAnnot = m_BAAnnot->GetPDFAnnot(); 39 CPDF_Annot* pPDFAnnot = m_BAAnnot->GetPDFAnnot();
37 vp << CPDF_Annot::IsAnnotationHidden(pPDFAnnot->GetAnnotDict()); 40 vp << CPDF_Annot::IsAnnotationHidden(pPDFAnnot->GetAnnotDict());
38 return TRUE; 41 return TRUE;
39 } 42 }
40 43
41 bool bHidden; 44 bool bHidden;
42 vp >> bHidden; 45 vp >> bHidden;
43 46
44 uint32_t flags = m_BAAnnot->GetFlags(); 47 uint32_t flags = m_BAAnnot->GetFlags();
45 if (bHidden) { 48 if (bHidden) {
46 flags |= ANNOTFLAG_HIDDEN; 49 flags |= ANNOTFLAG_HIDDEN;
47 flags |= ANNOTFLAG_INVISIBLE; 50 flags |= ANNOTFLAG_INVISIBLE;
48 flags |= ANNOTFLAG_NOVIEW; 51 flags |= ANNOTFLAG_NOVIEW;
49 flags &= ~ANNOTFLAG_PRINT; 52 flags &= ~ANNOTFLAG_PRINT;
50 } else { 53 } else {
51 flags &= ~ANNOTFLAG_HIDDEN; 54 flags &= ~ANNOTFLAG_HIDDEN;
52 flags &= ~ANNOTFLAG_INVISIBLE; 55 flags &= ~ANNOTFLAG_INVISIBLE;
53 flags &= ~ANNOTFLAG_NOVIEW; 56 flags &= ~ANNOTFLAG_NOVIEW;
54 flags |= ANNOTFLAG_PRINT; 57 flags |= ANNOTFLAG_PRINT;
55 } 58 }
56 m_BAAnnot->SetFlags(flags); 59 m_BAAnnot->SetFlags(flags);
57 return TRUE; 60 return TRUE;
58 } 61 }
59 62
60 FX_BOOL Annot::name(IJS_Context* cc, 63 FX_BOOL Annot::name(IJS_Context* cc,
61 CJS_PropValue& vp, 64 CJS_PropValue& vp,
62 CFX_WideString& sError) { 65 CFX_WideString& sError) {
66 if (!m_BAAnnot)
67 return FALSE;
68
63 if (vp.IsGetting()) { 69 if (vp.IsGetting()) {
64 vp << m_BAAnnot->GetAnnotName(); 70 vp << m_BAAnnot->GetAnnotName();
65 return TRUE; 71 return TRUE;
66 } 72 }
67 73
68 CFX_WideString annotName; 74 CFX_WideString annotName;
69 vp >> annotName; 75 vp >> annotName;
70 m_BAAnnot->SetAnnotName(annotName); 76 m_BAAnnot->SetAnnotName(annotName);
71 return TRUE; 77 return TRUE;
72 } 78 }
73 79
74 FX_BOOL Annot::type(IJS_Context* cc, 80 FX_BOOL Annot::type(IJS_Context* cc,
75 CJS_PropValue& vp, 81 CJS_PropValue& vp,
76 CFX_WideString& sError) { 82 CFX_WideString& sError) {
77 if (vp.IsSetting()) { 83 if (vp.IsSetting()) {
78 CJS_Context* pContext = static_cast<CJS_Context*>(cc); 84 CJS_Context* pContext = static_cast<CJS_Context*>(cc);
79 sError = JSGetStringFromID(pContext, IDS_STRING_JSREADONLY); 85 sError = JSGetStringFromID(pContext, IDS_STRING_JSREADONLY);
80 return FALSE; 86 return FALSE;
81 } 87 }
82 88
89 if (!m_BAAnnot)
90 return FALSE;
91
83 vp << CPDF_Annot::AnnotSubtypeToString(m_BAAnnot->GetAnnotSubtype()); 92 vp << CPDF_Annot::AnnotSubtypeToString(m_BAAnnot->GetAnnotSubtype());
84 return TRUE; 93 return TRUE;
85 } 94 }
86 95
87 void Annot::SetSDKAnnot(CPDFSDK_BAAnnot* annot) { 96 void Annot::SetSDKAnnot(CPDFSDK_BAAnnot* baannot) {
88 m_BAAnnot = annot; 97 m_BAAnnot = baannot;
Tom Sepez 2016/09/01 18:04:24 m_BAAnnot can't be a widget?
dsinclair 2016/09/01 18:11:58 I don't think so as the Widget inherits from BAAnn
Tom Sepez 2016/09/01 18:12:06 I mean, what if we repalce m_BAAnont with a CPDFSD
98 m_pObserver.reset(new CPDFSDK_BAAnnot::Observer(&m_BAAnnot));
89 } 99 }
OLDNEW
« fpdfsdk/javascript/Annot.h ('K') | « fpdfsdk/javascript/Annot.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698