• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2016 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_PARSER_CXFA_WIDGETDATA_H_
8 #define XFA_FXFA_PARSER_CXFA_WIDGETDATA_H_
9 
10 #include <vector>
11 
12 #include "core/fxcrt/fx_string.h"
13 #include "core/fxcrt/fx_system.h"
14 #include "xfa/fxfa/parser/cxfa_assist.h"
15 #include "xfa/fxfa/parser/cxfa_bind.h"
16 #include "xfa/fxfa/parser/cxfa_border.h"
17 #include "xfa/fxfa/parser/cxfa_calculate.h"
18 #include "xfa/fxfa/parser/cxfa_caption.h"
19 #include "xfa/fxfa/parser/cxfa_data.h"
20 #include "xfa/fxfa/parser/cxfa_font.h"
21 #include "xfa/fxfa/parser/cxfa_margin.h"
22 #include "xfa/fxfa/parser/cxfa_para.h"
23 #include "xfa/fxfa/parser/cxfa_validate.h"
24 #include "xfa/fxfa/parser/xfa_object.h"
25 
26 enum XFA_CHECKSTATE {
27   XFA_CHECKSTATE_On = 0,
28   XFA_CHECKSTATE_Off = 1,
29   XFA_CHECKSTATE_Neutral = 2,
30 };
31 
32 enum XFA_VALUEPICTURE {
33   XFA_VALUEPICTURE_Raw = 0,
34   XFA_VALUEPICTURE_Display,
35   XFA_VALUEPICTURE_Edit,
36   XFA_VALUEPICTURE_DataBind,
37 };
38 
39 class CXFA_Node;
40 class IFX_Locale;
41 
42 class CXFA_WidgetData : public CXFA_Data {
43  public:
44   explicit CXFA_WidgetData(CXFA_Node* pNode);
45 
46   CXFA_Node* GetUIChild();
47   XFA_Element GetUIType();
48   CFX_WideString GetRawValue();
49   int32_t GetAccess(bool bTemplate = false);
50   int32_t GetRotate();
51   CXFA_Border GetBorder(bool bModified = false);
52   CXFA_Caption GetCaption(bool bModified = false);
53   CXFA_Font GetFont(bool bModified = false);
54   CXFA_Margin GetMargin(bool bModified = false);
55   CXFA_Para GetPara(bool bModified = false);
56   void GetEventList(CXFA_NodeArray& events);
57   int32_t GetEventByActivity(int32_t iActivity,
58                              CXFA_NodeArray& events,
59                              bool bIsFormReady = false);
60   CXFA_Value GetDefaultValue(bool bModified = false);
61   CXFA_Value GetFormValue(bool bModified = false);
62   CXFA_Calculate GetCalculate(bool bModified = false);
63   CXFA_Validate GetValidate(bool bModified = false);
64   CXFA_Bind GetBind(bool bModified = false);
65   CXFA_Assist GetAssist(bool bModified = false);
66   bool GetWidth(FX_FLOAT& fWidth);
67   bool GetHeight(FX_FLOAT& fHeight);
68   bool GetMinWidth(FX_FLOAT& fMinWidth);
69   bool GetMinHeight(FX_FLOAT& fMinHeight);
70   bool GetMaxWidth(FX_FLOAT& fMaxWidth);
71   bool GetMaxHeight(FX_FLOAT& fMaxHeight);
72   CXFA_Border GetUIBorder();
73   CFX_RectF GetUIMargin();
74   int32_t GetButtonHighlight();
75   bool GetButtonRollover(CFX_WideString& wsRollover, bool& bRichText);
76   bool GetButtonDown(CFX_WideString& wsDown, bool& bRichText);
77   int32_t GetCheckButtonShape();
78   int32_t GetCheckButtonMark();
79   FX_FLOAT GetCheckButtonSize();
80   bool IsAllowNeutral();
81   bool IsRadioButton();
82   XFA_CHECKSTATE GetCheckState();
83   void SetCheckState(XFA_CHECKSTATE eCheckState, bool bNotify);
84   CXFA_Node* GetExclGroupNode();
85   CXFA_Node* GetSelectedMember();
86   CXFA_Node* SetSelectedMember(const CFX_WideStringC& wsName, bool bNotify);
87   void SetSelectedMemberByValue(const CFX_WideStringC& wsValue,
88                                 bool bNotify,
89                                 bool bScriptModify,
90                                 bool bSyncData);
91   CXFA_Node* GetExclGroupFirstMember();
92   CXFA_Node* GetExclGroupNextMember(CXFA_Node* pNode);
93   int32_t GetChoiceListCommitOn();
94   bool IsChoiceListAllowTextEntry();
95   int32_t GetChoiceListOpen();
96   bool IsListBox();
97   int32_t CountChoiceListItems(bool bSaveValue = false);
98   bool GetChoiceListItem(CFX_WideString& wsText,
99                          int32_t nIndex,
100                          bool bSaveValue = false);
101   void GetChoiceListItems(std::vector<CFX_WideString>& wsTextArray,
102                           bool bSaveValue = false);
103   int32_t CountSelectedItems();
104   int32_t GetSelectedItem(int32_t nIndex = 0);
105   void GetSelectedItems(CFX_ArrayTemplate<int32_t>& iSelArray);
106   void GetSelectedItemsValue(std::vector<CFX_WideString>& wsSelTextArray);
107   bool GetItemState(int32_t nIndex);
108   void SetItemState(int32_t nIndex,
109                     bool bSelected,
110                     bool bNotify,
111                     bool bScriptModify,
112                     bool bSyncData);
113   void SetSelectedItems(CFX_ArrayTemplate<int32_t>& iSelArray,
114                         bool bNotify,
115                         bool bScriptModify,
116                         bool bSyncData);
117   void ClearAllSelections();
118   void InsertItem(const CFX_WideString& wsLabel,
119                   const CFX_WideString& wsValue,
120                   int32_t nIndex = -1,
121                   bool bNotify = false);
122   void GetItemLabel(const CFX_WideStringC& wsValue, CFX_WideString& wsLabel);
123   void GetItemValue(const CFX_WideStringC& wsLabel, CFX_WideString& wsValue);
124   bool DeleteItem(int32_t nIndex,
125                   bool bNotify = false,
126                   bool bScriptModify = false,
127                   bool bSyncData = true);
128   int32_t GetHorizontalScrollPolicy();
129   int32_t GetNumberOfCells();
130   bool SetValue(const CFX_WideString& wsValue, XFA_VALUEPICTURE eValueType);
131   bool GetPictureContent(CFX_WideString& wsPicture, XFA_VALUEPICTURE ePicture);
132   IFX_Locale* GetLocal();
133   bool GetValue(CFX_WideString& wsValue, XFA_VALUEPICTURE eValueType);
134   bool GetNormalizeDataValue(const CFX_WideString& wsValue,
135                              CFX_WideString& wsNormalizeValue);
136   bool GetFormatDataValue(const CFX_WideString& wsValue,
137                           CFX_WideString& wsFormattedValue);
138   void NormalizeNumStr(const CFX_WideString& wsValue, CFX_WideString& wsOutput);
139   CFX_WideString GetBarcodeType();
140   bool GetBarcodeAttribute_CharEncoding(int32_t& val);
141   bool GetBarcodeAttribute_Checksum(bool& val);
142   bool GetBarcodeAttribute_DataLength(int32_t& val);
143   bool GetBarcodeAttribute_StartChar(FX_CHAR& val);
144   bool GetBarcodeAttribute_EndChar(FX_CHAR& val);
145   bool GetBarcodeAttribute_ECLevel(int32_t& val);
146   bool GetBarcodeAttribute_ModuleWidth(int32_t& val);
147   bool GetBarcodeAttribute_ModuleHeight(int32_t& val);
148   bool GetBarcodeAttribute_PrintChecksum(bool& val);
149   bool GetBarcodeAttribute_TextLocation(int32_t& val);
150   bool GetBarcodeAttribute_Truncate(bool& val);
151   bool GetBarcodeAttribute_WideNarrowRatio(FX_FLOAT& val);
152   void GetPasswordChar(CFX_WideString& wsPassWord);
153   bool IsMultiLine();
154   int32_t GetVerticalScrollPolicy();
155   int32_t GetMaxChars(XFA_Element& eType);
156   bool GetFracDigits(int32_t& iFracDigits);
157   bool GetLeadDigits(int32_t& iLeadDigits);
158 
159   CFX_WideString NumericLimit(const CFX_WideString& wsValue,
160                               int32_t iLead,
161                               int32_t iTread) const;
162 
163   bool m_bIsNull;
164   bool m_bPreNull;
165 
166  protected:
167   void SyncValue(const CFX_WideString& wsValue, bool bNotify);
168   void InsertListTextItem(CXFA_Node* pItems,
169                           const CFX_WideString& wsText,
170                           int32_t nIndex = -1);
171   void FormatNumStr(const CFX_WideString& wsValue,
172                     IFX_Locale* pLocale,
173                     CFX_WideString& wsOutput);
174 
175   CXFA_Node* m_pUiChildNode;
176   XFA_Element m_eUIType;
177 };
178 
179 #endif  // XFA_FXFA_PARSER_CXFA_WIDGETDATA_H_
180