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 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 = 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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 ThrowException(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 = nullptr; |
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(); |
191 if (!pDocLayout) { | 191 if (!pDocLayout) { |
192 return; | 192 return; |
193 } | 193 } |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"absPageInBatch"); | 435 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"absPageInBatch"); |
436 return; | 436 return; |
437 } | 437 } |
438 CXFA_Node* pNode = NULL; | 438 CXFA_Node* pNode = nullptr; |
439 if (iLength >= 1) { | 439 if (iLength >= 1) { |
440 pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); | 440 pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); |
441 } | 441 } |
442 if (!pNode) { | 442 if (!pNode) { |
443 return; | 443 return; |
444 } | 444 } |
445 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 445 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
446 if (!pNotify) { | 446 if (!pNotify) { |
447 return; | 447 return; |
448 } | 448 } |
(...skipping 13 matching lines...) Expand all Loading... |
462 FXJSE_Value_SetInteger(pValue, iPageCount); | 462 FXJSE_Value_SetInteger(pValue, iPageCount); |
463 } | 463 } |
464 } | 464 } |
465 void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_SheetInBatch( | 465 void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_SheetInBatch( |
466 CFXJSE_Arguments* pArguments) { | 466 CFXJSE_Arguments* pArguments) { |
467 int32_t iLength = pArguments->GetLength(); | 467 int32_t iLength = pArguments->GetLength(); |
468 if (iLength != 1) { | 468 if (iLength != 1) { |
469 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"sheetInBatch"); | 469 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"sheetInBatch"); |
470 return; | 470 return; |
471 } | 471 } |
472 CXFA_Node* pNode = NULL; | 472 CXFA_Node* pNode = nullptr; |
473 if (iLength >= 1) { | 473 if (iLength >= 1) { |
474 pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); | 474 pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); |
475 } | 475 } |
476 if (!pNode) { | 476 if (!pNode) { |
477 return; | 477 return; |
478 } | 478 } |
479 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 479 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
480 if (!pNotify) { | 480 if (!pNotify) { |
481 return; | 481 return; |
482 } | 482 } |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
517 if (iLength != 1) { | 517 if (iLength != 1) { |
518 const FX_WCHAR* methodName; | 518 const FX_WCHAR* methodName; |
519 if (bAbsPage) { | 519 if (bAbsPage) { |
520 methodName = L"absPage"; | 520 methodName = L"absPage"; |
521 } else { | 521 } else { |
522 methodName = L"page"; | 522 methodName = L"page"; |
523 } | 523 } |
524 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, methodName); | 524 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, methodName); |
525 return; | 525 return; |
526 } | 526 } |
527 CXFA_Node* pNode = NULL; | 527 CXFA_Node* pNode = nullptr; |
528 if (iLength >= 1) { | 528 if (iLength >= 1) { |
529 pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); | 529 pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); |
530 } | 530 } |
531 int32_t iPage = 0; | 531 int32_t iPage = 0; |
532 CFXJSE_Value* pValue = pArguments->GetReturnValue(); | 532 CFXJSE_Value* pValue = pArguments->GetReturnValue(); |
533 if (!pNode && pValue) { | 533 if (!pNode && pValue) { |
534 FXJSE_Value_SetInteger(pValue, iPage); | 534 FXJSE_Value_SetInteger(pValue, iPage); |
535 } | 535 } |
536 CXFA_LayoutProcessor* pDocLayout = m_pDocument->GetDocLayout(); | 536 CXFA_LayoutProcessor* pDocLayout = m_pDocument->GetDocLayout(); |
537 if (!pDocLayout) { | 537 if (!pDocLayout) { |
538 return; | 538 return; |
539 } | 539 } |
540 CXFA_LayoutItem* pLayoutItem = pDocLayout->GetLayoutItem(pNode); | 540 CXFA_LayoutItem* pLayoutItem = pDocLayout->GetLayoutItem(pNode); |
541 if (!pLayoutItem) { | 541 if (!pLayoutItem) { |
542 FXJSE_Value_SetInteger(pValue, -1); | 542 FXJSE_Value_SetInteger(pValue, -1); |
543 return; | 543 return; |
544 } | 544 } |
545 iPage = pLayoutItem->GetFirst()->GetPage()->GetPageIndex(); | 545 iPage = pLayoutItem->GetFirst()->GetPage()->GetPageIndex(); |
546 if (pValue) { | 546 if (pValue) { |
547 FXJSE_Value_SetInteger(pValue, bAbsPage ? iPage : iPage + 1); | 547 FXJSE_Value_SetInteger(pValue, bAbsPage ? iPage : iPage + 1); |
548 } | 548 } |
549 } | 549 } |
OLD | NEW |