2
0

template.js 168 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915
  1. /**
  2. * @licstart The following is the entire license notice for the
  3. * JavaScript code in this page
  4. *
  5. * Copyright 2022 Mozilla Foundation
  6. *
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. *
  19. * @licend The above is the entire license notice for the
  20. * JavaScript code in this page
  21. */
  22. "use strict";
  23. Object.defineProperty(exports, "__esModule", {
  24. value: true
  25. });
  26. exports.Value = exports.Text = exports.TemplateNamespace = exports.Template = exports.SetProperty = exports.Items = exports.Field = exports.BindItems = void 0;
  27. var _xfa_object = require("./xfa_object.js");
  28. var _namespaces = require("./namespaces.js");
  29. var _layout = require("./layout.js");
  30. var _html_utils = require("./html_utils.js");
  31. var _utils = require("./utils.js");
  32. var _util = require("../../shared/util.js");
  33. var _fonts = require("./fonts.js");
  34. var _core_utils = require("../core_utils.js");
  35. var _som = require("./som.js");
  36. const TEMPLATE_NS_ID = _namespaces.NamespaceIds.template.id;
  37. const SVG_NS = "http://www.w3.org/2000/svg";
  38. const MAX_ATTEMPTS_FOR_LRTB_LAYOUT = 2;
  39. const MAX_EMPTY_PAGES = 3;
  40. const DEFAULT_TAB_INDEX = 5000;
  41. const HEADING_PATTERN = /^H(\d+)$/;
  42. const MIMES = new Set(["image/gif", "image/jpeg", "image/jpg", "image/pjpeg", "image/png", "image/apng", "image/x-png", "image/bmp", "image/x-ms-bmp", "image/tiff", "image/tif", "application/octet-stream"]);
  43. const IMAGES_HEADERS = [[[0x42, 0x4d], "image/bmp"], [[0xff, 0xd8, 0xff], "image/jpeg"], [[0x49, 0x49, 0x2a, 0x00], "image/tiff"], [[0x4d, 0x4d, 0x00, 0x2a], "image/tiff"], [[0x47, 0x49, 0x46, 0x38, 0x39, 0x61], "image/gif"], [[0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a], "image/png"]];
  44. function getBorderDims(node) {
  45. if (!node || !node.border) {
  46. return {
  47. w: 0,
  48. h: 0
  49. };
  50. }
  51. const borderExtra = node.border[_xfa_object.$getExtra]();
  52. if (!borderExtra) {
  53. return {
  54. w: 0,
  55. h: 0
  56. };
  57. }
  58. return {
  59. w: borderExtra.widths[0] + borderExtra.widths[2] + borderExtra.insets[0] + borderExtra.insets[2],
  60. h: borderExtra.widths[1] + borderExtra.widths[3] + borderExtra.insets[1] + borderExtra.insets[3]
  61. };
  62. }
  63. function hasMargin(node) {
  64. return node.margin && (node.margin.topInset || node.margin.rightInset || node.margin.bottomInset || node.margin.leftInset);
  65. }
  66. function _setValue(templateNode, value) {
  67. if (!templateNode.value) {
  68. const nodeValue = new Value({});
  69. templateNode[_xfa_object.$appendChild](nodeValue);
  70. templateNode.value = nodeValue;
  71. }
  72. templateNode.value[_xfa_object.$setValue](value);
  73. }
  74. function* getContainedChildren(node) {
  75. for (const child of node[_xfa_object.$getChildren]()) {
  76. if (child instanceof SubformSet) {
  77. yield* child[_xfa_object.$getContainedChildren]();
  78. continue;
  79. }
  80. yield child;
  81. }
  82. }
  83. function isRequired(node) {
  84. return node.validate && node.validate.nullTest === "error";
  85. }
  86. function setTabIndex(node) {
  87. while (node) {
  88. if (!node.traversal) {
  89. node[_xfa_object.$tabIndex] = node[_xfa_object.$getParent]()[_xfa_object.$tabIndex];
  90. return;
  91. }
  92. if (node[_xfa_object.$tabIndex]) {
  93. return;
  94. }
  95. let next = null;
  96. for (const child of node.traversal[_xfa_object.$getChildren]()) {
  97. if (child.operation === "next") {
  98. next = child;
  99. break;
  100. }
  101. }
  102. if (!next || !next.ref) {
  103. node[_xfa_object.$tabIndex] = node[_xfa_object.$getParent]()[_xfa_object.$tabIndex];
  104. return;
  105. }
  106. const root = node[_xfa_object.$getTemplateRoot]();
  107. node[_xfa_object.$tabIndex] = ++root[_xfa_object.$tabIndex];
  108. const ref = root[_xfa_object.$searchNode](next.ref, node);
  109. if (!ref) {
  110. return;
  111. }
  112. node = ref[0];
  113. }
  114. }
  115. function applyAssist(obj, attributes) {
  116. const assist = obj.assist;
  117. if (assist) {
  118. const assistTitle = assist[_xfa_object.$toHTML]();
  119. if (assistTitle) {
  120. attributes.title = assistTitle;
  121. }
  122. const role = assist.role;
  123. const match = role.match(HEADING_PATTERN);
  124. if (match) {
  125. const ariaRole = "heading";
  126. const ariaLevel = match[1];
  127. attributes.role = ariaRole;
  128. attributes["aria-level"] = ariaLevel;
  129. }
  130. }
  131. if (obj.layout === "table") {
  132. attributes.role = "table";
  133. } else if (obj.layout === "row") {
  134. attributes.role = "row";
  135. } else {
  136. const parent = obj[_xfa_object.$getParent]();
  137. if (parent.layout === "row") {
  138. if (parent.assist && parent.assist.role === "TH") {
  139. attributes.role = "columnheader";
  140. } else {
  141. attributes.role = "cell";
  142. }
  143. }
  144. }
  145. }
  146. function ariaLabel(obj) {
  147. if (!obj.assist) {
  148. return null;
  149. }
  150. const assist = obj.assist;
  151. if (assist.speak && assist.speak[_xfa_object.$content] !== "") {
  152. return assist.speak[_xfa_object.$content];
  153. }
  154. if (assist.toolTip) {
  155. return assist.toolTip[_xfa_object.$content];
  156. }
  157. return null;
  158. }
  159. function valueToHtml(value) {
  160. return _utils.HTMLResult.success({
  161. name: "div",
  162. attributes: {
  163. class: ["xfaRich"],
  164. style: Object.create(null)
  165. },
  166. children: [{
  167. name: "span",
  168. attributes: {
  169. style: Object.create(null)
  170. },
  171. value
  172. }]
  173. });
  174. }
  175. function setFirstUnsplittable(node) {
  176. const root = node[_xfa_object.$getTemplateRoot]();
  177. if (root[_xfa_object.$extra].firstUnsplittable === null) {
  178. root[_xfa_object.$extra].firstUnsplittable = node;
  179. root[_xfa_object.$extra].noLayoutFailure = true;
  180. }
  181. }
  182. function unsetFirstUnsplittable(node) {
  183. const root = node[_xfa_object.$getTemplateRoot]();
  184. if (root[_xfa_object.$extra].firstUnsplittable === node) {
  185. root[_xfa_object.$extra].noLayoutFailure = false;
  186. }
  187. }
  188. function handleBreak(node) {
  189. if (node[_xfa_object.$extra]) {
  190. return false;
  191. }
  192. node[_xfa_object.$extra] = Object.create(null);
  193. if (node.targetType === "auto") {
  194. return false;
  195. }
  196. const root = node[_xfa_object.$getTemplateRoot]();
  197. let target = null;
  198. if (node.target) {
  199. target = root[_xfa_object.$searchNode](node.target, node[_xfa_object.$getParent]());
  200. if (!target) {
  201. return false;
  202. }
  203. target = target[0];
  204. }
  205. const {
  206. currentPageArea,
  207. currentContentArea
  208. } = root[_xfa_object.$extra];
  209. if (node.targetType === "pageArea") {
  210. if (!(target instanceof PageArea)) {
  211. target = null;
  212. }
  213. if (node.startNew) {
  214. node[_xfa_object.$extra].target = target || currentPageArea;
  215. return true;
  216. } else if (target && target !== currentPageArea) {
  217. node[_xfa_object.$extra].target = target;
  218. return true;
  219. }
  220. return false;
  221. }
  222. if (!(target instanceof ContentArea)) {
  223. target = null;
  224. }
  225. const pageArea = target && target[_xfa_object.$getParent]();
  226. let index;
  227. let nextPageArea = pageArea;
  228. if (node.startNew) {
  229. if (target) {
  230. const contentAreas = pageArea.contentArea.children;
  231. const indexForCurrent = contentAreas.indexOf(currentContentArea);
  232. const indexForTarget = contentAreas.indexOf(target);
  233. if (indexForCurrent !== -1 && indexForCurrent < indexForTarget) {
  234. nextPageArea = null;
  235. }
  236. index = indexForTarget - 1;
  237. } else {
  238. index = currentPageArea.contentArea.children.indexOf(currentContentArea);
  239. }
  240. } else if (target && target !== currentContentArea) {
  241. const contentAreas = pageArea.contentArea.children;
  242. index = contentAreas.indexOf(target) - 1;
  243. nextPageArea = pageArea === currentPageArea ? null : pageArea;
  244. } else {
  245. return false;
  246. }
  247. node[_xfa_object.$extra].target = nextPageArea;
  248. node[_xfa_object.$extra].index = index;
  249. return true;
  250. }
  251. function handleOverflow(node, extraNode, space) {
  252. const root = node[_xfa_object.$getTemplateRoot]();
  253. const saved = root[_xfa_object.$extra].noLayoutFailure;
  254. const savedMethod = extraNode[_xfa_object.$getSubformParent];
  255. extraNode[_xfa_object.$getSubformParent] = () => node;
  256. root[_xfa_object.$extra].noLayoutFailure = true;
  257. const res = extraNode[_xfa_object.$toHTML](space);
  258. node[_xfa_object.$addHTML](res.html, res.bbox);
  259. root[_xfa_object.$extra].noLayoutFailure = saved;
  260. extraNode[_xfa_object.$getSubformParent] = savedMethod;
  261. }
  262. class AppearanceFilter extends _xfa_object.StringObject {
  263. constructor(attributes) {
  264. super(TEMPLATE_NS_ID, "appearanceFilter");
  265. this.id = attributes.id || "";
  266. this.type = (0, _utils.getStringOption)(attributes.type, ["optional", "required"]);
  267. this.use = attributes.use || "";
  268. this.usehref = attributes.usehref || "";
  269. }
  270. }
  271. class Arc extends _xfa_object.XFAObject {
  272. constructor(attributes) {
  273. super(TEMPLATE_NS_ID, "arc", true);
  274. this.circular = (0, _utils.getInteger)({
  275. data: attributes.circular,
  276. defaultValue: 0,
  277. validate: x => x === 1
  278. });
  279. this.hand = (0, _utils.getStringOption)(attributes.hand, ["even", "left", "right"]);
  280. this.id = attributes.id || "";
  281. this.startAngle = (0, _utils.getFloat)({
  282. data: attributes.startAngle,
  283. defaultValue: 0,
  284. validate: x => true
  285. });
  286. this.sweepAngle = (0, _utils.getFloat)({
  287. data: attributes.sweepAngle,
  288. defaultValue: 360,
  289. validate: x => true
  290. });
  291. this.use = attributes.use || "";
  292. this.usehref = attributes.usehref || "";
  293. this.edge = null;
  294. this.fill = null;
  295. }
  296. [_xfa_object.$toHTML]() {
  297. const edge = this.edge || new Edge({});
  298. const edgeStyle = edge[_xfa_object.$toStyle]();
  299. const style = Object.create(null);
  300. if (this.fill && this.fill.presence === "visible") {
  301. Object.assign(style, this.fill[_xfa_object.$toStyle]());
  302. } else {
  303. style.fill = "transparent";
  304. }
  305. style.strokeWidth = (0, _html_utils.measureToString)(edge.presence === "visible" ? edge.thickness : 0);
  306. style.stroke = edgeStyle.color;
  307. let arc;
  308. const attributes = {
  309. xmlns: SVG_NS,
  310. style: {
  311. width: "100%",
  312. height: "100%",
  313. overflow: "visible"
  314. }
  315. };
  316. if (this.sweepAngle === 360) {
  317. arc = {
  318. name: "ellipse",
  319. attributes: {
  320. xmlns: SVG_NS,
  321. cx: "50%",
  322. cy: "50%",
  323. rx: "50%",
  324. ry: "50%",
  325. style
  326. }
  327. };
  328. } else {
  329. const startAngle = this.startAngle * Math.PI / 180;
  330. const sweepAngle = this.sweepAngle * Math.PI / 180;
  331. const largeArc = this.sweepAngle > 180 ? 1 : 0;
  332. const [x1, y1, x2, y2] = [50 * (1 + Math.cos(startAngle)), 50 * (1 - Math.sin(startAngle)), 50 * (1 + Math.cos(startAngle + sweepAngle)), 50 * (1 - Math.sin(startAngle + sweepAngle))];
  333. arc = {
  334. name: "path",
  335. attributes: {
  336. xmlns: SVG_NS,
  337. d: `M ${x1} ${y1} A 50 50 0 ${largeArc} 0 ${x2} ${y2}`,
  338. vectorEffect: "non-scaling-stroke",
  339. style
  340. }
  341. };
  342. Object.assign(attributes, {
  343. viewBox: "0 0 100 100",
  344. preserveAspectRatio: "none"
  345. });
  346. }
  347. const svg = {
  348. name: "svg",
  349. children: [arc],
  350. attributes
  351. };
  352. const parent = this[_xfa_object.$getParent]()[_xfa_object.$getParent]();
  353. if (hasMargin(parent)) {
  354. return _utils.HTMLResult.success({
  355. name: "div",
  356. attributes: {
  357. style: {
  358. display: "inline",
  359. width: "100%",
  360. height: "100%"
  361. }
  362. },
  363. children: [svg]
  364. });
  365. }
  366. svg.attributes.style.position = "absolute";
  367. return _utils.HTMLResult.success(svg);
  368. }
  369. }
  370. class Area extends _xfa_object.XFAObject {
  371. constructor(attributes) {
  372. super(TEMPLATE_NS_ID, "area", true);
  373. this.colSpan = (0, _utils.getInteger)({
  374. data: attributes.colSpan,
  375. defaultValue: 1,
  376. validate: n => n >= 1 || n === -1
  377. });
  378. this.id = attributes.id || "";
  379. this.name = attributes.name || "";
  380. this.relevant = (0, _utils.getRelevant)(attributes.relevant);
  381. this.use = attributes.use || "";
  382. this.usehref = attributes.usehref || "";
  383. this.x = (0, _utils.getMeasurement)(attributes.x, "0pt");
  384. this.y = (0, _utils.getMeasurement)(attributes.y, "0pt");
  385. this.desc = null;
  386. this.extras = null;
  387. this.area = new _xfa_object.XFAObjectArray();
  388. this.draw = new _xfa_object.XFAObjectArray();
  389. this.exObject = new _xfa_object.XFAObjectArray();
  390. this.exclGroup = new _xfa_object.XFAObjectArray();
  391. this.field = new _xfa_object.XFAObjectArray();
  392. this.subform = new _xfa_object.XFAObjectArray();
  393. this.subformSet = new _xfa_object.XFAObjectArray();
  394. }
  395. *[_xfa_object.$getContainedChildren]() {
  396. yield* getContainedChildren(this);
  397. }
  398. [_xfa_object.$isTransparent]() {
  399. return true;
  400. }
  401. [_xfa_object.$isBindable]() {
  402. return true;
  403. }
  404. [_xfa_object.$addHTML](html, bbox) {
  405. const [x, y, w, h] = bbox;
  406. this[_xfa_object.$extra].width = Math.max(this[_xfa_object.$extra].width, x + w);
  407. this[_xfa_object.$extra].height = Math.max(this[_xfa_object.$extra].height, y + h);
  408. this[_xfa_object.$extra].children.push(html);
  409. }
  410. [_xfa_object.$getAvailableSpace]() {
  411. return this[_xfa_object.$extra].availableSpace;
  412. }
  413. [_xfa_object.$toHTML](availableSpace) {
  414. const style = (0, _html_utils.toStyle)(this, "position");
  415. const attributes = {
  416. style,
  417. id: this[_xfa_object.$uid],
  418. class: ["xfaArea"]
  419. };
  420. if ((0, _html_utils.isPrintOnly)(this)) {
  421. attributes.class.push("xfaPrintOnly");
  422. }
  423. if (this.name) {
  424. attributes.xfaName = this.name;
  425. }
  426. const children = [];
  427. this[_xfa_object.$extra] = {
  428. children,
  429. width: 0,
  430. height: 0,
  431. availableSpace
  432. };
  433. const result = this[_xfa_object.$childrenToHTML]({
  434. filter: new Set(["area", "draw", "field", "exclGroup", "subform", "subformSet"]),
  435. include: true
  436. });
  437. if (!result.success) {
  438. if (result.isBreak()) {
  439. return result;
  440. }
  441. delete this[_xfa_object.$extra];
  442. return _utils.HTMLResult.FAILURE;
  443. }
  444. style.width = (0, _html_utils.measureToString)(this[_xfa_object.$extra].width);
  445. style.height = (0, _html_utils.measureToString)(this[_xfa_object.$extra].height);
  446. const html = {
  447. name: "div",
  448. attributes,
  449. children
  450. };
  451. const bbox = [this.x, this.y, this[_xfa_object.$extra].width, this[_xfa_object.$extra].height];
  452. delete this[_xfa_object.$extra];
  453. return _utils.HTMLResult.success(html, bbox);
  454. }
  455. }
  456. class Assist extends _xfa_object.XFAObject {
  457. constructor(attributes) {
  458. super(TEMPLATE_NS_ID, "assist", true);
  459. this.id = attributes.id || "";
  460. this.role = attributes.role || "";
  461. this.use = attributes.use || "";
  462. this.usehref = attributes.usehref || "";
  463. this.speak = null;
  464. this.toolTip = null;
  465. }
  466. [_xfa_object.$toHTML]() {
  467. return this.toolTip && this.toolTip[_xfa_object.$content] ? this.toolTip[_xfa_object.$content] : null;
  468. }
  469. }
  470. class Barcode extends _xfa_object.XFAObject {
  471. constructor(attributes) {
  472. super(TEMPLATE_NS_ID, "barcode", true);
  473. this.charEncoding = (0, _utils.getKeyword)({
  474. data: attributes.charEncoding ? attributes.charEncoding.toLowerCase() : "",
  475. defaultValue: "",
  476. validate: k => ["utf-8", "big-five", "fontspecific", "gbk", "gb-18030", "gb-2312", "ksc-5601", "none", "shift-jis", "ucs-2", "utf-16"].includes(k) || k.match(/iso-8859-\d{2}/)
  477. });
  478. this.checksum = (0, _utils.getStringOption)(attributes.checksum, ["none", "1mod10", "1mod10_1mod11", "2mod10", "auto"]);
  479. this.dataColumnCount = (0, _utils.getInteger)({
  480. data: attributes.dataColumnCount,
  481. defaultValue: -1,
  482. validate: x => x >= 0
  483. });
  484. this.dataLength = (0, _utils.getInteger)({
  485. data: attributes.dataLength,
  486. defaultValue: -1,
  487. validate: x => x >= 0
  488. });
  489. this.dataPrep = (0, _utils.getStringOption)(attributes.dataPrep, ["none", "flateCompress"]);
  490. this.dataRowCount = (0, _utils.getInteger)({
  491. data: attributes.dataRowCount,
  492. defaultValue: -1,
  493. validate: x => x >= 0
  494. });
  495. this.endChar = attributes.endChar || "";
  496. this.errorCorrectionLevel = (0, _utils.getInteger)({
  497. data: attributes.errorCorrectionLevel,
  498. defaultValue: -1,
  499. validate: x => x >= 0 && x <= 8
  500. });
  501. this.id = attributes.id || "";
  502. this.moduleHeight = (0, _utils.getMeasurement)(attributes.moduleHeight, "5mm");
  503. this.moduleWidth = (0, _utils.getMeasurement)(attributes.moduleWidth, "0.25mm");
  504. this.printCheckDigit = (0, _utils.getInteger)({
  505. data: attributes.printCheckDigit,
  506. defaultValue: 0,
  507. validate: x => x === 1
  508. });
  509. this.rowColumnRatio = (0, _utils.getRatio)(attributes.rowColumnRatio);
  510. this.startChar = attributes.startChar || "";
  511. this.textLocation = (0, _utils.getStringOption)(attributes.textLocation, ["below", "above", "aboveEmbedded", "belowEmbedded", "none"]);
  512. this.truncate = (0, _utils.getInteger)({
  513. data: attributes.truncate,
  514. defaultValue: 0,
  515. validate: x => x === 1
  516. });
  517. this.type = (0, _utils.getStringOption)(attributes.type ? attributes.type.toLowerCase() : "", ["aztec", "codabar", "code2of5industrial", "code2of5interleaved", "code2of5matrix", "code2of5standard", "code3of9", "code3of9extended", "code11", "code49", "code93", "code128", "code128a", "code128b", "code128c", "code128sscc", "datamatrix", "ean8", "ean8add2", "ean8add5", "ean13", "ean13add2", "ean13add5", "ean13pwcd", "fim", "logmars", "maxicode", "msi", "pdf417", "pdf417macro", "plessey", "postauscust2", "postauscust3", "postausreplypaid", "postausstandard", "postukrm4scc", "postusdpbc", "postusimb", "postusstandard", "postus5zip", "qrcode", "rfid", "rss14", "rss14expanded", "rss14limited", "rss14stacked", "rss14stackedomni", "rss14truncated", "telepen", "ucc128", "ucc128random", "ucc128sscc", "upca", "upcaadd2", "upcaadd5", "upcapwcd", "upce", "upceadd2", "upceadd5", "upcean2", "upcean5", "upsmaxicode"]);
  518. this.upsMode = (0, _utils.getStringOption)(attributes.upsMode, ["usCarrier", "internationalCarrier", "secureSymbol", "standardSymbol"]);
  519. this.use = attributes.use || "";
  520. this.usehref = attributes.usehref || "";
  521. this.wideNarrowRatio = (0, _utils.getRatio)(attributes.wideNarrowRatio);
  522. this.encrypt = null;
  523. this.extras = null;
  524. }
  525. }
  526. class Bind extends _xfa_object.XFAObject {
  527. constructor(attributes) {
  528. super(TEMPLATE_NS_ID, "bind", true);
  529. this.match = (0, _utils.getStringOption)(attributes.match, ["once", "dataRef", "global", "none"]);
  530. this.ref = attributes.ref || "";
  531. this.picture = null;
  532. }
  533. }
  534. class BindItems extends _xfa_object.XFAObject {
  535. constructor(attributes) {
  536. super(TEMPLATE_NS_ID, "bindItems");
  537. this.connection = attributes.connection || "";
  538. this.labelRef = attributes.labelRef || "";
  539. this.ref = attributes.ref || "";
  540. this.valueRef = attributes.valueRef || "";
  541. }
  542. }
  543. exports.BindItems = BindItems;
  544. class Bookend extends _xfa_object.XFAObject {
  545. constructor(attributes) {
  546. super(TEMPLATE_NS_ID, "bookend");
  547. this.id = attributes.id || "";
  548. this.leader = attributes.leader || "";
  549. this.trailer = attributes.trailer || "";
  550. this.use = attributes.use || "";
  551. this.usehref = attributes.usehref || "";
  552. }
  553. }
  554. class BooleanElement extends _xfa_object.Option01 {
  555. constructor(attributes) {
  556. super(TEMPLATE_NS_ID, "boolean");
  557. this.id = attributes.id || "";
  558. this.name = attributes.name || "";
  559. this.use = attributes.use || "";
  560. this.usehref = attributes.usehref || "";
  561. }
  562. [_xfa_object.$toHTML](availableSpace) {
  563. return valueToHtml(this[_xfa_object.$content] === 1 ? "1" : "0");
  564. }
  565. }
  566. class Border extends _xfa_object.XFAObject {
  567. constructor(attributes) {
  568. super(TEMPLATE_NS_ID, "border", true);
  569. this.break = (0, _utils.getStringOption)(attributes.break, ["close", "open"]);
  570. this.hand = (0, _utils.getStringOption)(attributes.hand, ["even", "left", "right"]);
  571. this.id = attributes.id || "";
  572. this.presence = (0, _utils.getStringOption)(attributes.presence, ["visible", "hidden", "inactive", "invisible"]);
  573. this.relevant = (0, _utils.getRelevant)(attributes.relevant);
  574. this.use = attributes.use || "";
  575. this.usehref = attributes.usehref || "";
  576. this.corner = new _xfa_object.XFAObjectArray(4);
  577. this.edge = new _xfa_object.XFAObjectArray(4);
  578. this.extras = null;
  579. this.fill = null;
  580. this.margin = null;
  581. }
  582. [_xfa_object.$getExtra]() {
  583. if (!this[_xfa_object.$extra]) {
  584. const edges = this.edge.children.slice();
  585. if (edges.length < 4) {
  586. const defaultEdge = edges.at(-1) || new Edge({});
  587. for (let i = edges.length; i < 4; i++) {
  588. edges.push(defaultEdge);
  589. }
  590. }
  591. const widths = edges.map(edge => edge.thickness);
  592. const insets = [0, 0, 0, 0];
  593. if (this.margin) {
  594. insets[0] = this.margin.topInset;
  595. insets[1] = this.margin.rightInset;
  596. insets[2] = this.margin.bottomInset;
  597. insets[3] = this.margin.leftInset;
  598. }
  599. this[_xfa_object.$extra] = {
  600. widths,
  601. insets,
  602. edges
  603. };
  604. }
  605. return this[_xfa_object.$extra];
  606. }
  607. [_xfa_object.$toStyle]() {
  608. const {
  609. edges
  610. } = this[_xfa_object.$getExtra]();
  611. const edgeStyles = edges.map(node => {
  612. const style = node[_xfa_object.$toStyle]();
  613. style.color = style.color || "#000000";
  614. return style;
  615. });
  616. const style = Object.create(null);
  617. if (this.margin) {
  618. Object.assign(style, this.margin[_xfa_object.$toStyle]());
  619. }
  620. if (this.fill && this.fill.presence === "visible") {
  621. Object.assign(style, this.fill[_xfa_object.$toStyle]());
  622. }
  623. if (this.corner.children.some(node => node.radius !== 0)) {
  624. const cornerStyles = this.corner.children.map(node => node[_xfa_object.$toStyle]());
  625. if (cornerStyles.length === 2 || cornerStyles.length === 3) {
  626. const last = cornerStyles.at(-1);
  627. for (let i = cornerStyles.length; i < 4; i++) {
  628. cornerStyles.push(last);
  629. }
  630. }
  631. style.borderRadius = cornerStyles.map(s => s.radius).join(" ");
  632. }
  633. switch (this.presence) {
  634. case "invisible":
  635. case "hidden":
  636. style.borderStyle = "";
  637. break;
  638. case "inactive":
  639. style.borderStyle = "none";
  640. break;
  641. default:
  642. style.borderStyle = edgeStyles.map(s => s.style).join(" ");
  643. break;
  644. }
  645. style.borderWidth = edgeStyles.map(s => s.width).join(" ");
  646. style.borderColor = edgeStyles.map(s => s.color).join(" ");
  647. return style;
  648. }
  649. }
  650. class Break extends _xfa_object.XFAObject {
  651. constructor(attributes) {
  652. super(TEMPLATE_NS_ID, "break", true);
  653. this.after = (0, _utils.getStringOption)(attributes.after, ["auto", "contentArea", "pageArea", "pageEven", "pageOdd"]);
  654. this.afterTarget = attributes.afterTarget || "";
  655. this.before = (0, _utils.getStringOption)(attributes.before, ["auto", "contentArea", "pageArea", "pageEven", "pageOdd"]);
  656. this.beforeTarget = attributes.beforeTarget || "";
  657. this.bookendLeader = attributes.bookendLeader || "";
  658. this.bookendTrailer = attributes.bookendTrailer || "";
  659. this.id = attributes.id || "";
  660. this.overflowLeader = attributes.overflowLeader || "";
  661. this.overflowTarget = attributes.overflowTarget || "";
  662. this.overflowTrailer = attributes.overflowTrailer || "";
  663. this.startNew = (0, _utils.getInteger)({
  664. data: attributes.startNew,
  665. defaultValue: 0,
  666. validate: x => x === 1
  667. });
  668. this.use = attributes.use || "";
  669. this.usehref = attributes.usehref || "";
  670. this.extras = null;
  671. }
  672. }
  673. class BreakAfter extends _xfa_object.XFAObject {
  674. constructor(attributes) {
  675. super(TEMPLATE_NS_ID, "breakAfter", true);
  676. this.id = attributes.id || "";
  677. this.leader = attributes.leader || "";
  678. this.startNew = (0, _utils.getInteger)({
  679. data: attributes.startNew,
  680. defaultValue: 0,
  681. validate: x => x === 1
  682. });
  683. this.target = attributes.target || "";
  684. this.targetType = (0, _utils.getStringOption)(attributes.targetType, ["auto", "contentArea", "pageArea"]);
  685. this.trailer = attributes.trailer || "";
  686. this.use = attributes.use || "";
  687. this.usehref = attributes.usehref || "";
  688. this.script = null;
  689. }
  690. }
  691. class BreakBefore extends _xfa_object.XFAObject {
  692. constructor(attributes) {
  693. super(TEMPLATE_NS_ID, "breakBefore", true);
  694. this.id = attributes.id || "";
  695. this.leader = attributes.leader || "";
  696. this.startNew = (0, _utils.getInteger)({
  697. data: attributes.startNew,
  698. defaultValue: 0,
  699. validate: x => x === 1
  700. });
  701. this.target = attributes.target || "";
  702. this.targetType = (0, _utils.getStringOption)(attributes.targetType, ["auto", "contentArea", "pageArea"]);
  703. this.trailer = attributes.trailer || "";
  704. this.use = attributes.use || "";
  705. this.usehref = attributes.usehref || "";
  706. this.script = null;
  707. }
  708. [_xfa_object.$toHTML](availableSpace) {
  709. this[_xfa_object.$extra] = {};
  710. return _utils.HTMLResult.FAILURE;
  711. }
  712. }
  713. class Button extends _xfa_object.XFAObject {
  714. constructor(attributes) {
  715. super(TEMPLATE_NS_ID, "button", true);
  716. this.highlight = (0, _utils.getStringOption)(attributes.highlight, ["inverted", "none", "outline", "push"]);
  717. this.id = attributes.id || "";
  718. this.use = attributes.use || "";
  719. this.usehref = attributes.usehref || "";
  720. this.extras = null;
  721. }
  722. [_xfa_object.$toHTML](availableSpace) {
  723. const parent = this[_xfa_object.$getParent]();
  724. const grandpa = parent[_xfa_object.$getParent]();
  725. const htmlButton = {
  726. name: "button",
  727. attributes: {
  728. id: this[_xfa_object.$uid],
  729. class: ["xfaButton"],
  730. style: {}
  731. },
  732. children: []
  733. };
  734. for (const event of grandpa.event.children) {
  735. if (event.activity !== "click" || !event.script) {
  736. continue;
  737. }
  738. const jsURL = (0, _core_utils.recoverJsURL)(event.script[_xfa_object.$content]);
  739. if (!jsURL) {
  740. continue;
  741. }
  742. const href = (0, _html_utils.fixURL)(jsURL.url);
  743. if (!href) {
  744. continue;
  745. }
  746. htmlButton.children.push({
  747. name: "a",
  748. attributes: {
  749. id: "link" + this[_xfa_object.$uid],
  750. href,
  751. newWindow: jsURL.newWindow,
  752. class: ["xfaLink"],
  753. style: {}
  754. },
  755. children: []
  756. });
  757. }
  758. return _utils.HTMLResult.success(htmlButton);
  759. }
  760. }
  761. class Calculate extends _xfa_object.XFAObject {
  762. constructor(attributes) {
  763. super(TEMPLATE_NS_ID, "calculate", true);
  764. this.id = attributes.id || "";
  765. this.override = (0, _utils.getStringOption)(attributes.override, ["disabled", "error", "ignore", "warning"]);
  766. this.use = attributes.use || "";
  767. this.usehref = attributes.usehref || "";
  768. this.extras = null;
  769. this.message = null;
  770. this.script = null;
  771. }
  772. }
  773. class Caption extends _xfa_object.XFAObject {
  774. constructor(attributes) {
  775. super(TEMPLATE_NS_ID, "caption", true);
  776. this.id = attributes.id || "";
  777. this.placement = (0, _utils.getStringOption)(attributes.placement, ["left", "bottom", "inline", "right", "top"]);
  778. this.presence = (0, _utils.getStringOption)(attributes.presence, ["visible", "hidden", "inactive", "invisible"]);
  779. this.reserve = Math.ceil((0, _utils.getMeasurement)(attributes.reserve));
  780. this.use = attributes.use || "";
  781. this.usehref = attributes.usehref || "";
  782. this.extras = null;
  783. this.font = null;
  784. this.margin = null;
  785. this.para = null;
  786. this.value = null;
  787. }
  788. [_xfa_object.$setValue](value) {
  789. _setValue(this, value);
  790. }
  791. [_xfa_object.$getExtra](availableSpace) {
  792. if (!this[_xfa_object.$extra]) {
  793. let {
  794. width,
  795. height
  796. } = availableSpace;
  797. switch (this.placement) {
  798. case "left":
  799. case "right":
  800. case "inline":
  801. width = this.reserve <= 0 ? width : this.reserve;
  802. break;
  803. case "top":
  804. case "bottom":
  805. height = this.reserve <= 0 ? height : this.reserve;
  806. break;
  807. }
  808. this[_xfa_object.$extra] = (0, _html_utils.layoutNode)(this, {
  809. width,
  810. height
  811. });
  812. }
  813. return this[_xfa_object.$extra];
  814. }
  815. [_xfa_object.$toHTML](availableSpace) {
  816. if (!this.value) {
  817. return _utils.HTMLResult.EMPTY;
  818. }
  819. this[_xfa_object.$pushPara]();
  820. const value = this.value[_xfa_object.$toHTML](availableSpace).html;
  821. if (!value) {
  822. this[_xfa_object.$popPara]();
  823. return _utils.HTMLResult.EMPTY;
  824. }
  825. const savedReserve = this.reserve;
  826. if (this.reserve <= 0) {
  827. const {
  828. w,
  829. h
  830. } = this[_xfa_object.$getExtra](availableSpace);
  831. switch (this.placement) {
  832. case "left":
  833. case "right":
  834. case "inline":
  835. this.reserve = w;
  836. break;
  837. case "top":
  838. case "bottom":
  839. this.reserve = h;
  840. break;
  841. }
  842. }
  843. const children = [];
  844. if (typeof value === "string") {
  845. children.push({
  846. name: "#text",
  847. value
  848. });
  849. } else {
  850. children.push(value);
  851. }
  852. const style = (0, _html_utils.toStyle)(this, "font", "margin", "visibility");
  853. switch (this.placement) {
  854. case "left":
  855. case "right":
  856. if (this.reserve > 0) {
  857. style.width = (0, _html_utils.measureToString)(this.reserve);
  858. }
  859. break;
  860. case "top":
  861. case "bottom":
  862. if (this.reserve > 0) {
  863. style.height = (0, _html_utils.measureToString)(this.reserve);
  864. }
  865. break;
  866. }
  867. (0, _html_utils.setPara)(this, null, value);
  868. this[_xfa_object.$popPara]();
  869. this.reserve = savedReserve;
  870. return _utils.HTMLResult.success({
  871. name: "div",
  872. attributes: {
  873. style,
  874. class: ["xfaCaption"]
  875. },
  876. children
  877. });
  878. }
  879. }
  880. class Certificate extends _xfa_object.StringObject {
  881. constructor(attributes) {
  882. super(TEMPLATE_NS_ID, "certificate");
  883. this.id = attributes.id || "";
  884. this.name = attributes.name || "";
  885. this.use = attributes.use || "";
  886. this.usehref = attributes.usehref || "";
  887. }
  888. }
  889. class Certificates extends _xfa_object.XFAObject {
  890. constructor(attributes) {
  891. super(TEMPLATE_NS_ID, "certificates", true);
  892. this.credentialServerPolicy = (0, _utils.getStringOption)(attributes.credentialServerPolicy, ["optional", "required"]);
  893. this.id = attributes.id || "";
  894. this.url = attributes.url || "";
  895. this.urlPolicy = attributes.urlPolicy || "";
  896. this.use = attributes.use || "";
  897. this.usehref = attributes.usehref || "";
  898. this.encryption = null;
  899. this.issuers = null;
  900. this.keyUsage = null;
  901. this.oids = null;
  902. this.signing = null;
  903. this.subjectDNs = null;
  904. }
  905. }
  906. class CheckButton extends _xfa_object.XFAObject {
  907. constructor(attributes) {
  908. super(TEMPLATE_NS_ID, "checkButton", true);
  909. this.id = attributes.id || "";
  910. this.mark = (0, _utils.getStringOption)(attributes.mark, ["default", "check", "circle", "cross", "diamond", "square", "star"]);
  911. this.shape = (0, _utils.getStringOption)(attributes.shape, ["square", "round"]);
  912. this.size = (0, _utils.getMeasurement)(attributes.size, "10pt");
  913. this.use = attributes.use || "";
  914. this.usehref = attributes.usehref || "";
  915. this.border = null;
  916. this.extras = null;
  917. this.margin = null;
  918. }
  919. [_xfa_object.$toHTML](availableSpace) {
  920. const style = (0, _html_utils.toStyle)("margin");
  921. const size = (0, _html_utils.measureToString)(this.size);
  922. style.width = style.height = size;
  923. let type;
  924. let className;
  925. let groupId;
  926. const field = this[_xfa_object.$getParent]()[_xfa_object.$getParent]();
  927. const items = field.items.children.length && field.items.children[0][_xfa_object.$toHTML]().html || [];
  928. const exportedValue = {
  929. on: (items[0] !== undefined ? items[0] : "on").toString(),
  930. off: (items[1] !== undefined ? items[1] : "off").toString()
  931. };
  932. const value = field.value && field.value[_xfa_object.$text]() || "off";
  933. const checked = value === exportedValue.on || undefined;
  934. const container = field[_xfa_object.$getSubformParent]();
  935. const fieldId = field[_xfa_object.$uid];
  936. let dataId;
  937. if (container instanceof ExclGroup) {
  938. groupId = container[_xfa_object.$uid];
  939. type = "radio";
  940. className = "xfaRadio";
  941. dataId = container[_xfa_object.$data] && container[_xfa_object.$data][_xfa_object.$uid] || container[_xfa_object.$uid];
  942. } else {
  943. type = "checkbox";
  944. className = "xfaCheckbox";
  945. dataId = field[_xfa_object.$data] && field[_xfa_object.$data][_xfa_object.$uid] || field[_xfa_object.$uid];
  946. }
  947. const input = {
  948. name: "input",
  949. attributes: {
  950. class: [className],
  951. style,
  952. fieldId,
  953. dataId,
  954. type,
  955. checked,
  956. xfaOn: exportedValue.on,
  957. xfaOff: exportedValue.off,
  958. "aria-label": ariaLabel(field),
  959. "aria-required": false
  960. }
  961. };
  962. if (groupId) {
  963. input.attributes.name = groupId;
  964. }
  965. if (isRequired(field)) {
  966. input.attributes["aria-required"] = true;
  967. input.attributes.required = true;
  968. }
  969. return _utils.HTMLResult.success({
  970. name: "label",
  971. attributes: {
  972. class: ["xfaLabel"]
  973. },
  974. children: [input]
  975. });
  976. }
  977. }
  978. class ChoiceList extends _xfa_object.XFAObject {
  979. constructor(attributes) {
  980. super(TEMPLATE_NS_ID, "choiceList", true);
  981. this.commitOn = (0, _utils.getStringOption)(attributes.commitOn, ["select", "exit"]);
  982. this.id = attributes.id || "";
  983. this.open = (0, _utils.getStringOption)(attributes.open, ["userControl", "always", "multiSelect", "onEntry"]);
  984. this.textEntry = (0, _utils.getInteger)({
  985. data: attributes.textEntry,
  986. defaultValue: 0,
  987. validate: x => x === 1
  988. });
  989. this.use = attributes.use || "";
  990. this.usehref = attributes.usehref || "";
  991. this.border = null;
  992. this.extras = null;
  993. this.margin = null;
  994. }
  995. [_xfa_object.$toHTML](availableSpace) {
  996. const style = (0, _html_utils.toStyle)(this, "border", "margin");
  997. const ui = this[_xfa_object.$getParent]();
  998. const field = ui[_xfa_object.$getParent]();
  999. const fontSize = field.font && field.font.size || 10;
  1000. const optionStyle = {
  1001. fontSize: `calc(${fontSize}px * var(--scale-factor))`
  1002. };
  1003. const children = [];
  1004. if (field.items.children.length > 0) {
  1005. const items = field.items;
  1006. let displayedIndex = 0;
  1007. let saveIndex = 0;
  1008. if (items.children.length === 2) {
  1009. displayedIndex = items.children[0].save;
  1010. saveIndex = 1 - displayedIndex;
  1011. }
  1012. const displayed = items.children[displayedIndex][_xfa_object.$toHTML]().html;
  1013. const values = items.children[saveIndex][_xfa_object.$toHTML]().html;
  1014. let selected = false;
  1015. const value = field.value && field.value[_xfa_object.$text]() || "";
  1016. for (let i = 0, ii = displayed.length; i < ii; i++) {
  1017. const option = {
  1018. name: "option",
  1019. attributes: {
  1020. value: values[i] || displayed[i],
  1021. style: optionStyle
  1022. },
  1023. value: displayed[i]
  1024. };
  1025. if (values[i] === value) {
  1026. option.attributes.selected = selected = true;
  1027. }
  1028. children.push(option);
  1029. }
  1030. if (!selected) {
  1031. children.splice(0, 0, {
  1032. name: "option",
  1033. attributes: {
  1034. hidden: true,
  1035. selected: true
  1036. },
  1037. value: " "
  1038. });
  1039. }
  1040. }
  1041. const selectAttributes = {
  1042. class: ["xfaSelect"],
  1043. fieldId: field[_xfa_object.$uid],
  1044. dataId: field[_xfa_object.$data] && field[_xfa_object.$data][_xfa_object.$uid] || field[_xfa_object.$uid],
  1045. style,
  1046. "aria-label": ariaLabel(field),
  1047. "aria-required": false
  1048. };
  1049. if (isRequired(field)) {
  1050. selectAttributes["aria-required"] = true;
  1051. selectAttributes.required = true;
  1052. }
  1053. if (this.open === "multiSelect") {
  1054. selectAttributes.multiple = true;
  1055. }
  1056. return _utils.HTMLResult.success({
  1057. name: "label",
  1058. attributes: {
  1059. class: ["xfaLabel"]
  1060. },
  1061. children: [{
  1062. name: "select",
  1063. children,
  1064. attributes: selectAttributes
  1065. }]
  1066. });
  1067. }
  1068. }
  1069. class Color extends _xfa_object.XFAObject {
  1070. constructor(attributes) {
  1071. super(TEMPLATE_NS_ID, "color", true);
  1072. this.cSpace = (0, _utils.getStringOption)(attributes.cSpace, ["SRGB"]);
  1073. this.id = attributes.id || "";
  1074. this.use = attributes.use || "";
  1075. this.usehref = attributes.usehref || "";
  1076. this.value = attributes.value ? (0, _utils.getColor)(attributes.value) : "";
  1077. this.extras = null;
  1078. }
  1079. [_xfa_object.$hasSettableValue]() {
  1080. return false;
  1081. }
  1082. [_xfa_object.$toStyle]() {
  1083. return this.value ? _util.Util.makeHexColor(this.value.r, this.value.g, this.value.b) : null;
  1084. }
  1085. }
  1086. class Comb extends _xfa_object.XFAObject {
  1087. constructor(attributes) {
  1088. super(TEMPLATE_NS_ID, "comb");
  1089. this.id = attributes.id || "";
  1090. this.numberOfCells = (0, _utils.getInteger)({
  1091. data: attributes.numberOfCells,
  1092. defaultValue: 0,
  1093. validate: x => x >= 0
  1094. });
  1095. this.use = attributes.use || "";
  1096. this.usehref = attributes.usehref || "";
  1097. }
  1098. }
  1099. class Connect extends _xfa_object.XFAObject {
  1100. constructor(attributes) {
  1101. super(TEMPLATE_NS_ID, "connect", true);
  1102. this.connection = attributes.connection || "";
  1103. this.id = attributes.id || "";
  1104. this.ref = attributes.ref || "";
  1105. this.usage = (0, _utils.getStringOption)(attributes.usage, ["exportAndImport", "exportOnly", "importOnly"]);
  1106. this.use = attributes.use || "";
  1107. this.usehref = attributes.usehref || "";
  1108. this.picture = null;
  1109. }
  1110. }
  1111. class ContentArea extends _xfa_object.XFAObject {
  1112. constructor(attributes) {
  1113. super(TEMPLATE_NS_ID, "contentArea", true);
  1114. this.h = (0, _utils.getMeasurement)(attributes.h);
  1115. this.id = attributes.id || "";
  1116. this.name = attributes.name || "";
  1117. this.relevant = (0, _utils.getRelevant)(attributes.relevant);
  1118. this.use = attributes.use || "";
  1119. this.usehref = attributes.usehref || "";
  1120. this.w = (0, _utils.getMeasurement)(attributes.w);
  1121. this.x = (0, _utils.getMeasurement)(attributes.x, "0pt");
  1122. this.y = (0, _utils.getMeasurement)(attributes.y, "0pt");
  1123. this.desc = null;
  1124. this.extras = null;
  1125. }
  1126. [_xfa_object.$toHTML](availableSpace) {
  1127. const left = (0, _html_utils.measureToString)(this.x);
  1128. const top = (0, _html_utils.measureToString)(this.y);
  1129. const style = {
  1130. left,
  1131. top,
  1132. width: (0, _html_utils.measureToString)(this.w),
  1133. height: (0, _html_utils.measureToString)(this.h)
  1134. };
  1135. const classNames = ["xfaContentarea"];
  1136. if ((0, _html_utils.isPrintOnly)(this)) {
  1137. classNames.push("xfaPrintOnly");
  1138. }
  1139. return _utils.HTMLResult.success({
  1140. name: "div",
  1141. children: [],
  1142. attributes: {
  1143. style,
  1144. class: classNames,
  1145. id: this[_xfa_object.$uid]
  1146. }
  1147. });
  1148. }
  1149. }
  1150. class Corner extends _xfa_object.XFAObject {
  1151. constructor(attributes) {
  1152. super(TEMPLATE_NS_ID, "corner", true);
  1153. this.id = attributes.id || "";
  1154. this.inverted = (0, _utils.getInteger)({
  1155. data: attributes.inverted,
  1156. defaultValue: 0,
  1157. validate: x => x === 1
  1158. });
  1159. this.join = (0, _utils.getStringOption)(attributes.join, ["square", "round"]);
  1160. this.presence = (0, _utils.getStringOption)(attributes.presence, ["visible", "hidden", "inactive", "invisible"]);
  1161. this.radius = (0, _utils.getMeasurement)(attributes.radius);
  1162. this.stroke = (0, _utils.getStringOption)(attributes.stroke, ["solid", "dashDot", "dashDotDot", "dashed", "dotted", "embossed", "etched", "lowered", "raised"]);
  1163. this.thickness = (0, _utils.getMeasurement)(attributes.thickness, "0.5pt");
  1164. this.use = attributes.use || "";
  1165. this.usehref = attributes.usehref || "";
  1166. this.color = null;
  1167. this.extras = null;
  1168. }
  1169. [_xfa_object.$toStyle]() {
  1170. const style = (0, _html_utils.toStyle)(this, "visibility");
  1171. style.radius = (0, _html_utils.measureToString)(this.join === "square" ? 0 : this.radius);
  1172. return style;
  1173. }
  1174. }
  1175. class DateElement extends _xfa_object.ContentObject {
  1176. constructor(attributes) {
  1177. super(TEMPLATE_NS_ID, "date");
  1178. this.id = attributes.id || "";
  1179. this.name = attributes.name || "";
  1180. this.use = attributes.use || "";
  1181. this.usehref = attributes.usehref || "";
  1182. }
  1183. [_xfa_object.$finalize]() {
  1184. const date = this[_xfa_object.$content].trim();
  1185. this[_xfa_object.$content] = date ? new Date(date) : null;
  1186. }
  1187. [_xfa_object.$toHTML](availableSpace) {
  1188. return valueToHtml(this[_xfa_object.$content] ? this[_xfa_object.$content].toString() : "");
  1189. }
  1190. }
  1191. class DateTime extends _xfa_object.ContentObject {
  1192. constructor(attributes) {
  1193. super(TEMPLATE_NS_ID, "dateTime");
  1194. this.id = attributes.id || "";
  1195. this.name = attributes.name || "";
  1196. this.use = attributes.use || "";
  1197. this.usehref = attributes.usehref || "";
  1198. }
  1199. [_xfa_object.$finalize]() {
  1200. const date = this[_xfa_object.$content].trim();
  1201. this[_xfa_object.$content] = date ? new Date(date) : null;
  1202. }
  1203. [_xfa_object.$toHTML](availableSpace) {
  1204. return valueToHtml(this[_xfa_object.$content] ? this[_xfa_object.$content].toString() : "");
  1205. }
  1206. }
  1207. class DateTimeEdit extends _xfa_object.XFAObject {
  1208. constructor(attributes) {
  1209. super(TEMPLATE_NS_ID, "dateTimeEdit", true);
  1210. this.hScrollPolicy = (0, _utils.getStringOption)(attributes.hScrollPolicy, ["auto", "off", "on"]);
  1211. this.id = attributes.id || "";
  1212. this.picker = (0, _utils.getStringOption)(attributes.picker, ["host", "none"]);
  1213. this.use = attributes.use || "";
  1214. this.usehref = attributes.usehref || "";
  1215. this.border = null;
  1216. this.comb = null;
  1217. this.extras = null;
  1218. this.margin = null;
  1219. }
  1220. [_xfa_object.$toHTML](availableSpace) {
  1221. const style = (0, _html_utils.toStyle)(this, "border", "font", "margin");
  1222. const field = this[_xfa_object.$getParent]()[_xfa_object.$getParent]();
  1223. const html = {
  1224. name: "input",
  1225. attributes: {
  1226. type: "text",
  1227. fieldId: field[_xfa_object.$uid],
  1228. dataId: field[_xfa_object.$data] && field[_xfa_object.$data][_xfa_object.$uid] || field[_xfa_object.$uid],
  1229. class: ["xfaTextfield"],
  1230. style,
  1231. "aria-label": ariaLabel(field),
  1232. "aria-required": false
  1233. }
  1234. };
  1235. if (isRequired(field)) {
  1236. html.attributes["aria-required"] = true;
  1237. html.attributes.required = true;
  1238. }
  1239. return _utils.HTMLResult.success({
  1240. name: "label",
  1241. attributes: {
  1242. class: ["xfaLabel"]
  1243. },
  1244. children: [html]
  1245. });
  1246. }
  1247. }
  1248. class Decimal extends _xfa_object.ContentObject {
  1249. constructor(attributes) {
  1250. super(TEMPLATE_NS_ID, "decimal");
  1251. this.fracDigits = (0, _utils.getInteger)({
  1252. data: attributes.fracDigits,
  1253. defaultValue: 2,
  1254. validate: x => true
  1255. });
  1256. this.id = attributes.id || "";
  1257. this.leadDigits = (0, _utils.getInteger)({
  1258. data: attributes.leadDigits,
  1259. defaultValue: -1,
  1260. validate: x => true
  1261. });
  1262. this.name = attributes.name || "";
  1263. this.use = attributes.use || "";
  1264. this.usehref = attributes.usehref || "";
  1265. }
  1266. [_xfa_object.$finalize]() {
  1267. const number = parseFloat(this[_xfa_object.$content].trim());
  1268. this[_xfa_object.$content] = isNaN(number) ? null : number;
  1269. }
  1270. [_xfa_object.$toHTML](availableSpace) {
  1271. return valueToHtml(this[_xfa_object.$content] !== null ? this[_xfa_object.$content].toString() : "");
  1272. }
  1273. }
  1274. class DefaultUi extends _xfa_object.XFAObject {
  1275. constructor(attributes) {
  1276. super(TEMPLATE_NS_ID, "defaultUi", true);
  1277. this.id = attributes.id || "";
  1278. this.use = attributes.use || "";
  1279. this.usehref = attributes.usehref || "";
  1280. this.extras = null;
  1281. }
  1282. }
  1283. class Desc extends _xfa_object.XFAObject {
  1284. constructor(attributes) {
  1285. super(TEMPLATE_NS_ID, "desc", true);
  1286. this.id = attributes.id || "";
  1287. this.use = attributes.use || "";
  1288. this.usehref = attributes.usehref || "";
  1289. this.boolean = new _xfa_object.XFAObjectArray();
  1290. this.date = new _xfa_object.XFAObjectArray();
  1291. this.dateTime = new _xfa_object.XFAObjectArray();
  1292. this.decimal = new _xfa_object.XFAObjectArray();
  1293. this.exData = new _xfa_object.XFAObjectArray();
  1294. this.float = new _xfa_object.XFAObjectArray();
  1295. this.image = new _xfa_object.XFAObjectArray();
  1296. this.integer = new _xfa_object.XFAObjectArray();
  1297. this.text = new _xfa_object.XFAObjectArray();
  1298. this.time = new _xfa_object.XFAObjectArray();
  1299. }
  1300. }
  1301. class DigestMethod extends _xfa_object.OptionObject {
  1302. constructor(attributes) {
  1303. super(TEMPLATE_NS_ID, "digestMethod", ["", "SHA1", "SHA256", "SHA512", "RIPEMD160"]);
  1304. this.id = attributes.id || "";
  1305. this.use = attributes.use || "";
  1306. this.usehref = attributes.usehref || "";
  1307. }
  1308. }
  1309. class DigestMethods extends _xfa_object.XFAObject {
  1310. constructor(attributes) {
  1311. super(TEMPLATE_NS_ID, "digestMethods", true);
  1312. this.id = attributes.id || "";
  1313. this.type = (0, _utils.getStringOption)(attributes.type, ["optional", "required"]);
  1314. this.use = attributes.use || "";
  1315. this.usehref = attributes.usehref || "";
  1316. this.digestMethod = new _xfa_object.XFAObjectArray();
  1317. }
  1318. }
  1319. class Draw extends _xfa_object.XFAObject {
  1320. constructor(attributes) {
  1321. super(TEMPLATE_NS_ID, "draw", true);
  1322. this.anchorType = (0, _utils.getStringOption)(attributes.anchorType, ["topLeft", "bottomCenter", "bottomLeft", "bottomRight", "middleCenter", "middleLeft", "middleRight", "topCenter", "topRight"]);
  1323. this.colSpan = (0, _utils.getInteger)({
  1324. data: attributes.colSpan,
  1325. defaultValue: 1,
  1326. validate: n => n >= 1 || n === -1
  1327. });
  1328. this.h = attributes.h ? (0, _utils.getMeasurement)(attributes.h) : "";
  1329. this.hAlign = (0, _utils.getStringOption)(attributes.hAlign, ["left", "center", "justify", "justifyAll", "radix", "right"]);
  1330. this.id = attributes.id || "";
  1331. this.locale = attributes.locale || "";
  1332. this.maxH = (0, _utils.getMeasurement)(attributes.maxH, "0pt");
  1333. this.maxW = (0, _utils.getMeasurement)(attributes.maxW, "0pt");
  1334. this.minH = (0, _utils.getMeasurement)(attributes.minH, "0pt");
  1335. this.minW = (0, _utils.getMeasurement)(attributes.minW, "0pt");
  1336. this.name = attributes.name || "";
  1337. this.presence = (0, _utils.getStringOption)(attributes.presence, ["visible", "hidden", "inactive", "invisible"]);
  1338. this.relevant = (0, _utils.getRelevant)(attributes.relevant);
  1339. this.rotate = (0, _utils.getInteger)({
  1340. data: attributes.rotate,
  1341. defaultValue: 0,
  1342. validate: x => x % 90 === 0
  1343. });
  1344. this.use = attributes.use || "";
  1345. this.usehref = attributes.usehref || "";
  1346. this.w = attributes.w ? (0, _utils.getMeasurement)(attributes.w) : "";
  1347. this.x = (0, _utils.getMeasurement)(attributes.x, "0pt");
  1348. this.y = (0, _utils.getMeasurement)(attributes.y, "0pt");
  1349. this.assist = null;
  1350. this.border = null;
  1351. this.caption = null;
  1352. this.desc = null;
  1353. this.extras = null;
  1354. this.font = null;
  1355. this.keep = null;
  1356. this.margin = null;
  1357. this.para = null;
  1358. this.traversal = null;
  1359. this.ui = null;
  1360. this.value = null;
  1361. this.setProperty = new _xfa_object.XFAObjectArray();
  1362. }
  1363. [_xfa_object.$setValue](value) {
  1364. _setValue(this, value);
  1365. }
  1366. [_xfa_object.$toHTML](availableSpace) {
  1367. setTabIndex(this);
  1368. if (this.presence === "hidden" || this.presence === "inactive") {
  1369. return _utils.HTMLResult.EMPTY;
  1370. }
  1371. (0, _html_utils.fixDimensions)(this);
  1372. this[_xfa_object.$pushPara]();
  1373. const savedW = this.w;
  1374. const savedH = this.h;
  1375. const {
  1376. w,
  1377. h,
  1378. isBroken
  1379. } = (0, _html_utils.layoutNode)(this, availableSpace);
  1380. if (w && this.w === "") {
  1381. if (isBroken && this[_xfa_object.$getSubformParent]()[_xfa_object.$isThereMoreWidth]()) {
  1382. this[_xfa_object.$popPara]();
  1383. return _utils.HTMLResult.FAILURE;
  1384. }
  1385. this.w = w;
  1386. }
  1387. if (h && this.h === "") {
  1388. this.h = h;
  1389. }
  1390. setFirstUnsplittable(this);
  1391. if (!(0, _layout.checkDimensions)(this, availableSpace)) {
  1392. this.w = savedW;
  1393. this.h = savedH;
  1394. this[_xfa_object.$popPara]();
  1395. return _utils.HTMLResult.FAILURE;
  1396. }
  1397. unsetFirstUnsplittable(this);
  1398. const style = (0, _html_utils.toStyle)(this, "font", "hAlign", "dimensions", "position", "presence", "rotate", "anchorType", "border", "margin");
  1399. (0, _html_utils.setMinMaxDimensions)(this, style);
  1400. if (style.margin) {
  1401. style.padding = style.margin;
  1402. delete style.margin;
  1403. }
  1404. const classNames = ["xfaDraw"];
  1405. if (this.font) {
  1406. classNames.push("xfaFont");
  1407. }
  1408. if ((0, _html_utils.isPrintOnly)(this)) {
  1409. classNames.push("xfaPrintOnly");
  1410. }
  1411. const attributes = {
  1412. style,
  1413. id: this[_xfa_object.$uid],
  1414. class: classNames
  1415. };
  1416. if (this.name) {
  1417. attributes.xfaName = this.name;
  1418. }
  1419. const html = {
  1420. name: "div",
  1421. attributes,
  1422. children: []
  1423. };
  1424. applyAssist(this, attributes);
  1425. const bbox = (0, _html_utils.computeBbox)(this, html, availableSpace);
  1426. const value = this.value ? this.value[_xfa_object.$toHTML](availableSpace).html : null;
  1427. if (value === null) {
  1428. this.w = savedW;
  1429. this.h = savedH;
  1430. this[_xfa_object.$popPara]();
  1431. return _utils.HTMLResult.success((0, _html_utils.createWrapper)(this, html), bbox);
  1432. }
  1433. html.children.push(value);
  1434. (0, _html_utils.setPara)(this, style, value);
  1435. this.w = savedW;
  1436. this.h = savedH;
  1437. this[_xfa_object.$popPara]();
  1438. return _utils.HTMLResult.success((0, _html_utils.createWrapper)(this, html), bbox);
  1439. }
  1440. }
  1441. class Edge extends _xfa_object.XFAObject {
  1442. constructor(attributes) {
  1443. super(TEMPLATE_NS_ID, "edge", true);
  1444. this.cap = (0, _utils.getStringOption)(attributes.cap, ["square", "butt", "round"]);
  1445. this.id = attributes.id || "";
  1446. this.presence = (0, _utils.getStringOption)(attributes.presence, ["visible", "hidden", "inactive", "invisible"]);
  1447. this.stroke = (0, _utils.getStringOption)(attributes.stroke, ["solid", "dashDot", "dashDotDot", "dashed", "dotted", "embossed", "etched", "lowered", "raised"]);
  1448. this.thickness = (0, _utils.getMeasurement)(attributes.thickness, "0.5pt");
  1449. this.use = attributes.use || "";
  1450. this.usehref = attributes.usehref || "";
  1451. this.color = null;
  1452. this.extras = null;
  1453. }
  1454. [_xfa_object.$toStyle]() {
  1455. const style = (0, _html_utils.toStyle)(this, "visibility");
  1456. Object.assign(style, {
  1457. linecap: this.cap,
  1458. width: (0, _html_utils.measureToString)(this.thickness),
  1459. color: this.color ? this.color[_xfa_object.$toStyle]() : "#000000",
  1460. style: ""
  1461. });
  1462. if (this.presence !== "visible") {
  1463. style.style = "none";
  1464. } else {
  1465. switch (this.stroke) {
  1466. case "solid":
  1467. style.style = "solid";
  1468. break;
  1469. case "dashDot":
  1470. style.style = "dashed";
  1471. break;
  1472. case "dashDotDot":
  1473. style.style = "dashed";
  1474. break;
  1475. case "dashed":
  1476. style.style = "dashed";
  1477. break;
  1478. case "dotted":
  1479. style.style = "dotted";
  1480. break;
  1481. case "embossed":
  1482. style.style = "ridge";
  1483. break;
  1484. case "etched":
  1485. style.style = "groove";
  1486. break;
  1487. case "lowered":
  1488. style.style = "inset";
  1489. break;
  1490. case "raised":
  1491. style.style = "outset";
  1492. break;
  1493. }
  1494. }
  1495. return style;
  1496. }
  1497. }
  1498. class Encoding extends _xfa_object.OptionObject {
  1499. constructor(attributes) {
  1500. super(TEMPLATE_NS_ID, "encoding", ["adbe.x509.rsa_sha1", "adbe.pkcs7.detached", "adbe.pkcs7.sha1"]);
  1501. this.id = attributes.id || "";
  1502. this.use = attributes.use || "";
  1503. this.usehref = attributes.usehref || "";
  1504. }
  1505. }
  1506. class Encodings extends _xfa_object.XFAObject {
  1507. constructor(attributes) {
  1508. super(TEMPLATE_NS_ID, "encodings", true);
  1509. this.id = attributes.id || "";
  1510. this.type = (0, _utils.getStringOption)(attributes.type, ["optional", "required"]);
  1511. this.use = attributes.use || "";
  1512. this.usehref = attributes.usehref || "";
  1513. this.encoding = new _xfa_object.XFAObjectArray();
  1514. }
  1515. }
  1516. class Encrypt extends _xfa_object.XFAObject {
  1517. constructor(attributes) {
  1518. super(TEMPLATE_NS_ID, "encrypt", true);
  1519. this.id = attributes.id || "";
  1520. this.use = attributes.use || "";
  1521. this.usehref = attributes.usehref || "";
  1522. this.certificate = null;
  1523. }
  1524. }
  1525. class EncryptData extends _xfa_object.XFAObject {
  1526. constructor(attributes) {
  1527. super(TEMPLATE_NS_ID, "encryptData", true);
  1528. this.id = attributes.id || "";
  1529. this.operation = (0, _utils.getStringOption)(attributes.operation, ["encrypt", "decrypt"]);
  1530. this.target = attributes.target || "";
  1531. this.use = attributes.use || "";
  1532. this.usehref = attributes.usehref || "";
  1533. this.filter = null;
  1534. this.manifest = null;
  1535. }
  1536. }
  1537. class Encryption extends _xfa_object.XFAObject {
  1538. constructor(attributes) {
  1539. super(TEMPLATE_NS_ID, "encryption", true);
  1540. this.id = attributes.id || "";
  1541. this.type = (0, _utils.getStringOption)(attributes.type, ["optional", "required"]);
  1542. this.use = attributes.use || "";
  1543. this.usehref = attributes.usehref || "";
  1544. this.certificate = new _xfa_object.XFAObjectArray();
  1545. }
  1546. }
  1547. class EncryptionMethod extends _xfa_object.OptionObject {
  1548. constructor(attributes) {
  1549. super(TEMPLATE_NS_ID, "encryptionMethod", ["", "AES256-CBC", "TRIPLEDES-CBC", "AES128-CBC", "AES192-CBC"]);
  1550. this.id = attributes.id || "";
  1551. this.use = attributes.use || "";
  1552. this.usehref = attributes.usehref || "";
  1553. }
  1554. }
  1555. class EncryptionMethods extends _xfa_object.XFAObject {
  1556. constructor(attributes) {
  1557. super(TEMPLATE_NS_ID, "encryptionMethods", true);
  1558. this.id = attributes.id || "";
  1559. this.type = (0, _utils.getStringOption)(attributes.type, ["optional", "required"]);
  1560. this.use = attributes.use || "";
  1561. this.usehref = attributes.usehref || "";
  1562. this.encryptionMethod = new _xfa_object.XFAObjectArray();
  1563. }
  1564. }
  1565. class Event extends _xfa_object.XFAObject {
  1566. constructor(attributes) {
  1567. super(TEMPLATE_NS_ID, "event", true);
  1568. this.activity = (0, _utils.getStringOption)(attributes.activity, ["click", "change", "docClose", "docReady", "enter", "exit", "full", "indexChange", "initialize", "mouseDown", "mouseEnter", "mouseExit", "mouseUp", "postExecute", "postOpen", "postPrint", "postSave", "postSign", "postSubmit", "preExecute", "preOpen", "prePrint", "preSave", "preSign", "preSubmit", "ready", "validationState"]);
  1569. this.id = attributes.id || "";
  1570. this.listen = (0, _utils.getStringOption)(attributes.listen, ["refOnly", "refAndDescendents"]);
  1571. this.name = attributes.name || "";
  1572. this.ref = attributes.ref || "";
  1573. this.use = attributes.use || "";
  1574. this.usehref = attributes.usehref || "";
  1575. this.extras = null;
  1576. this.encryptData = null;
  1577. this.execute = null;
  1578. this.script = null;
  1579. this.signData = null;
  1580. this.submit = null;
  1581. }
  1582. }
  1583. class ExData extends _xfa_object.ContentObject {
  1584. constructor(attributes) {
  1585. super(TEMPLATE_NS_ID, "exData");
  1586. this.contentType = attributes.contentType || "";
  1587. this.href = attributes.href || "";
  1588. this.id = attributes.id || "";
  1589. this.maxLength = (0, _utils.getInteger)({
  1590. data: attributes.maxLength,
  1591. defaultValue: -1,
  1592. validate: x => x >= -1
  1593. });
  1594. this.name = attributes.name || "";
  1595. this.rid = attributes.rid || "";
  1596. this.transferEncoding = (0, _utils.getStringOption)(attributes.transferEncoding, ["none", "base64", "package"]);
  1597. this.use = attributes.use || "";
  1598. this.usehref = attributes.usehref || "";
  1599. }
  1600. [_xfa_object.$isCDATAXml]() {
  1601. return this.contentType === "text/html";
  1602. }
  1603. [_xfa_object.$onChild](child) {
  1604. if (this.contentType === "text/html" && child[_xfa_object.$namespaceId] === _namespaces.NamespaceIds.xhtml.id) {
  1605. this[_xfa_object.$content] = child;
  1606. return true;
  1607. }
  1608. if (this.contentType === "text/xml") {
  1609. this[_xfa_object.$content] = child;
  1610. return true;
  1611. }
  1612. return false;
  1613. }
  1614. [_xfa_object.$toHTML](availableSpace) {
  1615. if (this.contentType !== "text/html" || !this[_xfa_object.$content]) {
  1616. return _utils.HTMLResult.EMPTY;
  1617. }
  1618. return this[_xfa_object.$content][_xfa_object.$toHTML](availableSpace);
  1619. }
  1620. }
  1621. class ExObject extends _xfa_object.XFAObject {
  1622. constructor(attributes) {
  1623. super(TEMPLATE_NS_ID, "exObject", true);
  1624. this.archive = attributes.archive || "";
  1625. this.classId = attributes.classId || "";
  1626. this.codeBase = attributes.codeBase || "";
  1627. this.codeType = attributes.codeType || "";
  1628. this.id = attributes.id || "";
  1629. this.name = attributes.name || "";
  1630. this.use = attributes.use || "";
  1631. this.usehref = attributes.usehref || "";
  1632. this.extras = null;
  1633. this.boolean = new _xfa_object.XFAObjectArray();
  1634. this.date = new _xfa_object.XFAObjectArray();
  1635. this.dateTime = new _xfa_object.XFAObjectArray();
  1636. this.decimal = new _xfa_object.XFAObjectArray();
  1637. this.exData = new _xfa_object.XFAObjectArray();
  1638. this.exObject = new _xfa_object.XFAObjectArray();
  1639. this.float = new _xfa_object.XFAObjectArray();
  1640. this.image = new _xfa_object.XFAObjectArray();
  1641. this.integer = new _xfa_object.XFAObjectArray();
  1642. this.text = new _xfa_object.XFAObjectArray();
  1643. this.time = new _xfa_object.XFAObjectArray();
  1644. }
  1645. }
  1646. class ExclGroup extends _xfa_object.XFAObject {
  1647. constructor(attributes) {
  1648. super(TEMPLATE_NS_ID, "exclGroup", true);
  1649. this.access = (0, _utils.getStringOption)(attributes.access, ["open", "nonInteractive", "protected", "readOnly"]);
  1650. this.accessKey = attributes.accessKey || "";
  1651. this.anchorType = (0, _utils.getStringOption)(attributes.anchorType, ["topLeft", "bottomCenter", "bottomLeft", "bottomRight", "middleCenter", "middleLeft", "middleRight", "topCenter", "topRight"]);
  1652. this.colSpan = (0, _utils.getInteger)({
  1653. data: attributes.colSpan,
  1654. defaultValue: 1,
  1655. validate: n => n >= 1 || n === -1
  1656. });
  1657. this.h = attributes.h ? (0, _utils.getMeasurement)(attributes.h) : "";
  1658. this.hAlign = (0, _utils.getStringOption)(attributes.hAlign, ["left", "center", "justify", "justifyAll", "radix", "right"]);
  1659. this.id = attributes.id || "";
  1660. this.layout = (0, _utils.getStringOption)(attributes.layout, ["position", "lr-tb", "rl-row", "rl-tb", "row", "table", "tb"]);
  1661. this.maxH = (0, _utils.getMeasurement)(attributes.maxH, "0pt");
  1662. this.maxW = (0, _utils.getMeasurement)(attributes.maxW, "0pt");
  1663. this.minH = (0, _utils.getMeasurement)(attributes.minH, "0pt");
  1664. this.minW = (0, _utils.getMeasurement)(attributes.minW, "0pt");
  1665. this.name = attributes.name || "";
  1666. this.presence = (0, _utils.getStringOption)(attributes.presence, ["visible", "hidden", "inactive", "invisible"]);
  1667. this.relevant = (0, _utils.getRelevant)(attributes.relevant);
  1668. this.use = attributes.use || "";
  1669. this.usehref = attributes.usehref || "";
  1670. this.w = attributes.w ? (0, _utils.getMeasurement)(attributes.w) : "";
  1671. this.x = (0, _utils.getMeasurement)(attributes.x, "0pt");
  1672. this.y = (0, _utils.getMeasurement)(attributes.y, "0pt");
  1673. this.assist = null;
  1674. this.bind = null;
  1675. this.border = null;
  1676. this.calculate = null;
  1677. this.caption = null;
  1678. this.desc = null;
  1679. this.extras = null;
  1680. this.margin = null;
  1681. this.para = null;
  1682. this.traversal = null;
  1683. this.validate = null;
  1684. this.connect = new _xfa_object.XFAObjectArray();
  1685. this.event = new _xfa_object.XFAObjectArray();
  1686. this.field = new _xfa_object.XFAObjectArray();
  1687. this.setProperty = new _xfa_object.XFAObjectArray();
  1688. }
  1689. [_xfa_object.$isBindable]() {
  1690. return true;
  1691. }
  1692. [_xfa_object.$hasSettableValue]() {
  1693. return true;
  1694. }
  1695. [_xfa_object.$setValue](value) {
  1696. for (const field of this.field.children) {
  1697. if (!field.value) {
  1698. const nodeValue = new Value({});
  1699. field[_xfa_object.$appendChild](nodeValue);
  1700. field.value = nodeValue;
  1701. }
  1702. field.value[_xfa_object.$setValue](value);
  1703. }
  1704. }
  1705. [_xfa_object.$isThereMoreWidth]() {
  1706. return this.layout.endsWith("-tb") && this[_xfa_object.$extra].attempt === 0 && this[_xfa_object.$extra].numberInLine > 0 || this[_xfa_object.$getParent]()[_xfa_object.$isThereMoreWidth]();
  1707. }
  1708. [_xfa_object.$isSplittable]() {
  1709. const parent = this[_xfa_object.$getSubformParent]();
  1710. if (!parent[_xfa_object.$isSplittable]()) {
  1711. return false;
  1712. }
  1713. if (this[_xfa_object.$extra]._isSplittable !== undefined) {
  1714. return this[_xfa_object.$extra]._isSplittable;
  1715. }
  1716. if (this.layout === "position" || this.layout.includes("row")) {
  1717. this[_xfa_object.$extra]._isSplittable = false;
  1718. return false;
  1719. }
  1720. if (parent.layout && parent.layout.endsWith("-tb") && parent[_xfa_object.$extra].numberInLine !== 0) {
  1721. return false;
  1722. }
  1723. this[_xfa_object.$extra]._isSplittable = true;
  1724. return true;
  1725. }
  1726. [_xfa_object.$flushHTML]() {
  1727. return (0, _layout.flushHTML)(this);
  1728. }
  1729. [_xfa_object.$addHTML](html, bbox) {
  1730. (0, _layout.addHTML)(this, html, bbox);
  1731. }
  1732. [_xfa_object.$getAvailableSpace]() {
  1733. return (0, _layout.getAvailableSpace)(this);
  1734. }
  1735. [_xfa_object.$toHTML](availableSpace) {
  1736. setTabIndex(this);
  1737. if (this.presence === "hidden" || this.presence === "inactive" || this.h === 0 || this.w === 0) {
  1738. return _utils.HTMLResult.EMPTY;
  1739. }
  1740. (0, _html_utils.fixDimensions)(this);
  1741. const children = [];
  1742. const attributes = {
  1743. id: this[_xfa_object.$uid],
  1744. class: []
  1745. };
  1746. (0, _html_utils.setAccess)(this, attributes.class);
  1747. if (!this[_xfa_object.$extra]) {
  1748. this[_xfa_object.$extra] = Object.create(null);
  1749. }
  1750. Object.assign(this[_xfa_object.$extra], {
  1751. children,
  1752. attributes,
  1753. attempt: 0,
  1754. line: null,
  1755. numberInLine: 0,
  1756. availableSpace: {
  1757. width: Math.min(this.w || Infinity, availableSpace.width),
  1758. height: Math.min(this.h || Infinity, availableSpace.height)
  1759. },
  1760. width: 0,
  1761. height: 0,
  1762. prevHeight: 0,
  1763. currentWidth: 0
  1764. });
  1765. const isSplittable = this[_xfa_object.$isSplittable]();
  1766. if (!isSplittable) {
  1767. setFirstUnsplittable(this);
  1768. }
  1769. if (!(0, _layout.checkDimensions)(this, availableSpace)) {
  1770. return _utils.HTMLResult.FAILURE;
  1771. }
  1772. const filter = new Set(["field"]);
  1773. if (this.layout.includes("row")) {
  1774. const columnWidths = this[_xfa_object.$getSubformParent]().columnWidths;
  1775. if (Array.isArray(columnWidths) && columnWidths.length > 0) {
  1776. this[_xfa_object.$extra].columnWidths = columnWidths;
  1777. this[_xfa_object.$extra].currentColumn = 0;
  1778. }
  1779. }
  1780. const style = (0, _html_utils.toStyle)(this, "anchorType", "dimensions", "position", "presence", "border", "margin", "hAlign");
  1781. const classNames = ["xfaExclgroup"];
  1782. const cl = (0, _html_utils.layoutClass)(this);
  1783. if (cl) {
  1784. classNames.push(cl);
  1785. }
  1786. if ((0, _html_utils.isPrintOnly)(this)) {
  1787. classNames.push("xfaPrintOnly");
  1788. }
  1789. attributes.style = style;
  1790. attributes.class = classNames;
  1791. if (this.name) {
  1792. attributes.xfaName = this.name;
  1793. }
  1794. this[_xfa_object.$pushPara]();
  1795. const isLrTb = this.layout === "lr-tb" || this.layout === "rl-tb";
  1796. const maxRun = isLrTb ? MAX_ATTEMPTS_FOR_LRTB_LAYOUT : 1;
  1797. for (; this[_xfa_object.$extra].attempt < maxRun; this[_xfa_object.$extra].attempt++) {
  1798. if (isLrTb && this[_xfa_object.$extra].attempt === MAX_ATTEMPTS_FOR_LRTB_LAYOUT - 1) {
  1799. this[_xfa_object.$extra].numberInLine = 0;
  1800. }
  1801. const result = this[_xfa_object.$childrenToHTML]({
  1802. filter,
  1803. include: true
  1804. });
  1805. if (result.success) {
  1806. break;
  1807. }
  1808. if (result.isBreak()) {
  1809. this[_xfa_object.$popPara]();
  1810. return result;
  1811. }
  1812. if (isLrTb && this[_xfa_object.$extra].attempt === 0 && this[_xfa_object.$extra].numberInLine === 0 && !this[_xfa_object.$getTemplateRoot]()[_xfa_object.$extra].noLayoutFailure) {
  1813. this[_xfa_object.$extra].attempt = maxRun;
  1814. break;
  1815. }
  1816. }
  1817. this[_xfa_object.$popPara]();
  1818. if (!isSplittable) {
  1819. unsetFirstUnsplittable(this);
  1820. }
  1821. if (this[_xfa_object.$extra].attempt === maxRun) {
  1822. if (!isSplittable) {
  1823. delete this[_xfa_object.$extra];
  1824. }
  1825. return _utils.HTMLResult.FAILURE;
  1826. }
  1827. let marginH = 0;
  1828. let marginV = 0;
  1829. if (this.margin) {
  1830. marginH = this.margin.leftInset + this.margin.rightInset;
  1831. marginV = this.margin.topInset + this.margin.bottomInset;
  1832. }
  1833. const width = Math.max(this[_xfa_object.$extra].width + marginH, this.w || 0);
  1834. const height = Math.max(this[_xfa_object.$extra].height + marginV, this.h || 0);
  1835. const bbox = [this.x, this.y, width, height];
  1836. if (this.w === "") {
  1837. style.width = (0, _html_utils.measureToString)(width);
  1838. }
  1839. if (this.h === "") {
  1840. style.height = (0, _html_utils.measureToString)(height);
  1841. }
  1842. const html = {
  1843. name: "div",
  1844. attributes,
  1845. children
  1846. };
  1847. applyAssist(this, attributes);
  1848. delete this[_xfa_object.$extra];
  1849. return _utils.HTMLResult.success((0, _html_utils.createWrapper)(this, html), bbox);
  1850. }
  1851. }
  1852. class Execute extends _xfa_object.XFAObject {
  1853. constructor(attributes) {
  1854. super(TEMPLATE_NS_ID, "execute");
  1855. this.connection = attributes.connection || "";
  1856. this.executeType = (0, _utils.getStringOption)(attributes.executeType, ["import", "remerge"]);
  1857. this.id = attributes.id || "";
  1858. this.runAt = (0, _utils.getStringOption)(attributes.runAt, ["client", "both", "server"]);
  1859. this.use = attributes.use || "";
  1860. this.usehref = attributes.usehref || "";
  1861. }
  1862. }
  1863. class Extras extends _xfa_object.XFAObject {
  1864. constructor(attributes) {
  1865. super(TEMPLATE_NS_ID, "extras", true);
  1866. this.id = attributes.id || "";
  1867. this.name = attributes.name || "";
  1868. this.use = attributes.use || "";
  1869. this.usehref = attributes.usehref || "";
  1870. this.boolean = new _xfa_object.XFAObjectArray();
  1871. this.date = new _xfa_object.XFAObjectArray();
  1872. this.dateTime = new _xfa_object.XFAObjectArray();
  1873. this.decimal = new _xfa_object.XFAObjectArray();
  1874. this.exData = new _xfa_object.XFAObjectArray();
  1875. this.extras = new _xfa_object.XFAObjectArray();
  1876. this.float = new _xfa_object.XFAObjectArray();
  1877. this.image = new _xfa_object.XFAObjectArray();
  1878. this.integer = new _xfa_object.XFAObjectArray();
  1879. this.text = new _xfa_object.XFAObjectArray();
  1880. this.time = new _xfa_object.XFAObjectArray();
  1881. }
  1882. }
  1883. class Field extends _xfa_object.XFAObject {
  1884. constructor(attributes) {
  1885. super(TEMPLATE_NS_ID, "field", true);
  1886. this.access = (0, _utils.getStringOption)(attributes.access, ["open", "nonInteractive", "protected", "readOnly"]);
  1887. this.accessKey = attributes.accessKey || "";
  1888. this.anchorType = (0, _utils.getStringOption)(attributes.anchorType, ["topLeft", "bottomCenter", "bottomLeft", "bottomRight", "middleCenter", "middleLeft", "middleRight", "topCenter", "topRight"]);
  1889. this.colSpan = (0, _utils.getInteger)({
  1890. data: attributes.colSpan,
  1891. defaultValue: 1,
  1892. validate: n => n >= 1 || n === -1
  1893. });
  1894. this.h = attributes.h ? (0, _utils.getMeasurement)(attributes.h) : "";
  1895. this.hAlign = (0, _utils.getStringOption)(attributes.hAlign, ["left", "center", "justify", "justifyAll", "radix", "right"]);
  1896. this.id = attributes.id || "";
  1897. this.locale = attributes.locale || "";
  1898. this.maxH = (0, _utils.getMeasurement)(attributes.maxH, "0pt");
  1899. this.maxW = (0, _utils.getMeasurement)(attributes.maxW, "0pt");
  1900. this.minH = (0, _utils.getMeasurement)(attributes.minH, "0pt");
  1901. this.minW = (0, _utils.getMeasurement)(attributes.minW, "0pt");
  1902. this.name = attributes.name || "";
  1903. this.presence = (0, _utils.getStringOption)(attributes.presence, ["visible", "hidden", "inactive", "invisible"]);
  1904. this.relevant = (0, _utils.getRelevant)(attributes.relevant);
  1905. this.rotate = (0, _utils.getInteger)({
  1906. data: attributes.rotate,
  1907. defaultValue: 0,
  1908. validate: x => x % 90 === 0
  1909. });
  1910. this.use = attributes.use || "";
  1911. this.usehref = attributes.usehref || "";
  1912. this.w = attributes.w ? (0, _utils.getMeasurement)(attributes.w) : "";
  1913. this.x = (0, _utils.getMeasurement)(attributes.x, "0pt");
  1914. this.y = (0, _utils.getMeasurement)(attributes.y, "0pt");
  1915. this.assist = null;
  1916. this.bind = null;
  1917. this.border = null;
  1918. this.calculate = null;
  1919. this.caption = null;
  1920. this.desc = null;
  1921. this.extras = null;
  1922. this.font = null;
  1923. this.format = null;
  1924. this.items = new _xfa_object.XFAObjectArray(2);
  1925. this.keep = null;
  1926. this.margin = null;
  1927. this.para = null;
  1928. this.traversal = null;
  1929. this.ui = null;
  1930. this.validate = null;
  1931. this.value = null;
  1932. this.bindItems = new _xfa_object.XFAObjectArray();
  1933. this.connect = new _xfa_object.XFAObjectArray();
  1934. this.event = new _xfa_object.XFAObjectArray();
  1935. this.setProperty = new _xfa_object.XFAObjectArray();
  1936. }
  1937. [_xfa_object.$isBindable]() {
  1938. return true;
  1939. }
  1940. [_xfa_object.$setValue](value) {
  1941. _setValue(this, value);
  1942. }
  1943. [_xfa_object.$toHTML](availableSpace) {
  1944. setTabIndex(this);
  1945. if (!this.ui) {
  1946. this.ui = new Ui({});
  1947. this.ui[_xfa_object.$globalData] = this[_xfa_object.$globalData];
  1948. this[_xfa_object.$appendChild](this.ui);
  1949. let node;
  1950. switch (this.items.children.length) {
  1951. case 0:
  1952. node = new TextEdit({});
  1953. this.ui.textEdit = node;
  1954. break;
  1955. case 1:
  1956. node = new CheckButton({});
  1957. this.ui.checkButton = node;
  1958. break;
  1959. case 2:
  1960. node = new ChoiceList({});
  1961. this.ui.choiceList = node;
  1962. break;
  1963. }
  1964. this.ui[_xfa_object.$appendChild](node);
  1965. }
  1966. if (!this.ui || this.presence === "hidden" || this.presence === "inactive" || this.h === 0 || this.w === 0) {
  1967. return _utils.HTMLResult.EMPTY;
  1968. }
  1969. if (this.caption) {
  1970. delete this.caption[_xfa_object.$extra];
  1971. }
  1972. this[_xfa_object.$pushPara]();
  1973. const caption = this.caption ? this.caption[_xfa_object.$toHTML](availableSpace).html : null;
  1974. const savedW = this.w;
  1975. const savedH = this.h;
  1976. let marginH = 0;
  1977. let marginV = 0;
  1978. if (this.margin) {
  1979. marginH = this.margin.leftInset + this.margin.rightInset;
  1980. marginV = this.margin.topInset + this.margin.bottomInset;
  1981. }
  1982. let borderDims = null;
  1983. if (this.w === "" || this.h === "") {
  1984. let width = null;
  1985. let height = null;
  1986. let uiW = 0;
  1987. let uiH = 0;
  1988. if (this.ui.checkButton) {
  1989. uiW = uiH = this.ui.checkButton.size;
  1990. } else {
  1991. const {
  1992. w,
  1993. h
  1994. } = (0, _html_utils.layoutNode)(this, availableSpace);
  1995. if (w !== null) {
  1996. uiW = w;
  1997. uiH = h;
  1998. } else {
  1999. uiH = (0, _fonts.getMetrics)(this.font, true).lineNoGap;
  2000. }
  2001. }
  2002. borderDims = getBorderDims(this.ui[_xfa_object.$getExtra]());
  2003. uiW += borderDims.w;
  2004. uiH += borderDims.h;
  2005. if (this.caption) {
  2006. const {
  2007. w,
  2008. h,
  2009. isBroken
  2010. } = this.caption[_xfa_object.$getExtra](availableSpace);
  2011. if (isBroken && this[_xfa_object.$getSubformParent]()[_xfa_object.$isThereMoreWidth]()) {
  2012. this[_xfa_object.$popPara]();
  2013. return _utils.HTMLResult.FAILURE;
  2014. }
  2015. width = w;
  2016. height = h;
  2017. switch (this.caption.placement) {
  2018. case "left":
  2019. case "right":
  2020. case "inline":
  2021. width += uiW;
  2022. break;
  2023. case "top":
  2024. case "bottom":
  2025. height += uiH;
  2026. break;
  2027. }
  2028. } else {
  2029. width = uiW;
  2030. height = uiH;
  2031. }
  2032. if (width && this.w === "") {
  2033. width += marginH;
  2034. this.w = Math.min(this.maxW <= 0 ? Infinity : this.maxW, this.minW + 1 < width ? width : this.minW);
  2035. }
  2036. if (height && this.h === "") {
  2037. height += marginV;
  2038. this.h = Math.min(this.maxH <= 0 ? Infinity : this.maxH, this.minH + 1 < height ? height : this.minH);
  2039. }
  2040. }
  2041. this[_xfa_object.$popPara]();
  2042. (0, _html_utils.fixDimensions)(this);
  2043. setFirstUnsplittable(this);
  2044. if (!(0, _layout.checkDimensions)(this, availableSpace)) {
  2045. this.w = savedW;
  2046. this.h = savedH;
  2047. this[_xfa_object.$popPara]();
  2048. return _utils.HTMLResult.FAILURE;
  2049. }
  2050. unsetFirstUnsplittable(this);
  2051. const style = (0, _html_utils.toStyle)(this, "font", "dimensions", "position", "rotate", "anchorType", "presence", "margin", "hAlign");
  2052. (0, _html_utils.setMinMaxDimensions)(this, style);
  2053. const classNames = ["xfaField"];
  2054. if (this.font) {
  2055. classNames.push("xfaFont");
  2056. }
  2057. if ((0, _html_utils.isPrintOnly)(this)) {
  2058. classNames.push("xfaPrintOnly");
  2059. }
  2060. const attributes = {
  2061. style,
  2062. id: this[_xfa_object.$uid],
  2063. class: classNames
  2064. };
  2065. if (style.margin) {
  2066. style.padding = style.margin;
  2067. delete style.margin;
  2068. }
  2069. (0, _html_utils.setAccess)(this, classNames);
  2070. if (this.name) {
  2071. attributes.xfaName = this.name;
  2072. }
  2073. const children = [];
  2074. const html = {
  2075. name: "div",
  2076. attributes,
  2077. children
  2078. };
  2079. applyAssist(this, attributes);
  2080. const borderStyle = this.border ? this.border[_xfa_object.$toStyle]() : null;
  2081. const bbox = (0, _html_utils.computeBbox)(this, html, availableSpace);
  2082. const ui = this.ui[_xfa_object.$toHTML]().html;
  2083. if (!ui) {
  2084. Object.assign(style, borderStyle);
  2085. return _utils.HTMLResult.success((0, _html_utils.createWrapper)(this, html), bbox);
  2086. }
  2087. if (this[_xfa_object.$tabIndex]) {
  2088. if (ui.children && ui.children[0]) {
  2089. ui.children[0].attributes.tabindex = this[_xfa_object.$tabIndex];
  2090. } else {
  2091. ui.attributes.tabindex = this[_xfa_object.$tabIndex];
  2092. }
  2093. }
  2094. if (!ui.attributes.style) {
  2095. ui.attributes.style = Object.create(null);
  2096. }
  2097. let aElement = null;
  2098. if (this.ui.button) {
  2099. if (ui.children.length === 1) {
  2100. [aElement] = ui.children.splice(0, 1);
  2101. }
  2102. Object.assign(ui.attributes.style, borderStyle);
  2103. } else {
  2104. Object.assign(style, borderStyle);
  2105. }
  2106. children.push(ui);
  2107. if (this.value) {
  2108. if (this.ui.imageEdit) {
  2109. ui.children.push(this.value[_xfa_object.$toHTML]().html);
  2110. } else if (!this.ui.button) {
  2111. let value = "";
  2112. if (this.value.exData) {
  2113. value = this.value.exData[_xfa_object.$text]();
  2114. } else if (this.value.text) {
  2115. value = this.value.text[_xfa_object.$getExtra]();
  2116. } else {
  2117. const htmlValue = this.value[_xfa_object.$toHTML]().html;
  2118. if (htmlValue !== null) {
  2119. value = htmlValue.children[0].value;
  2120. }
  2121. }
  2122. if (this.ui.textEdit && this.value.text && this.value.text.maxChars) {
  2123. ui.children[0].attributes.maxLength = this.value.text.maxChars;
  2124. }
  2125. if (value) {
  2126. if (this.ui.numericEdit) {
  2127. value = parseFloat(value);
  2128. value = isNaN(value) ? "" : value.toString();
  2129. }
  2130. if (ui.children[0].name === "textarea") {
  2131. ui.children[0].attributes.textContent = value;
  2132. } else {
  2133. ui.children[0].attributes.value = value;
  2134. }
  2135. }
  2136. }
  2137. }
  2138. if (!this.ui.imageEdit && ui.children && ui.children[0] && this.h) {
  2139. borderDims = borderDims || getBorderDims(this.ui[_xfa_object.$getExtra]());
  2140. let captionHeight = 0;
  2141. if (this.caption && ["top", "bottom"].includes(this.caption.placement)) {
  2142. captionHeight = this.caption.reserve;
  2143. if (captionHeight <= 0) {
  2144. captionHeight = this.caption[_xfa_object.$getExtra](availableSpace).h;
  2145. }
  2146. const inputHeight = this.h - captionHeight - marginV - borderDims.h;
  2147. ui.children[0].attributes.style.height = (0, _html_utils.measureToString)(inputHeight);
  2148. } else {
  2149. ui.children[0].attributes.style.height = "100%";
  2150. }
  2151. }
  2152. if (aElement) {
  2153. ui.children.push(aElement);
  2154. }
  2155. if (!caption) {
  2156. if (ui.attributes.class) {
  2157. ui.attributes.class.push("xfaLeft");
  2158. }
  2159. this.w = savedW;
  2160. this.h = savedH;
  2161. return _utils.HTMLResult.success((0, _html_utils.createWrapper)(this, html), bbox);
  2162. }
  2163. if (this.ui.button) {
  2164. if (style.padding) {
  2165. delete style.padding;
  2166. }
  2167. if (caption.name === "div") {
  2168. caption.name = "span";
  2169. }
  2170. ui.children.push(caption);
  2171. return _utils.HTMLResult.success(html, bbox);
  2172. } else if (this.ui.checkButton) {
  2173. caption.attributes.class[0] = "xfaCaptionForCheckButton";
  2174. }
  2175. if (!ui.attributes.class) {
  2176. ui.attributes.class = [];
  2177. }
  2178. ui.children.splice(0, 0, caption);
  2179. switch (this.caption.placement) {
  2180. case "left":
  2181. ui.attributes.class.push("xfaLeft");
  2182. break;
  2183. case "right":
  2184. ui.attributes.class.push("xfaRight");
  2185. break;
  2186. case "top":
  2187. ui.attributes.class.push("xfaTop");
  2188. break;
  2189. case "bottom":
  2190. ui.attributes.class.push("xfaBottom");
  2191. break;
  2192. case "inline":
  2193. ui.attributes.class.push("xfaLeft");
  2194. break;
  2195. }
  2196. this.w = savedW;
  2197. this.h = savedH;
  2198. return _utils.HTMLResult.success((0, _html_utils.createWrapper)(this, html), bbox);
  2199. }
  2200. }
  2201. exports.Field = Field;
  2202. class Fill extends _xfa_object.XFAObject {
  2203. constructor(attributes) {
  2204. super(TEMPLATE_NS_ID, "fill", true);
  2205. this.id = attributes.id || "";
  2206. this.presence = (0, _utils.getStringOption)(attributes.presence, ["visible", "hidden", "inactive", "invisible"]);
  2207. this.use = attributes.use || "";
  2208. this.usehref = attributes.usehref || "";
  2209. this.color = null;
  2210. this.extras = null;
  2211. this.linear = null;
  2212. this.pattern = null;
  2213. this.radial = null;
  2214. this.solid = null;
  2215. this.stipple = null;
  2216. }
  2217. [_xfa_object.$toStyle]() {
  2218. const parent = this[_xfa_object.$getParent]();
  2219. const grandpa = parent[_xfa_object.$getParent]();
  2220. const ggrandpa = grandpa[_xfa_object.$getParent]();
  2221. const style = Object.create(null);
  2222. let propName = "color";
  2223. let altPropName = propName;
  2224. if (parent instanceof Border) {
  2225. propName = "background-color";
  2226. altPropName = "background";
  2227. if (ggrandpa instanceof Ui) {
  2228. style.backgroundColor = "white";
  2229. }
  2230. }
  2231. if (parent instanceof Rectangle || parent instanceof Arc) {
  2232. propName = altPropName = "fill";
  2233. style.fill = "white";
  2234. }
  2235. for (const name of Object.getOwnPropertyNames(this)) {
  2236. if (name === "extras" || name === "color") {
  2237. continue;
  2238. }
  2239. const obj = this[name];
  2240. if (!(obj instanceof _xfa_object.XFAObject)) {
  2241. continue;
  2242. }
  2243. const color = obj[_xfa_object.$toStyle](this.color);
  2244. if (color) {
  2245. style[color.startsWith("#") ? propName : altPropName] = color;
  2246. }
  2247. return style;
  2248. }
  2249. if (this.color && this.color.value) {
  2250. const color = this.color[_xfa_object.$toStyle]();
  2251. style[color.startsWith("#") ? propName : altPropName] = color;
  2252. }
  2253. return style;
  2254. }
  2255. }
  2256. class Filter extends _xfa_object.XFAObject {
  2257. constructor(attributes) {
  2258. super(TEMPLATE_NS_ID, "filter", true);
  2259. this.addRevocationInfo = (0, _utils.getStringOption)(attributes.addRevocationInfo, ["", "required", "optional", "none"]);
  2260. this.id = attributes.id || "";
  2261. this.name = attributes.name || "";
  2262. this.use = attributes.use || "";
  2263. this.usehref = attributes.usehref || "";
  2264. this.version = (0, _utils.getInteger)({
  2265. data: this.version,
  2266. defaultValue: 5,
  2267. validate: x => x >= 1 && x <= 5
  2268. });
  2269. this.appearanceFilter = null;
  2270. this.certificates = null;
  2271. this.digestMethods = null;
  2272. this.encodings = null;
  2273. this.encryptionMethods = null;
  2274. this.handler = null;
  2275. this.lockDocument = null;
  2276. this.mdp = null;
  2277. this.reasons = null;
  2278. this.timeStamp = null;
  2279. }
  2280. }
  2281. class Float extends _xfa_object.ContentObject {
  2282. constructor(attributes) {
  2283. super(TEMPLATE_NS_ID, "float");
  2284. this.id = attributes.id || "";
  2285. this.name = attributes.name || "";
  2286. this.use = attributes.use || "";
  2287. this.usehref = attributes.usehref || "";
  2288. }
  2289. [_xfa_object.$finalize]() {
  2290. const number = parseFloat(this[_xfa_object.$content].trim());
  2291. this[_xfa_object.$content] = isNaN(number) ? null : number;
  2292. }
  2293. [_xfa_object.$toHTML](availableSpace) {
  2294. return valueToHtml(this[_xfa_object.$content] !== null ? this[_xfa_object.$content].toString() : "");
  2295. }
  2296. }
  2297. class Font extends _xfa_object.XFAObject {
  2298. constructor(attributes) {
  2299. super(TEMPLATE_NS_ID, "font", true);
  2300. this.baselineShift = (0, _utils.getMeasurement)(attributes.baselineShift);
  2301. this.fontHorizontalScale = (0, _utils.getFloat)({
  2302. data: attributes.fontHorizontalScale,
  2303. defaultValue: 100,
  2304. validate: x => x >= 0
  2305. });
  2306. this.fontVerticalScale = (0, _utils.getFloat)({
  2307. data: attributes.fontVerticalScale,
  2308. defaultValue: 100,
  2309. validate: x => x >= 0
  2310. });
  2311. this.id = attributes.id || "";
  2312. this.kerningMode = (0, _utils.getStringOption)(attributes.kerningMode, ["none", "pair"]);
  2313. this.letterSpacing = (0, _utils.getMeasurement)(attributes.letterSpacing, "0");
  2314. this.lineThrough = (0, _utils.getInteger)({
  2315. data: attributes.lineThrough,
  2316. defaultValue: 0,
  2317. validate: x => x === 1 || x === 2
  2318. });
  2319. this.lineThroughPeriod = (0, _utils.getStringOption)(attributes.lineThroughPeriod, ["all", "word"]);
  2320. this.overline = (0, _utils.getInteger)({
  2321. data: attributes.overline,
  2322. defaultValue: 0,
  2323. validate: x => x === 1 || x === 2
  2324. });
  2325. this.overlinePeriod = (0, _utils.getStringOption)(attributes.overlinePeriod, ["all", "word"]);
  2326. this.posture = (0, _utils.getStringOption)(attributes.posture, ["normal", "italic"]);
  2327. this.size = (0, _utils.getMeasurement)(attributes.size, "10pt");
  2328. this.typeface = attributes.typeface || "Courier";
  2329. this.underline = (0, _utils.getInteger)({
  2330. data: attributes.underline,
  2331. defaultValue: 0,
  2332. validate: x => x === 1 || x === 2
  2333. });
  2334. this.underlinePeriod = (0, _utils.getStringOption)(attributes.underlinePeriod, ["all", "word"]);
  2335. this.use = attributes.use || "";
  2336. this.usehref = attributes.usehref || "";
  2337. this.weight = (0, _utils.getStringOption)(attributes.weight, ["normal", "bold"]);
  2338. this.extras = null;
  2339. this.fill = null;
  2340. }
  2341. [_xfa_object.$clean](builder) {
  2342. super[_xfa_object.$clean](builder);
  2343. this[_xfa_object.$globalData].usedTypefaces.add(this.typeface);
  2344. }
  2345. [_xfa_object.$toStyle]() {
  2346. const style = (0, _html_utils.toStyle)(this, "fill");
  2347. const color = style.color;
  2348. if (color) {
  2349. if (color === "#000000") {
  2350. delete style.color;
  2351. } else if (!color.startsWith("#")) {
  2352. style.background = color;
  2353. style.backgroundClip = "text";
  2354. style.color = "transparent";
  2355. }
  2356. }
  2357. if (this.baselineShift) {
  2358. style.verticalAlign = (0, _html_utils.measureToString)(this.baselineShift);
  2359. }
  2360. style.fontKerning = this.kerningMode === "none" ? "none" : "normal";
  2361. style.letterSpacing = (0, _html_utils.measureToString)(this.letterSpacing);
  2362. if (this.lineThrough !== 0) {
  2363. style.textDecoration = "line-through";
  2364. if (this.lineThrough === 2) {
  2365. style.textDecorationStyle = "double";
  2366. }
  2367. }
  2368. if (this.overline !== 0) {
  2369. style.textDecoration = "overline";
  2370. if (this.overline === 2) {
  2371. style.textDecorationStyle = "double";
  2372. }
  2373. }
  2374. style.fontStyle = this.posture;
  2375. style.fontSize = (0, _html_utils.measureToString)(0.99 * this.size);
  2376. (0, _html_utils.setFontFamily)(this, this, this[_xfa_object.$globalData].fontFinder, style);
  2377. if (this.underline !== 0) {
  2378. style.textDecoration = "underline";
  2379. if (this.underline === 2) {
  2380. style.textDecorationStyle = "double";
  2381. }
  2382. }
  2383. style.fontWeight = this.weight;
  2384. return style;
  2385. }
  2386. }
  2387. class Format extends _xfa_object.XFAObject {
  2388. constructor(attributes) {
  2389. super(TEMPLATE_NS_ID, "format", true);
  2390. this.id = attributes.id || "";
  2391. this.use = attributes.use || "";
  2392. this.usehref = attributes.usehref || "";
  2393. this.extras = null;
  2394. this.picture = null;
  2395. }
  2396. }
  2397. class Handler extends _xfa_object.StringObject {
  2398. constructor(attributes) {
  2399. super(TEMPLATE_NS_ID, "handler");
  2400. this.id = attributes.id || "";
  2401. this.type = (0, _utils.getStringOption)(attributes.type, ["optional", "required"]);
  2402. this.use = attributes.use || "";
  2403. this.usehref = attributes.usehref || "";
  2404. }
  2405. }
  2406. class Hyphenation extends _xfa_object.XFAObject {
  2407. constructor(attributes) {
  2408. super(TEMPLATE_NS_ID, "hyphenation");
  2409. this.excludeAllCaps = (0, _utils.getInteger)({
  2410. data: attributes.excludeAllCaps,
  2411. defaultValue: 0,
  2412. validate: x => x === 1
  2413. });
  2414. this.excludeInitialCap = (0, _utils.getInteger)({
  2415. data: attributes.excludeInitialCap,
  2416. defaultValue: 0,
  2417. validate: x => x === 1
  2418. });
  2419. this.hyphenate = (0, _utils.getInteger)({
  2420. data: attributes.hyphenate,
  2421. defaultValue: 0,
  2422. validate: x => x === 1
  2423. });
  2424. this.id = attributes.id || "";
  2425. this.pushCharacterCount = (0, _utils.getInteger)({
  2426. data: attributes.pushCharacterCount,
  2427. defaultValue: 3,
  2428. validate: x => x >= 0
  2429. });
  2430. this.remainCharacterCount = (0, _utils.getInteger)({
  2431. data: attributes.remainCharacterCount,
  2432. defaultValue: 3,
  2433. validate: x => x >= 0
  2434. });
  2435. this.use = attributes.use || "";
  2436. this.usehref = attributes.usehref || "";
  2437. this.wordCharacterCount = (0, _utils.getInteger)({
  2438. data: attributes.wordCharacterCount,
  2439. defaultValue: 7,
  2440. validate: x => x >= 0
  2441. });
  2442. }
  2443. }
  2444. class Image extends _xfa_object.StringObject {
  2445. constructor(attributes) {
  2446. super(TEMPLATE_NS_ID, "image");
  2447. this.aspect = (0, _utils.getStringOption)(attributes.aspect, ["fit", "actual", "height", "none", "width"]);
  2448. this.contentType = attributes.contentType || "";
  2449. this.href = attributes.href || "";
  2450. this.id = attributes.id || "";
  2451. this.name = attributes.name || "";
  2452. this.transferEncoding = (0, _utils.getStringOption)(attributes.transferEncoding, ["base64", "none", "package"]);
  2453. this.use = attributes.use || "";
  2454. this.usehref = attributes.usehref || "";
  2455. }
  2456. [_xfa_object.$toHTML]() {
  2457. if (this.contentType && !MIMES.has(this.contentType.toLowerCase())) {
  2458. return _utils.HTMLResult.EMPTY;
  2459. }
  2460. let buffer = this[_xfa_object.$globalData].images && this[_xfa_object.$globalData].images.get(this.href);
  2461. if (!buffer && (this.href || !this[_xfa_object.$content])) {
  2462. return _utils.HTMLResult.EMPTY;
  2463. }
  2464. if (!buffer && this.transferEncoding === "base64") {
  2465. buffer = (0, _util.stringToBytes)(atob(this[_xfa_object.$content]));
  2466. }
  2467. if (!buffer) {
  2468. return _utils.HTMLResult.EMPTY;
  2469. }
  2470. if (!this.contentType) {
  2471. for (const [header, type] of IMAGES_HEADERS) {
  2472. if (buffer.length > header.length && header.every((x, i) => x === buffer[i])) {
  2473. this.contentType = type;
  2474. break;
  2475. }
  2476. }
  2477. if (!this.contentType) {
  2478. return _utils.HTMLResult.EMPTY;
  2479. }
  2480. }
  2481. const blob = new Blob([buffer], {
  2482. type: this.contentType
  2483. });
  2484. let style;
  2485. switch (this.aspect) {
  2486. case "fit":
  2487. case "actual":
  2488. break;
  2489. case "height":
  2490. style = {
  2491. height: "100%",
  2492. objectFit: "fill"
  2493. };
  2494. break;
  2495. case "none":
  2496. style = {
  2497. width: "100%",
  2498. height: "100%",
  2499. objectFit: "fill"
  2500. };
  2501. break;
  2502. case "width":
  2503. style = {
  2504. width: "100%",
  2505. objectFit: "fill"
  2506. };
  2507. break;
  2508. }
  2509. const parent = this[_xfa_object.$getParent]();
  2510. return _utils.HTMLResult.success({
  2511. name: "img",
  2512. attributes: {
  2513. class: ["xfaImage"],
  2514. style,
  2515. src: URL.createObjectURL(blob),
  2516. alt: parent ? ariaLabel(parent[_xfa_object.$getParent]()) : null
  2517. }
  2518. });
  2519. }
  2520. }
  2521. class ImageEdit extends _xfa_object.XFAObject {
  2522. constructor(attributes) {
  2523. super(TEMPLATE_NS_ID, "imageEdit", true);
  2524. this.data = (0, _utils.getStringOption)(attributes.data, ["link", "embed"]);
  2525. this.id = attributes.id || "";
  2526. this.use = attributes.use || "";
  2527. this.usehref = attributes.usehref || "";
  2528. this.border = null;
  2529. this.extras = null;
  2530. this.margin = null;
  2531. }
  2532. [_xfa_object.$toHTML](availableSpace) {
  2533. if (this.data === "embed") {
  2534. return _utils.HTMLResult.success({
  2535. name: "div",
  2536. children: [],
  2537. attributes: {}
  2538. });
  2539. }
  2540. return _utils.HTMLResult.EMPTY;
  2541. }
  2542. }
  2543. class Integer extends _xfa_object.ContentObject {
  2544. constructor(attributes) {
  2545. super(TEMPLATE_NS_ID, "integer");
  2546. this.id = attributes.id || "";
  2547. this.name = attributes.name || "";
  2548. this.use = attributes.use || "";
  2549. this.usehref = attributes.usehref || "";
  2550. }
  2551. [_xfa_object.$finalize]() {
  2552. const number = parseInt(this[_xfa_object.$content].trim(), 10);
  2553. this[_xfa_object.$content] = isNaN(number) ? null : number;
  2554. }
  2555. [_xfa_object.$toHTML](availableSpace) {
  2556. return valueToHtml(this[_xfa_object.$content] !== null ? this[_xfa_object.$content].toString() : "");
  2557. }
  2558. }
  2559. class Issuers extends _xfa_object.XFAObject {
  2560. constructor(attributes) {
  2561. super(TEMPLATE_NS_ID, "issuers", true);
  2562. this.id = attributes.id || "";
  2563. this.type = (0, _utils.getStringOption)(attributes.type, ["optional", "required"]);
  2564. this.use = attributes.use || "";
  2565. this.usehref = attributes.usehref || "";
  2566. this.certificate = new _xfa_object.XFAObjectArray();
  2567. }
  2568. }
  2569. class Items extends _xfa_object.XFAObject {
  2570. constructor(attributes) {
  2571. super(TEMPLATE_NS_ID, "items", true);
  2572. this.id = attributes.id || "";
  2573. this.name = attributes.name || "";
  2574. this.presence = (0, _utils.getStringOption)(attributes.presence, ["visible", "hidden", "inactive", "invisible"]);
  2575. this.ref = attributes.ref || "";
  2576. this.save = (0, _utils.getInteger)({
  2577. data: attributes.save,
  2578. defaultValue: 0,
  2579. validate: x => x === 1
  2580. });
  2581. this.use = attributes.use || "";
  2582. this.usehref = attributes.usehref || "";
  2583. this.boolean = new _xfa_object.XFAObjectArray();
  2584. this.date = new _xfa_object.XFAObjectArray();
  2585. this.dateTime = new _xfa_object.XFAObjectArray();
  2586. this.decimal = new _xfa_object.XFAObjectArray();
  2587. this.exData = new _xfa_object.XFAObjectArray();
  2588. this.float = new _xfa_object.XFAObjectArray();
  2589. this.image = new _xfa_object.XFAObjectArray();
  2590. this.integer = new _xfa_object.XFAObjectArray();
  2591. this.text = new _xfa_object.XFAObjectArray();
  2592. this.time = new _xfa_object.XFAObjectArray();
  2593. }
  2594. [_xfa_object.$toHTML]() {
  2595. const output = [];
  2596. for (const child of this[_xfa_object.$getChildren]()) {
  2597. output.push(child[_xfa_object.$text]());
  2598. }
  2599. return _utils.HTMLResult.success(output);
  2600. }
  2601. }
  2602. exports.Items = Items;
  2603. class Keep extends _xfa_object.XFAObject {
  2604. constructor(attributes) {
  2605. super(TEMPLATE_NS_ID, "keep", true);
  2606. this.id = attributes.id || "";
  2607. const options = ["none", "contentArea", "pageArea"];
  2608. this.intact = (0, _utils.getStringOption)(attributes.intact, options);
  2609. this.next = (0, _utils.getStringOption)(attributes.next, options);
  2610. this.previous = (0, _utils.getStringOption)(attributes.previous, options);
  2611. this.use = attributes.use || "";
  2612. this.usehref = attributes.usehref || "";
  2613. this.extras = null;
  2614. }
  2615. }
  2616. class KeyUsage extends _xfa_object.XFAObject {
  2617. constructor(attributes) {
  2618. super(TEMPLATE_NS_ID, "keyUsage");
  2619. const options = ["", "yes", "no"];
  2620. this.crlSign = (0, _utils.getStringOption)(attributes.crlSign, options);
  2621. this.dataEncipherment = (0, _utils.getStringOption)(attributes.dataEncipherment, options);
  2622. this.decipherOnly = (0, _utils.getStringOption)(attributes.decipherOnly, options);
  2623. this.digitalSignature = (0, _utils.getStringOption)(attributes.digitalSignature, options);
  2624. this.encipherOnly = (0, _utils.getStringOption)(attributes.encipherOnly, options);
  2625. this.id = attributes.id || "";
  2626. this.keyAgreement = (0, _utils.getStringOption)(attributes.keyAgreement, options);
  2627. this.keyCertSign = (0, _utils.getStringOption)(attributes.keyCertSign, options);
  2628. this.keyEncipherment = (0, _utils.getStringOption)(attributes.keyEncipherment, options);
  2629. this.nonRepudiation = (0, _utils.getStringOption)(attributes.nonRepudiation, options);
  2630. this.type = (0, _utils.getStringOption)(attributes.type, ["optional", "required"]);
  2631. this.use = attributes.use || "";
  2632. this.usehref = attributes.usehref || "";
  2633. }
  2634. }
  2635. class Line extends _xfa_object.XFAObject {
  2636. constructor(attributes) {
  2637. super(TEMPLATE_NS_ID, "line", true);
  2638. this.hand = (0, _utils.getStringOption)(attributes.hand, ["even", "left", "right"]);
  2639. this.id = attributes.id || "";
  2640. this.slope = (0, _utils.getStringOption)(attributes.slope, ["\\", "/"]);
  2641. this.use = attributes.use || "";
  2642. this.usehref = attributes.usehref || "";
  2643. this.edge = null;
  2644. }
  2645. [_xfa_object.$toHTML]() {
  2646. const parent = this[_xfa_object.$getParent]()[_xfa_object.$getParent]();
  2647. const edge = this.edge || new Edge({});
  2648. const edgeStyle = edge[_xfa_object.$toStyle]();
  2649. const style = Object.create(null);
  2650. const thickness = edge.presence === "visible" ? edge.thickness : 0;
  2651. style.strokeWidth = (0, _html_utils.measureToString)(thickness);
  2652. style.stroke = edgeStyle.color;
  2653. let x1, y1, x2, y2;
  2654. let width = "100%";
  2655. let height = "100%";
  2656. if (parent.w <= thickness) {
  2657. [x1, y1, x2, y2] = ["50%", 0, "50%", "100%"];
  2658. width = style.strokeWidth;
  2659. } else if (parent.h <= thickness) {
  2660. [x1, y1, x2, y2] = [0, "50%", "100%", "50%"];
  2661. height = style.strokeWidth;
  2662. } else {
  2663. if (this.slope === "\\") {
  2664. [x1, y1, x2, y2] = [0, 0, "100%", "100%"];
  2665. } else {
  2666. [x1, y1, x2, y2] = [0, "100%", "100%", 0];
  2667. }
  2668. }
  2669. const line = {
  2670. name: "line",
  2671. attributes: {
  2672. xmlns: SVG_NS,
  2673. x1,
  2674. y1,
  2675. x2,
  2676. y2,
  2677. style
  2678. }
  2679. };
  2680. const svg = {
  2681. name: "svg",
  2682. children: [line],
  2683. attributes: {
  2684. xmlns: SVG_NS,
  2685. width,
  2686. height,
  2687. style: {
  2688. overflow: "visible"
  2689. }
  2690. }
  2691. };
  2692. if (hasMargin(parent)) {
  2693. return _utils.HTMLResult.success({
  2694. name: "div",
  2695. attributes: {
  2696. style: {
  2697. display: "inline",
  2698. width: "100%",
  2699. height: "100%"
  2700. }
  2701. },
  2702. children: [svg]
  2703. });
  2704. }
  2705. svg.attributes.style.position = "absolute";
  2706. return _utils.HTMLResult.success(svg);
  2707. }
  2708. }
  2709. class Linear extends _xfa_object.XFAObject {
  2710. constructor(attributes) {
  2711. super(TEMPLATE_NS_ID, "linear", true);
  2712. this.id = attributes.id || "";
  2713. this.type = (0, _utils.getStringOption)(attributes.type, ["toRight", "toBottom", "toLeft", "toTop"]);
  2714. this.use = attributes.use || "";
  2715. this.usehref = attributes.usehref || "";
  2716. this.color = null;
  2717. this.extras = null;
  2718. }
  2719. [_xfa_object.$toStyle](startColor) {
  2720. startColor = startColor ? startColor[_xfa_object.$toStyle]() : "#FFFFFF";
  2721. const transf = this.type.replace(/([RBLT])/, " $1").toLowerCase();
  2722. const endColor = this.color ? this.color[_xfa_object.$toStyle]() : "#000000";
  2723. return `linear-gradient(${transf}, ${startColor}, ${endColor})`;
  2724. }
  2725. }
  2726. class LockDocument extends _xfa_object.ContentObject {
  2727. constructor(attributes) {
  2728. super(TEMPLATE_NS_ID, "lockDocument");
  2729. this.id = attributes.id || "";
  2730. this.type = (0, _utils.getStringOption)(attributes.type, ["optional", "required"]);
  2731. this.use = attributes.use || "";
  2732. this.usehref = attributes.usehref || "";
  2733. }
  2734. [_xfa_object.$finalize]() {
  2735. this[_xfa_object.$content] = (0, _utils.getStringOption)(this[_xfa_object.$content], ["auto", "0", "1"]);
  2736. }
  2737. }
  2738. class Manifest extends _xfa_object.XFAObject {
  2739. constructor(attributes) {
  2740. super(TEMPLATE_NS_ID, "manifest", true);
  2741. this.action = (0, _utils.getStringOption)(attributes.action, ["include", "all", "exclude"]);
  2742. this.id = attributes.id || "";
  2743. this.name = attributes.name || "";
  2744. this.use = attributes.use || "";
  2745. this.usehref = attributes.usehref || "";
  2746. this.extras = null;
  2747. this.ref = new _xfa_object.XFAObjectArray();
  2748. }
  2749. }
  2750. class Margin extends _xfa_object.XFAObject {
  2751. constructor(attributes) {
  2752. super(TEMPLATE_NS_ID, "margin", true);
  2753. this.bottomInset = (0, _utils.getMeasurement)(attributes.bottomInset, "0");
  2754. this.id = attributes.id || "";
  2755. this.leftInset = (0, _utils.getMeasurement)(attributes.leftInset, "0");
  2756. this.rightInset = (0, _utils.getMeasurement)(attributes.rightInset, "0");
  2757. this.topInset = (0, _utils.getMeasurement)(attributes.topInset, "0");
  2758. this.use = attributes.use || "";
  2759. this.usehref = attributes.usehref || "";
  2760. this.extras = null;
  2761. }
  2762. [_xfa_object.$toStyle]() {
  2763. return {
  2764. margin: (0, _html_utils.measureToString)(this.topInset) + " " + (0, _html_utils.measureToString)(this.rightInset) + " " + (0, _html_utils.measureToString)(this.bottomInset) + " " + (0, _html_utils.measureToString)(this.leftInset)
  2765. };
  2766. }
  2767. }
  2768. class Mdp extends _xfa_object.XFAObject {
  2769. constructor(attributes) {
  2770. super(TEMPLATE_NS_ID, "mdp");
  2771. this.id = attributes.id || "";
  2772. this.permissions = (0, _utils.getInteger)({
  2773. data: attributes.permissions,
  2774. defaultValue: 2,
  2775. validate: x => x === 1 || x === 3
  2776. });
  2777. this.signatureType = (0, _utils.getStringOption)(attributes.signatureType, ["filler", "author"]);
  2778. this.use = attributes.use || "";
  2779. this.usehref = attributes.usehref || "";
  2780. }
  2781. }
  2782. class Medium extends _xfa_object.XFAObject {
  2783. constructor(attributes) {
  2784. super(TEMPLATE_NS_ID, "medium");
  2785. this.id = attributes.id || "";
  2786. this.imagingBBox = (0, _utils.getBBox)(attributes.imagingBBox);
  2787. this.long = (0, _utils.getMeasurement)(attributes.long);
  2788. this.orientation = (0, _utils.getStringOption)(attributes.orientation, ["portrait", "landscape"]);
  2789. this.short = (0, _utils.getMeasurement)(attributes.short);
  2790. this.stock = attributes.stock || "";
  2791. this.trayIn = (0, _utils.getStringOption)(attributes.trayIn, ["auto", "delegate", "pageFront"]);
  2792. this.trayOut = (0, _utils.getStringOption)(attributes.trayOut, ["auto", "delegate"]);
  2793. this.use = attributes.use || "";
  2794. this.usehref = attributes.usehref || "";
  2795. }
  2796. }
  2797. class Message extends _xfa_object.XFAObject {
  2798. constructor(attributes) {
  2799. super(TEMPLATE_NS_ID, "message", true);
  2800. this.id = attributes.id || "";
  2801. this.use = attributes.use || "";
  2802. this.usehref = attributes.usehref || "";
  2803. this.text = new _xfa_object.XFAObjectArray();
  2804. }
  2805. }
  2806. class NumericEdit extends _xfa_object.XFAObject {
  2807. constructor(attributes) {
  2808. super(TEMPLATE_NS_ID, "numericEdit", true);
  2809. this.hScrollPolicy = (0, _utils.getStringOption)(attributes.hScrollPolicy, ["auto", "off", "on"]);
  2810. this.id = attributes.id || "";
  2811. this.use = attributes.use || "";
  2812. this.usehref = attributes.usehref || "";
  2813. this.border = null;
  2814. this.comb = null;
  2815. this.extras = null;
  2816. this.margin = null;
  2817. }
  2818. [_xfa_object.$toHTML](availableSpace) {
  2819. const style = (0, _html_utils.toStyle)(this, "border", "font", "margin");
  2820. const field = this[_xfa_object.$getParent]()[_xfa_object.$getParent]();
  2821. const html = {
  2822. name: "input",
  2823. attributes: {
  2824. type: "text",
  2825. fieldId: field[_xfa_object.$uid],
  2826. dataId: field[_xfa_object.$data] && field[_xfa_object.$data][_xfa_object.$uid] || field[_xfa_object.$uid],
  2827. class: ["xfaTextfield"],
  2828. style,
  2829. "aria-label": ariaLabel(field),
  2830. "aria-required": false
  2831. }
  2832. };
  2833. if (isRequired(field)) {
  2834. html.attributes["aria-required"] = true;
  2835. html.attributes.required = true;
  2836. }
  2837. return _utils.HTMLResult.success({
  2838. name: "label",
  2839. attributes: {
  2840. class: ["xfaLabel"]
  2841. },
  2842. children: [html]
  2843. });
  2844. }
  2845. }
  2846. class Occur extends _xfa_object.XFAObject {
  2847. constructor(attributes) {
  2848. super(TEMPLATE_NS_ID, "occur", true);
  2849. this.id = attributes.id || "";
  2850. this.initial = attributes.initial !== "" ? (0, _utils.getInteger)({
  2851. data: attributes.initial,
  2852. defaultValue: "",
  2853. validate: x => true
  2854. }) : "";
  2855. this.max = attributes.max !== "" ? (0, _utils.getInteger)({
  2856. data: attributes.max,
  2857. defaultValue: 1,
  2858. validate: x => true
  2859. }) : "";
  2860. this.min = attributes.min !== "" ? (0, _utils.getInteger)({
  2861. data: attributes.min,
  2862. defaultValue: 1,
  2863. validate: x => true
  2864. }) : "";
  2865. this.use = attributes.use || "";
  2866. this.usehref = attributes.usehref || "";
  2867. this.extras = null;
  2868. }
  2869. [_xfa_object.$clean]() {
  2870. const parent = this[_xfa_object.$getParent]();
  2871. const originalMin = this.min;
  2872. if (this.min === "") {
  2873. this.min = parent instanceof PageArea || parent instanceof PageSet ? 0 : 1;
  2874. }
  2875. if (this.max === "") {
  2876. if (originalMin === "") {
  2877. this.max = parent instanceof PageArea || parent instanceof PageSet ? -1 : 1;
  2878. } else {
  2879. this.max = this.min;
  2880. }
  2881. }
  2882. if (this.max !== -1 && this.max < this.min) {
  2883. this.max = this.min;
  2884. }
  2885. if (this.initial === "") {
  2886. this.initial = parent instanceof Template ? 1 : this.min;
  2887. }
  2888. }
  2889. }
  2890. class Oid extends _xfa_object.StringObject {
  2891. constructor(attributes) {
  2892. super(TEMPLATE_NS_ID, "oid");
  2893. this.id = attributes.id || "";
  2894. this.name = attributes.name || "";
  2895. this.use = attributes.use || "";
  2896. this.usehref = attributes.usehref || "";
  2897. }
  2898. }
  2899. class Oids extends _xfa_object.XFAObject {
  2900. constructor(attributes) {
  2901. super(TEMPLATE_NS_ID, "oids", true);
  2902. this.id = attributes.id || "";
  2903. this.type = (0, _utils.getStringOption)(attributes.type, ["optional", "required"]);
  2904. this.use = attributes.use || "";
  2905. this.usehref = attributes.usehref || "";
  2906. this.oid = new _xfa_object.XFAObjectArray();
  2907. }
  2908. }
  2909. class Overflow extends _xfa_object.XFAObject {
  2910. constructor(attributes) {
  2911. super(TEMPLATE_NS_ID, "overflow");
  2912. this.id = attributes.id || "";
  2913. this.leader = attributes.leader || "";
  2914. this.target = attributes.target || "";
  2915. this.trailer = attributes.trailer || "";
  2916. this.use = attributes.use || "";
  2917. this.usehref = attributes.usehref || "";
  2918. }
  2919. [_xfa_object.$getExtra]() {
  2920. if (!this[_xfa_object.$extra]) {
  2921. const parent = this[_xfa_object.$getParent]();
  2922. const root = this[_xfa_object.$getTemplateRoot]();
  2923. const target = root[_xfa_object.$searchNode](this.target, parent);
  2924. const leader = root[_xfa_object.$searchNode](this.leader, parent);
  2925. const trailer = root[_xfa_object.$searchNode](this.trailer, parent);
  2926. this[_xfa_object.$extra] = {
  2927. target: target && target[0] || null,
  2928. leader: leader && leader[0] || null,
  2929. trailer: trailer && trailer[0] || null,
  2930. addLeader: false,
  2931. addTrailer: false
  2932. };
  2933. }
  2934. return this[_xfa_object.$extra];
  2935. }
  2936. }
  2937. class PageArea extends _xfa_object.XFAObject {
  2938. constructor(attributes) {
  2939. super(TEMPLATE_NS_ID, "pageArea", true);
  2940. this.blankOrNotBlank = (0, _utils.getStringOption)(attributes.blankOrNotBlank, ["any", "blank", "notBlank"]);
  2941. this.id = attributes.id || "";
  2942. this.initialNumber = (0, _utils.getInteger)({
  2943. data: attributes.initialNumber,
  2944. defaultValue: 1,
  2945. validate: x => true
  2946. });
  2947. this.name = attributes.name || "";
  2948. this.numbered = (0, _utils.getInteger)({
  2949. data: attributes.numbered,
  2950. defaultValue: 1,
  2951. validate: x => true
  2952. });
  2953. this.oddOrEven = (0, _utils.getStringOption)(attributes.oddOrEven, ["any", "even", "odd"]);
  2954. this.pagePosition = (0, _utils.getStringOption)(attributes.pagePosition, ["any", "first", "last", "only", "rest"]);
  2955. this.relevant = (0, _utils.getRelevant)(attributes.relevant);
  2956. this.use = attributes.use || "";
  2957. this.usehref = attributes.usehref || "";
  2958. this.desc = null;
  2959. this.extras = null;
  2960. this.medium = null;
  2961. this.occur = null;
  2962. this.area = new _xfa_object.XFAObjectArray();
  2963. this.contentArea = new _xfa_object.XFAObjectArray();
  2964. this.draw = new _xfa_object.XFAObjectArray();
  2965. this.exclGroup = new _xfa_object.XFAObjectArray();
  2966. this.field = new _xfa_object.XFAObjectArray();
  2967. this.subform = new _xfa_object.XFAObjectArray();
  2968. }
  2969. [_xfa_object.$isUsable]() {
  2970. if (!this[_xfa_object.$extra]) {
  2971. this[_xfa_object.$extra] = {
  2972. numberOfUse: 0
  2973. };
  2974. return true;
  2975. }
  2976. return !this.occur || this.occur.max === -1 || this[_xfa_object.$extra].numberOfUse < this.occur.max;
  2977. }
  2978. [_xfa_object.$cleanPage]() {
  2979. delete this[_xfa_object.$extra];
  2980. }
  2981. [_xfa_object.$getNextPage]() {
  2982. if (!this[_xfa_object.$extra]) {
  2983. this[_xfa_object.$extra] = {
  2984. numberOfUse: 0
  2985. };
  2986. }
  2987. const parent = this[_xfa_object.$getParent]();
  2988. if (parent.relation === "orderedOccurrence") {
  2989. if (this[_xfa_object.$isUsable]()) {
  2990. this[_xfa_object.$extra].numberOfUse += 1;
  2991. return this;
  2992. }
  2993. }
  2994. return parent[_xfa_object.$getNextPage]();
  2995. }
  2996. [_xfa_object.$getAvailableSpace]() {
  2997. return this[_xfa_object.$extra].space || {
  2998. width: 0,
  2999. height: 0
  3000. };
  3001. }
  3002. [_xfa_object.$toHTML]() {
  3003. if (!this[_xfa_object.$extra]) {
  3004. this[_xfa_object.$extra] = {
  3005. numberOfUse: 1
  3006. };
  3007. }
  3008. const children = [];
  3009. this[_xfa_object.$extra].children = children;
  3010. const style = Object.create(null);
  3011. if (this.medium && this.medium.short && this.medium.long) {
  3012. style.width = (0, _html_utils.measureToString)(this.medium.short);
  3013. style.height = (0, _html_utils.measureToString)(this.medium.long);
  3014. this[_xfa_object.$extra].space = {
  3015. width: this.medium.short,
  3016. height: this.medium.long
  3017. };
  3018. if (this.medium.orientation === "landscape") {
  3019. const x = style.width;
  3020. style.width = style.height;
  3021. style.height = x;
  3022. this[_xfa_object.$extra].space = {
  3023. width: this.medium.long,
  3024. height: this.medium.short
  3025. };
  3026. }
  3027. } else {
  3028. (0, _util.warn)("XFA - No medium specified in pageArea: please file a bug.");
  3029. }
  3030. this[_xfa_object.$childrenToHTML]({
  3031. filter: new Set(["area", "draw", "field", "subform"]),
  3032. include: true
  3033. });
  3034. this[_xfa_object.$childrenToHTML]({
  3035. filter: new Set(["contentArea"]),
  3036. include: true
  3037. });
  3038. return _utils.HTMLResult.success({
  3039. name: "div",
  3040. children,
  3041. attributes: {
  3042. class: ["xfaPage"],
  3043. id: this[_xfa_object.$uid],
  3044. style,
  3045. xfaName: this.name
  3046. }
  3047. });
  3048. }
  3049. }
  3050. class PageSet extends _xfa_object.XFAObject {
  3051. constructor(attributes) {
  3052. super(TEMPLATE_NS_ID, "pageSet", true);
  3053. this.duplexImposition = (0, _utils.getStringOption)(attributes.duplexImposition, ["longEdge", "shortEdge"]);
  3054. this.id = attributes.id || "";
  3055. this.name = attributes.name || "";
  3056. this.relation = (0, _utils.getStringOption)(attributes.relation, ["orderedOccurrence", "duplexPaginated", "simplexPaginated"]);
  3057. this.relevant = (0, _utils.getRelevant)(attributes.relevant);
  3058. this.use = attributes.use || "";
  3059. this.usehref = attributes.usehref || "";
  3060. this.extras = null;
  3061. this.occur = null;
  3062. this.pageArea = new _xfa_object.XFAObjectArray();
  3063. this.pageSet = new _xfa_object.XFAObjectArray();
  3064. }
  3065. [_xfa_object.$cleanPage]() {
  3066. for (const page of this.pageArea.children) {
  3067. page[_xfa_object.$cleanPage]();
  3068. }
  3069. for (const page of this.pageSet.children) {
  3070. page[_xfa_object.$cleanPage]();
  3071. }
  3072. }
  3073. [_xfa_object.$isUsable]() {
  3074. return !this.occur || this.occur.max === -1 || this[_xfa_object.$extra].numberOfUse < this.occur.max;
  3075. }
  3076. [_xfa_object.$getNextPage]() {
  3077. if (!this[_xfa_object.$extra]) {
  3078. this[_xfa_object.$extra] = {
  3079. numberOfUse: 1,
  3080. pageIndex: -1,
  3081. pageSetIndex: -1
  3082. };
  3083. }
  3084. if (this.relation === "orderedOccurrence") {
  3085. if (this[_xfa_object.$extra].pageIndex + 1 < this.pageArea.children.length) {
  3086. this[_xfa_object.$extra].pageIndex += 1;
  3087. const pageArea = this.pageArea.children[this[_xfa_object.$extra].pageIndex];
  3088. return pageArea[_xfa_object.$getNextPage]();
  3089. }
  3090. if (this[_xfa_object.$extra].pageSetIndex + 1 < this.pageSet.children.length) {
  3091. this[_xfa_object.$extra].pageSetIndex += 1;
  3092. return this.pageSet.children[this[_xfa_object.$extra].pageSetIndex][_xfa_object.$getNextPage]();
  3093. }
  3094. if (this[_xfa_object.$isUsable]()) {
  3095. this[_xfa_object.$extra].numberOfUse += 1;
  3096. this[_xfa_object.$extra].pageIndex = -1;
  3097. this[_xfa_object.$extra].pageSetIndex = -1;
  3098. return this[_xfa_object.$getNextPage]();
  3099. }
  3100. const parent = this[_xfa_object.$getParent]();
  3101. if (parent instanceof PageSet) {
  3102. return parent[_xfa_object.$getNextPage]();
  3103. }
  3104. this[_xfa_object.$cleanPage]();
  3105. return this[_xfa_object.$getNextPage]();
  3106. }
  3107. const pageNumber = this[_xfa_object.$getTemplateRoot]()[_xfa_object.$extra].pageNumber;
  3108. const parity = pageNumber % 2 === 0 ? "even" : "odd";
  3109. const position = pageNumber === 0 ? "first" : "rest";
  3110. let page = this.pageArea.children.find(p => p.oddOrEven === parity && p.pagePosition === position);
  3111. if (page) {
  3112. return page;
  3113. }
  3114. page = this.pageArea.children.find(p => p.oddOrEven === "any" && p.pagePosition === position);
  3115. if (page) {
  3116. return page;
  3117. }
  3118. page = this.pageArea.children.find(p => p.oddOrEven === "any" && p.pagePosition === "any");
  3119. if (page) {
  3120. return page;
  3121. }
  3122. return this.pageArea.children[0];
  3123. }
  3124. }
  3125. class Para extends _xfa_object.XFAObject {
  3126. constructor(attributes) {
  3127. super(TEMPLATE_NS_ID, "para", true);
  3128. this.hAlign = (0, _utils.getStringOption)(attributes.hAlign, ["left", "center", "justify", "justifyAll", "radix", "right"]);
  3129. this.id = attributes.id || "";
  3130. this.lineHeight = attributes.lineHeight ? (0, _utils.getMeasurement)(attributes.lineHeight, "0pt") : "";
  3131. this.marginLeft = attributes.marginLeft ? (0, _utils.getMeasurement)(attributes.marginLeft, "0pt") : "";
  3132. this.marginRight = attributes.marginRight ? (0, _utils.getMeasurement)(attributes.marginRight, "0pt") : "";
  3133. this.orphans = (0, _utils.getInteger)({
  3134. data: attributes.orphans,
  3135. defaultValue: 0,
  3136. validate: x => x >= 0
  3137. });
  3138. this.preserve = attributes.preserve || "";
  3139. this.radixOffset = attributes.radixOffset ? (0, _utils.getMeasurement)(attributes.radixOffset, "0pt") : "";
  3140. this.spaceAbove = attributes.spaceAbove ? (0, _utils.getMeasurement)(attributes.spaceAbove, "0pt") : "";
  3141. this.spaceBelow = attributes.spaceBelow ? (0, _utils.getMeasurement)(attributes.spaceBelow, "0pt") : "";
  3142. this.tabDefault = attributes.tabDefault ? (0, _utils.getMeasurement)(this.tabDefault) : "";
  3143. this.tabStops = (attributes.tabStops || "").trim().split(/\s+/).map((x, i) => i % 2 === 1 ? (0, _utils.getMeasurement)(x) : x);
  3144. this.textIndent = attributes.textIndent ? (0, _utils.getMeasurement)(attributes.textIndent, "0pt") : "";
  3145. this.use = attributes.use || "";
  3146. this.usehref = attributes.usehref || "";
  3147. this.vAlign = (0, _utils.getStringOption)(attributes.vAlign, ["top", "bottom", "middle"]);
  3148. this.widows = (0, _utils.getInteger)({
  3149. data: attributes.widows,
  3150. defaultValue: 0,
  3151. validate: x => x >= 0
  3152. });
  3153. this.hyphenation = null;
  3154. }
  3155. [_xfa_object.$toStyle]() {
  3156. const style = (0, _html_utils.toStyle)(this, "hAlign");
  3157. if (this.marginLeft !== "") {
  3158. style.paddingLeft = (0, _html_utils.measureToString)(this.marginLeft);
  3159. }
  3160. if (this.marginRight !== "") {
  3161. style.paddingight = (0, _html_utils.measureToString)(this.marginRight);
  3162. }
  3163. if (this.spaceAbove !== "") {
  3164. style.paddingTop = (0, _html_utils.measureToString)(this.spaceAbove);
  3165. }
  3166. if (this.spaceBelow !== "") {
  3167. style.paddingBottom = (0, _html_utils.measureToString)(this.spaceBelow);
  3168. }
  3169. if (this.textIndent !== "") {
  3170. style.textIndent = (0, _html_utils.measureToString)(this.textIndent);
  3171. (0, _html_utils.fixTextIndent)(style);
  3172. }
  3173. if (this.lineHeight > 0) {
  3174. style.lineHeight = (0, _html_utils.measureToString)(this.lineHeight);
  3175. }
  3176. if (this.tabDefault !== "") {
  3177. style.tabSize = (0, _html_utils.measureToString)(this.tabDefault);
  3178. }
  3179. if (this.tabStops.length > 0) {}
  3180. if (this.hyphenatation) {
  3181. Object.assign(style, this.hyphenatation[_xfa_object.$toStyle]());
  3182. }
  3183. return style;
  3184. }
  3185. }
  3186. class PasswordEdit extends _xfa_object.XFAObject {
  3187. constructor(attributes) {
  3188. super(TEMPLATE_NS_ID, "passwordEdit", true);
  3189. this.hScrollPolicy = (0, _utils.getStringOption)(attributes.hScrollPolicy, ["auto", "off", "on"]);
  3190. this.id = attributes.id || "";
  3191. this.passwordChar = attributes.passwordChar || "*";
  3192. this.use = attributes.use || "";
  3193. this.usehref = attributes.usehref || "";
  3194. this.border = null;
  3195. this.extras = null;
  3196. this.margin = null;
  3197. }
  3198. }
  3199. class Pattern extends _xfa_object.XFAObject {
  3200. constructor(attributes) {
  3201. super(TEMPLATE_NS_ID, "pattern", true);
  3202. this.id = attributes.id || "";
  3203. this.type = (0, _utils.getStringOption)(attributes.type, ["crossHatch", "crossDiagonal", "diagonalLeft", "diagonalRight", "horizontal", "vertical"]);
  3204. this.use = attributes.use || "";
  3205. this.usehref = attributes.usehref || "";
  3206. this.color = null;
  3207. this.extras = null;
  3208. }
  3209. [_xfa_object.$toStyle](startColor) {
  3210. startColor = startColor ? startColor[_xfa_object.$toStyle]() : "#FFFFFF";
  3211. const endColor = this.color ? this.color[_xfa_object.$toStyle]() : "#000000";
  3212. const width = 5;
  3213. const cmd = "repeating-linear-gradient";
  3214. const colors = `${startColor},${startColor} ${width}px,${endColor} ${width}px,${endColor} ${2 * width}px`;
  3215. switch (this.type) {
  3216. case "crossHatch":
  3217. return `${cmd}(to top,${colors}) ${cmd}(to right,${colors})`;
  3218. case "crossDiagonal":
  3219. return `${cmd}(45deg,${colors}) ${cmd}(-45deg,${colors})`;
  3220. case "diagonalLeft":
  3221. return `${cmd}(45deg,${colors})`;
  3222. case "diagonalRight":
  3223. return `${cmd}(-45deg,${colors})`;
  3224. case "horizontal":
  3225. return `${cmd}(to top,${colors})`;
  3226. case "vertical":
  3227. return `${cmd}(to right,${colors})`;
  3228. }
  3229. return "";
  3230. }
  3231. }
  3232. class Picture extends _xfa_object.StringObject {
  3233. constructor(attributes) {
  3234. super(TEMPLATE_NS_ID, "picture");
  3235. this.id = attributes.id || "";
  3236. this.use = attributes.use || "";
  3237. this.usehref = attributes.usehref || "";
  3238. }
  3239. }
  3240. class Proto extends _xfa_object.XFAObject {
  3241. constructor(attributes) {
  3242. super(TEMPLATE_NS_ID, "proto", true);
  3243. this.appearanceFilter = new _xfa_object.XFAObjectArray();
  3244. this.arc = new _xfa_object.XFAObjectArray();
  3245. this.area = new _xfa_object.XFAObjectArray();
  3246. this.assist = new _xfa_object.XFAObjectArray();
  3247. this.barcode = new _xfa_object.XFAObjectArray();
  3248. this.bindItems = new _xfa_object.XFAObjectArray();
  3249. this.bookend = new _xfa_object.XFAObjectArray();
  3250. this.boolean = new _xfa_object.XFAObjectArray();
  3251. this.border = new _xfa_object.XFAObjectArray();
  3252. this.break = new _xfa_object.XFAObjectArray();
  3253. this.breakAfter = new _xfa_object.XFAObjectArray();
  3254. this.breakBefore = new _xfa_object.XFAObjectArray();
  3255. this.button = new _xfa_object.XFAObjectArray();
  3256. this.calculate = new _xfa_object.XFAObjectArray();
  3257. this.caption = new _xfa_object.XFAObjectArray();
  3258. this.certificate = new _xfa_object.XFAObjectArray();
  3259. this.certificates = new _xfa_object.XFAObjectArray();
  3260. this.checkButton = new _xfa_object.XFAObjectArray();
  3261. this.choiceList = new _xfa_object.XFAObjectArray();
  3262. this.color = new _xfa_object.XFAObjectArray();
  3263. this.comb = new _xfa_object.XFAObjectArray();
  3264. this.connect = new _xfa_object.XFAObjectArray();
  3265. this.contentArea = new _xfa_object.XFAObjectArray();
  3266. this.corner = new _xfa_object.XFAObjectArray();
  3267. this.date = new _xfa_object.XFAObjectArray();
  3268. this.dateTime = new _xfa_object.XFAObjectArray();
  3269. this.dateTimeEdit = new _xfa_object.XFAObjectArray();
  3270. this.decimal = new _xfa_object.XFAObjectArray();
  3271. this.defaultUi = new _xfa_object.XFAObjectArray();
  3272. this.desc = new _xfa_object.XFAObjectArray();
  3273. this.digestMethod = new _xfa_object.XFAObjectArray();
  3274. this.digestMethods = new _xfa_object.XFAObjectArray();
  3275. this.draw = new _xfa_object.XFAObjectArray();
  3276. this.edge = new _xfa_object.XFAObjectArray();
  3277. this.encoding = new _xfa_object.XFAObjectArray();
  3278. this.encodings = new _xfa_object.XFAObjectArray();
  3279. this.encrypt = new _xfa_object.XFAObjectArray();
  3280. this.encryptData = new _xfa_object.XFAObjectArray();
  3281. this.encryption = new _xfa_object.XFAObjectArray();
  3282. this.encryptionMethod = new _xfa_object.XFAObjectArray();
  3283. this.encryptionMethods = new _xfa_object.XFAObjectArray();
  3284. this.event = new _xfa_object.XFAObjectArray();
  3285. this.exData = new _xfa_object.XFAObjectArray();
  3286. this.exObject = new _xfa_object.XFAObjectArray();
  3287. this.exclGroup = new _xfa_object.XFAObjectArray();
  3288. this.execute = new _xfa_object.XFAObjectArray();
  3289. this.extras = new _xfa_object.XFAObjectArray();
  3290. this.field = new _xfa_object.XFAObjectArray();
  3291. this.fill = new _xfa_object.XFAObjectArray();
  3292. this.filter = new _xfa_object.XFAObjectArray();
  3293. this.float = new _xfa_object.XFAObjectArray();
  3294. this.font = new _xfa_object.XFAObjectArray();
  3295. this.format = new _xfa_object.XFAObjectArray();
  3296. this.handler = new _xfa_object.XFAObjectArray();
  3297. this.hyphenation = new _xfa_object.XFAObjectArray();
  3298. this.image = new _xfa_object.XFAObjectArray();
  3299. this.imageEdit = new _xfa_object.XFAObjectArray();
  3300. this.integer = new _xfa_object.XFAObjectArray();
  3301. this.issuers = new _xfa_object.XFAObjectArray();
  3302. this.items = new _xfa_object.XFAObjectArray();
  3303. this.keep = new _xfa_object.XFAObjectArray();
  3304. this.keyUsage = new _xfa_object.XFAObjectArray();
  3305. this.line = new _xfa_object.XFAObjectArray();
  3306. this.linear = new _xfa_object.XFAObjectArray();
  3307. this.lockDocument = new _xfa_object.XFAObjectArray();
  3308. this.manifest = new _xfa_object.XFAObjectArray();
  3309. this.margin = new _xfa_object.XFAObjectArray();
  3310. this.mdp = new _xfa_object.XFAObjectArray();
  3311. this.medium = new _xfa_object.XFAObjectArray();
  3312. this.message = new _xfa_object.XFAObjectArray();
  3313. this.numericEdit = new _xfa_object.XFAObjectArray();
  3314. this.occur = new _xfa_object.XFAObjectArray();
  3315. this.oid = new _xfa_object.XFAObjectArray();
  3316. this.oids = new _xfa_object.XFAObjectArray();
  3317. this.overflow = new _xfa_object.XFAObjectArray();
  3318. this.pageArea = new _xfa_object.XFAObjectArray();
  3319. this.pageSet = new _xfa_object.XFAObjectArray();
  3320. this.para = new _xfa_object.XFAObjectArray();
  3321. this.passwordEdit = new _xfa_object.XFAObjectArray();
  3322. this.pattern = new _xfa_object.XFAObjectArray();
  3323. this.picture = new _xfa_object.XFAObjectArray();
  3324. this.radial = new _xfa_object.XFAObjectArray();
  3325. this.reason = new _xfa_object.XFAObjectArray();
  3326. this.reasons = new _xfa_object.XFAObjectArray();
  3327. this.rectangle = new _xfa_object.XFAObjectArray();
  3328. this.ref = new _xfa_object.XFAObjectArray();
  3329. this.script = new _xfa_object.XFAObjectArray();
  3330. this.setProperty = new _xfa_object.XFAObjectArray();
  3331. this.signData = new _xfa_object.XFAObjectArray();
  3332. this.signature = new _xfa_object.XFAObjectArray();
  3333. this.signing = new _xfa_object.XFAObjectArray();
  3334. this.solid = new _xfa_object.XFAObjectArray();
  3335. this.speak = new _xfa_object.XFAObjectArray();
  3336. this.stipple = new _xfa_object.XFAObjectArray();
  3337. this.subform = new _xfa_object.XFAObjectArray();
  3338. this.subformSet = new _xfa_object.XFAObjectArray();
  3339. this.subjectDN = new _xfa_object.XFAObjectArray();
  3340. this.subjectDNs = new _xfa_object.XFAObjectArray();
  3341. this.submit = new _xfa_object.XFAObjectArray();
  3342. this.text = new _xfa_object.XFAObjectArray();
  3343. this.textEdit = new _xfa_object.XFAObjectArray();
  3344. this.time = new _xfa_object.XFAObjectArray();
  3345. this.timeStamp = new _xfa_object.XFAObjectArray();
  3346. this.toolTip = new _xfa_object.XFAObjectArray();
  3347. this.traversal = new _xfa_object.XFAObjectArray();
  3348. this.traverse = new _xfa_object.XFAObjectArray();
  3349. this.ui = new _xfa_object.XFAObjectArray();
  3350. this.validate = new _xfa_object.XFAObjectArray();
  3351. this.value = new _xfa_object.XFAObjectArray();
  3352. this.variables = new _xfa_object.XFAObjectArray();
  3353. }
  3354. }
  3355. class Radial extends _xfa_object.XFAObject {
  3356. constructor(attributes) {
  3357. super(TEMPLATE_NS_ID, "radial", true);
  3358. this.id = attributes.id || "";
  3359. this.type = (0, _utils.getStringOption)(attributes.type, ["toEdge", "toCenter"]);
  3360. this.use = attributes.use || "";
  3361. this.usehref = attributes.usehref || "";
  3362. this.color = null;
  3363. this.extras = null;
  3364. }
  3365. [_xfa_object.$toStyle](startColor) {
  3366. startColor = startColor ? startColor[_xfa_object.$toStyle]() : "#FFFFFF";
  3367. const endColor = this.color ? this.color[_xfa_object.$toStyle]() : "#000000";
  3368. const colors = this.type === "toEdge" ? `${startColor},${endColor}` : `${endColor},${startColor}`;
  3369. return `radial-gradient(circle at center, ${colors})`;
  3370. }
  3371. }
  3372. class Reason extends _xfa_object.StringObject {
  3373. constructor(attributes) {
  3374. super(TEMPLATE_NS_ID, "reason");
  3375. this.id = attributes.id || "";
  3376. this.name = attributes.name || "";
  3377. this.use = attributes.use || "";
  3378. this.usehref = attributes.usehref || "";
  3379. }
  3380. }
  3381. class Reasons extends _xfa_object.XFAObject {
  3382. constructor(attributes) {
  3383. super(TEMPLATE_NS_ID, "reasons", true);
  3384. this.id = attributes.id || "";
  3385. this.type = (0, _utils.getStringOption)(attributes.type, ["optional", "required"]);
  3386. this.use = attributes.use || "";
  3387. this.usehref = attributes.usehref || "";
  3388. this.reason = new _xfa_object.XFAObjectArray();
  3389. }
  3390. }
  3391. class Rectangle extends _xfa_object.XFAObject {
  3392. constructor(attributes) {
  3393. super(TEMPLATE_NS_ID, "rectangle", true);
  3394. this.hand = (0, _utils.getStringOption)(attributes.hand, ["even", "left", "right"]);
  3395. this.id = attributes.id || "";
  3396. this.use = attributes.use || "";
  3397. this.usehref = attributes.usehref || "";
  3398. this.corner = new _xfa_object.XFAObjectArray(4);
  3399. this.edge = new _xfa_object.XFAObjectArray(4);
  3400. this.fill = null;
  3401. }
  3402. [_xfa_object.$toHTML]() {
  3403. const edge = this.edge.children.length ? this.edge.children[0] : new Edge({});
  3404. const edgeStyle = edge[_xfa_object.$toStyle]();
  3405. const style = Object.create(null);
  3406. if (this.fill && this.fill.presence === "visible") {
  3407. Object.assign(style, this.fill[_xfa_object.$toStyle]());
  3408. } else {
  3409. style.fill = "transparent";
  3410. }
  3411. style.strokeWidth = (0, _html_utils.measureToString)(edge.presence === "visible" ? edge.thickness : 0);
  3412. style.stroke = edgeStyle.color;
  3413. const corner = this.corner.children.length ? this.corner.children[0] : new Corner({});
  3414. const cornerStyle = corner[_xfa_object.$toStyle]();
  3415. const rect = {
  3416. name: "rect",
  3417. attributes: {
  3418. xmlns: SVG_NS,
  3419. width: "100%",
  3420. height: "100%",
  3421. x: 0,
  3422. y: 0,
  3423. rx: cornerStyle.radius,
  3424. ry: cornerStyle.radius,
  3425. style
  3426. }
  3427. };
  3428. const svg = {
  3429. name: "svg",
  3430. children: [rect],
  3431. attributes: {
  3432. xmlns: SVG_NS,
  3433. style: {
  3434. overflow: "visible"
  3435. },
  3436. width: "100%",
  3437. height: "100%"
  3438. }
  3439. };
  3440. const parent = this[_xfa_object.$getParent]()[_xfa_object.$getParent]();
  3441. if (hasMargin(parent)) {
  3442. return _utils.HTMLResult.success({
  3443. name: "div",
  3444. attributes: {
  3445. style: {
  3446. display: "inline",
  3447. width: "100%",
  3448. height: "100%"
  3449. }
  3450. },
  3451. children: [svg]
  3452. });
  3453. }
  3454. svg.attributes.style.position = "absolute";
  3455. return _utils.HTMLResult.success(svg);
  3456. }
  3457. }
  3458. class RefElement extends _xfa_object.StringObject {
  3459. constructor(attributes) {
  3460. super(TEMPLATE_NS_ID, "ref");
  3461. this.id = attributes.id || "";
  3462. this.use = attributes.use || "";
  3463. this.usehref = attributes.usehref || "";
  3464. }
  3465. }
  3466. class Script extends _xfa_object.StringObject {
  3467. constructor(attributes) {
  3468. super(TEMPLATE_NS_ID, "script");
  3469. this.binding = attributes.binding || "";
  3470. this.contentType = attributes.contentType || "";
  3471. this.id = attributes.id || "";
  3472. this.name = attributes.name || "";
  3473. this.runAt = (0, _utils.getStringOption)(attributes.runAt, ["client", "both", "server"]);
  3474. this.use = attributes.use || "";
  3475. this.usehref = attributes.usehref || "";
  3476. }
  3477. }
  3478. class SetProperty extends _xfa_object.XFAObject {
  3479. constructor(attributes) {
  3480. super(TEMPLATE_NS_ID, "setProperty");
  3481. this.connection = attributes.connection || "";
  3482. this.ref = attributes.ref || "";
  3483. this.target = attributes.target || "";
  3484. }
  3485. }
  3486. exports.SetProperty = SetProperty;
  3487. class SignData extends _xfa_object.XFAObject {
  3488. constructor(attributes) {
  3489. super(TEMPLATE_NS_ID, "signData", true);
  3490. this.id = attributes.id || "";
  3491. this.operation = (0, _utils.getStringOption)(attributes.operation, ["sign", "clear", "verify"]);
  3492. this.ref = attributes.ref || "";
  3493. this.target = attributes.target || "";
  3494. this.use = attributes.use || "";
  3495. this.usehref = attributes.usehref || "";
  3496. this.filter = null;
  3497. this.manifest = null;
  3498. }
  3499. }
  3500. class Signature extends _xfa_object.XFAObject {
  3501. constructor(attributes) {
  3502. super(TEMPLATE_NS_ID, "signature", true);
  3503. this.id = attributes.id || "";
  3504. this.type = (0, _utils.getStringOption)(attributes.type, ["PDF1.3", "PDF1.6"]);
  3505. this.use = attributes.use || "";
  3506. this.usehref = attributes.usehref || "";
  3507. this.border = null;
  3508. this.extras = null;
  3509. this.filter = null;
  3510. this.manifest = null;
  3511. this.margin = null;
  3512. }
  3513. }
  3514. class Signing extends _xfa_object.XFAObject {
  3515. constructor(attributes) {
  3516. super(TEMPLATE_NS_ID, "signing", true);
  3517. this.id = attributes.id || "";
  3518. this.type = (0, _utils.getStringOption)(attributes.type, ["optional", "required"]);
  3519. this.use = attributes.use || "";
  3520. this.usehref = attributes.usehref || "";
  3521. this.certificate = new _xfa_object.XFAObjectArray();
  3522. }
  3523. }
  3524. class Solid extends _xfa_object.XFAObject {
  3525. constructor(attributes) {
  3526. super(TEMPLATE_NS_ID, "solid", true);
  3527. this.id = attributes.id || "";
  3528. this.use = attributes.use || "";
  3529. this.usehref = attributes.usehref || "";
  3530. this.extras = null;
  3531. }
  3532. [_xfa_object.$toStyle](startColor) {
  3533. return startColor ? startColor[_xfa_object.$toStyle]() : "#FFFFFF";
  3534. }
  3535. }
  3536. class Speak extends _xfa_object.StringObject {
  3537. constructor(attributes) {
  3538. super(TEMPLATE_NS_ID, "speak");
  3539. this.disable = (0, _utils.getInteger)({
  3540. data: attributes.disable,
  3541. defaultValue: 0,
  3542. validate: x => x === 1
  3543. });
  3544. this.id = attributes.id || "";
  3545. this.priority = (0, _utils.getStringOption)(attributes.priority, ["custom", "caption", "name", "toolTip"]);
  3546. this.rid = attributes.rid || "";
  3547. this.use = attributes.use || "";
  3548. this.usehref = attributes.usehref || "";
  3549. }
  3550. }
  3551. class Stipple extends _xfa_object.XFAObject {
  3552. constructor(attributes) {
  3553. super(TEMPLATE_NS_ID, "stipple", true);
  3554. this.id = attributes.id || "";
  3555. this.rate = (0, _utils.getInteger)({
  3556. data: attributes.rate,
  3557. defaultValue: 50,
  3558. validate: x => x >= 0 && x <= 100
  3559. });
  3560. this.use = attributes.use || "";
  3561. this.usehref = attributes.usehref || "";
  3562. this.color = null;
  3563. this.extras = null;
  3564. }
  3565. [_xfa_object.$toStyle](bgColor) {
  3566. const alpha = this.rate / 100;
  3567. return _util.Util.makeHexColor(Math.round(bgColor.value.r * (1 - alpha) + this.value.r * alpha), Math.round(bgColor.value.g * (1 - alpha) + this.value.g * alpha), Math.round(bgColor.value.b * (1 - alpha) + this.value.b * alpha));
  3568. }
  3569. }
  3570. class Subform extends _xfa_object.XFAObject {
  3571. constructor(attributes) {
  3572. super(TEMPLATE_NS_ID, "subform", true);
  3573. this.access = (0, _utils.getStringOption)(attributes.access, ["open", "nonInteractive", "protected", "readOnly"]);
  3574. this.allowMacro = (0, _utils.getInteger)({
  3575. data: attributes.allowMacro,
  3576. defaultValue: 0,
  3577. validate: x => x === 1
  3578. });
  3579. this.anchorType = (0, _utils.getStringOption)(attributes.anchorType, ["topLeft", "bottomCenter", "bottomLeft", "bottomRight", "middleCenter", "middleLeft", "middleRight", "topCenter", "topRight"]);
  3580. this.colSpan = (0, _utils.getInteger)({
  3581. data: attributes.colSpan,
  3582. defaultValue: 1,
  3583. validate: n => n >= 1 || n === -1
  3584. });
  3585. this.columnWidths = (attributes.columnWidths || "").trim().split(/\s+/).map(x => x === "-1" ? -1 : (0, _utils.getMeasurement)(x));
  3586. this.h = attributes.h ? (0, _utils.getMeasurement)(attributes.h) : "";
  3587. this.hAlign = (0, _utils.getStringOption)(attributes.hAlign, ["left", "center", "justify", "justifyAll", "radix", "right"]);
  3588. this.id = attributes.id || "";
  3589. this.layout = (0, _utils.getStringOption)(attributes.layout, ["position", "lr-tb", "rl-row", "rl-tb", "row", "table", "tb"]);
  3590. this.locale = attributes.locale || "";
  3591. this.maxH = (0, _utils.getMeasurement)(attributes.maxH, "0pt");
  3592. this.maxW = (0, _utils.getMeasurement)(attributes.maxW, "0pt");
  3593. this.mergeMode = (0, _utils.getStringOption)(attributes.mergeMode, ["consumeData", "matchTemplate"]);
  3594. this.minH = (0, _utils.getMeasurement)(attributes.minH, "0pt");
  3595. this.minW = (0, _utils.getMeasurement)(attributes.minW, "0pt");
  3596. this.name = attributes.name || "";
  3597. this.presence = (0, _utils.getStringOption)(attributes.presence, ["visible", "hidden", "inactive", "invisible"]);
  3598. this.relevant = (0, _utils.getRelevant)(attributes.relevant);
  3599. this.restoreState = (0, _utils.getStringOption)(attributes.restoreState, ["manual", "auto"]);
  3600. this.scope = (0, _utils.getStringOption)(attributes.scope, ["name", "none"]);
  3601. this.use = attributes.use || "";
  3602. this.usehref = attributes.usehref || "";
  3603. this.w = attributes.w ? (0, _utils.getMeasurement)(attributes.w) : "";
  3604. this.x = (0, _utils.getMeasurement)(attributes.x, "0pt");
  3605. this.y = (0, _utils.getMeasurement)(attributes.y, "0pt");
  3606. this.assist = null;
  3607. this.bind = null;
  3608. this.bookend = null;
  3609. this.border = null;
  3610. this.break = null;
  3611. this.calculate = null;
  3612. this.desc = null;
  3613. this.extras = null;
  3614. this.keep = null;
  3615. this.margin = null;
  3616. this.occur = null;
  3617. this.overflow = null;
  3618. this.pageSet = null;
  3619. this.para = null;
  3620. this.traversal = null;
  3621. this.validate = null;
  3622. this.variables = null;
  3623. this.area = new _xfa_object.XFAObjectArray();
  3624. this.breakAfter = new _xfa_object.XFAObjectArray();
  3625. this.breakBefore = new _xfa_object.XFAObjectArray();
  3626. this.connect = new _xfa_object.XFAObjectArray();
  3627. this.draw = new _xfa_object.XFAObjectArray();
  3628. this.event = new _xfa_object.XFAObjectArray();
  3629. this.exObject = new _xfa_object.XFAObjectArray();
  3630. this.exclGroup = new _xfa_object.XFAObjectArray();
  3631. this.field = new _xfa_object.XFAObjectArray();
  3632. this.proto = new _xfa_object.XFAObjectArray();
  3633. this.setProperty = new _xfa_object.XFAObjectArray();
  3634. this.subform = new _xfa_object.XFAObjectArray();
  3635. this.subformSet = new _xfa_object.XFAObjectArray();
  3636. }
  3637. [_xfa_object.$getSubformParent]() {
  3638. const parent = this[_xfa_object.$getParent]();
  3639. if (parent instanceof SubformSet) {
  3640. return parent[_xfa_object.$getSubformParent]();
  3641. }
  3642. return parent;
  3643. }
  3644. [_xfa_object.$isBindable]() {
  3645. return true;
  3646. }
  3647. [_xfa_object.$isThereMoreWidth]() {
  3648. return this.layout.endsWith("-tb") && this[_xfa_object.$extra].attempt === 0 && this[_xfa_object.$extra].numberInLine > 0 || this[_xfa_object.$getParent]()[_xfa_object.$isThereMoreWidth]();
  3649. }
  3650. *[_xfa_object.$getContainedChildren]() {
  3651. yield* getContainedChildren(this);
  3652. }
  3653. [_xfa_object.$flushHTML]() {
  3654. return (0, _layout.flushHTML)(this);
  3655. }
  3656. [_xfa_object.$addHTML](html, bbox) {
  3657. (0, _layout.addHTML)(this, html, bbox);
  3658. }
  3659. [_xfa_object.$getAvailableSpace]() {
  3660. return (0, _layout.getAvailableSpace)(this);
  3661. }
  3662. [_xfa_object.$isSplittable]() {
  3663. const parent = this[_xfa_object.$getSubformParent]();
  3664. if (!parent[_xfa_object.$isSplittable]()) {
  3665. return false;
  3666. }
  3667. if (this[_xfa_object.$extra]._isSplittable !== undefined) {
  3668. return this[_xfa_object.$extra]._isSplittable;
  3669. }
  3670. if (this.layout === "position" || this.layout.includes("row")) {
  3671. this[_xfa_object.$extra]._isSplittable = false;
  3672. return false;
  3673. }
  3674. if (this.keep && this.keep.intact !== "none") {
  3675. this[_xfa_object.$extra]._isSplittable = false;
  3676. return false;
  3677. }
  3678. if (parent.layout && parent.layout.endsWith("-tb") && parent[_xfa_object.$extra].numberInLine !== 0) {
  3679. return false;
  3680. }
  3681. this[_xfa_object.$extra]._isSplittable = true;
  3682. return true;
  3683. }
  3684. [_xfa_object.$toHTML](availableSpace) {
  3685. setTabIndex(this);
  3686. if (this.break) {
  3687. if (this.break.after !== "auto" || this.break.afterTarget !== "") {
  3688. const node = new BreakAfter({
  3689. targetType: this.break.after,
  3690. target: this.break.afterTarget,
  3691. startNew: this.break.startNew.toString()
  3692. });
  3693. node[_xfa_object.$globalData] = this[_xfa_object.$globalData];
  3694. this[_xfa_object.$appendChild](node);
  3695. this.breakAfter.push(node);
  3696. }
  3697. if (this.break.before !== "auto" || this.break.beforeTarget !== "") {
  3698. const node = new BreakBefore({
  3699. targetType: this.break.before,
  3700. target: this.break.beforeTarget,
  3701. startNew: this.break.startNew.toString()
  3702. });
  3703. node[_xfa_object.$globalData] = this[_xfa_object.$globalData];
  3704. this[_xfa_object.$appendChild](node);
  3705. this.breakBefore.push(node);
  3706. }
  3707. if (this.break.overflowTarget !== "") {
  3708. const node = new Overflow({
  3709. target: this.break.overflowTarget,
  3710. leader: this.break.overflowLeader,
  3711. trailer: this.break.overflowTrailer
  3712. });
  3713. node[_xfa_object.$globalData] = this[_xfa_object.$globalData];
  3714. this[_xfa_object.$appendChild](node);
  3715. this.overflow.push(node);
  3716. }
  3717. this[_xfa_object.$removeChild](this.break);
  3718. this.break = null;
  3719. }
  3720. if (this.presence === "hidden" || this.presence === "inactive") {
  3721. return _utils.HTMLResult.EMPTY;
  3722. }
  3723. if (this.breakBefore.children.length > 1 || this.breakAfter.children.length > 1) {
  3724. (0, _util.warn)("XFA - Several breakBefore or breakAfter in subforms: please file a bug.");
  3725. }
  3726. if (this.breakBefore.children.length >= 1) {
  3727. const breakBefore = this.breakBefore.children[0];
  3728. if (handleBreak(breakBefore)) {
  3729. return _utils.HTMLResult.breakNode(breakBefore);
  3730. }
  3731. }
  3732. if (this[_xfa_object.$extra] && this[_xfa_object.$extra].afterBreakAfter) {
  3733. return _utils.HTMLResult.EMPTY;
  3734. }
  3735. (0, _html_utils.fixDimensions)(this);
  3736. const children = [];
  3737. const attributes = {
  3738. id: this[_xfa_object.$uid],
  3739. class: []
  3740. };
  3741. (0, _html_utils.setAccess)(this, attributes.class);
  3742. if (!this[_xfa_object.$extra]) {
  3743. this[_xfa_object.$extra] = Object.create(null);
  3744. }
  3745. Object.assign(this[_xfa_object.$extra], {
  3746. children,
  3747. line: null,
  3748. attributes,
  3749. attempt: 0,
  3750. numberInLine: 0,
  3751. availableSpace: {
  3752. width: Math.min(this.w || Infinity, availableSpace.width),
  3753. height: Math.min(this.h || Infinity, availableSpace.height)
  3754. },
  3755. width: 0,
  3756. height: 0,
  3757. prevHeight: 0,
  3758. currentWidth: 0
  3759. });
  3760. const root = this[_xfa_object.$getTemplateRoot]();
  3761. const savedNoLayoutFailure = root[_xfa_object.$extra].noLayoutFailure;
  3762. const isSplittable = this[_xfa_object.$isSplittable]();
  3763. if (!isSplittable) {
  3764. setFirstUnsplittable(this);
  3765. }
  3766. if (!(0, _layout.checkDimensions)(this, availableSpace)) {
  3767. return _utils.HTMLResult.FAILURE;
  3768. }
  3769. const filter = new Set(["area", "draw", "exclGroup", "field", "subform", "subformSet"]);
  3770. if (this.layout.includes("row")) {
  3771. const columnWidths = this[_xfa_object.$getSubformParent]().columnWidths;
  3772. if (Array.isArray(columnWidths) && columnWidths.length > 0) {
  3773. this[_xfa_object.$extra].columnWidths = columnWidths;
  3774. this[_xfa_object.$extra].currentColumn = 0;
  3775. }
  3776. }
  3777. const style = (0, _html_utils.toStyle)(this, "anchorType", "dimensions", "position", "presence", "border", "margin", "hAlign");
  3778. const classNames = ["xfaSubform"];
  3779. const cl = (0, _html_utils.layoutClass)(this);
  3780. if (cl) {
  3781. classNames.push(cl);
  3782. }
  3783. attributes.style = style;
  3784. attributes.class = classNames;
  3785. if (this.name) {
  3786. attributes.xfaName = this.name;
  3787. }
  3788. if (this.overflow) {
  3789. const overflowExtra = this.overflow[_xfa_object.$getExtra]();
  3790. if (overflowExtra.addLeader) {
  3791. overflowExtra.addLeader = false;
  3792. handleOverflow(this, overflowExtra.leader, availableSpace);
  3793. }
  3794. }
  3795. this[_xfa_object.$pushPara]();
  3796. const isLrTb = this.layout === "lr-tb" || this.layout === "rl-tb";
  3797. const maxRun = isLrTb ? MAX_ATTEMPTS_FOR_LRTB_LAYOUT : 1;
  3798. for (; this[_xfa_object.$extra].attempt < maxRun; this[_xfa_object.$extra].attempt++) {
  3799. if (isLrTb && this[_xfa_object.$extra].attempt === MAX_ATTEMPTS_FOR_LRTB_LAYOUT - 1) {
  3800. this[_xfa_object.$extra].numberInLine = 0;
  3801. }
  3802. const result = this[_xfa_object.$childrenToHTML]({
  3803. filter,
  3804. include: true
  3805. });
  3806. if (result.success) {
  3807. break;
  3808. }
  3809. if (result.isBreak()) {
  3810. this[_xfa_object.$popPara]();
  3811. return result;
  3812. }
  3813. if (isLrTb && this[_xfa_object.$extra].attempt === 0 && this[_xfa_object.$extra].numberInLine === 0 && !root[_xfa_object.$extra].noLayoutFailure) {
  3814. this[_xfa_object.$extra].attempt = maxRun;
  3815. break;
  3816. }
  3817. }
  3818. this[_xfa_object.$popPara]();
  3819. if (!isSplittable) {
  3820. unsetFirstUnsplittable(this);
  3821. }
  3822. root[_xfa_object.$extra].noLayoutFailure = savedNoLayoutFailure;
  3823. if (this[_xfa_object.$extra].attempt === maxRun) {
  3824. if (this.overflow) {
  3825. this[_xfa_object.$getTemplateRoot]()[_xfa_object.$extra].overflowNode = this.overflow;
  3826. }
  3827. if (!isSplittable) {
  3828. delete this[_xfa_object.$extra];
  3829. }
  3830. return _utils.HTMLResult.FAILURE;
  3831. }
  3832. if (this.overflow) {
  3833. const overflowExtra = this.overflow[_xfa_object.$getExtra]();
  3834. if (overflowExtra.addTrailer) {
  3835. overflowExtra.addTrailer = false;
  3836. handleOverflow(this, overflowExtra.trailer, availableSpace);
  3837. }
  3838. }
  3839. let marginH = 0;
  3840. let marginV = 0;
  3841. if (this.margin) {
  3842. marginH = this.margin.leftInset + this.margin.rightInset;
  3843. marginV = this.margin.topInset + this.margin.bottomInset;
  3844. }
  3845. const width = Math.max(this[_xfa_object.$extra].width + marginH, this.w || 0);
  3846. const height = Math.max(this[_xfa_object.$extra].height + marginV, this.h || 0);
  3847. const bbox = [this.x, this.y, width, height];
  3848. if (this.w === "") {
  3849. style.width = (0, _html_utils.measureToString)(width);
  3850. }
  3851. if (this.h === "") {
  3852. style.height = (0, _html_utils.measureToString)(height);
  3853. }
  3854. if ((style.width === "0px" || style.height === "0px") && children.length === 0) {
  3855. return _utils.HTMLResult.EMPTY;
  3856. }
  3857. const html = {
  3858. name: "div",
  3859. attributes,
  3860. children
  3861. };
  3862. applyAssist(this, attributes);
  3863. const result = _utils.HTMLResult.success((0, _html_utils.createWrapper)(this, html), bbox);
  3864. if (this.breakAfter.children.length >= 1) {
  3865. const breakAfter = this.breakAfter.children[0];
  3866. if (handleBreak(breakAfter)) {
  3867. this[_xfa_object.$extra].afterBreakAfter = result;
  3868. return _utils.HTMLResult.breakNode(breakAfter);
  3869. }
  3870. }
  3871. delete this[_xfa_object.$extra];
  3872. return result;
  3873. }
  3874. }
  3875. class SubformSet extends _xfa_object.XFAObject {
  3876. constructor(attributes) {
  3877. super(TEMPLATE_NS_ID, "subformSet", true);
  3878. this.id = attributes.id || "";
  3879. this.name = attributes.name || "";
  3880. this.relation = (0, _utils.getStringOption)(attributes.relation, ["ordered", "choice", "unordered"]);
  3881. this.relevant = (0, _utils.getRelevant)(attributes.relevant);
  3882. this.use = attributes.use || "";
  3883. this.usehref = attributes.usehref || "";
  3884. this.bookend = null;
  3885. this.break = null;
  3886. this.desc = null;
  3887. this.extras = null;
  3888. this.occur = null;
  3889. this.overflow = null;
  3890. this.breakAfter = new _xfa_object.XFAObjectArray();
  3891. this.breakBefore = new _xfa_object.XFAObjectArray();
  3892. this.subform = new _xfa_object.XFAObjectArray();
  3893. this.subformSet = new _xfa_object.XFAObjectArray();
  3894. }
  3895. *[_xfa_object.$getContainedChildren]() {
  3896. yield* getContainedChildren(this);
  3897. }
  3898. [_xfa_object.$getSubformParent]() {
  3899. let parent = this[_xfa_object.$getParent]();
  3900. while (!(parent instanceof Subform)) {
  3901. parent = parent[_xfa_object.$getParent]();
  3902. }
  3903. return parent;
  3904. }
  3905. [_xfa_object.$isBindable]() {
  3906. return true;
  3907. }
  3908. }
  3909. class SubjectDN extends _xfa_object.ContentObject {
  3910. constructor(attributes) {
  3911. super(TEMPLATE_NS_ID, "subjectDN");
  3912. this.delimiter = attributes.delimiter || ",";
  3913. this.id = attributes.id || "";
  3914. this.name = attributes.name || "";
  3915. this.use = attributes.use || "";
  3916. this.usehref = attributes.usehref || "";
  3917. }
  3918. [_xfa_object.$finalize]() {
  3919. this[_xfa_object.$content] = new Map(this[_xfa_object.$content].split(this.delimiter).map(kv => {
  3920. kv = kv.split("=", 2);
  3921. kv[0] = kv[0].trim();
  3922. return kv;
  3923. }));
  3924. }
  3925. }
  3926. class SubjectDNs extends _xfa_object.XFAObject {
  3927. constructor(attributes) {
  3928. super(TEMPLATE_NS_ID, "subjectDNs", true);
  3929. this.id = attributes.id || "";
  3930. this.type = (0, _utils.getStringOption)(attributes.type, ["optional", "required"]);
  3931. this.use = attributes.use || "";
  3932. this.usehref = attributes.usehref || "";
  3933. this.subjectDN = new _xfa_object.XFAObjectArray();
  3934. }
  3935. }
  3936. class Submit extends _xfa_object.XFAObject {
  3937. constructor(attributes) {
  3938. super(TEMPLATE_NS_ID, "submit", true);
  3939. this.embedPDF = (0, _utils.getInteger)({
  3940. data: attributes.embedPDF,
  3941. defaultValue: 0,
  3942. validate: x => x === 1
  3943. });
  3944. this.format = (0, _utils.getStringOption)(attributes.format, ["xdp", "formdata", "pdf", "urlencoded", "xfd", "xml"]);
  3945. this.id = attributes.id || "";
  3946. this.target = attributes.target || "";
  3947. this.textEncoding = (0, _utils.getKeyword)({
  3948. data: attributes.textEncoding ? attributes.textEncoding.toLowerCase() : "",
  3949. defaultValue: "",
  3950. validate: k => ["utf-8", "big-five", "fontspecific", "gbk", "gb-18030", "gb-2312", "ksc-5601", "none", "shift-jis", "ucs-2", "utf-16"].includes(k) || k.match(/iso-8859-\d{2}/)
  3951. });
  3952. this.use = attributes.use || "";
  3953. this.usehref = attributes.usehref || "";
  3954. this.xdpContent = attributes.xdpContent || "";
  3955. this.encrypt = null;
  3956. this.encryptData = new _xfa_object.XFAObjectArray();
  3957. this.signData = new _xfa_object.XFAObjectArray();
  3958. }
  3959. }
  3960. class Template extends _xfa_object.XFAObject {
  3961. constructor(attributes) {
  3962. super(TEMPLATE_NS_ID, "template", true);
  3963. this.baseProfile = (0, _utils.getStringOption)(attributes.baseProfile, ["full", "interactiveForms"]);
  3964. this.extras = null;
  3965. this.subform = new _xfa_object.XFAObjectArray();
  3966. }
  3967. [_xfa_object.$finalize]() {
  3968. if (this.subform.children.length === 0) {
  3969. (0, _util.warn)("XFA - No subforms in template node.");
  3970. }
  3971. if (this.subform.children.length >= 2) {
  3972. (0, _util.warn)("XFA - Several subforms in template node: please file a bug.");
  3973. }
  3974. this[_xfa_object.$tabIndex] = DEFAULT_TAB_INDEX;
  3975. }
  3976. [_xfa_object.$isSplittable]() {
  3977. return true;
  3978. }
  3979. [_xfa_object.$searchNode](expr, container) {
  3980. if (expr.startsWith("#")) {
  3981. return [this[_xfa_object.$ids].get(expr.slice(1))];
  3982. }
  3983. return (0, _som.searchNode)(this, container, expr, true, true);
  3984. }
  3985. *[_xfa_object.$toPages]() {
  3986. if (!this.subform.children.length) {
  3987. return _utils.HTMLResult.success({
  3988. name: "div",
  3989. children: []
  3990. });
  3991. }
  3992. this[_xfa_object.$extra] = {
  3993. overflowNode: null,
  3994. firstUnsplittable: null,
  3995. currentContentArea: null,
  3996. currentPageArea: null,
  3997. noLayoutFailure: false,
  3998. pageNumber: 1,
  3999. pagePosition: "first",
  4000. oddOrEven: "odd",
  4001. blankOrNotBlank: "nonBlank",
  4002. paraStack: []
  4003. };
  4004. const root = this.subform.children[0];
  4005. root.pageSet[_xfa_object.$cleanPage]();
  4006. const pageAreas = root.pageSet.pageArea.children;
  4007. const mainHtml = {
  4008. name: "div",
  4009. children: []
  4010. };
  4011. let pageArea = null;
  4012. let breakBefore = null;
  4013. let breakBeforeTarget = null;
  4014. if (root.breakBefore.children.length >= 1) {
  4015. breakBefore = root.breakBefore.children[0];
  4016. breakBeforeTarget = breakBefore.target;
  4017. } else if (root.subform.children.length >= 1 && root.subform.children[0].breakBefore.children.length >= 1) {
  4018. breakBefore = root.subform.children[0].breakBefore.children[0];
  4019. breakBeforeTarget = breakBefore.target;
  4020. } else if (root.break && root.break.beforeTarget) {
  4021. breakBefore = root.break;
  4022. breakBeforeTarget = breakBefore.beforeTarget;
  4023. } else if (root.subform.children.length >= 1 && root.subform.children[0].break && root.subform.children[0].break.beforeTarget) {
  4024. breakBefore = root.subform.children[0].break;
  4025. breakBeforeTarget = breakBefore.beforeTarget;
  4026. }
  4027. if (breakBefore) {
  4028. const target = this[_xfa_object.$searchNode](breakBeforeTarget, breakBefore[_xfa_object.$getParent]());
  4029. if (target instanceof PageArea) {
  4030. pageArea = target;
  4031. breakBefore[_xfa_object.$extra] = {};
  4032. }
  4033. }
  4034. if (!pageArea) {
  4035. pageArea = pageAreas[0];
  4036. }
  4037. pageArea[_xfa_object.$extra] = {
  4038. numberOfUse: 1
  4039. };
  4040. const pageAreaParent = pageArea[_xfa_object.$getParent]();
  4041. pageAreaParent[_xfa_object.$extra] = {
  4042. numberOfUse: 1,
  4043. pageIndex: pageAreaParent.pageArea.children.indexOf(pageArea),
  4044. pageSetIndex: 0
  4045. };
  4046. let targetPageArea;
  4047. let leader = null;
  4048. let trailer = null;
  4049. let hasSomething = true;
  4050. let hasSomethingCounter = 0;
  4051. let startIndex = 0;
  4052. while (true) {
  4053. if (!hasSomething) {
  4054. mainHtml.children.pop();
  4055. if (++hasSomethingCounter === MAX_EMPTY_PAGES) {
  4056. (0, _util.warn)("XFA - Something goes wrong: please file a bug.");
  4057. return mainHtml;
  4058. }
  4059. } else {
  4060. hasSomethingCounter = 0;
  4061. }
  4062. targetPageArea = null;
  4063. this[_xfa_object.$extra].currentPageArea = pageArea;
  4064. const page = pageArea[_xfa_object.$toHTML]().html;
  4065. mainHtml.children.push(page);
  4066. if (leader) {
  4067. this[_xfa_object.$extra].noLayoutFailure = true;
  4068. page.children.push(leader[_xfa_object.$toHTML](pageArea[_xfa_object.$extra].space).html);
  4069. leader = null;
  4070. }
  4071. if (trailer) {
  4072. this[_xfa_object.$extra].noLayoutFailure = true;
  4073. page.children.push(trailer[_xfa_object.$toHTML](pageArea[_xfa_object.$extra].space).html);
  4074. trailer = null;
  4075. }
  4076. const contentAreas = pageArea.contentArea.children;
  4077. const htmlContentAreas = page.children.filter(node => node.attributes.class.includes("xfaContentarea"));
  4078. hasSomething = false;
  4079. this[_xfa_object.$extra].firstUnsplittable = null;
  4080. this[_xfa_object.$extra].noLayoutFailure = false;
  4081. const flush = index => {
  4082. const html = root[_xfa_object.$flushHTML]();
  4083. if (html) {
  4084. hasSomething = hasSomething || html.children && html.children.length !== 0;
  4085. htmlContentAreas[index].children.push(html);
  4086. }
  4087. };
  4088. for (let i = startIndex, ii = contentAreas.length; i < ii; i++) {
  4089. const contentArea = this[_xfa_object.$extra].currentContentArea = contentAreas[i];
  4090. const space = {
  4091. width: contentArea.w,
  4092. height: contentArea.h
  4093. };
  4094. startIndex = 0;
  4095. if (leader) {
  4096. htmlContentAreas[i].children.push(leader[_xfa_object.$toHTML](space).html);
  4097. leader = null;
  4098. }
  4099. if (trailer) {
  4100. htmlContentAreas[i].children.push(trailer[_xfa_object.$toHTML](space).html);
  4101. trailer = null;
  4102. }
  4103. const html = root[_xfa_object.$toHTML](space);
  4104. if (html.success) {
  4105. if (html.html) {
  4106. hasSomething = hasSomething || html.html.children && html.html.children.length !== 0;
  4107. htmlContentAreas[i].children.push(html.html);
  4108. } else if (!hasSomething && mainHtml.children.length > 1) {
  4109. mainHtml.children.pop();
  4110. }
  4111. return mainHtml;
  4112. }
  4113. if (html.isBreak()) {
  4114. const node = html.breakNode;
  4115. flush(i);
  4116. if (node.targetType === "auto") {
  4117. continue;
  4118. }
  4119. if (node.leader) {
  4120. leader = this[_xfa_object.$searchNode](node.leader, node[_xfa_object.$getParent]());
  4121. leader = leader ? leader[0] : null;
  4122. }
  4123. if (node.trailer) {
  4124. trailer = this[_xfa_object.$searchNode](node.trailer, node[_xfa_object.$getParent]());
  4125. trailer = trailer ? trailer[0] : null;
  4126. }
  4127. if (node.targetType === "pageArea") {
  4128. targetPageArea = node[_xfa_object.$extra].target;
  4129. i = Infinity;
  4130. } else if (!node[_xfa_object.$extra].target) {
  4131. i = node[_xfa_object.$extra].index;
  4132. } else {
  4133. targetPageArea = node[_xfa_object.$extra].target;
  4134. startIndex = node[_xfa_object.$extra].index + 1;
  4135. i = Infinity;
  4136. }
  4137. continue;
  4138. }
  4139. if (this[_xfa_object.$extra].overflowNode) {
  4140. const node = this[_xfa_object.$extra].overflowNode;
  4141. this[_xfa_object.$extra].overflowNode = null;
  4142. const overflowExtra = node[_xfa_object.$getExtra]();
  4143. const target = overflowExtra.target;
  4144. overflowExtra.addLeader = overflowExtra.leader !== null;
  4145. overflowExtra.addTrailer = overflowExtra.trailer !== null;
  4146. flush(i);
  4147. const currentIndex = i;
  4148. i = Infinity;
  4149. if (target instanceof PageArea) {
  4150. targetPageArea = target;
  4151. } else if (target instanceof ContentArea) {
  4152. const index = contentAreas.indexOf(target);
  4153. if (index !== -1) {
  4154. if (index > currentIndex) {
  4155. i = index - 1;
  4156. } else {
  4157. startIndex = index;
  4158. }
  4159. } else {
  4160. targetPageArea = target[_xfa_object.$getParent]();
  4161. startIndex = targetPageArea.contentArea.children.indexOf(target);
  4162. }
  4163. }
  4164. continue;
  4165. }
  4166. flush(i);
  4167. }
  4168. this[_xfa_object.$extra].pageNumber += 1;
  4169. if (targetPageArea) {
  4170. if (targetPageArea[_xfa_object.$isUsable]()) {
  4171. targetPageArea[_xfa_object.$extra].numberOfUse += 1;
  4172. } else {
  4173. targetPageArea = null;
  4174. }
  4175. }
  4176. pageArea = targetPageArea || pageArea[_xfa_object.$getNextPage]();
  4177. yield null;
  4178. }
  4179. }
  4180. }
  4181. exports.Template = Template;
  4182. class Text extends _xfa_object.ContentObject {
  4183. constructor(attributes) {
  4184. super(TEMPLATE_NS_ID, "text");
  4185. this.id = attributes.id || "";
  4186. this.maxChars = (0, _utils.getInteger)({
  4187. data: attributes.maxChars,
  4188. defaultValue: 0,
  4189. validate: x => x >= 0
  4190. });
  4191. this.name = attributes.name || "";
  4192. this.rid = attributes.rid || "";
  4193. this.use = attributes.use || "";
  4194. this.usehref = attributes.usehref || "";
  4195. }
  4196. [_xfa_object.$acceptWhitespace]() {
  4197. return true;
  4198. }
  4199. [_xfa_object.$onChild](child) {
  4200. if (child[_xfa_object.$namespaceId] === _namespaces.NamespaceIds.xhtml.id) {
  4201. this[_xfa_object.$content] = child;
  4202. return true;
  4203. }
  4204. (0, _util.warn)(`XFA - Invalid content in Text: ${child[_xfa_object.$nodeName]}.`);
  4205. return false;
  4206. }
  4207. [_xfa_object.$onText](str) {
  4208. if (this[_xfa_object.$content] instanceof _xfa_object.XFAObject) {
  4209. return;
  4210. }
  4211. super[_xfa_object.$onText](str);
  4212. }
  4213. [_xfa_object.$finalize]() {
  4214. if (typeof this[_xfa_object.$content] === "string") {
  4215. this[_xfa_object.$content] = this[_xfa_object.$content].replace(/\r\n/g, "\n");
  4216. }
  4217. }
  4218. [_xfa_object.$getExtra]() {
  4219. if (typeof this[_xfa_object.$content] === "string") {
  4220. return this[_xfa_object.$content].split(/[\u2029\u2028\n]/).reduce((acc, line) => {
  4221. if (line) {
  4222. acc.push(line);
  4223. }
  4224. return acc;
  4225. }, []).join("\n");
  4226. }
  4227. return this[_xfa_object.$content][_xfa_object.$text]();
  4228. }
  4229. [_xfa_object.$toHTML](availableSpace) {
  4230. if (typeof this[_xfa_object.$content] === "string") {
  4231. const html = valueToHtml(this[_xfa_object.$content]).html;
  4232. if (this[_xfa_object.$content].includes("\u2029")) {
  4233. html.name = "div";
  4234. html.children = [];
  4235. this[_xfa_object.$content].split("\u2029").map(para => para.split(/[\u2028\n]/).reduce((acc, line) => {
  4236. acc.push({
  4237. name: "span",
  4238. value: line
  4239. }, {
  4240. name: "br"
  4241. });
  4242. return acc;
  4243. }, [])).forEach(lines => {
  4244. html.children.push({
  4245. name: "p",
  4246. children: lines
  4247. });
  4248. });
  4249. } else if (/[\u2028\n]/.test(this[_xfa_object.$content])) {
  4250. html.name = "div";
  4251. html.children = [];
  4252. this[_xfa_object.$content].split(/[\u2028\n]/).forEach(line => {
  4253. html.children.push({
  4254. name: "span",
  4255. value: line
  4256. }, {
  4257. name: "br"
  4258. });
  4259. });
  4260. }
  4261. return _utils.HTMLResult.success(html);
  4262. }
  4263. return this[_xfa_object.$content][_xfa_object.$toHTML](availableSpace);
  4264. }
  4265. }
  4266. exports.Text = Text;
  4267. class TextEdit extends _xfa_object.XFAObject {
  4268. constructor(attributes) {
  4269. super(TEMPLATE_NS_ID, "textEdit", true);
  4270. this.allowRichText = (0, _utils.getInteger)({
  4271. data: attributes.allowRichText,
  4272. defaultValue: 0,
  4273. validate: x => x === 1
  4274. });
  4275. this.hScrollPolicy = (0, _utils.getStringOption)(attributes.hScrollPolicy, ["auto", "off", "on"]);
  4276. this.id = attributes.id || "";
  4277. this.multiLine = (0, _utils.getInteger)({
  4278. data: attributes.multiLine,
  4279. defaultValue: "",
  4280. validate: x => x === 0 || x === 1
  4281. });
  4282. this.use = attributes.use || "";
  4283. this.usehref = attributes.usehref || "";
  4284. this.vScrollPolicy = (0, _utils.getStringOption)(attributes.vScrollPolicy, ["auto", "off", "on"]);
  4285. this.border = null;
  4286. this.comb = null;
  4287. this.extras = null;
  4288. this.margin = null;
  4289. }
  4290. [_xfa_object.$toHTML](availableSpace) {
  4291. const style = (0, _html_utils.toStyle)(this, "border", "font", "margin");
  4292. let html;
  4293. const field = this[_xfa_object.$getParent]()[_xfa_object.$getParent]();
  4294. if (this.multiLine === "") {
  4295. this.multiLine = field instanceof Draw ? 1 : 0;
  4296. }
  4297. if (this.multiLine === 1) {
  4298. html = {
  4299. name: "textarea",
  4300. attributes: {
  4301. dataId: field[_xfa_object.$data] && field[_xfa_object.$data][_xfa_object.$uid] || field[_xfa_object.$uid],
  4302. fieldId: field[_xfa_object.$uid],
  4303. class: ["xfaTextfield"],
  4304. style,
  4305. "aria-label": ariaLabel(field),
  4306. "aria-required": false
  4307. }
  4308. };
  4309. } else {
  4310. html = {
  4311. name: "input",
  4312. attributes: {
  4313. type: "text",
  4314. dataId: field[_xfa_object.$data] && field[_xfa_object.$data][_xfa_object.$uid] || field[_xfa_object.$uid],
  4315. fieldId: field[_xfa_object.$uid],
  4316. class: ["xfaTextfield"],
  4317. style,
  4318. "aria-label": ariaLabel(field),
  4319. "aria-required": false
  4320. }
  4321. };
  4322. }
  4323. if (isRequired(field)) {
  4324. html.attributes["aria-required"] = true;
  4325. html.attributes.required = true;
  4326. }
  4327. return _utils.HTMLResult.success({
  4328. name: "label",
  4329. attributes: {
  4330. class: ["xfaLabel"]
  4331. },
  4332. children: [html]
  4333. });
  4334. }
  4335. }
  4336. class Time extends _xfa_object.StringObject {
  4337. constructor(attributes) {
  4338. super(TEMPLATE_NS_ID, "time");
  4339. this.id = attributes.id || "";
  4340. this.name = attributes.name || "";
  4341. this.use = attributes.use || "";
  4342. this.usehref = attributes.usehref || "";
  4343. }
  4344. [_xfa_object.$finalize]() {
  4345. const date = this[_xfa_object.$content].trim();
  4346. this[_xfa_object.$content] = date ? new Date(date) : null;
  4347. }
  4348. [_xfa_object.$toHTML](availableSpace) {
  4349. return valueToHtml(this[_xfa_object.$content] ? this[_xfa_object.$content].toString() : "");
  4350. }
  4351. }
  4352. class TimeStamp extends _xfa_object.XFAObject {
  4353. constructor(attributes) {
  4354. super(TEMPLATE_NS_ID, "timeStamp");
  4355. this.id = attributes.id || "";
  4356. this.server = attributes.server || "";
  4357. this.type = (0, _utils.getStringOption)(attributes.type, ["optional", "required"]);
  4358. this.use = attributes.use || "";
  4359. this.usehref = attributes.usehref || "";
  4360. }
  4361. }
  4362. class ToolTip extends _xfa_object.StringObject {
  4363. constructor(attributes) {
  4364. super(TEMPLATE_NS_ID, "toolTip");
  4365. this.id = attributes.id || "";
  4366. this.rid = attributes.rid || "";
  4367. this.use = attributes.use || "";
  4368. this.usehref = attributes.usehref || "";
  4369. }
  4370. }
  4371. class Traversal extends _xfa_object.XFAObject {
  4372. constructor(attributes) {
  4373. super(TEMPLATE_NS_ID, "traversal", true);
  4374. this.id = attributes.id || "";
  4375. this.use = attributes.use || "";
  4376. this.usehref = attributes.usehref || "";
  4377. this.extras = null;
  4378. this.traverse = new _xfa_object.XFAObjectArray();
  4379. }
  4380. }
  4381. class Traverse extends _xfa_object.XFAObject {
  4382. constructor(attributes) {
  4383. super(TEMPLATE_NS_ID, "traverse", true);
  4384. this.id = attributes.id || "";
  4385. this.operation = (0, _utils.getStringOption)(attributes.operation, ["next", "back", "down", "first", "left", "right", "up"]);
  4386. this.ref = attributes.ref || "";
  4387. this.use = attributes.use || "";
  4388. this.usehref = attributes.usehref || "";
  4389. this.extras = null;
  4390. this.script = null;
  4391. }
  4392. get name() {
  4393. return this.operation;
  4394. }
  4395. [_xfa_object.$isTransparent]() {
  4396. return false;
  4397. }
  4398. }
  4399. class Ui extends _xfa_object.XFAObject {
  4400. constructor(attributes) {
  4401. super(TEMPLATE_NS_ID, "ui", true);
  4402. this.id = attributes.id || "";
  4403. this.use = attributes.use || "";
  4404. this.usehref = attributes.usehref || "";
  4405. this.extras = null;
  4406. this.picture = null;
  4407. this.barcode = null;
  4408. this.button = null;
  4409. this.checkButton = null;
  4410. this.choiceList = null;
  4411. this.dateTimeEdit = null;
  4412. this.defaultUi = null;
  4413. this.imageEdit = null;
  4414. this.numericEdit = null;
  4415. this.passwordEdit = null;
  4416. this.signature = null;
  4417. this.textEdit = null;
  4418. }
  4419. [_xfa_object.$getExtra]() {
  4420. if (this[_xfa_object.$extra] === undefined) {
  4421. for (const name of Object.getOwnPropertyNames(this)) {
  4422. if (name === "extras" || name === "picture") {
  4423. continue;
  4424. }
  4425. const obj = this[name];
  4426. if (!(obj instanceof _xfa_object.XFAObject)) {
  4427. continue;
  4428. }
  4429. this[_xfa_object.$extra] = obj;
  4430. return obj;
  4431. }
  4432. this[_xfa_object.$extra] = null;
  4433. }
  4434. return this[_xfa_object.$extra];
  4435. }
  4436. [_xfa_object.$toHTML](availableSpace) {
  4437. const obj = this[_xfa_object.$getExtra]();
  4438. if (obj) {
  4439. return obj[_xfa_object.$toHTML](availableSpace);
  4440. }
  4441. return _utils.HTMLResult.EMPTY;
  4442. }
  4443. }
  4444. class Validate extends _xfa_object.XFAObject {
  4445. constructor(attributes) {
  4446. super(TEMPLATE_NS_ID, "validate", true);
  4447. this.formatTest = (0, _utils.getStringOption)(attributes.formatTest, ["warning", "disabled", "error"]);
  4448. this.id = attributes.id || "";
  4449. this.nullTest = (0, _utils.getStringOption)(attributes.nullTest, ["disabled", "error", "warning"]);
  4450. this.scriptTest = (0, _utils.getStringOption)(attributes.scriptTest, ["error", "disabled", "warning"]);
  4451. this.use = attributes.use || "";
  4452. this.usehref = attributes.usehref || "";
  4453. this.extras = null;
  4454. this.message = null;
  4455. this.picture = null;
  4456. this.script = null;
  4457. }
  4458. }
  4459. class Value extends _xfa_object.XFAObject {
  4460. constructor(attributes) {
  4461. super(TEMPLATE_NS_ID, "value", true);
  4462. this.id = attributes.id || "";
  4463. this.override = (0, _utils.getInteger)({
  4464. data: attributes.override,
  4465. defaultValue: 0,
  4466. validate: x => x === 1
  4467. });
  4468. this.relevant = (0, _utils.getRelevant)(attributes.relevant);
  4469. this.use = attributes.use || "";
  4470. this.usehref = attributes.usehref || "";
  4471. this.arc = null;
  4472. this.boolean = null;
  4473. this.date = null;
  4474. this.dateTime = null;
  4475. this.decimal = null;
  4476. this.exData = null;
  4477. this.float = null;
  4478. this.image = null;
  4479. this.integer = null;
  4480. this.line = null;
  4481. this.rectangle = null;
  4482. this.text = null;
  4483. this.time = null;
  4484. }
  4485. [_xfa_object.$setValue](value) {
  4486. const parent = this[_xfa_object.$getParent]();
  4487. if (parent instanceof Field) {
  4488. if (parent.ui && parent.ui.imageEdit) {
  4489. if (!this.image) {
  4490. this.image = new Image({});
  4491. this[_xfa_object.$appendChild](this.image);
  4492. }
  4493. this.image[_xfa_object.$content] = value[_xfa_object.$content];
  4494. return;
  4495. }
  4496. }
  4497. const valueName = value[_xfa_object.$nodeName];
  4498. if (this[valueName] !== null) {
  4499. this[valueName][_xfa_object.$content] = value[_xfa_object.$content];
  4500. return;
  4501. }
  4502. for (const name of Object.getOwnPropertyNames(this)) {
  4503. const obj = this[name];
  4504. if (obj instanceof _xfa_object.XFAObject) {
  4505. this[name] = null;
  4506. this[_xfa_object.$removeChild](obj);
  4507. }
  4508. }
  4509. this[value[_xfa_object.$nodeName]] = value;
  4510. this[_xfa_object.$appendChild](value);
  4511. }
  4512. [_xfa_object.$text]() {
  4513. if (this.exData) {
  4514. if (typeof this.exData[_xfa_object.$content] === "string") {
  4515. return this.exData[_xfa_object.$content].trim();
  4516. }
  4517. return this.exData[_xfa_object.$content][_xfa_object.$text]().trim();
  4518. }
  4519. for (const name of Object.getOwnPropertyNames(this)) {
  4520. if (name === "image") {
  4521. continue;
  4522. }
  4523. const obj = this[name];
  4524. if (obj instanceof _xfa_object.XFAObject) {
  4525. return (obj[_xfa_object.$content] || "").toString().trim();
  4526. }
  4527. }
  4528. return null;
  4529. }
  4530. [_xfa_object.$toHTML](availableSpace) {
  4531. for (const name of Object.getOwnPropertyNames(this)) {
  4532. const obj = this[name];
  4533. if (!(obj instanceof _xfa_object.XFAObject)) {
  4534. continue;
  4535. }
  4536. return obj[_xfa_object.$toHTML](availableSpace);
  4537. }
  4538. return _utils.HTMLResult.EMPTY;
  4539. }
  4540. }
  4541. exports.Value = Value;
  4542. class Variables extends _xfa_object.XFAObject {
  4543. constructor(attributes) {
  4544. super(TEMPLATE_NS_ID, "variables", true);
  4545. this.id = attributes.id || "";
  4546. this.use = attributes.use || "";
  4547. this.usehref = attributes.usehref || "";
  4548. this.boolean = new _xfa_object.XFAObjectArray();
  4549. this.date = new _xfa_object.XFAObjectArray();
  4550. this.dateTime = new _xfa_object.XFAObjectArray();
  4551. this.decimal = new _xfa_object.XFAObjectArray();
  4552. this.exData = new _xfa_object.XFAObjectArray();
  4553. this.float = new _xfa_object.XFAObjectArray();
  4554. this.image = new _xfa_object.XFAObjectArray();
  4555. this.integer = new _xfa_object.XFAObjectArray();
  4556. this.manifest = new _xfa_object.XFAObjectArray();
  4557. this.script = new _xfa_object.XFAObjectArray();
  4558. this.text = new _xfa_object.XFAObjectArray();
  4559. this.time = new _xfa_object.XFAObjectArray();
  4560. }
  4561. [_xfa_object.$isTransparent]() {
  4562. return true;
  4563. }
  4564. }
  4565. class TemplateNamespace {
  4566. static [_namespaces.$buildXFAObject](name, attributes) {
  4567. if (TemplateNamespace.hasOwnProperty(name)) {
  4568. const node = TemplateNamespace[name](attributes);
  4569. node[_xfa_object.$setSetAttributes](attributes);
  4570. return node;
  4571. }
  4572. return undefined;
  4573. }
  4574. static appearanceFilter(attrs) {
  4575. return new AppearanceFilter(attrs);
  4576. }
  4577. static arc(attrs) {
  4578. return new Arc(attrs);
  4579. }
  4580. static area(attrs) {
  4581. return new Area(attrs);
  4582. }
  4583. static assist(attrs) {
  4584. return new Assist(attrs);
  4585. }
  4586. static barcode(attrs) {
  4587. return new Barcode(attrs);
  4588. }
  4589. static bind(attrs) {
  4590. return new Bind(attrs);
  4591. }
  4592. static bindItems(attrs) {
  4593. return new BindItems(attrs);
  4594. }
  4595. static bookend(attrs) {
  4596. return new Bookend(attrs);
  4597. }
  4598. static boolean(attrs) {
  4599. return new BooleanElement(attrs);
  4600. }
  4601. static border(attrs) {
  4602. return new Border(attrs);
  4603. }
  4604. static break(attrs) {
  4605. return new Break(attrs);
  4606. }
  4607. static breakAfter(attrs) {
  4608. return new BreakAfter(attrs);
  4609. }
  4610. static breakBefore(attrs) {
  4611. return new BreakBefore(attrs);
  4612. }
  4613. static button(attrs) {
  4614. return new Button(attrs);
  4615. }
  4616. static calculate(attrs) {
  4617. return new Calculate(attrs);
  4618. }
  4619. static caption(attrs) {
  4620. return new Caption(attrs);
  4621. }
  4622. static certificate(attrs) {
  4623. return new Certificate(attrs);
  4624. }
  4625. static certificates(attrs) {
  4626. return new Certificates(attrs);
  4627. }
  4628. static checkButton(attrs) {
  4629. return new CheckButton(attrs);
  4630. }
  4631. static choiceList(attrs) {
  4632. return new ChoiceList(attrs);
  4633. }
  4634. static color(attrs) {
  4635. return new Color(attrs);
  4636. }
  4637. static comb(attrs) {
  4638. return new Comb(attrs);
  4639. }
  4640. static connect(attrs) {
  4641. return new Connect(attrs);
  4642. }
  4643. static contentArea(attrs) {
  4644. return new ContentArea(attrs);
  4645. }
  4646. static corner(attrs) {
  4647. return new Corner(attrs);
  4648. }
  4649. static date(attrs) {
  4650. return new DateElement(attrs);
  4651. }
  4652. static dateTime(attrs) {
  4653. return new DateTime(attrs);
  4654. }
  4655. static dateTimeEdit(attrs) {
  4656. return new DateTimeEdit(attrs);
  4657. }
  4658. static decimal(attrs) {
  4659. return new Decimal(attrs);
  4660. }
  4661. static defaultUi(attrs) {
  4662. return new DefaultUi(attrs);
  4663. }
  4664. static desc(attrs) {
  4665. return new Desc(attrs);
  4666. }
  4667. static digestMethod(attrs) {
  4668. return new DigestMethod(attrs);
  4669. }
  4670. static digestMethods(attrs) {
  4671. return new DigestMethods(attrs);
  4672. }
  4673. static draw(attrs) {
  4674. return new Draw(attrs);
  4675. }
  4676. static edge(attrs) {
  4677. return new Edge(attrs);
  4678. }
  4679. static encoding(attrs) {
  4680. return new Encoding(attrs);
  4681. }
  4682. static encodings(attrs) {
  4683. return new Encodings(attrs);
  4684. }
  4685. static encrypt(attrs) {
  4686. return new Encrypt(attrs);
  4687. }
  4688. static encryptData(attrs) {
  4689. return new EncryptData(attrs);
  4690. }
  4691. static encryption(attrs) {
  4692. return new Encryption(attrs);
  4693. }
  4694. static encryptionMethod(attrs) {
  4695. return new EncryptionMethod(attrs);
  4696. }
  4697. static encryptionMethods(attrs) {
  4698. return new EncryptionMethods(attrs);
  4699. }
  4700. static event(attrs) {
  4701. return new Event(attrs);
  4702. }
  4703. static exData(attrs) {
  4704. return new ExData(attrs);
  4705. }
  4706. static exObject(attrs) {
  4707. return new ExObject(attrs);
  4708. }
  4709. static exclGroup(attrs) {
  4710. return new ExclGroup(attrs);
  4711. }
  4712. static execute(attrs) {
  4713. return new Execute(attrs);
  4714. }
  4715. static extras(attrs) {
  4716. return new Extras(attrs);
  4717. }
  4718. static field(attrs) {
  4719. return new Field(attrs);
  4720. }
  4721. static fill(attrs) {
  4722. return new Fill(attrs);
  4723. }
  4724. static filter(attrs) {
  4725. return new Filter(attrs);
  4726. }
  4727. static float(attrs) {
  4728. return new Float(attrs);
  4729. }
  4730. static font(attrs) {
  4731. return new Font(attrs);
  4732. }
  4733. static format(attrs) {
  4734. return new Format(attrs);
  4735. }
  4736. static handler(attrs) {
  4737. return new Handler(attrs);
  4738. }
  4739. static hyphenation(attrs) {
  4740. return new Hyphenation(attrs);
  4741. }
  4742. static image(attrs) {
  4743. return new Image(attrs);
  4744. }
  4745. static imageEdit(attrs) {
  4746. return new ImageEdit(attrs);
  4747. }
  4748. static integer(attrs) {
  4749. return new Integer(attrs);
  4750. }
  4751. static issuers(attrs) {
  4752. return new Issuers(attrs);
  4753. }
  4754. static items(attrs) {
  4755. return new Items(attrs);
  4756. }
  4757. static keep(attrs) {
  4758. return new Keep(attrs);
  4759. }
  4760. static keyUsage(attrs) {
  4761. return new KeyUsage(attrs);
  4762. }
  4763. static line(attrs) {
  4764. return new Line(attrs);
  4765. }
  4766. static linear(attrs) {
  4767. return new Linear(attrs);
  4768. }
  4769. static lockDocument(attrs) {
  4770. return new LockDocument(attrs);
  4771. }
  4772. static manifest(attrs) {
  4773. return new Manifest(attrs);
  4774. }
  4775. static margin(attrs) {
  4776. return new Margin(attrs);
  4777. }
  4778. static mdp(attrs) {
  4779. return new Mdp(attrs);
  4780. }
  4781. static medium(attrs) {
  4782. return new Medium(attrs);
  4783. }
  4784. static message(attrs) {
  4785. return new Message(attrs);
  4786. }
  4787. static numericEdit(attrs) {
  4788. return new NumericEdit(attrs);
  4789. }
  4790. static occur(attrs) {
  4791. return new Occur(attrs);
  4792. }
  4793. static oid(attrs) {
  4794. return new Oid(attrs);
  4795. }
  4796. static oids(attrs) {
  4797. return new Oids(attrs);
  4798. }
  4799. static overflow(attrs) {
  4800. return new Overflow(attrs);
  4801. }
  4802. static pageArea(attrs) {
  4803. return new PageArea(attrs);
  4804. }
  4805. static pageSet(attrs) {
  4806. return new PageSet(attrs);
  4807. }
  4808. static para(attrs) {
  4809. return new Para(attrs);
  4810. }
  4811. static passwordEdit(attrs) {
  4812. return new PasswordEdit(attrs);
  4813. }
  4814. static pattern(attrs) {
  4815. return new Pattern(attrs);
  4816. }
  4817. static picture(attrs) {
  4818. return new Picture(attrs);
  4819. }
  4820. static proto(attrs) {
  4821. return new Proto(attrs);
  4822. }
  4823. static radial(attrs) {
  4824. return new Radial(attrs);
  4825. }
  4826. static reason(attrs) {
  4827. return new Reason(attrs);
  4828. }
  4829. static reasons(attrs) {
  4830. return new Reasons(attrs);
  4831. }
  4832. static rectangle(attrs) {
  4833. return new Rectangle(attrs);
  4834. }
  4835. static ref(attrs) {
  4836. return new RefElement(attrs);
  4837. }
  4838. static script(attrs) {
  4839. return new Script(attrs);
  4840. }
  4841. static setProperty(attrs) {
  4842. return new SetProperty(attrs);
  4843. }
  4844. static signData(attrs) {
  4845. return new SignData(attrs);
  4846. }
  4847. static signature(attrs) {
  4848. return new Signature(attrs);
  4849. }
  4850. static signing(attrs) {
  4851. return new Signing(attrs);
  4852. }
  4853. static solid(attrs) {
  4854. return new Solid(attrs);
  4855. }
  4856. static speak(attrs) {
  4857. return new Speak(attrs);
  4858. }
  4859. static stipple(attrs) {
  4860. return new Stipple(attrs);
  4861. }
  4862. static subform(attrs) {
  4863. return new Subform(attrs);
  4864. }
  4865. static subformSet(attrs) {
  4866. return new SubformSet(attrs);
  4867. }
  4868. static subjectDN(attrs) {
  4869. return new SubjectDN(attrs);
  4870. }
  4871. static subjectDNs(attrs) {
  4872. return new SubjectDNs(attrs);
  4873. }
  4874. static submit(attrs) {
  4875. return new Submit(attrs);
  4876. }
  4877. static template(attrs) {
  4878. return new Template(attrs);
  4879. }
  4880. static text(attrs) {
  4881. return new Text(attrs);
  4882. }
  4883. static textEdit(attrs) {
  4884. return new TextEdit(attrs);
  4885. }
  4886. static time(attrs) {
  4887. return new Time(attrs);
  4888. }
  4889. static timeStamp(attrs) {
  4890. return new TimeStamp(attrs);
  4891. }
  4892. static toolTip(attrs) {
  4893. return new ToolTip(attrs);
  4894. }
  4895. static traversal(attrs) {
  4896. return new Traversal(attrs);
  4897. }
  4898. static traverse(attrs) {
  4899. return new Traverse(attrs);
  4900. }
  4901. static ui(attrs) {
  4902. return new Ui(attrs);
  4903. }
  4904. static validate(attrs) {
  4905. return new Validate(attrs);
  4906. }
  4907. static value(attrs) {
  4908. return new Value(attrs);
  4909. }
  4910. static variables(attrs) {
  4911. return new Variables(attrs);
  4912. }
  4913. }
  4914. exports.TemplateNamespace = TemplateNamespace;