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

Unified Diff: fpdfsdk/javascript/Document.cpp

Issue 2281273002: Add support to Document::getAnnots method (Closed)
Patch Set: fixed nit as per tsepez's request 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
« no previous file with comments | « no previous file | testing/resources/javascript/bug_492_1.in » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: fpdfsdk/javascript/Document.cpp
diff --git a/fpdfsdk/javascript/Document.cpp b/fpdfsdk/javascript/Document.cpp
index 8fb9ce60dc5433c32e11c6f0b8b657059ebbd141..c1381f5865d0fe481479c5b3f45e44646d4fb53d 100644
--- a/fpdfsdk/javascript/Document.cpp
+++ b/fpdfsdk/javascript/Document.cpp
@@ -1090,7 +1090,48 @@ FX_BOOL Document::getAnnots(IJS_Context* cc,
const std::vector<CJS_Value>& params,
CJS_Value& vRet,
CFX_WideString& sError) {
- vRet.SetNull(CJS_Runtime::FromContext(cc));
+ CJS_Context* pContext = static_cast<CJS_Context*>(cc);
+
+ // TODO(tonikitoo): Add support supported parameters as per
+ // the PDF spec.
+
+ CJS_Runtime* pRuntime = pContext->GetJSRuntime();
+
+ int nPageNo = m_pDocument->GetPageCount();
+ CJS_Array annots;
+
+ for (int i = 0; i < nPageNo; ++i) {
+ CPDFSDK_PageView* pPageView = m_pDocument->GetPageView(i);
+ if (!pPageView)
+ return FALSE;
+
+ CPDFSDK_AnnotIterator annotIterator(pPageView, false);
+ while (CPDFSDK_Annot* pSDKAnnotCur = annotIterator.Next()) {
+ CPDFSDK_BAAnnot* pSDKBAAnnot =
+ static_cast<CPDFSDK_BAAnnot*>(pSDKAnnotCur);
+ if (!pSDKBAAnnot)
+ return FALSE;
+
+ v8::Local<v8::Object> pObj =
+ pRuntime->NewFxDynamicObj(CJS_Annot::g_nObjDefnID);
+ if (pObj.IsEmpty())
+ return FALSE;
+
+ CJS_Annot* pJS_Annot =
+ static_cast<CJS_Annot*>(pRuntime->GetObjectPrivate(pObj));
+ if (!pJS_Annot)
+ return FALSE;
+
+ Annot* pAnnot = static_cast<Annot*>(pJS_Annot->GetEmbedObject());
+ if (!pAnnot)
+ return FALSE;
+
+ pAnnot->SetSDKAnnot(pSDKBAAnnot);
+ annots.SetElement(pRuntime, i, CJS_Value(pRuntime, pJS_Annot));
+ }
+ }
+
+ vRet = CJS_Value(pRuntime, annots);
return TRUE;
}
« no previous file with comments | « no previous file | testing/resources/javascript/bug_492_1.in » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698