Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(555)

Side by Side Diff: xfa/fxfa/parser/cxfa_widgetdata.cpp

Issue 2132513003: Cleanup redundant method names. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 PDFium Authors. All rights reserved. 1 // Copyright 2016 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/parser/cxfa_widgetdata.h" 7 #include "xfa/fxfa/parser/cxfa_widgetdata.h"
8 8
9 #include "core/fxcrt/include/fx_ext.h" 9 #include "core/fxcrt/include/fx_ext.h"
10 #include "xfa/fxbarcode/include/BC_Library.h" 10 #include "xfa/fxbarcode/include/BC_Library.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 for (i = 0; i < iCount; i++) { 63 for (i = 0; i < iCount; i++) {
64 if (wsTime[i] >= '0' && wsTime[i] <= '9') 64 if (wsTime[i] >= '0' && wsTime[i] <= '9')
65 break; 65 break;
66 } 66 }
67 if (i == iCount) 67 if (i == iCount)
68 return FALSE; 68 return FALSE;
69 } 69 }
70 return TRUE; 70 return TRUE;
71 } 71 }
72 72
73 CXFA_Node* CreateUIChild(CXFA_Node* pNode, XFA_Element& eWidgetType) {
74 XFA_Element eType = pNode->GetElementType();
75 eWidgetType = eType;
76 if (eType != XFA_Element::Field && eType != XFA_Element::Draw)
77 return nullptr;
78
79 eWidgetType = XFA_Element::Unknown;
80 XFA_Element eUIType = XFA_Element::Unknown;
81 CXFA_Value defValue(pNode->GetProperty(0, XFA_Element::Value, TRUE));
82 XFA_Element eValueType = defValue.GetChildValueClassID();
83 switch (eValueType) {
84 case XFA_Element::Boolean:
85 eUIType = XFA_Element::CheckButton;
86 break;
87 case XFA_Element::Integer:
88 case XFA_Element::Decimal:
89 case XFA_Element::Float:
90 eUIType = XFA_Element::NumericEdit;
91 break;
92 case XFA_Element::ExData:
93 case XFA_Element::Text:
94 eUIType = XFA_Element::TextEdit;
95 eWidgetType = XFA_Element::Text;
96 break;
97 case XFA_Element::Date:
98 case XFA_Element::Time:
99 case XFA_Element::DateTime:
100 eUIType = XFA_Element::DateTimeEdit;
101 break;
102 case XFA_Element::Image:
103 eUIType = XFA_Element::ImageEdit;
104 eWidgetType = XFA_Element::Image;
105 break;
106 case XFA_Element::Arc:
107 case XFA_Element::Line:
108 case XFA_Element::Rectangle:
109 eUIType = XFA_Element::DefaultUi;
110 eWidgetType = eValueType;
111 break;
112 default:
113 break;
114 }
115
116 CXFA_Node* pUIChild = nullptr;
117 CXFA_Node* pUI = pNode->GetProperty(0, XFA_Element::Ui, TRUE);
118 CXFA_Node* pChild = pUI->GetNodeItem(XFA_NODEITEM_FirstChild);
119 for (; pChild; pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling)) {
120 XFA_Element eChildType = pChild->GetElementType();
121 if (eChildType == XFA_Element::Extras ||
122 eChildType == XFA_Element::Picture) {
123 continue;
124 }
125 const XFA_PROPERTY* pProperty = XFA_GetPropertyOfElement(
126 XFA_Element::Ui, eChildType, XFA_XDPPACKET_Form);
127 if (pProperty && (pProperty->uFlags & XFA_PROPERTYFLAG_OneOf)) {
128 pUIChild = pChild;
129 break;
130 }
131 }
132
133 if (eType == XFA_Element::Draw) {
134 XFA_Element eDraw =
135 pUIChild ? pUIChild->GetElementType() : XFA_Element::Unknown;
136 switch (eDraw) {
137 case XFA_Element::TextEdit:
138 eWidgetType = XFA_Element::Text;
139 break;
140 case XFA_Element::ImageEdit:
141 eWidgetType = XFA_Element::Image;
142 break;
143 default:
144 eWidgetType = eWidgetType == XFA_Element::Unknown ? XFA_Element::Text
145 : eWidgetType;
146 break;
147 }
148 } else {
149 if (pUIChild && pUIChild->GetElementType() == XFA_Element::DefaultUi) {
150 eWidgetType = XFA_Element::TextEdit;
151 } else {
152 eWidgetType =
153 pUIChild ? pUIChild->GetElementType()
154 : (eUIType == XFA_Element::Unknown ? XFA_Element::TextEdit
155 : eUIType);
156 }
157 }
158
159 if (!pUIChild) {
160 if (eUIType == XFA_Element::Unknown) {
161 eUIType = XFA_Element::TextEdit;
162 defValue.GetNode()->GetProperty(0, XFA_Element::Text, TRUE);
163 }
164 return pUI->GetProperty(0, eUIType, TRUE);
165 }
166
167 if (eUIType != XFA_Element::Unknown)
168 return pUIChild;
169
170 switch (pUIChild->GetElementType()) {
171 case XFA_Element::CheckButton: {
172 eValueType = XFA_Element::Text;
173 if (CXFA_Node* pItems = pNode->GetChild(0, XFA_Element::Items)) {
174 if (CXFA_Node* pItem = pItems->GetChild(0, XFA_Element::Unknown))
175 eValueType = pItem->GetElementType();
176 }
177 break;
178 }
179 case XFA_Element::DateTimeEdit:
180 eValueType = XFA_Element::DateTime;
181 break;
182 case XFA_Element::ImageEdit:
183 eValueType = XFA_Element::Image;
184 break;
185 case XFA_Element::NumericEdit:
186 eValueType = XFA_Element::Float;
187 break;
188 case XFA_Element::ChoiceList: {
189 eValueType = (pUIChild->GetEnum(XFA_ATTRIBUTE_Open) ==
190 XFA_ATTRIBUTEENUM_MultiSelect)
191 ? XFA_Element::ExData
192 : XFA_Element::Text;
193 break;
194 }
195 case XFA_Element::Barcode:
196 case XFA_Element::Button:
197 case XFA_Element::PasswordEdit:
198 case XFA_Element::Signature:
199 case XFA_Element::TextEdit:
200 default:
201 eValueType = XFA_Element::Text;
202 break;
203 }
204 defValue.GetNode()->GetProperty(0, eValueType, TRUE);
205
206 return pUIChild;
207 }
208
73 } // namespace 209 } // namespace
74 210
75 CXFA_WidgetData::CXFA_WidgetData(CXFA_Node* pNode) 211 CXFA_WidgetData::CXFA_WidgetData(CXFA_Node* pNode)
76 : CXFA_Data(pNode), 212 : CXFA_Data(pNode),
77 m_bIsNull(TRUE), 213 m_bIsNull(TRUE),
78 m_bPreNull(TRUE), 214 m_bPreNull(TRUE),
79 m_pUiChildNode(nullptr), 215 m_pUiChildNode(nullptr),
80 m_eUIType(XFA_Element::Unknown) {} 216 m_eUIType(XFA_Element::Unknown) {}
81 217
82 CXFA_Node* CXFA_WidgetData::GetUIChild() { 218 CXFA_Node* CXFA_WidgetData::GetUIChild() {
83 if (m_eUIType == XFA_Element::Unknown) 219 if (m_eUIType == XFA_Element::Unknown)
84 m_pUiChildNode = XFA_CreateUIChild(m_pNode, m_eUIType); 220 m_pUiChildNode = CreateUIChild(m_pNode, m_eUIType);
85 221
86 return m_pUiChildNode; 222 return m_pUiChildNode;
87 } 223 }
88 224
89 XFA_Element CXFA_WidgetData::GetUIType() { 225 XFA_Element CXFA_WidgetData::GetUIType() {
90 GetUIChild(); 226 GetUIChild();
91 return m_eUIType; 227 return m_eUIType;
92 } 228 }
93 229
94 CFX_WideString CXFA_WidgetData::GetRawValue() { 230 CFX_WideString CXFA_WidgetData::GetRawValue() {
(...skipping 1675 matching lines...) Expand 10 before | Expand all | Expand 10 after
1770 } 1906 }
1771 } 1907 }
1772 } else if (wc == L'.') { 1908 } else if (wc == L'.') {
1773 iTread_ = 0; 1909 iTread_ = 0;
1774 iLead = -1; 1910 iLead = -1;
1775 } 1911 }
1776 wsRet += wc; 1912 wsRet += wc;
1777 } 1913 }
1778 return wsRet; 1914 return wsRet;
1779 } 1915 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698