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

Side by Side Diff: xfa/fxfa/parser/xfa_script_layoutpseudomodel.cpp

Issue 2029043002: Change ThrowScriptErrorMessage() to ThrowException(). (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@value_toobject_cleanup
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
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 "xfa/fxfa/parser/xfa_script_layoutpseudomodel.h" 7 #include "xfa/fxfa/parser/xfa_script_layoutpseudomodel.h"
8 8
9 #include <set> 9 #include <set>
10 10
(...skipping 19 matching lines...) Expand all
30 CScript_LayoutPseudoModel::~CScript_LayoutPseudoModel() {} 30 CScript_LayoutPseudoModel::~CScript_LayoutPseudoModel() {}
31 void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_Ready( 31 void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_Ready(
32 CFXJSE_Value* pValue, 32 CFXJSE_Value* pValue,
33 FX_BOOL bSetting, 33 FX_BOOL bSetting,
34 XFA_ATTRIBUTE eAttribute) { 34 XFA_ATTRIBUTE eAttribute) {
35 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); 35 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify();
36 if (!pNotify) { 36 if (!pNotify) {
37 return; 37 return;
38 } 38 }
39 if (bSetting) { 39 if (bSetting) {
40 ThrowScriptErrorMessage(XFA_IDS_UNABLE_SET_READY); 40 ThrowException(XFA_IDS_UNABLE_SET_READY);
41 return; 41 return;
42 } 42 }
43 int32_t iStatus = pNotify->GetLayoutStatus(); 43 int32_t iStatus = pNotify->GetLayoutStatus();
44 FXJSE_Value_SetBoolean(pValue, iStatus >= 2); 44 FXJSE_Value_SetBoolean(pValue, iStatus >= 2);
45 } 45 }
46 void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_HWXY( 46 void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_HWXY(
47 CFXJSE_Arguments* pArguments, 47 CFXJSE_Arguments* pArguments,
48 XFA_LAYOUTMODEL_HWXY layoutModel) { 48 XFA_LAYOUTMODEL_HWXY layoutModel) {
49 int32_t iLength = pArguments->GetLength(); 49 int32_t iLength = pArguments->GetLength();
50 if (iLength < 1 || iLength > 3) { 50 if (iLength < 1 || iLength > 3) {
51 const FX_WCHAR* methodName = NULL; 51 const FX_WCHAR* methodName = NULL;
52 switch (layoutModel) { 52 switch (layoutModel) {
53 case XFA_LAYOUTMODEL_H: 53 case XFA_LAYOUTMODEL_H:
54 methodName = L"h"; 54 methodName = L"h";
55 break; 55 break;
56 case XFA_LAYOUTMODEL_W: 56 case XFA_LAYOUTMODEL_W:
57 methodName = L"w"; 57 methodName = L"w";
58 break; 58 break;
59 case XFA_LAYOUTMODEL_X: 59 case XFA_LAYOUTMODEL_X:
60 methodName = L"x"; 60 methodName = L"x";
61 break; 61 break;
62 case XFA_LAYOUTMODEL_Y: 62 case XFA_LAYOUTMODEL_Y:
63 methodName = L"y"; 63 methodName = L"y";
64 break; 64 break;
65 } 65 }
66 ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, methodName); 66 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, methodName);
67 return; 67 return;
68 } 68 }
69 CXFA_Node* pNode = NULL; 69 CXFA_Node* pNode = NULL;
70 CFX_WideString wsUnit(L"pt"); 70 CFX_WideString wsUnit(L"pt");
71 int32_t iIndex = 0; 71 int32_t iIndex = 0;
72 if (iLength >= 1) { 72 if (iLength >= 1) {
73 pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); 73 pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0));
74 } 74 }
75 if (iLength >= 2) { 75 if (iLength >= 2) {
76 CFX_ByteString bsUnit = pArguments->GetUTF8String(1); 76 CFX_ByteString bsUnit = pArguments->GetUTF8String(1);
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 } 170 }
171 } 171 }
172 void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_PageCount( 172 void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_PageCount(
173 CFXJSE_Arguments* pArguments) { 173 CFXJSE_Arguments* pArguments) {
174 Script_LayoutPseudoModel_NumberedPageCount(pArguments, TRUE); 174 Script_LayoutPseudoModel_NumberedPageCount(pArguments, TRUE);
175 } 175 }
176 void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_PageSpan( 176 void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_PageSpan(
177 CFXJSE_Arguments* pArguments) { 177 CFXJSE_Arguments* pArguments) {
178 int32_t iLength = pArguments->GetLength(); 178 int32_t iLength = pArguments->GetLength();
179 if (iLength != 1) { 179 if (iLength != 1) {
180 ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"pageSpan"); 180 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"pageSpan");
181 return; 181 return;
182 } 182 }
183 CXFA_Node* pNode = NULL; 183 CXFA_Node* pNode = NULL;
184 if (iLength >= 1) { 184 if (iLength >= 1) {
185 pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); 185 pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0));
186 } 186 }
187 if (!pNode) { 187 if (!pNode) {
188 return; 188 return;
189 } 189 }
190 CXFA_LayoutProcessor* pDocLayout = m_pDocument->GetDocLayout(); 190 CXFA_LayoutProcessor* pDocLayout = m_pDocument->GetDocLayout();
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 } 342 }
343 } 343 }
344 } 344 }
345 return; 345 return;
346 } 346 }
347 } 347 }
348 void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_PageContent( 348 void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_PageContent(
349 CFXJSE_Arguments* pArguments) { 349 CFXJSE_Arguments* pArguments) {
350 int32_t iLength = pArguments->GetLength(); 350 int32_t iLength = pArguments->GetLength();
351 if (iLength < 1 || iLength > 3) { 351 if (iLength < 1 || iLength > 3) {
352 ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"pageContent"); 352 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"pageContent");
353 return; 353 return;
354 } 354 }
355 int32_t iIndex = 0; 355 int32_t iIndex = 0;
356 CFX_WideString wsType; 356 CFX_WideString wsType;
357 FX_BOOL bOnPageArea = FALSE; 357 FX_BOOL bOnPageArea = FALSE;
358 if (iLength >= 1) { 358 if (iLength >= 1) {
359 iIndex = pArguments->GetInt32(0); 359 iIndex = pArguments->GetInt32(0);
360 } 360 }
361 if (iLength >= 2) { 361 if (iLength >= 2) {
362 CFX_ByteString bsType = pArguments->GetUTF8String(1); 362 CFX_ByteString bsType = pArguments->GetUTF8String(1);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 pLayoutProcessor->SetForceReLayout(TRUE); 425 pLayoutProcessor->SetForceReLayout(TRUE);
426 } 426 }
427 void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_AbsPageSpan( 427 void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_AbsPageSpan(
428 CFXJSE_Arguments* pArguments) { 428 CFXJSE_Arguments* pArguments) {
429 Script_LayoutPseudoModel_PageSpan(pArguments); 429 Script_LayoutPseudoModel_PageSpan(pArguments);
430 } 430 }
431 void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_AbsPageInBatch( 431 void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_AbsPageInBatch(
432 CFXJSE_Arguments* pArguments) { 432 CFXJSE_Arguments* pArguments) {
433 int32_t iLength = pArguments->GetLength(); 433 int32_t iLength = pArguments->GetLength();
434 if (iLength != 1) { 434 if (iLength != 1) {
435 ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 435 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"absPageInBatch");
436 L"absPageInBatch");
437 return; 436 return;
438 } 437 }
439 CXFA_Node* pNode = NULL; 438 CXFA_Node* pNode = NULL;
440 if (iLength >= 1) { 439 if (iLength >= 1) {
441 pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); 440 pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0));
442 } 441 }
443 if (!pNode) { 442 if (!pNode) {
444 return; 443 return;
445 } 444 }
446 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); 445 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify();
(...skipping 13 matching lines...) Expand all
460 int32_t iPageCount = pNotify->GetDocProvider()->AbsPageInBatch(hDoc, hWidget); 459 int32_t iPageCount = pNotify->GetDocProvider()->AbsPageInBatch(hDoc, hWidget);
461 CFXJSE_Value* pValue = pArguments->GetReturnValue(); 460 CFXJSE_Value* pValue = pArguments->GetReturnValue();
462 if (pValue) { 461 if (pValue) {
463 FXJSE_Value_SetInteger(pValue, iPageCount); 462 FXJSE_Value_SetInteger(pValue, iPageCount);
464 } 463 }
465 } 464 }
466 void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_SheetInBatch( 465 void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_SheetInBatch(
467 CFXJSE_Arguments* pArguments) { 466 CFXJSE_Arguments* pArguments) {
468 int32_t iLength = pArguments->GetLength(); 467 int32_t iLength = pArguments->GetLength();
469 if (iLength != 1) { 468 if (iLength != 1) {
470 ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 469 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"sheetInBatch");
471 L"sheetInBatch");
472 return; 470 return;
473 } 471 }
474 CXFA_Node* pNode = NULL; 472 CXFA_Node* pNode = NULL;
475 if (iLength >= 1) { 473 if (iLength >= 1) {
476 pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); 474 pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0));
477 } 475 }
478 if (!pNode) { 476 if (!pNode) {
479 return; 477 return;
480 } 478 }
481 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); 479 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify();
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 CFXJSE_Arguments* pArguments, 514 CFXJSE_Arguments* pArguments,
517 FX_BOOL bAbsPage) { 515 FX_BOOL bAbsPage) {
518 int32_t iLength = pArguments->GetLength(); 516 int32_t iLength = pArguments->GetLength();
519 if (iLength != 1) { 517 if (iLength != 1) {
520 const FX_WCHAR* methodName; 518 const FX_WCHAR* methodName;
521 if (bAbsPage) { 519 if (bAbsPage) {
522 methodName = L"absPage"; 520 methodName = L"absPage";
523 } else { 521 } else {
524 methodName = L"page"; 522 methodName = L"page";
525 } 523 }
526 ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, methodName); 524 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, methodName);
527 return; 525 return;
528 } 526 }
529 CXFA_Node* pNode = NULL; 527 CXFA_Node* pNode = NULL;
530 if (iLength >= 1) { 528 if (iLength >= 1) {
531 pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); 529 pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0));
532 } 530 }
533 int32_t iPage = 0; 531 int32_t iPage = 0;
534 CFXJSE_Value* pValue = pArguments->GetReturnValue(); 532 CFXJSE_Value* pValue = pArguments->GetReturnValue();
535 if (!pNode && pValue) { 533 if (!pNode && pValue) {
536 FXJSE_Value_SetInteger(pValue, iPage); 534 FXJSE_Value_SetInteger(pValue, iPage);
537 } 535 }
538 CXFA_LayoutProcessor* pDocLayout = m_pDocument->GetDocLayout(); 536 CXFA_LayoutProcessor* pDocLayout = m_pDocument->GetDocLayout();
539 if (!pDocLayout) { 537 if (!pDocLayout) {
540 return; 538 return;
541 } 539 }
542 CXFA_LayoutItem* pLayoutItem = pDocLayout->GetLayoutItem(pNode); 540 CXFA_LayoutItem* pLayoutItem = pDocLayout->GetLayoutItem(pNode);
543 if (!pLayoutItem) { 541 if (!pLayoutItem) {
544 FXJSE_Value_SetInteger(pValue, -1); 542 FXJSE_Value_SetInteger(pValue, -1);
545 return; 543 return;
546 } 544 }
547 iPage = pLayoutItem->GetFirst()->GetPage()->GetPageIndex(); 545 iPage = pLayoutItem->GetFirst()->GetPage()->GetPageIndex();
548 if (pValue) { 546 if (pValue) {
549 FXJSE_Value_SetInteger(pValue, bAbsPage ? iPage : iPage + 1); 547 FXJSE_Value_SetInteger(pValue, bAbsPage ? iPage : iPage + 1);
550 } 548 }
551 } 549 }
OLDNEW
« no previous file with comments | « xfa/fxfa/parser/xfa_script_hostpseudomodel.cpp ('k') | xfa/fxfa/parser/xfa_script_signaturepseudomodel.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698