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

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

Issue 1890563003: Simplify XFA event handling. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: Events / params ignored by CPDFXFA_Document::WidgetEvent(). Created 4 years, 8 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/app/xfa_ffnotify.h" 7 #include "xfa/fxfa/app/xfa_ffnotify.h"
8 8
9 #include "xfa/fxfa/app/xfa_ffbarcode.h" 9 #include "xfa/fxfa/app/xfa_ffbarcode.h"
10 #include "xfa/fxfa/app/xfa_ffcheckbutton.h" 10 #include "xfa/fxfa/app/xfa_ffcheckbutton.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 switch (dwEvent) { 81 switch (dwEvent) {
82 case XFA_WIDGETEVENT_ListItemAdded: { 82 case XFA_WIDGETEVENT_ListItemAdded: {
83 if (pWidgetAcc->GetUIType() != XFA_ELEMENT_ChoiceList) { 83 if (pWidgetAcc->GetUIType() != XFA_ELEMENT_ChoiceList) {
84 return; 84 return;
85 } 85 }
86 FX_BOOL bStaticNotify = pWidgetAcc->GetDocView()->IsStaticNotify(); 86 FX_BOOL bStaticNotify = pWidgetAcc->GetDocView()->IsStaticNotify();
87 CXFA_FFWidget* pWidget = pWidgetAcc->GetNextWidget(NULL); 87 CXFA_FFWidget* pWidget = pWidgetAcc->GetNextWidget(NULL);
88 if (!pWidget) { 88 if (!pWidget) {
89 if (bStaticNotify) { 89 if (bStaticNotify) {
90 pWidgetAcc->GetDoc()->GetDocProvider()->WidgetEvent( 90 pWidgetAcc->GetDoc()->GetDocProvider()->WidgetEvent(
91 pWidget, pWidgetAcc, XFA_WIDGETEVENT_ListItemAdded, pParam, 91 pWidget, pWidgetAcc, XFA_WIDGETEVENT_ListItemAdded);
92 pAdditional);
93 } 92 }
94 return; 93 return;
95 } 94 }
96 while (pWidget) { 95 while (pWidget) {
97 if (pWidget->IsLoaded()) { 96 if (pWidget->IsLoaded()) {
98 if (pWidgetAcc->IsListBox()) { 97 if (pWidgetAcc->IsListBox()) {
99 static_cast<CXFA_FFListBox*>(pWidget) 98 static_cast<CXFA_FFListBox*>(pWidget)
100 ->InsertItem((const CFX_WideStringC&)(const FX_WCHAR*)pParam, 99 ->InsertItem((const CFX_WideStringC&)(const FX_WCHAR*)pParam,
101 (int32_t)(uintptr_t)pAdditional2); 100 (int32_t)(uintptr_t)pAdditional2);
102 } else { 101 } else {
103 static_cast<CXFA_FFComboBox*>(pWidget) 102 static_cast<CXFA_FFComboBox*>(pWidget)
104 ->InsertItem((const CFX_WideStringC&)(const FX_WCHAR*)pParam, 103 ->InsertItem((const CFX_WideStringC&)(const FX_WCHAR*)pParam,
105 (int32_t)(uintptr_t)pAdditional2); 104 (int32_t)(uintptr_t)pAdditional2);
106 } 105 }
107 } 106 }
108 if (bStaticNotify) { 107 if (bStaticNotify) {
109 pWidgetAcc->GetDoc()->GetDocProvider()->WidgetEvent( 108 pWidgetAcc->GetDoc()->GetDocProvider()->WidgetEvent(
110 pWidget, pWidgetAcc, XFA_WIDGETEVENT_ListItemAdded, pParam, 109 pWidget, pWidgetAcc, XFA_WIDGETEVENT_ListItemAdded);
111 pAdditional);
112 } 110 }
113 pWidget = pWidgetAcc->GetNextWidget(pWidget); 111 pWidget = pWidgetAcc->GetNextWidget(pWidget);
114 } 112 }
115 } break; 113 } break;
116 case XFA_WIDGETEVENT_ListItemRemoved: { 114 case XFA_WIDGETEVENT_ListItemRemoved: {
117 if (pWidgetAcc->GetUIType() != XFA_ELEMENT_ChoiceList) { 115 if (pWidgetAcc->GetUIType() != XFA_ELEMENT_ChoiceList) {
118 return; 116 return;
119 } 117 }
120 FX_BOOL bStaticNotify = pWidgetAcc->GetDocView()->IsStaticNotify(); 118 FX_BOOL bStaticNotify = pWidgetAcc->GetDocView()->IsStaticNotify();
121 CXFA_FFWidget* pWidget = pWidgetAcc->GetNextWidget(NULL); 119 CXFA_FFWidget* pWidget = pWidgetAcc->GetNextWidget(NULL);
122 if (!pWidget) { 120 if (!pWidget) {
123 if (bStaticNotify) { 121 if (bStaticNotify) {
124 pWidgetAcc->GetDoc()->GetDocProvider()->WidgetEvent( 122 pWidgetAcc->GetDoc()->GetDocProvider()->WidgetEvent(
125 pWidget, pWidgetAcc, XFA_WIDGETEVENT_ListItemRemoved, pParam, 123 pWidget, pWidgetAcc, XFA_WIDGETEVENT_ListItemRemoved);
126 pAdditional);
127 } 124 }
128 return; 125 return;
129 } 126 }
130 while (pWidget) { 127 while (pWidget) {
131 if (pWidget->IsLoaded()) { 128 if (pWidget->IsLoaded()) {
132 if (pWidgetAcc->IsListBox()) { 129 if (pWidgetAcc->IsListBox()) {
133 static_cast<CXFA_FFListBox*>(pWidget) 130 static_cast<CXFA_FFListBox*>(pWidget)
134 ->DeleteItem((int32_t)(uintptr_t)pParam); 131 ->DeleteItem((int32_t)(uintptr_t)pParam);
135 } else { 132 } else {
136 static_cast<CXFA_FFComboBox*>(pWidget) 133 static_cast<CXFA_FFComboBox*>(pWidget)
137 ->DeleteItem((int32_t)(uintptr_t)pParam); 134 ->DeleteItem((int32_t)(uintptr_t)pParam);
138 } 135 }
139 } 136 }
140 if (bStaticNotify) { 137 if (bStaticNotify) {
141 pWidgetAcc->GetDoc()->GetDocProvider()->WidgetEvent( 138 pWidgetAcc->GetDoc()->GetDocProvider()->WidgetEvent(
142 pWidget, pWidgetAcc, XFA_WIDGETEVENT_ListItemRemoved, pParam, 139 pWidget, pWidgetAcc, XFA_WIDGETEVENT_ListItemRemoved);
143 pAdditional);
144 } 140 }
145 pWidget = pWidgetAcc->GetNextWidget(pWidget); 141 pWidget = pWidgetAcc->GetNextWidget(pWidget);
146 } 142 }
147 } break; 143 } break;
148 } 144 }
149 } 145 }
150 CXFA_LayoutItem* CXFA_FFNotify::OnCreateLayoutItem(CXFA_Node* pNode) { 146 CXFA_LayoutItem* CXFA_FFNotify::OnCreateLayoutItem(CXFA_Node* pNode) {
151 CXFA_LayoutProcessor* pLayout = m_pDoc->GetXFADoc()->GetDocLayout(); 147 CXFA_LayoutProcessor* pLayout = m_pDoc->GetXFADoc()->GetDocLayout();
152 CXFA_FFDocView* pDocView = m_pDoc->GetDocView(pLayout); 148 CXFA_FFDocView* pDocView = m_pDoc->GetDocView(pLayout);
153 XFA_ELEMENT eType = pNode->GetClassID(); 149 XFA_ELEMENT eType = pNode->GetClassID();
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 bUpdateProperty = TRUE; 483 bUpdateProperty = TRUE;
488 break; 484 break;
489 case XFA_ELEMENT_Font: 485 case XFA_ELEMENT_Font:
490 case XFA_ELEMENT_Margin: 486 case XFA_ELEMENT_Margin:
491 case XFA_ELEMENT_Value: 487 case XFA_ELEMENT_Value:
492 case XFA_ELEMENT_Items: 488 case XFA_ELEMENT_Items:
493 break; 489 break;
494 default: 490 default:
495 break; 491 break;
496 } 492 }
497 if (bIsContainerNode && eAttr == XFA_ATTRIBUTE_Access) { 493 if (bIsContainerNode && eAttr == XFA_ATTRIBUTE_Access)
498 bUpdateProperty = TRUE; 494 bUpdateProperty = TRUE;
499 FX_BOOL bNotify = pDocView->IsStaticNotify(); 495
500 if (bNotify) {
501 pWidgetAcc->NotifyEvent(XFA_WIDGETEVENT_AccessChanged, NULL, pParam2,
502 NULL);
503 }
504 }
505 if (eAttr == XFA_ATTRIBUTE_Value) { 496 if (eAttr == XFA_ATTRIBUTE_Value) {
506 pDocView->AddCalculateNodeNotify(pSender); 497 pDocView->AddCalculateNodeNotify(pSender);
507 if (ePType == XFA_ELEMENT_Value || bIsContainerNode) { 498 if (ePType == XFA_ELEMENT_Value || bIsContainerNode) {
508 FX_BOOL bNotify = pDocView->IsStaticNotify();
509 if (bIsContainerNode) { 499 if (bIsContainerNode) {
510 pWidgetAcc->UpdateUIDisplay(); 500 pWidgetAcc->UpdateUIDisplay();
511 pDocView->AddCalculateWidgetAcc(pWidgetAcc); 501 pDocView->AddCalculateWidgetAcc(pWidgetAcc);
512 pDocView->AddValidateWidget(pWidgetAcc); 502 pDocView->AddValidateWidget(pWidgetAcc);
513 } else if (pWidgetNode->GetNodeItem(XFA_NODEITEM_Parent) 503 } else if (pWidgetNode->GetNodeItem(XFA_NODEITEM_Parent)
514 ->GetClassID() == XFA_ELEMENT_ExclGroup) { 504 ->GetClassID() == XFA_ELEMENT_ExclGroup) {
515 pWidgetAcc->UpdateUIDisplay(); 505 pWidgetAcc->UpdateUIDisplay();
516 } 506 }
517 if (bNotify) {
518 pWidgetAcc->NotifyEvent(XFA_WIDGETEVENT_PostContentChanged, NULL,
519 NULL, NULL);
520 }
521 return; 507 return;
522 } 508 }
523 } 509 }
524 CXFA_FFWidget* pWidget = NULL; 510 CXFA_FFWidget* pWidget = NULL;
525 while ((pWidget = pWidgetAcc->GetNextWidget(pWidget))) { 511 while ((pWidget = pWidgetAcc->GetNextWidget(pWidget))) {
526 if (!pWidget->IsLoaded()) { 512 if (!pWidget->IsLoaded()) {
527 continue; 513 continue;
528 } 514 }
529 if (bUpdateProperty) { 515 if (bUpdateProperty) {
530 pWidget->UpdateWidgetProperty(); 516 pWidget->UpdateWidgetProperty();
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 uint32_t dwStatus = (uint32_t)(uintptr_t)pParam2; 564 uint32_t dwStatus = (uint32_t)(uintptr_t)pParam2;
579 uint32_t dwFilter = XFA_WIDGETSTATUS_Visible | XFA_WIDGETSTATUS_Viewable | 565 uint32_t dwFilter = XFA_WIDGETSTATUS_Visible | XFA_WIDGETSTATUS_Viewable |
580 XFA_WIDGETSTATUS_Printable; 566 XFA_WIDGETSTATUS_Printable;
581 pWidget->ModifyStatus(dwStatus, dwFilter); 567 pWidget->ModifyStatus(dwStatus, dwFilter);
582 CXFA_FFPageView* pPrePageView = pWidget->GetPageView(); 568 CXFA_FFPageView* pPrePageView = pWidget->GetPageView();
583 if (pPrePageView != pNewPageView || 569 if (pPrePageView != pNewPageView ||
584 (dwStatus & (XFA_WIDGETSTATUS_Visible | XFA_WIDGETSTATUS_Viewable)) == 570 (dwStatus & (XFA_WIDGETSTATUS_Visible | XFA_WIDGETSTATUS_Viewable)) ==
585 (XFA_WIDGETSTATUS_Visible | XFA_WIDGETSTATUS_Viewable)) { 571 (XFA_WIDGETSTATUS_Visible | XFA_WIDGETSTATUS_Viewable)) {
586 pWidget->SetPageView(pNewPageView); 572 pWidget->SetPageView(pNewPageView);
587 m_pDoc->GetDocProvider()->WidgetEvent(pWidget, pWidget->GetDataAcc(), 573 m_pDoc->GetDocProvider()->WidgetEvent(pWidget, pWidget->GetDataAcc(),
588 XFA_WIDGETEVENT_PostAdded, 574 XFA_WIDGETEVENT_PostAdded);
589 pNewPageView, pPrePageView);
590 } 575 }
591 if (pDocView->GetLayoutStatus() != XFA_DOCVIEW_LAYOUTSTATUS_End || 576 if (pDocView->GetLayoutStatus() != XFA_DOCVIEW_LAYOUTSTATUS_End ||
592 !(dwStatus & XFA_WIDGETSTATUS_Visible)) { 577 !(dwStatus & XFA_WIDGETSTATUS_Visible)) {
593 return; 578 return;
594 } 579 }
595 if (pWidget->IsLoaded()) { 580 if (pWidget->IsLoaded()) {
596 CFX_RectF rtOld; 581 CFX_RectF rtOld;
597 pWidget->GetWidgetRect(rtOld); 582 pWidget->GetWidgetRect(rtOld);
598 if (rtOld != pWidget->ReCacheWidgetRect()) 583 if (rtOld != pWidget->ReCacheWidgetRect())
599 pWidget->PerformLayout(); 584 pWidget->PerformLayout();
600 } else { 585 } else {
601 pWidget->LoadWidget(); 586 pWidget->LoadWidget();
602 } 587 }
603 pWidget->AddInvalidateRect(nullptr); 588 pWidget->AddInvalidateRect(nullptr);
604 } 589 }
605 void CXFA_FFNotify::OnLayoutItemRemoving(CXFA_FFDocView* pDocView, 590 void CXFA_FFNotify::OnLayoutItemRemoving(CXFA_FFDocView* pDocView,
606 CXFA_LayoutProcessor* pLayout, 591 CXFA_LayoutProcessor* pLayout,
607 CXFA_LayoutItem* pSender, 592 CXFA_LayoutItem* pSender,
608 void* pParam, 593 void* pParam,
609 void* pParam2) { 594 void* pParam2) {
610 CXFA_FFWidget* pWidget = static_cast<CXFA_FFWidget*>(pSender); 595 CXFA_FFWidget* pWidget = static_cast<CXFA_FFWidget*>(pSender);
611 pDocView->DeleteLayoutItem(pWidget); 596 pDocView->DeleteLayoutItem(pWidget);
612 m_pDoc->GetDocProvider()->WidgetEvent(pWidget, pWidget->GetDataAcc(), 597 m_pDoc->GetDocProvider()->WidgetEvent(pWidget, pWidget->GetDataAcc(),
613 XFA_WIDGETEVENT_PreRemoved, nullptr, 598 XFA_WIDGETEVENT_PreRemoved);
614 pWidget->GetPageView());
615 pWidget->AddInvalidateRect(nullptr); 599 pWidget->AddInvalidateRect(nullptr);
616 } 600 }
617 void CXFA_FFNotify::OnLayoutItemRectChanged(CXFA_FFDocView* pDocView, 601 void CXFA_FFNotify::OnLayoutItemRectChanged(CXFA_FFDocView* pDocView,
618 CXFA_LayoutProcessor* pLayout, 602 CXFA_LayoutProcessor* pLayout,
619 CXFA_LayoutItem* pSender, 603 CXFA_LayoutItem* pSender,
620 void* pParam, 604 void* pParam,
621 void* pParam2) {} 605 void* pParam2) {}
622 void CXFA_FFNotify::OnLayoutItemStatustChanged(CXFA_FFDocView* pDocView, 606 void CXFA_FFNotify::OnLayoutItemStatustChanged(CXFA_FFDocView* pDocView,
623 CXFA_LayoutProcessor* pLayout, 607 CXFA_LayoutProcessor* pLayout,
624 CXFA_LayoutItem* pSender, 608 CXFA_LayoutItem* pSender,
(...skipping 14 matching lines...) Expand all
639 } 623 }
640 } 624 }
641 uint32_t dwOldStatus = pWidget->GetStatus(); 625 uint32_t dwOldStatus = pWidget->GetStatus();
642 uint32_t dwFilter = XFA_WIDGETSTATUS_Visible | XFA_WIDGETSTATUS_Viewable | 626 uint32_t dwFilter = XFA_WIDGETSTATUS_Visible | XFA_WIDGETSTATUS_Viewable |
643 XFA_WIDGETSTATUS_Printable; 627 XFA_WIDGETSTATUS_Printable;
644 if ((dwOldStatus & dwFilter) == dwStatus) { 628 if ((dwOldStatus & dwFilter) == dwStatus) {
645 return; 629 return;
646 } 630 }
647 pWidget->ModifyStatus(dwStatus, dwFilter); 631 pWidget->ModifyStatus(dwStatus, dwFilter);
648 } 632 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698