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

Unified Diff: fpdfsdk/javascript/Annot.cpp

Issue 2260663002: Add initial Document::getAnnot support (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: fpdfsdk/javascript/Annot.cpp
diff --git a/fpdfsdk/javascript/Annot.cpp b/fpdfsdk/javascript/Annot.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..98f502a914738584bc32e8190250b4fb6dca3e30
--- /dev/null
+++ b/fpdfsdk/javascript/Annot.cpp
@@ -0,0 +1,90 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "fpdfsdk/javascript/Annot.h"
+
+#include "fpdfsdk/javascript/JS_Define.h"
+#include "fpdfsdk/javascript/JS_Object.h"
+#include "fpdfsdk/javascript/JS_Value.h"
+#include "fpdfsdk/javascript/cjs_context.h"
+
+BEGIN_JS_STATIC_CONST(CJS_Annot)
+END_JS_STATIC_CONST()
+
+BEGIN_JS_STATIC_PROP(CJS_Annot)
+JS_STATIC_PROP_ENTRY(hidden)
+JS_STATIC_PROP_ENTRY(name)
+JS_STATIC_PROP_ENTRY(type)
+END_JS_STATIC_PROP()
+
+BEGIN_JS_STATIC_METHOD(CJS_Annot)
+END_JS_STATIC_METHOD()
+
+IMPLEMENT_JS_CLASS(CJS_Annot, Annot)
+
+Annot::Annot(CJS_Object* pJSObject) : CJS_EmbedObj(pJSObject) {}
+
+Annot::~Annot() {}
+
+FX_BOOL Annot::hidden(IJS_Context* cc,
+ CJS_PropValue& vp,
+ CFX_WideString& sError) {
+ if (vp.IsGetting()) {
+ CPDF_Annot* pPDFAnnot = m_BAAnnot->GetPDFAnnot();
+ 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.
+ vp << bHidden;
+ return TRUE;
+ }
+
+ bool bHidden;
+ vp >> bHidden;
+
+ uint32_t flags = m_BAAnnot->GetFlags();
+ if (bHidden) {
+ flags |= ANNOTFLAG_HIDDEN;
+ flags |= ANNOTFLAG_INVISIBLE;
+ flags |= ANNOTFLAG_NOVIEW;
+ flags &= ~ANNOTFLAG_PRINT;
+ } else {
+ flags &= ~ANNOTFLAG_HIDDEN;
+ flags &= ~ANNOTFLAG_INVISIBLE;
+ flags &= ~ANNOTFLAG_NOVIEW;
+ flags |= ANNOTFLAG_PRINT;
+ }
+ m_BAAnnot->SetFlags(flags);
+ return TRUE;
+}
+
+FX_BOOL Annot::name(IJS_Context* cc,
+ CJS_PropValue& vp,
+ CFX_WideString& sError) {
+ if (vp.IsGetting()) {
+ vp << m_BAAnnot->GetAnnotName();
+ return TRUE;
+ }
+
+ CFX_WideString annotName;
+ vp >> annotName;
+ m_BAAnnot->SetAnnotName(annotName);
+ return TRUE;
+}
+
+FX_BOOL Annot::type(IJS_Context* cc,
+ CJS_PropValue& vp,
+ CFX_WideString& sError) {
+ if (vp.IsSetting()) {
+ CJS_Context* pContext = static_cast<CJS_Context*>(cc);
+ sError = JSGetStringFromID(pContext, IDS_STRING_JSREADONLY);
+ return FALSE;
+ }
+
+ vp << m_BAAnnot->GetType();
+ return TRUE;
+}
+
+void Annot::SetData(CPDFSDK_BAAnnot* annot) {
+ m_BAAnnot = annot;
+}

Powered by Google App Engine
This is Rietveld 408576698