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/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 Loading... |
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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 void* pParam2) { | 236 void* pParam2) { |
241 CXFA_FFDocView* pDocView = m_pDoc->GetDocView(pLayout); | 237 CXFA_FFDocView* pDocView = m_pDoc->GetDocView(pLayout); |
242 if (!pDocView || !XFA_GetWidgetFromLayoutItem(pSender)) { | 238 if (!pDocView || !XFA_GetWidgetFromLayoutItem(pSender)) { |
243 return; | 239 return; |
244 } | 240 } |
245 switch (eEvent) { | 241 switch (eEvent) { |
246 case XFA_LAYOUTEVENT_ItemAdded: | 242 case XFA_LAYOUTEVENT_ItemAdded: |
247 OnLayoutItemAdd(pDocView, pLayout, pSender, pParam, pParam2); | 243 OnLayoutItemAdd(pDocView, pLayout, pSender, pParam, pParam2); |
248 break; | 244 break; |
249 case XFA_LAYOUTEVENT_ItemRemoving: | 245 case XFA_LAYOUTEVENT_ItemRemoving: |
250 OnLayoutItemRemoving(pDocView, pLayout, pSender, pParam, pParam2); | 246 OnLayoutItemRemoving(pDocView, pLayout, pSender); |
251 break; | |
252 case XFA_LAYOUTEVENT_RectChanged: | |
253 OnLayoutItemRectChanged(pDocView, pLayout, pSender, pParam, pParam2); | |
254 break; | |
255 case XFA_LAYOUTEVENT_StatusChanged: | |
256 OnLayoutItemStatustChanged(pDocView, pLayout, pSender, pParam, pParam2); | |
257 break; | 247 break; |
258 } | 248 } |
259 } | 249 } |
260 void CXFA_FFNotify::StartFieldDrawLayout(CXFA_Node* pItem, | 250 void CXFA_FFNotify::StartFieldDrawLayout(CXFA_Node* pItem, |
261 FX_FLOAT& fCalcWidth, | 251 FX_FLOAT& fCalcWidth, |
262 FX_FLOAT& fCalcHeight) { | 252 FX_FLOAT& fCalcHeight) { |
263 CXFA_WidgetAcc* pAcc = static_cast<CXFA_WidgetAcc*>(pItem->GetWidgetData()); | 253 CXFA_WidgetAcc* pAcc = static_cast<CXFA_WidgetAcc*>(pItem->GetWidgetData()); |
264 if (!pAcc) { | 254 if (!pAcc) { |
265 return; | 255 return; |
266 } | 256 } |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 bUpdateProperty = TRUE; | 477 bUpdateProperty = TRUE; |
488 break; | 478 break; |
489 case XFA_ELEMENT_Font: | 479 case XFA_ELEMENT_Font: |
490 case XFA_ELEMENT_Margin: | 480 case XFA_ELEMENT_Margin: |
491 case XFA_ELEMENT_Value: | 481 case XFA_ELEMENT_Value: |
492 case XFA_ELEMENT_Items: | 482 case XFA_ELEMENT_Items: |
493 break; | 483 break; |
494 default: | 484 default: |
495 break; | 485 break; |
496 } | 486 } |
497 if (bIsContainerNode && eAttr == XFA_ATTRIBUTE_Access) { | 487 if (bIsContainerNode && eAttr == XFA_ATTRIBUTE_Access) |
498 bUpdateProperty = TRUE; | 488 bUpdateProperty = TRUE; |
499 FX_BOOL bNotify = pDocView->IsStaticNotify(); | 489 |
500 if (bNotify) { | |
501 pWidgetAcc->NotifyEvent(XFA_WIDGETEVENT_AccessChanged, NULL, pParam2, | |
502 NULL); | |
503 } | |
504 } | |
505 if (eAttr == XFA_ATTRIBUTE_Value) { | 490 if (eAttr == XFA_ATTRIBUTE_Value) { |
506 pDocView->AddCalculateNodeNotify(pSender); | 491 pDocView->AddCalculateNodeNotify(pSender); |
507 if (ePType == XFA_ELEMENT_Value || bIsContainerNode) { | 492 if (ePType == XFA_ELEMENT_Value || bIsContainerNode) { |
508 FX_BOOL bNotify = pDocView->IsStaticNotify(); | |
509 if (bIsContainerNode) { | 493 if (bIsContainerNode) { |
510 pWidgetAcc->UpdateUIDisplay(); | 494 pWidgetAcc->UpdateUIDisplay(); |
511 pDocView->AddCalculateWidgetAcc(pWidgetAcc); | 495 pDocView->AddCalculateWidgetAcc(pWidgetAcc); |
512 pDocView->AddValidateWidget(pWidgetAcc); | 496 pDocView->AddValidateWidget(pWidgetAcc); |
513 } else if (pWidgetNode->GetNodeItem(XFA_NODEITEM_Parent) | 497 } else if (pWidgetNode->GetNodeItem(XFA_NODEITEM_Parent) |
514 ->GetClassID() == XFA_ELEMENT_ExclGroup) { | 498 ->GetClassID() == XFA_ELEMENT_ExclGroup) { |
515 pWidgetAcc->UpdateUIDisplay(); | 499 pWidgetAcc->UpdateUIDisplay(); |
516 } | 500 } |
517 if (bNotify) { | |
518 pWidgetAcc->NotifyEvent(XFA_WIDGETEVENT_PostContentChanged, NULL, | |
519 NULL, NULL); | |
520 } | |
521 return; | 501 return; |
522 } | 502 } |
523 } | 503 } |
524 CXFA_FFWidget* pWidget = NULL; | 504 CXFA_FFWidget* pWidget = NULL; |
525 while ((pWidget = pWidgetAcc->GetNextWidget(pWidget))) { | 505 while ((pWidget = pWidgetAcc->GetNextWidget(pWidget))) { |
526 if (!pWidget->IsLoaded()) { | 506 if (!pWidget->IsLoaded()) { |
527 continue; | 507 continue; |
528 } | 508 } |
529 if (bUpdateProperty) { | 509 if (bUpdateProperty) { |
530 pWidget->UpdateWidgetProperty(); | 510 pWidget->UpdateWidgetProperty(); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
578 uint32_t dwStatus = (uint32_t)(uintptr_t)pParam2; | 558 uint32_t dwStatus = (uint32_t)(uintptr_t)pParam2; |
579 uint32_t dwFilter = XFA_WIDGETSTATUS_Visible | XFA_WIDGETSTATUS_Viewable | | 559 uint32_t dwFilter = XFA_WIDGETSTATUS_Visible | XFA_WIDGETSTATUS_Viewable | |
580 XFA_WIDGETSTATUS_Printable; | 560 XFA_WIDGETSTATUS_Printable; |
581 pWidget->ModifyStatus(dwStatus, dwFilter); | 561 pWidget->ModifyStatus(dwStatus, dwFilter); |
582 CXFA_FFPageView* pPrePageView = pWidget->GetPageView(); | 562 CXFA_FFPageView* pPrePageView = pWidget->GetPageView(); |
583 if (pPrePageView != pNewPageView || | 563 if (pPrePageView != pNewPageView || |
584 (dwStatus & (XFA_WIDGETSTATUS_Visible | XFA_WIDGETSTATUS_Viewable)) == | 564 (dwStatus & (XFA_WIDGETSTATUS_Visible | XFA_WIDGETSTATUS_Viewable)) == |
585 (XFA_WIDGETSTATUS_Visible | XFA_WIDGETSTATUS_Viewable)) { | 565 (XFA_WIDGETSTATUS_Visible | XFA_WIDGETSTATUS_Viewable)) { |
586 pWidget->SetPageView(pNewPageView); | 566 pWidget->SetPageView(pNewPageView); |
587 m_pDoc->GetDocProvider()->WidgetEvent(pWidget, pWidget->GetDataAcc(), | 567 m_pDoc->GetDocProvider()->WidgetEvent(pWidget, pWidget->GetDataAcc(), |
588 XFA_WIDGETEVENT_PostAdded, | 568 XFA_WIDGETEVENT_PostAdded); |
589 pNewPageView, pPrePageView); | |
590 } | 569 } |
591 if (pDocView->GetLayoutStatus() != XFA_DOCVIEW_LAYOUTSTATUS_End || | 570 if (pDocView->GetLayoutStatus() != XFA_DOCVIEW_LAYOUTSTATUS_End || |
592 !(dwStatus & XFA_WIDGETSTATUS_Visible)) { | 571 !(dwStatus & XFA_WIDGETSTATUS_Visible)) { |
593 return; | 572 return; |
594 } | 573 } |
595 if (pWidget->IsLoaded()) { | 574 if (pWidget->IsLoaded()) { |
596 CFX_RectF rtOld; | 575 CFX_RectF rtOld; |
597 pWidget->GetWidgetRect(rtOld); | 576 pWidget->GetWidgetRect(rtOld); |
598 if (rtOld != pWidget->ReCacheWidgetRect()) | 577 if (rtOld != pWidget->ReCacheWidgetRect()) |
599 pWidget->PerformLayout(); | 578 pWidget->PerformLayout(); |
600 } else { | 579 } else { |
601 pWidget->LoadWidget(); | 580 pWidget->LoadWidget(); |
602 } | 581 } |
603 pWidget->AddInvalidateRect(nullptr); | 582 pWidget->AddInvalidateRect(nullptr); |
604 } | 583 } |
605 void CXFA_FFNotify::OnLayoutItemRemoving(CXFA_FFDocView* pDocView, | 584 void CXFA_FFNotify::OnLayoutItemRemoving(CXFA_FFDocView* pDocView, |
606 CXFA_LayoutProcessor* pLayout, | 585 CXFA_LayoutProcessor* pLayout, |
607 CXFA_LayoutItem* pSender, | 586 CXFA_LayoutItem* pSender) { |
608 void* pParam, | |
609 void* pParam2) { | |
610 CXFA_FFWidget* pWidget = static_cast<CXFA_FFWidget*>(pSender); | 587 CXFA_FFWidget* pWidget = static_cast<CXFA_FFWidget*>(pSender); |
611 pDocView->DeleteLayoutItem(pWidget); | 588 pDocView->DeleteLayoutItem(pWidget); |
612 m_pDoc->GetDocProvider()->WidgetEvent(pWidget, pWidget->GetDataAcc(), | 589 m_pDoc->GetDocProvider()->WidgetEvent(pWidget, pWidget->GetDataAcc(), |
613 XFA_WIDGETEVENT_PreRemoved, nullptr, | 590 XFA_WIDGETEVENT_PreRemoved); |
614 pWidget->GetPageView()); | |
615 pWidget->AddInvalidateRect(nullptr); | 591 pWidget->AddInvalidateRect(nullptr); |
616 } | 592 } |
617 void CXFA_FFNotify::OnLayoutItemRectChanged(CXFA_FFDocView* pDocView, | |
618 CXFA_LayoutProcessor* pLayout, | |
619 CXFA_LayoutItem* pSender, | |
620 void* pParam, | |
621 void* pParam2) {} | |
622 void CXFA_FFNotify::OnLayoutItemStatustChanged(CXFA_FFDocView* pDocView, | |
623 CXFA_LayoutProcessor* pLayout, | |
624 CXFA_LayoutItem* pSender, | |
625 void* pParam, | |
626 void* pParam2) { | |
627 CXFA_FFWidget* pWidget = static_cast<CXFA_FFWidget*>(pSender); | |
628 if (!pWidget) { | |
629 return; | |
630 } | |
631 uint32_t dwStatus = (uint32_t)(uintptr_t)pParam; | |
632 if (dwStatus == 0) { | |
633 CXFA_LayoutItem* pPreItem = pSender->GetPrev(); | |
634 if (pPreItem) { | |
635 CXFA_FFWidget* pPreWidget = static_cast<CXFA_FFWidget*>(pPreItem); | |
636 if (pPreWidget) { | |
637 dwStatus = pPreWidget->GetStatus(); | |
638 } | |
639 } | |
640 } | |
641 uint32_t dwOldStatus = pWidget->GetStatus(); | |
642 uint32_t dwFilter = XFA_WIDGETSTATUS_Visible | XFA_WIDGETSTATUS_Viewable | | |
643 XFA_WIDGETSTATUS_Printable; | |
644 if ((dwOldStatus & dwFilter) == dwStatus) { | |
645 return; | |
646 } | |
647 pWidget->ModifyStatus(dwStatus, dwFilter); | |
648 } | |
OLD | NEW |