Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
cxfa_node.cpp
Go to the documentation of this file.
1// Copyright 2016 The PDFium Authors
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#include "xfa/fxfa/parser/cxfa_node.h"
8
9#include <math.h>
10#include <stdint.h>
11
12#include <algorithm>
13#include <map>
14#include <memory>
15#include <set>
16#include <utility>
17#include <vector>
18
19#include "core/fxcrt/autorestorer.h"
20#include "core/fxcrt/cfx_read_only_string_stream.h"
21#include "core/fxcrt/cfx_read_only_vector_stream.h"
22#include "core/fxcrt/data_vector.h"
23#include "core/fxcrt/fx_codepage.h"
24#include "core/fxcrt/fx_extension.h"
25#include "core/fxcrt/stl_util.h"
26#include "core/fxcrt/xml/cfx_xmldocument.h"
27#include "core/fxcrt/xml/cfx_xmlelement.h"
28#include "core/fxcrt/xml/cfx_xmlnode.h"
29#include "core/fxcrt/xml/cfx_xmltext.h"
30#include "core/fxge/dib/cfx_dibitmap.h"
31#include "core/fxge/fx_font.h"
32#include "fxjs/gc/container_trace.h"
33#include "fxjs/xfa/cfxjse_engine.h"
34#include "fxjs/xfa/cfxjse_value.h"
35#include "fxjs/xfa/cjx_node.h"
36#include "third_party/base/check.h"
37#include "third_party/base/check_op.h"
38#include "third_party/base/containers/contains.h"
39#include "third_party/base/containers/span.h"
40#include "third_party/base/notreached.h"
41#include "xfa/fde/cfde_textout.h"
42#include "xfa/fgas/crt/cfgas_decimal.h"
43#include "xfa/fgas/crt/locale_iface.h"
44#include "xfa/fgas/font/cfgas_fontmgr.h"
45#include "xfa/fgas/font/cfgas_gefont.h"
46#include "xfa/fxfa/cxfa_eventparam.h"
47#include "xfa/fxfa/cxfa_ffapp.h"
48#include "xfa/fxfa/cxfa_ffdocview.h"
49#include "xfa/fxfa/cxfa_ffnotify.h"
50#include "xfa/fxfa/cxfa_fontmgr.h"
51#include "xfa/fxfa/cxfa_textprovider.h"
52#include "xfa/fxfa/parser/cxfa_accessiblecontent.h"
53#include "xfa/fxfa/parser/cxfa_acrobat.h"
54#include "xfa/fxfa/parser/cxfa_acrobat7.h"
55#include "xfa/fxfa/parser/cxfa_adbe_jsconsole.h"
56#include "xfa/fxfa/parser/cxfa_adbe_jsdebugger.h"
57#include "xfa/fxfa/parser/cxfa_addsilentprint.h"
58#include "xfa/fxfa/parser/cxfa_addviewerpreferences.h"
59#include "xfa/fxfa/parser/cxfa_adjustdata.h"
60#include "xfa/fxfa/parser/cxfa_adobeextensionlevel.h"
61#include "xfa/fxfa/parser/cxfa_agent.h"
62#include "xfa/fxfa/parser/cxfa_alwaysembed.h"
63#include "xfa/fxfa/parser/cxfa_amd.h"
64#include "xfa/fxfa/parser/cxfa_appearancefilter.h"
65#include "xfa/fxfa/parser/cxfa_arc.h"
66#include "xfa/fxfa/parser/cxfa_area.h"
67#include "xfa/fxfa/parser/cxfa_arraynodelist.h"
68#include "xfa/fxfa/parser/cxfa_assist.h"
69#include "xfa/fxfa/parser/cxfa_attachnodelist.h"
70#include "xfa/fxfa/parser/cxfa_attributes.h"
71#include "xfa/fxfa/parser/cxfa_autosave.h"
72#include "xfa/fxfa/parser/cxfa_barcode.h"
73#include "xfa/fxfa/parser/cxfa_base.h"
74#include "xfa/fxfa/parser/cxfa_batchoutput.h"
75#include "xfa/fxfa/parser/cxfa_behavioroverride.h"
76#include "xfa/fxfa/parser/cxfa_bind.h"
77#include "xfa/fxfa/parser/cxfa_binditems.h"
78#include "xfa/fxfa/parser/cxfa_bookend.h"
79#include "xfa/fxfa/parser/cxfa_boolean.h"
80#include "xfa/fxfa/parser/cxfa_border.h"
81#include "xfa/fxfa/parser/cxfa_break.h"
82#include "xfa/fxfa/parser/cxfa_breakafter.h"
83#include "xfa/fxfa/parser/cxfa_breakbefore.h"
84#include "xfa/fxfa/parser/cxfa_button.h"
85#include "xfa/fxfa/parser/cxfa_cache.h"
86#include "xfa/fxfa/parser/cxfa_calculate.h"
87#include "xfa/fxfa/parser/cxfa_calendarsymbols.h"
88#include "xfa/fxfa/parser/cxfa_caption.h"
89#include "xfa/fxfa/parser/cxfa_certificate.h"
90#include "xfa/fxfa/parser/cxfa_certificates.h"
91#include "xfa/fxfa/parser/cxfa_change.h"
92#include "xfa/fxfa/parser/cxfa_checkbutton.h"
93#include "xfa/fxfa/parser/cxfa_choicelist.h"
94#include "xfa/fxfa/parser/cxfa_color.h"
95#include "xfa/fxfa/parser/cxfa_comb.h"
96#include "xfa/fxfa/parser/cxfa_command.h"
97#include "xfa/fxfa/parser/cxfa_common.h"
98#include "xfa/fxfa/parser/cxfa_compress.h"
99#include "xfa/fxfa/parser/cxfa_compression.h"
100#include "xfa/fxfa/parser/cxfa_compresslogicalstructure.h"
101#include "xfa/fxfa/parser/cxfa_compressobjectstream.h"
102#include "xfa/fxfa/parser/cxfa_config.h"
103#include "xfa/fxfa/parser/cxfa_conformance.h"
104#include "xfa/fxfa/parser/cxfa_connect.h"
105#include "xfa/fxfa/parser/cxfa_connectionset.h"
106#include "xfa/fxfa/parser/cxfa_connectstring.h"
107#include "xfa/fxfa/parser/cxfa_contentarea.h"
108#include "xfa/fxfa/parser/cxfa_contentcopy.h"
109#include "xfa/fxfa/parser/cxfa_copies.h"
110#include "xfa/fxfa/parser/cxfa_corner.h"
111#include "xfa/fxfa/parser/cxfa_creator.h"
112#include "xfa/fxfa/parser/cxfa_currencysymbol.h"
113#include "xfa/fxfa/parser/cxfa_currencysymbols.h"
114#include "xfa/fxfa/parser/cxfa_currentpage.h"
115#include "xfa/fxfa/parser/cxfa_data.h"
116#include "xfa/fxfa/parser/cxfa_datagroup.h"
117#include "xfa/fxfa/parser/cxfa_datamodel.h"
118#include "xfa/fxfa/parser/cxfa_datavalue.h"
119#include "xfa/fxfa/parser/cxfa_date.h"
120#include "xfa/fxfa/parser/cxfa_datepattern.h"
121#include "xfa/fxfa/parser/cxfa_datepatterns.h"
122#include "xfa/fxfa/parser/cxfa_datetime.h"
123#include "xfa/fxfa/parser/cxfa_datetimeedit.h"
124#include "xfa/fxfa/parser/cxfa_datetimesymbols.h"
125#include "xfa/fxfa/parser/cxfa_day.h"
126#include "xfa/fxfa/parser/cxfa_daynames.h"
127#include "xfa/fxfa/parser/cxfa_debug.h"
128#include "xfa/fxfa/parser/cxfa_decimal.h"
129#include "xfa/fxfa/parser/cxfa_defaulttypeface.h"
130#include "xfa/fxfa/parser/cxfa_defaultui.h"
131#include "xfa/fxfa/parser/cxfa_delete.h"
132#include "xfa/fxfa/parser/cxfa_delta.h"
133#include "xfa/fxfa/parser/cxfa_desc.h"
134#include "xfa/fxfa/parser/cxfa_destination.h"
135#include "xfa/fxfa/parser/cxfa_digestmethod.h"
136#include "xfa/fxfa/parser/cxfa_digestmethods.h"
137#include "xfa/fxfa/parser/cxfa_document.h"
138#include "xfa/fxfa/parser/cxfa_document_builder.h"
139#include "xfa/fxfa/parser/cxfa_documentassembly.h"
140#include "xfa/fxfa/parser/cxfa_draw.h"
141#include "xfa/fxfa/parser/cxfa_driver.h"
142#include "xfa/fxfa/parser/cxfa_dsigdata.h"
143#include "xfa/fxfa/parser/cxfa_duplexoption.h"
144#include "xfa/fxfa/parser/cxfa_dynamicrender.h"
145#include "xfa/fxfa/parser/cxfa_edge.h"
146#include "xfa/fxfa/parser/cxfa_effectiveinputpolicy.h"
147#include "xfa/fxfa/parser/cxfa_effectiveoutputpolicy.h"
148#include "xfa/fxfa/parser/cxfa_embed.h"
149#include "xfa/fxfa/parser/cxfa_encoding.h"
150#include "xfa/fxfa/parser/cxfa_encodings.h"
151#include "xfa/fxfa/parser/cxfa_encrypt.h"
152#include "xfa/fxfa/parser/cxfa_encryption.h"
153#include "xfa/fxfa/parser/cxfa_encryptionlevel.h"
154#include "xfa/fxfa/parser/cxfa_encryptionmethod.h"
155#include "xfa/fxfa/parser/cxfa_encryptionmethods.h"
156#include "xfa/fxfa/parser/cxfa_enforce.h"
157#include "xfa/fxfa/parser/cxfa_equate.h"
158#include "xfa/fxfa/parser/cxfa_equaterange.h"
159#include "xfa/fxfa/parser/cxfa_era.h"
160#include "xfa/fxfa/parser/cxfa_eranames.h"
161#include "xfa/fxfa/parser/cxfa_event.h"
162#include "xfa/fxfa/parser/cxfa_exclgroup.h"
163#include "xfa/fxfa/parser/cxfa_exclude.h"
164#include "xfa/fxfa/parser/cxfa_excludens.h"
165#include "xfa/fxfa/parser/cxfa_exdata.h"
166#include "xfa/fxfa/parser/cxfa_execute.h"
167#include "xfa/fxfa/parser/cxfa_exobject.h"
168#include "xfa/fxfa/parser/cxfa_extras.h"
169#include "xfa/fxfa/parser/cxfa_field.h"
170#include "xfa/fxfa/parser/cxfa_fill.h"
171#include "xfa/fxfa/parser/cxfa_filter.h"
172#include "xfa/fxfa/parser/cxfa_fliplabel.h"
173#include "xfa/fxfa/parser/cxfa_float.h"
174#include "xfa/fxfa/parser/cxfa_font.h"
175#include "xfa/fxfa/parser/cxfa_fontinfo.h"
176#include "xfa/fxfa/parser/cxfa_form.h"
177#include "xfa/fxfa/parser/cxfa_format.h"
178#include "xfa/fxfa/parser/cxfa_formfieldfilling.h"
179#include "xfa/fxfa/parser/cxfa_groupparent.h"
180#include "xfa/fxfa/parser/cxfa_handler.h"
181#include "xfa/fxfa/parser/cxfa_hyphenation.h"
182#include "xfa/fxfa/parser/cxfa_ifempty.h"
183#include "xfa/fxfa/parser/cxfa_image.h"
184#include "xfa/fxfa/parser/cxfa_imageedit.h"
185#include "xfa/fxfa/parser/cxfa_includexdpcontent.h"
186#include "xfa/fxfa/parser/cxfa_incrementalload.h"
187#include "xfa/fxfa/parser/cxfa_incrementalmerge.h"
188#include "xfa/fxfa/parser/cxfa_insert.h"
189#include "xfa/fxfa/parser/cxfa_instancemanager.h"
190#include "xfa/fxfa/parser/cxfa_integer.h"
191#include "xfa/fxfa/parser/cxfa_interactive.h"
192#include "xfa/fxfa/parser/cxfa_issuers.h"
193#include "xfa/fxfa/parser/cxfa_items.h"
194#include "xfa/fxfa/parser/cxfa_jog.h"
195#include "xfa/fxfa/parser/cxfa_keep.h"
196#include "xfa/fxfa/parser/cxfa_keyusage.h"
197#include "xfa/fxfa/parser/cxfa_labelprinter.h"
198#include "xfa/fxfa/parser/cxfa_layout.h"
199#include "xfa/fxfa/parser/cxfa_level.h"
200#include "xfa/fxfa/parser/cxfa_line.h"
201#include "xfa/fxfa/parser/cxfa_linear.h"
202#include "xfa/fxfa/parser/cxfa_linearized.h"
203#include "xfa/fxfa/parser/cxfa_locale.h"
204#include "xfa/fxfa/parser/cxfa_localeset.h"
205#include "xfa/fxfa/parser/cxfa_localevalue.h"
206#include "xfa/fxfa/parser/cxfa_lockdocument.h"
207#include "xfa/fxfa/parser/cxfa_log.h"
208#include "xfa/fxfa/parser/cxfa_manifest.h"
209#include "xfa/fxfa/parser/cxfa_map.h"
210#include "xfa/fxfa/parser/cxfa_margin.h"
211#include "xfa/fxfa/parser/cxfa_mdp.h"
212#include "xfa/fxfa/parser/cxfa_measurement.h"
213#include "xfa/fxfa/parser/cxfa_medium.h"
214#include "xfa/fxfa/parser/cxfa_mediuminfo.h"
215#include "xfa/fxfa/parser/cxfa_meridiem.h"
216#include "xfa/fxfa/parser/cxfa_meridiemnames.h"
217#include "xfa/fxfa/parser/cxfa_message.h"
218#include "xfa/fxfa/parser/cxfa_messaging.h"
219#include "xfa/fxfa/parser/cxfa_mode.h"
220#include "xfa/fxfa/parser/cxfa_modifyannots.h"
221#include "xfa/fxfa/parser/cxfa_month.h"
222#include "xfa/fxfa/parser/cxfa_monthnames.h"
223#include "xfa/fxfa/parser/cxfa_msgid.h"
224#include "xfa/fxfa/parser/cxfa_nameattr.h"
225#include "xfa/fxfa/parser/cxfa_neverembed.h"
226#include "xfa/fxfa/parser/cxfa_nodeiteratortemplate.h"
227#include "xfa/fxfa/parser/cxfa_numberofcopies.h"
228#include "xfa/fxfa/parser/cxfa_numberpattern.h"
229#include "xfa/fxfa/parser/cxfa_numberpatterns.h"
230#include "xfa/fxfa/parser/cxfa_numbersymbol.h"
231#include "xfa/fxfa/parser/cxfa_numbersymbols.h"
232#include "xfa/fxfa/parser/cxfa_numericedit.h"
233#include "xfa/fxfa/parser/cxfa_occur.h"
234#include "xfa/fxfa/parser/cxfa_oid.h"
235#include "xfa/fxfa/parser/cxfa_oids.h"
236#include "xfa/fxfa/parser/cxfa_openaction.h"
237#include "xfa/fxfa/parser/cxfa_operation.h"
238#include "xfa/fxfa/parser/cxfa_output.h"
239#include "xfa/fxfa/parser/cxfa_outputbin.h"
240#include "xfa/fxfa/parser/cxfa_outputxsl.h"
241#include "xfa/fxfa/parser/cxfa_overflow.h"
242#include "xfa/fxfa/parser/cxfa_overprint.h"
243#include "xfa/fxfa/parser/cxfa_packet.h"
244#include "xfa/fxfa/parser/cxfa_packets.h"
245#include "xfa/fxfa/parser/cxfa_pagearea.h"
246#include "xfa/fxfa/parser/cxfa_pageoffset.h"
247#include "xfa/fxfa/parser/cxfa_pagerange.h"
248#include "xfa/fxfa/parser/cxfa_pageset.h"
249#include "xfa/fxfa/parser/cxfa_pagination.h"
250#include "xfa/fxfa/parser/cxfa_paginationoverride.h"
251#include "xfa/fxfa/parser/cxfa_para.h"
252#include "xfa/fxfa/parser/cxfa_part.h"
253#include "xfa/fxfa/parser/cxfa_password.h"
254#include "xfa/fxfa/parser/cxfa_passwordedit.h"
255#include "xfa/fxfa/parser/cxfa_pattern.h"
256#include "xfa/fxfa/parser/cxfa_pcl.h"
257#include "xfa/fxfa/parser/cxfa_pdf.h"
258#include "xfa/fxfa/parser/cxfa_pdfa.h"
259#include "xfa/fxfa/parser/cxfa_permissions.h"
260#include "xfa/fxfa/parser/cxfa_picktraybypdfsize.h"
261#include "xfa/fxfa/parser/cxfa_picture.h"
262#include "xfa/fxfa/parser/cxfa_plaintextmetadata.h"
263#include "xfa/fxfa/parser/cxfa_presence.h"
264#include "xfa/fxfa/parser/cxfa_present.h"
265#include "xfa/fxfa/parser/cxfa_print.h"
266#include "xfa/fxfa/parser/cxfa_printername.h"
267#include "xfa/fxfa/parser/cxfa_printhighquality.h"
268#include "xfa/fxfa/parser/cxfa_printscaling.h"
269#include "xfa/fxfa/parser/cxfa_producer.h"
270#include "xfa/fxfa/parser/cxfa_proto.h"
271#include "xfa/fxfa/parser/cxfa_ps.h"
272#include "xfa/fxfa/parser/cxfa_psmap.h"
273#include "xfa/fxfa/parser/cxfa_query.h"
274#include "xfa/fxfa/parser/cxfa_radial.h"
275#include "xfa/fxfa/parser/cxfa_range.h"
276#include "xfa/fxfa/parser/cxfa_reason.h"
277#include "xfa/fxfa/parser/cxfa_reasons.h"
278#include "xfa/fxfa/parser/cxfa_record.h"
279#include "xfa/fxfa/parser/cxfa_recordset.h"
280#include "xfa/fxfa/parser/cxfa_rectangle.h"
281#include "xfa/fxfa/parser/cxfa_ref.h"
282#include "xfa/fxfa/parser/cxfa_relevant.h"
283#include "xfa/fxfa/parser/cxfa_rename.h"
284#include "xfa/fxfa/parser/cxfa_renderpolicy.h"
285#include "xfa/fxfa/parser/cxfa_rootelement.h"
286#include "xfa/fxfa/parser/cxfa_runscripts.h"
287#include "xfa/fxfa/parser/cxfa_script.h"
288#include "xfa/fxfa/parser/cxfa_scriptmodel.h"
289#include "xfa/fxfa/parser/cxfa_select.h"
290#include "xfa/fxfa/parser/cxfa_setproperty.h"
291#include "xfa/fxfa/parser/cxfa_severity.h"
292#include "xfa/fxfa/parser/cxfa_sharptext.h"
293#include "xfa/fxfa/parser/cxfa_sharpxhtml.h"
294#include "xfa/fxfa/parser/cxfa_sharpxml.h"
295#include "xfa/fxfa/parser/cxfa_signature.h"
296#include "xfa/fxfa/parser/cxfa_signatureproperties.h"
297#include "xfa/fxfa/parser/cxfa_signdata.h"
298#include "xfa/fxfa/parser/cxfa_signing.h"
299#include "xfa/fxfa/parser/cxfa_silentprint.h"
300#include "xfa/fxfa/parser/cxfa_soapaction.h"
301#include "xfa/fxfa/parser/cxfa_soapaddress.h"
302#include "xfa/fxfa/parser/cxfa_solid.h"
303#include "xfa/fxfa/parser/cxfa_source.h"
304#include "xfa/fxfa/parser/cxfa_sourceset.h"
305#include "xfa/fxfa/parser/cxfa_speak.h"
306#include "xfa/fxfa/parser/cxfa_staple.h"
307#include "xfa/fxfa/parser/cxfa_startnode.h"
308#include "xfa/fxfa/parser/cxfa_startpage.h"
309#include "xfa/fxfa/parser/cxfa_stipple.h"
310#include "xfa/fxfa/parser/cxfa_stroke.h"
311#include "xfa/fxfa/parser/cxfa_subform.h"
312#include "xfa/fxfa/parser/cxfa_subformset.h"
313#include "xfa/fxfa/parser/cxfa_subjectdn.h"
314#include "xfa/fxfa/parser/cxfa_subjectdns.h"
315#include "xfa/fxfa/parser/cxfa_submit.h"
316#include "xfa/fxfa/parser/cxfa_submitformat.h"
317#include "xfa/fxfa/parser/cxfa_submiturl.h"
318#include "xfa/fxfa/parser/cxfa_subsetbelow.h"
319#include "xfa/fxfa/parser/cxfa_suppressbanner.h"
320#include "xfa/fxfa/parser/cxfa_tagged.h"
321#include "xfa/fxfa/parser/cxfa_template.h"
322#include "xfa/fxfa/parser/cxfa_templatecache.h"
323#include "xfa/fxfa/parser/cxfa_text.h"
324#include "xfa/fxfa/parser/cxfa_textedit.h"
325#include "xfa/fxfa/parser/cxfa_threshold.h"
326#include "xfa/fxfa/parser/cxfa_time.h"
327#include "xfa/fxfa/parser/cxfa_timepattern.h"
328#include "xfa/fxfa/parser/cxfa_timepatterns.h"
329#include "xfa/fxfa/parser/cxfa_timestamp.h"
330#include "xfa/fxfa/parser/cxfa_to.h"
331#include "xfa/fxfa/parser/cxfa_tooltip.h"
332#include "xfa/fxfa/parser/cxfa_trace.h"
333#include "xfa/fxfa/parser/cxfa_transform.h"
334#include "xfa/fxfa/parser/cxfa_traversal.h"
335#include "xfa/fxfa/parser/cxfa_traverse.h"
336#include "xfa/fxfa/parser/cxfa_traversestrategy_xfacontainernode.h"
337#include "xfa/fxfa/parser/cxfa_traversestrategy_xfanode.h"
338#include "xfa/fxfa/parser/cxfa_type.h"
339#include "xfa/fxfa/parser/cxfa_typeface.h"
340#include "xfa/fxfa/parser/cxfa_typefaces.h"
341#include "xfa/fxfa/parser/cxfa_ui.h"
342#include "xfa/fxfa/parser/cxfa_update.h"
343#include "xfa/fxfa/parser/cxfa_uri.h"
344#include "xfa/fxfa/parser/cxfa_user.h"
345#include "xfa/fxfa/parser/cxfa_validate.h"
346#include "xfa/fxfa/parser/cxfa_validateapprovalsignatures.h"
347#include "xfa/fxfa/parser/cxfa_validationmessaging.h"
348#include "xfa/fxfa/parser/cxfa_value.h"
349#include "xfa/fxfa/parser/cxfa_variables.h"
350#include "xfa/fxfa/parser/cxfa_version.h"
351#include "xfa/fxfa/parser/cxfa_versioncontrol.h"
352#include "xfa/fxfa/parser/cxfa_viewerpreferences.h"
353#include "xfa/fxfa/parser/cxfa_webclient.h"
354#include "xfa/fxfa/parser/cxfa_whitespace.h"
355#include "xfa/fxfa/parser/cxfa_window.h"
356#include "xfa/fxfa/parser/cxfa_wsdladdress.h"
357#include "xfa/fxfa/parser/cxfa_wsdlconnection.h"
358#include "xfa/fxfa/parser/cxfa_xdc.h"
359#include "xfa/fxfa/parser/cxfa_xdp.h"
360#include "xfa/fxfa/parser/cxfa_xfa.h"
361#include "xfa/fxfa/parser/cxfa_xmlconnection.h"
362#include "xfa/fxfa/parser/cxfa_xsdconnection.h"
363#include "xfa/fxfa/parser/cxfa_xsl.h"
364#include "xfa/fxfa/parser/cxfa_zpl.h"
365#include "xfa/fxfa/parser/xfa_basic_data.h"
366#include "xfa/fxfa/parser/xfa_utils.h"
367
369class CXFA_ImageEditData;
370class CXFA_ImageLayoutData;
371class CXFA_TextEditData;
372class CXFA_TextLayoutData;
373
374namespace {
375
376constexpr uint8_t kMaxExecuteRecursion = 2;
377
378constexpr uint8_t kInvBase64[128] = {
379 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
380 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
381 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 62, 255,
382 255, 255, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 255, 255,
383 255, 255, 255, 255, 255, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
384 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
385 25, 255, 255, 255, 255, 255, 255, 26, 27, 28, 29, 30, 31, 32, 33,
386 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
387 49, 50, 51, 255, 255, 255, 255, 255,
388};
389
390inline uint8_t GetInvBase64(uint8_t x) {
391 return (x & 128) == 0 ? kInvBase64[x] : 255;
392}
393
394DataVector<uint8_t> XFA_RemoveBase64Whitespace(
395 pdfium::span<const uint8_t> spStr) {
396 DataVector<uint8_t> result;
397 result.reserve(spStr.size());
398 for (uint8_t ch : spStr) {
399 if (GetInvBase64(ch) != 255 || ch == '=')
400 result.push_back(ch);
401 }
402 return result;
403}
404
405DataVector<uint8_t> XFA_Base64Decode(const ByteString& bsStr) {
406 DataVector<uint8_t> result;
407 if (bsStr.IsEmpty())
408 return result;
409
410 DataVector<uint8_t> buffer = XFA_RemoveBase64Whitespace(bsStr.raw_span());
411 result.reserve(3 * (buffer.size() / 4));
412
413 uint32_t dwLimb = 0;
414 for (size_t i = 0; i + 3 < buffer.size(); i += 4) {
415 if (buffer[i] == '=' || buffer[i + 1] == '=' || buffer[i + 2] == '=' ||
416 buffer[i + 3] == '=') {
417 if (buffer[i] == '=' || buffer[i + 1] == '=') {
418 break;
419 }
420 if (buffer[i + 2] == '=') {
421 dwLimb = ((uint32_t)kInvBase64[buffer[i]] << 6) |
422 ((uint32_t)kInvBase64[buffer[i + 1]]);
423 result.push_back((uint8_t)(dwLimb >> 4) & 0xFF);
424 } else {
425 dwLimb = ((uint32_t)kInvBase64[buffer[i]] << 12) |
426 ((uint32_t)kInvBase64[buffer[i + 1]] << 6) |
427 ((uint32_t)kInvBase64[buffer[i + 2]]);
428 result.push_back((uint8_t)(dwLimb >> 10) & 0xFF);
429 result.push_back((uint8_t)(dwLimb >> 2) & 0xFF);
430 }
431 } else {
432 dwLimb = ((uint32_t)kInvBase64[buffer[i]] << 18) |
433 ((uint32_t)kInvBase64[buffer[i + 1]] << 12) |
434 ((uint32_t)kInvBase64[buffer[i + 2]] << 6) |
435 ((uint32_t)kInvBase64[buffer[i + 3]]);
436 result.push_back((uint8_t)(dwLimb >> 16) & 0xff);
437 result.push_back((uint8_t)(dwLimb >> 8) & 0xff);
438 result.push_back((uint8_t)(dwLimb)&0xff);
439 }
440 }
441 return result;
442}
443
444FXCODEC_IMAGE_TYPE XFA_GetImageType(const WideString& wsType) {
445 WideString wsContentType(wsType);
446 if (wsContentType.EqualsASCIINoCase("image/jpg"))
447 return FXCODEC_IMAGE_JPG;
448
449#ifdef PDF_ENABLE_XFA_BMP
450 if (wsContentType.EqualsASCIINoCase("image/bmp"))
451 return FXCODEC_IMAGE_BMP;
452#endif // PDF_ENABLE_XFA_BMP
453
454#ifdef PDF_ENABLE_XFA_GIF
455 if (wsContentType.EqualsASCIINoCase("image/gif"))
456 return FXCODEC_IMAGE_GIF;
457#endif // PDF_ENABLE_XFA_GIF
458
459#ifdef PDF_ENABLE_XFA_PNG
460 if (wsContentType.EqualsASCIINoCase("image/png"))
461 return FXCODEC_IMAGE_PNG;
462#endif // PDF_ENABLE_XFA_PNG
463
464#ifdef PDF_ENABLE_XFA_TIFF
465 if (wsContentType.EqualsASCII("image/tif"))
466 return FXCODEC_IMAGE_TIFF;
467#endif // PDF_ENABLE_XFA_TIFF
468
469 return FXCODEC_IMAGE_UNKNOWN;
470}
471
472RetainPtr<CFX_DIBitmap> XFA_LoadImageData(CXFA_FFDoc* pDoc,
473 CXFA_Image* pImage,
474 bool& bNameImage,
475 int32_t& iImageXDpi,
476 int32_t& iImageYDpi) {
477 WideString wsHref = pImage->GetHref();
478 WideString wsImage = pImage->GetContent();
479 if (wsHref.IsEmpty() && wsImage.IsEmpty())
480 return nullptr;
481
482 FXCODEC_IMAGE_TYPE type = XFA_GetImageType(pImage->GetContentType());
483
484 RetainPtr<IFX_SeekableReadStream> pImageFileRead;
485 if (wsImage.GetLength() > 0) {
487 if (iEncoding == XFA_AttributeValue::Base64) {
488 DataVector<uint8_t> buffer = XFA_Base64Decode(wsImage.ToUTF8());
489 if (!buffer.empty()) {
490 pImageFileRead =
491 pdfium::MakeRetain<CFX_ReadOnlyVectorStream>(std::move(buffer));
492 }
493 } else {
494 pImageFileRead =
495 pdfium::MakeRetain<CFX_ReadOnlyStringStream>(wsImage.ToDefANSI());
496 }
497 } else {
498 WideString wsURL = wsHref;
499 if (!(wsURL.First(7).EqualsASCII("http://") ||
500 wsURL.First(6).EqualsASCII("ftp://"))) {
501 RetainPtr<CFX_DIBitmap> pBitmap =
502 pDoc->GetPDFNamedImage(wsURL.AsStringView(), iImageXDpi, iImageYDpi);
503 if (pBitmap) {
504 bNameImage = true;
505 return pBitmap;
506 }
507 }
508 pImageFileRead = pDoc->OpenLinkedFile(wsURL);
509 }
510 if (!pImageFileRead)
511 return nullptr;
512
513 bNameImage = false;
514 return XFA_LoadImageFromBuffer(std::move(pImageFileRead), type, iImageXDpi,
515 iImageYDpi);
516}
517
518bool SplitDateTime(const WideString& wsDateTime,
519 WideString& wsDate,
520 WideString& wsTime) {
521 wsDate.clear();
522 wsTime.clear();
523 if (wsDateTime.IsEmpty())
524 return false;
525
526 auto nSplitIndex = wsDateTime.Find('T');
527 if (!nSplitIndex.has_value())
528 nSplitIndex = wsDateTime.Find(' ');
529 if (!nSplitIndex.has_value())
530 return false;
531
532 wsDate = wsDateTime.First(nSplitIndex.value());
533 if (!wsDate.IsEmpty()) {
534 if (!std::any_of(wsDate.begin(), wsDate.end(),
535 [](wchar_t c) { return FXSYS_IsDecimalDigit(c); })) {
536 return false;
537 }
538 }
539 wsTime = wsDateTime.Last(wsDateTime.GetLength() - nSplitIndex.value() - 1);
540 if (!wsTime.IsEmpty()) {
541 if (!std::any_of(wsTime.begin(), wsTime.end(),
542 [](wchar_t c) { return FXSYS_IsDecimalDigit(c); })) {
543 return false;
544 }
545 }
546 return true;
547}
548
549// Stack allocated. Using containers of members would be correct here
550// if advanced GC worked with STL.
551using NodeSet = std::set<cppgc::Member<CXFA_Node>>;
552using NodeSetPair = std::pair<NodeSet, NodeSet>;
553using NodeSetPairMap = std::map<uint32_t, NodeSetPair>;
554using NodeSetPairMapMap = std::map<CXFA_Node*, NodeSetPairMap>;
555using NodeVector = std::vector<cppgc::Member<CXFA_Node>>;
556
557NodeVector NodesSortedByDocumentIdx(const NodeSet& rgNodeSet) {
558 if (rgNodeSet.empty())
559 return NodeVector();
560
561 NodeVector rgNodeArray;
562 CXFA_Node* pCommonParent = (*rgNodeSet.begin())->GetParent();
563 for (CXFA_Node* pNode = pCommonParent->GetFirstChild(); pNode;
564 pNode = pNode->GetNextSibling()) {
565 if (pdfium::Contains(rgNodeSet, pNode))
566 rgNodeArray.push_back(pNode);
567 }
568 return rgNodeArray;
569}
570
571NodeSetPair* NodeSetPairForNode(CXFA_Node* pNode, NodeSetPairMapMap* pMap) {
572 CXFA_Node* pParentNode = pNode->GetParent();
573 uint32_t dwNameHash = pNode->GetNameHash();
574 if (!pParentNode || !dwNameHash)
575 return nullptr;
576
577 return &((*pMap)[pParentNode][dwNameHash]);
578}
579
580void ReorderDataNodes(const NodeSet& sSet1,
581 const NodeSet& sSet2,
582 bool bInsertBefore) {
583 NodeSetPairMapMap rgMap;
584 for (CXFA_Node* pNode : sSet1) {
585 NodeSetPair* pNodeSetPair = NodeSetPairForNode(pNode, &rgMap);
586 if (pNodeSetPair)
587 pNodeSetPair->first.insert(pNode);
588 }
589 for (CXFA_Node* pNode : sSet2) {
590 NodeSetPair* pNodeSetPair = NodeSetPairForNode(pNode, &rgMap);
591 if (pNodeSetPair) {
592 if (pdfium::Contains(pNodeSetPair->first, pNode))
593 pNodeSetPair->first.erase(pNode);
594 else
595 pNodeSetPair->second.insert(pNode);
596 }
597 }
598 for (auto& iter1 : rgMap) {
599 NodeSetPairMap* pNodeSetPairMap = &iter1.second;
600 for (auto& iter2 : *pNodeSetPairMap) {
601 NodeSetPair* pNodeSetPair = &iter2.second;
602 if (!pNodeSetPair->first.empty() && !pNodeSetPair->second.empty()) {
603 NodeVector rgNodeArray1 = NodesSortedByDocumentIdx(pNodeSetPair->first);
604 NodeVector rgNodeArray2 =
605 NodesSortedByDocumentIdx(pNodeSetPair->second);
606 CXFA_Node* pParentNode = nullptr;
607 CXFA_Node* pBeforeNode = nullptr;
608 if (bInsertBefore) {
609 pBeforeNode = rgNodeArray2.front();
610 pParentNode = pBeforeNode->GetParent();
611 } else {
612 CXFA_Node* pLastNode = rgNodeArray2.back();
613 pParentNode = pLastNode->GetParent();
614 pBeforeNode = pLastNode->GetNextSibling();
615 }
616 for (auto& pCurNode : rgNodeArray1) {
617 pParentNode->RemoveChildAndNotify(pCurNode, true);
618 pParentNode->InsertChildAndNotify(pCurNode, pBeforeNode);
619 }
620 }
621 }
622 pNodeSetPairMap->clear();
623 }
624}
625
626float GetEdgeThickness(const std::vector<CXFA_Stroke*>& strokes,
627 bool b3DStyle,
628 int32_t nIndex) {
629 float fThickness = 0.0f;
630 CXFA_Stroke* stroke = strokes[nIndex * 2 + 1];
631 if (stroke->IsVisible()) {
632 if (nIndex == 0)
633 fThickness += 2.5f;
634
635 fThickness += stroke->GetThickness() * (b3DStyle ? 4 : 2);
636 }
637 return fThickness;
638}
639
640WideString FormatNumStr(const WideString& wsValue, LocaleIface* pLocale) {
641 if (wsValue.IsEmpty())
642 return WideString();
643
644 WideString wsSrcNum = wsValue;
645 WideString wsGroupSymbol = pLocale->GetGroupingSymbol();
646 bool bNeg = false;
647 if (wsSrcNum[0] == '-') {
648 bNeg = true;
649 wsSrcNum.Delete(0, 1);
650 }
651
652 size_t dot_index = wsSrcNum.Find('.').value_or(wsSrcNum.GetLength());
653 if (dot_index == 0)
654 return WideString();
655
656 size_t nPos = dot_index % 3;
657 WideString wsOutput;
658 for (size_t i = 0; i < dot_index; i++) {
659 if (i % 3 == nPos && i != 0)
660 wsOutput += wsGroupSymbol;
661
662 wsOutput += wsSrcNum[i];
663 }
664 if (dot_index < wsSrcNum.GetLength()) {
665 wsOutput += pLocale->GetDecimalSymbol();
666 wsOutput += wsSrcNum.Last(wsSrcNum.GetLength() - dot_index - 1);
667 }
668 if (bNeg)
669 return pLocale->GetMinusSymbol() + wsOutput;
670
671 return wsOutput;
672}
673
674CXFA_Node* FindFirstSiblingNamedInList(CXFA_Node* parent,
675 uint32_t dwNameHash,
676 Mask<XFA_NodeFilter> dwFilter);
677CXFA_Node* FindFirstSiblingOfClassInList(CXFA_Node* parent,
678 XFA_Element element,
679 Mask<XFA_NodeFilter> dwFilter);
680
681CXFA_Node* FindFirstSiblingNamed(CXFA_Node* parent, uint32_t dwNameHash) {
682 CXFA_Node* result = FindFirstSiblingNamedInList(parent, dwNameHash,
684 if (result)
685 return result;
686
687 return FindFirstSiblingNamedInList(parent, dwNameHash,
689}
690
691CXFA_Node* FindFirstSiblingNamedInList(CXFA_Node* parent,
692 uint32_t dwNameHash,
693 Mask<XFA_NodeFilter> dwFilter) {
694 for (CXFA_Node* child : parent->GetNodeListWithFilter(dwFilter)) {
695 if (child->GetNameHash() == dwNameHash)
696 return child;
697
698 CXFA_Node* result = FindFirstSiblingNamed(child, dwNameHash);
699 if (result)
700 return result;
701 }
702 return nullptr;
703}
704
705CXFA_Node* FindFirstSiblingOfClass(CXFA_Node* parent, XFA_Element element) {
706 CXFA_Node* result = FindFirstSiblingOfClassInList(
707 parent, element, XFA_NodeFilter::kProperties);
708 if (result)
709 return result;
710
711 return FindFirstSiblingOfClassInList(parent, element,
713}
714
715CXFA_Node* FindFirstSiblingOfClassInList(CXFA_Node* parent,
716 XFA_Element element,
717 Mask<XFA_NodeFilter> dwFilter) {
718 for (CXFA_Node* child : parent->GetNodeListWithFilter(dwFilter)) {
719 if (child->GetElementType() == element)
720 return child;
721
722 CXFA_Node* result = FindFirstSiblingOfClass(child, element);
723 if (result)
724 return result;
725 }
726 return nullptr;
727}
728
729WideString GetNameExpressionSinglePath(CXFA_Node* pNode) {
730 const bool bIsProperty = pNode->IsProperty();
731 const bool bIsClassIndex =
732 pNode->IsUnnamed() ||
733 (bIsProperty && pNode->GetElementType() != XFA_Element::PageSet);
734 const wchar_t* pszFormat;
735 WideString ws;
736 if (bIsClassIndex) {
737 pszFormat = L"#%ls[%zu]";
738 ws = WideString::FromASCII(pNode->GetClassName());
739 } else {
740 pszFormat = L"%ls[%zu]";
741 ws = pNode->JSObject()->GetCData(XFA_Attribute::Name);
742 ws.Replace(L".", L"\\.");
743 }
744
745 return WideString::Format(pszFormat, ws.c_str(),
746 pNode->GetIndex(bIsProperty, bIsClassIndex));
747}
748
749void TraverseSiblings(CXFA_Node* parent,
750 uint32_t dwNameHash,
751 std::vector<CXFA_Node*>* pSiblings,
752 bool bIsClassName) {
753 DCHECK(parent);
754 DCHECK(pSiblings);
755 for (CXFA_Node* child :
756 parent->GetNodeListWithFilter(XFA_NodeFilter::kChildren)) {
757 if (child->GetElementType() == XFA_Element::Variables)
758 continue;
759
760 if (bIsClassName) {
761 if (child->GetClassHashCode() == dwNameHash)
762 pSiblings->push_back(child);
763 } else {
764 if (child->GetNameHash() == dwNameHash)
765 pSiblings->push_back(child);
766 }
767 if (child->IsTransparent() &&
768 child->GetElementType() != XFA_Element::PageSet) {
769 TraverseSiblings(child, dwNameHash, pSiblings, bIsClassName);
770 }
771 }
772}
773
774void TraversePropertiesOrSiblings(CXFA_Node* parent,
775 uint32_t dwNameHash,
776 std::vector<CXFA_Node*>* pSiblings,
777 bool bIsClassName) {
778 DCHECK(parent);
779 DCHECK(pSiblings);
780 for (CXFA_Node* child :
781 parent->GetNodeListWithFilter(XFA_NodeFilter::kProperties)) {
782 if (bIsClassName) {
783 if (child->GetClassHashCode() == dwNameHash)
784 pSiblings->push_back(child);
785 } else {
786 if (child->GetNameHash() == dwNameHash) {
787 if (child->GetElementType() != XFA_Element::PageSet &&
788 child->GetElementType() != XFA_Element::Extras &&
789 child->GetElementType() != XFA_Element::Items) {
790 pSiblings->push_back(child);
791 }
792 }
793 }
794 if (child->IsUnnamed() && child->GetElementType() == XFA_Element::PageSet) {
795 TraverseSiblings(child, dwNameHash, pSiblings, bIsClassName);
796 }
797 }
798 if (pSiblings->empty())
799 TraverseSiblings(parent, dwNameHash, pSiblings, bIsClassName);
800}
801
802} // namespace
803
806 public:
808 virtual ~CXFA_WidgetLayoutData() = default;
809
810 virtual void Trace(cppgc::Visitor* visitor) const {}
811
812 virtual CXFA_FieldLayoutData* AsFieldLayoutData() { return nullptr; }
813 virtual CXFA_ImageLayoutData* AsImageLayoutData() { return nullptr; }
814 virtual CXFA_TextLayoutData* AsTextLayoutData() { return nullptr; }
815
816 float GetWidgetHeight() const { return m_fWidgetHeight; }
817 void SetWidgetHeight(float height) { m_fWidgetHeight = height; }
818
819 protected:
821
822 private:
823 float m_fWidgetHeight = -1.0f;
824};
825
826class CXFA_TextLayoutData final : public CXFA_WidgetLayoutData {
827 public:
829 ~CXFA_TextLayoutData() override = default;
830
831 void Trace(cppgc::Visitor* visitor) const override {
833 visitor->Trace(m_pTextLayout);
834 visitor->Trace(m_pTextProvider);
835 }
836
837 CXFA_TextLayoutData* AsTextLayoutData() override { return this; }
838
839 CXFA_TextLayout* GetTextLayout() const { return m_pTextLayout; }
840 CXFA_TextProvider* GetTextProvider() const { return m_pTextProvider; }
841
842 void LoadText(CXFA_FFDoc* doc, CXFA_Node* pNode) {
843 if (m_pTextLayout)
844 return;
845
846 m_pTextProvider = cppgc::MakeGarbageCollected<CXFA_TextProvider>(
847 doc->GetHeap()->GetAllocationHandle(), pNode,
848 CXFA_TextProvider::Type::kText);
849 m_pTextLayout = cppgc::MakeGarbageCollected<CXFA_TextLayout>(
850 doc->GetHeap()->GetAllocationHandle(), doc, m_pTextProvider);
851 }
852
853 private:
854 CXFA_TextLayoutData() = default;
855
856 cppgc::Member<CXFA_TextLayout> m_pTextLayout;
857 cppgc::Member<CXFA_TextProvider> m_pTextProvider;
858};
859
860class CXFA_ImageLayoutData final : public CXFA_WidgetLayoutData {
861 public:
863 ~CXFA_ImageLayoutData() override = default;
864
865 CXFA_ImageLayoutData* AsImageLayoutData() override { return this; }
866
867 bool LoadImageData(CXFA_FFDoc* doc, CXFA_Node* pNode) {
868 if (m_pDIBitmap)
869 return true;
870
871 CXFA_Value* value = pNode->GetFormValueIfExists();
872 if (!value)
873 return false;
874
875 CXFA_Image* image = value->GetImageIfExists();
876 if (!image)
877 return false;
878
879 pNode->SetLayoutImage(XFA_LoadImageData(doc, image, m_bNamedImage,
880 m_iImageXDpi, m_iImageYDpi));
881 return !!m_pDIBitmap;
882 }
883
884 CFX_Size GetDpi() const { return CFX_Size(m_iImageXDpi, m_iImageYDpi); }
885 RetainPtr<CFX_DIBitmap> GetBitmap() { return m_pDIBitmap; }
886 void SetBitmap(RetainPtr<CFX_DIBitmap> pBitmap) {
887 m_pDIBitmap = std::move(pBitmap);
888 }
889
890 private:
891 CXFA_ImageLayoutData() = default;
892
893 bool m_bNamedImage = false;
894 int32_t m_iImageXDpi = 0;
895 int32_t m_iImageYDpi = 0;
896 RetainPtr<CFX_DIBitmap> m_pDIBitmap;
897};
898
900 public:
902 ~CXFA_FieldLayoutData() override = default;
903
904 void Trace(cppgc::Visitor* visitor) const override {
906 visitor->Trace(m_pCapTextLayout);
907 visitor->Trace(m_pCapTextProvider);
908 }
909 CXFA_FieldLayoutData* AsFieldLayoutData() override { return this; }
910
911 virtual CXFA_ImageEditData* AsImageEditData() { return nullptr; }
912 virtual CXFA_TextEditData* AsTextEditData() { return nullptr; }
913
914 bool LoadCaption(CXFA_FFDoc* doc, CXFA_Node* pNode) {
915 if (m_pCapTextLayout)
916 return true;
917 CXFA_Caption* caption = pNode->GetCaptionIfExists();
918 if (!caption || caption->IsHidden())
919 return false;
920
921 m_pCapTextProvider = cppgc::MakeGarbageCollected<CXFA_TextProvider>(
922 doc->GetHeap()->GetAllocationHandle(), pNode,
923 CXFA_TextProvider::Type::kCaption);
924 m_pCapTextLayout = cppgc::MakeGarbageCollected<CXFA_TextLayout>(
925 doc->GetHeap()->GetAllocationHandle(), doc, m_pCapTextProvider);
926 return true;
927 }
928
933
934 protected:
936};
937
938class CXFA_TextEditData final : public CXFA_FieldLayoutData {
939 public:
941 ~CXFA_TextEditData() override = default;
942
943 CXFA_TextEditData* AsTextEditData() override { return this; }
944
945 protected:
946 CXFA_TextEditData() = default;
947};
948
949class CXFA_ImageEditData final : public CXFA_FieldLayoutData {
950 public:
952 ~CXFA_ImageEditData() override = default;
953
954 CXFA_ImageEditData* AsImageEditData() override { return this; }
955
956 bool LoadImageData(CXFA_FFDoc* doc, CXFA_Node* pNode) {
957 if (m_pDIBitmap)
958 return true;
959
960 CXFA_Value* value = pNode->GetFormValueIfExists();
961 if (!value)
962 return false;
963
964 CXFA_Image* image = value->GetImageIfExists();
965 if (!image)
966 return false;
967
968 pNode->SetEditImage(XFA_LoadImageData(doc, image, m_bNamedImage,
969 m_iImageXDpi, m_iImageYDpi));
970 return !!m_pDIBitmap;
971 }
972
973 CFX_Size GetDpi() const { return CFX_Size(m_iImageXDpi, m_iImageYDpi); }
974 RetainPtr<CFX_DIBitmap> GetBitmap() { return m_pDIBitmap; }
975 void SetBitmap(RetainPtr<CFX_DIBitmap> pBitmap) {
976 m_pDIBitmap = std::move(pBitmap);
977 }
978
979 private:
980 CXFA_ImageEditData() = default;
981
982 bool m_bNamedImage = false;
983 int32_t m_iImageXDpi = 0;
984 int32_t m_iImageYDpi = 0;
985 RetainPtr<CFX_DIBitmap> m_pDIBitmap;
986};
987
988CXFA_Node::CXFA_Node(CXFA_Document* pDoc,
989 XFA_PacketType ePacket,
990 Mask<XFA_XDPPACKET> validPackets,
991 XFA_ObjectType oType,
992 XFA_Element eType,
993 pdfium::span<const PropertyData> properties,
994 pdfium::span<const AttributeData> attributes,
995 CJX_Object* js_object)
996 : CXFA_Object(pDoc, oType, eType, js_object),
1000 m_ePacket(ePacket) {
1001 DCHECK(m_pDocument);
1002}
1003
1004CXFA_Node::~CXFA_Node() = default;
1005
1006void CXFA_Node::Trace(cppgc::Visitor* visitor) const {
1007 CXFA_Object::Trace(visitor);
1008 GCedTreeNodeMixin<CXFA_Node>::Trace(visitor);
1009 visitor->Trace(m_pAuxNode);
1010 visitor->Trace(m_pLayoutData);
1011 visitor->Trace(ui_);
1012 ContainerTrace(visitor, binding_nodes_);
1013}
1014
1015CXFA_Node* CXFA_Node::Clone(bool bRecursive) {
1016 CXFA_Node* pClone = m_pDocument->CreateNode(m_ePacket, m_elementType);
1017 if (!pClone)
1018 return nullptr;
1019
1020 JSObject()->MergeAllData(pClone);
1021 pClone->UpdateNameHash();
1023 CFX_XMLNode* pCloneXML;
1024 if (IsAttributeInXML()) {
1025 WideString wsName = JSObject()
1026 ->TryAttribute(XFA_Attribute::Name, false)
1027 .value_or(WideString());
1028 auto* pCloneXMLElement =
1029 GetXMLDocument()->CreateNode<CFX_XMLElement>(wsName);
1030
1031 WideString wsValue = JSObject()->GetCData(XFA_Attribute::Value);
1032 if (!wsValue.IsEmpty()) {
1033 auto* text = GetXMLDocument()->CreateNode<CFX_XMLText>(wsValue);
1034 pCloneXMLElement->AppendLastChild(text);
1035 }
1036
1037 pCloneXML = pCloneXMLElement;
1038 pClone->JSObject()->SetEnum(XFA_Attribute::Contains,
1039 XFA_AttributeValue::Unknown, false);
1040 } else {
1041 pCloneXML = xml_node_->Clone(GetXMLDocument());
1042 }
1043 pClone->SetXMLMappingNode(pCloneXML);
1044 }
1045 if (bRecursive) {
1046 for (CXFA_Node* pChild = GetFirstChild(); pChild;
1047 pChild = pChild->GetNextSibling()) {
1048 pClone->InsertChildAndNotify(pChild->Clone(bRecursive), nullptr);
1049 }
1050 }
1052 pClone->SetBindingNode(nullptr);
1053 return pClone;
1054}
1055
1057 for (auto* pNode = GetNextSibling(); pNode; pNode = pNode->GetNextSibling()) {
1058 if (pNode->GetObjectType() == XFA_ObjectType::ContainerNode)
1059 return pNode;
1060 }
1061 return nullptr;
1062}
1063
1065 for (auto* pNode = GetPrevSibling(); pNode; pNode = pNode->GetPrevSibling()) {
1066 if (pNode->GetObjectType() == XFA_ObjectType::ContainerNode)
1067 return pNode;
1068 }
1069 return nullptr;
1070}
1071
1073 for (auto* pNode = GetFirstChild(); pNode; pNode = pNode->GetNextSibling()) {
1074 if (pNode->GetObjectType() == XFA_ObjectType::ContainerNode)
1075 return pNode;
1076 }
1077 return nullptr;
1078}
1079
1081 for (auto* pNode = GetParent(); pNode; pNode = pNode->GetParent()) {
1082 if (pNode->GetObjectType() == XFA_ObjectType::ContainerNode)
1083 return pNode;
1084 }
1085 return nullptr;
1086}
1087
1088bool CXFA_Node::IsValidInPacket(XFA_PacketType packet) const {
1089 uint32_t bitflag = 1 << static_cast<uint8_t>(packet);
1090 return !!(m_ValidPackets & static_cast<XFA_XDPPACKET>(bitflag));
1091}
1092
1093const CXFA_Node::PropertyData* CXFA_Node::GetPropertyData(
1094 XFA_Element property) const {
1095 DCHECK(property != XFA_Element::Unknown);
1096 for (const auto& prop : m_Properties) {
1097 if (prop.property == property)
1098 return &prop;
1099 }
1100 return nullptr;
1101}
1102
1103bool CXFA_Node::HasProperty(XFA_Element property) const {
1104 return !!GetPropertyData(property);
1105}
1106
1108 XFA_PropertyFlag flag) const {
1109 const PropertyData* data = GetPropertyData(property);
1110 return data && !!(data->flags & flag);
1111}
1112
1114 const PropertyData* data = GetPropertyData(property);
1115 return data ? data->occurrence_count : 0;
1116}
1117
1119 int32_t index,
1120 XFA_Element eProperty) const {
1121 if (index < 0 || index >= PropertyOccurrenceCount(eProperty))
1122 return {nullptr, 0};
1123
1124 int32_t iCount = 0;
1125 for (CXFA_Node* pNode = GetFirstChild(); pNode;
1126 pNode = pNode->GetNextSibling()) {
1127 if (pNode->GetElementType() == eProperty) {
1128 iCount++;
1129 if (iCount > index)
1130 return {pNode, iCount};
1131 }
1132 }
1133 return {nullptr, iCount};
1134}
1135
1137 XFA_Element eProperty) {
1138 if (index < 0 || index >= PropertyOccurrenceCount(eProperty))
1139 return nullptr;
1140
1141 int32_t iCount = 0;
1142 CXFA_Node* node;
1143 std::tie(node, iCount) = GetProperty(index, eProperty);
1144 if (node)
1145 return node;
1146
1148 for (CXFA_Node* pNode = GetFirstChild(); pNode;
1149 pNode = pNode->GetNextSibling()) {
1151 return nullptr;
1152 }
1153 }
1154 }
1155
1156 CXFA_Node* pNewNode = nullptr;
1157 for (; iCount <= index; ++iCount) {
1158 pNewNode = GetDocument()->CreateNode(GetPacketType(), eProperty);
1159 if (!pNewNode)
1160 return nullptr;
1161
1162 InsertChildAndNotify(pNewNode, nullptr);
1164 }
1165 return pNewNode;
1166}
1167
1168absl::optional<XFA_Element> CXFA_Node::GetFirstPropertyWithFlag(
1169 XFA_PropertyFlag flag) const {
1170 for (const auto& prop : m_Properties) {
1171 if (prop.flags & flag)
1172 return prop.property;
1173 }
1174 return absl::nullopt;
1175}
1176
1177const CXFA_Node::AttributeData* CXFA_Node::GetAttributeData(
1178 XFA_Attribute attr) const {
1179 DCHECK(attr != XFA_Attribute::Unknown);
1180 for (const auto& cur_attr : m_Attributes) {
1181 if (cur_attr.attribute == attr)
1182 return &cur_attr;
1183 }
1184 return nullptr;
1185}
1186
1188 return !!GetAttributeData(attr);
1189}
1190
1192 return i < m_Attributes.size() ? m_Attributes[i].attribute
1193 : XFA_Attribute::Unknown;
1194}
1195
1197 const AttributeData* data = GetAttributeData(type);
1198 return data ? data->type : XFA_AttributeType::CData;
1199}
1200
1202 std::vector<CXFA_Node*> nodes;
1203 for (CXFA_Node* pChild = GetFirstChild(); pChild;
1204 pChild = pChild->GetNextSibling()) {
1205 if (pChild->GetElementType() == eTypeFilter)
1206 nodes.push_back(pChild);
1207 }
1208 return nodes;
1209}
1210
1212 Mask<XFA_NodeFilter> dwFilter) {
1213 if (!dwFilter)
1214 return std::vector<CXFA_Node*>();
1215
1216 const bool bFilterChildren = !!(dwFilter & XFA_NodeFilter::kChildren);
1217 const bool bFilterProperties = !!(dwFilter & XFA_NodeFilter::kProperties);
1218 const bool bFilterOneOfProperties =
1219 !!(dwFilter & XFA_NodeFilter::kOneOfProperty);
1220
1221 std::vector<CXFA_Node*> nodes;
1222 if (bFilterChildren && bFilterProperties && !bFilterOneOfProperties) {
1223 for (CXFA_Node* pChild = GetFirstChild(); pChild;
1224 pChild = pChild->GetNextSibling()) {
1225 nodes.push_back(pChild);
1226 }
1227 return nodes;
1228 }
1229
1230 for (CXFA_Node* pChild = GetFirstChild(); pChild;
1231 pChild = pChild->GetNextSibling()) {
1232 if (HasProperty(pChild->GetElementType())) {
1233 if (bFilterProperties) {
1234 nodes.push_back(pChild);
1235 } else if (bFilterOneOfProperties &&
1238 nodes.push_back(pChild);
1239 } else if (bFilterChildren &&
1240 (pChild->GetElementType() == XFA_Element::Variables ||
1241 pChild->GetElementType() == XFA_Element::PageSet)) {
1242 nodes.push_back(pChild);
1243 }
1244 } else if (bFilterChildren) {
1245 nodes.push_back(pChild);
1246 }
1247 }
1248
1249 if (!bFilterOneOfProperties || !nodes.empty())
1250 return nodes;
1251
1252 absl::optional<XFA_Element> property =
1253 GetFirstPropertyWithFlag(XFA_PropertyFlag::kDefaultOneOf);
1254 if (!property.has_value())
1255 return nodes;
1256
1257 CXFA_Node* pNewNode =
1258 m_pDocument->CreateNode(GetPacketType(), property.value());
1259 if (pNewNode) {
1260 InsertChildAndNotify(pNewNode, nullptr);
1262 nodes.push_back(pNewNode);
1263 }
1264 return nodes;
1265}
1266
1268 CXFA_Node* pNode = m_pDocument->CreateNode(m_ePacket, eType);
1269 if (!pNode)
1270 return nullptr;
1271
1273 return pNode;
1274}
1275
1277 DCHECK_EQ(m_ePacket, XFA_PacketType::Template);
1278 CXFA_Node* pClone =
1279 m_pDocument->CreateNode(XFA_PacketType::Form, m_elementType);
1280 if (!pClone)
1281 return nullptr;
1282
1283 pClone->SetTemplateNode(this);
1284 pClone->UpdateNameHash();
1286 if (bRecursive) {
1287 for (CXFA_Node* pChild = GetFirstChild(); pChild;
1288 pChild = pChild->GetNextSibling()) {
1290 nullptr);
1291 }
1292 }
1294 return pClone;
1295}
1296
1298 return m_pAuxNode;
1299}
1300
1301void CXFA_Node::SetTemplateNode(CXFA_Node* pTemplateNode) {
1302 m_pAuxNode = pTemplateNode;
1303}
1304
1306 DCHECK_EQ(GetPacketType(), XFA_PacketType::Form);
1307 return GetBindingNode();
1308}
1309
1311 return std::vector<CXFA_Node*>(binding_nodes_.begin(), binding_nodes_.end());
1312}
1313
1315 DCHECK(pFormNode);
1316
1317 if (BindsFormItems()) {
1318 if (!pdfium::Contains(binding_nodes_, pFormNode))
1319 binding_nodes_.emplace_back(pFormNode);
1320 return;
1321 }
1322
1323 CXFA_Node* pOldFormItem = GetBindingNode();
1324 if (!pOldFormItem) {
1325 SetBindingNode(pFormNode);
1326 return;
1327 }
1328 if (pOldFormItem == pFormNode)
1329 return;
1330
1331 binding_nodes_.clear();
1332 binding_nodes_.push_back(pOldFormItem);
1333 binding_nodes_.push_back(pFormNode);
1334 m_uNodeFlags |= XFA_NodeFlag::kBindFormItems;
1335}
1336
1338 if (BindsFormItems()) {
1339 auto it =
1340 std::find(binding_nodes_.begin(), binding_nodes_.end(), pFormNode);
1341 if (it != binding_nodes_.end())
1342 binding_nodes_.erase(it);
1343
1344 if (binding_nodes_.size() == 1) {
1345 m_uNodeFlags.Clear(XFA_NodeFlag::kBindFormItems);
1346 return true;
1347 }
1348 return !binding_nodes_.empty();
1349 }
1350
1351 CXFA_Node* pOldFormItem = GetBindingNode();
1352 if (pOldFormItem != pFormNode)
1353 return !!pOldFormItem;
1354
1355 SetBindingNode(nullptr);
1356 return false;
1357}
1358
1359bool CXFA_Node::HasBindItem() const {
1360 return GetPacketType() == XFA_PacketType::Datasets && GetBindingNode();
1361}
1362
1364 if (GetPacketType() != XFA_PacketType::Form)
1365 return nullptr;
1366 XFA_Element eType = GetElementType();
1367 if (eType == XFA_Element::ExclGroup)
1368 return nullptr;
1369 CXFA_Node* pParentNode = GetParent();
1370 if (pParentNode && pParentNode->GetElementType() == XFA_Element::ExclGroup)
1371 return nullptr;
1372
1373 if (eType == XFA_Element::Field) {
1375 return nullptr;
1376
1378 if (!wsPicture.IsEmpty())
1379 return this;
1380
1381 CXFA_Node* pDataNode = GetBindData();
1382 if (!pDataNode)
1383 return nullptr;
1384
1385 CXFA_Node* pFieldNode = nullptr;
1386 for (auto* pFormNode : pDataNode->GetBindItemsCopy()) {
1387 if (!pFormNode || pFormNode->HasRemovedChildren())
1388 continue;
1389 pFieldNode = pFormNode->IsWidgetReady() ? pFormNode : nullptr;
1390 if (pFieldNode)
1391 wsPicture = pFieldNode->GetPictureContent(XFA_ValuePicture::kDataBind);
1392 if (!wsPicture.IsEmpty())
1393 break;
1394
1395 pFieldNode = nullptr;
1396 }
1397 return pFieldNode;
1398 }
1399
1400 CXFA_Node* pGrandNode = pParentNode ? pParentNode->GetParent() : nullptr;
1401 CXFA_Node* pValueNode =
1402 (pParentNode && pParentNode->GetElementType() == XFA_Element::Value)
1403 ? pParentNode
1404 : nullptr;
1405 if (!pValueNode) {
1406 pValueNode =
1407 (pGrandNode && pGrandNode->GetElementType() == XFA_Element::Value)
1408 ? pGrandNode
1409 : nullptr;
1410 }
1411 CXFA_Node* pParentOfValueNode =
1412 pValueNode ? pValueNode->GetParent() : nullptr;
1413 return pParentOfValueNode ? pParentOfValueNode->GetContainerNode() : nullptr;
1414}
1415
1417 absl::optional<WideString> localeName = GetLocaleName();
1418 if (!localeName.has_value())
1419 return nullptr;
1420 if (localeName.value().EqualsASCII("ambient"))
1421 return GetDocument()->GetLocaleMgr()->GetDefLocale();
1422 return GetDocument()->GetLocaleMgr()->GetLocaleByName(localeName.value());
1423}
1424
1426 CXFA_Node* pForm = ToNode(GetDocument()->GetXFAObject(XFA_HASHCODE_Form));
1427 if (!pForm)
1428 return absl::nullopt;
1429
1430 CXFA_Subform* pTopSubform =
1431 pForm->GetFirstChildByClass<CXFA_Subform>(XFA_Element::Subform);
1432 if (!pTopSubform)
1433 return absl::nullopt;
1434
1435 absl::optional<WideString> localeName;
1436 CXFA_Node* pLocaleNode = this;
1437 do {
1438 localeName =
1439 pLocaleNode->JSObject()->TryCData(XFA_Attribute::Locale, false);
1440 if (localeName.has_value())
1441 return localeName;
1442
1443 pLocaleNode = pLocaleNode->GetParent();
1444 } while (pLocaleNode && pLocaleNode != pTopSubform);
1445
1446 CXFA_Node* pConfig = ToNode(GetDocument()->GetXFAObject(XFA_HASHCODE_Config));
1447 localeName = GetDocument()->GetLocaleMgr()->GetConfigLocaleName(pConfig);
1448 if (localeName.has_value())
1449 return localeName;
1450
1451 if (pTopSubform) {
1452 localeName =
1453 pTopSubform->JSObject()->TryCData(XFA_Attribute::Locale, false);
1454 if (localeName.has_value())
1455 return localeName;
1456 }
1457
1458 LocaleIface* pLocale = GetDocument()->GetLocaleMgr()->GetDefLocale();
1459 if (!pLocale)
1460 return absl::nullopt;
1461
1462 return pLocale->GetName();
1463}
1464
1466 CXFA_Keep* pKeep = GetFirstChildByClass<CXFA_Keep>(XFA_Element::Keep);
1467 auto layout = JSObject()->TryEnum(XFA_Attribute::Layout, true);
1468 XFA_AttributeValue eLayoutType =
1469 layout.value_or(XFA_AttributeValue::Position);
1470 if (pKeep) {
1471 absl::optional<XFA_AttributeValue> intact =
1472 GetIntactFromKeep(pKeep, eLayoutType);
1473 if (intact.has_value())
1474 return intact.value();
1475 }
1476
1477 switch (GetElementType()) {
1478 case XFA_Element::Subform:
1479 switch (eLayoutType) {
1480 case XFA_AttributeValue::Position:
1481 case XFA_AttributeValue::Row:
1482 return XFA_AttributeValue::ContentArea;
1483 default:
1484 return XFA_AttributeValue::None;
1485 }
1486 case XFA_Element::Field: {
1487 CXFA_Node* parent = GetParent();
1488 if (!parent || parent->GetElementType() == XFA_Element::PageArea)
1489 return XFA_AttributeValue::ContentArea;
1490 if (parent->GetIntact() != XFA_AttributeValue::None)
1491 return XFA_AttributeValue::ContentArea;
1492
1493 auto value = parent->JSObject()->TryEnum(XFA_Attribute::Layout, true);
1494 XFA_AttributeValue eParLayout =
1495 value.value_or(XFA_AttributeValue::Position);
1496 if (eParLayout == XFA_AttributeValue::Position ||
1497 eParLayout == XFA_AttributeValue::Row ||
1498 eParLayout == XFA_AttributeValue::Table) {
1499 return XFA_AttributeValue::None;
1500 }
1501
1502 XFA_VERSION version = m_pDocument->GetCurVersionMode();
1503 if (eParLayout == XFA_AttributeValue::Tb && version < XFA_VERSION_208) {
1504 absl::optional<CXFA_Measurement> measureH =
1505 JSObject()->TryMeasure(XFA_Attribute::H, false);
1506 if (measureH.has_value())
1507 return XFA_AttributeValue::ContentArea;
1508 }
1509 return XFA_AttributeValue::None;
1510 }
1511 case XFA_Element::Draw:
1512 return XFA_AttributeValue::ContentArea;
1513 default:
1514 return XFA_AttributeValue::None;
1515 }
1516}
1517
1519 WideString wsName = GetNameExpressionSinglePath(this);
1520 CXFA_Node* parent = GetParent();
1521 while (parent) {
1522 WideString wsParent = GetNameExpressionSinglePath(parent);
1523 wsParent += L".";
1524 wsParent += wsName;
1525 wsName = std::move(wsParent);
1526 parent = parent->GetParent();
1527 }
1528 return wsName;
1529}
1530
1532 if (m_ePacket == XFA_PacketType::Datasets)
1533 return m_pAuxNode;
1534 return nullptr;
1535}
1536
1537void CXFA_Node::SetDataDescriptionNode(CXFA_Node* pDataDescriptionNode) {
1538 DCHECK_EQ(m_ePacket, XFA_PacketType::Datasets);
1539 m_pAuxNode = pDataDescriptionNode;
1540}
1541
1543 switch (GetPacketType()) {
1544 case XFA_PacketType::Xdp:
1545 return m_pDocument->GetRoot();
1546 case XFA_PacketType::Config:
1547 return ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Config));
1548 case XFA_PacketType::Template:
1549 return ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Template));
1550 case XFA_PacketType::Form:
1551 return ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Form));
1552 case XFA_PacketType::Datasets:
1553 return ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Datasets));
1554 case XFA_PacketType::LocaleSet:
1555 return ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_LocaleSet));
1556 case XFA_PacketType::ConnectionSet:
1557 return ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_ConnectionSet));
1558 case XFA_PacketType::SourceSet:
1559 return ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_SourceSet));
1560 case XFA_PacketType::Xdc:
1561 return ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Xdc));
1562 default:
1563 return this;
1564 }
1565}
1566
1567size_t CXFA_Node::CountChildren(XFA_Element eType, bool bOnlyChild) {
1568 size_t count = 0;
1569 for (CXFA_Node* pNode = GetFirstChild(); pNode;
1570 pNode = pNode->GetNextSibling()) {
1571 if (pNode->GetElementType() != eType && eType != XFA_Element::Unknown)
1572 continue;
1573 if (bOnlyChild && HasProperty(pNode->GetElementType()))
1574 continue;
1575 ++count;
1576 }
1577 return count;
1578}
1579
1580CXFA_Node* CXFA_Node::GetChildInternal(size_t index,
1581 XFA_Element eType,
1582 bool bOnlyChild) const {
1583 size_t count = 0;
1584 for (CXFA_Node* pNode = GetFirstChild(); pNode;
1585 pNode = pNode->GetNextSibling()) {
1586 if (pNode->GetElementType() != eType && eType != XFA_Element::Unknown)
1587 continue;
1588 if (bOnlyChild && HasProperty(pNode->GetElementType()))
1589 continue;
1590 if (count == index)
1591 return pNode;
1592
1593 ++count;
1594 }
1595 return nullptr;
1596}
1597
1598bool CXFA_Node::IsAncestorOf(const CXFA_Node* that) const {
1599 while (that) {
1600 if (this == that)
1601 return true;
1602 that = that->GetParent();
1603 }
1604 return false;
1605}
1606
1607void CXFA_Node::InsertChildAndNotify(int32_t index, CXFA_Node* pNode) {
1608 InsertChildAndNotify(pNode, GetNthChild(index));
1609}
1610
1612 CHECK(!pNode->GetParent());
1613 CHECK(!pBeforeNode || pBeforeNode->GetParent() == this);
1615 InsertBefore(pNode, pBeforeNode);
1616
1617 CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
1618 if (pNotify)
1619 pNotify->OnChildAdded(this);
1620
1621 if (!IsNeedSavingXMLNode() || !pNode->xml_node_)
1622 return;
1623
1624 DCHECK(!pNode->xml_node_->GetParent());
1625 xml_node_->InsertBefore(pNode->xml_node_,
1626 pBeforeNode ? pBeforeNode->xml_node_ : nullptr);
1627}
1628
1629void CXFA_Node::RemoveChildAndNotify(CXFA_Node* pNode, bool bNotify) {
1630 CHECK(pNode);
1631 if (pNode->GetParent() != this)
1632 return;
1633
1635 GCedTreeNodeMixin<CXFA_Node>::RemoveChild(pNode);
1636 OnRemoved(bNotify);
1637
1638 if (!IsNeedSavingXMLNode() || !pNode->xml_node_)
1639 return;
1640
1641 if (!pNode->IsAttributeInXML()) {
1642 xml_node_->RemoveChild(pNode->xml_node_);
1643 return;
1644 }
1645
1646 DCHECK_EQ(pNode->xml_node_, xml_node_);
1647 CFX_XMLElement* pXMLElement = ToXMLElement(pNode->xml_node_);
1648 if (pXMLElement) {
1649 WideString wsAttributeName =
1650 pNode->JSObject()->GetCData(XFA_Attribute::QualifiedName);
1651 pXMLElement->RemoveAttribute(wsAttributeName);
1652 }
1653
1654 WideString wsName = pNode->JSObject()
1655 ->TryAttribute(XFA_Attribute::Name, false)
1656 .value_or(WideString());
1657
1658 auto* pNewXMLElement = GetXMLDocument()->CreateNode<CFX_XMLElement>(wsName);
1659 WideString wsValue = JSObject()->GetCData(XFA_Attribute::Value);
1660 if (!wsValue.IsEmpty()) {
1661 auto* text = GetXMLDocument()->CreateNode<CFX_XMLText>(wsValue);
1662 pNewXMLElement->AppendLastChild(text);
1663 }
1664 pNode->xml_node_ = pNewXMLElement;
1665 pNode->JSObject()->SetEnum(XFA_Attribute::Contains,
1666 XFA_AttributeValue::Unknown, false);
1667}
1668
1669CXFA_Node* CXFA_Node::GetFirstChildByName(WideStringView wsName) const {
1670 return GetFirstChildByName(FX_HashCode_GetW(wsName));
1671}
1672
1673CXFA_Node* CXFA_Node::GetFirstChildByName(uint32_t dwNameHash) const {
1674 for (CXFA_Node* pNode = GetFirstChild(); pNode;
1675 pNode = pNode->GetNextSibling()) {
1676 if (pNode->GetNameHash() == dwNameHash)
1677 return pNode;
1678 }
1679 return nullptr;
1680}
1681
1682CXFA_Node* CXFA_Node::GetFirstChildByClassInternal(XFA_Element eType) const {
1683 for (CXFA_Node* pNode = GetFirstChild(); pNode;
1684 pNode = pNode->GetNextSibling()) {
1685 if (pNode->GetElementType() == eType)
1686 return pNode;
1687 }
1688 return nullptr;
1689}
1690
1691CXFA_Node* CXFA_Node::GetNextSameNameSibling(uint32_t dwNameHash) const {
1692 for (CXFA_Node* pNode = GetNextSibling(); pNode;
1693 pNode = pNode->GetNextSibling()) {
1694 if (pNode->GetNameHash() == dwNameHash)
1695 return pNode;
1696 }
1697 return nullptr;
1698}
1699
1700CXFA_Node* CXFA_Node::GetNextSameNameSiblingInternal(
1701 WideStringView wsNodeName) const {
1702 return GetNextSameNameSibling(FX_HashCode_GetW(wsNodeName));
1703}
1704
1705CXFA_Node* CXFA_Node::GetNextSameClassSiblingInternal(XFA_Element eType) const {
1706 for (CXFA_Node* pNode = GetNextSibling(); pNode;
1707 pNode = pNode->GetNextSibling()) {
1708 if (pNode->GetElementType() == eType)
1709 return pNode;
1710 }
1711 return nullptr;
1712}
1713
1714CXFA_Node* CXFA_Node::GetOneChildNamed(WideStringView wsName) {
1715 return FindFirstSiblingNamed(this, FX_HashCode_GetW(wsName));
1716}
1717
1718CXFA_Node* CXFA_Node::GetOneChildOfClass(WideStringView wsClass) {
1719 XFA_Element element = XFA_GetElementByName(wsClass);
1720 if (element == XFA_Element::Unknown)
1721 return nullptr;
1722
1723 return FindFirstSiblingOfClass(this, element);
1724}
1725
1726std::vector<CXFA_Node*> CXFA_Node::GetSiblings(bool bIsClassName) {
1727 std::vector<CXFA_Node*> siblings;
1728 CXFA_Node* parent = GetParent();
1729 if (!parent)
1730 return siblings;
1731 if (!parent->HasProperty(GetElementType())) {
1732 parent = GetTransparentParent();
1733 if (!parent)
1734 return siblings;
1735 }
1736
1737 uint32_t dwNameHash = bIsClassName ? GetClassHashCode() : GetNameHash();
1738 TraversePropertiesOrSiblings(parent, dwNameHash, &siblings, bIsClassName);
1739 return siblings;
1740}
1741
1742size_t CXFA_Node::GetIndex(bool bIsProperty, bool bIsClassIndex) {
1743 CXFA_Node* parent = GetParent();
1744 if (!parent)
1745 return 0;
1746
1747 if (!bIsProperty) {
1748 parent = GetTransparentParent();
1749 if (!parent)
1750 return 0;
1751 }
1752 uint32_t dwHashName = bIsClassIndex ? GetClassHashCode() : GetNameHash();
1753 std::vector<CXFA_Node*> siblings;
1754 TraversePropertiesOrSiblings(parent, dwHashName, &siblings, bIsClassIndex);
1755 for (size_t i = 0; i < siblings.size(); ++i) {
1756 if (siblings[i] == this)
1757 return i;
1758 }
1759 return 0;
1760}
1761
1763 return GetIndex(IsProperty(), /*bIsClassIndex=*/false);
1764}
1765
1767 return GetIndex(IsProperty(), /*bIsClassIndex=*/true);
1768}
1769
1771 CXFA_Node* pInstanceMgr = nullptr;
1772 if (m_ePacket == XFA_PacketType::Form) {
1773 CXFA_Node* pParentNode = GetParent();
1774 if (!pParentNode || pParentNode->GetElementType() == XFA_Element::Area)
1775 return pInstanceMgr;
1776
1777 for (CXFA_Node* pNode = GetPrevSibling(); pNode;
1778 pNode = pNode->GetPrevSibling()) {
1779 XFA_Element eType = pNode->GetElementType();
1780 if ((eType == XFA_Element::Subform || eType == XFA_Element::SubformSet) &&
1781 pNode->m_dwNameHash != m_dwNameHash) {
1782 break;
1783 }
1784 if (eType == XFA_Element::InstanceManager) {
1785 WideString wsName = JSObject()->GetCData(XFA_Attribute::Name);
1786 WideString wsInstName =
1787 pNode->JSObject()->GetCData(XFA_Attribute::Name);
1788 if (wsInstName.GetLength() > 0 && wsInstName[0] == '_' &&
1789 wsInstName.Last(wsInstName.GetLength() - 1) == wsName) {
1790 pInstanceMgr = pNode;
1791 }
1792 break;
1793 }
1794 }
1795 }
1796 return pInstanceMgr;
1797}
1798
1800 return GetFirstChildByClass<CXFA_Occur>(XFA_Element::Occur);
1801}
1802
1803bool CXFA_Node::HasFlag(XFA_NodeFlag dwFlag) const {
1804 if (m_uNodeFlags & dwFlag)
1805 return true;
1807 return GetParent() && GetParent()->HasFlag(dwFlag);
1808 return false;
1809}
1810
1812 if (!IsInitialized()) {
1813 CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
1814 if (pNotify)
1815 pNotify->OnNodeReady(this);
1816 }
1817 m_uNodeFlags |= XFA_NodeFlag::kInitialized;
1818}
1819
1821 m_uNodeFlags |= dwFlag;
1822}
1823
1825 m_uNodeFlags.Clear(dwFlag);
1826}
1827
1829 return JSObject()->GetEnum(XFA_Attribute::Contains) ==
1830 XFA_AttributeValue::MetaData;
1831}
1832
1833void CXFA_Node::OnRemoved(bool bNotify) const {
1834 if (!bNotify)
1835 return;
1836
1837 CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
1838 if (pNotify)
1839 pNotify->OnChildRemoved();
1840}
1841
1843 WideString wsName = JSObject()->GetCData(XFA_Attribute::Name);
1844 m_dwNameHash = FX_HashCode_GetW(wsName.AsStringView());
1845}
1846
1848 if (!xml_node_) {
1849 xml_node_ = GetXMLDocument()->CreateNode<CFX_XMLElement>(
1850 JSObject()->GetCData(XFA_Attribute::Name));
1851 }
1852 return xml_node_;
1853}
1854
1856 return xml_node_ && (GetPacketType() == XFA_PacketType::Datasets ||
1857 GetElementType() == XFA_Element::Xfa);
1858}
1859
1861 int32_t iCount = 0;
1862 uint32_t dwNameHash = 0;
1863 for (CXFA_Node* pNode = GetNextSibling(); pNode;
1864 pNode = pNode->GetNextSibling()) {
1865 XFA_Element eCurType = pNode->GetElementType();
1866 if (eCurType == XFA_Element::InstanceManager)
1867 break;
1868 if ((eCurType != XFA_Element::Subform) &&
1869 (eCurType != XFA_Element::SubformSet)) {
1870 continue;
1871 }
1872 if (iCount == 0) {
1873 WideString wsName = pNode->JSObject()->GetCData(XFA_Attribute::Name);
1874 WideString wsInstName = JSObject()->GetCData(XFA_Attribute::Name);
1875 if (wsInstName.GetLength() < 1 || wsInstName[0] != '_' ||
1876 wsInstName.Last(wsInstName.GetLength() - 1) != wsName) {
1877 return nullptr;
1878 }
1879 dwNameHash = pNode->GetNameHash();
1880 }
1881 if (dwNameHash != pNode->GetNameHash())
1882 break;
1883
1884 iCount++;
1885 if (iCount > iIndex)
1886 return pNode;
1887 }
1888 return nullptr;
1889}
1890
1892 int32_t iCount = 0;
1893 uint32_t dwNameHash = 0;
1894 for (CXFA_Node* pNode = GetNextSibling(); pNode;
1895 pNode = pNode->GetNextSibling()) {
1896 XFA_Element eCurType = pNode->GetElementType();
1897 if (eCurType == XFA_Element::InstanceManager)
1898 break;
1899 if ((eCurType != XFA_Element::Subform) &&
1900 (eCurType != XFA_Element::SubformSet)) {
1901 continue;
1902 }
1903 if (iCount == 0) {
1904 WideString wsName = pNode->JSObject()->GetCData(XFA_Attribute::Name);
1905 WideString wsInstName = JSObject()->GetCData(XFA_Attribute::Name);
1906 if (wsInstName.GetLength() < 1 || wsInstName[0] != '_' ||
1907 wsInstName.Last(wsInstName.GetLength() - 1) != wsName) {
1908 return iCount;
1909 }
1910 dwNameHash = pNode->GetNameHash();
1911 }
1912 if (dwNameHash != pNode->GetNameHash())
1913 break;
1914
1915 iCount++;
1916 }
1917 return iCount;
1918}
1919
1920void CXFA_Node::InsertItem(CXFA_Node* pNewInstance,
1921 int32_t iPos,
1922 int32_t iCount,
1923 bool bMoveDataBindingNodes) {
1924 if (iCount < 0)
1925 iCount = GetCount();
1926 if (iPos < 0)
1927 iPos = iCount;
1928 if (iPos == iCount) {
1929 CXFA_Node* item = GetItemIfExists(iCount - 1);
1930 if (!item)
1931 return;
1932
1933 CXFA_Node* pNextSibling =
1934 iCount > 0 ? item->GetNextSibling() : GetNextSibling();
1935 GetParent()->InsertChildAndNotify(pNewInstance, pNextSibling);
1936 if (bMoveDataBindingNodes) {
1937 NodeSet sNew;
1938 CXFA_NodeIteratorTemplate<CXFA_Node,
1939 CXFA_TraverseStrategy_XFAContainerNode>
1940 sIteratorNew(pNewInstance);
1941 for (CXFA_Node* pNode = sIteratorNew.GetCurrent(); pNode;
1942 pNode = sIteratorNew.MoveToNext()) {
1943 CXFA_Node* pDataNode = pNode->GetBindData();
1944 if (pDataNode)
1945 sNew.insert(pDataNode);
1946 }
1947 NodeSet sAfter;
1948 CXFA_NodeIteratorTemplate<CXFA_Node,
1949 CXFA_TraverseStrategy_XFAContainerNode>
1950 sIteratorAfter(pNextSibling);
1951 for (CXFA_Node* pNode = sIteratorAfter.GetCurrent(); pNode;
1952 pNode = sIteratorAfter.MoveToNext()) {
1953 CXFA_Node* pDataNode = pNode->GetBindData();
1954 if (pDataNode)
1955 sAfter.insert(pDataNode);
1956 }
1957 ReorderDataNodes(sNew, sAfter, false);
1958 }
1959 } else {
1960 CXFA_Node* pBeforeInstance = GetItemIfExists(iPos);
1961 if (!pBeforeInstance) {
1962 // TODO(dsinclair): What should happen here?
1963 return;
1964 }
1965
1966 GetParent()->InsertChildAndNotify(pNewInstance, pBeforeInstance);
1967 if (bMoveDataBindingNodes) {
1968 NodeSet sNew;
1969 CXFA_NodeIteratorTemplate<CXFA_Node,
1970 CXFA_TraverseStrategy_XFAContainerNode>
1971 sIteratorNew(pNewInstance);
1972 for (CXFA_Node* pNode = sIteratorNew.GetCurrent(); pNode;
1973 pNode = sIteratorNew.MoveToNext()) {
1974 CXFA_Node* pDataNode = pNode->GetBindData();
1975 if (pDataNode)
1976 sNew.insert(pDataNode);
1977 }
1978 NodeSet sBefore;
1979 CXFA_NodeIteratorTemplate<CXFA_Node,
1980 CXFA_TraverseStrategy_XFAContainerNode>
1981 sIteratorBefore(pBeforeInstance);
1982 for (CXFA_Node* pNode = sIteratorBefore.GetCurrent(); pNode;
1983 pNode = sIteratorBefore.MoveToNext()) {
1984 CXFA_Node* pDataNode = pNode->GetBindData();
1985 if (pDataNode)
1986 sBefore.insert(pDataNode);
1987 }
1988 ReorderDataNodes(sNew, sBefore, true);
1989 }
1990 }
1991}
1992
1993void CXFA_Node::RemoveItem(CXFA_Node* pRemoveInstance,
1994 bool bRemoveDataBinding) {
1995 GetParent()->RemoveChildAndNotify(pRemoveInstance, true);
1996 if (!bRemoveDataBinding)
1997 return;
1998
1999 CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_XFAContainerNode>
2000 sIterator(pRemoveInstance);
2001 for (CXFA_Node* pFormNode = sIterator.GetCurrent(); pFormNode;
2002 pFormNode = sIterator.MoveToNext()) {
2003 CXFA_Node* pDataNode = pFormNode->GetBindData();
2004 if (!pDataNode)
2005 continue;
2006
2007 if (!pDataNode->RemoveBindItem(pFormNode)) {
2008 if (CXFA_Node* pDataParent = pDataNode->GetParent()) {
2009 pDataParent->RemoveChildAndNotify(pDataNode, true);
2010 }
2011 }
2012 pFormNode->SetBindingNode(nullptr);
2013 }
2014}
2015
2017 CXFA_Document* pDocument = GetDocument();
2018 CXFA_Node* pTemplateNode = GetTemplateNodeIfExists();
2019 if (!pTemplateNode)
2020 return nullptr;
2021
2022 CXFA_Node* pFormParent = GetParent();
2023 CXFA_Node* pDataScope = nullptr;
2024 for (CXFA_Node* pRootBoundNode = pFormParent;
2025 pRootBoundNode && pRootBoundNode->IsContainerNode();
2026 pRootBoundNode = pRootBoundNode->GetParent()) {
2027 pDataScope = pRootBoundNode->GetBindData();
2028 if (pDataScope)
2029 break;
2030 }
2031 if (!pDataScope) {
2032 pDataScope = ToNode(pDocument->GetXFAObject(XFA_HASHCODE_Record));
2033 DCHECK(pDataScope);
2034 }
2035
2036 CXFA_Node* pInstance = pDocument->DataMerge_CopyContainer(
2037 pTemplateNode, pFormParent, pDataScope, true, bDataMerge, true);
2038 if (pInstance) {
2039 pDocument->DataMerge_UpdateBindingRelations(pInstance);
2040 pFormParent->RemoveChildAndNotify(pInstance, true);
2041 }
2042 return pInstance;
2043}
2044
2046 absl::optional<void*> value =
2047 GetDefaultValue(attr, XFA_AttributeType::Boolean);
2048 if (!value.has_value())
2049 return absl::nullopt;
2050 return !!value.value();
2051}
2052
2054 absl::optional<void*> value =
2055 GetDefaultValue(attr, XFA_AttributeType::Integer);
2056 if (!value.has_value())
2057 return absl::nullopt;
2058 return static_cast<int32_t>(reinterpret_cast<uintptr_t>(value.value()));
2059}
2060
2062 XFA_Attribute attr) const {
2063 absl::optional<void*> value =
2064 GetDefaultValue(attr, XFA_AttributeType::Measure);
2065 if (!value.has_value())
2066 return absl::nullopt;
2067
2068 WideString str = WideString(static_cast<const wchar_t*>(value.value()));
2069 return CXFA_Measurement(str.AsStringView());
2070}
2071
2073 XFA_Attribute attr) const {
2074 absl::optional<void*> value = GetDefaultValue(attr, XFA_AttributeType::CData);
2075 if (!value.has_value())
2076 return absl::nullopt;
2077
2078 return WideString(static_cast<const wchar_t*>(value.value()));
2079}
2080
2082 XFA_Attribute attr) const {
2083 absl::optional<void*> value = GetDefaultValue(attr, XFA_AttributeType::Enum);
2084 if (!value.has_value())
2085 return absl::nullopt;
2086 return static_cast<XFA_AttributeValue>(
2087 reinterpret_cast<uintptr_t>(value.value()));
2088}
2089
2090absl::optional<void*> CXFA_Node::GetDefaultValue(
2091 XFA_Attribute attr,
2092 XFA_AttributeType eType) const {
2093 const AttributeData* data = GetAttributeData(attr);
2094 if (!data || data->type != eType)
2095 return absl::nullopt;
2096 return data->default_value;
2097}
2098
2100 bool bScriptModify) {
2101 CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
2102 if (!pNotify)
2103 return;
2104
2105 if (GetPacketType() != XFA_PacketType::Form) {
2106 pNotify->OnValueChanged(this, eAttribute, this, this);
2107 return;
2108 }
2109
2110 bool bNeedFindContainer = false;
2111 switch (GetElementType()) {
2112 case XFA_Element::Caption:
2113 bNeedFindContainer = true;
2114 pNotify->OnValueChanged(this, eAttribute, this, GetParent());
2115 break;
2116 case XFA_Element::Font:
2117 case XFA_Element::Para: {
2118 bNeedFindContainer = true;
2119 CXFA_Node* pParentNode = GetParent();
2120 if (pParentNode->GetElementType() == XFA_Element::Caption) {
2121 pNotify->OnValueChanged(this, eAttribute, pParentNode,
2122 pParentNode->GetParent());
2123 } else {
2124 pNotify->OnValueChanged(this, eAttribute, this, pParentNode);
2125 }
2126 break;
2127 }
2128 case XFA_Element::Margin: {
2129 bNeedFindContainer = true;
2130 CXFA_Node* pParentNode = GetParent();
2131 XFA_Element eParentType = pParentNode->GetElementType();
2132 if (pParentNode->IsContainerNode()) {
2133 pNotify->OnValueChanged(this, eAttribute, this, pParentNode);
2134 } else if (eParentType == XFA_Element::Caption) {
2135 pNotify->OnValueChanged(this, eAttribute, pParentNode,
2136 pParentNode->GetParent());
2137 } else {
2138 CXFA_Node* pNode = pParentNode->GetParent();
2139 if (pNode && pNode->GetElementType() == XFA_Element::Ui)
2140 pNotify->OnValueChanged(this, eAttribute, pNode, pNode->GetParent());
2141 }
2142 break;
2143 }
2144 case XFA_Element::Comb: {
2145 CXFA_Node* pEditNode = GetParent();
2146 XFA_Element eUIType = pEditNode->GetElementType();
2147 if (pEditNode && (eUIType == XFA_Element::DateTimeEdit ||
2148 eUIType == XFA_Element::NumericEdit ||
2149 eUIType == XFA_Element::TextEdit)) {
2150 CXFA_Node* pUINode = pEditNode->GetParent();
2151 if (pUINode) {
2152 pNotify->OnValueChanged(this, eAttribute, pUINode,
2153 pUINode->GetParent());
2154 }
2155 }
2156 break;
2157 }
2158 case XFA_Element::Button:
2159 case XFA_Element::Barcode:
2160 case XFA_Element::ChoiceList:
2161 case XFA_Element::DateTimeEdit:
2162 case XFA_Element::NumericEdit:
2163 case XFA_Element::PasswordEdit:
2164 case XFA_Element::TextEdit: {
2165 CXFA_Node* pUINode = GetParent();
2166 if (pUINode) {
2167 pNotify->OnValueChanged(this, eAttribute, pUINode,
2168 pUINode->GetParent());
2169 }
2170 break;
2171 }
2172 case XFA_Element::CheckButton: {
2173 bNeedFindContainer = true;
2174 CXFA_Node* pUINode = GetParent();
2175 if (pUINode) {
2176 pNotify->OnValueChanged(this, eAttribute, pUINode,
2177 pUINode->GetParent());
2178 }
2179 break;
2180 }
2181 case XFA_Element::Keep:
2182 case XFA_Element::Bookend:
2183 case XFA_Element::Break:
2184 case XFA_Element::BreakAfter:
2185 case XFA_Element::BreakBefore:
2186 case XFA_Element::Overflow:
2187 bNeedFindContainer = true;
2188 break;
2189 case XFA_Element::Area:
2190 case XFA_Element::Draw:
2191 case XFA_Element::ExclGroup:
2192 case XFA_Element::Field:
2193 case XFA_Element::Subform:
2194 case XFA_Element::SubformSet:
2196 pNotify->OnValueChanged(this, eAttribute, this, this);
2197 break;
2198 case XFA_Element::Sharptext:
2199 case XFA_Element::Sharpxml:
2200 case XFA_Element::SharpxHTML: {
2201 CXFA_Node* pTextNode = GetParent();
2202 if (!pTextNode)
2203 return;
2204
2205 CXFA_Node* pValueNode = pTextNode->GetParent();
2206 if (!pValueNode)
2207 return;
2208
2209 XFA_Element eType = pValueNode->GetElementType();
2210 if (eType == XFA_Element::Value) {
2211 bNeedFindContainer = true;
2212 CXFA_Node* pNode = pValueNode->GetParent();
2213 if (pNode && pNode->IsContainerNode()) {
2214 if (bScriptModify)
2215 pValueNode = pNode;
2216
2217 pNotify->OnValueChanged(this, eAttribute, pValueNode, pNode);
2218 } else {
2219 pNotify->OnValueChanged(this, eAttribute, pNode, pNode->GetParent());
2220 }
2221 } else {
2222 if (eType == XFA_Element::Items) {
2223 CXFA_Node* pNode = pValueNode->GetParent();
2224 if (pNode && pNode->IsContainerNode()) {
2225 pNotify->OnValueChanged(this, eAttribute, pValueNode, pNode);
2226 }
2227 }
2228 }
2229 break;
2230 }
2231 default:
2232 break;
2233 }
2234
2235 if (!bNeedFindContainer)
2236 return;
2237
2238 CXFA_Node* pParent = this;
2239 while (pParent && !pParent->IsContainerNode())
2240 pParent = pParent->GetParent();
2241
2242 if (pParent)
2244}
2245
2246void CXFA_Node::SyncValue(const WideString& wsValue, bool bNotify) {
2247 WideString wsFormatValue = wsValue;
2248 CXFA_Node* pContainerNode = GetContainerNode();
2249 if (pContainerNode)
2250 wsFormatValue = pContainerNode->GetFormatDataValue(wsValue);
2251
2252 JSObject()->SetContent(wsValue, wsFormatValue, bNotify, false, true);
2253}
2254
2255WideString CXFA_Node::GetRawValue() const {
2256 return JSObject()->GetContent(false);
2257}
2258
2259int32_t CXFA_Node::GetRotate() const {
2260 absl::optional<int32_t> degrees =
2261 JSObject()->TryInteger(XFA_Attribute::Rotate, false);
2262 return degrees.has_value() ? XFA_MapRotation(degrees.value()) / 90 * 90 : 0;
2263}
2264
2265CXFA_Border* CXFA_Node::GetBorderIfExists() const {
2266 return JSObject()->GetProperty<CXFA_Border>(0, XFA_Element::Border);
2267}
2268
2270 return JSObject()->GetOrCreateProperty<CXFA_Border>(0, XFA_Element::Border);
2271}
2272
2273CXFA_Caption* CXFA_Node::GetCaptionIfExists() const {
2274 return JSObject()->GetProperty<CXFA_Caption>(0, XFA_Element::Caption);
2275}
2276
2278 return JSObject()->GetOrCreateProperty<CXFA_Font>(0, XFA_Element::Font);
2279}
2280
2281CXFA_Font* CXFA_Node::GetFontIfExists() const {
2282 return JSObject()->GetProperty<CXFA_Font>(0, XFA_Element::Font);
2283}
2284
2285float CXFA_Node::GetFontSize() const {
2286 CXFA_Font* font = GetFontIfExists();
2287 float fFontSize = font ? font->GetFontSize() : 10.0f;
2288 return fFontSize < 0.1f ? 10.0f : fFontSize;
2289}
2290
2291float CXFA_Node::GetLineHeight() const {
2292 float fLineHeight = 0;
2293 CXFA_Para* para = GetParaIfExists();
2294 if (para)
2295 fLineHeight = para->GetLineHeight();
2296
2297 if (fLineHeight < 1)
2298 fLineHeight = GetFontSize() * 1.2f;
2299 return fLineHeight;
2300}
2301
2302FX_ARGB CXFA_Node::GetTextColor() const {
2303 CXFA_Font* font = GetFontIfExists();
2304 return font ? font->GetColor() : 0xFF000000;
2305}
2306
2307CXFA_Margin* CXFA_Node::GetMarginIfExists() const {
2308 return JSObject()->GetProperty<CXFA_Margin>(0, XFA_Element::Margin);
2309}
2310
2311CXFA_Para* CXFA_Node::GetParaIfExists() const {
2312 return JSObject()->GetProperty<CXFA_Para>(0, XFA_Element::Para);
2313}
2314
2316 for (auto* pNode = this; pNode; pNode = pNode->GetContainerParent()) {
2317 XFA_AttributeValue iAcc = pNode->JSObject()->GetEnum(XFA_Attribute::Access);
2318 if (iAcc != XFA_AttributeValue::Open)
2319 return false;
2320 }
2321 return true;
2322}
2323
2324CXFA_Value* CXFA_Node::GetDefaultValueIfExists() {
2326 return pTemNode ? pTemNode->JSObject()->GetProperty<CXFA_Value>(
2327 0, XFA_Element::Value)
2328 : nullptr;
2329}
2330
2331CXFA_Value* CXFA_Node::GetFormValueIfExists() const {
2332 return JSObject()->GetProperty<CXFA_Value>(0, XFA_Element::Value);
2333}
2334
2335CXFA_Calculate* CXFA_Node::GetCalculateIfExists() const {
2336 return JSObject()->GetProperty<CXFA_Calculate>(0, XFA_Element::Calculate);
2337}
2338
2339CXFA_Validate* CXFA_Node::GetValidateIfExists() const {
2340 return JSObject()->GetProperty<CXFA_Validate>(0, XFA_Element::Validate);
2341}
2342
2344 return JSObject()->GetOrCreateProperty<CXFA_Validate>(0,
2345 XFA_Element::Validate);
2346}
2347
2348CXFA_Bind* CXFA_Node::GetBindIfExists() const {
2349 return JSObject()->GetProperty<CXFA_Bind>(0, XFA_Element::Bind);
2350}
2351
2352absl::optional<XFA_AttributeValue> CXFA_Node::GetIntactFromKeep(
2353 const CXFA_Keep* pKeep,
2354 XFA_AttributeValue eLayoutType) const {
2355 absl::optional<XFA_AttributeValue> intact =
2356 pKeep->JSObject()->TryEnum(XFA_Attribute::Intact, false);
2357 if (!intact.has_value())
2358 return absl::nullopt;
2359
2360 if (intact.value() != XFA_AttributeValue::None ||
2361 eLayoutType != XFA_AttributeValue::Row ||
2362 m_pDocument->GetCurVersionMode() >= XFA_VERSION_208) {
2363 return intact;
2364 }
2365
2366 CXFA_Node* pPreviewRow = GetPrevContainerSibling();
2367 if (!pPreviewRow || pPreviewRow->JSObject()->GetEnum(XFA_Attribute::Layout) !=
2368 XFA_AttributeValue::Row) {
2369 return intact;
2370 }
2371
2372 absl::optional<XFA_AttributeValue> value =
2373 pKeep->JSObject()->TryEnum(XFA_Attribute::Previous, false);
2374 if (value == XFA_AttributeValue::ContentArea ||
2375 value == XFA_AttributeValue::PageArea) {
2376 return XFA_AttributeValue::ContentArea;
2377 }
2378
2379 CXFA_Keep* pNode =
2380 pPreviewRow->GetFirstChildByClass<CXFA_Keep>(XFA_Element::Keep);
2381 if (!pNode)
2382 return intact;
2383
2384 absl::optional<XFA_AttributeValue> ret =
2385 pNode->JSObject()->TryEnum(XFA_Attribute::Next, false);
2386 if (ret == XFA_AttributeValue::ContentArea ||
2387 ret == XFA_AttributeValue::PageArea) {
2388 return XFA_AttributeValue::ContentArea;
2389 }
2390 return intact;
2391}
2392
2394 return JSObject()->TryMeasureAsFloat(XFA_Attribute::W);
2395}
2396
2397absl::optional<float> CXFA_Node::TryHeight() {
2398 return JSObject()->TryMeasureAsFloat(XFA_Attribute::H);
2399}
2400
2401absl::optional<float> CXFA_Node::TryMinWidth() {
2402 return JSObject()->TryMeasureAsFloat(XFA_Attribute::MinW);
2403}
2404
2405absl::optional<float> CXFA_Node::TryMinHeight() {
2406 return JSObject()->TryMeasureAsFloat(XFA_Attribute::MinH);
2407}
2408
2409absl::optional<float> CXFA_Node::TryMaxWidth() {
2410 return JSObject()->TryMeasureAsFloat(XFA_Attribute::MaxW);
2411}
2412
2413absl::optional<float> CXFA_Node::TryMaxHeight() {
2414 return JSObject()->TryMeasureAsFloat(XFA_Attribute::MaxH);
2415}
2416
2418 CXFA_Node* pExcl = GetParent();
2419 if (!pExcl || pExcl->GetElementType() != XFA_Element::ExclGroup)
2420 return nullptr;
2421 return pExcl;
2422}
2423
2425 XFA_AttributeValue iActivity,
2426 CXFA_EventParam* pEventParam) {
2427 if (GetElementType() == XFA_Element::Draw)
2429
2430 std::vector<CXFA_Event*> eventArray =
2431 GetEventByActivity(iActivity, pEventParam->m_bIsFormReady);
2432 bool first = true;
2434 for (CXFA_Event* event : eventArray) {
2435 XFA_EventError result =
2436 ProcessEventInternal(pDocView, iActivity, event, pEventParam);
2437 if (first || result == XFA_EventError::kSuccess)
2438 iRet = result;
2439 first = false;
2440 }
2441 return iRet;
2442}
2443
2444XFA_EventError CXFA_Node::ProcessEventInternal(CXFA_FFDocView* pDocView,
2445 XFA_AttributeValue iActivity,
2446 CXFA_Event* event,
2447 CXFA_EventParam* pEventParam) {
2448 if (!event)
2450
2451 switch (event->GetEventType()) {
2452 case XFA_Element::Execute:
2453 break;
2454 case XFA_Element::Script:
2455 if (iActivity == XFA_AttributeValue::DocClose) {
2456 // Too late, scripting engine already gone.
2458 }
2459 return ExecuteScript(pDocView, event->GetScriptIfExists(), pEventParam);
2460 case XFA_Element::SignData:
2461 break;
2462 case XFA_Element::Submit: {
2463// TODO(crbug.com/867485): Submit is disabled for now. Fix it and reenable this
2464// code.
2465#ifdef PDF_XFA_ELEMENT_SUBMIT_ENABLED
2466 CXFA_Submit* submit = event->GetSubmitIfExists();
2467 if (!submit)
2468 return XFA_EventError::kNotExist;
2469 return pDocView->GetDoc()->GetDocEnvironment()->Submit(pDocView->GetDoc(),
2470 submit);
2471#else
2473#endif // PDF_XFA_ELEMENT_SUBMIT_ENABLED
2474 }
2475 default:
2476 break;
2477 }
2479}
2480
2482 if (GetElementType() == XFA_Element::Draw)
2484
2485 CXFA_Calculate* calc = GetCalculateIfExists();
2486 if (!calc)
2490
2492 EventParam.m_bTargeted = false;
2493 XFA_EventError iRet =
2494 ExecuteScript(pDocView, calc->GetScriptIfExists(), &EventParam);
2495 if (iRet != XFA_EventError::kSuccess)
2496 return iRet;
2497
2498 if (GetRawValue() != EventParam.m_wsResult) {
2499 SetValue(XFA_ValuePicture::kRaw, EventParam.m_wsResult);
2500 pDocView->UpdateUIDisplay(this, nullptr);
2501 }
2503}
2504
2505void CXFA_Node::ProcessScriptTestValidate(CXFA_FFDocView* pDocView,
2506 CXFA_Validate* validate,
2507 bool bVersionFlag) {
2508 CXFA_FFApp::CallbackIface* pAppProvider =
2510 if (!pAppProvider)
2511 return;
2512
2513 WideString wsTitle = pAppProvider->GetAppTitle();
2514 WideString wsScriptMsg = validate->GetScriptMessageText();
2515 if (validate->GetScriptTest() == XFA_AttributeValue::Warning) {
2517 return;
2518 if (wsScriptMsg.IsEmpty())
2519 wsScriptMsg = GetValidateMessage(false, bVersionFlag);
2520
2521 if (bVersionFlag) {
2522 pAppProvider->MsgBox(wsScriptMsg, wsTitle,
2523 static_cast<uint32_t>(AlertIcon::kWarning),
2524 static_cast<uint32_t>(AlertButton::kOK));
2525 return;
2526 }
2527 if (pAppProvider->MsgBox(wsScriptMsg, wsTitle,
2528 static_cast<uint32_t>(AlertIcon::kWarning),
2529 static_cast<uint32_t>(AlertButton::kYesNo)) ==
2530 static_cast<uint32_t>(AlertReturn::kYes)) {
2532 }
2533 return;
2534 }
2535
2536 if (wsScriptMsg.IsEmpty())
2537 wsScriptMsg = GetValidateMessage(true, bVersionFlag);
2538 pAppProvider->MsgBox(wsScriptMsg, wsTitle,
2539 static_cast<uint32_t>(AlertIcon::kError),
2540 static_cast<uint32_t>(AlertButton::kOK));
2541}
2542
2543XFA_EventError CXFA_Node::ProcessFormatTestValidate(CXFA_FFDocView* pDocView,
2544 CXFA_Validate* validate,
2545 bool bVersionFlag) {
2546 WideString wsPicture = validate->GetPicture();
2547 if (wsPicture.IsEmpty())
2549
2550 WideString wsRawValue = GetRawValue();
2551 if (wsRawValue.IsEmpty())
2553
2554 GCedLocaleIface* pLocale = GetLocale();
2555 if (!pLocale)
2557
2559 if (lcValue.ValidateValue(lcValue.GetValue(), wsPicture, pLocale, nullptr))
2561
2562 CXFA_FFApp::CallbackIface* pAppProvider =
2564 if (!pAppProvider)
2566
2567 WideString wsFormatMsg = validate->GetFormatMessageText();
2568 WideString wsTitle = pAppProvider->GetAppTitle();
2569 if (validate->GetFormatTest() == XFA_AttributeValue::Error) {
2570 if (wsFormatMsg.IsEmpty())
2571 wsFormatMsg = GetValidateMessage(true, bVersionFlag);
2572 pAppProvider->MsgBox(wsFormatMsg, wsTitle,
2573 static_cast<uint32_t>(AlertIcon::kError),
2574 static_cast<uint32_t>(AlertButton::kOK));
2576 }
2577
2578 if (wsFormatMsg.IsEmpty())
2579 wsFormatMsg = GetValidateMessage(false, bVersionFlag);
2580
2581 if (bVersionFlag) {
2582 pAppProvider->MsgBox(wsFormatMsg, wsTitle,
2583 static_cast<uint32_t>(AlertIcon::kWarning),
2584 static_cast<uint32_t>(AlertButton::kOK));
2586 }
2587
2588 if (pAppProvider->MsgBox(wsFormatMsg, wsTitle,
2589 static_cast<uint32_t>(AlertIcon::kWarning),
2590 static_cast<uint32_t>(AlertButton::kYesNo)) ==
2591 static_cast<uint32_t>(AlertReturn::kYes)) {
2593 }
2594
2596}
2597
2598XFA_EventError CXFA_Node::ProcessNullTestValidate(CXFA_FFDocView* pDocView,
2599 CXFA_Validate* validate,
2600 int32_t iFlags,
2601 bool bVersionFlag) {
2604 if (m_bIsNull && m_bPreNull)
2606
2607 XFA_AttributeValue eNullTest = validate->GetNullTest();
2608 WideString wsNullMsg = validate->GetNullMessageText();
2609 if (iFlags & 0x01) {
2610 if (eNullTest == XFA_AttributeValue::Disabled)
2612
2613 if (!wsNullMsg.IsEmpty())
2614 pDocView->AddNullTestMsg(wsNullMsg);
2616 }
2617 if (wsNullMsg.IsEmpty() && bVersionFlag &&
2618 eNullTest != XFA_AttributeValue::Disabled) {
2620 }
2621 CXFA_FFApp::CallbackIface* pAppProvider =
2623 if (!pAppProvider)
2625
2626 WideString wsCaptionName;
2627 WideString wsTitle = pAppProvider->GetAppTitle();
2628 switch (eNullTest) {
2629 case XFA_AttributeValue::Error: {
2630 if (wsNullMsg.IsEmpty()) {
2631 wsCaptionName = GetValidateCaptionName(bVersionFlag);
2632 wsNullMsg = wsCaptionName + L" cannot be blank.";
2633 }
2634 pAppProvider->MsgBox(wsNullMsg, wsTitle,
2635 static_cast<uint32_t>(AlertIcon::kStatus),
2636 static_cast<uint32_t>(AlertButton::kOK));
2638 }
2639 case XFA_AttributeValue::Warning: {
2642
2643 if (wsNullMsg.IsEmpty()) {
2644 wsCaptionName = GetValidateCaptionName(bVersionFlag);
2645 wsNullMsg = wsCaptionName +
2646 L" cannot be blank. To ignore validations for " +
2647 wsCaptionName + L", click Ignore.";
2648 }
2649 if (pAppProvider->MsgBox(wsNullMsg, wsTitle,
2650 static_cast<uint32_t>(AlertIcon::kWarning),
2651 static_cast<uint32_t>(AlertButton::kYesNo)) ==
2652 static_cast<uint32_t>(AlertReturn::kYes)) {
2654 }
2656 }
2657 case XFA_AttributeValue::Disabled:
2658 default:
2659 break;
2660 }
2662}
2663
2665 int32_t iFlags) {
2666 if (GetElementType() == XFA_Element::Draw)
2668
2669 CXFA_Validate* validate = GetValidateIfExists();
2670 if (!validate)
2672
2673 const bool bInitDoc = validate->NeedsInitApp();
2674 const bool bStatus =
2676
2678 CXFA_Script* script = validate->GetScriptIfExists();
2679 bool hasBoolResult = (bInitDoc || bStatus) && GetRawValue().IsEmpty();
2681 if (script) {
2683 result = ExecuteBoolScript(pDocView, script, &eParam);
2684 }
2685
2687 bool bVersionFlag = version < XFA_VERSION_208;
2688
2689 if (bInitDoc) {
2691 } else {
2692 iFormat = ProcessFormatTestValidate(pDocView, validate, bVersionFlag);
2693 if (!bVersionFlag)
2694 bVersionFlag = pDocView->GetDoc()->GetXFADoc()->is_scripting();
2696 &result.xfa_event_result,
2697 ProcessNullTestValidate(pDocView, validate, iFlags, bVersionFlag));
2698 }
2700 iFormat != XFA_EventError::kSuccess && hasBoolResult &&
2701 !result.script_result) {
2702 ProcessScriptTestValidate(pDocView, validate, bVersionFlag);
2703 }
2705 return result.xfa_event_result;
2706}
2707
2708WideString CXFA_Node::GetValidateCaptionName(bool bVersionFlag) {
2709 WideString wsCaptionName;
2710
2711 if (!bVersionFlag) {
2712 CXFA_Caption* caption = GetCaptionIfExists();
2713 if (caption) {
2714 CXFA_Value* capValue = caption->GetValueIfExists();
2715 if (capValue) {
2716 CXFA_Text* captionText = capValue->GetTextIfExists();
2717 if (captionText)
2718 wsCaptionName = captionText->GetContent();
2719 }
2720 }
2721 }
2722 if (!wsCaptionName.IsEmpty())
2723 return wsCaptionName;
2724 return JSObject()->GetCData(XFA_Attribute::Name);
2725}
2726
2727WideString CXFA_Node::GetValidateMessage(bool bError, bool bVersionFlag) {
2728 WideString wsCaptionName = GetValidateCaptionName(bVersionFlag);
2729 if (bVersionFlag)
2730 return wsCaptionName + L" validation failed";
2731 WideString result =
2732 L"The value you entered for " + wsCaptionName + L" is invalid.";
2733 if (!bError) {
2734 result +=
2735 L" To ignore validations for " + wsCaptionName + L", click Ignore.";
2736 }
2737 return result;
2738}
2739
2741 CXFA_Script* script,
2742 CXFA_EventParam* pEventParam) {
2743 return ExecuteBoolScript(pDocView, script, pEventParam).xfa_event_result;
2744}
2745
2747 CXFA_FFDocView* pDocView,
2748 CXFA_Script* script,
2749 CXFA_EventParam* pEventParam) {
2750 if (m_ExecuteRecursionDepth > kMaxExecuteRecursion)
2751 return {XFA_EventError::kSuccess, false};
2752
2753 DCHECK(pEventParam);
2754 if (!script)
2755 return {XFA_EventError::kNotExist, false};
2756 if (script->GetRunAt() == XFA_AttributeValue::Server)
2757 return {XFA_EventError::kDisabled, false};
2758
2759 WideString wsExpression = script->GetExpression();
2760 if (wsExpression.IsEmpty())
2761 return {XFA_EventError::kNotExist, false};
2762
2763 CXFA_Script::Type eScriptType = script->GetContentType();
2764 if (eScriptType == CXFA_Script::Type::Unknown)
2765 return {XFA_EventError::kSuccess, false};
2766
2767 CXFA_FFDoc* pDoc = pDocView->GetDoc();
2770 pContext, pEventParam->m_bTargeted ? this : nullptr, pEventParam);
2771 pContext->SetRunAtType(script->GetRunAt());
2772
2773 std::vector<cppgc::Persistent<CXFA_Node>> refNodes;
2774 if (pEventParam->m_eType == XFA_EVENT_InitCalculate ||
2775 pEventParam->m_eType == XFA_EVENT_Calculate) {
2776 pContext->SetNodesOfRunScript(&refNodes);
2777 }
2778
2779 CFXJSE_Context::ExecutionResult exec_result;
2780 {
2781 AutoRestorer<uint8_t> restorer(&m_ExecuteRecursionDepth);
2782 ++m_ExecuteRecursionDepth;
2783 exec_result =
2784 pContext->RunScript(eScriptType, wsExpression.AsStringView(), this);
2785 }
2786
2788 if (exec_result.status) {
2790 if (pEventParam->m_eType == XFA_EVENT_Calculate ||
2791 pEventParam->m_eType == XFA_EVENT_InitCalculate) {
2792 if (!exec_result.value->IsUndefined(pContext->GetIsolate())) {
2793 if (!exec_result.value->IsNull(pContext->GetIsolate())) {
2794 pEventParam->m_wsResult =
2795 exec_result.value->ToWideString(pContext->GetIsolate());
2796 }
2797
2799 } else {
2801 }
2802 if (pEventParam->m_eType == XFA_EVENT_InitCalculate) {
2803 if ((iRet == XFA_EventError::kSuccess) &&
2804 (GetRawValue() != pEventParam->m_wsResult)) {
2805 SetValue(XFA_ValuePicture::kRaw, pEventParam->m_wsResult);
2806 pDocView->AddValidateNode(this);
2807 }
2808 }
2809 for (CXFA_Node* pRefNode : refNodes) {
2810 if (pRefNode == this)
2811 continue;
2812
2813 CJX_Object::CalcData* pGlobalData =
2814 pRefNode->JSObject()->GetOrCreateCalcData(pDoc->GetHeap());
2815 if (!pdfium::Contains(pGlobalData->m_Globals, this))
2816 pGlobalData->m_Globals.push_back(this);
2817 }
2818 }
2819 }
2820 pContext->SetNodesOfRunScript(nullptr);
2821
2822 return {iRet, exec_result.value->IsBoolean(pContext->GetIsolate()) &&
2823 exec_result.value->ToBoolean(pContext->GetIsolate())};
2824}
2825
2826std::pair<XFA_FFWidgetType, CXFA_Ui*>
2827CXFA_Node::CreateChildUIAndValueNodesIfNeeded() {
2828 XFA_Element eType = GetElementType();
2829 DCHECK(eType == XFA_Element::Field || eType == XFA_Element::Draw);
2830
2831 // Both Field and Draw have a UI property. We should always be able to
2832 // retrieve or create the UI element. If we can't something is wrong.
2833 CXFA_Ui* pUI = JSObject()->GetOrCreateProperty<CXFA_Ui>(0, XFA_Element::Ui);
2834 DCHECK(pUI);
2835
2836 CXFA_Node* pUIChild = nullptr;
2837 // Search through the children of the UI node to see if we have any of our
2838 // One-Of entries. If so, that is the node associated with our UI.
2839 for (CXFA_Node* pChild = pUI->GetFirstChild(); pChild;
2840 pChild = pChild->GetNextSibling()) {
2841 if (pUI->IsAOneOfChild(pChild)) {
2842 pUIChild = pChild;
2843 break;
2844 }
2845 }
2846
2848 XFA_Element expected_ui_child_type = XFA_Element::Unknown;
2849
2850 // Both Field and Draw nodes have a Value child. So, we should either always
2851 // have it, or always create it. If we don't get the Value child for some
2852 // reason something has gone really wrong.
2853 CXFA_Value* value =
2854 JSObject()->GetOrCreateProperty<CXFA_Value>(0, XFA_Element::Value);
2855 DCHECK(value);
2856
2857 // The Value nodes only have One-Of children. So, if we have a first child
2858 // that child must be the type we want to use.
2859 CXFA_Node* child = value->GetFirstChild();
2860 if (child) {
2861 switch (child->GetElementType()) {
2862 case XFA_Element::Boolean:
2863 expected_ui_child_type = XFA_Element::CheckButton;
2864 break;
2865 case XFA_Element::Integer:
2866 case XFA_Element::Decimal:
2867 case XFA_Element::Float:
2868 expected_ui_child_type = XFA_Element::NumericEdit;
2869 break;
2870 case XFA_Element::ExData:
2871 case XFA_Element::Text:
2872 expected_ui_child_type = XFA_Element::TextEdit;
2873 widget_type = XFA_FFWidgetType::kText;
2874 break;
2875 case XFA_Element::Date:
2876 case XFA_Element::Time:
2877 case XFA_Element::DateTime:
2878 expected_ui_child_type = XFA_Element::DateTimeEdit;
2879 break;
2880 case XFA_Element::Image:
2881 expected_ui_child_type = XFA_Element::ImageEdit;
2882 widget_type = XFA_FFWidgetType::kImage;
2883 break;
2884 case XFA_Element::Arc:
2885 expected_ui_child_type = XFA_Element::DefaultUi;
2886 widget_type = XFA_FFWidgetType::kArc;
2887 break;
2888 case XFA_Element::Line:
2889 expected_ui_child_type = XFA_Element::DefaultUi;
2890 widget_type = XFA_FFWidgetType::kLine;
2891 break;
2892 case XFA_Element::Rectangle:
2893 expected_ui_child_type = XFA_Element::DefaultUi;
2894 widget_type = XFA_FFWidgetType::kRectangle;
2895 break;
2896 default:
2897 break;
2898 }
2899 }
2900
2901 if (eType == XFA_Element::Draw) {
2902 if (pUIChild && pUIChild->GetElementType() == XFA_Element::TextEdit) {
2903 widget_type = XFA_FFWidgetType::kText;
2904 } else if (pUIChild &&
2905 pUIChild->GetElementType() == XFA_Element::ImageEdit) {
2906 widget_type = XFA_FFWidgetType::kImage;
2907 } else if (widget_type == XFA_FFWidgetType::kNone) {
2908 widget_type = XFA_FFWidgetType::kText;
2909 }
2910 } else if (eType == XFA_Element::Field) {
2911 if (pUIChild && pUIChild->GetElementType() == XFA_Element::DefaultUi) {
2912 widget_type = XFA_FFWidgetType::kTextEdit;
2913 } else if (pUIChild) {
2914 widget_type = pUIChild->GetDefaultFFWidgetType();
2915 } else if (expected_ui_child_type == XFA_Element::Unknown) {
2916 widget_type = XFA_FFWidgetType::kTextEdit;
2917 }
2918 } else {
2919 NOTREACHED_NORETURN();
2920 }
2921
2922 if (!pUIChild) {
2923 if (expected_ui_child_type == XFA_Element::Unknown)
2924 expected_ui_child_type = XFA_Element::TextEdit;
2925 pUIChild = pUI->JSObject()->GetOrCreateProperty<CXFA_Node>(
2926 0, expected_ui_child_type);
2927 }
2928
2929 CreateValueNodeIfNeeded(value, pUIChild);
2930 return {widget_type, pUI};
2931}
2932
2934 NOTREACHED_NORETURN();
2935}
2936
2937CXFA_Node* CXFA_Node::CreateUINodeIfNeeded(CXFA_Ui* ui, XFA_Element type) {
2938 return ui->JSObject()->GetOrCreateProperty<CXFA_Node>(0, type);
2939}
2940
2941void CXFA_Node::CreateValueNodeIfNeeded(CXFA_Value* value,
2942 CXFA_Node* pUIChild) {
2943 // Value nodes only have one child. If we have one already we're done.
2944 if (value->GetFirstChild())
2945 return;
2946
2947 // Create the Value node for our UI if needed.
2948 XFA_Element valueType = pUIChild->GetValueNodeType();
2949 if (pUIChild->GetElementType() == XFA_Element::CheckButton) {
2950 CXFA_Items* pItems = GetChild<CXFA_Items>(0, XFA_Element::Items, false);
2951 if (pItems) {
2952 CXFA_Node* pItem =
2953 pItems->GetChild<CXFA_Node>(0, XFA_Element::Unknown, false);
2954 if (pItem)
2955 valueType = pItem->GetElementType();
2956 }
2957 }
2958 value->JSObject()->GetOrCreateProperty<CXFA_Node>(0, valueType);
2959}
2960
2962 return XFA_Element::Text;
2963}
2964
2966 DCHECK(HasCreatedUIWidget());
2967
2968 if (ff_widget_type_ != XFA_FFWidgetType::kNone)
2969 return ui_ ? ui_->GetFirstChild() : nullptr;
2970
2971 XFA_Element type = GetElementType();
2972 if (type == XFA_Element::Field || type == XFA_Element::Draw) {
2973 std::tie(ff_widget_type_, ui_) = CreateChildUIAndValueNodesIfNeeded();
2974 } else if (type == XFA_Element::Subform) {
2975 ff_widget_type_ = XFA_FFWidgetType::kSubform;
2976 } else if (type == XFA_Element::ExclGroup) {
2977 ff_widget_type_ = XFA_FFWidgetType::kExclGroup;
2978 } else {
2979 NOTREACHED_NORETURN();
2980 }
2981 return ui_ ? ui_->GetFirstChild() : nullptr;
2982}
2983
2986 return ff_widget_type_;
2987}
2988
2989CXFA_Border* CXFA_Node::GetUIBorder() {
2990 CXFA_Node* pUIChild = GetUIChildNode();
2991 return pUIChild ? pUIChild->JSObject()->GetProperty<CXFA_Border>(
2992 0, XFA_Element::Border)
2993 : nullptr;
2994}
2995
2997 CXFA_Node* pUIChild = GetUIChildNode();
2998 if (!pUIChild)
2999 return CFX_RectF();
3000
3001 CXFA_Margin* mgUI =
3002 pUIChild->JSObject()->GetProperty<CXFA_Margin>(0, XFA_Element::Margin);
3003 if (!mgUI)
3004 return CFX_RectF();
3005
3006 CXFA_Border* border = GetUIBorder();
3007 if (border && border->GetPresence() != XFA_AttributeValue::Visible)
3008 return CFX_RectF();
3009
3010 absl::optional<float> left = mgUI->TryLeftInset();
3011 absl::optional<float> top = mgUI->TryTopInset();
3012 absl::optional<float> right = mgUI->TryRightInset();
3013 absl::optional<float> bottom = mgUI->TryBottomInset();
3014 if (border) {
3015 bool bVisible = false;
3016 float fThickness = 0;
3017 XFA_AttributeValue iType = XFA_AttributeValue::Unknown;
3018 std::tie(iType, bVisible, fThickness) = border->Get3DStyle();
3019 if (!left.has_value() || !top.has_value() || !right.has_value() ||
3020 !bottom.has_value()) {
3021 std::vector<CXFA_Stroke*> strokes = border->GetStrokes();
3022 if (!top.has_value())
3023 top = GetEdgeThickness(strokes, bVisible, 0);
3024 if (!right.has_value())
3025 right = GetEdgeThickness(strokes, bVisible, 1);
3026 if (!bottom.has_value())
3027 bottom = GetEdgeThickness(strokes, bVisible, 2);
3028 if (!left.has_value())
3029 left = GetEdgeThickness(strokes, bVisible, 3);
3030 }
3031 }
3032 return CFX_RectF(left.value_or(0.0), top.value_or(0.0), right.value_or(0.0),
3033 bottom.value_or(0.0));
3034}
3035
3037 XFA_AttributeValue iActivity,
3038 bool bIsFormReady) {
3039 std::vector<CXFA_Event*> events;
3040 for (CXFA_Node* node : GetNodeListForType(XFA_Element::Event)) {
3041 auto* event = static_cast<CXFA_Event*>(node);
3042 if (event->GetActivity() != iActivity)
3043 continue;
3044
3045 if (iActivity != XFA_AttributeValue::Ready) {
3046 events.push_back(event);
3047 continue;
3048 }
3049
3050 WideString wsRef = event->GetRef();
3051 if (bIsFormReady) {
3052 if (wsRef == WideStringView(L"$form"))
3053 events.push_back(event);
3054 continue;
3055 }
3056
3057 if (wsRef == WideStringView(L"$layout"))
3058 events.push_back(event);
3059 }
3060 return events;
3061}
3062
3064 WideString wsValue;
3065 switch (GetFFWidgetType()) {
3067 CXFA_Value* imageValue = GetDefaultValueIfExists();
3068 CXFA_Image* image = imageValue ? imageValue->GetImageIfExists() : nullptr;
3069 WideString wsContentType, wsHref;
3070 if (image) {
3071 wsValue = image->GetContent();
3072 wsContentType = image->GetContentType();
3073 wsHref = image->GetHref();
3074 }
3075 SetImageEdit(wsContentType, wsHref, wsValue);
3076 break;
3077 }
3079 CXFA_Node* pNextChild = GetFirstContainerChild();
3080 while (pNextChild) {
3081 CXFA_Node* pChild = pNextChild;
3082 if (!pChild->IsWidgetReady())
3083 continue;
3084
3085 bool done = false;
3086 if (wsValue.IsEmpty()) {
3087 CXFA_Value* defValue = pChild->GetDefaultValueIfExists();
3088 if (defValue) {
3089 wsValue = defValue->GetChildValueContent();
3092 done = true;
3093 }
3094 }
3095 if (!done) {
3096 CXFA_Items* pItems =
3097 pChild->GetChild<CXFA_Items>(0, XFA_Element::Items, false);
3098 if (!pItems)
3099 continue;
3100
3101 WideString itemText;
3102 if (pItems->CountChildren(XFA_Element::Unknown, false) > 1) {
3103 itemText =
3104 pItems->GetChild<CXFA_Node>(1, XFA_Element::Unknown, false)
3105 ->JSObject()
3106 ->GetContent(false);
3107 }
3109 }
3110 pNextChild = pChild->GetNextContainerSibling();
3111 }
3112 break;
3113 }
3116 [[fallthrough]];
3117 default: {
3118 CXFA_Value* defValue = GetDefaultValueIfExists();
3119 if (defValue)
3120 wsValue = defValue->GetChildValueContent();
3121
3123 break;
3124 }
3125 }
3126}
3127
3128void CXFA_Node::SetImageEdit(const WideString& wsContentType,
3129 const WideString& wsHref,
3130 const WideString& wsData) {
3131 CXFA_Value* formValue = GetFormValueIfExists();
3132 CXFA_Image* image = formValue ? formValue->GetImageIfExists() : nullptr;
3133 if (image) {
3134 image->SetContentType(WideString(wsContentType));
3135 image->SetHref(wsHref);
3136 }
3137
3138 JSObject()->SetContent(wsData, GetFormatDataValue(wsData), true, false, true);
3139
3140 CXFA_Node* pBind = GetBindData();
3141 if (!pBind) {
3142 if (image)
3144 return;
3145 }
3146 pBind->JSObject()->SetCData(XFA_Attribute::ContentType, wsContentType);
3147 CXFA_Node* pHrefNode = pBind->GetFirstChild();
3148 if (pHrefNode) {
3149 pHrefNode->JSObject()->SetCData(XFA_Attribute::Value, wsHref);
3150 return;
3151 }
3152 CFX_XMLElement* pElement = ToXMLElement(pBind->GetXMLMappingNode());
3153 pElement->SetAttribute(L"href", wsHref);
3154}
3155
3156void CXFA_Node::CalcCaptionSize(CXFA_FFDoc* doc, CFX_SizeF* pszCap) {
3157 CXFA_Caption* caption = GetCaptionIfExists();
3158 if (!caption || !caption->IsVisible())
3159 return;
3160
3161 LoadCaption(doc);
3162
3163 const float fCapReserve = caption->GetReserve();
3164 const XFA_AttributeValue iCapPlacement = caption->GetPlacementType();
3165 const bool bReserveExit = fCapReserve > 0.01;
3166 const bool bVert = iCapPlacement == XFA_AttributeValue::Top ||
3167 iCapPlacement == XFA_AttributeValue::Bottom;
3168 CXFA_TextLayout* pCapTextLayout =
3169 m_pLayoutData->AsFieldLayoutData()->m_pCapTextLayout;
3170 if (pCapTextLayout) {
3172 pszCap->width = fCapReserve;
3173
3174 CFX_SizeF minSize;
3175 *pszCap = pCapTextLayout->CalcSize(minSize, *pszCap);
3176 if (bReserveExit)
3177 bVert ? pszCap->height = fCapReserve : pszCap->width = fCapReserve;
3178 } else {
3179 float fFontSize = 10.0f;
3180 CXFA_Font* font = caption->GetFontIfExists();
3181 if (font) {
3182 fFontSize = font->GetFontSize();
3183 } else {
3184 CXFA_Font* widgetfont = GetFontIfExists();
3185 if (widgetfont)
3186 fFontSize = widgetfont->GetFontSize();
3187 }
3188
3189 if (bVert) {
3190 pszCap->height = fCapReserve > 0 ? fCapReserve : fFontSize;
3191 } else {
3192 pszCap->width = fCapReserve > 0 ? fCapReserve : 0;
3193 pszCap->height = fFontSize;
3194 }
3195 }
3196
3197 CXFA_Margin* captionMargin = caption->GetMarginIfExists();
3198 if (!captionMargin)
3199 return;
3200
3201 float fLeftInset = captionMargin->GetLeftInset();
3202 float fTopInset = captionMargin->GetTopInset();
3203 float fRightInset = captionMargin->GetRightInset();
3204 float fBottomInset = captionMargin->GetBottomInset();
3205 if (bReserveExit) {
3206 bVert ? (pszCap->width += fLeftInset + fRightInset)
3207 : (pszCap->height += fTopInset + fBottomInset);
3208 } else {
3209 pszCap->width += fLeftInset + fRightInset;
3210 pszCap->height += fTopInset + fBottomInset;
3211 }
3212}
3213
3214bool CXFA_Node::CalculateFieldAutoSize(CXFA_FFDoc* doc, CFX_SizeF* pSize) {
3215 CFX_SizeF szCap;
3216 CalcCaptionSize(doc, &szCap);
3217
3218 CFX_RectF rtUIMargin = GetUIMargin();
3219 pSize->width += rtUIMargin.left + rtUIMargin.width;
3220 pSize->height += rtUIMargin.top + rtUIMargin.height;
3221 if (szCap.width > 0 && szCap.height > 0) {
3222 CXFA_Caption* caption = GetCaptionIfExists();
3223 XFA_AttributeValue placement = caption
3224 ? caption->GetPlacementType()
3225 : CXFA_Caption::kDefaultPlacementType;
3226 switch (placement) {
3227 case XFA_AttributeValue::Left:
3228 case XFA_AttributeValue::Right:
3229 case XFA_AttributeValue::Inline: {
3230 pSize->width += szCap.width;
3231 pSize->height = std::max(pSize->height, szCap.height);
3232 } break;
3233 case XFA_AttributeValue::Top:
3234 case XFA_AttributeValue::Bottom: {
3235 pSize->height += szCap.height;
3236 pSize->width = std::max(pSize->width, szCap.width);
3237 break;
3238 }
3239 default:
3240 break;
3241 }
3242 }
3243 return CalculateWidgetAutoSize(pSize);
3244}
3245
3246bool CXFA_Node::CalculateWidgetAutoSize(CFX_SizeF* pSize) {
3247 CXFA_Margin* margin = GetMarginIfExists();
3248 if (margin) {
3249 pSize->width += margin->GetLeftInset() + margin->GetRightInset();
3250 pSize->height += margin->GetTopInset() + margin->GetBottomInset();
3251 }
3252
3253 CXFA_Para* para = GetParaIfExists();
3254 if (para)
3255 pSize->width += para->GetMarginLeft() + para->GetTextIndent();
3256
3257 absl::optional<float> width = TryWidth();
3258 if (width.has_value()) {
3259 pSize->width = width.value();
3260 } else {
3261 absl::optional<float> min = TryMinWidth();
3262 if (min.has_value())
3263 pSize->width = std::max(pSize->width, min.value());
3264
3265 absl::optional<float> max = TryMaxWidth();
3266 if (max.has_value() && max.value() > 0)
3267 pSize->width = std::min(pSize->width, max.value());
3268 }
3269
3270 absl::optional<float> height = TryHeight();
3271 if (height.has_value()) {
3272 pSize->height = height.value();
3273 } else {
3274 absl::optional<float> min = TryMinHeight();
3275 if (min.has_value())
3276 pSize->height = std::max(pSize->height, min.value());
3277
3278 absl::optional<float> max = TryMaxHeight();
3279 if (max.has_value() && max.value() > 0)
3280 pSize->height = std::min(pSize->height, max.value());
3281 }
3282 return true;
3283}
3284
3285void CXFA_Node::CalculateTextContentSize(CXFA_FFDoc* doc, CFX_SizeF* pSize) {
3286 float fFontSize = GetFontSize();
3287 WideString wsText = GetValue(XFA_ValuePicture::kDisplay);
3288 if (wsText.IsEmpty()) {
3289 pSize->height += fFontSize;
3290 return;
3291 }
3292
3293 if (wsText.Back() == L'\n')
3294 wsText += L'\n';
3295
3296 CXFA_FieldLayoutData* layoutData = m_pLayoutData->AsFieldLayoutData();
3297 if (!layoutData->m_pTextOut) {
3298 layoutData->m_pTextOut = std::make_unique<CFDE_TextOut>();
3299 CFDE_TextOut* pTextOut = layoutData->m_pTextOut.get();
3300 pTextOut->SetFont(GetFGASFont(doc));
3301 pTextOut->SetFontSize(fFontSize);
3302 pTextOut->SetLineBreakTolerance(fFontSize * 0.2f);
3304
3305 FDE_TextStyle dwStyles;
3306 dwStyles.last_line_height_ = true;
3308 dwStyles.line_wrap_ = true;
3309
3310 pTextOut->SetStyles(dwStyles);
3311 }
3312 layoutData->m_pTextOut->CalcLogicSize(wsText.AsStringView(), pSize);
3313}
3314
3315bool CXFA_Node::CalculateTextEditAutoSize(CXFA_FFDoc* doc, CFX_SizeF* pSize) {
3316 if (pSize->width > 0) {
3317 CFX_SizeF szOrz = *pSize;
3318 CFX_SizeF szCap;
3319 CalcCaptionSize(doc, &szCap);
3320 bool bCapExit = szCap.width > 0.01 && szCap.height > 0.01;
3321 XFA_AttributeValue iCapPlacement = XFA_AttributeValue::Unknown;
3322 if (bCapExit) {
3323 CXFA_Caption* caption = GetCaptionIfExists();
3324 iCapPlacement = caption ? caption->GetPlacementType()
3325 : CXFA_Caption::kDefaultPlacementType;
3326 switch (iCapPlacement) {
3327 case XFA_AttributeValue::Left:
3328 case XFA_AttributeValue::Right:
3329 case XFA_AttributeValue::Inline: {
3330 pSize->width -= szCap.width;
3331 break;
3332 }
3333 default:
3334 break;
3335 }
3336 }
3337 CFX_RectF rtUIMargin = GetUIMargin();
3338 pSize->width -= rtUIMargin.left + rtUIMargin.width;
3339 CXFA_Margin* margin = GetMarginIfExists();
3340 if (margin)
3341 pSize->width -= margin->GetLeftInset() + margin->GetRightInset();
3342
3343 CalculateTextContentSize(doc, pSize);
3344 pSize->height += rtUIMargin.top + rtUIMargin.height;
3345 if (bCapExit) {
3346 switch (iCapPlacement) {
3347 case XFA_AttributeValue::Left:
3348 case XFA_AttributeValue::Right:
3349 case XFA_AttributeValue::Inline: {
3350 pSize->height = std::max(pSize->height, szCap.height);
3351 } break;
3352 case XFA_AttributeValue::Top:
3353 case XFA_AttributeValue::Bottom: {
3354 pSize->height += szCap.height;
3355 break;
3356 }
3357 default:
3358 break;
3359 }
3360 }
3361 pSize->width = szOrz.width;
3362 return CalculateWidgetAutoSize(pSize);
3363 }
3364 CalculateTextContentSize(doc, pSize);
3365 return CalculateFieldAutoSize(doc, pSize);
3366}
3367
3368bool CXFA_Node::CalculateCheckButtonAutoSize(CXFA_FFDoc* doc,
3369 CFX_SizeF* pSize) {
3370 float fCheckSize = GetCheckButtonSize();
3371 *pSize = CFX_SizeF(fCheckSize, fCheckSize);
3372 return CalculateFieldAutoSize(doc, pSize);
3373}
3374
3375bool CXFA_Node::CalculatePushButtonAutoSize(CXFA_FFDoc* doc, CFX_SizeF* pSize) {
3376 CalcCaptionSize(doc, pSize);
3377 return CalculateWidgetAutoSize(pSize);
3378}
3379
3380CFX_SizeF CXFA_Node::CalculateImageSize(float img_width,
3381 float img_height,
3382 const CFX_Size& dpi) {
3383 CFX_RectF rtImage(0, 0, XFA_UnitPx2Pt(img_width, dpi.width),
3384 XFA_UnitPx2Pt(img_height, dpi.height));
3385
3386 CFX_RectF rtFit;
3387 absl::optional<float> width = TryWidth();
3388 if (width.has_value()) {
3389 rtFit.width = width.value();
3390 GetWidthWithoutMargin(rtFit.width);
3391 } else {
3392 rtFit.width = rtImage.width;
3393 }
3394
3395 absl::optional<float> height = TryHeight();
3396 if (height.has_value()) {
3397 rtFit.height = height.value();
3398 GetHeightWithoutMargin(rtFit.height);
3399 } else {
3400 rtFit.height = rtImage.height;
3401 }
3402
3403 return rtFit.Size();
3404}
3405
3406bool CXFA_Node::CalculateImageAutoSize(CXFA_FFDoc* doc, CFX_SizeF* pSize) {
3407 if (!GetLayoutImage())
3409
3410 pSize->clear();
3411 RetainPtr<CFX_DIBitmap> pBitmap = GetLayoutImage();
3412 if (!pBitmap)
3413 return CalculateWidgetAutoSize(pSize);
3414
3415 *pSize = CalculateImageSize(pBitmap->GetWidth(), pBitmap->GetHeight(),
3416 GetLayoutImageDpi());
3417 return CalculateWidgetAutoSize(pSize);
3418}
3419
3420bool CXFA_Node::CalculateImageEditAutoSize(CXFA_FFDoc* doc, CFX_SizeF* pSize) {
3421 if (!GetEditImage())
3422 LoadEditImage(doc);
3423
3424 pSize->clear();
3425 RetainPtr<CFX_DIBitmap> pBitmap = GetEditImage();
3426 if (!pBitmap)
3427 return CalculateFieldAutoSize(doc, pSize);
3428
3429 *pSize = CalculateImageSize(pBitmap->GetWidth(), pBitmap->GetHeight(),
3430 GetEditImageDpi());
3431 return CalculateFieldAutoSize(doc, pSize);
3432}
3433
3435 InitLayoutData(doc);
3436 return m_pLayoutData->AsImageLayoutData()->LoadImageData(doc, this);
3437}
3438
3440 InitLayoutData(doc);
3441 return m_pLayoutData->AsFieldLayoutData()->AsImageEditData()->LoadImageData(
3442 doc, this);
3443}
3444
3445CFX_Size CXFA_Node::GetLayoutImageDpi() const {
3446 return m_pLayoutData->AsImageLayoutData()->GetDpi();
3447}
3448
3449CFX_Size CXFA_Node::GetEditImageDpi() const {
3450 CXFA_ImageEditData* pData =
3451 m_pLayoutData->AsFieldLayoutData()->AsImageEditData();
3452 return pData->GetDpi();
3453}
3454
3455float CXFA_Node::CalculateWidgetAutoWidth(float fWidthCalc) {
3456 CXFA_Margin* margin = GetMarginIfExists();
3457 if (margin)
3458 fWidthCalc += margin->GetLeftInset() + margin->GetRightInset();
3459
3460 absl::optional<float> min = TryMinWidth();
3461 if (min.has_value())
3462 fWidthCalc = std::max(fWidthCalc, min.value());
3463
3464 absl::optional<float> max = TryMaxWidth();
3465 if (max.has_value() && max.value() > 0)
3466 fWidthCalc = std::min(fWidthCalc, max.value());
3467
3468 return fWidthCalc;
3469}
3470
3471float CXFA_Node::GetWidthWithoutMargin(float fWidthCalc) const {
3472 CXFA_Margin* margin = GetMarginIfExists();
3473 if (margin)
3474 fWidthCalc -= margin->GetLeftInset() + margin->GetRightInset();
3475 return fWidthCalc;
3476}
3477
3478float CXFA_Node::CalculateWidgetAutoHeight(float fHeightCalc) {
3479 CXFA_Margin* margin = GetMarginIfExists();
3480 if (margin)
3481 fHeightCalc += margin->GetTopInset() + margin->GetBottomInset();
3482
3483 absl::optional<float> min = TryMinHeight();
3484 if (min.has_value())
3485 fHeightCalc = std::max(fHeightCalc, min.value());
3486
3487 absl::optional<float> max = TryMaxHeight();
3488 if (max.has_value() && max.value() > 0)
3489 fHeightCalc = std::min(fHeightCalc, max.value());
3490
3491 return fHeightCalc;
3492}
3493
3494float CXFA_Node::GetHeightWithoutMargin(float fHeightCalc) const {
3495 CXFA_Margin* margin = GetMarginIfExists();
3496 if (margin)
3497 fHeightCalc -= margin->GetTopInset() + margin->GetBottomInset();
3498 return fHeightCalc;
3499}
3500
3502 float* pCalcWidth,
3503 float* pCalcHeight) {
3504 InitLayoutData(doc);
3505
3507 m_pLayoutData->SetWidgetHeight(TryHeight().value_or(-1));
3508 StartTextLayout(doc, pCalcWidth, pCalcHeight);
3509 return;
3510 }
3511 if (*pCalcWidth > 0 && *pCalcHeight > 0)
3512 return;
3513
3514 m_pLayoutData->SetWidgetHeight(-1.0f);
3515 float fWidth = 0;
3516 if (*pCalcWidth > 0 && *pCalcHeight < 0) {
3517 absl::optional<float> height = TryHeight();
3518 if (height.has_value()) {
3519 *pCalcHeight = height.value();
3520 } else {
3521 CFX_SizeF size = CalculateAccWidthAndHeight(doc, *pCalcWidth);
3522 *pCalcWidth = size.width;
3523 *pCalcHeight = size.height;
3524 }
3525 m_pLayoutData->SetWidgetHeight(*pCalcHeight);
3526 return;
3527 }
3528 if (*pCalcWidth < 0 && *pCalcHeight < 0) {
3529 absl::optional<float> height;
3530 absl::optional<float> width = TryWidth();
3531 if (width.has_value()) {
3532 fWidth = width.value();
3533 height = TryHeight();
3534 if (height.has_value())
3535 *pCalcHeight = height.value();
3536 }
3537 if (!width.has_value() || !height.has_value()) {
3538 CFX_SizeF size = CalculateAccWidthAndHeight(doc, fWidth);
3539 *pCalcWidth = size.width;
3540 *pCalcHeight = size.height;
3541 } else {
3542 *pCalcWidth = fWidth;
3543 }
3544 }
3545 m_pLayoutData->SetWidgetHeight(*pCalcHeight);
3546}
3547
3548CFX_SizeF CXFA_Node::CalculateAccWidthAndHeight(CXFA_FFDoc* doc, float fWidth) {
3549 CFX_SizeF sz(fWidth, m_pLayoutData->GetWidgetHeight());
3550 switch (GetFFWidgetType()) {
3554 CalculateFieldAutoSize(doc, &sz);
3555 break;
3557 CalculateImageEditAutoSize(doc, &sz);
3558 break;
3560 CalculatePushButtonAutoSize(doc, &sz);
3561 break;
3563 CalculateCheckButtonAutoSize(doc, &sz);
3564 break;
3569 CalculateTextEditAutoSize(doc, &sz);
3570 break;
3572 CalculateImageAutoSize(doc, &sz);
3573 break;
3579 CalculateWidgetAutoSize(&sz);
3580 break;
3583 break;
3584 }
3585 m_pLayoutData->SetWidgetHeight(sz.height);
3586 return sz;
3587}
3588
3590 size_t szBlockIndex,
3591 float fCalcHeight) {
3592 if (!HasCreatedUIWidget())
3593 return absl::nullopt;
3594
3595 if (GetFFWidgetType() == XFA_FFWidgetType::kSubform)
3596 return absl::nullopt;
3597
3598 switch (GetFFWidgetType()) {
3603 break;
3604 default:
3605 return 0.0f;
3606 }
3607
3608 float fTopInset = 0;
3609 float fBottomInset = 0;
3610 if (szBlockIndex == 0) {
3611 CXFA_Margin* margin = GetMarginIfExists();
3612 if (margin) {
3613 fTopInset = margin->GetTopInset();
3614 fBottomInset = margin->GetBottomInset();
3615 }
3616
3617 CFX_RectF rtUIMargin = GetUIMargin();
3618 fTopInset += rtUIMargin.top;
3619 fBottomInset += rtUIMargin.width;
3620 }
3622 float fHeight = fCalcHeight;
3623 if (szBlockIndex == 0) {
3624 fCalcHeight -= fTopInset;
3625 fCalcHeight = std::max(fCalcHeight, 0.0f);
3626 }
3627 CXFA_TextLayout* pTextLayout =
3628 m_pLayoutData->AsTextLayoutData()->GetTextLayout();
3629 fCalcHeight = pTextLayout->DoSplitLayout(
3630 szBlockIndex, fCalcHeight,
3631 m_pLayoutData->GetWidgetHeight() - fTopInset);
3632 if (fCalcHeight != 0) {
3633 if (szBlockIndex == 0)
3634 fCalcHeight += fTopInset;
3635 if (fabs(fHeight - fCalcHeight) < kXFAWidgetPrecision)
3636 return absl::nullopt;
3637 }
3638 return fCalcHeight;
3639 }
3640
3641 XFA_AttributeValue iCapPlacement = XFA_AttributeValue::Unknown;
3642 float fCapReserve = 0;
3643 if (szBlockIndex == 0) {
3644 CXFA_Caption* caption = GetCaptionIfExists();
3645 if (caption && !caption->IsHidden()) {
3646 iCapPlacement = caption->GetPlacementType();
3647 fCapReserve = caption->GetReserve();
3648 }
3649 if (iCapPlacement == XFA_AttributeValue::Top &&
3650 fCalcHeight < fCapReserve + fTopInset) {
3651 return 0.0f;
3652 }
3653 if (iCapPlacement == XFA_AttributeValue::Bottom &&
3654 m_pLayoutData->GetWidgetHeight() - fCapReserve - fBottomInset) {
3655 return 0.0f;
3656 }
3657 if (iCapPlacement != XFA_AttributeValue::Top)
3658 fCapReserve = 0;
3659 }
3660 CXFA_FieldLayoutData* pFieldData = m_pLayoutData->AsFieldLayoutData();
3661 int32_t iLinesCount = 0;
3662 float fHeight = m_pLayoutData->GetWidgetHeight();
3664 iLinesCount = 1;
3665 } else {
3666 if (!pFieldData->m_pTextOut) {
3667 CFX_SizeF size = CalculateAccWidthAndHeight(pDocView->GetDoc(),
3668 TryWidth().value_or(0));
3669 fHeight = size.height;
3670 }
3671
3672 iLinesCount = pFieldData->m_pTextOut->GetTotalLines();
3673 }
3674 std::vector<float>* pFieldArray = &pFieldData->m_FieldSplitArray;
3675 size_t szFieldSplitCount = pFieldArray->size();
3676 if (szFieldSplitCount < szBlockIndex * 3)
3677 return absl::nullopt;
3678
3679 for (size_t i = 0; i < szBlockIndex * 3; i += 3) {
3680 iLinesCount -= static_cast<int32_t>((*pFieldArray)[i + 1]);
3681 fHeight -= (*pFieldArray)[i + 2];
3682 }
3683 if (iLinesCount == 0)
3684 return absl::nullopt;
3685
3686 float fLineHeight = GetLineHeight();
3687 float fFontSize = GetFontSize();
3688 float fTextHeight = iLinesCount * fLineHeight - fLineHeight + fFontSize;
3689 float fSpaceAbove = 0;
3690 float fStartOffset = 0;
3691 if (fHeight > 0.1f && szBlockIndex == 0) {
3692 fStartOffset = fTopInset;
3693 fHeight -= (fTopInset + fBottomInset);
3694 CXFA_Para* para = GetParaIfExists();
3695 if (para) {
3696 fSpaceAbove = para->GetSpaceAbove();
3697 float fSpaceBelow = para->GetSpaceBelow();
3698 fHeight -= (fSpaceAbove + fSpaceBelow);
3699 switch (para->GetVerticalAlign()) {
3700 case XFA_AttributeValue::Top:
3701 fStartOffset += fSpaceAbove;
3702 break;
3703 case XFA_AttributeValue::Middle:
3704 fStartOffset += ((fHeight - fTextHeight) / 2 + fSpaceAbove);
3705 break;
3706 case XFA_AttributeValue::Bottom:
3707 fStartOffset += (fHeight - fTextHeight + fSpaceAbove);
3708 break;
3709 default:
3710 NOTREACHED_NORETURN();
3711 }
3712 }
3713 if (fStartOffset < 0.1f)
3714 fStartOffset = 0;
3715 }
3716 if (szBlockIndex > 0) {
3717 size_t i = szBlockIndex - 1;
3718 fStartOffset = (*pFieldArray)[i * 3] - (*pFieldArray)[i * 3 + 2];
3719 if (fStartOffset < 0.1f)
3720 fStartOffset = 0;
3721 }
3722 if (szFieldSplitCount / 3 == (szBlockIndex + 1))
3723 (*pFieldArray)[0] = fStartOffset;
3724 else
3725 pFieldArray->push_back(fStartOffset);
3726
3728 bool bCanSplitNoContent = false;
3729 auto value = GetParent()->JSObject()->TryEnum(XFA_Attribute::Layout, true);
3730 XFA_AttributeValue eLayoutMode = value.value_or(XFA_AttributeValue::Position);
3731 if ((eLayoutMode == XFA_AttributeValue::Position ||
3732 eLayoutMode == XFA_AttributeValue::Tb ||
3733 eLayoutMode == XFA_AttributeValue::Row ||
3734 eLayoutMode == XFA_AttributeValue::Table) &&
3735 version > XFA_VERSION_208) {
3736 bCanSplitNoContent = true;
3737 }
3738 if ((eLayoutMode == XFA_AttributeValue::Tb ||
3739 eLayoutMode == XFA_AttributeValue::Row ||
3740 eLayoutMode == XFA_AttributeValue::Table) &&
3741 version <= XFA_VERSION_208) {
3742 if (fStartOffset >= fCalcHeight)
3743 return 0.0f;
3744
3745 bCanSplitNoContent = true;
3746 }
3747 if (!bCanSplitNoContent ||
3748 fCalcHeight - fTopInset - fSpaceAbove < fLineHeight) {
3749 return 0.0f;
3750 }
3751
3752 if (fStartOffset + kXFAWidgetPrecision >= fCalcHeight) {
3753 if (szFieldSplitCount / 3 == (szBlockIndex + 1)) {
3754 (*pFieldArray)[szBlockIndex * 3 + 1] = 0;
3755 (*pFieldArray)[szBlockIndex * 3 + 2] = fCalcHeight;
3756 } else {
3757 pFieldArray->push_back(0);
3758 pFieldArray->push_back(fCalcHeight);
3759 }
3760 return absl::nullopt;
3761 }
3762
3763 if (fCalcHeight - fStartOffset < fLineHeight) {
3764 fCalcHeight = fStartOffset;
3765 if (szFieldSplitCount / 3 == (szBlockIndex + 1)) {
3766 (*pFieldArray)[szBlockIndex * 3 + 1] = 0;
3767 (*pFieldArray)[szBlockIndex * 3 + 2] = fCalcHeight;
3768 } else {
3769 pFieldArray->push_back(0);
3770 pFieldArray->push_back(fCalcHeight);
3771 }
3772 return fCalcHeight;
3773 }
3774
3775 float fTextNum =
3776 fCalcHeight + kXFAWidgetPrecision - fCapReserve - fStartOffset;
3777 int32_t iLineNum = static_cast<int32_t>(
3778 (fTextNum + (fLineHeight - fFontSize)) / fLineHeight);
3779 if (iLineNum >= iLinesCount) {
3780 if (fCalcHeight - fStartOffset - fTextHeight >= fFontSize) {
3781 if (szFieldSplitCount / 3 == (szBlockIndex + 1)) {
3782 (*pFieldArray)[szBlockIndex * 3 + 1] = iLinesCount;
3783 (*pFieldArray)[szBlockIndex * 3 + 2] = fCalcHeight;
3784 } else {
3785 pFieldArray->push_back(iLinesCount);
3786 pFieldArray->push_back(fCalcHeight);
3787 }
3788 return absl::nullopt;
3789 }
3790 if (fHeight - fStartOffset - fTextHeight < fFontSize) {
3791 iLineNum -= 1;
3792 if (iLineNum == 0)
3793 return 0.0f;
3794 } else {
3795 iLineNum = static_cast<int32_t>(fTextNum / fLineHeight);
3796 }
3797 }
3798 if (iLineNum <= 0)
3799 return 0.0f;
3800
3801 float fSplitHeight = iLineNum * fLineHeight + fCapReserve + fStartOffset;
3802 if (szFieldSplitCount / 3 == (szBlockIndex + 1)) {
3803 (*pFieldArray)[szBlockIndex * 3 + 1] = iLineNum;
3804 (*pFieldArray)[szBlockIndex * 3 + 2] = fSplitHeight;
3805 } else {
3806 pFieldArray->push_back(iLineNum);
3807 pFieldArray->push_back(fSplitHeight);
3808 }
3809 if (fabs(fSplitHeight - fCalcHeight) < kXFAWidgetPrecision)
3810 return absl::nullopt;
3811 return fSplitHeight;
3812}
3813
3814void CXFA_Node::InitLayoutData(CXFA_FFDoc* doc) {
3815 if (m_pLayoutData)
3816 return;
3817
3818 switch (GetFFWidgetType()) {
3819 case XFA_FFWidgetType::kText:
3820 m_pLayoutData = cppgc::MakeGarbageCollected<CXFA_TextLayoutData>(
3821 doc->GetHeap()->GetAllocationHandle());
3822 return;
3823 case XFA_FFWidgetType::kTextEdit:
3824 m_pLayoutData = cppgc::MakeGarbageCollected<CXFA_TextEditData>(
3825 doc->GetHeap()->GetAllocationHandle());
3826 return;
3827 case XFA_FFWidgetType::kImage:
3828 m_pLayoutData = cppgc::MakeGarbageCollected<CXFA_ImageLayoutData>(
3829 doc->GetHeap()->GetAllocationHandle());
3830 return;
3831 case XFA_FFWidgetType::kImageEdit:
3832 m_pLayoutData = cppgc::MakeGarbageCollected<CXFA_ImageEditData>(
3833 doc->GetHeap()->GetAllocationHandle());
3834 return;
3835 default:
3836 break;
3837 }
3838 if (GetElementType() == XFA_Element::Field) {
3839 m_pLayoutData = cppgc::MakeGarbageCollected<CXFA_FieldLayoutData>(
3840 doc->GetHeap()->GetAllocationHandle());
3841 return;
3842 }
3843 m_pLayoutData = cppgc::MakeGarbageCollected<CXFA_WidgetLayoutData>(
3844 doc->GetHeap()->GetAllocationHandle());
3845}
3846
3847void CXFA_Node::StartTextLayout(CXFA_FFDoc* doc,
3848 float* pCalcWidth,
3849 float* pCalcHeight) {
3850 InitLayoutData(doc);
3851
3852 CXFA_TextLayoutData* pTextLayoutData = m_pLayoutData->AsTextLayoutData();
3853 pTextLayoutData->LoadText(doc, this);
3854
3855 CXFA_TextLayout* pTextLayout = pTextLayoutData->GetTextLayout();
3856 float fTextHeight = 0;
3857 if (*pCalcWidth > 0 && *pCalcHeight > 0) {
3858 float fWidth = GetWidthWithoutMargin(*pCalcWidth);
3859 pTextLayout->StartLayout(fWidth);
3860 fTextHeight = *pCalcHeight;
3861 fTextHeight = GetHeightWithoutMargin(fTextHeight);
3862 pTextLayout->DoLayout(fTextHeight);
3863 return;
3864 }
3865 if (*pCalcWidth > 0 && *pCalcHeight < 0) {
3866 float fWidth = GetWidthWithoutMargin(*pCalcWidth);
3867 pTextLayout->StartLayout(fWidth);
3868 }
3869 if (*pCalcWidth < 0 && *pCalcHeight < 0) {
3870 absl::optional<float> width = TryWidth();
3871 if (width.has_value()) {
3872 pTextLayout->StartLayout(GetWidthWithoutMargin(width.value()));
3873 *pCalcWidth = width.value();
3874 } else {
3875 float fMaxWidth = CalculateWidgetAutoWidth(pTextLayout->StartLayout(-1));
3876 pTextLayout->StartLayout(GetWidthWithoutMargin(fMaxWidth));
3877 *pCalcWidth = fMaxWidth;
3878 }
3879 }
3880 if (m_pLayoutData->GetWidgetHeight() < 0) {
3881 m_pLayoutData->SetWidgetHeight(
3882 CalculateWidgetAutoHeight(pTextLayout->GetLayoutHeight()));
3883 }
3884 fTextHeight = m_pLayoutData->GetWidgetHeight();
3885 fTextHeight = GetHeightWithoutMargin(fTextHeight);
3886 pTextLayout->DoLayout(fTextHeight);
3887 *pCalcHeight = m_pLayoutData->GetWidgetHeight();
3888}
3889
3891 InitLayoutData(doc);
3892 return m_pLayoutData->AsFieldLayoutData()->LoadCaption(doc, this);
3893}
3894
3895CXFA_TextLayout* CXFA_Node::GetCaptionTextLayout() {
3896 return m_pLayoutData ? m_pLayoutData->AsFieldLayoutData()->m_pCapTextLayout
3897 : nullptr;
3898}
3899
3900CXFA_TextLayout* CXFA_Node::GetTextLayout() {
3901 return m_pLayoutData ? m_pLayoutData->AsTextLayoutData()->GetTextLayout()
3902 : nullptr;
3903}
3904
3906 return m_pLayoutData ? m_pLayoutData->AsImageLayoutData()->GetBitmap()
3907 : nullptr;
3908}
3909
3911 return m_pLayoutData ? m_pLayoutData->AsFieldLayoutData()
3912 ->AsImageEditData()
3913 ->GetBitmap()
3914 : nullptr;
3915}
3916
3917void CXFA_Node::SetLayoutImage(RetainPtr<CFX_DIBitmap> newImage) {
3918 CXFA_ImageLayoutData* pData = m_pLayoutData->AsImageLayoutData();
3919 if (pData->GetBitmap() != newImage)
3920 pData->SetBitmap(std::move(newImage));
3921}
3922
3923void CXFA_Node::SetEditImage(RetainPtr<CFX_DIBitmap> newImage) {
3924 CXFA_ImageEditData* pData =
3925 m_pLayoutData->AsFieldLayoutData()->AsImageEditData();
3926 if (pData->GetBitmap() != newImage)
3927 pData->SetBitmap(std::move(newImage));
3928}
3929
3931 WideString wsFontName = L"Courier";
3932 uint32_t dwFontStyle = 0;
3933 CXFA_Font* font = GetFontIfExists();
3934 if (font) {
3935 if (font->IsBold())
3936 dwFontStyle |= FXFONT_FORCE_BOLD;
3937 if (font->IsItalic())
3938 dwFontStyle |= FXFONT_ITALIC;
3939
3940 wsFontName = font->GetTypeface();
3941 }
3942 return doc->GetApp()->GetXFAFontMgr()->GetFont(doc, wsFontName, dwFontStyle);
3943}
3944
3946 const auto* pItems = GetChild<CXFA_Items>(0, XFA_Element::Items, false);
3947 if (!pItems)
3948 return false;
3949
3950 for (CXFA_Node* pText = pItems->GetFirstChild(); pText;
3951 pText = pText->GetNextSibling()) {
3952 if (pText->JSObject()
3953 ->GetCData(XFA_Attribute::Name)
3954 .EqualsASCII("rollover")) {
3955 return !pText->JSObject()->GetContent(false).IsEmpty();
3956 }
3957 }
3958 return false;
3959}
3960
3962 const auto* pItems = GetChild<CXFA_Items>(0, XFA_Element::Items, false);
3963 if (!pItems)
3964 return false;
3965
3966 for (CXFA_Node* pText = pItems->GetFirstChild(); pText;
3967 pText = pText->GetNextSibling()) {
3968 if (pText->JSObject()->GetCData(XFA_Attribute::Name).EqualsASCII("down")) {
3969 return !pText->JSObject()->GetContent(false).IsEmpty();
3970 }
3971 }
3972 return false;
3973}
3974
3976 CXFA_Node* pParent = GetParent();
3977 return pParent && pParent->GetElementType() == XFA_Element::ExclGroup;
3978}
3979
3981 CXFA_Node* pUIChild = GetUIChildNode();
3982 if (pUIChild) {
3983 return pUIChild->JSObject()->GetMeasureInUnit(XFA_Attribute::Size,
3984 XFA_Unit::Pt);
3985 }
3987}
3988
3990 WideString wsValue = GetRawValue();
3991 if (wsValue.IsEmpty())
3992 return XFA_CheckState::kOff;
3993
3994 auto* pItems = GetChild<CXFA_Items>(0, XFA_Element::Items, false);
3995 if (!pItems)
3996 return XFA_CheckState::kOff;
3997
3998 CXFA_Node* pText = pItems->GetFirstChild();
3999 int32_t i = 0;
4000 while (pText) {
4001 absl::optional<WideString> wsContent =
4002 pText->JSObject()->TryContent(false, true);
4003 if (wsContent == wsValue)
4004 return static_cast<XFA_CheckState>(i);
4005
4006 i++;
4007 pText = pText->GetNextSibling();
4008 }
4009 return XFA_CheckState::kOff;
4010}
4011
4014 if (!node) {
4015 CXFA_Items* pItems = GetChild<CXFA_Items>(0, XFA_Element::Items, false);
4016 if (!pItems)
4017 return;
4018
4019 int32_t i = -1;
4020 CXFA_Node* pText = pItems->GetFirstChild();
4021 WideString wsContent;
4022 while (pText) {
4023 i++;
4024 if (i == static_cast<int32_t>(eCheckState)) {
4025 wsContent = pText->JSObject()->GetContent(false);
4026 break;
4027 }
4028 pText = pText->GetNextSibling();
4029 }
4030 SyncValue(wsContent, true);
4031
4032 return;
4033 }
4034
4035 WideString wsValue;
4036 if (eCheckState != XFA_CheckState::kOff) {
4037 if (CXFA_Items* pItems =
4038 GetChild<CXFA_Items>(0, XFA_Element::Items, false)) {
4039 CXFA_Node* pText = pItems->GetFirstChild();
4040 if (pText)
4041 wsValue = pText->JSObject()->GetContent(false);
4042 }
4043 }
4044 CXFA_Node* pChild = node->GetFirstChild();
4045 for (; pChild; pChild = pChild->GetNextSibling()) {
4046 if (pChild->GetElementType() != XFA_Element::Field)
4047 continue;
4048
4049 CXFA_Items* pItem =
4050 pChild->GetChild<CXFA_Items>(0, XFA_Element::Items, false);
4051 if (!pItem)
4052 continue;
4053
4054 CXFA_Node* pItemchild = pItem->GetFirstChild();
4055 if (!pItemchild)
4056 continue;
4057
4058 WideString text = pItemchild->JSObject()->GetContent(false);
4059 WideString wsChildValue = text;
4060 if (wsValue != text) {
4061 pItemchild = pItemchild->GetNextSibling();
4062 if (pItemchild)
4063 wsChildValue = pItemchild->JSObject()->GetContent(false);
4064 else
4065 wsChildValue.clear();
4066 }
4067 pChild->SyncValue(wsChildValue, true);
4068 }
4069 node->SyncValue(wsValue, true);
4070}
4071
4073 CXFA_Node* pSelectedMember = nullptr;
4074 WideString wsState = GetRawValue();
4075 if (wsState.IsEmpty())
4076 return pSelectedMember;
4077
4078 for (CXFA_Node* pNode = ToNode(GetFirstChild()); pNode;
4079 pNode = pNode->GetNextSibling()) {
4081 pSelectedMember = pNode;
4082 break;
4083 }
4084 }
4085 return pSelectedMember;
4086}
4087
4088CXFA_Node* CXFA_Node::SetSelectedMember(WideStringView wsName) {
4089 uint32_t nameHash = FX_HashCode_GetW(wsName);
4090 for (CXFA_Node* pNode = ToNode(GetFirstChild()); pNode;
4091 pNode = pNode->GetNextSibling()) {
4092 if (pNode->GetNameHash() == nameHash) {
4094 return pNode;
4095 }
4096 }
4097 return nullptr;
4098}
4099
4100void CXFA_Node::SetSelectedMemberByValue(WideStringView wsValue,
4101 bool bNotify,
4102 bool bScriptModify,
4103 bool bSyncData) {
4104 WideString wsExclGroup;
4105 for (CXFA_Node* pNode = GetFirstChild(); pNode;
4106 pNode = pNode->GetNextSibling()) {
4107 if (pNode->GetElementType() != XFA_Element::Field)
4108 continue;
4109
4110 CXFA_Items* pItem =
4111 pNode->GetChild<CXFA_Items>(0, XFA_Element::Items, false);
4112 if (!pItem)
4113 continue;
4114
4115 CXFA_Node* pItemchild = pItem->GetFirstChild();
4116 if (!pItemchild)
4117 continue;
4118
4119 WideString wsChildValue = pItemchild->JSObject()->GetContent(false);
4120 if (wsValue != wsChildValue) {
4121 pItemchild = pItemchild->GetNextSibling();
4122 if (pItemchild)
4123 wsChildValue = pItemchild->JSObject()->GetContent(false);
4124 else
4125 wsChildValue.clear();
4126 } else {
4127 wsExclGroup = wsValue;
4128 }
4129 pNode->JSObject()->SetContent(wsChildValue, wsChildValue, bNotify,
4130 bScriptModify, false);
4131 }
4132 JSObject()->SetContent(wsExclGroup, wsExclGroup, bNotify, bScriptModify,
4133 bSyncData);
4134}
4135
4137 CXFA_Node* pNode = GetFirstChild();
4138 while (pNode) {
4139 if (pNode->GetElementType() == XFA_Element::Field)
4140 return pNode;
4141
4142 pNode = pNode->GetNextSibling();
4143 }
4144 return nullptr;
4145}
4146
4148 if (!pNode)
4149 return nullptr;
4150
4151 CXFA_Node* pNodeField = pNode->GetNextSibling();
4152 while (pNodeField) {
4153 if (pNodeField->GetElementType() == XFA_Element::Field)
4154 return pNodeField;
4155
4156 pNodeField = pNodeField->GetNextSibling();
4157 }
4158 return nullptr;
4159}
4160
4162 CXFA_Node* pUIChild = GetUIChildNode();
4163 if (pUIChild) {
4164 return pUIChild->JSObject()->GetEnum(XFA_Attribute::CommitOn) ==
4165 XFA_AttributeValue::Select;
4166 }
4167 return true;
4168}
4169
4171 CXFA_Node* pUIChild = GetUIChildNode();
4172 return pUIChild && pUIChild->JSObject()->GetBoolean(XFA_Attribute::TextEntry);
4173}
4174
4176 CXFA_Node* pUIChild = GetUIChildNode();
4177 if (pUIChild) {
4178 return pUIChild->JSObject()->GetEnum(XFA_Attribute::Open) ==
4179 XFA_AttributeValue::MultiSelect;
4180 }
4181 return false;
4182}
4183
4185 CXFA_Node* pUIChild = GetUIChildNode();
4186 if (!pUIChild)
4187 return false;
4188
4189 XFA_AttributeValue attr = pUIChild->JSObject()->GetEnum(XFA_Attribute::Open);
4190 return attr == XFA_AttributeValue::Always ||
4191 attr == XFA_AttributeValue::MultiSelect;
4192}
4193
4195 std::vector<CXFA_Node*> pItems;
4196 int32_t iCount = 0;
4197 for (CXFA_Node* pNode = GetFirstChild(); pNode;
4198 pNode = pNode->GetNextSibling()) {
4199 if (pNode->GetElementType() != XFA_Element::Items)
4200 continue;
4201 iCount++;
4202 pItems.push_back(pNode);
4203 if (iCount == 2)
4204 break;
4205 }
4206 if (iCount == 0)
4207 return 0;
4208
4209 CXFA_Node* pItem = pItems[0];
4210 if (iCount > 1) {
4211 bool bItemOneHasSave =
4212 pItems[0]->JSObject()->GetBoolean(XFA_Attribute::Save);
4213 bool bItemTwoHasSave =
4214 pItems[1]->JSObject()->GetBoolean(XFA_Attribute::Save);
4215 if (bItemOneHasSave != bItemTwoHasSave && bSaveValue == bItemTwoHasSave)
4216 pItem = pItems[1];
4217 }
4218 return pItem->CountChildren(XFA_Element::Unknown, false);
4219}
4220
4222 bool bSaveValue) {
4223 std::vector<CXFA_Node*> pItemsArray;
4224 int32_t iCount = 0;
4225 for (CXFA_Node* pNode = GetFirstChild(); pNode;
4226 pNode = pNode->GetNextSibling()) {
4227 if (pNode->GetElementType() != XFA_Element::Items)
4228 continue;
4229
4230 ++iCount;
4231 pItemsArray.push_back(pNode);
4232 if (iCount == 2)
4233 break;
4234 }
4235 if (iCount == 0)
4236 return absl::nullopt;
4237
4238 CXFA_Node* pItems = pItemsArray[0];
4239 if (iCount > 1) {
4240 bool bItemOneHasSave =
4241 pItemsArray[0]->JSObject()->GetBoolean(XFA_Attribute::Save);
4242 bool bItemTwoHasSave =
4243 pItemsArray[1]->JSObject()->GetBoolean(XFA_Attribute::Save);
4244 if (bItemOneHasSave != bItemTwoHasSave && bSaveValue == bItemTwoHasSave)
4245 pItems = pItemsArray[1];
4246 }
4247 if (!pItems)
4248 return absl::nullopt;
4249
4250 CXFA_Node* pItem =
4251 pItems->GetChild<CXFA_Node>(nIndex, XFA_Element::Unknown, false);
4252 if (!pItem)
4253 return absl::nullopt;
4254
4255 return pItem->JSObject()->GetContent(false);
4256}
4257
4259 std::vector<CXFA_Node*> items;
4260 for (CXFA_Node* pNode = GetFirstChild(); pNode && items.size() < 2;
4261 pNode = pNode->GetNextSibling()) {
4262 if (pNode->GetElementType() == XFA_Element::Items)
4263 items.push_back(pNode);
4264 }
4265 if (items.empty())
4266 return std::vector<WideString>();
4267
4268 CXFA_Node* pItem = items.front();
4269 if (items.size() > 1) {
4270 bool bItemOneHasSave =
4271 items[0]->JSObject()->GetBoolean(XFA_Attribute::Save);
4272 bool bItemTwoHasSave =
4273 items[1]->JSObject()->GetBoolean(XFA_Attribute::Save);
4274 if (bItemOneHasSave != bItemTwoHasSave && bSaveValue == bItemTwoHasSave)
4275 pItem = items[1];
4276 }
4277
4278 std::vector<WideString> wsTextArray;
4279 for (CXFA_Node* pNode = pItem->GetFirstChild(); pNode;
4280 pNode = pNode->GetNextSibling()) {
4281 wsTextArray.emplace_back(pNode->JSObject()->GetContent(false));
4282 }
4283 return wsTextArray;
4284}
4285
4287 std::vector<WideString> wsValueArray = GetSelectedItemsValue();
4289 return fxcrt::CollectionSize<int32_t>(wsValueArray);
4290
4291 int32_t iSelected = 0;
4292 std::vector<WideString> wsSaveTextArray = GetChoiceListItems(true);
4293 for (const auto& value : wsValueArray) {
4294 if (pdfium::Contains(wsSaveTextArray, value))
4295 iSelected++;
4296 }
4297 return iSelected;
4298}
4299
4300int32_t CXFA_Node::GetSelectedItem(int32_t nIndex) {
4301 std::vector<WideString> wsValueArray = GetSelectedItemsValue();
4302 if (!fxcrt::IndexInBounds(wsValueArray, nIndex))
4303 return -1;
4304
4305 std::vector<WideString> wsSaveTextArray = GetChoiceListItems(true);
4306 auto it = std::find(wsSaveTextArray.begin(), wsSaveTextArray.end(),
4307 wsValueArray[nIndex]);
4308 return it != wsSaveTextArray.end()
4309 ? pdfium::base::checked_cast<int32_t>(it - wsSaveTextArray.begin())
4310 : -1;
4311}
4312
4314 std::vector<int32_t> iSelArray;
4315 std::vector<WideString> wsValueArray = GetSelectedItemsValue();
4316 std::vector<WideString> wsSaveTextArray = GetChoiceListItems(true);
4317 for (const auto& value : wsValueArray) {
4318 auto it = std::find(wsSaveTextArray.begin(), wsSaveTextArray.end(), value);
4319 if (it != wsSaveTextArray.end()) {
4320 iSelArray.push_back(
4321 pdfium::base::checked_cast<int32_t>(it - wsSaveTextArray.begin()));
4322 }
4323 }
4324 return iSelArray;
4325}
4326
4328 WideString wsValue = GetRawValue();
4330 return fxcrt::Split(wsValue, L'\n');
4331
4332 std::vector<WideString> wsSelTextArray;
4333 wsSelTextArray.push_back(wsValue);
4334 return wsSelTextArray;
4335}
4336
4337bool CXFA_Node::GetItemState(int32_t nIndex) {
4338 std::vector<WideString> wsSaveTextArray = GetChoiceListItems(true);
4339 return fxcrt::IndexInBounds(wsSaveTextArray, nIndex) &&
4340 pdfium::Contains(GetSelectedItemsValue(), wsSaveTextArray[nIndex]);
4341}
4342
4343void CXFA_Node::SetItemState(int32_t nIndex,
4344 bool bSelected,
4345 bool bNotify,
4346 bool bScriptModify) {
4347 std::vector<WideString> wsSaveTextArray = GetChoiceListItems(true);
4348 if (!fxcrt::IndexInBounds(wsSaveTextArray, nIndex))
4349 return;
4350
4351 int32_t iSel = -1;
4352 std::vector<WideString> wsValueArray = GetSelectedItemsValue();
4353 auto value_iter = std::find(wsValueArray.begin(), wsValueArray.end(),
4354 wsSaveTextArray[nIndex]);
4355 if (value_iter != wsValueArray.end()) {
4356 iSel =
4357 pdfium::base::checked_cast<int32_t>(value_iter - wsValueArray.begin());
4358 }
4360 if (bSelected) {
4361 if (iSel < 0) {
4362 WideString wsValue = GetRawValue();
4363 if (!wsValue.IsEmpty()) {
4364 wsValue += L"\n";
4365 }
4366 wsValue += wsSaveTextArray[nIndex];
4367 JSObject()->SetContent(wsValue, wsValue, bNotify, bScriptModify, true);
4368 }
4369 } else if (iSel >= 0) {
4370 std::vector<int32_t> iSelArray = GetSelectedItems();
4371 auto selected_iter =
4372 std::find(iSelArray.begin(), iSelArray.end(), nIndex);
4373 if (selected_iter != iSelArray.end())
4374 iSelArray.erase(selected_iter);
4375 SetSelectedItems(iSelArray, bNotify, bScriptModify, true);
4376 }
4377 } else {
4378 if (bSelected) {
4379 if (iSel < 0) {
4380 WideString wsSaveText = wsSaveTextArray[nIndex];
4381 JSObject()->SetContent(wsSaveText, GetFormatDataValue(wsSaveText),
4382 bNotify, bScriptModify, true);
4383 }
4384 } else if (iSel >= 0) {
4385 JSObject()->SetContent(WideString(), WideString(), bNotify, bScriptModify,
4386 true);
4387 }
4388 }
4389}
4390
4391void CXFA_Node::SetSelectedItems(const std::vector<int32_t>& iSelArray,
4392 bool bNotify,
4393 bool bScriptModify,
4394 bool bSyncData) {
4395 WideString wsValue;
4396 int32_t iSize = fxcrt::CollectionSize<int32_t>(iSelArray);
4397 if (iSize >= 1) {
4398 std::vector<WideString> wsSaveTextArray = GetChoiceListItems(true);
4399 WideString wsItemValue;
4400 for (int32_t i = 0; i < iSize; i++) {
4401 wsItemValue = (iSize == 1) ? wsSaveTextArray[iSelArray[i]]
4402 : wsSaveTextArray[iSelArray[i]] + L"\n";
4403 wsValue += wsItemValue;
4404 }
4405 }
4406 WideString wsFormat(wsValue);
4408 wsFormat = GetFormatDataValue(wsValue);
4409
4410 JSObject()->SetContent(wsValue, wsFormat, bNotify, bScriptModify, bSyncData);
4411}
4412
4414 CXFA_Node* pBind = GetBindData();
4415 if (!pBind || !IsChoiceListMultiSelect()) {
4416 SyncValue(WideString(), false);
4417 return;
4418 }
4419
4420 while (CXFA_Node* pChildNode = pBind->GetFirstChild())
4421 pBind->RemoveChildAndNotify(pChildNode, true);
4422}
4423
4424void CXFA_Node::InsertItem(const WideString& wsLabel,
4425 const WideString& wsValue,
4426 bool bNotify) {
4427 int32_t nIndex = -1;
4428 WideString wsNewValue(wsValue);
4429 if (wsNewValue.IsEmpty())
4430 wsNewValue = wsLabel;
4431
4432 std::vector<CXFA_Node*> listitems;
4433 for (CXFA_Node* pItem = GetFirstChild(); pItem;
4434 pItem = pItem->GetNextSibling()) {
4435 if (pItem->GetElementType() == XFA_Element::Items)
4436 listitems.push_back(pItem);
4437 }
4438 if (listitems.empty()) {
4440 InsertChildAndNotify(-1, pItems);
4441 InsertListTextItem(pItems, wsLabel, nIndex);
4442 CXFA_Node* pSaveItems = CreateSamePacketNode(XFA_Element::Items);
4443 InsertChildAndNotify(-1, pSaveItems);
4444 pSaveItems->JSObject()->SetBoolean(XFA_Attribute::Save, true, false);
4445 InsertListTextItem(pSaveItems, wsNewValue, nIndex);
4446 } else if (listitems.size() > 1) {
4447 for (int32_t i = 0; i < 2; i++) {
4448 CXFA_Node* pNode = listitems[i];
4449 bool bHasSave = pNode->JSObject()->GetBoolean(XFA_Attribute::Save);
4450 if (bHasSave)
4451 InsertListTextItem(pNode, wsNewValue, nIndex);
4452 else
4453 InsertListTextItem(pNode, wsLabel, nIndex);
4454 }
4455 } else {
4456 CXFA_Node* pNode = listitems[0];
4457 pNode->JSObject()->SetBoolean(XFA_Attribute::Save, false, false);
4458 pNode->JSObject()->SetEnum(XFA_Attribute::Presence,
4459 XFA_AttributeValue::Visible, false);
4460 CXFA_Node* pSaveItems = CreateSamePacketNode(XFA_Element::Items);
4461 InsertChildAndNotify(-1, pSaveItems);
4462 pSaveItems->JSObject()->SetBoolean(XFA_Attribute::Save, true, false);
4463 pSaveItems->JSObject()->SetEnum(XFA_Attribute::Presence,
4464 XFA_AttributeValue::Hidden, false);
4465 CXFA_Node* pListNode = pNode->GetFirstChild();
4466 int32_t i = 0;
4467 while (pListNode) {
4468 InsertListTextItem(pSaveItems, pListNode->JSObject()->GetContent(false),
4469 i);
4470 ++i;
4471
4472 pListNode = pListNode->GetNextSibling();
4473 }
4474 InsertListTextItem(pNode, wsLabel, nIndex);
4475 InsertListTextItem(pSaveItems, wsNewValue, nIndex);
4476 }
4477 if (bNotify)
4478 GetDocument()->GetNotify()->OnWidgetListItemAdded(this, wsLabel, nIndex);
4479}
4480
4481WideString CXFA_Node::GetItemLabel(WideStringView wsValue) const {
4482 std::vector<CXFA_Node*> listitems;
4483 CXFA_Node* pItems = GetFirstChild();
4484 for (; pItems; pItems = pItems->GetNextSibling()) {
4485 if (pItems->GetElementType() != XFA_Element::Items)
4486 continue;
4487 listitems.push_back(pItems);
4488 }
4489
4490 if (listitems.size() <= 1)
4491 return WideString(wsValue);
4492
4493 CXFA_Node* pLabelItems = listitems[0];
4494 bool bSave = pLabelItems->JSObject()->GetBoolean(XFA_Attribute::Save);
4495 CXFA_Node* pSaveItems = nullptr;
4496 if (bSave) {
4497 pSaveItems = pLabelItems;
4498 pLabelItems = listitems[1];
4499 } else {
4500 pSaveItems = listitems[1];
4501 }
4502
4503 int32_t iCount = 0;
4504 int32_t iSearch = -1;
4505 for (CXFA_Node* pChildItem = pSaveItems->GetFirstChild(); pChildItem;
4506 pChildItem = pChildItem->GetNextSibling()) {
4507 if (pChildItem->JSObject()->GetContent(false) == wsValue) {
4508 iSearch = iCount;
4509 break;
4510 }
4511 iCount++;
4512 }
4513 if (iSearch < 0)
4514 return WideString();
4515
4516 CXFA_Node* pText =
4517 pLabelItems->GetChild<CXFA_Node>(iSearch, XFA_Element::Unknown, false);
4518 return pText ? pText->JSObject()->GetContent(false) : WideString();
4519}
4520
4521WideString CXFA_Node::GetItemValue(WideStringView wsLabel) {
4522 int32_t iCount = 0;
4523 std::vector<CXFA_Node*> listitems;
4524 for (CXFA_Node* pItems = GetFirstChild(); pItems;
4525 pItems = pItems->GetNextSibling()) {
4526 if (pItems->GetElementType() != XFA_Element::Items)
4527 continue;
4528 iCount++;
4529 listitems.push_back(pItems);
4530 }
4531 if (iCount <= 1)
4532 return WideString(wsLabel);
4533
4534 CXFA_Node* pLabelItems = listitems[0];
4535 bool bSave = pLabelItems->JSObject()->GetBoolean(XFA_Attribute::Save);
4536 CXFA_Node* pSaveItems = nullptr;
4537 if (bSave) {
4538 pSaveItems = pLabelItems;
4539 pLabelItems = listitems[1];
4540 } else {
4541 pSaveItems = listitems[1];
4542 }
4543 iCount = 0;
4544
4545 int32_t iSearch = -1;
4546 WideString wsContent;
4547 CXFA_Node* pChildItem = pLabelItems->GetFirstChild();
4548 for (; pChildItem; pChildItem = pChildItem->GetNextSibling()) {
4549 if (pChildItem->JSObject()->GetContent(false) == wsLabel) {
4550 iSearch = iCount;
4551 break;
4552 }
4553 iCount++;
4554 }
4555 if (iSearch < 0)
4556 return WideString();
4557
4558 CXFA_Node* pText =
4559 pSaveItems->GetChild<CXFA_Node>(iSearch, XFA_Element::Unknown, false);
4560 return pText ? pText->JSObject()->GetContent(false) : WideString();
4561}
4562
4563bool CXFA_Node::DeleteItem(int32_t nIndex, bool bNotify, bool bScriptModify) {
4564 bool bSetValue = false;
4565 CXFA_Node* pItems = GetFirstChild();
4566 for (; pItems; pItems = pItems->GetNextSibling()) {
4567 if (pItems->GetElementType() != XFA_Element::Items)
4568 continue;
4569
4570 if (nIndex < 0) {
4571 while (CXFA_Node* pNode = pItems->GetFirstChild()) {
4572 pItems->RemoveChildAndNotify(pNode, true);
4573 }
4574 } else {
4575 if (!bSetValue && pItems->JSObject()->GetBoolean(XFA_Attribute::Save)) {
4576 SetItemState(nIndex, false, true, bScriptModify);
4577 bSetValue = true;
4578 }
4579 int32_t i = 0;
4580 CXFA_Node* pNode = pItems->GetFirstChild();
4581 while (pNode) {
4582 if (i == nIndex) {
4583 pItems->RemoveChildAndNotify(pNode, true);
4584 break;
4585 }
4586 i++;
4587 pNode = pNode->GetNextSibling();
4588 }
4589 }
4590 }
4591 if (bNotify)
4592 GetDocument()->GetNotify()->OnWidgetListItemRemoved(this, nIndex);
4593 return true;
4594}
4595
4597 CXFA_Node* pUIChild = GetUIChildNode();
4598 if (pUIChild) {
4599 return pUIChild->JSObject()->GetEnum(XFA_Attribute::HScrollPolicy) ==
4600 XFA_AttributeValue::Off;
4601 }
4602 return false;
4603}
4604
4606 CXFA_Node* pUIChild = GetUIChildNode();
4607 if (pUIChild) {
4608 return pUIChild->JSObject()->GetEnum(XFA_Attribute::VScrollPolicy) ==
4609 XFA_AttributeValue::Off;
4610 }
4611 return false;
4612}
4613
4615 CXFA_Node* pUIChild = GetUIChildNode();
4616 if (!pUIChild)
4617 return absl::nullopt;
4618
4619 CXFA_Comb* pNode = pUIChild->GetChild<CXFA_Comb>(0, XFA_Element::Comb, false);
4620 if (!pNode)
4621 return absl::nullopt;
4622
4623 return pNode->JSObject()->GetInteger(XFA_Attribute::NumberOfCells);
4624}
4625
4627 CXFA_Node* pUIChild = GetUIChildNode();
4628 return pUIChild && pUIChild->JSObject()->GetBoolean(XFA_Attribute::MultiLine);
4629}
4630
4631std::pair<XFA_Element, int32_t> CXFA_Node::GetMaxChars() const {
4632 const auto* pNode = GetChild<CXFA_Value>(0, XFA_Element::Value, false);
4633 if (pNode) {
4634 if (CXFA_Node* pChild = pNode->GetFirstChild()) {
4635 switch (pChild->GetElementType()) {
4636 case XFA_Element::Text:
4637 return {XFA_Element::Text,
4638 pChild->JSObject()->GetInteger(XFA_Attribute::MaxChars)};
4639 case XFA_Element::ExData: {
4640 int32_t iMax =
4641 pChild->JSObject()->GetInteger(XFA_Attribute::MaxLength);
4642 return {XFA_Element::ExData, iMax < 0 ? 0 : iMax};
4643 }
4644 default:
4645 break;
4646 }
4647 }
4648 }
4649 return {XFA_Element::Unknown, 0};
4650}
4651
4652int32_t CXFA_Node::GetFracDigits() const {
4653 const auto* pNode = GetChild<CXFA_Value>(0, XFA_Element::Value, false);
4654 if (!pNode)
4655 return -1;
4656
4657 const auto* pChild =
4658 pNode->GetChild<CXFA_Decimal>(0, XFA_Element::Decimal, false);
4659 if (!pChild)
4660 return -1;
4661
4662 return pChild->JSObject()
4663 ->TryInteger(XFA_Attribute::FracDigits, true)
4664 .value_or(-1);
4665}
4666
4667int32_t CXFA_Node::GetLeadDigits() const {
4668 const auto* pNode = GetChild<CXFA_Value>(0, XFA_Element::Value, false);
4669 if (!pNode)
4670 return -1;
4671
4672 const auto* pChild =
4673 pNode->GetChild<CXFA_Decimal>(0, XFA_Element::Decimal, false);
4674 if (!pChild)
4675 return -1;
4676
4677 return pChild->JSObject()
4678 ->TryInteger(XFA_Attribute::LeadDigits, true)
4679 .value_or(-1);
4680}
4681
4683 const WideString& wsValue) {
4684 if (wsValue.IsEmpty()) {
4685 SyncValue(wsValue, true);
4686 return true;
4687 }
4688
4690 SetIsNull(false);
4691
4692 WideString wsNewText(wsValue);
4693 WideString wsPicture = GetPictureContent(eValueType);
4694 bool bValidate = true;
4695 bool bSyncData = false;
4696 CXFA_Node* pNode = GetUIChildNode();
4697 if (!pNode)
4698 return true;
4699
4700 XFA_Element eType = pNode->GetElementType();
4701 if (!wsPicture.IsEmpty()) {
4702 CXFA_LocaleMgr* pLocaleMgr = GetDocument()->GetLocaleMgr();
4703 GCedLocaleIface* pLocale = GetLocale();
4704 CXFA_LocaleValue widgetValue = XFA_GetLocaleValue(this);
4705 bValidate =
4706 widgetValue.ValidateValue(wsValue, wsPicture, pLocale, &wsPicture);
4707 if (bValidate) {
4708 widgetValue = CXFA_LocaleValue(widgetValue.GetType(), wsNewText,
4709 wsPicture, pLocale, pLocaleMgr);
4710 wsNewText = widgetValue.GetValue();
4711 if (eType == XFA_Element::NumericEdit)
4712 wsNewText = NumericLimit(wsNewText);
4713
4714 bSyncData = true;
4715 }
4716 } else if (eType == XFA_Element::NumericEdit) {
4717 if (!wsNewText.EqualsASCII("0"))
4718 wsNewText = NumericLimit(wsNewText);
4719
4720 bSyncData = true;
4721 }
4722 if (eType != XFA_Element::NumericEdit || bSyncData)
4723 SyncValue(wsNewText, true);
4724
4725 return bValidate;
4726}
4727
4729 if (ePicture == XFA_ValuePicture::kRaw)
4730 return WideString();
4731
4732 CXFA_LocaleValue widgetValue = XFA_GetLocaleValue(this);
4733 switch (ePicture) {
4735 auto* pFormat = GetChild<CXFA_Format>(0, XFA_Element::Format, false);
4736 if (pFormat) {
4737 auto* pPicture =
4738 pFormat->GetChild<CXFA_Picture>(0, XFA_Element::Picture, false);
4739 if (pPicture) {
4740 absl::optional<WideString> picture =
4741 pPicture->JSObject()->TryContent(false, true);
4742 if (picture.has_value())
4743 return picture.value();
4744 }
4745 }
4746
4747 LocaleIface* pLocale = GetLocale();
4748 if (!pLocale)
4749 return WideString();
4750
4751 switch (widgetValue.GetType()) {
4753 return pLocale->GetDatePattern(
4756 return pLocale->GetTimePattern(
4759 return pLocale->GetDatePattern(
4761 L"T" +
4762 pLocale->GetTimePattern(
4766 default:
4767 return WideString();
4768 }
4769 }
4771 CXFA_Ui* pUI = GetChild<CXFA_Ui>(0, XFA_Element::Ui, false);
4772 if (pUI) {
4773 if (CXFA_Picture* pPicture =
4774 pUI->GetChild<CXFA_Picture>(0, XFA_Element::Picture, false)) {
4775 absl::optional<WideString> picture =
4776 pPicture->JSObject()->TryContent(false, true);
4777 if (picture.has_value())
4778 return picture.value();
4779 }
4780 }
4781
4782 LocaleIface* pLocale = GetLocale();
4783 if (!pLocale)
4784 return WideString();
4785
4786 switch (widgetValue.GetType()) {
4788 return pLocale->GetDatePattern(
4791 return pLocale->GetTimePattern(
4794 return pLocale->GetDatePattern(
4796 L"T" +
4797 pLocale->GetTimePattern(
4799 default:
4800 return WideString();
4801 }
4802 }
4804 CXFA_Bind* bind = GetBindIfExists();
4805 if (bind)
4806 return bind->GetPicture();
4807 break;
4808 }
4809 default:
4810 break;
4811 }
4812 return WideString();
4813}
4814
4815WideString CXFA_Node::GetValue(XFA_ValuePicture eValueType) {
4816 WideString wsValue = JSObject()->GetContent(false);
4817
4818 if (eValueType == XFA_ValuePicture::kDisplay)
4819 wsValue = GetItemLabel(wsValue.AsStringView());
4820
4821 WideString wsPicture = GetPictureContent(eValueType);
4822 CXFA_Node* pNode = GetUIChildNode();
4823 if (!pNode)
4824 return wsValue;
4825
4826 switch (pNode->GetElementType()) {
4827 case XFA_Element::ChoiceList: {
4828 if (eValueType == XFA_ValuePicture::kDisplay) {
4829 int32_t iSelItemIndex = GetSelectedItem(0);
4830 if (iSelItemIndex >= 0) {
4831 wsValue =
4832 GetChoiceListItem(iSelItemIndex, false).value_or(WideString());
4833 wsPicture.clear();
4834 }
4835 }
4836 break;
4837 }
4838 case XFA_Element::NumericEdit:
4839 if (eValueType != XFA_ValuePicture::kRaw && wsPicture.IsEmpty()) {
4840 LocaleIface* pLocale = GetLocale();
4841 if (eValueType == XFA_ValuePicture::kDisplay && pLocale)
4842 wsValue = FormatNumStr(NormalizeNumStr(wsValue), pLocale);
4843 }
4844 break;
4845 default:
4846 break;
4847 }
4848 if (wsPicture.IsEmpty())
4849 return wsValue;
4850
4851 GCedLocaleIface* pLocale = GetLocale();
4852 if (pLocale) {
4853 CXFA_LocaleValue widgetValue = XFA_GetLocaleValue(this);
4854 CXFA_LocaleMgr* pLocaleMgr = GetDocument()->GetLocaleMgr();
4855 switch (widgetValue.GetType()) {
4857 WideString wsDate, wsTime;
4858 if (SplitDateTime(wsValue, wsDate, wsTime)) {
4860 pLocaleMgr);
4861 if (date.FormatPatterns(wsValue, wsPicture, pLocale, eValueType))
4862 return wsValue;
4863 }
4864 break;
4865 }
4867 WideString wsDate, wsTime;
4868 if (SplitDateTime(wsValue, wsDate, wsTime)) {
4870 pLocaleMgr);
4871 if (time.FormatPatterns(wsValue, wsPicture, pLocale, eValueType))
4872 return wsValue;
4873 }
4874 break;
4875 }
4876 default:
4877 break;
4878 }
4879 widgetValue.FormatPatterns(wsValue, wsPicture, pLocale, eValueType);
4880 }
4881 return wsValue;
4882}
4883
4884WideString CXFA_Node::GetNormalizeDataValue(const WideString& wsValue) {
4885 if (wsValue.IsEmpty())
4886 return WideString();
4887
4889 if (wsPicture.IsEmpty())
4890 return wsValue;
4891
4892 CXFA_LocaleMgr* pLocaleMgr = GetDocument()->GetLocaleMgr();
4893 GCedLocaleIface* pLocale = GetLocale();
4894 CXFA_LocaleValue widgetValue = XFA_GetLocaleValue(this);
4895 if (widgetValue.ValidateValue(wsValue, wsPicture, pLocale, &wsPicture)) {
4896 widgetValue = CXFA_LocaleValue(widgetValue.GetType(), wsValue, wsPicture,
4897 pLocale, pLocaleMgr);
4898 return widgetValue.GetValue();
4899 }
4900 return wsValue;
4901}
4902
4903WideString CXFA_Node::GetFormatDataValue(const WideString& wsValue) {
4904 if (wsValue.IsEmpty())
4905 return WideString();
4906
4908 if (wsPicture.IsEmpty())
4909 return wsValue;
4910
4911 WideString wsFormattedValue = wsValue;
4912 GCedLocaleIface* pLocale = GetLocale();
4913 if (pLocale) {
4914 CXFA_Value* pNodeValue = GetChild<CXFA_Value>(0, XFA_Element::Value, false);
4915 if (!pNodeValue)
4916 return wsValue;
4917
4918 CXFA_Node* pValueChild = pNodeValue->GetFirstChild();
4919 if (!pValueChild)
4920 return wsValue;
4921
4922 CXFA_LocaleValue::ValueType iVTType =
4923 XFA_GetLocaleValueType(pValueChild->GetElementType());
4924 CXFA_LocaleMgr* pLocaleMgr = GetDocument()->GetLocaleMgr();
4925 CXFA_LocaleValue widgetValue(iVTType, wsValue, pLocaleMgr);
4926 switch (widgetValue.GetType()) {
4928 WideString wsDate, wsTime;
4929 if (SplitDateTime(wsValue, wsDate, wsTime)) {
4931 pLocaleMgr);
4932 if (date.FormatPatterns(wsFormattedValue, wsPicture, pLocale,
4934 return wsFormattedValue;
4935 }
4936 }
4937 break;
4938 }
4940 WideString wsDate, wsTime;
4941 if (SplitDateTime(wsValue, wsDate, wsTime)) {
4943 pLocaleMgr);
4944 if (time.FormatPatterns(wsFormattedValue, wsPicture, pLocale,
4946 return wsFormattedValue;
4947 }
4948 }
4949 break;
4950 }
4951 default:
4952 break;
4953 }
4954 widgetValue.FormatPatterns(wsFormattedValue, wsPicture, pLocale,
4956 }
4957 return wsFormattedValue;
4958}
4959
4960WideString CXFA_Node::NormalizeNumStr(const WideString& wsValue) {
4961 if (wsValue.IsEmpty())
4962 return WideString();
4963
4964 WideString wsOutput = wsValue;
4965 wsOutput.TrimLeft('0');
4966
4967 if (!wsOutput.IsEmpty() && wsOutput.Contains('.') && GetFracDigits() != -1) {
4968 wsOutput.TrimRight(L"0");
4969 wsOutput.TrimRight(L".");
4970 }
4971 if (wsOutput.IsEmpty() || wsOutput[0] == '.')
4972 wsOutput.InsertAtFront('0');
4973
4974 return wsOutput;
4975}
4976
4977void CXFA_Node::InsertListTextItem(CXFA_Node* pItems,
4978 const WideString& wsText,
4979 int32_t nIndex) {
4981 pItems->InsertChildAndNotify(nIndex, pText);
4982 pText->JSObject()->SetContent(wsText, wsText, false, false, false);
4983}
4984
4985WideString CXFA_Node::NumericLimit(const WideString& wsValue) {
4986 int32_t iLead = GetLeadDigits();
4987 int32_t iTread = GetFracDigits();
4988 if (iLead == -1 && iTread == -1)
4989 return wsValue;
4990
4991 int32_t iCount = pdfium::base::checked_cast<int32_t>(wsValue.GetLength());
4992 if (iCount == 0)
4993 return wsValue;
4994
4995 WideString wsRet;
4996 int32_t i = 0;
4997 if (wsValue[i] == L'-') {
4998 wsRet += L'-';
4999 i++;
5000 }
5001
5002 int32_t iLead2 = 0;
5003 int32_t iTread2 = -1;
5004 for (; i < iCount; i++) {
5005 wchar_t wc = wsValue[i];
5006 if (FXSYS_IsDecimalDigit(wc)) {
5007 if (iLead >= 0) {
5008 iLead2++;
5009 if (iLead2 > iLead)
5010 return L"0";
5011 } else if (iTread2 >= 0) {
5012 iTread2++;
5013 if (iTread2 > iTread) {
5014 if (iTread != -1) {
5015 CFGAS_Decimal wsDeci = CFGAS_Decimal(wsValue.AsStringView());
5016 wsDeci.SetScale(iTread);
5017 wsRet = wsDeci.ToWideString();
5018 }
5019 return wsRet;
5020 }
5021 }
5022 } else if (wc == L'.') {
5023 iTread2 = 0;
5024 iLead = -1;
5025 }
5026 wsRet += wc;
5027 }
5028 return wsRet;
5029}
5030
5032 XFA_Element type = GetElementType();
5033 return type == XFA_Element::SubformSet || type == XFA_Element::Area ||
5034 type == XFA_Element::Proto || (IsUnnamed() && IsContainerNode());
5035}
5036
5037bool CXFA_Node::IsProperty() const {
5038 CXFA_Node* parent = GetParent();
5039 return parent && parent->HasProperty(GetElementType());
5040}
5041
5043 auto value = JSObject()->TryEnum(XFA_Attribute::Presence, true);
5044 XFA_AttributeValue ePresence = value.value_or(XFA_AttributeValue::Visible);
5045 return ePresence == XFA_AttributeValue::Visible ||
5046 ePresence == XFA_AttributeValue::Invisible;
5047}
5048
5050 binding_nodes_.clear();
5051 if (node)
5052 binding_nodes_.emplace_back(node);
5053}
5054
5056 CXFA_NodeIterator sIterator(this);
5057 for (CXFA_Node* pNode = sIterator.GetCurrent(); pNode;
5058 pNode = sIterator.MoveToNext()) {
5060 }
5061}
5062
5063void CXFA_Node::SetToXML(const WideString& value) {
5064 auto* pNode = GetXMLMappingNode();
5065 switch (pNode->GetType()) {
5067 auto* elem = static_cast<CFX_XMLElement*>(pNode);
5068 if (IsAttributeInXML()) {
5069 elem->SetAttribute(JSObject()->GetCData(XFA_Attribute::QualifiedName),
5070 value);
5071 return;
5072 }
5073
5074 bool bDeleteChildren = true;
5075 if (GetPacketType() == XFA_PacketType::Datasets) {
5076 for (CXFA_Node* pChildDataNode = GetFirstChild(); pChildDataNode;
5077 pChildDataNode = pChildDataNode->GetNextSibling()) {
5078 if (pChildDataNode->HasBindItems()) {
5079 bDeleteChildren = false;
5080 break;
5081 }
5082 }
5083 }
5084 if (bDeleteChildren)
5085 elem->RemoveAllChildren();
5086
5087 auto* text = GetXMLDocument()->CreateNode<CFX_XMLText>(value);
5088 elem->AppendLastChild(text);
5089 break;
5090 }
5093 break;
5094 default:
5095 NOTREACHED_NORETURN();
5096 }
5097}
5098
5099CXFA_Node* CXFA_Node::GetTransparentParent() {
5100 CXFA_Node* parent = GetParent();
5101 while (parent) {
5102 XFA_Element type = parent->GetElementType();
5103 if (type == XFA_Element::Variables ||
5104 (type != XFA_Element::SubformSet && !parent->IsUnnamed())) {
5105 return parent;
5106 }
5107 parent = parent->GetParent();
5108 }
5109 return nullptr;
5110}
5111
5112CFX_XMLDocument* CXFA_Node::GetXMLDocument() const {
5113 return GetDocument()->GetNotify()->GetFFDoc()->GetXMLDocument();
5114}
5115
5116// static
5117CXFA_Node* CXFA_Node::Create(CXFA_Document* doc,
5118 XFA_Element element,
5119 XFA_PacketType packet) {
5120 CXFA_Node* node = nullptr;
5121 switch (element) {
5122 case XFA_Element::Ps:
5123 node = cppgc::MakeGarbageCollected<CXFA_Ps>(
5124 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5125 break;
5126 case XFA_Element::To:
5127 node = cppgc::MakeGarbageCollected<CXFA_To>(
5128 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5129 break;
5130 case XFA_Element::Ui:
5131 node = cppgc::MakeGarbageCollected<CXFA_Ui>(
5132 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5133 break;
5134 case XFA_Element::RecordSet:
5135 node = cppgc::MakeGarbageCollected<CXFA_RecordSet>(
5136 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5137 break;
5138 case XFA_Element::SubsetBelow:
5139 node = cppgc::MakeGarbageCollected<CXFA_SubsetBelow>(
5140 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5141 break;
5142 case XFA_Element::SubformSet:
5143 node = cppgc::MakeGarbageCollected<CXFA_SubformSet>(
5144 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5145 break;
5146 case XFA_Element::AdobeExtensionLevel:
5147 node = cppgc::MakeGarbageCollected<CXFA_AdobeExtensionLevel>(
5148 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5149 break;
5150 case XFA_Element::Typeface:
5151 node = cppgc::MakeGarbageCollected<CXFA_Typeface>(
5152 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5153 break;
5154 case XFA_Element::Break:
5155 node = cppgc::MakeGarbageCollected<CXFA_Break>(
5156 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5157 break;
5158 case XFA_Element::FontInfo:
5159 node = cppgc::MakeGarbageCollected<CXFA_FontInfo>(
5160 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5161 break;
5162 case XFA_Element::NumberPattern:
5163 node = cppgc::MakeGarbageCollected<CXFA_NumberPattern>(
5164 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5165 break;
5166 case XFA_Element::DynamicRender:
5167 node = cppgc::MakeGarbageCollected<CXFA_DynamicRender>(
5168 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5169 break;
5170 case XFA_Element::PrintScaling:
5171 node = cppgc::MakeGarbageCollected<CXFA_PrintScaling>(
5172 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5173 break;
5174 case XFA_Element::CheckButton:
5175 node = cppgc::MakeGarbageCollected<CXFA_CheckButton>(
5176 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5177 break;
5178 case XFA_Element::DatePatterns:
5179 node = cppgc::MakeGarbageCollected<CXFA_DatePatterns>(
5180 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5181 break;
5182 case XFA_Element::SourceSet:
5183 node = cppgc::MakeGarbageCollected<CXFA_SourceSet>(
5184 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5185 break;
5186 case XFA_Element::Amd:
5187 node = cppgc::MakeGarbageCollected<CXFA_Amd>(
5188 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5189 break;
5190 case XFA_Element::Arc:
5191 node = cppgc::MakeGarbageCollected<CXFA_Arc>(
5192 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5193 break;
5194 case XFA_Element::Day:
5195 node = cppgc::MakeGarbageCollected<CXFA_Day>(
5196 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5197 break;
5198 case XFA_Element::Era:
5199 node = cppgc::MakeGarbageCollected<CXFA_Era>(
5200 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5201 break;
5202 case XFA_Element::Jog:
5203 node = cppgc::MakeGarbageCollected<CXFA_Jog>(
5204 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5205 break;
5206 case XFA_Element::Log:
5207 node = cppgc::MakeGarbageCollected<CXFA_Log>(
5208 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5209 break;
5210 case XFA_Element::Map:
5211 node = cppgc::MakeGarbageCollected<CXFA_Map>(
5212 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5213 break;
5214 case XFA_Element::Mdp:
5215 node = cppgc::MakeGarbageCollected<CXFA_Mdp>(
5216 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5217 break;
5218 case XFA_Element::BreakBefore:
5219 node = cppgc::MakeGarbageCollected<CXFA_BreakBefore>(
5220 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5221 break;
5222 case XFA_Element::Oid:
5223 node = cppgc::MakeGarbageCollected<CXFA_Oid>(
5224 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5225 break;
5226 case XFA_Element::Pcl:
5227 node = cppgc::MakeGarbageCollected<CXFA_Pcl>(
5228 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5229 break;
5230 case XFA_Element::Pdf:
5231 node = cppgc::MakeGarbageCollected<CXFA_Pdf>(
5232 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5233 break;
5234 case XFA_Element::Ref:
5235 node = cppgc::MakeGarbageCollected<CXFA_Ref>(
5236 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5237 break;
5238 case XFA_Element::Uri:
5239 node = cppgc::MakeGarbageCollected<CXFA_Uri>(
5240 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5241 break;
5242 case XFA_Element::Xdc:
5243 node = cppgc::MakeGarbageCollected<CXFA_Xdc>(
5244 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5245 break;
5246 case XFA_Element::Xdp:
5247 node = cppgc::MakeGarbageCollected<CXFA_Xdp>(
5248 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5249 break;
5250 case XFA_Element::Xfa:
5251 node = cppgc::MakeGarbageCollected<CXFA_Xfa>(
5252 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5253 break;
5254 case XFA_Element::Xsl:
5255 node = cppgc::MakeGarbageCollected<CXFA_Xsl>(
5256 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5257 break;
5258 case XFA_Element::Zpl:
5259 node = cppgc::MakeGarbageCollected<CXFA_Zpl>(
5260 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5261 break;
5262 case XFA_Element::Cache:
5263 node = cppgc::MakeGarbageCollected<CXFA_Cache>(
5264 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5265 break;
5266 case XFA_Element::Margin:
5267 node = cppgc::MakeGarbageCollected<CXFA_Margin>(
5268 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5269 break;
5270 case XFA_Element::KeyUsage:
5271 node = cppgc::MakeGarbageCollected<CXFA_KeyUsage>(
5272 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5273 break;
5274 case XFA_Element::Exclude:
5275 node = cppgc::MakeGarbageCollected<CXFA_Exclude>(
5276 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5277 break;
5278 case XFA_Element::ChoiceList:
5279 node = cppgc::MakeGarbageCollected<CXFA_ChoiceList>(
5280 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5281 break;
5282 case XFA_Element::Level:
5283 node = cppgc::MakeGarbageCollected<CXFA_Level>(
5284 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5285 break;
5286 case XFA_Element::LabelPrinter:
5287 node = cppgc::MakeGarbageCollected<CXFA_LabelPrinter>(
5288 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5289 break;
5290 case XFA_Element::CalendarSymbols:
5291 node = cppgc::MakeGarbageCollected<CXFA_CalendarSymbols>(
5292 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5293 break;
5294 case XFA_Element::Para:
5295 node = cppgc::MakeGarbageCollected<CXFA_Para>(
5296 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5297 break;
5298 case XFA_Element::Part:
5299 node = cppgc::MakeGarbageCollected<CXFA_Part>(
5300 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5301 break;
5302 case XFA_Element::Pdfa:
5303 node = cppgc::MakeGarbageCollected<CXFA_Pdfa>(
5304 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5305 break;
5306 case XFA_Element::Filter:
5307 node = cppgc::MakeGarbageCollected<CXFA_Filter>(
5308 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5309 break;
5310 case XFA_Element::Present:
5311 node = cppgc::MakeGarbageCollected<CXFA_Present>(
5312 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5313 break;
5314 case XFA_Element::Pagination:
5315 node = cppgc::MakeGarbageCollected<CXFA_Pagination>(
5316 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5317 break;
5318 case XFA_Element::Encoding:
5319 node = cppgc::MakeGarbageCollected<CXFA_Encoding>(
5320 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5321 break;
5322 case XFA_Element::Event:
5323 node = cppgc::MakeGarbageCollected<CXFA_Event>(
5324 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5325 break;
5326 case XFA_Element::Whitespace:
5327 node = cppgc::MakeGarbageCollected<CXFA_Whitespace>(
5328 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5329 break;
5330 case XFA_Element::DefaultUi:
5331 node = cppgc::MakeGarbageCollected<CXFA_DefaultUi>(
5332 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5333 break;
5334 case XFA_Element::DataModel:
5335 node = cppgc::MakeGarbageCollected<CXFA_DataModel>(
5336 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5337 break;
5338 case XFA_Element::Barcode:
5339 node = cppgc::MakeGarbageCollected<CXFA_Barcode>(
5340 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5341 break;
5342 case XFA_Element::TimePattern:
5343 node = cppgc::MakeGarbageCollected<CXFA_TimePattern>(
5344 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5345 break;
5346 case XFA_Element::BatchOutput:
5347 node = cppgc::MakeGarbageCollected<CXFA_BatchOutput>(
5348 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5349 break;
5350 case XFA_Element::Enforce:
5351 node = cppgc::MakeGarbageCollected<CXFA_Enforce>(
5352 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5353 break;
5354 case XFA_Element::CurrencySymbols:
5355 node = cppgc::MakeGarbageCollected<CXFA_CurrencySymbols>(
5356 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5357 break;
5358 case XFA_Element::AddSilentPrint:
5359 node = cppgc::MakeGarbageCollected<CXFA_AddSilentPrint>(
5360 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5361 break;
5362 case XFA_Element::Rename:
5363 node = cppgc::MakeGarbageCollected<CXFA_Rename>(
5364 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5365 break;
5366 case XFA_Element::Operation:
5367 node = cppgc::MakeGarbageCollected<CXFA_Operation>(
5368 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5369 break;
5370 case XFA_Element::Typefaces:
5371 node = cppgc::MakeGarbageCollected<CXFA_Typefaces>(
5372 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5373 break;
5374 case XFA_Element::SubjectDNs:
5375 node = cppgc::MakeGarbageCollected<CXFA_SubjectDNs>(
5376 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5377 break;
5378 case XFA_Element::Issuers:
5379 node = cppgc::MakeGarbageCollected<CXFA_Issuers>(
5380 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5381 break;
5382 case XFA_Element::WsdlConnection:
5383 node = cppgc::MakeGarbageCollected<CXFA_WsdlConnection>(
5384 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5385 break;
5386 case XFA_Element::Debug:
5387 node = cppgc::MakeGarbageCollected<CXFA_Debug>(
5388 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5389 break;
5390 case XFA_Element::Delta:
5391 node = cppgc::MakeGarbageCollected<CXFA_Delta>(
5392 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5393 break;
5394 case XFA_Element::EraNames:
5395 node = cppgc::MakeGarbageCollected<CXFA_EraNames>(
5396 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5397 break;
5398 case XFA_Element::ModifyAnnots:
5399 node = cppgc::MakeGarbageCollected<CXFA_ModifyAnnots>(
5400 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5401 break;
5402 case XFA_Element::StartNode:
5403 node = cppgc::MakeGarbageCollected<CXFA_StartNode>(
5404 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5405 break;
5406 case XFA_Element::Button:
5407 node = cppgc::MakeGarbageCollected<CXFA_Button>(
5408 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5409 break;
5410 case XFA_Element::Format:
5411 node = cppgc::MakeGarbageCollected<CXFA_Format>(
5412 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5413 break;
5414 case XFA_Element::Border:
5415 node = cppgc::MakeGarbageCollected<CXFA_Border>(
5416 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5417 break;
5418 case XFA_Element::Area:
5419 node = cppgc::MakeGarbageCollected<CXFA_Area>(
5420 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5421 break;
5422 case XFA_Element::Hyphenation:
5423 node = cppgc::MakeGarbageCollected<CXFA_Hyphenation>(
5424 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5425 break;
5426 case XFA_Element::Text:
5427 node = cppgc::MakeGarbageCollected<CXFA_Text>(
5428 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5429 break;
5430 case XFA_Element::Time:
5431 node = cppgc::MakeGarbageCollected<CXFA_Time>(
5432 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5433 break;
5434 case XFA_Element::Type:
5435 node = cppgc::MakeGarbageCollected<CXFA_Type>(
5436 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5437 break;
5438 case XFA_Element::Overprint:
5439 node = cppgc::MakeGarbageCollected<CXFA_Overprint>(
5440 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5441 break;
5442 case XFA_Element::Certificates:
5443 node = cppgc::MakeGarbageCollected<CXFA_Certificates>(
5444 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5445 break;
5446 case XFA_Element::EncryptionMethods:
5447 node = cppgc::MakeGarbageCollected<CXFA_EncryptionMethods>(
5448 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5449 break;
5450 case XFA_Element::SetProperty:
5451 node = cppgc::MakeGarbageCollected<CXFA_SetProperty>(
5452 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5453 break;
5454 case XFA_Element::PrinterName:
5455 node = cppgc::MakeGarbageCollected<CXFA_PrinterName>(
5456 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5457 break;
5458 case XFA_Element::StartPage:
5459 node = cppgc::MakeGarbageCollected<CXFA_StartPage>(
5460 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5461 break;
5462 case XFA_Element::PageOffset:
5463 node = cppgc::MakeGarbageCollected<CXFA_PageOffset>(
5464 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5465 break;
5466 case XFA_Element::DateTime:
5467 node = cppgc::MakeGarbageCollected<CXFA_DateTime>(
5468 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5469 break;
5470 case XFA_Element::Comb:
5471 node = cppgc::MakeGarbageCollected<CXFA_Comb>(
5472 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5473 break;
5474 case XFA_Element::Pattern:
5475 node = cppgc::MakeGarbageCollected<CXFA_Pattern>(
5476 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5477 break;
5478 case XFA_Element::IfEmpty:
5479 node = cppgc::MakeGarbageCollected<CXFA_IfEmpty>(
5480 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5481 break;
5482 case XFA_Element::SuppressBanner:
5483 node = cppgc::MakeGarbageCollected<CXFA_SuppressBanner>(
5484 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5485 break;
5486 case XFA_Element::OutputBin:
5487 node = cppgc::MakeGarbageCollected<CXFA_OutputBin>(
5488 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5489 break;
5490 case XFA_Element::Field:
5491 node = cppgc::MakeGarbageCollected<CXFA_Field>(
5492 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5493 break;
5494 case XFA_Element::Agent:
5495 node = cppgc::MakeGarbageCollected<CXFA_Agent>(
5496 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5497 break;
5498 case XFA_Element::OutputXSL:
5499 node = cppgc::MakeGarbageCollected<CXFA_OutputXSL>(
5500 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5501 break;
5502 case XFA_Element::AdjustData:
5503 node = cppgc::MakeGarbageCollected<CXFA_AdjustData>(
5504 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5505 break;
5506 case XFA_Element::AutoSave:
5507 node = cppgc::MakeGarbageCollected<CXFA_AutoSave>(
5508 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5509 break;
5510 case XFA_Element::ContentArea:
5511 node = cppgc::MakeGarbageCollected<CXFA_ContentArea>(
5512 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5513 break;
5514 case XFA_Element::WsdlAddress:
5515 node = cppgc::MakeGarbageCollected<CXFA_WsdlAddress>(
5516 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5517 break;
5518 case XFA_Element::Solid:
5519 node = cppgc::MakeGarbageCollected<CXFA_Solid>(
5520 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5521 break;
5522 case XFA_Element::DateTimeSymbols:
5523 node = cppgc::MakeGarbageCollected<CXFA_DateTimeSymbols>(
5524 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5525 break;
5526 case XFA_Element::EncryptionLevel:
5527 node = cppgc::MakeGarbageCollected<CXFA_EncryptionLevel>(
5528 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5529 break;
5530 case XFA_Element::Edge:
5531 node = cppgc::MakeGarbageCollected<CXFA_Edge>(
5532 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5533 break;
5534 case XFA_Element::Stipple:
5535 node = cppgc::MakeGarbageCollected<CXFA_Stipple>(
5536 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5537 break;
5538 case XFA_Element::Attributes:
5539 node = cppgc::MakeGarbageCollected<CXFA_Attributes>(
5540 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5541 break;
5542 case XFA_Element::VersionControl:
5543 node = cppgc::MakeGarbageCollected<CXFA_VersionControl>(
5544 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5545 break;
5546 case XFA_Element::Meridiem:
5547 node = cppgc::MakeGarbageCollected<CXFA_Meridiem>(
5548 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5549 break;
5550 case XFA_Element::ExclGroup:
5551 node = cppgc::MakeGarbageCollected<CXFA_ExclGroup>(
5552 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5553 break;
5554 case XFA_Element::ToolTip:
5555 node = cppgc::MakeGarbageCollected<CXFA_ToolTip>(
5556 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5557 break;
5558 case XFA_Element::Compress:
5559 node = cppgc::MakeGarbageCollected<CXFA_Compress>(
5560 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5561 break;
5562 case XFA_Element::Reason:
5563 node = cppgc::MakeGarbageCollected<CXFA_Reason>(
5564 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5565 break;
5566 case XFA_Element::Execute:
5567 node = cppgc::MakeGarbageCollected<CXFA_Execute>(
5568 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5569 break;
5570 case XFA_Element::ContentCopy:
5571 node = cppgc::MakeGarbageCollected<CXFA_ContentCopy>(
5572 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5573 break;
5574 case XFA_Element::DateTimeEdit:
5575 node = cppgc::MakeGarbageCollected<CXFA_DateTimeEdit>(
5576 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5577 break;
5578 case XFA_Element::Config:
5579 node = cppgc::MakeGarbageCollected<CXFA_Config>(
5580 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5581 break;
5582 case XFA_Element::Image:
5583 node = cppgc::MakeGarbageCollected<CXFA_Image>(
5584 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5585 break;
5586 case XFA_Element::SharpxHTML:
5587 node = cppgc::MakeGarbageCollected<CXFA_SharpxHTML>(
5588 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5589 break;
5590 case XFA_Element::NumberOfCopies:
5591 node = cppgc::MakeGarbageCollected<CXFA_NumberOfCopies>(
5592 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5593 break;
5594 case XFA_Element::BehaviorOverride:
5595 node = cppgc::MakeGarbageCollected<CXFA_BehaviorOverride>(
5596 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5597 break;
5598 case XFA_Element::TimeStamp:
5599 node = cppgc::MakeGarbageCollected<CXFA_TimeStamp>(
5600 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5601 break;
5602 case XFA_Element::Month:
5603 node = cppgc::MakeGarbageCollected<CXFA_Month>(
5604 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5605 break;
5606 case XFA_Element::ViewerPreferences:
5607 node = cppgc::MakeGarbageCollected<CXFA_ViewerPreferences>(
5608 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5609 break;
5610 case XFA_Element::ScriptModel:
5611 node = cppgc::MakeGarbageCollected<CXFA_ScriptModel>(
5612 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5613 break;
5614 case XFA_Element::Decimal:
5615 node = cppgc::MakeGarbageCollected<CXFA_Decimal>(
5616 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5617 break;
5618 case XFA_Element::Subform:
5619 node = cppgc::MakeGarbageCollected<CXFA_Subform>(
5620 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5621 break;
5622 case XFA_Element::Select:
5623 node = cppgc::MakeGarbageCollected<CXFA_Select>(
5624 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5625 break;
5626 case XFA_Element::Window:
5627 node = cppgc::MakeGarbageCollected<CXFA_Window>(
5628 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5629 break;
5630 case XFA_Element::LocaleSet:
5631 node = cppgc::MakeGarbageCollected<CXFA_LocaleSet>(
5632 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5633 break;
5634 case XFA_Element::Handler:
5635 node = cppgc::MakeGarbageCollected<CXFA_Handler>(
5636 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5637 break;
5638 case XFA_Element::Presence:
5639 node = cppgc::MakeGarbageCollected<CXFA_Presence>(
5640 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5641 break;
5642 case XFA_Element::Record:
5643 node = cppgc::MakeGarbageCollected<CXFA_Record>(
5644 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5645 break;
5646 case XFA_Element::Embed:
5647 node = cppgc::MakeGarbageCollected<CXFA_Embed>(
5648 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5649 break;
5650 case XFA_Element::Version:
5651 node = cppgc::MakeGarbageCollected<CXFA_Version>(
5652 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5653 break;
5654 case XFA_Element::Command:
5655 node = cppgc::MakeGarbageCollected<CXFA_Command>(
5656 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5657 break;
5658 case XFA_Element::Copies:
5659 node = cppgc::MakeGarbageCollected<CXFA_Copies>(
5660 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5661 break;
5662 case XFA_Element::Staple:
5663 node = cppgc::MakeGarbageCollected<CXFA_Staple>(
5664 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5665 break;
5666 case XFA_Element::SubmitFormat:
5667 node = cppgc::MakeGarbageCollected<CXFA_SubmitFormat>(
5668 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5669 break;
5670 case XFA_Element::Boolean:
5671 node = cppgc::MakeGarbageCollected<CXFA_Boolean>(
5672 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5673 break;
5674 case XFA_Element::Message:
5675 node = cppgc::MakeGarbageCollected<CXFA_Message>(
5676 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5677 break;
5678 case XFA_Element::Output:
5679 node = cppgc::MakeGarbageCollected<CXFA_Output>(
5680 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5681 break;
5682 case XFA_Element::PsMap:
5683 node = cppgc::MakeGarbageCollected<CXFA_PsMap>(
5684 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5685 break;
5686 case XFA_Element::ExcludeNS:
5687 node = cppgc::MakeGarbageCollected<CXFA_ExcludeNS>(
5688 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5689 break;
5690 case XFA_Element::Assist:
5691 node = cppgc::MakeGarbageCollected<CXFA_Assist>(
5692 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5693 break;
5694 case XFA_Element::Picture:
5695 node = cppgc::MakeGarbageCollected<CXFA_Picture>(
5696 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5697 break;
5698 case XFA_Element::Traversal:
5699 node = cppgc::MakeGarbageCollected<CXFA_Traversal>(
5700 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5701 break;
5702 case XFA_Element::SilentPrint:
5703 node = cppgc::MakeGarbageCollected<CXFA_SilentPrint>(
5704 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5705 break;
5706 case XFA_Element::WebClient:
5707 node = cppgc::MakeGarbageCollected<CXFA_WebClient>(
5708 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5709 break;
5710 case XFA_Element::Producer:
5711 node = cppgc::MakeGarbageCollected<CXFA_Producer>(
5712 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5713 break;
5714 case XFA_Element::Corner:
5715 node = cppgc::MakeGarbageCollected<CXFA_Corner>(
5716 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5717 break;
5718 case XFA_Element::MsgId:
5719 node = cppgc::MakeGarbageCollected<CXFA_MsgId>(
5720 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5721 break;
5722 case XFA_Element::Color:
5723 node = cppgc::MakeGarbageCollected<CXFA_Color>(
5724 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5725 break;
5726 case XFA_Element::Keep:
5727 node = cppgc::MakeGarbageCollected<CXFA_Keep>(
5728 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5729 break;
5730 case XFA_Element::Query:
5731 node = cppgc::MakeGarbageCollected<CXFA_Query>(
5732 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5733 break;
5734 case XFA_Element::Insert:
5735 node = cppgc::MakeGarbageCollected<CXFA_Insert>(
5736 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5737 break;
5738 case XFA_Element::ImageEdit:
5739 node = cppgc::MakeGarbageCollected<CXFA_ImageEdit>(
5740 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5741 break;
5742 case XFA_Element::Validate:
5743 node = cppgc::MakeGarbageCollected<CXFA_Validate>(
5744 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5745 break;
5746 case XFA_Element::DigestMethods:
5747 node = cppgc::MakeGarbageCollected<CXFA_DigestMethods>(
5748 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5749 break;
5750 case XFA_Element::NumberPatterns:
5751 node = cppgc::MakeGarbageCollected<CXFA_NumberPatterns>(
5752 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5753 break;
5754 case XFA_Element::PageSet:
5755 node = cppgc::MakeGarbageCollected<CXFA_PageSet>(
5756 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5757 break;
5758 case XFA_Element::Integer:
5759 node = cppgc::MakeGarbageCollected<CXFA_Integer>(
5760 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5761 break;
5762 case XFA_Element::SoapAddress:
5763 node = cppgc::MakeGarbageCollected<CXFA_SoapAddress>(
5764 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5765 break;
5766 case XFA_Element::Equate:
5767 node = cppgc::MakeGarbageCollected<CXFA_Equate>(
5768 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5769 break;
5770 case XFA_Element::FormFieldFilling:
5771 node = cppgc::MakeGarbageCollected<CXFA_FormFieldFilling>(
5772 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5773 break;
5774 case XFA_Element::PageRange:
5775 node = cppgc::MakeGarbageCollected<CXFA_PageRange>(
5776 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5777 break;
5778 case XFA_Element::Update:
5779 node = cppgc::MakeGarbageCollected<CXFA_Update>(
5780 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5781 break;
5782 case XFA_Element::ConnectString:
5783 node = cppgc::MakeGarbageCollected<CXFA_ConnectString>(
5784 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5785 break;
5786 case XFA_Element::Mode:
5787 node = cppgc::MakeGarbageCollected<CXFA_Mode>(
5788 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5789 break;
5790 case XFA_Element::Layout:
5791 node = cppgc::MakeGarbageCollected<CXFA_Layout>(
5792 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5793 break;
5794 case XFA_Element::Sharpxml:
5795 node = cppgc::MakeGarbageCollected<CXFA_Sharpxml>(
5796 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5797 break;
5798 case XFA_Element::XsdConnection:
5799 node = cppgc::MakeGarbageCollected<CXFA_XsdConnection>(
5800 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5801 break;
5802 case XFA_Element::Traverse:
5803 node = cppgc::MakeGarbageCollected<CXFA_Traverse>(
5804 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5805 break;
5806 case XFA_Element::Encodings:
5807 node = cppgc::MakeGarbageCollected<CXFA_Encodings>(
5808 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5809 break;
5810 case XFA_Element::Template:
5811 node = cppgc::MakeGarbageCollected<CXFA_Template>(
5812 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5813 break;
5814 case XFA_Element::Acrobat:
5815 node = cppgc::MakeGarbageCollected<CXFA_Acrobat>(
5816 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5817 break;
5818 case XFA_Element::ValidationMessaging:
5819 node = cppgc::MakeGarbageCollected<CXFA_ValidationMessaging>(
5820 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5821 break;
5822 case XFA_Element::Signing:
5823 node = cppgc::MakeGarbageCollected<CXFA_Signing>(
5824 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5825 break;
5826 case XFA_Element::Script:
5827 node = cppgc::MakeGarbageCollected<CXFA_Script>(
5828 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5829 break;
5830 case XFA_Element::AddViewerPreferences:
5831 node = cppgc::MakeGarbageCollected<CXFA_AddViewerPreferences>(
5832 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5833 break;
5834 case XFA_Element::AlwaysEmbed:
5835 node = cppgc::MakeGarbageCollected<CXFA_AlwaysEmbed>(
5836 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5837 break;
5838 case XFA_Element::PasswordEdit:
5839 node = cppgc::MakeGarbageCollected<CXFA_PasswordEdit>(
5840 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5841 break;
5842 case XFA_Element::NumericEdit:
5843 node = cppgc::MakeGarbageCollected<CXFA_NumericEdit>(
5844 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5845 break;
5846 case XFA_Element::EncryptionMethod:
5847 node = cppgc::MakeGarbageCollected<CXFA_EncryptionMethod>(
5848 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5849 break;
5850 case XFA_Element::Change:
5851 node = cppgc::MakeGarbageCollected<CXFA_Change>(
5852 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5853 break;
5854 case XFA_Element::PageArea:
5855 node = cppgc::MakeGarbageCollected<CXFA_PageArea>(
5856 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5857 break;
5858 case XFA_Element::SubmitUrl:
5859 node = cppgc::MakeGarbageCollected<CXFA_SubmitUrl>(
5860 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5861 break;
5862 case XFA_Element::Oids:
5863 node = cppgc::MakeGarbageCollected<CXFA_Oids>(
5864 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5865 break;
5866 case XFA_Element::Signature:
5867 node = cppgc::MakeGarbageCollected<CXFA_Signature>(
5868 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5869 break;
5870 case XFA_Element::ADBE_JSConsole:
5871 node = cppgc::MakeGarbageCollected<CXFA_ADBE_JSConsole>(
5872 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5873 break;
5874 case XFA_Element::Caption:
5875 node = cppgc::MakeGarbageCollected<CXFA_Caption>(
5876 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5877 break;
5878 case XFA_Element::Relevant:
5879 node = cppgc::MakeGarbageCollected<CXFA_Relevant>(
5880 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5881 break;
5882 case XFA_Element::FlipLabel:
5883 node = cppgc::MakeGarbageCollected<CXFA_FlipLabel>(
5884 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5885 break;
5886 case XFA_Element::ExData:
5887 node = cppgc::MakeGarbageCollected<CXFA_ExData>(
5888 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5889 break;
5890 case XFA_Element::DayNames:
5891 node = cppgc::MakeGarbageCollected<CXFA_DayNames>(
5892 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5893 break;
5894 case XFA_Element::SoapAction:
5895 node = cppgc::MakeGarbageCollected<CXFA_SoapAction>(
5896 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5897 break;
5898 case XFA_Element::DefaultTypeface:
5899 node = cppgc::MakeGarbageCollected<CXFA_DefaultTypeface>(
5900 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5901 break;
5902 case XFA_Element::Manifest:
5903 node = cppgc::MakeGarbageCollected<CXFA_Manifest>(
5904 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5905 break;
5906 case XFA_Element::Overflow:
5907 node = cppgc::MakeGarbageCollected<CXFA_Overflow>(
5908 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5909 break;
5910 case XFA_Element::Linear:
5911 node = cppgc::MakeGarbageCollected<CXFA_Linear>(
5912 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5913 break;
5914 case XFA_Element::CurrencySymbol:
5915 node = cppgc::MakeGarbageCollected<CXFA_CurrencySymbol>(
5916 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5917 break;
5918 case XFA_Element::Delete:
5919 node = cppgc::MakeGarbageCollected<CXFA_Delete>(
5920 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5921 break;
5922 case XFA_Element::DigestMethod:
5923 node = cppgc::MakeGarbageCollected<CXFA_DigestMethod>(
5924 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5925 break;
5926 case XFA_Element::InstanceManager:
5927 node = cppgc::MakeGarbageCollected<CXFA_InstanceManager>(
5928 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5929 break;
5930 case XFA_Element::EquateRange:
5931 node = cppgc::MakeGarbageCollected<CXFA_EquateRange>(
5932 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5933 break;
5934 case XFA_Element::Medium:
5935 node = cppgc::MakeGarbageCollected<CXFA_Medium>(
5936 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5937 break;
5938 case XFA_Element::TextEdit:
5939 node = cppgc::MakeGarbageCollected<CXFA_TextEdit>(
5940 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5941 break;
5942 case XFA_Element::TemplateCache:
5943 node = cppgc::MakeGarbageCollected<CXFA_TemplateCache>(
5944 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5945 break;
5946 case XFA_Element::CompressObjectStream:
5947 node = cppgc::MakeGarbageCollected<CXFA_CompressObjectStream>(
5948 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5949 break;
5950 case XFA_Element::DataValue:
5951 node = cppgc::MakeGarbageCollected<CXFA_DataValue>(
5952 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5953 break;
5954 case XFA_Element::AccessibleContent:
5955 node = cppgc::MakeGarbageCollected<CXFA_AccessibleContent>(
5956 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5957 break;
5958 case XFA_Element::IncludeXDPContent:
5959 node = cppgc::MakeGarbageCollected<CXFA_IncludeXDPContent>(
5960 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5961 break;
5962 case XFA_Element::XmlConnection:
5963 node = cppgc::MakeGarbageCollected<CXFA_XmlConnection>(
5964 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5965 break;
5966 case XFA_Element::ValidateApprovalSignatures:
5967 node = cppgc::MakeGarbageCollected<CXFA_ValidateApprovalSignatures>(
5968 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5969 break;
5970 case XFA_Element::SignData:
5971 node = cppgc::MakeGarbageCollected<CXFA_SignData>(
5972 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5973 break;
5974 case XFA_Element::Packets:
5975 node = cppgc::MakeGarbageCollected<CXFA_Packets>(
5976 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5977 break;
5978 case XFA_Element::DatePattern:
5979 node = cppgc::MakeGarbageCollected<CXFA_DatePattern>(
5980 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5981 break;
5982 case XFA_Element::DuplexOption:
5983 node = cppgc::MakeGarbageCollected<CXFA_DuplexOption>(
5984 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5985 break;
5986 case XFA_Element::Base:
5987 node = cppgc::MakeGarbageCollected<CXFA_Base>(
5988 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5989 break;
5990 case XFA_Element::Bind:
5991 node = cppgc::MakeGarbageCollected<CXFA_Bind>(
5992 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5993 break;
5994 case XFA_Element::Compression:
5995 node = cppgc::MakeGarbageCollected<CXFA_Compression>(
5996 doc->GetHeap()->GetAllocationHandle(), doc, packet);
5997 break;
5998 case XFA_Element::User:
5999 node = cppgc::MakeGarbageCollected<CXFA_User>(
6000 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6001 break;
6002 case XFA_Element::Rectangle:
6003 node = cppgc::MakeGarbageCollected<CXFA_Rectangle>(
6004 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6005 break;
6006 case XFA_Element::EffectiveOutputPolicy:
6007 node = cppgc::MakeGarbageCollected<CXFA_EffectiveOutputPolicy>(
6008 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6009 break;
6010 case XFA_Element::ADBE_JSDebugger:
6011 node = cppgc::MakeGarbageCollected<CXFA_ADBE_JSDebugger>(
6012 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6013 break;
6014 case XFA_Element::Acrobat7:
6015 node = cppgc::MakeGarbageCollected<CXFA_Acrobat7>(
6016 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6017 break;
6018 case XFA_Element::Interactive:
6019 node = cppgc::MakeGarbageCollected<CXFA_Interactive>(
6020 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6021 break;
6022 case XFA_Element::Locale:
6023 node = cppgc::MakeGarbageCollected<CXFA_Locale>(
6024 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6025 break;
6026 case XFA_Element::CurrentPage:
6027 node = cppgc::MakeGarbageCollected<CXFA_CurrentPage>(
6028 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6029 break;
6030 case XFA_Element::Data:
6031 node = cppgc::MakeGarbageCollected<CXFA_Data>(
6032 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6033 break;
6034 case XFA_Element::Date:
6035 node = cppgc::MakeGarbageCollected<CXFA_Date>(
6036 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6037 break;
6038 case XFA_Element::Desc:
6039 node = cppgc::MakeGarbageCollected<CXFA_Desc>(
6040 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6041 break;
6042 case XFA_Element::Encrypt:
6043 node = cppgc::MakeGarbageCollected<CXFA_Encrypt>(
6044 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6045 break;
6046 case XFA_Element::Draw:
6047 node = cppgc::MakeGarbageCollected<CXFA_Draw>(
6048 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6049 break;
6050 case XFA_Element::Encryption:
6051 node = cppgc::MakeGarbageCollected<CXFA_Encryption>(
6052 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6053 break;
6054 case XFA_Element::MeridiemNames:
6055 node = cppgc::MakeGarbageCollected<CXFA_MeridiemNames>(
6056 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6057 break;
6058 case XFA_Element::Messaging:
6059 node = cppgc::MakeGarbageCollected<CXFA_Messaging>(
6060 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6061 break;
6062 case XFA_Element::Speak:
6063 node = cppgc::MakeGarbageCollected<CXFA_Speak>(
6064 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6065 break;
6066 case XFA_Element::DataGroup:
6067 node = cppgc::MakeGarbageCollected<CXFA_DataGroup>(
6068 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6069 break;
6070 case XFA_Element::Common:
6071 node = cppgc::MakeGarbageCollected<CXFA_Common>(
6072 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6073 break;
6074 case XFA_Element::Sharptext:
6075 node = cppgc::MakeGarbageCollected<CXFA_Sharptext>(
6076 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6077 break;
6078 case XFA_Element::PaginationOverride:
6079 node = cppgc::MakeGarbageCollected<CXFA_PaginationOverride>(
6080 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6081 break;
6082 case XFA_Element::Reasons:
6083 node = cppgc::MakeGarbageCollected<CXFA_Reasons>(
6084 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6085 break;
6086 case XFA_Element::SignatureProperties:
6087 node = cppgc::MakeGarbageCollected<CXFA_SignatureProperties>(
6088 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6089 break;
6090 case XFA_Element::Threshold:
6091 node = cppgc::MakeGarbageCollected<CXFA_Threshold>(
6092 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6093 break;
6094 case XFA_Element::AppearanceFilter:
6095 node = cppgc::MakeGarbageCollected<CXFA_AppearanceFilter>(
6096 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6097 break;
6098 case XFA_Element::Fill:
6099 node = cppgc::MakeGarbageCollected<CXFA_Fill>(
6100 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6101 break;
6102 case XFA_Element::Font:
6103 node = cppgc::MakeGarbageCollected<CXFA_Font>(
6104 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6105 break;
6106 case XFA_Element::Form:
6107 node = cppgc::MakeGarbageCollected<CXFA_Form>(
6108 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6109 break;
6110 case XFA_Element::MediumInfo:
6111 node = cppgc::MakeGarbageCollected<CXFA_MediumInfo>(
6112 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6113 break;
6114 case XFA_Element::Certificate:
6115 node = cppgc::MakeGarbageCollected<CXFA_Certificate>(
6116 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6117 break;
6118 case XFA_Element::Password:
6119 node = cppgc::MakeGarbageCollected<CXFA_Password>(
6120 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6121 break;
6122 case XFA_Element::RunScripts:
6123 node = cppgc::MakeGarbageCollected<CXFA_RunScripts>(
6124 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6125 break;
6126 case XFA_Element::Trace:
6127 node = cppgc::MakeGarbageCollected<CXFA_Trace>(
6128 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6129 break;
6130 case XFA_Element::Float:
6131 node = cppgc::MakeGarbageCollected<CXFA_Float>(
6132 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6133 break;
6134 case XFA_Element::RenderPolicy:
6135 node = cppgc::MakeGarbageCollected<CXFA_RenderPolicy>(
6136 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6137 break;
6138 case XFA_Element::Destination:
6139 node = cppgc::MakeGarbageCollected<CXFA_Destination>(
6140 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6141 break;
6142 case XFA_Element::Value:
6143 node = cppgc::MakeGarbageCollected<CXFA_Value>(
6144 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6145 break;
6146 case XFA_Element::Bookend:
6147 node = cppgc::MakeGarbageCollected<CXFA_Bookend>(
6148 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6149 break;
6150 case XFA_Element::ExObject:
6151 node = cppgc::MakeGarbageCollected<CXFA_ExObject>(
6152 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6153 break;
6154 case XFA_Element::OpenAction:
6155 node = cppgc::MakeGarbageCollected<CXFA_OpenAction>(
6156 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6157 break;
6158 case XFA_Element::NeverEmbed:
6159 node = cppgc::MakeGarbageCollected<CXFA_NeverEmbed>(
6160 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6161 break;
6162 case XFA_Element::BindItems:
6163 node = cppgc::MakeGarbageCollected<CXFA_BindItems>(
6164 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6165 break;
6166 case XFA_Element::Calculate:
6167 node = cppgc::MakeGarbageCollected<CXFA_Calculate>(
6168 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6169 break;
6170 case XFA_Element::Print:
6171 node = cppgc::MakeGarbageCollected<CXFA_Print>(
6172 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6173 break;
6174 case XFA_Element::Extras:
6175 node = cppgc::MakeGarbageCollected<CXFA_Extras>(
6176 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6177 break;
6178 case XFA_Element::Proto:
6179 node = cppgc::MakeGarbageCollected<CXFA_Proto>(
6180 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6181 break;
6182 case XFA_Element::DSigData:
6183 node = cppgc::MakeGarbageCollected<CXFA_DSigData>(
6184 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6185 break;
6186 case XFA_Element::Creator:
6187 node = cppgc::MakeGarbageCollected<CXFA_Creator>(
6188 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6189 break;
6190 case XFA_Element::Connect:
6191 node = cppgc::MakeGarbageCollected<CXFA_Connect>(
6192 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6193 break;
6194 case XFA_Element::Permissions:
6195 node = cppgc::MakeGarbageCollected<CXFA_Permissions>(
6196 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6197 break;
6198 case XFA_Element::ConnectionSet:
6199 node = cppgc::MakeGarbageCollected<CXFA_ConnectionSet>(
6200 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6201 break;
6202 case XFA_Element::Submit:
6203 node = cppgc::MakeGarbageCollected<CXFA_Submit>(
6204 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6205 break;
6206 case XFA_Element::Range:
6207 node = cppgc::MakeGarbageCollected<CXFA_Range>(
6208 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6209 break;
6210 case XFA_Element::Linearized:
6211 node = cppgc::MakeGarbageCollected<CXFA_Linearized>(
6212 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6213 break;
6214 case XFA_Element::Packet:
6215 node = cppgc::MakeGarbageCollected<CXFA_Packet>(
6216 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6217 break;
6218 case XFA_Element::RootElement:
6219 node = cppgc::MakeGarbageCollected<CXFA_RootElement>(
6220 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6221 break;
6222 case XFA_Element::PlaintextMetadata:
6223 node = cppgc::MakeGarbageCollected<CXFA_PlaintextMetadata>(
6224 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6225 break;
6226 case XFA_Element::NumberSymbols:
6227 node = cppgc::MakeGarbageCollected<CXFA_NumberSymbols>(
6228 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6229 break;
6230 case XFA_Element::PrintHighQuality:
6231 node = cppgc::MakeGarbageCollected<CXFA_PrintHighQuality>(
6232 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6233 break;
6234 case XFA_Element::Driver:
6235 node = cppgc::MakeGarbageCollected<CXFA_Driver>(
6236 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6237 break;
6238 case XFA_Element::IncrementalLoad:
6239 node = cppgc::MakeGarbageCollected<CXFA_IncrementalLoad>(
6240 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6241 break;
6242 case XFA_Element::SubjectDN:
6243 node = cppgc::MakeGarbageCollected<CXFA_SubjectDN>(
6244 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6245 break;
6246 case XFA_Element::CompressLogicalStructure:
6247 node = cppgc::MakeGarbageCollected<CXFA_CompressLogicalStructure>(
6248 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6249 break;
6250 case XFA_Element::IncrementalMerge:
6251 node = cppgc::MakeGarbageCollected<CXFA_IncrementalMerge>(
6252 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6253 break;
6254 case XFA_Element::Radial:
6255 node = cppgc::MakeGarbageCollected<CXFA_Radial>(
6256 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6257 break;
6258 case XFA_Element::Variables:
6259 node = cppgc::MakeGarbageCollected<CXFA_Variables>(
6260 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6261 break;
6262 case XFA_Element::TimePatterns:
6263 node = cppgc::MakeGarbageCollected<CXFA_TimePatterns>(
6264 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6265 break;
6266 case XFA_Element::EffectiveInputPolicy:
6267 node = cppgc::MakeGarbageCollected<CXFA_EffectiveInputPolicy>(
6268 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6269 break;
6270 case XFA_Element::NameAttr:
6271 node = cppgc::MakeGarbageCollected<CXFA_NameAttr>(
6272 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6273 break;
6274 case XFA_Element::Conformance:
6275 node = cppgc::MakeGarbageCollected<CXFA_Conformance>(
6276 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6277 break;
6278 case XFA_Element::Transform:
6279 node = cppgc::MakeGarbageCollected<CXFA_Transform>(
6280 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6281 break;
6282 case XFA_Element::LockDocument:
6283 node = cppgc::MakeGarbageCollected<CXFA_LockDocument>(
6284 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6285 break;
6286 case XFA_Element::BreakAfter:
6287 node = cppgc::MakeGarbageCollected<CXFA_BreakAfter>(
6288 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6289 break;
6290 case XFA_Element::Line:
6291 node = cppgc::MakeGarbageCollected<CXFA_Line>(
6292 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6293 break;
6294 case XFA_Element::Source:
6295 node = cppgc::MakeGarbageCollected<CXFA_Source>(
6296 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6297 break;
6298 case XFA_Element::Occur:
6299 node = cppgc::MakeGarbageCollected<CXFA_Occur>(
6300 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6301 break;
6302 case XFA_Element::PickTrayByPDFSize:
6303 node = cppgc::MakeGarbageCollected<CXFA_PickTrayByPDFSize>(
6304 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6305 break;
6306 case XFA_Element::MonthNames:
6307 node = cppgc::MakeGarbageCollected<CXFA_MonthNames>(
6308 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6309 break;
6310 case XFA_Element::Severity:
6311 node = cppgc::MakeGarbageCollected<CXFA_Severity>(
6312 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6313 break;
6314 case XFA_Element::GroupParent:
6315 node = cppgc::MakeGarbageCollected<CXFA_GroupParent>(
6316 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6317 break;
6318 case XFA_Element::DocumentAssembly:
6319 node = cppgc::MakeGarbageCollected<CXFA_DocumentAssembly>(
6320 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6321 break;
6322 case XFA_Element::NumberSymbol:
6323 node = cppgc::MakeGarbageCollected<CXFA_NumberSymbol>(
6324 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6325 break;
6326 case XFA_Element::Tagged:
6327 node = cppgc::MakeGarbageCollected<CXFA_Tagged>(
6328 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6329 break;
6330 case XFA_Element::Items:
6331 node = cppgc::MakeGarbageCollected<CXFA_Items>(
6332 doc->GetHeap()->GetAllocationHandle(), doc, packet);
6333 break;
6334 case XFA_Element::DataWindow:
6335 case XFA_Element::Deltas:
6336 case XFA_Element::EventPseudoModel:
6337 case XFA_Element::HostPseudoModel:
6338 case XFA_Element::LayoutPseudoModel:
6339 case XFA_Element::List:
6340 case XFA_Element::ListDuplicate:
6341 case XFA_Element::LogPseudoModel:
6342 case XFA_Element::Model:
6343 case XFA_Element::Node:
6344 case XFA_Element::NodeWithDesc:
6345 case XFA_Element::NodeWithUse:
6346 case XFA_Element::NodeWithValue:
6347 case XFA_Element::Object:
6348 case XFA_Element::SignaturePseudoModel:
6349 case XFA_Element::Tree:
6350 case XFA_Element::TreeList:
6352 // These defined elements can not be made from an XML parse. Some are
6353 // not CXFA_Node sub-classes, some are only used as intermediate classes,
6354 // and so forth.
6355 return nullptr;
6356 }
6357 if (!node || !node->IsValidInPacket(packet))
6358 return nullptr;
6359 return node;
6360}
CFX_XMLElement * ToXMLElement(CFX_XMLNode *pNode)
CFX_XMLText * ToXMLText(CFX_XMLNode *pNode)
Definition cfx_xmltext.h:38
void SetFont(RetainPtr< CFGAS_GEFont > pFont)
void SetStyles(const FDE_TextStyle &dwStyles)
void SetLineSpace(float fLineSpace)
void SetLineBreakTolerance(float fTolerance)
void SetFontSize(float fFontSize)
void SetScale(uint8_t newScale)
WideString ToWideString() const
EventParamScope(CFXJSE_Engine *pEngine, CXFA_Node *pTarget, CXFA_EventParam *pEventParam)
void SetRunAtType(XFA_AttributeValue eRunAt)
friend class EventParamScope
CFXJSE_Context::ExecutionResult RunScript(CXFA_Script::Type eScriptType, WideStringView wsScript, CXFA_Object *pThisObject)
constexpr CFX_RectF()=default
v8::Isolate * GetIsolate() const
Definition cfx_v8.h:23
void SetAttribute(const WideString &name, const WideString &value)
void RemoveAttribute(const WideString &name)
virtual Type GetType() const =0
void SetText(const WideString &wsText)
Definition cfx_xmltext.h:26
WideString GetPicture() const
Definition cxfa_bind.cpp:50
std::tuple< XFA_AttributeValue, bool, float > Get3DStyle()
Definition cxfa_box.cpp:126
XFA_AttributeValue GetPresence()
Definition cxfa_box.cpp:87
CXFA_Script * GetScriptIfExists()
float GetReserve() const
CXFA_Font * GetFontIfExists()
static constexpr XFA_AttributeValue kDefaultPlacementType
CXFA_Margin * GetMarginIfExists()
CXFA_Value * GetValueIfExists()
XFA_AttributeValue GetPlacementType()
CXFA_Node * DataMerge_CopyContainer(CXFA_Node *pTemplateNode, CXFA_Node *pFormNode, CXFA_Node *pDataScope, bool bOneInstance, bool bDataMerge, bool bUpLevel)
void DataMerge_UpdateBindingRelations(CXFA_Node *pFormUpdateRoot)
XFA_VERSION GetCurVersionMode() const
CFXJSE_Engine * GetScriptContext() const
bool is_scripting() const
CXFA_Object * GetXFAObject(XFA_HashCode wsNodeNameHash)
XFA_EVENTTYPE m_eType
CXFA_EventParam(XFA_EVENTTYPE type)
XFA_Element GetEventType() const
CXFA_Script * GetScriptIfExists()
virtual WideString GetAppTitle() const =0
virtual int32_t MsgBox(const WideString &wsMessage, const WideString &wsTitle, uint32_t dwIconType, uint32_t dwButtonType)=0
CallbackIface * GetAppProvider() const
Definition cxfa_ffapp.h:144
CXFA_FontMgr * GetXFAFontMgr() const
Definition cxfa_ffapp.h:146
LayoutStatus GetLayoutStatus() const
void AddValidateNode(CXFA_Node *node)
CXFA_FFDoc * GetDoc() const
void AddNullTestMsg(const WideString &msg)
void UpdateUIDisplay(CXFA_Node *pNode, CXFA_FFWidget *pExcept)
CXFA_Document * GetXFADoc() const
Definition cxfa_ffdoc.h:167
CXFA_FFApp * GetApp() const
Definition cxfa_ffdoc.h:168
RetainPtr< IFX_SeekableReadStream > OpenLinkedFile(const WideString &wsLink)
void OnValueChanged(CXFA_Node *pSender, XFA_Attribute eAttr, CXFA_Node *pParentNode, CXFA_Node *pWidgetNode)
void OnNodeReady(CXFA_Node *pNode)
void OnChildAdded(CXFA_Node *pSender)
void OnContainerChanged()
virtual CXFA_TextEditData * AsTextEditData()
CXFA_FieldLayoutData * AsFieldLayoutData() override
std::vector< float > m_FieldSplitArray
~CXFA_FieldLayoutData() override=default
void Trace(cppgc::Visitor *visitor) const override
cppgc::Member< CXFA_TextLayout > m_pCapTextLayout
bool LoadCaption(CXFA_FFDoc *doc, CXFA_Node *pNode)
CXFA_FieldLayoutData()=default
cppgc::Member< CXFA_TextProvider > m_pCapTextProvider
std::unique_ptr< CFDE_TextOut > m_pTextOut
virtual CXFA_ImageEditData * AsImageEditData()
RetainPtr< CFGAS_GEFont > GetFont(CXFA_FFDoc *hDoc, const WideString &wsFontFamily, uint32_t dwFontStyles)
WideString GetTypeface()
bool IsItalic()
FX_ARGB GetColor() const
bool IsBold()
float GetFontSize() const
void SetBitmap(RetainPtr< CFX_DIBitmap > pBitmap)
bool LoadImageData(CXFA_FFDoc *doc, CXFA_Node *pNode)
CFX_Size GetDpi() const
CXFA_ImageEditData * AsImageEditData() override
~CXFA_ImageEditData() override=default
RetainPtr< CFX_DIBitmap > GetBitmap()
CXFA_ImageLayoutData * AsImageLayoutData() override
bool LoadImageData(CXFA_FFDoc *doc, CXFA_Node *pNode)
RetainPtr< CFX_DIBitmap > GetBitmap()
CFX_Size GetDpi() const
void SetBitmap(RetainPtr< CFX_DIBitmap > pBitmap)
~CXFA_ImageLayoutData() override=default
WideString GetContent()
void SetTransferEncoding(XFA_AttributeValue iTransferEncoding)
void SetContentType(const WideString &wsContentType)
void SetHref(const WideString &wsHref)
WideString GetContentType()
XFA_AttributeValue GetTransferEncoding()
WideString GetHref()
CXFA_LocaleValue(ValueType dwType, const WideString &wsValue, const WideString &wsFormat, GCedLocaleIface *pLocale, CXFA_LocaleMgr *pLocaleMgr)
const WideString & GetValue() const
CXFA_LocaleValue(ValueType eType, const WideString &wsValue, CXFA_LocaleMgr *pLocaleMgr)
bool FormatPatterns(WideString &wsResult, const WideString &wsFormat, GCedLocaleIface *pLocale, XFA_ValuePicture eValueType) const
CXFA_LocaleValue & operator=(const CXFA_LocaleValue &that)
bool ValidateValue(const WideString &wsValue, const WideString &wsPattern, GCedLocaleIface *pLocale, WideString *pMatchFormat)
ValueType GetType() const
float GetBottomInset() const
float GetLeftInset() const
float GetTopInset() const
float GetRightInset() const
CXFA_Measurement(float fValue, XFA_Unit eUnit)
float ToUnit(XFA_Unit eUnit) const
CFX_XMLNode * GetXMLMappingNode() const
Definition cxfa_node.h:184
FX_ARGB GetTextColor() const
void RemoveChildAndNotify(CXFA_Node *pNode, bool bNotify)
CXFA_Caption * GetCaptionIfExists() const
bool HasButtonDown() const
XFA_Attribute GetAttribute(size_t i) const
CXFA_Font * GetOrCreateFontIfPossible()
float GetFontSize() const
CXFA_Node * GetFirstContainerChild() const
CXFA_Value * GetFormValueIfExists() const
absl::optional< bool > GetDefaultBoolean(XFA_Attribute attr) const
bool IsListBox()
bool LoadCaption(CXFA_FFDoc *doc)
CXFA_Node(CXFA_Document *pDoc, XFA_PacketType ePacket, Mask< XFA_XDPPACKET > validPackets, XFA_ObjectType oType, XFA_Element eType, pdfium::span< const PropertyData > properties, pdfium::span< const AttributeData > attributes, CJX_Object *js_object)
bool IsVerticalScrollPolicyOff()
bool LoadLayoutImage(CXFA_FFDoc *doc)
~CXFA_Node() override
bool HasProperty(XFA_Element property) const
WideString NormalizeNumStr(const WideString &wsValue)
int32_t GetFracDigits() const
WideString GetValue(XFA_ValuePicture eValueType)
bool LoadEditImage(CXFA_FFDoc *doc)
CXFA_Node * GetExclGroupIfExists()
int32_t GetLeadDigits() const
void Trace(cppgc::Visitor *visitor) const override
CXFA_Occur * GetOccurIfExists()
bool IsOpenAccess() const
void SetNodeAndDescendantsUnused()
CXFA_Node * GetFirstChildByName(uint32_t dwNodeNameHash) const
bool SetValue(XFA_ValuePicture eValueType, const WideString &wsValue)
std::vector< CXFA_Event * > GetEventByActivity(XFA_AttributeValue iActivity, bool bIsFormReady)
size_t GetIndexByClassName()
void SetTemplateNode(CXFA_Node *pTemplateNode)
std::vector< CXFA_Node * > GetBindItemsCopy() const
WideString GetRawValue() const
bool IsProperty() const
CXFA_Node * GetContainerParent() const
CXFA_Node * Clone(bool bRecursive)
CXFA_Node * GetNextContainerSibling() const
XFA_AttributeValue GetIntact()
void InsertChildAndNotify(CXFA_Node *pNode, CXFA_Node *pBeforeNode)
float GetCheckButtonSize()
size_t CountChoiceListItems(bool bSaveValue)
CXFA_Validate * GetValidateIfExists() const
bool IsAttributeInXML()
int32_t GetSelectedItem(int32_t nIndex)
CXFA_Node * GetFirstChildByName(WideStringView wsNodeName) const
CXFA_TextLayout * GetTextLayout()
int32_t GetRotate() const
absl::optional< XFA_AttributeValue > GetDefaultEnum(XFA_Attribute attr) const
void SetDataDescriptionNode(CXFA_Node *pDataDescriptionNode)
void SetItemState(int32_t nIndex, bool bSelected, bool bNotify, bool bScriptModify)
CXFA_Node * GetNextSameNameSibling(uint32_t dwNodeNameHash) const
CXFA_Para * GetParaIfExists() const
CXFA_Node * GetInstanceMgrOfSubform()
RetainPtr< CFX_DIBitmap > GetLayoutImage()
static CXFA_Node * Create(CXFA_Document *doc, XFA_Element element, XFA_PacketType packet)
CXFA_Node * CreateInstanceIfPossible(bool bDataMerge)
virtual XFA_Element GetValueNodeType() const
WideString NumericLimit(const WideString &wsValue)
void SetSelectedMemberByValue(WideStringView wsValue, bool bNotify, bool bScriptModify, bool bSyncData)
void InsertItem(const WideString &wsLabel, const WideString &wsValue, bool bNotify)
void SetBindingNode(CXFA_Node *node)
CXFA_Node * GetSelectedMember()
CXFA_Node * GetOrCreateProperty(int32_t index, XFA_Element eProperty)
void SendAttributeChangeMessage(XFA_Attribute eAttribute, bool bScriptModify)
void AddBindItem(CXFA_Node *pFormNode)
bool IsHorizontalScrollPolicyOff()
WideString GetFormatDataValue(const WideString &wsValue)
CXFA_Calculate * GetCalculateIfExists() const
float GetLineHeight() const
absl::optional< float > TryWidth()
bool HasBindItems() const
Definition cxfa_node.h:229
bool DeleteItem(int32_t nIndex, bool bNotify, bool bScriptModify)
void SetFlag(XFA_NodeFlag dwFlag)
XFA_EventError ExecuteScript(CXFA_FFDocView *pDocView, CXFA_Script *script, CXFA_EventParam *pEventParam)
bool IsChoiceListMultiSelect()
std::vector< CXFA_Node * > GetNodeListWithFilter(Mask< XFA_NodeFilter > dwFilter)
absl::optional< int32_t > GetDefaultInteger(XFA_Attribute attr) const
CXFA_Node * GetOneChildOfClass(WideStringView wsClass)
CXFA_Node * CreateSamePacketNode(XFA_Element eType)
void SetPreNull(bool val)
Definition cxfa_node.h:322
std::vector< int32_t > GetSelectedItems()
void UpdateNameHash()
bool GetItemState(int32_t nIndex)
void ClearFlag(XFA_NodeFlag dwFlag)
RetainPtr< CFX_DIBitmap > GetEditImage()
WideString GetNameExpression()
bool HasAttribute(XFA_Attribute attr) const
uint8_t PropertyOccurrenceCount(XFA_Element property) const
int32_t CountSelectedItems()
CXFA_Node * GetTemplateNodeIfExists() const
WideString GetNormalizeDataValue(const WideString &wsValue)
absl::optional< WideString > GetDefaultCData(XFA_Attribute attr) const
size_t GetIndex(bool bIsProperty, bool bIsClassIndex)
CXFA_Border * GetOrCreateBorderIfPossible()
std::vector< CXFA_Node * > GetSiblings(bool bIsClassName)
absl::optional< WideString > GetChoiceListItem(int32_t nIndex, bool bSaveValue)
CFX_Size GetLayoutImageDpi() const
CFX_RectF GetUIMargin()
std::vector< WideString > GetChoiceListItems(bool bSaveValue)
CXFA_Node * GetExclGroupFirstMember()
CXFA_Node * GetDataDescriptionNode()
CXFA_Node * GetPrevContainerSibling() const
void SetEditImage(RetainPtr< CFX_DIBitmap > newImage)
CXFA_Node * GetOneChildNamed(WideStringView wsName)
CXFA_Node * GetBindData()
uint32_t GetNameHash() const
Definition cxfa_node.h:190
GCedLocaleIface * GetLocale()
CXFA_Node * GetExclGroupNextMember(CXFA_Node *pNode)
CFX_XMLNode * CreateXMLMappingNode()
void SetXMLMappingNode(CFX_XMLNode *node)
Definition cxfa_node.h:183
CXFA_Node * SetSelectedMember(WideStringView wsName)
void SetToXML(const WideString &value)
bool IsUserInteractive() const
Definition cxfa_node.h:162
std::pair< CXFA_Node *, int32_t > GetProperty(int32_t index, XFA_Element eProperty) const
CXFA_Node * CloneTemplateToForm(bool bRecursive)
void ClearAllSelections()
bool HasButtonRollover() const
bool IsUnnamed() const
Definition cxfa_node.h:191
CXFA_Font * GetFontIfExists() const
bool IsNull() const
Definition cxfa_node.h:323
CXFA_Node * GetContainerNode()
bool RemoveBindItem(CXFA_Node *pFormNode)
absl::optional< WideString > GetLocaleName()
WideString GetPictureContent(XFA_ValuePicture ePicture)
void SetSelectedItems(const std::vector< int32_t > &iSelArray, bool bNotify, bool bScriptModify, bool bSyncData)
CXFA_TextLayout * GetCaptionTextLayout()
XFA_EventError ProcessEvent(CXFA_FFDocView *pDocView, XFA_AttributeValue iActivity, CXFA_EventParam *pEventParam)
bool IsMultiLine()
std::vector< WideString > GetSelectedItemsValue()
void InsertChildAndNotify(int32_t index, CXFA_Node *pNode)
absl::optional< float > FindSplitPos(CXFA_FFDocView *pDocView, size_t szBlockIndex, float fCalcHeight)
CFX_Size GetEditImageDpi() const
bool IsWidgetReady() const
Definition cxfa_node.h:327
bool HasPropertyFlag(XFA_Element property, XFA_PropertyFlag flag) const
absl::optional< CXFA_Measurement > GetDefaultMeasurement(XFA_Attribute attr) const
CXFA_Validate * GetOrCreateValidateIfPossible()
BoolScriptResult ExecuteBoolScript(CXFA_FFDocView *pDocView, CXFA_Script *script, CXFA_EventParam *pEventParam)
bool HasBindItem() const
void ResetData()
size_t CountChildren(XFA_Element eType, bool bOnlyChild)
XFA_AttributeType GetAttributeType(XFA_Attribute type) const
RetainPtr< CFGAS_GEFont > GetFGASFont(CXFA_FFDoc *doc)
CXFA_Node * GetUIChildNode()
XFA_PacketType GetPacketType() const
Definition cxfa_node.h:146
CXFA_Border * GetUIBorder()
void SetCheckState(XFA_CheckState eCheckState)
XFA_FFWidgetType GetFFWidgetType()
CXFA_Margin * GetMarginIfExists() const
void InsertItem(CXFA_Node *pNewInstance, int32_t iPos, int32_t iCount, bool bMoveDataBindingNodes)
std::vector< CXFA_Node * > GetNodeListForType(XFA_Element eTypeFilter)
XFA_EventError ProcessValidate(CXFA_FFDocView *pDocView, int32_t iFlags)
bool IsChoiceListAllowTextEntry()
void SetLayoutImage(RetainPtr< CFX_DIBitmap > newImage)
WideString GetItemValue(WideStringView wsLabel)
CXFA_Node * GetItemIfExists(int32_t iIndex)
bool IsChoiceListCommitOnSelect()
XFA_EventError ProcessCalculate(CXFA_FFDocView *pDocView)
void StartWidgetLayout(CXFA_FFDoc *doc, float *pCalcWidth, float *pCalcHeight)
virtual XFA_FFWidgetType GetDefaultFFWidgetType() const
bool PresenceRequiresSpace() const
void SetIsNull(bool val)
Definition cxfa_node.h:324
bool IsTransparent() const
bool IsAncestorOf(const CXFA_Node *that) const
void RemoveItem(CXFA_Node *pRemoveInstance, bool bRemoveDataBinding)
XFA_CheckState GetCheckState()
bool IsNeedSavingXMLNode() const
std::pair< XFA_Element, int32_t > GetMaxChars() const
absl::optional< int32_t > GetNumberOfCells()
void SetInitializedFlagAndNotify()
bool IsInitialized() const
Definition cxfa_node.h:161
size_t GetIndexByName()
int32_t GetCount()
CXFA_Node * GetModelNode()
bool IsRadioButton()
CXFA_Border * GetBorderIfExists() const
XFA_Element GetElementType() const
Definition cxfa_object.h:91
uint32_t GetClassHashCode() const
Definition cxfa_object.h:93
CXFA_Document * GetDocument() const
Definition cxfa_object.h:48
virtual void Trace(cppgc::Visitor *visitor) const
CXFA_Object(CXFA_Document *pDocument, XFA_ObjectType objectType, XFA_Element eType, CJX_Object *jsObject)
bool IsContainerNode() const
Definition cxfa_object.h:69
float GetMarginLeft()
Definition cxfa_para.cpp:73
float GetTextIndent()
Definition cxfa_para.cpp:89
float GetSpaceAbove()
Definition cxfa_para.cpp:81
float GetLineHeight()
Definition cxfa_para.cpp:69
XFA_AttributeValue GetVerticalAlign()
Definition cxfa_para.cpp:63
float GetSpaceBelow()
Definition cxfa_para.cpp:85
XFA_AttributeValue GetRunAt()
Type GetContentType()
WideString GetExpression()
bool IsVisible()
float GetThickness() const
CXFA_TextEditData()=default
CXFA_TextEditData * AsTextEditData() override
~CXFA_TextEditData() override=default
CXFA_TextProvider * GetTextProvider() const
CXFA_TextLayoutData * AsTextLayoutData() override
CXFA_TextLayout * GetTextLayout() const
~CXFA_TextLayoutData() override=default
void Trace(cppgc::Visitor *visitor) const override
void LoadText(CXFA_FFDoc *doc, CXFA_Node *pNode)
float StartLayout(float fWidth)
CFX_SizeF CalcSize(const CFX_SizeF &minSize, const CFX_SizeF &maxSize)
float DoLayout(float fTextHeight)
WideString GetContent() const
Definition cxfa_text.cpp:47
bool IsAOneOfChild(CXFA_Node *child) const
Definition cxfa_ui.cpp:52
XFA_AttributeValue GetNullTest()
XFA_AttributeValue GetFormatTest()
WideString GetNullMessageText()
WideString GetScriptMessageText()
CXFA_Script * GetScriptIfExists()
XFA_AttributeValue GetScriptTest()
WideString GetPicture() const
WideString GetFormatMessageText()
CXFA_Text * GetTextIfExists() const
WideString GetChildValueContent() const
CXFA_Image * GetImageIfExists() const
float GetWidgetHeight() const
virtual CXFA_TextLayoutData * AsTextLayoutData()
void SetWidgetHeight(float height)
virtual CXFA_ImageLayoutData * AsImageLayoutData()
virtual void Trace(cppgc::Visitor *visitor) const
virtual ~CXFA_WidgetLayoutData()=default
virtual CXFA_FieldLayoutData * AsFieldLayoutData()
CXFA_WidgetLayoutData()=default
virtual WideString GetDecimalSymbol() const =0
virtual WideString GetDatePattern(DateTimeSubcategory eType) const =0
virtual WideString GetName() const =0
virtual WideString GetTimePattern(DateTimeSubcategory eType) const =0
virtual WideString GetGroupingSymbol() const =0
virtual WideString GetMinusSymbol() const =0
bool IsEmpty() const
Definition bytestring.h:119
WideString & operator+=(const WideString &str)
static WideString Format(const wchar_t *pFormat,...)
WideString & operator=(WideString &&that) noexcept
WideString & operator+=(const wchar_t *str)
WideString & operator+=(wchar_t ch)
void TrimLeft(wchar_t target)
CharType operator[](const size_t index) const
Definition widestring.h:146
bool IsEmpty() const
Definition widestring.h:118
const wchar_t * c_str() const
Definition widestring.h:81
WideString(const WideString &other)
bool operator!=(const WideString &other) const
Definition widestring.h:140
WideString & operator=(const WideString &that)
static WideString FromASCII(ByteStringView str)
const_iterator end() const
Definition widestring.h:98
const_iterator begin() const
Definition widestring.h:97
CharType Back() const
Definition widestring.h:152
bool EqualsASCII(ByteStringView that) const
Definition widestring.h:216
ByteString ToDefANSI() const
XFA_VERSION
@ XFA_VERSION_208
@ XFA_EVENT_InitCalculate
@ XFA_EVENT_Calculate
@ XFA_EVENT_Validate
constexpr float kXFAWidgetPrecision
XFA_FFWidgetType
XFA_PropertyFlag
Definition cxfa_node.h:88
XFA_NodeFilter
Definition cxfa_node.h:58
XFA_NodeFlag
Definition cxfa_node.h:77
XFA_ValuePicture
Definition cxfa_node.h:70
XFA_CheckState
Definition cxfa_node.h:64
XFA_ObjectType
Definition cxfa_object.h:21
CXFA_Node * ToNode(CXFA_Object *pObj)
bool FXSYS_IsDecimalDigit(wchar_t c)
#define FXFONT_ITALIC
Definition fx_font.h:33
#define FXFONT_FORCE_BOLD
Definition fx_font.h:36
AlertIcon
Definition fxfa.h:20
AlertButton
Definition fxfa.h:11
XFA_EventError
Definition fxfa.h:54
AlertReturn
Definition fxfa.h:30
XFA_Unit
Definition fxfa_basic.h:91
XFA_AttributeType
Definition fxfa_basic.h:83
XFA_Attribute
Definition fxfa_basic.h:67
XFA_XDPPACKET
Definition fxfa_basic.h:51
@ XFA_HASHCODE_Config
Definition fxfa_basic.h:15
@ XFA_HASHCODE_Form
Definition fxfa_basic.h:22
@ XFA_HASHCODE_Record
Definition fxfa_basic.h:31
XFA_Element
Definition fxfa_basic.h:75
XFA_AttributeValue
Definition fxfa_basic.h:60
XFA_PacketType
Definition fxfa_basic.h:44
#define CONSTRUCT_VIA_MAKE_GARBAGE_COLLECTED
Definition heap.h:32
Definition heap.h:12
WideString operator+(const WideString &str1, const WideString &str2)
Definition widestring.h:269
WideString operator+(const wchar_t *str1, const WideString &str2)
Definition widestring.h:281
WideString operator+(const WideString &str1, const wchar_t *str2)
Definition widestring.h:278
#define CHECK(cvref)
XFA_AttributeType type
Definition cxfa_node.h:111
UNOWNED_PTR_EXCLUSION void * default_value
Definition cxfa_node.h:112
XFA_EventError xfa_event_result
Definition cxfa_node.h:116
bool last_line_height_
Definition cfde_data.h:31
bool line_wrap_
Definition cfde_data.h:30
void XFA_EventErrorAccumulate(XFA_EventError *pAcc, XFA_EventError eNew)
CXFA_LocaleValue XFA_GetLocaleValue(const CXFA_Node *pNode)