32d2789c7d79fad2d2d8c209d7e3d35a296c4506
[pdfium.git] / xfa / src / fxfa / src / app / xfa_ffdocview.cpp
1 // Copyright 2014 PDFium Authors. All rights reserved.\r
2 // Use of this source code is governed by a BSD-style license that can be\r
3 // found in the LICENSE file.\r
4 \r
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com\r
6 \r
7 #include "../../../foxitlib.h"\r
8 #include "../common/xfa_common.h"\r
9 #include "xfa_fwladapter.h"\r
10 #include "xfa_ffdocview.h"\r
11 #include "xfa_ffpageview.h"\r
12 #include "xfa_ffwidgethandler.h"\r
13 #include "xfa_ffdoc.h"\r
14 #include "xfa_ffwidget.h"\r
15 #include "xfa_fffield.h"\r
16 #include "xfa_ffpushbutton.h"\r
17 #include "xfa_ffcheckbutton.h"\r
18 #include "xfa_ffchoicelist.h"\r
19 #include "xfa_ffimageedit.h"\r
20 #include "xfa_fftextedit.h"\r
21 #include "xfa_ffbarcode.h"\r
22 #include "xfa_ffdraw.h"\r
23 #include "xfa_fftext.h"\r
24 #include "xfa_ffpath.h"\r
25 #include "xfa_ffimage.h"\r
26 #include "xfa_ffexclgroup.h"\r
27 #include "xfa_ffsubform.h"\r
28 #include "xfa_ffsignature.h"\r
29 #include "xfa_ffapp.h"\r
30 #include "xfa_textlayout.h"\r
31 #include "xfa_ffwidgetacc.h"\r
32 extern const XFA_ATTRIBUTEENUM gs_EventActivity[] = {\r
33     XFA_ATTRIBUTEENUM_Click,\r
34     XFA_ATTRIBUTEENUM_Change,\r
35     XFA_ATTRIBUTEENUM_DocClose,\r
36     XFA_ATTRIBUTEENUM_DocReady,\r
37     XFA_ATTRIBUTEENUM_Enter,\r
38     XFA_ATTRIBUTEENUM_Exit,\r
39     XFA_ATTRIBUTEENUM_Full,\r
40     XFA_ATTRIBUTEENUM_IndexChange,\r
41     XFA_ATTRIBUTEENUM_Initialize,\r
42     XFA_ATTRIBUTEENUM_MouseDown,\r
43     XFA_ATTRIBUTEENUM_MouseEnter,\r
44     XFA_ATTRIBUTEENUM_MouseExit,\r
45     XFA_ATTRIBUTEENUM_MouseUp,\r
46     XFA_ATTRIBUTEENUM_PostExecute,\r
47     XFA_ATTRIBUTEENUM_PostOpen,\r
48     XFA_ATTRIBUTEENUM_PostPrint,\r
49     XFA_ATTRIBUTEENUM_PostSave,\r
50     XFA_ATTRIBUTEENUM_PostSign,\r
51     XFA_ATTRIBUTEENUM_PostSubmit,\r
52     XFA_ATTRIBUTEENUM_PreExecute,\r
53     XFA_ATTRIBUTEENUM_PreOpen,\r
54     XFA_ATTRIBUTEENUM_PrePrint,\r
55     XFA_ATTRIBUTEENUM_PreSave,\r
56     XFA_ATTRIBUTEENUM_PreSign,\r
57     XFA_ATTRIBUTEENUM_PreSubmit,\r
58     XFA_ATTRIBUTEENUM_Ready,\r
59     XFA_ATTRIBUTEENUM_Unknown,\r
60 };\r
61 CXFA_FFDocView::CXFA_FFDocView(CXFA_FFDoc* pDoc)\r
62     : m_pDoc(pDoc)\r
63     , m_pWidgetHandler(NULL)\r
64     , m_pXFADocLayout(NULL)\r
65     , m_iStatus(XFA_DOCVIEW_LAYOUTSTATUS_None)\r
66     , m_iLock(0)\r
67     , m_bLayoutEvent(FALSE)\r
68     , m_pFocusAcc(NULL)\r
69     , m_pFocusWidget(NULL)\r
70     , m_pListFocusWidget(NULL)\r
71     , m_pOldFocusWidget(NULL)\r
72     , m_bInLayoutStatus(FALSE)\r
73 {\r
74 }\r
75 CXFA_FFDocView::~CXFA_FFDocView()\r
76 {\r
77     DestroyDocView();\r
78     if (m_pWidgetHandler) {\r
79         delete m_pWidgetHandler;\r
80     }\r
81     m_pWidgetHandler = NULL;\r
82 }\r
83 void CXFA_FFDocView::InitLayout(CXFA_Node* pNode)\r
84 {\r
85     RunBindItems();\r
86     ExecEventActivityByDeepFirst(pNode, XFA_EVENT_Initialize);\r
87     ExecEventActivityByDeepFirst(pNode, XFA_EVENT_IndexChange);\r
88 }\r
89 FX_INT32 CXFA_FFDocView::StartLayout(FX_INT32 iStartPage )\r
90 {\r
91     m_iStatus = XFA_DOCVIEW_LAYOUTSTATUS_Start;\r
92     m_pDoc->GetXFADoc()->DoProtoMerge();\r
93     m_pDoc->GetXFADoc()->DoDataMerge();\r
94     m_pXFADocLayout = GetXFALayout();\r
95     FX_INT32 iStatus = m_pXFADocLayout->StartLayout();\r
96     if (iStatus < 0) {\r
97         return iStatus;\r
98     }\r
99     CXFA_Node* pRootItem = (CXFA_Node*)m_pDoc->GetXFADoc()->GetXFANode(XFA_HASHCODE_Form);\r
100     if (!pRootItem) {\r
101         return iStatus;\r
102     }\r
103     InitLayout(pRootItem);\r
104     InitCalculate(pRootItem);\r
105     InitValidate(pRootItem);\r
106     ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_Ready, TRUE);\r
107     m_iStatus = XFA_DOCVIEW_LAYOUTSTATUS_Start;\r
108     return iStatus;\r
109 }\r
110 FX_INT32 CXFA_FFDocView::DoLayout(IFX_Pause *pPause )\r
111 {\r
112     FX_INT32 iStatus = 100;\r
113     iStatus = m_pXFADocLayout->DoLayout(pPause);\r
114     if (iStatus != 100) {\r
115         return iStatus;\r
116     }\r
117     m_iStatus = XFA_DOCVIEW_LAYOUTSTATUS_Doing;\r
118     return iStatus;\r
119 }\r
120 void CXFA_FFDocView::StopLayout()\r
121 {\r
122     CXFA_Node* pRootItem = (CXFA_Node*)m_pDoc->GetXFADoc()->GetXFANode(XFA_HASHCODE_Form);\r
123     if (!pRootItem) {\r
124         return;\r
125     }\r
126     CXFA_Node* pSubformNode = pRootItem->GetChild(0, XFA_ELEMENT_Subform);\r
127     if (!pSubformNode) {\r
128         return;\r
129     }\r
130     CXFA_Node* pPageSetNode = pSubformNode->GetFirstChildByClass(XFA_ELEMENT_PageSet);\r
131     if(!pPageSetNode) {\r
132         return;\r
133     }\r
134     RunCalculateWidgets();\r
135     RunValidate();\r
136     InitLayout(pPageSetNode);\r
137     InitCalculate(pPageSetNode);\r
138     InitValidate(pPageSetNode);\r
139     ExecEventActivityByDeepFirst(pPageSetNode, XFA_EVENT_Ready, TRUE);\r
140     ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_Ready);\r
141     ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_DocReady);\r
142     RunCalculateWidgets();\r
143     RunValidate();\r
144     if(RunLayout()) {\r
145         ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_Ready);\r
146     }\r
147     m_CalculateAccs.RemoveAll();\r
148     if (m_pFocusAcc && !m_pFocusWidget) {\r
149         SetFocusWidgetAcc(m_pFocusAcc);\r
150     }\r
151     m_iStatus = XFA_DOCVIEW_LAYOUTSTATUS_End;\r
152 }\r
153 FX_INT32 CXFA_FFDocView::GetLayoutStatus()\r
154 {\r
155     return m_iStatus;\r
156 }\r
157 void CXFA_FFDocView::ShowNullTestMsg()\r
158 {\r
159     FX_INT32 iCount = m_arrNullTestMsg.GetSize();\r
160     CXFA_FFApp* pApp = m_pDoc->GetApp();\r
161     IXFA_AppProvider* pAppProvider = pApp->GetAppProvider();\r
162     if (pAppProvider && iCount) {\r
163         FX_INT32 iRemain = iCount > 7 ? iCount - 7 : 0;\r
164         iCount -= iRemain;\r
165         CFX_WideString wsMsg;\r
166         for (FX_INT32 i = 0; i < iCount; i++) {\r
167             wsMsg += m_arrNullTestMsg[i] + FX_WSTRC(L"\n");\r
168         }\r
169         if (iRemain > 0) {\r
170             CFX_WideString wsLimit;\r
171             pAppProvider->LoadString(XFA_IDS_ValidateLimit, wsLimit);\r
172             if (!wsLimit.IsEmpty()) {\r
173                 CFX_WideString wsTemp;\r
174                 wsTemp.Format((FX_LPCWSTR)wsLimit, iRemain);\r
175                 wsMsg += FX_WSTRC(L"\n") + wsTemp;\r
176             }\r
177         }\r
178         CFX_WideString wsTitle;\r
179         pAppProvider->LoadString(XFA_IDS_AppName, wsTitle);\r
180         pAppProvider->MsgBox(wsMsg, wsTitle, XFA_MBICON_Status, XFA_MB_OK);\r
181     }\r
182     m_arrNullTestMsg.RemoveAll();\r
183 }\r
184 void CXFA_FFDocView::UpdateDocView()\r
185 {\r
186     if (IsUpdateLocked()) {\r
187         return;\r
188     }\r
189     LockUpdate();\r
190     FX_INT32 iNewAdds = m_NewAddedNodes.GetSize();\r
191     for (FX_INT32 i = 0; i < iNewAdds; i++) {\r
192         CXFA_Node* pNode = (CXFA_Node*)m_NewAddedNodes[i];\r
193         InitCalculate(pNode);\r
194         InitValidate(pNode);\r
195         ExecEventActivityByDeepFirst(pNode, XFA_EVENT_Ready, TRUE);\r
196     }\r
197     m_NewAddedNodes.RemoveAll();\r
198     this->RunSubformIndexChange();\r
199     this->RunCalculateWidgets();\r
200     this->RunValidate();\r
201     ShowNullTestMsg();\r
202     m_iStatus = XFA_DOCVIEW_LAYOUTSTATUS_Next;\r
203     if (RunLayout() && m_bLayoutEvent) {\r
204         RunEventLayoutReady();\r
205     }\r
206     m_bLayoutEvent = FALSE;\r
207     m_CalculateAccs.RemoveAll();\r
208     this->RunInvalidate();\r
209     UnlockUpdate();\r
210 }\r
211 FX_INT32 CXFA_FFDocView::CountPageViews()\r
212 {\r
213     if (!m_pXFADocLayout) {\r
214         return 0;\r
215     }\r
216     return m_pXFADocLayout->CountPages();\r
217 }\r
218 IXFA_PageView* CXFA_FFDocView::GetPageView(FX_INT32 nIndex)\r
219 {\r
220     if (!m_pXFADocLayout) {\r
221         return NULL;\r
222     }\r
223     return (CXFA_FFPageView*)m_pXFADocLayout->GetPage(nIndex);\r
224 }\r
225 XFA_HWIDGET CXFA_FFDocView::GetWidgetByName(FX_WSTR wsName)\r
226 {\r
227     return (XFA_HWIDGET)GetWidgetByName(wsName, NULL);\r
228 }\r
229 CXFA_WidgetAcc* CXFA_FFDocView::GetWidgetAccByName(FX_WSTR wsName)\r
230 {\r
231     return GetWidgetAccByName(wsName, NULL);\r
232 }\r
233 IXFA_DocLayout* CXFA_FFDocView::GetXFALayout() const\r
234 {\r
235     return m_pDoc->GetXFADoc()->GetDocLayout();\r
236 }\r
237 FX_BOOL CXFA_FFDocView::ResetSingleWidgetAccData(CXFA_WidgetAcc* pWidgetAcc)\r
238 {\r
239     CXFA_Node* pNode = pWidgetAcc->GetNode();\r
240     XFA_ELEMENT eType = pNode->GetClassID();\r
241     if (eType != XFA_ELEMENT_Field && eType != XFA_ELEMENT_ExclGroup) {\r
242         return FALSE;\r
243     }\r
244     FX_BOOL bNotify = IsStaticNotify();\r
245     pWidgetAcc->ResetData();\r
246     pWidgetAcc->UpdateUIDisplay();\r
247     if (bNotify) {\r
248         pWidgetAcc->NotifyEvent(XFA_WIDGETEVENT_PostContentChanged, NULL, NULL, NULL);\r
249     }\r
250     if (CXFA_Validate validate = pWidgetAcc->GetValidate()) {\r
251         AddValidateWidget(pWidgetAcc);\r
252         ((CXFA_Node*)validate)->SetFlag(XFA_NODEFLAG_NeedsInitApp, TRUE, FALSE);\r
253     }\r
254     return TRUE;\r
255 }\r
256 void CXFA_FFDocView::ResetWidgetData(CXFA_WidgetAcc* pWidgetAcc )\r
257 {\r
258     m_bLayoutEvent = TRUE;\r
259     FX_BOOL bChanged = FALSE;\r
260     CXFA_Node* pFormNode = NULL;\r
261     if (pWidgetAcc) {\r
262         bChanged = ResetSingleWidgetAccData(pWidgetAcc);\r
263         pFormNode = pWidgetAcc->GetNode();\r
264     } else {\r
265         pFormNode = GetRootSubform();\r
266     }\r
267     if (!pFormNode) {\r
268         return;\r
269     }\r
270     if (pFormNode->GetClassID() != XFA_ELEMENT_Field && pFormNode->GetClassID() != XFA_ELEMENT_ExclGroup) {\r
271         CXFA_WidgetAccIterator Iterator(this, pFormNode);\r
272         while (CXFA_WidgetAcc* pAcc = Iterator.MoveToNext()) {\r
273             bChanged |= ResetSingleWidgetAccData(pAcc);\r
274             if (pAcc->GetNode()->GetClassID() == XFA_ELEMENT_ExclGroup) {\r
275                 Iterator.SkipTree();\r
276             }\r
277         }\r
278     }\r
279     if (bChanged) {\r
280         m_pDoc->GetDocProvider()->SetChangeMark(m_pDoc);\r
281     }\r
282 }\r
283 FX_INT32 CXFA_FFDocView::ProcessWidgetEvent(CXFA_EventParam* pParam, CXFA_WidgetAcc* pWidgetAcc )\r
284 {\r
285     if (pParam == NULL) {\r
286         return XFA_EVENTERROR_Error;\r
287     }\r
288     if (pParam->m_eType == XFA_EVENT_Validate) {\r
289         CFX_WideString wsValidateStr = FX_WSTRC(L"preSubmit");\r
290         CXFA_Node* pConfigItem = (CXFA_Node*)m_pDoc->GetXFADoc()->GetXFANode(XFA_HASHCODE_Config);\r
291         if (pConfigItem) {\r
292             CXFA_Node* pValidateNode = NULL;\r
293             CXFA_Node* pAcrobatNode = pConfigItem->GetChild(0, XFA_ELEMENT_Acrobat);\r
294             pValidateNode = pAcrobatNode ? pAcrobatNode->GetChild(0, XFA_ELEMENT_Validate) : NULL;\r
295             if (!pValidateNode) {\r
296                 CXFA_Node* pPresentNode = pConfigItem->GetChild(0, XFA_ELEMENT_Present);\r
297                 pValidateNode = pPresentNode ? pPresentNode->GetChild(0, XFA_ELEMENT_Validate) : NULL;\r
298             }\r
299             if (pValidateNode) {\r
300                 wsValidateStr = pValidateNode->GetContent();\r
301             }\r
302         }\r
303         FX_BOOL bValidate = FALSE;\r
304         switch (pParam->m_iValidateActivities) {\r
305             case XFA_VALIDATE_preSubmit:\r
306                 bValidate = wsValidateStr.Find(L"preSubmit") != -1;\r
307                 break;\r
308             case XFA_VALIDATE_prePrint:\r
309                 bValidate = wsValidateStr.Find(L"prePrint") != -1;\r
310                 break;\r
311             case XFA_VALIDATE_preExecute:\r
312                 bValidate = wsValidateStr.Find(L"preExecute") != -1;\r
313                 break;\r
314             case XFA_VALIDATE_preSave:\r
315                 bValidate = wsValidateStr.Find(L"preSave") != -1;\r
316                 break;\r
317         }\r
318         if (!bValidate) {\r
319             return XFA_EVENTERROR_Sucess;\r
320         }\r
321     }\r
322     CXFA_Node* pNode = pWidgetAcc ? pWidgetAcc->GetNode() : NULL;\r
323     if (!pNode) {\r
324         CXFA_Node* pRootItem = (CXFA_Node*)m_pDoc->GetXFADoc()->GetXFANode(XFA_HASHCODE_Form);\r
325         if (!pRootItem) {\r
326             return XFA_EVENTERROR_Error;\r
327         }\r
328         pNode = pRootItem->GetChild(0, XFA_ELEMENT_Subform);\r
329     }\r
330     ExecEventActivityByDeepFirst(pNode, pParam->m_eType, pParam->m_bIsFormReady);\r
331     return XFA_EVENTERROR_Sucess;\r
332 }\r
333 IXFA_WidgetHandler* CXFA_FFDocView::GetWidgetHandler()\r
334 {\r
335     if (!m_pWidgetHandler) {\r
336         m_pWidgetHandler = FX_NEW CXFA_FFWidgetHandler(this);\r
337     }\r
338     return m_pWidgetHandler;\r
339 }\r
340 IXFA_WidgetIterator* CXFA_FFDocView::CreateWidgetIterator()\r
341 {\r
342     CXFA_Node* pFormRoot = GetRootSubform();\r
343     if (!pFormRoot) {\r
344         return NULL;\r
345     }\r
346     return FX_NEW CXFA_FFDocWidgetIterator(this, pFormRoot);\r
347 }\r
348 IXFA_WidgetAccIterator* CXFA_FFDocView::CreateWidgetAccIterator(XFA_WIDGETORDER eOrder )\r
349 {\r
350     CXFA_Node* pFormRoot = GetRootSubform();\r
351     if (!pFormRoot) {\r
352         return NULL;\r
353     }\r
354     return FX_NEW CXFA_WidgetAccIterator(this, pFormRoot);\r
355 }\r
356 XFA_HWIDGET CXFA_FFDocView::GetFocusWidget()\r
357 {\r
358     return (XFA_HWIDGET)m_pFocusWidget;\r
359 }\r
360 void CXFA_FFDocView::KillFocus()\r
361 {\r
362     if (m_pFocusWidget && (m_pFocusWidget->GetStatus() & XFA_WIDGETSTATUS_Focused)) {\r
363         (m_pFocusWidget)->OnKillFocus(NULL);\r
364     }\r
365     m_pFocusAcc = NULL;\r
366     m_pFocusWidget = NULL;\r
367     m_pOldFocusWidget = NULL;\r
368 }\r
369 FX_BOOL CXFA_FFDocView::SetFocus(XFA_HWIDGET hWidget)\r
370 {\r
371     CXFA_FFWidget* pNewFocus = (CXFA_FFWidget*)hWidget;\r
372     if (m_pOldFocusWidget == pNewFocus) {\r
373         return FALSE;\r
374     }\r
375     CXFA_FFWidget* pOldFocus = m_pOldFocusWidget;\r
376     m_pOldFocusWidget = pNewFocus;\r
377     if (pOldFocus) {\r
378         if (m_pFocusWidget != m_pOldFocusWidget && (pOldFocus->GetStatus() & XFA_WIDGETSTATUS_Focused)) {\r
379             m_pFocusWidget = pOldFocus;\r
380             pOldFocus->OnKillFocus(pNewFocus);\r
381         } else if ((pOldFocus->GetStatus() & XFA_WIDGETSTATUS_Visible)) {\r
382             if (!pOldFocus->IsLoaded()) {\r
383                 pOldFocus->LoadWidget();\r
384             }\r
385             pOldFocus->OnSetFocus(m_pFocusWidget);\r
386             m_pFocusWidget = pOldFocus;\r
387             pOldFocus->OnKillFocus(pNewFocus);\r
388         }\r
389     }\r
390     if (m_pFocusWidget == m_pOldFocusWidget) {\r
391         return FALSE;\r
392     }\r
393     pNewFocus = m_pOldFocusWidget;\r
394     if (m_pListFocusWidget && pNewFocus == m_pListFocusWidget) {\r
395         m_pFocusAcc = NULL;\r
396         m_pFocusWidget = NULL;\r
397         m_pListFocusWidget = NULL;\r
398         m_pOldFocusWidget = NULL;\r
399         return FALSE;\r
400     }\r
401     if (pNewFocus && (pNewFocus->GetStatus() & XFA_WIDGETSTATUS_Visible)) {\r
402         if (!pNewFocus->IsLoaded()) {\r
403             pNewFocus->LoadWidget();\r
404         }\r
405         pNewFocus->OnSetFocus(m_pFocusWidget);\r
406     }\r
407     m_pFocusAcc = pNewFocus ? pNewFocus->GetDataAcc() : NULL;\r
408     m_pFocusWidget = pNewFocus;\r
409     m_pOldFocusWidget = m_pFocusWidget;\r
410     return TRUE;\r
411 }\r
412 CXFA_WidgetAcc* CXFA_FFDocView::GetFocusWidgetAcc()\r
413 {\r
414     return m_pFocusAcc;\r
415 }\r
416 void CXFA_FFDocView::SetFocusWidgetAcc(CXFA_WidgetAcc* pWidgetAcc)\r
417 {\r
418     CXFA_FFWidget* pNewFocus = pWidgetAcc ? pWidgetAcc->GetNextWidget(NULL) : NULL;\r
419     if (SetFocus((XFA_HWIDGET)pNewFocus)) {\r
420         m_pFocusAcc = pWidgetAcc;\r
421         if (m_iStatus >= XFA_DOCVIEW_LAYOUTSTATUS_End) {\r
422             m_pDoc->GetDocProvider()->SetFocusWidget(m_pDoc, (XFA_HWIDGET)m_pFocusWidget);\r
423         }\r
424     }\r
425 }\r
426 void CXFA_FFDocView::DeleteLayoutItem(CXFA_FFWidget* pWidget)\r
427 {\r
428     if (m_pFocusAcc == pWidget->GetDataAcc()) {\r
429         m_pFocusAcc = NULL;\r
430         m_pFocusWidget = NULL;\r
431         m_pOldFocusWidget = NULL;\r
432     }\r
433 }\r
434 static FX_INT32 XFA_ProcessEvent(CXFA_FFDocView* pDocView, CXFA_WidgetAcc* pWidgetAcc, CXFA_EventParam* pParam)\r
435 {\r
436     if (!pParam || pParam->m_eType == XFA_EVENT_Unknown) {\r
437         return XFA_EVENTERROR_NotExist;\r
438     }\r
439     if (!pWidgetAcc || pWidgetAcc->GetClassID() == XFA_ELEMENT_Draw) {\r
440         return XFA_EVENTERROR_NotExist;\r
441     }\r
442     switch (pParam->m_eType) {\r
443         case XFA_EVENT_Calculate:\r
444             return pWidgetAcc->ProcessCalculate();\r
445         case XFA_EVENT_Validate:\r
446             if (((CXFA_FFDoc*)pDocView->GetDoc())->GetDocProvider()->IsValidationsEnabled(pDocView->GetDoc())) {\r
447                 return pWidgetAcc->ProcessValidate(0x01);\r
448             }\r
449             return XFA_EVENTERROR_Disabled;\r
450         case XFA_EVENT_InitCalculate: {\r
451                 CXFA_Calculate calc = pWidgetAcc->GetCalculate();\r
452                 if (!calc) {\r
453                     return XFA_EVENTERROR_NotExist;\r
454                 }\r
455                 if (pWidgetAcc->GetNode()->HasFlag(XFA_NODEFLAG_UserInteractive)) {\r
456                     return XFA_EVENTERROR_Disabled;\r
457                 }\r
458                 CXFA_Script script = calc.GetScript();\r
459                 return pWidgetAcc->ExecuteScript(script, pParam);\r
460             }\r
461         default:\r
462             break;\r
463     }\r
464     FX_INT32 iRet = pWidgetAcc->ProcessEvent(gs_EventActivity[pParam->m_eType], pParam);\r
465     return iRet;\r
466 }\r
467 FX_INT32 CXFA_FFDocView::ExecEventActivityByDeepFirst(CXFA_Node* pFormNode, XFA_EVENTTYPE eEventType, FX_BOOL bIsFormReady, FX_BOOL bRecursive, CXFA_Node* pExclude)\r
468 {\r
469     FX_INT32 iRet = XFA_EVENTERROR_NotExist;\r
470     if (pFormNode == pExclude) {\r
471         return iRet;\r
472     }\r
473     XFA_ELEMENT elementType = pFormNode->GetClassID();\r
474     if (elementType == XFA_ELEMENT_Field) {\r
475         if (eEventType == XFA_EVENT_IndexChange) {\r
476             return iRet;\r
477         }\r
478         CXFA_WidgetAcc* pWidgetAcc = (CXFA_WidgetAcc*)pFormNode->GetWidgetData();\r
479         if (pWidgetAcc == NULL) {\r
480             return iRet;\r
481         }\r
482         CXFA_EventParam eParam;\r
483         eParam.m_eType = eEventType;\r
484         eParam.m_pTarget = pWidgetAcc;\r
485         eParam.m_bIsFormReady = bIsFormReady;\r
486         return XFA_ProcessEvent(this, pWidgetAcc, &eParam);\r
487     }\r
488     if (bRecursive) {\r
489         for(CXFA_Node* pNode = pFormNode->GetNodeItem(XFA_NODEITEM_FirstChild, XFA_OBJECTTYPE_ContainerNode); pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling, XFA_OBJECTTYPE_ContainerNode)) {\r
490             elementType = pNode->GetClassID();\r
491             if (elementType != XFA_ELEMENT_Variables && elementType != XFA_ELEMENT_Draw) {\r
492                 iRet |= ExecEventActivityByDeepFirst(pNode, eEventType, bIsFormReady, bRecursive, pExclude);\r
493             }\r
494         }\r
495     }\r
496     CXFA_WidgetAcc* pWidgetAcc = (CXFA_WidgetAcc*)pFormNode->GetWidgetData();\r
497     if (pWidgetAcc == NULL) {\r
498         return iRet;\r
499     }\r
500     CXFA_EventParam eParam;\r
501     eParam.m_eType = eEventType;\r
502     eParam.m_pTarget = pWidgetAcc;\r
503     eParam.m_bIsFormReady = bIsFormReady;\r
504     iRet |= XFA_ProcessEvent(this, pWidgetAcc, &eParam);\r
505     return iRet;\r
506 }\r
507 CXFA_FFWidget* CXFA_FFDocView::GetWidgetByName(FX_WSTR wsName, CXFA_FFWidget* pRefWidget )\r
508 {\r
509     CXFA_WidgetAcc* pRefAcc = pRefWidget ? pRefWidget->GetDataAcc() : NULL;\r
510     if (CXFA_WidgetAcc* pAcc = GetWidgetAccByName(wsName, pRefAcc)) {\r
511         return pAcc->GetNextWidget(NULL);\r
512     }\r
513     return NULL;\r
514 }\r
515 CXFA_WidgetAcc* CXFA_FFDocView::GetWidgetAccByName(FX_WSTR wsName, CXFA_WidgetAcc* pRefWidgetAcc )\r
516 {\r
517     CFX_WideString wsExpression;\r
518     FX_DWORD dwStyle = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties | XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent;\r
519     IXFA_ScriptContext* pScriptContext = m_pDoc->GetXFADoc()->GetScriptContext();\r
520     if (!pScriptContext) {\r
521         return NULL;\r
522     }\r
523     CXFA_Node* refNode = NULL;\r
524     if(pRefWidgetAcc != NULL) {\r
525         refNode = pRefWidgetAcc->GetNode();\r
526         wsExpression = wsName;\r
527     } else {\r
528         wsExpression = L"$form." + wsName;\r
529     }\r
530     XFA_RESOLVENODE_RS resoveNodeRS;\r
531     FX_INT32 iRet = pScriptContext->ResolveObjects(refNode, wsExpression, resoveNodeRS, dwStyle);\r
532     if (iRet < 1) {\r
533         return NULL;\r
534     }\r
535     if (resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) {\r
536         CXFA_Object* pNode = resoveNodeRS.nodes[0];\r
537         if(pNode->IsNode()) {\r
538             return (CXFA_WidgetAcc*)((CXFA_Node*)pNode)->GetWidgetData();\r
539         }\r
540     }\r
541     return NULL;\r
542 }\r
543 void CXFA_FFDocView::OnPageEvent(IXFA_LayoutPage *pSender, XFA_PAGEEVENT eEvent, FX_INT32 iPageIndex)\r
544 {\r
545     FX_BOOL bNofify = m_iStatus >= XFA_DOCVIEW_LAYOUTSTATUS_End;\r
546     if (eEvent == XFA_PAGEEVENT_PageRemoved) {\r
547         if (bNofify) {\r
548             m_pDoc->GetDocProvider()->PageViewEvent((CXFA_FFPageView*)pSender, XFA_PAGEVIEWEVENT_PostRemoved);\r
549         }\r
550     } else if (eEvent == XFA_PAGEEVENT_PageAdded) {\r
551         if (bNofify) {\r
552             m_pDoc->GetDocProvider()->PageViewEvent((CXFA_FFPageView*)pSender, XFA_PAGEVIEWEVENT_PostAdded);\r
553             ((CXFA_FFPageView*)pSender)->LoadPageView();\r
554         }\r
555     }\r
556 }\r
557 void CXFA_FFDocView::LockUpdate()\r
558 {\r
559     m_iLock++;\r
560 }\r
561 void CXFA_FFDocView::UnlockUpdate()\r
562 {\r
563     m_iLock--;\r
564 }\r
565 FX_BOOL CXFA_FFDocView::IsUpdateLocked()\r
566 {\r
567     return m_iLock;\r
568 }\r
569 void CXFA_FFDocView::ClearInvalidateList()\r
570 {\r
571     FX_POSITION ps = m_mapPageInvalidate.GetStartPosition();\r
572     while (ps) {\r
573         void* pPageView = NULL;\r
574         CFX_RectF* pRect = NULL;\r
575         m_mapPageInvalidate.GetNextAssoc(ps, pPageView, (void*&)pRect);\r
576         delete pRect;\r
577     }\r
578     m_mapPageInvalidate.RemoveAll();\r
579 }\r
580 void CXFA_FFDocView::AddInvalidateRect(CXFA_FFWidget* pWidget, const CFX_RectF &rtInvalidate)\r
581 {\r
582     AddInvalidateRect(pWidget->GetPageView(), rtInvalidate);\r
583 }\r
584 void CXFA_FFDocView::AddInvalidateRect(IXFA_PageView* pPageView, const CFX_RectF &rtInvalidate)\r
585 {\r
586     CFX_RectF* pRect = (CFX_RectF*)m_mapPageInvalidate.GetValueAt(pPageView);\r
587     if (!pRect) {\r
588         pRect = FX_NEW CFX_RectF;\r
589         pRect->Set(rtInvalidate.left, rtInvalidate.top, rtInvalidate.width, rtInvalidate.height);\r
590         m_mapPageInvalidate.SetAt(pPageView, pRect);\r
591     } else {\r
592         pRect->Union(rtInvalidate);\r
593     }\r
594 }\r
595 void CXFA_FFDocView::RunInvalidate()\r
596 {\r
597     FX_POSITION ps = m_mapPageInvalidate.GetStartPosition();\r
598     while (ps) {\r
599         IXFA_PageView* pPageView = NULL;\r
600         CFX_RectF* pRect = NULL;\r
601         m_mapPageInvalidate.GetNextAssoc(ps, (void*&)pPageView, (void*&)pRect);\r
602         m_pDoc->GetDocProvider()->InvalidateRect(pPageView, *pRect);\r
603         delete pRect;\r
604     }\r
605     m_mapPageInvalidate.RemoveAll();\r
606 }\r
607 FX_BOOL CXFA_FFDocView::RunLayout()\r
608 {\r
609     LockUpdate();\r
610     m_bInLayoutStatus = TRUE;\r
611     if (!m_pXFADocLayout->IncrementLayout() && m_pXFADocLayout->StartLayout() < 100) {\r
612         m_pXFADocLayout->DoLayout();\r
613         UnlockUpdate();\r
614         m_bInLayoutStatus = FALSE;\r
615         return TRUE;\r
616     }\r
617     m_bInLayoutStatus = FALSE;\r
618     UnlockUpdate();\r
619     return FALSE;\r
620 }\r
621 void CXFA_FFDocView::RunSubformIndexChange()\r
622 {\r
623     FX_INT32 iSubforms = m_IndexChangedSubforms.GetSize();\r
624     for (FX_INT32 i = 0; i < iSubforms; i++) {\r
625         CXFA_Node* pSubformNode = (CXFA_Node*)m_IndexChangedSubforms[i];\r
626         CXFA_WidgetAcc* pWidgetAcc = (CXFA_WidgetAcc*)pSubformNode->GetWidgetData();\r
627         if (!pWidgetAcc) {\r
628             continue;\r
629         }\r
630         CXFA_EventParam eParam;\r
631         eParam.m_eType = XFA_EVENT_IndexChange;\r
632         eParam.m_pTarget = pWidgetAcc;\r
633         pWidgetAcc->ProcessEvent(XFA_ATTRIBUTEENUM_IndexChange, &eParam);\r
634     }\r
635     m_IndexChangedSubforms.RemoveAll();\r
636 }\r
637 void CXFA_FFDocView::AddNewFormNode(CXFA_Node* pNode)\r
638 {\r
639     m_NewAddedNodes.Add(pNode);\r
640     this->InitLayout(pNode);\r
641 }\r
642 void CXFA_FFDocView::AddIndexChangedSubform(CXFA_Node* pNode)\r
643 {\r
644     FXSYS_assert(pNode->GetClassID() == XFA_ELEMENT_Subform );\r
645     m_IndexChangedSubforms.Add(pNode);\r
646 }\r
647 void CXFA_FFDocView::RunDocClose()\r
648 {\r
649     CXFA_Node* pRootItem = (CXFA_Node*)m_pDoc->GetXFADoc()->GetXFANode(XFA_HASHCODE_Form);\r
650     if (!pRootItem) {\r
651         return;\r
652     }\r
653     ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_DocClose);\r
654 }\r
655 void CXFA_FFDocView::DestroyDocView()\r
656 {\r
657     ClearInvalidateList();\r
658     m_iStatus = XFA_DOCVIEW_LAYOUTSTATUS_None;\r
659     m_iLock = 0;\r
660     m_ValidateAccs.RemoveAll();\r
661     m_bindItems.RemoveAll();\r
662     m_CalculateAccs.RemoveAll();\r
663 }\r
664 FX_BOOL CXFA_FFDocView::IsStaticNotify()\r
665 {\r
666     return  m_pDoc->GetDocType() == XFA_DOCTYPE_Static;\r
667 }\r
668 void CXFA_FFDocView::AddCalculateWidgetAcc(CXFA_WidgetAcc* pWidgetAcc)\r
669 {\r
670     FX_INT32 iAccs = m_CalculateAccs.GetSize();\r
671     CXFA_WidgetAcc* pCurrentAcc = (iAccs < 1) ? (CXFA_WidgetAcc*)NULL : (CXFA_WidgetAcc*)m_CalculateAccs[iAccs - 1];\r
672     if (pCurrentAcc != pWidgetAcc) {\r
673         m_CalculateAccs.Add(pWidgetAcc);\r
674     }\r
675 }\r
676 void CXFA_FFDocView::AddCalculateNodeNotify(CXFA_Node* pNodeChange)\r
677 {\r
678     CXFA_CalcData* pGlobalData = (CXFA_CalcData*)pNodeChange->GetUserData(XFA_CalcData);\r
679     FX_INT32 iCount = pGlobalData ? pGlobalData->m_Globals.GetSize() : 0;\r
680     for (FX_INT32 i = 0; i <  iCount; i++) {\r
681         CXFA_WidgetAcc* pResultAcc = (CXFA_WidgetAcc*)pGlobalData->m_Globals[i];\r
682         if (pResultAcc->GetNode()->HasFlag(XFA_NODEFLAG_HasRemoved)) {\r
683             continue;\r
684         }\r
685         FX_INT32 iAccs = m_CalculateAccs.GetSize();\r
686         CXFA_WidgetAcc* pCurrentAcc = (iAccs < 1) ? (CXFA_WidgetAcc*)NULL : (CXFA_WidgetAcc*)m_CalculateAccs[iAccs - 1];\r
687         if (pCurrentAcc != pResultAcc) {\r
688             m_CalculateAccs.Add(pResultAcc);\r
689         }\r
690     }\r
691 }\r
692 void CXFA_FFDocView::RunCalculateRecursive(FX_INT32& iIndex)\r
693 {\r
694     while (iIndex < m_CalculateAccs.GetSize()) {\r
695         CXFA_WidgetAcc* pCurAcc = (CXFA_WidgetAcc*)m_CalculateAccs[iIndex];\r
696         AddCalculateNodeNotify(pCurAcc->GetNode());\r
697         FX_INT32 iRefCount = (FX_INT32)(FX_UINTPTR)pCurAcc->GetNode()->GetUserData(XFA_CalcRefCount);\r
698         iRefCount++;\r
699         pCurAcc->GetNode()->SetUserData(XFA_CalcRefCount, (FX_LPVOID)(FX_UINTPTR)iRefCount);\r
700         if (iRefCount > 11) {\r
701             break;\r
702         }\r
703         if ((pCurAcc->ProcessCalculate()) == XFA_EVENTERROR_Sucess) {\r
704             AddValidateWidget(pCurAcc);\r
705         }\r
706         iIndex++;\r
707         RunCalculateRecursive(iIndex);\r
708     }\r
709 }\r
710 FX_INT32 CXFA_FFDocView::RunCalculateWidgets()\r
711 {\r
712     if (!m_pDoc->GetDocProvider()->IsCalculationsEnabled(m_pDoc)) {\r
713         return XFA_EVENTERROR_Disabled;\r
714     }\r
715     FX_INT32 iCounts = m_CalculateAccs.GetSize();\r
716     FX_INT32 iIndex = 0;\r
717     if (iCounts > 0) {\r
718         RunCalculateRecursive(iIndex);\r
719     }\r
720     for (FX_INT32 i = 0; i < m_CalculateAccs.GetSize(); i++) {\r
721         CXFA_WidgetAcc* pCurAcc = (CXFA_WidgetAcc*)m_CalculateAccs[i];\r
722         pCurAcc->GetNode()->SetUserData(XFA_CalcRefCount, (FX_LPVOID)(FX_UINTPTR)0);\r
723     }\r
724     m_CalculateAccs.RemoveAll();\r
725     return XFA_EVENTERROR_Sucess;\r
726 }\r
727 void CXFA_FFDocView::AddValidateWidget(CXFA_WidgetAcc* pWidget)\r
728 {\r
729     if (m_ValidateAccs.Find(pWidget) < 0) {\r
730         m_ValidateAccs.Add(pWidget);\r
731     }\r
732 }\r
733 FX_BOOL CXFA_FFDocView::InitCalculate(CXFA_Node* pNode)\r
734 {\r
735     ExecEventActivityByDeepFirst(pNode, XFA_EVENT_InitCalculate);\r
736     return TRUE;\r
737 }\r
738 FX_BOOL CXFA_FFDocView::InitValidate(CXFA_Node* pNode)\r
739 {\r
740     if (!m_pDoc->GetDocProvider()->IsValidationsEnabled(m_pDoc)) {\r
741         return FALSE;\r
742     }\r
743     ExecEventActivityByDeepFirst(pNode, XFA_EVENT_Validate);\r
744     m_ValidateAccs.RemoveAll();\r
745     return TRUE;\r
746 }\r
747 FX_BOOL CXFA_FFDocView::RunValidate()\r
748 {\r
749     if (!m_pDoc->GetDocProvider()->IsValidationsEnabled(m_pDoc)) {\r
750         return FALSE;\r
751     }\r
752     FX_INT32 iCounts = m_ValidateAccs.GetSize();\r
753     for (FX_INT32 i = 0; i < iCounts; i++) {\r
754         CXFA_WidgetAcc* pAcc = (CXFA_WidgetAcc*)m_ValidateAccs[i];\r
755         if (pAcc->GetNode()->HasFlag(XFA_NODEFLAG_HasRemoved)) {\r
756             continue;\r
757         }\r
758         pAcc->ProcessValidate();\r
759     }\r
760     m_ValidateAccs.RemoveAll();\r
761     return TRUE;\r
762 }\r
763 FX_BOOL CXFA_FFDocView::RunEventLayoutReady()\r
764 {\r
765     CXFA_Node* pRootItem = (CXFA_Node*)m_pDoc->GetXFADoc()->GetXFANode(XFA_HASHCODE_Form);\r
766     if (!pRootItem) {\r
767         return FALSE;\r
768     }\r
769     ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_Ready);\r
770     RunLayout();\r
771     return TRUE;\r
772 }\r
773 void CXFA_FFDocView::RunBindItems()\r
774 {\r
775     FX_INT32 iCount = m_bindItems.GetSize();\r
776     for (FX_INT32 i = 0; i < iCount; i++) {\r
777         if (((CXFA_Node*)m_bindItems[i])->HasFlag(XFA_NODEFLAG_HasRemoved)) {\r
778             continue;\r
779         }\r
780         CXFA_Node* pWidgetNode = ((CXFA_Node*)m_bindItems[i])->GetNodeItem(XFA_NODEITEM_Parent);\r
781         CXFA_WidgetAcc* pAcc = (CXFA_WidgetAcc*)pWidgetNode->GetWidgetData();\r
782         if (!pAcc) {\r
783             continue;\r
784         }\r
785         CXFA_BindItems binditems((CXFA_Node*)m_bindItems[i]);\r
786         IXFA_ScriptContext* pScriptContext = pWidgetNode->GetDocument()->GetScriptContext();\r
787         CFX_WideStringC wsRef;\r
788         binditems.GetRef(wsRef);\r
789         FX_DWORD dwStyle = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties | XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_ALL;\r
790         XFA_RESOLVENODE_RS rs;\r
791         pScriptContext->ResolveObjects(pWidgetNode, wsRef, rs, dwStyle);\r
792         FX_INT32 iCount = rs.nodes.GetSize();\r
793         pAcc->DeleteItem(-1);\r
794         if (rs.dwFlags != XFA_RESOVENODE_RSTYPE_Nodes || iCount < 1) {\r
795             continue;\r
796         }\r
797         CFX_WideStringC wsValueRef, wsLabelRef;\r
798         binditems.GetValueRef(wsValueRef);\r
799         binditems.GetLabelRef(wsLabelRef);\r
800         FX_BOOL bUseValue = wsLabelRef.IsEmpty() || wsLabelRef == wsValueRef;\r
801         FX_BOOL bLabelUseContent = wsLabelRef.IsEmpty() || wsLabelRef == FX_WSTRC(L"$");\r
802         FX_BOOL bValueUseContent = wsValueRef.IsEmpty() || wsValueRef == FX_WSTRC(L"$");\r
803         CFX_WideString wsValue, wsLabel;\r
804         FX_DWORD uValueHash = FX_HashCode_String_GetW(CFX_WideString(wsValueRef), wsValueRef.GetLength());\r
805         FX_DWORD uLableHash = FX_HashCode_String_GetW(CFX_WideString(wsLabelRef), wsLabelRef.GetLength());\r
806         for (FX_INT32 i = 0; i < iCount; i++) {\r
807             CXFA_Object* refObj = rs.nodes[i];\r
808             if(!refObj->IsNode()) {\r
809                 continue;\r
810             }\r
811             CXFA_Node* refNode = (CXFA_Node*)refObj;\r
812             if (bValueUseContent) {\r
813                 wsValue = refNode->GetContent();\r
814             } else {\r
815                 CXFA_Node* nodeValue = refNode->GetFirstChildByName(uValueHash);\r
816                 if (nodeValue == NULL) {\r
817                     wsValue = refNode->GetContent();\r
818                 } else {\r
819                     wsValue = nodeValue->GetContent();\r
820                 }\r
821             }\r
822             if (!bUseValue) {\r
823                 if (bLabelUseContent) {\r
824                     wsLabel = refNode->GetContent();\r
825                 } else {\r
826                     CXFA_Node* nodeLabel =  refNode->GetFirstChildByName(wsLabelRef);\r
827                     if (nodeLabel != NULL) {\r
828                         wsLabel = nodeLabel->GetContent();\r
829                     }\r
830                 }\r
831             } else {\r
832                 wsLabel = wsValue;\r
833             }\r
834             pAcc->InsertItem(wsLabel, wsValue);\r
835         }\r
836     }\r
837     m_bindItems.RemoveAll();\r
838 }\r
839 void CXFA_FFDocView::SetChangeMark()\r
840 {\r
841     if (m_iStatus < XFA_DOCVIEW_LAYOUTSTATUS_End) {\r
842         return;\r
843     }\r
844     m_pDoc->GetDocProvider()->SetChangeMark(m_pDoc);\r
845 }\r
846 CXFA_Node* CXFA_FFDocView::GetRootSubform()\r
847 {\r
848     CXFA_Node* pFormPacketNode = (CXFA_Node*)m_pDoc->GetXFADoc()->GetXFANode(XFA_HASHCODE_Form);\r
849     if (!pFormPacketNode) {\r
850         return NULL;\r
851     }\r
852     return pFormPacketNode->GetFirstChildByClass(XFA_ELEMENT_Subform);\r
853 }\r
854 CXFA_FFDocWidgetIterator::CXFA_FFDocWidgetIterator(CXFA_FFDocView* pDocView, CXFA_Node* pTravelRoot)\r
855     : m_ContentIterator(pTravelRoot)\r
856 {\r
857     m_pDocView = pDocView;\r
858     m_pCurWidget = NULL;\r
859 }\r
860 CXFA_FFDocWidgetIterator::~CXFA_FFDocWidgetIterator()\r
861 {\r
862 }\r
863 void CXFA_FFDocWidgetIterator::Reset()\r
864 {\r
865     m_ContentIterator.Reset();\r
866     m_pCurWidget = NULL;\r
867 }\r
868 XFA_HWIDGET CXFA_FFDocWidgetIterator::MoveToFirst()\r
869 {\r
870     return NULL;\r
871 }\r
872 XFA_HWIDGET CXFA_FFDocWidgetIterator::MoveToLast()\r
873 {\r
874     return NULL;\r
875 }\r
876 XFA_HWIDGET CXFA_FFDocWidgetIterator::MoveToNext()\r
877 {\r
878     CXFA_Node* pItem = m_pCurWidget ? m_ContentIterator.MoveToNext() : m_ContentIterator.GetCurrent();\r
879     while (pItem) {\r
880         if (CXFA_WidgetAcc* pAcc = (CXFA_WidgetAcc*)pItem->GetWidgetData()) {\r
881             while ((m_pCurWidget = pAcc->GetNextWidget(NULL)) != NULL) {\r
882                 if (!m_pCurWidget->IsLoaded() && (m_pCurWidget->GetStatus() & XFA_WIDGETSTATUS_Visible)) {\r
883                     m_pCurWidget->LoadWidget();\r
884                 }\r
885                 return (XFA_HWIDGET)m_pCurWidget;\r
886             }\r
887         }\r
888         pItem = m_ContentIterator.MoveToNext();\r
889     }\r
890     return NULL;\r
891 }\r
892 XFA_HWIDGET CXFA_FFDocWidgetIterator::MoveToPrevious()\r
893 {\r
894     return NULL;\r
895 }\r
896 XFA_HWIDGET CXFA_FFDocWidgetIterator::GetCurrentWidget()\r
897 {\r
898     return NULL;\r
899 }\r
900 FX_BOOL CXFA_FFDocWidgetIterator::SetCurrentWidget(XFA_HWIDGET hWidget)\r
901 {\r
902     return FALSE;\r
903 }\r
904 IXFA_WidgetAccIterator* XFA_WidgetAccIterator_Create(CXFA_WidgetAcc* pTravelRoot, XFA_WIDGETORDER eOrder)\r
905 {\r
906     if (!pTravelRoot) {\r
907         return NULL;\r
908     }\r
909     return FX_NEW CXFA_WidgetAccIterator(pTravelRoot->GetDocView(), pTravelRoot->GetNode());\r
910 }\r
911 CXFA_WidgetAccIterator::CXFA_WidgetAccIterator(CXFA_FFDocView* pDocView, CXFA_Node* pTravelRoot)\r
912     : m_ContentIterator(pTravelRoot)\r
913 {\r
914     m_pDocView = pDocView;\r
915     m_pCurWidgetAcc = NULL;\r
916 }\r
917 CXFA_WidgetAccIterator::~CXFA_WidgetAccIterator()\r
918 {\r
919 }\r
920 void CXFA_WidgetAccIterator::Reset()\r
921 {\r
922     m_pCurWidgetAcc = NULL;\r
923     m_ContentIterator.Reset();\r
924 }\r
925 CXFA_WidgetAcc* CXFA_WidgetAccIterator::MoveToFirst()\r
926 {\r
927     return NULL;\r
928 }\r
929 CXFA_WidgetAcc* CXFA_WidgetAccIterator::MoveToLast()\r
930 {\r
931     return NULL;\r
932 }\r
933 CXFA_WidgetAcc* CXFA_WidgetAccIterator::MoveToNext()\r
934 {\r
935     CXFA_Node* pItem = m_pCurWidgetAcc ? m_ContentIterator.MoveToNext() : m_ContentIterator.GetCurrent();\r
936     while (pItem) {\r
937         if ((m_pCurWidgetAcc = (CXFA_WidgetAcc*)pItem->GetWidgetData()) != NULL) {\r
938             return m_pCurWidgetAcc;\r
939         }\r
940         pItem = m_ContentIterator.MoveToNext();\r
941     }\r
942     return NULL;\r
943 }\r
944 CXFA_WidgetAcc* CXFA_WidgetAccIterator::MoveToPrevious()\r
945 {\r
946     return NULL;\r
947 }\r
948 CXFA_WidgetAcc* CXFA_WidgetAccIterator::GetCurrentWidgetAcc()\r
949 {\r
950     return NULL;\r
951 }\r
952 FX_BOOL CXFA_WidgetAccIterator::SetCurrentWidgetAcc(CXFA_WidgetAcc* hWidget)\r
953 {\r
954     return FALSE;\r
955 }\r
956 void CXFA_WidgetAccIterator::SkipTree()\r
957 {\r
958     m_ContentIterator.SkipChildrenAndMoveToNext();\r
959     m_pCurWidgetAcc = NULL;\r
960 }\r