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

Side by Side Diff: fpdfsdk/src/javascript/Document.cpp

Issue 1512763013: Get rid of most instance of 'foo != NULL' (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: nits Created 5 years 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 | « fpdfsdk/src/fxedit/fxet_module.cpp ('k') | fpdfsdk/src/javascript/Field.cpp » ('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 "Document.h" 7 #include "Document.h"
8 8
9 #include "Field.h" 9 #include "Field.h"
10 #include "Icon.h" 10 #include "Icon.h"
11 #include "JS_Context.h" 11 #include "JS_Context.h"
12 #include "JS_Define.h" 12 #include "JS_Define.h"
13 #include "JS_EventHandler.h" 13 #include "JS_EventHandler.h"
14 #include "JS_Object.h" 14 #include "JS_Object.h"
15 #include "JS_Runtime.h" 15 #include "JS_Runtime.h"
16 #include "JS_Value.h" 16 #include "JS_Value.h"
17 #include "app.h" 17 #include "app.h"
18 #include "fpdfsdk/include/fsdk_mgr.h" // For CPDFDoc_Environment. 18 #include "fpdfsdk/include/fsdk_mgr.h" // For CPDFDoc_Environment.
19 #include "fpdfsdk/include/javascript/IJavaScript.h" 19 #include "fpdfsdk/include/javascript/IJavaScript.h"
20 #include "resource.h" 20 #include "resource.h"
21 #include "third_party/base/numerics/safe_math.h" 21 #include "third_party/base/numerics/safe_math.h"
22 22
23 static v8::Isolate* GetIsolate(IJS_Context* cc) { 23 static v8::Isolate* GetIsolate(IJS_Context* cc) {
24 CJS_Context* pContext = (CJS_Context*)cc; 24 CJS_Context* pContext = (CJS_Context*)cc;
25 ASSERT(pContext != NULL);
26
27 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); 25 CJS_Runtime* pRuntime = pContext->GetJSRuntime();
28 ASSERT(pRuntime != NULL);
29
30 return pRuntime->GetIsolate(); 26 return pRuntime->GetIsolate();
31 } 27 }
32 28
33 BEGIN_JS_STATIC_CONST(CJS_PrintParamsObj) 29 BEGIN_JS_STATIC_CONST(CJS_PrintParamsObj)
34 END_JS_STATIC_CONST() 30 END_JS_STATIC_CONST()
35 31
36 BEGIN_JS_STATIC_PROP(CJS_PrintParamsObj) 32 BEGIN_JS_STATIC_PROP(CJS_PrintParamsObj)
37 END_JS_STATIC_PROP() 33 END_JS_STATIC_PROP()
38 34
39 BEGIN_JS_STATIC_METHOD(CJS_PrintParamsObj) 35 BEGIN_JS_STATIC_METHOD(CJS_PrintParamsObj)
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 } 183 }
188 CPDFSDK_InterForm* pInterForm = m_pDocument->GetInterForm(); 184 CPDFSDK_InterForm* pInterForm = m_pDocument->GetInterForm();
189 CPDF_InterForm* pPDFForm = pInterForm->GetInterForm(); 185 CPDF_InterForm* pPDFForm = pInterForm->GetInterForm();
190 vp << (int)pPDFForm->CountFields(); 186 vp << (int)pPDFForm->CountFields();
191 return TRUE; 187 return TRUE;
192 } 188 }
193 189
194 FX_BOOL Document::dirty(IJS_Context* cc, 190 FX_BOOL Document::dirty(IJS_Context* cc,
195 CJS_PropValue& vp, 191 CJS_PropValue& vp,
196 CFX_WideString& sError) { 192 CFX_WideString& sError) {
197 ASSERT(m_pDocument != NULL);
198
199 if (vp.IsGetting()) { 193 if (vp.IsGetting()) {
200 if (m_pDocument->GetChangeMark()) 194 if (m_pDocument->GetChangeMark())
201 vp << true; 195 vp << true;
202 else 196 else
203 vp << false; 197 vp << false;
204 } else { 198 } else {
205 bool bChanged = false; 199 bool bChanged = false;
206 200
207 vp >> bChanged; 201 vp >> bChanged;
208 202
209 if (bChanged) 203 if (bChanged)
210 m_pDocument->SetChangeMark(); 204 m_pDocument->SetChangeMark();
211 else 205 else
212 m_pDocument->ClearChangeMark(); 206 m_pDocument->ClearChangeMark();
213 } 207 }
214 208
215 return TRUE; 209 return TRUE;
216 } 210 }
217 211
218 FX_BOOL Document::ADBE(IJS_Context* cc, 212 FX_BOOL Document::ADBE(IJS_Context* cc,
219 CJS_PropValue& vp, 213 CJS_PropValue& vp,
220 CFX_WideString& sError) { 214 CFX_WideString& sError) {
221 ASSERT(m_pDocument != NULL);
222
223 if (vp.IsGetting()) { 215 if (vp.IsGetting()) {
224 vp.SetNull(); 216 vp.SetNull();
225 } else { 217 } else {
226 } 218 }
227 219
228 return TRUE; 220 return TRUE;
229 } 221 }
230 222
231 FX_BOOL Document::pageNum(IJS_Context* cc, 223 FX_BOOL Document::pageNum(IJS_Context* cc,
232 CJS_PropValue& vp, 224 CJS_PropValue& vp,
233 CFX_WideString& sError) { 225 CFX_WideString& sError) {
234 ASSERT(m_pDocument != NULL);
235
236 if (vp.IsGetting()) { 226 if (vp.IsGetting()) {
237 if (CPDFSDK_PageView* pPageView = m_pDocument->GetCurrentView()) { 227 if (CPDFSDK_PageView* pPageView = m_pDocument->GetCurrentView()) {
238 vp << pPageView->GetPageIndex(); 228 vp << pPageView->GetPageIndex();
239 } 229 }
240 } else { 230 } else {
241 int iPageCount = m_pDocument->GetPageCount(); 231 int iPageCount = m_pDocument->GetPageCount();
242 int iPageNum = 0; 232 int iPageNum = 0;
243 vp >> iPageNum; 233 vp >> iPageNum;
244 234
245 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); 235 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv();
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 // all recipients. 377 // all recipients.
388 // comment: need reader supports 378 // comment: need reader supports
389 // note: 379 // note:
390 // int CPDFSDK_Document::mailForm(FX_BOOL bUI,String cto,string ccc,string 380 // int CPDFSDK_Document::mailForm(FX_BOOL bUI,String cto,string ccc,string
391 // cbcc,string cSubject,string cms); 381 // cbcc,string cSubject,string cms);
392 382
393 FX_BOOL Document::mailForm(IJS_Context* cc, 383 FX_BOOL Document::mailForm(IJS_Context* cc,
394 const std::vector<CJS_Value>& params, 384 const std::vector<CJS_Value>& params,
395 CJS_Value& vRet, 385 CJS_Value& vRet,
396 CFX_WideString& sError) { 386 CFX_WideString& sError) {
397 ASSERT(m_pDocument != NULL);
398
399 if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) 387 if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS))
400 return FALSE; 388 return FALSE;
401 389
402 int iLength = params.size(); 390 int iLength = params.size();
403 391
404 FX_BOOL bUI = iLength > 0 ? params[0].ToBool() : TRUE; 392 FX_BOOL bUI = iLength > 0 ? params[0].ToBool() : TRUE;
405 CFX_WideString cTo = iLength > 1 ? params[1].ToCFXWideString() : L""; 393 CFX_WideString cTo = iLength > 1 ? params[1].ToCFXWideString() : L"";
406 CFX_WideString cCc = iLength > 2 ? params[2].ToCFXWideString() : L""; 394 CFX_WideString cCc = iLength > 2 ? params[2].ToCFXWideString() : L"";
407 CFX_WideString cBcc = iLength > 3 ? params[3].ToCFXWideString() : L""; 395 CFX_WideString cBcc = iLength > 3 ? params[3].ToCFXWideString() : L"";
408 CFX_WideString cSubject = iLength > 4 ? params[4].ToCFXWideString() : L""; 396 CFX_WideString cSubject = iLength > 4 ? params[4].ToCFXWideString() : L"";
409 CFX_WideString cMsg = iLength > 5 ? params[5].ToCFXWideString() : L""; 397 CFX_WideString cMsg = iLength > 5 ? params[5].ToCFXWideString() : L"";
410 398
411 CPDFSDK_InterForm* pInterForm = 399 CPDFSDK_InterForm* pInterForm =
412 (CPDFSDK_InterForm*)m_pDocument->GetInterForm(); 400 (CPDFSDK_InterForm*)m_pDocument->GetInterForm();
413 ASSERT(pInterForm != NULL);
414
415 CFX_ByteTextBuf textBuf; 401 CFX_ByteTextBuf textBuf;
416 if (!pInterForm->ExportFormToFDFTextBuf(textBuf)) 402 if (!pInterForm->ExportFormToFDFTextBuf(textBuf))
417 return FALSE; 403 return FALSE;
418 404
419 CJS_Context* pContext = (CJS_Context*)cc; 405 CJS_Context* pContext = (CJS_Context*)cc;
420 ASSERT(pContext != NULL);
421 CPDFDoc_Environment* pEnv = pContext->GetReaderApp(); 406 CPDFDoc_Environment* pEnv = pContext->GetReaderApp();
422 ASSERT(pEnv != NULL);
423 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); 407 CJS_Runtime* pRuntime = pContext->GetJSRuntime();
424 ASSERT(pRuntime != NULL);
425 408
426 pRuntime->BeginBlock(); 409 pRuntime->BeginBlock();
427 pEnv->JS_docmailForm(textBuf.GetBuffer(), textBuf.GetLength(), bUI, 410 pEnv->JS_docmailForm(textBuf.GetBuffer(), textBuf.GetLength(), bUI,
428 cTo.c_str(), cSubject.c_str(), cCc.c_str(), cBcc.c_str(), 411 cTo.c_str(), cSubject.c_str(), cCc.c_str(), cBcc.c_str(),
429 cMsg.c_str()); 412 cMsg.c_str());
430 pRuntime->EndBlock(); 413 pRuntime->EndBlock();
431 return TRUE; 414 return TRUE;
432 } 415 }
433 416
434 FX_BOOL Document::print(IJS_Context* cc, 417 FX_BOOL Document::print(IJS_Context* cc,
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 if (nlength >= 5) 461 if (nlength >= 5)
479 bShrinkToFit = params[4].ToBool(); 462 bShrinkToFit = params[4].ToBool();
480 if (nlength >= 6) 463 if (nlength >= 6)
481 bPrintAsImage = params[5].ToBool(); 464 bPrintAsImage = params[5].ToBool();
482 if (nlength >= 7) 465 if (nlength >= 7)
483 bReverse = params[6].ToBool(); 466 bReverse = params[6].ToBool();
484 if (nlength >= 8) 467 if (nlength >= 8)
485 bAnnotations = params[7].ToBool(); 468 bAnnotations = params[7].ToBool();
486 } 469 }
487 470
488 ASSERT(m_pDocument != NULL);
489
490 if (CPDFDoc_Environment* pEnv = m_pDocument->GetEnv()) { 471 if (CPDFDoc_Environment* pEnv = m_pDocument->GetEnv()) {
491 pEnv->JS_docprint(bUI, nStart, nEnd, bSilent, bShrinkToFit, bPrintAsImage, 472 pEnv->JS_docprint(bUI, nStart, nEnd, bSilent, bShrinkToFit, bPrintAsImage,
492 bReverse, bAnnotations); 473 bReverse, bAnnotations);
493 return TRUE; 474 return TRUE;
494 } 475 }
495 return FALSE; 476 return FALSE;
496 } 477 }
497 478
498 // removes the specified field from the document. 479 // removes the specified field from the document.
499 // comment: 480 // comment:
500 // note: if the filed name is not retional, adobe is dumb for it. 481 // note: if the filed name is not retional, adobe is dumb for it.
501 482
502 FX_BOOL Document::removeField(IJS_Context* cc, 483 FX_BOOL Document::removeField(IJS_Context* cc,
503 const std::vector<CJS_Value>& params, 484 const std::vector<CJS_Value>& params,
504 CJS_Value& vRet, 485 CJS_Value& vRet,
505 CFX_WideString& sError) { 486 CFX_WideString& sError) {
506 ASSERT(m_pDocument != NULL);
507
508 if (!(m_pDocument->GetPermissions(FPDFPERM_MODIFY) || 487 if (!(m_pDocument->GetPermissions(FPDFPERM_MODIFY) ||
509 m_pDocument->GetPermissions(FPDFPERM_ANNOT_FORM))) 488 m_pDocument->GetPermissions(FPDFPERM_ANNOT_FORM)))
510 return FALSE; 489 return FALSE;
511 490
512 CJS_Context* pContext = (CJS_Context*)cc; 491 CJS_Context* pContext = (CJS_Context*)cc;
513 if (params.size() != 1) { 492 if (params.size() != 1) {
514 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 493 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
515 return FALSE; 494 return FALSE;
516 } 495 }
517 496
518 CFX_WideString sFieldName = params[0].ToCFXWideString(); 497 CFX_WideString sFieldName = params[0].ToCFXWideString();
519 CPDFSDK_InterForm* pInterForm = 498 CPDFSDK_InterForm* pInterForm =
520 (CPDFSDK_InterForm*)m_pDocument->GetInterForm(); 499 (CPDFSDK_InterForm*)m_pDocument->GetInterForm();
521 ASSERT(pInterForm != NULL);
522 500
523 std::vector<CPDFSDK_Widget*> widgets; 501 std::vector<CPDFSDK_Widget*> widgets;
524 pInterForm->GetWidgets(sFieldName, &widgets); 502 pInterForm->GetWidgets(sFieldName, &widgets);
525 503
526 if (widgets.empty()) 504 if (widgets.empty())
527 return TRUE; 505 return TRUE;
528 506
529 for (CPDFSDK_Widget* pWidget : widgets) { 507 for (CPDFSDK_Widget* pWidget : widgets) {
530 CPDF_Rect rcAnnot = pWidget->GetRect(); 508 CPDF_Rect rcAnnot = pWidget->GetRect();
531 --rcAnnot.left; 509 --rcAnnot.left;
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after
1093 vp << m_cwBaseURL; 1071 vp << m_cwBaseURL;
1094 } else { 1072 } else {
1095 vp >> m_cwBaseURL; 1073 vp >> m_cwBaseURL;
1096 } 1074 }
1097 return TRUE; 1075 return TRUE;
1098 } 1076 }
1099 1077
1100 FX_BOOL Document::calculate(IJS_Context* cc, 1078 FX_BOOL Document::calculate(IJS_Context* cc,
1101 CJS_PropValue& vp, 1079 CJS_PropValue& vp,
1102 CFX_WideString& sError) { 1080 CFX_WideString& sError) {
1103 ASSERT(m_pDocument != NULL);
1104
1105 CPDFSDK_InterForm* pInterForm = 1081 CPDFSDK_InterForm* pInterForm =
1106 (CPDFSDK_InterForm*)m_pDocument->GetInterForm(); 1082 (CPDFSDK_InterForm*)m_pDocument->GetInterForm();
1107 ASSERT(pInterForm != NULL);
1108 1083
1109 if (vp.IsGetting()) { 1084 if (vp.IsGetting()) {
1110 if (pInterForm->IsCalculateEnabled()) 1085 if (pInterForm->IsCalculateEnabled())
1111 vp << true; 1086 vp << true;
1112 else 1087 else
1113 vp << false; 1088 vp << false;
1114 } else { 1089 } else {
1115 bool bCalculate; 1090 bool bCalculate;
1116 vp >> bCalculate; 1091 vp >> bCalculate;
1117 1092
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
1213 const std::vector<CJS_Value>& params, 1188 const std::vector<CJS_Value>& params,
1214 CJS_Value& vRet, 1189 CJS_Value& vRet,
1215 CFX_WideString& sError) { 1190 CFX_WideString& sError) {
1216 return TRUE; 1191 return TRUE;
1217 } 1192 }
1218 1193
1219 FX_BOOL Document::closeDoc(IJS_Context* cc, 1194 FX_BOOL Document::closeDoc(IJS_Context* cc,
1220 const std::vector<CJS_Value>& params, 1195 const std::vector<CJS_Value>& params,
1221 CJS_Value& vRet, 1196 CJS_Value& vRet,
1222 CFX_WideString& sError) { 1197 CFX_WideString& sError) {
1223 ASSERT(m_pDocument != NULL);
1224 return TRUE; 1198 return TRUE;
1225 } 1199 }
1226 1200
1227 FX_BOOL Document::getPageBox(IJS_Context* cc, 1201 FX_BOOL Document::getPageBox(IJS_Context* cc,
1228 const std::vector<CJS_Value>& params, 1202 const std::vector<CJS_Value>& params,
1229 CJS_Value& vRet, 1203 CJS_Value& vRet,
1230 CFX_WideString& sError) { 1204 CFX_WideString& sError) {
1231 return TRUE; 1205 return TRUE;
1232 } 1206 }
1233 1207
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
1472 FX_BOOL Document::media(IJS_Context* cc, 1446 FX_BOOL Document::media(IJS_Context* cc,
1473 CJS_PropValue& vp, 1447 CJS_PropValue& vp,
1474 CFX_WideString& sError) { 1448 CFX_WideString& sError) {
1475 return TRUE; 1449 return TRUE;
1476 } 1450 }
1477 1451
1478 FX_BOOL Document::calculateNow(IJS_Context* cc, 1452 FX_BOOL Document::calculateNow(IJS_Context* cc,
1479 const std::vector<CJS_Value>& params, 1453 const std::vector<CJS_Value>& params,
1480 CJS_Value& vRet, 1454 CJS_Value& vRet,
1481 CFX_WideString& sError) { 1455 CFX_WideString& sError) {
1482 ASSERT(m_pDocument != NULL);
1483
1484 if (!(m_pDocument->GetPermissions(FPDFPERM_MODIFY) || 1456 if (!(m_pDocument->GetPermissions(FPDFPERM_MODIFY) ||
1485 m_pDocument->GetPermissions(FPDFPERM_ANNOT_FORM) || 1457 m_pDocument->GetPermissions(FPDFPERM_ANNOT_FORM) ||
1486 m_pDocument->GetPermissions(FPDFPERM_FILL_FORM))) 1458 m_pDocument->GetPermissions(FPDFPERM_FILL_FORM)))
1487 return FALSE; 1459 return FALSE;
1488 1460
1489 CPDFSDK_InterForm* pInterForm = 1461 CPDFSDK_InterForm* pInterForm =
1490 (CPDFSDK_InterForm*)m_pDocument->GetInterForm(); 1462 (CPDFSDK_InterForm*)m_pDocument->GetInterForm();
1491 ASSERT(pInterForm != NULL);
1492 pInterForm->OnCalculate(); 1463 pInterForm->OnCalculate();
1493 return TRUE; 1464 return TRUE;
1494 } 1465 }
1495 1466
1496 FX_BOOL Document::Collab(IJS_Context* cc, 1467 FX_BOOL Document::Collab(IJS_Context* cc,
1497 CJS_PropValue& vp, 1468 CJS_PropValue& vp,
1498 CFX_WideString& sError) { 1469 CFX_WideString& sError) {
1499 return TRUE; 1470 return TRUE;
1500 } 1471 }
1501 1472
1502 FX_BOOL Document::getPageNthWord(IJS_Context* cc, 1473 FX_BOOL Document::getPageNthWord(IJS_Context* cc,
1503 const std::vector<CJS_Value>& params, 1474 const std::vector<CJS_Value>& params,
1504 CJS_Value& vRet, 1475 CJS_Value& vRet,
1505 CFX_WideString& sError) { 1476 CFX_WideString& sError) {
1506 ASSERT(m_pDocument != NULL);
1507
1508 if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) 1477 if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS))
1509 return FALSE; 1478 return FALSE;
1510 1479
1511 int nPageNo = params.size() > 0 ? params[0].ToInt() : 0; 1480 int nPageNo = params.size() > 0 ? params[0].ToInt() : 0;
1512 int nWordNo = params.size() > 1 ? params[1].ToInt() : 0; 1481 int nWordNo = params.size() > 1 ? params[1].ToInt() : 0;
1513 bool bStrip = params.size() > 2 ? params[2].ToBool() : true; 1482 bool bStrip = params.size() > 2 ? params[2].ToBool() : true;
1514 1483
1515 CPDF_Document* pDocument = m_pDocument->GetPDFDocument(); 1484 CPDF_Document* pDocument = m_pDocument->GetPDFDocument();
1516 if (!pDocument) 1485 if (!pDocument)
1517 return FALSE; 1486 return FALSE;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1558 } 1527 }
1559 1528
1560 vRet = swRet.c_str(); 1529 vRet = swRet.c_str();
1561 return TRUE; 1530 return TRUE;
1562 } 1531 }
1563 1532
1564 FX_BOOL Document::getPageNthWordQuads(IJS_Context* cc, 1533 FX_BOOL Document::getPageNthWordQuads(IJS_Context* cc,
1565 const std::vector<CJS_Value>& params, 1534 const std::vector<CJS_Value>& params,
1566 CJS_Value& vRet, 1535 CJS_Value& vRet,
1567 CFX_WideString& sError) { 1536 CFX_WideString& sError) {
1568 ASSERT(m_pDocument != NULL);
1569
1570 if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) 1537 if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS))
1571 return FALSE; 1538 return FALSE;
1572 1539
1573 return FALSE; 1540 return FALSE;
1574 } 1541 }
1575 1542
1576 FX_BOOL Document::getPageNumWords(IJS_Context* cc, 1543 FX_BOOL Document::getPageNumWords(IJS_Context* cc,
1577 const std::vector<CJS_Value>& params, 1544 const std::vector<CJS_Value>& params,
1578 CJS_Value& vRet, 1545 CJS_Value& vRet,
1579 CFX_WideString& sError) { 1546 CFX_WideString& sError) {
1580 ASSERT(m_pDocument != NULL);
1581
1582 if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) 1547 if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS))
1583 return FALSE; 1548 return FALSE;
1584 1549
1585 int nPageNo = params.size() > 0 ? params[0].ToInt() : 0; 1550 int nPageNo = params.size() > 0 ? params[0].ToInt() : 0;
1586 1551
1587 CPDF_Document* pDocument = m_pDocument->GetPDFDocument(); 1552 CPDF_Document* pDocument = m_pDocument->GetPDFDocument();
1588 ASSERT(pDocument != NULL);
1589
1590 CJS_Context* pContext = static_cast<CJS_Context*>(cc); 1553 CJS_Context* pContext = static_cast<CJS_Context*>(cc);
1591 if (nPageNo < 0 || nPageNo >= pDocument->GetPageCount()) { 1554 if (nPageNo < 0 || nPageNo >= pDocument->GetPageCount()) {
1592 sError = JSGetStringFromID(pContext, IDS_STRING_JSVALUEERROR); 1555 sError = JSGetStringFromID(pContext, IDS_STRING_JSVALUEERROR);
1593 return FALSE; 1556 return FALSE;
1594 } 1557 }
1595 1558
1596 CPDF_Dictionary* pPageDict = pDocument->GetPage(nPageNo); 1559 CPDF_Dictionary* pPageDict = pDocument->GetPage(nPageNo);
1597 if (!pPageDict) 1560 if (!pPageDict)
1598 return FALSE; 1561 return FALSE;
1599 1562
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1666 bIsLatin = ISLATINWORD(unicode); 1629 bIsLatin = ISLATINWORD(unicode);
1667 if (unicode != 0x20) 1630 if (unicode != 0x20)
1668 nWords++; 1631 nWords++;
1669 } 1632 }
1670 1633
1671 return nWords; 1634 return nWords;
1672 } 1635 }
1673 1636
1674 CFX_WideString Document::GetObjWordStr(CPDF_TextObject* pTextObj, 1637 CFX_WideString Document::GetObjWordStr(CPDF_TextObject* pTextObj,
1675 int nWordIndex) { 1638 int nWordIndex) {
1676 ASSERT(pTextObj != NULL);
1677
1678 CFX_WideString swRet; 1639 CFX_WideString swRet;
1679 1640
1680 CPDF_Font* pFont = pTextObj->GetFont(); 1641 CPDF_Font* pFont = pTextObj->GetFont();
1681 if (!pFont) 1642 if (!pFont)
1682 return L""; 1643 return L"";
1683 1644
1684 int nWords = 0; 1645 int nWords = 0;
1685 FX_BOOL bIsLatin = FALSE; 1646 FX_BOOL bIsLatin = FALSE;
1686 1647
1687 for (int i = 0, sz = pTextObj->CountChars(); i < sz; i++) { 1648 for (int i = 0, sz = pTextObj->CountChars(); i < sz; i++) {
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
1812 CFX_DWordArray DelArray; 1773 CFX_DWordArray DelArray;
1813 1774
1814 for (int j = DelArray.GetSize() - 1; j >= 0; j--) { 1775 for (int j = DelArray.GetSize() - 1; j >= 0; j--) {
1815 m_DelayData.RemoveAt(DelArray[j]); 1776 m_DelayData.RemoveAt(DelArray[j]);
1816 } 1777 }
1817 } 1778 }
1818 1779
1819 CJS_Document* Document::GetCJSDoc() const { 1780 CJS_Document* Document::GetCJSDoc() const {
1820 return static_cast<CJS_Document*>(m_pJSObject); 1781 return static_cast<CJS_Document*>(m_pJSObject);
1821 } 1782 }
OLDNEW
« no previous file with comments | « fpdfsdk/src/fxedit/fxet_module.cpp ('k') | fpdfsdk/src/javascript/Field.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698