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

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: remove CXFA_FFNotify::OnWidgetDataEvent 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
« no previous file with comments | « xfa/fxfa/app/xfa_ffnotify.h ('k') | xfa/fxfa/app/xfa_ffwidgetacc.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/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 21 matching lines...) Expand all
32 32
33 static void XFA_FFDeleteWidgetAcc(void* pData) { 33 static void XFA_FFDeleteWidgetAcc(void* pData) {
34 delete static_cast<CXFA_WidgetAcc*>(pData); 34 delete static_cast<CXFA_WidgetAcc*>(pData);
35 } 35 }
36 36
37 static XFA_MAPDATABLOCKCALLBACKINFO gs_XFADeleteWidgetAcc = { 37 static XFA_MAPDATABLOCKCALLBACKINFO gs_XFADeleteWidgetAcc = {
38 XFA_FFDeleteWidgetAcc, nullptr}; 38 XFA_FFDeleteWidgetAcc, nullptr};
39 39
40 CXFA_FFNotify::CXFA_FFNotify(CXFA_FFDoc* pDoc) : m_pDoc(pDoc) {} 40 CXFA_FFNotify::CXFA_FFNotify(CXFA_FFDoc* pDoc) : m_pDoc(pDoc) {}
41 CXFA_FFNotify::~CXFA_FFNotify() {} 41 CXFA_FFNotify::~CXFA_FFNotify() {}
42
42 void CXFA_FFNotify::OnPageEvent(CXFA_ContainerLayoutItem* pSender, 43 void CXFA_FFNotify::OnPageEvent(CXFA_ContainerLayoutItem* pSender,
43 XFA_PAGEEVENT eEvent, 44 uint32_t dwEvent) {
44 void* pParam) {
45 CXFA_FFDocView* pDocView = m_pDoc->GetDocView(pSender->GetLayout()); 45 CXFA_FFDocView* pDocView = m_pDoc->GetDocView(pSender->GetLayout());
46 if (!pDocView) { 46 if (pDocView)
47 pDocView->OnPageEvent(pSender, dwEvent);
48 }
49
50 void CXFA_FFNotify::OnWidgetListItemAdded(CXFA_WidgetData* pSender,
51 const FX_WCHAR* pLabel,
52 const FX_WCHAR* pValue,
53 int32_t iIndex) {
54 CXFA_WidgetAcc* pWidgetAcc = static_cast<CXFA_WidgetAcc*>(pSender);
55 if (pWidgetAcc->GetUIType() != XFA_ELEMENT_ChoiceList) {
47 return; 56 return;
48 } 57 }
49 pDocView->OnPageEvent(pSender, eEvent, (int32_t)(uintptr_t)pParam); 58 CXFA_FFWidget* pWidget = pWidgetAcc->GetNextWidget(NULL);
50 } 59 while (pWidget) {
Tom Sepez 2016/04/14 22:45:44 nit: rewrite loop in while ((pWidget = pWidgetAcc-
Lei Zhang 2016/04/15 01:16:40 Done. Same for line 77.
51 void CXFA_FFNotify::OnNodeEvent(CXFA_Node* pSender, 60 if (pWidget->IsLoaded()) {
52 XFA_NODEEVENT eEvent, 61 if (pWidgetAcc->IsListBox()) {
53 void* pParam, 62 static_cast<CXFA_FFListBox*>(pWidget)->InsertItem(pLabel, iIndex);
54 void* pParam2, 63 } else {
55 void* pParam3, 64 static_cast<CXFA_FFComboBox*>(pWidget)->InsertItem(pLabel, iIndex);
56 void* pParam4) { 65 }
57 switch (eEvent) { 66 }
58 case XFA_NODEEVENT_Ready: 67 pWidget = pWidgetAcc->GetNextWidget(pWidget);
59 OnNodeReady(pSender);
60 break;
61 case XFA_NODEEVENT_ValueChanging:
62 OnValueChanging(pSender, pParam, pParam2);
63 break;
64 case XFA_NODEEVENT_ValueChanged:
65 OnValueChanged(pSender, pParam, pParam2, pParam3, pParam4);
66 break;
67 case XFA_NODEEVENT_ChildAdded:
68 OnChildAdded(pSender, pParam, pParam2);
69 break;
70 case XFA_NODEEVENT_ChildRemoved:
71 OnChildRemoved(pSender, pParam, pParam2);
72 break;
73 } 68 }
74 } 69 }
75 void CXFA_FFNotify::OnWidgetDataEvent(CXFA_WidgetData* pSender, 70
76 uint32_t dwEvent, 71 void CXFA_FFNotify::OnWidgetListItemRemoved(CXFA_WidgetData* pSender,
77 void* pParam, 72 int32_t iIndex) {
78 void* pAdditional,
79 void* pAdditional2) {
80 CXFA_WidgetAcc* pWidgetAcc = static_cast<CXFA_WidgetAcc*>(pSender); 73 CXFA_WidgetAcc* pWidgetAcc = static_cast<CXFA_WidgetAcc*>(pSender);
81 switch (dwEvent) { 74 if (pWidgetAcc->GetUIType() != XFA_ELEMENT_ChoiceList) {
82 case XFA_WIDGETEVENT_ListItemAdded: { 75 return;
83 if (pWidgetAcc->GetUIType() != XFA_ELEMENT_ChoiceList) { 76 }
84 return; 77 CXFA_FFWidget* pWidget = pWidgetAcc->GetNextWidget(NULL);
78 while (pWidget) {
79 if (pWidget->IsLoaded()) {
80 if (pWidgetAcc->IsListBox()) {
81 static_cast<CXFA_FFListBox*>(pWidget)->DeleteItem(iIndex);
82 } else {
83 static_cast<CXFA_FFComboBox*>(pWidget)->DeleteItem(iIndex);
85 } 84 }
86 FX_BOOL bStaticNotify = pWidgetAcc->GetDocView()->IsStaticNotify(); 85 }
87 CXFA_FFWidget* pWidget = pWidgetAcc->GetNextWidget(NULL); 86 pWidget = pWidgetAcc->GetNextWidget(pWidget);
88 if (!pWidget) {
89 if (bStaticNotify) {
90 pWidgetAcc->GetDoc()->GetDocProvider()->WidgetEvent(
91 pWidget, pWidgetAcc, XFA_WIDGETEVENT_ListItemAdded, pParam,
92 pAdditional);
93 }
94 return;
95 }
96 while (pWidget) {
97 if (pWidget->IsLoaded()) {
98 if (pWidgetAcc->IsListBox()) {
99 static_cast<CXFA_FFListBox*>(pWidget)
100 ->InsertItem((const CFX_WideStringC&)(const FX_WCHAR*)pParam,
101 (int32_t)(uintptr_t)pAdditional2);
102 } else {
103 static_cast<CXFA_FFComboBox*>(pWidget)
104 ->InsertItem((const CFX_WideStringC&)(const FX_WCHAR*)pParam,
105 (int32_t)(uintptr_t)pAdditional2);
106 }
107 }
108 if (bStaticNotify) {
109 pWidgetAcc->GetDoc()->GetDocProvider()->WidgetEvent(
110 pWidget, pWidgetAcc, XFA_WIDGETEVENT_ListItemAdded, pParam,
111 pAdditional);
112 }
113 pWidget = pWidgetAcc->GetNextWidget(pWidget);
114 }
115 } break;
116 case XFA_WIDGETEVENT_ListItemRemoved: {
117 if (pWidgetAcc->GetUIType() != XFA_ELEMENT_ChoiceList) {
118 return;
119 }
120 FX_BOOL bStaticNotify = pWidgetAcc->GetDocView()->IsStaticNotify();
121 CXFA_FFWidget* pWidget = pWidgetAcc->GetNextWidget(NULL);
122 if (!pWidget) {
123 if (bStaticNotify) {
124 pWidgetAcc->GetDoc()->GetDocProvider()->WidgetEvent(
125 pWidget, pWidgetAcc, XFA_WIDGETEVENT_ListItemRemoved, pParam,
126 pAdditional);
127 }
128 return;
129 }
130 while (pWidget) {
131 if (pWidget->IsLoaded()) {
132 if (pWidgetAcc->IsListBox()) {
133 static_cast<CXFA_FFListBox*>(pWidget)
134 ->DeleteItem((int32_t)(uintptr_t)pParam);
135 } else {
136 static_cast<CXFA_FFComboBox*>(pWidget)
137 ->DeleteItem((int32_t)(uintptr_t)pParam);
138 }
139 }
140 if (bStaticNotify) {
141 pWidgetAcc->GetDoc()->GetDocProvider()->WidgetEvent(
142 pWidget, pWidgetAcc, XFA_WIDGETEVENT_ListItemRemoved, pParam,
143 pAdditional);
144 }
145 pWidget = pWidgetAcc->GetNextWidget(pWidget);
146 }
147 } break;
148 } 87 }
149 } 88 }
89
150 CXFA_LayoutItem* CXFA_FFNotify::OnCreateLayoutItem(CXFA_Node* pNode) { 90 CXFA_LayoutItem* CXFA_FFNotify::OnCreateLayoutItem(CXFA_Node* pNode) {
151 CXFA_LayoutProcessor* pLayout = m_pDoc->GetXFADoc()->GetDocLayout(); 91 CXFA_LayoutProcessor* pLayout = m_pDoc->GetXFADoc()->GetDocLayout();
152 CXFA_FFDocView* pDocView = m_pDoc->GetDocView(pLayout); 92 CXFA_FFDocView* pDocView = m_pDoc->GetDocView(pLayout);
153 XFA_ELEMENT eType = pNode->GetClassID(); 93 XFA_ELEMENT eType = pNode->GetClassID();
154 if (eType == XFA_ELEMENT_PageArea) { 94 if (eType == XFA_ELEMENT_PageArea) {
155 return new CXFA_FFPageView(pDocView, pNode); 95 return new CXFA_FFPageView(pDocView, pNode);
156 } 96 }
157 if (eType == XFA_ELEMENT_ContentArea) { 97 if (eType == XFA_ELEMENT_ContentArea) {
158 return new CXFA_ContainerLayoutItem(pNode); 98 return new CXFA_ContainerLayoutItem(pNode);
159 } 99 }
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 default: 166 default:
227 pWidget = NULL; 167 pWidget = NULL;
228 break; 168 break;
229 } 169 }
230 if (!pWidget) { 170 if (!pWidget) {
231 return NULL; 171 return NULL;
232 } 172 }
233 pWidget->SetDocView(pDocView); 173 pWidget->SetDocView(pDocView);
234 return pWidget; 174 return pWidget;
235 } 175 }
236 void CXFA_FFNotify::OnLayoutEvent(CXFA_LayoutProcessor* pLayout, 176
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, 177 void CXFA_FFNotify::StartFieldDrawLayout(CXFA_Node* pItem,
261 FX_FLOAT& fCalcWidth, 178 FX_FLOAT& fCalcWidth,
262 FX_FLOAT& fCalcHeight) { 179 FX_FLOAT& fCalcHeight) {
263 CXFA_WidgetAcc* pAcc = static_cast<CXFA_WidgetAcc*>(pItem->GetWidgetData()); 180 CXFA_WidgetAcc* pAcc = static_cast<CXFA_WidgetAcc*>(pItem->GetWidgetData());
264 if (!pAcc) { 181 if (!pAcc) {
265 return; 182 return;
266 } 183 }
267 pAcc->StartWidgetLayout(fCalcWidth, fCalcHeight); 184 pAcc->StartWidgetLayout(fCalcWidth, fCalcHeight);
268 } 185 }
269 FX_BOOL CXFA_FFNotify::FindSplitPos(CXFA_Node* pItem, 186 FX_BOOL CXFA_FFNotify::FindSplitPos(CXFA_Node* pItem,
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 } 310 }
394 void CXFA_FFNotify::SetFocusWidgetNode(CXFA_Node* pNode) { 311 void CXFA_FFNotify::SetFocusWidgetNode(CXFA_Node* pNode) {
395 CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); 312 CXFA_FFDocView* pDocView = m_pDoc->GetDocView();
396 if (!pDocView) { 313 if (!pDocView) {
397 return; 314 return;
398 } 315 }
399 CXFA_WidgetAcc* pAcc = 316 CXFA_WidgetAcc* pAcc =
400 pNode ? static_cast<CXFA_WidgetAcc*>(pNode->GetWidgetData()) : nullptr; 317 pNode ? static_cast<CXFA_WidgetAcc*>(pNode->GetWidgetData()) : nullptr;
401 pDocView->SetFocusWidgetAcc(pAcc); 318 pDocView->SetFocusWidgetAcc(pAcc);
402 } 319 }
320
403 void CXFA_FFNotify::OnNodeReady(CXFA_Node* pNode) { 321 void CXFA_FFNotify::OnNodeReady(CXFA_Node* pNode) {
404 CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); 322 CXFA_FFDocView* pDocView = m_pDoc->GetDocView();
405 if (!pDocView) { 323 if (!pDocView) {
406 return; 324 return;
407 } 325 }
408 XFA_ELEMENT iType = pNode->GetClassID(); 326 XFA_ELEMENT iType = pNode->GetClassID();
409 if (XFA_IsCreateWidget(iType)) { 327 if (XFA_IsCreateWidget(iType)) {
410 CXFA_WidgetAcc* pAcc = new CXFA_WidgetAcc(pDocView, pNode); 328 CXFA_WidgetAcc* pAcc = new CXFA_WidgetAcc(pDocView, pNode);
411 pNode->SetObject(XFA_ATTRIBUTE_WidgetData, pAcc, &gs_XFADeleteWidgetAcc); 329 pNode->SetObject(XFA_ATTRIBUTE_WidgetData, pAcc, &gs_XFADeleteWidgetAcc);
412 return; 330 return;
413 } 331 }
414 switch (iType) { 332 switch (iType) {
415 case XFA_ELEMENT_BindItems: 333 case XFA_ELEMENT_BindItems:
416 pDocView->m_bindItems.Add(pNode); 334 pDocView->m_bindItems.Add(pNode);
417 break; 335 break;
418 case XFA_ELEMENT_Validate: { 336 case XFA_ELEMENT_Validate: {
419 pNode->SetFlag(XFA_NODEFLAG_NeedsInitApp, TRUE, FALSE); 337 pNode->SetFlag(XFA_NODEFLAG_NeedsInitApp, TRUE, FALSE);
420 } break; 338 } break;
421 default: 339 default:
422 break; 340 break;
423 } 341 }
424 } 342 }
425 void CXFA_FFNotify::OnValueChanging(CXFA_Node* pSender, 343
426 void* pParam, 344 void CXFA_FFNotify::OnValueChanging(CXFA_Node* pSender, XFA_ATTRIBUTE eAttr) {
427 void* pParam2) {
428 CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); 345 CXFA_FFDocView* pDocView = m_pDoc->GetDocView();
429 if (!pDocView) { 346 if (!pDocView) {
430 return; 347 return;
431 } 348 }
432 if (pDocView->GetLayoutStatus() < XFA_DOCVIEW_LAYOUTSTATUS_End) { 349 if (pDocView->GetLayoutStatus() < XFA_DOCVIEW_LAYOUTSTATUS_End) {
433 return; 350 return;
434 } 351 }
435 uint32_t dwPacket = pSender->GetPacketID(); 352 uint32_t dwPacket = pSender->GetPacketID();
436 if (dwPacket & XFA_XDPPACKET_Datasets) { 353 if (dwPacket & XFA_XDPPACKET_Datasets) {
437 } else if (pSender->IsFormContainer()) { 354 } else if (pSender->IsFormContainer()) {
438 XFA_ATTRIBUTE eAttr = (XFA_ATTRIBUTE)(uintptr_t)pParam;
439 if (eAttr == XFA_ATTRIBUTE_Presence) { 355 if (eAttr == XFA_ATTRIBUTE_Presence) {
440 CXFA_WidgetAcc* pWidgetAcc = 356 CXFA_WidgetAcc* pWidgetAcc =
441 static_cast<CXFA_WidgetAcc*>(pSender->GetWidgetData()); 357 static_cast<CXFA_WidgetAcc*>(pSender->GetWidgetData());
442 if (!pWidgetAcc) { 358 if (!pWidgetAcc) {
443 return; 359 return;
444 } 360 }
445 CXFA_FFWidget* pWidget = NULL; 361 CXFA_FFWidget* pWidget = NULL;
446 while ((pWidget = pWidgetAcc->GetNextWidget(pWidget))) { 362 while ((pWidget = pWidgetAcc->GetNextWidget(pWidget))) {
447 if (pWidget->IsLoaded()) { 363 if (pWidget->IsLoaded()) {
448 pWidget->AddInvalidateRect(); 364 pWidget->AddInvalidateRect();
449 } 365 }
450 } 366 }
451 } 367 }
452 } 368 }
453 } 369 }
370
454 void CXFA_FFNotify::OnValueChanged(CXFA_Node* pSender, 371 void CXFA_FFNotify::OnValueChanged(CXFA_Node* pSender,
455 void* pParam, 372 XFA_ATTRIBUTE eAttr,
456 void* pParam2, 373 CXFA_Node* pParentNode,
457 void* pParam3, 374 CXFA_Node* pWidgetNode) {
458 void* pParam4) {
459 CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); 375 CXFA_FFDocView* pDocView = m_pDoc->GetDocView();
460 if (!pDocView) { 376 if (!pDocView) {
461 return; 377 return;
462 } 378 }
463 uint32_t dwPacket = pSender->GetPacketID(); 379 uint32_t dwPacket = pSender->GetPacketID();
464 XFA_ATTRIBUTE eAttr = (XFA_ATTRIBUTE)(uintptr_t)pParam;
465 if (dwPacket & XFA_XDPPACKET_Form) { 380 if (dwPacket & XFA_XDPPACKET_Form) {
466 CXFA_Node* pParentNode = static_cast<CXFA_Node*>(pParam3);
467 CXFA_Node* pWidgetNode = static_cast<CXFA_Node*>(pParam4);
468 XFA_ELEMENT ePType = pParentNode->GetClassID(); 381 XFA_ELEMENT ePType = pParentNode->GetClassID();
469 FX_BOOL bIsContainerNode = pParentNode->IsContainerNode(); 382 FX_BOOL bIsContainerNode = pParentNode->IsContainerNode();
470 CXFA_WidgetAcc* pWidgetAcc = 383 CXFA_WidgetAcc* pWidgetAcc =
471 static_cast<CXFA_WidgetAcc*>(pWidgetNode->GetWidgetData()); 384 static_cast<CXFA_WidgetAcc*>(pWidgetNode->GetWidgetData());
472 if (!pWidgetAcc) { 385 if (!pWidgetAcc) {
473 return; 386 return;
474 } 387 }
475 FX_BOOL bUpdateProperty = FALSE; 388 FX_BOOL bUpdateProperty = FALSE;
476 pDocView->SetChangeMark(); 389 pDocView->SetChangeMark();
477 switch (ePType) { 390 switch (ePType) {
478 case XFA_ELEMENT_Caption: { 391 case XFA_ELEMENT_Caption: {
479 CXFA_TextLayout* pCapOut = pWidgetAcc->GetCaptionTextLayout(); 392 CXFA_TextLayout* pCapOut = pWidgetAcc->GetCaptionTextLayout();
480 if (!pCapOut) { 393 if (!pCapOut) {
481 return; 394 return;
482 } 395 }
483 pCapOut->Unload(); 396 pCapOut->Unload();
484 } break; 397 } break;
485 case XFA_ELEMENT_Ui: 398 case XFA_ELEMENT_Ui:
486 case XFA_ELEMENT_Para: 399 case XFA_ELEMENT_Para:
487 bUpdateProperty = TRUE; 400 bUpdateProperty = TRUE;
488 break; 401 break;
489 case XFA_ELEMENT_Font: 402 case XFA_ELEMENT_Font:
490 case XFA_ELEMENT_Margin: 403 case XFA_ELEMENT_Margin:
491 case XFA_ELEMENT_Value: 404 case XFA_ELEMENT_Value:
492 case XFA_ELEMENT_Items: 405 case XFA_ELEMENT_Items:
493 break; 406 break;
494 default: 407 default:
495 break; 408 break;
496 } 409 }
497 if (bIsContainerNode && eAttr == XFA_ATTRIBUTE_Access) { 410 if (bIsContainerNode && eAttr == XFA_ATTRIBUTE_Access)
498 bUpdateProperty = TRUE; 411 bUpdateProperty = TRUE;
499 FX_BOOL bNotify = pDocView->IsStaticNotify(); 412
500 if (bNotify) {
501 pWidgetAcc->NotifyEvent(XFA_WIDGETEVENT_AccessChanged, NULL, pParam2,
502 NULL);
503 }
504 }
505 if (eAttr == XFA_ATTRIBUTE_Value) { 413 if (eAttr == XFA_ATTRIBUTE_Value) {
506 pDocView->AddCalculateNodeNotify(pSender); 414 pDocView->AddCalculateNodeNotify(pSender);
507 if (ePType == XFA_ELEMENT_Value || bIsContainerNode) { 415 if (ePType == XFA_ELEMENT_Value || bIsContainerNode) {
508 FX_BOOL bNotify = pDocView->IsStaticNotify();
509 if (bIsContainerNode) { 416 if (bIsContainerNode) {
510 pWidgetAcc->UpdateUIDisplay(); 417 pWidgetAcc->UpdateUIDisplay();
511 pDocView->AddCalculateWidgetAcc(pWidgetAcc); 418 pDocView->AddCalculateWidgetAcc(pWidgetAcc);
512 pDocView->AddValidateWidget(pWidgetAcc); 419 pDocView->AddValidateWidget(pWidgetAcc);
513 } else if (pWidgetNode->GetNodeItem(XFA_NODEITEM_Parent) 420 } else if (pWidgetNode->GetNodeItem(XFA_NODEITEM_Parent)
514 ->GetClassID() == XFA_ELEMENT_ExclGroup) { 421 ->GetClassID() == XFA_ELEMENT_ExclGroup) {
515 pWidgetAcc->UpdateUIDisplay(); 422 pWidgetAcc->UpdateUIDisplay();
516 } 423 }
517 if (bNotify) {
518 pWidgetAcc->NotifyEvent(XFA_WIDGETEVENT_PostContentChanged, NULL,
519 NULL, NULL);
520 }
521 return; 424 return;
522 } 425 }
523 } 426 }
524 CXFA_FFWidget* pWidget = NULL; 427 CXFA_FFWidget* pWidget = NULL;
525 while ((pWidget = pWidgetAcc->GetNextWidget(pWidget))) { 428 while ((pWidget = pWidgetAcc->GetNextWidget(pWidget))) {
526 if (!pWidget->IsLoaded()) { 429 if (!pWidget->IsLoaded()) {
527 continue; 430 continue;
528 } 431 }
529 if (bUpdateProperty) { 432 if (bUpdateProperty) {
530 pWidget->UpdateWidgetProperty(); 433 pWidget->UpdateWidgetProperty();
531 } 434 }
532 pWidget->PerformLayout(); 435 pWidget->PerformLayout();
533 pWidget->AddInvalidateRect(); 436 pWidget->AddInvalidateRect();
534 } 437 }
535 } else { 438 } else {
536 if (eAttr == XFA_ATTRIBUTE_Value) { 439 if (eAttr == XFA_ATTRIBUTE_Value) {
537 pDocView->AddCalculateNodeNotify(pSender); 440 pDocView->AddCalculateNodeNotify(pSender);
538 } 441 }
539 } 442 }
540 } 443 }
541 void CXFA_FFNotify::OnChildAdded(CXFA_Node* pSender, 444
542 void* pParam, 445 void CXFA_FFNotify::OnChildAdded(CXFA_Node* pSender) {
543 void* pParam2) {
544 if (!pSender->IsFormContainer()) { 446 if (!pSender->IsFormContainer()) {
545 return; 447 return;
546 } 448 }
547 CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); 449 CXFA_FFDocView* pDocView = m_pDoc->GetDocView();
548 if (!pDocView) { 450 if (!pDocView) {
549 return; 451 return;
550 } 452 }
551 FX_BOOL bLayoutReady = 453 FX_BOOL bLayoutReady =
552 !(pDocView->m_bInLayoutStatus) && 454 !(pDocView->m_bInLayoutStatus) &&
553 (pDocView->GetLayoutStatus() == XFA_DOCVIEW_LAYOUTSTATUS_End); 455 (pDocView->GetLayoutStatus() == XFA_DOCVIEW_LAYOUTSTATUS_End);
554 if (bLayoutReady) { 456 if (bLayoutReady) {
555 m_pDoc->GetDocProvider()->SetChangeMark(m_pDoc); 457 m_pDoc->GetDocProvider()->SetChangeMark(m_pDoc);
556 } 458 }
557 } 459 }
558 void CXFA_FFNotify::OnChildRemoved(CXFA_Node* pSender, 460
559 void* pParam, 461 void CXFA_FFNotify::OnChildRemoved() {
560 void* pParam2) {
561 if (CXFA_FFDocView* pDocView = m_pDoc->GetDocView()) { 462 if (CXFA_FFDocView* pDocView = m_pDoc->GetDocView()) {
562 FX_BOOL bLayoutReady = 463 FX_BOOL bLayoutReady =
563 !(pDocView->m_bInLayoutStatus) && 464 !(pDocView->m_bInLayoutStatus) &&
564 (pDocView->GetLayoutStatus() == XFA_DOCVIEW_LAYOUTSTATUS_End); 465 (pDocView->GetLayoutStatus() == XFA_DOCVIEW_LAYOUTSTATUS_End);
565 if (bLayoutReady) { 466 if (bLayoutReady) {
566 m_pDoc->GetDocProvider()->SetChangeMark(m_pDoc); 467 m_pDoc->GetDocProvider()->SetChangeMark(m_pDoc);
567 } 468 }
568 } 469 }
569 } 470 }
570 void CXFA_FFNotify::OnLayoutItemAdd(CXFA_FFDocView* pDocView, 471
571 CXFA_LayoutProcessor* pLayout, 472 void CXFA_FFNotify::OnLayoutItemAdd(CXFA_LayoutProcessor* pLayout,
572 CXFA_LayoutItem* pSender, 473 CXFA_LayoutItem* pSender,
573 void* pParam, 474 int32_t iPageIdx,
574 void* pParam2) { 475 uint32_t dwStatus) {
575 CXFA_FFWidget* pWidget = static_cast<CXFA_FFWidget*>(pSender); 476 CXFA_FFDocView* pDocView = m_pDoc->GetDocView(pLayout);
576 int32_t iPageIdx = (int32_t)(uintptr_t)pParam; 477 if (!pDocView)
478 return;
479
480 CXFA_FFWidget* pWidget = XFA_GetWidgetFromLayoutItem(pSender);
481 if (!pWidget)
482 return;
483
577 CXFA_FFPageView* pNewPageView = pDocView->GetPageView(iPageIdx); 484 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 | 485 uint32_t dwFilter = XFA_WIDGETSTATUS_Visible | XFA_WIDGETSTATUS_Viewable |
580 XFA_WIDGETSTATUS_Printable; 486 XFA_WIDGETSTATUS_Printable;
581 pWidget->ModifyStatus(dwStatus, dwFilter); 487 pWidget->ModifyStatus(dwStatus, dwFilter);
582 CXFA_FFPageView* pPrePageView = pWidget->GetPageView(); 488 CXFA_FFPageView* pPrePageView = pWidget->GetPageView();
583 if (pPrePageView != pNewPageView || 489 if (pPrePageView != pNewPageView ||
584 (dwStatus & (XFA_WIDGETSTATUS_Visible | XFA_WIDGETSTATUS_Viewable)) == 490 (dwStatus & (XFA_WIDGETSTATUS_Visible | XFA_WIDGETSTATUS_Viewable)) ==
585 (XFA_WIDGETSTATUS_Visible | XFA_WIDGETSTATUS_Viewable)) { 491 (XFA_WIDGETSTATUS_Visible | XFA_WIDGETSTATUS_Viewable)) {
586 pWidget->SetPageView(pNewPageView); 492 pWidget->SetPageView(pNewPageView);
587 m_pDoc->GetDocProvider()->WidgetEvent(pWidget, pWidget->GetDataAcc(), 493 m_pDoc->GetDocProvider()->WidgetEvent(pWidget, pWidget->GetDataAcc(),
588 XFA_WIDGETEVENT_PostAdded, 494 XFA_WIDGETEVENT_PostAdded);
589 pNewPageView, pPrePageView);
590 } 495 }
591 if (pDocView->GetLayoutStatus() != XFA_DOCVIEW_LAYOUTSTATUS_End || 496 if (pDocView->GetLayoutStatus() != XFA_DOCVIEW_LAYOUTSTATUS_End ||
592 !(dwStatus & XFA_WIDGETSTATUS_Visible)) { 497 !(dwStatus & XFA_WIDGETSTATUS_Visible)) {
593 return; 498 return;
594 } 499 }
595 if (pWidget->IsLoaded()) { 500 if (pWidget->IsLoaded()) {
596 CFX_RectF rtOld; 501 CFX_RectF rtOld;
597 pWidget->GetWidgetRect(rtOld); 502 pWidget->GetWidgetRect(rtOld);
598 if (rtOld != pWidget->ReCacheWidgetRect()) 503 if (rtOld != pWidget->ReCacheWidgetRect())
599 pWidget->PerformLayout(); 504 pWidget->PerformLayout();
600 } else { 505 } else {
601 pWidget->LoadWidget(); 506 pWidget->LoadWidget();
602 } 507 }
603 pWidget->AddInvalidateRect(nullptr); 508 pWidget->AddInvalidateRect(nullptr);
604 } 509 }
605 void CXFA_FFNotify::OnLayoutItemRemoving(CXFA_FFDocView* pDocView, 510
606 CXFA_LayoutProcessor* pLayout, 511 void CXFA_FFNotify::OnLayoutItemRemoving(CXFA_LayoutProcessor* pLayout,
607 CXFA_LayoutItem* pSender, 512 CXFA_LayoutItem* pSender) {
608 void* pParam, 513 CXFA_FFDocView* pDocView = m_pDoc->GetDocView(pLayout);
609 void* pParam2) { 514 if (!pDocView)
610 CXFA_FFWidget* pWidget = static_cast<CXFA_FFWidget*>(pSender); 515 return;
516
517 CXFA_FFWidget* pWidget = XFA_GetWidgetFromLayoutItem(pSender);
518 if (!pWidget)
519 return;
520
611 pDocView->DeleteLayoutItem(pWidget); 521 pDocView->DeleteLayoutItem(pWidget);
612 m_pDoc->GetDocProvider()->WidgetEvent(pWidget, pWidget->GetDataAcc(), 522 m_pDoc->GetDocProvider()->WidgetEvent(pWidget, pWidget->GetDataAcc(),
613 XFA_WIDGETEVENT_PreRemoved, nullptr, 523 XFA_WIDGETEVENT_PreRemoved);
614 pWidget->GetPageView());
615 pWidget->AddInvalidateRect(nullptr); 524 pWidget->AddInvalidateRect(nullptr);
616 } 525 }
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 }
OLDNEW
« no previous file with comments | « xfa/fxfa/app/xfa_ffnotify.h ('k') | xfa/fxfa/app/xfa_ffwidgetacc.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698