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

Side by Side 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, 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
« no previous file with comments | « no previous file | testing/resources/javascript/bug_492_1.in » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 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/Document.h" 7 #include "fpdfsdk/javascript/Document.h"
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 1072 matching lines...) Expand 10 before | Expand all | Expand 10 after
1083 pAnnot->SetSDKAnnot(pSDKBAAnnot); 1083 pAnnot->SetSDKAnnot(pSDKBAAnnot);
1084 1084
1085 vRet = CJS_Value(pRuntime, pJS_Annot); 1085 vRet = CJS_Value(pRuntime, pJS_Annot);
1086 return TRUE; 1086 return TRUE;
1087 } 1087 }
1088 1088
1089 FX_BOOL Document::getAnnots(IJS_Context* cc, 1089 FX_BOOL Document::getAnnots(IJS_Context* cc,
1090 const std::vector<CJS_Value>& params, 1090 const std::vector<CJS_Value>& params,
1091 CJS_Value& vRet, 1091 CJS_Value& vRet,
1092 CFX_WideString& sError) { 1092 CFX_WideString& sError) {
1093 vRet.SetNull(CJS_Runtime::FromContext(cc)); 1093 CJS_Context* pContext = static_cast<CJS_Context*>(cc);
1094
1095 // TODO(tonikitoo): Add support supported parameters as per
1096 // the PDF spec.
1097
1098 CJS_Runtime* pRuntime = pContext->GetJSRuntime();
1099
1100 int nPageNo = m_pDocument->GetPageCount();
1101 CJS_Array annots;
1102
1103 for (int i = 0; i < nPageNo; ++i) {
1104 CPDFSDK_PageView* pPageView = m_pDocument->GetPageView(i);
1105 if (!pPageView)
1106 return FALSE;
1107
1108 CPDFSDK_AnnotIterator annotIterator(pPageView, false);
1109 while (CPDFSDK_Annot* pSDKAnnotCur = annotIterator.Next()) {
1110 CPDFSDK_BAAnnot* pSDKBAAnnot =
1111 static_cast<CPDFSDK_BAAnnot*>(pSDKAnnotCur);
1112 if (!pSDKBAAnnot)
1113 return FALSE;
1114
1115 v8::Local<v8::Object> pObj =
1116 pRuntime->NewFxDynamicObj(CJS_Annot::g_nObjDefnID);
1117 if (pObj.IsEmpty())
1118 return FALSE;
1119
1120 CJS_Annot* pJS_Annot =
1121 static_cast<CJS_Annot*>(pRuntime->GetObjectPrivate(pObj));
1122 if (!pJS_Annot)
1123 return FALSE;
1124
1125 Annot* pAnnot = static_cast<Annot*>(pJS_Annot->GetEmbedObject());
1126 if (!pAnnot)
1127 return FALSE;
1128
1129 pAnnot->SetSDKAnnot(pSDKBAAnnot);
1130 annots.SetElement(pRuntime, i, CJS_Value(pRuntime, pJS_Annot));
1131 }
1132 }
1133
1134 vRet = CJS_Value(pRuntime, annots);
1094 return TRUE; 1135 return TRUE;
1095 } 1136 }
1096 1137
1097 FX_BOOL Document::getAnnot3D(IJS_Context* cc, 1138 FX_BOOL Document::getAnnot3D(IJS_Context* cc,
1098 const std::vector<CJS_Value>& params, 1139 const std::vector<CJS_Value>& params,
1099 CJS_Value& vRet, 1140 CJS_Value& vRet,
1100 CFX_WideString& sError) { 1141 CFX_WideString& sError) {
1101 vRet.SetNull(CJS_Runtime::FromContext(cc)); 1142 vRet.SetNull(CJS_Runtime::FromContext(cc));
1102 return TRUE; 1143 return TRUE;
1103 } 1144 }
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
1608 } 1649 }
1609 } 1650 }
1610 1651
1611 for (const auto& pData : DelayDataForFieldAndControlIndex) 1652 for (const auto& pData : DelayDataForFieldAndControlIndex)
1612 Field::DoDelay(m_pDocument, pData.get()); 1653 Field::DoDelay(m_pDocument, pData.get());
1613 } 1654 }
1614 1655
1615 CJS_Document* Document::GetCJSDoc() const { 1656 CJS_Document* Document::GetCJSDoc() const {
1616 return static_cast<CJS_Document*>(m_pJSObject); 1657 return static_cast<CJS_Document*>(m_pJSObject);
1617 } 1658 }
OLDNEW
« 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