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

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

Issue 1803723002: Move xfa/src up to xfa/. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebase to master Created 4 years, 9 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/src/fxfa/app/xfa_ffnotify.h ('k') | xfa/src/fxfa/app/xfa_ffpageview.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7 #include "xfa/src/fxfa/app/xfa_ffnotify.h"
8
9 #include "xfa/src/fxfa/app/xfa_ffapp.h"
10 #include "xfa/src/fxfa/app/xfa_ffbarcode.h"
11 #include "xfa/src/fxfa/app/xfa_ffcheckbutton.h"
12 #include "xfa/src/fxfa/app/xfa_ffchoicelist.h"
13 #include "xfa/src/fxfa/app/xfa_ffdoc.h"
14 #include "xfa/src/fxfa/app/xfa_ffdocview.h"
15 #include "xfa/src/fxfa/app/xfa_ffdraw.h"
16 #include "xfa/src/fxfa/app/xfa_ffexclgroup.h"
17 #include "xfa/src/fxfa/app/xfa_fffield.h"
18 #include "xfa/src/fxfa/app/xfa_ffimage.h"
19 #include "xfa/src/fxfa/app/xfa_ffimageedit.h"
20 #include "xfa/src/fxfa/app/xfa_ffpageview.h"
21 #include "xfa/src/fxfa/app/xfa_ffpath.h"
22 #include "xfa/src/fxfa/app/xfa_ffpushbutton.h"
23 #include "xfa/src/fxfa/app/xfa_ffsignature.h"
24 #include "xfa/src/fxfa/app/xfa_ffsubform.h"
25 #include "xfa/src/fxfa/app/xfa_fftext.h"
26 #include "xfa/src/fxfa/app/xfa_fftextedit.h"
27 #include "xfa/src/fxfa/app/xfa_ffwidget.h"
28 #include "xfa/src/fxfa/app/xfa_ffwidgetacc.h"
29 #include "xfa/src/fxfa/app/xfa_ffwidgethandler.h"
30 #include "xfa/src/fxfa/app/xfa_fwladapter.h"
31 #include "xfa/src/fxfa/app/xfa_textlayout.h"
32
33 static void XFA_FFDeleteWidgetAcc(void* pData) {
34 delete static_cast<CXFA_WidgetAcc*>(pData);
35 }
36 static XFA_MAPDATABLOCKCALLBACKINFO gs_XFADeleteWidgetAcc = {
37 XFA_FFDeleteWidgetAcc, NULL};
38 CXFA_FFNotify::CXFA_FFNotify(CXFA_FFDoc* pDoc) : m_pDoc(pDoc) {}
39 CXFA_FFNotify::~CXFA_FFNotify() {}
40 void CXFA_FFNotify::OnPageEvent(IXFA_LayoutPage* pSender,
41 XFA_PAGEEVENT eEvent,
42 void* pParam) {
43 CXFA_FFDocView* pDocView = m_pDoc->GetDocView(pSender->GetLayout());
44 if (!pDocView) {
45 return;
46 }
47 pDocView->OnPageEvent(pSender, eEvent, (int32_t)(uintptr_t)pParam);
48 }
49 void CXFA_FFNotify::OnNodeEvent(CXFA_Node* pSender,
50 XFA_NODEEVENT eEvent,
51 void* pParam,
52 void* pParam2,
53 void* pParam3,
54 void* pParam4) {
55 switch (eEvent) {
56 case XFA_NODEEVENT_Ready:
57 OnNodeReady(pSender);
58 break;
59 case XFA_NODEEVENT_ValueChanging:
60 OnValueChanging(pSender, pParam, pParam2);
61 break;
62 case XFA_NODEEVENT_ValueChanged:
63 OnValueChanged(pSender, pParam, pParam2, pParam3, pParam4);
64 break;
65 case XFA_NODEEVENT_ChildAdded:
66 OnChildAdded(pSender, pParam, pParam2);
67 break;
68 case XFA_NODEEVENT_ChildRemoved:
69 OnChildRemoved(pSender, pParam, pParam2);
70 break;
71 }
72 }
73 void CXFA_FFNotify::OnWidgetDataEvent(CXFA_WidgetData* pSender,
74 FX_DWORD dwEvent,
75 void* pParam,
76 void* pAdditional,
77 void* pAdditional2) {
78 CXFA_WidgetAcc* pWidgetAcc = static_cast<CXFA_WidgetAcc*>(pSender);
79 switch (dwEvent) {
80 case XFA_WIDGETEVENT_ListItemAdded: {
81 if (pWidgetAcc->GetUIType() != XFA_ELEMENT_ChoiceList) {
82 return;
83 }
84 FX_BOOL bStaticNotify = pWidgetAcc->GetDocView()->IsStaticNotify();
85 CXFA_FFWidget* pWidget = pWidgetAcc->GetNextWidget(NULL);
86 if (!pWidget) {
87 if (bStaticNotify) {
88 pWidgetAcc->GetDoc()->GetDocProvider()->WidgetEvent(
89 pWidget, pWidgetAcc, XFA_WIDGETEVENT_ListItemAdded, pParam,
90 pAdditional);
91 }
92 return;
93 }
94 while (pWidget) {
95 if (pWidget->IsLoaded()) {
96 if (pWidgetAcc->IsListBox()) {
97 static_cast<CXFA_FFListBox*>(pWidget)
98 ->InsertItem((const CFX_WideStringC&)(const FX_WCHAR*)pParam,
99 (int32_t)(uintptr_t)pAdditional2);
100 } else {
101 static_cast<CXFA_FFComboBox*>(pWidget)
102 ->InsertItem((const CFX_WideStringC&)(const FX_WCHAR*)pParam,
103 (int32_t)(uintptr_t)pAdditional2);
104 }
105 }
106 if (bStaticNotify) {
107 pWidgetAcc->GetDoc()->GetDocProvider()->WidgetEvent(
108 pWidget, pWidgetAcc, XFA_WIDGETEVENT_ListItemAdded, pParam,
109 pAdditional);
110 }
111 pWidget = pWidgetAcc->GetNextWidget(pWidget);
112 }
113 } break;
114 case XFA_WIDGETEVENT_ListItemRemoved: {
115 if (pWidgetAcc->GetUIType() != XFA_ELEMENT_ChoiceList) {
116 return;
117 }
118 FX_BOOL bStaticNotify = pWidgetAcc->GetDocView()->IsStaticNotify();
119 CXFA_FFWidget* pWidget = pWidgetAcc->GetNextWidget(NULL);
120 if (!pWidget) {
121 if (bStaticNotify) {
122 pWidgetAcc->GetDoc()->GetDocProvider()->WidgetEvent(
123 pWidget, pWidgetAcc, XFA_WIDGETEVENT_ListItemRemoved, pParam,
124 pAdditional);
125 }
126 return;
127 }
128 while (pWidget) {
129 if (pWidget->IsLoaded()) {
130 if (pWidgetAcc->IsListBox()) {
131 static_cast<CXFA_FFListBox*>(pWidget)
132 ->DeleteItem((int32_t)(uintptr_t)pParam);
133 } else {
134 static_cast<CXFA_FFComboBox*>(pWidget)
135 ->DeleteItem((int32_t)(uintptr_t)pParam);
136 }
137 }
138 if (bStaticNotify) {
139 pWidgetAcc->GetDoc()->GetDocProvider()->WidgetEvent(
140 pWidget, pWidgetAcc, XFA_WIDGETEVENT_ListItemRemoved, pParam,
141 pAdditional);
142 }
143 pWidget = pWidgetAcc->GetNextWidget(pWidget);
144 }
145 } break;
146 }
147 }
148 CXFA_LayoutItem* CXFA_FFNotify::OnCreateLayoutItem(CXFA_Node* pNode) {
149 IXFA_DocLayout* pLayout = m_pDoc->GetXFADoc()->GetDocLayout();
150 CXFA_FFDocView* pDocView = m_pDoc->GetDocView(pLayout);
151 XFA_ELEMENT eType = pNode->GetClassID();
152 if (eType == XFA_ELEMENT_PageArea) {
153 return new CXFA_FFPageView(pDocView, pNode);
154 }
155 if (eType == XFA_ELEMENT_ContentArea) {
156 return new CXFA_ContainerLayoutItem(pNode);
157 }
158 CXFA_WidgetAcc* pAcc = static_cast<CXFA_WidgetAcc*>(pNode->GetWidgetData());
159 if (!pAcc) {
160 return new CXFA_ContentLayoutItem(pNode);
161 }
162 CXFA_FFPageView* pPageView = NULL;
163 CXFA_FFWidget* pWidget = NULL;
164 switch (pAcc->GetUIType()) {
165 case XFA_ELEMENT_Barcode:
166 pWidget = new CXFA_FFBarcode(pPageView, pAcc);
167 break;
168 case XFA_ELEMENT_Button:
169 pWidget = new CXFA_FFPushButton(pPageView, pAcc);
170 break;
171 case XFA_ELEMENT_CheckButton:
172 pWidget = new CXFA_FFCheckButton(pPageView, pAcc);
173 break;
174 case XFA_ELEMENT_ChoiceList: {
175 if (pAcc->IsListBox()) {
176 pWidget = new CXFA_FFListBox(pPageView, pAcc);
177 } else {
178 pWidget = new CXFA_FFComboBox(pPageView, pAcc);
179 }
180 } break;
181 case XFA_ELEMENT_DateTimeEdit:
182 pWidget = new CXFA_FFDateTimeEdit(pPageView, pAcc);
183 break;
184 case XFA_ELEMENT_ImageEdit:
185 pWidget = new CXFA_FFImageEdit(pPageView, pAcc);
186 break;
187 case XFA_ELEMENT_NumericEdit:
188 pWidget = new CXFA_FFNumericEdit(pPageView, pAcc);
189 break;
190 case XFA_ELEMENT_PasswordEdit:
191 pWidget = new CXFA_FFPasswordEdit(pPageView, pAcc);
192 break;
193 case XFA_ELEMENT_Signature:
194 pWidget = new CXFA_FFSignature(pPageView, pAcc);
195 break;
196 case XFA_ELEMENT_TextEdit:
197 pWidget = new CXFA_FFTextEdit(pPageView, pAcc);
198 break;
199 case XFA_ELEMENT_Arc:
200 pWidget = new CXFA_FFArc(pPageView, pAcc);
201 break;
202 case XFA_ELEMENT_Line:
203 pWidget = new CXFA_FFLine(pPageView, pAcc);
204 break;
205 case XFA_ELEMENT_Rectangle:
206 pWidget = new CXFA_FFRectangle(pPageView, pAcc);
207 break;
208 case XFA_ELEMENT_Text:
209 pWidget = new CXFA_FFText(pPageView, pAcc);
210 break;
211 case XFA_ELEMENT_Image:
212 pWidget = new CXFA_FFImage(pPageView, pAcc);
213 break;
214 case XFA_ELEMENT_Draw:
215 pWidget = new CXFA_FFDraw(pPageView, pAcc);
216 break;
217 case XFA_ELEMENT_Subform:
218 pWidget = new CXFA_FFSubForm(pPageView, pAcc);
219 break;
220 case XFA_ELEMENT_ExclGroup:
221 pWidget = new CXFA_FFExclGroup(pPageView, pAcc);
222 break;
223 case XFA_ELEMENT_DefaultUi:
224 default:
225 pWidget = NULL;
226 break;
227 }
228 if (!pWidget) {
229 return NULL;
230 }
231 pWidget->SetDocView(pDocView);
232 return pWidget;
233 }
234 void CXFA_FFNotify::OnLayoutEvent(IXFA_DocLayout* pLayout,
235 CXFA_LayoutItem* pSender,
236 XFA_LAYOUTEVENT eEvent,
237 void* pParam,
238 void* pParam2) {
239 CXFA_FFDocView* pDocView = m_pDoc->GetDocView(pLayout);
240 if (!pDocView || !XFA_GetWidgetFromLayoutItem(pSender)) {
241 return;
242 }
243 switch (eEvent) {
244 case XFA_LAYOUTEVENT_ItemAdded:
245 OnLayoutItemAdd(pDocView, pLayout, pSender, pParam, pParam2);
246 break;
247 case XFA_LAYOUTEVENT_ItemRemoving:
248 OnLayoutItemRemoving(pDocView, pLayout, pSender, pParam, pParam2);
249 break;
250 case XFA_LAYOUTEVENT_RectChanged:
251 OnLayoutItemRectChanged(pDocView, pLayout, pSender, pParam, pParam2);
252 break;
253 case XFA_LAYOUTEVENT_StatusChanged:
254 OnLayoutItemStatustChanged(pDocView, pLayout, pSender, pParam, pParam2);
255 break;
256 }
257 }
258 void CXFA_FFNotify::StartFieldDrawLayout(CXFA_Node* pItem,
259 FX_FLOAT& fCalcWidth,
260 FX_FLOAT& fCalcHeight) {
261 CXFA_WidgetAcc* pAcc = static_cast<CXFA_WidgetAcc*>(pItem->GetWidgetData());
262 if (!pAcc) {
263 return;
264 }
265 pAcc->StartWidgetLayout(fCalcWidth, fCalcHeight);
266 }
267 FX_BOOL CXFA_FFNotify::FindSplitPos(CXFA_Node* pItem,
268 int32_t iBlockIndex,
269 FX_FLOAT& fCalcHeightPos) {
270 CXFA_WidgetAcc* pAcc = static_cast<CXFA_WidgetAcc*>(pItem->GetWidgetData());
271 if (!pAcc) {
272 return FALSE;
273 }
274 return (XFA_LAYOUTRESULT)pAcc->FindSplitPos(iBlockIndex, fCalcHeightPos);
275 }
276 FX_BOOL CXFA_FFNotify::RunScript(CXFA_Node* pScript, CXFA_Node* pFormItem) {
277 FX_BOOL bRet = FALSE;
278 CXFA_FFDocView* pDocView = m_pDoc->GetDocView();
279 if (!pDocView) {
280 return bRet;
281 }
282 CXFA_WidgetAcc* pWidgetAcc =
283 static_cast<CXFA_WidgetAcc*>(pFormItem->GetWidgetData());
284 if (!pWidgetAcc) {
285 return bRet;
286 }
287 CXFA_EventParam EventParam;
288 EventParam.m_eType = XFA_EVENT_Unknown;
289 FXJSE_HVALUE pRetValue = NULL;
290 int32_t iRet =
291 pWidgetAcc->ExecuteScript(CXFA_Script(pScript), &EventParam, &pRetValue);
292 if (iRet == XFA_EVENTERROR_Sucess && pRetValue) {
293 bRet = FXJSE_Value_ToBoolean(pRetValue);
294 FXJSE_Value_Release(pRetValue);
295 }
296 return bRet;
297 }
298 int32_t CXFA_FFNotify::ExecEventByDeepFirst(CXFA_Node* pFormNode,
299 XFA_EVENTTYPE eEventType,
300 FX_BOOL bIsFormReady,
301 FX_BOOL bRecursive,
302 CXFA_WidgetAcc* pExclude) {
303 CXFA_FFDocView* pDocView = m_pDoc->GetDocView();
304 if (!pDocView) {
305 return XFA_EVENTERROR_NotExist;
306 }
307 return pDocView->ExecEventActivityByDeepFirst(
308 pFormNode, eEventType, bIsFormReady, bRecursive,
309 pExclude ? pExclude->GetNode() : NULL);
310 }
311 void CXFA_FFNotify::AddCalcValidate(CXFA_Node* pNode) {
312 CXFA_FFDocView* pDocView = m_pDoc->GetDocView();
313 if (!pDocView) {
314 return;
315 }
316 CXFA_WidgetAcc* pWidgetAcc =
317 static_cast<CXFA_WidgetAcc*>(pNode->GetWidgetData());
318 if (!pWidgetAcc) {
319 return;
320 }
321 pDocView->AddCalculateWidgetAcc(pWidgetAcc);
322 pDocView->AddValidateWidget(pWidgetAcc);
323 }
324 IXFA_Doc* CXFA_FFNotify::GetHDOC() {
325 return m_pDoc;
326 }
327 IXFA_DocProvider* CXFA_FFNotify::GetDocProvider() {
328 return m_pDoc->GetDocProvider();
329 }
330 IXFA_AppProvider* CXFA_FFNotify::GetAppProvider() {
331 return m_pDoc->GetApp()->GetAppProvider();
332 }
333 IXFA_WidgetHandler* CXFA_FFNotify::GetWidgetHandler() {
334 CXFA_FFDocView* pDocView = m_pDoc->GetDocView();
335 return pDocView ? pDocView->GetWidgetHandler() : NULL;
336 }
337 IXFA_Widget* CXFA_FFNotify::GetHWidget(CXFA_LayoutItem* pLayoutItem) {
338 return XFA_GetWidgetFromLayoutItem(pLayoutItem);
339 }
340 void CXFA_FFNotify::OpenDropDownList(IXFA_Widget* hWidget) {
341 CXFA_FFWidget* pWidget = static_cast<CXFA_FFWidget*>(hWidget);
342 if (pWidget->GetDataAcc()->GetUIType() != XFA_ELEMENT_ChoiceList) {
343 return;
344 }
345 CXFA_FFDocView* pDocView = m_pDoc->GetDocView();
346 pDocView->LockUpdate();
347 static_cast<CXFA_FFComboBox*>(pWidget)->OpenDropDownList();
348 pDocView->UnlockUpdate();
349 pDocView->UpdateDocView();
350 }
351 CFX_WideString CXFA_FFNotify::GetCurrentDateTime() {
352 CFX_Unitime dataTime;
353 dataTime.Now();
354 CFX_WideString wsDateTime;
355 wsDateTime.Format(L"%d%02d%02dT%02d%02d%02d", dataTime.GetYear(),
356 dataTime.GetMonth(), dataTime.GetDay(), dataTime.GetHour(),
357 dataTime.GetMinute(), dataTime.GetSecond());
358 return wsDateTime;
359 }
360 void CXFA_FFNotify::ResetData(CXFA_WidgetData* pWidgetData) {
361 CXFA_FFDocView* pDocView = m_pDoc->GetDocView();
362 if (!pDocView) {
363 return;
364 }
365 pDocView->ResetWidgetData(static_cast<CXFA_WidgetAcc*>(pWidgetData));
366 }
367 int32_t CXFA_FFNotify::GetLayoutStatus() {
368 CXFA_FFDocView* pDocView = m_pDoc->GetDocView();
369 return pDocView ? pDocView->GetLayoutStatus() : 0;
370 }
371 void CXFA_FFNotify::RunNodeInitialize(CXFA_Node* pNode) {
372 CXFA_FFDocView* pDocView = m_pDoc->GetDocView();
373 if (!pDocView) {
374 return;
375 }
376 pDocView->AddNewFormNode(pNode);
377 }
378 void CXFA_FFNotify::RunSubformIndexChange(CXFA_Node* pSubformNode) {
379 CXFA_FFDocView* pDocView = m_pDoc->GetDocView();
380 if (!pDocView) {
381 return;
382 }
383 pDocView->AddIndexChangedSubform(pSubformNode);
384 }
385 CXFA_Node* CXFA_FFNotify::GetFocusWidgetNode() {
386 CXFA_FFDocView* pDocView = m_pDoc->GetDocView();
387 if (!pDocView) {
388 return NULL;
389 }
390 CXFA_WidgetAcc* pAcc = pDocView->GetFocusWidgetAcc();
391 return pAcc ? pAcc->GetNode() : NULL;
392 }
393 void CXFA_FFNotify::SetFocusWidgetNode(CXFA_Node* pNode) {
394 CXFA_FFDocView* pDocView = m_pDoc->GetDocView();
395 if (!pDocView) {
396 return;
397 }
398 CXFA_WidgetAcc* pAcc =
399 pNode ? static_cast<CXFA_WidgetAcc*>(pNode->GetWidgetData()) : nullptr;
400 pDocView->SetFocusWidgetAcc(pAcc);
401 }
402 void CXFA_FFNotify::OnNodeReady(CXFA_Node* pNode) {
403 CXFA_FFDocView* pDocView = m_pDoc->GetDocView();
404 if (!pDocView) {
405 return;
406 }
407 XFA_ELEMENT iType = pNode->GetClassID();
408 if (XFA_IsCreateWidget(iType)) {
409 CXFA_WidgetAcc* pAcc =
410 new CXFA_WidgetAcc(pDocView, static_cast<CXFA_Node*>(pNode));
411 pNode->SetObject(XFA_ATTRIBUTE_WidgetData, pAcc, &gs_XFADeleteWidgetAcc);
412 return;
413 }
414 switch (iType) {
415 case XFA_ELEMENT_BindItems:
416 pDocView->m_bindItems.Add(pNode);
417 break;
418 case XFA_ELEMENT_Validate: {
419 pNode->SetFlag(XFA_NODEFLAG_NeedsInitApp, TRUE, FALSE);
420 } break;
421 default:
422 break;
423 }
424 }
425 void CXFA_FFNotify::OnValueChanging(CXFA_Node* pSender,
426 void* pParam,
427 void* pParam2) {
428 CXFA_FFDocView* pDocView = m_pDoc->GetDocView();
429 if (!pDocView) {
430 return;
431 }
432 if (pDocView->GetLayoutStatus() < XFA_DOCVIEW_LAYOUTSTATUS_End) {
433 return;
434 }
435 FX_DWORD dwPacket = pSender->GetPacketID();
436 if (dwPacket & XFA_XDPPACKET_Datasets) {
437 } else if (pSender->IsFormContainer()) {
438 XFA_ATTRIBUTE eAttr = (XFA_ATTRIBUTE)(uintptr_t)pParam;
439 if (eAttr == XFA_ATTRIBUTE_Presence) {
440 CXFA_WidgetAcc* pWidgetAcc =
441 static_cast<CXFA_WidgetAcc*>(pSender->GetWidgetData());
442 if (!pWidgetAcc) {
443 return;
444 }
445 CXFA_FFWidget* pWidget = NULL;
446 while ((pWidget = pWidgetAcc->GetNextWidget(pWidget))) {
447 if (pWidget->IsLoaded()) {
448 pWidget->AddInvalidateRect();
449 }
450 }
451 }
452 }
453 }
454 void CXFA_FFNotify::OnValueChanged(CXFA_Node* pSender,
455 void* pParam,
456 void* pParam2,
457 void* pParam3,
458 void* pParam4) {
459 CXFA_FFDocView* pDocView = m_pDoc->GetDocView();
460 if (!pDocView) {
461 return;
462 }
463 FX_DWORD dwPacket = pSender->GetPacketID();
464 XFA_ATTRIBUTE eAttr = (XFA_ATTRIBUTE)(uintptr_t)pParam;
465 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();
469 FX_BOOL bIsContainerNode = pParentNode->IsContainerNode();
470 CXFA_WidgetAcc* pWidgetAcc =
471 static_cast<CXFA_WidgetAcc*>(pWidgetNode->GetWidgetData());
472 if (!pWidgetAcc) {
473 return;
474 }
475 FX_BOOL bUpdateProperty = FALSE;
476 pDocView->SetChangeMark();
477 switch (ePType) {
478 case XFA_ELEMENT_Caption: {
479 CXFA_TextLayout* pCapOut = pWidgetAcc->GetCaptionTextLayout();
480 if (!pCapOut) {
481 return;
482 }
483 pCapOut->Unload();
484 } break;
485 case XFA_ELEMENT_Ui:
486 case XFA_ELEMENT_Para:
487 bUpdateProperty = TRUE;
488 break;
489 case XFA_ELEMENT_Font:
490 case XFA_ELEMENT_Margin:
491 case XFA_ELEMENT_Value:
492 case XFA_ELEMENT_Items:
493 break;
494 default:
495 break;
496 }
497 if (bIsContainerNode && eAttr == XFA_ATTRIBUTE_Access) {
498 bUpdateProperty = TRUE;
499 FX_BOOL bNotify = pDocView->IsStaticNotify();
500 if (bNotify) {
501 pWidgetAcc->NotifyEvent(XFA_WIDGETEVENT_AccessChanged, NULL, pParam2,
502 NULL);
503 }
504 }
505 if (eAttr == XFA_ATTRIBUTE_Value) {
506 pDocView->AddCalculateNodeNotify(pSender);
507 if (ePType == XFA_ELEMENT_Value || bIsContainerNode) {
508 FX_BOOL bNotify = pDocView->IsStaticNotify();
509 if (bIsContainerNode) {
510 pWidgetAcc->UpdateUIDisplay();
511 pDocView->AddCalculateWidgetAcc(pWidgetAcc);
512 pDocView->AddValidateWidget(pWidgetAcc);
513 } else if (pWidgetNode->GetNodeItem(XFA_NODEITEM_Parent)
514 ->GetClassID() == XFA_ELEMENT_ExclGroup) {
515 pWidgetAcc->UpdateUIDisplay();
516 }
517 if (bNotify) {
518 pWidgetAcc->NotifyEvent(XFA_WIDGETEVENT_PostContentChanged, NULL,
519 NULL, NULL);
520 }
521 return;
522 }
523 }
524 CXFA_FFWidget* pWidget = NULL;
525 while ((pWidget = pWidgetAcc->GetNextWidget(pWidget))) {
526 if (!pWidget->IsLoaded()) {
527 continue;
528 }
529 if (bUpdateProperty) {
530 pWidget->UpdateWidgetProperty();
531 }
532 pWidget->PerformLayout();
533 pWidget->AddInvalidateRect();
534 }
535 } else {
536 if (eAttr == XFA_ATTRIBUTE_Value) {
537 pDocView->AddCalculateNodeNotify(pSender);
538 }
539 }
540 }
541 void CXFA_FFNotify::OnChildAdded(CXFA_Node* pSender,
542 void* pParam,
543 void* pParam2) {
544 if (!pSender->IsFormContainer()) {
545 return;
546 }
547 CXFA_FFDocView* pDocView = m_pDoc->GetDocView();
548 if (!pDocView) {
549 return;
550 }
551 FX_BOOL bLayoutReady =
552 !(pDocView->m_bInLayoutStatus) &&
553 (pDocView->GetLayoutStatus() == XFA_DOCVIEW_LAYOUTSTATUS_End);
554 if (bLayoutReady) {
555 m_pDoc->GetDocProvider()->SetChangeMark(m_pDoc);
556 }
557 }
558 void CXFA_FFNotify::OnChildRemoved(CXFA_Node* pSender,
559 void* pParam,
560 void* pParam2) {
561 if (CXFA_FFDocView* pDocView = m_pDoc->GetDocView()) {
562 FX_BOOL bLayoutReady =
563 !(pDocView->m_bInLayoutStatus) &&
564 (pDocView->GetLayoutStatus() == XFA_DOCVIEW_LAYOUTSTATUS_End);
565 if (bLayoutReady) {
566 m_pDoc->GetDocProvider()->SetChangeMark(m_pDoc);
567 }
568 }
569 }
570 void CXFA_FFNotify::OnLayoutItemAdd(CXFA_FFDocView* pDocView,
571 IXFA_DocLayout* pLayout,
572 CXFA_LayoutItem* pSender,
573 void* pParam,
574 void* pParam2) {
575 CXFA_FFWidget* pWidget = static_cast<CXFA_FFWidget*>(pSender);
576 int32_t iPageIdx = (int32_t)(uintptr_t)pParam;
577 IXFA_PageView* pNewPageView = pDocView->GetPageView(iPageIdx);
578 FX_DWORD dwStatus = (FX_DWORD)(uintptr_t)pParam2;
579 FX_DWORD dwFilter = XFA_WIDGETSTATUS_Visible | XFA_WIDGETSTATUS_Viewable |
580 XFA_WIDGETSTATUS_Printable;
581 pWidget->ModifyStatus(dwStatus, dwFilter);
582 IXFA_PageView* pPrePageView = pWidget->GetPageView();
583 if (pPrePageView != pNewPageView ||
584 (dwStatus & (XFA_WIDGETSTATUS_Visible | XFA_WIDGETSTATUS_Viewable)) ==
585 (XFA_WIDGETSTATUS_Visible | XFA_WIDGETSTATUS_Viewable)) {
586 pWidget->SetPageView(pNewPageView);
587 m_pDoc->GetDocProvider()->WidgetEvent(pWidget, pWidget->GetDataAcc(),
588 XFA_WIDGETEVENT_PostAdded,
589 pNewPageView, pPrePageView);
590 }
591 if (pDocView->GetLayoutStatus() != XFA_DOCVIEW_LAYOUTSTATUS_End ||
592 !(dwStatus & XFA_WIDGETSTATUS_Visible)) {
593 return;
594 }
595 if (pWidget->IsLoaded()) {
596 CFX_RectF rtOld;
597 pWidget->GetWidgetRect(rtOld);
598 if (rtOld != pWidget->ReCacheWidgetRect())
599 pWidget->PerformLayout();
600 } else {
601 pWidget->LoadWidget();
602 }
603 pWidget->AddInvalidateRect(nullptr);
604 }
605 void CXFA_FFNotify::OnLayoutItemRemoving(CXFA_FFDocView* pDocView,
606 IXFA_DocLayout* pLayout,
607 CXFA_LayoutItem* pSender,
608 void* pParam,
609 void* pParam2) {
610 CXFA_FFWidget* pWidget = static_cast<CXFA_FFWidget*>(pSender);
611 pDocView->DeleteLayoutItem(pWidget);
612 m_pDoc->GetDocProvider()->WidgetEvent(pWidget, pWidget->GetDataAcc(),
613 XFA_WIDGETEVENT_PreRemoved, nullptr,
614 pWidget->GetPageView());
615 pWidget->AddInvalidateRect(nullptr);
616 }
617 void CXFA_FFNotify::OnLayoutItemRectChanged(CXFA_FFDocView* pDocView,
618 IXFA_DocLayout* pLayout,
619 CXFA_LayoutItem* pSender,
620 void* pParam,
621 void* pParam2) {}
622 void CXFA_FFNotify::OnLayoutItemStatustChanged(CXFA_FFDocView* pDocView,
623 IXFA_DocLayout* 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 FX_DWORD dwStatus = (FX_DWORD)(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 FX_DWORD dwOldStatus = pWidget->GetStatus();
642 FX_DWORD 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/src/fxfa/app/xfa_ffnotify.h ('k') | xfa/src/fxfa/app/xfa_ffpageview.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698