OLD | NEW |
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 "../../include/javascript/JavaScript.h" | 7 #include "../../include/javascript/JavaScript.h" |
8 #include "../../include/javascript/IJavaScript.h" | 8 #include "../../include/javascript/IJavaScript.h" |
9 #include "../../include/javascript/JS_Define.h" | 9 #include "../../include/javascript/JS_Define.h" |
10 #include "../../include/javascript/JS_Object.h" | 10 #include "../../include/javascript/JS_Object.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 END_JS_STATIC_PROP() | 38 END_JS_STATIC_PROP() |
39 | 39 |
40 BEGIN_JS_STATIC_METHOD(CJS_PrintParamsObj) | 40 BEGIN_JS_STATIC_METHOD(CJS_PrintParamsObj) |
41 END_JS_STATIC_METHOD() | 41 END_JS_STATIC_METHOD() |
42 | 42 |
43 IMPLEMENT_JS_CLASS(CJS_PrintParamsObj, PrintParamsObj) | 43 IMPLEMENT_JS_CLASS(CJS_PrintParamsObj, PrintParamsObj) |
44 | 44 |
45 PrintParamsObj::PrintParamsObj(CJS_Object* pJSObject) | 45 PrintParamsObj::PrintParamsObj(CJS_Object* pJSObject) |
46 : CJS_EmbedObj(pJSObject) | 46 : CJS_EmbedObj(pJSObject) |
47 { | 47 { |
48 bUI = true; | 48 bUI = TRUE; |
49 nStart = 0; | 49 nStart = 0; |
50 nEnd = 0; | 50 nEnd = 0; |
51 bSilent = false; | 51 bSilent = FALSE; |
52 bShrinkToFit = false; | 52 bShrinkToFit = FALSE; |
53 bPrintAsImage = false; | 53 bPrintAsImage = FALSE; |
54 bReverse = false; | 54 bReverse = FALSE; |
55 bAnnotations = true; | 55 bAnnotations = TRUE; |
56 } | 56 } |
57 | 57 |
58 /* ---------------------- Document ---------------------- */ | 58 /* ---------------------- Document ---------------------- */ |
59 | 59 |
60 #define MINWIDTH 5.0f | 60 #define MINWIDTH 5.0f |
61 #define MINHEIGHT 5.0f | 61 #define MINHEIGHT 5.0f |
62 | 62 |
63 BEGIN_JS_STATIC_CONST(CJS_Document) | 63 BEGIN_JS_STATIC_CONST(CJS_Document) |
64 END_JS_STATIC_CONST() | 64 END_JS_STATIC_CONST() |
65 | 65 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 JS_STATIC_METHOD_ENTRY(replacePages) | 135 JS_STATIC_METHOD_ENTRY(replacePages) |
136 JS_STATIC_METHOD_ENTRY(resetForm) | 136 JS_STATIC_METHOD_ENTRY(resetForm) |
137 JS_STATIC_METHOD_ENTRY(removeIcon) | 137 JS_STATIC_METHOD_ENTRY(removeIcon) |
138 JS_STATIC_METHOD_ENTRY(saveAs) | 138 JS_STATIC_METHOD_ENTRY(saveAs) |
139 JS_STATIC_METHOD_ENTRY(submitForm) | 139 JS_STATIC_METHOD_ENTRY(submitForm) |
140 JS_STATIC_METHOD_ENTRY(mailDoc) | 140 JS_STATIC_METHOD_ENTRY(mailDoc) |
141 END_JS_STATIC_METHOD() | 141 END_JS_STATIC_METHOD() |
142 | 142 |
143 IMPLEMENT_JS_CLASS(CJS_Document, Document) | 143 IMPLEMENT_JS_CLASS(CJS_Document, Document) |
144 | 144 |
145 bool CJS_Document::InitInstance(IFXJS_Context* cc) | 145 FX_BOOL CJS_Document::InitInstance(IFXJS_Context* cc) |
146 { | 146 { |
147 CJS_Context* pContext = (CJS_Context*)cc; | 147 CJS_Context* pContext = (CJS_Context*)cc; |
148 ASSERT(pContext != NULL); | 148 ASSERT(pContext != NULL); |
149 | 149 |
150 Document* pDoc = (Document*)GetEmbedObject(); | 150 Document* pDoc = (Document*)GetEmbedObject(); |
151 ASSERT(pDoc != NULL); | 151 ASSERT(pDoc != NULL); |
152 | 152 |
153 pDoc->AttachDoc(pContext->GetReaderDocument()); | 153 pDoc->AttachDoc(pContext->GetReaderDocument()); |
154 pDoc->SetIsolate(pContext->GetJSRuntime()->GetIsolate()); | 154 pDoc->SetIsolate(pContext->GetJSRuntime()->GetIsolate()); |
155 return true; | 155 return TRUE; |
156 }; | 156 }; |
157 | 157 |
158 /* --------------------------------- Document ---------------------------------
*/ | 158 /* --------------------------------- Document ---------------------------------
*/ |
159 | 159 |
160 Document::Document(CJS_Object* pJSObject) : CJS_EmbedObj(pJSObject), | 160 Document::Document(CJS_Object* pJSObject) : CJS_EmbedObj(pJSObject), |
161 m_isolate(NULL), | 161 m_isolate(NULL), |
162 m_pIconTree(NULL), | 162 m_pIconTree(NULL), |
163 m_pDocument(NULL), | 163 m_pDocument(NULL), |
164 m_cwBaseURL(L""), | 164 m_cwBaseURL(L""), |
165 m_bDelay(false) | 165 m_bDelay(FALSE) |
166 { | 166 { |
167 } | 167 } |
168 | 168 |
169 Document::~Document() | 169 Document::~Document() |
170 { | 170 { |
171 if (m_pIconTree) | 171 if (m_pIconTree) |
172 { | 172 { |
173 m_pIconTree->DeleteIconTree(); | 173 m_pIconTree->DeleteIconTree(); |
174 delete m_pIconTree; | 174 delete m_pIconTree; |
175 m_pIconTree = NULL; | 175 m_pIconTree = NULL; |
176 } | 176 } |
177 for (int i=0; i<m_DelayData.GetSize(); i++) | 177 for (int i=0; i<m_DelayData.GetSize(); i++) |
178 { | 178 { |
179 if (CJS_DelayData* pData = m_DelayData.GetAt(i)) | 179 if (CJS_DelayData* pData = m_DelayData.GetAt(i)) |
180 { | 180 { |
181 delete pData; | 181 delete pData; |
182 pData = NULL; | 182 pData = NULL; |
183 m_DelayData.SetAt(i, NULL); | 183 m_DelayData.SetAt(i, NULL); |
184 | 184 |
185 } | 185 } |
186 } | 186 } |
187 | 187 |
188 m_DelayData.RemoveAll(); | 188 m_DelayData.RemoveAll(); |
189 m_DelayAnnotData.RemoveAll(); | 189 m_DelayAnnotData.RemoveAll(); |
190 } | 190 } |
191 | 191 |
192 //the total number of fileds in document. | 192 //the total number of fileds in document. |
193 bool Document::numFields(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& s
Error) | 193 FX_BOOL Document::numFields(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString
& sError) |
194 { | 194 { |
195 if (vp.IsSetting()) { | 195 if (vp.IsSetting()) { |
196 CJS_Context* pContext = static_cast<CJS_Context*>(cc); | 196 CJS_Context* pContext = static_cast<CJS_Context*>(cc); |
197 sError = JSGetStringFromID(pContext, IDS_STRING_JSREADONLY); | 197 sError = JSGetStringFromID(pContext, IDS_STRING_JSREADONLY); |
198 return false; | 198 return FALSE; |
199 } | 199 } |
200 CPDFSDK_InterForm *pInterForm = m_pDocument->GetInterForm(); | 200 CPDFSDK_InterForm *pInterForm = m_pDocument->GetInterForm(); |
201 CPDF_InterForm *pPDFForm = pInterForm->GetInterForm(); | 201 CPDF_InterForm *pPDFForm = pInterForm->GetInterForm(); |
202 vp << (int)pPDFForm->CountFields(); | 202 vp << (int)pPDFForm->CountFields(); |
203 return true; | 203 return TRUE; |
204 } | 204 } |
205 | 205 |
206 bool Document::dirty(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sErro
r) | 206 FX_BOOL Document::dirty(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sE
rror) |
207 { | 207 { |
208 ASSERT(m_pDocument != NULL); | 208 ASSERT(m_pDocument != NULL); |
209 | 209 |
210 if (vp.IsGetting()) | 210 if (vp.IsGetting()) |
211 { | 211 { |
212 if (m_pDocument->GetChangeMark()) | 212 if (m_pDocument->GetChangeMark()) |
213 vp << true; | 213 vp << true; |
214 else | 214 else |
215 vp << false; | 215 vp << false; |
216 } | 216 } |
217 else | 217 else |
218 { | 218 { |
219 bool bChanged = false; | 219 bool bChanged = false; |
220 | 220 |
221 vp >> bChanged; | 221 vp >> bChanged; |
222 | 222 |
223 if (bChanged) | 223 if (bChanged) |
224 m_pDocument->SetChangeMark(); | 224 m_pDocument->SetChangeMark(); |
225 else | 225 else |
226 m_pDocument->ClearChangeMark(); | 226 m_pDocument->ClearChangeMark(); |
227 } | 227 } |
228 | 228 |
229 return true; | 229 return TRUE; |
230 } | 230 } |
231 | 231 |
232 bool Document::ADBE(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError
) | 232 FX_BOOL Document::ADBE(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sEr
ror) |
233 { | 233 { |
234 ASSERT(m_pDocument != NULL); | 234 ASSERT(m_pDocument != NULL); |
235 | 235 |
236 if (vp.IsGetting()) | 236 if (vp.IsGetting()) |
237 { | 237 { |
238 vp.SetNull(); | 238 vp.SetNull(); |
239 } | 239 } |
240 else | 240 else |
241 { | 241 { |
242 } | 242 } |
243 | 243 |
244 return true; | 244 return TRUE; |
245 } | 245 } |
246 | 246 |
247 bool Document::pageNum(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sEr
ror) | 247 FX_BOOL Document::pageNum(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString&
sError) |
248 { | 248 { |
249 ASSERT(m_pDocument != NULL); | 249 ASSERT(m_pDocument != NULL); |
250 | 250 |
251 if (vp.IsGetting()) | 251 if (vp.IsGetting()) |
252 { | 252 { |
253 if (CPDFSDK_PageView* pPageView = m_pDocument->GetCurrentView()) | 253 if (CPDFSDK_PageView* pPageView = m_pDocument->GetCurrentView()) |
254 { | 254 { |
255 vp << pPageView->GetPageIndex(); | 255 vp << pPageView->GetPageIndex(); |
256 } | 256 } |
257 } | 257 } |
(...skipping 11 matching lines...) Expand all Loading... |
269 else if (iPageNum >= iPageCount) | 269 else if (iPageNum >= iPageCount) |
270 { | 270 { |
271 pEnv->JS_docgotoPage(iPageCount-1); | 271 pEnv->JS_docgotoPage(iPageCount-1); |
272 } | 272 } |
273 else if (iPageNum < 0) | 273 else if (iPageNum < 0) |
274 { | 274 { |
275 pEnv->JS_docgotoPage(0); | 275 pEnv->JS_docgotoPage(0); |
276 } | 276 } |
277 } | 277 } |
278 | 278 |
279 return true; | 279 return TRUE; |
280 } | 280 } |
281 | 281 |
282 bool Document::ParserParams(JSObject* pObj,CJS_AnnotObj& annotobj) | 282 FX_BOOL Document::ParserParams(JSObject* pObj,CJS_AnnotObj& annotobj) |
283 { | 283 { |
284 // Not supported. | 284 // Not supported. |
285 return true; | 285 return TRUE; |
286 } | 286 } |
287 | 287 |
288 bool Document::addAnnot(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Val
ue& vRet, CFX_WideString& sError) | 288 FX_BOOL Document::addAnnot(IFXJS_Context* cc, const CJS_Parameters& params, CJS_
Value& vRet, CFX_WideString& sError) |
289 { | 289 { |
290 // Not supported. | 290 // Not supported. |
291 return true; | 291 return TRUE; |
292 } | 292 } |
293 | 293 |
294 bool Document::addField(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Val
ue& vRet, CFX_WideString& sError) | 294 FX_BOOL Document::addField(IFXJS_Context* cc, const CJS_Parameters& params, CJS_
Value& vRet, CFX_WideString& sError) |
295 { | 295 { |
296 // Not supported. | 296 // Not supported. |
297 return true; | 297 return TRUE; |
298 } | 298 } |
299 | 299 |
300 bool Document::exportAsText(IFXJS_Context* cc, const CJS_Parameters& params, CJS
_Value& vRet, CFX_WideString& sError) | 300 FX_BOOL Document::exportAsText(IFXJS_Context* cc, const CJS_Parameters& params,
CJS_Value& vRet, CFX_WideString& sError) |
301 { | 301 { |
302 // Unsafe, not supported. | 302 // Unsafe, not supported. |
303 return true; | 303 return TRUE; |
304 } | 304 } |
305 | 305 |
306 bool Document::exportAsFDF(IFXJS_Context* cc, const CJS_Parameters& params, CJS_
Value& vRet, CFX_WideString& sError) | 306 FX_BOOL Document::exportAsFDF(IFXJS_Context* cc, const CJS_Parameters& params, C
JS_Value& vRet, CFX_WideString& sError) |
307 { | 307 { |
308 // Unsafe, not supported. | 308 // Unsafe, not supported. |
309 return true; | 309 return TRUE; |
310 } | 310 } |
311 | 311 |
312 bool Document::exportAsXFDF(IFXJS_Context* cc, const CJS_Parameters& params, CJS
_Value& vRet, CFX_WideString& sError) | 312 FX_BOOL Document::exportAsXFDF(IFXJS_Context* cc, const CJS_Parameters& params,
CJS_Value& vRet, CFX_WideString& sError) |
313 { | 313 { |
314 // Unsafe, not supported. | 314 // Unsafe, not supported. |
315 return true; | 315 return TRUE; |
316 } | 316 } |
317 | 317 |
318 //Maps a field object in PDF document to a JavaScript variable | 318 //Maps a field object in PDF document to a JavaScript variable |
319 //comment: | 319 //comment: |
320 //note: the paremter cName, this is clue how to treat if the cName is not a vali
able filed name in this document | 320 //note: the paremter cName, this is clue how to treat if the cName is not a vali
able filed name in this document |
321 | 321 |
322 bool Document::getField(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Val
ue& vRet, CFX_WideString& sError) | 322 FX_BOOL Document::getField(IFXJS_Context* cc, const CJS_Parameters& params, CJS_
Value& vRet, CFX_WideString& sError) |
323 { | 323 { |
324 CJS_Context* pContext = (CJS_Context*)cc; | 324 CJS_Context* pContext = (CJS_Context*)cc; |
325 if (params.size() < 1) { | 325 if (params.size() < 1) { |
326 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); | 326 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
327 return false; | 327 return FALSE; |
328 } | 328 } |
329 | 329 |
330 CFX_WideString wideName = params[0].ToCFXWideString(); | 330 CFX_WideString wideName = params[0].ToCFXWideString(); |
331 | 331 |
332 CPDFSDK_InterForm* pInterForm = m_pDocument->GetInterForm(); | 332 CPDFSDK_InterForm* pInterForm = m_pDocument->GetInterForm(); |
333 CPDF_InterForm* pPDFForm = pInterForm->GetInterForm(); | 333 CPDF_InterForm* pPDFForm = pInterForm->GetInterForm(); |
334 if (pPDFForm->CountFields(wideName) <= 0) | 334 if (pPDFForm->CountFields(wideName) <= 0) |
335 { | 335 { |
336 vRet.SetNull(); | 336 vRet.SetNull(); |
337 return true; | 337 return TRUE; |
338 } | 338 } |
339 | 339 |
340 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 340 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
341 JSFXObject pFieldObj = JS_NewFxDynamicObj(*pRuntime, pContext, JS_GetObjDefn
ID(*pRuntime, L"Field")); | 341 JSFXObject pFieldObj = JS_NewFxDynamicObj(*pRuntime, pContext, JS_GetObjDefn
ID(*pRuntime, L"Field")); |
342 | 342 |
343 v8::Isolate* isolate = GetIsolate(cc); | 343 v8::Isolate* isolate = GetIsolate(cc); |
344 CJS_Field* pJSField = (CJS_Field*)JS_GetPrivate(isolate,pFieldObj); | 344 CJS_Field* pJSField = (CJS_Field*)JS_GetPrivate(isolate,pFieldObj); |
345 Field* pField = (Field *)pJSField->GetEmbedObject(); | 345 Field* pField = (Field *)pJSField->GetEmbedObject(); |
346 pField->AttachField(this, wideName); | 346 pField->AttachField(this, wideName); |
347 | 347 |
348 vRet = pJSField; | 348 vRet = pJSField; |
349 return true; | 349 return TRUE; |
350 } | 350 } |
351 | 351 |
352 //Gets the name of the nth field in the document | 352 //Gets the name of the nth field in the document |
353 bool Document::getNthFieldName(IFXJS_Context* cc, const CJS_Parameters& params,
CJS_Value& vRet, CFX_WideString& sError) | 353 FX_BOOL Document::getNthFieldName(IFXJS_Context* cc, const CJS_Parameters& param
s, CJS_Value& vRet, CFX_WideString& sError) |
354 { | 354 { |
355 CJS_Context* pContext = (CJS_Context*)cc; | 355 CJS_Context* pContext = (CJS_Context*)cc; |
356 if (params.size() != 1) { | 356 if (params.size() != 1) { |
357 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); | 357 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
358 return false; | 358 return FALSE; |
359 } | 359 } |
360 | 360 |
361 int nIndex = params[0].ToInt(); | 361 int nIndex = params[0].ToInt(); |
362 if (nIndex < 0) { | 362 if (nIndex < 0) { |
363 sError = JSGetStringFromID(pContext, IDS_STRING_JSVALUEERROR); | 363 sError = JSGetStringFromID(pContext, IDS_STRING_JSVALUEERROR); |
364 return false; | 364 return FALSE; |
365 } | 365 } |
366 | 366 |
367 CPDFSDK_InterForm* pInterForm = m_pDocument->GetInterForm(); | 367 CPDFSDK_InterForm* pInterForm = m_pDocument->GetInterForm(); |
368 CPDF_InterForm* pPDFForm = pInterForm->GetInterForm(); | 368 CPDF_InterForm* pPDFForm = pInterForm->GetInterForm(); |
369 CPDF_FormField* pField = pPDFForm->GetField(nIndex); | 369 CPDF_FormField* pField = pPDFForm->GetField(nIndex); |
370 if (!pField) | 370 if (!pField) |
371 return false; | 371 return FALSE; |
372 | 372 |
373 vRet = pField->GetFullName().c_str(); | 373 vRet = pField->GetFullName().c_str(); |
374 return true; | 374 return TRUE; |
375 } | 375 } |
376 | 376 |
377 bool Document::importAnFDF(IFXJS_Context* cc, const CJS_Parameters& params, CJS_
Value& vRet, CFX_WideString& sError) | 377 FX_BOOL Document::importAnFDF(IFXJS_Context* cc, const CJS_Parameters& params, C
JS_Value& vRet, CFX_WideString& sError) |
378 { | 378 { |
379 // Unsafe, not supported. | 379 // Unsafe, not supported. |
380 return true; | 380 return TRUE; |
381 } | 381 } |
382 | 382 |
383 bool Document::importAnXFDF(IFXJS_Context* cc, const CJS_Parameters& params, CJS
_Value& vRet, CFX_WideString& sError) | 383 FX_BOOL Document::importAnXFDF(IFXJS_Context* cc, const CJS_Parameters& params,
CJS_Value& vRet, CFX_WideString& sError) |
384 { | 384 { |
385 // Unsafe, not supported. | 385 // Unsafe, not supported. |
386 return true; | 386 return TRUE; |
387 } | 387 } |
388 | 388 |
389 bool Document::importTextData(IFXJS_Context* cc, const CJS_Parameters& params, C
JS_Value& vRet, CFX_WideString& sError) | 389 FX_BOOL Document::importTextData(IFXJS_Context* cc, const CJS_Parameters& params
, CJS_Value& vRet, CFX_WideString& sError) |
390 { | 390 { |
391 // Unsafe, not supported. | 391 // Unsafe, not supported. |
392 return true; | 392 return TRUE; |
393 } | 393 } |
394 | 394 |
395 //exports the form data and mails the resulting fdf file as an attachment to all
recipients. | 395 //exports the form data and mails the resulting fdf file as an attachment to all
recipients. |
396 //comment: need reader supports | 396 //comment: need reader supports |
397 //note: | 397 //note: |
398 //int CPDFSDK_Document::mailForm(bool bUI,String cto,string ccc,string cbcc,stri
ng cSubject,string cms); | 398 //int CPDFSDK_Document::mailForm(FX_BOOL bUI,String cto,string ccc,string cbcc,s
tring cSubject,string cms); |
399 | 399 |
400 bool Document::mailForm(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Val
ue& vRet, CFX_WideString& sError) | 400 FX_BOOL Document::mailForm(IFXJS_Context* cc, const CJS_Parameters& params, CJS_
Value& vRet, CFX_WideString& sError) |
401 { | 401 { |
402 ASSERT(m_pDocument != NULL); | 402 ASSERT(m_pDocument != NULL); |
403 | 403 |
404 if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) return false; | 404 if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) return FALSE; |
405 | 405 |
406 int iLength = params.size(); | 406 int iLength = params.size(); |
407 | 407 |
408 bool bUI = iLength > 0 ? params[0].ToBool() : true; | 408 FX_BOOL bUI = iLength > 0 ? params[0].ToBool() : TRUE; |
409 CFX_WideString cTo = iLength > 1 ? params[1].ToCFXWideString() : L""; | 409 CFX_WideString cTo = iLength > 1 ? params[1].ToCFXWideString() : L""; |
410 CFX_WideString cCc = iLength > 2 ? params[2].ToCFXWideString() : L""; | 410 CFX_WideString cCc = iLength > 2 ? params[2].ToCFXWideString() : L""; |
411 CFX_WideString cBcc = iLength > 3 ? params[3].ToCFXWideString() : L""; | 411 CFX_WideString cBcc = iLength > 3 ? params[3].ToCFXWideString() : L""; |
412 CFX_WideString cSubject = iLength > 4 ? params[4].ToCFXWideString() : L""; | 412 CFX_WideString cSubject = iLength > 4 ? params[4].ToCFXWideString() : L""; |
413 CFX_WideString cMsg = iLength > 5 ? params[5].ToCFXWideString() : L""; | 413 CFX_WideString cMsg = iLength > 5 ? params[5].ToCFXWideString() : L""; |
414 | 414 |
415 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInterFor
m(); | 415 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInterFor
m(); |
416 ASSERT(pInterForm != NULL); | 416 ASSERT(pInterForm != NULL); |
417 | 417 |
418 CFX_ByteTextBuf textBuf; | 418 CFX_ByteTextBuf textBuf; |
419 if (!pInterForm->ExportFormToFDFTextBuf(textBuf)) | 419 if (!pInterForm->ExportFormToFDFTextBuf(textBuf)) |
420 return false; | 420 return FALSE; |
421 | 421 |
422 CJS_Context* pContext = (CJS_Context*)cc; | 422 CJS_Context* pContext = (CJS_Context*)cc; |
423 ASSERT(pContext != NULL); | 423 ASSERT(pContext != NULL); |
424 CPDFDoc_Environment* pEnv = pContext->GetReaderApp(); | 424 CPDFDoc_Environment* pEnv = pContext->GetReaderApp(); |
425 ASSERT(pEnv != NULL); | 425 ASSERT(pEnv != NULL); |
426 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 426 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
427 ASSERT(pRuntime != NULL); | 427 ASSERT(pRuntime != NULL); |
428 | 428 |
429 pRuntime->BeginBlock(); | 429 pRuntime->BeginBlock(); |
430 pEnv->JS_docmailForm(textBuf.GetBuffer(), textBuf.GetLength(), bUI, cTo.c_st
r(), cSubject.c_str(), cCc.c_str(), cBcc.c_str(), cMsg.c_str()); | 430 pEnv->JS_docmailForm(textBuf.GetBuffer(), textBuf.GetLength(), bUI, cTo.c_st
r(), cSubject.c_str(), cCc.c_str(), cBcc.c_str(), cMsg.c_str()); |
431 pRuntime->EndBlock(); | 431 pRuntime->EndBlock(); |
432 return true; | 432 return TRUE; |
433 } | 433 } |
434 | 434 |
435 bool Document::print(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value&
vRet, CFX_WideString& sError) | 435 FX_BOOL Document::print(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Val
ue& vRet, CFX_WideString& sError) |
436 { | 436 { |
437 CJS_Context* pContext = (CJS_Context*)cc; | 437 CJS_Context* pContext = (CJS_Context*)cc; |
438 ASSERT(pContext != NULL); | 438 ASSERT(pContext != NULL); |
439 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 439 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
440 ASSERT(pRuntime != NULL); | 440 ASSERT(pRuntime != NULL); |
441 | 441 |
442 bool bUI = true; | 442 FX_BOOL bUI = TRUE; |
443 int nStart = 0; | 443 int nStart = 0; |
444 int nEnd = 0; | 444 int nEnd = 0; |
445 bool bSilent = false; | 445 FX_BOOL bSilent = FALSE; |
446 bool bShrinkToFit = false; | 446 FX_BOOL bShrinkToFit = FALSE; |
447 bool bPrintAsImage = false; | 447 FX_BOOL bPrintAsImage = FALSE; |
448 bool bReverse = false; | 448 FX_BOOL bReverse = FALSE; |
449 bool bAnnotations = false; | 449 FX_BOOL bAnnotations = FALSE; |
450 | 450 |
451 int nlength = params.size(); | 451 int nlength = params.size(); |
452 if(nlength ==9) | 452 if(nlength ==9) |
453 { | 453 { |
454 if (params[8].GetType() == VT_fxobject) | 454 if (params[8].GetType() == VT_fxobject) |
455 { | 455 { |
456 JSFXObject pObj = params[8].ToV8Object(); | 456 JSFXObject pObj = params[8].ToV8Object(); |
457 { | 457 { |
458 if (JS_GetObjDefnID(pObj) == JS_GetObjDefnID(*pRuntime, L"PrintP
aramsObj")) | 458 if (JS_GetObjDefnID(pObj) == JS_GetObjDefnID(*pRuntime, L"PrintP
aramsObj")) |
459 { | 459 { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 bReverse = params[6].ToBool(); | 493 bReverse = params[6].ToBool(); |
494 if(nlength >= 8) | 494 if(nlength >= 8) |
495 bAnnotations = params[7].ToBool(); | 495 bAnnotations = params[7].ToBool(); |
496 } | 496 } |
497 | 497 |
498 ASSERT(m_pDocument != NULL); | 498 ASSERT(m_pDocument != NULL); |
499 | 499 |
500 if (CPDFDoc_Environment* pEnv = m_pDocument->GetEnv()) | 500 if (CPDFDoc_Environment* pEnv = m_pDocument->GetEnv()) |
501 { | 501 { |
502 pEnv->JS_docprint(bUI, nStart, nEnd, bSilent, bShrinkToFit, bPrintAsImag
e, bReverse, bAnnotations); | 502 pEnv->JS_docprint(bUI, nStart, nEnd, bSilent, bShrinkToFit, bPrintAsImag
e, bReverse, bAnnotations); |
503 return true; | 503 return TRUE; |
504 } | 504 } |
505 return false; | 505 return FALSE; |
506 } | 506 } |
507 | 507 |
508 //removes the specified field from the document. | 508 //removes the specified field from the document. |
509 //comment: | 509 //comment: |
510 //note: if the filed name is not retional, adobe is dumb for it. | 510 //note: if the filed name is not retional, adobe is dumb for it. |
511 | 511 |
512 bool Document::removeField(IFXJS_Context* cc, const CJS_Parameters& params, CJS_
Value& vRet, CFX_WideString& sError) | 512 FX_BOOL Document::removeField(IFXJS_Context* cc, const CJS_Parameters& params, C
JS_Value& vRet, CFX_WideString& sError) |
513 { | 513 { |
514 ASSERT(m_pDocument != NULL); | 514 ASSERT(m_pDocument != NULL); |
515 | 515 |
516 if (!(m_pDocument->GetPermissions(FPDFPERM_MODIFY) || | 516 if (!(m_pDocument->GetPermissions(FPDFPERM_MODIFY) || |
517 m_pDocument->GetPermissions(FPDFPERM_ANNOT_FORM))) return false; | 517 m_pDocument->GetPermissions(FPDFPERM_ANNOT_FORM))) return FALSE; |
518 | 518 |
519 CJS_Context* pContext = (CJS_Context*)cc; | 519 CJS_Context* pContext = (CJS_Context*)cc; |
520 if (params.size() != 1) { | 520 if (params.size() != 1) { |
521 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); | 521 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
522 return false; | 522 return FALSE; |
523 } | 523 } |
524 | 524 |
525 CFX_WideString sFieldName = params[0].ToCFXWideString(); | 525 CFX_WideString sFieldName = params[0].ToCFXWideString(); |
526 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInterFor
m(); | 526 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInterFor
m(); |
527 ASSERT(pInterForm != NULL); | 527 ASSERT(pInterForm != NULL); |
528 | 528 |
529 CFX_PtrArray widgets; | 529 CFX_PtrArray widgets; |
530 pInterForm->GetWidgets(sFieldName, widgets); | 530 pInterForm->GetWidgets(sFieldName, widgets); |
531 | 531 |
532 int nSize = widgets.GetSize(); | 532 int nSize = widgets.GetSize(); |
(...skipping 18 matching lines...) Expand all Loading... |
551 ASSERT(pPage != NULL); | 551 ASSERT(pPage != NULL); |
552 | 552 |
553 CPDFSDK_PageView* pPageView = m_pDocument->GetPageView(pPage); | 553 CPDFSDK_PageView* pPageView = m_pDocument->GetPageView(pPage); |
554 pPageView->DeleteAnnot(pWidget); | 554 pPageView->DeleteAnnot(pWidget); |
555 | 555 |
556 pPageView->UpdateRects(aRefresh); | 556 pPageView->UpdateRects(aRefresh); |
557 } | 557 } |
558 m_pDocument->SetChangeMark(); | 558 m_pDocument->SetChangeMark(); |
559 } | 559 } |
560 | 560 |
561 return true; | 561 return TRUE; |
562 } | 562 } |
563 | 563 |
564 //reset filed values within a document. | 564 //reset filed values within a document. |
565 //comment: | 565 //comment: |
566 //note: if the fields names r not rational, aodbe is dumb for it. | 566 //note: if the fields names r not rational, aodbe is dumb for it. |
567 | 567 |
568 bool Document::resetForm(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Va
lue& vRet, CFX_WideString& sError) | 568 FX_BOOL Document::resetForm(IFXJS_Context* cc, const CJS_Parameters& params, CJS
_Value& vRet, CFX_WideString& sError) |
569 { | 569 { |
570 ASSERT(m_pDocument != NULL); | 570 ASSERT(m_pDocument != NULL); |
571 | 571 |
572 if (!(m_pDocument->GetPermissions(FPDFPERM_MODIFY) || | 572 if (!(m_pDocument->GetPermissions(FPDFPERM_MODIFY) || |
573 m_pDocument->GetPermissions(FPDFPERM_ANNOT_FORM) || | 573 m_pDocument->GetPermissions(FPDFPERM_ANNOT_FORM) || |
574 m_pDocument->GetPermissions(FPDFPERM_FILL_FORM))) return false; | 574 m_pDocument->GetPermissions(FPDFPERM_FILL_FORM))) return FALSE; |
575 | 575 |
576 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInterFor
m(); | 576 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInterFor
m(); |
577 ASSERT(pInterForm != NULL); | 577 ASSERT(pInterForm != NULL); |
578 | 578 |
579 CPDF_InterForm* pPDFForm = pInterForm->GetInterForm(); | 579 CPDF_InterForm* pPDFForm = pInterForm->GetInterForm(); |
580 ASSERT(pPDFForm != NULL); | 580 ASSERT(pPDFForm != NULL); |
581 | 581 |
582 v8::Isolate* isolate = GetIsolate(cc); | 582 v8::Isolate* isolate = GetIsolate(cc); |
583 CJS_Array aName(isolate); | 583 CJS_Array aName(isolate); |
584 | 584 |
(...skipping 18 matching lines...) Expand all Loading... |
603 CFX_WideString swVal = valElement.ToCFXWideString(); | 603 CFX_WideString swVal = valElement.ToCFXWideString(); |
604 | 604 |
605 for (int j=0,jsz=pPDFForm->CountFields(swVal); j<jsz; j++) | 605 for (int j=0,jsz=pPDFForm->CountFields(swVal); j<jsz; j++) |
606 { | 606 { |
607 aFields.Add((void*)pPDFForm->GetField(j,swVal)); | 607 aFields.Add((void*)pPDFForm->GetField(j,swVal)); |
608 } | 608 } |
609 } | 609 } |
610 | 610 |
611 if (aFields.GetSize() > 0) | 611 if (aFields.GetSize() > 0) |
612 { | 612 { |
613 pPDFForm->ResetForm(aFields, true, true); | 613 pPDFForm->ResetForm(aFields, TRUE, TRUE); |
614 m_pDocument->SetChangeMark(); | 614 m_pDocument->SetChangeMark(); |
615 | 615 |
616 } | 616 } |
617 } | 617 } |
618 else | 618 else |
619 { | 619 { |
620 pPDFForm->ResetForm(true); | 620 pPDFForm->ResetForm(TRUE); |
621 m_pDocument->SetChangeMark(); | 621 m_pDocument->SetChangeMark(); |
622 | 622 |
623 } | 623 } |
624 | 624 |
625 return true; | 625 return TRUE; |
626 } | 626 } |
627 | 627 |
628 | 628 |
629 bool Document::saveAs(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value
& vRet, CFX_WideString& sError) | 629 FX_BOOL Document::saveAs(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Va
lue& vRet, CFX_WideString& sError) |
630 { | 630 { |
631 // Unsafe, not supported. | 631 // Unsafe, not supported. |
632 return true; | 632 return TRUE; |
633 } | 633 } |
634 | 634 |
635 | 635 |
636 bool Document::submitForm(IFXJS_Context* cc, const CJS_Parameters& params, CJS_V
alue& vRet, CFX_WideString& sError) | 636 FX_BOOL Document::submitForm(IFXJS_Context* cc, const CJS_Parameters& params, CJ
S_Value& vRet, CFX_WideString& sError) |
637 { | 637 { |
638 ASSERT(m_pDocument != NULL); | 638 ASSERT(m_pDocument != NULL); |
639 CJS_Context* pContext = (CJS_Context*)cc; | 639 CJS_Context* pContext = (CJS_Context*)cc; |
640 int nSize = params.size(); | 640 int nSize = params.size(); |
641 if (nSize < 1) { | 641 if (nSize < 1) { |
642 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); | 642 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
643 return false; | 643 return FALSE; |
644 } | 644 } |
645 | 645 |
646 CFX_WideString strURL; | 646 CFX_WideString strURL; |
647 bool bFDF = true; | 647 FX_BOOL bFDF = TRUE; |
648 bool bEmpty = false; | 648 FX_BOOL bEmpty = FALSE; |
649 v8::Isolate* isolate = GetIsolate(cc); | 649 v8::Isolate* isolate = GetIsolate(cc); |
650 CJS_Array aFields(isolate); | 650 CJS_Array aFields(isolate); |
651 | 651 |
652 CJS_Value v = params[0]; | 652 CJS_Value v = params[0]; |
653 if (v.GetType() == VT_string) | 653 if (v.GetType() == VT_string) |
654 { | 654 { |
655 strURL = params[0].ToCFXWideString(); | 655 strURL = params[0].ToCFXWideString(); |
656 if (nSize > 1) | 656 if (nSize > 1) |
657 bFDF = params[1].ToBool(); | 657 bFDF = params[1].ToBool(); |
658 if (nSize > 2) | 658 if (nSize > 2) |
(...skipping 11 matching lines...) Expand all Loading... |
670 bFDF = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToBool(); | 670 bFDF = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToBool(); |
671 pValue = JS_GetObjectElement(isolate, pObj, L"bEmpty"); | 671 pValue = JS_GetObjectElement(isolate, pObj, L"bEmpty"); |
672 bEmpty = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToBool(); | 672 bEmpty = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToBool(); |
673 pValue = JS_GetObjectElement(isolate, pObj,L"aFields"); | 673 pValue = JS_GetObjectElement(isolate, pObj,L"aFields"); |
674 aFields.Attach(CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToV8Ar
ray()); | 674 aFields.Attach(CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToV8Ar
ray()); |
675 } | 675 } |
676 | 676 |
677 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 677 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
678 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInterFor
m(); | 678 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInterFor
m(); |
679 CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm(); | 679 CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm(); |
680 bool bAll = (aFields.GetLength() == 0); | 680 FX_BOOL bAll = (aFields.GetLength() == 0); |
681 if (bAll && bEmpty) | 681 if (bAll && bEmpty) |
682 { | 682 { |
683 if (pPDFInterForm->CheckRequiredFields()) | 683 if (pPDFInterForm->CheckRequiredFields()) |
684 { | 684 { |
685 pRuntime->BeginBlock(); | 685 pRuntime->BeginBlock(); |
686 pInterForm->SubmitForm(strURL, false); | 686 pInterForm->SubmitForm(strURL, FALSE); |
687 pRuntime->EndBlock(); | 687 pRuntime->EndBlock(); |
688 } | 688 } |
689 return true; | 689 return TRUE; |
690 } | 690 } |
691 | 691 |
692 CFX_PtrArray fieldObjects; | 692 CFX_PtrArray fieldObjects; |
693 for (int i=0,sz=aFields.GetLength(); i<sz; i++) | 693 for (int i=0,sz=aFields.GetLength(); i<sz; i++) |
694 { | 694 { |
695 CJS_Value valName(isolate); | 695 CJS_Value valName(isolate); |
696 aFields.GetElement(i, valName); | 696 aFields.GetElement(i, valName); |
697 | 697 |
698 CFX_WideString sName = valName.ToCFXWideString(); | 698 CFX_WideString sName = valName.ToCFXWideString(); |
699 CPDF_InterForm* pPDFForm = pInterForm->GetInterForm(); | 699 CPDF_InterForm* pPDFForm = pInterForm->GetInterForm(); |
700 for (int j = 0, jsz = pPDFForm->CountFields(sName); j < jsz; ++j) | 700 for (int j = 0, jsz = pPDFForm->CountFields(sName); j < jsz; ++j) |
701 { | 701 { |
702 CPDF_FormField* pField = pPDFForm->GetField(j, sName); | 702 CPDF_FormField* pField = pPDFForm->GetField(j, sName); |
703 if (!bEmpty && pField->GetValue().IsEmpty()) | 703 if (!bEmpty && pField->GetValue().IsEmpty()) |
704 continue; | 704 continue; |
705 | 705 |
706 fieldObjects.Add(pField); | 706 fieldObjects.Add(pField); |
707 } | 707 } |
708 } | 708 } |
709 | 709 |
710 if (pPDFInterForm->CheckRequiredFields(&fieldObjects, true)) | 710 if (pPDFInterForm->CheckRequiredFields(&fieldObjects, TRUE)) |
711 { | 711 { |
712 pRuntime->BeginBlock(); | 712 pRuntime->BeginBlock(); |
713 pInterForm->SubmitFields(strURL, fieldObjects, true, !bFDF); | 713 pInterForm->SubmitFields(strURL, fieldObjects, TRUE, !bFDF); |
714 pRuntime->EndBlock(); | 714 pRuntime->EndBlock(); |
715 } | 715 } |
716 return true; | 716 return TRUE; |
717 } | 717 } |
718 | 718 |
719 ////////////////////////////////////////////////////////////////////////////////
////////////// | 719 ////////////////////////////////////////////////////////////////////////////////
////////////// |
720 | 720 |
721 void Document::AttachDoc(CPDFSDK_Document *pDoc) | 721 void Document::AttachDoc(CPDFSDK_Document *pDoc) |
722 { | 722 { |
723 m_pDocument = pDoc; | 723 m_pDocument = pDoc; |
724 } | 724 } |
725 | 725 |
726 CPDFSDK_Document * Document::GetReaderDoc() | 726 CPDFSDK_Document * Document::GetReaderDoc() |
727 { | 727 { |
728 return m_pDocument; | 728 return m_pDocument; |
729 } | 729 } |
730 | 730 |
731 bool Document::ExtractFileName(CPDFSDK_Document *pDoc,CFX_ByteString &strFileNam
e) | 731 FX_BOOL Document::ExtractFileName(CPDFSDK_Document *pDoc,CFX_ByteString &strFile
Name) |
732 { | 732 { |
733 return false; | 733 return FALSE; |
734 } | 734 } |
735 | 735 |
736 bool Document::ExtractFolderName(CPDFSDK_Document *pDoc,CFX_ByteString &strFolde
rName) | 736 FX_BOOL Document::ExtractFolderName(CPDFSDK_Document *pDoc,CFX_ByteString &strFo
lderName) |
737 { | 737 { |
738 return false; | 738 return FALSE; |
739 } | 739 } |
740 | 740 |
741 bool Document::bookmarkRoot(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString
& sError) | 741 FX_BOOL Document::bookmarkRoot(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideStr
ing& sError) |
742 { | 742 { |
743 return true; | 743 return TRUE; |
744 } | 744 } |
745 | 745 |
746 bool Document::mailDoc(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Valu
e& vRet, CFX_WideString& sError) | 746 FX_BOOL Document::mailDoc(IFXJS_Context* cc, const CJS_Parameters& params, CJS_V
alue& vRet, CFX_WideString& sError) |
747 { | 747 { |
748 ASSERT(m_pDocument != NULL); | 748 ASSERT(m_pDocument != NULL); |
749 | 749 |
750 bool bUI = true; | 750 FX_BOOL bUI = TRUE; |
751 CFX_WideString cTo = L""; | 751 CFX_WideString cTo = L""; |
752 CFX_WideString cCc = L""; | 752 CFX_WideString cCc = L""; |
753 CFX_WideString cBcc = L""; | 753 CFX_WideString cBcc = L""; |
754 CFX_WideString cSubject = L""; | 754 CFX_WideString cSubject = L""; |
755 CFX_WideString cMsg = L""; | 755 CFX_WideString cMsg = L""; |
756 | 756 |
757 if (params.size() >= 1) | 757 if (params.size() >= 1) |
758 bUI = params[0].ToBool(); | 758 bUI = params[0].ToBool(); |
759 if (params.size() >= 2) | 759 if (params.size() >= 2) |
760 cTo = params[1].ToCFXWideString(); | 760 cTo = params[1].ToCFXWideString(); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
796 CJS_Context* pContext = (CJS_Context*)cc; | 796 CJS_Context* pContext = (CJS_Context*)cc; |
797 ASSERT(pContext != NULL); | 797 ASSERT(pContext != NULL); |
798 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 798 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
799 ASSERT(pRuntime != NULL); | 799 ASSERT(pRuntime != NULL); |
800 | 800 |
801 pRuntime->BeginBlock(); | 801 pRuntime->BeginBlock(); |
802 CPDFDoc_Environment* pEnv = pRuntime->GetReaderApp(); | 802 CPDFDoc_Environment* pEnv = pRuntime->GetReaderApp(); |
803 pEnv->JS_docmailForm(NULL, 0, bUI, cTo.c_str(), cSubject.c_str(), cCc.c_str(
), cBcc.c_str(), cMsg.c_str()); | 803 pEnv->JS_docmailForm(NULL, 0, bUI, cTo.c_str(), cSubject.c_str(), cCc.c_str(
), cBcc.c_str(), cMsg.c_str()); |
804 pRuntime->EndBlock(); | 804 pRuntime->EndBlock(); |
805 | 805 |
806 return true; | 806 return TRUE; |
807 } | 807 } |
808 | 808 |
809 bool Document::author(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sErr
or) | 809 FX_BOOL Document::author(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& s
Error) |
810 { | 810 { |
811 ASSERT(m_pDocument != NULL); | 811 ASSERT(m_pDocument != NULL); |
812 | 812 |
813 CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo(); | 813 CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo(); |
814 if (!pDictionary)return false; | 814 if (!pDictionary)return FALSE; |
815 | 815 |
816 if (vp.IsGetting()) | 816 if (vp.IsGetting()) |
817 { | 817 { |
818 vp << pDictionary->GetUnicodeText("Author"); | 818 vp << pDictionary->GetUnicodeText("Author"); |
819 return true; | 819 return TRUE; |
820 } | 820 } |
821 else | 821 else |
822 { | 822 { |
823 if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) return false; | 823 if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) return FALSE; |
824 | 824 |
825 CFX_WideString csAuthor; | 825 CFX_WideString csAuthor; |
826 vp >> csAuthor; | 826 vp >> csAuthor; |
827 pDictionary->SetAtString("Author", PDF_EncodeText(csAuthor)); | 827 pDictionary->SetAtString("Author", PDF_EncodeText(csAuthor)); |
828 m_pDocument->SetChangeMark(); | 828 m_pDocument->SetChangeMark(); |
829 return true; | 829 return TRUE; |
830 } | 830 } |
831 } | 831 } |
832 | 832 |
833 bool Document::info(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError
) | 833 FX_BOOL Document::info(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sEr
ror) |
834 { | 834 { |
835 ASSERT(m_pDocument != NULL); | 835 ASSERT(m_pDocument != NULL); |
836 | 836 |
837 CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo(); | 837 CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo(); |
838 if (!pDictionary) | 838 if (!pDictionary) |
839 return false; | 839 return FALSE; |
840 | 840 |
841 CFX_WideString cwAuthor = pDictionary->GetUnicodeText("Author"); | 841 CFX_WideString cwAuthor = pDictionary->GetUnicodeText("Author"); |
842 CFX_WideString cwTitle = pDictionary->GetUnicodeText("Title"); | 842 CFX_WideString cwTitle = pDictionary->GetUnicodeText("Title"); |
843 CFX_WideString cwSubject = pDictionary->GetUnicodeText("Subject"); | 843 CFX_WideString cwSubject = pDictionary->GetUnicodeText("Subject"); |
844 CFX_WideString cwKeywords = pDictionary->GetUnicodeText("Keywords"); | 844 CFX_WideString cwKeywords = pDictionary->GetUnicodeText("Keywords"); |
845 CFX_WideString cwCreator = pDictionary->GetUnicodeText("Creator"); | 845 CFX_WideString cwCreator = pDictionary->GetUnicodeText("Creator"); |
846 CFX_WideString cwProducer = pDictionary->GetUnicodeText("Producer"); | 846 CFX_WideString cwProducer = pDictionary->GetUnicodeText("Producer"); |
847 CFX_WideString cwCreationDate = pDictionary->GetUnicodeText("CreationDate"
); | 847 CFX_WideString cwCreationDate = pDictionary->GetUnicodeText("CreationDate"
); |
848 CFX_WideString cwModDate = pDictionary->GetUnicodeText("ModDate"); | 848 CFX_WideString cwModDate = pDictionary->GetUnicodeText("ModDate"); |
849 CFX_WideString cwTrapped = pDictionary->GetUnicodeText("Trapped"); | 849 CFX_WideString cwTrapped = pDictionary->GetUnicodeText("Trapped"); |
(...skipping 23 matching lines...) Expand all Loading... |
873 CFX_WideString wsKey = CFX_WideString::FromUTF8(bsKey, bsKey.GetLen
gth()); | 873 CFX_WideString wsKey = CFX_WideString::FromUTF8(bsKey, bsKey.GetLen
gth()); |
874 if((pValueObj->GetType()==PDFOBJ_STRING) || (pValueObj->GetType()==P
DFOBJ_NAME) ) | 874 if((pValueObj->GetType()==PDFOBJ_STRING) || (pValueObj->GetType()==P
DFOBJ_NAME) ) |
875 JS_PutObjectString(isolate, pObj, wsKey.c_str(), pValueObj->GetU
nicodeText().c_str()); | 875 JS_PutObjectString(isolate, pObj, wsKey.c_str(), pValueObj->GetU
nicodeText().c_str()); |
876 if(pValueObj->GetType()==PDFOBJ_NUMBER) | 876 if(pValueObj->GetType()==PDFOBJ_NUMBER) |
877 JS_PutObjectNumber(isolate,pObj, wsKey.c_str(), (float)pValueObj
->GetNumber()); | 877 JS_PutObjectNumber(isolate,pObj, wsKey.c_str(), (float)pValueObj
->GetNumber()); |
878 if(pValueObj->GetType()==PDFOBJ_BOOLEAN) | 878 if(pValueObj->GetType()==PDFOBJ_BOOLEAN) |
879 JS_PutObjectBoolean(isolate,pObj, wsKey.c_str(), (bool)pValueObj
->GetInteger()); | 879 JS_PutObjectBoolean(isolate,pObj, wsKey.c_str(), (bool)pValueObj
->GetInteger()); |
880 } | 880 } |
881 vp << pObj; | 881 vp << pObj; |
882 } | 882 } |
883 return true; | 883 return TRUE; |
884 } | 884 } |
885 | 885 |
886 bool Document::creationDate(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString
& sError) | 886 FX_BOOL Document::creationDate(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideStr
ing& sError) |
887 { | 887 { |
888 CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo(); | 888 CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo(); |
889 if (!pDictionary) | 889 if (!pDictionary) |
890 return false; | 890 return FALSE; |
891 | 891 |
892 if (vp.IsGetting()) | 892 if (vp.IsGetting()) |
893 { | 893 { |
894 vp << pDictionary->GetUnicodeText("CreationDate"); | 894 vp << pDictionary->GetUnicodeText("CreationDate"); |
895 } | 895 } |
896 else | 896 else |
897 { | 897 { |
898 if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) | 898 if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) |
899 return false; | 899 return FALSE; |
900 | 900 |
901 CFX_WideString csCreationDate; | 901 CFX_WideString csCreationDate; |
902 vp >> csCreationDate; | 902 vp >> csCreationDate; |
903 pDictionary->SetAtString("CreationDate", PDF_EncodeText(csCreationDate))
; | 903 pDictionary->SetAtString("CreationDate", PDF_EncodeText(csCreationDate))
; |
904 m_pDocument->SetChangeMark(); | 904 m_pDocument->SetChangeMark(); |
905 } | 905 } |
906 return true; | 906 return TRUE; |
907 } | 907 } |
908 | 908 |
909 bool Document::creator(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sEr
ror) | 909 FX_BOOL Document::creator(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString&
sError) |
910 { | 910 { |
911 CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo(); | 911 CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo(); |
912 if (!pDictionary) | 912 if (!pDictionary) |
913 return false; | 913 return FALSE; |
914 | 914 |
915 if (vp.IsGetting()) | 915 if (vp.IsGetting()) |
916 { | 916 { |
917 vp << pDictionary->GetUnicodeText("Creator"); | 917 vp << pDictionary->GetUnicodeText("Creator"); |
918 } | 918 } |
919 else | 919 else |
920 { | 920 { |
921 if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) | 921 if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) |
922 return false; | 922 return FALSE; |
923 | 923 |
924 CFX_WideString csCreator; | 924 CFX_WideString csCreator; |
925 vp >> csCreator; | 925 vp >> csCreator; |
926 pDictionary->SetAtString("Creator", PDF_EncodeText(csCreator)); | 926 pDictionary->SetAtString("Creator", PDF_EncodeText(csCreator)); |
927 m_pDocument->SetChangeMark(); | 927 m_pDocument->SetChangeMark(); |
928 } | 928 } |
929 return true; | 929 return TRUE; |
930 } | 930 } |
931 | 931 |
932 bool Document::delay(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sErro
r) | 932 FX_BOOL Document::delay(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sE
rror) |
933 { | 933 { |
934 if (vp.IsGetting()) | 934 if (vp.IsGetting()) |
935 { | 935 { |
936 vp << m_bDelay; | 936 vp << m_bDelay; |
937 } | 937 } |
938 else | 938 else |
939 { | 939 { |
940 if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) | 940 if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) |
941 return false; | 941 return FALSE; |
942 | 942 |
943 bool b; | 943 bool b; |
944 vp >> b; | 944 vp >> b; |
945 m_bDelay = b; | 945 m_bDelay = b; |
946 if (m_bDelay) | 946 if (m_bDelay) |
947 { | 947 { |
948 for (int i=0,sz=m_DelayData.GetSize(); i<sz; i++) | 948 for (int i=0,sz=m_DelayData.GetSize(); i<sz; i++) |
949 delete m_DelayData.GetAt(i); | 949 delete m_DelayData.GetAt(i); |
950 | 950 |
951 m_DelayData.RemoveAll(); | 951 m_DelayData.RemoveAll(); |
(...skipping 12 matching lines...) Expand all Loading... |
964 m_DelayData.RemoveAll(); | 964 m_DelayData.RemoveAll(); |
965 for (int i=0,sz=DelayDataToProcess.GetSize(); i < sz; i++) | 965 for (int i=0,sz=DelayDataToProcess.GetSize(); i < sz; i++) |
966 { | 966 { |
967 CJS_DelayData* pData = DelayDataToProcess.GetAt(i); | 967 CJS_DelayData* pData = DelayDataToProcess.GetAt(i); |
968 Field::DoDelay(m_pDocument, pData); | 968 Field::DoDelay(m_pDocument, pData); |
969 DelayDataToProcess.SetAt(i,NULL); | 969 DelayDataToProcess.SetAt(i,NULL); |
970 delete pData; | 970 delete pData; |
971 } | 971 } |
972 } | 972 } |
973 } | 973 } |
974 return true; | 974 return TRUE; |
975 } | 975 } |
976 | 976 |
977 bool Document::keywords(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sE
rror) | 977 FX_BOOL Document::keywords(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString&
sError) |
978 { | 978 { |
979 CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo(); | 979 CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo(); |
980 if (!pDictionary) | 980 if (!pDictionary) |
981 return false; | 981 return FALSE; |
982 | 982 |
983 if (vp.IsGetting()) | 983 if (vp.IsGetting()) |
984 { | 984 { |
985 vp << pDictionary->GetUnicodeText("Keywords"); | 985 vp << pDictionary->GetUnicodeText("Keywords"); |
986 } | 986 } |
987 else | 987 else |
988 { | 988 { |
989 if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) | 989 if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) |
990 return false; | 990 return FALSE; |
991 | 991 |
992 CFX_WideString csKeywords; | 992 CFX_WideString csKeywords; |
993 vp >> csKeywords; | 993 vp >> csKeywords; |
994 pDictionary->SetAtString("Keywords", PDF_EncodeText(csKeywords)); | 994 pDictionary->SetAtString("Keywords", PDF_EncodeText(csKeywords)); |
995 m_pDocument->SetChangeMark(); | 995 m_pDocument->SetChangeMark(); |
996 } | 996 } |
997 return true; | 997 return TRUE; |
998 } | 998 } |
999 | 999 |
1000 bool Document::modDate(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sEr
ror) | 1000 FX_BOOL Document::modDate(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString&
sError) |
1001 { | 1001 { |
1002 CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo(); | 1002 CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo(); |
1003 if (!pDictionary) | 1003 if (!pDictionary) |
1004 return false; | 1004 return FALSE; |
1005 | 1005 |
1006 if (vp.IsGetting()) | 1006 if (vp.IsGetting()) |
1007 { | 1007 { |
1008 vp << pDictionary->GetUnicodeText("ModDate"); | 1008 vp << pDictionary->GetUnicodeText("ModDate"); |
1009 } | 1009 } |
1010 else | 1010 else |
1011 { | 1011 { |
1012 if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) | 1012 if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) |
1013 return false; | 1013 return FALSE; |
1014 | 1014 |
1015 CFX_WideString csmodDate; | 1015 CFX_WideString csmodDate; |
1016 vp >> csmodDate; | 1016 vp >> csmodDate; |
1017 pDictionary->SetAtString("ModDate", PDF_EncodeText(csmodDate)); | 1017 pDictionary->SetAtString("ModDate", PDF_EncodeText(csmodDate)); |
1018 m_pDocument->SetChangeMark(); | 1018 m_pDocument->SetChangeMark(); |
1019 } | 1019 } |
1020 return true; | 1020 return TRUE; |
1021 } | 1021 } |
1022 | 1022 |
1023 bool Document::producer(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sE
rror) | 1023 FX_BOOL Document::producer(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString&
sError) |
1024 { | 1024 { |
1025 CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo(); | 1025 CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo(); |
1026 if (!pDictionary) | 1026 if (!pDictionary) |
1027 return false; | 1027 return FALSE; |
1028 | 1028 |
1029 if (vp.IsGetting()) | 1029 if (vp.IsGetting()) |
1030 { | 1030 { |
1031 vp << pDictionary->GetUnicodeText("Producer"); | 1031 vp << pDictionary->GetUnicodeText("Producer"); |
1032 } | 1032 } |
1033 else | 1033 else |
1034 { | 1034 { |
1035 if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) | 1035 if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) |
1036 return false; | 1036 return FALSE; |
1037 | 1037 |
1038 CFX_WideString csproducer; | 1038 CFX_WideString csproducer; |
1039 vp >> csproducer; | 1039 vp >> csproducer; |
1040 pDictionary->SetAtString("Producer", PDF_EncodeText(csproducer)); | 1040 pDictionary->SetAtString("Producer", PDF_EncodeText(csproducer)); |
1041 m_pDocument->SetChangeMark(); | 1041 m_pDocument->SetChangeMark(); |
1042 } | 1042 } |
1043 return true; | 1043 return TRUE; |
1044 } | 1044 } |
1045 | 1045 |
1046 bool Document::subject(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sEr
ror) | 1046 FX_BOOL Document::subject(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString&
sError) |
1047 { | 1047 { |
1048 CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo(); | 1048 CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo(); |
1049 if (!pDictionary) | 1049 if (!pDictionary) |
1050 return false; | 1050 return FALSE; |
1051 | 1051 |
1052 if (vp.IsGetting()) | 1052 if (vp.IsGetting()) |
1053 { | 1053 { |
1054 vp << pDictionary->GetUnicodeText("Subject"); | 1054 vp << pDictionary->GetUnicodeText("Subject"); |
1055 } | 1055 } |
1056 else | 1056 else |
1057 { | 1057 { |
1058 if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) | 1058 if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) |
1059 return false; | 1059 return FALSE; |
1060 | 1060 |
1061 CFX_WideString cssubject; | 1061 CFX_WideString cssubject; |
1062 vp >> cssubject; | 1062 vp >> cssubject; |
1063 pDictionary->SetAtString("Subject", PDF_EncodeText(cssubject)); | 1063 pDictionary->SetAtString("Subject", PDF_EncodeText(cssubject)); |
1064 m_pDocument->SetChangeMark(); | 1064 m_pDocument->SetChangeMark(); |
1065 } | 1065 } |
1066 return true; | 1066 return TRUE; |
1067 } | 1067 } |
1068 | 1068 |
1069 bool Document::title(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sErro
r) | 1069 FX_BOOL Document::title(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sE
rror) |
1070 { | 1070 { |
1071 if (m_pDocument == NULL || m_pDocument->GetDocument() == NULL) | 1071 if (m_pDocument == NULL || m_pDocument->GetDocument() == NULL) |
1072 return false; | 1072 return FALSE; |
1073 | 1073 |
1074 CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo(); | 1074 CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo(); |
1075 if (!pDictionary) | 1075 if (!pDictionary) |
1076 return false; | 1076 return FALSE; |
1077 | 1077 |
1078 if (vp.IsGetting()) | 1078 if (vp.IsGetting()) |
1079 { | 1079 { |
1080 vp << pDictionary->GetUnicodeText("Title"); | 1080 vp << pDictionary->GetUnicodeText("Title"); |
1081 } | 1081 } |
1082 else | 1082 else |
1083 { | 1083 { |
1084 if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) | 1084 if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) |
1085 return false; | 1085 return FALSE; |
1086 | 1086 |
1087 CFX_WideString cstitle; | 1087 CFX_WideString cstitle; |
1088 vp >> cstitle; | 1088 vp >> cstitle; |
1089 pDictionary->SetAtString("Title", PDF_EncodeText(cstitle)); | 1089 pDictionary->SetAtString("Title", PDF_EncodeText(cstitle)); |
1090 m_pDocument->SetChangeMark(); | 1090 m_pDocument->SetChangeMark(); |
1091 } | 1091 } |
1092 return true; | 1092 return TRUE; |
1093 } | 1093 } |
1094 | 1094 |
1095 bool Document::numPages(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sE
rror) | 1095 FX_BOOL Document::numPages(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString&
sError) |
1096 { | 1096 { |
1097 if (vp.IsSetting()) { | 1097 if (vp.IsSetting()) { |
1098 CJS_Context* pContext = static_cast<CJS_Context*>(cc); | 1098 CJS_Context* pContext = static_cast<CJS_Context*>(cc); |
1099 sError = JSGetStringFromID(pContext, IDS_STRING_JSREADONLY); | 1099 sError = JSGetStringFromID(pContext, IDS_STRING_JSREADONLY); |
1100 return false; | 1100 return FALSE; |
1101 } | 1101 } |
1102 vp << m_pDocument->GetPageCount(); | 1102 vp << m_pDocument->GetPageCount(); |
1103 return true; | 1103 return TRUE; |
1104 } | 1104 } |
1105 | 1105 |
1106 bool Document::external(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sE
rror) | 1106 FX_BOOL Document::external(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString&
sError) |
1107 { | 1107 { |
1108 //In Chrome case,should always return true. | 1108 //In Chrome case,should always return true. |
1109 if (vp.IsGetting()) { | 1109 if (vp.IsGetting()) { |
1110 vp << true; | 1110 vp << TRUE; |
1111 } | 1111 } |
1112 return true; | 1112 return TRUE; |
1113 } | 1113 } |
1114 | 1114 |
1115 bool Document::filesize(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sE
rror) | 1115 FX_BOOL Document::filesize(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString&
sError) |
1116 { | 1116 { |
1117 if (vp.IsSetting()) { | 1117 if (vp.IsSetting()) { |
1118 CJS_Context* pContext = static_cast<CJS_Context*>(cc); | 1118 CJS_Context* pContext = static_cast<CJS_Context*>(cc); |
1119 sError = JSGetStringFromID(pContext, IDS_STRING_JSREADONLY); | 1119 sError = JSGetStringFromID(pContext, IDS_STRING_JSREADONLY); |
1120 return false; | 1120 return FALSE; |
1121 } | 1121 } |
1122 vp << 0; | 1122 vp << 0; |
1123 return true; | 1123 return TRUE; |
1124 } | 1124 } |
1125 | 1125 |
1126 bool Document::mouseX(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sErr
or) | 1126 FX_BOOL Document::mouseX(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& s
Error) |
1127 { | 1127 { |
1128 return true; | 1128 return TRUE; |
1129 } | 1129 } |
1130 | 1130 |
1131 bool Document::mouseY(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sErr
or) | 1131 FX_BOOL Document::mouseY(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& s
Error) |
1132 { | 1132 { |
1133 return true; | 1133 return TRUE; |
1134 } | 1134 } |
1135 | 1135 |
1136 bool Document::baseURL(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sEr
ror) | 1136 FX_BOOL Document::baseURL(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString&
sError) |
1137 { | 1137 { |
1138 if (vp.IsGetting()) | 1138 if (vp.IsGetting()) |
1139 { | 1139 { |
1140 vp << m_cwBaseURL; | 1140 vp << m_cwBaseURL; |
1141 } | 1141 } |
1142 else | 1142 else |
1143 { | 1143 { |
1144 vp >> m_cwBaseURL; | 1144 vp >> m_cwBaseURL; |
1145 } | 1145 } |
1146 return true; | 1146 return TRUE; |
1147 } | 1147 } |
1148 | 1148 |
1149 bool Document::calculate(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& s
Error) | 1149 FX_BOOL Document::calculate(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString
& sError) |
1150 { | 1150 { |
1151 ASSERT(m_pDocument != NULL); | 1151 ASSERT(m_pDocument != NULL); |
1152 | 1152 |
1153 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInterFor
m(); | 1153 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInterFor
m(); |
1154 ASSERT(pInterForm != NULL); | 1154 ASSERT(pInterForm != NULL); |
1155 | 1155 |
1156 if (vp.IsGetting()) | 1156 if (vp.IsGetting()) |
1157 { | 1157 { |
1158 if (pInterForm->IsCalculateEnabled()) | 1158 if (pInterForm->IsCalculateEnabled()) |
1159 vp << true; | 1159 vp << true; |
1160 else | 1160 else |
1161 vp << false; | 1161 vp << false; |
1162 } | 1162 } |
1163 else | 1163 else |
1164 { | 1164 { |
1165 bool bCalculate; | 1165 bool bCalculate; |
1166 vp >> bCalculate; | 1166 vp >> bCalculate; |
1167 | 1167 |
1168 pInterForm->EnableCalculate(bCalculate); | 1168 pInterForm->EnableCalculate(bCalculate); |
1169 } | 1169 } |
1170 | 1170 |
1171 return true; | 1171 return TRUE; |
1172 } | 1172 } |
1173 | 1173 |
1174 bool Document::documentFileName(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideSt
ring& sError) | 1174 FX_BOOL Document::documentFileName(IFXJS_Context* cc, CJS_PropValue& vp, CFX_Wid
eString& sError) |
1175 { | 1175 { |
1176 if (vp.IsSetting()) { | 1176 if (vp.IsSetting()) { |
1177 CJS_Context* pContext = static_cast<CJS_Context*>(cc); | 1177 CJS_Context* pContext = static_cast<CJS_Context*>(cc); |
1178 sError = JSGetStringFromID(pContext, IDS_STRING_JSREADONLY); | 1178 sError = JSGetStringFromID(pContext, IDS_STRING_JSREADONLY); |
1179 return false; | 1179 return FALSE; |
1180 } | 1180 } |
1181 CFX_WideString wsFilePath = m_pDocument->GetPath(); | 1181 CFX_WideString wsFilePath = m_pDocument->GetPath(); |
1182 int32_t i = wsFilePath.GetLength() - 1; | 1182 int32_t i = wsFilePath.GetLength() - 1; |
1183 for ( ; i >= 0; i-- ) | 1183 for ( ; i >= 0; i-- ) |
1184 { | 1184 { |
1185 if ( wsFilePath.GetAt( i ) == L'\\' || wsFilePath.GetAt( i ) == L'/' ) | 1185 if ( wsFilePath.GetAt( i ) == L'\\' || wsFilePath.GetAt( i ) == L'/' ) |
1186 break; | 1186 break; |
1187 } | 1187 } |
1188 if ( i >= 0 && i < wsFilePath.GetLength() - 1 ) | 1188 if ( i >= 0 && i < wsFilePath.GetLength() - 1 ) |
1189 { | 1189 { |
1190 vp << ( wsFilePath.GetBuffer( wsFilePath.GetLength() ) + i + 1 ); | 1190 vp << ( wsFilePath.GetBuffer( wsFilePath.GetLength() ) + i + 1 ); |
1191 }else{ | 1191 }else{ |
1192 vp << L""; | 1192 vp << L""; |
1193 } | 1193 } |
1194 return true; | 1194 return TRUE; |
1195 } | 1195 } |
1196 | 1196 |
1197 CFX_WideString Document::ReversalStr(CFX_WideString cbFrom) | 1197 CFX_WideString Document::ReversalStr(CFX_WideString cbFrom) |
1198 { | 1198 { |
1199 size_t iLength = cbFrom.GetLength(); | 1199 size_t iLength = cbFrom.GetLength(); |
1200 pdfium::base::CheckedNumeric<size_t> iSize = sizeof(wchar_t); | 1200 pdfium::base::CheckedNumeric<size_t> iSize = sizeof(wchar_t); |
1201 iSize *= (iLength + 1); | 1201 iSize *= (iLength + 1); |
1202 wchar_t* pResult = (wchar_t*)malloc(iSize.ValueOrDie()); | 1202 wchar_t* pResult = (wchar_t*)malloc(iSize.ValueOrDie()); |
1203 wchar_t* pFrom = (wchar_t*)cbFrom.GetBuffer(iLength); | 1203 wchar_t* pFrom = (wchar_t*)cbFrom.GetBuffer(iLength); |
1204 | 1204 |
(...skipping 29 matching lines...) Expand all Loading... |
1234 } | 1234 } |
1235 pResult[iLength] = L'\0'; | 1235 pResult[iLength] = L'\0'; |
1236 | 1236 |
1237 cbFrom.ReleaseBuffer(); | 1237 cbFrom.ReleaseBuffer(); |
1238 CFX_WideString cbRet = CFX_WideString(pResult); | 1238 CFX_WideString cbRet = CFX_WideString(pResult); |
1239 free(pResult); | 1239 free(pResult); |
1240 pResult = NULL; | 1240 pResult = NULL; |
1241 return cbRet; | 1241 return cbRet; |
1242 } | 1242 } |
1243 | 1243 |
1244 bool Document::path(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError
) | 1244 FX_BOOL Document::path(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sEr
ror) |
1245 { | 1245 { |
1246 if (vp.IsSetting()) { | 1246 if (vp.IsSetting()) { |
1247 CJS_Context* pContext = static_cast<CJS_Context*>(cc); | 1247 CJS_Context* pContext = static_cast<CJS_Context*>(cc); |
1248 sError = JSGetStringFromID(pContext, IDS_STRING_JSREADONLY); | 1248 sError = JSGetStringFromID(pContext, IDS_STRING_JSREADONLY); |
1249 return false; | 1249 return FALSE; |
1250 } | 1250 } |
1251 vp << app::SysPathToPDFPath(m_pDocument->GetPath()); | 1251 vp << app::SysPathToPDFPath(m_pDocument->GetPath()); |
1252 return true; | 1252 return TRUE; |
1253 } | 1253 } |
1254 | 1254 |
1255 bool Document::pageWindowRect(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideStri
ng& sError) | 1255 FX_BOOL Document::pageWindowRect(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideS
tring& sError) |
1256 { | 1256 { |
1257 return true; | 1257 return TRUE; |
1258 } | 1258 } |
1259 | 1259 |
1260 bool Document::layout(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sErr
or) | 1260 FX_BOOL Document::layout(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& s
Error) |
1261 { | 1261 { |
1262 return true; | 1262 return TRUE; |
1263 } | 1263 } |
1264 | 1264 |
1265 bool Document::addLink(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Valu
e& vRet, CFX_WideString& sError) | 1265 FX_BOOL Document::addLink(IFXJS_Context* cc, const CJS_Parameters& params, CJS_V
alue& vRet, CFX_WideString& sError) |
1266 { | 1266 { |
1267 return true; | 1267 return TRUE; |
1268 } | 1268 } |
1269 | 1269 |
1270 bool Document::closeDoc(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Val
ue& vRet, CFX_WideString& sError) | 1270 FX_BOOL Document::closeDoc(IFXJS_Context* cc, const CJS_Parameters& params, CJS_
Value& vRet, CFX_WideString& sError) |
1271 { | 1271 { |
1272 ASSERT(m_pDocument != NULL); | 1272 ASSERT(m_pDocument != NULL); |
1273 return true; | 1273 return TRUE; |
1274 } | 1274 } |
1275 | 1275 |
1276 bool Document::getPageBox(IFXJS_Context* cc, const CJS_Parameters& params, CJS_V
alue& vRet, CFX_WideString& sError) | 1276 FX_BOOL Document::getPageBox(IFXJS_Context* cc, const CJS_Parameters& params, CJ
S_Value& vRet, CFX_WideString& sError) |
1277 { | 1277 { |
1278 return true; | 1278 return TRUE; |
1279 } | 1279 } |
1280 | 1280 |
1281 bool Document::getAnnot(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Val
ue& vRet, CFX_WideString& sError) | 1281 FX_BOOL Document::getAnnot(IFXJS_Context* cc, const CJS_Parameters& params, CJS_
Value& vRet, CFX_WideString& sError) |
1282 { | 1282 { |
1283 return true; | 1283 return TRUE; |
1284 } | 1284 } |
1285 | 1285 |
1286 bool Document::getAnnots(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Va
lue& vRet, CFX_WideString& sError) | 1286 FX_BOOL Document::getAnnots(IFXJS_Context* cc, const CJS_Parameters& params, CJS
_Value& vRet, CFX_WideString& sError) |
1287 { | 1287 { |
1288 vRet.SetNull(); | 1288 vRet.SetNull(); |
1289 return true; | 1289 return TRUE; |
1290 } | 1290 } |
1291 | 1291 |
1292 bool Document::getAnnot3D(IFXJS_Context* cc, const CJS_Parameters& params, CJS_V
alue& vRet, CFX_WideString& sError) | 1292 FX_BOOL Document::getAnnot3D(IFXJS_Context* cc, const CJS_Parameters& params, CJ
S_Value& vRet, CFX_WideString& sError) |
1293 { | 1293 { |
1294 vRet.SetNull(); | 1294 vRet.SetNull(); |
1295 return true; | 1295 return TRUE; |
1296 } | 1296 } |
1297 | 1297 |
1298 bool Document::getAnnots3D(IFXJS_Context* cc, const CJS_Parameters& params, CJS_
Value& vRet, CFX_WideString& sError) | 1298 FX_BOOL Document::getAnnots3D(IFXJS_Context* cc, const CJS_Parameters& params, C
JS_Value& vRet, CFX_WideString& sError) |
1299 { | 1299 { |
1300 vRet = VT_undefined; | 1300 vRet = VT_undefined; |
1301 return true; | 1301 return TRUE; |
1302 } | 1302 } |
1303 | 1303 |
1304 bool Document::getOCGs(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Valu
e& vRet, CFX_WideString& sError) | 1304 FX_BOOL Document::getOCGs(IFXJS_Context* cc, const CJS_Parameters& params, CJS_V
alue& vRet, CFX_WideString& sError) |
1305 { | 1305 { |
1306 return true; | 1306 return TRUE; |
1307 } | 1307 } |
1308 | 1308 |
1309 bool Document::getLinks(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Val
ue& vRet, CFX_WideString& sError) | 1309 FX_BOOL Document::getLinks(IFXJS_Context* cc, const CJS_Parameters& params, CJS_
Value& vRet, CFX_WideString& sError) |
1310 { | 1310 { |
1311 return true; | 1311 return TRUE; |
1312 } | 1312 } |
1313 | 1313 |
1314 bool Document::IsEnclosedInRect(CFX_FloatRect rect, CFX_FloatRect LinkRect) | 1314 bool Document::IsEnclosedInRect(CFX_FloatRect rect, CFX_FloatRect LinkRect) |
1315 { | 1315 { |
1316 return (rect.left <= LinkRect.left && | 1316 return (rect.left <= LinkRect.left && |
1317 rect.top <= LinkRect.top && | 1317 rect.top <= LinkRect.top && |
1318 rect.right >= LinkRect.right && | 1318 rect.right >= LinkRect.right && |
1319 rect.bottom >= LinkRect.bottom); | 1319 rect.bottom >= LinkRect.bottom); |
1320 } | 1320 } |
1321 | 1321 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1365 IconElement* pTemp = m_pHead; | 1365 IconElement* pTemp = m_pHead; |
1366 for (int i = 0; i < iIndex; i++) | 1366 for (int i = 0; i < iIndex; i++) |
1367 { | 1367 { |
1368 pTemp = pTemp->NextIcon; | 1368 pTemp = pTemp->NextIcon; |
1369 } | 1369 } |
1370 return pTemp; | 1370 return pTemp; |
1371 } | 1371 } |
1372 return NULL; | 1372 return NULL; |
1373 } | 1373 } |
1374 | 1374 |
1375 bool Document::addIcon(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Valu
e& vRet, CFX_WideString& sError) | 1375 FX_BOOL Document::addIcon(IFXJS_Context* cc, const CJS_Parameters& params, CJS_V
alue& vRet, CFX_WideString& sError) |
1376 { | 1376 { |
1377 CJS_Context* pContext = (CJS_Context*)cc; | 1377 CJS_Context* pContext = (CJS_Context*)cc; |
1378 if (params.size() != 2) { | 1378 if (params.size() != 2) { |
1379 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); | 1379 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
1380 return false; | 1380 return FALSE; |
1381 } | 1381 } |
1382 | 1382 |
1383 CFX_WideString swIconName = params[0].ToCFXWideString(); | 1383 CFX_WideString swIconName = params[0].ToCFXWideString(); |
1384 JSFXObject pJSIcon = params[1].ToV8Object(); | 1384 JSFXObject pJSIcon = params[1].ToV8Object(); |
1385 | 1385 |
1386 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 1386 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
1387 if (JS_GetObjDefnID(pJSIcon) != JS_GetObjDefnID(*pRuntime, L"Icon")) { | 1387 if (JS_GetObjDefnID(pJSIcon) != JS_GetObjDefnID(*pRuntime, L"Icon")) { |
1388 sError = JSGetStringFromID(pContext, IDS_STRING_JSTYPEERROR); | 1388 sError = JSGetStringFromID(pContext, IDS_STRING_JSTYPEERROR); |
1389 return false; | 1389 return FALSE; |
1390 } | 1390 } |
1391 | 1391 |
1392 CJS_EmbedObj* pEmbedObj = params[1].ToCJSObject()->GetEmbedObject(); | 1392 CJS_EmbedObj* pEmbedObj = params[1].ToCJSObject()->GetEmbedObject(); |
1393 if (!pEmbedObj) { | 1393 if (!pEmbedObj) { |
1394 sError = JSGetStringFromID(pContext, IDS_STRING_JSTYPEERROR); | 1394 sError = JSGetStringFromID(pContext, IDS_STRING_JSTYPEERROR); |
1395 return false; | 1395 return FALSE; |
1396 } | 1396 } |
1397 | 1397 |
1398 Icon* pIcon = (Icon*)pEmbedObj; | 1398 Icon* pIcon = (Icon*)pEmbedObj; |
1399 if (!m_pIconTree) | 1399 if (!m_pIconTree) |
1400 m_pIconTree = new IconTree(); | 1400 m_pIconTree = new IconTree(); |
1401 | 1401 |
1402 IconElement* pNewIcon = new IconElement(); | 1402 IconElement* pNewIcon = new IconElement(); |
1403 pNewIcon->IconName = swIconName; | 1403 pNewIcon->IconName = swIconName; |
1404 pNewIcon->NextIcon = NULL; | 1404 pNewIcon->NextIcon = NULL; |
1405 pNewIcon->IconStream = pIcon; | 1405 pNewIcon->IconStream = pIcon; |
1406 m_pIconTree->InsertIconElement(pNewIcon); | 1406 m_pIconTree->InsertIconElement(pNewIcon); |
1407 return true; | 1407 return TRUE; |
1408 } | 1408 } |
1409 | 1409 |
1410 bool Document::icons(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sErro
r) | 1410 FX_BOOL Document::icons(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sE
rror) |
1411 { | 1411 { |
1412 if (vp.IsSetting()) { | 1412 if (vp.IsSetting()) { |
1413 CJS_Context* pContext = static_cast<CJS_Context*>(cc); | 1413 CJS_Context* pContext = static_cast<CJS_Context*>(cc); |
1414 sError = JSGetStringFromID(pContext, IDS_STRING_JSREADONLY); | 1414 sError = JSGetStringFromID(pContext, IDS_STRING_JSREADONLY); |
1415 return false; | 1415 return FALSE; |
1416 } | 1416 } |
1417 | 1417 |
1418 if (!m_pIconTree) | 1418 if (!m_pIconTree) |
1419 { | 1419 { |
1420 vp.SetNull(); | 1420 vp.SetNull(); |
1421 return true; | 1421 return TRUE; |
1422 } | 1422 } |
1423 | 1423 |
1424 CJS_Array Icons(m_isolate); | 1424 CJS_Array Icons(m_isolate); |
1425 IconElement* pIconElement = NULL; | 1425 IconElement* pIconElement = NULL; |
1426 int iIconTreeLength = m_pIconTree->GetLength(); | 1426 int iIconTreeLength = m_pIconTree->GetLength(); |
1427 | 1427 |
1428 CJS_Context* pContext = (CJS_Context *)cc; | 1428 CJS_Context* pContext = (CJS_Context *)cc; |
1429 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 1429 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
1430 | 1430 |
1431 for (int i = 0; i < iIconTreeLength; i++) | 1431 for (int i = 0; i < iIconTreeLength; i++) |
1432 { | 1432 { |
1433 pIconElement = (*m_pIconTree)[i]; | 1433 pIconElement = (*m_pIconTree)[i]; |
1434 | 1434 |
1435 JSFXObject pObj = JS_NewFxDynamicObj(*pRuntime, pContext, JS_GetObjDefn
ID(*pRuntime, L"Icon")); | 1435 JSFXObject pObj = JS_NewFxDynamicObj(*pRuntime, pContext, JS_GetObjDefn
ID(*pRuntime, L"Icon")); |
1436 if (pObj.IsEmpty()) return false; | 1436 if (pObj.IsEmpty()) return FALSE; |
1437 | 1437 |
1438 CJS_Icon * pJS_Icon = (CJS_Icon *)JS_GetPrivate(pObj); | 1438 CJS_Icon * pJS_Icon = (CJS_Icon *)JS_GetPrivate(pObj); |
1439 if (!pJS_Icon) return false; | 1439 if (!pJS_Icon) return FALSE; |
1440 | 1440 |
1441 Icon* pIcon = (Icon*)pJS_Icon->GetEmbedObject(); | 1441 Icon* pIcon = (Icon*)pJS_Icon->GetEmbedObject(); |
1442 if (!pIcon)return false; | 1442 if (!pIcon)return FALSE; |
1443 | 1443 |
1444 pIcon->SetStream(pIconElement->IconStream->GetStream()); | 1444 pIcon->SetStream(pIconElement->IconStream->GetStream()); |
1445 pIcon->SetIconName(pIconElement->IconName); | 1445 pIcon->SetIconName(pIconElement->IconName); |
1446 Icons.SetElement(i, CJS_Value(m_isolate,pJS_Icon)); | 1446 Icons.SetElement(i, CJS_Value(m_isolate,pJS_Icon)); |
1447 } | 1447 } |
1448 | 1448 |
1449 vp << Icons; | 1449 vp << Icons; |
1450 return true; | 1450 return TRUE; |
1451 } | 1451 } |
1452 | 1452 |
1453 bool Document::getIcon(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Valu
e& vRet, CFX_WideString& sError) | 1453 FX_BOOL Document::getIcon(IFXJS_Context* cc, const CJS_Parameters& params, CJS_V
alue& vRet, CFX_WideString& sError) |
1454 { | 1454 { |
1455 CJS_Context* pContext = (CJS_Context *)cc; | 1455 CJS_Context* pContext = (CJS_Context *)cc; |
1456 if (params.size() != 1) { | 1456 if (params.size() != 1) { |
1457 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); | 1457 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
1458 return false; | 1458 return FALSE; |
1459 } | 1459 } |
1460 | 1460 |
1461 if(!m_pIconTree) | 1461 if(!m_pIconTree) |
1462 return false; | 1462 return FALSE; |
1463 CFX_WideString swIconName = params[0].ToCFXWideString(); | 1463 CFX_WideString swIconName = params[0].ToCFXWideString(); |
1464 int iIconCounts = m_pIconTree->GetLength(); | 1464 int iIconCounts = m_pIconTree->GetLength(); |
1465 | 1465 |
1466 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 1466 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
1467 | 1467 |
1468 for (int i = 0; i < iIconCounts; i++) | 1468 for (int i = 0; i < iIconCounts; i++) |
1469 { | 1469 { |
1470 if ((*m_pIconTree)[i]->IconName == swIconName) | 1470 if ((*m_pIconTree)[i]->IconName == swIconName) |
1471 { | 1471 { |
1472 Icon* pRetIcon = (*m_pIconTree)[i]->IconStream; | 1472 Icon* pRetIcon = (*m_pIconTree)[i]->IconStream; |
1473 | 1473 |
1474 JSFXObject pObj = JS_NewFxDynamicObj(*pRuntime, pContext, JS_GetObj
DefnID(*pRuntime, L"Icon")); | 1474 JSFXObject pObj = JS_NewFxDynamicObj(*pRuntime, pContext, JS_GetObj
DefnID(*pRuntime, L"Icon")); |
1475 if (pObj.IsEmpty()) return false; | 1475 if (pObj.IsEmpty()) return FALSE; |
1476 | 1476 |
1477 CJS_Icon * pJS_Icon = (CJS_Icon *)JS_GetPrivate(pObj); | 1477 CJS_Icon * pJS_Icon = (CJS_Icon *)JS_GetPrivate(pObj); |
1478 if (!pJS_Icon) return false; | 1478 if (!pJS_Icon) return FALSE; |
1479 | 1479 |
1480 Icon* pIcon = (Icon*)pJS_Icon->GetEmbedObject(); | 1480 Icon* pIcon = (Icon*)pJS_Icon->GetEmbedObject(); |
1481 if (!pIcon)return false; | 1481 if (!pIcon)return FALSE; |
1482 | 1482 |
1483 pIcon->SetIconName(swIconName); | 1483 pIcon->SetIconName(swIconName); |
1484 pIcon->SetStream(pRetIcon->GetStream()); | 1484 pIcon->SetStream(pRetIcon->GetStream()); |
1485 vRet = pJS_Icon; | 1485 vRet = pJS_Icon; |
1486 return true; | 1486 return TRUE; |
1487 } | 1487 } |
1488 } | 1488 } |
1489 | 1489 |
1490 return false; | 1490 return FALSE; |
1491 } | 1491 } |
1492 | 1492 |
1493 bool Document::removeIcon(IFXJS_Context* cc, const CJS_Parameters& params, CJS_V
alue& vRet, CFX_WideString& sError) | 1493 FX_BOOL Document::removeIcon(IFXJS_Context* cc, const CJS_Parameters& params, CJ
S_Value& vRet, CFX_WideString& sError) |
1494 { | 1494 { |
1495 // Unsafe, no supported. | 1495 // Unsafe, no supported. |
1496 return true; | 1496 return TRUE; |
1497 } | 1497 } |
1498 | 1498 |
1499 bool Document::createDataObject(IFXJS_Context* cc, const CJS_Parameters& params,
CJS_Value& vRet, CFX_WideString& sError) | 1499 FX_BOOL Document::createDataObject(IFXJS_Context* cc, const CJS_Parameters& para
ms, CJS_Value& vRet, CFX_WideString& sError) |
1500 { | 1500 { |
1501 // Unsafe, not implemented. | 1501 // Unsafe, not implemented. |
1502 return true; | 1502 return TRUE; |
1503 } | 1503 } |
1504 | 1504 |
1505 bool Document::media(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sErro
r) | 1505 FX_BOOL Document::media(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sE
rror) |
1506 { | 1506 { |
1507 return true; | 1507 return TRUE; |
1508 } | 1508 } |
1509 | 1509 |
1510 bool Document::calculateNow(IFXJS_Context* cc, const CJS_Parameters& params, CJS
_Value& vRet, CFX_WideString& sError) | 1510 FX_BOOL Document::calculateNow(IFXJS_Context* cc, const CJS_Parameters& params,
CJS_Value& vRet, CFX_WideString& sError) |
1511 { | 1511 { |
1512 ASSERT(m_pDocument != NULL); | 1512 ASSERT(m_pDocument != NULL); |
1513 | 1513 |
1514 if (!(m_pDocument->GetPermissions(FPDFPERM_MODIFY) || | 1514 if (!(m_pDocument->GetPermissions(FPDFPERM_MODIFY) || |
1515 m_pDocument->GetPermissions(FPDFPERM_ANNOT_FORM) || | 1515 m_pDocument->GetPermissions(FPDFPERM_ANNOT_FORM) || |
1516 m_pDocument->GetPermissions(FPDFPERM_FILL_FORM))) return false; | 1516 m_pDocument->GetPermissions(FPDFPERM_FILL_FORM))) return FALSE; |
1517 | 1517 |
1518 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInterFor
m(); | 1518 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInterFor
m(); |
1519 ASSERT(pInterForm != NULL); | 1519 ASSERT(pInterForm != NULL); |
1520 pInterForm->OnCalculate(); | 1520 pInterForm->OnCalculate(); |
1521 return true; | 1521 return TRUE; |
1522 } | 1522 } |
1523 | 1523 |
1524 bool Document::Collab(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sErr
or) | 1524 FX_BOOL Document::Collab(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& s
Error) |
1525 { | 1525 { |
1526 return true; | 1526 return TRUE; |
1527 } | 1527 } |
1528 | 1528 |
1529 bool Document::getPageNthWord(IFXJS_Context* cc, const CJS_Parameters& params, C
JS_Value& vRet, CFX_WideString& sError) | 1529 FX_BOOL Document::getPageNthWord(IFXJS_Context* cc, const CJS_Parameters& params
, CJS_Value& vRet, CFX_WideString& sError) |
1530 { | 1530 { |
1531 ASSERT(m_pDocument != NULL); | 1531 ASSERT(m_pDocument != NULL); |
1532 | 1532 |
1533 if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) return false; | 1533 if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) return FALSE; |
1534 | 1534 |
1535 int nPageNo = params.GetSize() > 0 ? params[0].ToInt() : 0; | 1535 int nPageNo = params.GetSize() > 0 ? params[0].ToInt() : 0; |
1536 int nWordNo = params.GetSize() > 1 ? params[1].ToInt() : 0; | 1536 int nWordNo = params.GetSize() > 1 ? params[1].ToInt() : 0; |
1537 bool bStrip = params.GetSize() > 2 ? params[2].ToBool() : true; | 1537 bool bStrip = params.GetSize() > 2 ? params[2].ToBool() : true; |
1538 | 1538 |
1539 CPDF_Document* pDocument = m_pDocument->GetDocument(); | 1539 CPDF_Document* pDocument = m_pDocument->GetDocument(); |
1540 if (!pDocument) return false; | 1540 if (!pDocument) return FALSE; |
1541 | 1541 |
1542 CJS_Context* pContext = static_cast<CJS_Context*>(cc); | 1542 CJS_Context* pContext = static_cast<CJS_Context*>(cc); |
1543 if (nPageNo < 0 || nPageNo >= pDocument->GetPageCount()) | 1543 if (nPageNo < 0 || nPageNo >= pDocument->GetPageCount()) |
1544 { | 1544 { |
1545 sError = JSGetStringFromID(pContext, IDS_STRING_JSVALUEERROR); | 1545 sError = JSGetStringFromID(pContext, IDS_STRING_JSVALUEERROR); |
1546 return false; | 1546 return FALSE; |
1547 } | 1547 } |
1548 | 1548 |
1549 CPDF_Dictionary* pPageDict = pDocument->GetPage(nPageNo); | 1549 CPDF_Dictionary* pPageDict = pDocument->GetPage(nPageNo); |
1550 if (!pPageDict) return false; | 1550 if (!pPageDict) return FALSE; |
1551 | 1551 |
1552 CPDF_Page page; | 1552 CPDF_Page page; |
1553 page.Load(pDocument, pPageDict); | 1553 page.Load(pDocument, pPageDict); |
1554 page.StartParse(); | 1554 page.StartParse(); |
1555 page.ParseContent(); | 1555 page.ParseContent(); |
1556 | 1556 |
1557 FX_POSITION pos = page.GetFirstObjectPosition(); | 1557 FX_POSITION pos = page.GetFirstObjectPosition(); |
1558 | 1558 |
1559 int nWords = 0; | 1559 int nWords = 0; |
1560 | 1560 |
(...skipping 18 matching lines...) Expand all Loading... |
1579 } | 1579 } |
1580 } | 1580 } |
1581 | 1581 |
1582 if (bStrip) | 1582 if (bStrip) |
1583 { | 1583 { |
1584 swRet.TrimLeft(); | 1584 swRet.TrimLeft(); |
1585 swRet.TrimRight(); | 1585 swRet.TrimRight(); |
1586 } | 1586 } |
1587 | 1587 |
1588 vRet = swRet.c_str(); | 1588 vRet = swRet.c_str(); |
1589 return true; | 1589 return TRUE; |
1590 } | 1590 } |
1591 | 1591 |
1592 bool Document::getPageNthWordQuads(IFXJS_Context* cc, const CJS_Parameters& para
ms, CJS_Value& vRet, CFX_WideString& sError) | 1592 FX_BOOL Document::getPageNthWordQuads(IFXJS_Context* cc, const CJS_Parameters& p
arams, CJS_Value& vRet, CFX_WideString& sError) |
1593 { | 1593 { |
1594 ASSERT(m_pDocument != NULL); | 1594 ASSERT(m_pDocument != NULL); |
1595 | 1595 |
1596 if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) return false; | 1596 if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) return FALSE; |
1597 | 1597 |
1598 return false; | 1598 return FALSE; |
1599 } | 1599 } |
1600 | 1600 |
1601 bool Document::getPageNumWords(IFXJS_Context* cc, const CJS_Parameters& params,
CJS_Value& vRet, CFX_WideString& sError) | 1601 FX_BOOL Document::getPageNumWords(IFXJS_Context* cc, const CJS_Parameters& param
s, CJS_Value& vRet, CFX_WideString& sError) |
1602 { | 1602 { |
1603 ASSERT(m_pDocument != NULL); | 1603 ASSERT(m_pDocument != NULL); |
1604 | 1604 |
1605 if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) return false; | 1605 if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) return FALSE; |
1606 | 1606 |
1607 int nPageNo = params.GetSize() > 0 ? params[0].ToInt() : 0; | 1607 int nPageNo = params.GetSize() > 0 ? params[0].ToInt() : 0; |
1608 | 1608 |
1609 CPDF_Document* pDocument = m_pDocument->GetDocument(); | 1609 CPDF_Document* pDocument = m_pDocument->GetDocument(); |
1610 ASSERT(pDocument != NULL); | 1610 ASSERT(pDocument != NULL); |
1611 | 1611 |
1612 CJS_Context* pContext = static_cast<CJS_Context*>(cc); | 1612 CJS_Context* pContext = static_cast<CJS_Context*>(cc); |
1613 if (nPageNo < 0 || nPageNo >= pDocument->GetPageCount()) | 1613 if (nPageNo < 0 || nPageNo >= pDocument->GetPageCount()) |
1614 { | 1614 { |
1615 sError = JSGetStringFromID(pContext, IDS_STRING_JSVALUEERROR); | 1615 sError = JSGetStringFromID(pContext, IDS_STRING_JSVALUEERROR); |
1616 return false; | 1616 return FALSE; |
1617 } | 1617 } |
1618 | 1618 |
1619 CPDF_Dictionary* pPageDict = pDocument->GetPage(nPageNo); | 1619 CPDF_Dictionary* pPageDict = pDocument->GetPage(nPageNo); |
1620 if (!pPageDict) return false; | 1620 if (!pPageDict) return FALSE; |
1621 | 1621 |
1622 CPDF_Page page; | 1622 CPDF_Page page; |
1623 page.Load(pDocument, pPageDict); | 1623 page.Load(pDocument, pPageDict); |
1624 page.StartParse(); | 1624 page.StartParse(); |
1625 page.ParseContent(); | 1625 page.ParseContent(); |
1626 | 1626 |
1627 FX_POSITION pos = page.GetFirstObjectPosition(); | 1627 FX_POSITION pos = page.GetFirstObjectPosition(); |
1628 | 1628 |
1629 int nWords = 0; | 1629 int nWords = 0; |
1630 | 1630 |
1631 while (pos) | 1631 while (pos) |
1632 { | 1632 { |
1633 if (CPDF_PageObject* pPageObj = page.GetNextObject(pos)) | 1633 if (CPDF_PageObject* pPageObj = page.GetNextObject(pos)) |
1634 { | 1634 { |
1635 if (pPageObj->m_Type == PDFPAGE_TEXT) | 1635 if (pPageObj->m_Type == PDFPAGE_TEXT) |
1636 { | 1636 { |
1637 CPDF_TextObject* pTextObj = (CPDF_TextObject*)pPageObj; | 1637 CPDF_TextObject* pTextObj = (CPDF_TextObject*)pPageObj; |
1638 nWords += CountWords(pTextObj); | 1638 nWords += CountWords(pTextObj); |
1639 } | 1639 } |
1640 } | 1640 } |
1641 } | 1641 } |
1642 | 1642 |
1643 vRet = nWords; | 1643 vRet = nWords; |
1644 | 1644 |
1645 return true; | 1645 return TRUE; |
1646 } | 1646 } |
1647 | 1647 |
1648 bool Document::getPrintParams(IFXJS_Context* cc, const CJS_Parameters& params, C
JS_Value& vRet, CFX_WideString& sError) | 1648 FX_BOOL Document::getPrintParams(IFXJS_Context* cc, const CJS_Parameters& params
, CJS_Value& vRet, CFX_WideString& sError) |
1649 { | 1649 { |
1650 CJS_Context* pContext = (CJS_Context*)cc; | 1650 CJS_Context* pContext = (CJS_Context*)cc; |
1651 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 1651 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
1652 JSFXObject pRetObj = JS_NewFxDynamicObj(*pRuntime, pContext, JS_GetObjDefnID
(*pRuntime, L"PrintParamsObj")); | 1652 JSFXObject pRetObj = JS_NewFxDynamicObj(*pRuntime, pContext, JS_GetObjDefnID
(*pRuntime, L"PrintParamsObj")); |
1653 | 1653 |
1654 // Not implemented yet. | 1654 // Not implemented yet. |
1655 | 1655 |
1656 vRet = pRetObj; | 1656 vRet = pRetObj; |
1657 return true; | 1657 return TRUE; |
1658 } | 1658 } |
1659 | 1659 |
1660 #define ISLATINWORD(u) (u != 0x20 && u <= 0x28FF) | 1660 #define ISLATINWORD(u) (u != 0x20 && u <= 0x28FF) |
1661 | 1661 |
1662 int Document::CountWords(CPDF_TextObject* pTextObj) | 1662 int Document::CountWords(CPDF_TextObject* pTextObj) |
1663 { | 1663 { |
1664 if (!pTextObj) return 0; | 1664 if (!pTextObj) return 0; |
1665 | 1665 |
1666 int nWords = 0; | 1666 int nWords = 0; |
1667 | 1667 |
1668 CPDF_Font* pFont = pTextObj->GetFont(); | 1668 CPDF_Font* pFont = pTextObj->GetFont(); |
1669 if (!pFont) return 0; | 1669 if (!pFont) return 0; |
1670 | 1670 |
1671 bool bIsLatin = false; | 1671 FX_BOOL bIsLatin = FALSE; |
1672 | 1672 |
1673 for (int i=0, sz=pTextObj->CountChars(); i<sz; i++) | 1673 for (int i=0, sz=pTextObj->CountChars(); i<sz; i++) |
1674 { | 1674 { |
1675 FX_DWORD charcode = -1; | 1675 FX_DWORD charcode = -1; |
1676 FX_FLOAT kerning; | 1676 FX_FLOAT kerning; |
1677 | 1677 |
1678 pTextObj->GetCharInfo(i, charcode, kerning); | 1678 pTextObj->GetCharInfo(i, charcode, kerning); |
1679 CFX_WideString swUnicode = pFont->UnicodeFromCharCode(charcode); | 1679 CFX_WideString swUnicode = pFont->UnicodeFromCharCode(charcode); |
1680 | 1680 |
1681 FX_WORD unicode = 0; | 1681 FX_WORD unicode = 0; |
(...skipping 14 matching lines...) Expand all Loading... |
1696 CFX_WideString Document::GetObjWordStr(CPDF_TextObject* pTextObj, int nWordIndex
) | 1696 CFX_WideString Document::GetObjWordStr(CPDF_TextObject* pTextObj, int nWordIndex
) |
1697 { | 1697 { |
1698 ASSERT(pTextObj != NULL); | 1698 ASSERT(pTextObj != NULL); |
1699 | 1699 |
1700 CFX_WideString swRet; | 1700 CFX_WideString swRet; |
1701 | 1701 |
1702 CPDF_Font* pFont = pTextObj->GetFont(); | 1702 CPDF_Font* pFont = pTextObj->GetFont(); |
1703 if (!pFont) return L""; | 1703 if (!pFont) return L""; |
1704 | 1704 |
1705 int nWords = 0; | 1705 int nWords = 0; |
1706 bool bIsLatin = false; | 1706 FX_BOOL bIsLatin = FALSE; |
1707 | 1707 |
1708 for (int i=0, sz=pTextObj->CountChars(); i<sz; i++) | 1708 for (int i=0, sz=pTextObj->CountChars(); i<sz; i++) |
1709 { | 1709 { |
1710 FX_DWORD charcode = -1; | 1710 FX_DWORD charcode = -1; |
1711 FX_FLOAT kerning; | 1711 FX_FLOAT kerning; |
1712 | 1712 |
1713 pTextObj->GetCharInfo(i, charcode, kerning); | 1713 pTextObj->GetCharInfo(i, charcode, kerning); |
1714 CFX_WideString swUnicode = pFont->UnicodeFromCharCode(charcode); | 1714 CFX_WideString swUnicode = pFont->UnicodeFromCharCode(charcode); |
1715 | 1715 |
1716 FX_WORD unicode = 0; | 1716 FX_WORD unicode = 0; |
(...skipping 10 matching lines...) Expand all Loading... |
1727 nWords++; | 1727 nWords++; |
1728 } | 1728 } |
1729 | 1729 |
1730 if (nWords-1 == nWordIndex) | 1730 if (nWords-1 == nWordIndex) |
1731 swRet += unicode; | 1731 swRet += unicode; |
1732 } | 1732 } |
1733 | 1733 |
1734 return swRet; | 1734 return swRet; |
1735 } | 1735 } |
1736 | 1736 |
1737 bool Document::zoom(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError
) | 1737 FX_BOOL Document::zoom(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sEr
ror) |
1738 { | 1738 { |
1739 | 1739 |
1740 return true; | 1740 return TRUE; |
1741 } | 1741 } |
1742 | 1742 |
1743 /** | 1743 /** |
1744 (none, NoVary) | 1744 (none, NoVary) |
1745 (fitP, FitPage) | 1745 (fitP, FitPage) |
1746 (fitW, FitWidth) | 1746 (fitW, FitWidth) |
1747 (fitH, FitHeight) | 1747 (fitH, FitHeight) |
1748 (fitV, FitVisibleWidth) | 1748 (fitV, FitVisibleWidth) |
1749 (pref, Preferred) | 1749 (pref, Preferred) |
1750 (refW, ReflowWidth) | 1750 (refW, ReflowWidth) |
1751 */ | 1751 */ |
1752 | 1752 |
1753 bool Document::zoomType(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sE
rror) | 1753 FX_BOOL Document::zoomType(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString&
sError) |
1754 { | 1754 { |
1755 return true; | 1755 return TRUE; |
1756 } | 1756 } |
1757 | 1757 |
1758 bool Document::deletePages(IFXJS_Context* cc, const CJS_Parameters& params, CJS_
Value& vRet, CFX_WideString& sError) | 1758 FX_BOOL Document::deletePages(IFXJS_Context* cc, const CJS_Parameters& params, C
JS_Value& vRet, CFX_WideString& sError) |
1759 { | 1759 { |
1760 // Unsafe, no supported. | 1760 // Unsafe, no supported. |
1761 return true; | 1761 return TRUE; |
1762 } | 1762 } |
1763 | 1763 |
1764 bool Document::extractPages(IFXJS_Context* cc, const CJS_Parameters& params, CJS
_Value& vRet, CFX_WideString& sError) | 1764 FX_BOOL Document::extractPages(IFXJS_Context* cc, const CJS_Parameters& params,
CJS_Value& vRet, CFX_WideString& sError) |
1765 { | 1765 { |
1766 // Unsafe, not supported. | 1766 // Unsafe, not supported. |
1767 return true; | 1767 return TRUE; |
1768 } | 1768 } |
1769 | 1769 |
1770 bool Document::insertPages(IFXJS_Context* cc, const CJS_Parameters& params, CJS_
Value& vRet, CFX_WideString& sError) | 1770 FX_BOOL Document::insertPages(IFXJS_Context* cc, const CJS_Parameters& params, C
JS_Value& vRet, CFX_WideString& sError) |
1771 { | 1771 { |
1772 // Unsafe, not supported. | 1772 // Unsafe, not supported. |
1773 return true; | 1773 return TRUE; |
1774 } | 1774 } |
1775 | 1775 |
1776 bool Document::replacePages(IFXJS_Context* cc, const CJS_Parameters& params, CJS
_Value& vRet, CFX_WideString& sError) | 1776 FX_BOOL Document::replacePages(IFXJS_Context* cc, const CJS_Parameters& params,
CJS_Value& vRet, CFX_WideString& sError) |
1777 { | 1777 { |
1778 // Unsafe, not supported. | 1778 // Unsafe, not supported. |
1779 return true; | 1779 return TRUE; |
1780 } | 1780 } |
1781 | 1781 |
1782 bool Document::getURL(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value
& vRet, CFX_WideString& sError) | 1782 FX_BOOL Document::getURL(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Va
lue& vRet, CFX_WideString& sError) |
1783 { | 1783 { |
1784 // Unsafe, not supported. | 1784 // Unsafe, not supported. |
1785 return true; | 1785 return TRUE; |
1786 } | 1786 } |
1787 | 1787 |
1788 void Document::AddDelayData(CJS_DelayData* pData) | 1788 void Document::AddDelayData(CJS_DelayData* pData) |
1789 { | 1789 { |
1790 m_DelayData.Add(pData); | 1790 m_DelayData.Add(pData); |
1791 } | 1791 } |
1792 | 1792 |
1793 void Document::DoFieldDelay(const CFX_WideString& sFieldName, int nControlIndex) | 1793 void Document::DoFieldDelay(const CFX_WideString& sFieldName, int nControlIndex) |
1794 { | 1794 { |
1795 CFX_DWordArray DelArray; | 1795 CFX_DWordArray DelArray; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1834 for (int j=DelArray.GetSize()-1; j>=0; j--) | 1834 for (int j=DelArray.GetSize()-1; j>=0; j--) |
1835 { | 1835 { |
1836 m_DelayData.RemoveAt(DelArray[j]); | 1836 m_DelayData.RemoveAt(DelArray[j]); |
1837 } | 1837 } |
1838 } | 1838 } |
1839 | 1839 |
1840 CJS_Document* Document::GetCJSDoc() const | 1840 CJS_Document* Document::GetCJSDoc() const |
1841 { | 1841 { |
1842 return static_cast<CJS_Document*>(m_pJSObject); | 1842 return static_cast<CJS_Document*>(m_pJSObject); |
1843 } | 1843 } |
OLD | NEW |