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 "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 30 matching lines...) Expand all Loading... |
41 return; | 41 return; |
42 } | 42 } |
43 int32_t iStatus = pNotify->GetLayoutStatus(); | 43 int32_t iStatus = pNotify->GetLayoutStatus(); |
44 pValue->SetBoolean(iStatus >= 2); | 44 pValue->SetBoolean(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 = nullptr; |
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 ThrowException(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 = nullptr; |
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); |
77 if (!bsUnit.IsEmpty()) { | 77 if (!bsUnit.IsEmpty()) { |
78 wsUnit = CFX_WideString::FromUTF8(bsUnit.AsStringC()); | 78 wsUnit = CFX_WideString::FromUTF8(bsUnit.AsStringC()); |
79 } | 79 } |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 CFXJSE_Arguments* pArguments) { | 171 CFXJSE_Arguments* pArguments) { |
172 Script_LayoutPseudoModel_NumberedPageCount(pArguments, TRUE); | 172 Script_LayoutPseudoModel_NumberedPageCount(pArguments, TRUE); |
173 } | 173 } |
174 void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_PageSpan( | 174 void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_PageSpan( |
175 CFXJSE_Arguments* pArguments) { | 175 CFXJSE_Arguments* pArguments) { |
176 int32_t iLength = pArguments->GetLength(); | 176 int32_t iLength = pArguments->GetLength(); |
177 if (iLength != 1) { | 177 if (iLength != 1) { |
178 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"pageSpan"); | 178 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"pageSpan"); |
179 return; | 179 return; |
180 } | 180 } |
181 CXFA_Node* pNode = NULL; | 181 CXFA_Node* pNode = nullptr; |
182 if (iLength >= 1) { | 182 if (iLength >= 1) { |
183 pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); | 183 pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); |
184 } | 184 } |
185 if (!pNode) { | 185 if (!pNode) { |
186 return; | 186 return; |
187 } | 187 } |
188 CXFA_LayoutProcessor* pDocLayout = m_pDocument->GetDocLayout(); | 188 CXFA_LayoutProcessor* pDocLayout = m_pDocument->GetDocLayout(); |
189 if (!pDocLayout) { | 189 if (!pDocLayout) { |
190 return; | 190 return; |
191 } | 191 } |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 CFXJSE_Arguments* pArguments) { | 417 CFXJSE_Arguments* pArguments) { |
418 Script_LayoutPseudoModel_PageSpan(pArguments); | 418 Script_LayoutPseudoModel_PageSpan(pArguments); |
419 } | 419 } |
420 void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_AbsPageInBatch( | 420 void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_AbsPageInBatch( |
421 CFXJSE_Arguments* pArguments) { | 421 CFXJSE_Arguments* pArguments) { |
422 int32_t iLength = pArguments->GetLength(); | 422 int32_t iLength = pArguments->GetLength(); |
423 if (iLength != 1) { | 423 if (iLength != 1) { |
424 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"absPageInBatch"); | 424 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"absPageInBatch"); |
425 return; | 425 return; |
426 } | 426 } |
427 CXFA_Node* pNode = NULL; | 427 CXFA_Node* pNode = nullptr; |
428 if (iLength >= 1) { | 428 if (iLength >= 1) { |
429 pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); | 429 pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); |
430 } | 430 } |
431 if (!pNode) { | 431 if (!pNode) { |
432 return; | 432 return; |
433 } | 433 } |
434 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 434 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
435 if (!pNotify) { | 435 if (!pNotify) { |
436 return; | 436 return; |
437 } | 437 } |
(...skipping 12 matching lines...) Expand all Loading... |
450 if (pValue) | 450 if (pValue) |
451 pValue->SetInteger(iPageCount); | 451 pValue->SetInteger(iPageCount); |
452 } | 452 } |
453 void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_SheetInBatch( | 453 void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_SheetInBatch( |
454 CFXJSE_Arguments* pArguments) { | 454 CFXJSE_Arguments* pArguments) { |
455 int32_t iLength = pArguments->GetLength(); | 455 int32_t iLength = pArguments->GetLength(); |
456 if (iLength != 1) { | 456 if (iLength != 1) { |
457 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"sheetInBatch"); | 457 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"sheetInBatch"); |
458 return; | 458 return; |
459 } | 459 } |
460 CXFA_Node* pNode = NULL; | 460 CXFA_Node* pNode = nullptr; |
461 if (iLength >= 1) { | 461 if (iLength >= 1) { |
462 pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); | 462 pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); |
463 } | 463 } |
464 if (!pNode) { | 464 if (!pNode) { |
465 return; | 465 return; |
466 } | 466 } |
467 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 467 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
468 if (!pNotify) { | 468 if (!pNotify) { |
469 return; | 469 return; |
470 } | 470 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 if (iLength != 1) { | 504 if (iLength != 1) { |
505 const FX_WCHAR* methodName; | 505 const FX_WCHAR* methodName; |
506 if (bAbsPage) { | 506 if (bAbsPage) { |
507 methodName = L"absPage"; | 507 methodName = L"absPage"; |
508 } else { | 508 } else { |
509 methodName = L"page"; | 509 methodName = L"page"; |
510 } | 510 } |
511 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, methodName); | 511 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, methodName); |
512 return; | 512 return; |
513 } | 513 } |
514 CXFA_Node* pNode = NULL; | 514 CXFA_Node* pNode = nullptr; |
515 if (iLength >= 1) { | 515 if (iLength >= 1) { |
516 pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); | 516 pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); |
517 } | 517 } |
518 int32_t iPage = 0; | 518 int32_t iPage = 0; |
519 CFXJSE_Value* pValue = pArguments->GetReturnValue(); | 519 CFXJSE_Value* pValue = pArguments->GetReturnValue(); |
520 if (!pNode && pValue) | 520 if (!pNode && pValue) |
521 pValue->SetInteger(iPage); | 521 pValue->SetInteger(iPage); |
522 | 522 |
523 CXFA_LayoutProcessor* pDocLayout = m_pDocument->GetDocLayout(); | 523 CXFA_LayoutProcessor* pDocLayout = m_pDocument->GetDocLayout(); |
524 if (!pDocLayout) { | 524 if (!pDocLayout) { |
525 return; | 525 return; |
526 } | 526 } |
527 CXFA_LayoutItem* pLayoutItem = pDocLayout->GetLayoutItem(pNode); | 527 CXFA_LayoutItem* pLayoutItem = pDocLayout->GetLayoutItem(pNode); |
528 if (!pLayoutItem) { | 528 if (!pLayoutItem) { |
529 pValue->SetInteger(-1); | 529 pValue->SetInteger(-1); |
530 return; | 530 return; |
531 } | 531 } |
532 iPage = pLayoutItem->GetFirst()->GetPage()->GetPageIndex(); | 532 iPage = pLayoutItem->GetFirst()->GetPage()->GetPageIndex(); |
533 if (pValue) | 533 if (pValue) |
534 pValue->SetInteger(bAbsPage ? iPage : iPage + 1); | 534 pValue->SetInteger(bAbsPage ? iPage : iPage + 1); |
535 } | 535 } |
OLD | NEW |