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