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 |
11 #include "fxjse/include/cfxjse_arguments.h" | 11 #include "fxjse/include/cfxjse_arguments.h" |
12 #include "third_party/base/stl_util.h" | 12 #include "third_party/base/stl_util.h" |
13 #include "xfa/fxfa/app/xfa_ffnotify.h" | 13 #include "xfa/fxfa/app/xfa_ffnotify.h" |
14 #include "xfa/fxfa/parser/xfa_doclayout.h" | 14 #include "xfa/fxfa/parser/xfa_doclayout.h" |
15 #include "xfa/fxfa/parser/xfa_document.h" | 15 #include "xfa/fxfa/parser/xfa_document.h" |
16 #include "xfa/fxfa/parser/xfa_document_layout_imp.h" | 16 #include "xfa/fxfa/parser/xfa_document_layout_imp.h" |
17 #include "xfa/fxfa/parser/xfa_layout_appadapter.h" | 17 #include "xfa/fxfa/parser/xfa_layout_appadapter.h" |
18 #include "xfa/fxfa/parser/xfa_localemgr.h" | 18 #include "xfa/fxfa/parser/xfa_localemgr.h" |
19 #include "xfa/fxfa/parser/xfa_object.h" | 19 #include "xfa/fxfa/parser/xfa_object.h" |
20 #include "xfa/fxfa/parser/xfa_parser.h" | |
21 #include "xfa/fxfa/parser/xfa_parser_imp.h" | 20 #include "xfa/fxfa/parser/xfa_parser_imp.h" |
22 #include "xfa/fxfa/parser/xfa_script.h" | 21 #include "xfa/fxfa/parser/xfa_script.h" |
23 #include "xfa/fxfa/parser/xfa_script_imp.h" | 22 #include "xfa/fxfa/parser/xfa_script_imp.h" |
24 #include "xfa/fxfa/parser/xfa_utils.h" | 23 #include "xfa/fxfa/parser/xfa_utils.h" |
25 | 24 |
26 CScript_LayoutPseudoModel::CScript_LayoutPseudoModel(CXFA_Document* pDocument) | 25 CScript_LayoutPseudoModel::CScript_LayoutPseudoModel(CXFA_Document* pDocument) |
27 : CXFA_Object(pDocument, | 26 : CXFA_Object(pDocument, |
28 XFA_ObjectType::Object, | 27 XFA_ObjectType::Object, |
29 XFA_Element::LayoutPseudoModel) {} | 28 XFA_Element::LayoutPseudoModel) {} |
30 CScript_LayoutPseudoModel::~CScript_LayoutPseudoModel() {} | 29 CScript_LayoutPseudoModel::~CScript_LayoutPseudoModel() {} |
31 void CScript_LayoutPseudoModel::Ready(CFXJSE_Value* pValue, | 30 void CScript_LayoutPseudoModel::Ready(CFXJSE_Value* pValue, |
32 FX_BOOL bSetting, | 31 FX_BOOL bSetting, |
33 XFA_ATTRIBUTE eAttribute) { | 32 XFA_ATTRIBUTE eAttribute) { |
34 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 33 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); |
35 if (!pNotify) { | 34 if (!pNotify) { |
36 return; | 35 return; |
37 } | 36 } |
38 if (bSetting) { | 37 if (bSetting) { |
39 ThrowException(XFA_IDS_UNABLE_SET_READY); | 38 ThrowException(XFA_IDS_UNABLE_SET_READY); |
40 return; | 39 return; |
41 } | 40 } |
42 int32_t iStatus = pNotify->GetLayoutStatus(); | 41 int32_t iStatus = pNotify->GetLayoutStatus(); |
43 pValue->SetBoolean(iStatus >= 2); | 42 pValue->SetBoolean(iStatus >= 2); |
44 } | 43 } |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 if (iLength >= 1) { | 337 if (iLength >= 1) { |
339 iIndex = pArguments->GetInt32(0); | 338 iIndex = pArguments->GetInt32(0); |
340 } | 339 } |
341 if (iLength >= 2) { | 340 if (iLength >= 2) { |
342 CFX_ByteString bsType = pArguments->GetUTF8String(1); | 341 CFX_ByteString bsType = pArguments->GetUTF8String(1); |
343 wsType = CFX_WideString::FromUTF8(bsType.AsStringC()); | 342 wsType = CFX_WideString::FromUTF8(bsType.AsStringC()); |
344 } | 343 } |
345 if (iLength >= 3) { | 344 if (iLength >= 3) { |
346 bOnPageArea = pArguments->GetInt32(2) == 0 ? FALSE : TRUE; | 345 bOnPageArea = pArguments->GetInt32(2) == 0 ? FALSE : TRUE; |
347 } | 346 } |
348 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 347 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); |
349 if (!pNotify) { | 348 if (!pNotify) { |
350 return; | 349 return; |
351 } | 350 } |
352 CXFA_LayoutProcessor* pDocLayout = m_pDocument->GetDocLayout(); | 351 CXFA_LayoutProcessor* pDocLayout = m_pDocument->GetDocLayout(); |
353 if (!pDocLayout) { | 352 if (!pDocLayout) { |
354 return; | 353 return; |
355 } | 354 } |
356 CXFA_NodeArray retArray; | 355 CXFA_NodeArray retArray; |
357 GetObjArray(pDocLayout, iIndex, wsType, bOnPageArea, retArray); | 356 GetObjArray(pDocLayout, iIndex, wsType, bOnPageArea, retArray); |
358 CXFA_ArrayNodeList* pArrayNodeList = new CXFA_ArrayNodeList(m_pDocument); | 357 CXFA_ArrayNodeList* pArrayNodeList = new CXFA_ArrayNodeList(m_pDocument); |
359 pArrayNodeList->SetArrayNodeList(retArray); | 358 pArrayNodeList->SetArrayNodeList(retArray); |
360 pArguments->GetReturnValue()->SetObject( | 359 pArguments->GetReturnValue()->SetObject( |
361 pArrayNodeList, m_pDocument->GetScriptContext()->GetJseNormalClass()); | 360 pArrayNodeList, m_pDocument->GetScriptContext()->GetJseNormalClass()); |
362 } | 361 } |
363 void CScript_LayoutPseudoModel::AbsPageCount(CFXJSE_Arguments* pArguments) { | 362 void CScript_LayoutPseudoModel::AbsPageCount(CFXJSE_Arguments* pArguments) { |
364 NumberedPageCount(pArguments, FALSE); | 363 NumberedPageCount(pArguments, FALSE); |
365 } | 364 } |
366 void CScript_LayoutPseudoModel::AbsPageCountInBatch( | 365 void CScript_LayoutPseudoModel::AbsPageCountInBatch( |
367 CFXJSE_Arguments* pArguments) { | 366 CFXJSE_Arguments* pArguments) { |
368 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 367 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); |
369 if (!pNotify) { | 368 if (!pNotify) { |
370 return; | 369 return; |
371 } | 370 } |
372 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); | 371 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); |
373 int32_t iPageCount = pNotify->GetDocProvider()->AbsPageCountInBatch(hDoc); | 372 int32_t iPageCount = pNotify->GetDocProvider()->AbsPageCountInBatch(hDoc); |
374 CFXJSE_Value* pValue = pArguments->GetReturnValue(); | 373 CFXJSE_Value* pValue = pArguments->GetReturnValue(); |
375 if (pValue) | 374 if (pValue) |
376 pValue->SetInteger(iPageCount); | 375 pValue->SetInteger(iPageCount); |
377 } | 376 } |
378 void CScript_LayoutPseudoModel::SheetCountInBatch( | 377 void CScript_LayoutPseudoModel::SheetCountInBatch( |
379 CFXJSE_Arguments* pArguments) { | 378 CFXJSE_Arguments* pArguments) { |
380 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 379 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); |
381 if (!pNotify) { | 380 if (!pNotify) { |
382 return; | 381 return; |
383 } | 382 } |
384 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); | 383 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); |
385 int32_t iPageCount = pNotify->GetDocProvider()->SheetCountInBatch(hDoc); | 384 int32_t iPageCount = pNotify->GetDocProvider()->SheetCountInBatch(hDoc); |
386 CFXJSE_Value* pValue = pArguments->GetReturnValue(); | 385 CFXJSE_Value* pValue = pArguments->GetReturnValue(); |
387 if (pValue) | 386 if (pValue) |
388 pValue->SetInteger(iPageCount); | 387 pValue->SetInteger(iPageCount); |
389 } | 388 } |
390 void CScript_LayoutPseudoModel::Relayout(CFXJSE_Arguments* pArguments) { | 389 void CScript_LayoutPseudoModel::Relayout(CFXJSE_Arguments* pArguments) { |
(...skipping 16 matching lines...) Expand all Loading... |
407 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"absPageInBatch"); | 406 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"absPageInBatch"); |
408 return; | 407 return; |
409 } | 408 } |
410 CXFA_Node* pNode = nullptr; | 409 CXFA_Node* pNode = nullptr; |
411 if (iLength >= 1) { | 410 if (iLength >= 1) { |
412 pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); | 411 pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); |
413 } | 412 } |
414 if (!pNode) { | 413 if (!pNode) { |
415 return; | 414 return; |
416 } | 415 } |
417 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 416 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); |
418 if (!pNotify) { | 417 if (!pNotify) { |
419 return; | 418 return; |
420 } | 419 } |
421 CXFA_LayoutProcessor* pDocLayout = m_pDocument->GetDocLayout(); | 420 CXFA_LayoutProcessor* pDocLayout = m_pDocument->GetDocLayout(); |
422 if (!pDocLayout) { | 421 if (!pDocLayout) { |
423 return; | 422 return; |
424 } | 423 } |
425 CXFA_FFWidget* hWidget = | 424 CXFA_FFWidget* hWidget = |
426 pNotify->GetHWidget(pDocLayout->GetLayoutItem(pNode)); | 425 pNotify->GetHWidget(pDocLayout->GetLayoutItem(pNode)); |
427 if (!hWidget) { | 426 if (!hWidget) { |
(...skipping 11 matching lines...) Expand all Loading... |
439 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"sheetInBatch"); | 438 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"sheetInBatch"); |
440 return; | 439 return; |
441 } | 440 } |
442 CXFA_Node* pNode = nullptr; | 441 CXFA_Node* pNode = nullptr; |
443 if (iLength >= 1) { | 442 if (iLength >= 1) { |
444 pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); | 443 pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); |
445 } | 444 } |
446 if (!pNode) { | 445 if (!pNode) { |
447 return; | 446 return; |
448 } | 447 } |
449 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 448 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); |
450 if (!pNotify) { | 449 if (!pNotify) { |
451 return; | 450 return; |
452 } | 451 } |
453 CXFA_LayoutProcessor* pDocLayout = m_pDocument->GetDocLayout(); | 452 CXFA_LayoutProcessor* pDocLayout = m_pDocument->GetDocLayout(); |
454 if (!pDocLayout) { | 453 if (!pDocLayout) { |
455 return; | 454 return; |
456 } | 455 } |
457 CXFA_FFWidget* hWidget = | 456 CXFA_FFWidget* hWidget = |
458 pNotify->GetHWidget(pDocLayout->GetLayoutItem(pNode)); | 457 pNotify->GetHWidget(pDocLayout->GetLayoutItem(pNode)); |
459 if (!hWidget) { | 458 if (!hWidget) { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 } | 503 } |
505 CXFA_LayoutItem* pLayoutItem = pDocLayout->GetLayoutItem(pNode); | 504 CXFA_LayoutItem* pLayoutItem = pDocLayout->GetLayoutItem(pNode); |
506 if (!pLayoutItem) { | 505 if (!pLayoutItem) { |
507 pValue->SetInteger(-1); | 506 pValue->SetInteger(-1); |
508 return; | 507 return; |
509 } | 508 } |
510 iPage = pLayoutItem->GetFirst()->GetPage()->GetPageIndex(); | 509 iPage = pLayoutItem->GetFirst()->GetPage()->GetPageIndex(); |
511 if (pValue) | 510 if (pValue) |
512 pValue->SetInteger(bAbsPage ? iPage : iPage + 1); | 511 pValue->SetInteger(bAbsPage ? iPage : iPage + 1); |
513 } | 512 } |
OLD | NEW |