exporter-debug.js 222 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269
  1. /*
  2. @source http://purl.eligrey.com/github/FileSaver.js/blob/master/FileSaver.js */
  3. var $jscomp = $jscomp || {};
  4. $jscomp.scope = {};
  5. $jscomp.defineProperty = typeof Object.defineProperties == 'function' ? Object.defineProperty : function(target, property, descriptor) {
  6. descriptor = (descriptor);
  7. if (target == Array.prototype || target == Object.prototype) {
  8. return;
  9. }
  10. target[property] = descriptor.value;
  11. };
  12. $jscomp.getGlobal = function(maybeGlobal) {
  13. return typeof window != 'undefined' && window === maybeGlobal ? maybeGlobal : typeof global != 'undefined' && global != null ? global : maybeGlobal;
  14. };
  15. $jscomp.global = $jscomp.getGlobal(this);
  16. $jscomp.polyfill = function(target, polyfill, fromLang, toLang) {
  17. if (!polyfill) {
  18. return;
  19. }
  20. var obj = $jscomp.global;
  21. var split = target.split('.');
  22. for (var i = 0; i < split.length - 1; i++) {
  23. var key = split[i];
  24. if (!(key in obj)) {
  25. obj[key] = {};
  26. }
  27. obj = obj[key];
  28. }
  29. var property = split[split.length - 1];
  30. var orig = obj[property];
  31. var impl = polyfill(orig);
  32. if (impl == orig || impl == null) {
  33. return;
  34. }
  35. $jscomp.defineProperty(obj, property, {configurable:true, writable:true, value:impl});
  36. };
  37. $jscomp.polyfill('Array.prototype.copyWithin', function(orig) {
  38. if (orig) {
  39. return orig;
  40. }
  41. var polyfill = function(target, start, opt_end) {
  42. var len = this.length;
  43. target = Number(target);
  44. start = Number(start);
  45. opt_end = Number(opt_end != null ? opt_end : len);
  46. if (target < start) {
  47. opt_end = Math.min(opt_end, len);
  48. while (start < opt_end) {
  49. if (start in this) {
  50. this[target++] = this[start++];
  51. } else {
  52. delete this[target++];
  53. start++;
  54. }
  55. }
  56. } else {
  57. opt_end = Math.min(opt_end, len + start - target);
  58. target += opt_end - start;
  59. while (opt_end > start) {
  60. if (--opt_end in this) {
  61. this[--target] = this[opt_end];
  62. } else {
  63. delete this[target];
  64. }
  65. }
  66. }
  67. return this;
  68. };
  69. return polyfill;
  70. }, 'es6-impl', 'es3');
  71. $jscomp.SYMBOL_PREFIX = 'jscomp_symbol_';
  72. $jscomp.initSymbol = function() {
  73. $jscomp.initSymbol = function() {
  74. };
  75. if (!$jscomp.global['Symbol']) {
  76. $jscomp.global['Symbol'] = $jscomp.Symbol;
  77. }
  78. };
  79. $jscomp.symbolCounter_ = 0;
  80. $jscomp.Symbol = function(opt_description) {
  81. return ($jscomp.SYMBOL_PREFIX + (opt_description || '') + $jscomp.symbolCounter_++);
  82. };
  83. $jscomp.initSymbolIterator = function() {
  84. $jscomp.initSymbol();
  85. var symbolIterator = $jscomp.global['Symbol'].iterator;
  86. if (!symbolIterator) {
  87. symbolIterator = $jscomp.global['Symbol'].iterator = $jscomp.global['Symbol']('iterator');
  88. }
  89. if (typeof Array.prototype[symbolIterator] != 'function') {
  90. $jscomp.defineProperty(Array.prototype, symbolIterator, {configurable:true, writable:true, value:function() {
  91. return $jscomp.arrayIterator(this);
  92. }});
  93. }
  94. $jscomp.initSymbolIterator = function() {
  95. };
  96. };
  97. $jscomp.arrayIterator = function(array) {
  98. var index = 0;
  99. return $jscomp.iteratorPrototype(function() {
  100. if (index < array.length) {
  101. return {done:false, value:array[index++]};
  102. } else {
  103. return {done:true};
  104. }
  105. });
  106. };
  107. $jscomp.iteratorPrototype = function(next) {
  108. $jscomp.initSymbolIterator();
  109. var iterator = {next:next};
  110. iterator[$jscomp.global['Symbol'].iterator] = function() {
  111. return this;
  112. };
  113. return (iterator);
  114. };
  115. $jscomp.iteratorFromArray = function(array, transform) {
  116. $jscomp.initSymbolIterator();
  117. if (array instanceof String) {
  118. array = array + '';
  119. }
  120. var i = 0;
  121. var iter = {next:function() {
  122. if (i < array.length) {
  123. var index = i++;
  124. return {value:transform(index, array[index]), done:false};
  125. }
  126. iter.next = function() {
  127. return {done:true, value:void 0};
  128. };
  129. return iter.next();
  130. }};
  131. iter[Symbol.iterator] = function() {
  132. return iter;
  133. };
  134. return iter;
  135. };
  136. $jscomp.polyfill('Array.prototype.entries', function(orig) {
  137. if (orig) {
  138. return orig;
  139. }
  140. var polyfill = function() {
  141. return $jscomp.iteratorFromArray(this, function(i, v) {
  142. return [i, v];
  143. });
  144. };
  145. return polyfill;
  146. }, 'es6-impl', 'es3');
  147. $jscomp.polyfill('Array.prototype.fill', function(orig) {
  148. if (orig) {
  149. return orig;
  150. }
  151. var polyfill = function(value, opt_start, opt_end) {
  152. var length = this.length || 0;
  153. if (opt_start < 0) {
  154. opt_start = Math.max(0, length + (opt_start));
  155. }
  156. if (opt_end == null || opt_end > length) {
  157. opt_end = length;
  158. }
  159. opt_end = Number(opt_end);
  160. if (opt_end < 0) {
  161. opt_end = Math.max(0, length + opt_end);
  162. }
  163. for (var i = Number(opt_start || 0); i < opt_end; i++) {
  164. this[i] = value;
  165. }
  166. return this;
  167. };
  168. return polyfill;
  169. }, 'es6-impl', 'es3');
  170. $jscomp.findInternal = function(array, callback, thisArg) {
  171. if (array instanceof String) {
  172. array = (String(array));
  173. }
  174. var len = array.length;
  175. for (var i = 0; i < len; i++) {
  176. var value = array[i];
  177. if (callback.call(thisArg, value, i, array)) {
  178. return {i:i, v:value};
  179. }
  180. }
  181. return {i:-1, v:void 0};
  182. };
  183. $jscomp.polyfill('Array.prototype.find', function(orig) {
  184. if (orig) {
  185. return orig;
  186. }
  187. var polyfill = function(callback, opt_thisArg) {
  188. return $jscomp.findInternal(this, callback, opt_thisArg).v;
  189. };
  190. return polyfill;
  191. }, 'es6-impl', 'es3');
  192. $jscomp.polyfill('Array.prototype.findIndex', function(orig) {
  193. if (orig) {
  194. return orig;
  195. }
  196. var polyfill = function(callback, opt_thisArg) {
  197. return $jscomp.findInternal(this, callback, opt_thisArg).i;
  198. };
  199. return polyfill;
  200. }, 'es6-impl', 'es3');
  201. $jscomp.polyfill('Array.from', function(orig) {
  202. if (orig) {
  203. return orig;
  204. }
  205. var polyfill = function(arrayLike, opt_mapFn, opt_thisArg) {
  206. $jscomp.initSymbolIterator();
  207. opt_mapFn = opt_mapFn != null ? opt_mapFn : function(x) {
  208. return x;
  209. };
  210. var result = [];
  211. var iteratorFunction = (arrayLike)[Symbol.iterator];
  212. if (typeof iteratorFunction == 'function') {
  213. arrayLike = iteratorFunction.call(arrayLike);
  214. var next;
  215. while (!(next = arrayLike.next()).done) {
  216. result.push(opt_mapFn.call((opt_thisArg), next.value));
  217. }
  218. } else {
  219. var len = arrayLike.length;
  220. for (var i = 0; i < len; i++) {
  221. result.push(opt_mapFn.call((opt_thisArg), arrayLike[i]));
  222. }
  223. }
  224. return result;
  225. };
  226. return polyfill;
  227. }, 'es6-impl', 'es3');
  228. $jscomp.polyfill('Object.is', function(orig) {
  229. if (orig) {
  230. return orig;
  231. }
  232. var polyfill = function(left, right) {
  233. if (left === right) {
  234. return left !== 0 || 1 / left === 1 / (right);
  235. } else {
  236. return left !== left && right !== right;
  237. }
  238. };
  239. return polyfill;
  240. }, 'es6-impl', 'es3');
  241. $jscomp.polyfill('Array.prototype.includes', function(orig) {
  242. if (orig) {
  243. return orig;
  244. }
  245. var includes = function(searchElement, opt_fromIndex) {
  246. var array = this;
  247. if (array instanceof String) {
  248. array = (String(array));
  249. }
  250. var len = array.length;
  251. for (var i = opt_fromIndex || 0; i < len; i++) {
  252. if (array[i] == searchElement || Object.is(array[i], searchElement)) {
  253. return true;
  254. }
  255. }
  256. return false;
  257. };
  258. return includes;
  259. }, 'es7', 'es3');
  260. $jscomp.polyfill('Array.prototype.keys', function(orig) {
  261. if (orig) {
  262. return orig;
  263. }
  264. var polyfill = function() {
  265. return $jscomp.iteratorFromArray(this, function(i) {
  266. return i;
  267. });
  268. };
  269. return polyfill;
  270. }, 'es6-impl', 'es3');
  271. $jscomp.polyfill('Array.of', function(orig) {
  272. if (orig) {
  273. return orig;
  274. }
  275. var polyfill = function(var_args) {
  276. return Array.from(arguments);
  277. };
  278. return polyfill;
  279. }, 'es6-impl', 'es3');
  280. $jscomp.polyfill('Array.prototype.values', function(orig) {
  281. if (orig) {
  282. return orig;
  283. }
  284. var polyfill = function() {
  285. return $jscomp.iteratorFromArray(this, function(k, v) {
  286. return v;
  287. });
  288. };
  289. return polyfill;
  290. }, 'es6', 'es3');
  291. $jscomp.makeIterator = function(iterable) {
  292. $jscomp.initSymbolIterator();
  293. var iteratorFunction = (iterable)[Symbol.iterator];
  294. return iteratorFunction ? iteratorFunction.call(iterable) : $jscomp.arrayIterator((iterable));
  295. };
  296. $jscomp.EXPOSE_ASYNC_EXECUTOR = true;
  297. $jscomp.FORCE_POLYFILL_PROMISE = false;
  298. $jscomp.polyfill('Promise', function(NativePromise) {
  299. if (NativePromise && !$jscomp.FORCE_POLYFILL_PROMISE) {
  300. return NativePromise;
  301. }
  302. function AsyncExecutor() {
  303. this.batch_ = null;
  304. }
  305. AsyncExecutor.prototype.asyncExecute = function(f) {
  306. if (this.batch_ == null) {
  307. this.batch_ = [];
  308. this.asyncExecuteBatch_();
  309. }
  310. this.batch_.push(f);
  311. return this;
  312. };
  313. AsyncExecutor.prototype.asyncExecuteBatch_ = function() {
  314. var self = this;
  315. this.asyncExecuteFunction(function() {
  316. self.executeBatch_();
  317. });
  318. };
  319. var nativeSetTimeout = $jscomp.global['setTimeout'];
  320. AsyncExecutor.prototype.asyncExecuteFunction = function(f) {
  321. nativeSetTimeout(f, 0);
  322. };
  323. AsyncExecutor.prototype.executeBatch_ = function() {
  324. while (this.batch_ && this.batch_.length) {
  325. var executingBatch = this.batch_;
  326. this.batch_ = [];
  327. for (var i = 0; i < executingBatch.length; ++i) {
  328. var f = executingBatch[i];
  329. delete executingBatch[i];
  330. try {
  331. f();
  332. } catch (error) {
  333. this.asyncThrow_(error);
  334. }
  335. }
  336. }
  337. this.batch_ = null;
  338. };
  339. AsyncExecutor.prototype.asyncThrow_ = function(exception) {
  340. this.asyncExecuteFunction(function() {
  341. throw exception;
  342. });
  343. };
  344. var PromiseState = {PENDING:0, FULFILLED:1, REJECTED:2};
  345. var PolyfillPromise = function(executor) {
  346. this.state_ = PromiseState.PENDING;
  347. this.result_ = undefined;
  348. this.onSettledCallbacks_ = [];
  349. var resolveAndReject = this.createResolveAndReject_();
  350. try {
  351. executor(resolveAndReject.resolve, resolveAndReject.reject);
  352. } catch (e) {
  353. resolveAndReject.reject(e);
  354. }
  355. };
  356. PolyfillPromise.prototype.createResolveAndReject_ = function() {
  357. var thisPromise = this;
  358. var alreadyCalled = false;
  359. function firstCallWins(method) {
  360. return function(x) {
  361. if (!alreadyCalled) {
  362. alreadyCalled = true;
  363. method.call(thisPromise, x);
  364. }
  365. };
  366. }
  367. return {resolve:firstCallWins(this.resolveTo_), reject:firstCallWins(this.reject_)};
  368. };
  369. PolyfillPromise.prototype.resolveTo_ = function(value) {
  370. if (value === this) {
  371. this.reject_(new TypeError('A Promise cannot resolve to itself'));
  372. } else {
  373. if (value instanceof PolyfillPromise) {
  374. this.settleSameAsPromise_((value));
  375. } else {
  376. if (isObject(value)) {
  377. this.resolveToNonPromiseObj_((value));
  378. } else {
  379. this.fulfill_(value);
  380. }
  381. }
  382. }
  383. };
  384. PolyfillPromise.prototype.resolveToNonPromiseObj_ = function(obj) {
  385. var thenMethod = undefined;
  386. try {
  387. thenMethod = obj.then;
  388. } catch (error) {
  389. this.reject_(error);
  390. return;
  391. }
  392. if (typeof thenMethod == 'function') {
  393. this.settleSameAsThenable_(thenMethod, (obj));
  394. } else {
  395. this.fulfill_(obj);
  396. }
  397. };
  398. function isObject(value) {
  399. switch(typeof value) {
  400. case 'object':
  401. return value != null;
  402. case 'function':
  403. return true;
  404. default:
  405. return false;
  406. }
  407. }
  408. PolyfillPromise.prototype.reject_ = function(reason) {
  409. this.settle_(PromiseState.REJECTED, reason);
  410. };
  411. PolyfillPromise.prototype.fulfill_ = function(value) {
  412. this.settle_(PromiseState.FULFILLED, value);
  413. };
  414. PolyfillPromise.prototype.settle_ = function(settledState, valueOrReason) {
  415. if (this.state_ != PromiseState.PENDING) {
  416. throw new Error('Cannot settle(' + settledState + ', ' + valueOrReason | '): Promise already settled in state' + this.state_);
  417. }
  418. this.state_ = settledState;
  419. this.result_ = valueOrReason;
  420. this.executeOnSettledCallbacks_();
  421. };
  422. PolyfillPromise.prototype.executeOnSettledCallbacks_ = function() {
  423. if (this.onSettledCallbacks_ != null) {
  424. var callbacks = this.onSettledCallbacks_;
  425. for (var i = 0; i < callbacks.length; ++i) {
  426. (callbacks[i]).call();
  427. callbacks[i] = null;
  428. }
  429. this.onSettledCallbacks_ = null;
  430. }
  431. };
  432. var asyncExecutor = new AsyncExecutor;
  433. PolyfillPromise.prototype.settleSameAsPromise_ = function(promise) {
  434. var methods = this.createResolveAndReject_();
  435. promise.callWhenSettled_(methods.resolve, methods.reject);
  436. };
  437. PolyfillPromise.prototype.settleSameAsThenable_ = function(thenMethod, thenable) {
  438. var methods = this.createResolveAndReject_();
  439. try {
  440. thenMethod.call(thenable, methods.resolve, methods.reject);
  441. } catch (error) {
  442. methods.reject(error);
  443. }
  444. };
  445. PolyfillPromise.prototype.then = function(onFulfilled, onRejected) {
  446. var resolveChild;
  447. var rejectChild;
  448. var childPromise = new PolyfillPromise(function(resolve, reject) {
  449. resolveChild = resolve;
  450. rejectChild = reject;
  451. });
  452. function createCallback(paramF, defaultF) {
  453. if (typeof paramF == 'function') {
  454. return function(x) {
  455. try {
  456. resolveChild(paramF(x));
  457. } catch (error) {
  458. rejectChild(error);
  459. }
  460. };
  461. } else {
  462. return defaultF;
  463. }
  464. }
  465. this.callWhenSettled_(createCallback(onFulfilled, resolveChild), createCallback(onRejected, rejectChild));
  466. return childPromise;
  467. };
  468. PolyfillPromise.prototype['catch'] = function(onRejected) {
  469. return this.then(undefined, onRejected);
  470. };
  471. PolyfillPromise.prototype.callWhenSettled_ = function(onFulfilled, onRejected) {
  472. var thisPromise = this;
  473. function callback() {
  474. switch(thisPromise.state_) {
  475. case PromiseState.FULFILLED:
  476. onFulfilled(thisPromise.result_);
  477. break;
  478. case PromiseState.REJECTED:
  479. onRejected(thisPromise.result_);
  480. break;
  481. default:
  482. throw new Error('Unexpected state: ' + thisPromise.state_);
  483. }
  484. }
  485. if (this.onSettledCallbacks_ == null) {
  486. asyncExecutor.asyncExecute(callback);
  487. } else {
  488. this.onSettledCallbacks_.push(function() {
  489. asyncExecutor.asyncExecute(callback);
  490. });
  491. }
  492. };
  493. PolyfillPromise.resolve = function(opt_value) {
  494. if (opt_value instanceof PolyfillPromise) {
  495. return opt_value;
  496. } else {
  497. return new PolyfillPromise(function(resolve, reject) {
  498. resolve(opt_value);
  499. });
  500. }
  501. };
  502. PolyfillPromise.reject = function(opt_reason) {
  503. return new PolyfillPromise(function(resolve, reject) {
  504. reject(opt_reason);
  505. });
  506. };
  507. PolyfillPromise.race = function(thenablesOrValues) {
  508. return new PolyfillPromise(function(resolve, reject) {
  509. var iterator = $jscomp.makeIterator(thenablesOrValues);
  510. for (var iterRec = iterator.next(); !iterRec.done; iterRec = iterator.next()) {
  511. PolyfillPromise.resolve(iterRec.value).callWhenSettled_(resolve, reject);
  512. }
  513. });
  514. };
  515. PolyfillPromise.all = function(thenablesOrValues) {
  516. var iterator = $jscomp.makeIterator(thenablesOrValues);
  517. var iterRec = iterator.next();
  518. if (iterRec.done) {
  519. return PolyfillPromise.resolve([]);
  520. } else {
  521. return new PolyfillPromise(function(resolveAll, rejectAll) {
  522. var resultsArray = [];
  523. var unresolvedCount = 0;
  524. function onFulfilled(i) {
  525. return function(ithResult) {
  526. resultsArray[i] = ithResult;
  527. unresolvedCount--;
  528. if (unresolvedCount == 0) {
  529. resolveAll(resultsArray);
  530. }
  531. };
  532. }
  533. do {
  534. resultsArray.push(undefined);
  535. unresolvedCount++;
  536. PolyfillPromise.resolve(iterRec.value).callWhenSettled_(onFulfilled(resultsArray.length - 1), rejectAll);
  537. iterRec = iterator.next();
  538. } while (!iterRec.done);
  539. });
  540. }
  541. };
  542. if ($jscomp.EXPOSE_ASYNC_EXECUTOR) {
  543. PolyfillPromise['$jscomp$new$AsyncExecutor'] = function() {
  544. return new AsyncExecutor;
  545. };
  546. }
  547. return PolyfillPromise;
  548. }, 'es6-impl', 'es3');
  549. $jscomp.executeAsyncGenerator = function(generator) {
  550. function passValueToGenerator(value) {
  551. return generator.next(value);
  552. }
  553. function passErrorToGenerator(error) {
  554. return generator['throw'](error);
  555. }
  556. return new Promise(function(resolve, reject) {
  557. function handleGeneratorRecord(genRec) {
  558. if (genRec.done) {
  559. resolve(genRec.value);
  560. } else {
  561. Promise.resolve(genRec.value).then(passValueToGenerator, passErrorToGenerator).then(handleGeneratorRecord, reject);
  562. }
  563. }
  564. handleGeneratorRecord(generator.next());
  565. });
  566. };
  567. $jscomp.owns = function(obj, prop) {
  568. return Object.prototype.hasOwnProperty.call(obj, prop);
  569. };
  570. $jscomp.polyfill('WeakMap', function(NativeWeakMap) {
  571. function isConformant() {
  572. if (!NativeWeakMap || !Object.seal) {
  573. return false;
  574. }
  575. try {
  576. var x = Object.seal({});
  577. var y = Object.seal({});
  578. var map = new (NativeWeakMap)([[x, 2], [y, 3]]);
  579. if (map.get(x) != 2 || map.get(y) != 3) {
  580. return false;
  581. }
  582. map['delete'](x);
  583. map.set(y, 4);
  584. return !map.has(x) && map.get(y) == 4;
  585. } catch (err) {
  586. return false;
  587. }
  588. }
  589. if (isConformant()) {
  590. return NativeWeakMap;
  591. }
  592. var prop = '$jscomp_hidden_' + Math.random().toString().substring(2);
  593. function insert(target) {
  594. if (!$jscomp.owns(target, prop)) {
  595. var obj = {};
  596. $jscomp.defineProperty(target, prop, {value:obj});
  597. }
  598. }
  599. function patch(name) {
  600. var prev = Object[name];
  601. if (prev) {
  602. Object[name] = function(target) {
  603. insert(target);
  604. return prev(target);
  605. };
  606. }
  607. }
  608. patch('freeze');
  609. patch('preventExtensions');
  610. patch('seal');
  611. var index = 0;
  612. var PolyfillWeakMap = function(opt_iterable) {
  613. this.id_ = (index += Math.random() + 1).toString();
  614. if (opt_iterable) {
  615. $jscomp.initSymbol();
  616. $jscomp.initSymbolIterator();
  617. var iter = $jscomp.makeIterator(opt_iterable);
  618. var entry;
  619. while (!(entry = iter.next()).done) {
  620. var item = entry.value;
  621. this.set((item[0]), (item[1]));
  622. }
  623. }
  624. };
  625. PolyfillWeakMap.prototype.set = function(key, value) {
  626. insert(key);
  627. if (!$jscomp.owns(key, prop)) {
  628. throw new Error('WeakMap key fail: ' + key);
  629. }
  630. key[prop][this.id_] = value;
  631. return this;
  632. };
  633. PolyfillWeakMap.prototype.get = function(key) {
  634. return $jscomp.owns(key, prop) ? key[prop][this.id_] : undefined;
  635. };
  636. PolyfillWeakMap.prototype.has = function(key) {
  637. return $jscomp.owns(key, prop) && $jscomp.owns(key[prop], this.id_);
  638. };
  639. PolyfillWeakMap.prototype['delete'] = function(key) {
  640. if (!$jscomp.owns(key, prop) || !$jscomp.owns(key[prop], this.id_)) {
  641. return false;
  642. }
  643. return delete key[prop][this.id_];
  644. };
  645. return PolyfillWeakMap;
  646. }, 'es6-impl', 'es3');
  647. $jscomp.MapEntry = function() {
  648. this.previous;
  649. this.next;
  650. this.head;
  651. this.key;
  652. this.value;
  653. };
  654. $jscomp.ASSUME_NO_NATIVE_MAP = false;
  655. $jscomp.polyfill('Map', function(NativeMap) {
  656. var isConformant = !$jscomp.ASSUME_NO_NATIVE_MAP && function() {
  657. if (!NativeMap || !NativeMap.prototype.entries || typeof Object.seal != 'function') {
  658. return false;
  659. }
  660. try {
  661. NativeMap = (NativeMap);
  662. var key = Object.seal({x:4});
  663. var map = new NativeMap($jscomp.makeIterator([[key, 's']]));
  664. if (map.get(key) != 's' || map.size != 1 || map.get({x:4}) || map.set({x:4}, 't') != map || map.size != 2) {
  665. return false;
  666. }
  667. var iter = map.entries();
  668. var item = iter.next();
  669. if (item.done || item.value[0] != key || item.value[1] != 's') {
  670. return false;
  671. }
  672. item = iter.next();
  673. if (item.done || item.value[0].x != 4 || item.value[1] != 't' || !iter.next().done) {
  674. return false;
  675. }
  676. return true;
  677. } catch (err) {
  678. return false;
  679. }
  680. }();
  681. if (isConformant) {
  682. return NativeMap;
  683. }
  684. $jscomp.initSymbol();
  685. $jscomp.initSymbolIterator();
  686. var idMap = new WeakMap;
  687. var PolyfillMap = function(opt_iterable) {
  688. this.data_ = {};
  689. this.head_ = createHead();
  690. this.size = 0;
  691. if (opt_iterable) {
  692. var iter = $jscomp.makeIterator(opt_iterable);
  693. var entry;
  694. while (!(entry = iter.next()).done) {
  695. var item = (entry).value;
  696. this.set((item[0]), (item[1]));
  697. }
  698. }
  699. };
  700. PolyfillMap.prototype.set = function(key, value) {
  701. var r = maybeGetEntry(this, key);
  702. if (!r.list) {
  703. r.list = this.data_[r.id] = [];
  704. }
  705. if (!r.entry) {
  706. r.entry = {next:this.head_, previous:this.head_.previous, head:this.head_, key:key, value:value};
  707. r.list.push(r.entry);
  708. this.head_.previous.next = r.entry;
  709. this.head_.previous = r.entry;
  710. this.size++;
  711. } else {
  712. r.entry.value = value;
  713. }
  714. return this;
  715. };
  716. PolyfillMap.prototype['delete'] = function(key) {
  717. var r = maybeGetEntry(this, key);
  718. if (r.entry && r.list) {
  719. r.list.splice(r.index, 1);
  720. if (!r.list.length) {
  721. delete this.data_[r.id];
  722. }
  723. r.entry.previous.next = r.entry.next;
  724. r.entry.next.previous = r.entry.previous;
  725. r.entry.head = null;
  726. this.size--;
  727. return true;
  728. }
  729. return false;
  730. };
  731. PolyfillMap.prototype.clear = function() {
  732. this.data_ = {};
  733. this.head_ = this.head_.previous = createHead();
  734. this.size = 0;
  735. };
  736. PolyfillMap.prototype.has = function(key) {
  737. return !!maybeGetEntry(this, key).entry;
  738. };
  739. PolyfillMap.prototype.get = function(key) {
  740. var entry = maybeGetEntry(this, key).entry;
  741. return (entry && (entry.value));
  742. };
  743. PolyfillMap.prototype.entries = function() {
  744. return makeIterator(this, function(entry) {
  745. return [entry.key, entry.value];
  746. });
  747. };
  748. PolyfillMap.prototype.keys = function() {
  749. return makeIterator(this, function(entry) {
  750. return entry.key;
  751. });
  752. };
  753. PolyfillMap.prototype.values = function() {
  754. return makeIterator(this, function(entry) {
  755. return entry.value;
  756. });
  757. };
  758. PolyfillMap.prototype.forEach = function(callback, opt_thisArg) {
  759. var iter = this.entries();
  760. var item;
  761. while (!(item = iter.next()).done) {
  762. var entry = item.value;
  763. callback.call((opt_thisArg), (entry[1]), (entry[0]), this);
  764. }
  765. };
  766. (PolyfillMap.prototype)[Symbol.iterator] = PolyfillMap.prototype.entries;
  767. var maybeGetEntry = function(map, key) {
  768. var id = getId(key);
  769. var list = map.data_[id];
  770. if (list && $jscomp.owns(map.data_, id)) {
  771. for (var index = 0; index < list.length; index++) {
  772. var entry = list[index];
  773. if (key !== key && entry.key !== entry.key || key === entry.key) {
  774. return {id:id, list:list, index:index, entry:entry};
  775. }
  776. }
  777. }
  778. return {id:id, list:list, index:-1, entry:undefined};
  779. };
  780. var makeIterator = function(map, func) {
  781. var entry = map.head_;
  782. return $jscomp.iteratorPrototype(function() {
  783. if (entry) {
  784. while (entry.head != map.head_) {
  785. entry = entry.previous;
  786. }
  787. while (entry.next != entry.head) {
  788. entry = entry.next;
  789. return {done:false, value:func(entry)};
  790. }
  791. entry = null;
  792. }
  793. return {done:true, value:void 0};
  794. });
  795. };
  796. var createHead = function() {
  797. var head = {};
  798. head.previous = head.next = head.head = head;
  799. return head;
  800. };
  801. var mapIndex = 0;
  802. var getId = function(obj) {
  803. var type = obj && typeof obj;
  804. if (type == 'object' || type == 'function') {
  805. obj = (obj);
  806. if (!idMap.has(obj)) {
  807. var id = '' + ++mapIndex;
  808. idMap.set(obj, id);
  809. return id;
  810. }
  811. return idMap.get(obj);
  812. }
  813. return 'p_' + obj;
  814. };
  815. return PolyfillMap;
  816. }, 'es6-impl', 'es3');
  817. $jscomp.polyfill('Math.acosh', function(orig) {
  818. if (orig) {
  819. return orig;
  820. }
  821. var polyfill = function(x) {
  822. x = Number(x);
  823. return Math.log(x + Math.sqrt(x * x - 1));
  824. };
  825. return polyfill;
  826. }, 'es6-impl', 'es3');
  827. $jscomp.polyfill('Math.asinh', function(orig) {
  828. if (orig) {
  829. return orig;
  830. }
  831. var polyfill = function(x) {
  832. x = Number(x);
  833. if (x === 0) {
  834. return x;
  835. }
  836. var y = Math.log(Math.abs(x) + Math.sqrt(x * x + 1));
  837. return x < 0 ? -y : y;
  838. };
  839. return polyfill;
  840. }, 'es6-impl', 'es3');
  841. $jscomp.polyfill('Math.log1p', function(orig) {
  842. if (orig) {
  843. return orig;
  844. }
  845. var polyfill = function(x) {
  846. x = Number(x);
  847. if (x < 0.25 && x > -0.25) {
  848. var y = x;
  849. var d = 1;
  850. var z = x;
  851. var zPrev = 0;
  852. var s = 1;
  853. while (zPrev != z) {
  854. y *= x;
  855. s *= -1;
  856. z = (zPrev = z) + s * y / ++d;
  857. }
  858. return z;
  859. }
  860. return Math.log(1 + x);
  861. };
  862. return polyfill;
  863. }, 'es6-impl', 'es3');
  864. $jscomp.polyfill('Math.atanh', function(orig) {
  865. if (orig) {
  866. return orig;
  867. }
  868. var log1p = Math.log1p;
  869. var polyfill = function(x) {
  870. x = Number(x);
  871. return (log1p(x) - log1p(-x)) / 2;
  872. };
  873. return polyfill;
  874. }, 'es6-impl', 'es3');
  875. $jscomp.polyfill('Math.cbrt', function(orig) {
  876. if (orig) {
  877. return orig;
  878. }
  879. var polyfill = function(x) {
  880. if (x === 0) {
  881. return x;
  882. }
  883. x = Number(x);
  884. var y = Math.pow(Math.abs(x), 1 / 3);
  885. return x < 0 ? -y : y;
  886. };
  887. return polyfill;
  888. }, 'es6-impl', 'es3');
  889. $jscomp.polyfill('Math.clz32', function(orig) {
  890. if (orig) {
  891. return orig;
  892. }
  893. var polyfill = function(x) {
  894. x = Number(x) >>> 0;
  895. if (x === 0) {
  896. return 32;
  897. }
  898. var result = 0;
  899. if ((x & 4294901760) === 0) {
  900. x <<= 16;
  901. result += 16;
  902. }
  903. if ((x & 4278190080) === 0) {
  904. x <<= 8;
  905. result += 8;
  906. }
  907. if ((x & 4026531840) === 0) {
  908. x <<= 4;
  909. result += 4;
  910. }
  911. if ((x & 3221225472) === 0) {
  912. x <<= 2;
  913. result += 2;
  914. }
  915. if ((x & 2147483648) === 0) {
  916. result++;
  917. }
  918. return result;
  919. };
  920. return polyfill;
  921. }, 'es6-impl', 'es3');
  922. $jscomp.polyfill('Math.cosh', function(orig) {
  923. if (orig) {
  924. return orig;
  925. }
  926. var exp = Math.exp;
  927. var polyfill = function(x) {
  928. x = Number(x);
  929. return (exp(x) + exp(-x)) / 2;
  930. };
  931. return polyfill;
  932. }, 'es6-impl', 'es3');
  933. $jscomp.polyfill('Math.expm1', function(orig) {
  934. if (orig) {
  935. return orig;
  936. }
  937. var polyfill = function(x) {
  938. x = Number(x);
  939. if (x < .25 && x > -.25) {
  940. var y = x;
  941. var d = 1;
  942. var z = x;
  943. var zPrev = 0;
  944. while (zPrev != z) {
  945. y *= x / ++d;
  946. z = (zPrev = z) + y;
  947. }
  948. return z;
  949. }
  950. return Math.exp(x) - 1;
  951. };
  952. return polyfill;
  953. }, 'es6-impl', 'es3');
  954. $jscomp.polyfill('Math.hypot', function(orig) {
  955. if (orig) {
  956. return orig;
  957. }
  958. var polyfill = function(x, y, var_args) {
  959. x = Number(x);
  960. y = Number(y);
  961. var i, z, sum;
  962. var max = Math.max(Math.abs(x), Math.abs(y));
  963. for (i = 2; i < arguments.length; i++) {
  964. max = Math.max(max, Math.abs(arguments[i]));
  965. }
  966. if (max > 1e100 || max < 1e-100) {
  967. x = x / max;
  968. y = y / max;
  969. sum = x * x + y * y;
  970. for (i = 2; i < arguments.length; i++) {
  971. z = Number(arguments[i]) / max;
  972. sum += z * z;
  973. }
  974. return Math.sqrt(sum) * max;
  975. } else {
  976. sum = x * x + y * y;
  977. for (i = 2; i < arguments.length; i++) {
  978. z = Number(arguments[i]);
  979. sum += z * z;
  980. }
  981. return Math.sqrt(sum);
  982. }
  983. };
  984. return polyfill;
  985. }, 'es6-impl', 'es3');
  986. $jscomp.polyfill('Math.imul', function(orig) {
  987. if (orig) {
  988. return orig;
  989. }
  990. var polyfill = function(a, b) {
  991. a = Number(a);
  992. b = Number(b);
  993. var ah = a >>> 16 & 65535;
  994. var al = a & 65535;
  995. var bh = b >>> 16 & 65535;
  996. var bl = b & 65535;
  997. var lh = ah * bl + al * bh << 16 >>> 0;
  998. return al * bl + lh | 0;
  999. };
  1000. return polyfill;
  1001. }, 'es6-impl', 'es3');
  1002. $jscomp.polyfill('Math.log10', function(orig) {
  1003. if (orig) {
  1004. return orig;
  1005. }
  1006. var polyfill = function(x) {
  1007. return Math.log(x) / Math.LN10;
  1008. };
  1009. return polyfill;
  1010. }, 'es6-impl', 'es3');
  1011. $jscomp.polyfill('Math.log2', function(orig) {
  1012. if (orig) {
  1013. return orig;
  1014. }
  1015. var polyfill = function(x) {
  1016. return Math.log(x) / Math.LN2;
  1017. };
  1018. return polyfill;
  1019. }, 'es6-impl', 'es3');
  1020. $jscomp.polyfill('Math.sign', function(orig) {
  1021. if (orig) {
  1022. return orig;
  1023. }
  1024. var polyfill = function(x) {
  1025. x = Number(x);
  1026. return x === 0 || isNaN(x) ? x : x > 0 ? 1 : -1;
  1027. };
  1028. return polyfill;
  1029. }, 'es6-impl', 'es3');
  1030. $jscomp.polyfill('Math.sinh', function(orig) {
  1031. if (orig) {
  1032. return orig;
  1033. }
  1034. var exp = Math.exp;
  1035. var polyfill = function(x) {
  1036. x = Number(x);
  1037. if (x === 0) {
  1038. return x;
  1039. }
  1040. return (exp(x) - exp(-x)) / 2;
  1041. };
  1042. return polyfill;
  1043. }, 'es6-impl', 'es3');
  1044. $jscomp.polyfill('Math.tanh', function(orig) {
  1045. if (orig) {
  1046. return orig;
  1047. }
  1048. var polyfill = function(x) {
  1049. x = Number(x);
  1050. if (x === 0) {
  1051. return x;
  1052. }
  1053. var y = Math.exp(-2 * Math.abs(x));
  1054. var z = (1 - y) / (1 + y);
  1055. return x < 0 ? -z : z;
  1056. };
  1057. return polyfill;
  1058. }, 'es6-impl', 'es3');
  1059. $jscomp.polyfill('Math.trunc', function(orig) {
  1060. if (orig) {
  1061. return orig;
  1062. }
  1063. var polyfill = function(x) {
  1064. x = Number(x);
  1065. if (isNaN(x) || x === Infinity || x === -Infinity || x === 0) {
  1066. return x;
  1067. }
  1068. var y = Math.floor(Math.abs(x));
  1069. return x < 0 ? -y : y;
  1070. };
  1071. return polyfill;
  1072. }, 'es6-impl', 'es3');
  1073. $jscomp.polyfill('Number.EPSILON', function(orig) {
  1074. return Math.pow(2, -52);
  1075. }, 'es6-impl', 'es3');
  1076. $jscomp.polyfill('Number.MAX_SAFE_INTEGER', function() {
  1077. return 9007199254740991;
  1078. }, 'es6-impl', 'es3');
  1079. $jscomp.polyfill('Number.MIN_SAFE_INTEGER', function() {
  1080. return -9007199254740991;
  1081. }, 'es6-impl', 'es3');
  1082. $jscomp.polyfill('Number.isFinite', function(orig) {
  1083. if (orig) {
  1084. return orig;
  1085. }
  1086. var polyfill = function(x) {
  1087. if (typeof x !== 'number') {
  1088. return false;
  1089. }
  1090. return !isNaN(x) && x !== Infinity && x !== -Infinity;
  1091. };
  1092. return polyfill;
  1093. }, 'es6-impl', 'es3');
  1094. $jscomp.polyfill('Number.isInteger', function(orig) {
  1095. if (orig) {
  1096. return orig;
  1097. }
  1098. var polyfill = function(x) {
  1099. if (!Number.isFinite(x)) {
  1100. return false;
  1101. }
  1102. return x === Math.floor(x);
  1103. };
  1104. return polyfill;
  1105. }, 'es6-impl', 'es3');
  1106. $jscomp.polyfill('Number.isNaN', function(orig) {
  1107. if (orig) {
  1108. return orig;
  1109. }
  1110. var polyfill = function(x) {
  1111. return typeof x === 'number' && isNaN(x);
  1112. };
  1113. return polyfill;
  1114. }, 'es6-impl', 'es3');
  1115. $jscomp.polyfill('Number.isSafeInteger', function(orig) {
  1116. if (orig) {
  1117. return orig;
  1118. }
  1119. var polyfill = function(x) {
  1120. return Number.isInteger(x) && Math.abs(x) <= Number.MAX_SAFE_INTEGER;
  1121. };
  1122. return polyfill;
  1123. }, 'es6-impl', 'es3');
  1124. $jscomp.polyfill('Object.assign', function(orig) {
  1125. if (orig) {
  1126. return orig;
  1127. }
  1128. var polyfill = function(target, var_args) {
  1129. for (var i = 1; i < arguments.length; i++) {
  1130. var source = arguments[i];
  1131. if (!source) {
  1132. continue;
  1133. }
  1134. for (var key in source) {
  1135. if ($jscomp.owns(source, key)) {
  1136. target[key] = source[key];
  1137. }
  1138. }
  1139. }
  1140. return target;
  1141. };
  1142. return polyfill;
  1143. }, 'es6-impl', 'es3');
  1144. $jscomp.polyfill('Object.entries', function(orig) {
  1145. if (orig) {
  1146. return orig;
  1147. }
  1148. var entries = function(obj) {
  1149. var result = [];
  1150. for (var key in obj) {
  1151. if ($jscomp.owns(obj, key)) {
  1152. result.push([key, obj[key]]);
  1153. }
  1154. }
  1155. return result;
  1156. };
  1157. return entries;
  1158. }, 'es8', 'es3');
  1159. $jscomp.polyfill('Object.getOwnPropertySymbols', function(orig) {
  1160. if (orig) {
  1161. return orig;
  1162. }
  1163. return function() {
  1164. return [];
  1165. };
  1166. }, 'es6-impl', 'es5');
  1167. $jscomp.polyfill('Reflect.ownKeys', function(orig) {
  1168. if (orig) {
  1169. return orig;
  1170. }
  1171. var symbolPrefix = 'jscomp_symbol_';
  1172. function isSymbol(key) {
  1173. return key.substring(0, symbolPrefix.length) == symbolPrefix;
  1174. }
  1175. var polyfill = function(target) {
  1176. var keys = [];
  1177. var names = Object.getOwnPropertyNames(target);
  1178. var symbols = Object.getOwnPropertySymbols(target);
  1179. for (var i = 0; i < names.length; i++) {
  1180. (isSymbol(names[i]) ? symbols : keys).push(names[i]);
  1181. }
  1182. return keys.concat(symbols);
  1183. };
  1184. return polyfill;
  1185. }, 'es6', 'es5');
  1186. $jscomp.polyfill('Object.getOwnPropertyDescriptors', function(orig) {
  1187. if (orig) {
  1188. return orig;
  1189. }
  1190. var getOwnPropertyDescriptors = function(obj) {
  1191. var result = {};
  1192. var keys = Reflect.ownKeys(obj);
  1193. for (var i = 0; i < keys.length; i++) {
  1194. result[keys[i]] = Object.getOwnPropertyDescriptor(obj, keys[i]);
  1195. }
  1196. return result;
  1197. };
  1198. return getOwnPropertyDescriptors;
  1199. }, 'es8', 'es5');
  1200. $jscomp.polyfill('Object.setPrototypeOf', function(orig) {
  1201. if (orig) {
  1202. return orig;
  1203. }
  1204. if (typeof ''.__proto__ != 'object') {
  1205. return null;
  1206. }
  1207. var polyfill = function(target, proto) {
  1208. target.__proto__ = proto;
  1209. if (target.__proto__ !== proto) {
  1210. throw new TypeError(target + ' is not extensible');
  1211. }
  1212. return target;
  1213. };
  1214. return polyfill;
  1215. }, 'es6', 'es5');
  1216. $jscomp.polyfill('Object.values', function(orig) {
  1217. if (orig) {
  1218. return orig;
  1219. }
  1220. var values = function(obj) {
  1221. var result = [];
  1222. for (var key in obj) {
  1223. if ($jscomp.owns(obj, key)) {
  1224. result.push(obj[key]);
  1225. }
  1226. }
  1227. return result;
  1228. };
  1229. return values;
  1230. }, 'es8', 'es3');
  1231. $jscomp.polyfill('Reflect.apply', function(orig) {
  1232. if (orig) {
  1233. return orig;
  1234. }
  1235. var apply = Function.prototype.apply;
  1236. var polyfill = function(target, thisArg, argList) {
  1237. return apply.call(target, thisArg, argList);
  1238. };
  1239. return polyfill;
  1240. }, 'es6', 'es3');
  1241. $jscomp.polyfill('Reflect.construct', function(orig) {
  1242. if (orig) {
  1243. return orig;
  1244. }
  1245. var polyfill = function(target, argList, opt_newTarget) {
  1246. if (opt_newTarget === undefined) {
  1247. opt_newTarget = target;
  1248. }
  1249. var proto = opt_newTarget.prototype || Object.prototype;
  1250. var obj = Object.create(proto);
  1251. var out = Reflect.apply(target, obj, argList);
  1252. return out || obj;
  1253. };
  1254. return polyfill;
  1255. }, 'es6', 'es5');
  1256. $jscomp.polyfill('Reflect.defineProperty', function(orig) {
  1257. if (orig) {
  1258. return orig;
  1259. }
  1260. var polyfill = function(target, propertyKey, attributes) {
  1261. try {
  1262. Object.defineProperty(target, propertyKey, attributes);
  1263. var desc = Object.getOwnPropertyDescriptor(target, propertyKey);
  1264. if (!desc) {
  1265. return false;
  1266. }
  1267. return desc.configurable === (attributes.configurable || false) && desc.enumerable === (attributes.enumerable || false) && ('value' in desc ? desc.value === attributes.value && desc.writable === (attributes.writable || false) : desc.get === attributes.get && desc.set === attributes.set);
  1268. } catch (err) {
  1269. return false;
  1270. }
  1271. };
  1272. return polyfill;
  1273. }, 'es6', 'es5');
  1274. $jscomp.polyfill('Reflect.deleteProperty', function(orig) {
  1275. if (orig) {
  1276. return orig;
  1277. }
  1278. var polyfill = function(target, propertyKey) {
  1279. if (!$jscomp.owns(target, propertyKey)) {
  1280. return true;
  1281. }
  1282. try {
  1283. return delete target[propertyKey];
  1284. } catch (err) {
  1285. return false;
  1286. }
  1287. };
  1288. return polyfill;
  1289. }, 'es6', 'es3');
  1290. $jscomp.polyfill('Reflect.getOwnPropertyDescriptor', function(orig) {
  1291. return orig || Object.getOwnPropertyDescriptor;
  1292. }, 'es6', 'es5');
  1293. $jscomp.polyfill('Reflect.getPrototypeOf', function(orig) {
  1294. return orig || Object.getPrototypeOf;
  1295. }, 'es6', 'es5');
  1296. $jscomp.findDescriptor = function(target, propertyKey) {
  1297. var obj = target;
  1298. while (obj) {
  1299. var property = Reflect.getOwnPropertyDescriptor(obj, propertyKey);
  1300. if (property) {
  1301. return property;
  1302. }
  1303. obj = Reflect.getPrototypeOf(obj);
  1304. }
  1305. return undefined;
  1306. };
  1307. $jscomp.polyfill('Reflect.get', function(orig) {
  1308. if (orig) {
  1309. return orig;
  1310. }
  1311. var polyfill = function(target, propertyKey, opt_receiver) {
  1312. if (arguments.length <= 2) {
  1313. return target[propertyKey];
  1314. }
  1315. var property = $jscomp.findDescriptor(target, propertyKey);
  1316. if (property) {
  1317. return property.get ? property.get.call(opt_receiver) : property.value;
  1318. }
  1319. return undefined;
  1320. };
  1321. return polyfill;
  1322. }, 'es6', 'es5');
  1323. $jscomp.polyfill('Reflect.has', function(orig) {
  1324. if (orig) {
  1325. return orig;
  1326. }
  1327. var polyfill = function(target, propertyKey) {
  1328. return propertyKey in target;
  1329. };
  1330. return polyfill;
  1331. }, 'es6', 'es3');
  1332. $jscomp.polyfill('Reflect.isExtensible', function(orig) {
  1333. if (orig) {
  1334. return orig;
  1335. }
  1336. if (typeof Object.isExtensible == 'function') {
  1337. return Object.isExtensible;
  1338. }
  1339. return function() {
  1340. return true;
  1341. };
  1342. }, 'es6', 'es3');
  1343. $jscomp.polyfill('Reflect.preventExtensions', function(orig) {
  1344. if (orig) {
  1345. return orig;
  1346. }
  1347. if (typeof Object.preventExtensions != 'function') {
  1348. return function() {
  1349. return false;
  1350. };
  1351. }
  1352. var polyfill = function(target) {
  1353. Object.preventExtensions(target);
  1354. return !Object.isExtensible(target);
  1355. };
  1356. return polyfill;
  1357. }, 'es6', 'es3');
  1358. $jscomp.polyfill('Reflect.set', function(orig) {
  1359. if (orig) {
  1360. return orig;
  1361. }
  1362. var polyfill = function(target, propertyKey, value, opt_receiver) {
  1363. var property = $jscomp.findDescriptor(target, propertyKey);
  1364. if (!property) {
  1365. if (Reflect.isExtensible(target)) {
  1366. target[propertyKey] = value;
  1367. return true;
  1368. }
  1369. return false;
  1370. }
  1371. if (property.set) {
  1372. property.set.call(arguments.length > 3 ? opt_receiver : target, value);
  1373. return true;
  1374. } else {
  1375. if (property.writable && !Object.isFrozen(target)) {
  1376. target[propertyKey] = value;
  1377. return true;
  1378. }
  1379. }
  1380. return false;
  1381. };
  1382. return polyfill;
  1383. }, 'es6', 'es5');
  1384. $jscomp.polyfill('Reflect.setPrototypeOf', function(orig) {
  1385. if (orig) {
  1386. return orig;
  1387. }
  1388. if (typeof ''.__proto__ != 'object') {
  1389. return null;
  1390. }
  1391. var polyfill = function(target, proto) {
  1392. try {
  1393. target.__proto__ = proto;
  1394. return target.__proto__ === proto;
  1395. } catch (err) {
  1396. return false;
  1397. }
  1398. };
  1399. return polyfill;
  1400. }, 'es6', 'es5');
  1401. $jscomp.ASSUME_NO_NATIVE_SET = false;
  1402. $jscomp.polyfill('Set', function(NativeSet) {
  1403. var isConformant = !$jscomp.ASSUME_NO_NATIVE_SET && function() {
  1404. if (!NativeSet || !NativeSet.prototype.entries || typeof Object.seal != 'function') {
  1405. return false;
  1406. }
  1407. try {
  1408. NativeSet = (NativeSet);
  1409. var value = Object.seal({x:4});
  1410. var set = new NativeSet($jscomp.makeIterator([value]));
  1411. if (!set.has(value) || set.size != 1 || set.add(value) != set || set.size != 1 || set.add({x:4}) != set || set.size != 2) {
  1412. return false;
  1413. }
  1414. var iter = set.entries();
  1415. var item = iter.next();
  1416. if (item.done || item.value[0] != value || item.value[1] != value) {
  1417. return false;
  1418. }
  1419. item = iter.next();
  1420. if (item.done || item.value[0] == value || item.value[0].x != 4 || item.value[1] != item.value[0]) {
  1421. return false;
  1422. }
  1423. return iter.next().done;
  1424. } catch (err) {
  1425. return false;
  1426. }
  1427. }();
  1428. if (isConformant) {
  1429. return NativeSet;
  1430. }
  1431. $jscomp.initSymbol();
  1432. $jscomp.initSymbolIterator();
  1433. var PolyfillSet = function(opt_iterable) {
  1434. this.map_ = new Map;
  1435. if (opt_iterable) {
  1436. var iter = $jscomp.makeIterator(opt_iterable);
  1437. var entry;
  1438. while (!(entry = iter.next()).done) {
  1439. var item = (entry).value;
  1440. this.add(item);
  1441. }
  1442. }
  1443. this.size = this.map_.size;
  1444. };
  1445. PolyfillSet.prototype.add = function(value) {
  1446. this.map_.set(value, value);
  1447. this.size = this.map_.size;
  1448. return this;
  1449. };
  1450. PolyfillSet.prototype['delete'] = function(value) {
  1451. var result = this.map_['delete'](value);
  1452. this.size = this.map_.size;
  1453. return result;
  1454. };
  1455. PolyfillSet.prototype.clear = function() {
  1456. this.map_.clear();
  1457. this.size = 0;
  1458. };
  1459. PolyfillSet.prototype.has = function(value) {
  1460. return this.map_.has(value);
  1461. };
  1462. PolyfillSet.prototype.entries = function() {
  1463. return this.map_.entries();
  1464. };
  1465. PolyfillSet.prototype.values = function() {
  1466. return this.map_.values();
  1467. };
  1468. PolyfillSet.prototype.keys = PolyfillSet.prototype.values;
  1469. (PolyfillSet.prototype)[Symbol.iterator] = PolyfillSet.prototype.values;
  1470. PolyfillSet.prototype.forEach = function(callback, opt_thisArg) {
  1471. var set = this;
  1472. this.map_.forEach(function(value) {
  1473. return callback.call((opt_thisArg), value, value, set);
  1474. });
  1475. };
  1476. return PolyfillSet;
  1477. }, 'es6-impl', 'es3');
  1478. $jscomp.checkStringArgs = function(thisArg, arg, func) {
  1479. if (thisArg == null) {
  1480. throw new TypeError("The 'this' value for String.prototype." + func + ' must not be null or undefined');
  1481. }
  1482. if (arg instanceof RegExp) {
  1483. throw new TypeError('First argument to String.prototype.' + func + ' must not be a regular expression');
  1484. }
  1485. return thisArg + '';
  1486. };
  1487. $jscomp.polyfill('String.prototype.codePointAt', function(orig) {
  1488. if (orig) {
  1489. return orig;
  1490. }
  1491. var polyfill = function(position) {
  1492. var string = $jscomp.checkStringArgs(this, null, 'codePointAt');
  1493. var size = string.length;
  1494. position = Number(position) || 0;
  1495. if (!(position >= 0 && position < size)) {
  1496. return void 0;
  1497. }
  1498. position = position | 0;
  1499. var first = string.charCodeAt(position);
  1500. if (first < 55296 || first > 56319 || position + 1 === size) {
  1501. return first;
  1502. }
  1503. var second = string.charCodeAt(position + 1);
  1504. if (second < 56320 || second > 57343) {
  1505. return first;
  1506. }
  1507. return (first - 55296) * 1024 + second + 9216;
  1508. };
  1509. return polyfill;
  1510. }, 'es6-impl', 'es3');
  1511. $jscomp.polyfill('String.prototype.endsWith', function(orig) {
  1512. if (orig) {
  1513. return orig;
  1514. }
  1515. var polyfill = function(searchString, opt_position) {
  1516. var string = $jscomp.checkStringArgs(this, searchString, 'endsWith');
  1517. searchString = searchString + '';
  1518. if (opt_position === void 0) {
  1519. opt_position = string.length;
  1520. }
  1521. var i = Math.max(0, Math.min(opt_position | 0, string.length));
  1522. var j = searchString.length;
  1523. while (j > 0 && i > 0) {
  1524. if (string[--i] != searchString[--j]) {
  1525. return false;
  1526. }
  1527. }
  1528. return j <= 0;
  1529. };
  1530. return polyfill;
  1531. }, 'es6-impl', 'es3');
  1532. $jscomp.polyfill('String.fromCodePoint', function(orig) {
  1533. if (orig) {
  1534. return orig;
  1535. }
  1536. var polyfill = function(var_args) {
  1537. var result = '';
  1538. for (var i = 0; i < arguments.length; i++) {
  1539. var code = Number(arguments[i]);
  1540. if (code < 0 || code > 1114111 || code !== Math.floor(code)) {
  1541. throw new RangeError('invalid_code_point ' + code);
  1542. }
  1543. if (code <= 65535) {
  1544. result += String.fromCharCode(code);
  1545. } else {
  1546. code -= 65536;
  1547. result += String.fromCharCode(code >>> 10 & 1023 | 55296);
  1548. result += String.fromCharCode(code & 1023 | 56320);
  1549. }
  1550. }
  1551. return result;
  1552. };
  1553. return polyfill;
  1554. }, 'es6-impl', 'es3');
  1555. $jscomp.polyfill('String.prototype.includes', function(orig) {
  1556. if (orig) {
  1557. return orig;
  1558. }
  1559. var polyfill = function(searchString, opt_position) {
  1560. var string = $jscomp.checkStringArgs(this, searchString, 'includes');
  1561. return string.indexOf(searchString, opt_position || 0) !== -1;
  1562. };
  1563. return polyfill;
  1564. }, 'es6-impl', 'es3');
  1565. $jscomp.polyfill('String.prototype.repeat', function(orig) {
  1566. if (orig) {
  1567. return orig;
  1568. }
  1569. var polyfill = function(copies) {
  1570. var string = $jscomp.checkStringArgs(this, null, 'repeat');
  1571. if (copies < 0 || copies > 1342177279) {
  1572. throw new RangeError('Invalid count value');
  1573. }
  1574. copies = copies | 0;
  1575. var result = '';
  1576. while (copies) {
  1577. if (copies & 1) {
  1578. result += string;
  1579. }
  1580. if (copies >>>= 1) {
  1581. string += string;
  1582. }
  1583. }
  1584. return result;
  1585. };
  1586. return polyfill;
  1587. }, 'es6-impl', 'es3');
  1588. $jscomp.stringPadding = function(padString, padLength) {
  1589. var padding = padString !== undefined ? String(padString) : ' ';
  1590. if (!(padLength > 0) || !padding) {
  1591. return '';
  1592. }
  1593. var repeats = Math.ceil(padLength / padding.length);
  1594. return padding.repeat(repeats).substring(0, padLength);
  1595. };
  1596. $jscomp.polyfill('String.prototype.padEnd', function(orig) {
  1597. if (orig) {
  1598. return orig;
  1599. }
  1600. var padEnd = function(targetLength, opt_padString) {
  1601. var string = $jscomp.checkStringArgs(this, null, 'padStart');
  1602. var padLength = targetLength - string.length;
  1603. return string + $jscomp.stringPadding(opt_padString, padLength);
  1604. };
  1605. return padEnd;
  1606. }, 'es8', 'es3');
  1607. $jscomp.polyfill('String.prototype.padStart', function(orig) {
  1608. if (orig) {
  1609. return orig;
  1610. }
  1611. var padStart = function(targetLength, opt_padString) {
  1612. var string = $jscomp.checkStringArgs(this, null, 'padStart');
  1613. var padLength = targetLength - string.length;
  1614. return $jscomp.stringPadding(opt_padString, padLength) + string;
  1615. };
  1616. return padStart;
  1617. }, 'es8', 'es3');
  1618. $jscomp.polyfill('String.prototype.startsWith', function(orig) {
  1619. if (orig) {
  1620. return orig;
  1621. }
  1622. var polyfill = function(searchString, opt_position) {
  1623. var string = $jscomp.checkStringArgs(this, searchString, 'startsWith');
  1624. searchString = searchString + '';
  1625. var strLen = string.length;
  1626. var searchLen = searchString.length;
  1627. var i = Math.max(0, Math.min((opt_position) | 0, string.length));
  1628. var j = 0;
  1629. while (j < searchLen && i < strLen) {
  1630. if (string[i++] != searchString[j++]) {
  1631. return false;
  1632. }
  1633. }
  1634. return j >= searchLen;
  1635. };
  1636. return polyfill;
  1637. }, 'es6-impl', 'es3');
  1638. $jscomp.arrayFromIterator = function(iterator) {
  1639. var i;
  1640. var arr = [];
  1641. while (!(i = iterator.next()).done) {
  1642. arr.push(i.value);
  1643. }
  1644. return arr;
  1645. };
  1646. $jscomp.arrayFromIterable = function(iterable) {
  1647. if (iterable instanceof Array) {
  1648. return iterable;
  1649. } else {
  1650. return $jscomp.arrayFromIterator($jscomp.makeIterator(iterable));
  1651. }
  1652. };
  1653. $jscomp.inherits = function(childCtor, parentCtor) {
  1654. function tempCtor() {
  1655. }
  1656. tempCtor.prototype = parentCtor.prototype;
  1657. childCtor.superClass_ = parentCtor.prototype;
  1658. childCtor.prototype = new tempCtor;
  1659. childCtor.prototype.constructor = childCtor;
  1660. for (var p in parentCtor) {
  1661. if (Object.defineProperties) {
  1662. var descriptor = Object.getOwnPropertyDescriptor(parentCtor, p);
  1663. if (descriptor) {
  1664. Object.defineProperty(childCtor, p, descriptor);
  1665. }
  1666. } else {
  1667. childCtor[p] = parentCtor[p];
  1668. }
  1669. }
  1670. };
  1671. $jscomp.polyfill('WeakSet', function(NativeWeakSet) {
  1672. function isConformant() {
  1673. if (!NativeWeakSet || !Object.seal) {
  1674. return false;
  1675. }
  1676. try {
  1677. var x = Object.seal({});
  1678. var y = Object.seal({});
  1679. var set = new (NativeWeakSet)([x]);
  1680. if (!set.has(x) || set.has(y)) {
  1681. return false;
  1682. }
  1683. set['delete'](x);
  1684. set.add(y);
  1685. return !set.has(x) && set.has(y);
  1686. } catch (err) {
  1687. return false;
  1688. }
  1689. }
  1690. if (isConformant()) {
  1691. return NativeWeakSet;
  1692. }
  1693. var PolyfillWeakSet = function(opt_iterable) {
  1694. this.map_ = new WeakMap;
  1695. if (opt_iterable) {
  1696. $jscomp.initSymbol();
  1697. $jscomp.initSymbolIterator();
  1698. var iter = $jscomp.makeIterator(opt_iterable);
  1699. var entry;
  1700. while (!(entry = iter.next()).done) {
  1701. var item = entry.value;
  1702. this.add(item);
  1703. }
  1704. }
  1705. };
  1706. PolyfillWeakSet.prototype.add = function(elem) {
  1707. this.map_.set(elem, true);
  1708. return this;
  1709. };
  1710. PolyfillWeakSet.prototype.has = function(elem) {
  1711. return this.map_.has(elem);
  1712. };
  1713. PolyfillWeakSet.prototype['delete'] = function(elem) {
  1714. return this.map_['delete'](elem);
  1715. };
  1716. return PolyfillWeakSet;
  1717. }, 'es6-impl', 'es3');
  1718. try {
  1719. if (Array.prototype.values.toString().indexOf('[native code]') == -1) {
  1720. delete Array.prototype.values;
  1721. }
  1722. } catch (e) {
  1723. }
  1724. Ext.define('Ext.overrides.exporter.util.Format', {override:'Ext.util.Format', decToHex:function(dec, bytes) {
  1725. var hex = '', i;
  1726. for (i = 0; i < bytes; i++) {
  1727. hex += String.fromCharCode(dec & 255);
  1728. dec = dec >>> 8;
  1729. }
  1730. return hex;
  1731. }});
  1732. Ext.define('Ext.exporter.data.Base', {requires:['Ext.util.Collection'], config:{idPrefix:'id', id:null, autoGenerateId:true, autoGenerateKey:{$value:false, merge:function(newValue, oldValue) {
  1733. return newValue ? Ext.concat(newValue, oldValue || null) : false;
  1734. }}}, internalCols:null, clearPropertiesOnDestroy:false, constructor:function(config) {
  1735. var me = this;
  1736. me.internalCols = [];
  1737. me.initConfig(config);
  1738. if (!me._id) {
  1739. me.setId(null);
  1740. }
  1741. return me.callParent([config]);
  1742. }, destroy:function() {
  1743. this.destroyCollections();
  1744. this.callParent();
  1745. this.internalCols = null;
  1746. }, destroyCollections:function() {
  1747. var cols = this.internalCols, len = cols.length, i, j, length, col;
  1748. for (i = 0; i < len; i++) {
  1749. col = cols[i];
  1750. length = col.length;
  1751. for (j = 0; j < length; j++) {
  1752. col.items[j].destroy();
  1753. }
  1754. col.destroy();
  1755. }
  1756. cols.length = 0;
  1757. }, clearCollections:function(cols) {
  1758. var i, len, col;
  1759. cols = cols ? Ext.Array.from(cols) : this.internalCols;
  1760. len = cols.length;
  1761. for (i = len - 1; i >= 0; i--) {
  1762. col = cols[i];
  1763. if (col) {
  1764. col.destroy();
  1765. }
  1766. Ext.Array.remove(this.internalCols, col);
  1767. }
  1768. }, applyId:function(data) {
  1769. var id;
  1770. if (!data && this._autoGenerateId) {
  1771. id = this._idPrefix + ++Ext.idSeed;
  1772. } else {
  1773. id = data;
  1774. }
  1775. return id;
  1776. }, checkCollection:function(data, dataCollection, className) {
  1777. var col;
  1778. if (data) {
  1779. col = this.constructCollection(className);
  1780. col.add(data);
  1781. }
  1782. if (dataCollection) {
  1783. Ext.Array.remove(this.internalCols, dataCollection);
  1784. Ext.destroy(dataCollection.items, dataCollection);
  1785. }
  1786. return col;
  1787. }, constructCollection:function(className) {
  1788. var cls = Ext.ClassManager.get(className), cfg = {decoder:this.getCollectionDecoder(cls)}, col;
  1789. if (typeof cls.prototype.getKey === 'function') {
  1790. cfg.keyFn = this.getCollectionItemKey;
  1791. }
  1792. col = new Ext.util.Collection(cfg);
  1793. this.internalCols.push(col);
  1794. return col;
  1795. }, getCollectionDecoder:function(klass) {
  1796. return function(config) {
  1797. return config && config.isInstance ? config : new klass(config || {});
  1798. };
  1799. }, getCollectionItemKey:function(item) {
  1800. return item.getKey ? item.getKey() : item._id || item.getId();
  1801. }, getKey:function() {
  1802. var generate = this.getAutoGenerateKey(), key = '', config = this.getConfig(), len, i;
  1803. if (!Ext.isArray(generate) || !generate.length) {
  1804. return this.getId();
  1805. }
  1806. len = generate.length;
  1807. for (i = 0; i < len; i++) {
  1808. key += this.serializeKeyValue(config[generate[i]]);
  1809. }
  1810. return key;
  1811. }, serializeKeyValue:function(value) {
  1812. var key = '', keys, len, i;
  1813. if (value === null) {
  1814. key = '_';
  1815. } else {
  1816. if (Ext.isDate(value)) {
  1817. key = value.getTime();
  1818. } else {
  1819. if (Ext.isArray(value)) {
  1820. len = value.length;
  1821. for (i = 0; i < len; i++) {
  1822. key += this.serializeKeyValue(value[i]);
  1823. }
  1824. } else {
  1825. if (typeof value === 'object') {
  1826. if (value.isInstance) {
  1827. key = value.getKey ? value.getKey() : '_';
  1828. } else {
  1829. keys = Ext.Object.getAllKeys(value);
  1830. keys = Ext.Array.sort(keys);
  1831. len = keys.length;
  1832. for (i = 0; i < len; i++) {
  1833. key += this.serializeKeyValue(value[keys[i]]);
  1834. }
  1835. }
  1836. } else {
  1837. key = value;
  1838. }
  1839. }
  1840. }
  1841. }
  1842. return key;
  1843. }});
  1844. Ext.define('Ext.exporter.data.Cell', {extend:'Ext.exporter.data.Base', config:{style:null, value:null}});
  1845. Ext.define('Ext.exporter.data.Row', {extend:'Ext.exporter.data.Base', requires:['Ext.exporter.data.Cell'], config:{cells:null}, destroy:function() {
  1846. this.clearCollections();
  1847. }, applyCells:function(data, dataCollection) {
  1848. return this.checkCollection(data, dataCollection, 'Ext.exporter.data.Cell');
  1849. }, addCell:function(config) {
  1850. if (!this._cells) {
  1851. this.setCells([]);
  1852. }
  1853. return this._cells.add(config || {});
  1854. }, getCell:function(id) {
  1855. return this._cells ? this._cells.get(id) : null;
  1856. }});
  1857. Ext.define('Ext.exporter.data.Group', {extend:'Ext.exporter.data.Base', requires:['Ext.exporter.data.Row'], config:{text:null, rows:null, summaries:null, summary:null, groups:null}, applyRows:function(data, dataCollection) {
  1858. return this.checkCollection(data, dataCollection, 'Ext.exporter.data.Row');
  1859. }, addRow:function(config) {
  1860. if (!this._rows) {
  1861. this.setRows([]);
  1862. }
  1863. return this._rows.add(config || {});
  1864. }, getRow:function(id) {
  1865. return this._rows ? this._rows.get(id) : null;
  1866. }, applyGroups:function(data, dataCollection) {
  1867. return this.checkCollection(data, dataCollection, 'Ext.exporter.data.Group');
  1868. }, addGroup:function(config) {
  1869. if (!this._groups) {
  1870. this.setGroups([]);
  1871. }
  1872. return this._groups.add(config || {});
  1873. }, getGroup:function(id) {
  1874. return this._groups ? this._groups.get(id) : null;
  1875. }, applySummaries:function(data, dataCollection) {
  1876. return this.checkCollection(data, dataCollection, 'Ext.exporter.data.Row');
  1877. }, applySummary:function(value) {
  1878. if (value) {
  1879. this.addSummary(value);
  1880. }
  1881. return null;
  1882. }, addSummary:function(config) {
  1883. if (!this._summaries) {
  1884. this.setSummaries([]);
  1885. }
  1886. return this._summaries.add(config || {});
  1887. }, getSummary:function(id) {
  1888. return this._summaries ? this._summaries.get(id) : null;
  1889. }});
  1890. Ext.define('Ext.exporter.data.Column', {extend:'Ext.exporter.data.Base', config:{table:null, text:null, style:null, width:null, mergeAcross:null, mergeDown:null, level:0, index:null, columns:null}, destroy:function() {
  1891. this.setTable(null);
  1892. this.callParent();
  1893. }, updateTable:function(table) {
  1894. var cols = this.getColumns(), i, length;
  1895. if (cols) {
  1896. length = cols.length;
  1897. for (i = 0; i < length; i++) {
  1898. cols.getAt(i).setTable(table);
  1899. }
  1900. }
  1901. }, applyColumns:function(data, dataCollection) {
  1902. return this.checkCollection(data, dataCollection, 'Ext.exporter.data.Column');
  1903. }, updateColumns:function(collection, oldCollection) {
  1904. var me = this;
  1905. if (oldCollection) {
  1906. oldCollection.un({add:me.onColumnAdd, remove:me.onColumnRemove, scope:me});
  1907. Ext.destroy(oldCollection.items, oldCollection);
  1908. }
  1909. if (collection) {
  1910. collection.on({add:me.onColumnAdd, remove:me.onColumnRemove, scope:me});
  1911. me.onColumnAdd(collection, {items:collection.getRange()});
  1912. }
  1913. }, sync:function(level, depth) {
  1914. var me = this, count = me.getColumnCount() - 1, cols = me.getColumns(), i, length, down;
  1915. me.setLevel(level);
  1916. if (cols) {
  1917. length = cols.length;
  1918. for (i = 0; i < length; i++) {
  1919. cols.items[i].sync(level + 1, depth);
  1920. }
  1921. me.setMergeDown(null);
  1922. } else {
  1923. down = depth - level;
  1924. me.setMergeDown(down > 0 ? down : null);
  1925. }
  1926. me.setMergeAcross(count > 0 ? count : null);
  1927. }, onColumnAdd:function(collection, details) {
  1928. var items = details.items, length = items.length, table = this.getTable(), i, item;
  1929. for (i = 0; i < length; i++) {
  1930. item = items[i];
  1931. item.setTable(table);
  1932. }
  1933. if (table) {
  1934. table.syncColumns();
  1935. }
  1936. }, onColumnRemove:function(collection, details) {
  1937. var table = this.getTable();
  1938. Ext.destroy(details.items);
  1939. if (table) {
  1940. table.syncColumns();
  1941. }
  1942. }, getColumnCount:function(columns) {
  1943. var s = 0, cols;
  1944. if (!columns) {
  1945. columns = this.getColumns();
  1946. if (!columns) {
  1947. return 1;
  1948. }
  1949. }
  1950. for (var i = 0; i < columns.length; i++) {
  1951. cols = columns.getAt(i).getColumns();
  1952. if (!cols) {
  1953. s += 1;
  1954. } else {
  1955. s += this.getColumnCount(cols);
  1956. }
  1957. }
  1958. return s;
  1959. }, addColumn:function(config) {
  1960. if (!this.getColumns()) {
  1961. this.setColumns([]);
  1962. }
  1963. return this.getColumns().add(config || {});
  1964. }, getColumn:function(id) {
  1965. return this.getColumns().get(id);
  1966. }});
  1967. Ext.define('Ext.exporter.data.Table', {extend:'Ext.exporter.data.Group', requires:['Ext.exporter.data.Column'], isDataTable:true, config:{columns:null}, autoGenerateId:false, applyColumns:function(data, dataCollection) {
  1968. return this.checkCollection(data, dataCollection, 'Ext.exporter.data.Column');
  1969. }, updateColumns:function(collection, oldCollection) {
  1970. var me = this;
  1971. if (oldCollection) {
  1972. oldCollection.un({add:me.onColumnAdd, remove:me.onColumnRemove, scope:me});
  1973. Ext.destroy(oldCollection.items, oldCollection);
  1974. }
  1975. if (collection) {
  1976. collection.on({add:me.onColumnAdd, remove:me.onColumnRemove, scope:me});
  1977. me.onColumnAdd(collection, {items:collection.getRange()});
  1978. me.syncColumns();
  1979. }
  1980. }, syncColumns:function() {
  1981. var cols = this.getColumns(), depth = this.getColDepth(cols, -1), result = {}, i, j, length, len, keys, arr, prevCol, index;
  1982. if (!cols) {
  1983. return;
  1984. }
  1985. length = cols.length;
  1986. for (i = 0; i < length; i++) {
  1987. cols.items[i].sync(0, depth);
  1988. }
  1989. this.getColumnLevels(cols, depth, result);
  1990. keys = Ext.Object.getKeys(result);
  1991. length = keys.length;
  1992. for (i = 0; i < length; i++) {
  1993. arr = result[keys[i]];
  1994. len = arr.length;
  1995. for (j = 0; j < len; j++) {
  1996. if (j === 0) {
  1997. index = 1;
  1998. } else {
  1999. if (arr[j - 1]) {
  2000. prevCol = arr[j - 1].getConfig();
  2001. index += prevCol.mergeAcross ? prevCol.mergeAcross + 1 : 1;
  2002. } else {
  2003. index++;
  2004. }
  2005. }
  2006. if (arr[j]) {
  2007. arr[j].setIndex(index);
  2008. }
  2009. }
  2010. }
  2011. }, getLeveledColumns:function() {
  2012. var cols = this.getColumns(), depth = this.getColDepth(cols, -1), result = {};
  2013. this.getColumnLevels(cols, depth, result, true);
  2014. return result;
  2015. }, getBottomColumns:function() {
  2016. var result = this.getLeveledColumns(), keys, len;
  2017. keys = Ext.Object.getKeys(result);
  2018. len = keys.length;
  2019. return len ? result[keys[keys.length - 1]] : [];
  2020. }, getColumnLevels:function(columns, depth, result, topDown) {
  2021. var col, i, j, len, name, level, cols;
  2022. if (!columns) {
  2023. return;
  2024. }
  2025. len = columns.length;
  2026. for (i = 0; i < len; i++) {
  2027. col = columns.items[i];
  2028. level = col.getLevel();
  2029. cols = col.getColumns();
  2030. name = 's' + level;
  2031. result[name] = result[name] || [];
  2032. result[name].push(col);
  2033. if (!cols) {
  2034. for (j = level + 1; j <= depth; j++) {
  2035. name = 's' + j;
  2036. result[name] = result[name] || [];
  2037. result[name].push(topDown ? col : null);
  2038. }
  2039. } else {
  2040. this.getColumnLevels(cols, depth, result, topDown);
  2041. }
  2042. }
  2043. }, onColumnAdd:function(collection, details) {
  2044. var items = details.items, length = items.length, i, item;
  2045. for (i = 0; i < length; i++) {
  2046. item = items[i];
  2047. item.setTable(this);
  2048. }
  2049. this.syncColumns();
  2050. }, onColumnRemove:function(collection, details) {
  2051. Ext.destroy(details.items);
  2052. this.syncColumns();
  2053. }, getColumnCount:function() {
  2054. var cols = this._columns, s = 0, i, length;
  2055. if (cols) {
  2056. length = cols.length;
  2057. for (i = 0; i < length; i++) {
  2058. s += cols.items[i].getColumnCount();
  2059. }
  2060. }
  2061. return s;
  2062. }, getColDepth:function(columns, level) {
  2063. var m = 0, len;
  2064. if (!columns) {
  2065. return level;
  2066. }
  2067. len = columns.length;
  2068. for (var i = 0; i < len; i++) {
  2069. m = Math.max(m, this.getColDepth(columns.items[i]._columns, level + 1));
  2070. }
  2071. return m;
  2072. }, addColumn:function(config) {
  2073. if (!this._columns) {
  2074. this.setColumns([]);
  2075. }
  2076. return this._columns.add(config || {});
  2077. }, getColumn:function(id) {
  2078. return this._columns ? this._columns.get(id) : null;
  2079. }});
  2080. Ext.define('Ext.exporter.file.Base', {extend:'Ext.exporter.data.Base', requires:['Ext.XTemplate'], tpl:null, destroy:function() {
  2081. this.tpl = null;
  2082. this.callParent();
  2083. }, render:function() {
  2084. var me = this, data = me.processRenderData(me.getRenderData());
  2085. return me.tpl ? Ext.XTemplate.getTpl(me, 'tpl').apply(data) : '';
  2086. }, processRenderData:function(data) {
  2087. return data;
  2088. }, getRenderData:function() {
  2089. var data = this.getConfig();
  2090. data.self = this;
  2091. return data;
  2092. }});
  2093. Ext.define('Ext.exporter.file.Style', {extend:'Ext.exporter.file.Base', config:{name:null, alignment:null, font:null, interior:null, format:null, borders:null, checks:{alignment:{horizontal:['Automatic', 'Left', 'Center', 'Right', 'Justify'], readingOrder:['LeftToRight', 'RightToLeft', 'Context'], vertical:['Automatic', 'Top', 'Bottom', 'Center']}, font:{bold:[true, false], italic:[true, false], strikeThrough:[true, false], underline:['None', 'Single']}, border:{position:['Left', 'Top', 'Right',
  2094. 'Bottom'], lineStyle:['None', 'Continuous', 'Dash', 'Dot']}, interior:{pattern:['None', 'Solid']}}}, datePatterns:{'General Date':'Y-m-d H:i:s', 'Long Date':'l, F d, Y', 'Medium Date':'Y-m-d', 'Short Date':'n/j/Y', 'Long Time':'g:i:s A', 'Medium Time':'H:i:s', 'Short Time':'g:i A'}, numberPatterns:{'General Number':'0', 'Fixed':'0.00', 'Standard':'0.00'}, booleanPatterns:{'Yes/No':['Yes', 'No'], 'True/False':['True', 'False'], 'On/Off':['On', 'Off']}, isStyle:true, autoGenerateKey:['alignment', 'font',
  2095. 'interior', 'format', 'borders'], constructor:function(config) {
  2096. this.callParent([this.uncapitalizeKeys(config)]);
  2097. }, uncapitalizeKeys:function(config) {
  2098. var ret = config, keys, len, i, key, v;
  2099. if (Ext.isObject(config)) {
  2100. ret = {};
  2101. keys = Ext.Object.getAllKeys(config);
  2102. len = keys.length;
  2103. for (i = 0; i < len; i++) {
  2104. key = keys[i];
  2105. ret[Ext.String.uncapitalize(key)] = this.uncapitalizeKeys(config[key]);
  2106. }
  2107. } else {
  2108. if (Ext.isArray(config)) {
  2109. ret = [];
  2110. len = config.length;
  2111. for (i = 0; i < len; i++) {
  2112. ret.push(this.uncapitalizeKeys(config[i]));
  2113. }
  2114. }
  2115. }
  2116. return ret;
  2117. }, destroy:function() {
  2118. var me = this;
  2119. me.setAlignment(null);
  2120. me.setFont(null);
  2121. me.setInterior(null);
  2122. me.setBorders(null);
  2123. me.setChecks(null);
  2124. me.callParent();
  2125. }, updateAlignment:function(data) {
  2126. this.checkAttribute(data, 'alignment');
  2127. }, updateFont:function(data) {
  2128. this.checkAttribute(data, 'font');
  2129. }, updateInterior:function(data) {
  2130. this.checkAttribute(data, 'interior');
  2131. }, applyBorders:function(borders, oldBolders) {
  2132. if (!borders) {
  2133. return borders;
  2134. }
  2135. borders = Ext.Array.from(borders);
  2136. if (Ext.Array.unique(Ext.Array.pluck(borders, 'position')).length != borders.length) {
  2137. Ext.raise('Invalid border positions supplied');
  2138. }
  2139. return borders;
  2140. }, updateBorders:function(data) {
  2141. this.checkAttribute(data, 'border');
  2142. }, checkAttribute:function(data, checkName) {
  2143. var checks = this.getChecks(), values, keys, len, i, j, arr, key, obj, lenV, valid;
  2144. if (!data || !checks || !checks[checkName]) {
  2145. return;
  2146. }
  2147. values = Ext.Array.from(data);
  2148. lenV = values.length;
  2149. for (i = 0; i < lenV; i++) {
  2150. obj = values[i];
  2151. keys = Ext.Object.getKeys(obj || {});
  2152. len = keys.length;
  2153. for (j = 0; j < len; j++) {
  2154. key = keys[j];
  2155. if (arr = checks[checkName][key] && obj[key]) {
  2156. valid = Ext.isArray(arr) ? Ext.Array.indexOf(arr, obj[key]) : arr === obj[key];
  2157. if (!valid) {
  2158. delete obj[key];
  2159. Ext.raise(Ext.String.format('Invalid key (%0) or value (%1) provided for Style!', key, obj[key]));
  2160. }
  2161. }
  2162. }
  2163. }
  2164. }, getFormattedValue:function(v) {
  2165. var me = this, f = me.getFormat(), ret = v, fmt = Ext.util.Format;
  2166. if (!f || f === 'General' || Ext.isEmpty(v)) {
  2167. return ret;
  2168. }
  2169. if (f === 'Currency') {
  2170. return fmt.currency(v);
  2171. } else {
  2172. if (f === 'Euro Currency') {
  2173. return fmt.currency(v, '€');
  2174. } else {
  2175. if (f === 'Percent') {
  2176. return fmt.number(v * 100, '0.00') + '%';
  2177. } else {
  2178. if (f === 'Scientific') {
  2179. return Number(v).toExponential();
  2180. } else {
  2181. if (me.datePatterns[f]) {
  2182. return fmt.date(v, me.datePatterns[f]);
  2183. } else {
  2184. if (me.numberPatterns[f]) {
  2185. return fmt.number(v, me.numberPatterns[f]);
  2186. } else {
  2187. if (me.booleanPatterns[f]) {
  2188. return v ? me.booleanPatterns[f][0] : me.booleanPatterns[f][1];
  2189. } else {
  2190. if (Ext.isFunction(f)) {
  2191. return f(v);
  2192. }
  2193. }
  2194. }
  2195. }
  2196. }
  2197. }
  2198. }
  2199. }
  2200. return fmt.number(v, f);
  2201. }});
  2202. Ext.define('Ext.exporter.File', {singleton:true, requires:['Ext.promise.Promise', 'Ext.Deferred'], textPopupWait:'You may close this window after the file is downloaded!', textPopupBlocker:'The file was not saved because pop-up blocker might be enabled! Please check your browser settings.', url:'https://exporter.sencha.com', forceDownload:false, requiresPopup:function() {
  2203. var pt = Ext.platformTags;
  2204. return this.forceDownload || Ext.isSafari || pt.phone || pt.tablet;
  2205. }, initializePopup:function(binary) {
  2206. var me = this, required = me.requiresPopup(), win;
  2207. if (!required && binary) {
  2208. required = !me.saveBlobAs;
  2209. }
  2210. me.popup = null;
  2211. if (required) {
  2212. win = window.open('', '_blank');
  2213. if (win) {
  2214. me.popup = win;
  2215. win.document.write(Ext.dom.Helper.markup({tag:'html', children:[{tag:'head'}, {tag:'body', children:[{tag:'p', html:me.textPopupWait}]}]}));
  2216. }
  2217. }
  2218. }, saveBinaryAs:function(content, filename, charset, mimeType) {
  2219. var me = this, saveAs = me.downloadBinaryAs;
  2220. if (!me.requiresPopup() && me.saveBlobAs) {
  2221. saveAs = me.saveBlobAs;
  2222. }
  2223. return saveAs.call(me, content, filename, charset, mimeType);
  2224. }, downloadBinaryAs:function(content, filename, charset, mimeType) {
  2225. var deferred = new Ext.Deferred, markup, win;
  2226. if (!this.url) {
  2227. Ext.raise('Cannot download file since no URL was defined!');
  2228. return deferred.promise;
  2229. }
  2230. markup = Ext.dom.Helper.markup({tag:'html', children:[{tag:'head'}, {tag:'body', children:[{tag:'form', method:'POST', action:this.url, children:[{tag:'input', type:'hidden', name:'content', value:Ext.util.Base64.encode(content)}, {tag:'input', type:'hidden', name:'filename', value:filename}, {tag:'input', type:'hidden', name:'charset', value:charset || 'UTF-8'}, {tag:'input', type:'hidden', name:'mime', value:mimeType || 'application/octet-stream'}]}, {tag:'script', type:'text/javascript', children:'document.getElementsByTagName("form")[0].submit();'}]}]});
  2231. win = this.popup || window.open('', '_blank');
  2232. if (win) {
  2233. win.document.write(markup);
  2234. deferred.resolve();
  2235. } else {
  2236. deferred.reject(this.textPopupBlocker);
  2237. }
  2238. this.popup = null;
  2239. return deferred.promise;
  2240. }}, function(File) {
  2241. var navigator = window.navigator, saveAs = window.saveAs || function(view) {
  2242. if (typeof navigator !== 'undefined' && /MSIE [1-9]\./.test(navigator.userAgent)) {
  2243. return;
  2244. }
  2245. var doc = view.document, get_URL = function() {
  2246. return view.URL || view.webkitURL || view;
  2247. }, save_link = doc.createElementNS('http://www.w3.org/1999/xhtml', 'a'), can_use_save_link = 'download' in save_link, click = function(node) {
  2248. var event = new MouseEvent('click');
  2249. node.dispatchEvent(event);
  2250. }, is_safari = /Version\/[\d\.]+.*Safari/.test(navigator.userAgent), webkit_req_fs = view.webkitRequestFileSystem, req_fs = view.requestFileSystem || webkit_req_fs || view.mozRequestFileSystem, throw_outside = function(ex) {
  2251. (view.setImmediate || view.setTimeout)(function() {
  2252. throw ex;
  2253. }, 0);
  2254. }, force_saveable_type = 'application/octet-stream', fs_min_size = 0, arbitrary_revoke_timeout = 1000 * 40, revoke = function(file) {
  2255. var revoker = function() {
  2256. if (typeof file === 'string') {
  2257. get_URL().revokeObjectURL(file);
  2258. } else {
  2259. file.remove();
  2260. }
  2261. };
  2262. setTimeout(revoker, arbitrary_revoke_timeout);
  2263. }, dispatch = function(filesaver, event_types, event) {
  2264. event_types = [].concat(event_types);
  2265. var i = event_types.length;
  2266. while (i--) {
  2267. var listener = filesaver['on' + event_types[i]];
  2268. if (typeof listener === 'function') {
  2269. try {
  2270. listener.call(filesaver, event || filesaver);
  2271. } catch (ex) {
  2272. throw_outside(ex);
  2273. }
  2274. }
  2275. }
  2276. }, auto_bom = function(blob) {
  2277. if (/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(blob.type)) {
  2278. return new Blob(['', blob], {type:blob.type});
  2279. }
  2280. return blob;
  2281. }, FileSaver = function(blob, name, no_auto_bom) {
  2282. if (!no_auto_bom) {
  2283. blob = auto_bom(blob);
  2284. }
  2285. var filesaver = this, type = blob.type, blob_changed = false, object_url, target_view, dispatch_all = function() {
  2286. dispatch(filesaver, 'writestart progress write writeend'.split(' '));
  2287. }, fs_error = function() {
  2288. if (target_view && is_safari && typeof FileReader !== 'undefined') {
  2289. var reader = new FileReader;
  2290. reader.onloadend = function() {
  2291. var base64Data = reader.result;
  2292. target_view.location.href = 'data:attachment/file' + base64Data.slice(base64Data.search(/[,;]/));
  2293. filesaver.readyState = filesaver.DONE;
  2294. dispatch_all();
  2295. };
  2296. reader.readAsDataURL(blob);
  2297. filesaver.readyState = filesaver.INIT;
  2298. return;
  2299. }
  2300. if (blob_changed || !object_url) {
  2301. object_url = get_URL().createObjectURL(blob);
  2302. }
  2303. if (target_view) {
  2304. target_view.location.href = object_url;
  2305. } else {
  2306. var new_tab = view.open(object_url, '_blank');
  2307. if (new_tab === undefined && is_safari) {
  2308. view.location.href = object_url;
  2309. }
  2310. }
  2311. filesaver.readyState = filesaver.DONE;
  2312. dispatch_all();
  2313. revoke(object_url);
  2314. }, abortable = function(func) {
  2315. return function() {
  2316. if (filesaver.readyState !== filesaver.DONE) {
  2317. return func.apply(this, arguments);
  2318. }
  2319. };
  2320. }, create_if_not_found = {create:true, exclusive:false}, slice;
  2321. filesaver.readyState = filesaver.INIT;
  2322. if (!name) {
  2323. name = 'download';
  2324. }
  2325. if (can_use_save_link) {
  2326. object_url = get_URL().createObjectURL(blob);
  2327. setTimeout(function() {
  2328. save_link.href = object_url;
  2329. save_link.download = name;
  2330. click(save_link);
  2331. dispatch_all();
  2332. revoke(object_url);
  2333. filesaver.readyState = filesaver.DONE;
  2334. });
  2335. return;
  2336. }
  2337. if (view.chrome && type && type !== force_saveable_type) {
  2338. slice = blob.slice || blob.webkitSlice;
  2339. blob = slice.call(blob, 0, blob.size, force_saveable_type);
  2340. blob_changed = true;
  2341. }
  2342. if (webkit_req_fs && name !== 'download') {
  2343. name += '.download';
  2344. }
  2345. if (type === force_saveable_type || webkit_req_fs) {
  2346. target_view = view;
  2347. }
  2348. if (!req_fs) {
  2349. fs_error();
  2350. return;
  2351. }
  2352. fs_min_size += blob.size;
  2353. req_fs(view.TEMPORARY, fs_min_size, abortable(function(fs) {
  2354. fs.root.getDirectory('saved', create_if_not_found, abortable(function(dir) {
  2355. var save = function() {
  2356. dir.getFile(name, create_if_not_found, abortable(function(file) {
  2357. file.createWriter(abortable(function(writer) {
  2358. writer.onwriteend = function(event) {
  2359. target_view.location.href = file.toURL();
  2360. filesaver.readyState = filesaver.DONE;
  2361. dispatch(filesaver, 'writeend', event);
  2362. revoke(file);
  2363. };
  2364. writer.onerror = function() {
  2365. var error = writer.error;
  2366. if (error.code !== error.ABORT_ERR) {
  2367. fs_error();
  2368. }
  2369. };
  2370. 'writestart progress write abort'.split(' ').forEach(function(event) {
  2371. writer['on' + event] = filesaver['on' + event];
  2372. });
  2373. writer.write(blob);
  2374. filesaver.abort = function() {
  2375. writer.abort();
  2376. filesaver.readyState = filesaver.DONE;
  2377. };
  2378. filesaver.readyState = filesaver.WRITING;
  2379. }), fs_error);
  2380. }), fs_error);
  2381. };
  2382. dir.getFile(name, {create:false}, abortable(function(file) {
  2383. file.remove();
  2384. save();
  2385. }), abortable(function(ex) {
  2386. if (ex.code === ex.NOT_FOUND_ERR) {
  2387. save();
  2388. } else {
  2389. fs_error();
  2390. }
  2391. }));
  2392. }), fs_error);
  2393. }), fs_error);
  2394. }, FS_proto = FileSaver.prototype, saveAs = function(blob, name, no_auto_bom) {
  2395. return new FileSaver(blob, name, no_auto_bom);
  2396. };
  2397. if (typeof navigator !== 'undefined' && navigator.msSaveOrOpenBlob) {
  2398. return function(blob, name, no_auto_bom) {
  2399. if (!no_auto_bom) {
  2400. blob = auto_bom(blob);
  2401. }
  2402. return navigator.msSaveOrOpenBlob(blob, name || 'download');
  2403. };
  2404. }
  2405. FS_proto.abort = function() {
  2406. var filesaver = this;
  2407. filesaver.readyState = filesaver.DONE;
  2408. dispatch(filesaver, 'abort');
  2409. };
  2410. FS_proto.readyState = FS_proto.INIT = 0;
  2411. FS_proto.WRITING = 1;
  2412. FS_proto.DONE = 2;
  2413. FS_proto.error = FS_proto.onwritestart = FS_proto.onprogress = FS_proto.onwrite = FS_proto.onabort = FS_proto.onerror = FS_proto.onwriteend = null;
  2414. return saveAs;
  2415. }(typeof self !== 'undefined' && self || typeof window !== 'undefined' && window || this.content);
  2416. if (typeof module !== 'undefined' && module.exports) {
  2417. module.exports.saveAs = saveAs;
  2418. } else {
  2419. if (typeof define !== 'undefined' && define !== null && define.amd !== null) {
  2420. define([], function() {
  2421. return saveAs;
  2422. });
  2423. }
  2424. }
  2425. var saveTextAs = window.saveTextAs || function(textContent, fileName, charset) {
  2426. fileName = fileName || 'download.txt';
  2427. charset = charset || 'utf-8';
  2428. textContent = (textContent || '').replace(/\r?\n/g, '\r\n');
  2429. if (saveAs && Blob) {
  2430. var blob = new Blob([textContent], {type:'text/plain;charset\x3d' + charset});
  2431. saveAs(blob, fileName);
  2432. return true;
  2433. } else {
  2434. var saveTxtWindow = window.frames.saveTxtWindow;
  2435. if (!saveTxtWindow) {
  2436. saveTxtWindow = document.createElement('iframe');
  2437. saveTxtWindow.id = 'saveTxtWindow';
  2438. saveTxtWindow.style.display = 'none';
  2439. document.body.insertBefore(saveTxtWindow, null);
  2440. saveTxtWindow = window.frames.saveTxtWindow;
  2441. if (!saveTxtWindow) {
  2442. saveTxtWindow = File.popup || window.open('', '_temp', 'width\x3d100,height\x3d100');
  2443. if (!saveTxtWindow) {
  2444. return false;
  2445. }
  2446. }
  2447. }
  2448. var doc = saveTxtWindow.document;
  2449. doc.open('text/html', 'replace');
  2450. doc.charset = charset;
  2451. doc.write(textContent);
  2452. doc.close();
  2453. var retValue = doc.execCommand('SaveAs', null, fileName);
  2454. saveTxtWindow.close();
  2455. return retValue;
  2456. }
  2457. };
  2458. File.saveAs = function(content, filename, charset, mimeType) {
  2459. var deferred;
  2460. if (this.requiresPopup()) {
  2461. return this.downloadBinaryAs(content, filename, charset || 'UTF-8', mimeType || 'text/plain');
  2462. } else {
  2463. deferred = new Ext.Deferred;
  2464. if (saveTextAs(content, filename, charset)) {
  2465. deferred.resolve();
  2466. } else {
  2467. deferred.reject();
  2468. }
  2469. return deferred.promise;
  2470. }
  2471. };
  2472. if (saveAs && Blob) {
  2473. File.saveBlobAs = function(textContent, fileName, charset, mimeType) {
  2474. var deferred = new Ext.Deferred;
  2475. var uint8 = new Uint8Array(textContent.length), len = uint8.length, bType = {type:mimeType || 'application/octet-stream'}, blob, i;
  2476. for (i = 0; i < len; i++) {
  2477. uint8[i] = textContent.charCodeAt(i);
  2478. }
  2479. blob = new Blob([uint8], bType);
  2480. saveAs(blob, fileName);
  2481. deferred.resolve();
  2482. return deferred.promise;
  2483. };
  2484. }
  2485. });
  2486. Ext.define('Ext.exporter.Base', {mixins:['Ext.mixin.Factoryable'], alias:'exporter.base', requires:['Ext.exporter.data.Table', 'Ext.exporter.file.Style', 'Ext.exporter.File'], config:{data:null, showSummary:true, title:null, author:'Sencha', fileName:'export.txt', charset:'UTF-8', mimeType:'text/plain', binary:false}, constructor:function(config) {
  2487. this.initConfig(config || {});
  2488. Ext.exporter.File.initializePopup(this.getBinary());
  2489. return this.callParent([config]);
  2490. }, destroy:function() {
  2491. this.setData(Ext.destroy(this.getData()));
  2492. this.callParent();
  2493. }, getContent:Ext.identityFn, saveAs:function() {
  2494. var me = this, deferred = new Ext.Deferred;
  2495. Ext.asap(me.delayedSave, me, [deferred]);
  2496. return deferred.promise;
  2497. }, delayedSave:function(deferred) {
  2498. var me = this, fn = me.getBinary() ? 'saveBinaryAs' : 'saveAs', promise = Ext.exporter.File[fn](me.getContent(), me.getFileName(), me.getCharset(), me.getMimeType());
  2499. promise.then(function() {
  2500. deferred.resolve();
  2501. }, function(msg) {
  2502. deferred.reject(msg);
  2503. });
  2504. }, getColumnCount:function(columns) {
  2505. var s = 0;
  2506. if (!columns) {
  2507. return s;
  2508. }
  2509. for (var i = 0; i < columns.length; i++) {
  2510. if (!columns[i].columns) {
  2511. s += 1;
  2512. } else {
  2513. s += this.getColumnCount(columns[i].columns);
  2514. }
  2515. }
  2516. return s;
  2517. }, applyData:function(data) {
  2518. if (!data || data.isDataTable) {
  2519. return data;
  2520. }
  2521. return new Ext.exporter.data.Table(data);
  2522. }});
  2523. Ext.define('Ext.overrides.exporter.Base', {override:'Ext.exporter.Base', applyTitle:function(title) {
  2524. return title ? 'Produced by Ext JS Trial - ' + title : title;
  2525. }});
  2526. Ext.define('Ext.exporter.file.ooxml.Base', {extend:'Ext.exporter.file.Base', config:{tplAttributes:{$value:[], merge:function(newValue, oldValue) {
  2527. return [].concat(newValue, oldValue);
  2528. }}, tplNonAttributes:{$value:['idPrefix', 'id', 'autoGenerateId', 'self', 'tplAttributes', 'tplNonAttributes'], merge:function(newValue, oldValue) {
  2529. return [].concat(newValue, oldValue);
  2530. }}}, generateTplAttributes:false, processRenderData:function(data) {
  2531. var attr = this.getTplAttributes(), nonAttr = this.getTplNonAttributes(), keys = Ext.Object.getAllKeys(data), len = keys.length, str = '', i, key;
  2532. if (!this.generateTplAttributes) {
  2533. data.attributes = '';
  2534. return data;
  2535. }
  2536. for (i = 0; i < len; i++) {
  2537. key = keys[i];
  2538. if (attr && attr.length) {
  2539. if (Ext.Array.indexOf(attr, key) >= 0 && data[key] !== null) {
  2540. str += (str.length ? ' ' : '') + this.processTplAttribute(key, data[key]);
  2541. }
  2542. } else {
  2543. if (nonAttr && nonAttr.length) {
  2544. if (Ext.Array.indexOf(nonAttr, key) < 0 && data[key] !== null) {
  2545. str += (str.length ? ' ' : '') + this.processTplAttribute(key, data[key]);
  2546. }
  2547. }
  2548. }
  2549. }
  2550. data.attributes = str;
  2551. return data;
  2552. }, processTplAttribute:function(attr, value) {
  2553. var v = value;
  2554. if (typeof value === 'boolean') {
  2555. v = Number(value);
  2556. } else {
  2557. if (typeof value === 'string') {
  2558. v = Ext.util.Base64._utf8_encode(Ext.util.Format.htmlEncode(value || ''));
  2559. }
  2560. }
  2561. return attr + '\x3d"' + v + '"';
  2562. }});
  2563. Ext.define('Ext.exporter.file.ooxml.Relationship', {extend:'Ext.exporter.file.Base', isRelationship:true, config:{idPrefix:'rId', schema:'', target:'', parentFolder:null, path:null}, tpl:['\x3cRelationship Id\x3d"{id}" Type\x3d"{schema}" Target\x3d"{path}"/\x3e'], updateTarget:function(target) {
  2564. this.calculatePath();
  2565. }, applyParentFolder:function(folder) {
  2566. folder = folder || '';
  2567. if (folder[folder.length - 1] == '/') {
  2568. folder = folder.slice(0, folder.length - 1);
  2569. }
  2570. return folder;
  2571. }, updateParentFolder:function(folder) {
  2572. this.calculatePath();
  2573. }, calculatePath:function() {
  2574. var from = String(this.getParentFolder() || ''), to = String(this.getTarget() || ''), fromParts = from.split('/'), toParts = to.split('/'), length = Math.min(fromParts.length, toParts.length), samePartsLength = length, path = '', outputParts = [], i;
  2575. for (i = 0; i < length; i++) {
  2576. if (fromParts[i] !== toParts[i]) {
  2577. samePartsLength = i;
  2578. break;
  2579. }
  2580. }
  2581. if (samePartsLength == 0) {
  2582. path = to;
  2583. } else {
  2584. for (i = samePartsLength; i < fromParts.length; i++) {
  2585. outputParts.push('..');
  2586. }
  2587. outputParts = outputParts.concat(toParts.slice(samePartsLength));
  2588. path = outputParts.join('/');
  2589. }
  2590. this.setPath(path);
  2591. }});
  2592. Ext.define('Ext.exporter.file.ooxml.ContentType', {extend:'Ext.exporter.file.Base', isContentType:true, config:{tag:'Override', partName:'', contentType:'', extension:''}, tpl:['\x3c{tag}', '\x3ctpl if\x3d"extension"\x3e Extension\x3d"{extension}"\x3c/tpl\x3e', '\x3ctpl if\x3d"partName"\x3e PartName\x3d"{partName}"\x3c/tpl\x3e', '\x3ctpl if\x3d"contentType"\x3e ContentType\x3d"{contentType}"\x3c/tpl\x3e', '/\x3e']});
  2593. Ext.define('Ext.exporter.file.ooxml.Xml', {extend:'Ext.exporter.file.ooxml.Base', requires:['Ext.exporter.file.ooxml.Relationship', 'Ext.exporter.file.ooxml.ContentType'], config:{folder:null, fileName:null, path:null, relationship:null, contentType:null}, cachedConfig:{fileNameTemplate:'{fileName}.xml'}, tplNonAttributes:['path', 'relationship', 'contentType', 'fileName', 'folder', 'fileNameTemplate'], destroy:function() {
  2594. this.setRelationship(null);
  2595. this.setContentType(null);
  2596. this.callParent();
  2597. }, applyFolder:function(folder) {
  2598. folder = folder || '';
  2599. if (folder[folder.length - 1] !== '/') {
  2600. folder += '/';
  2601. }
  2602. return folder;
  2603. }, updateFolder:function() {
  2604. this.generatePath();
  2605. }, updateFileName:function() {
  2606. this.generatePath();
  2607. }, getFileNameFromTemplate:function() {
  2608. var tpl = Ext.XTemplate.getTpl(this, '_fileNameTemplate');
  2609. return tpl ? tpl.apply(this.getConfig()) : '';
  2610. }, generatePath:function() {
  2611. this.setPath((this.getFolder() || '') + this.getFileNameFromTemplate());
  2612. }, updatePath:function(path) {
  2613. var relationship = this.getRelationship(), type = this.getContentType();
  2614. if (relationship) {
  2615. relationship.setTarget(path);
  2616. }
  2617. if (type) {
  2618. type.setPartName(path);
  2619. }
  2620. }, applyRelationship:function(data) {
  2621. if (!data || data.isRelationship) {
  2622. return data;
  2623. }
  2624. return new Ext.exporter.file.ooxml.Relationship(data);
  2625. }, updateRelationship:function(data, oldData) {
  2626. Ext.destroy(oldData);
  2627. }, applyContentType:function(data) {
  2628. if (!data || data.isContentType) {
  2629. return data;
  2630. }
  2631. return new Ext.exporter.file.ooxml.ContentType(data);
  2632. }, updateContentType:function(data, oldData) {
  2633. Ext.destroy(oldData);
  2634. }, collectFiles:Ext.emptyFn});
  2635. Ext.define('Ext.exporter.file.ooxml.Relationships', {extend:'Ext.exporter.file.ooxml.Xml', isRelationships:true, currentIndex:1, config:{parentFolder:null, items:[]}, contentType:{contentType:'application/vnd.openxmlformats-package.relationships+xml'}, fileNameTemplate:'{fileName}.rels', tpl:['\x3c?xml version\x3d"1.0" encoding\x3d"UTF-8" standalone\x3d"yes"?\x3e', '\x3cRelationships xmlns\x3d"http://schemas.openxmlformats.org/package/2006/relationships"\x3e', '\x3ctpl if\x3d"items"\x3e\x3ctpl for\x3d"items.getRange()"\x3e{[values.render()]}\x3c/tpl\x3e\x3c/tpl\x3e',
  2636. '\x3c/Relationships\x3e'], collectFiles:function(files) {
  2637. var items = this.getItems(), length = items.length, folder = this.getParentFolder(), i;
  2638. if (length) {
  2639. for (i = 0; i < length; i++) {
  2640. items.getAt(i).setParentFolder(folder);
  2641. }
  2642. files[this.getPath()] = this.render();
  2643. }
  2644. }, applyFolder:function(folder, oldFolder) {
  2645. folder = this.callParent([folder, oldFolder]);
  2646. return folder + '_rels/';
  2647. }, applyItems:function(data, dataCollection) {
  2648. return this.checkCollection(data, dataCollection, 'Ext.exporter.file.ooxml.Relationship');
  2649. }, updateItems:function(collection, oldCollection) {
  2650. var me = this;
  2651. if (oldCollection) {
  2652. oldCollection.un({add:me.updateIds, remove:me.updateIds, scope:me});
  2653. }
  2654. if (collection) {
  2655. collection.on({add:me.updateIds, remove:me.updateIds, scope:me});
  2656. }
  2657. }, updateIds:function(items) {
  2658. var i, len, item;
  2659. if (!items) {
  2660. return;
  2661. }
  2662. len = items.length;
  2663. for (i = 0; i < len; i++) {
  2664. item = items.getAt(i);
  2665. item.setId('rId' + (i + 1));
  2666. }
  2667. }, addRelationship:function(config) {
  2668. return this.getItems().add(config || {});
  2669. }, removeRelationship:function(config) {
  2670. return this.getItems().remove(config);
  2671. }});
  2672. Ext.define('Ext.exporter.file.ooxml.XmlRels', {extend:'Ext.exporter.file.ooxml.Xml', requires:['Ext.exporter.file.ooxml.Relationships'], config:{index:null, name:null, relationships:{contentType:{contentType:'application/vnd.openxmlformats-package.relationships+xml'}}}, cachedConfig:{nameTemplate:'{name}'}, tplNonAttributes:['index', 'relationships', 'nameTemplate'], contentType:{}, relationship:{}, fileNameTemplate:'{fileName}{index}.xml', destroy:function() {
  2673. this.setRelationships(null);
  2674. this.callParent();
  2675. }, updateFolder:function(folder, oldFolder) {
  2676. var rels = this.getRelationships();
  2677. if (rels) {
  2678. rels.setFolder(folder);
  2679. }
  2680. this.callParent([folder, oldFolder]);
  2681. }, applyRelationships:function(data) {
  2682. if (!data || data.isRelationships) {
  2683. return data;
  2684. }
  2685. return new Ext.exporter.file.ooxml.Relationships(data);
  2686. }, updateRelationships:function(data, oldData) {
  2687. Ext.destroy(oldData);
  2688. }, updateIndex:function() {
  2689. this.generatePath();
  2690. }, generateName:function() {
  2691. var tpl = Ext.XTemplate.getTpl(this, '_nameTemplate');
  2692. this.setName(tpl ? tpl.apply(this.getConfig()) : '');
  2693. }, collectFiles:function(files) {
  2694. this.collectRelationshipsFiles(files);
  2695. files[this.getPath()] = this.render();
  2696. }, collectRelationshipsFiles:function(files) {
  2697. var rels = this.getRelationships(), name = this.getFileName();
  2698. if (rels) {
  2699. rels.setFileName(name ? this.getFileNameFromTemplate() : '');
  2700. rels.setParentFolder(this.getFolder());
  2701. rels.collectFiles(files);
  2702. }
  2703. }, collectContentTypes:function(types) {
  2704. types.push(this.getContentType());
  2705. }});
  2706. Ext.define('Ext.exporter.file.zip.File', {extend:'Ext.Base', requires:['Ext.overrides.exporter.util.Format'], config:{path:'', data:null, dateTime:null, folder:false}, constructor:function(config) {
  2707. var me = this;
  2708. me.initConfig(config);
  2709. if (!me.getDateTime()) {
  2710. me.setDateTime(new Date);
  2711. }
  2712. return me.callParent([config]);
  2713. }, getId:function() {
  2714. return this.getPath();
  2715. }, crc32:function(input, crc) {
  2716. var table = this.self.crcTable, x = 0, y = 0, b = 0, isArray;
  2717. if (typeof input === 'undefined' || !input.length) {
  2718. return 0;
  2719. }
  2720. isArray = typeof input !== 'string';
  2721. if (typeof crc == 'undefined') {
  2722. crc = 0;
  2723. }
  2724. crc = crc ^ -1;
  2725. for (var i = 0, iTop = input.length; i < iTop; i++) {
  2726. b = isArray ? input[i] : input.charCodeAt(i);
  2727. y = (crc ^ b) & 255;
  2728. x = table[y];
  2729. crc = crc >>> 8 ^ x;
  2730. }
  2731. return crc ^ -1;
  2732. }, getHeader:function(offset) {
  2733. var data = this.getData(), path = this.getPath(), utfName = Ext.util.Base64._utf8_encode(path), useUTF8 = utfName !== path, dateTime = this.getDateTime(), extraFields = '', unicodePathExtraField = '', decToHex = Ext.util.Format.decToHex, header = '', dosTime, dosDate, fileHeader, dirHeader;
  2734. dosTime = dateTime.getHours();
  2735. dosTime = dosTime << 6;
  2736. dosTime = dosTime | dateTime.getMinutes();
  2737. dosTime = dosTime << 5;
  2738. dosTime = dosTime | dateTime.getSeconds() / 2;
  2739. dosDate = dateTime.getFullYear() - 1980;
  2740. dosDate = dosDate << 4;
  2741. dosDate = dosDate | dateTime.getMonth() + 1;
  2742. dosDate = dosDate << 5;
  2743. dosDate = dosDate | dateTime.getDate();
  2744. if (useUTF8) {
  2745. unicodePathExtraField = decToHex(1, 1) + decToHex(this.crc32(utfName), 4) + utfName;
  2746. extraFields += 'up' + decToHex(unicodePathExtraField.length, 2) + unicodePathExtraField;
  2747. }
  2748. header += '\n\x00';
  2749. header += useUTF8 ? '\x00\b' : '\x00\x00';
  2750. header += '\x00\x00';
  2751. header += decToHex(dosTime, 2);
  2752. header += decToHex(dosDate, 2);
  2753. header += decToHex(data ? this.crc32(data) : 0, 4);
  2754. header += decToHex(data ? data.length : 0, 4);
  2755. header += decToHex(data ? data.length : 0, 4);
  2756. header += decToHex(utfName.length, 2);
  2757. header += decToHex(extraFields.length, 2);
  2758. fileHeader = 'PK' + header + utfName + extraFields;
  2759. dirHeader = 'PK' + '\x00' + header + '\x00\x00' + '\x00\x00' + '\x00\x00' + (this.getFolder() === true ? '\x00\x00\x00' : '\x00\x00\x00\x00') + decToHex(offset, 4) + utfName + extraFields;
  2760. return {fileHeader:fileHeader, dirHeader:dirHeader, data:data || ''};
  2761. }}, function(File) {
  2762. var c, table = [];
  2763. for (var n = 0; n < 256; n++) {
  2764. c = n;
  2765. for (var k = 0; k < 8; k++) {
  2766. c = c & 1 ? 3.988292384E9 ^ c >>> 1 : c >>> 1;
  2767. }
  2768. table[n] = c;
  2769. }
  2770. File.crcTable = table;
  2771. });
  2772. Ext.define('Ext.exporter.file.zip.Folder', {extend:'Ext.exporter.file.zip.File', folder:true});
  2773. Ext.define('Ext.exporter.file.zip.Archive', {extend:'Ext.exporter.file.Base', requires:['Ext.exporter.file.zip.Folder'], config:{folders:[], files:[]}, destroy:function() {
  2774. this.setFolders(null);
  2775. this.setFiles(null);
  2776. this.callParent();
  2777. }, applyFolders:function(data, dataCollection) {
  2778. return this.checkCollection(data, dataCollection, 'Ext.exporter.file.zip.Folder');
  2779. }, applyFiles:function(data, dataCollection) {
  2780. return this.checkCollection(data, dataCollection, 'Ext.exporter.file.zip.File');
  2781. }, updateFiles:function(collection, oldCollection) {
  2782. var me = this;
  2783. if (oldCollection) {
  2784. oldCollection.un({add:me.onFileAdd, remove:me.onFileRemove, scope:me});
  2785. }
  2786. if (collection) {
  2787. collection.on({add:me.onFileAdd, remove:me.onFileRemove, scope:me});
  2788. me.onFileAdd(collection, {items:collection.getRange()});
  2789. }
  2790. }, onFileAdd:function(collection, details) {
  2791. var folders = this.getFolders(), items = details.items, length = items.length, i, item, folder;
  2792. for (i = 0; i < length; i++) {
  2793. item = items[i];
  2794. folder = this.getParentFolder(item.getPath());
  2795. if (folder) {
  2796. folders.add({path:folder});
  2797. }
  2798. }
  2799. }, onFileRemove:function(collection, details) {
  2800. Ext.destroy(details.items);
  2801. }, getParentFolder:function(path) {
  2802. var lastSlash;
  2803. if (path.slice(-1) == '/') {
  2804. path = path.substring(0, path.length - 1);
  2805. }
  2806. lastSlash = path.lastIndexOf('/');
  2807. return lastSlash > 0 ? path.substring(0, lastSlash + 1) : '';
  2808. }, addFile:function(config) {
  2809. return this.getFiles().add(config || {});
  2810. }, removeFile:function(config) {
  2811. return this.getFiles().remove(config);
  2812. }, getContent:function() {
  2813. var fileData = '', dirData = '', localDirLength = 0, centralDirLength = 0, decToHex = Ext.util.Format.decToHex, files = [], len, dirEnd, i, file, header;
  2814. Ext.Array.insert(files, 0, this._folders.items);
  2815. Ext.Array.insert(files, files.length, this._files.items);
  2816. len = files.length;
  2817. for (i = 0; i < len; i++) {
  2818. file = files[i];
  2819. header = file.getHeader(localDirLength);
  2820. localDirLength += header.fileHeader.length + header.data.length;
  2821. centralDirLength += header.dirHeader.length;
  2822. fileData += header.fileHeader + header.data;
  2823. dirData += header.dirHeader;
  2824. }
  2825. dirEnd = 'PK' + '\x00\x00' + '\x00\x00' + decToHex(len, 2) + decToHex(len, 2) + decToHex(centralDirLength, 4) + decToHex(localDirLength, 4) + '\x00\x00';
  2826. fileData += dirData + dirEnd;
  2827. return fileData;
  2828. }});
  2829. Ext.define('Ext.exporter.file.ooxml.excel.Sheet', {extend:'Ext.exporter.file.ooxml.XmlRels', config:{workbook:null}, folder:'sheet', fileName:'sheet', nameTemplate:'Sheet{index}', fileNameTemplate:'{fileName}{index}.xml', nameLengthLimit:31, destroy:function() {
  2830. this.callParent();
  2831. this.setWorkbook(null);
  2832. }, updateIndex:function() {
  2833. if (this._name == null) {
  2834. this.generateName();
  2835. }
  2836. this.callParent(arguments);
  2837. }, applyName:function(value) {
  2838. return Ext.util.Format.htmlEncode(Ext.String.ellipsis(String(value), this.nameLengthLimit));
  2839. }});
  2840. Ext.define('Ext.exporter.file.ooxml.excel.Column', {extend:'Ext.exporter.file.ooxml.Base', config:{min:1, max:1, width:10, autoFitWidth:false, hidden:false, styleId:null}, tpl:['\x3ccol ', 'min\x3d"{min}" ', 'max\x3d"{max}" ', 'width\x3d"{width}"', '\x3ctpl if\x3d"styleId"\x3e style\x3d"{styleId}"\x3c/tpl\x3e', '\x3ctpl if\x3d"hidden"\x3e hidden\x3d"1"\x3c/tpl\x3e', '\x3ctpl if\x3d"autoFitWidth"\x3e bestFit\x3d"1"\x3c/tpl\x3e', '\x3ctpl if\x3d"width !\x3d 10"\x3e customWidth\x3d"1"\x3c/tpl\x3e',
  2841. '/\x3e']});
  2842. Ext.define('Ext.exporter.file.ooxml.excel.Cell', {extend:'Ext.exporter.file.Base', isCell:true, config:{row:null, dataType:null, showPhonetic:null, index:null, styleId:null, mergeAcross:null, mergeDown:null, value:null, serializeDateToNumber:true}, isMergedCell:false, tpl:['\x3cc r\x3d"{ref}"', '\x3ctpl if\x3d"value !\x3d null"\x3e t\x3d"{dataType}"\x3c/tpl\x3e', '\x3ctpl if\x3d"showPhonetic"\x3e ph\x3d"1"\x3c/tpl\x3e', '\x3ctpl if\x3d"styleId"\x3e s\x3d"{styleId}"\x3c/tpl\x3e', '\x3ctpl if\x3d"value \x3d\x3d null"\x3e/\x3e\x3ctpl else\x3e\x3e\x3cv\x3e{value}\x3c/v\x3e\x3c/c\x3e\x3c/tpl\x3e'],
  2843. constructor:function(config) {
  2844. var cfg = config;
  2845. if (config == null || Ext.isDate(config) || Ext.isPrimitive(config)) {
  2846. cfg = {value:config};
  2847. }
  2848. return this.callParent([cfg]);
  2849. }, destroy:function() {
  2850. this.setRow(null);
  2851. this.callParent();
  2852. }, getRef:function() {
  2853. return this.getNotation(this._index) + this._row._index;
  2854. }, getRenderData:function() {
  2855. var me = this, data = {}, ws = me._row && me._row._worksheet, wb = ws && ws._workbook;
  2856. data.dataType = me._dataType;
  2857. data.value = me._value;
  2858. data.showPhonetic = me._showPhonetic;
  2859. data.styleId = me._styleId;
  2860. if (this.isMergedCell && ws) {
  2861. ws.setMergedCellsNo(ws._mergedCellsNo + 1);
  2862. }
  2863. if (data.dataType === 's' && wb) {
  2864. data.value = wb._sharedStrings.addString(data.value);
  2865. }
  2866. data.ref = this.getRef();
  2867. return data;
  2868. }, applyValue:function(v) {
  2869. var me = this, dt;
  2870. if (v != null) {
  2871. if (typeof v === 'number') {
  2872. dt = 'n';
  2873. } else {
  2874. if (typeof v === 'string') {
  2875. dt = 's';
  2876. v = Ext.util.Format.stripTags(v);
  2877. } else {
  2878. if (v instanceof Date) {
  2879. if (me.getSerializeDateToNumber()) {
  2880. dt = 'n';
  2881. v = me.dateValue(v);
  2882. } else {
  2883. dt = 'd';
  2884. v = Ext.Date.format(v, 'Y-m-d\\TH:i:s.u');
  2885. }
  2886. } else {
  2887. dt = 'b';
  2888. }
  2889. }
  2890. }
  2891. me.setDataType(dt);
  2892. }
  2893. return v;
  2894. }, updateMergeAcross:function(v) {
  2895. this.isMergedCell = v || this._mergeDown;
  2896. }, updateMergeDown:function(v) {
  2897. this.isMergedCell = v || this._mergeAcross;
  2898. }, getMergedCellRef:function() {
  2899. var me = this, currIndex = me._index, rowIndex = me._row._index, mAcross = me._mergeAcross, mDown = me._mergeDown, s = me.getNotation(currIndex) + rowIndex + ':';
  2900. if (mAcross) {
  2901. currIndex += mAcross;
  2902. }
  2903. if (mDown) {
  2904. rowIndex += mDown;
  2905. }
  2906. s += me.getNotation(currIndex) + rowIndex;
  2907. return s;
  2908. }, getNotation:function(index) {
  2909. var code = 65, length = 26, getChar = String.fromCharCode, r, n;
  2910. if (index <= 0) {
  2911. index = 1;
  2912. }
  2913. n = Math.floor(index / length);
  2914. r = index % length;
  2915. if (n === 0 || index === length) {
  2916. return getChar(code + index - 1);
  2917. } else {
  2918. if (r === 0) {
  2919. return this.getNotation(n - 1) + 'Z';
  2920. } else {
  2921. if (n < length) {
  2922. return getChar(code + n - 1) + getChar(code + r - 1);
  2923. } else {
  2924. return this.getNotation(n) + getChar(code + r - 1);
  2925. }
  2926. }
  2927. }
  2928. }, dateValue:function(d) {
  2929. return 25569 + (d.getTime() - d.getTimezoneOffset() * 60 * 1000) / (1000 * 60 * 60 * 24);
  2930. }});
  2931. Ext.define('Ext.exporter.file.ooxml.excel.Row', {extend:'Ext.exporter.file.Base', requires:['Ext.exporter.file.ooxml.excel.Cell'], config:{collapsed:null, hidden:null, height:null, outlineLevel:null, showPhonetic:null, index:null, styleId:null, worksheet:null, cells:[], cachedCells:null}, tpl:['\x3crow', '\x3ctpl if\x3d"index"\x3e r\x3d"{index}"\x3c/tpl\x3e', '\x3ctpl if\x3d"collapsed"\x3e collapsed\x3d"{collapsed}"\x3c/tpl\x3e', '\x3ctpl if\x3d"hidden"\x3e hidden\x3d"1"\x3c/tpl\x3e', '\x3ctpl if\x3d"height"\x3e ht\x3d"{height}" customHeight\x3d"1"\x3c/tpl\x3e',
  2932. '\x3ctpl if\x3d"outlineLevel"\x3e outlineLevel\x3d"{outlineLevel}"\x3c/tpl\x3e', '\x3ctpl if\x3d"styleId"\x3e s\x3d"{styleId}" customFormat\x3d"1"\x3c/tpl\x3e', '\x3ctpl if\x3d"cachedCells"\x3e', '\x3e{cachedCells}\x3c/row\x3e', '\x3ctpl elseif\x3d"cells \x26\x26 cells.length"\x3e', '\x3e\x3ctpl for\x3d"cells.items"\x3e{[values.render()]}\x3c/tpl\x3e\x3c/row\x3e', '\x3ctpl else\x3e', '/\x3e', '\x3c/tpl\x3e'], lastCellIndex:1, constructor:function(config) {
  2933. var cfg = config;
  2934. if (Ext.isArray(config)) {
  2935. cfg = {cells:config};
  2936. }
  2937. return this.callParent([cfg]);
  2938. }, destroy:function() {
  2939. this.setWorksheet(null);
  2940. this.callParent();
  2941. }, applyCells:function(data, dataCollection) {
  2942. return this.checkCollection(data, dataCollection, 'Ext.exporter.file.ooxml.excel.Cell');
  2943. }, updateCells:function(collection, oldCollection) {
  2944. var me = this;
  2945. if (oldCollection) {
  2946. collection.un({add:me.onCellAdd, remove:me.onCellRemove, scope:me});
  2947. }
  2948. if (collection) {
  2949. collection.on({add:me.onCellAdd, remove:me.onCellRemove, scope:me});
  2950. me.onCellAdd(collection, {items:collection.getRange()});
  2951. }
  2952. }, onCellAdd:function(collection, details) {
  2953. var items = details.items, length = items.length, i, item, index;
  2954. for (i = 0; i < length; i++) {
  2955. item = items[i];
  2956. item.setRow(this);
  2957. index = item._index;
  2958. if (!index) {
  2959. item.setIndex(this.lastCellIndex++);
  2960. } else {
  2961. this.lastCellIndex = Math.max(collection.length, index) + 1;
  2962. }
  2963. }
  2964. }, onCellRemove:function(collection, details) {
  2965. Ext.destroy(details.items);
  2966. this.updateCellIndexes();
  2967. }, addCell:function(config) {
  2968. if (!this._cells) {
  2969. this.setCells([]);
  2970. }
  2971. return this._cells.add(config || {});
  2972. }, getCell:function(id) {
  2973. return this._cells ? this._cells.get(id) : null;
  2974. }, beginCellRendering:function() {
  2975. var me = this;
  2976. me.tempCells = [];
  2977. me.startCaching = true;
  2978. me.lastCellIndex = 1;
  2979. if (!me.cachedCell) {
  2980. me.cachedCell = new Ext.exporter.file.ooxml.excel.Cell({row:me});
  2981. me.cachedCellConfig = me.cachedCell.getConfig();
  2982. me.cachedCellConfig.id = null;
  2983. }
  2984. }, endCellRendering:function() {
  2985. var me = this;
  2986. me.setCachedCells(me.tempCells.join(''));
  2987. me.tempCells = null;
  2988. me.startCaching = false;
  2989. me.lastCellIndex = 1;
  2990. }, renderCells:function(cells) {
  2991. var me = this, ret = {first:null, last:null, row:'', merged:''}, len = cells.length, mergedCells = [], i, cell, config, cache, index;
  2992. me.beginCellRendering();
  2993. cache = me.cachedCell;
  2994. for (i = 0; i < len; i++) {
  2995. cell = cells[i] || {};
  2996. if (typeof cell === 'object' && !(cell instanceof Date)) {
  2997. config = cell;
  2998. } else {
  2999. config = {value:cell};
  3000. }
  3001. Ext.applyIf(config, me.cachedCellConfig);
  3002. cache.setValue(config.value);
  3003. cache.setShowPhonetic(config.showPhonetic);
  3004. cache.setStyleId(config.styleId);
  3005. cache.setMergeAcross(config.mergeAcross);
  3006. cache.setMergeDown(config.mergeDown);
  3007. cache.setIndex(config.index);
  3008. index = cache.getIndex();
  3009. if (!index) {
  3010. cache.setIndex(me.lastCellIndex++);
  3011. } else {
  3012. me.lastCellIndex = Math.max(me.lastCellIndex, index) + 1;
  3013. }
  3014. if (i === 0) {
  3015. ret.first = ret.last = cache.getRef();
  3016. } else {
  3017. if (i === len - 1) {
  3018. ret.last = cache.getRef();
  3019. }
  3020. }
  3021. me.tempCells.push(cache.render());
  3022. if (cache.isMergedCell) {
  3023. mergedCells.push('\x3cmergeCell ref\x3d"' + cache.getMergedCellRef() + '"/\x3e');
  3024. }
  3025. }
  3026. me.endCellRendering();
  3027. ret.row = me.render();
  3028. ret.merged = mergedCells.join('');
  3029. return ret;
  3030. }});
  3031. Ext.define('Ext.exporter.file.ooxml.excel.Location', {extend:'Ext.exporter.file.ooxml.Base', config:{ref:null, firstHeaderRow:null, firstDataRow:null, firstDataCol:null, rowPageCount:null, colPageCount:null}, generateTplAttributes:true, tpl:['\x3clocation {attributes}/\x3e']});
  3032. Ext.define('Ext.exporter.file.ooxml.excel.FieldItem', {extend:'Ext.exporter.file.ooxml.Base', config:{c:null, d:null, e:null, f:null, h:null, m:null, n:null, s:null, sd:null, t:null, x:null}, generateTplAttributes:true, tpl:['\x3citem {attributes}/\x3e']});
  3033. Ext.define('Ext.exporter.file.ooxml.excel.PivotAreaReference', {extend:'Ext.exporter.file.ooxml.Base', config:{avgSubtotal:null, byPosition:null, count:null, countASubtotal:null, countSubtotal:null, defaultSubtotal:null, field:null, maxSubtotal:null, minSubtotal:null, productSubtotal:null, relative:null, selected:null, stdDevPSubtotal:null, stdDevSubtotal:null, sumSubtotal:null, varPSubtotal:null, varSubtotal:null, items:[]}, tplNonAttributes:['items'], generateTplAttributes:true, tpl:['\x3creference {attributes}\x3e',
  3034. '\x3ctpl if\x3d"items"\x3e\x3ctpl for\x3d"items"\x3e\x3cx v\x3d"{.}"/\x3e\x3c/tpl\x3e\x3c/tpl\x3e', '\x3c/reference\x3e'], getCount:function() {
  3035. return this.getItems().length;
  3036. }, applyItems:function(items) {
  3037. return items !== null ? Ext.Array.from(items) : null;
  3038. }});
  3039. Ext.define('Ext.exporter.file.ooxml.excel.PivotArea', {extend:'Ext.exporter.file.ooxml.Base', requires:['Ext.exporter.file.ooxml.excel.PivotAreaReference'], config:{axis:null, cacheIndex:null, collapsedLevelsAreSubtotals:null, dataOnly:null, field:null, fieldPosition:null, grandCol:null, grandRow:null, labelOnly:null, offset:null, outline:null, type:null, references:null}, tplNonAttributes:['references'], generateTplAttributes:true, tpl:['\x3cpivotArea {attributes}\x3e', '\x3ctpl if\x3d"references"\x3e\x3creferences count\x3d"{references.length}"\x3e\x3ctpl for\x3d"references.getRange()"\x3e{[values.render()]}\x3c/tpl\x3e\x3c/references\x3e\x3c/tpl\x3e',
  3040. '\x3c/pivotArea\x3e'], applyReferences:function(data, dataCollection) {
  3041. return this.checkCollection(data, dataCollection, 'Ext.exporter.file.ooxml.excel.PivotAreaReference');
  3042. }});
  3043. Ext.define('Ext.exporter.file.ooxml.excel.AutoSortScope', {extend:'Ext.exporter.file.ooxml.Base', requires:['Ext.exporter.file.ooxml.excel.PivotArea'], config:{pivotArea:{}}, tpl:['\x3cautoSortScope\x3e{[values.pivotArea.render()]}\x3c/autoSortScope\x3e'], destroy:function() {
  3044. this.setPivotArea(null);
  3045. this.callParent();
  3046. }, applyPivotArea:function(data) {
  3047. if (!data || data.isInstance) {
  3048. return data;
  3049. }
  3050. return new Ext.exporter.file.ooxml.excel.PivotArea(data);
  3051. }, updatePivotArea:function(data, oldData) {
  3052. Ext.destroy(oldData);
  3053. }});
  3054. Ext.define('Ext.exporter.file.ooxml.excel.PivotField', {extend:'Ext.exporter.file.ooxml.Base', requires:['Ext.exporter.file.ooxml.excel.FieldItem', 'Ext.exporter.file.ooxml.excel.AutoSortScope'], config:{allDrilled:null, autoShow:null, avgSubtotal:null, axis:null, compact:null, countASubtotal:null, countSubtotal:null, dataField:null, dataSourceSort:null, defaultAttributeDrillState:null, defaultSubtotal:null, dragOff:null, dragToCol:null, dragToData:null, dragToPage:null, dragToRow:null, hiddenLevel:null,
  3055. hideNewItems:null, includeNewItemsInFilter:null, insertBlankRow:null, insertPageBreak:null, itemPageCount:null, maxSubtotal:null, measureFilter:null, minSubtotal:null, multipleItemSelectionAllowed:null, nonAutoSortDefault:null, numFmtId:null, outline:null, productSubtotal:null, rankBy:null, serverField:null, showAll:null, showDropDowns:null, showPropAsCaption:null, showPropCell:null, showPropTip:null, sortType:null, stdDevPSubtotal:null, stdDevSubtotal:null, subtotalCaption:null, subtotalTop:null,
  3056. sumSubtotal:null, topAutoShow:null, uniqueMemberProperty:null, varPSubtotal:null, varSubtotal:null, items:null, autoSortScope:null}, tplNonAttributes:['items', 'autoSortScope'], generateTplAttributes:true, tpl:['\x3ctpl if\x3d"items || autoSortScope"\x3e', '\x3cpivotField {attributes}\x3e', '\x3ctpl if\x3d"items"\x3e\x3citems count\x3d"{items.length}"\x3e\x3ctpl for\x3d"items.getRange()"\x3e{[values.render()]}\x3c/tpl\x3e\x3c/items\x3e\x3c/tpl\x3e', '\x3ctpl if\x3d"autoSortScope"\x3e{[values.autoSortScope.render()]}\x3c/tpl\x3e',
  3057. '\x3c/pivotField\x3e', '\x3ctpl else\x3e', '\x3cpivotField {attributes} /\x3e', '\x3c/tpl\x3e'], destroy:function() {
  3058. this.setAutoSortScope(null);
  3059. this.callParent();
  3060. }, applyItems:function(data, dataCollection) {
  3061. return this.checkCollection(data, dataCollection, 'Ext.exporter.file.ooxml.excel.FieldItem');
  3062. }, applyAutoSortScope:function(data) {
  3063. if (!data || data.isInstance) {
  3064. return data;
  3065. }
  3066. return new Ext.exporter.file.ooxml.excel.AutoSortScope(data);
  3067. }, updateAutoSortScope:function(data, oldData) {
  3068. Ext.destroy(oldData);
  3069. }});
  3070. Ext.define('Ext.exporter.file.ooxml.excel.Field', {extend:'Ext.exporter.file.ooxml.Base', config:{x:null}, tpl:['\x3cfield x\x3d"{x}"/\x3e']});
  3071. Ext.define('Ext.exporter.file.ooxml.excel.Item', {extend:'Ext.exporter.file.ooxml.Base', config:{i:null, r:null, t:null, x:null}, tpl:['\x3ctpl if\x3d"x"\x3e\x3ci{attr}\x3e{x}\x3c/i\x3e\x3ctpl else\x3e\x3ci{attr}/\x3e\x3c/tpl\x3e'], getRenderData:function() {
  3072. var data = this.callParent(), len = data.x ? data.x.length : 0, str = '', attr = '', i;
  3073. for (i = 0; i < len; i++) {
  3074. if (data.x[i] > 0) {
  3075. str += '\x3cx v\x3d"' + data.x[i] + '"/\x3e';
  3076. } else {
  3077. str += '\x3cx/\x3e';
  3078. }
  3079. }
  3080. data.x = str;
  3081. if (data.t) {
  3082. attr += ' t\x3d"' + data.t + '"';
  3083. }
  3084. if (data.r > 0) {
  3085. attr += ' r\x3d"' + data.r + '"';
  3086. }
  3087. if (data.i > 0) {
  3088. attr += ' i\x3d"' + data.i + '"';
  3089. }
  3090. data.attr = attr;
  3091. return data;
  3092. }, applyX:function(data) {
  3093. return data != null ? Ext.Array.from(data) : null;
  3094. }});
  3095. Ext.define('Ext.exporter.file.ooxml.excel.DataField', {extend:'Ext.exporter.file.ooxml.Base', config:{baseField:null, baseItem:null, fld:null, name:null, numFmtId:null, showDataAs:null, subtotal:null}, generateTplAttributes:true, tpl:['\x3cdataField {attributes}/\x3e']});
  3096. Ext.define('Ext.exporter.file.ooxml.excel.Record', {extend:'Ext.exporter.file.ooxml.Base', config:{items:null}, tplNonAttributes:['items', 'stritems'], tpl:['\x3ctpl if\x3d"stritems"\x3e', '\x3cr\x3e', '{stritems}', '\x3c/r\x3e', '\x3ctpl else\x3e', '\x3cr/\x3e', '\x3c/tpl\x3e'], numberTpl:'\x3cn v\x3d"{0}"/\x3e', booleanTpl:'\x3cb v\x3d"{0}"/\x3e', stringTpl:'\x3cs v\x3d"{0}"/\x3e', dateTpl:'\x3cd v\x3d"{0}"/\x3e', constructor:function(config) {
  3097. var cfg;
  3098. if (Ext.isArray(config) || Ext.isDate(config) || Ext.isPrimitive(config)) {
  3099. cfg = {items:config};
  3100. } else {
  3101. cfg = config;
  3102. }
  3103. return this.callParent([cfg]);
  3104. }, getRenderData:function() {
  3105. var me = this, data = me.callParent(), items = data.items, str = '', types = [], i, len, v, tpl;
  3106. if (items) {
  3107. len = items.length;
  3108. for (i = 0; i < len; i++) {
  3109. v = items[i];
  3110. if (v == null || v === '') {
  3111. } else {
  3112. if (typeof v === 'string') {
  3113. tpl = me.stringTpl;
  3114. v = Ext.util.Base64._utf8_encode(Ext.util.Format.htmlEncode(v));
  3115. types.push('s');
  3116. } else {
  3117. if (typeof v === 'boolean') {
  3118. tpl = me.booleanTpl;
  3119. types.push('b');
  3120. } else {
  3121. if (typeof v === 'number') {
  3122. tpl = me.numberTpl;
  3123. types.push('n');
  3124. } else {
  3125. if (v instanceof Date) {
  3126. tpl = me.dateTpl;
  3127. v = Ext.Date.format(v, 'Y-m-d\\TH:i:s.u');
  3128. types.push('d');
  3129. }
  3130. }
  3131. }
  3132. }
  3133. str += Ext.String.format(tpl, v);
  3134. }
  3135. }
  3136. }
  3137. data.stritems = str;
  3138. return data;
  3139. }, applyItems:function(items) {
  3140. return items !== null ? Ext.Array.from(items) : null;
  3141. }});
  3142. Ext.define('Ext.exporter.file.ooxml.excel.PivotCacheRecords', {extend:'Ext.exporter.file.ooxml.XmlRels', requires:['Ext.exporter.file.ooxml.excel.Record'], config:{items:[]}, folder:'/xl/pivotCache/', fileName:'pivotCacheRecords', contentType:{contentType:'application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheRecords+xml'}, relationship:{schema:'http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheRecords'}, tpl:['\x3c?xml version\x3d"1.0" encoding\x3d"UTF-8" standalone\x3d"yes"?\x3e',
  3143. '\x3cpivotCacheRecords xmlns\x3d"http://schemas.openxmlformats.org/spreadsheetml/2006/main" ', 'xmlns:r\x3d"http://schemas.openxmlformats.org/officeDocument/2006/relationships" count\x3d"{items.length}"\x3e', '\x3ctpl for\x3d"items.getRange()"\x3e{[values.render()]}\x3c/tpl\x3e', '\x3c/pivotCacheRecords\x3e'], applyItems:function(data, dataCollection) {
  3144. return this.checkCollection(data, dataCollection, 'Ext.exporter.file.ooxml.excel.Record');
  3145. }});
  3146. Ext.define('Ext.exporter.file.ooxml.excel.WorksheetSource', {extend:'Ext.exporter.file.ooxml.Base', config:{id:null, name:null, ref:null, sheet:null}, autoGenerateId:false, tplAttributes:['id', 'name', 'ref', 'sheet'], generateTplAttributes:true, tpl:['\x3cworksheetSource {attributes} /\x3e']});
  3147. Ext.define('Ext.exporter.file.ooxml.excel.CacheSource', {extend:'Ext.exporter.file.ooxml.Base', requires:['Ext.exporter.file.ooxml.excel.WorksheetSource'], config:{type:'worksheet', worksheetSource:{}}, tplNonAttributes:['worksheetSource'], generateTplAttributes:true, tpl:['\x3ccacheSource {attributes}\x3e', '\x3ctpl if\x3d"type \x3d\x3d \'worksheet\'"\x3e', '{[values.worksheetSource.render()]}', '\x3c/tpl\x3e', '\x3c/cacheSource\x3e'], destroy:function() {
  3148. this.setWorksheetSource(null);
  3149. this.callParent();
  3150. }, applyWorksheetSource:function(data) {
  3151. if (!data || data.isInstance) {
  3152. return data;
  3153. }
  3154. return new Ext.exporter.file.ooxml.excel.WorksheetSource(data);
  3155. }, updateWorksheetSource:function(data, oldData) {
  3156. Ext.destroy(oldData);
  3157. }});
  3158. Ext.define('Ext.exporter.file.ooxml.excel.SharedItems', {extend:'Ext.exporter.file.ooxml.Base', config:{containsBlank:null, containsDate:null, containsInteger:null, containsMixedTypes:null, containsNonDate:null, containsNumber:null, containsSemiMixedTypes:null, containsString:null, longText:null, maxDate:null, maxValue:null, minDate:null, minValue:null, items:null}, tplNonAttributes:['items', 'stritems'], generateTplAttributes:true, tpl:['\x3ctpl if\x3d"stritems"\x3e', '\x3csharedItems {attributes}\x3e',
  3159. '{stritems}', '\x3c/sharedItems\x3e', '\x3ctpl else\x3e', '\x3csharedItems {attributes}/\x3e', '\x3c/tpl\x3e'], numberTpl:'\x3cn v\x3d"{0}"/\x3e', booleanTpl:'\x3cb v\x3d"{0}"/\x3e', stringTpl:'\x3cs v\x3d"{0}"/\x3e', dateTpl:'\x3cd v\x3d"{0}"/\x3e', getRenderData:function() {
  3160. var me = this, data = me.callParent(), items = data.items, str = '', hasBlank = false, hasBool = false, hasNumber = false, hasDate = false, hasString = false, hasFloat = false, count = 0, types = [], minValue = null, maxValue = null, i, len, v, tpl;
  3161. if (items) {
  3162. len = items.length;
  3163. for (i = 0; i < len; i++) {
  3164. v = items[i];
  3165. if (v == null || v === '') {
  3166. hasBlank = true;
  3167. } else {
  3168. count++;
  3169. if (typeof v === 'string') {
  3170. hasString = true;
  3171. tpl = me.stringTpl;
  3172. v = Ext.util.Base64._utf8_encode(Ext.util.Format.htmlEncode(v));
  3173. types.push('s');
  3174. } else {
  3175. if (typeof v === 'boolean') {
  3176. hasBool = true;
  3177. tpl = me.booleanTpl;
  3178. types.push('b');
  3179. } else {
  3180. if (typeof v === 'number') {
  3181. hasNumber = true;
  3182. tpl = me.numberTpl;
  3183. minValue = Math.min(minValue, v);
  3184. maxValue = Math.max(maxValue, v);
  3185. if (String(v).indexOf('.') >= 0) {
  3186. hasFloat = true;
  3187. }
  3188. types.push('n');
  3189. } else {
  3190. if (v instanceof Date) {
  3191. hasDate = true;
  3192. tpl = me.dateTpl;
  3193. v = Ext.Date.format(v, 'Y-m-d\\TH:i:s.u');
  3194. types.push('d');
  3195. }
  3196. }
  3197. }
  3198. }
  3199. str += Ext.String.format(tpl, v);
  3200. }
  3201. }
  3202. }
  3203. if (count > 0) {
  3204. data.count = count;
  3205. }
  3206. data.stritems = str;
  3207. if (hasDate) {
  3208. data.containsSemiMixedTypes = hasString;
  3209. data.containsDate = true;
  3210. data.stritems = '';
  3211. }
  3212. if (hasNumber) {
  3213. data.containsSemiMixedTypes = hasString;
  3214. data.containsNumber = true;
  3215. data.minValue = minValue;
  3216. data.maxValue = maxValue;
  3217. if (!hasFloat) {
  3218. data.containsInteger = true;
  3219. }
  3220. }
  3221. data.containsString = hasString;
  3222. len = Ext.Array.unique(types);
  3223. if (len > 0) {
  3224. data.containsMixedTypes = len > 1;
  3225. }
  3226. return data;
  3227. }, applyItems:function(items) {
  3228. return items !== null ? Ext.Array.from(items) : null;
  3229. }, updateMinValue:function(v) {
  3230. if (v != null) {
  3231. this.setContainsNumber(true);
  3232. }
  3233. }, updateMaxValue:function(v) {
  3234. if (v != null) {
  3235. this.setContainsNumber(true);
  3236. }
  3237. }, applyMinDate:function(v) {
  3238. if (v) {
  3239. v = Ext.Date.format(v, 'Y-m-d\\TH:i:s.u');
  3240. }
  3241. return v;
  3242. }, updateMinDate:function(v) {
  3243. if (v != null) {
  3244. this.setContainsDate(true);
  3245. }
  3246. }, applyMaxDate:function(v) {
  3247. if (v) {
  3248. v = Ext.Date.format(v, 'Y-m-d\\TH:i:s.u');
  3249. }
  3250. return v;
  3251. }, updateMaxDate:function(v) {
  3252. if (v != null) {
  3253. this.setContainsDate(true);
  3254. }
  3255. }});
  3256. Ext.define('Ext.exporter.file.ooxml.excel.CacheField', {extend:'Ext.exporter.file.ooxml.Base', requires:['Ext.exporter.file.ooxml.excel.SharedItems'], config:{caption:null, databaseField:null, formula:null, hierarchy:null, level:null, mappingCount:null, memberPropertyField:null, name:null, numFmtId:null, propertyName:null, serverField:null, sqlType:null, uniqueList:null, sharedItems:{}, fieldGroup:null, mpMap:null}, tplNonAttributes:['sharedItems', 'fieldGroup', 'mpMap'], generateTplAttributes:true,
  3257. tpl:['\x3ccacheField {attributes}\x3e', '\x3ctpl if\x3d"sharedItems"\x3e{[values.sharedItems.render()]}\x3c/tpl\x3e', '\x3c/cacheField\x3e'], destroy:function() {
  3258. this.setSharedItems(null);
  3259. this.callParent();
  3260. }, applySharedItems:function(data) {
  3261. if (!data || data.isInstance) {
  3262. return data;
  3263. }
  3264. return new Ext.exporter.file.ooxml.excel.SharedItems(data);
  3265. }, updateSharedItems:function(data, oldData) {
  3266. Ext.destroy(oldData);
  3267. }});
  3268. Ext.define('Ext.exporter.file.ooxml.excel.PivotCache', {extend:'Ext.exporter.file.ooxml.Base', config:{id:null, cacheId:null}, autoGenerateId:false, tpl:['\x3cpivotCache cacheId\x3d"{cacheId}" r:id\x3d"{id}"/\x3e']});
  3269. Ext.define('Ext.exporter.file.ooxml.excel.PivotCacheDefinition', {extend:'Ext.exporter.file.ooxml.XmlRels', requires:['Ext.exporter.file.ooxml.excel.PivotCacheRecords', 'Ext.exporter.file.ooxml.excel.CacheSource', 'Ext.exporter.file.ooxml.excel.CacheField', 'Ext.exporter.file.ooxml.excel.PivotCache'], config:{backgroundQuery:null, createdVersion:null, enableRefresh:null, invalid:null, minRefreshableVersion:null, missingItemsLimit:null, optimizeMemory:null, recordCount:null, refreshedBy:null, refreshedDateIso:null,
  3270. refreshedVersion:null, refreshOnLoad:null, saveData:null, supportAdvancedDrill:null, supportSubquery:null, tupleCache:null, upgradeOnRefresh:null, cacheRecords:{}, cacheSource:{}, cacheFields:null, pivotCache:{}}, folder:'/xl/pivotCache/', fileName:'pivotCacheDefinition', contentType:{contentType:'application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheDefinition+xml'}, relationship:{schema:'http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheDefinition'},
  3271. tplNonAttributes:['cacheRecords', 'cacheSource', 'cacheFields', 'pivotCache'], generateTplAttributes:true, tpl:['\x3c?xml version\x3d"1.0" encoding\x3d"UTF-8" standalone\x3d"yes"?\x3e', '\x3cpivotCacheDefinition xmlns\x3d"http://schemas.openxmlformats.org/spreadsheetml/2006/main" ', 'xmlns:r\x3d"http://schemas.openxmlformats.org/officeDocument/2006/relationships" r:id\x3d"{[values.relationship.getId()]}" {attributes}\x3e', '{[values.cacheSource.render()]}', '\x3ctpl if\x3d"cacheFields"\x3e\x3ccacheFields count\x3d"{cacheFields.length}"\x3e\x3ctpl for\x3d"cacheFields.getRange()"\x3e{[values.render()]}\x3c/tpl\x3e\x3c/cacheFields\x3e\x3c/tpl\x3e',
  3272. '\x3c/pivotCacheDefinition\x3e'], destroy:function() {
  3273. this.setCacheRecords(null);
  3274. this.setCacheSource(null);
  3275. this.setPivotCache(null);
  3276. this.callParent();
  3277. }, getRenderData:function() {
  3278. var data = this.callParent(), records = this.getCacheRecords();
  3279. if (records) {
  3280. records = records.getItems();
  3281. data.recordCount = records.length;
  3282. }
  3283. return data;
  3284. }, collectFiles:function(files) {
  3285. var records = this.getCacheRecords();
  3286. if (records) {
  3287. records.collectFiles(files);
  3288. }
  3289. this.callParent([files]);
  3290. }, collectContentTypes:function(types) {
  3291. var records = this.getCacheRecords();
  3292. if (records) {
  3293. records.collectContentTypes(types);
  3294. }
  3295. this.callParent([types]);
  3296. }, updateIndex:function(index, oldIndex) {
  3297. var cache = this.getCacheRecords();
  3298. if (cache) {
  3299. cache.setIndex(index);
  3300. }
  3301. this.callParent([index, oldIndex]);
  3302. }, applyPivotCache:function(data) {
  3303. if (!data || data.isInstance) {
  3304. return data;
  3305. }
  3306. return new Ext.exporter.file.ooxml.excel.PivotCache(data);
  3307. }, updatePivotCache:function(data, oldData) {
  3308. Ext.destroy(oldData);
  3309. }, applyCacheRecords:function(data) {
  3310. if (!data || data.isInstance) {
  3311. return data;
  3312. }
  3313. return new Ext.exporter.file.ooxml.excel.PivotCacheRecords(data);
  3314. }, updateCacheRecords:function(data, oldData) {
  3315. var rels = this.getRelationships(), rel;
  3316. if (oldData) {
  3317. rels.removeRelationship(oldData.getRelationship());
  3318. }
  3319. Ext.destroy(oldData);
  3320. if (data) {
  3321. rel = data.getRelationship();
  3322. rels.addRelationship(rel);
  3323. this.setId(rel.getId());
  3324. }
  3325. }, applyCacheSource:function(data) {
  3326. if (!data || data.isInstance) {
  3327. return data;
  3328. }
  3329. return new Ext.exporter.file.ooxml.excel.CacheSource(data);
  3330. }, updateCacheSource:function(data, oldData) {
  3331. Ext.destroy(oldData);
  3332. }, applyCacheFields:function(data, dataCollection) {
  3333. return this.checkCollection(data, dataCollection, 'Ext.exporter.file.ooxml.excel.CacheField');
  3334. }});
  3335. Ext.define('Ext.exporter.file.ooxml.excel.PivotTableStyleInfo', {extend:'Ext.exporter.file.ooxml.Base', config:{name:'PivotStyleLight2', showColHeaders:true, showColStripes:null, showLastColumn:true, showRowHeaders:true, showRowStripes:null}, generateTplAttributes:true, tpl:['\x3cpivotTableStyleInfo {attributes}/\x3e']});
  3336. Ext.define('Ext.exporter.file.ooxml.excel.PivotTable', {extend:'Ext.exporter.file.ooxml.XmlRels', requires:['Ext.exporter.file.ooxml.excel.Location', 'Ext.exporter.file.ooxml.excel.PivotField', 'Ext.exporter.file.ooxml.excel.Field', 'Ext.exporter.file.ooxml.excel.Item', 'Ext.exporter.file.ooxml.excel.DataField', 'Ext.exporter.file.ooxml.excel.PivotCacheDefinition', 'Ext.exporter.file.ooxml.excel.PivotTableStyleInfo'], config:{applyAlignmentFormats:false, applyBorderFormats:false, applyFontFormats:false,
  3337. applyNumberFormats:false, applyPatternFormats:false, applyWidthHeightFormats:true, asteriskTotals:null, autoFormatId:4096, cacheId:null, chartFormat:null, colGrandTotals:null, colHeaderCaption:null, compact:false, compactData:false, createdVersion:null, customListSort:null, dataCaption:'Values', dataOnRows:null, dataPosition:null, disableFieldList:null, editData:null, enableDrill:null, enableFieldProperties:null, enableWizard:null, errorCaption:null, fieldListSortAscending:null, fieldPrintTitles:null,
  3338. grandTotalCaption:null, gridDropZones:null, immersive:null, indent:null, itemPrintTitles:true, mdxSubqueries:null, mergeItem:null, minRefreshableVersion:null, missingCaption:null, multipleFieldFilters:false, name:null, outline:true, outlineData:null, pageOverThenDown:null, pageStyle:null, pageWrap:null, pivotTableStyle:null, preserveFormatting:null, printDrill:null, published:null, rowGrandTotals:null, rowHeaderCaption:null, showCalcMbrs:null, showDataDropDown:null, showDataTips:null, showDrill:null,
  3339. showDropZones:null, showEmptyCol:null, showEmptyRow:null, showError:null, showHeaders:null, showItems:null, showMemberPropertyTips:null, showMissing:null, showMultipleLabel:null, subtotalHiddenItems:null, tag:null, updatedVersion:null, useAutoFormatting:true, vacatedStyle:null, visualTotals:null, location:{}, pivotFields:null, rowFields:null, rowItems:null, colFields:null, colItems:null, pageFields:null, dataFields:null, pivotTableStyleInfo:{}, worksheet:null, cacheDefinition:{}, viewLayoutType:'outline'},
  3340. folder:'/xl/pivotTables/', fileName:'pivotTable', nameTemplate:'PivotTable{index}', contentType:{contentType:'application/vnd.openxmlformats-officedocument.spreadsheetml.pivotTable+xml'}, relationship:{schema:'http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotTable'}, tplNonAttributes:['location', 'worksheet', 'cacheDefinition', 'pivotFields', 'rowFields', 'rowItems', 'colFields', 'colItems', 'pageFields', 'dataFields', 'pivotTableStyleInfo', 'viewLayoutType'], generateTplAttributes:true,
  3341. tpl:['\x3c?xml version\x3d"1.0" encoding\x3d"UTF-8" standalone\x3d"yes"?\x3e', '\x3cpivotTableDefinition xmlns\x3d"http://schemas.openxmlformats.org/spreadsheetml/2006/main" {attributes}\x3e', '{[values.location.render()]}', '\x3ctpl if\x3d"pivotFields \x26\x26 pivotFields.length"\x3e\x3cpivotFields count\x3d"{pivotFields.length}"\x3e\x3ctpl for\x3d"pivotFields.getRange()"\x3e{[values.render()]}\x3c/tpl\x3e\x3c/pivotFields\x3e\x3c/tpl\x3e', '\x3ctpl if\x3d"rowFields \x26\x26 rowFields.length"\x3e\x3crowFields count\x3d"{rowFields.length}"\x3e\x3ctpl for\x3d"rowFields.getRange()"\x3e{[values.render()]}\x3c/tpl\x3e\x3c/rowFields\x3e\x3c/tpl\x3e',
  3342. '\x3ctpl if\x3d"rowItems \x26\x26 rowItems.length"\x3e\x3crowItems count\x3d"{rowItems.length}"\x3e\x3ctpl for\x3d"rowItems.getRange()"\x3e{[values.render()]}\x3c/tpl\x3e\x3c/rowItems\x3e\x3c/tpl\x3e', '\x3ctpl if\x3d"colFields \x26\x26 colFields.length"\x3e\x3ccolFields count\x3d"{colFields.length}"\x3e\x3ctpl for\x3d"colFields.getRange()"\x3e{[values.render()]}\x3c/tpl\x3e\x3c/colFields\x3e\x3c/tpl\x3e', '\x3ctpl if\x3d"colItems \x26\x26 colItems.length"\x3e\x3ccolItems count\x3d"{colItems.length}"\x3e\x3ctpl for\x3d"colItems.getRange()"\x3e{[values.render()]}\x3c/tpl\x3e\x3c/colItems\x3e\x3c/tpl\x3e',
  3343. '\x3ctpl if\x3d"pageFields \x26\x26 pageFields.length"\x3e\x3cpageFields count\x3d"{pageFields.length}"\x3e\x3ctpl for\x3d"pageFields.getRange()"\x3e{[values.render()]}\x3c/tpl\x3e\x3c/pageFields\x3e\x3c/tpl\x3e', '\x3ctpl if\x3d"dataFields \x26\x26 dataFields.length"\x3e\x3cdataFields count\x3d"{dataFields.length}"\x3e\x3ctpl for\x3d"dataFields.getRange()"\x3e{[values.render()]}\x3c/tpl\x3e\x3c/dataFields\x3e\x3c/tpl\x3e', '\x3ctpl if\x3d"pivotTableStyleInfo"\x3e{[values.pivotTableStyleInfo.render()]}\x3c/tpl\x3e',
  3344. '\x3c/pivotTableDefinition\x3e'], destroy:function() {
  3345. var me = this;
  3346. me.setWorksheet(null);
  3347. me.setLocation(null);
  3348. me.setCacheDefinition(null);
  3349. me.setPivotTableStyleInfo(null);
  3350. me.callParent();
  3351. }, collectFiles:function(files) {
  3352. this.getCacheDefinition().collectFiles(files);
  3353. this.callParent([files]);
  3354. }, collectContentTypes:function(types) {
  3355. this.getCacheDefinition().collectContentTypes(types);
  3356. this.callParent([types]);
  3357. }, updateIndex:function(index, oldIndex) {
  3358. var me = this, cache = me.getCacheDefinition();
  3359. if (cache) {
  3360. cache.setIndex(index);
  3361. }
  3362. if (me._name == null) {
  3363. me.generateName();
  3364. }
  3365. me.callParent([index, oldIndex]);
  3366. }, updateWorksheet:function(data, oldData) {
  3367. var def = this.getCacheDefinition(), wb, pc;
  3368. if (oldData && def && oldData.getWorkbook() && oldData.getWorkbook().getRelationships()) {
  3369. oldData.getWorkbook().getRelationships().removeRelationship(def.getRelationship());
  3370. }
  3371. if (data && def) {
  3372. wb = data.getWorkbook();
  3373. wb.getRelationships().addRelationship(def.getRelationship());
  3374. pc = def.getPivotCache();
  3375. wb.addPivotCache(pc);
  3376. this.setCacheId(pc.getCacheId());
  3377. pc.setId(def.getRelationship().getId());
  3378. }
  3379. }, applyPivotTableStyleInfo:function(data) {
  3380. if (!data || data.isInstance) {
  3381. return data;
  3382. }
  3383. return new Ext.exporter.file.ooxml.excel.PivotTableStyleInfo(data);
  3384. }, updatePivotTableStyleInfo:function(data, oldData) {
  3385. Ext.destroy(oldData);
  3386. }, applyCacheDefinition:function(data) {
  3387. if (!data || data.isInstance) {
  3388. return data;
  3389. }
  3390. return new Ext.exporter.file.ooxml.excel.PivotCacheDefinition(data);
  3391. }, updateCacheDefinition:function(data, oldData) {
  3392. var rels = this.getRelationships();
  3393. if (oldData) {
  3394. rels.removeRelationship(oldData.getRelationship());
  3395. }
  3396. Ext.destroy(oldData);
  3397. if (data) {
  3398. rels.addRelationship(data.getRelationship());
  3399. }
  3400. }, updateViewLayoutType:function(value) {
  3401. var me = this;
  3402. if (value === 'compact') {
  3403. me.setOutline(true);
  3404. me.setOutlineData(true);
  3405. me.setCompact(null);
  3406. me.setCompactData(null);
  3407. } else {
  3408. if (value === 'outline') {
  3409. me.setOutline(true);
  3410. me.setOutlineData(true);
  3411. me.setCompact(false);
  3412. me.setCompactData(false);
  3413. } else {
  3414. me.setOutline(null);
  3415. me.setOutlineData(null);
  3416. me.setCompact(false);
  3417. me.setCompactData(false);
  3418. }
  3419. }
  3420. me.processPivotFields(me.getPivotFields().getRange());
  3421. }, applyLocation:function(data) {
  3422. if (!data || data.isInstance) {
  3423. return data;
  3424. }
  3425. return new Ext.exporter.file.ooxml.excel.Location(data);
  3426. }, updateLocation:function(data, oldData) {
  3427. Ext.destroy(oldData);
  3428. }, applyPivotFields:function(data, dataCollection) {
  3429. return this.checkCollection(data, dataCollection, 'Ext.exporter.file.ooxml.excel.PivotField');
  3430. }, updatePivotFields:function(collection, oldCollection) {
  3431. var me = this;
  3432. if (oldCollection) {
  3433. oldCollection.un({add:me.onPivotFieldAdd, scope:me});
  3434. }
  3435. if (collection) {
  3436. collection.on({add:me.onPivotFieldAdd, scope:me});
  3437. this.processPivotFields(collection.getRange());
  3438. }
  3439. }, onPivotFieldAdd:function(collection, details) {
  3440. this.processPivotFields(details.items);
  3441. }, processPivotFields:function(items) {
  3442. var layout = this.getViewLayoutType(), length = items.length, i, item, compact, outline;
  3443. if (layout === 'compact') {
  3444. compact = null;
  3445. outline = null;
  3446. } else {
  3447. if (layout === 'outline') {
  3448. compact = false;
  3449. outline = null;
  3450. } else {
  3451. compact = false;
  3452. outline = false;
  3453. }
  3454. }
  3455. for (i = 0; i < length; i++) {
  3456. item = items[i];
  3457. item.setCompact(compact);
  3458. item.setOutline(outline);
  3459. }
  3460. }, applyRowFields:function(data, dataCollection) {
  3461. return this.checkCollection(data, dataCollection, 'Ext.exporter.file.ooxml.excel.Field');
  3462. }, applyRowItems:function(data, dataCollection) {
  3463. return this.checkCollection(data, dataCollection, 'Ext.exporter.file.ooxml.excel.Item');
  3464. }, applyColFields:function(data, dataCollection) {
  3465. return this.checkCollection(data, dataCollection, 'Ext.exporter.file.ooxml.excel.Field');
  3466. }, applyColItems:function(data, dataCollection) {
  3467. return this.checkCollection(data, dataCollection, 'Ext.exporter.file.ooxml.excel.Item');
  3468. }, applyDataFields:function(data, dataCollection) {
  3469. return this.checkCollection(data, dataCollection, 'Ext.exporter.file.ooxml.excel.DataField');
  3470. }, applyAutoFormatId:function(value) {
  3471. return value >= 4096 && value <= 4117 ? value : null;
  3472. }});
  3473. Ext.define('Ext.exporter.file.ooxml.excel.Worksheet', {extend:'Ext.exporter.file.ooxml.excel.Sheet', requires:['Ext.exporter.file.ooxml.excel.Column', 'Ext.exporter.file.ooxml.excel.Row', 'Ext.exporter.file.ooxml.excel.PivotTable'], isWorksheet:true, config:{columns:null, rows:[], drawings:null, tables:null, mergeCells:null, mergedCellsNo:0, topLeftRef:null, bottomRightRef:null, cachedRows:'', cachedMergeCells:'', pivotTables:null}, folder:'/xl/worksheets/', contentType:{contentType:'application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml'},
  3474. relationship:{schema:'http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet'}, tpl:['\x3c?xml version\x3d"1.0" encoding\x3d"UTF-8" standalone\x3d"yes"?\x3e', '\x3cworksheet xmlns\x3d"http://schemas.openxmlformats.org/spreadsheetml/2006/main" ', 'xmlns:r\x3d"http://schemas.openxmlformats.org/officeDocument/2006/relationships"\x3e', '\x3ctpl if\x3d"columns"\x3e', '\x3ccols\x3e', '\x3ctpl for\x3d"columns.items"\x3e{[values.render()]}\x3c/tpl\x3e', '\x3c/cols\x3e', '\x3c/tpl\x3e',
  3475. '\x3ctpl if\x3d"cachedRows"\x3e', '\x3csheetData\x3e{cachedRows}\x3c/sheetData\x3e', '\x3ctpl if\x3d"cachedMergeCells"\x3e\x3cmergeCells\x3e{cachedMergeCells}\x3c/mergeCells\x3e\x3c/tpl\x3e', '\x3ctpl elseif\x3d"rows"\x3e', '\x3csheetData\x3e\x3ctpl for\x3d"rows.items"\x3e{[values.render()]}\x3c/tpl\x3e\x3c/sheetData\x3e', '\x3ctpl if\x3d"values.self.getMergedCellsNo() \x26gt; 0"\x3e', '\x3cmergeCells\x3e', '\x3ctpl for\x3d"rows.items"\x3e', '\x3ctpl for\x3d"_cells.items"\x3e', '\x3ctpl if\x3d"isMergedCell"\x3e\x3cmergeCell ref\x3d"{[values.getMergedCellRef()]}"/\x3e\x3c/tpl\x3e',
  3476. '\x3c/tpl\x3e', '\x3c/tpl\x3e', '\x3c/mergeCells\x3e', '\x3c/tpl\x3e', '\x3ctpl else\x3e', '\x3c/sheetData\x3e', '\x3c/tpl\x3e', '\x3c/worksheet\x3e'], lastRowIndex:1, destroy:function() {
  3477. var me = this;
  3478. Ext.destroy(me.cachedRow);
  3479. me.cachedRow = me.cachedRowConfig = null;
  3480. me.callParent();
  3481. }, getRenderData:function() {
  3482. this.setMergedCellsNo(0);
  3483. return this.callParent();
  3484. }, collectFiles:function(files) {
  3485. var pivot = this.getPivotTables(), length, i;
  3486. if (pivot) {
  3487. length = pivot.length;
  3488. for (i = 0; i < length; i++) {
  3489. pivot.getAt(i).collectFiles(files);
  3490. }
  3491. }
  3492. this.callParent([files]);
  3493. }, collectContentTypes:function(types) {
  3494. var pivot = this.getPivotTables(), length, i;
  3495. if (pivot) {
  3496. length = pivot.length;
  3497. for (i = 0; i < length; i++) {
  3498. pivot.getAt(i).collectContentTypes(types);
  3499. }
  3500. }
  3501. this.callParent([types]);
  3502. }, applyColumns:function(data, dataCollection) {
  3503. return this.checkCollection(data, dataCollection, 'Ext.exporter.file.ooxml.excel.Column');
  3504. }, applyRows:function(data, dataCollection) {
  3505. return this.checkCollection(data, dataCollection, 'Ext.exporter.file.ooxml.excel.Row');
  3506. }, updateRows:function(collection, oldCollection) {
  3507. var me = this;
  3508. if (oldCollection) {
  3509. oldCollection.un({add:me.onRowAdd, remove:me.onRowRemove, scope:me});
  3510. }
  3511. if (collection) {
  3512. collection.on({add:me.onRowAdd, remove:me.onRowRemove, scope:me});
  3513. me.onRowAdd(collection, {items:collection.getRange()});
  3514. }
  3515. }, onRowAdd:function(collection, details) {
  3516. var items = details.items, length = items.length, i, item, index;
  3517. for (i = 0; i < length; i++) {
  3518. item = items[i];
  3519. item.setWorksheet(this);
  3520. index = item._index;
  3521. if (!index) {
  3522. item.setIndex(this.lastRowIndex++);
  3523. } else {
  3524. this.lastRowIndex = Math.max(collection.length, index) + 1;
  3525. }
  3526. }
  3527. }, onRowRemove:function(collection, details) {
  3528. Ext.destroy(details.items);
  3529. }, updateItemIndexes:function(items) {
  3530. var i, len, item;
  3531. if (!items) {
  3532. return;
  3533. }
  3534. len = items.length;
  3535. for (i = 0; i < len; i++) {
  3536. item = items.getAt(i);
  3537. if (!item.getIndex()) {
  3538. item.setIndex(i + 1);
  3539. }
  3540. }
  3541. }, updateDrawings:function(data) {
  3542. var rels = this.getRelationships();
  3543. if (oldData && rels) {
  3544. rels.removeRelationship(oldData.getRelationship());
  3545. }
  3546. if (data && rels) {
  3547. rels.addRelationship(data.getRelationship());
  3548. }
  3549. }, updateTables:function(data) {
  3550. var rels = this.getRelationships();
  3551. if (oldData && rels) {
  3552. rels.removeRelationship(oldData.getRelationship());
  3553. }
  3554. if (data && rels) {
  3555. rels.addRelationship(data.getRelationship());
  3556. }
  3557. }, applyPivotTables:function(data, dataCollection) {
  3558. return this.checkCollection(data, dataCollection, 'Ext.exporter.file.ooxml.excel.PivotTable');
  3559. }, updatePivotTables:function(collection, oldCollection) {
  3560. var me = this;
  3561. if (oldCollection) {
  3562. oldCollection.un({add:me.onPivotTableAdd, remove:me.onPivotTableRemove, scope:me});
  3563. }
  3564. if (collection) {
  3565. collection.on({add:me.onPivotTableAdd, remove:me.onPivotTableRemove, scope:me});
  3566. this.processPivotTables(collection.getRange());
  3567. }
  3568. }, onPivotTableAdd:function(collection, details) {
  3569. this.processPivotTables(details.items);
  3570. }, processPivotTables:function(items) {
  3571. var rels = this.getRelationships(), length = items.length, i, item;
  3572. for (i = 0; i < length; i++) {
  3573. item = items[i];
  3574. rels.addRelationship(item.getRelationship());
  3575. item.setWorksheet(this);
  3576. }
  3577. this.updateItemIndexes(this.getPivotTables());
  3578. }, onPivotTableRemove:function(collection, details) {
  3579. var rels = this.getRelationships(), length = details.items.length, i, item;
  3580. for (i = 0; i < length; i++) {
  3581. item = details.items[i];
  3582. rels.removeRelationship(item.getRelationship());
  3583. Ext.destroy(item);
  3584. }
  3585. }, addColumn:function(config) {
  3586. if (!this._columns) {
  3587. this.setColumns([]);
  3588. }
  3589. return this._columns.add(config || {});
  3590. }, addRow:function(config) {
  3591. if (!this._rows) {
  3592. this.setRows([]);
  3593. }
  3594. return this._rows.add(config || {});
  3595. }, getRow:function(id) {
  3596. return this._rows ? this._rows.get(id) : null;
  3597. }, addPivotTable:function(config) {
  3598. if (!this._pivotTables) {
  3599. this.setPivotTables([]);
  3600. }
  3601. return this._pivotTables.add(config || {});
  3602. }, getPivotTable:function(id) {
  3603. return this._pivotTables ? this._pivotTables.get(id) : null;
  3604. }, beginRowRendering:function() {
  3605. var me = this;
  3606. me.tempRows = [];
  3607. me.tempMergeCells = [];
  3608. me.startCaching = true;
  3609. me.setMergedCellsNo(0);
  3610. me.lastRowIndex = 1;
  3611. me.cachedIndex = 0;
  3612. if (!me.cachedRow) {
  3613. me.cachedRow = new Ext.exporter.file.ooxml.excel.Row({worksheet:me});
  3614. me.cachedRowConfig = me.cachedRow.getConfig();
  3615. me.cachedRowConfig.id = me.cachedRowConfig.cells = null;
  3616. }
  3617. }, endRowRendering:function() {
  3618. var me = this;
  3619. me.setCachedRows(me.tempRows.join(''));
  3620. me.setCachedMergeCells(me.tempMergeCells.join(''));
  3621. me.tempRows = me.tempMergeCells = null;
  3622. me.startCaching = false;
  3623. me.lastRowIndex = 1;
  3624. }, renderRows:function(rows) {
  3625. var items = Ext.Array.from(rows), len = items.length, i;
  3626. for (i = 0; i < len; i++) {
  3627. this.renderRow(items[i]);
  3628. }
  3629. }, renderRow:function(row) {
  3630. var me = this, config, len, i, cache, index, cells, ret;
  3631. if (!me.startCaching) {
  3632. me.beginRowRendering();
  3633. }
  3634. cache = me.cachedRow;
  3635. if (Ext.isArray(row)) {
  3636. cells = row;
  3637. config = {};
  3638. } else {
  3639. config = row;
  3640. cells = Ext.Array.from(config.cells || []);
  3641. }
  3642. delete config.cells;
  3643. Ext.applyIf(config, me.cachedRowConfig);
  3644. cache.setCollapsed(config.collapsed);
  3645. cache.setHidden(config.hidden);
  3646. cache.setHeight(config.height);
  3647. cache.setOutlineLevel(config.outlineLevel);
  3648. cache.setShowPhonetic(config.showPhonetic);
  3649. cache.setStyleId(config.styleId);
  3650. cache.setIndex(config.index);
  3651. index = cache.getIndex();
  3652. if (!index) {
  3653. cache.setIndex(me.lastRowIndex++);
  3654. } else {
  3655. me.lastRowIndex = Math.max(me.lastRowIndex, index) + 1;
  3656. }
  3657. ret = cache.renderCells(cells);
  3658. me.tempRows.push(ret.row);
  3659. if (me.cachedIndex === 0) {
  3660. me._topLeftRef = ret.first;
  3661. }
  3662. me._bottomRightRef = ret.last;
  3663. me.tempMergeCells.push(ret.merged);
  3664. me.cachedIndex++;
  3665. ret.rowIndex = cache.getIndex();
  3666. return ret;
  3667. }});
  3668. Ext.define('Ext.exporter.file.ooxml.excel.Font', {extend:'Ext.exporter.file.ooxml.Base', config:{size:10, fontName:'', family:null, charset:null, bold:false, italic:false, underline:false, outline:false, strikeThrough:false, color:null, verticalAlign:null}, mappings:{family:{Automatic:0, Roman:1, Swiss:2, Modern:3, Script:4, Decorative:5}}, tpl:['\x3cfont\x3e', '\x3ctpl if\x3d"size"\x3e\x3csz val\x3d"{size}"/\x3e\x3c/tpl\x3e', '\x3ctpl if\x3d"fontName"\x3e\x3cname val\x3d"{fontName}"/\x3e\x3c/tpl\x3e',
  3669. '\x3ctpl if\x3d"family"\x3e\x3cfamily val\x3d"{family}"/\x3e\x3c/tpl\x3e', '\x3ctpl if\x3d"charset"\x3e\x3ccharset val\x3d"{charset}"/\x3e\x3c/tpl\x3e', '\x3ctpl if\x3d"bold"\x3e\x3cb/\x3e\x3c/tpl\x3e', '\x3ctpl if\x3d"italic"\x3e\x3ci/\x3e\x3c/tpl\x3e', '\x3ctpl if\x3d"underline"\x3e\x3cu/\x3e\x3c/tpl\x3e', '\x3ctpl if\x3d"outline"\x3e\x3coutline/\x3e\x3c/tpl\x3e', '\x3ctpl if\x3d"strikeThrough"\x3e\x3cstrike/\x3e\x3c/tpl\x3e', '\x3ctpl if\x3d"color"\x3e\x3ccolor rgb\x3d"{color}"/\x3e\x3c/tpl\x3e',
  3670. '\x3ctpl if\x3d"verticalAlign"\x3e\x3cvertAlign val\x3d"{verticalAlign}"/\x3e\x3c/tpl\x3e', '\x3c/font\x3e'], autoGenerateKey:['size', 'fontName', 'family', 'charset', 'bold', 'italic', 'underline', 'outline', 'strikeThrough', 'color', 'verticalAlign'], constructor:function(config) {
  3671. var cfg = {}, keys = Ext.Object.getKeys(config || {}), len = keys.length, i;
  3672. if (config) {
  3673. for (i = 0; i < len; i++) {
  3674. cfg[Ext.String.uncapitalize(keys[i])] = config[keys[i]];
  3675. }
  3676. }
  3677. this.callParent([cfg]);
  3678. }, applyFamily:function(value) {
  3679. if (typeof value === 'string') {
  3680. return this.mappings.family[value];
  3681. }
  3682. return value;
  3683. }, applyBold:function(value) {
  3684. return !!value;
  3685. }, applyItalic:function(value) {
  3686. return !!value;
  3687. }, applyStrikeThrough:function(value) {
  3688. return !!value;
  3689. }, applyUnderline:function(value) {
  3690. return !!value;
  3691. }, applyOutline:function(value) {
  3692. return !!value;
  3693. }, applyColor:function(value) {
  3694. var v;
  3695. if (!value) {
  3696. return value;
  3697. }
  3698. v = String(value);
  3699. return v.indexOf('#') >= 0 ? v.replace('#', '') : v;
  3700. }, applyVerticalAlign:function(value) {
  3701. return Ext.util.Format.lowercase(value);
  3702. }});
  3703. Ext.define('Ext.exporter.file.ooxml.excel.NumberFormat', {extend:'Ext.exporter.file.ooxml.Base', config:{isDate:false, numFmtId:null, formatCode:''}, tpl:['\x3cnumFmt numFmtId\x3d"{numFmtId}" formatCode\x3d"{formatCode:htmlEncode}"/\x3e'], spaceRe:/(,| )/g, getRenderData:function() {
  3704. var data = this.callParent(), fmt = data.formatCode;
  3705. fmt = fmt && data.isDate ? fmt.replace(this.spaceRe, '\\$1') : fmt;
  3706. data.formatCode = fmt;
  3707. return data;
  3708. }, getKey:function() {
  3709. return this.getFormatCode();
  3710. }});
  3711. Ext.define('Ext.exporter.file.ooxml.excel.Fill', {extend:'Ext.exporter.file.ooxml.Base', requires:['Ext.util.Format'], config:{patternType:'none', fgColor:null, bgColor:null}, tpl:['\x3cfill\x3e', '\x3ctpl if\x3d"fgColor || bgColor"\x3e', '\x3cpatternFill patternType\x3d"{patternType}"\x3e', '\x3ctpl if\x3d"fgColor"\x3e\x3cfgColor rgb\x3d"{fgColor}"\x3e\x3c/fgColor\x3e\x3c/tpl\x3e', '\x3ctpl if\x3d"bgColor"\x3e\x3cbgColor rgb\x3d"{bgColor}"\x3e\x3c/bgColor\x3e\x3c/tpl\x3e', '\x3c/patternFill\x3e',
  3712. '\x3ctpl else\x3e', '\x3cpatternFill patternType\x3d"{patternType}"/\x3e', '\x3c/tpl\x3e', '\x3c/fill\x3e'], autoGenerateKey:['patternType', 'fgColor', 'bgColor'], constructor:function(config) {
  3713. var cfg = {};
  3714. if (config) {
  3715. cfg.id = config.id;
  3716. cfg.bgColor = config.Color || null;
  3717. cfg.patternType = config.Pattern || null;
  3718. }
  3719. this.callParent([cfg]);
  3720. }, formatColor:function(value) {
  3721. var v;
  3722. if (!value) {
  3723. return value;
  3724. }
  3725. v = String(value);
  3726. return v.indexOf('#') >= 0 ? v.replace('#', '') : v;
  3727. }, applyFgColor:function(value) {
  3728. return this.formatColor(value);
  3729. }, applyBgColor:function(value) {
  3730. return this.formatColor(value);
  3731. }, applyPatternType:function(value) {
  3732. var possible = ['none', 'solid', 'mediumGray', 'darkGray', 'lightGray', 'darkHorizontal', 'darkVertical', 'darkDown', 'darkUp', 'darkGrid', 'darkTrellis', 'lightHorizontal', 'lightVertical', 'lightDown', 'lightUp', 'lightGrid', 'lightTrellis', 'gray125', 'gray0625'], v = Ext.util.Format.uncapitalize(value);
  3733. return Ext.Array.indexOf(possible, v) >= 0 ? v : 'none';
  3734. }});
  3735. Ext.define('Ext.exporter.file.ooxml.excel.BorderPr', {extend:'Ext.exporter.file.ooxml.Base', isBorderPr:true, config:{tag:'left', color:null, lineStyle:'none'}, mappings:{lineStyle:{'None':'none', 'Continuous':'thin', 'Dash':'dashed', 'Dot':'dotted', 'DashDot':'dashDot', 'DashDotDot':'dashDotDot', 'SlantDashDot':'slantDashDot', 'Double':'double'}}, tpl:['\x3ctpl if\x3d"color"\x3e', '\x3c{tag} style\x3d"{lineStyle}"\x3e\x3ccolor rgb\x3d"{color}"/\x3e\x3c/{tag}\x3e', '\x3ctpl else\x3e', '\x3c{tag} style\x3d"{lineStyle}"/\x3e',
  3736. '\x3c/tpl\x3e'], autoGenerateKey:['tag', 'color', 'lineStyle'], applyColor:function(value) {
  3737. var v;
  3738. if (!value) {
  3739. return value;
  3740. }
  3741. v = String(value);
  3742. return v.indexOf('#') >= 0 ? v.replace('#', '') : v;
  3743. }, applyLineStyle:function(value) {
  3744. var possible = ['none', 'thin', 'medium', 'dashed', 'dotted', 'thick', 'double', 'hair', 'mediumDashed', 'dashDot', 'mediumDashDot', 'dashDotDot', 'mediumDashDotDot', 'slantDashDot'];
  3745. return Ext.Array.indexOf(possible, value) >= 0 ? value : this.mappings.lineStyle[value] || 'none';
  3746. }});
  3747. Ext.define('Ext.exporter.file.ooxml.excel.Border', {extend:'Ext.exporter.file.ooxml.Base', requires:['Ext.exporter.file.ooxml.excel.BorderPr'], config:{left:null, right:null, top:null, bottom:null}, tpl:['\x3cborder\x3e', '\x3ctpl if\x3d"left"\x3e{[values.left.render()]}\x3c/tpl\x3e', '\x3ctpl if\x3d"right"\x3e{[values.right.render()]}\x3c/tpl\x3e', '\x3ctpl if\x3d"top"\x3e{[values.top.render()]}\x3c/tpl\x3e', '\x3ctpl if\x3d"bottom"\x3e{[values.bottom.render()]}\x3c/tpl\x3e', '\x3c/border\x3e'],
  3748. autoGenerateKey:['left', 'right', 'top', 'bottom'], destroy:function() {
  3749. this.setConfig({left:null, right:null, top:null, bottom:null});
  3750. this.callParent();
  3751. }, applyLeft:function(border) {
  3752. if (border && !border.isBorderPr) {
  3753. return new Ext.exporter.file.ooxml.excel.BorderPr(border);
  3754. }
  3755. return border;
  3756. }, applyTop:function(border) {
  3757. if (border && !border.isBorderPr) {
  3758. return new Ext.exporter.file.ooxml.excel.BorderPr(border);
  3759. }
  3760. return border;
  3761. }, applyRight:function(border) {
  3762. if (border && !border.isBorderPr) {
  3763. return new Ext.exporter.file.ooxml.excel.BorderPr(border);
  3764. }
  3765. return border;
  3766. }, applyBottom:function(border) {
  3767. if (border && !border.isBorderPr) {
  3768. return new Ext.exporter.file.ooxml.excel.BorderPr(border);
  3769. }
  3770. return border;
  3771. }, updateLeft:function(border, oldData) {
  3772. Ext.destroy(oldData);
  3773. if (border) {
  3774. border.setTag('left');
  3775. }
  3776. }, updateTop:function(border, oldData) {
  3777. Ext.destroy(oldData);
  3778. if (border) {
  3779. border.setTag('top');
  3780. }
  3781. }, updateRight:function(border, oldData) {
  3782. Ext.destroy(oldData);
  3783. if (border) {
  3784. border.setTag('right');
  3785. }
  3786. }, updateBottom:function(border, oldData) {
  3787. Ext.destroy(oldData);
  3788. if (border) {
  3789. border.setTag('bottom');
  3790. }
  3791. }});
  3792. Ext.define('Ext.exporter.file.ooxml.excel.CellAlignment', {extend:'Ext.exporter.file.ooxml.Base', isCellAlignment:true, config:{horizontal:'general', vertical:'top', rotate:null, wrapText:false, indent:null, relativeIndent:null, justifyLastLine:false, shrinkToFit:false, readingOrder:null}, autoGenerateKey:['horizontal', 'vertical', 'rotate', 'wrapText', 'indent', 'relativeIndent', 'justifyLastLine', 'shrinkToFit', 'readingOrder'], mappings:{horizontal:{Automatic:'general', CenterAcrossSelection:'centerContinuous',
  3793. JustifyDistributed:'distributed'}, vertical:{Automatic:'top', JustifyDistributed:'distributed'}, readingOrder:{Context:0, LeftToRight:1, RightToLeft:2}}, tpl:['\x3calignment', '\x3ctpl if\x3d"horizontal"\x3e horizontal\x3d"{horizontal}"\x3c/tpl\x3e', '\x3ctpl if\x3d"vertical"\x3e vertical\x3d"{vertical}"\x3c/tpl\x3e', '\x3ctpl if\x3d"rotate"\x3e textRotation\x3d"{rotate}"\x3c/tpl\x3e', '\x3ctpl if\x3d"wrapText"\x3e wrapText\x3d"{wrapText}"\x3c/tpl\x3e', '\x3ctpl if\x3d"indent"\x3e indent\x3d"{indent}"\x3c/tpl\x3e',
  3794. '\x3ctpl if\x3d"relativeIndent"\x3e relativeIndent\x3d"{relativeIndent}"\x3c/tpl\x3e', '\x3ctpl if\x3d"justifyLastLine"\x3e justifyLastLine\x3d"{justifyLastLine}"\x3c/tpl\x3e', '\x3ctpl if\x3d"shrinkToFit"\x3e shrinkToFit\x3d"{shrinkToFit}"\x3c/tpl\x3e', '\x3ctpl if\x3d"readingOrder"\x3e readingOrder\x3d"{readingOrder}"\x3c/tpl\x3e', '/\x3e'], constructor:function(config) {
  3795. var cfg = {}, keys = Ext.Object.getKeys(config || {}), len = keys.length, i;
  3796. if (config) {
  3797. for (i = 0; i < len; i++) {
  3798. cfg[Ext.String.uncapitalize(keys[i])] = config[keys[i]];
  3799. }
  3800. }
  3801. this.callParent([cfg]);
  3802. }, applyHorizontal:function(value) {
  3803. var possible = ['general', 'left', 'center', 'right', 'fill', 'justify', 'centerContinuous', 'distributed'], v = Ext.util.Format.uncapitalize(value);
  3804. return Ext.Array.indexOf(possible, v) >= 0 ? v : this.mappings.horizontal[value] || 'general';
  3805. }, applyVertical:function(value) {
  3806. var possible = ['top', 'center', 'bottom', 'justify', 'distributed'], v = Ext.util.Format.uncapitalize(value);
  3807. return Ext.Array.indexOf(possible, v) >= 0 ? v : this.mappings.vertical[value] || 'top';
  3808. }, applyReadingOrder:function(value) {
  3809. if (typeof value === 'string') {
  3810. return this.mappings.readingOrder[value] || 0;
  3811. }
  3812. return value;
  3813. }});
  3814. Ext.define('Ext.exporter.file.ooxml.excel.CellStyleXf', {extend:'Ext.exporter.file.ooxml.Base', requires:['Ext.exporter.file.ooxml.excel.CellAlignment'], config:{numFmtId:0, fontId:0, fillId:0, borderId:0, alignment:null}, autoGenerateKey:['numFmtId', 'fontId', 'fillId', 'borderId', 'alignment'], tpl:['\x3cxf numFmtId\x3d"{numFmtId}" fontId\x3d"{fontId}" fillId\x3d"{fillId}" borderId\x3d"{borderId}"', '\x3ctpl if\x3d"numFmtId"\x3e applyNumberFormat\x3d"1"\x3c/tpl\x3e', '\x3ctpl if\x3d"fillId"\x3e applyFill\x3d"1"\x3c/tpl\x3e',
  3815. '\x3ctpl if\x3d"borderId"\x3e applyBorder\x3d"1"\x3c/tpl\x3e', '\x3ctpl if\x3d"fontId"\x3e applyFont\x3d"1"\x3c/tpl\x3e', '\x3ctpl if\x3d"alignment"\x3e', ' applyAlignment\x3d"1"\x3e{[values.alignment.render()]}\x3c/xf\x3e', '\x3ctpl else\x3e', '/\x3e', '\x3c/tpl\x3e'], applyAlignment:function(align) {
  3816. if (align && !align.isCellAlignment) {
  3817. return new Ext.exporter.file.ooxml.excel.CellAlignment(align);
  3818. }
  3819. return align;
  3820. }});
  3821. Ext.define('Ext.exporter.file.ooxml.excel.CellXf', {extend:'Ext.exporter.file.ooxml.excel.CellStyleXf', config:{xfId:0}, tpl:['\x3cxf numFmtId\x3d"{numFmtId}" fontId\x3d"{fontId}" fillId\x3d"{fillId}" borderId\x3d"{borderId}" xfId\x3d"{xfId}"', '\x3ctpl if\x3d"numFmtId"\x3e applyNumberFormat\x3d"1"\x3c/tpl\x3e', '\x3ctpl if\x3d"fillId"\x3e applyFill\x3d"1"\x3c/tpl\x3e', '\x3ctpl if\x3d"borderId"\x3e applyBorder\x3d"1"\x3c/tpl\x3e', '\x3ctpl if\x3d"fontId"\x3e applyFont\x3d"1"\x3c/tpl\x3e', '\x3ctpl if\x3d"alignment"\x3e',
  3822. ' applyAlignment\x3d"1"\x3e{[values.alignment.render()]}\x3c/xf\x3e', '\x3ctpl else\x3e', '/\x3e', '\x3c/tpl\x3e'], autoGenerateKey:['xfId']});
  3823. Ext.define('Ext.exporter.file.ooxml.excel.Stylesheet', {extend:'Ext.exporter.file.ooxml.Xml', requires:['Ext.exporter.file.Style', 'Ext.exporter.file.ooxml.excel.Font', 'Ext.exporter.file.ooxml.excel.NumberFormat', 'Ext.exporter.file.ooxml.excel.Fill', 'Ext.exporter.file.ooxml.excel.Border', 'Ext.exporter.file.ooxml.excel.CellXf'], isStylesheet:true, config:{fonts:[{fontName:'Arial', size:10, family:2}], numberFormats:null, fills:[{patternType:'none'}], borders:[{left:{}, top:{}, right:{}, bottom:{}}],
  3824. cellStyleXfs:[{}], cellXfs:[{}]}, contentType:{contentType:'application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml'}, relationship:{schema:'http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles'}, folder:'/xl/', fileName:'styles', tpl:['\x3c?xml version\x3d"1.0" encoding\x3d"UTF-8" standalone\x3d"yes"?\x3e', '\x3cstyleSheet xmlns\x3d"http://schemas.openxmlformats.org/spreadsheetml/2006/main"\x3e', '\x3ctpl if\x3d"numberFormats"\x3e\x3cnumFmts count\x3d"{numberFormats.length}"\x3e\x3ctpl for\x3d"numberFormats.items"\x3e{[values.render()]}\x3c/tpl\x3e\x3c/numFmts\x3e\x3c/tpl\x3e',
  3825. '\x3ctpl if\x3d"fonts"\x3e\x3cfonts count\x3d"{fonts.length}"\x3e\x3ctpl for\x3d"fonts.items"\x3e{[values.render()]}\x3c/tpl\x3e\x3c/fonts\x3e\x3c/tpl\x3e', '\x3ctpl if\x3d"fills"\x3e\x3cfills count\x3d"{fills.length}"\x3e\x3ctpl for\x3d"fills.items"\x3e{[values.render()]}\x3c/tpl\x3e\x3c/fills\x3e\x3c/tpl\x3e', '\x3ctpl if\x3d"borders"\x3e\x3cborders count\x3d"{borders.length}"\x3e\x3ctpl for\x3d"borders.items"\x3e{[values.render()]}\x3c/tpl\x3e\x3c/borders\x3e\x3c/tpl\x3e', '\x3ctpl if\x3d"cellStyleXfs"\x3e\x3ccellStyleXfs count\x3d"{cellStyleXfs.length}"\x3e\x3ctpl for\x3d"cellStyleXfs.items"\x3e{[values.render()]}\x3c/tpl\x3e\x3c/cellStyleXfs\x3e\x3c/tpl\x3e',
  3826. '\x3ctpl if\x3d"cellXfs"\x3e\x3ccellXfs count\x3d"{cellXfs.length}"\x3e\x3ctpl for\x3d"cellXfs.items"\x3e{[values.render()]}\x3c/tpl\x3e\x3c/cellXfs\x3e\x3c/tpl\x3e', '\x3ctableStyles count\x3d"0" defaultTableStyle\x3d"TableStyleMedium9" defaultPivotStyle\x3d"PivotStyleMedium7"/\x3e', '\x3c/styleSheet\x3e'], lastNumberFormatId:164, datePatterns:{'General Date':'[$-F800]dddd, mmmm dd, yyyy', 'Long Date':'[$-F800]dddd, mmmm dd, yyyy', 'Medium Date':'mm/dd/yy;@', 'Short Date':'m/d/yy;@', 'Long Time':'h:mm:ss;@',
  3827. 'Medium Time':'[$-409]h:mm AM/PM;@', 'Short Time':'h:mm;@'}, numberPatterns:{'General Number':1, 'Fixed':2, 'Standard':2, 'Percent':10, 'Scientific':11, 'Currency':'"$"#,##0.00', 'Euro Currency':'"€"#,##0.00'}, booleanPatterns:{'Yes/No':'"Yes";-;"No"', 'True/False':'"True";-;"False"', 'On/Off':'"On";-;"Off"'}, applyFonts:function(data, dataCollection) {
  3828. return this.checkCollection(data, dataCollection, 'Ext.exporter.file.ooxml.excel.Font');
  3829. }, applyNumberFormats:function(data, dataCollection) {
  3830. return this.checkCollection(data, dataCollection, 'Ext.exporter.file.ooxml.excel.NumberFormat');
  3831. }, applyFills:function(data, dataCollection) {
  3832. return this.checkCollection(data, dataCollection, 'Ext.exporter.file.ooxml.excel.Fill');
  3833. }, applyBorders:function(data, dataCollection) {
  3834. return this.checkCollection(data, dataCollection, 'Ext.exporter.file.ooxml.excel.Border');
  3835. }, applyCellXfs:function(data, dataCollection) {
  3836. return this.checkCollection(data, dataCollection, 'Ext.exporter.file.ooxml.excel.CellXf');
  3837. }, applyCellStyleXfs:function(data, dataCollection) {
  3838. return this.checkCollection(data, dataCollection, 'Ext.exporter.file.ooxml.excel.CellStyleXf');
  3839. }, addFont:function(config) {
  3840. var col = this._fonts, ret, font;
  3841. if (!col) {
  3842. this.setFonts([]);
  3843. col = this._fonts;
  3844. }
  3845. font = new Ext.exporter.file.ooxml.excel.Font(config);
  3846. ret = col.indexOfKey(font.getKey());
  3847. if (ret >= 0) {
  3848. font.destroy();
  3849. } else {
  3850. col.add(font);
  3851. ret = col.indexOf(font);
  3852. }
  3853. return ret;
  3854. }, addNumberFormat:function(config) {
  3855. var col = this._numberFormats, ret, temp;
  3856. if (!col) {
  3857. this.setNumberFormats([]);
  3858. col = this._numberFormats;
  3859. }
  3860. temp = new Ext.exporter.file.ooxml.excel.NumberFormat(config);
  3861. ret = col.get(temp.getKey());
  3862. if (!ret) {
  3863. ret = temp;
  3864. col.add(ret);
  3865. ret.setNumFmtId(this.lastNumberFormatId++);
  3866. }
  3867. return ret.getNumFmtId();
  3868. }, addFill:function(config) {
  3869. var col = this._fills, ret, fill;
  3870. if (!col) {
  3871. this.setFills([]);
  3872. col = this._fills;
  3873. }
  3874. fill = new Ext.exporter.file.ooxml.excel.Font(config);
  3875. ret = col.indexOfKey(fill.getKey());
  3876. if (ret >= 0) {
  3877. fill.destroy();
  3878. } else {
  3879. col.add(fill);
  3880. ret = col.indexOf(fill);
  3881. }
  3882. return ret;
  3883. }, addBorder:function(config) {
  3884. var col = this._borders, ret, border;
  3885. if (!col) {
  3886. this.setBorders([]);
  3887. col = this._borders;
  3888. }
  3889. border = new Ext.exporter.file.ooxml.excel.Border(config);
  3890. ret = col.indexOfKey(border.getKey());
  3891. if (ret >= 0) {
  3892. border.destroy();
  3893. } else {
  3894. col.add(border);
  3895. ret = col.indexOf(border);
  3896. }
  3897. return ret;
  3898. }, addCellXf:function(config) {
  3899. var col = this._cellXfs, ret, style;
  3900. if (!col) {
  3901. this.setCellXfs([]);
  3902. col = this._cellXfs;
  3903. }
  3904. style = new Ext.exporter.file.ooxml.excel.CellXf(config);
  3905. ret = col.indexOfKey(style.getKey());
  3906. if (ret >= 0) {
  3907. style.destroy();
  3908. } else {
  3909. col.add(style);
  3910. ret = col.indexOf(style);
  3911. }
  3912. return ret;
  3913. }, addCellStyleXf:function(config) {
  3914. var col = this._cellStyleXfs, ret, style;
  3915. if (!col) {
  3916. this.setCellStyleXfs([]);
  3917. col = this._cellStyleXfs;
  3918. }
  3919. style = new Ext.exporter.file.ooxml.excel.CellStyleXf(config);
  3920. ret = col.indexOfKey(style.getKey());
  3921. if (ret >= 0) {
  3922. style.destroy();
  3923. } else {
  3924. col.add(style);
  3925. ret = col.indexOf(style);
  3926. }
  3927. return ret;
  3928. }, getStyleParams:function(style) {
  3929. var me = this, s = style && style.isStyle ? style : new Ext.exporter.file.Style(style), cfg = s.getConfig(), numFmtId = 0, fontId = 0, fillId = 0, borderId = 0, xfId = 0;
  3930. cfg.parentId = style ? style.parentId : null;
  3931. if (cfg.font) {
  3932. fontId = me.addFont(cfg.font);
  3933. }
  3934. if (cfg.format) {
  3935. numFmtId = me.getNumberFormatId(cfg.format);
  3936. }
  3937. if (cfg.interior) {
  3938. fillId = me.addFill(cfg.interior);
  3939. }
  3940. if (cfg.borders) {
  3941. borderId = me.getBorderId(cfg.borders);
  3942. }
  3943. if (cfg.parentId) {
  3944. xfId = cfg.parentId;
  3945. }
  3946. return {numFmtId:numFmtId, fontId:fontId, fillId:fillId, borderId:borderId, xfId:xfId, alignment:cfg.alignment || null};
  3947. }, addStyle:function(style) {
  3948. return this.addCellStyleXf(this.getStyleParams(style));
  3949. }, addCellStyle:function(style, parentStyleId) {
  3950. var styles = this.getCellXfs(), parentStyle, newStyle, ret;
  3951. if (styles) {
  3952. parentStyle = styles.getAt(parentStyleId);
  3953. if (parentStyle) {
  3954. newStyle = parentStyle.getConfig();
  3955. }
  3956. }
  3957. return this.addCellXf(Ext.merge(newStyle || {}, this.getStyleParams(style)));
  3958. }, getNumberFormatId:function(f) {
  3959. var me = this, isDate = !!me.datePatterns[f], id, code;
  3960. if (f === 'General') {
  3961. return 0;
  3962. }
  3963. code = me.datePatterns[f] || me.booleanPatterns[f] || me.numberPatterns[f];
  3964. if (Ext.isNumeric(code)) {
  3965. id = code;
  3966. } else {
  3967. if (!code) {
  3968. code = f;
  3969. }
  3970. }
  3971. return id || me.addNumberFormat({isDate:isDate, formatCode:code});
  3972. }, getBorderId:function(borders) {
  3973. var cfg = {}, len = borders.length, i, b, key;
  3974. for (i = 0; i < len; i++) {
  3975. b = borders[i];
  3976. key = Ext.util.Format.lowercase(b.position);
  3977. delete b.position;
  3978. cfg[key] = b;
  3979. }
  3980. return this.addBorder(cfg);
  3981. }});
  3982. Ext.define('Ext.exporter.file.ooxml.excel.SharedStrings', {extend:'Ext.exporter.file.ooxml.Xml', isSharedStrings:true, config:{strings:[]}, contentType:{contentType:'application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml'}, relationship:{schema:'http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings'}, folder:'/xl/', fileName:'sharedStrings', tpl:['\x3c?xml version\x3d"1.0" encoding\x3d"UTF-8" standalone\x3d"yes"?\x3e', '\x3csst xmlns\x3d"http://schemas.openxmlformats.org/spreadsheetml/2006/main" count\x3d"{strings.length}" uniqueCount\x3d"{strings.length}"\x3e',
  3983. '\x3ctpl for\x3d"strings.getRange()"\x3e\x3csi\x3e\x3ct\x3e{.:this.utf8}\x3c/t\x3e\x3c/si\x3e\x3c/tpl\x3e', '\x3c/sst\x3e', {utf8:function(v) {
  3984. return Ext.util.Base64._utf8_encode(v);
  3985. }}], destroy:function() {
  3986. this.setStrings(null);
  3987. this.callParent();
  3988. }, applyStrings:function(data, dataCollection) {
  3989. var col;
  3990. if (data) {
  3991. col = new Ext.util.Collection({keyFn:Ext.identityFn});
  3992. col.add(data);
  3993. }
  3994. Ext.destroy(dataCollection);
  3995. return col;
  3996. }, addString:function(value) {
  3997. var v = Ext.util.Format.htmlEncode(value), s = this.getStrings(), index;
  3998. if (!s) {
  3999. this.setStrings([]);
  4000. s = this.getStrings();
  4001. }
  4002. index = s.indexOfKey(v);
  4003. if (index < 0) {
  4004. s.add(v);
  4005. index = s.length - 1;
  4006. }
  4007. return index;
  4008. }});
  4009. Ext.define('Ext.exporter.file.ooxml.theme.Base', {extend:'Ext.exporter.file.ooxml.XmlRels', alias:'ooxmltheme.base', mixins:['Ext.mixin.Factoryable'], folder:'/theme/', fileName:'theme', contentType:{contentType:'application/vnd.openxmlformats-officedocument.theme+xml'}, relationship:{schema:'http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme'}});
  4010. Ext.define('Ext.exporter.file.ooxml.theme.Office', {extend:'Ext.exporter.file.ooxml.theme.Base', alias:'ooxmltheme.office', tpl:['\x3c?xml version\x3d"1.0" encoding\x3d"UTF-8" standalone\x3d"yes"?\x3e', '\x3ca:theme xmlns:a\x3d"http://schemas.openxmlformats.org/drawingml/2006/main" name\x3d"Office Theme"\x3e', '\x3ca:themeElements\x3e', '\x3ca:clrScheme name\x3d"Office"\x3e', '\x3ca:dk1\x3e', '\x3ca:sysClr val\x3d"windowText" lastClr\x3d"000000"/\x3e', '\x3c/a:dk1\x3e', '\x3ca:lt1\x3e', '\x3ca:sysClr val\x3d"window" lastClr\x3d"FFFFFF"/\x3e',
  4011. '\x3c/a:lt1\x3e', '\x3ca:dk2\x3e', '\x3ca:srgbClr val\x3d"44546A"/\x3e', '\x3c/a:dk2\x3e', '\x3ca:lt2\x3e', '\x3ca:srgbClr val\x3d"E7E6E6"/\x3e', '\x3c/a:lt2\x3e', '\x3ca:accent1\x3e', '\x3ca:srgbClr val\x3d"4472C4"/\x3e', '\x3c/a:accent1\x3e', '\x3ca:accent2\x3e', '\x3ca:srgbClr val\x3d"ED7D31"/\x3e', '\x3c/a:accent2\x3e', '\x3ca:accent3\x3e', '\x3ca:srgbClr val\x3d"A5A5A5"/\x3e', '\x3c/a:accent3\x3e', '\x3ca:accent4\x3e', '\x3ca:srgbClr val\x3d"FFC000"/\x3e', '\x3c/a:accent4\x3e', '\x3ca:accent5\x3e',
  4012. '\x3ca:srgbClr val\x3d"5B9BD5"/\x3e', '\x3c/a:accent5\x3e', '\x3ca:accent6\x3e', '\x3ca:srgbClr val\x3d"70AD47"/\x3e', '\x3c/a:accent6\x3e', '\x3ca:hlink\x3e', '\x3ca:srgbClr val\x3d"0563C1"/\x3e', '\x3c/a:hlink\x3e', '\x3ca:folHlink\x3e', '\x3ca:srgbClr val\x3d"954F72"/\x3e', '\x3c/a:folHlink\x3e', '\x3c/a:clrScheme\x3e', '\x3ca:fontScheme name\x3d"Office"\x3e', '\x3ca:majorFont\x3e', '\x3ca:latin typeface\x3d"Calibri Light" panose\x3d"020F0302020204030204"/\x3e', '\x3ca:ea typeface\x3d""/\x3e',
  4013. '\x3ca:cs typeface\x3d""/\x3e', '\x3ca:font script\x3d"Jpan" typeface\x3d"Yu Gothic Light"/\x3e', '\x3ca:font script\x3d"Hang" typeface\x3d"{[this.utf8(\'맑은 고딕\')]}"/\x3e', '\x3ca:font script\x3d"Hans" typeface\x3d"DengXian Light"/\x3e', '\x3ca:font script\x3d"Hant" typeface\x3d"{[this.utf8(\'新細明體\')]}"/\x3e', '\x3ca:font script\x3d"Arab" typeface\x3d"Times New Roman"/\x3e', '\x3ca:font script\x3d"Hebr" typeface\x3d"Times New Roman"/\x3e', '\x3ca:font script\x3d"Thai" typeface\x3d"Tahoma"/\x3e',
  4014. '\x3ca:font script\x3d"Ethi" typeface\x3d"Nyala"/\x3e', '\x3ca:font script\x3d"Beng" typeface\x3d"Vrinda"/\x3e', '\x3ca:font script\x3d"Gujr" typeface\x3d"Shruti"/\x3e', '\x3ca:font script\x3d"Khmr" typeface\x3d"MoolBoran"/\x3e', '\x3ca:font script\x3d"Knda" typeface\x3d"Tunga"/\x3e', '\x3ca:font script\x3d"Guru" typeface\x3d"Raavi"/\x3e', '\x3ca:font script\x3d"Cans" typeface\x3d"Euphemia"/\x3e', '\x3ca:font script\x3d"Cher" typeface\x3d"Plantagenet Cherokee"/\x3e', '\x3ca:font script\x3d"Yiii" typeface\x3d"Microsoft Yi Baiti"/\x3e',
  4015. '\x3ca:font script\x3d"Tibt" typeface\x3d"Microsoft Himalaya"/\x3e', '\x3ca:font script\x3d"Thaa" typeface\x3d"MV Boli"/\x3e', '\x3ca:font script\x3d"Deva" typeface\x3d"Mangal"/\x3e', '\x3ca:font script\x3d"Telu" typeface\x3d"Gautami"/\x3e', '\x3ca:font script\x3d"Taml" typeface\x3d"Latha"/\x3e', '\x3ca:font script\x3d"Syrc" typeface\x3d"Estrangelo Edessa"/\x3e', '\x3ca:font script\x3d"Orya" typeface\x3d"Kalinga"/\x3e', '\x3ca:font script\x3d"Mlym" typeface\x3d"Kartika"/\x3e', '\x3ca:font script\x3d"Laoo" typeface\x3d"DokChampa"/\x3e',
  4016. '\x3ca:font script\x3d"Sinh" typeface\x3d"Iskoola Pota"/\x3e', '\x3ca:font script\x3d"Mong" typeface\x3d"Mongolian Baiti"/\x3e', '\x3ca:font script\x3d"Viet" typeface\x3d"Times New Roman"/\x3e', '\x3ca:font script\x3d"Uigh" typeface\x3d"Microsoft Uighur"/\x3e', '\x3ca:font script\x3d"Geor" typeface\x3d"Sylfaen"/\x3e', '\x3c/a:majorFont\x3e', '\x3ca:minorFont\x3e', '\x3ca:latin typeface\x3d"Calibri" panose\x3d"020F0502020204030204"/\x3e', '\x3ca:ea typeface\x3d""/\x3e', '\x3ca:cs typeface\x3d""/\x3e',
  4017. '\x3ca:font script\x3d"Jpan" typeface\x3d"Yu Gothic"/\x3e', '\x3ca:font script\x3d"Hang" typeface\x3d"{[this.utf8(\'맑은 고딕\')]}"/\x3e', '\x3ca:font script\x3d"Hans" typeface\x3d"DengXian"/\x3e', '\x3ca:font script\x3d"Hant" typeface\x3d"{[this.utf8(\'新細明體\')]}"/\x3e', '\x3ca:font script\x3d"Arab" typeface\x3d"Arial"/\x3e', '\x3ca:font script\x3d"Hebr" typeface\x3d"Arial"/\x3e', '\x3ca:font script\x3d"Thai" typeface\x3d"Tahoma"/\x3e', '\x3ca:font script\x3d"Ethi" typeface\x3d"Nyala"/\x3e', '\x3ca:font script\x3d"Beng" typeface\x3d"Vrinda"/\x3e',
  4018. '\x3ca:font script\x3d"Gujr" typeface\x3d"Shruti"/\x3e', '\x3ca:font script\x3d"Khmr" typeface\x3d"DaunPenh"/\x3e', '\x3ca:font script\x3d"Knda" typeface\x3d"Tunga"/\x3e', '\x3ca:font script\x3d"Guru" typeface\x3d"Raavi"/\x3e', '\x3ca:font script\x3d"Cans" typeface\x3d"Euphemia"/\x3e', '\x3ca:font script\x3d"Cher" typeface\x3d"Plantagenet Cherokee"/\x3e', '\x3ca:font script\x3d"Yiii" typeface\x3d"Microsoft Yi Baiti"/\x3e', '\x3ca:font script\x3d"Tibt" typeface\x3d"Microsoft Himalaya"/\x3e', '\x3ca:font script\x3d"Thaa" typeface\x3d"MV Boli"/\x3e',
  4019. '\x3ca:font script\x3d"Deva" typeface\x3d"Mangal"/\x3e', '\x3ca:font script\x3d"Telu" typeface\x3d"Gautami"/\x3e', '\x3ca:font script\x3d"Taml" typeface\x3d"Latha"/\x3e', '\x3ca:font script\x3d"Syrc" typeface\x3d"Estrangelo Edessa"/\x3e', '\x3ca:font script\x3d"Orya" typeface\x3d"Kalinga"/\x3e', '\x3ca:font script\x3d"Mlym" typeface\x3d"Kartika"/\x3e', '\x3ca:font script\x3d"Laoo" typeface\x3d"DokChampa"/\x3e', '\x3ca:font script\x3d"Sinh" typeface\x3d"Iskoola Pota"/\x3e', '\x3ca:font script\x3d"Mong" typeface\x3d"Mongolian Baiti"/\x3e',
  4020. '\x3ca:font script\x3d"Viet" typeface\x3d"Arial"/\x3e', '\x3ca:font script\x3d"Uigh" typeface\x3d"Microsoft Uighur"/\x3e', '\x3ca:font script\x3d"Geor" typeface\x3d"Sylfaen"/\x3e', '\x3c/a:minorFont\x3e', '\x3c/a:fontScheme\x3e', '\x3ca:fmtScheme name\x3d"Office"\x3e', '\x3ca:fillStyleLst\x3e', '\x3ca:solidFill\x3e', '\x3ca:schemeClr val\x3d"phClr"/\x3e', '\x3c/a:solidFill\x3e', '\x3ca:gradFill rotWithShape\x3d"1"\x3e', '\x3ca:gsLst\x3e', '\x3ca:gs pos\x3d"0"\x3e', '\x3ca:schemeClr val\x3d"phClr"\x3e',
  4021. '\x3ca:lumMod val\x3d"110000"/\x3e', '\x3ca:satMod val\x3d"105000"/\x3e', '\x3ca:tint val\x3d"67000"/\x3e', '\x3c/a:schemeClr\x3e', '\x3c/a:gs\x3e', '\x3ca:gs pos\x3d"50000"\x3e', '\x3ca:schemeClr val\x3d"phClr"\x3e', '\x3ca:lumMod val\x3d"105000"/\x3e', '\x3ca:satMod val\x3d"103000"/\x3e', '\x3ca:tint val\x3d"73000"/\x3e', '\x3c/a:schemeClr\x3e', '\x3c/a:gs\x3e', '\x3ca:gs pos\x3d"100000"\x3e', '\x3ca:schemeClr val\x3d"phClr"\x3e', '\x3ca:lumMod val\x3d"105000"/\x3e', '\x3ca:satMod val\x3d"109000"/\x3e',
  4022. '\x3ca:tint val\x3d"81000"/\x3e', '\x3c/a:schemeClr\x3e', '\x3c/a:gs\x3e', '\x3c/a:gsLst\x3e', '\x3ca:lin ang\x3d"5400000" scaled\x3d"0"/\x3e', '\x3c/a:gradFill\x3e', '\x3ca:gradFill rotWithShape\x3d"1"\x3e', '\x3ca:gsLst\x3e', '\x3ca:gs pos\x3d"0"\x3e', '\x3ca:schemeClr val\x3d"phClr"\x3e', '\x3ca:satMod val\x3d"103000"/\x3e', '\x3ca:lumMod val\x3d"102000"/\x3e', '\x3ca:tint val\x3d"94000"/\x3e', '\x3c/a:schemeClr\x3e', '\x3c/a:gs\x3e', '\x3ca:gs pos\x3d"50000"\x3e', '\x3ca:schemeClr val\x3d"phClr"\x3e',
  4023. '\x3ca:satMod val\x3d"110000"/\x3e', '\x3ca:lumMod val\x3d"100000"/\x3e', '\x3ca:shade val\x3d"100000"/\x3e', '\x3c/a:schemeClr\x3e', '\x3c/a:gs\x3e', '\x3ca:gs pos\x3d"100000"\x3e', '\x3ca:schemeClr val\x3d"phClr"\x3e', '\x3ca:lumMod val\x3d"99000"/\x3e', '\x3ca:satMod val\x3d"120000"/\x3e', '\x3ca:shade val\x3d"78000"/\x3e', '\x3c/a:schemeClr\x3e', '\x3c/a:gs\x3e', '\x3c/a:gsLst\x3e', '\x3ca:lin ang\x3d"5400000" scaled\x3d"0"/\x3e', '\x3c/a:gradFill\x3e', '\x3c/a:fillStyleLst\x3e', '\x3ca:lnStyleLst\x3e',
  4024. '\x3ca:ln w\x3d"6350" cap\x3d"flat" cmpd\x3d"sng" algn\x3d"ctr"\x3e', '\x3ca:solidFill\x3e', '\x3ca:schemeClr val\x3d"phClr"/\x3e', '\x3c/a:solidFill\x3e', '\x3ca:prstDash val\x3d"solid"/\x3e', '\x3ca:miter lim\x3d"800000"/\x3e', '\x3c/a:ln\x3e', '\x3ca:ln w\x3d"12700" cap\x3d"flat" cmpd\x3d"sng" algn\x3d"ctr"\x3e', '\x3ca:solidFill\x3e', '\x3ca:schemeClr val\x3d"phClr"/\x3e', '\x3c/a:solidFill\x3e', '\x3ca:prstDash val\x3d"solid"/\x3e', '\x3ca:miter lim\x3d"800000"/\x3e', '\x3c/a:ln\x3e', '\x3ca:ln w\x3d"19050" cap\x3d"flat" cmpd\x3d"sng" algn\x3d"ctr"\x3e',
  4025. '\x3ca:solidFill\x3e', '\x3ca:schemeClr val\x3d"phClr"/\x3e', '\x3c/a:solidFill\x3e', '\x3ca:prstDash val\x3d"solid"/\x3e', '\x3ca:miter lim\x3d"800000"/\x3e', '\x3c/a:ln\x3e', '\x3c/a:lnStyleLst\x3e', '\x3ca:effectStyleLst\x3e', '\x3ca:effectStyle\x3e', '\x3ca:effectLst/\x3e', '\x3c/a:effectStyle\x3e', '\x3ca:effectStyle\x3e', '\x3ca:effectLst/\x3e', '\x3c/a:effectStyle\x3e', '\x3ca:effectStyle\x3e', '\x3ca:effectLst\x3e', '\x3ca:outerShdw blurRad\x3d"57150" dist\x3d"19050" dir\x3d"5400000" algn\x3d"ctr" rotWithShape\x3d"0"\x3e',
  4026. '\x3ca:srgbClr val\x3d"000000"\x3e', '\x3ca:alpha val\x3d"63000"/\x3e', '\x3c/a:srgbClr\x3e', '\x3c/a:outerShdw\x3e', '\x3c/a:effectLst\x3e', '\x3c/a:effectStyle\x3e', '\x3c/a:effectStyleLst\x3e', '\x3ca:bgFillStyleLst\x3e', '\x3ca:solidFill\x3e', '\x3ca:schemeClr val\x3d"phClr"/\x3e', '\x3c/a:solidFill\x3e', '\x3ca:solidFill\x3e', '\x3ca:schemeClr val\x3d"phClr"\x3e', '\x3ca:tint val\x3d"95000"/\x3e', '\x3ca:satMod val\x3d"170000"/\x3e', '\x3c/a:schemeClr\x3e', '\x3c/a:solidFill\x3e', '\x3ca:gradFill rotWithShape\x3d"1"\x3e',
  4027. '\x3ca:gsLst\x3e', '\x3ca:gs pos\x3d"0"\x3e', '\x3ca:schemeClr val\x3d"phClr"\x3e', '\x3ca:tint val\x3d"93000"/\x3e', '\x3ca:satMod val\x3d"150000"/\x3e', '\x3ca:shade val\x3d"98000"/\x3e', '\x3ca:lumMod val\x3d"102000"/\x3e', '\x3c/a:schemeClr\x3e', '\x3c/a:gs\x3e', '\x3ca:gs pos\x3d"50000"\x3e', '\x3ca:schemeClr val\x3d"phClr"\x3e', '\x3ca:tint val\x3d"98000"/\x3e', '\x3ca:satMod val\x3d"130000"/\x3e', '\x3ca:shade val\x3d"90000"/\x3e', '\x3ca:lumMod val\x3d"103000"/\x3e', '\x3c/a:schemeClr\x3e',
  4028. '\x3c/a:gs\x3e', '\x3ca:gs pos\x3d"100000"\x3e', '\x3ca:schemeClr val\x3d"phClr"\x3e', '\x3ca:shade val\x3d"63000"/\x3e', '\x3ca:satMod val\x3d"120000"/\x3e', '\x3c/a:schemeClr\x3e', '\x3c/a:gs\x3e', '\x3c/a:gsLst\x3e', '\x3ca:lin ang\x3d"5400000" scaled\x3d"0"/\x3e', '\x3c/a:gradFill\x3e', '\x3c/a:bgFillStyleLst\x3e', '\x3c/a:fmtScheme\x3e', '\x3c/a:themeElements\x3e', '\x3ca:objectDefaults/\x3e', '\x3ca:extraClrSchemeLst/\x3e', '\x3c/a:theme\x3e', {utf8:function(v) {
  4029. return Ext.util.Base64._utf8_encode(v || '');
  4030. }}]});
  4031. Ext.define('Ext.exporter.file.ooxml.excel.Workbook', {extend:'Ext.exporter.file.ooxml.XmlRels', requires:['Ext.exporter.file.ooxml.excel.Worksheet', 'Ext.exporter.file.ooxml.excel.Stylesheet', 'Ext.exporter.file.ooxml.excel.SharedStrings', 'Ext.exporter.file.ooxml.theme.Office'], isWorkbook:true, currentSheetIndex:1, currentPivotCacheIndex:0, config:{stylesheet:{}, sharedStrings:{}, sheets:[], pivotCaches:null, theme:{type:'office', folder:'/xl/theme/', index:1}}, contentType:{contentType:'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml'},
  4032. relationship:{schema:'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument'}, folder:'/xl/', fileName:'workbook', tpl:['\x3c?xml version\x3d"1.0" encoding\x3d"UTF-8" standalone\x3d"yes"?\x3e', '\x3cworkbook xmlns\x3d"http://schemas.openxmlformats.org/spreadsheetml/2006/main" ', 'xmlns:r\x3d"http://schemas.openxmlformats.org/officeDocument/2006/relationships"\x3e', '\x3ctpl if\x3d"sheets"\x3e', '\x3csheets\x3e', '\x3ctpl if\x3d"sheets"\x3e\x3ctpl for\x3d"sheets.items"\x3e\x3csheet name\x3d"{[this.utf8(values.getName())]}" sheetId\x3d"{[xindex]}" state\x3d"visible" r:id\x3d"{[values.getRelationship().getId()]}"/\x3e\x3c/tpl\x3e\x3c/tpl\x3e',
  4033. '\x3c/sheets\x3e', '\x3c/tpl\x3e', '\x3ctpl if\x3d"pivotCaches"\x3e', '\x3cpivotCaches\x3e', '\x3ctpl for\x3d"pivotCaches.getRange()"\x3e{[values.render()]}\x3c/tpl\x3e', '\x3c/pivotCaches\x3e', '\x3c/tpl\x3e', '\x3c/workbook\x3e', {utf8:function(v) {
  4034. return Ext.util.Base64._utf8_encode(v || '');
  4035. }}], destroy:function() {
  4036. var me = this;
  4037. me.setStylesheet(null);
  4038. me.setSharedStrings(null);
  4039. me.setTheme(null);
  4040. me.callParent();
  4041. }, collectFiles:function(files) {
  4042. var me = this, style = me._stylesheet, strings = me._sharedStrings, theme = me._theme, ws, i, length;
  4043. ws = me._sheets;
  4044. length = ws.length;
  4045. for (i = 0; i < length; i++) {
  4046. ws.items[i].collectFiles(files);
  4047. }
  4048. files[me._path] = me.render();
  4049. files[style._path] = style.render();
  4050. files[strings._path] = strings.render();
  4051. files[theme._path] = theme.render();
  4052. me.collectRelationshipsFiles(files);
  4053. }, collectContentTypes:function(types) {
  4054. var me = this, ws, i, length;
  4055. types.push(me.getStylesheet().getContentType());
  4056. types.push(me.getSharedStrings().getContentType());
  4057. types.push(me.getTheme().getContentType());
  4058. ws = me.getSheets();
  4059. length = ws.length;
  4060. for (i = 0; i < length; i++) {
  4061. ws.getAt(i).collectContentTypes(types);
  4062. }
  4063. me.callParent([types]);
  4064. }, applyStylesheet:function(data) {
  4065. if (!data || data.isStylesheet) {
  4066. return data;
  4067. }
  4068. return new Ext.exporter.file.ooxml.excel.Stylesheet;
  4069. }, updateStylesheet:function(data, oldData) {
  4070. var rels = this.getRelationships();
  4071. if (oldData && rels) {
  4072. rels.removeRelationship(oldData.getRelationship());
  4073. }
  4074. if (data && rels) {
  4075. rels.addRelationship(data.getRelationship());
  4076. }
  4077. Ext.destroy(oldData);
  4078. }, applySharedStrings:function(data) {
  4079. if (!data || data.isSharedStrings) {
  4080. return data;
  4081. }
  4082. return new Ext.exporter.file.ooxml.excel.SharedStrings;
  4083. }, updateSharedStrings:function(data, oldData) {
  4084. var rels = this.getRelationships();
  4085. if (oldData && rels) {
  4086. rels.removeRelationship(oldData.getRelationship());
  4087. }
  4088. if (data) {
  4089. rels.addRelationship(data.getRelationship());
  4090. }
  4091. Ext.destroy(oldData);
  4092. }, applyPivotCaches:function(data, dataCollection) {
  4093. return this.checkCollection(data, dataCollection, 'Ext.exporter.file.ooxml.excel.PivotCache');
  4094. }, updatePivotCaches:function(collection, oldCollection) {
  4095. var me = this;
  4096. if (oldCollection) {
  4097. oldCollection.un({add:me.onPivotCacheAdd, scope:me});
  4098. }
  4099. if (collection) {
  4100. collection.on({add:me.onPivotCacheAdd, scope:me});
  4101. }
  4102. }, onPivotCacheAdd:function(collection, details) {
  4103. var length = details.items.length, i, item;
  4104. for (i = 0; i < length; i++) {
  4105. item = details.items[i];
  4106. item.setCacheId(this.currentPivotCacheIndex++);
  4107. }
  4108. }, applySheets:function(data, dataCollection) {
  4109. return this.checkCollection(data, dataCollection, 'Ext.exporter.file.ooxml.excel.Sheet');
  4110. }, updateSheets:function(collection, oldCollection) {
  4111. var me = this;
  4112. if (oldCollection) {
  4113. oldCollection.un({add:me.onSheetAdd, remove:me.onSheetRemove, scope:me});
  4114. }
  4115. if (collection) {
  4116. collection.on({add:me.onSheetAdd, remove:me.onSheetRemove, scope:me});
  4117. }
  4118. }, applyTheme:function(value) {
  4119. var cfg = {type:'office'};
  4120. if (value) {
  4121. if (typeof value == 'string') {
  4122. cfg.type = value;
  4123. } else {
  4124. Ext.apply(cfg, value);
  4125. }
  4126. value = Ext.Factory.ooxmltheme(value);
  4127. }
  4128. return value;
  4129. }, updateTheme:function(data, oldData) {
  4130. var rels = this.getRelationships();
  4131. if (oldData && rels) {
  4132. rels.removeRelationship(oldData.getRelationship());
  4133. }
  4134. if (data && rels) {
  4135. rels.addRelationship(data.getRelationship());
  4136. }
  4137. Ext.destroy(oldData);
  4138. }, onSheetAdd:function(collection, details) {
  4139. var rels = this.getRelationships(), length = details.items.length, i, item;
  4140. for (i = 0; i < length; i++) {
  4141. item = details.items[i];
  4142. item.setIndex(this.currentSheetIndex++);
  4143. item.setWorkbook(this);
  4144. rels.addRelationship(item.getRelationship());
  4145. }
  4146. }, onSheetRemove:function(collection, details) {
  4147. var rels = this.getRelationships(), length = details.items.length, i, item;
  4148. for (i = 0; i < length; i++) {
  4149. item = details.items[i];
  4150. rels.removeRelationship(item.getRelationship());
  4151. Ext.destroy(item);
  4152. }
  4153. }, addWorksheet:function(config) {
  4154. var ws = Ext.Array.from(config || {}), length = ws.length, i, w;
  4155. for (i = 0; i < length; i++) {
  4156. w = ws[i];
  4157. if (w && !w.isWorksheet) {
  4158. w.workbook = this;
  4159. ws[i] = new Ext.exporter.file.ooxml.excel.Worksheet(w);
  4160. }
  4161. }
  4162. return this.getSheets().add(ws);
  4163. }, removeWorksheet:function(config) {
  4164. return this.getSheets().remove(config);
  4165. }, addPivotCache:function(config) {
  4166. if (!this.getPivotCaches()) {
  4167. this.setPivotCaches([]);
  4168. }
  4169. return this.getPivotCaches().add(config || {});
  4170. }, removePivotCache:function(config) {
  4171. return this.getPivotCaches().remove(config);
  4172. }, addStyle:function(config) {
  4173. return this.getStylesheet().addStyle(config);
  4174. }, addCellStyle:function(config) {
  4175. return this.getStylesheet().addCellStyle(config);
  4176. }});
  4177. Ext.define('Ext.exporter.file.ooxml.ContentTypes', {extend:'Ext.exporter.file.ooxml.Xml', requires:['Ext.exporter.file.ooxml.ContentType'], isContentTypes:true, config:{contentTypes:[{tag:'Default', contentType:'application/vnd.openxmlformats-package.relationships+xml', extension:'rels'}, {tag:'Default', contentType:'application/xml', extension:'xml'}]}, tpl:['\x3c?xml version\x3d"1.0" encoding\x3d"UTF-8" standalone\x3d"yes"?\x3e', '\x3cTypes xmlns\x3d"http://schemas.openxmlformats.org/package/2006/content-types"\x3e',
  4178. '\x3ctpl if\x3d"contentTypes"\x3e\x3ctpl for\x3d"contentTypes.getRange()"\x3e{[values.render()]}\x3c/tpl\x3e\x3c/tpl\x3e', '\x3c/Types\x3e'], folder:'/', fileName:'[Content_Types]', applyContentTypes:function(data, dataCollection) {
  4179. return this.checkCollection(data, dataCollection, 'Ext.exporter.file.ooxml.ContentType');
  4180. }, addContentType:function(config) {
  4181. return this.getContentTypes().add(config || {});
  4182. }});
  4183. Ext.define('Ext.exporter.file.ooxml.CoreProperties', {extend:'Ext.exporter.file.ooxml.Xml', isCoreProperties:true, config:{title:'Workbook', author:'Sencha', subject:''}, contentType:{contentType:'application/vnd.openxmlformats-package.core-properties+xml', partName:'/docProps/core.xml'}, relationship:{schema:'http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties', target:'docProps/core.xml'}, path:'/docProps/core.xml', tpl:['\x3ccoreProperties xmlns\x3d"http://schemas.openxmlformats.org/package/2006/metadata/core-properties" ',
  4184. 'xmlns:dcterms\x3d"http://purl.org/dc/terms/" ', 'xmlns:dc\x3d"http://purl.org/dc/elements/1.1/" ', 'xmlns:xsi\x3d"http://www.w3.org/2001/XMLSchema-instance"\x3e', ' \x3cdc:creator\x3e{author:this.utf8}\x3c/dc:creator\x3e', ' \x3cdc:title\x3e{title:this.utf8}\x3c/dc:title\x3e', ' \x3cdc:subject\x3e{subject:this.utf8}\x3c/dc:subject\x3e', '\x3c/coreProperties\x3e', {utf8:function(v) {
  4185. return Ext.util.Base64._utf8_encode(v || '');
  4186. }}]});
  4187. Ext.define('Ext.exporter.file.ooxml.Excel', {extend:'Ext.exporter.file.ooxml.XmlRels', requires:['Ext.exporter.file.zip.Archive', 'Ext.exporter.file.ooxml.excel.Workbook', 'Ext.exporter.file.ooxml.Relationships', 'Ext.exporter.file.ooxml.ContentTypes', 'Ext.exporter.file.ooxml.CoreProperties'], config:{properties:null, workbook:{}}, folder:'/', fileName:null, tpl:[], constructor:function(config) {
  4188. var ret = this.callParent([config]);
  4189. if (!this.getWorkbook()) {
  4190. this.setWorkbook({});
  4191. }
  4192. return ret;
  4193. }, destroy:function() {
  4194. var me = this;
  4195. me.setWorkbook(null);
  4196. me.setProperties(null);
  4197. me.setRelationships(null);
  4198. me.callParent();
  4199. }, render:function() {
  4200. var files = {}, paths, path, content, i, len, zip;
  4201. this.collectFiles(files);
  4202. paths = Ext.Object.getKeys(files);
  4203. len = paths.length;
  4204. if (!len) {
  4205. return;
  4206. }
  4207. zip = new Ext.exporter.file.zip.Archive;
  4208. for (i = 0; i < len; i++) {
  4209. path = paths[i];
  4210. content = files[path];
  4211. path = path.substr(1);
  4212. if (path.indexOf('.xml') !== -1 || path.indexOf('.rel') !== -1) {
  4213. zip.addFile({path:path, data:content});
  4214. }
  4215. }
  4216. content = zip.getContent();
  4217. zip = Ext.destroy(zip);
  4218. return content;
  4219. }, collectFiles:function(files) {
  4220. var contentTypes = new Ext.exporter.file.ooxml.ContentTypes, wb = this.getWorkbook(), props = this.getProperties(), types = [];
  4221. wb.collectFiles(files);
  4222. if (props) {
  4223. contentTypes.addContentType(props.getContentType());
  4224. files[props.getPath()] = props.render();
  4225. }
  4226. wb.collectContentTypes(types);
  4227. contentTypes.addContentType(types);
  4228. files[contentTypes.getPath()] = contentTypes.render();
  4229. Ext.destroy(contentTypes);
  4230. this.collectRelationshipsFiles(files);
  4231. }, applyProperties:function(data) {
  4232. if (!data || data.isCoreProperties) {
  4233. return data;
  4234. }
  4235. return new Ext.exporter.file.ooxml.CoreProperties(data);
  4236. }, updateProperties:function(data, oldData) {
  4237. var rels = this.getRelationships();
  4238. if (oldData) {
  4239. rels.removeRelationship(oldData.getRelationship());
  4240. oldData.destroy();
  4241. }
  4242. if (data) {
  4243. rels.addRelationship(data.getRelationship());
  4244. }
  4245. }, applyWorkbook:function(data) {
  4246. if (!data || data.isWorkbook) {
  4247. return data;
  4248. }
  4249. return new Ext.exporter.file.ooxml.excel.Workbook(data);
  4250. }, updateWorkbook:function(data, oldData) {
  4251. var rels = this.getRelationships();
  4252. if (oldData) {
  4253. rels.removeRelationship(oldData.getRelationship());
  4254. oldData.destroy();
  4255. }
  4256. if (data) {
  4257. rels.addRelationship(data.getRelationship());
  4258. }
  4259. }, addWorksheet:function(config) {
  4260. return this.getWorkbook().addWorksheet(config);
  4261. }, addStyle:function(config) {
  4262. return this.getWorkbook().getStylesheet().addStyle(config);
  4263. }, addCellStyle:function(config, parentStyleId) {
  4264. return this.getWorkbook().getStylesheet().addCellStyle(config, parentStyleId);
  4265. }});
  4266. Ext.define('Ext.exporter.excel.Xlsx', {extend:'Ext.exporter.Base', alternateClassName:'Ext.exporter.Excel', alias:['exporter.excel07', 'exporter.xlsx', 'exporter.excel'], requires:['Ext.exporter.file.ooxml.Excel'], config:{defaultStyle:{alignment:{vertical:'Top'}, font:{fontName:'Arial', family:'Swiss', size:11, color:'#000000'}}, titleStyle:{alignment:{horizontal:'Center', vertical:'Center'}, font:{fontName:'Arial', family:'Swiss', size:18, color:'#1F497D'}}, groupHeaderStyle:{borders:[{position:'Bottom',
  4267. lineStyle:'Continuous', weight:1, color:'#4F81BD'}]}, groupFooterStyle:{borders:[{position:'Top', lineStyle:'Continuous', weight:1, color:'#4F81BD'}]}, tableHeaderStyle:{alignment:{horizontal:'Center', vertical:'Center'}, borders:[{position:'Bottom', lineStyle:'Continuous', weight:1, color:'#4F81BD'}], font:{fontName:'Arial', family:'Swiss', size:11, color:'#1F497D'}}}, fileName:'export.xlsx', charset:'ascii', mimeType:'application/zip', binary:true, titleRowHeight:22.5, headerRowHeight:20.25, destroy:function() {
  4268. var me = this;
  4269. me.excel = me.worksheet = Ext.destroy(me.excel, me.worksheet);
  4270. me.callParent();
  4271. }, getContent:function() {
  4272. var me = this, config = this.getConfig(), data = config.data, colMerge, ws;
  4273. me.excel = new Ext.exporter.file.ooxml.Excel({properties:{title:config.title, author:config.author}});
  4274. me.worksheet = ws = me.excel.addWorksheet({name:config.title});
  4275. me.tableHeaderStyleId = me.excel.addCellStyle(config.tableHeaderStyle);
  4276. colMerge = data ? data.getColumnCount() : 1;
  4277. ws.beginRowRendering();
  4278. me.addTitle(config, colMerge);
  4279. if (data) {
  4280. ws.renderRows(me.buildHeader());
  4281. ws.renderRows(me.buildRows(data, colMerge, -1));
  4282. }
  4283. ws.endRowRendering();
  4284. me.columnStylesNormal = me.columnStylesNormalId = me.columnStylesFooter = me.columnStylesFooterId = null;
  4285. me.headerStyles = me.footerStyles = null;
  4286. return me.excel.render();
  4287. }, addTitle:function(config, colMerge) {
  4288. if (!Ext.isEmpty(config.title)) {
  4289. this.worksheet.renderRow({height:this.titleRowHeight, cells:[{mergeAcross:colMerge - 1, value:config.title, styleId:this.excel.addCellStyle(config.titleStyle)}]});
  4290. }
  4291. }, buildRows:function(group, colMerge, level) {
  4292. var me = this, showSummary = me._showSummary, rows = [], groups, row, styleH, styleF, cells, i, j, k, gLen, sLen, cLen, oneLine, text, items, cell, temp, style;
  4293. if (!group) {
  4294. return rows;
  4295. }
  4296. groups = group._groups;
  4297. text = group._text;
  4298. oneLine = !groups && !group._rows;
  4299. if (showSummary !== false && !Ext.isEmpty(text) && !oneLine) {
  4300. styleH = me.getGroupHeaderStyleByLevel(level);
  4301. rows.push({styleId:styleH, cells:[{mergeAcross:colMerge - 1, value:text, styleId:styleH}]});
  4302. }
  4303. if (groups) {
  4304. gLen = groups.length;
  4305. for (i = 0; i < gLen; i++) {
  4306. Ext.Array.insert(rows, rows.length, me.buildRows(groups.items[i], colMerge, level + 1));
  4307. }
  4308. }
  4309. if (group._rows) {
  4310. items = group._rows.items;
  4311. sLen = items.length;
  4312. for (k = 0; k < sLen; k++) {
  4313. temp = items[k];
  4314. row = {id:temp._id, cells:[]};
  4315. cells = temp._cells;
  4316. cLen = cells.length;
  4317. for (j = 0; j < cLen; j++) {
  4318. cell = cells.items[j];
  4319. style = me.columnStylesNormalId[j];
  4320. row.cells.push({id:cell._id, value:cell._value, styleId:me.getCellStyleId(cell._style, style)});
  4321. }
  4322. rows.push(row);
  4323. }
  4324. }
  4325. items = group._summaries && group._summaries.items;
  4326. if (items && (showSummary || oneLine)) {
  4327. styleF = me.getGroupFooterStyleByLevel(level);
  4328. sLen = items.length;
  4329. for (k = 0; k < sLen; k++) {
  4330. temp = items[k];
  4331. row = {id:temp._id, cells:[]};
  4332. cells = temp._cells;
  4333. cLen = cells.length;
  4334. for (j = 0; j < cLen; j++) {
  4335. cell = cells.items[j];
  4336. style = oneLine ? me.columnStylesNormalId[j] : j === 0 ? styleF : me.columnStylesFooterId[j];
  4337. row.cells.push({id:cell._id, value:cell._value, styleId:me.getCellStyleId(cell._style, style)});
  4338. }
  4339. rows.push(row);
  4340. }
  4341. }
  4342. group.destroy();
  4343. return rows;
  4344. }, getGroupHeaderStyleByLevel:function(level) {
  4345. var me = this, key = 'l' + level, styles = me.headerStyles;
  4346. if (!styles) {
  4347. me.headerStyles = styles = {};
  4348. }
  4349. if (!styles.hasOwnProperty(key)) {
  4350. styles[key] = me.excel.addCellStyle(Ext.applyIf({alignment:{Indent:level > 0 ? level : 0}}, me._groupHeaderStyle));
  4351. }
  4352. return styles[key];
  4353. }, getGroupFooterStyleByLevel:function(level) {
  4354. var me = this, key = 'l' + level, styles = me.footerStyles;
  4355. if (!styles) {
  4356. me.footerStyles = styles = {};
  4357. }
  4358. if (!styles.hasOwnProperty(key)) {
  4359. styles[key] = me.excel.addCellStyle(Ext.applyIf({alignment:{Indent:level > 0 ? level : 0}}, me.columnStylesFooter[0]));
  4360. }
  4361. return styles[key];
  4362. }, buildHeader:function() {
  4363. var me = this, ret = {}, data = me.getData(), rows = [], keys, row, i, j, len, lenCells, style, arr, fStyle, col, colCfg, cell;
  4364. me.buildHeaderRows(data.getColumns(), ret);
  4365. keys = Ext.Object.getKeys(ret);
  4366. len = keys.length;
  4367. for (i = 0; i < len; i++) {
  4368. row = {height:me.headerRowHeight, styleId:me.tableHeaderStyleId, cells:[]};
  4369. arr = ret[keys[i]];
  4370. lenCells = arr.length;
  4371. for (j = 0; j < lenCells; j++) {
  4372. cell = arr[j];
  4373. cell.styleId = me.tableHeaderStyleId;
  4374. row.cells.push(cell);
  4375. }
  4376. rows.push(row);
  4377. }
  4378. arr = data.getBottomColumns();
  4379. lenCells = arr.length;
  4380. me.columnStylesNormal = [];
  4381. me.columnStylesNormalId = [];
  4382. me.columnStylesFooter = [];
  4383. me.columnStylesFooterId = [];
  4384. fStyle = me.getGroupFooterStyle();
  4385. for (j = 0; j < lenCells; j++) {
  4386. col = arr[j];
  4387. colCfg = {style:col.getStyle(), width:col.getWidth()};
  4388. style = Ext.applyIf({parentId:0}, fStyle);
  4389. style = Ext.merge(style, colCfg.style);
  4390. me.columnStylesFooter.push(style);
  4391. me.columnStylesFooterId.push(me.excel.addCellStyle(style));
  4392. style = Ext.applyIf({parentId:0}, colCfg.style);
  4393. me.columnStylesNormal.push(style);
  4394. colCfg.styleId = me.excel.addCellStyle(style);
  4395. me.columnStylesNormalId.push(colCfg.styleId);
  4396. colCfg.min = colCfg.max = j + 1;
  4397. colCfg.style = null;
  4398. if (colCfg.width) {
  4399. colCfg.width = colCfg.width / 10;
  4400. }
  4401. me.worksheet.addColumn(colCfg);
  4402. }
  4403. return rows;
  4404. }, getCellStyleId:function(style, parentStyleId) {
  4405. return style ? this.excel.addCellStyle(style, parentStyleId) : parentStyleId;
  4406. }, buildHeaderRows:function(columns, result) {
  4407. var col, cols, i, len, name;
  4408. if (!columns) {
  4409. return;
  4410. }
  4411. len = columns.length;
  4412. for (i = 0; i < len; i++) {
  4413. col = columns.items[i].getConfig();
  4414. col.value = col.text;
  4415. cols = col.columns;
  4416. delete col.columns;
  4417. delete col.table;
  4418. name = 's' + col.level;
  4419. result[name] = result[name] || [];
  4420. result[name].push(col);
  4421. this.buildHeaderRows(cols, result);
  4422. }
  4423. }});
  4424. Ext.define('Ext.exporter.Plugin', {extend:'Ext.plugin.Abstract', alias:['plugin.exporterplugin'], requires:['Ext.exporter.data.Table', 'Ext.exporter.Excel'], init:function(cmp) {
  4425. var me = this;
  4426. cmp.saveDocumentAs = Ext.bind(me.saveDocumentAs, me);
  4427. cmp.getDocumentData = Ext.bind(me.getDocumentData, me);
  4428. me.cmp = cmp;
  4429. return me.callParent([cmp]);
  4430. }, destroy:function() {
  4431. var me = this, cmp = me.cmp;
  4432. cmp.saveDocumentAs = cmp.getDocumentData = me.cmp = me.delayedSaveTimer = Ext.unasap(me.delayedSaveTimer);
  4433. me.callParent();
  4434. }, saveDocumentAs:function(config) {
  4435. var cmp = this.cmp, deferred = new Ext.Deferred, exporter = this.getExporter(config);
  4436. cmp.fireEvent('beforedocumentsave', cmp, {config:config, exporter:exporter});
  4437. this.delayedSaveTimer = Ext.asap(this.delayedSave, this, [exporter, config, deferred]);
  4438. return deferred.promise;
  4439. }, delayedSave:function(exporter, config, deferred) {
  4440. var cmp = this.cmp;
  4441. if (this.disabled || !cmp) {
  4442. Ext.destroy(exporter);
  4443. deferred.reject();
  4444. return;
  4445. }
  4446. this.setExporterData(exporter, config);
  4447. exporter.saveAs().then(function() {
  4448. deferred.resolve(config);
  4449. }, function(msg) {
  4450. deferred.reject(msg);
  4451. }).always(function() {
  4452. var canFire = cmp && !cmp.destroyed;
  4453. if (canFire) {
  4454. cmp.fireEvent('documentsave', cmp, {config:config, exporter:exporter});
  4455. }
  4456. Ext.destroy(exporter);
  4457. if (canFire) {
  4458. cmp.fireEvent('exportfinished', cmp, {config:config});
  4459. }
  4460. });
  4461. }, getDocumentData:function(config) {
  4462. var exporter, ret;
  4463. if (this.disabled) {
  4464. return;
  4465. }
  4466. exporter = this.getExporter(config);
  4467. this.setExporterData(exporter, config);
  4468. ret = exporter.getContent();
  4469. Ext.destroy(exporter);
  4470. return ret;
  4471. }, getExporter:function(config) {
  4472. var cfg = Ext.apply({type:'excel'}, config);
  4473. return Ext.Factory.exporter(cfg);
  4474. }, setExporterData:function(exporter, config) {
  4475. var cmp = this.cmp;
  4476. exporter.setData(this.prepareData(config));
  4477. cmp.fireEvent('dataready', cmp, {config:config, exporter:exporter});
  4478. }, getExportStyle:function(style, config) {
  4479. var type = config && config.type, types, def, index;
  4480. if (Ext.isArray(style)) {
  4481. types = Ext.Array.pluck(style, 'type');
  4482. index = Ext.Array.indexOf(types, undefined);
  4483. if (index >= 0) {
  4484. def = style[index];
  4485. }
  4486. index = Ext.Array.indexOf(types, type);
  4487. return index >= 0 ? style[index] : def;
  4488. } else {
  4489. return style;
  4490. }
  4491. }, prepareData:Ext.emptyFn});
  4492. Ext.define('Ext.exporter.file.excel.Worksheet', {extend:'Ext.exporter.file.Base', config:{name:'Sheet', protection:null, rightToLeft:null, showGridLines:true, tables:[]}, tpl:[' \x3cWorksheet ss:Name\x3d"{name:htmlEncode}"', '\x3ctpl if\x3d"this.exists(protection)"\x3e ss:Protected\x3d"{protection:this.toNumber}"\x3c/tpl\x3e', '\x3ctpl if\x3d"this.exists(rightToLeft)"\x3e ss:RightToLeft\x3d"{rightToLeft:this.toNumber}"\x3c/tpl\x3e', '\x3e\n', '\x3ctpl if\x3d"tables"\x3e\x3ctpl for\x3d"tables.getRange()"\x3e{[values.render()]}\x3c/tpl\x3e\x3c/tpl\x3e',
  4493. ' \x3cWorksheetOptions xmlns\x3d"urn:schemas-microsoft-com:office:excel"\x3e\n', ' \x3cPageSetup\x3e\n', ' \x3cLayout x:CenterHorizontal\x3d"1" x:Orientation\x3d"Portrait" /\x3e\n', ' \x3cHeader x:Margin\x3d"0.3" /\x3e\n', ' \x3cFooter x:Margin\x3d"0.3" x:Data\x3d"Page \x26amp;P of \x26amp;N" /\x3e\n', ' \x3cPageMargins x:Bottom\x3d"0.75" x:Left\x3d"0.7" x:Right\x3d"0.7" x:Top\x3d"0.75" /\x3e\n', ' \x3c/PageSetup\x3e\n',
  4494. ' \x3cFitToPage /\x3e\n', ' \x3cPrint\x3e\n', ' \x3cPrintErrors\x3eBlank\x3c/PrintErrors\x3e\n', ' \x3cFitWidth\x3e1\x3c/FitWidth\x3e\n', ' \x3cFitHeight\x3e32767\x3c/FitHeight\x3e\n', ' \x3cValidPrinterInfo /\x3e\n', ' \x3cVerticalResolution\x3e600\x3c/VerticalResolution\x3e\n', ' \x3c/Print\x3e\n', ' \x3cSelected /\x3e\n', '\x3ctpl if\x3d"!showGridLines"\x3e', ' \x3cDoNotDisplayGridlines /\x3e\n',
  4495. '\x3c/tpl\x3e', ' \x3cProtectObjects\x3eFalse\x3c/ProtectObjects\x3e\n', ' \x3cProtectScenarios\x3eFalse\x3c/ProtectScenarios\x3e\n', ' \x3c/WorksheetOptions\x3e\n', ' \x3c/Worksheet\x3e\n', {exists:function(value) {
  4496. return !Ext.isEmpty(value);
  4497. }, toNumber:function(value) {
  4498. return Number(Boolean(value));
  4499. }}], destroy:function() {
  4500. this.setTables(null);
  4501. this.callParent();
  4502. }, applyTables:function(data, dataCollection) {
  4503. return this.checkCollection(data, dataCollection, 'Ext.exporter.file.excel.Table');
  4504. }, addTable:function(config) {
  4505. return this.getTables().add(config || {});
  4506. }, getTable:function(id) {
  4507. return this.getTables().get(id);
  4508. }, applyName:function(value) {
  4509. return Ext.String.ellipsis(String(value), 31);
  4510. }});
  4511. Ext.define('Ext.exporter.file.excel.Table', {extend:'Ext.exporter.file.Base', config:{expandedColumnCount:null, expandedRowCount:null, fullColumns:1, fullRows:1, defaultColumnWidth:48, defaultRowHeight:12.75, styleId:null, leftCell:1, topCell:1, columns:[], rows:[]}, tpl:[' \x3cTable x:FullColumns\x3d"{fullColumns}" x:FullRows\x3d"{fullRows}"', '\x3ctpl if\x3d"this.exists(expandedRowCount)"\x3e ss:ExpandedRowCount\x3d"{expandedRowCount}"\x3c/tpl\x3e', '\x3ctpl if\x3d"this.exists(expandedColumnCount)"\x3e ss:ExpandedColumnCount\x3d"{expandedColumnCount}"\x3c/tpl\x3e',
  4512. '\x3ctpl if\x3d"this.exists(defaultRowHeight)"\x3e ss:DefaultRowHeight\x3d"{defaultRowHeight}"\x3c/tpl\x3e', '\x3ctpl if\x3d"this.exists(defaultColumnWidth)"\x3e ss:DefaultColumnWidth\x3d"{defaultColumnWidth}"\x3c/tpl\x3e', '\x3ctpl if\x3d"this.exists(leftCell)"\x3e ss:LeftCell\x3d"{leftCell}"\x3c/tpl\x3e', '\x3ctpl if\x3d"this.exists(topCell)"\x3e ss:TopCell\x3d"{topCell}"\x3c/tpl\x3e', '\x3ctpl if\x3d"this.exists(styleId)"\x3e ss:StyleID\x3d"{styleId}"\x3c/tpl\x3e', '\x3e\n', '\x3ctpl if\x3d"columns"\x3e\x3ctpl for\x3d"columns.getRange()"\x3e{[values.render()]}\x3c/tpl\x3e\x3c/tpl\x3e',
  4513. '\x3ctpl if\x3d"rows"\x3e', '\x3ctpl for\x3d"rows.getRange()"\x3e{[values.render()]}\x3c/tpl\x3e', '\x3ctpl else\x3e \x3cRow ss:AutoFitHeight\x3d"0"/\x3e\n\x3c/tpl\x3e', ' \x3c/Table\x3e\n', {exists:function(value) {
  4514. return !Ext.isEmpty(value);
  4515. }}], destroy:function() {
  4516. this.setColumns(null);
  4517. this.setRows(null);
  4518. this.callParent();
  4519. }, applyColumns:function(data, dataCollection) {
  4520. return this.checkCollection(data, dataCollection, 'Ext.exporter.file.excel.Column');
  4521. }, applyRows:function(data, dataCollection) {
  4522. return this.checkCollection(data, dataCollection, 'Ext.exporter.file.excel.Row');
  4523. }, addColumn:function(config) {
  4524. return this.getColumns().add(config || {});
  4525. }, getColumn:function(id) {
  4526. return this.getColumns().get(id);
  4527. }, addRow:function(config) {
  4528. return this.getRows().add(config || {});
  4529. }, getRow:function(id) {
  4530. return this.getRows().get(id);
  4531. }});
  4532. Ext.define('Ext.exporter.file.excel.Style', {extend:'Ext.exporter.file.Style', config:{parentId:null, protection:null}, checks:{alignment:{horizontal:['Automatic', 'Left', 'Center', 'Right', 'Fill', 'Justify', 'CenterAcrossSelection', 'Distributed', 'JustifyDistributed'], shrinkToFit:[true, false], vertical:['Automatic', 'Top', 'Bottom', 'Center', 'Justify', 'Distributed', 'JustifyDistributed'], verticalText:[true, false], wrapText:[true, false]}, font:{family:['Automatic', 'Decorative', 'Modern',
  4533. 'Roman', 'Script', 'Swiss'], outline:[true, false], shadow:[true, false], underline:['None', 'Single', 'Double', 'SingleAccounting', 'DoubleAccounting'], verticalAlign:['None', 'Subscript', 'Superscript']}, border:{position:['Left', 'Top', 'Right', 'Bottom', 'DiagonalLeft', 'DiagonalRight'], lineStyle:['None', 'Continuous', 'Dash', 'Dot', 'DashDot', 'DashDotDot', 'SlantDashDot', 'Double'], weight:[0, 1, 2, 3]}, interior:{pattern:['None', 'Solid', 'Gray75', 'Gray50', 'Gray25', 'Gray125', 'Gray0625',
  4534. 'HorzStripe', 'VertStripe', 'ReverseDiagStripe', 'DiagStripe', 'DiagCross', 'ThickDiagCross', 'ThinHorzStripe', 'ThinVertStripe', 'ThinReverseDiagStripe', 'ThinDiagStripe', 'ThinHorzCross', 'ThinDiagCross']}, protection:{'protected':[true, false], hideFormula:[true, false]}}, tpl:[' \x3cStyle ss:ID\x3d"{id}"', '\x3ctpl if\x3d"this.exists(parentId)"\x3e ss:Parent\x3d"{parentId}"\x3c/tpl\x3e', '\x3ctpl if\x3d"this.exists(name)"\x3e ss:Name\x3d"{name}"\x3c/tpl\x3e', '\x3e\n', '\x3ctpl if\x3d"this.exists(alignment)"\x3e \x3cAlignment{[this.getAttributes(values.alignment, "alignment")]}/\x3e\n\x3c/tpl\x3e',
  4535. '\x3ctpl if\x3d"this.exists(borders)"\x3e', ' \x3cBorders\x3e\n', '\x3ctpl for\x3d"borders"\x3e \x3cBorder{[this.getAttributes(values, "border")]}/\x3e\n\x3c/tpl\x3e', ' \x3c/Borders\x3e\n', '\x3c/tpl\x3e', '\x3ctpl if\x3d"this.exists(font)"\x3e \x3cFont{[this.getAttributes(values.font, "font")]}/\x3e\n\x3c/tpl\x3e', '\x3ctpl if\x3d"this.exists(interior)"\x3e \x3cInterior{[this.getAttributes(values.interior, "interior")]}/\x3e\n\x3c/tpl\x3e',
  4536. '\x3ctpl if\x3d"this.exists(format)"\x3e \x3cNumberFormat ss:Format\x3d"{format}"/\x3e\n\x3c/tpl\x3e', '\x3ctpl if\x3d"this.exists(protection)"\x3e \x3cProtection{[this.getAttributes(values.protection, "protection")]}/\x3e\n\x3c/tpl\x3e', ' \x3c/Style\x3e\n', {exists:function(value) {
  4537. return !Ext.isEmpty(value);
  4538. }, getAttributes:function(obj, checkName) {
  4539. var template = ' ss:{0}\x3d"{1}"', keys = Ext.Object.getKeys(obj || {}), len = keys.length, s = '', i, key;
  4540. for (i = 0; i < len; i++) {
  4541. key = keys[i];
  4542. s += Ext.String.format(template, Ext.String.capitalize(key), Ext.isBoolean(obj[key]) ? Number(obj[key]) : obj[key]);
  4543. }
  4544. return s;
  4545. }}], autoGenerateKey:['parentId', 'protection']});
  4546. Ext.define('Ext.exporter.file.excel.Row', {extend:'Ext.exporter.file.Base', config:{autoFitHeight:false, caption:null, cells:[], height:null, index:null, span:null, styleId:null}, tpl:[' \x3cRow', '\x3ctpl if\x3d"this.exists(index)"\x3e ss:Index\x3d"{index}"\x3c/tpl\x3e', '\x3ctpl if\x3d"this.exists(caption)"\x3e c:Caption\x3d"{caption}"\x3c/tpl\x3e', '\x3ctpl if\x3d"this.exists(autoFitHeight)"\x3e ss:AutoFitHeight\x3d"{autoFitHeight:this.toNumber}"\x3c/tpl\x3e', '\x3ctpl if\x3d"this.exists(span)"\x3e ss:Span\x3d"{span}"\x3c/tpl\x3e',
  4547. '\x3ctpl if\x3d"this.exists(height)"\x3e ss:Height\x3d"{height}"\x3c/tpl\x3e', '\x3ctpl if\x3d"this.exists(styleId)"\x3e ss:StyleID\x3d"{styleId}"\x3c/tpl\x3e', '\x3e\n', '\x3ctpl if\x3d"cells"\x3e\x3ctpl for\x3d"cells.getRange()"\x3e{[values.render()]}\x3c/tpl\x3e\x3c/tpl\x3e', ' \x3c/Row\x3e\n', {exists:function(value) {
  4548. return !Ext.isEmpty(value);
  4549. }, toNumber:function(value) {
  4550. return Number(Boolean(value));
  4551. }}], destroy:function() {
  4552. this.setCells(null);
  4553. this.callParent();
  4554. }, applyCells:function(data, dataCollection) {
  4555. return this.checkCollection(data, dataCollection, 'Ext.exporter.file.excel.Cell');
  4556. }, addCell:function(config) {
  4557. return this.getCells().add(config || {});
  4558. }, getCell:function(id) {
  4559. return this.getCells().get(id);
  4560. }});
  4561. Ext.define('Ext.exporter.file.excel.Column', {extend:'Ext.exporter.file.Base', config:{autoFitWidth:false, caption:null, hidden:null, index:null, span:null, styleId:null, width:null}, tpl:['\x3cColumn', '\x3ctpl if\x3d"this.exists(index)"\x3e ss:Index\x3d"{index}"\x3c/tpl\x3e', '\x3ctpl if\x3d"this.exists(caption)"\x3e c:Caption\x3d"{caption}"\x3c/tpl\x3e', '\x3ctpl if\x3d"this.exists(styleId)"\x3e ss:StyleID\x3d"{styleId}"\x3c/tpl\x3e', '\x3ctpl if\x3d"this.exists(hidden)"\x3e ss:Hidden\x3d"{hidden}"\x3c/tpl\x3e',
  4562. '\x3ctpl if\x3d"this.exists(span)"\x3e ss:Span\x3d"{span}"\x3c/tpl\x3e', '\x3ctpl if\x3d"this.exists(width)"\x3e ss:Width\x3d"{width}"\x3c/tpl\x3e', '\x3ctpl if\x3d"this.exists(autoFitWidth)"\x3e ss:AutoFitWidth\x3d"{autoFitWidth:this.toNumber}"\x3c/tpl\x3e', '/\x3e\n', {exists:function(value) {
  4563. return !Ext.isEmpty(value);
  4564. }, toNumber:function(value) {
  4565. return Number(Boolean(value));
  4566. }}]});
  4567. Ext.define('Ext.exporter.file.excel.Cell', {extend:'Ext.exporter.file.Base', config:{dataType:'String', formula:null, index:null, styleId:null, mergeAcross:null, mergeDown:null, value:''}, tpl:[' \x3cCell', '\x3ctpl if\x3d"this.exists(index)"\x3e ss:Index\x3d"{index}"\x3c/tpl\x3e', '\x3ctpl if\x3d"this.exists(styleId)"\x3e ss:StyleID\x3d"{styleId}"\x3c/tpl\x3e', '\x3ctpl if\x3d"this.exists(mergeAcross)"\x3e ss:MergeAcross\x3d"{mergeAcross}"\x3c/tpl\x3e', '\x3ctpl if\x3d"this.exists(mergeDown)"\x3e ss:MergeDown\x3d"{mergeDown}"\x3c/tpl\x3e',
  4568. '\x3ctpl if\x3d"this.exists(formula)"\x3e ss:Formula\x3d"{formula}"\x3c/tpl\x3e', '\x3e\n', ' \x3cData ss:Type\x3d"{dataType}"\x3e{value}\x3c/Data\x3e\n', ' \x3c/Cell\x3e\n', {exists:function(value) {
  4569. return !Ext.isEmpty(value);
  4570. }}], applyValue:function(v) {
  4571. var dt = 'String', format = Ext.util.Format;
  4572. if (v instanceof Date) {
  4573. dt = 'DateTime';
  4574. v = Ext.Date.format(v, 'Y-m-d\\TH:i:s.u');
  4575. } else {
  4576. if (Ext.isNumber(v)) {
  4577. dt = 'Number';
  4578. } else {
  4579. if (Ext.isBoolean(v)) {
  4580. dt = 'Boolean';
  4581. v = Number(v);
  4582. } else {
  4583. v = format.htmlEncode(format.htmlDecode(v));
  4584. }
  4585. }
  4586. }
  4587. this.setDataType(dt);
  4588. return v;
  4589. }});
  4590. Ext.define('Ext.exporter.file.excel.Workbook', {extend:'Ext.exporter.file.Base', requires:['Ext.exporter.file.excel.Worksheet', 'Ext.exporter.file.excel.Table', 'Ext.exporter.file.excel.Style', 'Ext.exporter.file.excel.Row', 'Ext.exporter.file.excel.Column', 'Ext.exporter.file.excel.Cell'], config:{title:'Workbook', author:'Sencha', windowHeight:9000, windowWidth:50000, protectStructure:false, protectWindows:false, styles:[], worksheets:[]}, tpl:['\x3c?xml version\x3d"1.0" encoding\x3d"utf-8"?\x3e\n',
  4591. '\x3c?mso-application progid\x3d"Excel.Sheet"?\x3e\n', '\x3cWorkbook ', 'xmlns\x3d"urn:schemas-microsoft-com:office:spreadsheet" ', 'xmlns:o\x3d"urn:schemas-microsoft-com:office:office" ', 'xmlns:x\x3d"urn:schemas-microsoft-com:office:excel" ', 'xmlns:ss\x3d"urn:schemas-microsoft-com:office:spreadsheet" ', 'xmlns:html\x3d"http://www.w3.org/TR/REC-html40"\x3e\n', ' \x3cDocumentProperties xmlns\x3d"urn:schemas-microsoft-com:office:office"\x3e\n', ' \x3cTitle\x3e{title:htmlEncode}\x3c/Title\x3e\n',
  4592. ' \x3cAuthor\x3e{author:htmlEncode}\x3c/Author\x3e\n', ' \x3cCreated\x3e{createdAt}\x3c/Created\x3e\n', ' \x3c/DocumentProperties\x3e\n', ' \x3cExcelWorkbook xmlns\x3d"urn:schemas-microsoft-com:office:excel"\x3e\n', ' \x3cWindowHeight\x3e{windowHeight}\x3c/WindowHeight\x3e\n', ' \x3cWindowWidth\x3e{windowWidth}\x3c/WindowWidth\x3e\n', ' \x3cProtectStructure\x3e{protectStructure}\x3c/ProtectStructure\x3e\n', ' \x3cProtectWindows\x3e{protectWindows}\x3c/ProtectWindows\x3e\n',
  4593. ' \x3c/ExcelWorkbook\x3e\n', ' \x3cStyles\x3e\n', '\x3ctpl if\x3d"styles"\x3e\x3ctpl for\x3d"styles.getRange()"\x3e{[values.render()]}\x3c/tpl\x3e\x3c/tpl\x3e', ' \x3c/Styles\x3e\n', '\x3ctpl if\x3d"worksheets"\x3e\x3ctpl for\x3d"worksheets.getRange()"\x3e{[values.render()]}\x3c/tpl\x3e\x3c/tpl\x3e', '\x3c/Workbook\x3e'], destroy:function() {
  4594. this.setStyles(null);
  4595. this.setWorksheets(null);
  4596. this.callParent();
  4597. }, applyStyles:function(data, dataCollection) {
  4598. return this.checkCollection(data, dataCollection, 'Ext.exporter.file.excel.Style');
  4599. }, applyWorksheets:function(data, dataCollection) {
  4600. return this.checkCollection(data, dataCollection, 'Ext.exporter.file.excel.Worksheet');
  4601. }, addStyle:function(config) {
  4602. var styles = this.getStyles(), items = styles.decodeItems(arguments, 0), len = items.length, ret = [], i, found, item;
  4603. for (i = 0; i < len; i++) {
  4604. item = items[i];
  4605. found = styles.get(item.getKey());
  4606. ret.push(found ? found : styles.add(item));
  4607. if (found) {
  4608. item.destroy();
  4609. }
  4610. }
  4611. return ret.length === 1 ? ret[0] : ret;
  4612. }, getStyle:function(id) {
  4613. return this.getStyles().get(id);
  4614. }, addWorksheet:function(config) {
  4615. return this.getWorksheets().add(config || {});
  4616. }, getWorksheet:function(id) {
  4617. return this.getWorksheets().get(id);
  4618. }});
  4619. Ext.define('Ext.exporter.excel.Xml', {extend:'Ext.exporter.Base', alias:'exporter.excel03', requires:['Ext.exporter.file.excel.Workbook'], config:{windowHeight:9000, windowWidth:50000, protectStructure:false, protectWindows:false, defaultStyle:{alignment:{vertical:'Top'}, font:{fontName:'Calibri', family:'Swiss', size:11, color:'#000000'}}, titleStyle:{name:'Title', parentId:'Default', alignment:{horizontal:'Center', vertical:'Center'}, font:{fontName:'Cambria', family:'Swiss', size:18, color:'#1F497D'}},
  4620. groupHeaderStyle:{name:'Group Header', parentId:'Default', borders:[{position:'Bottom', lineStyle:'Continuous', weight:1, color:'#4F81BD'}]}, groupFooterStyle:{borders:[{position:'Top', lineStyle:'Continuous', weight:1, color:'#4F81BD'}]}, tableHeaderStyle:{name:'Heading 1', parentId:'Default', alignment:{horizontal:'Center', vertical:'Center'}, borders:[{position:'Bottom', lineStyle:'Continuous', weight:1, color:'#4F81BD'}], font:{fontName:'Calibri', family:'Swiss', size:11, color:'#1F497D'}}},
  4621. fileName:'export.xml', mimeType:'text/xml', titleRowHeight:22.5, headerRowHeight:20.25, destroy:function() {
  4622. var me = this;
  4623. me.workbook = me.table = Ext.destroy(me.workbook);
  4624. me.callParent();
  4625. }, applyDefaultStyle:function(newValue) {
  4626. return Ext.applyIf({id:'Default', name:'Normal'}, newValue || {});
  4627. }, getContent:function() {
  4628. var me = this, config = this.getConfig(), data = config.data, colMerge;
  4629. me.workbook = new Ext.exporter.file.excel.Workbook({title:config.title, author:config.author, windowHeight:config.windowHeight, windowWidth:config.windowWidth, protectStructure:config.protectStructure, protectWindows:config.protectWindows});
  4630. me.table = me.workbook.addWorksheet({name:config.title}).addTable();
  4631. me.workbook.addStyle(config.defaultStyle);
  4632. me.tableHeaderStyleId = me.workbook.addStyle(config.tableHeaderStyle).getId();
  4633. me.groupHeaderStyleId = me.workbook.addStyle(config.groupHeaderStyle).getId();
  4634. colMerge = data ? data.getColumnCount() : 1;
  4635. me.addTitle(config, colMerge);
  4636. if (data) {
  4637. me.buildHeader();
  4638. me.table.addRow(me.buildRows(data, colMerge, -1));
  4639. }
  4640. me.columnStylesFooter = me.columnStylesNormal = null;
  4641. me.headerStyles = me.footerStyles = null;
  4642. return me.workbook.render();
  4643. }, addTitle:function(config, colMerge) {
  4644. if (!Ext.isEmpty(config.title)) {
  4645. this.table.addRow({autoFitHeight:1, height:this.titleRowHeight, styleId:this.workbook.addStyle(config.titleStyle).getId()}).addCell({mergeAcross:colMerge - 1, value:config.title});
  4646. }
  4647. }, buildRows:function(group, colMerge, level) {
  4648. var me = this, showSummary = me.getShowSummary(), rows = [], groups, row, styleH, styleF, cells, i, j, k, gLen, sLen, cLen, oneLine, cell, text, style;
  4649. if (!group) {
  4650. return;
  4651. }
  4652. groups = group._groups;
  4653. text = group._text;
  4654. oneLine = !groups && !group._rows;
  4655. if (showSummary !== false && !Ext.isEmpty(text) && !oneLine) {
  4656. styleH = me.getGroupHeaderStyleByLevel(level);
  4657. rows.push({cells:[{mergeAcross:colMerge - 1, value:text, styleId:styleH}]});
  4658. }
  4659. if (groups) {
  4660. gLen = groups.length;
  4661. for (i = 0; i < gLen; i++) {
  4662. Ext.Array.insert(rows, rows.length, me.buildRows(groups.items[i], colMerge, level + 1));
  4663. }
  4664. }
  4665. if (group._rows) {
  4666. sLen = group._rows.length;
  4667. for (k = 0; k < sLen; k++) {
  4668. row = {cells:[]};
  4669. cells = group._rows.items[k]._cells;
  4670. cLen = cells.length;
  4671. for (j = 0; j < cLen; j++) {
  4672. cell = cells.items[j];
  4673. style = me.columnStylesNormal[j];
  4674. row.cells.push({value:cell._value, styleId:me.getCellStyleId(cell._style, style)});
  4675. }
  4676. rows.push(row);
  4677. }
  4678. }
  4679. if (group._summaries && (showSummary || oneLine)) {
  4680. styleF = me.getGroupFooterStyleByLevel(level);
  4681. sLen = group._summaries.length;
  4682. for (k = 0; k < sLen; k++) {
  4683. row = {cells:[]};
  4684. cells = group._summaries.items[k]._cells;
  4685. cLen = cells.length;
  4686. for (j = 0; j < cLen; j++) {
  4687. cell = cells.items[j];
  4688. style = oneLine ? me.columnStylesNormal[j] : j === 0 ? styleF : me.columnStylesFooter[j];
  4689. row.cells.push({value:cell._value, styleId:me.getCellStyleId(cell._style, style)});
  4690. }
  4691. rows.push(row);
  4692. }
  4693. }
  4694. return rows;
  4695. }, getCellStyleId:function(style, parentStyleId) {
  4696. var config = Ext.applyIf({parentId:parentStyleId}, style);
  4697. return style ? this.workbook.addStyle(config).getId() : parentStyleId;
  4698. }, getGroupHeaderStyleByLevel:function(level) {
  4699. var me = this, key = 'l' + level, styles = me.headerStyles;
  4700. if (!styles) {
  4701. me.headerStyles = styles = {};
  4702. }
  4703. if (!styles.hasOwnProperty(key)) {
  4704. styles[key] = me.workbook.addStyle({parentId:me.groupHeaderStyleId, alignment:{Indent:level > 0 ? level : 0}}).getId();
  4705. }
  4706. return styles[key];
  4707. }, getGroupFooterStyleByLevel:function(level) {
  4708. var me = this, key = 'l' + level, styles = me.footerStyles;
  4709. if (!styles) {
  4710. me.footerStyles = styles = {};
  4711. }
  4712. if (!styles.hasOwnProperty(key)) {
  4713. styles[key] = me.workbook.addStyle({parentId:me.columnStylesFooter[0], alignment:{Indent:level > 0 ? level : 0}}).getId();
  4714. }
  4715. return styles[key];
  4716. }, buildHeader:function() {
  4717. var me = this, ret = {}, data = me.getData(), keys, row, i, j, len, lenCells, style, arr, fStyle, col, colCfg;
  4718. me.buildHeaderRows(data.getColumns(), ret);
  4719. keys = Ext.Object.getKeys(ret);
  4720. len = keys.length;
  4721. for (i = 0; i < len; i++) {
  4722. row = me.table.addRow({height:me.headerRowHeight, autoFitHeight:1});
  4723. arr = ret[keys[i]];
  4724. lenCells = arr.length;
  4725. for (j = 0; j < lenCells; j++) {
  4726. row.addCell(arr[j]).setStyleId(me.tableHeaderStyleId);
  4727. }
  4728. }
  4729. arr = data.getBottomColumns();
  4730. lenCells = arr.length;
  4731. me.columnStylesNormal = [];
  4732. me.columnStylesFooter = [];
  4733. fStyle = me.getGroupFooterStyle();
  4734. for (j = 0; j < lenCells; j++) {
  4735. col = arr[j];
  4736. colCfg = {width:col.getWidth()};
  4737. style = Ext.applyIf({parentId:'Default'}, fStyle);
  4738. style = Ext.merge(style, col.getStyle());
  4739. style.id = null;
  4740. me.columnStylesFooter.push(me.workbook.addStyle(style).getId());
  4741. style = Ext.merge({parentId:'Default'}, col.getStyle());
  4742. colCfg.styleId = me.workbook.addStyle(style).getId();
  4743. me.columnStylesNormal.push(colCfg.styleId);
  4744. me.table.addColumn(colCfg);
  4745. }
  4746. }, buildHeaderRows:function(columns, result) {
  4747. var col, cols, i, len, name;
  4748. if (!columns) {
  4749. return;
  4750. }
  4751. len = columns.length;
  4752. for (i = 0; i < len; i++) {
  4753. col = columns.items[i].getConfig();
  4754. col.value = col.text;
  4755. cols = col.columns;
  4756. delete col.columns;
  4757. delete col.table;
  4758. name = 's' + col.level;
  4759. result[name] = result[name] || [];
  4760. result[name].push(col);
  4761. this.buildHeaderRows(cols, result);
  4762. }
  4763. }});
  4764. Ext.define('Ext.exporter.file.html.Style', {extend:'Ext.exporter.file.Style', idPrefix:'ext-', indentation:10, mappings:{readingOrder:{LeftToRight:'ltr', RightToLeft:'rtl', Context:'initial', Automatic:'initial'}, horizontal:{Automatic:'initial', Left:'left', Center:'center', Right:'right', Justify:'justify'}, vertical:{Top:'top', Bottom:'bottom', Center:'middle', Automatic:'baseline'}, lineStyle:{None:'none', Continuous:'solid', Dash:'dashed', Dot:'dotted'}}, updateId:function(id) {
  4765. if (id && !this.getName()) {
  4766. this.setName('.' + id);
  4767. }
  4768. }, render:function() {
  4769. var cfg = this.getConfig(), map = this.mappings, s = '', align = cfg.alignment, font = cfg.font, borders = cfg.borders, interior = cfg.interior, i, length, name, border;
  4770. if (align) {
  4771. if (align.horizontal) {
  4772. s += 'text-align: ' + map.horizontal[align.horizontal] + ';\n';
  4773. }
  4774. if (align.readingOrder) {
  4775. s += 'direction: ' + map.readingOrder[align.readingOrder] + ';\n';
  4776. }
  4777. if (align.vertical) {
  4778. s += 'vertical-align: ' + map.vertical[align.vertical] + ';\n';
  4779. }
  4780. if (align.indent) {
  4781. s += 'padding-left: ' + align.indent * this.indentation + 'px;\n';
  4782. }
  4783. }
  4784. if (font) {
  4785. if (font.size) {
  4786. s += 'font-size: ' + font.size + 'px;\n';
  4787. }
  4788. if (font.bold) {
  4789. s += 'font-weight: bold;\n';
  4790. }
  4791. if (font.italic) {
  4792. s += 'font-style: italic;\n';
  4793. }
  4794. if (font.strikeThrough) {
  4795. s += 'text-decoration: line-through;\n';
  4796. }
  4797. if (font.underline === 'Single') {
  4798. s += 'text-decoration: underline;\n';
  4799. }
  4800. if (font.color) {
  4801. s += 'color: ' + font.color + ';\n';
  4802. }
  4803. }
  4804. if (interior && interior.color) {
  4805. s += 'background-color: ' + interior.color + ';\n';
  4806. }
  4807. if (borders) {
  4808. length = borders.length;
  4809. for (i = 0; i < length; i++) {
  4810. border = borders[i];
  4811. name = 'border-' + border.position.toLowerCase();
  4812. s += name + '-width: ' + (border.weight || 0) + 'px;\n';
  4813. s += name + '-style: ' + (map.lineStyle[border.lineStyle] || 'initial') + ';\n';
  4814. s += name + '-color: ' + (border.color || 'initial') + ';\n';
  4815. }
  4816. }
  4817. return cfg.name + '{\n' + s + '}\n';
  4818. }});
  4819. Ext.define('Ext.exporter.file.html.Doc', {extend:'Ext.exporter.file.Base', requires:['Ext.exporter.file.html.Style'], config:{title:'Title', author:'Sencha', charset:'UTF-8', styles:[], table:null}, destroy:function() {
  4820. this.setStyles(null);
  4821. this.setTable(null);
  4822. this.callParent();
  4823. }, applyStyles:function(data, dataCollection) {
  4824. return this.checkCollection(data, dataCollection, 'Ext.exporter.file.html.Style');
  4825. }, addStyle:function(config) {
  4826. var styles = this.getStyles(), items = styles.decodeItems(arguments, 0), len = items.length, ret = [], i, found, item;
  4827. for (i = 0; i < len; i++) {
  4828. item = items[i];
  4829. found = styles.get(item.getKey());
  4830. ret.push(found ? found : styles.add(item));
  4831. if (found) {
  4832. item.destroy();
  4833. }
  4834. }
  4835. return ret.length === 1 ? ret[0] : ret;
  4836. }, getStyle:function(id) {
  4837. return this.getStyles().get(id);
  4838. }});
  4839. Ext.define('Ext.exporter.file.ooxml.excel.PageField', {extend:'Ext.exporter.file.ooxml.Base', config:{cap:null, fld:null, hier:null, item:null, name:null}, generateTplAttributes:true, tpl:['\x3cpageField {attributes} /\x3e']});
  4840. Ext.define('Ext.exporter.text.CSV', {extend:'Ext.exporter.Base', alias:'exporter.csv', requires:['Ext.util.CSV'], fileName:'export.csv', getHelper:function() {
  4841. return Ext.util.CSV;
  4842. }, getContent:function() {
  4843. var me = this, result = [], data = me.getData();
  4844. if (data) {
  4845. me.buildHeader(result);
  4846. me.buildRows(data, result, data.getColumnCount());
  4847. me.columnStyles = Ext.destroy(me.columnStyles);
  4848. }
  4849. return me.getHelper().encode(result);
  4850. }, buildHeader:function(result) {
  4851. var me = this, ret = {}, data = me.getData(), arr, lenCells, i, style;
  4852. me.buildHeaderRows(data.getColumns(), ret);
  4853. result.push.apply(result, Ext.Object.getValues(ret));
  4854. arr = data.getBottomColumns();
  4855. lenCells = arr.length;
  4856. me.columnStyles = [];
  4857. for (i = 0; i < lenCells; i++) {
  4858. style = arr[i].getStyle() || {};
  4859. if (!style.id) {
  4860. style.id = 'c' + i;
  4861. }
  4862. style.name = '.' + style.id;
  4863. me.columnStyles.push(new Ext.exporter.file.Style(style));
  4864. }
  4865. }, buildHeaderRows:function(columns, result) {
  4866. var col, i, len, name, mAcross, mDown, j, level;
  4867. if (!columns) {
  4868. return;
  4869. }
  4870. len = columns.length;
  4871. for (i = 0; i < len; i++) {
  4872. col = columns.items[i];
  4873. mAcross = col._mergeAcross;
  4874. mDown = col._mergeDown;
  4875. level = col._level;
  4876. name = 's' + level;
  4877. result[name] = result[name] || [];
  4878. result[name].push(col._text);
  4879. for (j = 1; j <= mAcross; j++) {
  4880. result[name].push('');
  4881. }
  4882. for (j = 1; j <= mDown; j++) {
  4883. name = 's' + (level + j);
  4884. result[name] = result[name] || [];
  4885. result[name].push('');
  4886. }
  4887. this.buildHeaderRows(col._columns, result);
  4888. }
  4889. }, buildRows:function(group, result, length) {
  4890. var showSummary = this._showSummary, groups, i, row, gLen, j, rLen, k, cLen, r, cells, oneLine, cell, style, text;
  4891. if (!group) {
  4892. return;
  4893. }
  4894. groups = group._groups;
  4895. text = group._text;
  4896. oneLine = !groups && !group._rows;
  4897. if (!Ext.isEmpty(text) && !oneLine) {
  4898. row = [];
  4899. row.length = length;
  4900. row[group.level || 0] = text;
  4901. result.push(row);
  4902. }
  4903. if (groups) {
  4904. gLen = groups.length;
  4905. for (i = 0; i < gLen; i++) {
  4906. this.buildRows(groups.items[i], result, length);
  4907. }
  4908. }
  4909. if (group._rows) {
  4910. rLen = group._rows.length;
  4911. for (j = 0; j < rLen; j++) {
  4912. row = [];
  4913. r = group._rows.items[j];
  4914. cells = r._cells;
  4915. cLen = cells.length;
  4916. for (k = 0; k < cLen; k++) {
  4917. cell = cells.items[k];
  4918. style = this.columnStyles[k];
  4919. cell = style ? style.getFormattedValue(cell._value) : cell._value;
  4920. row.push(cell);
  4921. }
  4922. result.push(row);
  4923. }
  4924. }
  4925. if (group._summaries && (showSummary || oneLine)) {
  4926. rLen = group._summaries.length;
  4927. for (j = 0; j < rLen; j++) {
  4928. row = [];
  4929. r = group._summaries.items[j];
  4930. cells = r._cells;
  4931. cLen = cells.length;
  4932. for (k = 0; k < cLen; k++) {
  4933. cell = cells.items[k];
  4934. style = this.columnStyles[k];
  4935. cell = style ? style.getFormattedValue(cell._value) : cell._value;
  4936. row.push(cell);
  4937. }
  4938. result.push(row);
  4939. }
  4940. }
  4941. }});
  4942. Ext.define('Ext.exporter.text.Html', {extend:'Ext.exporter.Base', alias:'exporter.html', requires:['Ext.exporter.file.html.Doc'], config:{tpl:['\x3c!DOCTYPE html\x3e\n', '\x3chtml\x3e\n', ' \x3chead\x3e\n', ' \x3cmeta charset\x3d"{charset}"\x3e\n', ' \x3ctitle\x3e{title}\x3c/title\x3e\n', ' \x3cstyle\x3e\n', ' table { border-collapse: collapse; border-spacing: 0; }\n', '\x3ctpl if\x3d"styles"\x3e\x3ctpl for\x3d"styles.getRange()"\x3e{[values.render()]}\x3c/tpl\x3e\x3c/tpl\x3e',
  4943. ' \x3c/style\x3e\n', ' \x3c/head\x3e\n', ' \x3cbody\x3e\n', ' \x3ch1\x3e{title}\x3c/h1\x3e\n', ' \x3ctable\x3e\n', ' \x3cthead\x3e\n', '\x3ctpl for\x3d"table.columns"\x3e', ' \x3ctr\x3e\n', '\x3ctpl for\x3d"."\x3e', ' \x3cth\x3ctpl if\x3d"width"\x3e width\x3d"{width}"\x3c/tpl\x3e\x3ctpl if\x3d"mergeAcross"\x3e colSpan\x3d"{mergeAcross}"\x3c/tpl\x3e\x3ctpl if\x3d"mergeDown"\x3e rowSpan\x3d"{mergeDown}"\x3c/tpl\x3e\x3e{text}\x3c/th\x3e\n',
  4944. '\x3c/tpl\x3e', ' \x3c/tr\x3e\n', '\x3c/tpl\x3e', ' \x3c/thead\x3e\n', ' \x3ctbody\x3e\n', '\x3ctpl for\x3d"table.rows"\x3e', ' \x3ctr\x3ctpl if\x3d"cls"\x3e class\x3d"{cls}"\x3c/tpl\x3e\x3e\n', '\x3ctpl for\x3d"cells"\x3e', ' \x3ctd\x3ctpl if\x3d"cls"\x3e class\x3d"{cls}"\x3c/tpl\x3e\x3ctpl if\x3d"mergeAcross"\x3e colSpan\x3d"{mergeAcross}"\x3c/tpl\x3e\x3ctpl if\x3d"mergeDown"\x3e rowSpan\x3d"{mergeDown}"\x3c/tpl\x3e\x3e{value}\x3c/td\x3e\n',
  4945. '\x3c/tpl\x3e', ' \x3c/tr\x3e\n', '\x3c/tpl\x3e', ' \x3c/tbody\x3e\n', ' \x3ctfoot\x3e\n', ' \x3ctr\x3e\n', ' \x3cth\x3ctpl if\x3d"table.columnsCount"\x3e colSpan\x3d"{table.columnsCount}"\x3c/tpl\x3e\x3e\x26nbsp;\x3c/th\x3e\n', ' \x3c/tr\x3e\n', ' \x3c/tfoot\x3e\n', ' \x3c/table\x3e\n', ' \x3c/body\x3e\n', '\x3c/html\x3e'], defaultStyle:{name:'table tbody td, table thead th', alignment:{vertical:'Top'},
  4946. font:{fontName:'Arial', size:12, color:'#000000'}, borders:[{position:'Left', lineStyle:'Continuous', weight:1, color:'#4F81BD'}, {position:'Right', lineStyle:'Continuous', weight:1, color:'#4F81BD'}]}, titleStyle:{name:'h1', font:{fontName:'Arial', size:18, color:'#1F497D'}}, groupHeaderStyle:{name:'.groupHeader td', borders:[{position:'Top', lineStyle:'Continuous', weight:1, color:'#4F81BD'}, {position:'Bottom', lineStyle:'Continuous', weight:1, color:'#4F81BD'}]}, groupFooterStyle:{name:'.groupFooter td',
  4947. borders:[{position:'Bottom', lineStyle:'Continuous', weight:1, color:'#4F81BD'}]}, tableHeaderStyle:{name:'table thead th', alignment:{horizontal:'Center', vertical:'Center'}, borders:[{position:'Top', lineStyle:'Continuous', weight:1, color:'#4F81BD'}, {position:'Bottom', lineStyle:'Continuous', weight:1, color:'#4F81BD'}], font:{fontName:'Arial', size:12, color:'#1F497D'}}, tableFooterStyle:{name:'table tfoot th', borders:[{position:'Top', lineStyle:'Continuous', weight:1, color:'#4F81BD'}]}},
  4948. fileName:'export.html', mimeType:'text/html', getContent:function() {
  4949. var me = this, config = me.getConfig(), data = config.data, table = {columnsCount:0, columns:[], rows:[]}, colMerge, html;
  4950. me.doc = new Ext.exporter.file.html.Doc({title:config.title, author:config.author, tpl:config.tpl, styles:[config.defaultStyle, config.titleStyle, config.groupHeaderStyle, config.groupFooterStyle, config.tableHeaderStyle, config.tableFooterStyle]});
  4951. if (data) {
  4952. colMerge = data.getColumnCount();
  4953. Ext.apply(table, {columnsCount:data.getColumnCount(), columns:me.buildHeader(), rows:me.buildRows(data, colMerge, 0)});
  4954. }
  4955. me.doc.setTable(table);
  4956. html = me.doc.render();
  4957. me.doc = me.columnStyles = Ext.destroy(me.doc);
  4958. return html;
  4959. }, buildRows:function(group, colMerge, level) {
  4960. var me = this, showSummary = me._showSummary, result = [], groups, row, i, j, k, gLen, rLen, cLen, cell, r, cells, oneLine, style, text;
  4961. if (!group) {
  4962. return result;
  4963. }
  4964. me.doc.addStyle({id:'.levelHeader' + level, name:'.levelHeader' + level, alignment:{Horizontal:'Left', Indent:(level > 0 ? level : 0) * 5}});
  4965. me.doc.addStyle({id:'.levelFooter' + level, name:'.levelFooter' + level, alignment:{Horizontal:'Left', Indent:(level > 0 ? level : 0) * 5}});
  4966. groups = group._groups;
  4967. text = group._text;
  4968. oneLine = !groups && !group._rows;
  4969. if (!Ext.isEmpty(text) && !oneLine) {
  4970. result.push({cls:'groupHeader', cells:[{value:text, mergeAcross:colMerge, cls:'levelHeader' + level}]});
  4971. }
  4972. if (groups) {
  4973. gLen = groups.length;
  4974. for (i = 0; i < gLen; i++) {
  4975. Ext.Array.insert(result, result.length, me.buildRows(groups.items[i], colMerge, level + 1));
  4976. }
  4977. }
  4978. if (group._rows) {
  4979. rLen = group._rows.length;
  4980. for (j = 0; j < rLen; j++) {
  4981. row = [];
  4982. r = group._rows.items[j];
  4983. cells = r._cells;
  4984. cLen = cells.length;
  4985. for (k = 0; k < cLen; k++) {
  4986. cell = cells.items[k].getConfig();
  4987. style = me.columnStyles[k];
  4988. if (style) {
  4989. cell.cls = style._id + (cell.style ? ' ' + me.doc.addStyle(cell.style)._id : '');
  4990. cell.value = style.getFormattedValue(cell.value);
  4991. }
  4992. row.push(cell);
  4993. }
  4994. result.push({cells:row});
  4995. }
  4996. }
  4997. if (group._summaries && (showSummary || oneLine)) {
  4998. rLen = group._summaries.length;
  4999. for (j = 0; j < rLen; j++) {
  5000. row = [];
  5001. r = group._summaries.items[j];
  5002. cells = r._cells;
  5003. cLen = cells.length;
  5004. for (k = 0; k < cLen; k++) {
  5005. cell = cells.items[k].getConfig();
  5006. style = me.columnStyles[k];
  5007. cell.cls = k === 0 ? 'levelFooter' + level : '';
  5008. if (style) {
  5009. cell.cls += ' ' + style.getId() + (cell.style ? ' ' + me.doc.addStyle(cell.style).getId() : '');
  5010. cell.value = style.getFormattedValue(cell.value);
  5011. }
  5012. row.push(cell);
  5013. }
  5014. result.push({cls:'groupFooter' + (oneLine ? ' groupHeader' : ''), cells:row});
  5015. }
  5016. }
  5017. return result;
  5018. }, buildHeader:function() {
  5019. var me = this, ret = {}, data = me.getData(), arr, lenCells, i, style;
  5020. me.buildHeaderRows(data.getColumns(), ret);
  5021. arr = data.getBottomColumns();
  5022. lenCells = arr.length;
  5023. me.columnStyles = [];
  5024. for (i = 0; i < lenCells; i++) {
  5025. style = arr[i].getStyle() || {};
  5026. if (!style.id) {
  5027. style.id = Ext.id();
  5028. }
  5029. style.name = '.' + style.id;
  5030. me.columnStyles.push(me.doc.addStyle(style));
  5031. }
  5032. return Ext.Object.getValues(ret);
  5033. }, buildHeaderRows:function(columns, result) {
  5034. var col, i, len, name, s;
  5035. if (!columns) {
  5036. return;
  5037. }
  5038. len = columns.length;
  5039. for (i = 0; i < len; i++) {
  5040. col = columns.items[i].getConfig();
  5041. name = 's' + col.level;
  5042. result[name] = result[name] || [];
  5043. if (col.mergeAcross) {
  5044. col.mergeAcross++;
  5045. }
  5046. if (col.mergeDown) {
  5047. col.mergeDown++;
  5048. }
  5049. result[name].push(col);
  5050. this.buildHeaderRows(col.columns, result);
  5051. }
  5052. }});
  5053. Ext.define('Ext.exporter.text.TSV', {extend:'Ext.exporter.text.CSV', alias:'exporter.tsv', requires:['Ext.util.TSV'], getHelper:function() {
  5054. return Ext.util.TSV;
  5055. }});
  5056. Ext.define('Ext.grid.plugin.BaseExporter', {extend:'Ext.exporter.Plugin', prepareData:function(config) {
  5057. var me = this, store = me.cmp.getStore(), table = new Ext.exporter.data.Table, result, columns;
  5058. result = me.getColumnHeaders(config, me.getGridColumns());
  5059. table.setColumns(result.headers);
  5060. if (!store || store && store.destroyed) {
  5061. return table;
  5062. }
  5063. if (store && store.isBufferedStore) {
  5064. Ext.raise("BufferedStore can't be exported because it doesn't have all data available");
  5065. }
  5066. columns = me.prepareDataIndexColumns(config, result.dataIndexes);
  5067. if (store.isTreeStore) {
  5068. me.extractNodeData(config, table, columns, store.getRoot());
  5069. } else {
  5070. if (config && config.includeGroups && store.isGrouped()) {
  5071. me.extractData(config, table, columns, store.getGroups());
  5072. me.extractSummaryRow(config, table, columns, store);
  5073. } else {
  5074. me.extractRows(config, table, columns, store);
  5075. }
  5076. }
  5077. return table;
  5078. }, getColumnHeaders:function(config, columns) {
  5079. var cols = [], dataIndexes = [], len = columns.length, i, result;
  5080. for (i = 0; i < len; i++) {
  5081. result = this.getColumnHeader(config, columns[i]);
  5082. if (result) {
  5083. cols.push(result.header);
  5084. Ext.Array.insert(dataIndexes, dataIndexes.length, result.dataIndexes);
  5085. }
  5086. }
  5087. return {headers:cols, dataIndexes:dataIndexes};
  5088. }, getGridColumns:function() {
  5089. return [];
  5090. }, getColumnHeader:Ext.emptyFn, prepareDataIndexColumns:function(config, dataIndexes) {
  5091. var len = dataIndexes.length, columns = [], i;
  5092. for (i = 0; i < len; i++) {
  5093. columns.push(this.prepareDataIndexColumn(config, dataIndexes[i]));
  5094. }
  5095. return columns;
  5096. }, prepareDataIndexColumn:function(config, column) {
  5097. return {column:column, fn:Ext.emptyFn};
  5098. }, extractData:function(config, group, columns, collection) {
  5099. var i, len, children, storeGroup, tableGroup;
  5100. if (!collection) {
  5101. return;
  5102. }
  5103. len = collection.getCount();
  5104. for (i = 0; i < len; i++) {
  5105. storeGroup = collection.getAt(i);
  5106. children = storeGroup.getGroups();
  5107. tableGroup = group.addGroup({text:storeGroup.getGroupKey()});
  5108. if (children) {
  5109. this.extractData(config, tableGroup, columns, children);
  5110. } else {
  5111. this.extractRows(config, tableGroup, columns, storeGroup);
  5112. }
  5113. }
  5114. }, extractNodeData:function(config, group, columns, node) {
  5115. var me = this, store = me.cmp.getStore(), lenCols = columns.length, i, j, record, row, cell, column, children, len;
  5116. if (node && node.hasChildNodes()) {
  5117. children = node.childNodes;
  5118. len = children.length;
  5119. for (i = 0; i < len; i++) {
  5120. record = children[i];
  5121. row = {cells:[]};
  5122. for (j = 0; j < lenCols; j++) {
  5123. column = columns[j];
  5124. cell = me.getCell(store, record, column) || {value:null};
  5125. if (column.column.isTreeColumn && cell) {
  5126. cell.style = Ext.merge(cell.style || {}, {alignment:{indent:record.getDepth() - 1}});
  5127. }
  5128. row.cells.push(cell);
  5129. }
  5130. group.addRow(row);
  5131. if (record.hasChildNodes()) {
  5132. me.extractNodeData(config, group, columns, record);
  5133. }
  5134. }
  5135. }
  5136. }, extractRows:function(config, group, columns, collection) {
  5137. var cmp = this.cmp, store = cmp.getStore(), len = collection.getCount(), lenCols = columns.length, rows = [], i, j, record, row, cell;
  5138. for (i = 0; i < len; i++) {
  5139. record = collection.getAt(i);
  5140. row = {cells:[]};
  5141. for (j = 0; j < lenCols; j++) {
  5142. cell = this.getCell(store, record, columns[j]);
  5143. row.cells.push(cell || {value:null});
  5144. }
  5145. rows.push(row);
  5146. }
  5147. group.setRows(rows);
  5148. this.extractSummaryRow(config, group, columns, collection);
  5149. }, extractSummaryRow:function(config, group, columns, collection) {
  5150. var lenCols = columns.length, i, record, row, cell;
  5151. if (config.includeSummary) {
  5152. row = {cells:[]};
  5153. record = this.getSummaryRecord(collection, columns);
  5154. for (i = 0; i < lenCols; i++) {
  5155. cell = this.getSummaryCell(collection, record, columns[i]);
  5156. row.cells.push(cell || {value:null});
  5157. }
  5158. group.setSummaries(row);
  5159. }
  5160. }, getCell:Ext.emptyFn, getSummaryCell:Ext.emptyFn, getSummaryRecord:function(collection, columns) {
  5161. var len = columns.length, summaryRecord = collection.getSummaryRecord(), record = new Ext.data.Model({id:'summary-record'}), i, colDef, records;
  5162. record.beginEdit();
  5163. record.set(summaryRecord.getData());
  5164. for (i = 0; i < len; i++) {
  5165. colDef = columns[i];
  5166. if (colDef.summary) {
  5167. records = collection.isStore ? collection.data.items.slice() : collection.items.slice();
  5168. record.set(colDef.summaryIndex, colDef.summary.calculate(records, colDef.summaryIndex, 'data', 0, records.length));
  5169. } else {
  5170. if (colDef.summaryType) {
  5171. record.set(colDef.summaryIndex, this.getSummary(collection, colDef.summaryType, colDef.summaryIndex));
  5172. }
  5173. }
  5174. }
  5175. record.endEdit();
  5176. record.commit(true);
  5177. return record;
  5178. }, getSummary:function(item, type, field) {
  5179. var isStore = item.isStore;
  5180. if (type) {
  5181. if (Ext.isFunction(type)) {
  5182. if (isStore) {
  5183. return item.aggregate(type, null, false, [field]);
  5184. } else {
  5185. return item.aggregate(field, type);
  5186. }
  5187. }
  5188. switch(type) {
  5189. case 'count':
  5190. return item.count();
  5191. case 'min':
  5192. return item.min(field);
  5193. case 'max':
  5194. return item.max(field);
  5195. case 'sum':
  5196. return item.sum(field);
  5197. case 'average':
  5198. return item.average(field);
  5199. default:
  5200. return null;
  5201. }
  5202. }
  5203. }});
  5204. Ext.define('Ext.grid.plugin.Exporter', {alias:['plugin.gridexporter'], extend:'Ext.grid.plugin.BaseExporter', getGridColumns:function() {
  5205. return this.cmp.getHeaderContainer().innerItems;
  5206. }, getColumnHeader:function(config, column) {
  5207. var dataIndexes = [], obj, result, style;
  5208. obj = {text:column.getText(), width:column.getWidth()};
  5209. if (column.isHeaderGroup) {
  5210. result = this.getColumnHeaders(config, column.innerItems);
  5211. obj.columns = result.headers;
  5212. if (obj.columns.length === 0) {
  5213. obj = null;
  5214. } else {
  5215. Ext.Array.insert(dataIndexes, dataIndexes.length, result.dataIndexes);
  5216. }
  5217. } else {
  5218. if (!column.getHidden() && !column.getIgnoreExport()) {
  5219. style = this.getExportStyle(column.getExportStyle(), config);
  5220. obj.style = style;
  5221. obj.width = obj.width || column.getComputedWidth();
  5222. if (style) {
  5223. obj.width = style.width || obj.width;
  5224. }
  5225. dataIndexes.push(column);
  5226. } else {
  5227. obj = null;
  5228. }
  5229. }
  5230. if (obj) {
  5231. return {header:obj, dataIndexes:dataIndexes};
  5232. }
  5233. }, prepareDataIndexColumn:function(config, column) {
  5234. var fn = Ext.identityFn, summaryFn = Ext.identityFn, style = this.getExportStyle(column.getExportStyle(), config);
  5235. if (!style || style && !style.format) {
  5236. fn = this.getSpecialFn({renderer:'renderer', exportRenderer:'exportRenderer', formatter:'formatter'}, column) || fn;
  5237. summaryFn = this.getSpecialFn({renderer:'summaryRenderer', exportRenderer:'exportSummaryRenderer', formatter:'summaryFormatter'}, column) || fn;
  5238. }
  5239. return {dataIndex:column.getDataIndex(), column:column, fn:fn, summary:column.getSummary(), summaryType:column.getSummaryType(), summaryIndex:column.getSummaryDataIndex() || column.getDataIndex(), summaryFn:summaryFn};
  5240. }, getSpecialFn:function(names, column) {
  5241. var exportRenderer = column['get' + Ext.String.capitalize(names.exportRenderer)](), renderer = column['get' + Ext.String.capitalize(names.renderer)](), formatter = column['get' + Ext.String.capitalize(names.formatter)](), fn, scope, tempFn;
  5242. scope = column.getScope() || column.resolveListenerScope() || column;
  5243. tempFn = exportRenderer;
  5244. if (formatter && !tempFn) {
  5245. fn = formatter;
  5246. } else {
  5247. if (tempFn === true) {
  5248. tempFn = renderer;
  5249. }
  5250. if (typeof tempFn == 'string') {
  5251. fn = function() {
  5252. return Ext.callback(tempFn, scope, arguments, 0, column);
  5253. };
  5254. } else {
  5255. if (typeof tempFn == 'function') {
  5256. fn = function() {
  5257. return tempFn.apply(scope, arguments);
  5258. };
  5259. }
  5260. }
  5261. }
  5262. return fn;
  5263. }, getCell:function(store, record, colDef) {
  5264. var dataIndex = colDef.dataIndex, v = record.get(dataIndex);
  5265. return {value:colDef.fn(v, record, dataIndex, null, colDef.column)};
  5266. }, getSummaryCell:function(collection, record, colDef) {
  5267. var dataIndex = colDef.summaryIndex, v = record.get(dataIndex);
  5268. return {value:colDef.summaryFn(v, record, dataIndex, null, colDef.column)};
  5269. }});