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 21 matching lines...) Expand all Loading... |
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 = nullptr; |
50 } | 59 while ((pWidget = pWidgetAcc->GetNextWidget(pWidget))) { |
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: | |
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 } | 67 } |
74 } | 68 } |
75 void CXFA_FFNotify::OnWidgetDataEvent(CXFA_WidgetData* pSender, | 69 |
76 uint32_t dwEvent, | 70 void CXFA_FFNotify::OnWidgetListItemRemoved(CXFA_WidgetData* pSender, |
77 void* pParam, | 71 int32_t iIndex) { |
78 void* pAdditional, | |
79 void* pAdditional2) { | |
80 CXFA_WidgetAcc* pWidgetAcc = static_cast<CXFA_WidgetAcc*>(pSender); | 72 CXFA_WidgetAcc* pWidgetAcc = static_cast<CXFA_WidgetAcc*>(pSender); |
81 switch (dwEvent) { | 73 if (pWidgetAcc->GetUIType() != XFA_ELEMENT_ChoiceList) |
82 case XFA_WIDGETEVENT_ListItemAdded: { | 74 return; |
83 if (pWidgetAcc->GetUIType() != XFA_ELEMENT_ChoiceList) { | 75 |
84 return; | 76 CXFA_FFWidget* pWidget = nullptr; |
| 77 while ((pWidget = pWidgetAcc->GetNextWidget(pWidget))) { |
| 78 if (pWidget->IsLoaded()) { |
| 79 if (pWidgetAcc->IsListBox()) { |
| 80 static_cast<CXFA_FFListBox*>(pWidget)->DeleteItem(iIndex); |
| 81 } else { |
| 82 static_cast<CXFA_FFComboBox*>(pWidget)->DeleteItem(iIndex); |
85 } | 83 } |
86 FX_BOOL bStaticNotify = pWidgetAcc->GetDocView()->IsStaticNotify(); | 84 } |
87 CXFA_FFWidget* pWidget = pWidgetAcc->GetNextWidget(NULL); | |
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 } | 85 } |
149 } | 86 } |
| 87 |
150 CXFA_LayoutItem* CXFA_FFNotify::OnCreateLayoutItem(CXFA_Node* pNode) { | 88 CXFA_LayoutItem* CXFA_FFNotify::OnCreateLayoutItem(CXFA_Node* pNode) { |
151 CXFA_LayoutProcessor* pLayout = m_pDoc->GetXFADoc()->GetDocLayout(); | 89 CXFA_LayoutProcessor* pLayout = m_pDoc->GetXFADoc()->GetDocLayout(); |
152 CXFA_FFDocView* pDocView = m_pDoc->GetDocView(pLayout); | 90 CXFA_FFDocView* pDocView = m_pDoc->GetDocView(pLayout); |
153 XFA_ELEMENT eType = pNode->GetClassID(); | 91 XFA_ELEMENT eType = pNode->GetClassID(); |
154 if (eType == XFA_ELEMENT_PageArea) { | 92 if (eType == XFA_ELEMENT_PageArea) |
155 return new CXFA_FFPageView(pDocView, pNode); | 93 return new CXFA_FFPageView(pDocView, pNode); |
156 } | 94 |
157 if (eType == XFA_ELEMENT_ContentArea) { | 95 if (eType == XFA_ELEMENT_ContentArea) |
158 return new CXFA_ContainerLayoutItem(pNode); | 96 return new CXFA_ContainerLayoutItem(pNode); |
159 } | 97 |
160 CXFA_WidgetAcc* pAcc = static_cast<CXFA_WidgetAcc*>(pNode->GetWidgetData()); | 98 CXFA_WidgetAcc* pAcc = static_cast<CXFA_WidgetAcc*>(pNode->GetWidgetData()); |
161 if (!pAcc) { | 99 if (!pAcc) |
162 return new CXFA_ContentLayoutItem(pNode); | 100 return new CXFA_ContentLayoutItem(pNode); |
163 } | 101 |
164 CXFA_FFPageView* pPageView = NULL; | 102 CXFA_FFWidget* pWidget; |
165 CXFA_FFWidget* pWidget = NULL; | |
166 switch (pAcc->GetUIType()) { | 103 switch (pAcc->GetUIType()) { |
167 case XFA_ELEMENT_Barcode: | 104 case XFA_ELEMENT_Barcode: |
168 pWidget = new CXFA_FFBarcode(pPageView, pAcc); | 105 pWidget = new CXFA_FFBarcode(nullptr, pAcc); |
169 break; | 106 break; |
170 case XFA_ELEMENT_Button: | 107 case XFA_ELEMENT_Button: |
171 pWidget = new CXFA_FFPushButton(pPageView, pAcc); | 108 pWidget = new CXFA_FFPushButton(nullptr, pAcc); |
172 break; | 109 break; |
173 case XFA_ELEMENT_CheckButton: | 110 case XFA_ELEMENT_CheckButton: |
174 pWidget = new CXFA_FFCheckButton(pPageView, pAcc); | 111 pWidget = new CXFA_FFCheckButton(nullptr, pAcc); |
175 break; | 112 break; |
176 case XFA_ELEMENT_ChoiceList: { | 113 case XFA_ELEMENT_ChoiceList: { |
177 if (pAcc->IsListBox()) { | 114 if (pAcc->IsListBox()) { |
178 pWidget = new CXFA_FFListBox(pPageView, pAcc); | 115 pWidget = new CXFA_FFListBox(nullptr, pAcc); |
179 } else { | 116 } else { |
180 pWidget = new CXFA_FFComboBox(pPageView, pAcc); | 117 pWidget = new CXFA_FFComboBox(nullptr, pAcc); |
181 } | 118 } |
182 } break; | 119 } break; |
183 case XFA_ELEMENT_DateTimeEdit: | 120 case XFA_ELEMENT_DateTimeEdit: |
184 pWidget = new CXFA_FFDateTimeEdit(pPageView, pAcc); | 121 pWidget = new CXFA_FFDateTimeEdit(nullptr, pAcc); |
185 break; | 122 break; |
186 case XFA_ELEMENT_ImageEdit: | 123 case XFA_ELEMENT_ImageEdit: |
187 pWidget = new CXFA_FFImageEdit(pPageView, pAcc); | 124 pWidget = new CXFA_FFImageEdit(nullptr, pAcc); |
188 break; | 125 break; |
189 case XFA_ELEMENT_NumericEdit: | 126 case XFA_ELEMENT_NumericEdit: |
190 pWidget = new CXFA_FFNumericEdit(pPageView, pAcc); | 127 pWidget = new CXFA_FFNumericEdit(nullptr, pAcc); |
191 break; | 128 break; |
192 case XFA_ELEMENT_PasswordEdit: | 129 case XFA_ELEMENT_PasswordEdit: |
193 pWidget = new CXFA_FFPasswordEdit(pPageView, pAcc); | 130 pWidget = new CXFA_FFPasswordEdit(nullptr, pAcc); |
194 break; | 131 break; |
195 case XFA_ELEMENT_Signature: | 132 case XFA_ELEMENT_Signature: |
196 pWidget = new CXFA_FFSignature(pPageView, pAcc); | 133 pWidget = new CXFA_FFSignature(nullptr, pAcc); |
197 break; | 134 break; |
198 case XFA_ELEMENT_TextEdit: | 135 case XFA_ELEMENT_TextEdit: |
199 pWidget = new CXFA_FFTextEdit(pPageView, pAcc); | 136 pWidget = new CXFA_FFTextEdit(nullptr, pAcc); |
200 break; | 137 break; |
201 case XFA_ELEMENT_Arc: | 138 case XFA_ELEMENT_Arc: |
202 pWidget = new CXFA_FFArc(pPageView, pAcc); | 139 pWidget = new CXFA_FFArc(nullptr, pAcc); |
203 break; | 140 break; |
204 case XFA_ELEMENT_Line: | 141 case XFA_ELEMENT_Line: |
205 pWidget = new CXFA_FFLine(pPageView, pAcc); | 142 pWidget = new CXFA_FFLine(nullptr, pAcc); |
206 break; | 143 break; |
207 case XFA_ELEMENT_Rectangle: | 144 case XFA_ELEMENT_Rectangle: |
208 pWidget = new CXFA_FFRectangle(pPageView, pAcc); | 145 pWidget = new CXFA_FFRectangle(nullptr, pAcc); |
209 break; | 146 break; |
210 case XFA_ELEMENT_Text: | 147 case XFA_ELEMENT_Text: |
211 pWidget = new CXFA_FFText(pPageView, pAcc); | 148 pWidget = new CXFA_FFText(nullptr, pAcc); |
212 break; | 149 break; |
213 case XFA_ELEMENT_Image: | 150 case XFA_ELEMENT_Image: |
214 pWidget = new CXFA_FFImage(pPageView, pAcc); | 151 pWidget = new CXFA_FFImage(nullptr, pAcc); |
215 break; | 152 break; |
216 case XFA_ELEMENT_Draw: | 153 case XFA_ELEMENT_Draw: |
217 pWidget = new CXFA_FFDraw(pPageView, pAcc); | 154 pWidget = new CXFA_FFDraw(nullptr, pAcc); |
218 break; | 155 break; |
219 case XFA_ELEMENT_Subform: | 156 case XFA_ELEMENT_Subform: |
220 pWidget = new CXFA_FFSubForm(pPageView, pAcc); | 157 pWidget = new CXFA_FFSubForm(nullptr, pAcc); |
221 break; | 158 break; |
222 case XFA_ELEMENT_ExclGroup: | 159 case XFA_ELEMENT_ExclGroup: |
223 pWidget = new CXFA_FFExclGroup(pPageView, pAcc); | 160 pWidget = new CXFA_FFExclGroup(nullptr, pAcc); |
224 break; | 161 break; |
225 case XFA_ELEMENT_DefaultUi: | 162 case XFA_ELEMENT_DefaultUi: |
226 default: | 163 default: |
227 pWidget = NULL; | 164 pWidget = nullptr; |
228 break; | 165 break; |
229 } | 166 } |
230 if (!pWidget) { | 167 |
231 return NULL; | 168 if (pWidget) |
232 } | 169 pWidget->SetDocView(pDocView); |
233 pWidget->SetDocView(pDocView); | |
234 return pWidget; | 170 return pWidget; |
235 } | 171 } |
236 void CXFA_FFNotify::OnLayoutEvent(CXFA_LayoutProcessor* pLayout, | 172 |
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, | 173 void CXFA_FFNotify::StartFieldDrawLayout(CXFA_Node* pItem, |
261 FX_FLOAT& fCalcWidth, | 174 FX_FLOAT& fCalcWidth, |
262 FX_FLOAT& fCalcHeight) { | 175 FX_FLOAT& fCalcHeight) { |
263 CXFA_WidgetAcc* pAcc = static_cast<CXFA_WidgetAcc*>(pItem->GetWidgetData()); | 176 CXFA_WidgetAcc* pAcc = static_cast<CXFA_WidgetAcc*>(pItem->GetWidgetData()); |
264 if (!pAcc) { | 177 if (!pAcc) { |
265 return; | 178 return; |
266 } | 179 } |
267 pAcc->StartWidgetLayout(fCalcWidth, fCalcHeight); | 180 pAcc->StartWidgetLayout(fCalcWidth, fCalcHeight); |
268 } | 181 } |
269 FX_BOOL CXFA_FFNotify::FindSplitPos(CXFA_Node* pItem, | 182 FX_BOOL CXFA_FFNotify::FindSplitPos(CXFA_Node* pItem, |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 } | 306 } |
394 void CXFA_FFNotify::SetFocusWidgetNode(CXFA_Node* pNode) { | 307 void CXFA_FFNotify::SetFocusWidgetNode(CXFA_Node* pNode) { |
395 CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); | 308 CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); |
396 if (!pDocView) { | 309 if (!pDocView) { |
397 return; | 310 return; |
398 } | 311 } |
399 CXFA_WidgetAcc* pAcc = | 312 CXFA_WidgetAcc* pAcc = |
400 pNode ? static_cast<CXFA_WidgetAcc*>(pNode->GetWidgetData()) : nullptr; | 313 pNode ? static_cast<CXFA_WidgetAcc*>(pNode->GetWidgetData()) : nullptr; |
401 pDocView->SetFocusWidgetAcc(pAcc); | 314 pDocView->SetFocusWidgetAcc(pAcc); |
402 } | 315 } |
| 316 |
403 void CXFA_FFNotify::OnNodeReady(CXFA_Node* pNode) { | 317 void CXFA_FFNotify::OnNodeReady(CXFA_Node* pNode) { |
404 CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); | 318 CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); |
405 if (!pDocView) { | 319 if (!pDocView) { |
406 return; | 320 return; |
407 } | 321 } |
408 XFA_ELEMENT iType = pNode->GetClassID(); | 322 XFA_ELEMENT iType = pNode->GetClassID(); |
409 if (XFA_IsCreateWidget(iType)) { | 323 if (XFA_IsCreateWidget(iType)) { |
410 CXFA_WidgetAcc* pAcc = new CXFA_WidgetAcc(pDocView, pNode); | 324 CXFA_WidgetAcc* pAcc = new CXFA_WidgetAcc(pDocView, pNode); |
411 pNode->SetObject(XFA_ATTRIBUTE_WidgetData, pAcc, &gs_XFADeleteWidgetAcc); | 325 pNode->SetObject(XFA_ATTRIBUTE_WidgetData, pAcc, &gs_XFADeleteWidgetAcc); |
412 return; | 326 return; |
413 } | 327 } |
414 switch (iType) { | 328 switch (iType) { |
415 case XFA_ELEMENT_BindItems: | 329 case XFA_ELEMENT_BindItems: |
416 pDocView->m_bindItems.Add(pNode); | 330 pDocView->m_bindItems.Add(pNode); |
417 break; | 331 break; |
418 case XFA_ELEMENT_Validate: { | 332 case XFA_ELEMENT_Validate: { |
419 pNode->SetFlag(XFA_NODEFLAG_NeedsInitApp, TRUE, FALSE); | 333 pNode->SetFlag(XFA_NODEFLAG_NeedsInitApp, false); |
420 } break; | 334 } break; |
421 default: | 335 default: |
422 break; | 336 break; |
423 } | 337 } |
424 } | 338 } |
425 void CXFA_FFNotify::OnValueChanging(CXFA_Node* pSender, | 339 |
426 void* pParam, | 340 void CXFA_FFNotify::OnValueChanging(CXFA_Node* pSender, XFA_ATTRIBUTE eAttr) { |
427 void* pParam2) { | 341 if (eAttr != XFA_ATTRIBUTE_Presence) |
| 342 return; |
| 343 |
| 344 if (pSender->GetPacketID() & XFA_XDPPACKET_Datasets) |
| 345 return; |
| 346 |
| 347 if (!pSender->IsFormContainer()) |
| 348 return; |
| 349 |
428 CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); | 350 CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); |
429 if (!pDocView) { | 351 if (!pDocView) |
| 352 return; |
| 353 |
| 354 if (pDocView->GetLayoutStatus() < XFA_DOCVIEW_LAYOUTSTATUS_End) |
| 355 return; |
| 356 |
| 357 CXFA_WidgetAcc* pWidgetAcc = |
| 358 static_cast<CXFA_WidgetAcc*>(pSender->GetWidgetData()); |
| 359 if (!pWidgetAcc) |
| 360 return; |
| 361 |
| 362 CXFA_FFWidget* pWidget = nullptr; |
| 363 while ((pWidget = pWidgetAcc->GetNextWidget(pWidget))) { |
| 364 if (pWidget->IsLoaded()) |
| 365 pWidget->AddInvalidateRect(); |
| 366 } |
| 367 } |
| 368 |
| 369 void CXFA_FFNotify::OnValueChanged(CXFA_Node* pSender, |
| 370 XFA_ATTRIBUTE eAttr, |
| 371 CXFA_Node* pParentNode, |
| 372 CXFA_Node* pWidgetNode) { |
| 373 CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); |
| 374 if (!pDocView) |
| 375 return; |
| 376 |
| 377 if (!(pSender->GetPacketID() & XFA_XDPPACKET_Form)) { |
| 378 if (eAttr == XFA_ATTRIBUTE_Value) |
| 379 pDocView->AddCalculateNodeNotify(pSender); |
430 return; | 380 return; |
431 } | 381 } |
432 if (pDocView->GetLayoutStatus() < XFA_DOCVIEW_LAYOUTSTATUS_End) { | 382 |
| 383 XFA_ELEMENT ePType = pParentNode->GetClassID(); |
| 384 FX_BOOL bIsContainerNode = pParentNode->IsContainerNode(); |
| 385 CXFA_WidgetAcc* pWidgetAcc = |
| 386 static_cast<CXFA_WidgetAcc*>(pWidgetNode->GetWidgetData()); |
| 387 if (!pWidgetAcc) |
433 return; | 388 return; |
| 389 |
| 390 bool bUpdateProperty = false; |
| 391 pDocView->SetChangeMark(); |
| 392 switch (ePType) { |
| 393 case XFA_ELEMENT_Caption: { |
| 394 CXFA_TextLayout* pCapOut = pWidgetAcc->GetCaptionTextLayout(); |
| 395 if (!pCapOut) |
| 396 return; |
| 397 |
| 398 pCapOut->Unload(); |
| 399 } break; |
| 400 case XFA_ELEMENT_Ui: |
| 401 case XFA_ELEMENT_Para: |
| 402 bUpdateProperty = true; |
| 403 break; |
| 404 default: |
| 405 break; |
434 } | 406 } |
435 uint32_t dwPacket = pSender->GetPacketID(); | 407 if (bIsContainerNode && eAttr == XFA_ATTRIBUTE_Access) |
436 if (dwPacket & XFA_XDPPACKET_Datasets) { | 408 bUpdateProperty = true; |
437 } else if (pSender->IsFormContainer()) { | 409 |
438 XFA_ATTRIBUTE eAttr = (XFA_ATTRIBUTE)(uintptr_t)pParam; | 410 if (eAttr == XFA_ATTRIBUTE_Value) { |
439 if (eAttr == XFA_ATTRIBUTE_Presence) { | 411 pDocView->AddCalculateNodeNotify(pSender); |
440 CXFA_WidgetAcc* pWidgetAcc = | 412 if (ePType == XFA_ELEMENT_Value || bIsContainerNode) { |
441 static_cast<CXFA_WidgetAcc*>(pSender->GetWidgetData()); | 413 if (bIsContainerNode) { |
442 if (!pWidgetAcc) { | 414 pWidgetAcc->UpdateUIDisplay(); |
443 return; | 415 pDocView->AddCalculateWidgetAcc(pWidgetAcc); |
| 416 pDocView->AddValidateWidget(pWidgetAcc); |
| 417 } else if (pWidgetNode->GetNodeItem(XFA_NODEITEM_Parent)->GetClassID() == |
| 418 XFA_ELEMENT_ExclGroup) { |
| 419 pWidgetAcc->UpdateUIDisplay(); |
444 } | 420 } |
445 CXFA_FFWidget* pWidget = NULL; | 421 return; |
446 while ((pWidget = pWidgetAcc->GetNextWidget(pWidget))) { | |
447 if (pWidget->IsLoaded()) { | |
448 pWidget->AddInvalidateRect(); | |
449 } | |
450 } | |
451 } | 422 } |
452 } | 423 } |
453 } | 424 CXFA_FFWidget* pWidget = nullptr; |
454 void CXFA_FFNotify::OnValueChanged(CXFA_Node* pSender, | 425 while ((pWidget = pWidgetAcc->GetNextWidget(pWidget))) { |
455 void* pParam, | 426 if (!pWidget->IsLoaded()) |
456 void* pParam2, | 427 continue; |
457 void* pParam3, | 428 |
458 void* pParam4) { | 429 if (bUpdateProperty) |
459 CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); | 430 pWidget->UpdateWidgetProperty(); |
460 if (!pDocView) { | 431 pWidget->PerformLayout(); |
461 return; | 432 pWidget->AddInvalidateRect(); |
462 } | |
463 uint32_t 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 } | 433 } |
540 } | 434 } |
541 void CXFA_FFNotify::OnChildAdded(CXFA_Node* pSender, | 435 |
542 void* pParam, | 436 void CXFA_FFNotify::OnChildAdded(CXFA_Node* pSender) { |
543 void* pParam2) { | |
544 if (!pSender->IsFormContainer()) { | 437 if (!pSender->IsFormContainer()) { |
545 return; | 438 return; |
546 } | 439 } |
547 CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); | 440 CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); |
548 if (!pDocView) { | 441 if (!pDocView) { |
549 return; | 442 return; |
550 } | 443 } |
551 FX_BOOL bLayoutReady = | 444 FX_BOOL bLayoutReady = |
552 !(pDocView->m_bInLayoutStatus) && | 445 !(pDocView->m_bInLayoutStatus) && |
553 (pDocView->GetLayoutStatus() == XFA_DOCVIEW_LAYOUTSTATUS_End); | 446 (pDocView->GetLayoutStatus() == XFA_DOCVIEW_LAYOUTSTATUS_End); |
554 if (bLayoutReady) { | 447 if (bLayoutReady) |
555 m_pDoc->GetDocProvider()->SetChangeMark(m_pDoc); | 448 m_pDoc->GetDocProvider()->SetChangeMark(m_pDoc); |
556 } | |
557 } | 449 } |
558 void CXFA_FFNotify::OnChildRemoved(CXFA_Node* pSender, | 450 |
559 void* pParam, | 451 void CXFA_FFNotify::OnChildRemoved() { |
560 void* pParam2) { | 452 CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); |
561 if (CXFA_FFDocView* pDocView = m_pDoc->GetDocView()) { | 453 if (!pDocView) |
562 FX_BOOL bLayoutReady = | 454 return; |
563 !(pDocView->m_bInLayoutStatus) && | 455 |
564 (pDocView->GetLayoutStatus() == XFA_DOCVIEW_LAYOUTSTATUS_End); | 456 bool bLayoutReady = |
565 if (bLayoutReady) { | 457 !(pDocView->m_bInLayoutStatus) && |
566 m_pDoc->GetDocProvider()->SetChangeMark(m_pDoc); | 458 (pDocView->GetLayoutStatus() == XFA_DOCVIEW_LAYOUTSTATUS_End); |
567 } | 459 if (bLayoutReady) |
568 } | 460 m_pDoc->GetDocProvider()->SetChangeMark(m_pDoc); |
569 } | 461 } |
570 void CXFA_FFNotify::OnLayoutItemAdd(CXFA_FFDocView* pDocView, | 462 |
571 CXFA_LayoutProcessor* pLayout, | 463 void CXFA_FFNotify::OnLayoutItemAdded(CXFA_LayoutProcessor* pLayout, |
572 CXFA_LayoutItem* pSender, | 464 CXFA_LayoutItem* pSender, |
573 void* pParam, | 465 int32_t iPageIdx, |
574 void* pParam2) { | 466 uint32_t dwStatus) { |
575 CXFA_FFWidget* pWidget = static_cast<CXFA_FFWidget*>(pSender); | 467 CXFA_FFDocView* pDocView = m_pDoc->GetDocView(pLayout); |
576 int32_t iPageIdx = (int32_t)(uintptr_t)pParam; | 468 if (!pDocView) |
| 469 return; |
| 470 |
| 471 CXFA_FFWidget* pWidget = XFA_GetWidgetFromLayoutItem(pSender); |
| 472 if (!pWidget) |
| 473 return; |
| 474 |
577 CXFA_FFPageView* pNewPageView = pDocView->GetPageView(iPageIdx); | 475 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 | | 476 uint32_t dwFilter = XFA_WIDGETSTATUS_Visible | XFA_WIDGETSTATUS_Viewable | |
580 XFA_WIDGETSTATUS_Printable; | 477 XFA_WIDGETSTATUS_Printable; |
581 pWidget->ModifyStatus(dwStatus, dwFilter); | 478 pWidget->ModifyStatus(dwStatus, dwFilter); |
582 CXFA_FFPageView* pPrePageView = pWidget->GetPageView(); | 479 CXFA_FFPageView* pPrePageView = pWidget->GetPageView(); |
583 if (pPrePageView != pNewPageView || | 480 if (pPrePageView != pNewPageView || |
584 (dwStatus & (XFA_WIDGETSTATUS_Visible | XFA_WIDGETSTATUS_Viewable)) == | 481 (dwStatus & (XFA_WIDGETSTATUS_Visible | XFA_WIDGETSTATUS_Viewable)) == |
585 (XFA_WIDGETSTATUS_Visible | XFA_WIDGETSTATUS_Viewable)) { | 482 (XFA_WIDGETSTATUS_Visible | XFA_WIDGETSTATUS_Viewable)) { |
586 pWidget->SetPageView(pNewPageView); | 483 pWidget->SetPageView(pNewPageView); |
587 m_pDoc->GetDocProvider()->WidgetEvent(pWidget, pWidget->GetDataAcc(), | 484 m_pDoc->GetDocProvider()->WidgetEvent(pWidget, pWidget->GetDataAcc(), |
588 XFA_WIDGETEVENT_PostAdded, | 485 XFA_WIDGETEVENT_PostAdded); |
589 pNewPageView, pPrePageView); | |
590 } | 486 } |
591 if (pDocView->GetLayoutStatus() != XFA_DOCVIEW_LAYOUTSTATUS_End || | 487 if (pDocView->GetLayoutStatus() != XFA_DOCVIEW_LAYOUTSTATUS_End || |
592 !(dwStatus & XFA_WIDGETSTATUS_Visible)) { | 488 !(dwStatus & XFA_WIDGETSTATUS_Visible)) { |
593 return; | 489 return; |
594 } | 490 } |
595 if (pWidget->IsLoaded()) { | 491 if (pWidget->IsLoaded()) { |
596 CFX_RectF rtOld; | 492 CFX_RectF rtOld; |
597 pWidget->GetWidgetRect(rtOld); | 493 pWidget->GetWidgetRect(rtOld); |
598 if (rtOld != pWidget->ReCacheWidgetRect()) | 494 if (rtOld != pWidget->ReCacheWidgetRect()) |
599 pWidget->PerformLayout(); | 495 pWidget->PerformLayout(); |
600 } else { | 496 } else { |
601 pWidget->LoadWidget(); | 497 pWidget->LoadWidget(); |
602 } | 498 } |
603 pWidget->AddInvalidateRect(nullptr); | 499 pWidget->AddInvalidateRect(nullptr); |
604 } | 500 } |
605 void CXFA_FFNotify::OnLayoutItemRemoving(CXFA_FFDocView* pDocView, | 501 |
606 CXFA_LayoutProcessor* pLayout, | 502 void CXFA_FFNotify::OnLayoutItemRemoving(CXFA_LayoutProcessor* pLayout, |
607 CXFA_LayoutItem* pSender, | 503 CXFA_LayoutItem* pSender) { |
608 void* pParam, | 504 CXFA_FFDocView* pDocView = m_pDoc->GetDocView(pLayout); |
609 void* pParam2) { | 505 if (!pDocView) |
610 CXFA_FFWidget* pWidget = static_cast<CXFA_FFWidget*>(pSender); | 506 return; |
| 507 |
| 508 CXFA_FFWidget* pWidget = XFA_GetWidgetFromLayoutItem(pSender); |
| 509 if (!pWidget) |
| 510 return; |
| 511 |
611 pDocView->DeleteLayoutItem(pWidget); | 512 pDocView->DeleteLayoutItem(pWidget); |
612 m_pDoc->GetDocProvider()->WidgetEvent(pWidget, pWidget->GetDataAcc(), | 513 m_pDoc->GetDocProvider()->WidgetEvent(pWidget, pWidget->GetDataAcc(), |
613 XFA_WIDGETEVENT_PreRemoved, nullptr, | 514 XFA_WIDGETEVENT_PreRemoved); |
614 pWidget->GetPageView()); | |
615 pWidget->AddInvalidateRect(nullptr); | 515 pWidget->AddInvalidateRect(nullptr); |
616 } | 516 } |
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 |