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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 default: | 222 default: |
227 pWidget = NULL; | 223 pWidget = NULL; |
228 break; | 224 break; |
229 } | 225 } |
230 if (!pWidget) { | 226 if (!pWidget) { |
231 return NULL; | 227 return NULL; |
232 } | 228 } |
233 pWidget->SetDocView(pDocView); | 229 pWidget->SetDocView(pDocView); |
234 return pWidget; | 230 return pWidget; |
235 } | 231 } |
236 void CXFA_FFNotify::OnLayoutEvent(CXFA_LayoutProcessor* pLayout, | 232 |
237 CXFA_LayoutItem* pSender, | |
238 XFA_LAYOUTEVENT eEvent, | |
239 void* pParam, | |
240 void* pParam2) { | |
241 CXFA_FFDocView* pDocView = m_pDoc->GetDocView(pLayout); | |
242 if (!pDocView || !XFA_GetWidgetFromLayoutItem(pSender)) { | |
243 return; | |
244 } | |
245 switch (eEvent) { | |
246 case XFA_LAYOUTEVENT_ItemAdded: | |
247 OnLayoutItemAdd(pDocView, pLayout, pSender, pParam, pParam2); | |
248 break; | |
249 case XFA_LAYOUTEVENT_ItemRemoving: | |
250 OnLayoutItemRemoving(pDocView, pLayout, pSender, pParam, pParam2); | |
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; | |
258 } | |
259 } | |
260 void CXFA_FFNotify::StartFieldDrawLayout(CXFA_Node* pItem, | 233 void CXFA_FFNotify::StartFieldDrawLayout(CXFA_Node* pItem, |
261 FX_FLOAT& fCalcWidth, | 234 FX_FLOAT& fCalcWidth, |
262 FX_FLOAT& fCalcHeight) { | 235 FX_FLOAT& fCalcHeight) { |
263 CXFA_WidgetAcc* pAcc = static_cast<CXFA_WidgetAcc*>(pItem->GetWidgetData()); | 236 CXFA_WidgetAcc* pAcc = static_cast<CXFA_WidgetAcc*>(pItem->GetWidgetData()); |
264 if (!pAcc) { | 237 if (!pAcc) { |
265 return; | 238 return; |
266 } | 239 } |
267 pAcc->StartWidgetLayout(fCalcWidth, fCalcHeight); | 240 pAcc->StartWidgetLayout(fCalcWidth, fCalcHeight); |
268 } | 241 } |
269 FX_BOOL CXFA_FFNotify::FindSplitPos(CXFA_Node* pItem, | 242 FX_BOOL CXFA_FFNotify::FindSplitPos(CXFA_Node* pItem, |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 bUpdateProperty = TRUE; | 460 bUpdateProperty = TRUE; |
488 break; | 461 break; |
489 case XFA_ELEMENT_Font: | 462 case XFA_ELEMENT_Font: |
490 case XFA_ELEMENT_Margin: | 463 case XFA_ELEMENT_Margin: |
491 case XFA_ELEMENT_Value: | 464 case XFA_ELEMENT_Value: |
492 case XFA_ELEMENT_Items: | 465 case XFA_ELEMENT_Items: |
493 break; | 466 break; |
494 default: | 467 default: |
495 break; | 468 break; |
496 } | 469 } |
497 if (bIsContainerNode && eAttr == XFA_ATTRIBUTE_Access) { | 470 if (bIsContainerNode && eAttr == XFA_ATTRIBUTE_Access) |
498 bUpdateProperty = TRUE; | 471 bUpdateProperty = TRUE; |
499 FX_BOOL bNotify = pDocView->IsStaticNotify(); | 472 |
500 if (bNotify) { | |
501 pWidgetAcc->NotifyEvent(XFA_WIDGETEVENT_AccessChanged, NULL, pParam2, | |
502 NULL); | |
503 } | |
504 } | |
505 if (eAttr == XFA_ATTRIBUTE_Value) { | 473 if (eAttr == XFA_ATTRIBUTE_Value) { |
506 pDocView->AddCalculateNodeNotify(pSender); | 474 pDocView->AddCalculateNodeNotify(pSender); |
507 if (ePType == XFA_ELEMENT_Value || bIsContainerNode) { | 475 if (ePType == XFA_ELEMENT_Value || bIsContainerNode) { |
508 FX_BOOL bNotify = pDocView->IsStaticNotify(); | |
509 if (bIsContainerNode) { | 476 if (bIsContainerNode) { |
510 pWidgetAcc->UpdateUIDisplay(); | 477 pWidgetAcc->UpdateUIDisplay(); |
511 pDocView->AddCalculateWidgetAcc(pWidgetAcc); | 478 pDocView->AddCalculateWidgetAcc(pWidgetAcc); |
512 pDocView->AddValidateWidget(pWidgetAcc); | 479 pDocView->AddValidateWidget(pWidgetAcc); |
513 } else if (pWidgetNode->GetNodeItem(XFA_NODEITEM_Parent) | 480 } else if (pWidgetNode->GetNodeItem(XFA_NODEITEM_Parent) |
514 ->GetClassID() == XFA_ELEMENT_ExclGroup) { | 481 ->GetClassID() == XFA_ELEMENT_ExclGroup) { |
515 pWidgetAcc->UpdateUIDisplay(); | 482 pWidgetAcc->UpdateUIDisplay(); |
516 } | 483 } |
517 if (bNotify) { | |
518 pWidgetAcc->NotifyEvent(XFA_WIDGETEVENT_PostContentChanged, NULL, | |
519 NULL, NULL); | |
520 } | |
521 return; | 484 return; |
522 } | 485 } |
523 } | 486 } |
524 CXFA_FFWidget* pWidget = NULL; | 487 CXFA_FFWidget* pWidget = NULL; |
525 while ((pWidget = pWidgetAcc->GetNextWidget(pWidget))) { | 488 while ((pWidget = pWidgetAcc->GetNextWidget(pWidget))) { |
526 if (!pWidget->IsLoaded()) { | 489 if (!pWidget->IsLoaded()) { |
527 continue; | 490 continue; |
528 } | 491 } |
529 if (bUpdateProperty) { | 492 if (bUpdateProperty) { |
530 pWidget->UpdateWidgetProperty(); | 493 pWidget->UpdateWidgetProperty(); |
(...skipping 29 matching lines...) Expand all Loading... |
560 void* pParam2) { | 523 void* pParam2) { |
561 if (CXFA_FFDocView* pDocView = m_pDoc->GetDocView()) { | 524 if (CXFA_FFDocView* pDocView = m_pDoc->GetDocView()) { |
562 FX_BOOL bLayoutReady = | 525 FX_BOOL bLayoutReady = |
563 !(pDocView->m_bInLayoutStatus) && | 526 !(pDocView->m_bInLayoutStatus) && |
564 (pDocView->GetLayoutStatus() == XFA_DOCVIEW_LAYOUTSTATUS_End); | 527 (pDocView->GetLayoutStatus() == XFA_DOCVIEW_LAYOUTSTATUS_End); |
565 if (bLayoutReady) { | 528 if (bLayoutReady) { |
566 m_pDoc->GetDocProvider()->SetChangeMark(m_pDoc); | 529 m_pDoc->GetDocProvider()->SetChangeMark(m_pDoc); |
567 } | 530 } |
568 } | 531 } |
569 } | 532 } |
570 void CXFA_FFNotify::OnLayoutItemAdd(CXFA_FFDocView* pDocView, | 533 void CXFA_FFNotify::OnLayoutItemAdd(CXFA_LayoutProcessor* pLayout, |
571 CXFA_LayoutProcessor* pLayout, | |
572 CXFA_LayoutItem* pSender, | 534 CXFA_LayoutItem* pSender, |
573 void* pParam, | 535 int32_t iPageIdx, |
574 void* pParam2) { | 536 uint32_t dwStatus) { |
575 CXFA_FFWidget* pWidget = static_cast<CXFA_FFWidget*>(pSender); | 537 CXFA_FFDocView* pDocView = m_pDoc->GetDocView(pLayout); |
576 int32_t iPageIdx = (int32_t)(uintptr_t)pParam; | 538 if (!pDocView) |
| 539 return; |
| 540 |
| 541 CXFA_FFWidget* pWidget = XFA_GetWidgetFromLayoutItem(pSender); |
| 542 if (!pWidget) |
| 543 return; |
| 544 |
577 CXFA_FFPageView* pNewPageView = pDocView->GetPageView(iPageIdx); | 545 CXFA_FFPageView* pNewPageView = pDocView->GetPageView(iPageIdx); |
578 uint32_t dwStatus = (uint32_t)(uintptr_t)pParam2; | |
579 uint32_t dwFilter = XFA_WIDGETSTATUS_Visible | XFA_WIDGETSTATUS_Viewable | | 546 uint32_t dwFilter = XFA_WIDGETSTATUS_Visible | XFA_WIDGETSTATUS_Viewable | |
580 XFA_WIDGETSTATUS_Printable; | 547 XFA_WIDGETSTATUS_Printable; |
581 pWidget->ModifyStatus(dwStatus, dwFilter); | 548 pWidget->ModifyStatus(dwStatus, dwFilter); |
582 CXFA_FFPageView* pPrePageView = pWidget->GetPageView(); | 549 CXFA_FFPageView* pPrePageView = pWidget->GetPageView(); |
583 if (pPrePageView != pNewPageView || | 550 if (pPrePageView != pNewPageView || |
584 (dwStatus & (XFA_WIDGETSTATUS_Visible | XFA_WIDGETSTATUS_Viewable)) == | 551 (dwStatus & (XFA_WIDGETSTATUS_Visible | XFA_WIDGETSTATUS_Viewable)) == |
585 (XFA_WIDGETSTATUS_Visible | XFA_WIDGETSTATUS_Viewable)) { | 552 (XFA_WIDGETSTATUS_Visible | XFA_WIDGETSTATUS_Viewable)) { |
586 pWidget->SetPageView(pNewPageView); | 553 pWidget->SetPageView(pNewPageView); |
587 m_pDoc->GetDocProvider()->WidgetEvent(pWidget, pWidget->GetDataAcc(), | 554 m_pDoc->GetDocProvider()->WidgetEvent(pWidget, pWidget->GetDataAcc(), |
588 XFA_WIDGETEVENT_PostAdded, | 555 XFA_WIDGETEVENT_PostAdded); |
589 pNewPageView, pPrePageView); | |
590 } | 556 } |
591 if (pDocView->GetLayoutStatus() != XFA_DOCVIEW_LAYOUTSTATUS_End || | 557 if (pDocView->GetLayoutStatus() != XFA_DOCVIEW_LAYOUTSTATUS_End || |
592 !(dwStatus & XFA_WIDGETSTATUS_Visible)) { | 558 !(dwStatus & XFA_WIDGETSTATUS_Visible)) { |
593 return; | 559 return; |
594 } | 560 } |
595 if (pWidget->IsLoaded()) { | 561 if (pWidget->IsLoaded()) { |
596 CFX_RectF rtOld; | 562 CFX_RectF rtOld; |
597 pWidget->GetWidgetRect(rtOld); | 563 pWidget->GetWidgetRect(rtOld); |
598 if (rtOld != pWidget->ReCacheWidgetRect()) | 564 if (rtOld != pWidget->ReCacheWidgetRect()) |
599 pWidget->PerformLayout(); | 565 pWidget->PerformLayout(); |
600 } else { | 566 } else { |
601 pWidget->LoadWidget(); | 567 pWidget->LoadWidget(); |
602 } | 568 } |
603 pWidget->AddInvalidateRect(nullptr); | 569 pWidget->AddInvalidateRect(nullptr); |
604 } | 570 } |
605 void CXFA_FFNotify::OnLayoutItemRemoving(CXFA_FFDocView* pDocView, | 571 |
606 CXFA_LayoutProcessor* pLayout, | 572 void CXFA_FFNotify::OnLayoutItemRemoving(CXFA_LayoutProcessor* pLayout, |
607 CXFA_LayoutItem* pSender, | 573 CXFA_LayoutItem* pSender) { |
608 void* pParam, | 574 CXFA_FFDocView* pDocView = m_pDoc->GetDocView(pLayout); |
609 void* pParam2) { | 575 if (!pDocView) |
610 CXFA_FFWidget* pWidget = static_cast<CXFA_FFWidget*>(pSender); | 576 return; |
| 577 |
| 578 CXFA_FFWidget* pWidget = XFA_GetWidgetFromLayoutItem(pSender); |
| 579 if (!pWidget) |
| 580 return; |
| 581 |
611 pDocView->DeleteLayoutItem(pWidget); | 582 pDocView->DeleteLayoutItem(pWidget); |
612 m_pDoc->GetDocProvider()->WidgetEvent(pWidget, pWidget->GetDataAcc(), | 583 m_pDoc->GetDocProvider()->WidgetEvent(pWidget, pWidget->GetDataAcc(), |
613 XFA_WIDGETEVENT_PreRemoved, nullptr, | 584 XFA_WIDGETEVENT_PreRemoved); |
614 pWidget->GetPageView()); | |
615 pWidget->AddInvalidateRect(nullptr); | 585 pWidget->AddInvalidateRect(nullptr); |
616 } | 586 } |
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 |