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/xfa_ffdocview.h" | 7 #include "xfa/fxfa/xfa_ffdocview.h" |
8 | 8 |
9 #include "core/fxcrt/fx_ext.h" | 9 #include "core/fxcrt/fx_ext.h" |
10 #include "xfa/fxfa/app/xfa_ffbarcode.h" | 10 #include "xfa/fxfa/app/xfa_ffbarcode.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 XFA_ATTRIBUTEENUM_PostOpen, XFA_ATTRIBUTEENUM_PostPrint, | 45 XFA_ATTRIBUTEENUM_PostOpen, XFA_ATTRIBUTEENUM_PostPrint, |
46 XFA_ATTRIBUTEENUM_PostSave, XFA_ATTRIBUTEENUM_PostSign, | 46 XFA_ATTRIBUTEENUM_PostSave, XFA_ATTRIBUTEENUM_PostSign, |
47 XFA_ATTRIBUTEENUM_PostSubmit, XFA_ATTRIBUTEENUM_PreExecute, | 47 XFA_ATTRIBUTEENUM_PostSubmit, XFA_ATTRIBUTEENUM_PreExecute, |
48 XFA_ATTRIBUTEENUM_PreOpen, XFA_ATTRIBUTEENUM_PrePrint, | 48 XFA_ATTRIBUTEENUM_PreOpen, XFA_ATTRIBUTEENUM_PrePrint, |
49 XFA_ATTRIBUTEENUM_PreSave, XFA_ATTRIBUTEENUM_PreSign, | 49 XFA_ATTRIBUTEENUM_PreSave, XFA_ATTRIBUTEENUM_PreSign, |
50 XFA_ATTRIBUTEENUM_PreSubmit, XFA_ATTRIBUTEENUM_Ready, | 50 XFA_ATTRIBUTEENUM_PreSubmit, XFA_ATTRIBUTEENUM_Ready, |
51 XFA_ATTRIBUTEENUM_Unknown, | 51 XFA_ATTRIBUTEENUM_Unknown, |
52 }; | 52 }; |
53 | 53 |
54 CXFA_FFDocView::CXFA_FFDocView(CXFA_FFDoc* pDoc) | 54 CXFA_FFDocView::CXFA_FFDocView(CXFA_FFDoc* pDoc) |
55 : m_bLayoutEvent(FALSE), | 55 : m_bLayoutEvent(false), |
56 m_pListFocusWidget(nullptr), | 56 m_pListFocusWidget(nullptr), |
57 m_bInLayoutStatus(FALSE), | 57 m_bInLayoutStatus(false), |
58 m_pDoc(pDoc), | 58 m_pDoc(pDoc), |
59 m_pXFADocLayout(nullptr), | 59 m_pXFADocLayout(nullptr), |
60 m_pFocusAcc(nullptr), | 60 m_pFocusAcc(nullptr), |
61 m_pFocusWidget(nullptr), | 61 m_pFocusWidget(nullptr), |
62 m_pOldFocusWidget(nullptr), | 62 m_pOldFocusWidget(nullptr), |
63 m_iStatus(XFA_DOCVIEW_LAYOUTSTATUS_None), | 63 m_iStatus(XFA_DOCVIEW_LAYOUTSTATUS_None), |
64 m_iLock(0) {} | 64 m_iLock(0) {} |
65 | 65 |
66 CXFA_FFDocView::~CXFA_FFDocView() { | 66 CXFA_FFDocView::~CXFA_FFDocView() { |
67 DestroyDocView(); | 67 DestroyDocView(); |
68 } | 68 } |
69 | 69 |
70 void CXFA_FFDocView::InitLayout(CXFA_Node* pNode) { | 70 void CXFA_FFDocView::InitLayout(CXFA_Node* pNode) { |
71 RunBindItems(); | 71 RunBindItems(); |
72 ExecEventActivityByDeepFirst(pNode, XFA_EVENT_Initialize, FALSE, TRUE, | 72 ExecEventActivityByDeepFirst(pNode, XFA_EVENT_Initialize, false, true, |
73 nullptr); | 73 nullptr); |
74 ExecEventActivityByDeepFirst(pNode, XFA_EVENT_IndexChange, FALSE, TRUE, | 74 ExecEventActivityByDeepFirst(pNode, XFA_EVENT_IndexChange, false, true, |
75 nullptr); | 75 nullptr); |
76 } | 76 } |
77 int32_t CXFA_FFDocView::StartLayout(int32_t iStartPage) { | 77 int32_t CXFA_FFDocView::StartLayout(int32_t iStartPage) { |
78 m_iStatus = XFA_DOCVIEW_LAYOUTSTATUS_Start; | 78 m_iStatus = XFA_DOCVIEW_LAYOUTSTATUS_Start; |
79 m_pDoc->GetXFADoc()->DoProtoMerge(); | 79 m_pDoc->GetXFADoc()->DoProtoMerge(); |
80 m_pDoc->GetXFADoc()->DoDataMerge(); | 80 m_pDoc->GetXFADoc()->DoDataMerge(); |
81 m_pXFADocLayout = GetXFALayout(); | 81 m_pXFADocLayout = GetXFALayout(); |
82 int32_t iStatus = m_pXFADocLayout->StartLayout(); | 82 int32_t iStatus = m_pXFADocLayout->StartLayout(); |
83 if (iStatus < 0) { | 83 if (iStatus < 0) { |
84 return iStatus; | 84 return iStatus; |
85 } | 85 } |
86 CXFA_Node* pRootItem = | 86 CXFA_Node* pRootItem = |
87 ToNode(m_pDoc->GetXFADoc()->GetXFAObject(XFA_HASHCODE_Form)); | 87 ToNode(m_pDoc->GetXFADoc()->GetXFAObject(XFA_HASHCODE_Form)); |
88 if (!pRootItem) { | 88 if (!pRootItem) { |
89 return iStatus; | 89 return iStatus; |
90 } | 90 } |
91 InitLayout(pRootItem); | 91 InitLayout(pRootItem); |
92 InitCalculate(pRootItem); | 92 InitCalculate(pRootItem); |
93 InitValidate(pRootItem); | 93 InitValidate(pRootItem); |
94 ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_Ready, TRUE, TRUE, nullptr); | 94 ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_Ready, true, true, nullptr); |
95 m_iStatus = XFA_DOCVIEW_LAYOUTSTATUS_Start; | 95 m_iStatus = XFA_DOCVIEW_LAYOUTSTATUS_Start; |
96 return iStatus; | 96 return iStatus; |
97 } | 97 } |
98 int32_t CXFA_FFDocView::DoLayout(IFX_Pause* pPause) { | 98 int32_t CXFA_FFDocView::DoLayout(IFX_Pause* pPause) { |
99 int32_t iStatus = 100; | 99 int32_t iStatus = 100; |
100 iStatus = m_pXFADocLayout->DoLayout(pPause); | 100 iStatus = m_pXFADocLayout->DoLayout(pPause); |
101 if (iStatus != 100) { | 101 if (iStatus != 100) { |
102 return iStatus; | 102 return iStatus; |
103 } | 103 } |
104 m_iStatus = XFA_DOCVIEW_LAYOUTSTATUS_Doing; | 104 m_iStatus = XFA_DOCVIEW_LAYOUTSTATUS_Doing; |
(...skipping 12 matching lines...) Expand all Loading... |
117 CXFA_Node* pPageSetNode = | 117 CXFA_Node* pPageSetNode = |
118 pSubformNode->GetFirstChildByClass(XFA_Element::PageSet); | 118 pSubformNode->GetFirstChildByClass(XFA_Element::PageSet); |
119 if (!pPageSetNode) { | 119 if (!pPageSetNode) { |
120 return; | 120 return; |
121 } | 121 } |
122 RunCalculateWidgets(); | 122 RunCalculateWidgets(); |
123 RunValidate(); | 123 RunValidate(); |
124 InitLayout(pPageSetNode); | 124 InitLayout(pPageSetNode); |
125 InitCalculate(pPageSetNode); | 125 InitCalculate(pPageSetNode); |
126 InitValidate(pPageSetNode); | 126 InitValidate(pPageSetNode); |
127 ExecEventActivityByDeepFirst(pPageSetNode, XFA_EVENT_Ready, TRUE, TRUE, | 127 ExecEventActivityByDeepFirst(pPageSetNode, XFA_EVENT_Ready, true, true, |
128 nullptr); | 128 nullptr); |
129 ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_Ready, FALSE, TRUE, | 129 ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_Ready, false, true, |
130 nullptr); | 130 nullptr); |
131 ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_DocReady, FALSE, TRUE, | 131 ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_DocReady, false, true, |
132 nullptr); | 132 nullptr); |
133 RunCalculateWidgets(); | 133 RunCalculateWidgets(); |
134 RunValidate(); | 134 RunValidate(); |
135 if (RunLayout()) { | 135 if (RunLayout()) { |
136 ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_Ready, FALSE, TRUE, | 136 ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_Ready, false, true, |
137 nullptr); | 137 nullptr); |
138 } | 138 } |
139 m_CalculateAccs.RemoveAll(); | 139 m_CalculateAccs.RemoveAll(); |
140 if (m_pFocusAcc && !m_pFocusWidget) { | 140 if (m_pFocusAcc && !m_pFocusWidget) { |
141 SetFocusWidgetAcc(m_pFocusAcc); | 141 SetFocusWidgetAcc(m_pFocusAcc); |
142 } | 142 } |
143 m_iStatus = XFA_DOCVIEW_LAYOUTSTATUS_End; | 143 m_iStatus = XFA_DOCVIEW_LAYOUTSTATUS_End; |
144 } | 144 } |
145 int32_t CXFA_FFDocView::GetLayoutStatus() { | 145 int32_t CXFA_FFDocView::GetLayoutStatus() { |
146 return m_iStatus; | 146 return m_iStatus; |
(...skipping 27 matching lines...) Expand all Loading... |
174 void CXFA_FFDocView::UpdateDocView() { | 174 void CXFA_FFDocView::UpdateDocView() { |
175 if (IsUpdateLocked()) { | 175 if (IsUpdateLocked()) { |
176 return; | 176 return; |
177 } | 177 } |
178 LockUpdate(); | 178 LockUpdate(); |
179 int32_t iNewAdds = m_NewAddedNodes.GetSize(); | 179 int32_t iNewAdds = m_NewAddedNodes.GetSize(); |
180 for (int32_t i = 0; i < iNewAdds; i++) { | 180 for (int32_t i = 0; i < iNewAdds; i++) { |
181 CXFA_Node* pNode = m_NewAddedNodes[i]; | 181 CXFA_Node* pNode = m_NewAddedNodes[i]; |
182 InitCalculate(pNode); | 182 InitCalculate(pNode); |
183 InitValidate(pNode); | 183 InitValidate(pNode); |
184 ExecEventActivityByDeepFirst(pNode, XFA_EVENT_Ready, TRUE, TRUE, nullptr); | 184 ExecEventActivityByDeepFirst(pNode, XFA_EVENT_Ready, true, true, nullptr); |
185 } | 185 } |
186 m_NewAddedNodes.RemoveAll(); | 186 m_NewAddedNodes.RemoveAll(); |
187 RunSubformIndexChange(); | 187 RunSubformIndexChange(); |
188 RunCalculateWidgets(); | 188 RunCalculateWidgets(); |
189 RunValidate(); | 189 RunValidate(); |
190 ShowNullTestMsg(); | 190 ShowNullTestMsg(); |
191 if (RunLayout() && m_bLayoutEvent) { | 191 if (RunLayout() && m_bLayoutEvent) { |
192 RunEventLayoutReady(); | 192 RunEventLayoutReady(); |
193 } | 193 } |
194 m_bLayoutEvent = FALSE; | 194 m_bLayoutEvent = false; |
195 m_CalculateAccs.RemoveAll(); | 195 m_CalculateAccs.RemoveAll(); |
196 RunInvalidate(); | 196 RunInvalidate(); |
197 UnlockUpdate(); | 197 UnlockUpdate(); |
198 } | 198 } |
199 int32_t CXFA_FFDocView::CountPageViews() { | 199 int32_t CXFA_FFDocView::CountPageViews() { |
200 if (!m_pXFADocLayout) { | 200 if (!m_pXFADocLayout) { |
201 return 0; | 201 return 0; |
202 } | 202 } |
203 return m_pXFADocLayout->CountPages(); | 203 return m_pXFADocLayout->CountPages(); |
204 } | 204 } |
205 CXFA_FFPageView* CXFA_FFDocView::GetPageView(int32_t nIndex) { | 205 CXFA_FFPageView* CXFA_FFDocView::GetPageView(int32_t nIndex) { |
206 if (!m_pXFADocLayout) { | 206 if (!m_pXFADocLayout) { |
207 return nullptr; | 207 return nullptr; |
208 } | 208 } |
209 return static_cast<CXFA_FFPageView*>(m_pXFADocLayout->GetPage(nIndex)); | 209 return static_cast<CXFA_FFPageView*>(m_pXFADocLayout->GetPage(nIndex)); |
210 } | 210 } |
211 | 211 |
212 CXFA_LayoutProcessor* CXFA_FFDocView::GetXFALayout() const { | 212 CXFA_LayoutProcessor* CXFA_FFDocView::GetXFALayout() const { |
213 return m_pDoc->GetXFADoc()->GetDocLayout(); | 213 return m_pDoc->GetXFADoc()->GetDocLayout(); |
214 } | 214 } |
215 FX_BOOL CXFA_FFDocView::ResetSingleWidgetAccData(CXFA_WidgetAcc* pWidgetAcc) { | 215 bool CXFA_FFDocView::ResetSingleWidgetAccData(CXFA_WidgetAcc* pWidgetAcc) { |
216 CXFA_Node* pNode = pWidgetAcc->GetNode(); | 216 CXFA_Node* pNode = pWidgetAcc->GetNode(); |
217 XFA_Element eType = pNode->GetElementType(); | 217 XFA_Element eType = pNode->GetElementType(); |
218 if (eType != XFA_Element::Field && eType != XFA_Element::ExclGroup) { | 218 if (eType != XFA_Element::Field && eType != XFA_Element::ExclGroup) { |
219 return FALSE; | 219 return false; |
220 } | 220 } |
221 pWidgetAcc->ResetData(); | 221 pWidgetAcc->ResetData(); |
222 pWidgetAcc->UpdateUIDisplay(); | 222 pWidgetAcc->UpdateUIDisplay(); |
223 if (CXFA_Validate validate = pWidgetAcc->GetValidate()) { | 223 if (CXFA_Validate validate = pWidgetAcc->GetValidate()) { |
224 AddValidateWidget(pWidgetAcc); | 224 AddValidateWidget(pWidgetAcc); |
225 validate.GetNode()->SetFlag(XFA_NodeFlag_NeedsInitApp, false); | 225 validate.GetNode()->SetFlag(XFA_NodeFlag_NeedsInitApp, false); |
226 } | 226 } |
227 return TRUE; | 227 return true; |
228 } | 228 } |
229 void CXFA_FFDocView::ResetWidgetData(CXFA_WidgetAcc* pWidgetAcc) { | 229 void CXFA_FFDocView::ResetWidgetData(CXFA_WidgetAcc* pWidgetAcc) { |
230 m_bLayoutEvent = TRUE; | 230 m_bLayoutEvent = true; |
231 FX_BOOL bChanged = FALSE; | 231 bool bChanged = false; |
232 CXFA_Node* pFormNode = nullptr; | 232 CXFA_Node* pFormNode = nullptr; |
233 if (pWidgetAcc) { | 233 if (pWidgetAcc) { |
234 bChanged = ResetSingleWidgetAccData(pWidgetAcc); | 234 bChanged = ResetSingleWidgetAccData(pWidgetAcc); |
235 pFormNode = pWidgetAcc->GetNode(); | 235 pFormNode = pWidgetAcc->GetNode(); |
236 } else { | 236 } else { |
237 pFormNode = GetRootSubform(); | 237 pFormNode = GetRootSubform(); |
238 } | 238 } |
239 if (!pFormNode) { | 239 if (!pFormNode) { |
240 return; | 240 return; |
241 } | 241 } |
(...skipping 30 matching lines...) Expand all Loading... |
272 CXFA_Node* pPresentNode = | 272 CXFA_Node* pPresentNode = |
273 pConfigItem->GetChild(0, XFA_Element::Present); | 273 pConfigItem->GetChild(0, XFA_Element::Present); |
274 pValidateNode = pPresentNode | 274 pValidateNode = pPresentNode |
275 ? pPresentNode->GetChild(0, XFA_Element::Validate) | 275 ? pPresentNode->GetChild(0, XFA_Element::Validate) |
276 : nullptr; | 276 : nullptr; |
277 } | 277 } |
278 if (pValidateNode) { | 278 if (pValidateNode) { |
279 wsValidateStr = pValidateNode->GetContent(); | 279 wsValidateStr = pValidateNode->GetContent(); |
280 } | 280 } |
281 } | 281 } |
282 FX_BOOL bValidate = FALSE; | 282 bool bValidate = false; |
283 switch (pParam->m_iValidateActivities) { | 283 switch (pParam->m_iValidateActivities) { |
284 case XFA_VALIDATE_preSubmit: | 284 case XFA_VALIDATE_preSubmit: |
285 bValidate = wsValidateStr.Find(L"preSubmit") != -1; | 285 bValidate = wsValidateStr.Find(L"preSubmit") != -1; |
286 break; | 286 break; |
287 case XFA_VALIDATE_prePrint: | 287 case XFA_VALIDATE_prePrint: |
288 bValidate = wsValidateStr.Find(L"prePrint") != -1; | 288 bValidate = wsValidateStr.Find(L"prePrint") != -1; |
289 break; | 289 break; |
290 case XFA_VALIDATE_preExecute: | 290 case XFA_VALIDATE_preExecute: |
291 bValidate = wsValidateStr.Find(L"preExecute") != -1; | 291 bValidate = wsValidateStr.Find(L"preExecute") != -1; |
292 break; | 292 break; |
293 case XFA_VALIDATE_preSave: | 293 case XFA_VALIDATE_preSave: |
294 bValidate = wsValidateStr.Find(L"preSave") != -1; | 294 bValidate = wsValidateStr.Find(L"preSave") != -1; |
295 break; | 295 break; |
296 } | 296 } |
297 if (!bValidate) { | 297 if (!bValidate) { |
298 return XFA_EVENTERROR_Success; | 298 return XFA_EVENTERROR_Success; |
299 } | 299 } |
300 } | 300 } |
301 CXFA_Node* pNode = pWidgetAcc ? pWidgetAcc->GetNode() : nullptr; | 301 CXFA_Node* pNode = pWidgetAcc ? pWidgetAcc->GetNode() : nullptr; |
302 if (!pNode) { | 302 if (!pNode) { |
303 CXFA_Node* pRootItem = | 303 CXFA_Node* pRootItem = |
304 ToNode(m_pDoc->GetXFADoc()->GetXFAObject(XFA_HASHCODE_Form)); | 304 ToNode(m_pDoc->GetXFADoc()->GetXFAObject(XFA_HASHCODE_Form)); |
305 if (!pRootItem) { | 305 if (!pRootItem) { |
306 return XFA_EVENTERROR_Error; | 306 return XFA_EVENTERROR_Error; |
307 } | 307 } |
308 pNode = pRootItem->GetChild(0, XFA_Element::Subform); | 308 pNode = pRootItem->GetChild(0, XFA_Element::Subform); |
309 } | 309 } |
310 ExecEventActivityByDeepFirst(pNode, pParam->m_eType, pParam->m_bIsFormReady, | 310 ExecEventActivityByDeepFirst(pNode, pParam->m_eType, pParam->m_bIsFormReady, |
311 TRUE, nullptr); | 311 true, nullptr); |
312 return XFA_EVENTERROR_Success; | 312 return XFA_EVENTERROR_Success; |
313 } | 313 } |
314 CXFA_FFWidgetHandler* CXFA_FFDocView::GetWidgetHandler() { | 314 CXFA_FFWidgetHandler* CXFA_FFDocView::GetWidgetHandler() { |
315 if (!m_pWidgetHandler) { | 315 if (!m_pWidgetHandler) { |
316 m_pWidgetHandler.reset(new CXFA_FFWidgetHandler(this)); | 316 m_pWidgetHandler.reset(new CXFA_FFWidgetHandler(this)); |
317 } | 317 } |
318 return m_pWidgetHandler.get(); | 318 return m_pWidgetHandler.get(); |
319 } | 319 } |
320 | 320 |
321 CXFA_WidgetAccIterator* CXFA_FFDocView::CreateWidgetAccIterator( | 321 CXFA_WidgetAccIterator* CXFA_FFDocView::CreateWidgetAccIterator( |
322 XFA_WIDGETORDER eOrder) { | 322 XFA_WIDGETORDER eOrder) { |
323 CXFA_Node* pFormRoot = GetRootSubform(); | 323 CXFA_Node* pFormRoot = GetRootSubform(); |
324 return pFormRoot ? new CXFA_WidgetAccIterator(this, pFormRoot) : nullptr; | 324 return pFormRoot ? new CXFA_WidgetAccIterator(this, pFormRoot) : nullptr; |
325 } | 325 } |
326 CXFA_FFWidget* CXFA_FFDocView::GetFocusWidget() { | 326 CXFA_FFWidget* CXFA_FFDocView::GetFocusWidget() { |
327 return m_pFocusWidget; | 327 return m_pFocusWidget; |
328 } | 328 } |
329 void CXFA_FFDocView::KillFocus() { | 329 void CXFA_FFDocView::KillFocus() { |
330 if (m_pFocusWidget && | 330 if (m_pFocusWidget && |
331 (m_pFocusWidget->GetStatus() & XFA_WidgetStatus_Focused)) { | 331 (m_pFocusWidget->GetStatus() & XFA_WidgetStatus_Focused)) { |
332 (m_pFocusWidget)->OnKillFocus(nullptr); | 332 (m_pFocusWidget)->OnKillFocus(nullptr); |
333 } | 333 } |
334 m_pFocusAcc = nullptr; | 334 m_pFocusAcc = nullptr; |
335 m_pFocusWidget = nullptr; | 335 m_pFocusWidget = nullptr; |
336 m_pOldFocusWidget = nullptr; | 336 m_pOldFocusWidget = nullptr; |
337 } | 337 } |
338 FX_BOOL CXFA_FFDocView::SetFocus(CXFA_FFWidget* hWidget) { | 338 bool CXFA_FFDocView::SetFocus(CXFA_FFWidget* hWidget) { |
339 CXFA_FFWidget* pNewFocus = hWidget; | 339 CXFA_FFWidget* pNewFocus = hWidget; |
340 if (m_pOldFocusWidget == pNewFocus) { | 340 if (m_pOldFocusWidget == pNewFocus) { |
341 return FALSE; | 341 return false; |
342 } | 342 } |
343 CXFA_FFWidget* pOldFocus = m_pOldFocusWidget; | 343 CXFA_FFWidget* pOldFocus = m_pOldFocusWidget; |
344 m_pOldFocusWidget = pNewFocus; | 344 m_pOldFocusWidget = pNewFocus; |
345 if (pOldFocus) { | 345 if (pOldFocus) { |
346 if (m_pFocusWidget != m_pOldFocusWidget && | 346 if (m_pFocusWidget != m_pOldFocusWidget && |
347 (pOldFocus->GetStatus() & XFA_WidgetStatus_Focused)) { | 347 (pOldFocus->GetStatus() & XFA_WidgetStatus_Focused)) { |
348 m_pFocusWidget = pOldFocus; | 348 m_pFocusWidget = pOldFocus; |
349 pOldFocus->OnKillFocus(pNewFocus); | 349 pOldFocus->OnKillFocus(pNewFocus); |
350 } else if ((pOldFocus->GetStatus() & XFA_WidgetStatus_Visible)) { | 350 } else if ((pOldFocus->GetStatus() & XFA_WidgetStatus_Visible)) { |
351 if (!pOldFocus->IsLoaded()) { | 351 if (!pOldFocus->IsLoaded()) { |
352 pOldFocus->LoadWidget(); | 352 pOldFocus->LoadWidget(); |
353 } | 353 } |
354 pOldFocus->OnSetFocus(m_pFocusWidget); | 354 pOldFocus->OnSetFocus(m_pFocusWidget); |
355 m_pFocusWidget = pOldFocus; | 355 m_pFocusWidget = pOldFocus; |
356 pOldFocus->OnKillFocus(pNewFocus); | 356 pOldFocus->OnKillFocus(pNewFocus); |
357 } | 357 } |
358 } | 358 } |
359 if (m_pFocusWidget == m_pOldFocusWidget) { | 359 if (m_pFocusWidget == m_pOldFocusWidget) { |
360 return FALSE; | 360 return false; |
361 } | 361 } |
362 pNewFocus = m_pOldFocusWidget; | 362 pNewFocus = m_pOldFocusWidget; |
363 if (m_pListFocusWidget && pNewFocus == m_pListFocusWidget) { | 363 if (m_pListFocusWidget && pNewFocus == m_pListFocusWidget) { |
364 m_pFocusAcc = nullptr; | 364 m_pFocusAcc = nullptr; |
365 m_pFocusWidget = nullptr; | 365 m_pFocusWidget = nullptr; |
366 m_pListFocusWidget = nullptr; | 366 m_pListFocusWidget = nullptr; |
367 m_pOldFocusWidget = nullptr; | 367 m_pOldFocusWidget = nullptr; |
368 return FALSE; | 368 return false; |
369 } | 369 } |
370 if (pNewFocus && (pNewFocus->GetStatus() & XFA_WidgetStatus_Visible)) { | 370 if (pNewFocus && (pNewFocus->GetStatus() & XFA_WidgetStatus_Visible)) { |
371 if (!pNewFocus->IsLoaded()) { | 371 if (!pNewFocus->IsLoaded()) { |
372 pNewFocus->LoadWidget(); | 372 pNewFocus->LoadWidget(); |
373 } | 373 } |
374 pNewFocus->OnSetFocus(m_pFocusWidget); | 374 pNewFocus->OnSetFocus(m_pFocusWidget); |
375 } | 375 } |
376 m_pFocusAcc = pNewFocus ? pNewFocus->GetDataAcc() : nullptr; | 376 m_pFocusAcc = pNewFocus ? pNewFocus->GetDataAcc() : nullptr; |
377 m_pFocusWidget = pNewFocus; | 377 m_pFocusWidget = pNewFocus; |
378 m_pOldFocusWidget = m_pFocusWidget; | 378 m_pOldFocusWidget = m_pFocusWidget; |
379 return TRUE; | 379 return true; |
380 } | 380 } |
381 CXFA_WidgetAcc* CXFA_FFDocView::GetFocusWidgetAcc() { | 381 CXFA_WidgetAcc* CXFA_FFDocView::GetFocusWidgetAcc() { |
382 return m_pFocusAcc; | 382 return m_pFocusAcc; |
383 } | 383 } |
384 void CXFA_FFDocView::SetFocusWidgetAcc(CXFA_WidgetAcc* pWidgetAcc) { | 384 void CXFA_FFDocView::SetFocusWidgetAcc(CXFA_WidgetAcc* pWidgetAcc) { |
385 CXFA_FFWidget* pNewFocus = | 385 CXFA_FFWidget* pNewFocus = |
386 pWidgetAcc ? pWidgetAcc->GetNextWidget(nullptr) : nullptr; | 386 pWidgetAcc ? pWidgetAcc->GetNextWidget(nullptr) : nullptr; |
387 if (SetFocus(pNewFocus)) { | 387 if (SetFocus(pNewFocus)) { |
388 m_pFocusAcc = pWidgetAcc; | 388 m_pFocusAcc = pWidgetAcc; |
389 if (m_iStatus == XFA_DOCVIEW_LAYOUTSTATUS_End) { | 389 if (m_iStatus == XFA_DOCVIEW_LAYOUTSTATUS_End) { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 } | 430 } |
431 default: | 431 default: |
432 break; | 432 break; |
433 } | 433 } |
434 int32_t iRet = | 434 int32_t iRet = |
435 pWidgetAcc->ProcessEvent(gs_EventActivity[pParam->m_eType], pParam); | 435 pWidgetAcc->ProcessEvent(gs_EventActivity[pParam->m_eType], pParam); |
436 return iRet; | 436 return iRet; |
437 } | 437 } |
438 int32_t CXFA_FFDocView::ExecEventActivityByDeepFirst(CXFA_Node* pFormNode, | 438 int32_t CXFA_FFDocView::ExecEventActivityByDeepFirst(CXFA_Node* pFormNode, |
439 XFA_EVENTTYPE eEventType, | 439 XFA_EVENTTYPE eEventType, |
440 FX_BOOL bIsFormReady, | 440 bool bIsFormReady, |
441 FX_BOOL bRecursive, | 441 bool bRecursive, |
442 CXFA_Node* pExclude) { | 442 CXFA_Node* pExclude) { |
443 int32_t iRet = XFA_EVENTERROR_NotExist; | 443 int32_t iRet = XFA_EVENTERROR_NotExist; |
444 if (pFormNode == pExclude) { | 444 if (pFormNode == pExclude) { |
445 return iRet; | 445 return iRet; |
446 } | 446 } |
447 XFA_Element elementType = pFormNode->GetElementType(); | 447 XFA_Element elementType = pFormNode->GetElementType(); |
448 if (elementType == XFA_Element::Field) { | 448 if (elementType == XFA_Element::Field) { |
449 if (eEventType == XFA_EVENT_IndexChange) { | 449 if (eEventType == XFA_EVENT_IndexChange) { |
450 return iRet; | 450 return iRet; |
451 } | 451 } |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 CXFA_FFPageView* pFFPageView = static_cast<CXFA_FFPageView*>(pSender); | 528 CXFA_FFPageView* pFFPageView = static_cast<CXFA_FFPageView*>(pSender); |
529 m_pDoc->GetDocEnvironment()->PageViewEvent(pFFPageView, dwEvent); | 529 m_pDoc->GetDocEnvironment()->PageViewEvent(pFFPageView, dwEvent); |
530 } | 530 } |
531 | 531 |
532 void CXFA_FFDocView::LockUpdate() { | 532 void CXFA_FFDocView::LockUpdate() { |
533 m_iLock++; | 533 m_iLock++; |
534 } | 534 } |
535 void CXFA_FFDocView::UnlockUpdate() { | 535 void CXFA_FFDocView::UnlockUpdate() { |
536 m_iLock--; | 536 m_iLock--; |
537 } | 537 } |
538 FX_BOOL CXFA_FFDocView::IsUpdateLocked() { | 538 bool CXFA_FFDocView::IsUpdateLocked() { |
539 return m_iLock > 0; | 539 return m_iLock > 0; |
540 } | 540 } |
541 void CXFA_FFDocView::ClearInvalidateList() { | 541 void CXFA_FFDocView::ClearInvalidateList() { |
542 m_mapPageInvalidate.clear(); | 542 m_mapPageInvalidate.clear(); |
543 } | 543 } |
544 void CXFA_FFDocView::AddInvalidateRect(CXFA_FFWidget* pWidget, | 544 void CXFA_FFDocView::AddInvalidateRect(CXFA_FFWidget* pWidget, |
545 const CFX_RectF& rtInvalidate) { | 545 const CFX_RectF& rtInvalidate) { |
546 AddInvalidateRect(pWidget->GetPageView(), rtInvalidate); | 546 AddInvalidateRect(pWidget->GetPageView(), rtInvalidate); |
547 } | 547 } |
548 | 548 |
549 void CXFA_FFDocView::AddInvalidateRect(CXFA_FFPageView* pPageView, | 549 void CXFA_FFDocView::AddInvalidateRect(CXFA_FFPageView* pPageView, |
550 const CFX_RectF& rtInvalidate) { | 550 const CFX_RectF& rtInvalidate) { |
551 if (m_mapPageInvalidate[pPageView]) { | 551 if (m_mapPageInvalidate[pPageView]) { |
552 m_mapPageInvalidate[pPageView]->Union(rtInvalidate); | 552 m_mapPageInvalidate[pPageView]->Union(rtInvalidate); |
553 return; | 553 return; |
554 } | 554 } |
555 CFX_RectF* pRect = new CFX_RectF; | 555 CFX_RectF* pRect = new CFX_RectF; |
556 pRect->Set(rtInvalidate.left, rtInvalidate.top, rtInvalidate.width, | 556 pRect->Set(rtInvalidate.left, rtInvalidate.top, rtInvalidate.width, |
557 rtInvalidate.height); | 557 rtInvalidate.height); |
558 m_mapPageInvalidate[pPageView].reset(pRect); | 558 m_mapPageInvalidate[pPageView].reset(pRect); |
559 } | 559 } |
560 | 560 |
561 void CXFA_FFDocView::RunInvalidate() { | 561 void CXFA_FFDocView::RunInvalidate() { |
562 for (const auto& pair : m_mapPageInvalidate) | 562 for (const auto& pair : m_mapPageInvalidate) |
563 m_pDoc->GetDocEnvironment()->InvalidateRect(pair.first, *pair.second, 0); | 563 m_pDoc->GetDocEnvironment()->InvalidateRect(pair.first, *pair.second, 0); |
564 m_mapPageInvalidate.clear(); | 564 m_mapPageInvalidate.clear(); |
565 } | 565 } |
566 | 566 |
567 FX_BOOL CXFA_FFDocView::RunLayout() { | 567 bool CXFA_FFDocView::RunLayout() { |
568 LockUpdate(); | 568 LockUpdate(); |
569 m_bInLayoutStatus = TRUE; | 569 m_bInLayoutStatus = true; |
570 if (!m_pXFADocLayout->IncrementLayout() && | 570 if (!m_pXFADocLayout->IncrementLayout() && |
571 m_pXFADocLayout->StartLayout() < 100) { | 571 m_pXFADocLayout->StartLayout() < 100) { |
572 m_pXFADocLayout->DoLayout(); | 572 m_pXFADocLayout->DoLayout(); |
573 UnlockUpdate(); | 573 UnlockUpdate(); |
574 m_bInLayoutStatus = FALSE; | 574 m_bInLayoutStatus = false; |
575 m_pDoc->GetDocEnvironment()->PageViewEvent(nullptr, | 575 m_pDoc->GetDocEnvironment()->PageViewEvent(nullptr, |
576 XFA_PAGEVIEWEVENT_StopLayout); | 576 XFA_PAGEVIEWEVENT_StopLayout); |
577 return TRUE; | 577 return true; |
578 } | 578 } |
579 m_bInLayoutStatus = FALSE; | 579 m_bInLayoutStatus = false; |
580 m_pDoc->GetDocEnvironment()->PageViewEvent(nullptr, | 580 m_pDoc->GetDocEnvironment()->PageViewEvent(nullptr, |
581 XFA_PAGEVIEWEVENT_StopLayout); | 581 XFA_PAGEVIEWEVENT_StopLayout); |
582 UnlockUpdate(); | 582 UnlockUpdate(); |
583 return FALSE; | 583 return false; |
584 } | 584 } |
585 void CXFA_FFDocView::RunSubformIndexChange() { | 585 void CXFA_FFDocView::RunSubformIndexChange() { |
586 int32_t iSubforms = m_IndexChangedSubforms.GetSize(); | 586 int32_t iSubforms = m_IndexChangedSubforms.GetSize(); |
587 for (int32_t i = 0; i < iSubforms; i++) { | 587 for (int32_t i = 0; i < iSubforms; i++) { |
588 CXFA_Node* pSubformNode = m_IndexChangedSubforms[i]; | 588 CXFA_Node* pSubformNode = m_IndexChangedSubforms[i]; |
589 CXFA_WidgetAcc* pWidgetAcc = | 589 CXFA_WidgetAcc* pWidgetAcc = |
590 static_cast<CXFA_WidgetAcc*>(pSubformNode->GetWidgetData()); | 590 static_cast<CXFA_WidgetAcc*>(pSubformNode->GetWidgetData()); |
591 if (!pWidgetAcc) { | 591 if (!pWidgetAcc) { |
592 continue; | 592 continue; |
593 } | 593 } |
(...skipping 11 matching lines...) Expand all Loading... |
605 void CXFA_FFDocView::AddIndexChangedSubform(CXFA_Node* pNode) { | 605 void CXFA_FFDocView::AddIndexChangedSubform(CXFA_Node* pNode) { |
606 ASSERT(pNode->GetElementType() == XFA_Element::Subform); | 606 ASSERT(pNode->GetElementType() == XFA_Element::Subform); |
607 m_IndexChangedSubforms.Add(pNode); | 607 m_IndexChangedSubforms.Add(pNode); |
608 } | 608 } |
609 void CXFA_FFDocView::RunDocClose() { | 609 void CXFA_FFDocView::RunDocClose() { |
610 CXFA_Node* pRootItem = | 610 CXFA_Node* pRootItem = |
611 ToNode(m_pDoc->GetXFADoc()->GetXFAObject(XFA_HASHCODE_Form)); | 611 ToNode(m_pDoc->GetXFADoc()->GetXFAObject(XFA_HASHCODE_Form)); |
612 if (!pRootItem) { | 612 if (!pRootItem) { |
613 return; | 613 return; |
614 } | 614 } |
615 ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_DocClose, FALSE, TRUE, | 615 ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_DocClose, false, true, |
616 nullptr); | 616 nullptr); |
617 } | 617 } |
618 void CXFA_FFDocView::DestroyDocView() { | 618 void CXFA_FFDocView::DestroyDocView() { |
619 ClearInvalidateList(); | 619 ClearInvalidateList(); |
620 m_iStatus = XFA_DOCVIEW_LAYOUTSTATUS_None; | 620 m_iStatus = XFA_DOCVIEW_LAYOUTSTATUS_None; |
621 m_iLock = 0; | 621 m_iLock = 0; |
622 m_ValidateAccs.RemoveAll(); | 622 m_ValidateAccs.RemoveAll(); |
623 m_BindItems.RemoveAll(); | 623 m_BindItems.RemoveAll(); |
624 m_CalculateAccs.RemoveAll(); | 624 m_CalculateAccs.RemoveAll(); |
625 } | 625 } |
626 FX_BOOL CXFA_FFDocView::IsStaticNotify() { | 626 bool CXFA_FFDocView::IsStaticNotify() { |
627 return m_pDoc->GetDocType() == XFA_DOCTYPE_Static; | 627 return m_pDoc->GetDocType() == XFA_DOCTYPE_Static; |
628 } | 628 } |
629 void CXFA_FFDocView::AddCalculateWidgetAcc(CXFA_WidgetAcc* pWidgetAcc) { | 629 void CXFA_FFDocView::AddCalculateWidgetAcc(CXFA_WidgetAcc* pWidgetAcc) { |
630 int32_t iAccs = m_CalculateAccs.GetSize(); | 630 int32_t iAccs = m_CalculateAccs.GetSize(); |
631 CXFA_WidgetAcc* pCurrentAcc = | 631 CXFA_WidgetAcc* pCurrentAcc = |
632 iAccs > 0 ? m_CalculateAccs[iAccs - 1] : nullptr; | 632 iAccs > 0 ? m_CalculateAccs[iAccs - 1] : nullptr; |
633 if (pCurrentAcc != pWidgetAcc) { | 633 if (pCurrentAcc != pWidgetAcc) { |
634 m_CalculateAccs.Add(pWidgetAcc); | 634 m_CalculateAccs.Add(pWidgetAcc); |
635 } | 635 } |
636 } | 636 } |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
683 CXFA_WidgetAcc* pCurAcc = m_CalculateAccs[i]; | 683 CXFA_WidgetAcc* pCurAcc = m_CalculateAccs[i]; |
684 pCurAcc->GetNode()->SetUserData(XFA_CalcRefCount, (void*)(uintptr_t)0); | 684 pCurAcc->GetNode()->SetUserData(XFA_CalcRefCount, (void*)(uintptr_t)0); |
685 } | 685 } |
686 m_CalculateAccs.RemoveAll(); | 686 m_CalculateAccs.RemoveAll(); |
687 return XFA_EVENTERROR_Success; | 687 return XFA_EVENTERROR_Success; |
688 } | 688 } |
689 void CXFA_FFDocView::AddValidateWidget(CXFA_WidgetAcc* pWidget) { | 689 void CXFA_FFDocView::AddValidateWidget(CXFA_WidgetAcc* pWidget) { |
690 if (m_ValidateAccs.Find(pWidget) < 0) | 690 if (m_ValidateAccs.Find(pWidget) < 0) |
691 m_ValidateAccs.Add(pWidget); | 691 m_ValidateAccs.Add(pWidget); |
692 } | 692 } |
693 FX_BOOL CXFA_FFDocView::InitCalculate(CXFA_Node* pNode) { | 693 bool CXFA_FFDocView::InitCalculate(CXFA_Node* pNode) { |
694 ExecEventActivityByDeepFirst(pNode, XFA_EVENT_InitCalculate, FALSE, TRUE, | 694 ExecEventActivityByDeepFirst(pNode, XFA_EVENT_InitCalculate, false, true, |
695 nullptr); | 695 nullptr); |
696 return TRUE; | 696 return true; |
697 } | 697 } |
698 FX_BOOL CXFA_FFDocView::InitValidate(CXFA_Node* pNode) { | 698 bool CXFA_FFDocView::InitValidate(CXFA_Node* pNode) { |
699 if (!m_pDoc->GetDocEnvironment()->IsValidationsEnabled(m_pDoc)) { | 699 if (!m_pDoc->GetDocEnvironment()->IsValidationsEnabled(m_pDoc)) { |
700 return FALSE; | 700 return false; |
701 } | 701 } |
702 ExecEventActivityByDeepFirst(pNode, XFA_EVENT_Validate, FALSE, TRUE, nullptr); | 702 ExecEventActivityByDeepFirst(pNode, XFA_EVENT_Validate, false, true, nullptr); |
703 m_ValidateAccs.RemoveAll(); | 703 m_ValidateAccs.RemoveAll(); |
704 return TRUE; | 704 return true; |
705 } | 705 } |
706 FX_BOOL CXFA_FFDocView::RunValidate() { | 706 bool CXFA_FFDocView::RunValidate() { |
707 if (!m_pDoc->GetDocEnvironment()->IsValidationsEnabled(m_pDoc)) { | 707 if (!m_pDoc->GetDocEnvironment()->IsValidationsEnabled(m_pDoc)) { |
708 return FALSE; | 708 return false; |
709 } | 709 } |
710 int32_t iCounts = m_ValidateAccs.GetSize(); | 710 int32_t iCounts = m_ValidateAccs.GetSize(); |
711 for (int32_t i = 0; i < iCounts; i++) { | 711 for (int32_t i = 0; i < iCounts; i++) { |
712 CXFA_WidgetAcc* pAcc = m_ValidateAccs[i]; | 712 CXFA_WidgetAcc* pAcc = m_ValidateAccs[i]; |
713 if (pAcc->GetNode()->HasRemovedChildren()) | 713 if (pAcc->GetNode()->HasRemovedChildren()) |
714 continue; | 714 continue; |
715 | 715 |
716 pAcc->ProcessValidate(); | 716 pAcc->ProcessValidate(); |
717 } | 717 } |
718 m_ValidateAccs.RemoveAll(); | 718 m_ValidateAccs.RemoveAll(); |
719 return TRUE; | 719 return true; |
720 } | 720 } |
721 FX_BOOL CXFA_FFDocView::RunEventLayoutReady() { | 721 bool CXFA_FFDocView::RunEventLayoutReady() { |
722 CXFA_Node* pRootItem = | 722 CXFA_Node* pRootItem = |
723 ToNode(m_pDoc->GetXFADoc()->GetXFAObject(XFA_HASHCODE_Form)); | 723 ToNode(m_pDoc->GetXFADoc()->GetXFAObject(XFA_HASHCODE_Form)); |
724 if (!pRootItem) { | 724 if (!pRootItem) { |
725 return FALSE; | 725 return false; |
726 } | 726 } |
727 ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_Ready, FALSE, TRUE, | 727 ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_Ready, false, true, |
728 nullptr); | 728 nullptr); |
729 RunLayout(); | 729 RunLayout(); |
730 return TRUE; | 730 return true; |
731 } | 731 } |
732 void CXFA_FFDocView::RunBindItems() { | 732 void CXFA_FFDocView::RunBindItems() { |
733 for (int32_t i = 0; i < m_BindItems.GetSize(); i++) { | 733 for (int32_t i = 0; i < m_BindItems.GetSize(); i++) { |
734 if (m_BindItems[i]->HasRemovedChildren()) | 734 if (m_BindItems[i]->HasRemovedChildren()) |
735 continue; | 735 continue; |
736 | 736 |
737 CXFA_Node* pWidgetNode = m_BindItems[i]->GetNodeItem(XFA_NODEITEM_Parent); | 737 CXFA_Node* pWidgetNode = m_BindItems[i]->GetNodeItem(XFA_NODEITEM_Parent); |
738 CXFA_WidgetAcc* pAcc = | 738 CXFA_WidgetAcc* pAcc = |
739 static_cast<CXFA_WidgetAcc*>(pWidgetNode->GetWidgetData()); | 739 static_cast<CXFA_WidgetAcc*>(pWidgetNode->GetWidgetData()); |
740 if (!pAcc) | 740 if (!pAcc) |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
842 } | 842 } |
843 | 843 |
844 CXFA_WidgetAcc* CXFA_WidgetAccIterator::MoveToPrevious() { | 844 CXFA_WidgetAcc* CXFA_WidgetAccIterator::MoveToPrevious() { |
845 return nullptr; | 845 return nullptr; |
846 } | 846 } |
847 | 847 |
848 CXFA_WidgetAcc* CXFA_WidgetAccIterator::GetCurrentWidgetAcc() { | 848 CXFA_WidgetAcc* CXFA_WidgetAccIterator::GetCurrentWidgetAcc() { |
849 return nullptr; | 849 return nullptr; |
850 } | 850 } |
851 | 851 |
852 FX_BOOL CXFA_WidgetAccIterator::SetCurrentWidgetAcc(CXFA_WidgetAcc* hWidget) { | 852 bool CXFA_WidgetAccIterator::SetCurrentWidgetAcc(CXFA_WidgetAcc* hWidget) { |
853 return FALSE; | 853 return false; |
854 } | 854 } |
855 | 855 |
856 void CXFA_WidgetAccIterator::SkipTree() { | 856 void CXFA_WidgetAccIterator::SkipTree() { |
857 m_ContentIterator.SkipChildrenAndMoveToNext(); | 857 m_ContentIterator.SkipChildrenAndMoveToNext(); |
858 m_pCurWidgetAcc = nullptr; | 858 m_pCurWidgetAcc = nullptr; |
859 } | 859 } |
OLD | NEW |