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

Side by Side Diff: xfa/fxfa/app/xfa_ffdocview.cpp

Issue 2328573002: Split CPDFXFA_Document apart (Closed)
Patch Set: Fix merge Created 4 years, 3 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
« no previous file with comments | « xfa/fxfa/app/xfa_ffdoc.cpp ('k') | xfa/fxfa/app/xfa_fffield.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/include/xfa_ffdocview.h" 7 #include "xfa/fxfa/include/xfa_ffdocview.h"
8 8
9 #include "core/fxcrt/include/fx_ext.h" 9 #include "core/fxcrt/include/fx_ext.h"
10 #include "xfa/fxfa/app/xfa_ffbarcode.h" 10 #include "xfa/fxfa/app/xfa_ffbarcode.h"
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 pFormNode->GetElementType() != XFA_Element::ExclGroup) { 243 pFormNode->GetElementType() != XFA_Element::ExclGroup) {
244 CXFA_WidgetAccIterator Iterator(this, pFormNode); 244 CXFA_WidgetAccIterator Iterator(this, pFormNode);
245 while (CXFA_WidgetAcc* pAcc = Iterator.MoveToNext()) { 245 while (CXFA_WidgetAcc* pAcc = Iterator.MoveToNext()) {
246 bChanged |= ResetSingleWidgetAccData(pAcc); 246 bChanged |= ResetSingleWidgetAccData(pAcc);
247 if (pAcc->GetNode()->GetElementType() == XFA_Element::ExclGroup) { 247 if (pAcc->GetNode()->GetElementType() == XFA_Element::ExclGroup) {
248 Iterator.SkipTree(); 248 Iterator.SkipTree();
249 } 249 }
250 } 250 }
251 } 251 }
252 if (bChanged) { 252 if (bChanged) {
253 m_pDoc->GetDocProvider()->SetChangeMark(m_pDoc); 253 m_pDoc->GetDocEnvironment()->SetChangeMark(m_pDoc);
254 } 254 }
255 } 255 }
256 int32_t CXFA_FFDocView::ProcessWidgetEvent(CXFA_EventParam* pParam, 256 int32_t CXFA_FFDocView::ProcessWidgetEvent(CXFA_EventParam* pParam,
257 CXFA_WidgetAcc* pWidgetAcc) { 257 CXFA_WidgetAcc* pWidgetAcc) {
258 if (!pParam) 258 if (!pParam)
259 return XFA_EVENTERROR_Error; 259 return XFA_EVENTERROR_Error;
260 260
261 if (pParam->m_eType == XFA_EVENT_Validate) { 261 if (pParam->m_eType == XFA_EVENT_Validate) {
262 CFX_WideString wsValidateStr(L"preSubmit"); 262 CFX_WideString wsValidateStr(L"preSubmit");
263 CXFA_Node* pConfigItem = 263 CXFA_Node* pConfigItem =
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 } 380 }
381 CXFA_WidgetAcc* CXFA_FFDocView::GetFocusWidgetAcc() { 381 CXFA_WidgetAcc* CXFA_FFDocView::GetFocusWidgetAcc() {
382 return m_pFocusAcc; 382 return m_pFocusAcc;
383 } 383 }
384 void CXFA_FFDocView::SetFocusWidgetAcc(CXFA_WidgetAcc* pWidgetAcc) { 384 void CXFA_FFDocView::SetFocusWidgetAcc(CXFA_WidgetAcc* pWidgetAcc) {
385 CXFA_FFWidget* pNewFocus = 385 CXFA_FFWidget* pNewFocus =
386 pWidgetAcc ? pWidgetAcc->GetNextWidget(nullptr) : nullptr; 386 pWidgetAcc ? pWidgetAcc->GetNextWidget(nullptr) : nullptr;
387 if (SetFocus(pNewFocus)) { 387 if (SetFocus(pNewFocus)) {
388 m_pFocusAcc = pWidgetAcc; 388 m_pFocusAcc = pWidgetAcc;
389 if (m_iStatus == XFA_DOCVIEW_LAYOUTSTATUS_End) { 389 if (m_iStatus == XFA_DOCVIEW_LAYOUTSTATUS_End) {
390 m_pDoc->GetDocProvider()->SetFocusWidget(m_pDoc, m_pFocusWidget); 390 m_pDoc->GetDocEnvironment()->SetFocusWidget(m_pDoc, m_pFocusWidget);
391 } 391 }
392 } 392 }
393 } 393 }
394 void CXFA_FFDocView::DeleteLayoutItem(CXFA_FFWidget* pWidget) { 394 void CXFA_FFDocView::DeleteLayoutItem(CXFA_FFWidget* pWidget) {
395 if (m_pFocusAcc == pWidget->GetDataAcc()) { 395 if (m_pFocusAcc == pWidget->GetDataAcc()) {
396 m_pFocusAcc = nullptr; 396 m_pFocusAcc = nullptr;
397 m_pFocusWidget = nullptr; 397 m_pFocusWidget = nullptr;
398 m_pOldFocusWidget = nullptr; 398 m_pOldFocusWidget = nullptr;
399 } 399 }
400 } 400 }
401 static int32_t XFA_ProcessEvent(CXFA_FFDocView* pDocView, 401 static int32_t XFA_ProcessEvent(CXFA_FFDocView* pDocView,
402 CXFA_WidgetAcc* pWidgetAcc, 402 CXFA_WidgetAcc* pWidgetAcc,
403 CXFA_EventParam* pParam) { 403 CXFA_EventParam* pParam) {
404 if (!pParam || pParam->m_eType == XFA_EVENT_Unknown) { 404 if (!pParam || pParam->m_eType == XFA_EVENT_Unknown) {
405 return XFA_EVENTERROR_NotExist; 405 return XFA_EVENTERROR_NotExist;
406 } 406 }
407 if (!pWidgetAcc || pWidgetAcc->GetElementType() == XFA_Element::Draw) { 407 if (!pWidgetAcc || pWidgetAcc->GetElementType() == XFA_Element::Draw) {
408 return XFA_EVENTERROR_NotExist; 408 return XFA_EVENTERROR_NotExist;
409 } 409 }
410 switch (pParam->m_eType) { 410 switch (pParam->m_eType) {
411 case XFA_EVENT_Calculate: 411 case XFA_EVENT_Calculate:
412 return pWidgetAcc->ProcessCalculate(); 412 return pWidgetAcc->ProcessCalculate();
413 case XFA_EVENT_Validate: 413 case XFA_EVENT_Validate:
414 if (((CXFA_FFDoc*)pDocView->GetDoc()) 414 if (((CXFA_FFDoc*)pDocView->GetDoc())
415 ->GetDocProvider() 415 ->GetDocEnvironment()
416 ->IsValidationsEnabled(pDocView->GetDoc())) { 416 ->IsValidationsEnabled(pDocView->GetDoc())) {
417 return pWidgetAcc->ProcessValidate(0x01); 417 return pWidgetAcc->ProcessValidate(0x01);
418 } 418 }
419 return XFA_EVENTERROR_Disabled; 419 return XFA_EVENTERROR_Disabled;
420 case XFA_EVENT_InitCalculate: { 420 case XFA_EVENT_InitCalculate: {
421 CXFA_Calculate calc = pWidgetAcc->GetCalculate(); 421 CXFA_Calculate calc = pWidgetAcc->GetCalculate();
422 if (!calc) { 422 if (!calc) {
423 return XFA_EVENTERROR_NotExist; 423 return XFA_EVENTERROR_NotExist;
424 } 424 }
425 if (pWidgetAcc->GetNode()->IsUserInteractive()) 425 if (pWidgetAcc->GetNode()->IsUserInteractive())
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 if (pNode) { 519 if (pNode) {
520 return (CXFA_WidgetAcc*)pNode->GetWidgetData(); 520 return (CXFA_WidgetAcc*)pNode->GetWidgetData();
521 } 521 }
522 } 522 }
523 return nullptr; 523 return nullptr;
524 } 524 }
525 525
526 void CXFA_FFDocView::OnPageEvent(CXFA_ContainerLayoutItem* pSender, 526 void CXFA_FFDocView::OnPageEvent(CXFA_ContainerLayoutItem* pSender,
527 uint32_t dwEvent) { 527 uint32_t dwEvent) {
528 CXFA_FFPageView* pFFPageView = static_cast<CXFA_FFPageView*>(pSender); 528 CXFA_FFPageView* pFFPageView = static_cast<CXFA_FFPageView*>(pSender);
529 m_pDoc->GetDocProvider()->PageViewEvent(pFFPageView, dwEvent); 529 m_pDoc->GetDocEnvironment()->PageViewEvent(pFFPageView, dwEvent);
530 } 530 }
531 531
532 void CXFA_FFDocView::LockUpdate() { 532 void CXFA_FFDocView::LockUpdate() {
533 m_iLock++; 533 m_iLock++;
534 } 534 }
535 void CXFA_FFDocView::UnlockUpdate() { 535 void CXFA_FFDocView::UnlockUpdate() {
536 m_iLock--; 536 m_iLock--;
537 } 537 }
538 FX_BOOL CXFA_FFDocView::IsUpdateLocked() { 538 FX_BOOL CXFA_FFDocView::IsUpdateLocked() {
539 return m_iLock; 539 return m_iLock;
(...skipping 13 matching lines...) Expand all
553 return; 553 return;
554 } 554 }
555 CFX_RectF* pRect = new CFX_RectF; 555 CFX_RectF* pRect = new CFX_RectF;
556 pRect->Set(rtInvalidate.left, rtInvalidate.top, rtInvalidate.width, 556 pRect->Set(rtInvalidate.left, rtInvalidate.top, rtInvalidate.width,
557 rtInvalidate.height); 557 rtInvalidate.height);
558 m_mapPageInvalidate[pPageView].reset(pRect); 558 m_mapPageInvalidate[pPageView].reset(pRect);
559 } 559 }
560 560
561 void CXFA_FFDocView::RunInvalidate() { 561 void CXFA_FFDocView::RunInvalidate() {
562 for (const auto& pair : m_mapPageInvalidate) 562 for (const auto& pair : m_mapPageInvalidate)
563 m_pDoc->GetDocProvider()->InvalidateRect(pair.first, *pair.second, 0); 563 m_pDoc->GetDocEnvironment()->InvalidateRect(pair.first, *pair.second, 0);
564 m_mapPageInvalidate.clear(); 564 m_mapPageInvalidate.clear();
565 } 565 }
566 566
567 FX_BOOL CXFA_FFDocView::RunLayout() { 567 FX_BOOL CXFA_FFDocView::RunLayout() {
568 LockUpdate(); 568 LockUpdate();
569 m_bInLayoutStatus = TRUE; 569 m_bInLayoutStatus = TRUE;
570 if (!m_pXFADocLayout->IncrementLayout() && 570 if (!m_pXFADocLayout->IncrementLayout() &&
571 m_pXFADocLayout->StartLayout() < 100) { 571 m_pXFADocLayout->StartLayout() < 100) {
572 m_pXFADocLayout->DoLayout(); 572 m_pXFADocLayout->DoLayout();
573 UnlockUpdate(); 573 UnlockUpdate();
574 m_bInLayoutStatus = FALSE; 574 m_bInLayoutStatus = FALSE;
575 m_pDoc->GetDocProvider()->PageViewEvent(nullptr, 575 m_pDoc->GetDocEnvironment()->PageViewEvent(nullptr,
576 XFA_PAGEVIEWEVENT_StopLayout); 576 XFA_PAGEVIEWEVENT_StopLayout);
577 return TRUE; 577 return TRUE;
578 } 578 }
579 m_bInLayoutStatus = FALSE; 579 m_bInLayoutStatus = FALSE;
580 m_pDoc->GetDocProvider()->PageViewEvent(nullptr, 580 m_pDoc->GetDocEnvironment()->PageViewEvent(nullptr,
581 XFA_PAGEVIEWEVENT_StopLayout); 581 XFA_PAGEVIEWEVENT_StopLayout);
582 UnlockUpdate(); 582 UnlockUpdate();
583 return FALSE; 583 return FALSE;
584 } 584 }
585 void CXFA_FFDocView::RunSubformIndexChange() { 585 void CXFA_FFDocView::RunSubformIndexChange() {
586 int32_t iSubforms = m_IndexChangedSubforms.GetSize(); 586 int32_t iSubforms = m_IndexChangedSubforms.GetSize();
587 for (int32_t i = 0; i < iSubforms; i++) { 587 for (int32_t i = 0; i < iSubforms; i++) {
588 CXFA_Node* pSubformNode = m_IndexChangedSubforms[i]; 588 CXFA_Node* pSubformNode = m_IndexChangedSubforms[i];
589 CXFA_WidgetAcc* pWidgetAcc = 589 CXFA_WidgetAcc* pWidgetAcc =
590 static_cast<CXFA_WidgetAcc*>(pSubformNode->GetWidgetData()); 590 static_cast<CXFA_WidgetAcc*>(pSubformNode->GetWidgetData());
591 if (!pWidgetAcc) { 591 if (!pWidgetAcc) {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 break; 664 break;
665 } 665 }
666 if ((pCurAcc->ProcessCalculate()) == XFA_EVENTERROR_Success) { 666 if ((pCurAcc->ProcessCalculate()) == XFA_EVENTERROR_Success) {
667 AddValidateWidget(pCurAcc); 667 AddValidateWidget(pCurAcc);
668 } 668 }
669 iIndex++; 669 iIndex++;
670 RunCalculateRecursive(iIndex); 670 RunCalculateRecursive(iIndex);
671 } 671 }
672 } 672 }
673 int32_t CXFA_FFDocView::RunCalculateWidgets() { 673 int32_t CXFA_FFDocView::RunCalculateWidgets() {
674 if (!m_pDoc->GetDocProvider()->IsCalculationsEnabled(m_pDoc)) { 674 if (!m_pDoc->GetDocEnvironment()->IsCalculationsEnabled(m_pDoc)) {
675 return XFA_EVENTERROR_Disabled; 675 return XFA_EVENTERROR_Disabled;
676 } 676 }
677 int32_t iCounts = m_CalculateAccs.GetSize(); 677 int32_t iCounts = m_CalculateAccs.GetSize();
678 int32_t iIndex = 0; 678 int32_t iIndex = 0;
679 if (iCounts > 0) { 679 if (iCounts > 0) {
680 RunCalculateRecursive(iIndex); 680 RunCalculateRecursive(iIndex);
681 } 681 }
682 for (int32_t i = 0; i < m_CalculateAccs.GetSize(); i++) { 682 for (int32_t i = 0; i < m_CalculateAccs.GetSize(); i++) {
683 CXFA_WidgetAcc* pCurAcc = m_CalculateAccs[i]; 683 CXFA_WidgetAcc* pCurAcc = m_CalculateAccs[i];
684 pCurAcc->GetNode()->SetUserData(XFA_CalcRefCount, (void*)(uintptr_t)0); 684 pCurAcc->GetNode()->SetUserData(XFA_CalcRefCount, (void*)(uintptr_t)0);
685 } 685 }
686 m_CalculateAccs.RemoveAll(); 686 m_CalculateAccs.RemoveAll();
687 return XFA_EVENTERROR_Success; 687 return XFA_EVENTERROR_Success;
688 } 688 }
689 void CXFA_FFDocView::AddValidateWidget(CXFA_WidgetAcc* pWidget) { 689 void CXFA_FFDocView::AddValidateWidget(CXFA_WidgetAcc* pWidget) {
690 if (m_ValidateAccs.Find(pWidget) < 0) 690 if (m_ValidateAccs.Find(pWidget) < 0)
691 m_ValidateAccs.Add(pWidget); 691 m_ValidateAccs.Add(pWidget);
692 } 692 }
693 FX_BOOL CXFA_FFDocView::InitCalculate(CXFA_Node* pNode) { 693 FX_BOOL CXFA_FFDocView::InitCalculate(CXFA_Node* pNode) {
694 ExecEventActivityByDeepFirst(pNode, XFA_EVENT_InitCalculate, FALSE, TRUE, 694 ExecEventActivityByDeepFirst(pNode, XFA_EVENT_InitCalculate, FALSE, TRUE,
695 nullptr); 695 nullptr);
696 return TRUE; 696 return TRUE;
697 } 697 }
698 FX_BOOL CXFA_FFDocView::InitValidate(CXFA_Node* pNode) { 698 FX_BOOL CXFA_FFDocView::InitValidate(CXFA_Node* pNode) {
699 if (!m_pDoc->GetDocProvider()->IsValidationsEnabled(m_pDoc)) { 699 if (!m_pDoc->GetDocEnvironment()->IsValidationsEnabled(m_pDoc)) {
700 return FALSE; 700 return FALSE;
701 } 701 }
702 ExecEventActivityByDeepFirst(pNode, XFA_EVENT_Validate, FALSE, TRUE, nullptr); 702 ExecEventActivityByDeepFirst(pNode, XFA_EVENT_Validate, FALSE, TRUE, nullptr);
703 m_ValidateAccs.RemoveAll(); 703 m_ValidateAccs.RemoveAll();
704 return TRUE; 704 return TRUE;
705 } 705 }
706 FX_BOOL CXFA_FFDocView::RunValidate() { 706 FX_BOOL CXFA_FFDocView::RunValidate() {
707 if (!m_pDoc->GetDocProvider()->IsValidationsEnabled(m_pDoc)) { 707 if (!m_pDoc->GetDocEnvironment()->IsValidationsEnabled(m_pDoc)) {
708 return FALSE; 708 return FALSE;
709 } 709 }
710 int32_t iCounts = m_ValidateAccs.GetSize(); 710 int32_t iCounts = m_ValidateAccs.GetSize();
711 for (int32_t i = 0; i < iCounts; i++) { 711 for (int32_t i = 0; i < iCounts; i++) {
712 CXFA_WidgetAcc* pAcc = m_ValidateAccs[i]; 712 CXFA_WidgetAcc* pAcc = m_ValidateAccs[i];
713 if (pAcc->GetNode()->HasRemovedChildren()) 713 if (pAcc->GetNode()->HasRemovedChildren())
714 continue; 714 continue;
715 715
716 pAcc->ProcessValidate(); 716 pAcc->ProcessValidate();
717 } 717 }
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 } 791 }
792 pAcc->InsertItem(wsLabel, wsValue); 792 pAcc->InsertItem(wsLabel, wsValue);
793 } 793 }
794 } 794 }
795 m_BindItems.RemoveAll(); 795 m_BindItems.RemoveAll();
796 } 796 }
797 void CXFA_FFDocView::SetChangeMark() { 797 void CXFA_FFDocView::SetChangeMark() {
798 if (m_iStatus < XFA_DOCVIEW_LAYOUTSTATUS_End) { 798 if (m_iStatus < XFA_DOCVIEW_LAYOUTSTATUS_End) {
799 return; 799 return;
800 } 800 }
801 m_pDoc->GetDocProvider()->SetChangeMark(m_pDoc); 801 m_pDoc->GetDocEnvironment()->SetChangeMark(m_pDoc);
802 } 802 }
803 CXFA_Node* CXFA_FFDocView::GetRootSubform() { 803 CXFA_Node* CXFA_FFDocView::GetRootSubform() {
804 CXFA_Node* pFormPacketNode = 804 CXFA_Node* pFormPacketNode =
805 ToNode(m_pDoc->GetXFADoc()->GetXFAObject(XFA_HASHCODE_Form)); 805 ToNode(m_pDoc->GetXFADoc()->GetXFAObject(XFA_HASHCODE_Form));
806 if (!pFormPacketNode) { 806 if (!pFormPacketNode) {
807 return nullptr; 807 return nullptr;
808 } 808 }
809 return pFormPacketNode->GetFirstChildByClass(XFA_Element::Subform); 809 return pFormPacketNode->GetFirstChildByClass(XFA_Element::Subform);
810 } 810 }
811 811
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
850 } 850 }
851 851
852 FX_BOOL CXFA_WidgetAccIterator::SetCurrentWidgetAcc(CXFA_WidgetAcc* hWidget) { 852 FX_BOOL CXFA_WidgetAccIterator::SetCurrentWidgetAcc(CXFA_WidgetAcc* hWidget) {
853 return FALSE; 853 return FALSE;
854 } 854 }
855 855
856 void CXFA_WidgetAccIterator::SkipTree() { 856 void CXFA_WidgetAccIterator::SkipTree() {
857 m_ContentIterator.SkipChildrenAndMoveToNext(); 857 m_ContentIterator.SkipChildrenAndMoveToNext();
858 m_pCurWidgetAcc = nullptr; 858 m_pCurWidgetAcc = nullptr;
859 } 859 }
OLDNEW
« no previous file with comments | « xfa/fxfa/app/xfa_ffdoc.cpp ('k') | xfa/fxfa/app/xfa_fffield.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698