1// Copyright 2014 PDFium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7#ifndef XFA_FXFA_CXFA_FFNOTIFY_H_
8#define XFA_FXFA_CXFA_FFNOTIFY_H_
9
10#include "xfa/fxfa/cxfa_eventparam.h"
11#include "xfa/fxfa/parser/cxfa_document.h"
12
13class CXFA_FFWidgetHandler;
14class CXFA_ContainerLayoutItem;
15class CXFA_ContentLayoutItem;
16
17class CXFA_FFNotify {
18 public:
19  explicit CXFA_FFNotify(CXFA_FFDoc* pDoc);
20  ~CXFA_FFNotify();
21
22  void OnPageEvent(CXFA_ContainerLayoutItem* pSender, uint32_t dwEvent);
23
24  void OnWidgetListItemAdded(CXFA_WidgetAcc* pSender,
25                             const wchar_t* pLabel,
26                             const wchar_t* pValue,
27                             int32_t iIndex);
28  void OnWidgetListItemRemoved(CXFA_WidgetAcc* pSender, int32_t iIndex);
29
30  // Node events
31  void OnNodeReady(CXFA_Node* pNode);
32  void OnValueChanging(CXFA_Node* pSender, XFA_Attribute eAttr);
33  void OnValueChanged(CXFA_Node* pSender,
34                      XFA_Attribute eAttr,
35                      CXFA_Node* pParentNode,
36                      CXFA_Node* pWidgetNode);
37  void OnChildAdded(CXFA_Node* pSender);
38  void OnChildRemoved();
39
40  CXFA_ContainerLayoutItem* OnCreateContainerLayoutItem(CXFA_Node* pNode);
41  CXFA_ContentLayoutItem* OnCreateContentLayoutItem(CXFA_Node* pNode);
42
43  void OnLayoutItemAdded(CXFA_LayoutProcessor* pLayout,
44                         CXFA_LayoutItem* pSender,
45                         int32_t iPageIdx,
46                         uint32_t dwStatus);
47  void OnLayoutItemRemoving(CXFA_LayoutProcessor* pLayout,
48                            CXFA_LayoutItem* pSender);
49
50  void StartFieldDrawLayout(CXFA_Node* pItem,
51                            float& fCalcWidth,
52                            float& fCalcHeight);
53  bool FindSplitPos(CXFA_Node* pItem,
54                    int32_t iBlockIndex,
55                    float& fCalcHeightPos);
56  bool RunScript(CXFA_Script* pScript, CXFA_Node* pFormItem);
57  int32_t ExecEventByDeepFirst(CXFA_Node* pFormNode,
58                               XFA_EVENTTYPE eEventType,
59                               bool bIsFormReady = false,
60                               bool bRecursive = true,
61                               CXFA_WidgetAcc* pExclude = nullptr);
62  void AddCalcValidate(CXFA_Node* pNode);
63  CXFA_FFDoc* GetHDOC();
64  IXFA_DocEnvironment* GetDocEnvironment() const;
65  IXFA_AppProvider* GetAppProvider();
66  CXFA_FFWidgetHandler* GetWidgetHandler();
67  CXFA_FFWidget* GetHWidget(CXFA_LayoutItem* pLayoutItem);
68  void OpenDropDownList(CXFA_FFWidget* hWidget);
69  WideString GetCurrentDateTime();
70  void ResetData(CXFA_WidgetAcc* pWidgetAcc = nullptr);
71  int32_t GetLayoutStatus();
72  void RunNodeInitialize(CXFA_Node* pNode);
73  void RunSubformIndexChange(CXFA_Node* pSubformNode);
74  CXFA_Node* GetFocusWidgetNode();
75  void SetFocusWidgetNode(CXFA_Node* pNode);
76
77 private:
78  UnownedPtr<CXFA_FFDoc> const m_pDoc;
79};
80
81#endif  // XFA_FXFA_CXFA_FFNOTIFY_H_
82