template.js 168 KB

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