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

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

Issue 2123133004: Remove IXFA_Parser, cleanup XFA parser code. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Missing include Created 4 years, 5 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
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::Script_LayoutPseudoModel_Ready( 30 void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_Ready(
32 CFXJSE_Value* pValue, 31 CFXJSE_Value* pValue,
33 FX_BOOL bSetting, 32 FX_BOOL bSetting,
34 XFA_ATTRIBUTE eAttribute) { 33 XFA_ATTRIBUTE eAttribute) {
35 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); 34 CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
36 if (!pNotify) { 35 if (!pNotify) {
37 return; 36 return;
38 } 37 }
39 if (bSetting) { 38 if (bSetting) {
40 ThrowException(XFA_IDS_UNABLE_SET_READY); 39 ThrowException(XFA_IDS_UNABLE_SET_READY);
41 return; 40 return;
42 } 41 }
43 int32_t iStatus = pNotify->GetLayoutStatus(); 42 int32_t iStatus = pNotify->GetLayoutStatus();
44 pValue->SetBoolean(iStatus >= 2); 43 pValue->SetBoolean(iStatus >= 2);
45 } 44 }
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 if (iLength >= 1) { 349 if (iLength >= 1) {
351 iIndex = pArguments->GetInt32(0); 350 iIndex = pArguments->GetInt32(0);
352 } 351 }
353 if (iLength >= 2) { 352 if (iLength >= 2) {
354 CFX_ByteString bsType = pArguments->GetUTF8String(1); 353 CFX_ByteString bsType = pArguments->GetUTF8String(1);
355 wsType = CFX_WideString::FromUTF8(bsType.AsStringC()); 354 wsType = CFX_WideString::FromUTF8(bsType.AsStringC());
356 } 355 }
357 if (iLength >= 3) { 356 if (iLength >= 3) {
358 bOnPageArea = pArguments->GetInt32(2) == 0 ? FALSE : TRUE; 357 bOnPageArea = pArguments->GetInt32(2) == 0 ? FALSE : TRUE;
359 } 358 }
360 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); 359 CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
361 if (!pNotify) { 360 if (!pNotify) {
362 return; 361 return;
363 } 362 }
364 CXFA_LayoutProcessor* pDocLayout = m_pDocument->GetDocLayout(); 363 CXFA_LayoutProcessor* pDocLayout = m_pDocument->GetDocLayout();
365 if (!pDocLayout) { 364 if (!pDocLayout) {
366 return; 365 return;
367 } 366 }
368 CXFA_NodeArray retArray; 367 CXFA_NodeArray retArray;
369 Script_LayoutPseudoModel_GetObjArray(pDocLayout, iIndex, wsType, bOnPageArea, 368 Script_LayoutPseudoModel_GetObjArray(pDocLayout, iIndex, wsType, bOnPageArea,
370 retArray); 369 retArray);
371 CXFA_ArrayNodeList* pArrayNodeList = new CXFA_ArrayNodeList(m_pDocument); 370 CXFA_ArrayNodeList* pArrayNodeList = new CXFA_ArrayNodeList(m_pDocument);
372 pArrayNodeList->SetArrayNodeList(retArray); 371 pArrayNodeList->SetArrayNodeList(retArray);
373 pArguments->GetReturnValue()->SetObject( 372 pArguments->GetReturnValue()->SetObject(
374 pArrayNodeList, m_pDocument->GetScriptContext()->GetJseNormalClass()); 373 pArrayNodeList, m_pDocument->GetScriptContext()->GetJseNormalClass());
375 } 374 }
376 void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_AbsPageCount( 375 void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_AbsPageCount(
377 CFXJSE_Arguments* pArguments) { 376 CFXJSE_Arguments* pArguments) {
378 Script_LayoutPseudoModel_NumberedPageCount(pArguments, FALSE); 377 Script_LayoutPseudoModel_NumberedPageCount(pArguments, FALSE);
379 } 378 }
380 void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_AbsPageCountInBatch( 379 void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_AbsPageCountInBatch(
381 CFXJSE_Arguments* pArguments) { 380 CFXJSE_Arguments* pArguments) {
382 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); 381 CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
383 if (!pNotify) { 382 if (!pNotify) {
384 return; 383 return;
385 } 384 }
386 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); 385 CXFA_FFDoc* hDoc = pNotify->GetHDOC();
387 int32_t iPageCount = pNotify->GetDocProvider()->AbsPageCountInBatch(hDoc); 386 int32_t iPageCount = pNotify->GetDocProvider()->AbsPageCountInBatch(hDoc);
388 CFXJSE_Value* pValue = pArguments->GetReturnValue(); 387 CFXJSE_Value* pValue = pArguments->GetReturnValue();
389 if (pValue) 388 if (pValue)
390 pValue->SetInteger(iPageCount); 389 pValue->SetInteger(iPageCount);
391 } 390 }
392 void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_SheetCountInBatch( 391 void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_SheetCountInBatch(
393 CFXJSE_Arguments* pArguments) { 392 CFXJSE_Arguments* pArguments) {
394 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); 393 CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
395 if (!pNotify) { 394 if (!pNotify) {
396 return; 395 return;
397 } 396 }
398 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); 397 CXFA_FFDoc* hDoc = pNotify->GetHDOC();
399 int32_t iPageCount = pNotify->GetDocProvider()->SheetCountInBatch(hDoc); 398 int32_t iPageCount = pNotify->GetDocProvider()->SheetCountInBatch(hDoc);
400 CFXJSE_Value* pValue = pArguments->GetReturnValue(); 399 CFXJSE_Value* pValue = pArguments->GetReturnValue();
401 if (pValue) 400 if (pValue)
402 pValue->SetInteger(iPageCount); 401 pValue->SetInteger(iPageCount);
403 } 402 }
404 void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_Relayout( 403 void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_Relayout(
(...skipping 19 matching lines...) Expand all
424 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"absPageInBatch"); 423 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"absPageInBatch");
425 return; 424 return;
426 } 425 }
427 CXFA_Node* pNode = nullptr; 426 CXFA_Node* pNode = nullptr;
428 if (iLength >= 1) { 427 if (iLength >= 1) {
429 pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); 428 pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0));
430 } 429 }
431 if (!pNode) { 430 if (!pNode) {
432 return; 431 return;
433 } 432 }
434 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); 433 CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
435 if (!pNotify) { 434 if (!pNotify) {
436 return; 435 return;
437 } 436 }
438 CXFA_LayoutProcessor* pDocLayout = m_pDocument->GetDocLayout(); 437 CXFA_LayoutProcessor* pDocLayout = m_pDocument->GetDocLayout();
439 if (!pDocLayout) { 438 if (!pDocLayout) {
440 return; 439 return;
441 } 440 }
442 CXFA_FFWidget* hWidget = 441 CXFA_FFWidget* hWidget =
443 pNotify->GetHWidget(pDocLayout->GetLayoutItem(pNode)); 442 pNotify->GetHWidget(pDocLayout->GetLayoutItem(pNode));
444 if (!hWidget) { 443 if (!hWidget) {
(...skipping 12 matching lines...) Expand all
457 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"sheetInBatch"); 456 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"sheetInBatch");
458 return; 457 return;
459 } 458 }
460 CXFA_Node* pNode = nullptr; 459 CXFA_Node* pNode = nullptr;
461 if (iLength >= 1) { 460 if (iLength >= 1) {
462 pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); 461 pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0));
463 } 462 }
464 if (!pNode) { 463 if (!pNode) {
465 return; 464 return;
466 } 465 }
467 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); 466 CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
468 if (!pNotify) { 467 if (!pNotify) {
469 return; 468 return;
470 } 469 }
471 CXFA_LayoutProcessor* pDocLayout = m_pDocument->GetDocLayout(); 470 CXFA_LayoutProcessor* pDocLayout = m_pDocument->GetDocLayout();
472 if (!pDocLayout) { 471 if (!pDocLayout) {
473 return; 472 return;
474 } 473 }
475 CXFA_FFWidget* hWidget = 474 CXFA_FFWidget* hWidget =
476 pNotify->GetHWidget(pDocLayout->GetLayoutItem(pNode)); 475 pNotify->GetHWidget(pDocLayout->GetLayoutItem(pNode));
477 if (!hWidget) { 476 if (!hWidget) {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 } 525 }
527 CXFA_LayoutItem* pLayoutItem = pDocLayout->GetLayoutItem(pNode); 526 CXFA_LayoutItem* pLayoutItem = pDocLayout->GetLayoutItem(pNode);
528 if (!pLayoutItem) { 527 if (!pLayoutItem) {
529 pValue->SetInteger(-1); 528 pValue->SetInteger(-1);
530 return; 529 return;
531 } 530 }
532 iPage = pLayoutItem->GetFirst()->GetPage()->GetPageIndex(); 531 iPage = pLayoutItem->GetFirst()->GetPage()->GetPageIndex();
533 if (pValue) 532 if (pValue)
534 pValue->SetInteger(bAbsPage ? iPage : iPage + 1); 533 pValue->SetInteger(bAbsPage ? iPage : iPage + 1);
535 } 534 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698