Нема описа
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

powerpoint-web-16.00.debug.js 436KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451
  1. /* PowerPointer web application specific API library */
  2. /* Version: 16.0.7610.1000 */
  3. /*
  4. Copyright (c) Microsoft Corporation. All rights reserved.
  5. */
  6. /*
  7. Your use of this file is governed by the Microsoft Services Agreement http://go.microsoft.com/fwlink/?LinkId=266419.
  8. */
  9. var __extends = (this && this.__extends) || function (d, b) {
  10. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  11. function __() { this.constructor = d; }
  12. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  13. };
  14. var OfficeExt;
  15. (function (OfficeExt) {
  16. var MicrosoftAjaxFactory = (function () {
  17. function MicrosoftAjaxFactory() {
  18. }
  19. MicrosoftAjaxFactory.prototype.isMsAjaxLoaded = function () {
  20. if (typeof (Sys) !== 'undefined' && typeof (Type) !== 'undefined' &&
  21. Sys.StringBuilder && typeof (Sys.StringBuilder) === "function" &&
  22. Type.registerNamespace && typeof (Type.registerNamespace) === "function" &&
  23. Type.registerClass && typeof (Type.registerClass) === "function" &&
  24. typeof (Function._validateParams) === "function" &&
  25. Sys.Serialization && Sys.Serialization.JavaScriptSerializer && typeof (Sys.Serialization.JavaScriptSerializer.serialize) === "function") {
  26. return true;
  27. }
  28. else {
  29. return false;
  30. }
  31. };
  32. MicrosoftAjaxFactory.prototype.loadMsAjaxFull = function (callback) {
  33. var msAjaxCDNPath = (window.location.protocol.toLowerCase() === 'https:' ? 'https:' : 'http:') + '//ajax.aspnetcdn.com/ajax/3.5/MicrosoftAjax.js';
  34. OSF.OUtil.loadScript(msAjaxCDNPath, callback);
  35. };
  36. Object.defineProperty(MicrosoftAjaxFactory.prototype, "msAjaxError", {
  37. get: function () {
  38. if (this._msAjaxError == null && this.isMsAjaxLoaded()) {
  39. this._msAjaxError = Error;
  40. }
  41. return this._msAjaxError;
  42. },
  43. set: function (errorClass) {
  44. this._msAjaxError = errorClass;
  45. },
  46. enumerable: true,
  47. configurable: true
  48. });
  49. Object.defineProperty(MicrosoftAjaxFactory.prototype, "msAjaxString", {
  50. get: function () {
  51. if (this._msAjaxString == null && this.isMsAjaxLoaded()) {
  52. this._msAjaxString = String;
  53. }
  54. return this._msAjaxString;
  55. },
  56. set: function (stringClass) {
  57. this._msAjaxString = stringClass;
  58. },
  59. enumerable: true,
  60. configurable: true
  61. });
  62. Object.defineProperty(MicrosoftAjaxFactory.prototype, "msAjaxDebug", {
  63. get: function () {
  64. if (this._msAjaxDebug == null && this.isMsAjaxLoaded()) {
  65. this._msAjaxDebug = Sys.Debug;
  66. }
  67. return this._msAjaxDebug;
  68. },
  69. set: function (debugClass) {
  70. this._msAjaxDebug = debugClass;
  71. },
  72. enumerable: true,
  73. configurable: true
  74. });
  75. return MicrosoftAjaxFactory;
  76. })();
  77. OfficeExt.MicrosoftAjaxFactory = MicrosoftAjaxFactory;
  78. })(OfficeExt || (OfficeExt = {}));
  79. var OsfMsAjaxFactory = new OfficeExt.MicrosoftAjaxFactory();
  80. var OSF = OSF || {};
  81. var OfficeExt;
  82. (function (OfficeExt) {
  83. var SafeStorage = (function () {
  84. function SafeStorage(_internalStorage) {
  85. this._internalStorage = _internalStorage;
  86. }
  87. SafeStorage.prototype.getItem = function (key) {
  88. try {
  89. return this._internalStorage && this._internalStorage.getItem(key);
  90. }
  91. catch (e) {
  92. return null;
  93. }
  94. };
  95. SafeStorage.prototype.setItem = function (key, data) {
  96. try {
  97. this._internalStorage && this._internalStorage.setItem(key, data);
  98. }
  99. catch (e) {
  100. }
  101. };
  102. SafeStorage.prototype.clear = function () {
  103. try {
  104. this._internalStorage && this._internalStorage.clear();
  105. }
  106. catch (e) {
  107. }
  108. };
  109. SafeStorage.prototype.removeItem = function (key) {
  110. try {
  111. this._internalStorage && this._internalStorage.removeItem(key);
  112. }
  113. catch (e) {
  114. }
  115. };
  116. SafeStorage.prototype.getKeysWithPrefix = function (keyPrefix) {
  117. var keyList = [];
  118. try {
  119. var len = this._internalStorage && this._internalStorage.length || 0;
  120. for (var i = 0; i < len; i++) {
  121. var key = this._internalStorage.key(i);
  122. if (key.indexOf(keyPrefix) === 0) {
  123. keyList.push(key);
  124. }
  125. }
  126. }
  127. catch (e) {
  128. }
  129. return keyList;
  130. };
  131. return SafeStorage;
  132. })();
  133. OfficeExt.SafeStorage = SafeStorage;
  134. })(OfficeExt || (OfficeExt = {}));
  135. OSF.XdmFieldName = {
  136. ConversationUrl: "ConversationUrl",
  137. AppId: "AppId"
  138. };
  139. OSF.WindowNameItemKeys = {
  140. BaseFrameName: "baseFrameName",
  141. HostInfo: "hostInfo",
  142. XdmInfo: "xdmInfo",
  143. SerializerVersion: "serializerVersion",
  144. AppContext: "appContext"
  145. };
  146. OSF.OUtil = (function () {
  147. var _uniqueId = -1;
  148. var _xdmInfoKey = '&_xdm_Info=';
  149. var _serializerVersionKey = '&_serializer_version=';
  150. var _xdmSessionKeyPrefix = '_xdm_';
  151. var _serializerVersionKeyPrefix = '_serializer_version=';
  152. var _fragmentSeparator = '#';
  153. var _fragmentInfoDelimiter = '&';
  154. var _classN = "class";
  155. var _loadedScripts = {};
  156. var _defaultScriptLoadingTimeout = 30000;
  157. var _safeSessionStorage = null;
  158. var _safeLocalStorage = null;
  159. var _rndentropy = new Date().getTime();
  160. function _random() {
  161. var nextrand = 0x7fffffff * (Math.random());
  162. nextrand ^= _rndentropy ^ ((new Date().getMilliseconds()) << Math.floor(Math.random() * (31 - 10)));
  163. return nextrand.toString(16);
  164. }
  165. ;
  166. function _getSessionStorage() {
  167. if (!_safeSessionStorage) {
  168. try {
  169. var sessionStorage = window.sessionStorage;
  170. }
  171. catch (ex) {
  172. sessionStorage = null;
  173. }
  174. _safeSessionStorage = new OfficeExt.SafeStorage(sessionStorage);
  175. }
  176. return _safeSessionStorage;
  177. }
  178. ;
  179. function _reOrderTabbableElements(elements) {
  180. var bucket0 = [];
  181. var bucketPositive = [];
  182. var i;
  183. var len = elements.length;
  184. var ele;
  185. for (i = 0; i < len; i++) {
  186. ele = elements[i];
  187. if (ele.tabIndex) {
  188. if (ele.tabIndex > 0) {
  189. bucketPositive.push(ele);
  190. }
  191. else if (ele.tabIndex === 0) {
  192. bucket0.push(ele);
  193. }
  194. }
  195. else {
  196. bucket0.push(ele);
  197. }
  198. }
  199. bucketPositive = bucketPositive.sort(function (left, right) {
  200. var diff = left.tabIndex - right.tabIndex;
  201. if (diff === 0) {
  202. diff = bucketPositive.indexOf(left) - bucketPositive.indexOf(right);
  203. }
  204. return diff;
  205. });
  206. return [].concat(bucketPositive, bucket0);
  207. }
  208. ;
  209. return {
  210. set_entropy: function OSF_OUtil$set_entropy(entropy) {
  211. if (typeof entropy == "string") {
  212. for (var i = 0; i < entropy.length; i += 4) {
  213. var temp = 0;
  214. for (var j = 0; j < 4 && i + j < entropy.length; j++) {
  215. temp = (temp << 8) + entropy.charCodeAt(i + j);
  216. }
  217. _rndentropy ^= temp;
  218. }
  219. }
  220. else if (typeof entropy == "number") {
  221. _rndentropy ^= entropy;
  222. }
  223. else {
  224. _rndentropy ^= 0x7fffffff * Math.random();
  225. }
  226. _rndentropy &= 0x7fffffff;
  227. },
  228. extend: function OSF_OUtil$extend(child, parent) {
  229. var F = function () { };
  230. F.prototype = parent.prototype;
  231. child.prototype = new F();
  232. child.prototype.constructor = child;
  233. child.uber = parent.prototype;
  234. if (parent.prototype.constructor === Object.prototype.constructor) {
  235. parent.prototype.constructor = parent;
  236. }
  237. },
  238. setNamespace: function OSF_OUtil$setNamespace(name, parent) {
  239. if (parent && name && !parent[name]) {
  240. parent[name] = {};
  241. }
  242. },
  243. unsetNamespace: function OSF_OUtil$unsetNamespace(name, parent) {
  244. if (parent && name && parent[name]) {
  245. delete parent[name];
  246. }
  247. },
  248. loadScript: function OSF_OUtil$loadScript(url, callback, timeoutInMs) {
  249. if (url && callback) {
  250. var doc = window.document;
  251. var _loadedScriptEntry = _loadedScripts[url];
  252. if (!_loadedScriptEntry) {
  253. var script = doc.createElement("script");
  254. script.type = "text/javascript";
  255. _loadedScriptEntry = { loaded: false, pendingCallbacks: [callback], timer: null };
  256. _loadedScripts[url] = _loadedScriptEntry;
  257. var onLoadCallback = function OSF_OUtil_loadScript$onLoadCallback() {
  258. if (_loadedScriptEntry.timer != null) {
  259. clearTimeout(_loadedScriptEntry.timer);
  260. delete _loadedScriptEntry.timer;
  261. }
  262. _loadedScriptEntry.loaded = true;
  263. var pendingCallbackCount = _loadedScriptEntry.pendingCallbacks.length;
  264. for (var i = 0; i < pendingCallbackCount; i++) {
  265. var currentCallback = _loadedScriptEntry.pendingCallbacks.shift();
  266. currentCallback();
  267. }
  268. };
  269. var onLoadError = function OSF_OUtil_loadScript$onLoadError() {
  270. delete _loadedScripts[url];
  271. if (_loadedScriptEntry.timer != null) {
  272. clearTimeout(_loadedScriptEntry.timer);
  273. delete _loadedScriptEntry.timer;
  274. }
  275. var pendingCallbackCount = _loadedScriptEntry.pendingCallbacks.length;
  276. for (var i = 0; i < pendingCallbackCount; i++) {
  277. var currentCallback = _loadedScriptEntry.pendingCallbacks.shift();
  278. currentCallback();
  279. }
  280. };
  281. if (script.readyState) {
  282. script.onreadystatechange = function () {
  283. if (script.readyState == "loaded" || script.readyState == "complete") {
  284. script.onreadystatechange = null;
  285. onLoadCallback();
  286. }
  287. };
  288. }
  289. else {
  290. script.onload = onLoadCallback;
  291. }
  292. script.onerror = onLoadError;
  293. timeoutInMs = timeoutInMs || _defaultScriptLoadingTimeout;
  294. _loadedScriptEntry.timer = setTimeout(onLoadError, timeoutInMs);
  295. script.src = url;
  296. doc.getElementsByTagName("head")[0].appendChild(script);
  297. }
  298. else if (_loadedScriptEntry.loaded) {
  299. callback();
  300. }
  301. else {
  302. _loadedScriptEntry.pendingCallbacks.push(callback);
  303. }
  304. }
  305. },
  306. loadCSS: function OSF_OUtil$loadCSS(url) {
  307. if (url) {
  308. var doc = window.document;
  309. var link = doc.createElement("link");
  310. link.type = "text/css";
  311. link.rel = "stylesheet";
  312. link.href = url;
  313. doc.getElementsByTagName("head")[0].appendChild(link);
  314. }
  315. },
  316. parseEnum: function OSF_OUtil$parseEnum(str, enumObject) {
  317. var parsed = enumObject[str.trim()];
  318. if (typeof (parsed) == 'undefined') {
  319. OsfMsAjaxFactory.msAjaxDebug.trace("invalid enumeration string:" + str);
  320. throw OsfMsAjaxFactory.msAjaxError.argument("str");
  321. }
  322. return parsed;
  323. },
  324. delayExecutionAndCache: function OSF_OUtil$delayExecutionAndCache() {
  325. var obj = { calc: arguments[0] };
  326. return function () {
  327. if (obj.calc) {
  328. obj.val = obj.calc.apply(this, arguments);
  329. delete obj.calc;
  330. }
  331. return obj.val;
  332. };
  333. },
  334. getUniqueId: function OSF_OUtil$getUniqueId() {
  335. _uniqueId = _uniqueId + 1;
  336. return _uniqueId.toString();
  337. },
  338. formatString: function OSF_OUtil$formatString() {
  339. var args = arguments;
  340. var source = args[0];
  341. return source.replace(/{(\d+)}/gm, function (match, number) {
  342. var index = parseInt(number, 10) + 1;
  343. return args[index] === undefined ? '{' + number + '}' : args[index];
  344. });
  345. },
  346. generateConversationId: function OSF_OUtil$generateConversationId() {
  347. return [_random(), _random(), (new Date()).getTime().toString()].join('_');
  348. },
  349. getFrameName: function OSF_OUtil$getFrameName(cacheKey) {
  350. return _xdmSessionKeyPrefix + cacheKey + this.generateConversationId();
  351. },
  352. addXdmInfoAsHash: function OSF_OUtil$addXdmInfoAsHash(url, xdmInfoValue) {
  353. return OSF.OUtil.addInfoAsHash(url, _xdmInfoKey, xdmInfoValue, false);
  354. },
  355. addSerializerVersionAsHash: function OSF_OUtil$addSerializerVersionAsHash(url, serializerVersion) {
  356. return OSF.OUtil.addInfoAsHash(url, _serializerVersionKey, serializerVersion, true);
  357. },
  358. addInfoAsHash: function OSF_OUtil$addInfoAsHash(url, keyName, infoValue, encodeInfo) {
  359. url = url.trim() || '';
  360. var urlParts = url.split(_fragmentSeparator);
  361. var urlWithoutFragment = urlParts.shift();
  362. var fragment = urlParts.join(_fragmentSeparator);
  363. var newFragment;
  364. if (encodeInfo) {
  365. newFragment = [keyName, encodeURIComponent(infoValue), fragment].join('');
  366. }
  367. else {
  368. newFragment = [fragment, keyName, infoValue].join('');
  369. }
  370. return [urlWithoutFragment, _fragmentSeparator, newFragment].join('');
  371. },
  372. parseHostInfoFromWindowName: function OSF_OUtil$parseHostInfoFromWindowName(skipSessionStorage, windowName) {
  373. return OSF.OUtil.parseInfoFromWindowName(skipSessionStorage, windowName, OSF.WindowNameItemKeys.HostInfo);
  374. },
  375. parseXdmInfo: function OSF_OUtil$parseXdmInfo(skipSessionStorage) {
  376. var xdmInfoValue = OSF.OUtil.parseXdmInfoWithGivenFragment(skipSessionStorage, window.location.hash);
  377. if (!xdmInfoValue) {
  378. xdmInfoValue = OSF.OUtil.parseXdmInfoFromWindowName(skipSessionStorage, window.name);
  379. }
  380. return xdmInfoValue;
  381. },
  382. parseXdmInfoFromWindowName: function OSF_OUtil$parseXdmInfoFromWindowName(skipSessionStorage, windowName) {
  383. return OSF.OUtil.parseInfoFromWindowName(skipSessionStorage, windowName, OSF.WindowNameItemKeys.XdmInfo);
  384. },
  385. parseXdmInfoWithGivenFragment: function OSF_OUtil$parseXdmInfoWithGivenFragment(skipSessionStorage, fragment) {
  386. return OSF.OUtil.parseInfoWithGivenFragment(_xdmInfoKey, _xdmSessionKeyPrefix, false, skipSessionStorage, fragment);
  387. },
  388. parseSerializerVersion: function OSF_OUtil$parseSerializerVersion(skipSessionStorage) {
  389. var serializerVersion = OSF.OUtil.parseSerializerVersionWithGivenFragment(skipSessionStorage, window.location.hash);
  390. if (isNaN(serializerVersion)) {
  391. serializerVersion = OSF.OUtil.parseSerializerVersionFromWindowName(skipSessionStorage, window.name);
  392. }
  393. return serializerVersion;
  394. },
  395. parseSerializerVersionFromWindowName: function OSF_OUtil$parseSerializerVersionFromWindowName(skipSessionStorage, windowName) {
  396. return parseInt(OSF.OUtil.parseInfoFromWindowName(skipSessionStorage, windowName, OSF.WindowNameItemKeys.SerializerVersion));
  397. },
  398. parseSerializerVersionWithGivenFragment: function OSF_OUtil$parseSerializerVersionWithGivenFragment(skipSessionStorage, fragment) {
  399. return parseInt(OSF.OUtil.parseInfoWithGivenFragment(_serializerVersionKey, _serializerVersionKeyPrefix, true, skipSessionStorage, fragment));
  400. },
  401. parseInfoFromWindowName: function OSF_OUtil$parseInfoFromWindowName(skipSessionStorage, windowName, infoKey) {
  402. try {
  403. var windowNameObj = JSON.parse(windowName);
  404. var infoValue = windowNameObj != null ? windowNameObj[infoKey] : null;
  405. var osfSessionStorage = _getSessionStorage();
  406. if (!skipSessionStorage && osfSessionStorage && windowNameObj != null) {
  407. var sessionKey = windowNameObj[OSF.WindowNameItemKeys.BaseFrameName] + infoKey;
  408. if (infoValue) {
  409. osfSessionStorage.setItem(sessionKey, infoValue);
  410. }
  411. else {
  412. infoValue = osfSessionStorage.getItem(sessionKey);
  413. }
  414. }
  415. return infoValue;
  416. }
  417. catch (Exception) {
  418. return null;
  419. }
  420. },
  421. parseInfoWithGivenFragment: function OSF_OUtil$parseInfoWithGivenFragment(infoKey, infoKeyPrefix, decodeInfo, skipSessionStorage, fragment) {
  422. var fragmentParts = fragment.split(infoKey);
  423. var infoValue = fragmentParts.length > 1 ? fragmentParts[fragmentParts.length - 1] : null;
  424. if (decodeInfo && infoValue != null) {
  425. if (infoValue.indexOf(_fragmentInfoDelimiter) >= 0) {
  426. infoValue = infoValue.split(_fragmentInfoDelimiter)[0];
  427. }
  428. infoValue = decodeURIComponent(infoValue);
  429. }
  430. var osfSessionStorage = _getSessionStorage();
  431. if (!skipSessionStorage && osfSessionStorage) {
  432. var sessionKeyStart = window.name.indexOf(infoKeyPrefix);
  433. if (sessionKeyStart > -1) {
  434. var sessionKeyEnd = window.name.indexOf(";", sessionKeyStart);
  435. if (sessionKeyEnd == -1) {
  436. sessionKeyEnd = window.name.length;
  437. }
  438. var sessionKey = window.name.substring(sessionKeyStart, sessionKeyEnd);
  439. if (infoValue) {
  440. osfSessionStorage.setItem(sessionKey, infoValue);
  441. }
  442. else {
  443. infoValue = osfSessionStorage.getItem(sessionKey);
  444. }
  445. }
  446. }
  447. return infoValue;
  448. },
  449. getConversationId: function OSF_OUtil$getConversationId() {
  450. var searchString = window.location.search;
  451. var conversationId = null;
  452. if (searchString) {
  453. var index = searchString.indexOf("&");
  454. conversationId = index > 0 ? searchString.substring(1, index) : searchString.substr(1);
  455. if (conversationId && conversationId.charAt(conversationId.length - 1) === '=') {
  456. conversationId = conversationId.substring(0, conversationId.length - 1);
  457. if (conversationId) {
  458. conversationId = decodeURIComponent(conversationId);
  459. }
  460. }
  461. }
  462. return conversationId;
  463. },
  464. getInfoItems: function OSF_OUtil$getInfoItems(strInfo) {
  465. var items = strInfo.split("$");
  466. if (typeof items[1] == "undefined") {
  467. items = strInfo.split("|");
  468. }
  469. if (typeof items[1] == "undefined") {
  470. items = strInfo.split("%7C");
  471. }
  472. return items;
  473. },
  474. getXdmFieldValue: function OSF_OUtil$getXdmFieldValue(xdmFieldName, skipSessionStorage) {
  475. var fieldValue = '';
  476. var xdmInfoValue = OSF.OUtil.parseXdmInfo(skipSessionStorage);
  477. if (xdmInfoValue) {
  478. var items = OSF.OUtil.getInfoItems(xdmInfoValue);
  479. if (items != undefined && items.length >= 3) {
  480. switch (xdmFieldName) {
  481. case OSF.XdmFieldName.ConversationUrl:
  482. fieldValue = items[2];
  483. break;
  484. case OSF.XdmFieldName.AppId:
  485. fieldValue = items[1];
  486. break;
  487. }
  488. }
  489. }
  490. return fieldValue;
  491. },
  492. validateParamObject: function OSF_OUtil$validateParamObject(params, expectedProperties, callback) {
  493. var e = Function._validateParams(arguments, [{ name: "params", type: Object, mayBeNull: false },
  494. { name: "expectedProperties", type: Object, mayBeNull: false },
  495. { name: "callback", type: Function, mayBeNull: true }
  496. ]);
  497. if (e)
  498. throw e;
  499. for (var p in expectedProperties) {
  500. e = Function._validateParameter(params[p], expectedProperties[p], p);
  501. if (e)
  502. throw e;
  503. }
  504. },
  505. writeProfilerMark: function OSF_OUtil$writeProfilerMark(text) {
  506. if (window.msWriteProfilerMark) {
  507. window.msWriteProfilerMark(text);
  508. OsfMsAjaxFactory.msAjaxDebug.trace(text);
  509. }
  510. },
  511. outputDebug: function OSF_OUtil$outputDebug(text) {
  512. if (typeof (OsfMsAjaxFactory) !== 'undefined' && OsfMsAjaxFactory.msAjaxDebug && OsfMsAjaxFactory.msAjaxDebug.trace) {
  513. OsfMsAjaxFactory.msAjaxDebug.trace(text);
  514. }
  515. },
  516. defineNondefaultProperty: function OSF_OUtil$defineNondefaultProperty(obj, prop, descriptor, attributes) {
  517. descriptor = descriptor || {};
  518. for (var nd in attributes) {
  519. var attribute = attributes[nd];
  520. if (descriptor[attribute] == undefined) {
  521. descriptor[attribute] = true;
  522. }
  523. }
  524. Object.defineProperty(obj, prop, descriptor);
  525. return obj;
  526. },
  527. defineNondefaultProperties: function OSF_OUtil$defineNondefaultProperties(obj, descriptors, attributes) {
  528. descriptors = descriptors || {};
  529. for (var prop in descriptors) {
  530. OSF.OUtil.defineNondefaultProperty(obj, prop, descriptors[prop], attributes);
  531. }
  532. return obj;
  533. },
  534. defineEnumerableProperty: function OSF_OUtil$defineEnumerableProperty(obj, prop, descriptor) {
  535. return OSF.OUtil.defineNondefaultProperty(obj, prop, descriptor, ["enumerable"]);
  536. },
  537. defineEnumerableProperties: function OSF_OUtil$defineEnumerableProperties(obj, descriptors) {
  538. return OSF.OUtil.defineNondefaultProperties(obj, descriptors, ["enumerable"]);
  539. },
  540. defineMutableProperty: function OSF_OUtil$defineMutableProperty(obj, prop, descriptor) {
  541. return OSF.OUtil.defineNondefaultProperty(obj, prop, descriptor, ["writable", "enumerable", "configurable"]);
  542. },
  543. defineMutableProperties: function OSF_OUtil$defineMutableProperties(obj, descriptors) {
  544. return OSF.OUtil.defineNondefaultProperties(obj, descriptors, ["writable", "enumerable", "configurable"]);
  545. },
  546. finalizeProperties: function OSF_OUtil$finalizeProperties(obj, descriptor) {
  547. descriptor = descriptor || {};
  548. var props = Object.getOwnPropertyNames(obj);
  549. var propsLength = props.length;
  550. for (var i = 0; i < propsLength; i++) {
  551. var prop = props[i];
  552. var desc = Object.getOwnPropertyDescriptor(obj, prop);
  553. if (!desc.get && !desc.set) {
  554. desc.writable = descriptor.writable || false;
  555. }
  556. desc.configurable = descriptor.configurable || false;
  557. desc.enumerable = descriptor.enumerable || true;
  558. Object.defineProperty(obj, prop, desc);
  559. }
  560. return obj;
  561. },
  562. mapList: function OSF_OUtil$MapList(list, mapFunction) {
  563. var ret = [];
  564. if (list) {
  565. for (var item in list) {
  566. ret.push(mapFunction(list[item]));
  567. }
  568. }
  569. return ret;
  570. },
  571. listContainsKey: function OSF_OUtil$listContainsKey(list, key) {
  572. for (var item in list) {
  573. if (key == item) {
  574. return true;
  575. }
  576. }
  577. return false;
  578. },
  579. listContainsValue: function OSF_OUtil$listContainsElement(list, value) {
  580. for (var item in list) {
  581. if (value == list[item]) {
  582. return true;
  583. }
  584. }
  585. return false;
  586. },
  587. augmentList: function OSF_OUtil$augmentList(list, addenda) {
  588. var add = list.push ? function (key, value) { list.push(value); } : function (key, value) { list[key] = value; };
  589. for (var key in addenda) {
  590. add(key, addenda[key]);
  591. }
  592. },
  593. redefineList: function OSF_Outil$redefineList(oldList, newList) {
  594. for (var key1 in oldList) {
  595. delete oldList[key1];
  596. }
  597. for (var key2 in newList) {
  598. oldList[key2] = newList[key2];
  599. }
  600. },
  601. isArray: function OSF_OUtil$isArray(obj) {
  602. return Object.prototype.toString.apply(obj) === "[object Array]";
  603. },
  604. isFunction: function OSF_OUtil$isFunction(obj) {
  605. return Object.prototype.toString.apply(obj) === "[object Function]";
  606. },
  607. isDate: function OSF_OUtil$isDate(obj) {
  608. return Object.prototype.toString.apply(obj) === "[object Date]";
  609. },
  610. addEventListener: function OSF_OUtil$addEventListener(element, eventName, listener) {
  611. if (element.addEventListener) {
  612. element.addEventListener(eventName, listener, false);
  613. }
  614. else if ((Sys.Browser.agent === Sys.Browser.InternetExplorer) && element.attachEvent) {
  615. element.attachEvent("on" + eventName, listener);
  616. }
  617. else {
  618. element["on" + eventName] = listener;
  619. }
  620. },
  621. removeEventListener: function OSF_OUtil$removeEventListener(element, eventName, listener) {
  622. if (element.removeEventListener) {
  623. element.removeEventListener(eventName, listener, false);
  624. }
  625. else if ((Sys.Browser.agent === Sys.Browser.InternetExplorer) && element.detachEvent) {
  626. element.detachEvent("on" + eventName, listener);
  627. }
  628. else {
  629. element["on" + eventName] = null;
  630. }
  631. },
  632. getCookieValue: function OSF_OUtil$getCookieValue(cookieName) {
  633. var tmpCookieString = RegExp(cookieName + "[^;]+").exec(document.cookie);
  634. return tmpCookieString.toString().replace(/^[^=]+./, "");
  635. },
  636. xhrGet: function OSF_OUtil$xhrGet(url, onSuccess, onError) {
  637. var xmlhttp;
  638. try {
  639. xmlhttp = new XMLHttpRequest();
  640. xmlhttp.onreadystatechange = function () {
  641. if (xmlhttp.readyState == 4) {
  642. if (xmlhttp.status == 200) {
  643. onSuccess(xmlhttp.responseText);
  644. }
  645. else {
  646. onError(xmlhttp.status);
  647. }
  648. }
  649. };
  650. xmlhttp.open("GET", url, true);
  651. xmlhttp.send();
  652. }
  653. catch (ex) {
  654. onError(ex);
  655. }
  656. },
  657. xhrGetFull: function OSF_OUtil$xhrGetFull(url, oneDriveFileName, onSuccess, onError) {
  658. var xmlhttp;
  659. var requestedFileName = oneDriveFileName;
  660. try {
  661. xmlhttp = new XMLHttpRequest();
  662. xmlhttp.onreadystatechange = function () {
  663. if (xmlhttp.readyState == 4) {
  664. if (xmlhttp.status == 200) {
  665. onSuccess(xmlhttp, requestedFileName);
  666. }
  667. else {
  668. onError(xmlhttp.status);
  669. }
  670. }
  671. };
  672. xmlhttp.open("GET", url, true);
  673. xmlhttp.send();
  674. }
  675. catch (ex) {
  676. onError(ex);
  677. }
  678. },
  679. encodeBase64: function OSF_Outil$encodeBase64(input) {
  680. if (!input)
  681. return input;
  682. var codex = "ABCDEFGHIJKLMNOP" + "QRSTUVWXYZabcdef" + "ghijklmnopqrstuv" + "wxyz0123456789+/=";
  683. var output = [];
  684. var temp = [];
  685. var index = 0;
  686. var c1, c2, c3, a, b, c;
  687. var i;
  688. var length = input.length;
  689. do {
  690. c1 = input.charCodeAt(index++);
  691. c2 = input.charCodeAt(index++);
  692. c3 = input.charCodeAt(index++);
  693. i = 0;
  694. a = c1 & 255;
  695. b = c1 >> 8;
  696. c = c2 & 255;
  697. temp[i++] = a >> 2;
  698. temp[i++] = ((a & 3) << 4) | (b >> 4);
  699. temp[i++] = ((b & 15) << 2) | (c >> 6);
  700. temp[i++] = c & 63;
  701. if (!isNaN(c2)) {
  702. a = c2 >> 8;
  703. b = c3 & 255;
  704. c = c3 >> 8;
  705. temp[i++] = a >> 2;
  706. temp[i++] = ((a & 3) << 4) | (b >> 4);
  707. temp[i++] = ((b & 15) << 2) | (c >> 6);
  708. temp[i++] = c & 63;
  709. }
  710. if (isNaN(c2)) {
  711. temp[i - 1] = 64;
  712. }
  713. else if (isNaN(c3)) {
  714. temp[i - 2] = 64;
  715. temp[i - 1] = 64;
  716. }
  717. for (var t = 0; t < i; t++) {
  718. output.push(codex.charAt(temp[t]));
  719. }
  720. } while (index < length);
  721. return output.join("");
  722. },
  723. getSessionStorage: function OSF_Outil$getSessionStorage() {
  724. return _getSessionStorage();
  725. },
  726. getLocalStorage: function OSF_Outil$getLocalStorage() {
  727. if (!_safeLocalStorage) {
  728. try {
  729. var localStorage = window.localStorage;
  730. }
  731. catch (ex) {
  732. localStorage = null;
  733. }
  734. _safeLocalStorage = new OfficeExt.SafeStorage(localStorage);
  735. }
  736. return _safeLocalStorage;
  737. },
  738. convertIntToCssHexColor: function OSF_Outil$convertIntToCssHexColor(val) {
  739. var hex = "#" + (Number(val) + 0x1000000).toString(16).slice(-6);
  740. return hex;
  741. },
  742. attachClickHandler: function OSF_Outil$attachClickHandler(element, handler) {
  743. element.onclick = function (e) {
  744. handler();
  745. };
  746. element.ontouchend = function (e) {
  747. handler();
  748. e.preventDefault();
  749. };
  750. },
  751. getQueryStringParamValue: function OSF_Outil$getQueryStringParamValue(queryString, paramName) {
  752. var e = Function._validateParams(arguments, [{ name: "queryString", type: String, mayBeNull: false },
  753. { name: "paramName", type: String, mayBeNull: false }
  754. ]);
  755. if (e) {
  756. OsfMsAjaxFactory.msAjaxDebug.trace("OSF_Outil_getQueryStringParamValue: Parameters cannot be null.");
  757. return "";
  758. }
  759. var queryExp = new RegExp("[\\?&]" + paramName + "=([^&#]*)", "i");
  760. if (!queryExp.test(queryString)) {
  761. OsfMsAjaxFactory.msAjaxDebug.trace("OSF_Outil_getQueryStringParamValue: The parameter is not found.");
  762. return "";
  763. }
  764. return queryExp.exec(queryString)[1];
  765. },
  766. isiOS: function OSF_Outil$isiOS() {
  767. return (window.navigator.userAgent.match(/(iPad|iPhone|iPod)/g) ? true : false);
  768. },
  769. isChrome: function OSF_Outil$isChrome() {
  770. return (window.navigator.userAgent.indexOf("Chrome") > 0) && !OSF.OUtil.isEdge();
  771. },
  772. isEdge: function OSF_Outil$isEdge() {
  773. return window.navigator.userAgent.indexOf("Edge") > 0;
  774. },
  775. isIE: function OSF_Outil$isIE() {
  776. return window.navigator.userAgent.indexOf("Trident") > 0;
  777. },
  778. isFirefox: function OSF_Outil$isFirefox() {
  779. return window.navigator.userAgent.indexOf("Firefox") > 0;
  780. },
  781. shallowCopy: function OSF_Outil$shallowCopy(sourceObj) {
  782. if (sourceObj == null) {
  783. return null;
  784. }
  785. else if (Array.isArray(sourceObj)) {
  786. var copyArr = [];
  787. for (var i = 0; i < sourceObj.length; i++) {
  788. copyArr.push(sourceObj[i]);
  789. }
  790. return copyArr;
  791. }
  792. else {
  793. var copyObj = sourceObj.constructor();
  794. for (var property in sourceObj) {
  795. if (sourceObj.hasOwnProperty(property)) {
  796. copyObj[property] = sourceObj[property];
  797. }
  798. }
  799. return copyObj;
  800. }
  801. },
  802. createObject: function OSF_Outil$createObject(properties) {
  803. var obj = null;
  804. if (properties) {
  805. obj = {};
  806. var len = properties.length;
  807. for (var i = 0; i < len; i++) {
  808. obj[properties[i].name] = properties[i].value;
  809. }
  810. }
  811. return obj;
  812. },
  813. addClass: function OSF_OUtil$addClass(elmt, val) {
  814. if (!OSF.OUtil.hasClass(elmt, val)) {
  815. var className = elmt.getAttribute(_classN);
  816. if (className) {
  817. elmt.setAttribute(_classN, className + " " + val);
  818. }
  819. else {
  820. elmt.setAttribute(_classN, val);
  821. }
  822. }
  823. },
  824. hasClass: function OSF_OUtil$hasClass(elmt, clsName) {
  825. var className = elmt.getAttribute(_classN);
  826. return className && className.match(new RegExp('(\\s|^)' + clsName + '(\\s|$)'));
  827. },
  828. focusToFirstTabbable: function OSF_OUtil$focusToFirstTabbable(all, backward) {
  829. var next;
  830. var focused = false;
  831. var candidate;
  832. var setFlag = function (e) {
  833. focused = true;
  834. };
  835. var findNextPos = function (allLen, currPos, backward) {
  836. if (currPos < 0 || currPos > allLen) {
  837. return -1;
  838. }
  839. else if (currPos === 0 && backward) {
  840. return -1;
  841. }
  842. else if (currPos === allLen - 1 && !backward) {
  843. return -1;
  844. }
  845. if (backward) {
  846. return currPos - 1;
  847. }
  848. else {
  849. return currPos + 1;
  850. }
  851. };
  852. all = _reOrderTabbableElements(all);
  853. next = backward ? all.length - 1 : 0;
  854. if (all.length === 0) {
  855. return null;
  856. }
  857. while (!focused && next >= 0 && next < all.length) {
  858. candidate = all[next];
  859. window.focus();
  860. candidate.addEventListener('focus', setFlag);
  861. candidate.focus();
  862. candidate.removeEventListener('focus', setFlag);
  863. next = findNextPos(all.length, next, backward);
  864. if (!focused && candidate === document.activeElement) {
  865. focused = true;
  866. }
  867. }
  868. if (focused) {
  869. return candidate;
  870. }
  871. else {
  872. return null;
  873. }
  874. },
  875. focusToNextTabbable: function OSF_OUtil$focusToNextTabbable(all, curr, shift) {
  876. var currPos;
  877. var next;
  878. var focused = false;
  879. var candidate;
  880. var setFlag = function (e) {
  881. focused = true;
  882. };
  883. var findCurrPos = function (all, curr) {
  884. var i = 0;
  885. for (; i < all.length; i++) {
  886. if (all[i] === curr) {
  887. return i;
  888. }
  889. }
  890. return -1;
  891. };
  892. var findNextPos = function (allLen, currPos, shift) {
  893. if (currPos < 0 || currPos > allLen) {
  894. return -1;
  895. }
  896. else if (currPos === 0 && shift) {
  897. return -1;
  898. }
  899. else if (currPos === allLen - 1 && !shift) {
  900. return -1;
  901. }
  902. if (shift) {
  903. return currPos - 1;
  904. }
  905. else {
  906. return currPos + 1;
  907. }
  908. };
  909. all = _reOrderTabbableElements(all);
  910. currPos = findCurrPos(all, curr);
  911. next = findNextPos(all.length, currPos, shift);
  912. if (next < 0) {
  913. return null;
  914. }
  915. while (!focused && next >= 0 && next < all.length) {
  916. candidate = all[next];
  917. candidate.addEventListener('focus', setFlag);
  918. candidate.focus();
  919. candidate.removeEventListener('focus', setFlag);
  920. next = findNextPos(all.length, next, shift);
  921. if (!focused && candidate === document.activeElement) {
  922. focused = true;
  923. }
  924. }
  925. if (focused) {
  926. return candidate;
  927. }
  928. else {
  929. return null;
  930. }
  931. }
  932. };
  933. })();
  934. OSF.OUtil.Guid = (function () {
  935. var hexCode = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"];
  936. return {
  937. generateNewGuid: function OSF_Outil_Guid$generateNewGuid() {
  938. var result = "";
  939. var tick = (new Date()).getTime();
  940. var index = 0;
  941. for (; index < 32 && tick > 0; index++) {
  942. if (index == 8 || index == 12 || index == 16 || index == 20) {
  943. result += "-";
  944. }
  945. result += hexCode[tick % 16];
  946. tick = Math.floor(tick / 16);
  947. }
  948. for (; index < 32; index++) {
  949. if (index == 8 || index == 12 || index == 16 || index == 20) {
  950. result += "-";
  951. }
  952. result += hexCode[Math.floor(Math.random() * 16)];
  953. }
  954. return result;
  955. }
  956. };
  957. })();
  958. window.OSF = OSF;
  959. OSF.OUtil.setNamespace("OSF", window);
  960. OSF.AppName = {
  961. Unsupported: 0,
  962. Excel: 1,
  963. Word: 2,
  964. PowerPoint: 4,
  965. Outlook: 8,
  966. ExcelWebApp: 16,
  967. WordWebApp: 32,
  968. OutlookWebApp: 64,
  969. Project: 128,
  970. AccessWebApp: 256,
  971. PowerpointWebApp: 512,
  972. ExcelIOS: 1024,
  973. Sway: 2048,
  974. WordIOS: 4096,
  975. PowerPointIOS: 8192,
  976. Access: 16384,
  977. Lync: 32768,
  978. OutlookIOS: 65536,
  979. OneNoteWebApp: 131072,
  980. OneNote: 262144,
  981. ExcelWinRT: 524288,
  982. WordWinRT: 1048576,
  983. PowerpointWinRT: 2097152,
  984. OutlookAndroid: 4194304,
  985. OneNoteWinRT: 8388608,
  986. ExcelAndroid: 8388609,
  987. VisioWebApp: 8388610
  988. };
  989. OSF.InternalPerfMarker = {
  990. DataCoercionBegin: "Agave.HostCall.CoerceDataStart",
  991. DataCoercionEnd: "Agave.HostCall.CoerceDataEnd"
  992. };
  993. OSF.HostCallPerfMarker = {
  994. IssueCall: "Agave.HostCall.IssueCall",
  995. ReceiveResponse: "Agave.HostCall.ReceiveResponse",
  996. RuntimeExceptionRaised: "Agave.HostCall.RuntimeExecptionRaised"
  997. };
  998. OSF.AgaveHostAction = {
  999. "Select": 0,
  1000. "UnSelect": 1,
  1001. "CancelDialog": 2,
  1002. "InsertAgave": 3,
  1003. "CtrlF6In": 4,
  1004. "CtrlF6Exit": 5,
  1005. "CtrlF6ExitShift": 6,
  1006. "SelectWithError": 7,
  1007. "NotifyHostError": 8,
  1008. "RefreshAddinCommands": 9,
  1009. "PageIsReady": 10,
  1010. "TabIn": 11,
  1011. "TabInShift": 12,
  1012. "TabExit": 13,
  1013. "TabExitShift": 14,
  1014. "EscExit": 15,
  1015. "F2Exit": 16,
  1016. "ExitNoFocusable": 17,
  1017. "ExitNoFocusableShift": 18
  1018. };
  1019. OSF.SharedConstants = {
  1020. "NotificationConversationIdSuffix": '_ntf'
  1021. };
  1022. OSF.DialogMessageType = {
  1023. DialogMessageReceived: 0,
  1024. DialogParentMessageReceived: 1,
  1025. DialogClosed: 12006
  1026. };
  1027. OSF.OfficeAppContext = function OSF_OfficeAppContext(id, appName, appVersion, appUILocale, dataLocale, docUrl, clientMode, settings, reason, osfControlType, eToken, correlationId, appInstanceId, touchEnabled, commerceAllowed, appMinorVersion, requirementMatrix, hostCustomMessage, hostFullVersion, clientWindowHeight, clientWindowWidth, addinName, appDomains, dialogRequirementMatrix) {
  1028. this._id = id;
  1029. this._appName = appName;
  1030. this._appVersion = appVersion;
  1031. this._appUILocale = appUILocale;
  1032. this._dataLocale = dataLocale;
  1033. this._docUrl = docUrl;
  1034. this._clientMode = clientMode;
  1035. this._settings = settings;
  1036. this._reason = reason;
  1037. this._osfControlType = osfControlType;
  1038. this._eToken = eToken;
  1039. this._correlationId = correlationId;
  1040. this._appInstanceId = appInstanceId;
  1041. this._touchEnabled = touchEnabled;
  1042. this._commerceAllowed = commerceAllowed;
  1043. this._appMinorVersion = appMinorVersion;
  1044. this._requirementMatrix = requirementMatrix;
  1045. this._hostCustomMessage = hostCustomMessage;
  1046. this._hostFullVersion = hostFullVersion;
  1047. this._isDialog = false;
  1048. this._clientWindowHeight = clientWindowHeight;
  1049. this._clientWindowWidth = clientWindowWidth;
  1050. this._addinName = addinName;
  1051. this._appDomains = appDomains;
  1052. this._dialogRequirementMatrix = dialogRequirementMatrix;
  1053. this.get_id = function get_id() { return this._id; };
  1054. this.get_appName = function get_appName() { return this._appName; };
  1055. this.get_appVersion = function get_appVersion() { return this._appVersion; };
  1056. this.get_appUILocale = function get_appUILocale() { return this._appUILocale; };
  1057. this.get_dataLocale = function get_dataLocale() { return this._dataLocale; };
  1058. this.get_docUrl = function get_docUrl() { return this._docUrl; };
  1059. this.get_clientMode = function get_clientMode() { return this._clientMode; };
  1060. this.get_bindings = function get_bindings() { return this._bindings; };
  1061. this.get_settings = function get_settings() { return this._settings; };
  1062. this.get_reason = function get_reason() { return this._reason; };
  1063. this.get_osfControlType = function get_osfControlType() { return this._osfControlType; };
  1064. this.get_eToken = function get_eToken() { return this._eToken; };
  1065. this.get_correlationId = function get_correlationId() { return this._correlationId; };
  1066. this.get_appInstanceId = function get_appInstanceId() { return this._appInstanceId; };
  1067. this.get_touchEnabled = function get_touchEnabled() { return this._touchEnabled; };
  1068. this.get_commerceAllowed = function get_commerceAllowed() { return this._commerceAllowed; };
  1069. this.get_appMinorVersion = function get_appMinorVersion() { return this._appMinorVersion; };
  1070. this.get_requirementMatrix = function get_requirementMatrix() { return this._requirementMatrix; };
  1071. this.get_dialogRequirementMatrix = function get_dialogRequirementMatrix() { return this._dialogRequirementMatrix; };
  1072. this.get_hostCustomMessage = function get_hostCustomMessage() { return this._hostCustomMessage; };
  1073. this.get_hostFullVersion = function get_hostFullVersion() { return this._hostFullVersion; };
  1074. this.get_isDialog = function get_isDialog() { return this._isDialog; };
  1075. this.get_clientWindowHeight = function get_clientWindowHeight() { return this._clientWindowHeight; };
  1076. this.get_clientWindowWidth = function get_clientWindowWidth() { return this._clientWindowWidth; };
  1077. this.get_addinName = function get_addinName() { return this._addinName; };
  1078. this.get_appDomains = function get_appDomains() { return this._appDomains; };
  1079. };
  1080. OSF.OsfControlType = {
  1081. DocumentLevel: 0,
  1082. ContainerLevel: 1
  1083. };
  1084. OSF.ClientMode = {
  1085. ReadOnly: 0,
  1086. ReadWrite: 1
  1087. };
  1088. OSF.OUtil.setNamespace("Microsoft", window);
  1089. OSF.OUtil.setNamespace("Office", Microsoft);
  1090. OSF.OUtil.setNamespace("Client", Microsoft.Office);
  1091. OSF.OUtil.setNamespace("WebExtension", Microsoft.Office);
  1092. Microsoft.Office.WebExtension.InitializationReason = {
  1093. Inserted: "inserted",
  1094. DocumentOpened: "documentOpened"
  1095. };
  1096. Microsoft.Office.WebExtension.ValueFormat = {
  1097. Unformatted: "unformatted",
  1098. Formatted: "formatted"
  1099. };
  1100. Microsoft.Office.WebExtension.FilterType = {
  1101. All: "all"
  1102. };
  1103. Microsoft.Office.WebExtension.Parameters = {
  1104. BindingType: "bindingType",
  1105. CoercionType: "coercionType",
  1106. ValueFormat: "valueFormat",
  1107. FilterType: "filterType",
  1108. Columns: "columns",
  1109. SampleData: "sampleData",
  1110. GoToType: "goToType",
  1111. SelectionMode: "selectionMode",
  1112. Id: "id",
  1113. PromptText: "promptText",
  1114. ItemName: "itemName",
  1115. FailOnCollision: "failOnCollision",
  1116. StartRow: "startRow",
  1117. StartColumn: "startColumn",
  1118. RowCount: "rowCount",
  1119. ColumnCount: "columnCount",
  1120. Callback: "callback",
  1121. AsyncContext: "asyncContext",
  1122. Data: "data",
  1123. Rows: "rows",
  1124. OverwriteIfStale: "overwriteIfStale",
  1125. FileType: "fileType",
  1126. EventType: "eventType",
  1127. Handler: "handler",
  1128. SliceSize: "sliceSize",
  1129. SliceIndex: "sliceIndex",
  1130. ActiveView: "activeView",
  1131. Status: "status",
  1132. Xml: "xml",
  1133. Namespace: "namespace",
  1134. Prefix: "prefix",
  1135. XPath: "xPath",
  1136. Text: "text",
  1137. ImageLeft: "imageLeft",
  1138. ImageTop: "imageTop",
  1139. ImageWidth: "imageWidth",
  1140. ImageHeight: "imageHeight",
  1141. TaskId: "taskId",
  1142. FieldId: "fieldId",
  1143. FieldValue: "fieldValue",
  1144. ServerUrl: "serverUrl",
  1145. ListName: "listName",
  1146. ResourceId: "resourceId",
  1147. ViewType: "viewType",
  1148. ViewName: "viewName",
  1149. GetRawValue: "getRawValue",
  1150. CellFormat: "cellFormat",
  1151. TableOptions: "tableOptions",
  1152. TaskIndex: "taskIndex",
  1153. ResourceIndex: "resourceIndex",
  1154. CustomFieldId: "customFieldId",
  1155. Url: "url",
  1156. MessageHandler: "messageHandler",
  1157. Width: "width",
  1158. Height: "height",
  1159. RequireHTTPs: "requireHTTPS",
  1160. MessageToParent: "messageToParent",
  1161. DisplayInIframe: "displayInIframe",
  1162. MessageContent: "messageContent"
  1163. };
  1164. OSF.OUtil.setNamespace("DDA", OSF);
  1165. OSF.DDA.DocumentMode = {
  1166. ReadOnly: 1,
  1167. ReadWrite: 0
  1168. };
  1169. OSF.DDA.PropertyDescriptors = {
  1170. AsyncResultStatus: "AsyncResultStatus"
  1171. };
  1172. OSF.DDA.EventDescriptors = {};
  1173. OSF.DDA.ListDescriptors = {};
  1174. OSF.DDA.UI = {};
  1175. OSF.DDA.getXdmEventName = function OSF_DDA$GetXdmEventName(id, eventType) {
  1176. if (eventType == Microsoft.Office.WebExtension.EventType.BindingSelectionChanged ||
  1177. eventType == Microsoft.Office.WebExtension.EventType.BindingDataChanged ||
  1178. eventType == Microsoft.Office.WebExtension.EventType.DataNodeDeleted ||
  1179. eventType == Microsoft.Office.WebExtension.EventType.DataNodeInserted ||
  1180. eventType == Microsoft.Office.WebExtension.EventType.DataNodeReplaced) {
  1181. return id + "_" + eventType;
  1182. }
  1183. else {
  1184. return eventType;
  1185. }
  1186. };
  1187. OSF.DDA.MethodDispId = {
  1188. dispidMethodMin: 64,
  1189. dispidGetSelectedDataMethod: 64,
  1190. dispidSetSelectedDataMethod: 65,
  1191. dispidAddBindingFromSelectionMethod: 66,
  1192. dispidAddBindingFromPromptMethod: 67,
  1193. dispidGetBindingMethod: 68,
  1194. dispidReleaseBindingMethod: 69,
  1195. dispidGetBindingDataMethod: 70,
  1196. dispidSetBindingDataMethod: 71,
  1197. dispidAddRowsMethod: 72,
  1198. dispidClearAllRowsMethod: 73,
  1199. dispidGetAllBindingsMethod: 74,
  1200. dispidLoadSettingsMethod: 75,
  1201. dispidSaveSettingsMethod: 76,
  1202. dispidGetDocumentCopyMethod: 77,
  1203. dispidAddBindingFromNamedItemMethod: 78,
  1204. dispidAddColumnsMethod: 79,
  1205. dispidGetDocumentCopyChunkMethod: 80,
  1206. dispidReleaseDocumentCopyMethod: 81,
  1207. dispidNavigateToMethod: 82,
  1208. dispidGetActiveViewMethod: 83,
  1209. dispidGetDocumentThemeMethod: 84,
  1210. dispidGetOfficeThemeMethod: 85,
  1211. dispidGetFilePropertiesMethod: 86,
  1212. dispidClearFormatsMethod: 87,
  1213. dispidSetTableOptionsMethod: 88,
  1214. dispidSetFormatsMethod: 89,
  1215. dispidExecuteRichApiRequestMethod: 93,
  1216. dispidAppCommandInvocationCompletedMethod: 94,
  1217. dispidCloseContainerMethod: 97,
  1218. dispidGetSelectedTaskMethod: 110,
  1219. dispidGetSelectedResourceMethod: 111,
  1220. dispidGetTaskMethod: 112,
  1221. dispidGetResourceFieldMethod: 113,
  1222. dispidGetWSSUrlMethod: 114,
  1223. dispidGetTaskFieldMethod: 115,
  1224. dispidGetProjectFieldMethod: 116,
  1225. dispidGetSelectedViewMethod: 117,
  1226. dispidGetTaskByIndexMethod: 118,
  1227. dispidGetResourceByIndexMethod: 119,
  1228. dispidSetTaskFieldMethod: 120,
  1229. dispidSetResourceFieldMethod: 121,
  1230. dispidGetMaxTaskIndexMethod: 122,
  1231. dispidGetMaxResourceIndexMethod: 123,
  1232. dispidCreateTaskMethod: 124,
  1233. dispidAddDataPartMethod: 128,
  1234. dispidGetDataPartByIdMethod: 129,
  1235. dispidGetDataPartsByNamespaceMethod: 130,
  1236. dispidGetDataPartXmlMethod: 131,
  1237. dispidGetDataPartNodesMethod: 132,
  1238. dispidDeleteDataPartMethod: 133,
  1239. dispidGetDataNodeValueMethod: 134,
  1240. dispidGetDataNodeXmlMethod: 135,
  1241. dispidGetDataNodesMethod: 136,
  1242. dispidSetDataNodeValueMethod: 137,
  1243. dispidSetDataNodeXmlMethod: 138,
  1244. dispidAddDataNamespaceMethod: 139,
  1245. dispidGetDataUriByPrefixMethod: 140,
  1246. dispidGetDataPrefixByUriMethod: 141,
  1247. dispidGetDataNodeTextMethod: 142,
  1248. dispidSetDataNodeTextMethod: 143,
  1249. dispidMessageParentMethod: 144,
  1250. dispidSendMessageMethod: 145,
  1251. dispidMethodMax: 145
  1252. };
  1253. OSF.DDA.EventDispId = {
  1254. dispidEventMin: 0,
  1255. dispidInitializeEvent: 0,
  1256. dispidSettingsChangedEvent: 1,
  1257. dispidDocumentSelectionChangedEvent: 2,
  1258. dispidBindingSelectionChangedEvent: 3,
  1259. dispidBindingDataChangedEvent: 4,
  1260. dispidDocumentOpenEvent: 5,
  1261. dispidDocumentCloseEvent: 6,
  1262. dispidActiveViewChangedEvent: 7,
  1263. dispidDocumentThemeChangedEvent: 8,
  1264. dispidOfficeThemeChangedEvent: 9,
  1265. dispidDialogMessageReceivedEvent: 10,
  1266. dispidDialogNotificationShownInAddinEvent: 11,
  1267. dispidDialogParentMessageReceivedEvent: 12,
  1268. dispidActivationStatusChangedEvent: 32,
  1269. dispidAppCommandInvokedEvent: 39,
  1270. dispidOlkItemSelectedChangedEvent: 46,
  1271. dispidTaskSelectionChangedEvent: 56,
  1272. dispidResourceSelectionChangedEvent: 57,
  1273. dispidViewSelectionChangedEvent: 58,
  1274. dispidDataNodeAddedEvent: 60,
  1275. dispidDataNodeReplacedEvent: 61,
  1276. dispidDataNodeDeletedEvent: 62,
  1277. dispidEventMax: 63
  1278. };
  1279. OSF.DDA.ErrorCodeManager = (function () {
  1280. var _errorMappings = {};
  1281. return {
  1282. getErrorArgs: function OSF_DDA_ErrorCodeManager$getErrorArgs(errorCode) {
  1283. var errorArgs = _errorMappings[errorCode];
  1284. if (!errorArgs) {
  1285. errorArgs = _errorMappings[this.errorCodes.ooeInternalError];
  1286. }
  1287. else {
  1288. if (!errorArgs.name) {
  1289. errorArgs.name = _errorMappings[this.errorCodes.ooeInternalError].name;
  1290. }
  1291. if (!errorArgs.message) {
  1292. errorArgs.message = _errorMappings[this.errorCodes.ooeInternalError].message;
  1293. }
  1294. }
  1295. return errorArgs;
  1296. },
  1297. addErrorMessage: function OSF_DDA_ErrorCodeManager$addErrorMessage(errorCode, errorNameMessage) {
  1298. _errorMappings[errorCode] = errorNameMessage;
  1299. },
  1300. errorCodes: {
  1301. ooeSuccess: 0,
  1302. ooeChunkResult: 1,
  1303. ooeCoercionTypeNotSupported: 1000,
  1304. ooeGetSelectionNotMatchDataType: 1001,
  1305. ooeCoercionTypeNotMatchBinding: 1002,
  1306. ooeInvalidGetRowColumnCounts: 1003,
  1307. ooeSelectionNotSupportCoercionType: 1004,
  1308. ooeInvalidGetStartRowColumn: 1005,
  1309. ooeNonUniformPartialGetNotSupported: 1006,
  1310. ooeGetDataIsTooLarge: 1008,
  1311. ooeFileTypeNotSupported: 1009,
  1312. ooeGetDataParametersConflict: 1010,
  1313. ooeInvalidGetColumns: 1011,
  1314. ooeInvalidGetRows: 1012,
  1315. ooeInvalidReadForBlankRow: 1013,
  1316. ooeUnsupportedDataObject: 2000,
  1317. ooeCannotWriteToSelection: 2001,
  1318. ooeDataNotMatchSelection: 2002,
  1319. ooeOverwriteWorksheetData: 2003,
  1320. ooeDataNotMatchBindingSize: 2004,
  1321. ooeInvalidSetStartRowColumn: 2005,
  1322. ooeInvalidDataFormat: 2006,
  1323. ooeDataNotMatchCoercionType: 2007,
  1324. ooeDataNotMatchBindingType: 2008,
  1325. ooeSetDataIsTooLarge: 2009,
  1326. ooeNonUniformPartialSetNotSupported: 2010,
  1327. ooeInvalidSetColumns: 2011,
  1328. ooeInvalidSetRows: 2012,
  1329. ooeSetDataParametersConflict: 2013,
  1330. ooeCellDataAmountBeyondLimits: 2014,
  1331. ooeSelectionCannotBound: 3000,
  1332. ooeBindingNotExist: 3002,
  1333. ooeBindingToMultipleSelection: 3003,
  1334. ooeInvalidSelectionForBindingType: 3004,
  1335. ooeOperationNotSupportedOnThisBindingType: 3005,
  1336. ooeNamedItemNotFound: 3006,
  1337. ooeMultipleNamedItemFound: 3007,
  1338. ooeInvalidNamedItemForBindingType: 3008,
  1339. ooeUnknownBindingType: 3009,
  1340. ooeOperationNotSupportedOnMatrixData: 3010,
  1341. ooeInvalidColumnsForBinding: 3011,
  1342. ooeSettingNameNotExist: 4000,
  1343. ooeSettingsCannotSave: 4001,
  1344. ooeSettingsAreStale: 4002,
  1345. ooeOperationNotSupported: 5000,
  1346. ooeInternalError: 5001,
  1347. ooeDocumentReadOnly: 5002,
  1348. ooeEventHandlerNotExist: 5003,
  1349. ooeInvalidApiCallInContext: 5004,
  1350. ooeShuttingDown: 5005,
  1351. ooeUnsupportedEnumeration: 5007,
  1352. ooeIndexOutOfRange: 5008,
  1353. ooeBrowserAPINotSupported: 5009,
  1354. ooeInvalidParam: 5010,
  1355. ooeRequestTimeout: 5011,
  1356. ooeTooManyIncompleteRequests: 5100,
  1357. ooeRequestTokenUnavailable: 5101,
  1358. ooeActivityLimitReached: 5102,
  1359. ooeCustomXmlNodeNotFound: 6000,
  1360. ooeCustomXmlError: 6100,
  1361. ooeCustomXmlExceedQuota: 6101,
  1362. ooeCustomXmlOutOfDate: 6102,
  1363. ooeNoCapability: 7000,
  1364. ooeCannotNavTo: 7001,
  1365. ooeSpecifiedIdNotExist: 7002,
  1366. ooeNavOutOfBound: 7004,
  1367. ooeElementMissing: 8000,
  1368. ooeProtectedError: 8001,
  1369. ooeInvalidCellsValue: 8010,
  1370. ooeInvalidTableOptionValue: 8011,
  1371. ooeInvalidFormatValue: 8012,
  1372. ooeRowIndexOutOfRange: 8020,
  1373. ooeColIndexOutOfRange: 8021,
  1374. ooeFormatValueOutOfRange: 8022,
  1375. ooeCellFormatAmountBeyondLimits: 8023,
  1376. ooeMemoryFileLimit: 11000,
  1377. ooeNetworkProblemRetrieveFile: 11001,
  1378. ooeInvalidSliceSize: 11002,
  1379. ooeInvalidCallback: 11101,
  1380. ooeInvalidWidth: 12000,
  1381. ooeInvalidHeight: 12001,
  1382. ooeNavigationError: 12002,
  1383. ooeInvalidScheme: 12003,
  1384. ooeAppDomains: 12004,
  1385. ooeRequireHTTPS: 12005,
  1386. ooeWebDialogClosed: 12006,
  1387. ooeDialogAlreadyOpened: 12007,
  1388. ooeEndUserAllow: 12008,
  1389. ooeEndUserIgnore: 12009,
  1390. ooeNotUILessDialog: 12010,
  1391. ooeCrossZone: 12011
  1392. },
  1393. initializeErrorMessages: function OSF_DDA_ErrorCodeManager$initializeErrorMessages(stringNS) {
  1394. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeCoercionTypeNotSupported] = { name: stringNS.L_InvalidCoercion, message: stringNS.L_CoercionTypeNotSupported };
  1395. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeGetSelectionNotMatchDataType] = { name: stringNS.L_DataReadError, message: stringNS.L_GetSelectionNotSupported };
  1396. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeCoercionTypeNotMatchBinding] = { name: stringNS.L_InvalidCoercion, message: stringNS.L_CoercionTypeNotMatchBinding };
  1397. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeInvalidGetRowColumnCounts] = { name: stringNS.L_DataReadError, message: stringNS.L_InvalidGetRowColumnCounts };
  1398. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeSelectionNotSupportCoercionType] = { name: stringNS.L_DataReadError, message: stringNS.L_SelectionNotSupportCoercionType };
  1399. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeInvalidGetStartRowColumn] = { name: stringNS.L_DataReadError, message: stringNS.L_InvalidGetStartRowColumn };
  1400. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeNonUniformPartialGetNotSupported] = { name: stringNS.L_DataReadError, message: stringNS.L_NonUniformPartialGetNotSupported };
  1401. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeGetDataIsTooLarge] = { name: stringNS.L_DataReadError, message: stringNS.L_GetDataIsTooLarge };
  1402. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeFileTypeNotSupported] = { name: stringNS.L_DataReadError, message: stringNS.L_FileTypeNotSupported };
  1403. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeGetDataParametersConflict] = { name: stringNS.L_DataReadError, message: stringNS.L_GetDataParametersConflict };
  1404. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeInvalidGetColumns] = { name: stringNS.L_DataReadError, message: stringNS.L_InvalidGetColumns };
  1405. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeInvalidGetRows] = { name: stringNS.L_DataReadError, message: stringNS.L_InvalidGetRows };
  1406. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeInvalidReadForBlankRow] = { name: stringNS.L_DataReadError, message: stringNS.L_InvalidReadForBlankRow };
  1407. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeUnsupportedDataObject] = { name: stringNS.L_DataWriteError, message: stringNS.L_UnsupportedDataObject };
  1408. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeCannotWriteToSelection] = { name: stringNS.L_DataWriteError, message: stringNS.L_CannotWriteToSelection };
  1409. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeDataNotMatchSelection] = { name: stringNS.L_DataWriteError, message: stringNS.L_DataNotMatchSelection };
  1410. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeOverwriteWorksheetData] = { name: stringNS.L_DataWriteError, message: stringNS.L_OverwriteWorksheetData };
  1411. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeDataNotMatchBindingSize] = { name: stringNS.L_DataWriteError, message: stringNS.L_DataNotMatchBindingSize };
  1412. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeInvalidSetStartRowColumn] = { name: stringNS.L_DataWriteError, message: stringNS.L_InvalidSetStartRowColumn };
  1413. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeInvalidDataFormat] = { name: stringNS.L_InvalidFormat, message: stringNS.L_InvalidDataFormat };
  1414. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeDataNotMatchCoercionType] = { name: stringNS.L_InvalidDataObject, message: stringNS.L_DataNotMatchCoercionType };
  1415. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeDataNotMatchBindingType] = { name: stringNS.L_InvalidDataObject, message: stringNS.L_DataNotMatchBindingType };
  1416. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeSetDataIsTooLarge] = { name: stringNS.L_DataWriteError, message: stringNS.L_SetDataIsTooLarge };
  1417. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeNonUniformPartialSetNotSupported] = { name: stringNS.L_DataWriteError, message: stringNS.L_NonUniformPartialSetNotSupported };
  1418. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeInvalidSetColumns] = { name: stringNS.L_DataWriteError, message: stringNS.L_InvalidSetColumns };
  1419. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeInvalidSetRows] = { name: stringNS.L_DataWriteError, message: stringNS.L_InvalidSetRows };
  1420. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeSetDataParametersConflict] = { name: stringNS.L_DataWriteError, message: stringNS.L_SetDataParametersConflict };
  1421. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeSelectionCannotBound] = { name: stringNS.L_BindingCreationError, message: stringNS.L_SelectionCannotBound };
  1422. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeBindingNotExist] = { name: stringNS.L_InvalidBindingError, message: stringNS.L_BindingNotExist };
  1423. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeBindingToMultipleSelection] = { name: stringNS.L_BindingCreationError, message: stringNS.L_BindingToMultipleSelection };
  1424. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeInvalidSelectionForBindingType] = { name: stringNS.L_BindingCreationError, message: stringNS.L_InvalidSelectionForBindingType };
  1425. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeOperationNotSupportedOnThisBindingType] = { name: stringNS.L_InvalidBindingOperation, message: stringNS.L_OperationNotSupportedOnThisBindingType };
  1426. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeNamedItemNotFound] = { name: stringNS.L_BindingCreationError, message: stringNS.L_NamedItemNotFound };
  1427. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeMultipleNamedItemFound] = { name: stringNS.L_BindingCreationError, message: stringNS.L_MultipleNamedItemFound };
  1428. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeInvalidNamedItemForBindingType] = { name: stringNS.L_BindingCreationError, message: stringNS.L_InvalidNamedItemForBindingType };
  1429. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeUnknownBindingType] = { name: stringNS.L_InvalidBinding, message: stringNS.L_UnknownBindingType };
  1430. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeOperationNotSupportedOnMatrixData] = { name: stringNS.L_InvalidBindingOperation, message: stringNS.L_OperationNotSupportedOnMatrixData };
  1431. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeInvalidColumnsForBinding] = { name: stringNS.L_InvalidBinding, message: stringNS.L_InvalidColumnsForBinding };
  1432. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeSettingNameNotExist] = { name: stringNS.L_ReadSettingsError, message: stringNS.L_SettingNameNotExist };
  1433. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeSettingsCannotSave] = { name: stringNS.L_SaveSettingsError, message: stringNS.L_SettingsCannotSave };
  1434. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeSettingsAreStale] = { name: stringNS.L_SettingsStaleError, message: stringNS.L_SettingsAreStale };
  1435. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeOperationNotSupported] = { name: stringNS.L_HostError, message: stringNS.L_OperationNotSupported };
  1436. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeInternalError] = { name: stringNS.L_InternalError, message: stringNS.L_InternalErrorDescription };
  1437. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeDocumentReadOnly] = { name: stringNS.L_PermissionDenied, message: stringNS.L_DocumentReadOnly };
  1438. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeEventHandlerNotExist] = { name: stringNS.L_EventRegistrationError, message: stringNS.L_EventHandlerNotExist };
  1439. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeInvalidApiCallInContext] = { name: stringNS.L_InvalidAPICall, message: stringNS.L_InvalidApiCallInContext };
  1440. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeShuttingDown] = { name: stringNS.L_ShuttingDown, message: stringNS.L_ShuttingDown };
  1441. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeUnsupportedEnumeration] = { name: stringNS.L_UnsupportedEnumeration, message: stringNS.L_UnsupportedEnumerationMessage };
  1442. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeIndexOutOfRange] = { name: stringNS.L_IndexOutOfRange, message: stringNS.L_IndexOutOfRange };
  1443. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeBrowserAPINotSupported] = { name: stringNS.L_APINotSupported, message: stringNS.L_BrowserAPINotSupported };
  1444. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeRequestTimeout] = { name: stringNS.L_APICallFailed, message: stringNS.L_RequestTimeout };
  1445. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeTooManyIncompleteRequests] = { name: stringNS.L_APICallFailed, message: stringNS.L_TooManyIncompleteRequests };
  1446. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeRequestTokenUnavailable] = { name: stringNS.L_APICallFailed, message: stringNS.L_RequestTokenUnavailable };
  1447. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeActivityLimitReached] = { name: stringNS.L_APICallFailed, message: stringNS.L_ActivityLimitReached };
  1448. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeCustomXmlNodeNotFound] = { name: stringNS.L_InvalidNode, message: stringNS.L_CustomXmlNodeNotFound };
  1449. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeCustomXmlError] = { name: stringNS.L_CustomXmlError, message: stringNS.L_CustomXmlError };
  1450. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeCustomXmlExceedQuota] = { name: stringNS.L_CustomXmlExceedQuotaName, message: stringNS.L_CustomXmlExceedQuotaMessage };
  1451. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeCustomXmlOutOfDate] = { name: stringNS.L_CustomXmlOutOfDateName, message: stringNS.L_CustomXmlOutOfDateMessage };
  1452. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeNoCapability] = { name: stringNS.L_PermissionDenied, message: stringNS.L_NoCapability };
  1453. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeCannotNavTo] = { name: stringNS.L_CannotNavigateTo, message: stringNS.L_CannotNavigateTo };
  1454. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeSpecifiedIdNotExist] = { name: stringNS.L_SpecifiedIdNotExist, message: stringNS.L_SpecifiedIdNotExist };
  1455. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeNavOutOfBound] = { name: stringNS.L_NavOutOfBound, message: stringNS.L_NavOutOfBound };
  1456. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeCellDataAmountBeyondLimits] = { name: stringNS.L_DataWriteReminder, message: stringNS.L_CellDataAmountBeyondLimits };
  1457. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeElementMissing] = { name: stringNS.L_MissingParameter, message: stringNS.L_ElementMissing };
  1458. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeProtectedError] = { name: stringNS.L_PermissionDenied, message: stringNS.L_NoCapability };
  1459. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeInvalidCellsValue] = { name: stringNS.L_InvalidValue, message: stringNS.L_InvalidCellsValue };
  1460. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeInvalidTableOptionValue] = { name: stringNS.L_InvalidValue, message: stringNS.L_InvalidTableOptionValue };
  1461. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeInvalidFormatValue] = { name: stringNS.L_InvalidValue, message: stringNS.L_InvalidFormatValue };
  1462. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeRowIndexOutOfRange] = { name: stringNS.L_OutOfRange, message: stringNS.L_RowIndexOutOfRange };
  1463. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeColIndexOutOfRange] = { name: stringNS.L_OutOfRange, message: stringNS.L_ColIndexOutOfRange };
  1464. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeFormatValueOutOfRange] = { name: stringNS.L_OutOfRange, message: stringNS.L_FormatValueOutOfRange };
  1465. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeCellFormatAmountBeyondLimits] = { name: stringNS.L_FormattingReminder, message: stringNS.L_CellFormatAmountBeyondLimits };
  1466. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeMemoryFileLimit] = { name: stringNS.L_MemoryLimit, message: stringNS.L_CloseFileBeforeRetrieve };
  1467. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeNetworkProblemRetrieveFile] = { name: stringNS.L_NetworkProblem, message: stringNS.L_NetworkProblemRetrieveFile };
  1468. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeInvalidSliceSize] = { name: stringNS.L_InvalidValue, message: stringNS.L_SliceSizeNotSupported };
  1469. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeDialogAlreadyOpened] = { name: stringNS.L_DisplayDialogError, message: stringNS.L_DialogAlreadyOpened };
  1470. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeInvalidWidth] = { name: stringNS.L_IndexOutOfRange, message: stringNS.L_IndexOutOfRange };
  1471. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeInvalidHeight] = { name: stringNS.L_IndexOutOfRange, message: stringNS.L_IndexOutOfRange };
  1472. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeNavigationError] = { name: stringNS.L_DisplayDialogError, message: stringNS.L_NetworkProblem };
  1473. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeInvalidScheme] = { name: stringNS.L_DialogNavigateError, message: stringNS.L_DialogAddressNotTrusted };
  1474. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeAppDomains] = { name: stringNS.L_DisplayDialogError, message: stringNS.L_DialogAddressNotTrusted };
  1475. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeRequireHTTPS] = { name: stringNS.L_DisplayDialogError, message: stringNS.L_DialogAddressNotTrusted };
  1476. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeEndUserIgnore] = { name: stringNS.L_DisplayDialogError, message: stringNS.L_UserClickIgnore };
  1477. _errorMappings[OSF.DDA.ErrorCodeManager.errorCodes.ooeCrossZone] = { name: stringNS.L_DisplayDialogError, message: stringNS.L_NewWindowCrossZoneErrorString };
  1478. }
  1479. };
  1480. })();
  1481. var OfficeExt;
  1482. (function (OfficeExt) {
  1483. var Requirement;
  1484. (function (Requirement) {
  1485. var RequirementMatrix = (function () {
  1486. function RequirementMatrix(_setMap) {
  1487. this.isSetSupported = function _isSetSupported(name, minVersion) {
  1488. if (name == undefined) {
  1489. return false;
  1490. }
  1491. if (minVersion == undefined) {
  1492. minVersion = 0;
  1493. }
  1494. var setSupportArray = this._setMap;
  1495. var sets = setSupportArray._sets;
  1496. if (sets.hasOwnProperty(name.toLowerCase())) {
  1497. var setMaxVersion = sets[name.toLowerCase()];
  1498. return setMaxVersion > 0 && setMaxVersion >= minVersion;
  1499. }
  1500. else {
  1501. return false;
  1502. }
  1503. };
  1504. this._setMap = _setMap;
  1505. this.isSetSupported = this.isSetSupported.bind(this);
  1506. }
  1507. return RequirementMatrix;
  1508. })();
  1509. Requirement.RequirementMatrix = RequirementMatrix;
  1510. var DefaultSetRequirement = (function () {
  1511. function DefaultSetRequirement(setMap) {
  1512. this._addSetMap = function DefaultSetRequirement_addSetMap(addedSet) {
  1513. for (var name in addedSet) {
  1514. this._sets[name] = addedSet[name];
  1515. }
  1516. };
  1517. this._sets = setMap;
  1518. }
  1519. return DefaultSetRequirement;
  1520. })();
  1521. Requirement.DefaultSetRequirement = DefaultSetRequirement;
  1522. var DefaultDialogSetRequirement = (function (_super) {
  1523. __extends(DefaultDialogSetRequirement, _super);
  1524. function DefaultDialogSetRequirement() {
  1525. _super.call(this, {
  1526. "dialogapi": 1.1
  1527. });
  1528. }
  1529. return DefaultDialogSetRequirement;
  1530. })(DefaultSetRequirement);
  1531. Requirement.DefaultDialogSetRequirement = DefaultDialogSetRequirement;
  1532. var ExcelClientDefaultSetRequirement = (function (_super) {
  1533. __extends(ExcelClientDefaultSetRequirement, _super);
  1534. function ExcelClientDefaultSetRequirement() {
  1535. _super.call(this, {
  1536. "bindingevents": 1.1,
  1537. "documentevents": 1.1,
  1538. "excelapi": 1.1,
  1539. "matrixbindings": 1.1,
  1540. "matrixcoercion": 1.1,
  1541. "selection": 1.1,
  1542. "settings": 1.1,
  1543. "tablebindings": 1.1,
  1544. "tablecoercion": 1.1,
  1545. "textbindings": 1.1,
  1546. "textcoercion": 1.1
  1547. });
  1548. }
  1549. return ExcelClientDefaultSetRequirement;
  1550. })(DefaultSetRequirement);
  1551. Requirement.ExcelClientDefaultSetRequirement = ExcelClientDefaultSetRequirement;
  1552. var ExcelClientV1DefaultSetRequirement = (function (_super) {
  1553. __extends(ExcelClientV1DefaultSetRequirement, _super);
  1554. function ExcelClientV1DefaultSetRequirement() {
  1555. _super.call(this);
  1556. this._addSetMap({
  1557. "imagecoercion": 1.1
  1558. });
  1559. }
  1560. return ExcelClientV1DefaultSetRequirement;
  1561. })(ExcelClientDefaultSetRequirement);
  1562. Requirement.ExcelClientV1DefaultSetRequirement = ExcelClientV1DefaultSetRequirement;
  1563. var OutlookClientDefaultSetRequirement = (function (_super) {
  1564. __extends(OutlookClientDefaultSetRequirement, _super);
  1565. function OutlookClientDefaultSetRequirement() {
  1566. _super.call(this, {
  1567. "mailbox": 1.3
  1568. });
  1569. }
  1570. return OutlookClientDefaultSetRequirement;
  1571. })(DefaultSetRequirement);
  1572. Requirement.OutlookClientDefaultSetRequirement = OutlookClientDefaultSetRequirement;
  1573. var WordClientDefaultSetRequirement = (function (_super) {
  1574. __extends(WordClientDefaultSetRequirement, _super);
  1575. function WordClientDefaultSetRequirement() {
  1576. _super.call(this, {
  1577. "bindingevents": 1.1,
  1578. "compressedfile": 1.1,
  1579. "customxmlparts": 1.1,
  1580. "documentevents": 1.1,
  1581. "file": 1.1,
  1582. "htmlcoercion": 1.1,
  1583. "matrixbindings": 1.1,
  1584. "matrixcoercion": 1.1,
  1585. "ooxmlcoercion": 1.1,
  1586. "pdffile": 1.1,
  1587. "selection": 1.1,
  1588. "settings": 1.1,
  1589. "tablebindings": 1.1,
  1590. "tablecoercion": 1.1,
  1591. "textbindings": 1.1,
  1592. "textcoercion": 1.1,
  1593. "textfile": 1.1,
  1594. "wordapi": 1.1
  1595. });
  1596. }
  1597. return WordClientDefaultSetRequirement;
  1598. })(DefaultSetRequirement);
  1599. Requirement.WordClientDefaultSetRequirement = WordClientDefaultSetRequirement;
  1600. var WordClientV1DefaultSetRequirement = (function (_super) {
  1601. __extends(WordClientV1DefaultSetRequirement, _super);
  1602. function WordClientV1DefaultSetRequirement() {
  1603. _super.call(this);
  1604. this._addSetMap({
  1605. "customxmlparts": 1.2,
  1606. "wordapi": 1.2,
  1607. "imagecoercion": 1.1
  1608. });
  1609. }
  1610. return WordClientV1DefaultSetRequirement;
  1611. })(WordClientDefaultSetRequirement);
  1612. Requirement.WordClientV1DefaultSetRequirement = WordClientV1DefaultSetRequirement;
  1613. var PowerpointClientDefaultSetRequirement = (function (_super) {
  1614. __extends(PowerpointClientDefaultSetRequirement, _super);
  1615. function PowerpointClientDefaultSetRequirement() {
  1616. _super.call(this, {
  1617. "activeview": 1.1,
  1618. "compressedfile": 1.1,
  1619. "documentevents": 1.1,
  1620. "file": 1.1,
  1621. "pdffile": 1.1,
  1622. "selection": 1.1,
  1623. "settings": 1.1,
  1624. "textcoercion": 1.1
  1625. });
  1626. }
  1627. return PowerpointClientDefaultSetRequirement;
  1628. })(DefaultSetRequirement);
  1629. Requirement.PowerpointClientDefaultSetRequirement = PowerpointClientDefaultSetRequirement;
  1630. var PowerpointClientV1DefaultSetRequirement = (function (_super) {
  1631. __extends(PowerpointClientV1DefaultSetRequirement, _super);
  1632. function PowerpointClientV1DefaultSetRequirement() {
  1633. _super.call(this);
  1634. this._addSetMap({
  1635. "imagecoercion": 1.1
  1636. });
  1637. }
  1638. return PowerpointClientV1DefaultSetRequirement;
  1639. })(PowerpointClientDefaultSetRequirement);
  1640. Requirement.PowerpointClientV1DefaultSetRequirement = PowerpointClientV1DefaultSetRequirement;
  1641. var ProjectClientDefaultSetRequirement = (function (_super) {
  1642. __extends(ProjectClientDefaultSetRequirement, _super);
  1643. function ProjectClientDefaultSetRequirement() {
  1644. _super.call(this, {
  1645. "selection": 1.1,
  1646. "textcoercion": 1.1
  1647. });
  1648. }
  1649. return ProjectClientDefaultSetRequirement;
  1650. })(DefaultSetRequirement);
  1651. Requirement.ProjectClientDefaultSetRequirement = ProjectClientDefaultSetRequirement;
  1652. var ExcelWebDefaultSetRequirement = (function (_super) {
  1653. __extends(ExcelWebDefaultSetRequirement, _super);
  1654. function ExcelWebDefaultSetRequirement() {
  1655. _super.call(this, {
  1656. "bindingevents": 1.1,
  1657. "documentevents": 1.1,
  1658. "matrixbindings": 1.1,
  1659. "matrixcoercion": 1.1,
  1660. "selection": 1.1,
  1661. "settings": 1.1,
  1662. "tablebindings": 1.1,
  1663. "tablecoercion": 1.1,
  1664. "textbindings": 1.1,
  1665. "textcoercion": 1.1,
  1666. "file": 1.1
  1667. });
  1668. }
  1669. return ExcelWebDefaultSetRequirement;
  1670. })(DefaultSetRequirement);
  1671. Requirement.ExcelWebDefaultSetRequirement = ExcelWebDefaultSetRequirement;
  1672. var WordWebDefaultSetRequirement = (function (_super) {
  1673. __extends(WordWebDefaultSetRequirement, _super);
  1674. function WordWebDefaultSetRequirement() {
  1675. _super.call(this, {
  1676. "compressedfile": 1.1,
  1677. "documentevents": 1.1,
  1678. "file": 1.1,
  1679. "imagecoercion": 1.1,
  1680. "matrixcoercion": 1.1,
  1681. "ooxmlcoercion": 1.1,
  1682. "pdffile": 1.1,
  1683. "selection": 1.1,
  1684. "settings": 1.1,
  1685. "tablecoercion": 1.1,
  1686. "textcoercion": 1.1,
  1687. "textfile": 1.1
  1688. });
  1689. }
  1690. return WordWebDefaultSetRequirement;
  1691. })(DefaultSetRequirement);
  1692. Requirement.WordWebDefaultSetRequirement = WordWebDefaultSetRequirement;
  1693. var PowerpointWebDefaultSetRequirement = (function (_super) {
  1694. __extends(PowerpointWebDefaultSetRequirement, _super);
  1695. function PowerpointWebDefaultSetRequirement() {
  1696. _super.call(this, {
  1697. "activeview": 1.1,
  1698. "settings": 1.1
  1699. });
  1700. }
  1701. return PowerpointWebDefaultSetRequirement;
  1702. })(DefaultSetRequirement);
  1703. Requirement.PowerpointWebDefaultSetRequirement = PowerpointWebDefaultSetRequirement;
  1704. var OutlookWebDefaultSetRequirement = (function (_super) {
  1705. __extends(OutlookWebDefaultSetRequirement, _super);
  1706. function OutlookWebDefaultSetRequirement() {
  1707. _super.call(this, {
  1708. "mailbox": 1.3
  1709. });
  1710. }
  1711. return OutlookWebDefaultSetRequirement;
  1712. })(DefaultSetRequirement);
  1713. Requirement.OutlookWebDefaultSetRequirement = OutlookWebDefaultSetRequirement;
  1714. var SwayWebDefaultSetRequirement = (function (_super) {
  1715. __extends(SwayWebDefaultSetRequirement, _super);
  1716. function SwayWebDefaultSetRequirement() {
  1717. _super.call(this, {
  1718. "activeview": 1.1,
  1719. "documentevents": 1.1,
  1720. "selection": 1.1,
  1721. "settings": 1.1,
  1722. "textcoercion": 1.1
  1723. });
  1724. }
  1725. return SwayWebDefaultSetRequirement;
  1726. })(DefaultSetRequirement);
  1727. Requirement.SwayWebDefaultSetRequirement = SwayWebDefaultSetRequirement;
  1728. var AccessWebDefaultSetRequirement = (function (_super) {
  1729. __extends(AccessWebDefaultSetRequirement, _super);
  1730. function AccessWebDefaultSetRequirement() {
  1731. _super.call(this, {
  1732. "bindingevents": 1.1,
  1733. "partialtablebindings": 1.1,
  1734. "settings": 1.1,
  1735. "tablebindings": 1.1,
  1736. "tablecoercion": 1.1
  1737. });
  1738. }
  1739. return AccessWebDefaultSetRequirement;
  1740. })(DefaultSetRequirement);
  1741. Requirement.AccessWebDefaultSetRequirement = AccessWebDefaultSetRequirement;
  1742. var ExcelIOSDefaultSetRequirement = (function (_super) {
  1743. __extends(ExcelIOSDefaultSetRequirement, _super);
  1744. function ExcelIOSDefaultSetRequirement() {
  1745. _super.call(this, {
  1746. "bindingevents": 1.1,
  1747. "documentevents": 1.1,
  1748. "matrixbindings": 1.1,
  1749. "matrixcoercion": 1.1,
  1750. "selection": 1.1,
  1751. "settings": 1.1,
  1752. "tablebindings": 1.1,
  1753. "tablecoercion": 1.1,
  1754. "textbindings": 1.1,
  1755. "textcoercion": 1.1
  1756. });
  1757. }
  1758. return ExcelIOSDefaultSetRequirement;
  1759. })(DefaultSetRequirement);
  1760. Requirement.ExcelIOSDefaultSetRequirement = ExcelIOSDefaultSetRequirement;
  1761. var WordIOSDefaultSetRequirement = (function (_super) {
  1762. __extends(WordIOSDefaultSetRequirement, _super);
  1763. function WordIOSDefaultSetRequirement() {
  1764. _super.call(this, {
  1765. "bindingevents": 1.1,
  1766. "compressedfile": 1.1,
  1767. "customxmlparts": 1.1,
  1768. "documentevents": 1.1,
  1769. "file": 1.1,
  1770. "htmlcoercion": 1.1,
  1771. "matrixbindings": 1.1,
  1772. "matrixcoercion": 1.1,
  1773. "ooxmlcoercion": 1.1,
  1774. "pdffile": 1.1,
  1775. "selection": 1.1,
  1776. "settings": 1.1,
  1777. "tablebindings": 1.1,
  1778. "tablecoercion": 1.1,
  1779. "textbindings": 1.1,
  1780. "textcoercion": 1.1,
  1781. "textfile": 1.1
  1782. });
  1783. }
  1784. return WordIOSDefaultSetRequirement;
  1785. })(DefaultSetRequirement);
  1786. Requirement.WordIOSDefaultSetRequirement = WordIOSDefaultSetRequirement;
  1787. var WordIOSV1DefaultSetRequirement = (function (_super) {
  1788. __extends(WordIOSV1DefaultSetRequirement, _super);
  1789. function WordIOSV1DefaultSetRequirement() {
  1790. _super.call(this);
  1791. this._addSetMap({
  1792. "customxmlparts": 1.2,
  1793. "wordapi": 1.2
  1794. });
  1795. }
  1796. return WordIOSV1DefaultSetRequirement;
  1797. })(WordIOSDefaultSetRequirement);
  1798. Requirement.WordIOSV1DefaultSetRequirement = WordIOSV1DefaultSetRequirement;
  1799. var PowerpointIOSDefaultSetRequirement = (function (_super) {
  1800. __extends(PowerpointIOSDefaultSetRequirement, _super);
  1801. function PowerpointIOSDefaultSetRequirement() {
  1802. _super.call(this, {
  1803. "activeview": 1.1,
  1804. "compressedfile": 1.1,
  1805. "documentevents": 1.1,
  1806. "file": 1.1,
  1807. "pdffile": 1.1,
  1808. "selection": 1.1,
  1809. "settings": 1.1,
  1810. "textcoercion": 1.1
  1811. });
  1812. }
  1813. return PowerpointIOSDefaultSetRequirement;
  1814. })(DefaultSetRequirement);
  1815. Requirement.PowerpointIOSDefaultSetRequirement = PowerpointIOSDefaultSetRequirement;
  1816. var OutlookIOSDefaultSetRequirement = (function (_super) {
  1817. __extends(OutlookIOSDefaultSetRequirement, _super);
  1818. function OutlookIOSDefaultSetRequirement() {
  1819. _super.call(this, {
  1820. "mailbox": 1.1
  1821. });
  1822. }
  1823. return OutlookIOSDefaultSetRequirement;
  1824. })(DefaultSetRequirement);
  1825. Requirement.OutlookIOSDefaultSetRequirement = OutlookIOSDefaultSetRequirement;
  1826. var RequirementsMatrixFactory = (function () {
  1827. function RequirementsMatrixFactory() {
  1828. }
  1829. RequirementsMatrixFactory.initializeOsfDda = function () {
  1830. OSF.OUtil.setNamespace("Requirement", OSF.DDA);
  1831. };
  1832. RequirementsMatrixFactory.getDefaultRequirementMatrix = function (appContext) {
  1833. this.initializeDefaultSetMatrix();
  1834. var defaultRequirementMatrix = undefined;
  1835. var clientRequirement = appContext.get_requirementMatrix();
  1836. if (clientRequirement != undefined && clientRequirement.length > 0 && typeof (JSON) !== "undefined") {
  1837. var matrixItem = JSON.parse(appContext.get_requirementMatrix().toLowerCase());
  1838. defaultRequirementMatrix = new RequirementMatrix(new DefaultSetRequirement(matrixItem));
  1839. }
  1840. else {
  1841. var appLocator = RequirementsMatrixFactory.getClientFullVersionString(appContext);
  1842. if (RequirementsMatrixFactory.DefaultSetArrayMatrix != undefined && RequirementsMatrixFactory.DefaultSetArrayMatrix[appLocator] != undefined) {
  1843. defaultRequirementMatrix = new RequirementMatrix(RequirementsMatrixFactory.DefaultSetArrayMatrix[appLocator]);
  1844. }
  1845. else {
  1846. defaultRequirementMatrix = new RequirementMatrix(new DefaultSetRequirement({}));
  1847. }
  1848. }
  1849. return defaultRequirementMatrix;
  1850. };
  1851. RequirementsMatrixFactory.getDefaultDialogRequirementMatrix = function (appContext) {
  1852. var defaultRequirementMatrix = undefined;
  1853. var clientRequirement = appContext.get_dialogRequirementMatrix();
  1854. if (clientRequirement != undefined && clientRequirement.length > 0 && typeof (JSON) !== "undefined") {
  1855. var matrixItem = JSON.parse(appContext.get_requirementMatrix().toLowerCase());
  1856. defaultRequirementMatrix = new RequirementMatrix(new DefaultSetRequirement(matrixItem));
  1857. }
  1858. else {
  1859. defaultRequirementMatrix = new RequirementMatrix(new DefaultDialogSetRequirement());
  1860. }
  1861. return defaultRequirementMatrix;
  1862. };
  1863. RequirementsMatrixFactory.getClientFullVersionString = function (appContext) {
  1864. var appMinorVersion = appContext.get_appMinorVersion();
  1865. var appMinorVersionString = "";
  1866. var appFullVersion = "";
  1867. var appName = appContext.get_appName();
  1868. var isIOSClient = appName == 1024 ||
  1869. appName == 4096 ||
  1870. appName == 8192 ||
  1871. appName == 65536;
  1872. if (isIOSClient && appContext.get_appVersion() == 1) {
  1873. if (appName == 4096 && appMinorVersion >= 15) {
  1874. appFullVersion = "16.00.01";
  1875. }
  1876. else {
  1877. appFullVersion = "16.00";
  1878. }
  1879. }
  1880. else if (appContext.get_appName() == 64) {
  1881. appFullVersion = appContext.get_appVersion();
  1882. }
  1883. else {
  1884. if (appMinorVersion < 10) {
  1885. appMinorVersionString = "0" + appMinorVersion;
  1886. }
  1887. else {
  1888. appMinorVersionString = "" + appMinorVersion;
  1889. }
  1890. appFullVersion = appContext.get_appVersion() + "." + appMinorVersionString;
  1891. }
  1892. return appContext.get_appName() + "-" + appFullVersion;
  1893. };
  1894. RequirementsMatrixFactory.initializeDefaultSetMatrix = function () {
  1895. RequirementsMatrixFactory.DefaultSetArrayMatrix[RequirementsMatrixFactory.Excel_RCLIENT_1600] = new ExcelClientDefaultSetRequirement();
  1896. RequirementsMatrixFactory.DefaultSetArrayMatrix[RequirementsMatrixFactory.Word_RCLIENT_1600] = new WordClientDefaultSetRequirement();
  1897. RequirementsMatrixFactory.DefaultSetArrayMatrix[RequirementsMatrixFactory.PowerPoint_RCLIENT_1600] = new PowerpointClientDefaultSetRequirement();
  1898. RequirementsMatrixFactory.DefaultSetArrayMatrix[RequirementsMatrixFactory.Excel_RCLIENT_1601] = new ExcelClientV1DefaultSetRequirement();
  1899. RequirementsMatrixFactory.DefaultSetArrayMatrix[RequirementsMatrixFactory.Word_RCLIENT_1601] = new WordClientV1DefaultSetRequirement();
  1900. RequirementsMatrixFactory.DefaultSetArrayMatrix[RequirementsMatrixFactory.PowerPoint_RCLIENT_1601] = new PowerpointClientV1DefaultSetRequirement();
  1901. RequirementsMatrixFactory.DefaultSetArrayMatrix[RequirementsMatrixFactory.Outlook_RCLIENT_1600] = new OutlookClientDefaultSetRequirement();
  1902. RequirementsMatrixFactory.DefaultSetArrayMatrix[RequirementsMatrixFactory.Excel_WAC_1600] = new ExcelWebDefaultSetRequirement();
  1903. RequirementsMatrixFactory.DefaultSetArrayMatrix[RequirementsMatrixFactory.Word_WAC_1600] = new WordWebDefaultSetRequirement();
  1904. RequirementsMatrixFactory.DefaultSetArrayMatrix[RequirementsMatrixFactory.Outlook_WAC_1600] = new OutlookWebDefaultSetRequirement();
  1905. RequirementsMatrixFactory.DefaultSetArrayMatrix[RequirementsMatrixFactory.Outlook_WAC_1601] = new OutlookWebDefaultSetRequirement();
  1906. RequirementsMatrixFactory.DefaultSetArrayMatrix[RequirementsMatrixFactory.Project_RCLIENT_1600] = new ProjectClientDefaultSetRequirement();
  1907. RequirementsMatrixFactory.DefaultSetArrayMatrix[RequirementsMatrixFactory.Access_WAC_1600] = new AccessWebDefaultSetRequirement();
  1908. RequirementsMatrixFactory.DefaultSetArrayMatrix[RequirementsMatrixFactory.PowerPoint_WAC_1600] = new PowerpointWebDefaultSetRequirement();
  1909. RequirementsMatrixFactory.DefaultSetArrayMatrix[RequirementsMatrixFactory.Excel_IOS_1600] = new ExcelIOSDefaultSetRequirement();
  1910. RequirementsMatrixFactory.DefaultSetArrayMatrix[RequirementsMatrixFactory.SWAY_WAC_1600] = new SwayWebDefaultSetRequirement();
  1911. RequirementsMatrixFactory.DefaultSetArrayMatrix[RequirementsMatrixFactory.Word_IOS_1600] = new WordIOSDefaultSetRequirement();
  1912. RequirementsMatrixFactory.DefaultSetArrayMatrix[RequirementsMatrixFactory.Word_IOS_16001] = new WordIOSV1DefaultSetRequirement();
  1913. RequirementsMatrixFactory.DefaultSetArrayMatrix[RequirementsMatrixFactory.PowerPoint_IOS_1600] = new PowerpointIOSDefaultSetRequirement();
  1914. RequirementsMatrixFactory.DefaultSetArrayMatrix[RequirementsMatrixFactory.Outlook_IOS_1600] = new OutlookIOSDefaultSetRequirement();
  1915. };
  1916. RequirementsMatrixFactory.Excel_RCLIENT_1600 = "1-16.00";
  1917. RequirementsMatrixFactory.Excel_RCLIENT_1601 = "1-16.01";
  1918. RequirementsMatrixFactory.Word_RCLIENT_1600 = "2-16.00";
  1919. RequirementsMatrixFactory.Word_RCLIENT_1601 = "2-16.01";
  1920. RequirementsMatrixFactory.PowerPoint_RCLIENT_1600 = "4-16.00";
  1921. RequirementsMatrixFactory.PowerPoint_RCLIENT_1601 = "4-16.01";
  1922. RequirementsMatrixFactory.Outlook_RCLIENT_1600 = "8-16.00";
  1923. RequirementsMatrixFactory.Excel_WAC_1600 = "16-16.00";
  1924. RequirementsMatrixFactory.Word_WAC_1600 = "32-16.00";
  1925. RequirementsMatrixFactory.Outlook_WAC_1600 = "64-16.00";
  1926. RequirementsMatrixFactory.Outlook_WAC_1601 = "64-16.01";
  1927. RequirementsMatrixFactory.Project_RCLIENT_1600 = "128-16.00";
  1928. RequirementsMatrixFactory.Access_WAC_1600 = "256-16.00";
  1929. RequirementsMatrixFactory.PowerPoint_WAC_1600 = "512-16.00";
  1930. RequirementsMatrixFactory.Excel_IOS_1600 = "1024-16.00";
  1931. RequirementsMatrixFactory.SWAY_WAC_1600 = "2048-16.00";
  1932. RequirementsMatrixFactory.Word_IOS_1600 = "4096-16.00";
  1933. RequirementsMatrixFactory.Word_IOS_16001 = "4096-16.00.01";
  1934. RequirementsMatrixFactory.PowerPoint_IOS_1600 = "8192-16.00";
  1935. RequirementsMatrixFactory.Outlook_IOS_1600 = "65536-16.00";
  1936. RequirementsMatrixFactory.DefaultSetArrayMatrix = {};
  1937. return RequirementsMatrixFactory;
  1938. })();
  1939. Requirement.RequirementsMatrixFactory = RequirementsMatrixFactory;
  1940. })(Requirement = OfficeExt.Requirement || (OfficeExt.Requirement = {}));
  1941. })(OfficeExt || (OfficeExt = {}));
  1942. OfficeExt.Requirement.RequirementsMatrixFactory.initializeOsfDda();
  1943. Microsoft.Office.WebExtension.ApplicationMode = {
  1944. WebEditor: "webEditor",
  1945. WebViewer: "webViewer",
  1946. Client: "client"
  1947. };
  1948. Microsoft.Office.WebExtension.DocumentMode = {
  1949. ReadOnly: "readOnly",
  1950. ReadWrite: "readWrite"
  1951. };
  1952. OSF.NamespaceManager = (function OSF_NamespaceManager() {
  1953. var _userOffice;
  1954. var _useShortcut = false;
  1955. return {
  1956. enableShortcut: function OSF_NamespaceManager$enableShortcut() {
  1957. if (!_useShortcut) {
  1958. if (window.Office) {
  1959. _userOffice = window.Office;
  1960. }
  1961. else {
  1962. OSF.OUtil.setNamespace("Office", window);
  1963. }
  1964. window.Office = Microsoft.Office.WebExtension;
  1965. _useShortcut = true;
  1966. }
  1967. },
  1968. disableShortcut: function OSF_NamespaceManager$disableShortcut() {
  1969. if (_useShortcut) {
  1970. if (_userOffice) {
  1971. window.Office = _userOffice;
  1972. }
  1973. else {
  1974. OSF.OUtil.unsetNamespace("Office", window);
  1975. }
  1976. _useShortcut = false;
  1977. }
  1978. }
  1979. };
  1980. })();
  1981. OSF.NamespaceManager.enableShortcut();
  1982. Microsoft.Office.WebExtension.useShortNamespace = function Microsoft_Office_WebExtension_useShortNamespace(useShortcut) {
  1983. if (useShortcut) {
  1984. OSF.NamespaceManager.enableShortcut();
  1985. }
  1986. else {
  1987. OSF.NamespaceManager.disableShortcut();
  1988. }
  1989. };
  1990. Microsoft.Office.WebExtension.select = function Microsoft_Office_WebExtension_select(str, errorCallback) {
  1991. var promise;
  1992. if (str && typeof str == "string") {
  1993. var index = str.indexOf("#");
  1994. if (index != -1) {
  1995. var op = str.substring(0, index);
  1996. var target = str.substring(index + 1);
  1997. switch (op) {
  1998. case "binding":
  1999. case "bindings":
  2000. if (target) {
  2001. promise = new OSF.DDA.BindingPromise(target);
  2002. }
  2003. break;
  2004. }
  2005. }
  2006. }
  2007. if (!promise) {
  2008. if (errorCallback) {
  2009. var callbackType = typeof errorCallback;
  2010. if (callbackType == "function") {
  2011. var callArgs = {};
  2012. callArgs[Microsoft.Office.WebExtension.Parameters.Callback] = errorCallback;
  2013. OSF.DDA.issueAsyncResult(callArgs, OSF.DDA.ErrorCodeManager.errorCodes.ooeInvalidApiCallInContext, OSF.DDA.ErrorCodeManager.getErrorArgs(OSF.DDA.ErrorCodeManager.errorCodes.ooeInvalidApiCallInContext));
  2014. }
  2015. else {
  2016. throw OSF.OUtil.formatString(Strings.OfficeOM.L_CallbackNotAFunction, callbackType);
  2017. }
  2018. }
  2019. }
  2020. else {
  2021. promise.onFail = errorCallback;
  2022. return promise;
  2023. }
  2024. };
  2025. OSF.DDA.Context = function OSF_DDA_Context(officeAppContext, document, license, appOM, getOfficeTheme) {
  2026. OSF.OUtil.defineEnumerableProperties(this, {
  2027. "contentLanguage": {
  2028. value: officeAppContext.get_dataLocale()
  2029. },
  2030. "displayLanguage": {
  2031. value: officeAppContext.get_appUILocale()
  2032. },
  2033. "touchEnabled": {
  2034. value: officeAppContext.get_touchEnabled()
  2035. },
  2036. "commerceAllowed": {
  2037. value: officeAppContext.get_commerceAllowed()
  2038. }
  2039. });
  2040. if (license) {
  2041. OSF.OUtil.defineEnumerableProperty(this, "license", {
  2042. value: license
  2043. });
  2044. }
  2045. if (officeAppContext.ui) {
  2046. OSF.OUtil.defineEnumerableProperty(this, "ui", {
  2047. value: officeAppContext.ui
  2048. });
  2049. }
  2050. if (officeAppContext.get_isDialog()) {
  2051. var requirements = OfficeExt.Requirement.RequirementsMatrixFactory.getDefaultDialogRequirementMatrix(officeAppContext);
  2052. OSF.OUtil.defineEnumerableProperty(this, "requirements", {
  2053. value: requirements
  2054. });
  2055. }
  2056. else {
  2057. if (document) {
  2058. OSF.OUtil.defineEnumerableProperty(this, "document", {
  2059. value: document
  2060. });
  2061. }
  2062. if (appOM) {
  2063. var displayName = appOM.displayName || "appOM";
  2064. delete appOM.displayName;
  2065. OSF.OUtil.defineEnumerableProperty(this, displayName, {
  2066. value: appOM
  2067. });
  2068. }
  2069. if (getOfficeTheme) {
  2070. OSF.OUtil.defineEnumerableProperty(this, "officeTheme", {
  2071. get: function () {
  2072. return getOfficeTheme();
  2073. }
  2074. });
  2075. }
  2076. var requirements = OfficeExt.Requirement.RequirementsMatrixFactory.getDefaultRequirementMatrix(officeAppContext);
  2077. OSF.OUtil.defineEnumerableProperty(this, "requirements", {
  2078. value: requirements
  2079. });
  2080. }
  2081. };
  2082. OSF.DDA.OutlookContext = function OSF_DDA_OutlookContext(appContext, settings, license, appOM, getOfficeTheme) {
  2083. OSF.DDA.OutlookContext.uber.constructor.call(this, appContext, null, license, appOM, getOfficeTheme);
  2084. if (settings) {
  2085. OSF.OUtil.defineEnumerableProperty(this, "roamingSettings", {
  2086. value: settings
  2087. });
  2088. }
  2089. };
  2090. OSF.OUtil.extend(OSF.DDA.OutlookContext, OSF.DDA.Context);
  2091. OSF.DDA.OutlookAppOm = function OSF_DDA_OutlookAppOm(appContext, window, appReady) { };
  2092. OSF.DDA.Document = function OSF_DDA_Document(officeAppContext, settings) {
  2093. var mode;
  2094. switch (officeAppContext.get_clientMode()) {
  2095. case OSF.ClientMode.ReadOnly:
  2096. mode = Microsoft.Office.WebExtension.DocumentMode.ReadOnly;
  2097. break;
  2098. case OSF.ClientMode.ReadWrite:
  2099. mode = Microsoft.Office.WebExtension.DocumentMode.ReadWrite;
  2100. break;
  2101. }
  2102. ;
  2103. if (settings) {
  2104. OSF.OUtil.defineEnumerableProperty(this, "settings", {
  2105. value: settings
  2106. });
  2107. }
  2108. ;
  2109. OSF.OUtil.defineMutableProperties(this, {
  2110. "mode": {
  2111. value: mode
  2112. },
  2113. "url": {
  2114. value: officeAppContext.get_docUrl()
  2115. }
  2116. });
  2117. };
  2118. OSF.DDA.JsomDocument = function OSF_DDA_JsomDocument(officeAppContext, bindingFacade, settings) {
  2119. OSF.DDA.JsomDocument.uber.constructor.call(this, officeAppContext, settings);
  2120. if (bindingFacade) {
  2121. OSF.OUtil.defineEnumerableProperty(this, "bindings", {
  2122. get: function OSF_DDA_Document$GetBindings() { return bindingFacade; }
  2123. });
  2124. }
  2125. var am = OSF.DDA.AsyncMethodNames;
  2126. OSF.DDA.DispIdHost.addAsyncMethods(this, [
  2127. am.GetSelectedDataAsync,
  2128. am.SetSelectedDataAsync
  2129. ]);
  2130. OSF.DDA.DispIdHost.addEventSupport(this, new OSF.EventDispatch([Microsoft.Office.WebExtension.EventType.DocumentSelectionChanged]));
  2131. };
  2132. OSF.OUtil.extend(OSF.DDA.JsomDocument, OSF.DDA.Document);
  2133. OSF.OUtil.defineEnumerableProperty(Microsoft.Office.WebExtension, "context", {
  2134. get: function Microsoft_Office_WebExtension$GetContext() {
  2135. var context;
  2136. if (OSF && OSF._OfficeAppFactory) {
  2137. context = OSF._OfficeAppFactory.getContext();
  2138. }
  2139. return context;
  2140. }
  2141. });
  2142. OSF.DDA.License = function OSF_DDA_License(eToken) {
  2143. OSF.OUtil.defineEnumerableProperty(this, "value", {
  2144. value: eToken
  2145. });
  2146. };
  2147. OSF.DDA.ApiMethodCall = function OSF_DDA_ApiMethodCall(requiredParameters, supportedOptions, privateStateCallbacks, checkCallArgs, displayName) {
  2148. var requiredCount = requiredParameters.length;
  2149. var getInvalidParameterString = OSF.OUtil.delayExecutionAndCache(function () {
  2150. return OSF.OUtil.formatString(Strings.OfficeOM.L_InvalidParameters, displayName);
  2151. });
  2152. this.verifyArguments = function OSF_DDA_ApiMethodCall$VerifyArguments(params, args) {
  2153. for (var name in params) {
  2154. var param = params[name];
  2155. var arg = args[name];
  2156. if (param["enum"]) {
  2157. switch (typeof arg) {
  2158. case "string":
  2159. if (OSF.OUtil.listContainsValue(param["enum"], arg)) {
  2160. break;
  2161. }
  2162. case "undefined":
  2163. throw OSF.DDA.ErrorCodeManager.errorCodes.ooeUnsupportedEnumeration;
  2164. default:
  2165. throw getInvalidParameterString();
  2166. }
  2167. }
  2168. if (param["types"]) {
  2169. if (!OSF.OUtil.listContainsValue(param["types"], typeof arg)) {
  2170. throw getInvalidParameterString();
  2171. }
  2172. }
  2173. }
  2174. };
  2175. this.extractRequiredArguments = function OSF_DDA_ApiMethodCall$ExtractRequiredArguments(userArgs, caller, stateInfo) {
  2176. if (userArgs.length < requiredCount) {
  2177. throw OsfMsAjaxFactory.msAjaxError.parameterCount(Strings.OfficeOM.L_MissingRequiredArguments);
  2178. }
  2179. var requiredArgs = [];
  2180. var index;
  2181. for (index = 0; index < requiredCount; index++) {
  2182. requiredArgs.push(userArgs[index]);
  2183. }
  2184. this.verifyArguments(requiredParameters, requiredArgs);
  2185. var ret = {};
  2186. for (index = 0; index < requiredCount; index++) {
  2187. var param = requiredParameters[index];
  2188. var arg = requiredArgs[index];
  2189. if (param.verify) {
  2190. var isValid = param.verify(arg, caller, stateInfo);
  2191. if (!isValid) {
  2192. throw getInvalidParameterString();
  2193. }
  2194. }
  2195. ret[param.name] = arg;
  2196. }
  2197. return ret;
  2198. },
  2199. this.fillOptions = function OSF_DDA_ApiMethodCall$FillOptions(options, requiredArgs, caller, stateInfo) {
  2200. options = options || {};
  2201. for (var optionName in supportedOptions) {
  2202. if (!OSF.OUtil.listContainsKey(options, optionName)) {
  2203. var value = undefined;
  2204. var option = supportedOptions[optionName];
  2205. if (option.calculate && requiredArgs) {
  2206. value = option.calculate(requiredArgs, caller, stateInfo);
  2207. }
  2208. if (!value && option.defaultValue !== undefined) {
  2209. value = option.defaultValue;
  2210. }
  2211. options[optionName] = value;
  2212. }
  2213. }
  2214. return options;
  2215. };
  2216. this.constructCallArgs = function OSF_DAA_ApiMethodCall$ConstructCallArgs(required, options, caller, stateInfo) {
  2217. var callArgs = {};
  2218. for (var r in required) {
  2219. callArgs[r] = required[r];
  2220. }
  2221. for (var o in options) {
  2222. callArgs[o] = options[o];
  2223. }
  2224. for (var s in privateStateCallbacks) {
  2225. callArgs[s] = privateStateCallbacks[s](caller, stateInfo);
  2226. }
  2227. if (checkCallArgs) {
  2228. callArgs = checkCallArgs(callArgs, caller, stateInfo);
  2229. }
  2230. return callArgs;
  2231. };
  2232. };
  2233. OSF.OUtil.setNamespace("AsyncResultEnum", OSF.DDA);
  2234. OSF.DDA.AsyncResultEnum.Properties = {
  2235. Context: "Context",
  2236. Value: "Value",
  2237. Status: "Status",
  2238. Error: "Error"
  2239. };
  2240. Microsoft.Office.WebExtension.AsyncResultStatus = {
  2241. Succeeded: "succeeded",
  2242. Failed: "failed"
  2243. };
  2244. OSF.DDA.AsyncResultEnum.ErrorCode = {
  2245. Success: 0,
  2246. Failed: 1
  2247. };
  2248. OSF.DDA.AsyncResultEnum.ErrorProperties = {
  2249. Name: "Name",
  2250. Message: "Message",
  2251. Code: "Code"
  2252. };
  2253. OSF.DDA.AsyncMethodNames = {};
  2254. OSF.DDA.AsyncMethodNames.addNames = function (methodNames) {
  2255. for (var entry in methodNames) {
  2256. var am = {};
  2257. OSF.OUtil.defineEnumerableProperties(am, {
  2258. "id": {
  2259. value: entry
  2260. },
  2261. "displayName": {
  2262. value: methodNames[entry]
  2263. }
  2264. });
  2265. OSF.DDA.AsyncMethodNames[entry] = am;
  2266. }
  2267. };
  2268. OSF.DDA.AsyncMethodCall = function OSF_DDA_AsyncMethodCall(requiredParameters, supportedOptions, privateStateCallbacks, onSucceeded, onFailed, checkCallArgs, displayName) {
  2269. var requiredCount = requiredParameters.length;
  2270. var apiMethods = new OSF.DDA.ApiMethodCall(requiredParameters, supportedOptions, privateStateCallbacks, checkCallArgs, displayName);
  2271. function OSF_DAA_AsyncMethodCall$ExtractOptions(userArgs, requiredArgs, caller, stateInfo) {
  2272. if (userArgs.length > requiredCount + 2) {
  2273. throw OsfMsAjaxFactory.msAjaxError.parameterCount(Strings.OfficeOM.L_TooManyArguments);
  2274. }
  2275. var options, parameterCallback;
  2276. for (var i = userArgs.length - 1; i >= requiredCount; i--) {
  2277. var argument = userArgs[i];
  2278. switch (typeof argument) {
  2279. case "object":
  2280. if (options) {
  2281. throw OsfMsAjaxFactory.msAjaxError.parameterCount(Strings.OfficeOM.L_TooManyOptionalObjects);
  2282. }
  2283. else {
  2284. options = argument;
  2285. }
  2286. break;
  2287. case "function":
  2288. if (parameterCallback) {
  2289. throw OsfMsAjaxFactory.msAjaxError.parameterCount(Strings.OfficeOM.L_TooManyOptionalFunction);
  2290. }
  2291. else {
  2292. parameterCallback = argument;
  2293. }
  2294. break;
  2295. default:
  2296. throw OsfMsAjaxFactory.msAjaxError.argument(Strings.OfficeOM.L_InValidOptionalArgument);
  2297. break;
  2298. }
  2299. }
  2300. options = apiMethods.fillOptions(options, requiredArgs, caller, stateInfo);
  2301. if (parameterCallback) {
  2302. if (options[Microsoft.Office.WebExtension.Parameters.Callback]) {
  2303. throw Strings.OfficeOM.L_RedundantCallbackSpecification;
  2304. }
  2305. else {
  2306. options[Microsoft.Office.WebExtension.Parameters.Callback] = parameterCallback;
  2307. }
  2308. }
  2309. apiMethods.verifyArguments(supportedOptions, options);
  2310. return options;
  2311. }
  2312. ;
  2313. this.verifyAndExtractCall = function OSF_DAA_AsyncMethodCall$VerifyAndExtractCall(userArgs, caller, stateInfo) {
  2314. var required = apiMethods.extractRequiredArguments(userArgs, caller, stateInfo);
  2315. var options = OSF_DAA_AsyncMethodCall$ExtractOptions(userArgs, required, caller, stateInfo);
  2316. var callArgs = apiMethods.constructCallArgs(required, options, caller, stateInfo);
  2317. return callArgs;
  2318. };
  2319. this.processResponse = function OSF_DAA_AsyncMethodCall$ProcessResponse(status, response, caller, callArgs) {
  2320. var payload;
  2321. if (status == OSF.DDA.ErrorCodeManager.errorCodes.ooeSuccess) {
  2322. if (onSucceeded) {
  2323. payload = onSucceeded(response, caller, callArgs);
  2324. }
  2325. else {
  2326. payload = response;
  2327. }
  2328. }
  2329. else {
  2330. if (onFailed) {
  2331. payload = onFailed(status, response);
  2332. }
  2333. else {
  2334. payload = OSF.DDA.ErrorCodeManager.getErrorArgs(status);
  2335. }
  2336. }
  2337. return payload;
  2338. };
  2339. this.getCallArgs = function (suppliedArgs) {
  2340. var options, parameterCallback;
  2341. for (var i = suppliedArgs.length - 1; i >= requiredCount; i--) {
  2342. var argument = suppliedArgs[i];
  2343. switch (typeof argument) {
  2344. case "object":
  2345. options = argument;
  2346. break;
  2347. case "function":
  2348. parameterCallback = argument;
  2349. break;
  2350. }
  2351. }
  2352. options = options || {};
  2353. if (parameterCallback) {
  2354. options[Microsoft.Office.WebExtension.Parameters.Callback] = parameterCallback;
  2355. }
  2356. return options;
  2357. };
  2358. };
  2359. OSF.DDA.AsyncMethodCallFactory = (function () {
  2360. return {
  2361. manufacture: function (params) {
  2362. var supportedOptions = params.supportedOptions ? OSF.OUtil.createObject(params.supportedOptions) : [];
  2363. var privateStateCallbacks = params.privateStateCallbacks ? OSF.OUtil.createObject(params.privateStateCallbacks) : [];
  2364. return new OSF.DDA.AsyncMethodCall(params.requiredArguments || [], supportedOptions, privateStateCallbacks, params.onSucceeded, params.onFailed, params.checkCallArgs, params.method.displayName);
  2365. }
  2366. };
  2367. })();
  2368. OSF.DDA.AsyncMethodCalls = {};
  2369. OSF.DDA.AsyncMethodCalls.define = function (callDefinition) {
  2370. OSF.DDA.AsyncMethodCalls[callDefinition.method.id] = OSF.DDA.AsyncMethodCallFactory.manufacture(callDefinition);
  2371. };
  2372. OSF.DDA.Error = function OSF_DDA_Error(name, message, code) {
  2373. OSF.OUtil.defineEnumerableProperties(this, {
  2374. "name": {
  2375. value: name
  2376. },
  2377. "message": {
  2378. value: message
  2379. },
  2380. "code": {
  2381. value: code
  2382. }
  2383. });
  2384. };
  2385. OSF.DDA.AsyncResult = function OSF_DDA_AsyncResult(initArgs, errorArgs) {
  2386. OSF.OUtil.defineEnumerableProperties(this, {
  2387. "value": {
  2388. value: initArgs[OSF.DDA.AsyncResultEnum.Properties.Value]
  2389. },
  2390. "status": {
  2391. value: errorArgs ? Microsoft.Office.WebExtension.AsyncResultStatus.Failed : Microsoft.Office.WebExtension.AsyncResultStatus.Succeeded
  2392. }
  2393. });
  2394. if (initArgs[OSF.DDA.AsyncResultEnum.Properties.Context]) {
  2395. OSF.OUtil.defineEnumerableProperty(this, "asyncContext", {
  2396. value: initArgs[OSF.DDA.AsyncResultEnum.Properties.Context]
  2397. });
  2398. }
  2399. if (errorArgs) {
  2400. OSF.OUtil.defineEnumerableProperty(this, "error", {
  2401. value: new OSF.DDA.Error(errorArgs[OSF.DDA.AsyncResultEnum.ErrorProperties.Name], errorArgs[OSF.DDA.AsyncResultEnum.ErrorProperties.Message], errorArgs[OSF.DDA.AsyncResultEnum.ErrorProperties.Code])
  2402. });
  2403. }
  2404. };
  2405. OSF.DDA.issueAsyncResult = function OSF_DDA$IssueAsyncResult(callArgs, status, payload) {
  2406. var callback = callArgs[Microsoft.Office.WebExtension.Parameters.Callback];
  2407. if (callback) {
  2408. var asyncInitArgs = {};
  2409. asyncInitArgs[OSF.DDA.AsyncResultEnum.Properties.Context] = callArgs[Microsoft.Office.WebExtension.Parameters.AsyncContext];
  2410. var errorArgs;
  2411. if (status == OSF.DDA.ErrorCodeManager.errorCodes.ooeSuccess) {
  2412. asyncInitArgs[OSF.DDA.AsyncResultEnum.Properties.Value] = payload;
  2413. }
  2414. else {
  2415. errorArgs = {};
  2416. payload = payload || OSF.DDA.ErrorCodeManager.getErrorArgs(OSF.DDA.ErrorCodeManager.errorCodes.ooeInternalError);
  2417. errorArgs[OSF.DDA.AsyncResultEnum.ErrorProperties.Code] = status || OSF.DDA.ErrorCodeManager.errorCodes.ooeInternalError;
  2418. errorArgs[OSF.DDA.AsyncResultEnum.ErrorProperties.Name] = payload.name || payload;
  2419. errorArgs[OSF.DDA.AsyncResultEnum.ErrorProperties.Message] = payload.message || payload;
  2420. }
  2421. callback(new OSF.DDA.AsyncResult(asyncInitArgs, errorArgs));
  2422. }
  2423. };
  2424. OSF.DDA.SyncMethodNames = {};
  2425. OSF.DDA.SyncMethodNames.addNames = function (methodNames) {
  2426. for (var entry in methodNames) {
  2427. var am = {};
  2428. OSF.OUtil.defineEnumerableProperties(am, {
  2429. "id": {
  2430. value: entry
  2431. },
  2432. "displayName": {
  2433. value: methodNames[entry]
  2434. }
  2435. });
  2436. OSF.DDA.SyncMethodNames[entry] = am;
  2437. }
  2438. };
  2439. OSF.DDA.SyncMethodCall = function OSF_DDA_SyncMethodCall(requiredParameters, supportedOptions, privateStateCallbacks, checkCallArgs, displayName) {
  2440. var requiredCount = requiredParameters.length;
  2441. var apiMethods = new OSF.DDA.ApiMethodCall(requiredParameters, supportedOptions, privateStateCallbacks, checkCallArgs, displayName);
  2442. function OSF_DAA_SyncMethodCall$ExtractOptions(userArgs, requiredArgs, caller, stateInfo) {
  2443. if (userArgs.length > requiredCount + 1) {
  2444. throw OsfMsAjaxFactory.msAjaxError.parameterCount(Strings.OfficeOM.L_TooManyArguments);
  2445. }
  2446. var options, parameterCallback;
  2447. for (var i = userArgs.length - 1; i >= requiredCount; i--) {
  2448. var argument = userArgs[i];
  2449. switch (typeof argument) {
  2450. case "object":
  2451. if (options) {
  2452. throw OsfMsAjaxFactory.msAjaxError.parameterCount(Strings.OfficeOM.L_TooManyOptionalObjects);
  2453. }
  2454. else {
  2455. options = argument;
  2456. }
  2457. break;
  2458. default:
  2459. throw OsfMsAjaxFactory.msAjaxError.argument(Strings.OfficeOM.L_InValidOptionalArgument);
  2460. break;
  2461. }
  2462. }
  2463. options = apiMethods.fillOptions(options, requiredArgs, caller, stateInfo);
  2464. apiMethods.verifyArguments(supportedOptions, options);
  2465. return options;
  2466. }
  2467. ;
  2468. this.verifyAndExtractCall = function OSF_DAA_AsyncMethodCall$VerifyAndExtractCall(userArgs, caller, stateInfo) {
  2469. var required = apiMethods.extractRequiredArguments(userArgs, caller, stateInfo);
  2470. var options = OSF_DAA_SyncMethodCall$ExtractOptions(userArgs, required, caller, stateInfo);
  2471. var callArgs = apiMethods.constructCallArgs(required, options, caller, stateInfo);
  2472. return callArgs;
  2473. };
  2474. };
  2475. OSF.DDA.SyncMethodCallFactory = (function () {
  2476. return {
  2477. manufacture: function (params) {
  2478. var supportedOptions = params.supportedOptions ? OSF.OUtil.createObject(params.supportedOptions) : [];
  2479. return new OSF.DDA.SyncMethodCall(params.requiredArguments || [], supportedOptions, params.privateStateCallbacks, params.checkCallArgs, params.method.displayName);
  2480. }
  2481. };
  2482. })();
  2483. OSF.DDA.SyncMethodCalls = {};
  2484. OSF.DDA.SyncMethodCalls.define = function (callDefinition) {
  2485. OSF.DDA.SyncMethodCalls[callDefinition.method.id] = OSF.DDA.SyncMethodCallFactory.manufacture(callDefinition);
  2486. };
  2487. OSF.DDA.ListType = (function () {
  2488. var listTypes = {};
  2489. return {
  2490. setListType: function OSF_DDA_ListType$AddListType(t, prop) { listTypes[t] = prop; },
  2491. isListType: function OSF_DDA_ListType$IsListType(t) { return OSF.OUtil.listContainsKey(listTypes, t); },
  2492. getDescriptor: function OSF_DDA_ListType$getDescriptor(t) { return listTypes[t]; }
  2493. };
  2494. })();
  2495. OSF.DDA.HostParameterMap = function (specialProcessor, mappings) {
  2496. var toHostMap = "toHost";
  2497. var fromHostMap = "fromHost";
  2498. var sourceData = "sourceData";
  2499. var self = "self";
  2500. var dynamicTypes = {};
  2501. dynamicTypes[Microsoft.Office.WebExtension.Parameters.Data] = {
  2502. toHost: function (data) {
  2503. if (data != null && data.rows !== undefined) {
  2504. var tableData = {};
  2505. tableData[OSF.DDA.TableDataProperties.TableRows] = data.rows;
  2506. tableData[OSF.DDA.TableDataProperties.TableHeaders] = data.headers;
  2507. data = tableData;
  2508. }
  2509. return data;
  2510. },
  2511. fromHost: function (args) {
  2512. return args;
  2513. }
  2514. };
  2515. dynamicTypes[Microsoft.Office.WebExtension.Parameters.SampleData] = dynamicTypes[Microsoft.Office.WebExtension.Parameters.Data];
  2516. function mapValues(preimageSet, mapping) {
  2517. var ret = preimageSet ? {} : undefined;
  2518. for (var entry in preimageSet) {
  2519. var preimage = preimageSet[entry];
  2520. var image;
  2521. if (OSF.DDA.ListType.isListType(entry)) {
  2522. image = [];
  2523. for (var subEntry in preimage) {
  2524. image.push(mapValues(preimage[subEntry], mapping));
  2525. }
  2526. }
  2527. else if (OSF.OUtil.listContainsKey(dynamicTypes, entry)) {
  2528. image = dynamicTypes[entry][mapping](preimage);
  2529. }
  2530. else if (mapping == fromHostMap && specialProcessor.preserveNesting(entry)) {
  2531. image = mapValues(preimage, mapping);
  2532. }
  2533. else {
  2534. var maps = mappings[entry];
  2535. if (maps) {
  2536. var map = maps[mapping];
  2537. if (map) {
  2538. image = map[preimage];
  2539. if (image === undefined) {
  2540. image = preimage;
  2541. }
  2542. }
  2543. }
  2544. else {
  2545. image = preimage;
  2546. }
  2547. }
  2548. ret[entry] = image;
  2549. }
  2550. return ret;
  2551. }
  2552. ;
  2553. function generateArguments(imageSet, parameters) {
  2554. var ret;
  2555. for (var param in parameters) {
  2556. var arg;
  2557. if (specialProcessor.isComplexType(param)) {
  2558. arg = generateArguments(imageSet, mappings[param][toHostMap]);
  2559. }
  2560. else {
  2561. arg = imageSet[param];
  2562. }
  2563. if (arg != undefined) {
  2564. if (!ret) {
  2565. ret = {};
  2566. }
  2567. var index = parameters[param];
  2568. if (index == self) {
  2569. index = param;
  2570. }
  2571. ret[index] = specialProcessor.pack(param, arg);
  2572. }
  2573. }
  2574. return ret;
  2575. }
  2576. ;
  2577. function extractArguments(source, parameters, extracted) {
  2578. if (!extracted) {
  2579. extracted = {};
  2580. }
  2581. for (var param in parameters) {
  2582. var index = parameters[param];
  2583. var value;
  2584. if (index == self) {
  2585. value = source;
  2586. }
  2587. else if (index == sourceData) {
  2588. extracted[param] = source.toArray();
  2589. continue;
  2590. }
  2591. else {
  2592. value = source[index];
  2593. }
  2594. if (value === null || value === undefined) {
  2595. extracted[param] = undefined;
  2596. }
  2597. else {
  2598. value = specialProcessor.unpack(param, value);
  2599. var map;
  2600. if (specialProcessor.isComplexType(param)) {
  2601. map = mappings[param][fromHostMap];
  2602. if (specialProcessor.preserveNesting(param)) {
  2603. extracted[param] = extractArguments(value, map);
  2604. }
  2605. else {
  2606. extractArguments(value, map, extracted);
  2607. }
  2608. }
  2609. else {
  2610. if (OSF.DDA.ListType.isListType(param)) {
  2611. map = {};
  2612. var entryDescriptor = OSF.DDA.ListType.getDescriptor(param);
  2613. map[entryDescriptor] = self;
  2614. var extractedValues = new Array(value.length);
  2615. for (var item in value) {
  2616. extractedValues[item] = extractArguments(value[item], map);
  2617. }
  2618. extracted[param] = extractedValues;
  2619. }
  2620. else {
  2621. extracted[param] = value;
  2622. }
  2623. }
  2624. }
  2625. }
  2626. return extracted;
  2627. }
  2628. ;
  2629. function applyMap(mapName, preimage, mapping) {
  2630. var parameters = mappings[mapName][mapping];
  2631. var image;
  2632. if (mapping == "toHost") {
  2633. var imageSet = mapValues(preimage, mapping);
  2634. image = generateArguments(imageSet, parameters);
  2635. }
  2636. else if (mapping == "fromHost") {
  2637. var argumentSet = extractArguments(preimage, parameters);
  2638. image = mapValues(argumentSet, mapping);
  2639. }
  2640. return image;
  2641. }
  2642. ;
  2643. if (!mappings) {
  2644. mappings = {};
  2645. }
  2646. this.addMapping = function (mapName, description) {
  2647. var toHost, fromHost;
  2648. if (description.map) {
  2649. toHost = description.map;
  2650. fromHost = {};
  2651. for (var preimage in toHost) {
  2652. var image = toHost[preimage];
  2653. if (image == self) {
  2654. image = preimage;
  2655. }
  2656. fromHost[image] = preimage;
  2657. }
  2658. }
  2659. else {
  2660. toHost = description.toHost;
  2661. fromHost = description.fromHost;
  2662. }
  2663. var pair = mappings[mapName];
  2664. if (pair) {
  2665. var currMap = pair[toHostMap];
  2666. for (var th in currMap)
  2667. toHost[th] = currMap[th];
  2668. currMap = pair[fromHostMap];
  2669. for (var fh in currMap)
  2670. fromHost[fh] = currMap[fh];
  2671. }
  2672. else {
  2673. pair = mappings[mapName] = {};
  2674. }
  2675. pair[toHostMap] = toHost;
  2676. pair[fromHostMap] = fromHost;
  2677. };
  2678. this.toHost = function (mapName, preimage) { return applyMap(mapName, preimage, toHostMap); };
  2679. this.fromHost = function (mapName, image) { return applyMap(mapName, image, fromHostMap); };
  2680. this.self = self;
  2681. this.sourceData = sourceData;
  2682. this.addComplexType = function (ct) { specialProcessor.addComplexType(ct); };
  2683. this.getDynamicType = function (dt) { return specialProcessor.getDynamicType(dt); };
  2684. this.setDynamicType = function (dt, handler) { specialProcessor.setDynamicType(dt, handler); };
  2685. this.dynamicTypes = dynamicTypes;
  2686. this.doMapValues = function (preimageSet, mapping) { return mapValues(preimageSet, mapping); };
  2687. };
  2688. OSF.DDA.SpecialProcessor = function (complexTypes, dynamicTypes) {
  2689. this.addComplexType = function OSF_DDA_SpecialProcessor$addComplexType(ct) {
  2690. complexTypes.push(ct);
  2691. };
  2692. this.getDynamicType = function OSF_DDA_SpecialProcessor$getDynamicType(dt) {
  2693. return dynamicTypes[dt];
  2694. };
  2695. this.setDynamicType = function OSF_DDA_SpecialProcessor$setDynamicType(dt, handler) {
  2696. dynamicTypes[dt] = handler;
  2697. };
  2698. this.isComplexType = function OSF_DDA_SpecialProcessor$isComplexType(t) {
  2699. return OSF.OUtil.listContainsValue(complexTypes, t);
  2700. };
  2701. this.isDynamicType = function OSF_DDA_SpecialProcessor$isDynamicType(p) {
  2702. return OSF.OUtil.listContainsKey(dynamicTypes, p);
  2703. };
  2704. this.preserveNesting = function OSF_DDA_SpecialProcessor$preserveNesting(p) {
  2705. var pn = [];
  2706. if (OSF.DDA.PropertyDescriptors)
  2707. pn.push(OSF.DDA.PropertyDescriptors.Subset);
  2708. if (OSF.DDA.DataNodeEventProperties) {
  2709. pn = pn.concat([
  2710. OSF.DDA.DataNodeEventProperties.OldNode,
  2711. OSF.DDA.DataNodeEventProperties.NewNode,
  2712. OSF.DDA.DataNodeEventProperties.NextSiblingNode
  2713. ]);
  2714. }
  2715. return OSF.OUtil.listContainsValue(pn, p);
  2716. };
  2717. this.pack = function OSF_DDA_SpecialProcessor$pack(param, arg) {
  2718. var value;
  2719. if (this.isDynamicType(param)) {
  2720. value = dynamicTypes[param].toHost(arg);
  2721. }
  2722. else {
  2723. value = arg;
  2724. }
  2725. return value;
  2726. };
  2727. this.unpack = function OSF_DDA_SpecialProcessor$unpack(param, arg) {
  2728. var value;
  2729. if (this.isDynamicType(param)) {
  2730. value = dynamicTypes[param].fromHost(arg);
  2731. }
  2732. else {
  2733. value = arg;
  2734. }
  2735. return value;
  2736. };
  2737. };
  2738. OSF.DDA.getDecoratedParameterMap = function (specialProcessor, initialDefs) {
  2739. var parameterMap = new OSF.DDA.HostParameterMap(specialProcessor);
  2740. var self = parameterMap.self;
  2741. function createObject(properties) {
  2742. var obj = null;
  2743. if (properties) {
  2744. obj = {};
  2745. var len = properties.length;
  2746. for (var i = 0; i < len; i++) {
  2747. obj[properties[i].name] = properties[i].value;
  2748. }
  2749. }
  2750. return obj;
  2751. }
  2752. parameterMap.define = function define(definition) {
  2753. var args = {};
  2754. var toHost = createObject(definition.toHost);
  2755. if (definition.invertible) {
  2756. args.map = toHost;
  2757. }
  2758. else if (definition.canonical) {
  2759. args.toHost = args.fromHost = toHost;
  2760. }
  2761. else {
  2762. args.toHost = toHost;
  2763. args.fromHost = createObject(definition.fromHost);
  2764. }
  2765. parameterMap.addMapping(definition.type, args);
  2766. if (definition.isComplexType)
  2767. parameterMap.addComplexType(definition.type);
  2768. };
  2769. for (var id in initialDefs)
  2770. parameterMap.define(initialDefs[id]);
  2771. return parameterMap;
  2772. };
  2773. OSF.OUtil.setNamespace("DispIdHost", OSF.DDA);
  2774. OSF.DDA.DispIdHost.Methods = {
  2775. InvokeMethod: "invokeMethod",
  2776. AddEventHandler: "addEventHandler",
  2777. RemoveEventHandler: "removeEventHandler",
  2778. OpenDialog: "openDialog",
  2779. CloseDialog: "closeDialog",
  2780. MessageParent: "messageParent",
  2781. SendMessage: "sendMessage"
  2782. };
  2783. OSF.DDA.DispIdHost.Delegates = {
  2784. ExecuteAsync: "executeAsync",
  2785. RegisterEventAsync: "registerEventAsync",
  2786. UnregisterEventAsync: "unregisterEventAsync",
  2787. ParameterMap: "parameterMap",
  2788. OpenDialog: "openDialog",
  2789. CloseDialog: "closeDialog",
  2790. MessageParent: "messageParent",
  2791. SendMessage: "sendMessage"
  2792. };
  2793. OSF.DDA.DispIdHost.Facade = function OSF_DDA_DispIdHost_Facade(getDelegateMethods, parameterMap) {
  2794. var dispIdMap = {};
  2795. var jsom = OSF.DDA.AsyncMethodNames;
  2796. var did = OSF.DDA.MethodDispId;
  2797. var methodMap = {
  2798. "GoToByIdAsync": did.dispidNavigateToMethod,
  2799. "GetSelectedDataAsync": did.dispidGetSelectedDataMethod,
  2800. "SetSelectedDataAsync": did.dispidSetSelectedDataMethod,
  2801. "GetDocumentCopyChunkAsync": did.dispidGetDocumentCopyChunkMethod,
  2802. "ReleaseDocumentCopyAsync": did.dispidReleaseDocumentCopyMethod,
  2803. "GetDocumentCopyAsync": did.dispidGetDocumentCopyMethod,
  2804. "AddFromSelectionAsync": did.dispidAddBindingFromSelectionMethod,
  2805. "AddFromPromptAsync": did.dispidAddBindingFromPromptMethod,
  2806. "AddFromNamedItemAsync": did.dispidAddBindingFromNamedItemMethod,
  2807. "GetAllAsync": did.dispidGetAllBindingsMethod,
  2808. "GetByIdAsync": did.dispidGetBindingMethod,
  2809. "ReleaseByIdAsync": did.dispidReleaseBindingMethod,
  2810. "GetDataAsync": did.dispidGetBindingDataMethod,
  2811. "SetDataAsync": did.dispidSetBindingDataMethod,
  2812. "AddRowsAsync": did.dispidAddRowsMethod,
  2813. "AddColumnsAsync": did.dispidAddColumnsMethod,
  2814. "DeleteAllDataValuesAsync": did.dispidClearAllRowsMethod,
  2815. "RefreshAsync": did.dispidLoadSettingsMethod,
  2816. "SaveAsync": did.dispidSaveSettingsMethod,
  2817. "GetActiveViewAsync": did.dispidGetActiveViewMethod,
  2818. "GetFilePropertiesAsync": did.dispidGetFilePropertiesMethod,
  2819. "GetOfficeThemeAsync": did.dispidGetOfficeThemeMethod,
  2820. "GetDocumentThemeAsync": did.dispidGetDocumentThemeMethod,
  2821. "ClearFormatsAsync": did.dispidClearFormatsMethod,
  2822. "SetTableOptionsAsync": did.dispidSetTableOptionsMethod,
  2823. "SetFormatsAsync": did.dispidSetFormatsMethod,
  2824. "ExecuteRichApiRequestAsync": did.dispidExecuteRichApiRequestMethod,
  2825. "AppCommandInvocationCompletedAsync": did.dispidAppCommandInvocationCompletedMethod,
  2826. "CloseContainerAsync": did.dispidCloseContainerMethod,
  2827. "AddDataPartAsync": did.dispidAddDataPartMethod,
  2828. "GetDataPartByIdAsync": did.dispidGetDataPartByIdMethod,
  2829. "GetDataPartsByNameSpaceAsync": did.dispidGetDataPartsByNamespaceMethod,
  2830. "GetPartXmlAsync": did.dispidGetDataPartXmlMethod,
  2831. "GetPartNodesAsync": did.dispidGetDataPartNodesMethod,
  2832. "DeleteDataPartAsync": did.dispidDeleteDataPartMethod,
  2833. "GetNodeValueAsync": did.dispidGetDataNodeValueMethod,
  2834. "GetNodeXmlAsync": did.dispidGetDataNodeXmlMethod,
  2835. "GetRelativeNodesAsync": did.dispidGetDataNodesMethod,
  2836. "SetNodeValueAsync": did.dispidSetDataNodeValueMethod,
  2837. "SetNodeXmlAsync": did.dispidSetDataNodeXmlMethod,
  2838. "AddDataPartNamespaceAsync": did.dispidAddDataNamespaceMethod,
  2839. "GetDataPartNamespaceAsync": did.dispidGetDataUriByPrefixMethod,
  2840. "GetDataPartPrefixAsync": did.dispidGetDataPrefixByUriMethod,
  2841. "GetNodeTextAsync": did.dispidGetDataNodeTextMethod,
  2842. "SetNodeTextAsync": did.dispidSetDataNodeTextMethod,
  2843. "GetSelectedTask": did.dispidGetSelectedTaskMethod,
  2844. "GetTask": did.dispidGetTaskMethod,
  2845. "GetWSSUrl": did.dispidGetWSSUrlMethod,
  2846. "GetTaskField": did.dispidGetTaskFieldMethod,
  2847. "GetSelectedResource": did.dispidGetSelectedResourceMethod,
  2848. "GetResourceField": did.dispidGetResourceFieldMethod,
  2849. "GetProjectField": did.dispidGetProjectFieldMethod,
  2850. "GetSelectedView": did.dispidGetSelectedViewMethod,
  2851. "GetTaskByIndex": did.dispidGetTaskByIndexMethod,
  2852. "GetResourceByIndex": did.dispidGetResourceByIndexMethod,
  2853. "SetTaskField": did.dispidSetTaskFieldMethod,
  2854. "SetResourceField": did.dispidSetResourceFieldMethod,
  2855. "GetMaxTaskIndex": did.dispidGetMaxTaskIndexMethod,
  2856. "GetMaxResourceIndex": did.dispidGetMaxResourceIndexMethod,
  2857. "CreateTask": did.dispidCreateTaskMethod
  2858. };
  2859. for (var method in methodMap) {
  2860. if (jsom[method]) {
  2861. dispIdMap[jsom[method].id] = methodMap[method];
  2862. }
  2863. }
  2864. jsom = OSF.DDA.SyncMethodNames;
  2865. did = OSF.DDA.MethodDispId;
  2866. var asyncMethodMap = {
  2867. "MessageParent": did.dispidMessageParentMethod,
  2868. "SendMessage": did.dispidSendMessageMethod
  2869. };
  2870. for (var method in asyncMethodMap) {
  2871. if (jsom[method]) {
  2872. dispIdMap[jsom[method].id] = asyncMethodMap[method];
  2873. }
  2874. }
  2875. jsom = Microsoft.Office.WebExtension.EventType;
  2876. did = OSF.DDA.EventDispId;
  2877. var eventMap = {
  2878. "SettingsChanged": did.dispidSettingsChangedEvent,
  2879. "DocumentSelectionChanged": did.dispidDocumentSelectionChangedEvent,
  2880. "BindingSelectionChanged": did.dispidBindingSelectionChangedEvent,
  2881. "BindingDataChanged": did.dispidBindingDataChangedEvent,
  2882. "ActiveViewChanged": did.dispidActiveViewChangedEvent,
  2883. "OfficeThemeChanged": did.dispidOfficeThemeChangedEvent,
  2884. "DocumentThemeChanged": did.dispidDocumentThemeChangedEvent,
  2885. "AppCommandInvoked": did.dispidAppCommandInvokedEvent,
  2886. "DialogMessageReceived": did.dispidDialogMessageReceivedEvent,
  2887. "DialogParentMessageReceived": did.dispidDialogParentMessageReceivedEvent,
  2888. "ItemChanged": did.dispidOlkItemSelectedChangedEvent,
  2889. "TaskSelectionChanged": did.dispidTaskSelectionChangedEvent,
  2890. "ResourceSelectionChanged": did.dispidResourceSelectionChangedEvent,
  2891. "ViewSelectionChanged": did.dispidViewSelectionChangedEvent,
  2892. "DataNodeInserted": did.dispidDataNodeAddedEvent,
  2893. "DataNodeReplaced": did.dispidDataNodeReplacedEvent,
  2894. "DataNodeDeleted": did.dispidDataNodeDeletedEvent
  2895. };
  2896. for (var event in eventMap) {
  2897. if (jsom[event]) {
  2898. dispIdMap[jsom[event]] = eventMap[event];
  2899. }
  2900. }
  2901. function onException(ex, asyncMethodCall, suppliedArgs, callArgs) {
  2902. if (typeof ex == "number") {
  2903. if (!callArgs) {
  2904. callArgs = asyncMethodCall.getCallArgs(suppliedArgs);
  2905. }
  2906. OSF.DDA.issueAsyncResult(callArgs, ex, OSF.DDA.ErrorCodeManager.getErrorArgs(ex));
  2907. }
  2908. else {
  2909. throw ex;
  2910. }
  2911. }
  2912. ;
  2913. this[OSF.DDA.DispIdHost.Methods.InvokeMethod] = function OSF_DDA_DispIdHost_Facade$InvokeMethod(method, suppliedArguments, caller, privateState) {
  2914. var callArgs;
  2915. try {
  2916. var methodName = method.id;
  2917. var asyncMethodCall = OSF.DDA.AsyncMethodCalls[methodName];
  2918. callArgs = asyncMethodCall.verifyAndExtractCall(suppliedArguments, caller, privateState);
  2919. var dispId = dispIdMap[methodName];
  2920. var delegate = getDelegateMethods(methodName);
  2921. var richApiInExcelMethodSubstitution = null;
  2922. if (window.Excel && window.Office.context.requirements.isSetSupported("RedirectV1Api")) {
  2923. window.Excel._RedirectV1APIs = true;
  2924. }
  2925. if (window.Excel && window.Excel._RedirectV1APIs && (richApiInExcelMethodSubstitution = window.Excel._V1APIMap[methodName])) {
  2926. if (richApiInExcelMethodSubstitution.preprocess) {
  2927. callArgs = richApiInExcelMethodSubstitution.preprocess(callArgs);
  2928. }
  2929. var ctx = new window.Excel.RequestContext();
  2930. var result = richApiInExcelMethodSubstitution.call(ctx, callArgs);
  2931. ctx.sync()
  2932. .then(function () {
  2933. var response = result.value;
  2934. var status = response.status;
  2935. delete response["status"];
  2936. delete response["@odata.type"];
  2937. if (richApiInExcelMethodSubstitution.postprocess) {
  2938. response = richApiInExcelMethodSubstitution.postprocess(response, callArgs);
  2939. }
  2940. if (status != 0) {
  2941. response = OSF.DDA.ErrorCodeManager.getErrorArgs(status);
  2942. }
  2943. OSF.DDA.issueAsyncResult(callArgs, status, response);
  2944. })["catch"](function (error) {
  2945. OSF.DDA.issueAsyncResult(callArgs, OSF.DDA.ErrorCodeManager.errorCodes.ooeFailure, null);
  2946. });
  2947. }
  2948. else {
  2949. var hostCallArgs;
  2950. if (parameterMap.toHost) {
  2951. hostCallArgs = parameterMap.toHost(dispId, callArgs);
  2952. }
  2953. else {
  2954. hostCallArgs = callArgs;
  2955. }
  2956. delegate[OSF.DDA.DispIdHost.Delegates.ExecuteAsync]({
  2957. "dispId": dispId,
  2958. "hostCallArgs": hostCallArgs,
  2959. "onCalling": function OSF_DDA_DispIdFacade$Execute_onCalling() { },
  2960. "onReceiving": function OSF_DDA_DispIdFacade$Execute_onReceiving() { },
  2961. "onComplete": function (status, hostResponseArgs) {
  2962. var responseArgs;
  2963. if (status == OSF.DDA.ErrorCodeManager.errorCodes.ooeSuccess) {
  2964. if (parameterMap.fromHost) {
  2965. responseArgs = parameterMap.fromHost(dispId, hostResponseArgs);
  2966. }
  2967. else {
  2968. responseArgs = hostResponseArgs;
  2969. }
  2970. }
  2971. else {
  2972. responseArgs = hostResponseArgs;
  2973. }
  2974. var payload = asyncMethodCall.processResponse(status, responseArgs, caller, callArgs);
  2975. OSF.DDA.issueAsyncResult(callArgs, status, payload);
  2976. }
  2977. });
  2978. }
  2979. }
  2980. catch (ex) {
  2981. onException(ex, asyncMethodCall, suppliedArguments, callArgs);
  2982. }
  2983. };
  2984. this[OSF.DDA.DispIdHost.Methods.AddEventHandler] = function OSF_DDA_DispIdHost_Facade$AddEventHandler(suppliedArguments, eventDispatch, caller, isPopupWindow) {
  2985. var callArgs;
  2986. var eventType, handler;
  2987. function onEnsureRegistration(status) {
  2988. if (status == OSF.DDA.ErrorCodeManager.errorCodes.ooeSuccess) {
  2989. var added = eventDispatch.addEventHandler(eventType, handler);
  2990. if (!added) {
  2991. status = OSF.DDA.ErrorCodeManager.errorCodes.ooeEventHandlerAdditionFailed;
  2992. }
  2993. }
  2994. var error;
  2995. if (status != OSF.DDA.ErrorCodeManager.errorCodes.ooeSuccess) {
  2996. error = OSF.DDA.ErrorCodeManager.getErrorArgs(status);
  2997. }
  2998. OSF.DDA.issueAsyncResult(callArgs, status, error);
  2999. }
  3000. try {
  3001. var asyncMethodCall = OSF.DDA.AsyncMethodCalls[OSF.DDA.AsyncMethodNames.AddHandlerAsync.id];
  3002. callArgs = asyncMethodCall.verifyAndExtractCall(suppliedArguments, caller, eventDispatch);
  3003. eventType = callArgs[Microsoft.Office.WebExtension.Parameters.EventType];
  3004. handler = callArgs[Microsoft.Office.WebExtension.Parameters.Handler];
  3005. if (isPopupWindow) {
  3006. onEnsureRegistration(OSF.DDA.ErrorCodeManager.errorCodes.ooeSuccess);
  3007. return;
  3008. }
  3009. if (eventDispatch.getEventHandlerCount(eventType) == 0) {
  3010. var dispId = dispIdMap[eventType];
  3011. var invoker = getDelegateMethods(eventType)[OSF.DDA.DispIdHost.Delegates.RegisterEventAsync];
  3012. invoker({
  3013. "eventType": eventType,
  3014. "dispId": dispId,
  3015. "targetId": caller.id || "",
  3016. "onCalling": function OSF_DDA_DispIdFacade$Execute_onCalling() { OSF.OUtil.writeProfilerMark(OSF.HostCallPerfMarker.IssueCall); },
  3017. "onReceiving": function OSF_DDA_DispIdFacade$Execute_onReceiving() { OSF.OUtil.writeProfilerMark(OSF.HostCallPerfMarker.ReceiveResponse); },
  3018. "onComplete": onEnsureRegistration,
  3019. "onEvent": function handleEvent(hostArgs) {
  3020. var args = parameterMap.fromHost(dispId, hostArgs);
  3021. eventDispatch.fireEvent(OSF.DDA.OMFactory.manufactureEventArgs(eventType, caller, args));
  3022. }
  3023. });
  3024. }
  3025. else {
  3026. onEnsureRegistration(OSF.DDA.ErrorCodeManager.errorCodes.ooeSuccess);
  3027. }
  3028. }
  3029. catch (ex) {
  3030. onException(ex, asyncMethodCall, suppliedArguments, callArgs);
  3031. }
  3032. };
  3033. this[OSF.DDA.DispIdHost.Methods.RemoveEventHandler] = function OSF_DDA_DispIdHost_Facade$RemoveEventHandler(suppliedArguments, eventDispatch, caller) {
  3034. var callArgs;
  3035. var eventType, handler;
  3036. function onEnsureRegistration(status) {
  3037. var error;
  3038. if (status != OSF.DDA.ErrorCodeManager.errorCodes.ooeSuccess) {
  3039. error = OSF.DDA.ErrorCodeManager.getErrorArgs(status);
  3040. }
  3041. OSF.DDA.issueAsyncResult(callArgs, status, error);
  3042. }
  3043. try {
  3044. var asyncMethodCall = OSF.DDA.AsyncMethodCalls[OSF.DDA.AsyncMethodNames.RemoveHandlerAsync.id];
  3045. callArgs = asyncMethodCall.verifyAndExtractCall(suppliedArguments, caller, eventDispatch);
  3046. eventType = callArgs[Microsoft.Office.WebExtension.Parameters.EventType];
  3047. handler = callArgs[Microsoft.Office.WebExtension.Parameters.Handler];
  3048. var status, removeSuccess;
  3049. if (handler === null) {
  3050. removeSuccess = eventDispatch.clearEventHandlers(eventType);
  3051. status = OSF.DDA.ErrorCodeManager.errorCodes.ooeSuccess;
  3052. }
  3053. else {
  3054. removeSuccess = eventDispatch.removeEventHandler(eventType, handler);
  3055. status = removeSuccess ? OSF.DDA.ErrorCodeManager.errorCodes.ooeSuccess : OSF.DDA.ErrorCodeManager.errorCodes.ooeEventHandlerNotExist;
  3056. }
  3057. if (removeSuccess && eventDispatch.getEventHandlerCount(eventType) == 0) {
  3058. var dispId = dispIdMap[eventType];
  3059. var invoker = getDelegateMethods(eventType)[OSF.DDA.DispIdHost.Delegates.UnregisterEventAsync];
  3060. invoker({
  3061. "eventType": eventType,
  3062. "dispId": dispId,
  3063. "targetId": caller.id || "",
  3064. "onCalling": function OSF_DDA_DispIdFacade$Execute_onCalling() { OSF.OUtil.writeProfilerMark(OSF.HostCallPerfMarker.IssueCall); },
  3065. "onReceiving": function OSF_DDA_DispIdFacade$Execute_onReceiving() { OSF.OUtil.writeProfilerMark(OSF.HostCallPerfMarker.ReceiveResponse); },
  3066. "onComplete": onEnsureRegistration
  3067. });
  3068. }
  3069. else {
  3070. onEnsureRegistration(status);
  3071. }
  3072. }
  3073. catch (ex) {
  3074. onException(ex, asyncMethodCall, suppliedArguments, callArgs);
  3075. }
  3076. };
  3077. this[OSF.DDA.DispIdHost.Methods.OpenDialog] = function OSF_DDA_DispIdHost_Facade$OpenDialog(suppliedArguments, eventDispatch, caller) {
  3078. var callArgs;
  3079. var targetId;
  3080. var dialogMessageEvent = Microsoft.Office.WebExtension.EventType.DialogMessageReceived;
  3081. var dialogOtherEvent = Microsoft.Office.WebExtension.EventType.DialogEventReceived;
  3082. function onEnsureRegistration(status) {
  3083. var payload;
  3084. if (status != OSF.DDA.ErrorCodeManager.errorCodes.ooeSuccess) {
  3085. payload = OSF.DDA.ErrorCodeManager.getErrorArgs(status);
  3086. }
  3087. else {
  3088. var onSucceedArgs = {};
  3089. onSucceedArgs[Microsoft.Office.WebExtension.Parameters.Id] = targetId;
  3090. onSucceedArgs[Microsoft.Office.WebExtension.Parameters.Data] = eventDispatch;
  3091. var payload = asyncMethodCall.processResponse(status, onSucceedArgs, caller, callArgs);
  3092. OSF.DialogShownStatus.hasDialogShown = true;
  3093. eventDispatch.clearEventHandlers(dialogMessageEvent);
  3094. eventDispatch.clearEventHandlers(dialogOtherEvent);
  3095. }
  3096. OSF.DDA.issueAsyncResult(callArgs, status, payload);
  3097. }
  3098. try {
  3099. if (dialogMessageEvent == undefined || dialogOtherEvent == undefined) {
  3100. onEnsureRegistration(OSF.DDA.ErrorCodeManager.ooeOperationNotSupported);
  3101. }
  3102. if (OSF.DDA.AsyncMethodNames.DisplayDialogAsync == null) {
  3103. onEnsureRegistration(OSF.DDA.ErrorCodeManager.errorCodes.ooeInternalError);
  3104. return;
  3105. }
  3106. var asyncMethodCall = OSF.DDA.AsyncMethodCalls[OSF.DDA.AsyncMethodNames.DisplayDialogAsync.id];
  3107. callArgs = asyncMethodCall.verifyAndExtractCall(suppliedArguments, caller, eventDispatch);
  3108. var dispId = dispIdMap[dialogMessageEvent];
  3109. var delegateMethods = getDelegateMethods(dialogMessageEvent);
  3110. var invoker = delegateMethods[OSF.DDA.DispIdHost.Delegates.OpenDialog] != undefined ?
  3111. delegateMethods[OSF.DDA.DispIdHost.Delegates.OpenDialog] :
  3112. delegateMethods[OSF.DDA.DispIdHost.Delegates.RegisterEventAsync];
  3113. targetId = JSON.stringify(callArgs);
  3114. invoker({
  3115. "eventType": dialogMessageEvent,
  3116. "dispId": dispId,
  3117. "targetId": targetId,
  3118. "onCalling": function OSF_DDA_DispIdFacade$Execute_onCalling() { OSF.OUtil.writeProfilerMark(OSF.HostCallPerfMarker.IssueCall); },
  3119. "onReceiving": function OSF_DDA_DispIdFacade$Execute_onReceiving() { OSF.OUtil.writeProfilerMark(OSF.HostCallPerfMarker.ReceiveResponse); },
  3120. "onComplete": onEnsureRegistration,
  3121. "onEvent": function handleEvent(hostArgs) {
  3122. var args = parameterMap.fromHost(dispId, hostArgs);
  3123. var event = OSF.DDA.OMFactory.manufactureEventArgs(dialogMessageEvent, caller, args);
  3124. if (event.type == dialogOtherEvent) {
  3125. var payload = OSF.DDA.ErrorCodeManager.getErrorArgs(event.error);
  3126. var errorArgs = {};
  3127. errorArgs[OSF.DDA.AsyncResultEnum.ErrorProperties.Code] = status || OSF.DDA.ErrorCodeManager.errorCodes.ooeInternalError;
  3128. errorArgs[OSF.DDA.AsyncResultEnum.ErrorProperties.Name] = payload.name || payload;
  3129. errorArgs[OSF.DDA.AsyncResultEnum.ErrorProperties.Message] = payload.message || payload;
  3130. event.error = new OSF.DDA.Error(errorArgs[OSF.DDA.AsyncResultEnum.ErrorProperties.Name], errorArgs[OSF.DDA.AsyncResultEnum.ErrorProperties.Message], errorArgs[OSF.DDA.AsyncResultEnum.ErrorProperties.Code]);
  3131. }
  3132. eventDispatch.fireOrQueueEvent(event);
  3133. if (args[OSF.DDA.PropertyDescriptors.MessageType] == OSF.DialogMessageType.DialogClosed) {
  3134. eventDispatch.clearEventHandlers(dialogMessageEvent);
  3135. eventDispatch.clearEventHandlers(dialogOtherEvent);
  3136. eventDispatch.clearEventHandlers(Microsoft.Office.WebExtension.EventType.DialogParentMessageReceived);
  3137. OSF.DialogShownStatus.hasDialogShown = false;
  3138. }
  3139. }
  3140. });
  3141. }
  3142. catch (ex) {
  3143. onException(ex, asyncMethodCall, suppliedArguments, callArgs);
  3144. }
  3145. };
  3146. this[OSF.DDA.DispIdHost.Methods.CloseDialog] = function OSF_DDA_DispIdHost_Facade$CloseDialog(suppliedArguments, targetId, eventDispatch, caller) {
  3147. var callArgs;
  3148. var dialogMessageEvent, dialogOtherEvent;
  3149. var closeStatus = OSF.DDA.ErrorCodeManager.errorCodes.ooeSuccess;
  3150. function closeCallback(status) {
  3151. closeStatus = status;
  3152. OSF.DialogShownStatus.hasDialogShown = false;
  3153. }
  3154. try {
  3155. var asyncMethodCall = OSF.DDA.AsyncMethodCalls[OSF.DDA.AsyncMethodNames.CloseAsync.id];
  3156. callArgs = asyncMethodCall.verifyAndExtractCall(suppliedArguments, caller, eventDispatch);
  3157. dialogMessageEvent = Microsoft.Office.WebExtension.EventType.DialogMessageReceived;
  3158. dialogOtherEvent = Microsoft.Office.WebExtension.EventType.DialogEventReceived;
  3159. eventDispatch.clearEventHandlers(dialogMessageEvent);
  3160. eventDispatch.clearEventHandlers(dialogOtherEvent);
  3161. var dispId = dispIdMap[dialogMessageEvent];
  3162. var delegateMethods = getDelegateMethods(dialogMessageEvent);
  3163. var invoker = delegateMethods[OSF.DDA.DispIdHost.Delegates.CloseDialog] != undefined ?
  3164. delegateMethods[OSF.DDA.DispIdHost.Delegates.CloseDialog] :
  3165. delegateMethods[OSF.DDA.DispIdHost.Delegates.UnregisterEventAsync];
  3166. invoker({
  3167. "eventType": dialogMessageEvent,
  3168. "dispId": dispId,
  3169. "targetId": targetId,
  3170. "onCalling": function OSF_DDA_DispIdFacade$Execute_onCalling() { OSF.OUtil.writeProfilerMark(OSF.HostCallPerfMarker.IssueCall); },
  3171. "onReceiving": function OSF_DDA_DispIdFacade$Execute_onReceiving() { OSF.OUtil.writeProfilerMark(OSF.HostCallPerfMarker.ReceiveResponse); },
  3172. "onComplete": closeCallback
  3173. });
  3174. }
  3175. catch (ex) {
  3176. onException(ex, asyncMethodCall, suppliedArguments, callArgs);
  3177. }
  3178. if (closeStatus != OSF.DDA.ErrorCodeManager.errorCodes.ooeSuccess) {
  3179. throw OSF.OUtil.formatString(Strings.OfficeOM.L_FunctionCallFailed, OSF.DDA.AsyncMethodNames.CloseAsync.displayName, closeStatus);
  3180. }
  3181. };
  3182. this[OSF.DDA.DispIdHost.Methods.MessageParent] = function OSF_DDA_DispIdHost_Facade$MessageParent(suppliedArguments, caller) {
  3183. var stateInfo = {};
  3184. var syncMethodCall = OSF.DDA.SyncMethodCalls[OSF.DDA.SyncMethodNames.MessageParent.id];
  3185. var callArgs = syncMethodCall.verifyAndExtractCall(suppliedArguments, caller, stateInfo);
  3186. var delegate = getDelegateMethods(OSF.DDA.SyncMethodNames.MessageParent.id);
  3187. var invoker = delegate[OSF.DDA.DispIdHost.Delegates.MessageParent];
  3188. var dispId = dispIdMap[OSF.DDA.SyncMethodNames.MessageParent.id];
  3189. return invoker({
  3190. "dispId": dispId,
  3191. "hostCallArgs": callArgs,
  3192. "onCalling": function OSF_DDA_DispIdFacade$Execute_onCalling() { OSF.OUtil.writeProfilerMark(OSF.HostCallPerfMarker.IssueCall); },
  3193. "onReceiving": function OSF_DDA_DispIdFacade$Execute_onReceiving() { OSF.OUtil.writeProfilerMark(OSF.HostCallPerfMarker.ReceiveResponse); }
  3194. });
  3195. };
  3196. this[OSF.DDA.DispIdHost.Methods.SendMessage] = function OSF_DDA_DispIdHost_Facade$SendMessage(suppliedArguments, eventDispatch, caller) {
  3197. var stateInfo = {};
  3198. var syncMethodCall = OSF.DDA.SyncMethodCalls[OSF.DDA.SyncMethodNames.SendMessage.id];
  3199. var callArgs = syncMethodCall.verifyAndExtractCall(suppliedArguments, caller, stateInfo);
  3200. var delegate = getDelegateMethods(OSF.DDA.SyncMethodNames.SendMessage.id);
  3201. var invoker = delegate[OSF.DDA.DispIdHost.Delegates.SendMessage];
  3202. var dispId = dispIdMap[OSF.DDA.SyncMethodNames.SendMessage.id];
  3203. return invoker({
  3204. "dispId": dispId,
  3205. "hostCallArgs": callArgs,
  3206. "onCalling": function OSF_DDA_DispIdFacade$Execute_onCalling() { OSF.OUtil.writeProfilerMark(OSF.HostCallPerfMarker.IssueCall); },
  3207. "onReceiving": function OSF_DDA_DispIdFacade$Execute_onReceiving() { OSF.OUtil.writeProfilerMark(OSF.HostCallPerfMarker.ReceiveResponse); }
  3208. });
  3209. };
  3210. };
  3211. OSF.DDA.DispIdHost.addAsyncMethods = function OSF_DDA_DispIdHost$AddAsyncMethods(target, asyncMethodNames, privateState) {
  3212. for (var entry in asyncMethodNames) {
  3213. var method = asyncMethodNames[entry];
  3214. var name = method.displayName;
  3215. if (!target[name]) {
  3216. OSF.OUtil.defineEnumerableProperty(target, name, {
  3217. value: (function (asyncMethod) {
  3218. return function () {
  3219. var invokeMethod = OSF._OfficeAppFactory.getHostFacade()[OSF.DDA.DispIdHost.Methods.InvokeMethod];
  3220. invokeMethod(asyncMethod, arguments, target, privateState);
  3221. };
  3222. })(method)
  3223. });
  3224. }
  3225. }
  3226. };
  3227. OSF.DDA.DispIdHost.addEventSupport = function OSF_DDA_DispIdHost$AddEventSupport(target, eventDispatch, isPopupWindow) {
  3228. var add = OSF.DDA.AsyncMethodNames.AddHandlerAsync.displayName;
  3229. var remove = OSF.DDA.AsyncMethodNames.RemoveHandlerAsync.displayName;
  3230. if (!target[add]) {
  3231. OSF.OUtil.defineEnumerableProperty(target, add, {
  3232. value: function () {
  3233. var addEventHandler = OSF._OfficeAppFactory.getHostFacade()[OSF.DDA.DispIdHost.Methods.AddEventHandler];
  3234. addEventHandler(arguments, eventDispatch, target, isPopupWindow);
  3235. }
  3236. });
  3237. }
  3238. if (!target[remove]) {
  3239. OSF.OUtil.defineEnumerableProperty(target, remove, {
  3240. value: function () {
  3241. var removeEventHandler = OSF._OfficeAppFactory.getHostFacade()[OSF.DDA.DispIdHost.Methods.RemoveEventHandler];
  3242. removeEventHandler(arguments, eventDispatch, target);
  3243. }
  3244. });
  3245. }
  3246. };
  3247. OSF.ShowWindowDialogParameterKeys = {
  3248. Url: "url",
  3249. Width: "width",
  3250. Height: "height",
  3251. DisplayInIframe: "displayInIframe"
  3252. };
  3253. OSF.HostThemeButtonStyleKeys = {
  3254. ButtonBorderColor: "buttonBorderColor",
  3255. ButtonBackgroundColor: "buttonBackgroundColor"
  3256. };
  3257. var OfficeExt;
  3258. (function (OfficeExt) {
  3259. var WACUtils;
  3260. (function (WACUtils) {
  3261. var _trustedDomain = "^https:\/\/[a-zA-Z0-9]+\.(officeapps\.live|officeapps-df\.live|partner\.officewebapps)\.com\/";
  3262. function parseAppContextFromWindowName(skipSessionStorage, windowName) {
  3263. return OSF.OUtil.parseInfoFromWindowName(skipSessionStorage, windowName, OSF.WindowNameItemKeys.AppContext);
  3264. }
  3265. WACUtils.parseAppContextFromWindowName = parseAppContextFromWindowName;
  3266. function serializeObjectToString(response) {
  3267. if (typeof (JSON) !== "undefined") {
  3268. try {
  3269. return JSON.stringify(response);
  3270. }
  3271. catch (ex) {
  3272. }
  3273. }
  3274. return "";
  3275. }
  3276. WACUtils.serializeObjectToString = serializeObjectToString;
  3277. function isHostTrusted() {
  3278. return (new RegExp(_trustedDomain)).test(OSF.getClientEndPoint()._targetUrl);
  3279. }
  3280. WACUtils.isHostTrusted = isHostTrusted;
  3281. function addHostInfoAsQueryParam(url, hostInfoValue) {
  3282. if (!url) {
  3283. return null;
  3284. }
  3285. url = url.trim() || '';
  3286. var questionMark = "?";
  3287. var hostInfo = "_host_Info=";
  3288. var ampHostInfo = "&_host_Info=";
  3289. var fragmentSeparator = "#";
  3290. var urlParts = url.split(fragmentSeparator);
  3291. var urlWithoutFragment = urlParts.shift();
  3292. var fragment = urlParts.join(fragmentSeparator);
  3293. var querySplits = urlWithoutFragment.split(questionMark);
  3294. var urlWithoutFragmentWithHostInfo;
  3295. if (querySplits.length > 1) {
  3296. urlWithoutFragmentWithHostInfo = urlWithoutFragment + ampHostInfo + hostInfoValue;
  3297. }
  3298. else if (querySplits.length > 0) {
  3299. urlWithoutFragmentWithHostInfo = urlWithoutFragment + questionMark + hostInfo + hostInfoValue;
  3300. }
  3301. return [urlWithoutFragmentWithHostInfo, fragmentSeparator, fragment].join('');
  3302. }
  3303. WACUtils.addHostInfoAsQueryParam = addHostInfoAsQueryParam;
  3304. function getDomainForUrl(url) {
  3305. if (!url) {
  3306. return null;
  3307. }
  3308. var url_parser = document.createElement('a');
  3309. url_parser.href = url;
  3310. return url_parser.protocol + "//" + url_parser.host;
  3311. }
  3312. WACUtils.getDomainForUrl = getDomainForUrl;
  3313. })(WACUtils = OfficeExt.WACUtils || (OfficeExt.WACUtils = {}));
  3314. })(OfficeExt || (OfficeExt = {}));
  3315. var OfficeExt;
  3316. (function (OfficeExt) {
  3317. var MsAjaxTypeHelper = (function () {
  3318. function MsAjaxTypeHelper() {
  3319. }
  3320. MsAjaxTypeHelper.isInstanceOfType = function (type, instance) {
  3321. if (typeof (instance) === "undefined" || instance === null)
  3322. return false;
  3323. if (instance instanceof type)
  3324. return true;
  3325. var instanceType = instance.constructor;
  3326. if (!instanceType || (typeof (instanceType) !== "function") || !instanceType.__typeName || instanceType.__typeName === 'Object') {
  3327. instanceType = Object;
  3328. }
  3329. return !!(instanceType === type) ||
  3330. (instanceType.__typeName && type.__typeName && instanceType.__typeName === type.__typeName);
  3331. };
  3332. return MsAjaxTypeHelper;
  3333. })();
  3334. OfficeExt.MsAjaxTypeHelper = MsAjaxTypeHelper;
  3335. var MsAjaxError = (function () {
  3336. function MsAjaxError() {
  3337. }
  3338. MsAjaxError.create = function (message, errorInfo) {
  3339. var err = new Error(message);
  3340. err.message = message;
  3341. if (errorInfo) {
  3342. for (var v in errorInfo) {
  3343. err[v] = errorInfo[v];
  3344. }
  3345. }
  3346. err.popStackFrame();
  3347. return err;
  3348. };
  3349. MsAjaxError.parameterCount = function (message) {
  3350. var displayMessage = "Sys.ParameterCountException: " + (message ? message : "Parameter count mismatch.");
  3351. var err = MsAjaxError.create(displayMessage, { name: 'Sys.ParameterCountException' });
  3352. err.popStackFrame();
  3353. return err;
  3354. };
  3355. MsAjaxError.argument = function (paramName, message) {
  3356. var displayMessage = "Sys.ArgumentException: " + (message ? message : "Value does not fall within the expected range.");
  3357. if (paramName) {
  3358. displayMessage += "\n" + MsAjaxString.format("Parameter name: {0}", paramName);
  3359. }
  3360. var err = MsAjaxError.create(displayMessage, { name: "Sys.ArgumentException", paramName: paramName });
  3361. err.popStackFrame();
  3362. return err;
  3363. };
  3364. MsAjaxError.argumentNull = function (paramName, message) {
  3365. var displayMessage = "Sys.ArgumentNullException: " + (message ? message : "Value cannot be null.");
  3366. if (paramName) {
  3367. displayMessage += "\n" + MsAjaxString.format("Parameter name: {0}", paramName);
  3368. }
  3369. var err = MsAjaxError.create(displayMessage, { name: "Sys.ArgumentNullException", paramName: paramName });
  3370. err.popStackFrame();
  3371. return err;
  3372. };
  3373. MsAjaxError.argumentOutOfRange = function (paramName, actualValue, message) {
  3374. var displayMessage = "Sys.ArgumentOutOfRangeException: " + (message ? message : "Specified argument was out of the range of valid values.");
  3375. if (paramName) {
  3376. displayMessage += "\n" + MsAjaxString.format("Parameter name: {0}", paramName);
  3377. }
  3378. if (typeof (actualValue) !== "undefined" && actualValue !== null) {
  3379. displayMessage += "\n" + MsAjaxString.format("Actual value was {0}.", actualValue);
  3380. }
  3381. var err = MsAjaxError.create(displayMessage, {
  3382. name: "Sys.ArgumentOutOfRangeException",
  3383. paramName: paramName,
  3384. actualValue: actualValue
  3385. });
  3386. err.popStackFrame();
  3387. return err;
  3388. };
  3389. MsAjaxError.argumentType = function (paramName, actualType, expectedType, message) {
  3390. var displayMessage = "Sys.ArgumentTypeException: ";
  3391. if (message) {
  3392. displayMessage += message;
  3393. }
  3394. else if (actualType && expectedType) {
  3395. displayMessage += MsAjaxString.format("Object of type '{0}' cannot be converted to type '{1}'.", actualType.getName ? actualType.getName() : actualType, expectedType.getName ? expectedType.getName() : expectedType);
  3396. }
  3397. else {
  3398. displayMessage += "Object cannot be converted to the required type.";
  3399. }
  3400. if (paramName) {
  3401. displayMessage += "\n" + MsAjaxString.format("Parameter name: {0}", paramName);
  3402. }
  3403. var err = MsAjaxError.create(displayMessage, {
  3404. name: "Sys.ArgumentTypeException",
  3405. paramName: paramName,
  3406. actualType: actualType,
  3407. expectedType: expectedType
  3408. });
  3409. err.popStackFrame();
  3410. return err;
  3411. };
  3412. MsAjaxError.argumentUndefined = function (paramName, message) {
  3413. var displayMessage = "Sys.ArgumentUndefinedException: " + (message ? message : "Value cannot be undefined.");
  3414. if (paramName) {
  3415. displayMessage += "\n" + MsAjaxString.format("Parameter name: {0}", paramName);
  3416. }
  3417. var err = MsAjaxError.create(displayMessage, { name: "Sys.ArgumentUndefinedException", paramName: paramName });
  3418. err.popStackFrame();
  3419. return err;
  3420. };
  3421. MsAjaxError.invalidOperation = function (message) {
  3422. var displayMessage = "Sys.InvalidOperationException: " + (message ? message : "Operation is not valid due to the current state of the object.");
  3423. var err = MsAjaxError.create(displayMessage, { name: 'Sys.InvalidOperationException' });
  3424. err.popStackFrame();
  3425. return err;
  3426. };
  3427. return MsAjaxError;
  3428. })();
  3429. OfficeExt.MsAjaxError = MsAjaxError;
  3430. var MsAjaxString = (function () {
  3431. function MsAjaxString() {
  3432. }
  3433. MsAjaxString.format = function (format) {
  3434. var args = [];
  3435. for (var _i = 1; _i < arguments.length; _i++) {
  3436. args[_i - 1] = arguments[_i];
  3437. }
  3438. var source = format;
  3439. return source.replace(/{(\d+)}/gm, function (match, number) {
  3440. var index = parseInt(number, 10);
  3441. return args[index] === undefined ? '{' + number + '}' : args[index];
  3442. });
  3443. };
  3444. MsAjaxString.startsWith = function (str, prefix) {
  3445. return (str.substr(0, prefix.length) === prefix);
  3446. };
  3447. return MsAjaxString;
  3448. })();
  3449. OfficeExt.MsAjaxString = MsAjaxString;
  3450. var MsAjaxDebug = (function () {
  3451. function MsAjaxDebug() {
  3452. }
  3453. MsAjaxDebug.trace = function (text) {
  3454. if (typeof Debug !== "undefined" && Debug.writeln)
  3455. Debug.writeln(text);
  3456. if (window.console && window.console.log)
  3457. window.console.log(text);
  3458. if (window.opera && window.opera.postError)
  3459. window.opera.postError(text);
  3460. if (window.debugService && window.debugService.trace)
  3461. window.debugService.trace(text);
  3462. var a = document.getElementById("TraceConsole");
  3463. if (a && a.tagName.toUpperCase() === "TEXTAREA") {
  3464. a.innerHTML += text + "\n";
  3465. }
  3466. };
  3467. return MsAjaxDebug;
  3468. })();
  3469. OfficeExt.MsAjaxDebug = MsAjaxDebug;
  3470. if (!OsfMsAjaxFactory.isMsAjaxLoaded()) {
  3471. var registerTypeInternal = function registerTypeInternal(type, name, isClass) {
  3472. if (type.__typeName === undefined) {
  3473. type.__typeName = name;
  3474. }
  3475. if (type.__class === undefined) {
  3476. type.__class = isClass;
  3477. }
  3478. };
  3479. registerTypeInternal(Function, "Function", true);
  3480. registerTypeInternal(Error, "Error", true);
  3481. registerTypeInternal(Object, "Object", true);
  3482. registerTypeInternal(String, "String", true);
  3483. registerTypeInternal(Boolean, "Boolean", true);
  3484. registerTypeInternal(Date, "Date", true);
  3485. registerTypeInternal(Number, "Number", true);
  3486. registerTypeInternal(RegExp, "RegExp", true);
  3487. registerTypeInternal(Array, "Array", true);
  3488. if (!Function.createCallback) {
  3489. Function.createCallback = function Function$createCallback(method, context) {
  3490. var e = Function._validateParams(arguments, [
  3491. { name: "method", type: Function },
  3492. { name: "context", mayBeNull: true }
  3493. ]);
  3494. if (e)
  3495. throw e;
  3496. return function () {
  3497. var l = arguments.length;
  3498. if (l > 0) {
  3499. var args = [];
  3500. for (var i = 0; i < l; i++) {
  3501. args[i] = arguments[i];
  3502. }
  3503. args[l] = context;
  3504. return method.apply(this, args);
  3505. }
  3506. return method.call(this, context);
  3507. };
  3508. };
  3509. }
  3510. if (!Function.createDelegate) {
  3511. Function.createDelegate = function Function$createDelegate(instance, method) {
  3512. var e = Function._validateParams(arguments, [
  3513. { name: "instance", mayBeNull: true },
  3514. { name: "method", type: Function }
  3515. ]);
  3516. if (e)
  3517. throw e;
  3518. return function () {
  3519. return method.apply(instance, arguments);
  3520. };
  3521. };
  3522. }
  3523. if (!Function._validateParams) {
  3524. Function._validateParams = function (params, expectedParams, validateParameterCount) {
  3525. var e, expectedLength = expectedParams.length;
  3526. validateParameterCount = validateParameterCount || (typeof (validateParameterCount) === "undefined");
  3527. e = Function._validateParameterCount(params, expectedParams, validateParameterCount);
  3528. if (e) {
  3529. e.popStackFrame();
  3530. return e;
  3531. }
  3532. for (var i = 0, l = params.length; i < l; i++) {
  3533. var expectedParam = expectedParams[Math.min(i, expectedLength - 1)], paramName = expectedParam.name;
  3534. if (expectedParam.parameterArray) {
  3535. paramName += "[" + (i - expectedLength + 1) + "]";
  3536. }
  3537. else if (!validateParameterCount && (i >= expectedLength)) {
  3538. break;
  3539. }
  3540. e = Function._validateParameter(params[i], expectedParam, paramName);
  3541. if (e) {
  3542. e.popStackFrame();
  3543. return e;
  3544. }
  3545. }
  3546. return null;
  3547. };
  3548. }
  3549. if (!Function._validateParameterCount) {
  3550. Function._validateParameterCount = function (params, expectedParams, validateParameterCount) {
  3551. var i, error, expectedLen = expectedParams.length, actualLen = params.length;
  3552. if (actualLen < expectedLen) {
  3553. var minParams = expectedLen;
  3554. for (i = 0; i < expectedLen; i++) {
  3555. var param = expectedParams[i];
  3556. if (param.optional || param.parameterArray) {
  3557. minParams--;
  3558. }
  3559. }
  3560. if (actualLen < minParams) {
  3561. error = true;
  3562. }
  3563. }
  3564. else if (validateParameterCount && (actualLen > expectedLen)) {
  3565. error = true;
  3566. for (i = 0; i < expectedLen; i++) {
  3567. if (expectedParams[i].parameterArray) {
  3568. error = false;
  3569. break;
  3570. }
  3571. }
  3572. }
  3573. if (error) {
  3574. var e = MsAjaxError.parameterCount();
  3575. e.popStackFrame();
  3576. return e;
  3577. }
  3578. return null;
  3579. };
  3580. }
  3581. if (!Function._validateParameter) {
  3582. Function._validateParameter = function (param, expectedParam, paramName) {
  3583. var e, expectedType = expectedParam.type, expectedInteger = !!expectedParam.integer, expectedDomElement = !!expectedParam.domElement, mayBeNull = !!expectedParam.mayBeNull;
  3584. e = Function._validateParameterType(param, expectedType, expectedInteger, expectedDomElement, mayBeNull, paramName);
  3585. if (e) {
  3586. e.popStackFrame();
  3587. return e;
  3588. }
  3589. var expectedElementType = expectedParam.elementType, elementMayBeNull = !!expectedParam.elementMayBeNull;
  3590. if (expectedType === Array && typeof (param) !== "undefined" && param !== null &&
  3591. (expectedElementType || !elementMayBeNull)) {
  3592. var expectedElementInteger = !!expectedParam.elementInteger, expectedElementDomElement = !!expectedParam.elementDomElement;
  3593. for (var i = 0; i < param.length; i++) {
  3594. var elem = param[i];
  3595. e = Function._validateParameterType(elem, expectedElementType, expectedElementInteger, expectedElementDomElement, elementMayBeNull, paramName + "[" + i + "]");
  3596. if (e) {
  3597. e.popStackFrame();
  3598. return e;
  3599. }
  3600. }
  3601. }
  3602. return null;
  3603. };
  3604. }
  3605. if (!Function._validateParameterType) {
  3606. Function._validateParameterType = function (param, expectedType, expectedInteger, expectedDomElement, mayBeNull, paramName) {
  3607. var e, i;
  3608. if (typeof (param) === "undefined") {
  3609. if (mayBeNull) {
  3610. return null;
  3611. }
  3612. else {
  3613. e = OfficeExt.MsAjaxError.argumentUndefined(paramName);
  3614. e.popStackFrame();
  3615. return e;
  3616. }
  3617. }
  3618. if (param === null) {
  3619. if (mayBeNull) {
  3620. return null;
  3621. }
  3622. else {
  3623. e = OfficeExt.MsAjaxError.argumentNull(paramName);
  3624. e.popStackFrame();
  3625. return e;
  3626. }
  3627. }
  3628. if (expectedType && !OfficeExt.MsAjaxTypeHelper.isInstanceOfType(expectedType, param)) {
  3629. e = OfficeExt.MsAjaxError.argumentType(paramName, typeof (param), expectedType);
  3630. e.popStackFrame();
  3631. return e;
  3632. }
  3633. return null;
  3634. };
  3635. }
  3636. if (!window.Type) {
  3637. window.Type = Function;
  3638. }
  3639. if (!Type.registerNamespace) {
  3640. Type.registerNamespace = function (ns) {
  3641. var namespaceParts = ns.split('.');
  3642. var currentNamespace = window;
  3643. for (var i = 0; i < namespaceParts.length; i++) {
  3644. currentNamespace[namespaceParts[i]] = currentNamespace[namespaceParts[i]] || {};
  3645. currentNamespace = currentNamespace[namespaceParts[i]];
  3646. }
  3647. };
  3648. }
  3649. if (!Type.prototype.registerClass) {
  3650. Type.prototype.registerClass = function (cls) { cls = {}; };
  3651. }
  3652. if (typeof (Sys) === "undefined") {
  3653. Type.registerNamespace('Sys');
  3654. }
  3655. if (!Error.prototype.popStackFrame) {
  3656. Error.prototype.popStackFrame = function () {
  3657. if (arguments.length !== 0)
  3658. throw MsAjaxError.parameterCount();
  3659. if (typeof (this.stack) === "undefined" || this.stack === null ||
  3660. typeof (this.fileName) === "undefined" || this.fileName === null ||
  3661. typeof (this.lineNumber) === "undefined" || this.lineNumber === null) {
  3662. return;
  3663. }
  3664. var stackFrames = this.stack.split("\n");
  3665. var currentFrame = stackFrames[0];
  3666. var pattern = this.fileName + ":" + this.lineNumber;
  3667. while (typeof (currentFrame) !== "undefined" &&
  3668. currentFrame !== null &&
  3669. currentFrame.indexOf(pattern) === -1) {
  3670. stackFrames.shift();
  3671. currentFrame = stackFrames[0];
  3672. }
  3673. var nextFrame = stackFrames[1];
  3674. if (typeof (nextFrame) === "undefined" || nextFrame === null) {
  3675. return;
  3676. }
  3677. var nextFrameParts = nextFrame.match(/@(.*):(\d+)$/);
  3678. if (typeof (nextFrameParts) === "undefined" || nextFrameParts === null) {
  3679. return;
  3680. }
  3681. this.fileName = nextFrameParts[1];
  3682. this.lineNumber = parseInt(nextFrameParts[2]);
  3683. stackFrames.shift();
  3684. this.stack = stackFrames.join("\n");
  3685. };
  3686. }
  3687. OsfMsAjaxFactory.msAjaxError = MsAjaxError;
  3688. OsfMsAjaxFactory.msAjaxString = MsAjaxString;
  3689. OsfMsAjaxFactory.msAjaxDebug = MsAjaxDebug;
  3690. }
  3691. })(OfficeExt || (OfficeExt = {}));
  3692. OSF.OUtil.setNamespace("Microsoft", window);
  3693. OSF.OUtil.setNamespace("Office", Microsoft);
  3694. OSF.OUtil.setNamespace("Common", Microsoft.Office);
  3695. OSF.SerializerVersion = {
  3696. MsAjax: 0,
  3697. Browser: 1
  3698. };
  3699. var OfficeExt;
  3700. (function (OfficeExt) {
  3701. function appSpecificCheckOriginFunction(url, eventObj, messageObj, checkOriginFunction) {
  3702. return true;
  3703. }
  3704. ;
  3705. OfficeExt.appSpecificCheckOrigin = appSpecificCheckOriginFunction;
  3706. })(OfficeExt || (OfficeExt = {}));
  3707. Microsoft.Office.Common.InvokeType = { "async": 0,
  3708. "sync": 1,
  3709. "asyncRegisterEvent": 2,
  3710. "asyncUnregisterEvent": 3,
  3711. "syncRegisterEvent": 4,
  3712. "syncUnregisterEvent": 5
  3713. };
  3714. Microsoft.Office.Common.InvokeResultCode = {
  3715. "noError": 0,
  3716. "errorInRequest": -1,
  3717. "errorHandlingRequest": -2,
  3718. "errorInResponse": -3,
  3719. "errorHandlingResponse": -4,
  3720. "errorHandlingRequestAccessDenied": -5,
  3721. "errorHandlingMethodCallTimedout": -6
  3722. };
  3723. Microsoft.Office.Common.MessageType = { "request": 0,
  3724. "response": 1
  3725. };
  3726. Microsoft.Office.Common.ActionType = { "invoke": 0,
  3727. "registerEvent": 1,
  3728. "unregisterEvent": 2 };
  3729. Microsoft.Office.Common.ResponseType = { "forCalling": 0,
  3730. "forEventing": 1
  3731. };
  3732. Microsoft.Office.Common.MethodObject = function Microsoft_Office_Common_MethodObject(method, invokeType, blockingOthers) {
  3733. this._method = method;
  3734. this._invokeType = invokeType;
  3735. this._blockingOthers = blockingOthers;
  3736. };
  3737. Microsoft.Office.Common.MethodObject.prototype = {
  3738. getMethod: function Microsoft_Office_Common_MethodObject$getMethod() {
  3739. return this._method;
  3740. },
  3741. getInvokeType: function Microsoft_Office_Common_MethodObject$getInvokeType() {
  3742. return this._invokeType;
  3743. },
  3744. getBlockingFlag: function Microsoft_Office_Common_MethodObject$getBlockingFlag() {
  3745. return this._blockingOthers;
  3746. }
  3747. };
  3748. Microsoft.Office.Common.EventMethodObject = function Microsoft_Office_Common_EventMethodObject(registerMethodObject, unregisterMethodObject) {
  3749. this._registerMethodObject = registerMethodObject;
  3750. this._unregisterMethodObject = unregisterMethodObject;
  3751. };
  3752. Microsoft.Office.Common.EventMethodObject.prototype = {
  3753. getRegisterMethodObject: function Microsoft_Office_Common_EventMethodObject$getRegisterMethodObject() {
  3754. return this._registerMethodObject;
  3755. },
  3756. getUnregisterMethodObject: function Microsoft_Office_Common_EventMethodObject$getUnregisterMethodObject() {
  3757. return this._unregisterMethodObject;
  3758. }
  3759. };
  3760. Microsoft.Office.Common.ServiceEndPoint = function Microsoft_Office_Common_ServiceEndPoint(serviceEndPointId) {
  3761. var e = Function._validateParams(arguments, [
  3762. { name: "serviceEndPointId", type: String, mayBeNull: false }
  3763. ]);
  3764. if (e)
  3765. throw e;
  3766. this._methodObjectList = {};
  3767. this._eventHandlerProxyList = {};
  3768. this._Id = serviceEndPointId;
  3769. this._conversations = {};
  3770. this._policyManager = null;
  3771. this._appDomains = {};
  3772. this._onHandleRequestError = null;
  3773. };
  3774. Microsoft.Office.Common.ServiceEndPoint.prototype = {
  3775. registerMethod: function Microsoft_Office_Common_ServiceEndPoint$registerMethod(methodName, method, invokeType, blockingOthers) {
  3776. var e = Function._validateParams(arguments, [{ name: "methodName", type: String, mayBeNull: false },
  3777. { name: "method", type: Function, mayBeNull: false },
  3778. { name: "invokeType", type: Number, mayBeNull: false },
  3779. { name: "blockingOthers", type: Boolean, mayBeNull: false }
  3780. ]);
  3781. if (e)
  3782. throw e;
  3783. if (invokeType !== Microsoft.Office.Common.InvokeType.async
  3784. && invokeType !== Microsoft.Office.Common.InvokeType.sync) {
  3785. throw OsfMsAjaxFactory.msAjaxError.argument("invokeType");
  3786. }
  3787. var methodObject = new Microsoft.Office.Common.MethodObject(method, invokeType, blockingOthers);
  3788. this._methodObjectList[methodName] = methodObject;
  3789. },
  3790. unregisterMethod: function Microsoft_Office_Common_ServiceEndPoint$unregisterMethod(methodName) {
  3791. var e = Function._validateParams(arguments, [
  3792. { name: "methodName", type: String, mayBeNull: false }
  3793. ]);
  3794. if (e)
  3795. throw e;
  3796. delete this._methodObjectList[methodName];
  3797. },
  3798. registerEvent: function Microsoft_Office_Common_ServiceEndPoint$registerEvent(eventName, registerMethod, unregisterMethod) {
  3799. var e = Function._validateParams(arguments, [{ name: "eventName", type: String, mayBeNull: false },
  3800. { name: "registerMethod", type: Function, mayBeNull: false },
  3801. { name: "unregisterMethod", type: Function, mayBeNull: false }
  3802. ]);
  3803. if (e)
  3804. throw e;
  3805. var methodObject = new Microsoft.Office.Common.EventMethodObject(new Microsoft.Office.Common.MethodObject(registerMethod, Microsoft.Office.Common.InvokeType.syncRegisterEvent, false), new Microsoft.Office.Common.MethodObject(unregisterMethod, Microsoft.Office.Common.InvokeType.syncUnregisterEvent, false));
  3806. this._methodObjectList[eventName] = methodObject;
  3807. },
  3808. registerEventEx: function Microsoft_Office_Common_ServiceEndPoint$registerEventEx(eventName, registerMethod, registerMethodInvokeType, unregisterMethod, unregisterMethodInvokeType) {
  3809. var e = Function._validateParams(arguments, [{ name: "eventName", type: String, mayBeNull: false },
  3810. { name: "registerMethod", type: Function, mayBeNull: false },
  3811. { name: "registerMethodInvokeType", type: Number, mayBeNull: false },
  3812. { name: "unregisterMethod", type: Function, mayBeNull: false },
  3813. { name: "unregisterMethodInvokeType", type: Number, mayBeNull: false }
  3814. ]);
  3815. if (e)
  3816. throw e;
  3817. var methodObject = new Microsoft.Office.Common.EventMethodObject(new Microsoft.Office.Common.MethodObject(registerMethod, registerMethodInvokeType, false), new Microsoft.Office.Common.MethodObject(unregisterMethod, unregisterMethodInvokeType, false));
  3818. this._methodObjectList[eventName] = methodObject;
  3819. },
  3820. unregisterEvent: function (eventName) {
  3821. var e = Function._validateParams(arguments, [
  3822. { name: "eventName", type: String, mayBeNull: false }
  3823. ]);
  3824. if (e)
  3825. throw e;
  3826. this.unregisterMethod(eventName);
  3827. },
  3828. registerConversation: function Microsoft_Office_Common_ServiceEndPoint$registerConversation(conversationId, conversationUrl, appDomains, serializerVersion) {
  3829. var e = Function._validateParams(arguments, [
  3830. { name: "conversationId", type: String, mayBeNull: false },
  3831. { name: "conversationUrl", type: String, mayBeNull: false, optional: true },
  3832. { name: "appDomains", type: Object, mayBeNull: true, optional: true },
  3833. { name: "serializerVersion", type: Number, mayBeNull: true, optional: true }
  3834. ]);
  3835. if (e)
  3836. throw e;
  3837. ;
  3838. if (appDomains) {
  3839. if (!(appDomains instanceof Array)) {
  3840. throw OsfMsAjaxFactory.msAjaxError.argument("appDomains");
  3841. }
  3842. this._appDomains[conversationId] = appDomains;
  3843. }
  3844. this._conversations[conversationId] = { url: conversationUrl, serializerVersion: serializerVersion };
  3845. },
  3846. unregisterConversation: function Microsoft_Office_Common_ServiceEndPoint$unregisterConversation(conversationId) {
  3847. var e = Function._validateParams(arguments, [
  3848. { name: "conversationId", type: String, mayBeNull: false }
  3849. ]);
  3850. if (e)
  3851. throw e;
  3852. delete this._conversations[conversationId];
  3853. },
  3854. setPolicyManager: function Microsoft_Office_Common_ServiceEndPoint$setPolicyManager(policyManager) {
  3855. var e = Function._validateParams(arguments, [
  3856. { name: "policyManager", type: Object, mayBeNull: false }
  3857. ]);
  3858. if (e)
  3859. throw e;
  3860. if (!policyManager.checkPermission) {
  3861. throw OsfMsAjaxFactory.msAjaxError.argument("policyManager");
  3862. }
  3863. this._policyManager = policyManager;
  3864. },
  3865. getPolicyManager: function Microsoft_Office_Common_ServiceEndPoint$getPolicyManager() {
  3866. return this._policyManager;
  3867. },
  3868. dispose: function Microsoft_Office_Common_ServiceEndPoint$dispose() {
  3869. this._methodObjectList = null;
  3870. this._eventHandlerProxyList = null;
  3871. this._Id = null;
  3872. this._conversations = null;
  3873. this._policyManager = null;
  3874. this._appDomains = null;
  3875. this._onHandleRequestError = null;
  3876. }
  3877. };
  3878. Microsoft.Office.Common.ClientEndPoint = function Microsoft_Office_Common_ClientEndPoint(conversationId, targetWindow, targetUrl, serializerVersion) {
  3879. var e = Function._validateParams(arguments, [
  3880. { name: "conversationId", type: String, mayBeNull: false },
  3881. { name: "targetWindow", mayBeNull: false },
  3882. { name: "targetUrl", type: String, mayBeNull: false },
  3883. { name: "serializerVersion", type: Number, mayBeNull: true, optional: true }
  3884. ]);
  3885. if (e)
  3886. throw e;
  3887. try {
  3888. if (!targetWindow.postMessage) {
  3889. throw OsfMsAjaxFactory.msAjaxError.argument("targetWindow");
  3890. }
  3891. }
  3892. catch (ex) {
  3893. if (!Object.prototype.hasOwnProperty.call(targetWindow, "postMessage")) {
  3894. throw OsfMsAjaxFactory.msAjaxError.argument("targetWindow");
  3895. }
  3896. }
  3897. this._conversationId = conversationId;
  3898. this._targetWindow = targetWindow;
  3899. this._targetUrl = targetUrl;
  3900. this._callingIndex = 0;
  3901. this._callbackList = {};
  3902. this._eventHandlerList = {};
  3903. if (serializerVersion != null) {
  3904. this._serializerVersion = serializerVersion;
  3905. }
  3906. else {
  3907. this._serializerVersion = OSF.SerializerVersion.Browser;
  3908. }
  3909. };
  3910. Microsoft.Office.Common.ClientEndPoint.prototype = {
  3911. invoke: function Microsoft_Office_Common_ClientEndPoint$invoke(targetMethodName, callback, param) {
  3912. var e = Function._validateParams(arguments, [{ name: "targetMethodName", type: String, mayBeNull: false },
  3913. { name: "callback", type: Function, mayBeNull: true },
  3914. { name: "param", mayBeNull: true }
  3915. ]);
  3916. if (e)
  3917. throw e;
  3918. var correlationId = this._callingIndex++;
  3919. var now = new Date();
  3920. var callbackEntry = { "callback": callback, "createdOn": now.getTime() };
  3921. if (param && typeof param === "object" && typeof param.__timeout__ === "number") {
  3922. callbackEntry.timeout = param.__timeout__;
  3923. delete param.__timeout__;
  3924. }
  3925. this._callbackList[correlationId] = callbackEntry;
  3926. try {
  3927. var callRequest = new Microsoft.Office.Common.Request(targetMethodName, Microsoft.Office.Common.ActionType.invoke, this._conversationId, correlationId, param);
  3928. var msg = Microsoft.Office.Common.MessagePackager.envelope(callRequest, this._serializerVersion);
  3929. this._targetWindow.postMessage(msg, this._targetUrl);
  3930. Microsoft.Office.Common.XdmCommunicationManager._startMethodTimeoutTimer();
  3931. }
  3932. catch (ex) {
  3933. try {
  3934. if (callback !== null)
  3935. callback(Microsoft.Office.Common.InvokeResultCode.errorInRequest, ex);
  3936. }
  3937. finally {
  3938. delete this._callbackList[correlationId];
  3939. }
  3940. }
  3941. },
  3942. registerForEvent: function Microsoft_Office_Common_ClientEndPoint$registerForEvent(targetEventName, eventHandler, callback, data) {
  3943. var e = Function._validateParams(arguments, [{ name: "targetEventName", type: String, mayBeNull: false },
  3944. { name: "eventHandler", type: Function, mayBeNull: false },
  3945. { name: "callback", type: Function, mayBeNull: true },
  3946. { name: "data", mayBeNull: true, optional: true }
  3947. ]);
  3948. if (e)
  3949. throw e;
  3950. var correlationId = this._callingIndex++;
  3951. var now = new Date();
  3952. this._callbackList[correlationId] = { "callback": callback, "createdOn": now.getTime() };
  3953. try {
  3954. var callRequest = new Microsoft.Office.Common.Request(targetEventName, Microsoft.Office.Common.ActionType.registerEvent, this._conversationId, correlationId, data);
  3955. var msg = Microsoft.Office.Common.MessagePackager.envelope(callRequest, this._serializerVersion);
  3956. this._targetWindow.postMessage(msg, this._targetUrl);
  3957. Microsoft.Office.Common.XdmCommunicationManager._startMethodTimeoutTimer();
  3958. this._eventHandlerList[targetEventName] = eventHandler;
  3959. }
  3960. catch (ex) {
  3961. try {
  3962. if (callback !== null) {
  3963. callback(Microsoft.Office.Common.InvokeResultCode.errorInRequest, ex);
  3964. }
  3965. }
  3966. finally {
  3967. delete this._callbackList[correlationId];
  3968. }
  3969. }
  3970. },
  3971. unregisterForEvent: function Microsoft_Office_Common_ClientEndPoint$unregisterForEvent(targetEventName, callback, data) {
  3972. var e = Function._validateParams(arguments, [{ name: "targetEventName", type: String, mayBeNull: false },
  3973. { name: "callback", type: Function, mayBeNull: true },
  3974. { name: "data", mayBeNull: true, optional: true }
  3975. ]);
  3976. if (e)
  3977. throw e;
  3978. var correlationId = this._callingIndex++;
  3979. var now = new Date();
  3980. this._callbackList[correlationId] = { "callback": callback, "createdOn": now.getTime() };
  3981. try {
  3982. var callRequest = new Microsoft.Office.Common.Request(targetEventName, Microsoft.Office.Common.ActionType.unregisterEvent, this._conversationId, correlationId, data);
  3983. var msg = Microsoft.Office.Common.MessagePackager.envelope(callRequest, this._serializerVersion);
  3984. this._targetWindow.postMessage(msg, this._targetUrl);
  3985. Microsoft.Office.Common.XdmCommunicationManager._startMethodTimeoutTimer();
  3986. }
  3987. catch (ex) {
  3988. try {
  3989. if (callback !== null) {
  3990. callback(Microsoft.Office.Common.InvokeResultCode.errorInRequest, ex);
  3991. }
  3992. }
  3993. finally {
  3994. delete this._callbackList[correlationId];
  3995. }
  3996. }
  3997. finally {
  3998. delete this._eventHandlerList[targetEventName];
  3999. }
  4000. }
  4001. };
  4002. Microsoft.Office.Common.XdmCommunicationManager = (function () {
  4003. var _invokerQueue = [];
  4004. var _lastMessageProcessTime = null;
  4005. var _messageProcessingTimer = null;
  4006. var _processInterval = 10;
  4007. var _blockingFlag = false;
  4008. var _methodTimeoutTimer = null;
  4009. var _methodTimeoutProcessInterval = 2000;
  4010. var _methodTimeoutDefault = 65000;
  4011. var _methodTimeout = _methodTimeoutDefault;
  4012. var _serviceEndPoints = {};
  4013. var _clientEndPoints = {};
  4014. var _initialized = false;
  4015. function _lookupServiceEndPoint(conversationId) {
  4016. for (var id in _serviceEndPoints) {
  4017. if (_serviceEndPoints[id]._conversations[conversationId]) {
  4018. return _serviceEndPoints[id];
  4019. }
  4020. }
  4021. OsfMsAjaxFactory.msAjaxDebug.trace("Unknown conversation Id.");
  4022. throw OsfMsAjaxFactory.msAjaxError.argument("conversationId");
  4023. }
  4024. ;
  4025. function _lookupClientEndPoint(conversationId) {
  4026. var clientEndPoint = _clientEndPoints[conversationId];
  4027. if (!clientEndPoint) {
  4028. OsfMsAjaxFactory.msAjaxDebug.trace("Unknown conversation Id.");
  4029. }
  4030. return clientEndPoint;
  4031. }
  4032. ;
  4033. function _lookupMethodObject(serviceEndPoint, messageObject) {
  4034. var methodOrEventMethodObject = serviceEndPoint._methodObjectList[messageObject._actionName];
  4035. if (!methodOrEventMethodObject) {
  4036. OsfMsAjaxFactory.msAjaxDebug.trace("The specified method is not registered on service endpoint:" + messageObject._actionName);
  4037. throw OsfMsAjaxFactory.msAjaxError.argument("messageObject");
  4038. }
  4039. var methodObject = null;
  4040. if (messageObject._actionType === Microsoft.Office.Common.ActionType.invoke) {
  4041. methodObject = methodOrEventMethodObject;
  4042. }
  4043. else if (messageObject._actionType === Microsoft.Office.Common.ActionType.registerEvent) {
  4044. methodObject = methodOrEventMethodObject.getRegisterMethodObject();
  4045. }
  4046. else {
  4047. methodObject = methodOrEventMethodObject.getUnregisterMethodObject();
  4048. }
  4049. return methodObject;
  4050. }
  4051. ;
  4052. function _enqueInvoker(invoker) {
  4053. _invokerQueue.push(invoker);
  4054. }
  4055. ;
  4056. function _dequeInvoker() {
  4057. if (_messageProcessingTimer !== null) {
  4058. if (!_blockingFlag) {
  4059. if (_invokerQueue.length > 0) {
  4060. var invoker = _invokerQueue.shift();
  4061. _executeCommand(invoker);
  4062. }
  4063. else {
  4064. clearInterval(_messageProcessingTimer);
  4065. _messageProcessingTimer = null;
  4066. }
  4067. }
  4068. }
  4069. else {
  4070. OsfMsAjaxFactory.msAjaxDebug.trace("channel is not ready.");
  4071. }
  4072. }
  4073. ;
  4074. function _executeCommand(invoker) {
  4075. _blockingFlag = invoker.getInvokeBlockingFlag();
  4076. invoker.invoke();
  4077. _lastMessageProcessTime = (new Date()).getTime();
  4078. }
  4079. ;
  4080. function _checkMethodTimeout() {
  4081. if (_methodTimeoutTimer) {
  4082. var clientEndPoint;
  4083. var methodCallsNotTimedout = 0;
  4084. var now = new Date();
  4085. var timeoutValue;
  4086. for (var conversationId in _clientEndPoints) {
  4087. clientEndPoint = _clientEndPoints[conversationId];
  4088. for (var correlationId in clientEndPoint._callbackList) {
  4089. var callbackEntry = clientEndPoint._callbackList[correlationId];
  4090. timeoutValue = callbackEntry.timeout ? callbackEntry.timeout : _methodTimeout;
  4091. if (timeoutValue >= 0 && Math.abs(now.getTime() - callbackEntry.createdOn) >= timeoutValue) {
  4092. try {
  4093. if (callbackEntry.callback) {
  4094. callbackEntry.callback(Microsoft.Office.Common.InvokeResultCode.errorHandlingMethodCallTimedout, null);
  4095. }
  4096. }
  4097. finally {
  4098. delete clientEndPoint._callbackList[correlationId];
  4099. }
  4100. }
  4101. else {
  4102. methodCallsNotTimedout++;
  4103. }
  4104. ;
  4105. }
  4106. }
  4107. if (methodCallsNotTimedout === 0) {
  4108. clearInterval(_methodTimeoutTimer);
  4109. _methodTimeoutTimer = null;
  4110. }
  4111. }
  4112. else {
  4113. OsfMsAjaxFactory.msAjaxDebug.trace("channel is not ready.");
  4114. }
  4115. }
  4116. ;
  4117. function _postCallbackHandler() {
  4118. _blockingFlag = false;
  4119. }
  4120. ;
  4121. function _registerListener(listener) {
  4122. if (window.addEventListener) {
  4123. window.addEventListener("message", listener, false);
  4124. }
  4125. else if ((navigator.userAgent.indexOf("MSIE") > -1) && window.attachEvent) {
  4126. window.attachEvent("onmessage", listener);
  4127. }
  4128. else {
  4129. OsfMsAjaxFactory.msAjaxDebug.trace("Browser doesn't support the required API.");
  4130. throw OsfMsAjaxFactory.msAjaxError.argument("Browser");
  4131. }
  4132. }
  4133. ;
  4134. function _checkOrigin(url, origin) {
  4135. var res = false;
  4136. if (url === true) {
  4137. return true;
  4138. }
  4139. if (!url || !origin || !url.length || !origin.length) {
  4140. return res;
  4141. }
  4142. var url_parser, org_parser;
  4143. url_parser = document.createElement('a');
  4144. org_parser = document.createElement('a');
  4145. url_parser.href = url;
  4146. org_parser.href = origin;
  4147. res = _urlCompare(url_parser, org_parser);
  4148. delete url_parser, org_parser;
  4149. return res;
  4150. }
  4151. function _checkOriginWithAppDomains(allowed_domains, origin) {
  4152. var res = false;
  4153. if (!origin || !origin.length || !(allowed_domains) || !(allowed_domains instanceof Array) || !allowed_domains.length) {
  4154. return res;
  4155. }
  4156. var org_parser = document.createElement('a');
  4157. var app_domain_parser = document.createElement('a');
  4158. org_parser.href = origin;
  4159. for (var i = 0; i < allowed_domains.length && !res; i++) {
  4160. if (allowed_domains[i].indexOf("://") !== -1) {
  4161. app_domain_parser.href = allowed_domains[i];
  4162. res = _urlCompare(org_parser, app_domain_parser);
  4163. }
  4164. }
  4165. delete org_parser, app_domain_parser;
  4166. return res;
  4167. }
  4168. function _urlCompare(url_parser1, url_parser2) {
  4169. return ((url_parser1.hostname == url_parser2.hostname) &&
  4170. (url_parser1.protocol == url_parser2.protocol) &&
  4171. (url_parser1.port == url_parser2.port));
  4172. }
  4173. function _receive(e) {
  4174. if (!OSF) {
  4175. return;
  4176. }
  4177. if (e.data != '') {
  4178. var messageObject;
  4179. var serializerVersion = OSF.SerializerVersion.Browser;
  4180. var serializedMessage = e.data;
  4181. try {
  4182. messageObject = Microsoft.Office.Common.MessagePackager.unenvelope(serializedMessage, OSF.SerializerVersion.Browser);
  4183. serializerVersion = messageObject._serializerVersion != null ? messageObject._serializerVersion : serializerVersion;
  4184. }
  4185. catch (ex) {
  4186. return;
  4187. }
  4188. if (messageObject._messageType === Microsoft.Office.Common.MessageType.request) {
  4189. var requesterUrl = (e.origin == null || e.origin == "null") ? messageObject._origin : e.origin;
  4190. try {
  4191. var serviceEndPoint = _lookupServiceEndPoint(messageObject._conversationId);
  4192. ;
  4193. var conversation = serviceEndPoint._conversations[messageObject._conversationId];
  4194. serializerVersion = conversation.serializerVersion != null ? conversation.serializerVersion : serializerVersion;
  4195. ;
  4196. if (!_checkOrigin(conversation.url, e.origin) && !_checkOriginWithAppDomains(serviceEndPoint._appDomains[messageObject._conversationId], e.origin)) {
  4197. throw "Failed origin check";
  4198. }
  4199. var policyManager = serviceEndPoint.getPolicyManager();
  4200. if (policyManager && !policyManager.checkPermission(messageObject._conversationId, messageObject._actionName, messageObject._data)) {
  4201. throw "Access Denied";
  4202. }
  4203. var methodObject = _lookupMethodObject(serviceEndPoint, messageObject);
  4204. var invokeCompleteCallback = new Microsoft.Office.Common.InvokeCompleteCallback(e.source, requesterUrl, messageObject._actionName, messageObject._conversationId, messageObject._correlationId, _postCallbackHandler, serializerVersion);
  4205. var invoker = new Microsoft.Office.Common.Invoker(methodObject, messageObject._data, invokeCompleteCallback, serviceEndPoint._eventHandlerProxyList, messageObject._conversationId, messageObject._actionName, serializerVersion);
  4206. var shouldEnque = true;
  4207. if (_messageProcessingTimer == null) {
  4208. if ((_lastMessageProcessTime == null || (new Date()).getTime() - _lastMessageProcessTime > _processInterval) && !_blockingFlag) {
  4209. _executeCommand(invoker);
  4210. shouldEnque = false;
  4211. }
  4212. else {
  4213. _messageProcessingTimer = setInterval(_dequeInvoker, _processInterval);
  4214. }
  4215. }
  4216. if (shouldEnque) {
  4217. _enqueInvoker(invoker);
  4218. }
  4219. }
  4220. catch (ex) {
  4221. if (serviceEndPoint && serviceEndPoint._onHandleRequestError) {
  4222. serviceEndPoint._onHandleRequestError(messageObject, ex);
  4223. }
  4224. var errorCode = Microsoft.Office.Common.InvokeResultCode.errorHandlingRequest;
  4225. if (ex == "Access Denied") {
  4226. errorCode = Microsoft.Office.Common.InvokeResultCode.errorHandlingRequestAccessDenied;
  4227. }
  4228. var callResponse = new Microsoft.Office.Common.Response(messageObject._actionName, messageObject._conversationId, messageObject._correlationId, errorCode, Microsoft.Office.Common.ResponseType.forCalling, ex);
  4229. var envelopedResult = Microsoft.Office.Common.MessagePackager.envelope(callResponse, serializerVersion);
  4230. if (e.source && e.source.postMessage) {
  4231. e.source.postMessage(envelopedResult, requesterUrl);
  4232. }
  4233. }
  4234. }
  4235. else if (messageObject._messageType === Microsoft.Office.Common.MessageType.response) {
  4236. var clientEndPoint = _lookupClientEndPoint(messageObject._conversationId);
  4237. if (!clientEndPoint) {
  4238. return;
  4239. }
  4240. clientEndPoint._serializerVersion = serializerVersion;
  4241. ;
  4242. if (!_checkOrigin(clientEndPoint._targetUrl, e.origin)) {
  4243. throw "Failed orgin check";
  4244. }
  4245. if (messageObject._responseType === Microsoft.Office.Common.ResponseType.forCalling) {
  4246. var callbackEntry = clientEndPoint._callbackList[messageObject._correlationId];
  4247. if (callbackEntry) {
  4248. try {
  4249. if (callbackEntry.callback)
  4250. callbackEntry.callback(messageObject._errorCode, messageObject._data);
  4251. }
  4252. finally {
  4253. delete clientEndPoint._callbackList[messageObject._correlationId];
  4254. }
  4255. }
  4256. }
  4257. else {
  4258. var eventhandler = clientEndPoint._eventHandlerList[messageObject._actionName];
  4259. if (eventhandler !== undefined && eventhandler !== null) {
  4260. eventhandler(messageObject._data);
  4261. }
  4262. }
  4263. }
  4264. else {
  4265. return;
  4266. }
  4267. }
  4268. }
  4269. ;
  4270. function _initialize() {
  4271. if (!_initialized) {
  4272. _registerListener(_receive);
  4273. _initialized = true;
  4274. }
  4275. }
  4276. ;
  4277. return {
  4278. connect: function Microsoft_Office_Common_XdmCommunicationManager$connect(conversationId, targetWindow, targetUrl, serializerVersion) {
  4279. var clientEndPoint = _clientEndPoints[conversationId];
  4280. if (!clientEndPoint) {
  4281. _initialize();
  4282. clientEndPoint = new Microsoft.Office.Common.ClientEndPoint(conversationId, targetWindow, targetUrl, serializerVersion);
  4283. _clientEndPoints[conversationId] = clientEndPoint;
  4284. }
  4285. return clientEndPoint;
  4286. },
  4287. getClientEndPoint: function Microsoft_Office_Common_XdmCommunicationManager$getClientEndPoint(conversationId) {
  4288. var e = Function._validateParams(arguments, [
  4289. { name: "conversationId", type: String, mayBeNull: false }
  4290. ]);
  4291. if (e)
  4292. throw e;
  4293. return _clientEndPoints[conversationId];
  4294. },
  4295. createServiceEndPoint: function Microsoft_Office_Common_XdmCommunicationManager$createServiceEndPoint(serviceEndPointId) {
  4296. _initialize();
  4297. var serviceEndPoint = new Microsoft.Office.Common.ServiceEndPoint(serviceEndPointId);
  4298. _serviceEndPoints[serviceEndPointId] = serviceEndPoint;
  4299. return serviceEndPoint;
  4300. },
  4301. getServiceEndPoint: function Microsoft_Office_Common_XdmCommunicationManager$getServiceEndPoint(serviceEndPointId) {
  4302. var e = Function._validateParams(arguments, [
  4303. { name: "serviceEndPointId", type: String, mayBeNull: false }
  4304. ]);
  4305. if (e)
  4306. throw e;
  4307. return _serviceEndPoints[serviceEndPointId];
  4308. },
  4309. deleteClientEndPoint: function Microsoft_Office_Common_XdmCommunicationManager$deleteClientEndPoint(conversationId) {
  4310. var e = Function._validateParams(arguments, [
  4311. { name: "conversationId", type: String, mayBeNull: false }
  4312. ]);
  4313. if (e)
  4314. throw e;
  4315. delete _clientEndPoints[conversationId];
  4316. },
  4317. deleteServiceEndPoint: function Microsoft_Office_Common_XdmCommunicationManager$deleteServiceEndPoint(serviceEndPointId) {
  4318. var e = Function._validateParams(arguments, [
  4319. { name: "serviceEndPointId", type: String, mayBeNull: false }
  4320. ]);
  4321. if (e)
  4322. throw e;
  4323. delete _serviceEndPoints[serviceEndPointId];
  4324. },
  4325. checkUrlWithAppDomains: function Microsoft_Office_Common_XdmCommunicationManager$_checkUrlWithAppDomains(appDomains, origin) {
  4326. return _checkOriginWithAppDomains(appDomains, origin);
  4327. },
  4328. _setMethodTimeout: function Microsoft_Office_Common_XdmCommunicationManager$_setMethodTimeout(methodTimeout) {
  4329. var e = Function._validateParams(arguments, [
  4330. { name: "methodTimeout", type: Number, mayBeNull: false }
  4331. ]);
  4332. if (e)
  4333. throw e;
  4334. _methodTimeout = (methodTimeout <= 0) ? _methodTimeoutDefault : methodTimeout;
  4335. },
  4336. _startMethodTimeoutTimer: function Microsoft_Office_Common_XdmCommunicationManager$_startMethodTimeoutTimer() {
  4337. if (!_methodTimeoutTimer) {
  4338. _methodTimeoutTimer = setInterval(_checkMethodTimeout, _methodTimeoutProcessInterval);
  4339. }
  4340. }
  4341. };
  4342. })();
  4343. Microsoft.Office.Common.Message = function Microsoft_Office_Common_Message(messageType, actionName, conversationId, correlationId, data) {
  4344. var e = Function._validateParams(arguments, [{ name: "messageType", type: Number, mayBeNull: false },
  4345. { name: "actionName", type: String, mayBeNull: false },
  4346. { name: "conversationId", type: String, mayBeNull: false },
  4347. { name: "correlationId", mayBeNull: false },
  4348. { name: "data", mayBeNull: true, optional: true }
  4349. ]);
  4350. if (e)
  4351. throw e;
  4352. this._messageType = messageType;
  4353. this._actionName = actionName;
  4354. this._conversationId = conversationId;
  4355. this._correlationId = correlationId;
  4356. this._origin = window.location.href;
  4357. if (typeof data == "undefined") {
  4358. this._data = null;
  4359. }
  4360. else {
  4361. this._data = data;
  4362. }
  4363. };
  4364. Microsoft.Office.Common.Message.prototype = {
  4365. getActionName: function Microsoft_Office_Common_Message$getActionName() {
  4366. return this._actionName;
  4367. },
  4368. getConversationId: function Microsoft_Office_Common_Message$getConversationId() {
  4369. return this._conversationId;
  4370. },
  4371. getCorrelationId: function Microsoft_Office_Common_Message$getCorrelationId() {
  4372. return this._correlationId;
  4373. },
  4374. getOrigin: function Microsoft_Office_Common_Message$getOrigin() {
  4375. return this._origin;
  4376. },
  4377. getData: function Microsoft_Office_Common_Message$getData() {
  4378. return this._data;
  4379. },
  4380. getMessageType: function Microsoft_Office_Common_Message$getMessageType() {
  4381. return this._messageType;
  4382. }
  4383. };
  4384. Microsoft.Office.Common.Request = function Microsoft_Office_Common_Request(actionName, actionType, conversationId, correlationId, data) {
  4385. Microsoft.Office.Common.Request.uber.constructor.call(this, Microsoft.Office.Common.MessageType.request, actionName, conversationId, correlationId, data);
  4386. this._actionType = actionType;
  4387. };
  4388. OSF.OUtil.extend(Microsoft.Office.Common.Request, Microsoft.Office.Common.Message);
  4389. Microsoft.Office.Common.Request.prototype.getActionType = function Microsoft_Office_Common_Request$getActionType() {
  4390. return this._actionType;
  4391. };
  4392. Microsoft.Office.Common.Response = function Microsoft_Office_Common_Response(actionName, conversationId, correlationId, errorCode, responseType, data) {
  4393. Microsoft.Office.Common.Response.uber.constructor.call(this, Microsoft.Office.Common.MessageType.response, actionName, conversationId, correlationId, data);
  4394. this._errorCode = errorCode;
  4395. this._responseType = responseType;
  4396. };
  4397. OSF.OUtil.extend(Microsoft.Office.Common.Response, Microsoft.Office.Common.Message);
  4398. Microsoft.Office.Common.Response.prototype.getErrorCode = function Microsoft_Office_Common_Response$getErrorCode() {
  4399. return this._errorCode;
  4400. };
  4401. Microsoft.Office.Common.Response.prototype.getResponseType = function Microsoft_Office_Common_Response$getResponseType() {
  4402. return this._responseType;
  4403. };
  4404. Microsoft.Office.Common.MessagePackager = {
  4405. envelope: function Microsoft_Office_Common_MessagePackager$envelope(messageObject, serializerVersion) {
  4406. if (typeof (messageObject) === "object") {
  4407. messageObject._serializerVersion = OSF.SerializerVersion.Browser;
  4408. }
  4409. return JSON.stringify(messageObject);
  4410. },
  4411. unenvelope: function Microsoft_Office_Common_MessagePackager$unenvelope(messageObject, serializerVersion) {
  4412. return JSON.parse(messageObject);
  4413. }
  4414. };
  4415. Microsoft.Office.Common.ResponseSender = function Microsoft_Office_Common_ResponseSender(requesterWindow, requesterUrl, actionName, conversationId, correlationId, responseType, serializerVersion) {
  4416. var e = Function._validateParams(arguments, [{ name: "requesterWindow", mayBeNull: false },
  4417. { name: "requesterUrl", type: String, mayBeNull: false },
  4418. { name: "actionName", type: String, mayBeNull: false },
  4419. { name: "conversationId", type: String, mayBeNull: false },
  4420. { name: "correlationId", mayBeNull: false },
  4421. { name: "responsetype", type: Number, maybeNull: false },
  4422. { name: "serializerVersion", type: Number, maybeNull: true, optional: true }
  4423. ]);
  4424. if (e)
  4425. throw e;
  4426. this._requesterWindow = requesterWindow;
  4427. this._requesterUrl = requesterUrl;
  4428. this._actionName = actionName;
  4429. this._conversationId = conversationId;
  4430. this._correlationId = correlationId;
  4431. this._invokeResultCode = Microsoft.Office.Common.InvokeResultCode.noError;
  4432. this._responseType = responseType;
  4433. var me = this;
  4434. this._send = function (result) {
  4435. try {
  4436. var response = new Microsoft.Office.Common.Response(me._actionName, me._conversationId, me._correlationId, me._invokeResultCode, me._responseType, result);
  4437. var envelopedResult = Microsoft.Office.Common.MessagePackager.envelope(response, serializerVersion);
  4438. me._requesterWindow.postMessage(envelopedResult, me._requesterUrl);
  4439. ;
  4440. }
  4441. catch (ex) {
  4442. OsfMsAjaxFactory.msAjaxDebug.trace("ResponseSender._send error:" + ex.message);
  4443. }
  4444. };
  4445. };
  4446. Microsoft.Office.Common.ResponseSender.prototype = {
  4447. getRequesterWindow: function Microsoft_Office_Common_ResponseSender$getRequesterWindow() {
  4448. return this._requesterWindow;
  4449. },
  4450. getRequesterUrl: function Microsoft_Office_Common_ResponseSender$getRequesterUrl() {
  4451. return this._requesterUrl;
  4452. },
  4453. getActionName: function Microsoft_Office_Common_ResponseSender$getActionName() {
  4454. return this._actionName;
  4455. },
  4456. getConversationId: function Microsoft_Office_Common_ResponseSender$getConversationId() {
  4457. return this._conversationId;
  4458. },
  4459. getCorrelationId: function Microsoft_Office_Common_ResponseSender$getCorrelationId() {
  4460. return this._correlationId;
  4461. },
  4462. getSend: function Microsoft_Office_Common_ResponseSender$getSend() {
  4463. return this._send;
  4464. },
  4465. setResultCode: function Microsoft_Office_Common_ResponseSender$setResultCode(resultCode) {
  4466. this._invokeResultCode = resultCode;
  4467. }
  4468. };
  4469. Microsoft.Office.Common.InvokeCompleteCallback = function Microsoft_Office_Common_InvokeCompleteCallback(requesterWindow, requesterUrl, actionName, conversationId, correlationId, postCallbackHandler, serializerVersion) {
  4470. Microsoft.Office.Common.InvokeCompleteCallback.uber.constructor.call(this, requesterWindow, requesterUrl, actionName, conversationId, correlationId, Microsoft.Office.Common.ResponseType.forCalling, serializerVersion);
  4471. this._postCallbackHandler = postCallbackHandler;
  4472. var me = this;
  4473. this._send = function (result, responseCode) {
  4474. if (responseCode != undefined) {
  4475. me._invokeResultCode = responseCode;
  4476. }
  4477. try {
  4478. var response = new Microsoft.Office.Common.Response(me._actionName, me._conversationId, me._correlationId, me._invokeResultCode, me._responseType, result);
  4479. var envelopedResult = Microsoft.Office.Common.MessagePackager.envelope(response, serializerVersion);
  4480. me._requesterWindow.postMessage(envelopedResult, me._requesterUrl);
  4481. me._postCallbackHandler();
  4482. }
  4483. catch (ex) {
  4484. OsfMsAjaxFactory.msAjaxDebug.trace("InvokeCompleteCallback._send error:" + ex.message);
  4485. }
  4486. };
  4487. };
  4488. OSF.OUtil.extend(Microsoft.Office.Common.InvokeCompleteCallback, Microsoft.Office.Common.ResponseSender);
  4489. Microsoft.Office.Common.Invoker = function Microsoft_Office_Common_Invoker(methodObject, paramValue, invokeCompleteCallback, eventHandlerProxyList, conversationId, eventName, serializerVersion) {
  4490. var e = Function._validateParams(arguments, [
  4491. { name: "methodObject", mayBeNull: false },
  4492. { name: "paramValue", mayBeNull: true },
  4493. { name: "invokeCompleteCallback", mayBeNull: false },
  4494. { name: "eventHandlerProxyList", mayBeNull: true },
  4495. { name: "conversationId", type: String, mayBeNull: false },
  4496. { name: "eventName", type: String, mayBeNull: false },
  4497. { name: "serializerVersion", type: Number, mayBeNull: true, optional: true }
  4498. ]);
  4499. if (e)
  4500. throw e;
  4501. this._methodObject = methodObject;
  4502. this._param = paramValue;
  4503. this._invokeCompleteCallback = invokeCompleteCallback;
  4504. this._eventHandlerProxyList = eventHandlerProxyList;
  4505. this._conversationId = conversationId;
  4506. this._eventName = eventName;
  4507. this._serializerVersion = serializerVersion;
  4508. };
  4509. Microsoft.Office.Common.Invoker.prototype = {
  4510. invoke: function Microsoft_Office_Common_Invoker$invoke() {
  4511. try {
  4512. var result;
  4513. switch (this._methodObject.getInvokeType()) {
  4514. case Microsoft.Office.Common.InvokeType.async:
  4515. this._methodObject.getMethod()(this._param, this._invokeCompleteCallback.getSend());
  4516. break;
  4517. case Microsoft.Office.Common.InvokeType.sync:
  4518. result = this._methodObject.getMethod()(this._param);
  4519. this._invokeCompleteCallback.getSend()(result);
  4520. break;
  4521. case Microsoft.Office.Common.InvokeType.syncRegisterEvent:
  4522. var eventHandlerProxy = this._createEventHandlerProxyObject(this._invokeCompleteCallback);
  4523. result = this._methodObject.getMethod()(eventHandlerProxy.getSend(), this._param);
  4524. this._eventHandlerProxyList[this._conversationId + this._eventName] = eventHandlerProxy.getSend();
  4525. this._invokeCompleteCallback.getSend()(result);
  4526. break;
  4527. case Microsoft.Office.Common.InvokeType.syncUnregisterEvent:
  4528. var eventHandler = this._eventHandlerProxyList[this._conversationId + this._eventName];
  4529. result = this._methodObject.getMethod()(eventHandler, this._param);
  4530. delete this._eventHandlerProxyList[this._conversationId + this._eventName];
  4531. this._invokeCompleteCallback.getSend()(result);
  4532. break;
  4533. case Microsoft.Office.Common.InvokeType.asyncRegisterEvent:
  4534. var eventHandlerProxyAsync = this._createEventHandlerProxyObject(this._invokeCompleteCallback);
  4535. this._methodObject.getMethod()(eventHandlerProxyAsync.getSend(), this._invokeCompleteCallback.getSend(), this._param);
  4536. this._eventHandlerProxyList[this._callerId + this._eventName] = eventHandlerProxyAsync.getSend();
  4537. break;
  4538. case Microsoft.Office.Common.InvokeType.asyncUnregisterEvent:
  4539. var eventHandlerAsync = this._eventHandlerProxyList[this._callerId + this._eventName];
  4540. this._methodObject.getMethod()(eventHandlerAsync, this._invokeCompleteCallback.getSend(), this._param);
  4541. delete this._eventHandlerProxyList[this._callerId + this._eventName];
  4542. break;
  4543. default:
  4544. break;
  4545. }
  4546. }
  4547. catch (ex) {
  4548. this._invokeCompleteCallback.setResultCode(Microsoft.Office.Common.InvokeResultCode.errorInResponse);
  4549. this._invokeCompleteCallback.getSend()(ex);
  4550. }
  4551. },
  4552. getInvokeBlockingFlag: function Microsoft_Office_Common_Invoker$getInvokeBlockingFlag() {
  4553. return this._methodObject.getBlockingFlag();
  4554. },
  4555. _createEventHandlerProxyObject: function Microsoft_Office_Common_Invoker$_createEventHandlerProxyObject(invokeCompleteObject) {
  4556. return new Microsoft.Office.Common.ResponseSender(invokeCompleteObject.getRequesterWindow(), invokeCompleteObject.getRequesterUrl(), invokeCompleteObject.getActionName(), invokeCompleteObject.getConversationId(), invokeCompleteObject.getCorrelationId(), Microsoft.Office.Common.ResponseType.forEventing, this._serializerVersion);
  4557. }
  4558. };
  4559. OSF.OUtil.setNamespace("WAC", OSF.DDA);
  4560. OSF.DDA.WAC.UniqueArguments = {
  4561. Data: "Data",
  4562. Properties: "Properties",
  4563. BindingRequest: "DdaBindingsMethod",
  4564. BindingResponse: "Bindings",
  4565. SingleBindingResponse: "singleBindingResponse",
  4566. GetData: "DdaGetBindingData",
  4567. AddRowsColumns: "DdaAddRowsColumns",
  4568. SetData: "DdaSetBindingData",
  4569. ClearFormats: "DdaClearBindingFormats",
  4570. SetFormats: "DdaSetBindingFormats",
  4571. SettingsRequest: "DdaSettingsMethod",
  4572. BindingEventSource: "ddaBinding",
  4573. ArrayData: "ArrayData"
  4574. };
  4575. OSF.OUtil.setNamespace("Delegate", OSF.DDA.WAC);
  4576. OSF.DDA.WAC.Delegate.SpecialProcessor = function OSF_DDA_WAC_Delegate_SpecialProcessor() {
  4577. var complexTypes = [
  4578. OSF.DDA.WAC.UniqueArguments.SingleBindingResponse,
  4579. OSF.DDA.WAC.UniqueArguments.BindingRequest,
  4580. OSF.DDA.WAC.UniqueArguments.BindingResponse,
  4581. OSF.DDA.WAC.UniqueArguments.GetData,
  4582. OSF.DDA.WAC.UniqueArguments.AddRowsColumns,
  4583. OSF.DDA.WAC.UniqueArguments.SetData,
  4584. OSF.DDA.WAC.UniqueArguments.ClearFormats,
  4585. OSF.DDA.WAC.UniqueArguments.SetFormats,
  4586. OSF.DDA.WAC.UniqueArguments.SettingsRequest,
  4587. OSF.DDA.WAC.UniqueArguments.BindingEventSource
  4588. ];
  4589. var dynamicTypes = {};
  4590. OSF.DDA.WAC.Delegate.SpecialProcessor.uber.constructor.call(this, complexTypes, dynamicTypes);
  4591. };
  4592. OSF.OUtil.extend(OSF.DDA.WAC.Delegate.SpecialProcessor, OSF.DDA.SpecialProcessor);
  4593. OSF.DDA.WAC.Delegate.ParameterMap = OSF.DDA.getDecoratedParameterMap(new OSF.DDA.WAC.Delegate.SpecialProcessor(), []);
  4594. OSF.OUtil.setNamespace("WAC", OSF.DDA);
  4595. OSF.OUtil.setNamespace("Delegate", OSF.DDA.WAC);
  4596. OSF.DDA.WAC.getDelegateMethods = function OSF_DDA_WAC_getDelegateMethods() {
  4597. var delegateMethods = {};
  4598. delegateMethods[OSF.DDA.DispIdHost.Delegates.ExecuteAsync] = OSF.DDA.WAC.Delegate.executeAsync;
  4599. delegateMethods[OSF.DDA.DispIdHost.Delegates.RegisterEventAsync] = OSF.DDA.WAC.Delegate.registerEventAsync;
  4600. delegateMethods[OSF.DDA.DispIdHost.Delegates.UnregisterEventAsync] = OSF.DDA.WAC.Delegate.unregisterEventAsync;
  4601. delegateMethods[OSF.DDA.DispIdHost.Delegates.OpenDialog] = OSF.DDA.WAC.Delegate.openDialog;
  4602. delegateMethods[OSF.DDA.DispIdHost.Delegates.MessageParent] = OSF.DDA.WAC.Delegate.messageParent;
  4603. delegateMethods[OSF.DDA.DispIdHost.Delegates.SendMessage] = OSF.DDA.WAC.Delegate.sendMessage;
  4604. delegateMethods[OSF.DDA.DispIdHost.Delegates.CloseDialog] = OSF.DDA.WAC.Delegate.closeDialog;
  4605. return delegateMethods;
  4606. };
  4607. OSF.DDA.WAC.Delegate.version = 1;
  4608. OSF.DDA.WAC.Delegate.executeAsync = function OSF_DDA_WAC_Delegate$executeAsync(args) {
  4609. if (!args.hostCallArgs) {
  4610. args.hostCallArgs = {};
  4611. }
  4612. args.hostCallArgs["DdaMethod"] = {
  4613. "ControlId": OSF._OfficeAppFactory.getId(),
  4614. "Version": OSF.DDA.WAC.Delegate.version,
  4615. "DispatchId": args.dispId
  4616. };
  4617. args.hostCallArgs["__timeout__"] = -1;
  4618. if (args.onCalling) {
  4619. args.onCalling();
  4620. }
  4621. var startTime = (new Date()).getTime();
  4622. OSF.getClientEndPoint().invoke("executeMethod", function OSF_DDA_WAC_Delegate$OMFacade$OnResponse(xdmStatus, payload) {
  4623. if (args.onReceiving) {
  4624. args.onReceiving();
  4625. }
  4626. var error;
  4627. if (xdmStatus == Microsoft.Office.Common.InvokeResultCode.noError) {
  4628. OSF.DDA.WAC.Delegate.version = payload["Version"];
  4629. error = payload["Error"];
  4630. }
  4631. else {
  4632. switch (xdmStatus) {
  4633. case Microsoft.Office.Common.InvokeResultCode.errorHandlingRequestAccessDenied:
  4634. error = OSF.DDA.ErrorCodeManager.errorCodes.ooeNoCapability;
  4635. break;
  4636. default:
  4637. error = OSF.DDA.ErrorCodeManager.errorCodes.ooeInternalError;
  4638. break;
  4639. }
  4640. }
  4641. if (args.onComplete) {
  4642. args.onComplete(error, payload);
  4643. }
  4644. if (OSF.AppTelemetry) {
  4645. OSF.AppTelemetry.onMethodDone(args.dispId, args.hostCallArgs, Math.abs((new Date()).getTime() - startTime), error);
  4646. }
  4647. }, args.hostCallArgs);
  4648. };
  4649. OSF.DDA.WAC.Delegate._getOnAfterRegisterEvent = function OSF_DDA_WAC_Delegate$GetOnAfterRegisterEvent(register, args) {
  4650. var startTime = (new Date()).getTime();
  4651. return function OSF_DDA_WAC_Delegate$OnAfterRegisterEvent(xdmStatus, payload) {
  4652. if (args.onReceiving) {
  4653. args.onReceiving();
  4654. }
  4655. var status;
  4656. if (xdmStatus != Microsoft.Office.Common.InvokeResultCode.noError) {
  4657. switch (xdmStatus) {
  4658. case Microsoft.Office.Common.InvokeResultCode.errorHandlingRequestAccessDenied:
  4659. status = OSF.DDA.ErrorCodeManager.errorCodes.ooeNoCapability;
  4660. break;
  4661. default:
  4662. status = OSF.DDA.ErrorCodeManager.errorCodes.ooeInternalError;
  4663. break;
  4664. }
  4665. }
  4666. else {
  4667. if (payload) {
  4668. if (payload["Error"]) {
  4669. status = payload["Error"];
  4670. }
  4671. else {
  4672. status = OSF.DDA.ErrorCodeManager.errorCodes.ooeSuccess;
  4673. }
  4674. }
  4675. else {
  4676. status = OSF.DDA.ErrorCodeManager.errorCodes.ooeInternalError;
  4677. }
  4678. }
  4679. if (args.onComplete) {
  4680. args.onComplete(status);
  4681. }
  4682. if (OSF.AppTelemetry) {
  4683. OSF.AppTelemetry.onRegisterDone(register, args.dispId, Math.abs((new Date()).getTime() - startTime), status);
  4684. }
  4685. };
  4686. };
  4687. OSF.DDA.WAC.Delegate.registerEventAsync = function OSF_DDA_WAC_Delegate$RegisterEventAsync(args) {
  4688. if (args.onCalling) {
  4689. args.onCalling();
  4690. }
  4691. OSF.getClientEndPoint().registerForEvent(OSF.DDA.getXdmEventName(args.targetId, args.eventType), function OSF_DDA_WACOMFacade$OnEvent(payload) {
  4692. if (args.onEvent) {
  4693. args.onEvent(payload);
  4694. }
  4695. if (OSF.AppTelemetry) {
  4696. OSF.AppTelemetry.onEventDone(args.dispId);
  4697. }
  4698. }, OSF.DDA.WAC.Delegate._getOnAfterRegisterEvent(true, args), {
  4699. "controlId": OSF._OfficeAppFactory.getId(),
  4700. "eventDispId": args.dispId,
  4701. "targetId": args.targetId
  4702. });
  4703. };
  4704. OSF.DDA.WAC.Delegate.unregisterEventAsync = function OSF_DDA_WAC_Delegate$UnregisterEventAsync(args) {
  4705. if (args.onCalling) {
  4706. args.onCalling();
  4707. }
  4708. OSF.getClientEndPoint().unregisterForEvent(OSF.DDA.getXdmEventName(args.targetId, args.eventType), OSF.DDA.WAC.Delegate._getOnAfterRegisterEvent(false, args), {
  4709. "controlId": OSF._OfficeAppFactory.getId(),
  4710. "eventDispId": args.dispId,
  4711. "targetId": args.targetId
  4712. });
  4713. };
  4714. OSF.OUtil.setNamespace("WebApp", OSF);
  4715. OSF.WebApp.AddHostInfoAndXdmInfo = function OSF_WebApp$AddHostInfoAndXdmInfo(url) {
  4716. if (OSF._OfficeAppFactory.getWindowLocationSearch && OSF._OfficeAppFactory.getWindowLocationHash) {
  4717. return url + OSF._OfficeAppFactory.getWindowLocationSearch() + OSF._OfficeAppFactory.getWindowLocationHash();
  4718. }
  4719. else {
  4720. return url;
  4721. }
  4722. };
  4723. OSF.WebApp._UpdateLinksForHostAndXdmInfo = function OSF_WebApp$_UpdateLinksForHostAndXdmInfo() {
  4724. var links = document.querySelectorAll("a[data-officejs-navigate]");
  4725. for (var i = 0; i < links.length; i++) {
  4726. if (OSF.WebApp._isGoodUrl(links[i].href)) {
  4727. links[i].href = OSF.WebApp.AddHostInfoAndXdmInfo(links[i].href);
  4728. }
  4729. }
  4730. var forms = document.querySelectorAll("form[data-officejs-navigate]");
  4731. for (var i = 0; i < forms.length; i++) {
  4732. var form = forms[i];
  4733. if (OSF.WebApp._isGoodUrl(form.action)) {
  4734. form.action = OSF.WebApp.AddHostInfoAndXdmInfo(form.action);
  4735. }
  4736. }
  4737. };
  4738. OSF.WebApp._isGoodUrl = function OSF_WebApp$_isGoodUrl(url) {
  4739. if (typeof url == 'undefined')
  4740. return false;
  4741. url = url.trim();
  4742. var colonIndex = url.indexOf(':');
  4743. var protocol = colonIndex > 0 ? url.substr(0, colonIndex) : null;
  4744. var goodUrl = protocol !== null ? protocol.toLowerCase() === "http" || protocol.toLowerCase() === "https" : true;
  4745. goodUrl = goodUrl && url != "#" && url != "/" && url != "" && url != OSF._OfficeAppFactory.getWebAppState().webAppUrl;
  4746. return goodUrl;
  4747. };
  4748. OSF.InitializationHelper = function OSF_InitializationHelper(hostInfo, webAppState, context, settings, hostFacade) {
  4749. this._hostInfo = hostInfo;
  4750. this._webAppState = webAppState;
  4751. this._context = context;
  4752. this._settings = settings;
  4753. this._hostFacade = hostFacade;
  4754. this._appContext = {};
  4755. this._tabbableElements = "a[href]:not([tabindex='-1'])," + "area[href]:not([tabindex='-1'])," + "button:not([disabled]):not([tabindex='-1'])," + "input:not([disabled]):not([tabindex='-1'])," + "select:not([disabled]):not([tabindex='-1'])," + "textarea:not([disabled]):not([tabindex='-1'])," + "*[tabindex]:not([tabindex='-1'])," + "*[contenteditable]:not([disabled]):not([tabindex='-1'])";
  4756. this._initializeSettings = function OSF_InitializationHelper$initializeSettings(appContext, refreshSupported) {
  4757. var settings;
  4758. var serializedSettings = appContext.get_settings();
  4759. var osfSessionStorage = OSF.OUtil.getSessionStorage();
  4760. if (osfSessionStorage) {
  4761. var storageSettings = osfSessionStorage.getItem(OSF._OfficeAppFactory.getCachedSessionSettingsKey());
  4762. if (storageSettings) {
  4763. serializedSettings = JSON.parse(storageSettings);
  4764. }
  4765. else {
  4766. storageSettings = JSON.stringify(serializedSettings);
  4767. osfSessionStorage.setItem(OSF._OfficeAppFactory.getCachedSessionSettingsKey(), storageSettings);
  4768. }
  4769. }
  4770. var deserializedSettings = OSF.DDA.SettingsManager.deserializeSettings(serializedSettings);
  4771. if (refreshSupported) {
  4772. settings = new OSF.DDA.RefreshableSettings(deserializedSettings);
  4773. }
  4774. else {
  4775. settings = new OSF.DDA.Settings(deserializedSettings);
  4776. }
  4777. return settings;
  4778. };
  4779. var windowOpen = function OSF_InitializationHelper$windowOpen(windowObj) {
  4780. var proxy = window.open;
  4781. windowObj.open = function (strUrl, strWindowName, strWindowFeatures) {
  4782. var windowObject = null;
  4783. try {
  4784. windowObject = proxy(strUrl, strWindowName, strWindowFeatures);
  4785. }
  4786. catch (ex) {
  4787. if (OSF.AppTelemetry) {
  4788. OSF.AppTelemetry.logAppCommonMessage("Exception happens at windowOpen." + ex);
  4789. }
  4790. }
  4791. if (!windowObject) {
  4792. var params = {
  4793. "strUrl": strUrl,
  4794. "strWindowName": strWindowName,
  4795. "strWindowFeatures": strWindowFeatures
  4796. };
  4797. OSF._OfficeAppFactory.getClientEndPoint().invoke("ContextActivationManager_openWindowInHost", null, params);
  4798. }
  4799. return windowObject;
  4800. };
  4801. };
  4802. windowOpen(window);
  4803. };
  4804. OSF.InitializationHelper.prototype.saveAndSetDialogInfo = function OSF_InitializationHelper$saveAndSetDialogInfo(hostInfoValue) {
  4805. var getAppIdFromWindowLocation = function OSF_InitializationHelper$getAppIdFromWindowLocation() {
  4806. var xdmInfoValue = OSF.OUtil.parseXdmInfo(true);
  4807. if (xdmInfoValue) {
  4808. var items = xdmInfoValue.split("|");
  4809. return items[1];
  4810. }
  4811. return null;
  4812. };
  4813. var osfSessionStorage = OSF.OUtil.getSessionStorage();
  4814. if (osfSessionStorage) {
  4815. if (!hostInfoValue) {
  4816. hostInfoValue = OSF.OUtil.parseHostInfoFromWindowName(true, OSF._OfficeAppFactory.getWindowName());
  4817. }
  4818. if (hostInfoValue && hostInfoValue.indexOf("isDialog") > -1) {
  4819. var appId = getAppIdFromWindowLocation();
  4820. if (appId != null) {
  4821. osfSessionStorage.setItem(appId + "IsDialog", "true");
  4822. }
  4823. }
  4824. this._hostInfo.isDialog = osfSessionStorage.getItem(OSF.OUtil.getXdmFieldValue(OSF.XdmFieldName.AppId, false) + "IsDialog") != null ? true : false;
  4825. }
  4826. };
  4827. OSF.InitializationHelper.prototype.getAppContext = function OSF_InitializationHelper$getAppContext(wnd, gotAppContext) {
  4828. var me = this;
  4829. var getInvocationCallbackWebApp = function OSF_InitializationHelper_getAppContextAsync$getInvocationCallbackWebApp(errorCode, appContext) {
  4830. var settings;
  4831. if (appContext._appName === OSF.AppName.ExcelWebApp) {
  4832. var serializedSettings = appContext._settings;
  4833. settings = {};
  4834. for (var index in serializedSettings) {
  4835. var setting = serializedSettings[index];
  4836. settings[setting[0]] = setting[1];
  4837. }
  4838. }
  4839. else {
  4840. settings = appContext._settings;
  4841. }
  4842. if (errorCode === 0 && appContext._id != undefined && appContext._appName != undefined && appContext._appVersion != undefined && appContext._appUILocale != undefined && appContext._dataLocale != undefined &&
  4843. appContext._docUrl != undefined && appContext._clientMode != undefined && appContext._settings != undefined && appContext._reason != undefined) {
  4844. me._appContext = appContext;
  4845. var appInstanceId = (appContext._appInstanceId ? appContext._appInstanceId : appContext._id);
  4846. var touchEnabled = false;
  4847. var commerceAllowed = true;
  4848. var minorVersion = 0;
  4849. if (appContext._appMinorVersion != undefined) {
  4850. minorVersion = appContext._appMinorVersion;
  4851. }
  4852. var requirementMatrix = undefined;
  4853. if (appContext._requirementMatrix != undefined) {
  4854. requirementMatrix = appContext._requirementMatrix;
  4855. }
  4856. var returnedContext = new OSF.OfficeAppContext(appContext._id, appContext._appName, appContext._appVersion, appContext._appUILocale, appContext._dataLocale, appContext._docUrl, appContext._clientMode, settings, appContext._reason, appContext._osfControlType, appContext._eToken, appContext._correlationId, appInstanceId, touchEnabled, commerceAllowed, minorVersion, requirementMatrix, appContext._hostCustomMessage, appContext._hostFullVersion, appContext._clientWindowHeight, appContext._clientWindowWidth, appContext._addinName);
  4857. if (OSF.AppTelemetry) {
  4858. OSF.AppTelemetry.initialize(returnedContext);
  4859. }
  4860. gotAppContext(returnedContext);
  4861. }
  4862. else {
  4863. var errorMsg = "Function ContextActivationManager_getAppContextAsync call failed. ErrorCode is " + errorCode + ", exception: " + appContext;
  4864. if (OSF.AppTelemetry) {
  4865. OSF.AppTelemetry.logAppException(errorMsg);
  4866. }
  4867. throw errorMsg;
  4868. }
  4869. };
  4870. try {
  4871. if (this._hostInfo.isDialog && window.opener != null) {
  4872. var appContext = OfficeExt.WACUtils.parseAppContextFromWindowName(false, OSF._OfficeAppFactory.getWindowName());
  4873. getInvocationCallbackWebApp(0, appContext);
  4874. }
  4875. else {
  4876. this._webAppState.clientEndPoint.invoke("ContextActivationManager_getAppContextAsync", getInvocationCallbackWebApp, this._webAppState.id);
  4877. }
  4878. }
  4879. catch (ex) {
  4880. if (OSF.AppTelemetry) {
  4881. OSF.AppTelemetry.logAppException("Exception thrown when trying to invoke getAppContextAsync. Exception:[" + ex + "]");
  4882. }
  4883. throw ex;
  4884. }
  4885. };
  4886. OSF.InitializationHelper.prototype.setAgaveHostCommunication = function OSF_InitializationHelper$setAgaveHostCommunication() {
  4887. try {
  4888. var me = this;
  4889. var xdmInfoValue = OSF.OUtil.parseXdmInfoWithGivenFragment(false, OSF._OfficeAppFactory.getWindowLocationHash());
  4890. if (!xdmInfoValue && OSF._OfficeAppFactory.getWindowName) {
  4891. xdmInfoValue = OSF.OUtil.parseXdmInfoFromWindowName(false, OSF._OfficeAppFactory.getWindowName());
  4892. }
  4893. if (xdmInfoValue) {
  4894. var xdmItems = OSF.OUtil.getInfoItems(xdmInfoValue);
  4895. if (xdmItems != undefined && xdmItems.length >= 3) {
  4896. me._webAppState.conversationID = xdmItems[0];
  4897. me._webAppState.id = xdmItems[1];
  4898. me._webAppState.webAppUrl = xdmItems[2].indexOf(":") >= 0 ? xdmItems[2] : decodeURIComponent(xdmItems[2]);
  4899. }
  4900. }
  4901. me._webAppState.wnd = window.opener != null ? window.opener : window.parent;
  4902. var serializerVersion = OSF.OUtil.parseSerializerVersionWithGivenFragment(false, OSF._OfficeAppFactory.getWindowLocationHash());
  4903. if (isNaN(serializerVersion) && OSF._OfficeAppFactory.getWindowName) {
  4904. serializerVersion = OSF.OUtil.parseSerializerVersionFromWindowName(false, OSF._OfficeAppFactory.getWindowName());
  4905. }
  4906. me._webAppState.serializerVersion = serializerVersion;
  4907. me._webAppState.clientEndPoint = Microsoft.Office.Common.XdmCommunicationManager.connect(me._webAppState.conversationID, me._webAppState.wnd, me._webAppState.webAppUrl, me._webAppState.serializerVersion);
  4908. me._webAppState.serviceEndPoint = Microsoft.Office.Common.XdmCommunicationManager.createServiceEndPoint(me._webAppState.id);
  4909. var notificationConversationId = me._webAppState.conversationID + OSF.SharedConstants.NotificationConversationIdSuffix;
  4910. me._webAppState.serviceEndPoint.registerConversation(notificationConversationId, me._webAppState.webAppUrl);
  4911. if (this._hostInfo.isDialog && window.opener != null) {
  4912. return;
  4913. }
  4914. var notifyAgave = function OSF__OfficeAppFactory_initialize$notifyAgave(actionId) {
  4915. switch (actionId) {
  4916. case OSF.AgaveHostAction.Select:
  4917. me._webAppState.focused = true;
  4918. break;
  4919. case OSF.AgaveHostAction.UnSelect:
  4920. me._webAppState.focused = false;
  4921. break;
  4922. case OSF.AgaveHostAction.TabIn:
  4923. case OSF.AgaveHostAction.CtrlF6In:
  4924. window.focus();
  4925. var list = document.querySelectorAll(me._tabbableElements);
  4926. var focused = OSF.OUtil.focusToFirstTabbable(list, false);
  4927. if (!focused) {
  4928. window.blur();
  4929. me._webAppState.focused = false;
  4930. me._webAppState.clientEndPoint.invoke("ContextActivationManager_notifyHost", null, [me._webAppState.id, OSF.AgaveHostAction.ExitNoFocusable]);
  4931. }
  4932. break;
  4933. case OSF.AgaveHostAction.TabInShift:
  4934. window.focus();
  4935. var list = document.querySelectorAll(me._tabbableElements);
  4936. var focused = OSF.OUtil.focusToFirstTabbable(list, true);
  4937. if (!focused) {
  4938. window.blur();
  4939. me._webAppState.focused = false;
  4940. me._webAppState.clientEndPoint.invoke("ContextActivationManager_notifyHost", null, [me._webAppState.id, OSF.AgaveHostAction.ExitNoFocusableShift]);
  4941. }
  4942. break;
  4943. default:
  4944. OsfMsAjaxFactory.msAjaxDebug.trace("actionId " + actionId + " notifyAgave is wrong.");
  4945. break;
  4946. }
  4947. };
  4948. me._webAppState.serviceEndPoint.registerMethod("Office_notifyAgave", notifyAgave, Microsoft.Office.Common.InvokeType.async, false);
  4949. OSF.OUtil.addEventListener(window, "focus", function () {
  4950. if (!me._webAppState.focused) {
  4951. me._webAppState.focused = true;
  4952. }
  4953. me._webAppState.clientEndPoint.invoke("ContextActivationManager_notifyHost", null, [me._webAppState.id, OSF.AgaveHostAction.Select]);
  4954. });
  4955. OSF.OUtil.addEventListener(window, "blur", function () {
  4956. if (!OSF) {
  4957. return;
  4958. }
  4959. if (me._webAppState.focused) {
  4960. me._webAppState.focused = false;
  4961. }
  4962. me._webAppState.clientEndPoint.invoke("ContextActivationManager_notifyHost", null, [me._webAppState.id, OSF.AgaveHostAction.UnSelect]);
  4963. });
  4964. OSF.OUtil.addEventListener(window, "keydown", function (e) {
  4965. e.preventDefault = e.preventDefault || function () {
  4966. e.returnValue = false;
  4967. };
  4968. if (e.keyCode == 117 && (e.ctrlKey || e.metaKey)) {
  4969. var actionId = OSF.AgaveHostAction.CtrlF6Exit;
  4970. if (e.shiftKey) {
  4971. actionId = OSF.AgaveHostAction.CtrlF6ExitShift;
  4972. }
  4973. me._webAppState.clientEndPoint.invoke("ContextActivationManager_notifyHost", null, [me._webAppState.id, actionId]);
  4974. }
  4975. else if (e.keyCode == 9) {
  4976. e.preventDefault();
  4977. var allTabbableElements = document.querySelectorAll(me._tabbableElements);
  4978. var focused = OSF.OUtil.focusToNextTabbable(allTabbableElements, e.target || e.srcElement, e.shiftKey);
  4979. if (!focused) {
  4980. if (me._hostInfo.isDialog) {
  4981. OSF.OUtil.focusToFirstTabbable(allTabbableElements, e.shiftKey);
  4982. }
  4983. else {
  4984. if (e.shiftKey) {
  4985. me._webAppState.clientEndPoint.invoke("ContextActivationManager_notifyHost", null, [me._webAppState.id, OSF.AgaveHostAction.TabExitShift]);
  4986. }
  4987. else {
  4988. me._webAppState.clientEndPoint.invoke("ContextActivationManager_notifyHost", null, [me._webAppState.id, OSF.AgaveHostAction.TabExit]);
  4989. }
  4990. }
  4991. }
  4992. }
  4993. else if (e.keyCode == 27) {
  4994. e.preventDefault();
  4995. me.dismissDialogNotification && me.dismissDialogNotification();
  4996. me._webAppState.clientEndPoint.invoke("ContextActivationManager_notifyHost", null, [me._webAppState.id, OSF.AgaveHostAction.EscExit]);
  4997. }
  4998. else if (e.keyCode == 113) {
  4999. e.preventDefault();
  5000. me._webAppState.clientEndPoint.invoke("ContextActivationManager_notifyHost", null, [me._webAppState.id, OSF.AgaveHostAction.F2Exit]);
  5001. }
  5002. });
  5003. OSF.OUtil.addEventListener(window, "keypress", function (e) {
  5004. if (e.keyCode == 117 && e.ctrlKey) {
  5005. if (e.preventDefault) {
  5006. e.preventDefault();
  5007. }
  5008. else {
  5009. e.returnValue = false;
  5010. }
  5011. }
  5012. });
  5013. }
  5014. catch (ex) {
  5015. if (OSF.AppTelemetry) {
  5016. OSF.AppTelemetry.logAppException("Exception thrown in setAgaveHostCommunication. Exception:[" + ex + "]");
  5017. }
  5018. throw ex;
  5019. }
  5020. };
  5021. OSF.InitializationHelper.prototype.initWebDialog = function OSF_InitializationHelper$initWebDialog(appContext) {
  5022. if (appContext.get_isDialog()) {
  5023. if (OSF.DDA.UI.ChildUI) {
  5024. var isPopupWindow = (window.opener != null);
  5025. appContext.ui = new OSF.DDA.UI.ChildUI(isPopupWindow);
  5026. if (isPopupWindow) {
  5027. this.registerMessageReceivedEventForWindowDialog && this.registerMessageReceivedEventForWindowDialog();
  5028. }
  5029. }
  5030. }
  5031. else {
  5032. if (OSF.DDA.UI.ParentUI) {
  5033. appContext.ui = new OSF.DDA.UI.ParentUI();
  5034. if (OfficeExt.Container) {
  5035. OSF.DDA.DispIdHost.addAsyncMethods(appContext.ui, [OSF.DDA.AsyncMethodNames.CloseContainerAsync]);
  5036. }
  5037. }
  5038. }
  5039. };
  5040. OSF.getClientEndPoint = function OSF$getClientEndPoint() {
  5041. var initializationHelper = OSF._OfficeAppFactory.getInitializationHelper();
  5042. return initializationHelper._webAppState.clientEndPoint;
  5043. };
  5044. OSF.InitializationHelper.prototype.prepareRightAfterWebExtensionInitialize = function OSF_InitializationHelper$prepareRightAfterWebExtensionInitialize() {
  5045. if (this._hostInfo.isDialog) {
  5046. window.focus();
  5047. var list = document.querySelectorAll(this._tabbableElements);
  5048. var focused = OSF.OUtil.focusToFirstTabbable(list, false);
  5049. if (!focused) {
  5050. window.blur();
  5051. this._webAppState.focused = false;
  5052. this._webAppState.clientEndPoint.invoke("ContextActivationManager_notifyHost", null, [this._webAppState.id, OSF.AgaveHostAction.ExitNoFocusable]);
  5053. }
  5054. }
  5055. };
  5056. OSF.CommonUI = {
  5057. HostButtonBorderColor: "#f5ba9d",
  5058. HostButtonBackgroundColor: "#fcf0ed"
  5059. };
  5060. var OSFLog;
  5061. (function (OSFLog) {
  5062. var BaseUsageData = (function () {
  5063. function BaseUsageData(table) {
  5064. this._table = table;
  5065. this._fields = {};
  5066. }
  5067. Object.defineProperty(BaseUsageData.prototype, "Fields", {
  5068. get: function () {
  5069. return this._fields;
  5070. },
  5071. enumerable: true,
  5072. configurable: true
  5073. });
  5074. Object.defineProperty(BaseUsageData.prototype, "Table", {
  5075. get: function () {
  5076. return this._table;
  5077. },
  5078. enumerable: true,
  5079. configurable: true
  5080. });
  5081. BaseUsageData.prototype.SerializeFields = function () {
  5082. };
  5083. BaseUsageData.prototype.SetSerializedField = function (key, value) {
  5084. if (typeof (value) !== "undefined" && value !== null) {
  5085. this._serializedFields[key] = value.toString();
  5086. }
  5087. };
  5088. BaseUsageData.prototype.SerializeRow = function () {
  5089. this._serializedFields = {};
  5090. this.SetSerializedField("Table", this._table);
  5091. this.SerializeFields();
  5092. return JSON.stringify(this._serializedFields);
  5093. };
  5094. return BaseUsageData;
  5095. })();
  5096. OSFLog.BaseUsageData = BaseUsageData;
  5097. var AppActivatedUsageData = (function (_super) {
  5098. __extends(AppActivatedUsageData, _super);
  5099. function AppActivatedUsageData() {
  5100. _super.call(this, "AppActivated");
  5101. }
  5102. Object.defineProperty(AppActivatedUsageData.prototype, "CorrelationId", {
  5103. get: function () { return this.Fields["CorrelationId"]; },
  5104. set: function (value) { this.Fields["CorrelationId"] = value; },
  5105. enumerable: true,
  5106. configurable: true
  5107. });
  5108. Object.defineProperty(AppActivatedUsageData.prototype, "SessionId", {
  5109. get: function () { return this.Fields["SessionId"]; },
  5110. set: function (value) { this.Fields["SessionId"] = value; },
  5111. enumerable: true,
  5112. configurable: true
  5113. });
  5114. Object.defineProperty(AppActivatedUsageData.prototype, "AppId", {
  5115. get: function () { return this.Fields["AppId"]; },
  5116. set: function (value) { this.Fields["AppId"] = value; },
  5117. enumerable: true,
  5118. configurable: true
  5119. });
  5120. Object.defineProperty(AppActivatedUsageData.prototype, "AppInstanceId", {
  5121. get: function () { return this.Fields["AppInstanceId"]; },
  5122. set: function (value) { this.Fields["AppInstanceId"] = value; },
  5123. enumerable: true,
  5124. configurable: true
  5125. });
  5126. Object.defineProperty(AppActivatedUsageData.prototype, "AppURL", {
  5127. get: function () { return this.Fields["AppURL"]; },
  5128. set: function (value) { this.Fields["AppURL"] = value; },
  5129. enumerable: true,
  5130. configurable: true
  5131. });
  5132. Object.defineProperty(AppActivatedUsageData.prototype, "AssetId", {
  5133. get: function () { return this.Fields["AssetId"]; },
  5134. set: function (value) { this.Fields["AssetId"] = value; },
  5135. enumerable: true,
  5136. configurable: true
  5137. });
  5138. Object.defineProperty(AppActivatedUsageData.prototype, "Browser", {
  5139. get: function () { return this.Fields["Browser"]; },
  5140. set: function (value) { this.Fields["Browser"] = value; },
  5141. enumerable: true,
  5142. configurable: true
  5143. });
  5144. Object.defineProperty(AppActivatedUsageData.prototype, "UserId", {
  5145. get: function () { return this.Fields["UserId"]; },
  5146. set: function (value) { this.Fields["UserId"] = value; },
  5147. enumerable: true,
  5148. configurable: true
  5149. });
  5150. Object.defineProperty(AppActivatedUsageData.prototype, "Host", {
  5151. get: function () { return this.Fields["Host"]; },
  5152. set: function (value) { this.Fields["Host"] = value; },
  5153. enumerable: true,
  5154. configurable: true
  5155. });
  5156. Object.defineProperty(AppActivatedUsageData.prototype, "HostVersion", {
  5157. get: function () { return this.Fields["HostVersion"]; },
  5158. set: function (value) { this.Fields["HostVersion"] = value; },
  5159. enumerable: true,
  5160. configurable: true
  5161. });
  5162. Object.defineProperty(AppActivatedUsageData.prototype, "ClientId", {
  5163. get: function () { return this.Fields["ClientId"]; },
  5164. set: function (value) { this.Fields["ClientId"] = value; },
  5165. enumerable: true,
  5166. configurable: true
  5167. });
  5168. Object.defineProperty(AppActivatedUsageData.prototype, "AppSizeWidth", {
  5169. get: function () { return this.Fields["AppSizeWidth"]; },
  5170. set: function (value) { this.Fields["AppSizeWidth"] = value; },
  5171. enumerable: true,
  5172. configurable: true
  5173. });
  5174. Object.defineProperty(AppActivatedUsageData.prototype, "AppSizeHeight", {
  5175. get: function () { return this.Fields["AppSizeHeight"]; },
  5176. set: function (value) { this.Fields["AppSizeHeight"] = value; },
  5177. enumerable: true,
  5178. configurable: true
  5179. });
  5180. Object.defineProperty(AppActivatedUsageData.prototype, "Message", {
  5181. get: function () { return this.Fields["Message"]; },
  5182. set: function (value) { this.Fields["Message"] = value; },
  5183. enumerable: true,
  5184. configurable: true
  5185. });
  5186. Object.defineProperty(AppActivatedUsageData.prototype, "DocUrl", {
  5187. get: function () { return this.Fields["DocUrl"]; },
  5188. set: function (value) { this.Fields["DocUrl"] = value; },
  5189. enumerable: true,
  5190. configurable: true
  5191. });
  5192. Object.defineProperty(AppActivatedUsageData.prototype, "OfficeJSVersion", {
  5193. get: function () { return this.Fields["OfficeJSVersion"]; },
  5194. set: function (value) { this.Fields["OfficeJSVersion"] = value; },
  5195. enumerable: true,
  5196. configurable: true
  5197. });
  5198. Object.defineProperty(AppActivatedUsageData.prototype, "HostJSVersion", {
  5199. get: function () { return this.Fields["HostJSVersion"]; },
  5200. set: function (value) { this.Fields["HostJSVersion"] = value; },
  5201. enumerable: true,
  5202. configurable: true
  5203. });
  5204. AppActivatedUsageData.prototype.SerializeFields = function () {
  5205. this.SetSerializedField("CorrelationId", this.CorrelationId);
  5206. this.SetSerializedField("SessionId", this.SessionId);
  5207. this.SetSerializedField("AppId", this.AppId);
  5208. this.SetSerializedField("AppInstanceId", this.AppInstanceId);
  5209. this.SetSerializedField("AppURL", this.AppURL);
  5210. this.SetSerializedField("AssetId", this.AssetId);
  5211. this.SetSerializedField("Browser", this.Browser);
  5212. this.SetSerializedField("UserId", this.UserId);
  5213. this.SetSerializedField("Host", this.Host);
  5214. this.SetSerializedField("HostVersion", this.HostVersion);
  5215. this.SetSerializedField("ClientId", this.ClientId);
  5216. this.SetSerializedField("AppSizeWidth", this.AppSizeWidth);
  5217. this.SetSerializedField("AppSizeHeight", this.AppSizeHeight);
  5218. this.SetSerializedField("Message", this.Message);
  5219. this.SetSerializedField("DocUrl", this.DocUrl);
  5220. this.SetSerializedField("OfficeJSVersion", this.OfficeJSVersion);
  5221. this.SetSerializedField("HostJSVersion", this.HostJSVersion);
  5222. };
  5223. return AppActivatedUsageData;
  5224. })(BaseUsageData);
  5225. OSFLog.AppActivatedUsageData = AppActivatedUsageData;
  5226. var ScriptLoadUsageData = (function (_super) {
  5227. __extends(ScriptLoadUsageData, _super);
  5228. function ScriptLoadUsageData() {
  5229. _super.call(this, "ScriptLoad");
  5230. }
  5231. Object.defineProperty(ScriptLoadUsageData.prototype, "CorrelationId", {
  5232. get: function () { return this.Fields["CorrelationId"]; },
  5233. set: function (value) { this.Fields["CorrelationId"] = value; },
  5234. enumerable: true,
  5235. configurable: true
  5236. });
  5237. Object.defineProperty(ScriptLoadUsageData.prototype, "SessionId", {
  5238. get: function () { return this.Fields["SessionId"]; },
  5239. set: function (value) { this.Fields["SessionId"] = value; },
  5240. enumerable: true,
  5241. configurable: true
  5242. });
  5243. Object.defineProperty(ScriptLoadUsageData.prototype, "ScriptId", {
  5244. get: function () { return this.Fields["ScriptId"]; },
  5245. set: function (value) { this.Fields["ScriptId"] = value; },
  5246. enumerable: true,
  5247. configurable: true
  5248. });
  5249. Object.defineProperty(ScriptLoadUsageData.prototype, "StartTime", {
  5250. get: function () { return this.Fields["StartTime"]; },
  5251. set: function (value) { this.Fields["StartTime"] = value; },
  5252. enumerable: true,
  5253. configurable: true
  5254. });
  5255. Object.defineProperty(ScriptLoadUsageData.prototype, "ResponseTime", {
  5256. get: function () { return this.Fields["ResponseTime"]; },
  5257. set: function (value) { this.Fields["ResponseTime"] = value; },
  5258. enumerable: true,
  5259. configurable: true
  5260. });
  5261. ScriptLoadUsageData.prototype.SerializeFields = function () {
  5262. this.SetSerializedField("CorrelationId", this.CorrelationId);
  5263. this.SetSerializedField("SessionId", this.SessionId);
  5264. this.SetSerializedField("ScriptId", this.ScriptId);
  5265. this.SetSerializedField("StartTime", this.StartTime);
  5266. this.SetSerializedField("ResponseTime", this.ResponseTime);
  5267. };
  5268. return ScriptLoadUsageData;
  5269. })(BaseUsageData);
  5270. OSFLog.ScriptLoadUsageData = ScriptLoadUsageData;
  5271. var AppClosedUsageData = (function (_super) {
  5272. __extends(AppClosedUsageData, _super);
  5273. function AppClosedUsageData() {
  5274. _super.call(this, "AppClosed");
  5275. }
  5276. Object.defineProperty(AppClosedUsageData.prototype, "CorrelationId", {
  5277. get: function () { return this.Fields["CorrelationId"]; },
  5278. set: function (value) { this.Fields["CorrelationId"] = value; },
  5279. enumerable: true,
  5280. configurable: true
  5281. });
  5282. Object.defineProperty(AppClosedUsageData.prototype, "SessionId", {
  5283. get: function () { return this.Fields["SessionId"]; },
  5284. set: function (value) { this.Fields["SessionId"] = value; },
  5285. enumerable: true,
  5286. configurable: true
  5287. });
  5288. Object.defineProperty(AppClosedUsageData.prototype, "FocusTime", {
  5289. get: function () { return this.Fields["FocusTime"]; },
  5290. set: function (value) { this.Fields["FocusTime"] = value; },
  5291. enumerable: true,
  5292. configurable: true
  5293. });
  5294. Object.defineProperty(AppClosedUsageData.prototype, "AppSizeFinalWidth", {
  5295. get: function () { return this.Fields["AppSizeFinalWidth"]; },
  5296. set: function (value) { this.Fields["AppSizeFinalWidth"] = value; },
  5297. enumerable: true,
  5298. configurable: true
  5299. });
  5300. Object.defineProperty(AppClosedUsageData.prototype, "AppSizeFinalHeight", {
  5301. get: function () { return this.Fields["AppSizeFinalHeight"]; },
  5302. set: function (value) { this.Fields["AppSizeFinalHeight"] = value; },
  5303. enumerable: true,
  5304. configurable: true
  5305. });
  5306. Object.defineProperty(AppClosedUsageData.prototype, "OpenTime", {
  5307. get: function () { return this.Fields["OpenTime"]; },
  5308. set: function (value) { this.Fields["OpenTime"] = value; },
  5309. enumerable: true,
  5310. configurable: true
  5311. });
  5312. Object.defineProperty(AppClosedUsageData.prototype, "CloseMethod", {
  5313. get: function () { return this.Fields["CloseMethod"]; },
  5314. set: function (value) { this.Fields["CloseMethod"] = value; },
  5315. enumerable: true,
  5316. configurable: true
  5317. });
  5318. AppClosedUsageData.prototype.SerializeFields = function () {
  5319. this.SetSerializedField("CorrelationId", this.CorrelationId);
  5320. this.SetSerializedField("SessionId", this.SessionId);
  5321. this.SetSerializedField("FocusTime", this.FocusTime);
  5322. this.SetSerializedField("AppSizeFinalWidth", this.AppSizeFinalWidth);
  5323. this.SetSerializedField("AppSizeFinalHeight", this.AppSizeFinalHeight);
  5324. this.SetSerializedField("OpenTime", this.OpenTime);
  5325. this.SetSerializedField("CloseMethod", this.CloseMethod);
  5326. };
  5327. return AppClosedUsageData;
  5328. })(BaseUsageData);
  5329. OSFLog.AppClosedUsageData = AppClosedUsageData;
  5330. var APIUsageUsageData = (function (_super) {
  5331. __extends(APIUsageUsageData, _super);
  5332. function APIUsageUsageData() {
  5333. _super.call(this, "APIUsage");
  5334. }
  5335. Object.defineProperty(APIUsageUsageData.prototype, "CorrelationId", {
  5336. get: function () { return this.Fields["CorrelationId"]; },
  5337. set: function (value) { this.Fields["CorrelationId"] = value; },
  5338. enumerable: true,
  5339. configurable: true
  5340. });
  5341. Object.defineProperty(APIUsageUsageData.prototype, "SessionId", {
  5342. get: function () { return this.Fields["SessionId"]; },
  5343. set: function (value) { this.Fields["SessionId"] = value; },
  5344. enumerable: true,
  5345. configurable: true
  5346. });
  5347. Object.defineProperty(APIUsageUsageData.prototype, "APIType", {
  5348. get: function () { return this.Fields["APIType"]; },
  5349. set: function (value) { this.Fields["APIType"] = value; },
  5350. enumerable: true,
  5351. configurable: true
  5352. });
  5353. Object.defineProperty(APIUsageUsageData.prototype, "APIID", {
  5354. get: function () { return this.Fields["APIID"]; },
  5355. set: function (value) { this.Fields["APIID"] = value; },
  5356. enumerable: true,
  5357. configurable: true
  5358. });
  5359. Object.defineProperty(APIUsageUsageData.prototype, "Parameters", {
  5360. get: function () { return this.Fields["Parameters"]; },
  5361. set: function (value) { this.Fields["Parameters"] = value; },
  5362. enumerable: true,
  5363. configurable: true
  5364. });
  5365. Object.defineProperty(APIUsageUsageData.prototype, "ResponseTime", {
  5366. get: function () { return this.Fields["ResponseTime"]; },
  5367. set: function (value) { this.Fields["ResponseTime"] = value; },
  5368. enumerable: true,
  5369. configurable: true
  5370. });
  5371. Object.defineProperty(APIUsageUsageData.prototype, "ErrorType", {
  5372. get: function () { return this.Fields["ErrorType"]; },
  5373. set: function (value) { this.Fields["ErrorType"] = value; },
  5374. enumerable: true,
  5375. configurable: true
  5376. });
  5377. APIUsageUsageData.prototype.SerializeFields = function () {
  5378. this.SetSerializedField("CorrelationId", this.CorrelationId);
  5379. this.SetSerializedField("SessionId", this.SessionId);
  5380. this.SetSerializedField("APIType", this.APIType);
  5381. this.SetSerializedField("APIID", this.APIID);
  5382. this.SetSerializedField("Parameters", this.Parameters);
  5383. this.SetSerializedField("ResponseTime", this.ResponseTime);
  5384. this.SetSerializedField("ErrorType", this.ErrorType);
  5385. };
  5386. return APIUsageUsageData;
  5387. })(BaseUsageData);
  5388. OSFLog.APIUsageUsageData = APIUsageUsageData;
  5389. var AppInitializationUsageData = (function (_super) {
  5390. __extends(AppInitializationUsageData, _super);
  5391. function AppInitializationUsageData() {
  5392. _super.call(this, "AppInitialization");
  5393. }
  5394. Object.defineProperty(AppInitializationUsageData.prototype, "CorrelationId", {
  5395. get: function () { return this.Fields["CorrelationId"]; },
  5396. set: function (value) { this.Fields["CorrelationId"] = value; },
  5397. enumerable: true,
  5398. configurable: true
  5399. });
  5400. Object.defineProperty(AppInitializationUsageData.prototype, "SessionId", {
  5401. get: function () { return this.Fields["SessionId"]; },
  5402. set: function (value) { this.Fields["SessionId"] = value; },
  5403. enumerable: true,
  5404. configurable: true
  5405. });
  5406. Object.defineProperty(AppInitializationUsageData.prototype, "SuccessCode", {
  5407. get: function () { return this.Fields["SuccessCode"]; },
  5408. set: function (value) { this.Fields["SuccessCode"] = value; },
  5409. enumerable: true,
  5410. configurable: true
  5411. });
  5412. Object.defineProperty(AppInitializationUsageData.prototype, "Message", {
  5413. get: function () { return this.Fields["Message"]; },
  5414. set: function (value) { this.Fields["Message"] = value; },
  5415. enumerable: true,
  5416. configurable: true
  5417. });
  5418. AppInitializationUsageData.prototype.SerializeFields = function () {
  5419. this.SetSerializedField("CorrelationId", this.CorrelationId);
  5420. this.SetSerializedField("SessionId", this.SessionId);
  5421. this.SetSerializedField("SuccessCode", this.SuccessCode);
  5422. this.SetSerializedField("Message", this.Message);
  5423. };
  5424. return AppInitializationUsageData;
  5425. })(BaseUsageData);
  5426. OSFLog.AppInitializationUsageData = AppInitializationUsageData;
  5427. })(OSFLog || (OSFLog = {}));
  5428. var Logger;
  5429. (function (Logger) {
  5430. "use strict";
  5431. (function (TraceLevel) {
  5432. TraceLevel[TraceLevel["info"] = 0] = "info";
  5433. TraceLevel[TraceLevel["warning"] = 1] = "warning";
  5434. TraceLevel[TraceLevel["error"] = 2] = "error";
  5435. })(Logger.TraceLevel || (Logger.TraceLevel = {}));
  5436. var TraceLevel = Logger.TraceLevel;
  5437. (function (SendFlag) {
  5438. SendFlag[SendFlag["none"] = 0] = "none";
  5439. SendFlag[SendFlag["flush"] = 1] = "flush";
  5440. })(Logger.SendFlag || (Logger.SendFlag = {}));
  5441. var SendFlag = Logger.SendFlag;
  5442. function allowUploadingData() {
  5443. if (OSF.Logger && OSF.Logger.ulsEndpoint) {
  5444. OSF.Logger.ulsEndpoint.loadProxyFrame();
  5445. }
  5446. }
  5447. Logger.allowUploadingData = allowUploadingData;
  5448. function sendLog(traceLevel, message, flag) {
  5449. if (OSF.Logger && OSF.Logger.ulsEndpoint) {
  5450. var jsonObj = { traceLevel: traceLevel, message: message, flag: flag, internalLog: true };
  5451. var logs = JSON.stringify(jsonObj);
  5452. OSF.Logger.ulsEndpoint.writeLog(logs);
  5453. }
  5454. }
  5455. Logger.sendLog = sendLog;
  5456. function creatULSEndpoint() {
  5457. try {
  5458. return new ULSEndpointProxy();
  5459. }
  5460. catch (e) {
  5461. return null;
  5462. }
  5463. }
  5464. var ULSEndpointProxy = (function () {
  5465. function ULSEndpointProxy() {
  5466. var _this = this;
  5467. this.proxyFrame = null;
  5468. this.telemetryEndPoint = "https://telemetryservice.firstpartyapps.oaspapps.com/telemetryservice/telemetryproxy.html";
  5469. this.buffer = [];
  5470. this.proxyFrameReady = false;
  5471. OSF.OUtil.addEventListener(window, "message", function (e) { return _this.tellProxyFrameReady(e); });
  5472. setTimeout(function () {
  5473. _this.loadProxyFrame();
  5474. }, 3000);
  5475. }
  5476. ULSEndpointProxy.prototype.writeLog = function (log) {
  5477. if (this.proxyFrameReady === true) {
  5478. this.proxyFrame.contentWindow.postMessage(log, ULSEndpointProxy.telemetryOrigin);
  5479. }
  5480. else {
  5481. if (this.buffer.length < 128) {
  5482. this.buffer.push(log);
  5483. }
  5484. }
  5485. };
  5486. ULSEndpointProxy.prototype.loadProxyFrame = function () {
  5487. if (this.proxyFrame == null) {
  5488. this.proxyFrame = document.createElement("iframe");
  5489. this.proxyFrame.setAttribute("style", "display:none");
  5490. this.proxyFrame.setAttribute("src", this.telemetryEndPoint);
  5491. document.head.appendChild(this.proxyFrame);
  5492. }
  5493. };
  5494. ULSEndpointProxy.prototype.tellProxyFrameReady = function (e) {
  5495. var _this = this;
  5496. if (e.data === "ProxyFrameReadyToLog") {
  5497. this.proxyFrameReady = true;
  5498. for (var i = 0; i < this.buffer.length; i++) {
  5499. this.writeLog(this.buffer[i]);
  5500. }
  5501. this.buffer.length = 0;
  5502. OSF.OUtil.removeEventListener(window, "message", function (e) { return _this.tellProxyFrameReady(e); });
  5503. }
  5504. else if (e.data === "ProxyFrameReadyToInit") {
  5505. var initJson = { appName: "Office APPs", sessionId: OSF.OUtil.Guid.generateNewGuid() };
  5506. var initStr = JSON.stringify(initJson);
  5507. this.proxyFrame.contentWindow.postMessage(initStr, ULSEndpointProxy.telemetryOrigin);
  5508. }
  5509. };
  5510. ULSEndpointProxy.telemetryOrigin = "https://telemetryservice.firstpartyapps.oaspapps.com";
  5511. return ULSEndpointProxy;
  5512. })();
  5513. if (!OSF.Logger) {
  5514. OSF.Logger = Logger;
  5515. }
  5516. Logger.ulsEndpoint = creatULSEndpoint();
  5517. })(Logger || (Logger = {}));
  5518. var OSFAppTelemetry;
  5519. (function (OSFAppTelemetry) {
  5520. "use strict";
  5521. var appInfo;
  5522. var sessionId = OSF.OUtil.Guid.generateNewGuid();
  5523. var osfControlAppCorrelationId = "";
  5524. var omexDomainRegex = new RegExp("^https?://store\\.office(ppe|-int)?\\.com/", "i");
  5525. ;
  5526. var AppInfo = (function () {
  5527. function AppInfo() {
  5528. }
  5529. return AppInfo;
  5530. })();
  5531. var Event = (function () {
  5532. function Event(name, handler) {
  5533. this.name = name;
  5534. this.handler = handler;
  5535. }
  5536. return Event;
  5537. })();
  5538. var AppStorage = (function () {
  5539. function AppStorage() {
  5540. this.clientIDKey = "Office API client";
  5541. this.logIdSetKey = "Office App Log Id Set";
  5542. }
  5543. AppStorage.prototype.getClientId = function () {
  5544. var clientId = this.getValue(this.clientIDKey);
  5545. if (!clientId || clientId.length <= 0 || clientId.length > 40) {
  5546. clientId = OSF.OUtil.Guid.generateNewGuid();
  5547. this.setValue(this.clientIDKey, clientId);
  5548. }
  5549. return clientId;
  5550. };
  5551. AppStorage.prototype.saveLog = function (logId, log) {
  5552. var logIdSet = this.getValue(this.logIdSetKey);
  5553. logIdSet = ((logIdSet && logIdSet.length > 0) ? (logIdSet + ";") : "") + logId;
  5554. this.setValue(this.logIdSetKey, logIdSet);
  5555. this.setValue(logId, log);
  5556. };
  5557. AppStorage.prototype.enumerateLog = function (callback, clean) {
  5558. var logIdSet = this.getValue(this.logIdSetKey);
  5559. if (logIdSet) {
  5560. var ids = logIdSet.split(";");
  5561. for (var id in ids) {
  5562. var logId = ids[id];
  5563. var log = this.getValue(logId);
  5564. if (log) {
  5565. if (callback) {
  5566. callback(logId, log);
  5567. }
  5568. if (clean) {
  5569. this.remove(logId);
  5570. }
  5571. }
  5572. }
  5573. if (clean) {
  5574. this.remove(this.logIdSetKey);
  5575. }
  5576. }
  5577. };
  5578. AppStorage.prototype.getValue = function (key) {
  5579. var osfLocalStorage = OSF.OUtil.getLocalStorage();
  5580. var value = "";
  5581. if (osfLocalStorage) {
  5582. value = osfLocalStorage.getItem(key);
  5583. }
  5584. return value;
  5585. };
  5586. AppStorage.prototype.setValue = function (key, value) {
  5587. var osfLocalStorage = OSF.OUtil.getLocalStorage();
  5588. if (osfLocalStorage) {
  5589. osfLocalStorage.setItem(key, value);
  5590. }
  5591. };
  5592. AppStorage.prototype.remove = function (key) {
  5593. var osfLocalStorage = OSF.OUtil.getLocalStorage();
  5594. if (osfLocalStorage) {
  5595. try {
  5596. osfLocalStorage.removeItem(key);
  5597. }
  5598. catch (ex) {
  5599. }
  5600. }
  5601. };
  5602. return AppStorage;
  5603. })();
  5604. var AppLogger = (function () {
  5605. function AppLogger() {
  5606. }
  5607. AppLogger.prototype.LogData = function (data) {
  5608. if (!OSF.Logger) {
  5609. return;
  5610. }
  5611. OSF.Logger.sendLog(OSF.Logger.TraceLevel.info, data.SerializeRow(), OSF.Logger.SendFlag.none);
  5612. };
  5613. AppLogger.prototype.LogRawData = function (log) {
  5614. if (!OSF.Logger) {
  5615. return;
  5616. }
  5617. OSF.Logger.sendLog(OSF.Logger.TraceLevel.info, log, OSF.Logger.SendFlag.none);
  5618. };
  5619. return AppLogger;
  5620. })();
  5621. function initialize(context) {
  5622. if (!OSF.Logger) {
  5623. return;
  5624. }
  5625. if (appInfo) {
  5626. return;
  5627. }
  5628. appInfo = new AppInfo();
  5629. if (context.get_hostFullVersion()) {
  5630. appInfo.hostVersion = context.get_hostFullVersion();
  5631. }
  5632. else {
  5633. appInfo.hostVersion = context.get_appVersion();
  5634. }
  5635. appInfo.appId = context.get_id();
  5636. appInfo.host = context.get_appName();
  5637. appInfo.browser = window.navigator.userAgent;
  5638. appInfo.correlationId = context.get_correlationId();
  5639. appInfo.clientId = (new AppStorage()).getClientId();
  5640. appInfo.appInstanceId = context.get_appInstanceId();
  5641. if (appInfo.appInstanceId) {
  5642. appInfo.appInstanceId = appInfo.appInstanceId.replace(/[{}]/g, "").toLowerCase();
  5643. }
  5644. appInfo.message = context.get_hostCustomMessage();
  5645. appInfo.officeJSVersion = OSF.ConstantNames.FileVersion;
  5646. appInfo.hostJSVersion = "16.0.7610.1000";
  5647. var docUrl = context.get_docUrl();
  5648. appInfo.docUrl = omexDomainRegex.test(docUrl) ? docUrl : "";
  5649. var url = location.href;
  5650. if (url) {
  5651. url = url.split("?")[0].split("#")[0];
  5652. }
  5653. appInfo.appURL = url;
  5654. (function getUserIdAndAssetIdFromToken(token, appInfo) {
  5655. var xmlContent;
  5656. var parser;
  5657. var xmlDoc;
  5658. appInfo.assetId = "";
  5659. appInfo.userId = "";
  5660. try {
  5661. xmlContent = decodeURIComponent(token);
  5662. parser = new DOMParser();
  5663. xmlDoc = parser.parseFromString(xmlContent, "text/xml");
  5664. var cidNode = xmlDoc.getElementsByTagName("t")[0].attributes.getNamedItem("cid");
  5665. var oidNode = xmlDoc.getElementsByTagName("t")[0].attributes.getNamedItem("oid");
  5666. if (cidNode && cidNode.nodeValue) {
  5667. appInfo.userId = cidNode.nodeValue;
  5668. }
  5669. else if (oidNode && oidNode.nodeValue) {
  5670. appInfo.userId = oidNode.nodeValue;
  5671. }
  5672. appInfo.assetId = xmlDoc.getElementsByTagName("t")[0].attributes.getNamedItem("aid").nodeValue;
  5673. }
  5674. catch (e) {
  5675. }
  5676. finally {
  5677. xmlContent = null;
  5678. xmlDoc = null;
  5679. parser = null;
  5680. }
  5681. })(context.get_eToken(), appInfo);
  5682. (function handleLifecycle() {
  5683. var startTime = new Date();
  5684. var lastFocus = null;
  5685. var focusTime = 0;
  5686. var finished = false;
  5687. var adjustFocusTime = function () {
  5688. if (document.hasFocus()) {
  5689. if (lastFocus == null) {
  5690. lastFocus = new Date();
  5691. }
  5692. }
  5693. else if (lastFocus) {
  5694. focusTime += Math.abs((new Date()).getTime() - lastFocus.getTime());
  5695. lastFocus = null;
  5696. }
  5697. };
  5698. var eventList = [];
  5699. eventList.push(new Event("focus", adjustFocusTime));
  5700. eventList.push(new Event("blur", adjustFocusTime));
  5701. eventList.push(new Event("focusout", adjustFocusTime));
  5702. eventList.push(new Event("focusin", adjustFocusTime));
  5703. var exitFunction = function () {
  5704. for (var i = 0; i < eventList.length; i++) {
  5705. OSF.OUtil.removeEventListener(window, eventList[i].name, eventList[i].handler);
  5706. }
  5707. eventList.length = 0;
  5708. if (!finished) {
  5709. if (document.hasFocus() && lastFocus) {
  5710. focusTime += Math.abs((new Date()).getTime() - lastFocus.getTime());
  5711. lastFocus = null;
  5712. }
  5713. OSFAppTelemetry.onAppClosed(Math.abs((new Date()).getTime() - startTime.getTime()), focusTime);
  5714. finished = true;
  5715. }
  5716. };
  5717. eventList.push(new Event("beforeunload", exitFunction));
  5718. eventList.push(new Event("unload", exitFunction));
  5719. for (var i = 0; i < eventList.length; i++) {
  5720. OSF.OUtil.addEventListener(window, eventList[i].name, eventList[i].handler);
  5721. }
  5722. adjustFocusTime();
  5723. })();
  5724. OSFAppTelemetry.onAppActivated();
  5725. }
  5726. OSFAppTelemetry.initialize = initialize;
  5727. function onAppActivated() {
  5728. if (!appInfo) {
  5729. return;
  5730. }
  5731. (new AppStorage()).enumerateLog(function (id, log) { return (new AppLogger()).LogRawData(log); }, true);
  5732. var data = new OSFLog.AppActivatedUsageData();
  5733. data.SessionId = sessionId;
  5734. data.AppId = appInfo.appId;
  5735. data.AssetId = appInfo.assetId;
  5736. data.AppURL = appInfo.appURL;
  5737. data.UserId = appInfo.userId;
  5738. data.ClientId = appInfo.clientId;
  5739. data.Browser = appInfo.browser;
  5740. data.Host = appInfo.host;
  5741. data.HostVersion = appInfo.hostVersion;
  5742. data.CorrelationId = appInfo.correlationId;
  5743. data.AppSizeWidth = window.innerWidth;
  5744. data.AppSizeHeight = window.innerHeight;
  5745. data.AppInstanceId = appInfo.appInstanceId;
  5746. data.Message = appInfo.message;
  5747. data.DocUrl = appInfo.docUrl;
  5748. data.OfficeJSVersion = appInfo.officeJSVersion;
  5749. data.HostJSVersion = appInfo.hostJSVersion;
  5750. (new AppLogger()).LogData(data);
  5751. setTimeout(function () {
  5752. if (!OSF.Logger) {
  5753. return;
  5754. }
  5755. OSF.Logger.allowUploadingData();
  5756. }, 100);
  5757. }
  5758. OSFAppTelemetry.onAppActivated = onAppActivated;
  5759. function onScriptDone(scriptId, msStartTime, msResponseTime, appCorrelationId) {
  5760. var data = new OSFLog.ScriptLoadUsageData();
  5761. data.CorrelationId = appCorrelationId;
  5762. data.SessionId = sessionId;
  5763. data.ScriptId = scriptId;
  5764. data.StartTime = msStartTime;
  5765. data.ResponseTime = msResponseTime;
  5766. (new AppLogger()).LogData(data);
  5767. }
  5768. OSFAppTelemetry.onScriptDone = onScriptDone;
  5769. function onCallDone(apiType, id, parameters, msResponseTime, errorType) {
  5770. if (!appInfo) {
  5771. return;
  5772. }
  5773. var data = new OSFLog.APIUsageUsageData();
  5774. data.CorrelationId = osfControlAppCorrelationId;
  5775. data.SessionId = sessionId;
  5776. data.APIType = apiType;
  5777. data.APIID = id;
  5778. data.Parameters = parameters;
  5779. data.ResponseTime = msResponseTime;
  5780. data.ErrorType = errorType;
  5781. (new AppLogger()).LogData(data);
  5782. }
  5783. OSFAppTelemetry.onCallDone = onCallDone;
  5784. ;
  5785. function onMethodDone(id, args, msResponseTime, errorType) {
  5786. var parameters = null;
  5787. if (args) {
  5788. if (typeof args == "number") {
  5789. parameters = String(args);
  5790. }
  5791. else if (typeof args === "object") {
  5792. for (var index in args) {
  5793. if (parameters !== null) {
  5794. parameters += ",";
  5795. }
  5796. else {
  5797. parameters = "";
  5798. }
  5799. if (typeof args[index] == "number") {
  5800. parameters += String(args[index]);
  5801. }
  5802. }
  5803. }
  5804. else {
  5805. parameters = "";
  5806. }
  5807. }
  5808. OSF.AppTelemetry.onCallDone("method", id, parameters, msResponseTime, errorType);
  5809. }
  5810. OSFAppTelemetry.onMethodDone = onMethodDone;
  5811. function onPropertyDone(propertyName, msResponseTime) {
  5812. OSF.AppTelemetry.onCallDone("property", -1, propertyName, msResponseTime);
  5813. }
  5814. OSFAppTelemetry.onPropertyDone = onPropertyDone;
  5815. function onEventDone(id, errorType) {
  5816. OSF.AppTelemetry.onCallDone("event", id, null, 0, errorType);
  5817. }
  5818. OSFAppTelemetry.onEventDone = onEventDone;
  5819. function onRegisterDone(register, id, msResponseTime, errorType) {
  5820. OSF.AppTelemetry.onCallDone(register ? "registerevent" : "unregisterevent", id, null, msResponseTime, errorType);
  5821. }
  5822. OSFAppTelemetry.onRegisterDone = onRegisterDone;
  5823. function onAppClosed(openTime, focusTime) {
  5824. if (!appInfo) {
  5825. return;
  5826. }
  5827. var data = new OSFLog.AppClosedUsageData();
  5828. data.CorrelationId = osfControlAppCorrelationId;
  5829. data.SessionId = sessionId;
  5830. data.FocusTime = focusTime;
  5831. data.OpenTime = openTime;
  5832. data.AppSizeFinalWidth = window.innerWidth;
  5833. data.AppSizeFinalHeight = window.innerHeight;
  5834. (new AppStorage()).saveLog(sessionId, data.SerializeRow());
  5835. }
  5836. OSFAppTelemetry.onAppClosed = onAppClosed;
  5837. function setOsfControlAppCorrelationId(correlationId) {
  5838. osfControlAppCorrelationId = correlationId;
  5839. }
  5840. OSFAppTelemetry.setOsfControlAppCorrelationId = setOsfControlAppCorrelationId;
  5841. function doAppInitializationLogging(isException, message) {
  5842. var data = new OSFLog.AppInitializationUsageData();
  5843. data.CorrelationId = osfControlAppCorrelationId;
  5844. data.SessionId = sessionId;
  5845. data.SuccessCode = isException ? 1 : 0;
  5846. data.Message = message;
  5847. (new AppLogger()).LogData(data);
  5848. }
  5849. OSFAppTelemetry.doAppInitializationLogging = doAppInitializationLogging;
  5850. function logAppCommonMessage(message) {
  5851. doAppInitializationLogging(false, message);
  5852. }
  5853. OSFAppTelemetry.logAppCommonMessage = logAppCommonMessage;
  5854. function logAppException(errorMessage) {
  5855. doAppInitializationLogging(true, errorMessage);
  5856. }
  5857. OSFAppTelemetry.logAppException = logAppException;
  5858. OSF.AppTelemetry = OSFAppTelemetry;
  5859. })(OSFAppTelemetry || (OSFAppTelemetry = {}));
  5860. Microsoft.Office.WebExtension.TableData = function Microsoft_Office_WebExtension_TableData(rows, headers) {
  5861. function fixData(data) {
  5862. if (data == null || data == undefined) {
  5863. return null;
  5864. }
  5865. try {
  5866. for (var dim = OSF.DDA.DataCoercion.findArrayDimensionality(data, 2); dim < 2; dim++) {
  5867. data = [data];
  5868. }
  5869. return data;
  5870. }
  5871. catch (ex) {
  5872. }
  5873. }
  5874. ;
  5875. OSF.OUtil.defineEnumerableProperties(this, {
  5876. "headers": {
  5877. get: function () { return headers; },
  5878. set: function (value) {
  5879. headers = fixData(value);
  5880. }
  5881. },
  5882. "rows": {
  5883. get: function () { return rows; },
  5884. set: function (value) {
  5885. rows = (value == null || (OSF.OUtil.isArray(value) && (value.length == 0))) ?
  5886. [] :
  5887. fixData(value);
  5888. }
  5889. }
  5890. });
  5891. this.headers = headers;
  5892. this.rows = rows;
  5893. };
  5894. OSF.DDA.OMFactory = OSF.DDA.OMFactory || {};
  5895. OSF.DDA.OMFactory.manufactureTableData = function OSF_DDA_OMFactory$manufactureTableData(tableDataProperties) {
  5896. return new Microsoft.Office.WebExtension.TableData(tableDataProperties[OSF.DDA.TableDataProperties.TableRows], tableDataProperties[OSF.DDA.TableDataProperties.TableHeaders]);
  5897. };
  5898. Microsoft.Office.WebExtension.CoercionType = {
  5899. Text: "text",
  5900. Matrix: "matrix",
  5901. Table: "table"
  5902. };
  5903. OSF.DDA.DataCoercion = (function OSF_DDA_DataCoercion() {
  5904. return {
  5905. findArrayDimensionality: function OSF_DDA_DataCoercion$findArrayDimensionality(obj) {
  5906. if (OSF.OUtil.isArray(obj)) {
  5907. var dim = 0;
  5908. for (var index = 0; index < obj.length; index++) {
  5909. dim = Math.max(dim, OSF.DDA.DataCoercion.findArrayDimensionality(obj[index]));
  5910. }
  5911. return dim + 1;
  5912. }
  5913. else {
  5914. return 0;
  5915. }
  5916. },
  5917. getCoercionDefaultForBinding: function OSF_DDA_DataCoercion$getCoercionDefaultForBinding(bindingType) {
  5918. switch (bindingType) {
  5919. case Microsoft.Office.WebExtension.BindingType.Matrix: return Microsoft.Office.WebExtension.CoercionType.Matrix;
  5920. case Microsoft.Office.WebExtension.BindingType.Table: return Microsoft.Office.WebExtension.CoercionType.Table;
  5921. case Microsoft.Office.WebExtension.BindingType.Text:
  5922. default:
  5923. return Microsoft.Office.WebExtension.CoercionType.Text;
  5924. }
  5925. },
  5926. getBindingDefaultForCoercion: function OSF_DDA_DataCoercion$getBindingDefaultForCoercion(coercionType) {
  5927. switch (coercionType) {
  5928. case Microsoft.Office.WebExtension.CoercionType.Matrix: return Microsoft.Office.WebExtension.BindingType.Matrix;
  5929. case Microsoft.Office.WebExtension.CoercionType.Table: return Microsoft.Office.WebExtension.BindingType.Table;
  5930. case Microsoft.Office.WebExtension.CoercionType.Text:
  5931. case Microsoft.Office.WebExtension.CoercionType.Html:
  5932. case Microsoft.Office.WebExtension.CoercionType.Ooxml:
  5933. default:
  5934. return Microsoft.Office.WebExtension.BindingType.Text;
  5935. }
  5936. },
  5937. determineCoercionType: function OSF_DDA_DataCoercion$determineCoercionType(data) {
  5938. if (data == null || data == undefined)
  5939. return null;
  5940. var sourceType = null;
  5941. var runtimeType = typeof data;
  5942. if (data.rows !== undefined) {
  5943. sourceType = Microsoft.Office.WebExtension.CoercionType.Table;
  5944. }
  5945. else if (OSF.OUtil.isArray(data)) {
  5946. sourceType = Microsoft.Office.WebExtension.CoercionType.Matrix;
  5947. }
  5948. else if (runtimeType == "string" || runtimeType == "number" || runtimeType == "boolean" || OSF.OUtil.isDate(data)) {
  5949. sourceType = Microsoft.Office.WebExtension.CoercionType.Text;
  5950. }
  5951. else {
  5952. throw OSF.DDA.ErrorCodeManager.errorCodes.ooeUnsupportedDataObject;
  5953. }
  5954. return sourceType;
  5955. },
  5956. coerceData: function OSF_DDA_DataCoercion$coerceData(data, destinationType, sourceType) {
  5957. sourceType = sourceType || OSF.DDA.DataCoercion.determineCoercionType(data);
  5958. if (sourceType && sourceType != destinationType) {
  5959. OSF.OUtil.writeProfilerMark(OSF.InternalPerfMarker.DataCoercionBegin);
  5960. data = OSF.DDA.DataCoercion._coerceDataFromTable(destinationType, OSF.DDA.DataCoercion._coerceDataToTable(data, sourceType));
  5961. OSF.OUtil.writeProfilerMark(OSF.InternalPerfMarker.DataCoercionEnd);
  5962. }
  5963. return data;
  5964. },
  5965. _matrixToText: function OSF_DDA_DataCoercion$_matrixToText(matrix) {
  5966. if (matrix.length == 1 && matrix[0].length == 1)
  5967. return "" + matrix[0][0];
  5968. var val = "";
  5969. for (var i = 0; i < matrix.length; i++) {
  5970. val += matrix[i].join("\t") + "\n";
  5971. }
  5972. return val.substring(0, val.length - 1);
  5973. },
  5974. _textToMatrix: function OSF_DDA_DataCoercion$_textToMatrix(text) {
  5975. var ret = text.split("\n");
  5976. for (var i = 0; i < ret.length; i++)
  5977. ret[i] = ret[i].split("\t");
  5978. return ret;
  5979. },
  5980. _tableToText: function OSF_DDA_DataCoercion$_tableToText(table) {
  5981. var headers = "";
  5982. if (table.headers != null) {
  5983. headers = OSF.DDA.DataCoercion._matrixToText([table.headers]) + "\n";
  5984. }
  5985. var rows = OSF.DDA.DataCoercion._matrixToText(table.rows);
  5986. if (rows == "") {
  5987. headers = headers.substring(0, headers.length - 1);
  5988. }
  5989. return headers + rows;
  5990. },
  5991. _tableToMatrix: function OSF_DDA_DataCoercion$_tableToMatrix(table) {
  5992. var matrix = table.rows;
  5993. if (table.headers != null) {
  5994. matrix.unshift(table.headers);
  5995. }
  5996. return matrix;
  5997. },
  5998. _coerceDataFromTable: function OSF_DDA_DataCoercion$_coerceDataFromTable(coercionType, table) {
  5999. var value;
  6000. switch (coercionType) {
  6001. case Microsoft.Office.WebExtension.CoercionType.Table:
  6002. value = table;
  6003. break;
  6004. case Microsoft.Office.WebExtension.CoercionType.Matrix:
  6005. value = OSF.DDA.DataCoercion._tableToMatrix(table);
  6006. break;
  6007. case Microsoft.Office.WebExtension.CoercionType.SlideRange:
  6008. value = null;
  6009. if (OSF.DDA.OMFactory.manufactureSlideRange) {
  6010. value = OSF.DDA.OMFactory.manufactureSlideRange(OSF.DDA.DataCoercion._tableToText(table));
  6011. }
  6012. if (value == null) {
  6013. value = OSF.DDA.DataCoercion._tableToText(table);
  6014. }
  6015. break;
  6016. case Microsoft.Office.WebExtension.CoercionType.Text:
  6017. case Microsoft.Office.WebExtension.CoercionType.Html:
  6018. case Microsoft.Office.WebExtension.CoercionType.Ooxml:
  6019. default:
  6020. value = OSF.DDA.DataCoercion._tableToText(table);
  6021. break;
  6022. }
  6023. return value;
  6024. },
  6025. _coerceDataToTable: function OSF_DDA_DataCoercion$_coerceDataToTable(data, sourceType) {
  6026. if (sourceType == undefined) {
  6027. sourceType = OSF.DDA.DataCoercion.determineCoercionType(data);
  6028. }
  6029. var value;
  6030. switch (sourceType) {
  6031. case Microsoft.Office.WebExtension.CoercionType.Table:
  6032. value = data;
  6033. break;
  6034. case Microsoft.Office.WebExtension.CoercionType.Matrix:
  6035. value = new Microsoft.Office.WebExtension.TableData(data);
  6036. break;
  6037. case Microsoft.Office.WebExtension.CoercionType.Text:
  6038. case Microsoft.Office.WebExtension.CoercionType.Html:
  6039. case Microsoft.Office.WebExtension.CoercionType.Ooxml:
  6040. default:
  6041. value = new Microsoft.Office.WebExtension.TableData(OSF.DDA.DataCoercion._textToMatrix(data));
  6042. break;
  6043. }
  6044. return value;
  6045. }
  6046. };
  6047. })();
  6048. OSF.OUtil.augmentList(Microsoft.Office.WebExtension.CoercionType, { SlideRange: "slideRange" });
  6049. OSF.DDA.SlideProperties = {
  6050. Id: 0,
  6051. Title: 1,
  6052. Index: 2
  6053. };
  6054. OSF.DDA.Slide = function OSF_DDA_Slide(id, title, index) {
  6055. OSF.OUtil.defineEnumerableProperties(this, {
  6056. "id": {
  6057. value: id
  6058. },
  6059. "title": {
  6060. value: title
  6061. },
  6062. "index": {
  6063. value: index
  6064. }
  6065. });
  6066. };
  6067. OSF.DDA.SlideRange = function OSF_DDA_SlideRange(slides) {
  6068. OSF.OUtil.defineEnumerableProperties(this, {
  6069. "slides": {
  6070. value: slides
  6071. }
  6072. });
  6073. };
  6074. OSF.DDA.OMFactory = OSF.DDA.OMFactory || {};
  6075. OSF.DDA.OMFactory.manufactureSlideRange = function OSF_DDA_OMFactory$manufactureSlideRange(input) {
  6076. var items = null;
  6077. if (JSON) {
  6078. items = JSON.parse(input);
  6079. }
  6080. else {
  6081. items = Sys.Serialization.JavaScriptSerializer.deserialize(input);
  6082. }
  6083. if (items == null) {
  6084. return null;
  6085. }
  6086. var numField = 0;
  6087. for (var key in OSF.DDA.SlideProperties) {
  6088. if (OSF.DDA.SlideProperties.hasOwnProperty(key)) {
  6089. numField++;
  6090. }
  6091. }
  6092. var slides = [];
  6093. var dataValid = true;
  6094. for (var i = 0; i < items.length && dataValid; i++) {
  6095. dataValid = false;
  6096. if (items[i].length == numField) {
  6097. var id = parseInt(items[i][OSF.DDA.SlideProperties.Id]);
  6098. var title = items[i][OSF.DDA.SlideProperties.Title];
  6099. var index = parseInt(items[i][OSF.DDA.SlideProperties.Index]);
  6100. if (!isNaN(id) && !isNaN(index)) {
  6101. dataValid = true;
  6102. slides.push(new OSF.DDA.Slide(id, title, index));
  6103. }
  6104. }
  6105. }
  6106. if (!dataValid) {
  6107. return null;
  6108. }
  6109. return new OSF.DDA.SlideRange(slides);
  6110. };
  6111. Microsoft.Office.WebExtension.BindingType = {
  6112. Table: "table",
  6113. Text: "text",
  6114. Matrix: "matrix"
  6115. };
  6116. OSF.DDA.BindingProperties = {
  6117. Id: "BindingId",
  6118. Type: Microsoft.Office.WebExtension.Parameters.BindingType
  6119. };
  6120. OSF.OUtil.augmentList(OSF.DDA.ListDescriptors, { BindingList: "BindingList" });
  6121. OSF.OUtil.augmentList(OSF.DDA.PropertyDescriptors, {
  6122. Subset: "subset",
  6123. BindingProperties: "BindingProperties"
  6124. });
  6125. OSF.DDA.ListType.setListType(OSF.DDA.ListDescriptors.BindingList, OSF.DDA.PropertyDescriptors.BindingProperties);
  6126. OSF.DDA.BindingPromise = function OSF_DDA_BindingPromise(bindingId, errorCallback) {
  6127. this._id = bindingId;
  6128. OSF.OUtil.defineEnumerableProperty(this, "onFail", {
  6129. get: function () {
  6130. return errorCallback;
  6131. },
  6132. set: function (onError) {
  6133. var t = typeof onError;
  6134. if (t != "undefined" && t != "function") {
  6135. throw OSF.OUtil.formatString(Strings.OfficeOM.L_CallbackNotAFunction, t);
  6136. }
  6137. errorCallback = onError;
  6138. }
  6139. });
  6140. };
  6141. OSF.DDA.BindingPromise.prototype = {
  6142. _fetch: function OSF_DDA_BindingPromise$_fetch(onComplete) {
  6143. if (this.binding) {
  6144. if (onComplete)
  6145. onComplete(this.binding);
  6146. }
  6147. else {
  6148. if (!this._binding) {
  6149. var me = this;
  6150. Microsoft.Office.WebExtension.context.document.bindings.getByIdAsync(this._id, function (asyncResult) {
  6151. if (asyncResult.status == Microsoft.Office.WebExtension.AsyncResultStatus.Succeeded) {
  6152. OSF.OUtil.defineEnumerableProperty(me, "binding", {
  6153. value: asyncResult.value
  6154. });
  6155. if (onComplete)
  6156. onComplete(me.binding);
  6157. }
  6158. else {
  6159. if (me.onFail)
  6160. me.onFail(asyncResult);
  6161. }
  6162. });
  6163. }
  6164. }
  6165. return this;
  6166. },
  6167. getDataAsync: function OSF_DDA_BindingPromise$getDataAsync() {
  6168. var args = arguments;
  6169. this._fetch(function onComplete(binding) { binding.getDataAsync.apply(binding, args); });
  6170. return this;
  6171. },
  6172. setDataAsync: function OSF_DDA_BindingPromise$setDataAsync() {
  6173. var args = arguments;
  6174. this._fetch(function onComplete(binding) { binding.setDataAsync.apply(binding, args); });
  6175. return this;
  6176. },
  6177. addHandlerAsync: function OSF_DDA_BindingPromise$addHandlerAsync() {
  6178. var args = arguments;
  6179. this._fetch(function onComplete(binding) { binding.addHandlerAsync.apply(binding, args); });
  6180. return this;
  6181. },
  6182. removeHandlerAsync: function OSF_DDA_BindingPromise$removeHandlerAsync() {
  6183. var args = arguments;
  6184. this._fetch(function onComplete(binding) { binding.removeHandlerAsync.apply(binding, args); });
  6185. return this;
  6186. }
  6187. };
  6188. OSF.DDA.BindingFacade = function OSF_DDA_BindingFacade(docInstance) {
  6189. this._eventDispatches = [];
  6190. OSF.OUtil.defineEnumerableProperty(this, "document", {
  6191. value: docInstance
  6192. });
  6193. var am = OSF.DDA.AsyncMethodNames;
  6194. OSF.DDA.DispIdHost.addAsyncMethods(this, [
  6195. am.AddFromSelectionAsync,
  6196. am.AddFromNamedItemAsync,
  6197. am.GetAllAsync,
  6198. am.GetByIdAsync,
  6199. am.ReleaseByIdAsync
  6200. ]);
  6201. };
  6202. OSF.DDA.UnknownBinding = function OSF_DDA_UknonwnBinding(id, docInstance) {
  6203. OSF.OUtil.defineEnumerableProperties(this, {
  6204. "document": { value: docInstance },
  6205. "id": { value: id }
  6206. });
  6207. };
  6208. OSF.DDA.Binding = function OSF_DDA_Binding(id, docInstance) {
  6209. OSF.OUtil.defineEnumerableProperties(this, {
  6210. "document": {
  6211. value: docInstance
  6212. },
  6213. "id": {
  6214. value: id
  6215. }
  6216. });
  6217. var am = OSF.DDA.AsyncMethodNames;
  6218. OSF.DDA.DispIdHost.addAsyncMethods(this, [
  6219. am.GetDataAsync,
  6220. am.SetDataAsync
  6221. ]);
  6222. var et = Microsoft.Office.WebExtension.EventType;
  6223. var bindingEventDispatches = docInstance.bindings._eventDispatches;
  6224. if (!bindingEventDispatches[id]) {
  6225. bindingEventDispatches[id] = new OSF.EventDispatch([
  6226. et.BindingSelectionChanged,
  6227. et.BindingDataChanged
  6228. ]);
  6229. }
  6230. var eventDispatch = bindingEventDispatches[id];
  6231. OSF.DDA.DispIdHost.addEventSupport(this, eventDispatch);
  6232. };
  6233. OSF.DDA.generateBindingId = function OSF_DDA$GenerateBindingId() {
  6234. return "UnnamedBinding_" + OSF.OUtil.getUniqueId() + "_" + new Date().getTime();
  6235. };
  6236. OSF.DDA.OMFactory = OSF.DDA.OMFactory || {};
  6237. OSF.DDA.OMFactory.manufactureBinding = function OSF_DDA_OMFactory$manufactureBinding(bindingProperties, containingDocument) {
  6238. var id = bindingProperties[OSF.DDA.BindingProperties.Id];
  6239. var rows = bindingProperties[OSF.DDA.BindingProperties.RowCount];
  6240. var cols = bindingProperties[OSF.DDA.BindingProperties.ColumnCount];
  6241. var hasHeaders = bindingProperties[OSF.DDA.BindingProperties.HasHeaders];
  6242. var binding;
  6243. switch (bindingProperties[OSF.DDA.BindingProperties.Type]) {
  6244. case Microsoft.Office.WebExtension.BindingType.Text:
  6245. binding = new OSF.DDA.TextBinding(id, containingDocument);
  6246. break;
  6247. case Microsoft.Office.WebExtension.BindingType.Matrix:
  6248. binding = new OSF.DDA.MatrixBinding(id, containingDocument, rows, cols);
  6249. break;
  6250. case Microsoft.Office.WebExtension.BindingType.Table:
  6251. var isExcelApp = function () {
  6252. return (OSF.DDA.ExcelDocument)
  6253. && (Microsoft.Office.WebExtension.context.document)
  6254. && (Microsoft.Office.WebExtension.context.document instanceof OSF.DDA.ExcelDocument);
  6255. };
  6256. var tableBindingObject;
  6257. if (isExcelApp() && OSF.DDA.ExcelTableBinding) {
  6258. tableBindingObject = OSF.DDA.ExcelTableBinding;
  6259. }
  6260. else {
  6261. tableBindingObject = OSF.DDA.TableBinding;
  6262. }
  6263. binding = new tableBindingObject(id, containingDocument, rows, cols, hasHeaders);
  6264. break;
  6265. default:
  6266. binding = new OSF.DDA.UnknownBinding(id, containingDocument);
  6267. }
  6268. return binding;
  6269. };
  6270. OSF.DDA.AsyncMethodNames.addNames({
  6271. AddFromSelectionAsync: "addFromSelectionAsync",
  6272. AddFromNamedItemAsync: "addFromNamedItemAsync",
  6273. GetAllAsync: "getAllAsync",
  6274. GetByIdAsync: "getByIdAsync",
  6275. ReleaseByIdAsync: "releaseByIdAsync",
  6276. GetDataAsync: "getDataAsync",
  6277. SetDataAsync: "setDataAsync"
  6278. });
  6279. (function () {
  6280. function processBinding(bindingDescriptor) {
  6281. return OSF.DDA.OMFactory.manufactureBinding(bindingDescriptor, Microsoft.Office.WebExtension.context.document);
  6282. }
  6283. function getObjectId(obj) { return obj.id; }
  6284. function processData(dataDescriptor, caller, callArgs) {
  6285. var data = dataDescriptor[Microsoft.Office.WebExtension.Parameters.Data];
  6286. if (OSF.DDA.TableDataProperties && data && (data[OSF.DDA.TableDataProperties.TableRows] != undefined || data[OSF.DDA.TableDataProperties.TableHeaders] != undefined)) {
  6287. data = OSF.DDA.OMFactory.manufactureTableData(data);
  6288. }
  6289. data = OSF.DDA.DataCoercion.coerceData(data, callArgs[Microsoft.Office.WebExtension.Parameters.CoercionType]);
  6290. return data == undefined ? null : data;
  6291. }
  6292. OSF.DDA.AsyncMethodCalls.define({
  6293. method: OSF.DDA.AsyncMethodNames.AddFromSelectionAsync,
  6294. requiredArguments: [
  6295. {
  6296. "name": Microsoft.Office.WebExtension.Parameters.BindingType,
  6297. "enum": Microsoft.Office.WebExtension.BindingType
  6298. }
  6299. ],
  6300. supportedOptions: [{
  6301. name: Microsoft.Office.WebExtension.Parameters.Id,
  6302. value: {
  6303. "types": ["string"],
  6304. "calculate": OSF.DDA.generateBindingId
  6305. }
  6306. },
  6307. {
  6308. name: Microsoft.Office.WebExtension.Parameters.Columns,
  6309. value: {
  6310. "types": ["object"],
  6311. "defaultValue": null
  6312. }
  6313. }
  6314. ],
  6315. privateStateCallbacks: [],
  6316. onSucceeded: processBinding
  6317. });
  6318. OSF.DDA.AsyncMethodCalls.define({
  6319. method: OSF.DDA.AsyncMethodNames.AddFromNamedItemAsync,
  6320. requiredArguments: [{
  6321. "name": Microsoft.Office.WebExtension.Parameters.ItemName,
  6322. "types": ["string"]
  6323. },
  6324. {
  6325. "name": Microsoft.Office.WebExtension.Parameters.BindingType,
  6326. "enum": Microsoft.Office.WebExtension.BindingType
  6327. }
  6328. ],
  6329. supportedOptions: [{
  6330. name: Microsoft.Office.WebExtension.Parameters.Id,
  6331. value: {
  6332. "types": ["string"],
  6333. "calculate": OSF.DDA.generateBindingId
  6334. }
  6335. },
  6336. {
  6337. name: Microsoft.Office.WebExtension.Parameters.Columns,
  6338. value: {
  6339. "types": ["object"],
  6340. "defaultValue": null
  6341. }
  6342. }
  6343. ],
  6344. privateStateCallbacks: [
  6345. {
  6346. name: Microsoft.Office.WebExtension.Parameters.FailOnCollision,
  6347. value: function () { return true; }
  6348. }
  6349. ],
  6350. onSucceeded: processBinding
  6351. });
  6352. OSF.DDA.AsyncMethodCalls.define({
  6353. method: OSF.DDA.AsyncMethodNames.GetAllAsync,
  6354. requiredArguments: [],
  6355. supportedOptions: [],
  6356. privateStateCallbacks: [],
  6357. onSucceeded: function (response) { return OSF.OUtil.mapList(response[OSF.DDA.ListDescriptors.BindingList], processBinding); }
  6358. });
  6359. OSF.DDA.AsyncMethodCalls.define({
  6360. method: OSF.DDA.AsyncMethodNames.GetByIdAsync,
  6361. requiredArguments: [
  6362. {
  6363. "name": Microsoft.Office.WebExtension.Parameters.Id,
  6364. "types": ["string"]
  6365. }
  6366. ],
  6367. supportedOptions: [],
  6368. privateStateCallbacks: [],
  6369. onSucceeded: processBinding
  6370. });
  6371. OSF.DDA.AsyncMethodCalls.define({
  6372. method: OSF.DDA.AsyncMethodNames.ReleaseByIdAsync,
  6373. requiredArguments: [
  6374. {
  6375. "name": Microsoft.Office.WebExtension.Parameters.Id,
  6376. "types": ["string"]
  6377. }
  6378. ],
  6379. supportedOptions: [],
  6380. privateStateCallbacks: [],
  6381. onSucceeded: function (response, caller, callArgs) {
  6382. var id = callArgs[Microsoft.Office.WebExtension.Parameters.Id];
  6383. delete caller._eventDispatches[id];
  6384. }
  6385. });
  6386. OSF.DDA.AsyncMethodCalls.define({
  6387. method: OSF.DDA.AsyncMethodNames.GetDataAsync,
  6388. requiredArguments: [],
  6389. supportedOptions: [{
  6390. name: Microsoft.Office.WebExtension.Parameters.CoercionType,
  6391. value: {
  6392. "enum": Microsoft.Office.WebExtension.CoercionType,
  6393. "calculate": function (requiredArgs, binding) { return OSF.DDA.DataCoercion.getCoercionDefaultForBinding(binding.type); }
  6394. }
  6395. },
  6396. {
  6397. name: Microsoft.Office.WebExtension.Parameters.ValueFormat,
  6398. value: {
  6399. "enum": Microsoft.Office.WebExtension.ValueFormat,
  6400. "defaultValue": Microsoft.Office.WebExtension.ValueFormat.Unformatted
  6401. }
  6402. },
  6403. {
  6404. name: Microsoft.Office.WebExtension.Parameters.FilterType,
  6405. value: {
  6406. "enum": Microsoft.Office.WebExtension.FilterType,
  6407. "defaultValue": Microsoft.Office.WebExtension.FilterType.All
  6408. }
  6409. },
  6410. {
  6411. name: Microsoft.Office.WebExtension.Parameters.Rows,
  6412. value: {
  6413. "types": ["object", "string"],
  6414. "defaultValue": null
  6415. }
  6416. },
  6417. {
  6418. name: Microsoft.Office.WebExtension.Parameters.Columns,
  6419. value: {
  6420. "types": ["object"],
  6421. "defaultValue": null
  6422. }
  6423. },
  6424. {
  6425. name: Microsoft.Office.WebExtension.Parameters.StartRow,
  6426. value: {
  6427. "types": ["number"],
  6428. "defaultValue": 0
  6429. }
  6430. },
  6431. {
  6432. name: Microsoft.Office.WebExtension.Parameters.StartColumn,
  6433. value: {
  6434. "types": ["number"],
  6435. "defaultValue": 0
  6436. }
  6437. },
  6438. {
  6439. name: Microsoft.Office.WebExtension.Parameters.RowCount,
  6440. value: {
  6441. "types": ["number"],
  6442. "defaultValue": 0
  6443. }
  6444. },
  6445. {
  6446. name: Microsoft.Office.WebExtension.Parameters.ColumnCount,
  6447. value: {
  6448. "types": ["number"],
  6449. "defaultValue": 0
  6450. }
  6451. }
  6452. ],
  6453. checkCallArgs: function (callArgs, caller, stateInfo) {
  6454. if (callArgs[Microsoft.Office.WebExtension.Parameters.StartRow] == 0 &&
  6455. callArgs[Microsoft.Office.WebExtension.Parameters.StartColumn] == 0 &&
  6456. callArgs[Microsoft.Office.WebExtension.Parameters.RowCount] == 0 &&
  6457. callArgs[Microsoft.Office.WebExtension.Parameters.ColumnCount] == 0) {
  6458. delete callArgs[Microsoft.Office.WebExtension.Parameters.StartRow];
  6459. delete callArgs[Microsoft.Office.WebExtension.Parameters.StartColumn];
  6460. delete callArgs[Microsoft.Office.WebExtension.Parameters.RowCount];
  6461. delete callArgs[Microsoft.Office.WebExtension.Parameters.ColumnCount];
  6462. }
  6463. if (callArgs[Microsoft.Office.WebExtension.Parameters.CoercionType] != OSF.DDA.DataCoercion.getCoercionDefaultForBinding(caller.type) &&
  6464. (callArgs[Microsoft.Office.WebExtension.Parameters.StartRow] ||
  6465. callArgs[Microsoft.Office.WebExtension.Parameters.StartColumn] ||
  6466. callArgs[Microsoft.Office.WebExtension.Parameters.RowCount] ||
  6467. callArgs[Microsoft.Office.WebExtension.Parameters.ColumnCount])) {
  6468. throw OSF.DDA.ErrorCodeManager.errorCodes.ooeCoercionTypeNotMatchBinding;
  6469. }
  6470. return callArgs;
  6471. },
  6472. privateStateCallbacks: [
  6473. {
  6474. name: Microsoft.Office.WebExtension.Parameters.Id,
  6475. value: getObjectId
  6476. }
  6477. ],
  6478. onSucceeded: processData
  6479. });
  6480. OSF.DDA.AsyncMethodCalls.define({
  6481. method: OSF.DDA.AsyncMethodNames.SetDataAsync,
  6482. requiredArguments: [
  6483. {
  6484. "name": Microsoft.Office.WebExtension.Parameters.Data,
  6485. "types": ["string", "object", "number", "boolean"]
  6486. }
  6487. ],
  6488. supportedOptions: [{
  6489. name: Microsoft.Office.WebExtension.Parameters.CoercionType,
  6490. value: {
  6491. "enum": Microsoft.Office.WebExtension.CoercionType,
  6492. "calculate": function (requiredArgs) { return OSF.DDA.DataCoercion.determineCoercionType(requiredArgs[Microsoft.Office.WebExtension.Parameters.Data]); }
  6493. }
  6494. },
  6495. {
  6496. name: Microsoft.Office.WebExtension.Parameters.Rows,
  6497. value: {
  6498. "types": ["object", "string"],
  6499. "defaultValue": null
  6500. }
  6501. },
  6502. {
  6503. name: Microsoft.Office.WebExtension.Parameters.Columns,
  6504. value: {
  6505. "types": ["object"],
  6506. "defaultValue": null
  6507. }
  6508. },
  6509. {
  6510. name: Microsoft.Office.WebExtension.Parameters.StartRow,
  6511. value: {
  6512. "types": ["number"],
  6513. "defaultValue": 0
  6514. }
  6515. },
  6516. {
  6517. name: Microsoft.Office.WebExtension.Parameters.StartColumn,
  6518. value: {
  6519. "types": ["number"],
  6520. "defaultValue": 0
  6521. }
  6522. }
  6523. ],
  6524. checkCallArgs: function (callArgs, caller, stateInfo) {
  6525. if (callArgs[Microsoft.Office.WebExtension.Parameters.StartRow] == 0 &&
  6526. callArgs[Microsoft.Office.WebExtension.Parameters.StartColumn] == 0) {
  6527. delete callArgs[Microsoft.Office.WebExtension.Parameters.StartRow];
  6528. delete callArgs[Microsoft.Office.WebExtension.Parameters.StartColumn];
  6529. }
  6530. if (callArgs[Microsoft.Office.WebExtension.Parameters.CoercionType] != OSF.DDA.DataCoercion.getCoercionDefaultForBinding(caller.type) &&
  6531. (callArgs[Microsoft.Office.WebExtension.Parameters.StartRow] ||
  6532. callArgs[Microsoft.Office.WebExtension.Parameters.StartColumn])) {
  6533. throw OSF.DDA.ErrorCodeManager.errorCodes.ooeCoercionTypeNotMatchBinding;
  6534. }
  6535. return callArgs;
  6536. },
  6537. privateStateCallbacks: [
  6538. {
  6539. name: Microsoft.Office.WebExtension.Parameters.Id,
  6540. value: getObjectId
  6541. }
  6542. ]
  6543. });
  6544. })();
  6545. OSF.OUtil.augmentList(OSF.DDA.PropertyDescriptors, { TableDataProperties: "TableDataProperties" });
  6546. OSF.OUtil.augmentList(OSF.DDA.BindingProperties, {
  6547. RowCount: "BindingRowCount",
  6548. ColumnCount: "BindingColumnCount",
  6549. HasHeaders: "HasHeaders"
  6550. });
  6551. OSF.DDA.TableDataProperties = {
  6552. TableRows: "TableRows",
  6553. TableHeaders: "TableHeaders"
  6554. };
  6555. OSF.DDA.TableBinding = function OSF_DDA_TableBinding(id, docInstance, rows, cols, hasHeaders) {
  6556. OSF.DDA.TableBinding.uber.constructor.call(this, id, docInstance);
  6557. OSF.OUtil.defineEnumerableProperties(this, {
  6558. "type": {
  6559. value: Microsoft.Office.WebExtension.BindingType.Table
  6560. },
  6561. "rowCount": {
  6562. value: rows ? rows : 0
  6563. },
  6564. "columnCount": {
  6565. value: cols ? cols : 0
  6566. },
  6567. "hasHeaders": {
  6568. value: hasHeaders ? hasHeaders : false
  6569. }
  6570. });
  6571. var am = OSF.DDA.AsyncMethodNames;
  6572. OSF.DDA.DispIdHost.addAsyncMethods(this, [
  6573. am.AddRowsAsync,
  6574. am.AddColumnsAsync,
  6575. am.DeleteAllDataValuesAsync
  6576. ]);
  6577. };
  6578. OSF.OUtil.extend(OSF.DDA.TableBinding, OSF.DDA.Binding);
  6579. OSF.DDA.AsyncMethodNames.addNames({
  6580. AddRowsAsync: "addRowsAsync",
  6581. AddColumnsAsync: "addColumnsAsync",
  6582. DeleteAllDataValuesAsync: "deleteAllDataValuesAsync"
  6583. });
  6584. (function () {
  6585. function getObjectId(obj) { return obj.id; }
  6586. OSF.DDA.AsyncMethodCalls.define({
  6587. method: OSF.DDA.AsyncMethodNames.AddRowsAsync,
  6588. requiredArguments: [
  6589. {
  6590. "name": Microsoft.Office.WebExtension.Parameters.Data,
  6591. "types": ["object"]
  6592. }
  6593. ],
  6594. supportedOptions: [],
  6595. privateStateCallbacks: [
  6596. {
  6597. name: Microsoft.Office.WebExtension.Parameters.Id,
  6598. value: getObjectId
  6599. }
  6600. ]
  6601. });
  6602. OSF.DDA.AsyncMethodCalls.define({
  6603. method: OSF.DDA.AsyncMethodNames.AddColumnsAsync,
  6604. requiredArguments: [
  6605. {
  6606. "name": Microsoft.Office.WebExtension.Parameters.Data,
  6607. "types": ["object"]
  6608. }
  6609. ],
  6610. supportedOptions: [],
  6611. privateStateCallbacks: [
  6612. {
  6613. name: Microsoft.Office.WebExtension.Parameters.Id,
  6614. value: getObjectId
  6615. }
  6616. ]
  6617. });
  6618. OSF.DDA.AsyncMethodCalls.define({
  6619. method: OSF.DDA.AsyncMethodNames.DeleteAllDataValuesAsync,
  6620. requiredArguments: [],
  6621. supportedOptions: [],
  6622. privateStateCallbacks: [
  6623. {
  6624. name: Microsoft.Office.WebExtension.Parameters.Id,
  6625. value: getObjectId
  6626. }
  6627. ]
  6628. });
  6629. })();
  6630. OSF.DDA.WAC.Delegate.ParameterMap.define({
  6631. type: OSF.DDA.WAC.UniqueArguments.GetData,
  6632. toHost: [
  6633. { name: Microsoft.Office.WebExtension.Parameters.Id, value: "BindingId" },
  6634. { name: Microsoft.Office.WebExtension.Parameters.CoercionType, value: "CoerceType" },
  6635. { name: Microsoft.Office.WebExtension.Parameters.ValueFormat, value: "ValueFormat" },
  6636. { name: Microsoft.Office.WebExtension.Parameters.FilterType, value: "FilterType" },
  6637. { name: Microsoft.Office.WebExtension.Parameters.Rows, value: "Rows" },
  6638. { name: Microsoft.Office.WebExtension.Parameters.Columns, value: "Columns" },
  6639. { name: Microsoft.Office.WebExtension.Parameters.StartRow, value: "StartRow" },
  6640. { name: Microsoft.Office.WebExtension.Parameters.StartColumn, value: "StartCol" },
  6641. { name: Microsoft.Office.WebExtension.Parameters.RowCount, value: "RowCount" },
  6642. { name: Microsoft.Office.WebExtension.Parameters.ColumnCount, value: "ColCount" }
  6643. ]
  6644. });
  6645. OSF.DDA.WAC.Delegate.ParameterMap.define({
  6646. type: OSF.DDA.WAC.UniqueArguments.SetData,
  6647. toHost: [
  6648. { name: Microsoft.Office.WebExtension.Parameters.Id, value: "BindingId" },
  6649. { name: Microsoft.Office.WebExtension.Parameters.CoercionType, value: "CoerceType" },
  6650. { name: Microsoft.Office.WebExtension.Parameters.Data, value: OSF.DDA.WAC.UniqueArguments.Data },
  6651. { name: Microsoft.Office.WebExtension.Parameters.Rows, value: "Rows" },
  6652. { name: Microsoft.Office.WebExtension.Parameters.Columns, value: "Columns" },
  6653. { name: Microsoft.Office.WebExtension.Parameters.StartRow, value: "StartRow" },
  6654. { name: Microsoft.Office.WebExtension.Parameters.StartColumn, value: "StartCol" },
  6655. { name: Microsoft.Office.WebExtension.Parameters.ImageLeft, value: "ImageLeft" },
  6656. { name: Microsoft.Office.WebExtension.Parameters.ImageTop, value: "ImageTop" },
  6657. { name: Microsoft.Office.WebExtension.Parameters.ImageWidth, value: "ImageWidth" },
  6658. { name: Microsoft.Office.WebExtension.Parameters.ImageHeight, value: "ImageHeight" }
  6659. ]
  6660. });
  6661. OSF.DDA.WAC.Delegate.ParameterMap.addComplexType(OSF.DDA.PropertyDescriptors.BindingProperties);
  6662. OSF.DDA.WAC.Delegate.ParameterMap.define({
  6663. type: OSF.DDA.WAC.UniqueArguments.BindingRequest,
  6664. toHost: [
  6665. { name: Microsoft.Office.WebExtension.Parameters.ItemName, value: "ItemName" },
  6666. { name: Microsoft.Office.WebExtension.Parameters.Id, value: "BindingId" },
  6667. { name: Microsoft.Office.WebExtension.Parameters.BindingType, value: "BindingType" },
  6668. { name: Microsoft.Office.WebExtension.Parameters.PromptText, value: "PromptText" },
  6669. { name: Microsoft.Office.WebExtension.Parameters.Columns, value: "Columns" },
  6670. { name: Microsoft.Office.WebExtension.Parameters.SampleData, value: "SampleData" },
  6671. { name: Microsoft.Office.WebExtension.Parameters.FailOnCollision, value: "FailOnCollision" }
  6672. ]
  6673. });
  6674. OSF.DDA.WAC.Delegate.ParameterMap.define({
  6675. type: Microsoft.Office.WebExtension.Parameters.BindingType,
  6676. toHost: [
  6677. { name: Microsoft.Office.WebExtension.BindingType.Text, value: 2 },
  6678. { name: Microsoft.Office.WebExtension.BindingType.Matrix, value: 3 },
  6679. { name: Microsoft.Office.WebExtension.BindingType.Table, value: 1 }
  6680. ],
  6681. invertible: true
  6682. });
  6683. OSF.DDA.WAC.Delegate.ParameterMap.define({
  6684. type: OSF.DDA.PropertyDescriptors.BindingProperties,
  6685. fromHost: [
  6686. { name: OSF.DDA.BindingProperties.Id, value: "Name" },
  6687. { name: OSF.DDA.BindingProperties.Type, value: "BindingType" },
  6688. { name: OSF.DDA.BindingProperties.RowCount, value: "RowCount" },
  6689. { name: OSF.DDA.BindingProperties.ColumnCount, value: "ColCount" },
  6690. { name: OSF.DDA.BindingProperties.HasHeaders, value: "HasHeaders" }
  6691. ]
  6692. });
  6693. OSF.DDA.WAC.Delegate.ParameterMap.define({
  6694. type: OSF.DDA.WAC.UniqueArguments.SingleBindingResponse,
  6695. fromHost: [
  6696. { name: OSF.DDA.PropertyDescriptors.BindingProperties, value: 0 }
  6697. ]
  6698. });
  6699. OSF.DDA.WAC.Delegate.ParameterMap.define({
  6700. type: OSF.DDA.MethodDispId.dispidAddBindingFromSelectionMethod,
  6701. fromHost: [
  6702. { name: OSF.DDA.WAC.UniqueArguments.SingleBindingResponse, value: OSF.DDA.WAC.UniqueArguments.BindingResponse }
  6703. ],
  6704. toHost: [
  6705. { name: OSF.DDA.WAC.UniqueArguments.BindingRequest, value: OSF.DDA.WAC.Delegate.ParameterMap.self }
  6706. ]
  6707. });
  6708. OSF.DDA.WAC.Delegate.ParameterMap.define({
  6709. type: OSF.DDA.MethodDispId.dispidAddBindingFromNamedItemMethod,
  6710. fromHost: [
  6711. { name: OSF.DDA.WAC.UniqueArguments.SingleBindingResponse, value: OSF.DDA.WAC.UniqueArguments.BindingResponse }
  6712. ],
  6713. toHost: [
  6714. { name: OSF.DDA.WAC.UniqueArguments.BindingRequest, value: OSF.DDA.WAC.Delegate.ParameterMap.self }
  6715. ]
  6716. });
  6717. OSF.DDA.WAC.Delegate.ParameterMap.define({
  6718. type: OSF.DDA.MethodDispId.dispidReleaseBindingMethod,
  6719. toHost: [
  6720. { name: OSF.DDA.WAC.UniqueArguments.BindingRequest, value: OSF.DDA.WAC.Delegate.ParameterMap.self }
  6721. ]
  6722. });
  6723. OSF.DDA.WAC.Delegate.ParameterMap.define({
  6724. type: OSF.DDA.MethodDispId.dispidGetBindingMethod,
  6725. fromHost: [
  6726. { name: OSF.DDA.WAC.UniqueArguments.SingleBindingResponse, value: OSF.DDA.WAC.UniqueArguments.BindingResponse }
  6727. ],
  6728. toHost: [
  6729. { name: OSF.DDA.WAC.UniqueArguments.BindingRequest, value: OSF.DDA.WAC.Delegate.ParameterMap.self }
  6730. ]
  6731. });
  6732. OSF.DDA.WAC.Delegate.ParameterMap.define({
  6733. type: OSF.DDA.MethodDispId.dispidGetAllBindingsMethod,
  6734. fromHost: [
  6735. { name: OSF.DDA.ListDescriptors.BindingList, value: OSF.DDA.WAC.UniqueArguments.BindingResponse }
  6736. ]
  6737. });
  6738. OSF.DDA.WAC.Delegate.ParameterMap.define({
  6739. type: OSF.DDA.MethodDispId.dispidGetBindingDataMethod,
  6740. fromHost: [
  6741. { name: Microsoft.Office.WebExtension.Parameters.Data, value: OSF.DDA.WAC.UniqueArguments.Data }
  6742. ],
  6743. toHost: [
  6744. { name: OSF.DDA.WAC.UniqueArguments.GetData, value: OSF.DDA.WAC.Delegate.ParameterMap.self }
  6745. ]
  6746. });
  6747. OSF.DDA.WAC.Delegate.ParameterMap.define({
  6748. type: OSF.DDA.MethodDispId.dispidSetBindingDataMethod,
  6749. toHost: [
  6750. { name: OSF.DDA.WAC.UniqueArguments.SetData, value: OSF.DDA.WAC.Delegate.ParameterMap.self }
  6751. ]
  6752. });
  6753. OSF.DDA.WAC.Delegate.ParameterMap.define({
  6754. type: OSF.DDA.MethodDispId.dispidAddRowsMethod,
  6755. toHost: [
  6756. { name: OSF.DDA.WAC.UniqueArguments.AddRowsColumns, value: OSF.DDA.WAC.Delegate.ParameterMap.self }
  6757. ]
  6758. });
  6759. OSF.DDA.WAC.Delegate.ParameterMap.define({
  6760. type: OSF.DDA.MethodDispId.dispidAddColumnsMethod,
  6761. toHost: [
  6762. { name: OSF.DDA.WAC.UniqueArguments.AddRowsColumns, value: OSF.DDA.WAC.Delegate.ParameterMap.self }
  6763. ]
  6764. });
  6765. OSF.DDA.WAC.Delegate.ParameterMap.define({
  6766. type: OSF.DDA.MethodDispId.dispidClearAllRowsMethod,
  6767. toHost: [
  6768. { name: OSF.DDA.WAC.UniqueArguments.BindingRequest, value: OSF.DDA.WAC.Delegate.ParameterMap.self }
  6769. ]
  6770. });
  6771. OSF.DDA.WAC.Delegate.ParameterMap.define({
  6772. type: OSF.DDA.WAC.UniqueArguments.AddRowsColumns,
  6773. toHost: [
  6774. { name: Microsoft.Office.WebExtension.Parameters.Id, value: "BindingId" },
  6775. { name: Microsoft.Office.WebExtension.Parameters.Data, value: OSF.DDA.WAC.UniqueArguments.Data }
  6776. ]
  6777. });
  6778. OSF.DDA.WAC.Delegate.ParameterMap.define({
  6779. type: OSF.DDA.PropertyDescriptors.Subset,
  6780. fromHost: [
  6781. { name: Microsoft.Office.WebExtension.Parameters.StartRow, value: "StartRow" },
  6782. { name: Microsoft.Office.WebExtension.Parameters.StartColumn, value: "StartCol" },
  6783. { name: Microsoft.Office.WebExtension.Parameters.RowCount, value: "RowCount" },
  6784. { name: Microsoft.Office.WebExtension.Parameters.ColumnCount, value: "ColCount" }
  6785. ]
  6786. });
  6787. OSF.DDA.AsyncMethodNames.addNames({
  6788. GetSelectedDataAsync: "getSelectedDataAsync",
  6789. SetSelectedDataAsync: "setSelectedDataAsync"
  6790. });
  6791. (function () {
  6792. function processData(dataDescriptor, caller, callArgs) {
  6793. var data = dataDescriptor[Microsoft.Office.WebExtension.Parameters.Data];
  6794. if (OSF.DDA.TableDataProperties && data && (data[OSF.DDA.TableDataProperties.TableRows] != undefined || data[OSF.DDA.TableDataProperties.TableHeaders] != undefined)) {
  6795. data = OSF.DDA.OMFactory.manufactureTableData(data);
  6796. }
  6797. data = OSF.DDA.DataCoercion.coerceData(data, callArgs[Microsoft.Office.WebExtension.Parameters.CoercionType]);
  6798. return data == undefined ? null : data;
  6799. }
  6800. OSF.DDA.AsyncMethodCalls.define({
  6801. method: OSF.DDA.AsyncMethodNames.GetSelectedDataAsync,
  6802. requiredArguments: [
  6803. {
  6804. "name": Microsoft.Office.WebExtension.Parameters.CoercionType,
  6805. "enum": Microsoft.Office.WebExtension.CoercionType
  6806. }
  6807. ],
  6808. supportedOptions: [
  6809. {
  6810. name: Microsoft.Office.WebExtension.Parameters.ValueFormat,
  6811. value: {
  6812. "enum": Microsoft.Office.WebExtension.ValueFormat,
  6813. "defaultValue": Microsoft.Office.WebExtension.ValueFormat.Unformatted
  6814. }
  6815. },
  6816. {
  6817. name: Microsoft.Office.WebExtension.Parameters.FilterType,
  6818. value: {
  6819. "enum": Microsoft.Office.WebExtension.FilterType,
  6820. "defaultValue": Microsoft.Office.WebExtension.FilterType.All
  6821. }
  6822. }
  6823. ],
  6824. privateStateCallbacks: [],
  6825. onSucceeded: processData
  6826. });
  6827. OSF.DDA.AsyncMethodCalls.define({
  6828. method: OSF.DDA.AsyncMethodNames.SetSelectedDataAsync,
  6829. requiredArguments: [
  6830. {
  6831. "name": Microsoft.Office.WebExtension.Parameters.Data,
  6832. "types": ["string", "object", "number", "boolean"]
  6833. }
  6834. ],
  6835. supportedOptions: [
  6836. {
  6837. name: Microsoft.Office.WebExtension.Parameters.CoercionType,
  6838. value: {
  6839. "enum": Microsoft.Office.WebExtension.CoercionType,
  6840. "calculate": function (requiredArgs) {
  6841. return OSF.DDA.DataCoercion.determineCoercionType(requiredArgs[Microsoft.Office.WebExtension.Parameters.Data]);
  6842. }
  6843. }
  6844. },
  6845. {
  6846. name: Microsoft.Office.WebExtension.Parameters.ImageLeft,
  6847. value: {
  6848. "types": ["number", "boolean"],
  6849. "defaultValue": false
  6850. }
  6851. },
  6852. {
  6853. name: Microsoft.Office.WebExtension.Parameters.ImageTop,
  6854. value: {
  6855. "types": ["number", "boolean"],
  6856. "defaultValue": false
  6857. }
  6858. },
  6859. {
  6860. name: Microsoft.Office.WebExtension.Parameters.ImageWidth,
  6861. value: {
  6862. "types": ["number", "boolean"],
  6863. "defaultValue": false
  6864. }
  6865. },
  6866. {
  6867. name: Microsoft.Office.WebExtension.Parameters.ImageHeight,
  6868. value: {
  6869. "types": ["number", "boolean"],
  6870. "defaultValue": false
  6871. }
  6872. }
  6873. ],
  6874. privateStateCallbacks: []
  6875. });
  6876. })();
  6877. OSF.DDA.WAC.Delegate.ParameterMap.define({
  6878. type: OSF.DDA.MethodDispId.dispidGetSelectedDataMethod,
  6879. fromHost: [
  6880. { name: Microsoft.Office.WebExtension.Parameters.Data, value: OSF.DDA.WAC.UniqueArguments.Data }
  6881. ],
  6882. toHost: [
  6883. { name: OSF.DDA.WAC.UniqueArguments.GetData, value: OSF.DDA.WAC.Delegate.ParameterMap.self }
  6884. ]
  6885. });
  6886. OSF.DDA.WAC.Delegate.ParameterMap.define({
  6887. type: OSF.DDA.MethodDispId.dispidSetSelectedDataMethod,
  6888. toHost: [
  6889. { name: OSF.DDA.WAC.UniqueArguments.SetData, value: OSF.DDA.WAC.Delegate.ParameterMap.self }
  6890. ]
  6891. });
  6892. Microsoft.Office.WebExtension.EventType = {};
  6893. OSF.EventDispatch = function OSF_EventDispatch(eventTypes) {
  6894. this._eventHandlers = {};
  6895. this._queuedEventsArgs = {};
  6896. for (var entry in eventTypes) {
  6897. var eventType = eventTypes[entry];
  6898. this._eventHandlers[eventType] = [];
  6899. this._queuedEventsArgs[eventType] = [];
  6900. }
  6901. };
  6902. OSF.EventDispatch.prototype = {
  6903. getSupportedEvents: function OSF_EventDispatch$getSupportedEvents() {
  6904. var events = [];
  6905. for (var eventName in this._eventHandlers)
  6906. events.push(eventName);
  6907. return events;
  6908. },
  6909. supportsEvent: function OSF_EventDispatch$supportsEvent(event) {
  6910. var isSupported = false;
  6911. for (var eventName in this._eventHandlers) {
  6912. if (event == eventName) {
  6913. isSupported = true;
  6914. break;
  6915. }
  6916. }
  6917. return isSupported;
  6918. },
  6919. hasEventHandler: function OSF_EventDispatch$hasEventHandler(eventType, handler) {
  6920. var handlers = this._eventHandlers[eventType];
  6921. if (handlers && handlers.length > 0) {
  6922. for (var h in handlers) {
  6923. if (handlers[h] === handler)
  6924. return true;
  6925. }
  6926. }
  6927. return false;
  6928. },
  6929. addEventHandler: function OSF_EventDispatch$addEventHandler(eventType, handler) {
  6930. if (typeof handler != "function") {
  6931. return false;
  6932. }
  6933. var handlers = this._eventHandlers[eventType];
  6934. if (handlers && !this.hasEventHandler(eventType, handler)) {
  6935. handlers.push(handler);
  6936. return true;
  6937. }
  6938. else {
  6939. return false;
  6940. }
  6941. },
  6942. addEventHandlerAndFireQueuedEvent: function OSF_EventDispatch$addEventHandlerAndFireQueuedEvent(eventType, handler) {
  6943. var handlers = this._eventHandlers[eventType];
  6944. var isFirstHandler = handlers.length == 0;
  6945. var succeed = this.addEventHandler(eventType, handler);
  6946. if (isFirstHandler && succeed) {
  6947. this.fireQueuedEvent(eventType);
  6948. }
  6949. return succeed;
  6950. },
  6951. removeEventHandler: function OSF_EventDispatch$removeEventHandler(eventType, handler) {
  6952. var handlers = this._eventHandlers[eventType];
  6953. if (handlers && handlers.length > 0) {
  6954. for (var index = 0; index < handlers.length; index++) {
  6955. if (handlers[index] === handler) {
  6956. handlers.splice(index, 1);
  6957. return true;
  6958. }
  6959. }
  6960. }
  6961. return false;
  6962. },
  6963. clearEventHandlers: function OSF_EventDispatch$clearEventHandlers(eventType) {
  6964. if (typeof this._eventHandlers[eventType] != "undefined" && this._eventHandlers[eventType].length > 0) {
  6965. this._eventHandlers[eventType] = [];
  6966. return true;
  6967. }
  6968. return false;
  6969. },
  6970. getEventHandlerCount: function OSF_EventDispatch$getEventHandlerCount(eventType) {
  6971. return this._eventHandlers[eventType] != undefined ? this._eventHandlers[eventType].length : -1;
  6972. },
  6973. fireEvent: function OSF_EventDispatch$fireEvent(eventArgs) {
  6974. if (eventArgs.type == undefined)
  6975. return false;
  6976. var eventType = eventArgs.type;
  6977. if (eventType && this._eventHandlers[eventType]) {
  6978. var eventHandlers = this._eventHandlers[eventType];
  6979. for (var handler in eventHandlers)
  6980. eventHandlers[handler](eventArgs);
  6981. return true;
  6982. }
  6983. else {
  6984. return false;
  6985. }
  6986. },
  6987. fireOrQueueEvent: function OSF_EventDispatch$fireOrQueueEvent(eventArgs) {
  6988. var eventType = eventArgs.type;
  6989. if (eventType && this._eventHandlers[eventType]) {
  6990. var eventHandlers = this._eventHandlers[eventType];
  6991. var queuedEvents = this._queuedEventsArgs[eventType];
  6992. if (eventHandlers.length == 0) {
  6993. queuedEvents.push(eventArgs);
  6994. }
  6995. else {
  6996. this.fireEvent(eventArgs);
  6997. }
  6998. return true;
  6999. }
  7000. else {
  7001. return false;
  7002. }
  7003. },
  7004. fireQueuedEvent: function OSF_EventDispatch$queueEvent(eventType) {
  7005. if (eventType && this._eventHandlers[eventType]) {
  7006. var eventHandlers = this._eventHandlers[eventType];
  7007. var queuedEvents = this._queuedEventsArgs[eventType];
  7008. if (eventHandlers.length > 0) {
  7009. var eventHandler = eventHandlers[0];
  7010. while (queuedEvents.length > 0) {
  7011. var eventArgs = queuedEvents.shift();
  7012. eventHandler(eventArgs);
  7013. }
  7014. return true;
  7015. }
  7016. }
  7017. return false;
  7018. }
  7019. };
  7020. OSF.DDA.OMFactory = OSF.DDA.OMFactory || {};
  7021. OSF.DDA.OMFactory.manufactureEventArgs = function OSF_DDA_OMFactory$manufactureEventArgs(eventType, target, eventProperties) {
  7022. var args;
  7023. switch (eventType) {
  7024. case Microsoft.Office.WebExtension.EventType.DocumentSelectionChanged:
  7025. args = new OSF.DDA.DocumentSelectionChangedEventArgs(target);
  7026. break;
  7027. case Microsoft.Office.WebExtension.EventType.BindingSelectionChanged:
  7028. args = new OSF.DDA.BindingSelectionChangedEventArgs(this.manufactureBinding(eventProperties, target.document), eventProperties[OSF.DDA.PropertyDescriptors.Subset]);
  7029. break;
  7030. case Microsoft.Office.WebExtension.EventType.BindingDataChanged:
  7031. args = new OSF.DDA.BindingDataChangedEventArgs(this.manufactureBinding(eventProperties, target.document));
  7032. break;
  7033. case Microsoft.Office.WebExtension.EventType.SettingsChanged:
  7034. args = new OSF.DDA.SettingsChangedEventArgs(target);
  7035. break;
  7036. case Microsoft.Office.WebExtension.EventType.ActiveViewChanged:
  7037. args = new OSF.DDA.ActiveViewChangedEventArgs(eventProperties);
  7038. break;
  7039. case Microsoft.Office.WebExtension.EventType.OfficeThemeChanged:
  7040. args = new OSF.DDA.Theming.OfficeThemeChangedEventArgs(eventProperties);
  7041. break;
  7042. case Microsoft.Office.WebExtension.EventType.DocumentThemeChanged:
  7043. args = new OSF.DDA.Theming.DocumentThemeChangedEventArgs(eventProperties);
  7044. break;
  7045. case Microsoft.Office.WebExtension.EventType.AppCommandInvoked:
  7046. args = OSF.DDA.AppCommand.AppCommandInvokedEventArgs.create(eventProperties);
  7047. break;
  7048. case Microsoft.Office.WebExtension.EventType.DataNodeInserted:
  7049. args = new OSF.DDA.NodeInsertedEventArgs(this.manufactureDataNode(eventProperties[OSF.DDA.DataNodeEventProperties.NewNode]), eventProperties[OSF.DDA.DataNodeEventProperties.InUndoRedo]);
  7050. break;
  7051. case Microsoft.Office.WebExtension.EventType.DataNodeReplaced:
  7052. args = new OSF.DDA.NodeReplacedEventArgs(this.manufactureDataNode(eventProperties[OSF.DDA.DataNodeEventProperties.OldNode]), this.manufactureDataNode(eventProperties[OSF.DDA.DataNodeEventProperties.NewNode]), eventProperties[OSF.DDA.DataNodeEventProperties.InUndoRedo]);
  7053. break;
  7054. case Microsoft.Office.WebExtension.EventType.DataNodeDeleted:
  7055. args = new OSF.DDA.NodeDeletedEventArgs(this.manufactureDataNode(eventProperties[OSF.DDA.DataNodeEventProperties.OldNode]), this.manufactureDataNode(eventProperties[OSF.DDA.DataNodeEventProperties.NextSiblingNode]), eventProperties[OSF.DDA.DataNodeEventProperties.InUndoRedo]);
  7056. break;
  7057. case Microsoft.Office.WebExtension.EventType.TaskSelectionChanged:
  7058. args = new OSF.DDA.TaskSelectionChangedEventArgs(target);
  7059. break;
  7060. case Microsoft.Office.WebExtension.EventType.ResourceSelectionChanged:
  7061. args = new OSF.DDA.ResourceSelectionChangedEventArgs(target);
  7062. break;
  7063. case Microsoft.Office.WebExtension.EventType.ViewSelectionChanged:
  7064. args = new OSF.DDA.ViewSelectionChangedEventArgs(target);
  7065. break;
  7066. case Microsoft.Office.WebExtension.EventType.DialogMessageReceived:
  7067. args = new OSF.DDA.DialogEventArgs(eventProperties);
  7068. break;
  7069. case Microsoft.Office.WebExtension.EventType.DialogParentMessageReceived:
  7070. args = new OSF.DDA.DialogParentEventArgs(eventProperties);
  7071. break;
  7072. case Microsoft.Office.WebExtension.EventType.ItemChanged:
  7073. if (OSF._OfficeAppFactory.getHostInfo()["hostType"] == "outlook" || OSF._OfficeAppFactory.getHostInfo()["hostType"] == "outlookwebapp") {
  7074. args = new OSF.DDA.OlkItemSelectedChangedEventArgs(eventProperties);
  7075. target.initialize(args["initialData"]);
  7076. target.setCurrentItemNumber(args["itemNumber"].itemNumber);
  7077. }
  7078. else {
  7079. throw OsfMsAjaxFactory.msAjaxError.argument(Microsoft.Office.WebExtension.Parameters.EventType, OSF.OUtil.formatString(Strings.OfficeOM.L_NotSupportedEventType, eventType));
  7080. }
  7081. break;
  7082. default:
  7083. throw OsfMsAjaxFactory.msAjaxError.argument(Microsoft.Office.WebExtension.Parameters.EventType, OSF.OUtil.formatString(Strings.OfficeOM.L_NotSupportedEventType, eventType));
  7084. }
  7085. return args;
  7086. };
  7087. OSF.DDA.AsyncMethodNames.addNames({
  7088. AddHandlerAsync: "addHandlerAsync",
  7089. RemoveHandlerAsync: "removeHandlerAsync"
  7090. });
  7091. OSF.DDA.AsyncMethodCalls.define({
  7092. method: OSF.DDA.AsyncMethodNames.AddHandlerAsync,
  7093. requiredArguments: [{
  7094. "name": Microsoft.Office.WebExtension.Parameters.EventType,
  7095. "enum": Microsoft.Office.WebExtension.EventType,
  7096. "verify": function (eventType, caller, eventDispatch) { return eventDispatch.supportsEvent(eventType); }
  7097. },
  7098. {
  7099. "name": Microsoft.Office.WebExtension.Parameters.Handler,
  7100. "types": ["function"]
  7101. }
  7102. ],
  7103. supportedOptions: [],
  7104. privateStateCallbacks: []
  7105. });
  7106. OSF.DDA.AsyncMethodCalls.define({
  7107. method: OSF.DDA.AsyncMethodNames.RemoveHandlerAsync,
  7108. requiredArguments: [
  7109. {
  7110. "name": Microsoft.Office.WebExtension.Parameters.EventType,
  7111. "enum": Microsoft.Office.WebExtension.EventType,
  7112. "verify": function (eventType, caller, eventDispatch) { return eventDispatch.supportsEvent(eventType); }
  7113. }
  7114. ],
  7115. supportedOptions: [
  7116. {
  7117. name: Microsoft.Office.WebExtension.Parameters.Handler,
  7118. value: {
  7119. "types": ["function", "object"],
  7120. "defaultValue": null
  7121. }
  7122. }
  7123. ],
  7124. privateStateCallbacks: []
  7125. });
  7126. OSF.OUtil.augmentList(OSF.DDA.EventDescriptors, { ActiveViewChangedEvent: "ActiveViewChangedEvent" });
  7127. Microsoft.Office.WebExtension.ActiveView = {
  7128. Read: "read",
  7129. Edit: "edit"
  7130. };
  7131. OSF.OUtil.augmentList(Microsoft.Office.WebExtension.EventType, {
  7132. ActiveViewChanged: "activeViewChanged"
  7133. });
  7134. OSF.DDA.AsyncMethodNames.addNames({
  7135. GetActiveViewAsync: "getActiveViewAsync"
  7136. });
  7137. OSF.DDA.AsyncMethodCalls.define({
  7138. method: OSF.DDA.AsyncMethodNames.GetActiveViewAsync,
  7139. requiredArguments: [],
  7140. supportedOptions: [],
  7141. privateStateCallbacks: [],
  7142. onSucceeded: function (response) {
  7143. var data = response[Microsoft.Office.WebExtension.Parameters.ActiveView];
  7144. return data == undefined ? null : data;
  7145. }
  7146. });
  7147. OSF.DDA.ActiveViewChangedEventArgs = function OSF_DDA_ActiveViewChangedEventArgs(activeView) {
  7148. OSF.OUtil.defineEnumerableProperties(this, {
  7149. "type": {
  7150. value: Microsoft.Office.WebExtension.EventType.ActiveViewChanged
  7151. },
  7152. "activeView": {
  7153. value: activeView.activeView
  7154. }
  7155. });
  7156. };
  7157. OSF.DDA.WAC.Delegate.ParameterMap.define({
  7158. type: OSF.DDA.MethodDispId.dispidGetActiveViewMethod,
  7159. fromHost: [
  7160. { name: Microsoft.Office.WebExtension.Parameters.ActiveView, value: Microsoft.Office.WebExtension.Parameters.Data }
  7161. ]
  7162. });
  7163. Microsoft.Office.WebExtension.GoToType = {
  7164. Binding: "binding",
  7165. NamedItem: "namedItem",
  7166. Slide: "slide",
  7167. Index: "index"
  7168. };
  7169. Microsoft.Office.WebExtension.SelectionMode = {
  7170. Default: "default",
  7171. Selected: "selected",
  7172. None: "none"
  7173. };
  7174. Microsoft.Office.WebExtension.Index = {
  7175. First: "first",
  7176. Last: "last",
  7177. Next: "next",
  7178. Previous: "previous"
  7179. };
  7180. OSF.DDA.AsyncMethodNames.addNames({ GoToByIdAsync: "goToByIdAsync" });
  7181. OSF.DDA.AsyncMethodCalls.define({
  7182. method: OSF.DDA.AsyncMethodNames.GoToByIdAsync,
  7183. requiredArguments: [{
  7184. "name": Microsoft.Office.WebExtension.Parameters.Id,
  7185. "types": ["string", "number"]
  7186. },
  7187. {
  7188. "name": Microsoft.Office.WebExtension.Parameters.GoToType,
  7189. "enum": Microsoft.Office.WebExtension.GoToType
  7190. }
  7191. ],
  7192. supportedOptions: [
  7193. {
  7194. name: Microsoft.Office.WebExtension.Parameters.SelectionMode,
  7195. value: {
  7196. "enum": Microsoft.Office.WebExtension.SelectionMode,
  7197. "defaultValue": Microsoft.Office.WebExtension.SelectionMode.Default
  7198. }
  7199. }
  7200. ]
  7201. });
  7202. OSF.OUtil.setNamespace("Marshaling", OSF.DDA);
  7203. OSF.DDA.Marshaling.NavigationKeys = {
  7204. NavigationRequest: "DdaGoToByIdMethod",
  7205. Id: "Id",
  7206. GoToType: "GoToType",
  7207. SelectionMode: "SelectionMode"
  7208. };
  7209. var OSF_DDA_Marshaling_GoToType;
  7210. (function (OSF_DDA_Marshaling_GoToType) {
  7211. OSF_DDA_Marshaling_GoToType[OSF_DDA_Marshaling_GoToType["Binding"] = 0] = "Binding";
  7212. OSF_DDA_Marshaling_GoToType[OSF_DDA_Marshaling_GoToType["NamedItem"] = 1] = "NamedItem";
  7213. OSF_DDA_Marshaling_GoToType[OSF_DDA_Marshaling_GoToType["Slide"] = 2] = "Slide";
  7214. OSF_DDA_Marshaling_GoToType[OSF_DDA_Marshaling_GoToType["Index"] = 3] = "Index";
  7215. })(OSF_DDA_Marshaling_GoToType || (OSF_DDA_Marshaling_GoToType = {}));
  7216. ;
  7217. OSF.DDA.Marshaling.GoToType = OSF_DDA_Marshaling_GoToType;
  7218. var OSF_DDA_Marshaling_SelectionMode;
  7219. (function (OSF_DDA_Marshaling_SelectionMode) {
  7220. OSF_DDA_Marshaling_SelectionMode[OSF_DDA_Marshaling_SelectionMode["Default"] = 0] = "Default";
  7221. OSF_DDA_Marshaling_SelectionMode[OSF_DDA_Marshaling_SelectionMode["Selected"] = 1] = "Selected";
  7222. OSF_DDA_Marshaling_SelectionMode[OSF_DDA_Marshaling_SelectionMode["None"] = 2] = "None";
  7223. })(OSF_DDA_Marshaling_SelectionMode || (OSF_DDA_Marshaling_SelectionMode = {}));
  7224. ;
  7225. OSF.DDA.Marshaling.SelectionMode = OSF_DDA_Marshaling_SelectionMode;
  7226. OSF.DDA.WAC.Delegate.ParameterMap.addComplexType(OSF.DDA.Marshaling.NavigationKeys.NavigationRequest);
  7227. OSF.DDA.WAC.Delegate.ParameterMap.define({
  7228. type: OSF.DDA.Marshaling.NavigationKeys.NavigationRequest,
  7229. toHost: [
  7230. { name: Microsoft.Office.WebExtension.Parameters.Id, value: OSF.DDA.Marshaling.NavigationKeys.Id },
  7231. { name: Microsoft.Office.WebExtension.Parameters.GoToType, value: OSF.DDA.Marshaling.NavigationKeys.GoToType },
  7232. { name: Microsoft.Office.WebExtension.Parameters.SelectionMode, value: OSF.DDA.Marshaling.NavigationKeys.SelectionMode }
  7233. ]
  7234. });
  7235. OSF.DDA.WAC.Delegate.ParameterMap.define({
  7236. type: Microsoft.Office.WebExtension.Parameters.GoToType,
  7237. toHost: [
  7238. { name: Microsoft.Office.WebExtension.GoToType.Binding, value: OSF.DDA.Marshaling.GoToType.Binding },
  7239. { name: Microsoft.Office.WebExtension.GoToType.NamedItem, value: OSF.DDA.Marshaling.GoToType.NamedItem },
  7240. { name: Microsoft.Office.WebExtension.GoToType.Slide, value: OSF.DDA.Marshaling.GoToType.Slide },
  7241. { name: Microsoft.Office.WebExtension.GoToType.Index, value: OSF.DDA.Marshaling.GoToType.Index }
  7242. ]
  7243. });
  7244. OSF.DDA.WAC.Delegate.ParameterMap.define({
  7245. type: Microsoft.Office.WebExtension.Parameters.SelectionMode,
  7246. toHost: [
  7247. { name: Microsoft.Office.WebExtension.SelectionMode.Default, value: OSF.DDA.Marshaling.SelectionMode.Default },
  7248. { name: Microsoft.Office.WebExtension.SelectionMode.Selected, value: OSF.DDA.Marshaling.SelectionMode.Selected },
  7249. { name: Microsoft.Office.WebExtension.SelectionMode.None, value: OSF.DDA.Marshaling.SelectionMode.None }
  7250. ]
  7251. });
  7252. OSF.DDA.WAC.Delegate.ParameterMap.define({
  7253. type: OSF.DDA.MethodDispId.dispidNavigateToMethod,
  7254. toHost: [
  7255. { name: OSF.DDA.Marshaling.NavigationKeys.NavigationRequest, value: OSF.DDA.WAC.Delegate.ParameterMap.self }
  7256. ]
  7257. });
  7258. Microsoft.Office.WebExtension.FileType = {
  7259. Text: "text",
  7260. Compressed: "compressed",
  7261. Pdf: "pdf"
  7262. };
  7263. OSF.OUtil.augmentList(OSF.DDA.PropertyDescriptors, {
  7264. FileProperties: "FileProperties",
  7265. FileSliceProperties: "FileSliceProperties"
  7266. });
  7267. OSF.DDA.FileProperties = {
  7268. Handle: "FileHandle",
  7269. FileSize: "FileSize",
  7270. SliceSize: Microsoft.Office.WebExtension.Parameters.SliceSize
  7271. };
  7272. OSF.DDA.File = function OSF_DDA_File(handle, fileSize, sliceSize) {
  7273. OSF.OUtil.defineEnumerableProperties(this, {
  7274. "size": {
  7275. value: fileSize
  7276. },
  7277. "sliceCount": {
  7278. value: Math.ceil(fileSize / sliceSize)
  7279. }
  7280. });
  7281. var privateState = {};
  7282. privateState[OSF.DDA.FileProperties.Handle] = handle;
  7283. privateState[OSF.DDA.FileProperties.SliceSize] = sliceSize;
  7284. var am = OSF.DDA.AsyncMethodNames;
  7285. OSF.DDA.DispIdHost.addAsyncMethods(this, [
  7286. am.GetDocumentCopyChunkAsync,
  7287. am.ReleaseDocumentCopyAsync
  7288. ], privateState);
  7289. };
  7290. OSF.DDA.FileSliceOffset = "fileSliceoffset";
  7291. OSF.DDA.AsyncMethodNames.addNames({
  7292. GetDocumentCopyAsync: "getFileAsync",
  7293. GetDocumentCopyChunkAsync: "getSliceAsync",
  7294. ReleaseDocumentCopyAsync: "closeAsync"
  7295. });
  7296. OSF.DDA.AsyncMethodCalls.define({
  7297. method: OSF.DDA.AsyncMethodNames.GetDocumentCopyAsync,
  7298. requiredArguments: [
  7299. {
  7300. "name": Microsoft.Office.WebExtension.Parameters.FileType,
  7301. "enum": Microsoft.Office.WebExtension.FileType
  7302. }
  7303. ],
  7304. supportedOptions: [
  7305. {
  7306. name: Microsoft.Office.WebExtension.Parameters.SliceSize,
  7307. value: {
  7308. "types": ["number"],
  7309. "defaultValue": 4 * 1024 * 1024
  7310. }
  7311. }
  7312. ],
  7313. checkCallArgs: function (callArgs, caller, stateInfo) {
  7314. var sliceSize = callArgs[Microsoft.Office.WebExtension.Parameters.SliceSize];
  7315. if (sliceSize <= 0 || sliceSize > (4 * 1024 * 1024)) {
  7316. throw OSF.DDA.ErrorCodeManager.errorCodes.ooeInvalidSliceSize;
  7317. }
  7318. return callArgs;
  7319. },
  7320. onSucceeded: function (fileDescriptor, caller, callArgs) {
  7321. return new OSF.DDA.File(fileDescriptor[OSF.DDA.FileProperties.Handle], fileDescriptor[OSF.DDA.FileProperties.FileSize], callArgs[Microsoft.Office.WebExtension.Parameters.SliceSize]);
  7322. }
  7323. });
  7324. OSF.DDA.AsyncMethodCalls.define({
  7325. method: OSF.DDA.AsyncMethodNames.GetDocumentCopyChunkAsync,
  7326. requiredArguments: [
  7327. {
  7328. "name": Microsoft.Office.WebExtension.Parameters.SliceIndex,
  7329. "types": ["number"]
  7330. }
  7331. ],
  7332. privateStateCallbacks: [
  7333. {
  7334. name: OSF.DDA.FileProperties.Handle,
  7335. value: function (caller, stateInfo) { return stateInfo[OSF.DDA.FileProperties.Handle]; }
  7336. },
  7337. {
  7338. name: OSF.DDA.FileProperties.SliceSize,
  7339. value: function (caller, stateInfo) { return stateInfo[OSF.DDA.FileProperties.SliceSize]; }
  7340. }
  7341. ],
  7342. checkCallArgs: function (callArgs, caller, stateInfo) {
  7343. var index = callArgs[Microsoft.Office.WebExtension.Parameters.SliceIndex];
  7344. if (index < 0 || index >= caller.sliceCount) {
  7345. throw OSF.DDA.ErrorCodeManager.errorCodes.ooeIndexOutOfRange;
  7346. }
  7347. callArgs[OSF.DDA.FileSliceOffset] = parseInt((index * stateInfo[OSF.DDA.FileProperties.SliceSize]).toString());
  7348. return callArgs;
  7349. },
  7350. onSucceeded: function (sliceDescriptor, caller, callArgs) {
  7351. var slice = {};
  7352. OSF.OUtil.defineEnumerableProperties(slice, {
  7353. "data": {
  7354. value: sliceDescriptor[Microsoft.Office.WebExtension.Parameters.Data]
  7355. },
  7356. "index": {
  7357. value: callArgs[Microsoft.Office.WebExtension.Parameters.SliceIndex]
  7358. },
  7359. "size": {
  7360. value: sliceDescriptor[OSF.DDA.FileProperties.SliceSize]
  7361. }
  7362. });
  7363. return slice;
  7364. }
  7365. });
  7366. OSF.DDA.AsyncMethodCalls.define({
  7367. method: OSF.DDA.AsyncMethodNames.ReleaseDocumentCopyAsync,
  7368. privateStateCallbacks: [
  7369. {
  7370. name: OSF.DDA.FileProperties.Handle,
  7371. value: function (caller, stateInfo) { return stateInfo[OSF.DDA.FileProperties.Handle]; }
  7372. }
  7373. ]
  7374. });
  7375. OSF.OUtil.setNamespace("Marshaling", OSF.DDA);
  7376. OSF.OUtil.setNamespace("File", OSF.DDA.Marshaling);
  7377. var OSF_DDA_Marshaling_File_FilePropertiesKeys;
  7378. (function (OSF_DDA_Marshaling_File_FilePropertiesKeys) {
  7379. OSF_DDA_Marshaling_File_FilePropertiesKeys[OSF_DDA_Marshaling_File_FilePropertiesKeys["Handle"] = 0] = "Handle";
  7380. OSF_DDA_Marshaling_File_FilePropertiesKeys[OSF_DDA_Marshaling_File_FilePropertiesKeys["FileSize"] = 1] = "FileSize";
  7381. })(OSF_DDA_Marshaling_File_FilePropertiesKeys || (OSF_DDA_Marshaling_File_FilePropertiesKeys = {}));
  7382. ;
  7383. OSF.DDA.Marshaling.File.FilePropertiesKeys = OSF_DDA_Marshaling_File_FilePropertiesKeys;
  7384. var OSF_DDA_Marshaling_File_SlicePropertiesKeys;
  7385. (function (OSF_DDA_Marshaling_File_SlicePropertiesKeys) {
  7386. OSF_DDA_Marshaling_File_SlicePropertiesKeys[OSF_DDA_Marshaling_File_SlicePropertiesKeys["Data"] = 0] = "Data";
  7387. OSF_DDA_Marshaling_File_SlicePropertiesKeys[OSF_DDA_Marshaling_File_SlicePropertiesKeys["SliceSize"] = 1] = "SliceSize";
  7388. })(OSF_DDA_Marshaling_File_SlicePropertiesKeys || (OSF_DDA_Marshaling_File_SlicePropertiesKeys = {}));
  7389. ;
  7390. OSF.DDA.Marshaling.File.SlicePropertiesKeys = OSF_DDA_Marshaling_File_SlicePropertiesKeys;
  7391. var OSF_DDA_Marshaling_File_FileType;
  7392. (function (OSF_DDA_Marshaling_File_FileType) {
  7393. OSF_DDA_Marshaling_File_FileType[OSF_DDA_Marshaling_File_FileType["Text"] = 0] = "Text";
  7394. OSF_DDA_Marshaling_File_FileType[OSF_DDA_Marshaling_File_FileType["Compressed"] = 1] = "Compressed";
  7395. OSF_DDA_Marshaling_File_FileType[OSF_DDA_Marshaling_File_FileType["Pdf"] = 2] = "Pdf";
  7396. })(OSF_DDA_Marshaling_File_FileType || (OSF_DDA_Marshaling_File_FileType = {}));
  7397. ;
  7398. OSF.DDA.Marshaling.File.FileType = OSF_DDA_Marshaling_File_FileType;
  7399. var OSF_DDA_Marshaling_File_ParameterKeys;
  7400. (function (OSF_DDA_Marshaling_File_ParameterKeys) {
  7401. OSF_DDA_Marshaling_File_ParameterKeys[OSF_DDA_Marshaling_File_ParameterKeys["FileType"] = 0] = "FileType";
  7402. OSF_DDA_Marshaling_File_ParameterKeys[OSF_DDA_Marshaling_File_ParameterKeys["SliceSize"] = 1] = "SliceSize";
  7403. OSF_DDA_Marshaling_File_ParameterKeys[OSF_DDA_Marshaling_File_ParameterKeys["Handle"] = 2] = "Handle";
  7404. OSF_DDA_Marshaling_File_ParameterKeys[OSF_DDA_Marshaling_File_ParameterKeys["SliceIndex"] = 3] = "SliceIndex";
  7405. })(OSF_DDA_Marshaling_File_ParameterKeys || (OSF_DDA_Marshaling_File_ParameterKeys = {}));
  7406. ;
  7407. OSF.DDA.Marshaling.File.ParameterKeys = OSF_DDA_Marshaling_File_ParameterKeys;
  7408. OSF.DDA.WAC.Delegate.ParameterMap.addComplexType(OSF.DDA.PropertyDescriptors.FileProperties);
  7409. OSF.DDA.WAC.Delegate.ParameterMap.addComplexType(OSF.DDA.PropertyDescriptors.FileSliceProperties);
  7410. OSF.DDA.WAC.Delegate.ParameterMap.define({
  7411. type: OSF.DDA.PropertyDescriptors.FileProperties,
  7412. fromHost: [
  7413. { name: OSF.DDA.FileProperties.Handle, value: OSF.DDA.Marshaling.File.FilePropertiesKeys.Handle },
  7414. { name: OSF.DDA.FileProperties.FileSize, value: OSF.DDA.Marshaling.File.FilePropertiesKeys.FileSize }
  7415. ]
  7416. });
  7417. OSF.DDA.WAC.Delegate.ParameterMap.define({
  7418. type: OSF.DDA.PropertyDescriptors.FileSliceProperties,
  7419. fromHost: [
  7420. { name: Microsoft.Office.WebExtension.Parameters.Data, value: OSF.DDA.Marshaling.File.SlicePropertiesKeys.Data },
  7421. { name: OSF.DDA.FileProperties.SliceSize, value: OSF.DDA.Marshaling.File.SlicePropertiesKeys.SliceSize }
  7422. ]
  7423. });
  7424. OSF.DDA.WAC.Delegate.ParameterMap.define({
  7425. type: Microsoft.Office.WebExtension.Parameters.FileType,
  7426. toHost: [
  7427. { name: Microsoft.Office.WebExtension.FileType.Text, value: OSF.DDA.Marshaling.File.FileType.Text },
  7428. { name: Microsoft.Office.WebExtension.FileType.Compressed, value: OSF.DDA.Marshaling.File.FileType.Compressed },
  7429. { name: Microsoft.Office.WebExtension.FileType.Pdf, value: OSF.DDA.Marshaling.File.FileType.Pdf }
  7430. ]
  7431. });
  7432. OSF.DDA.WAC.Delegate.ParameterMap.define({
  7433. type: OSF.DDA.MethodDispId.dispidGetDocumentCopyMethod,
  7434. toHost: [
  7435. { name: Microsoft.Office.WebExtension.Parameters.FileType, value: OSF.DDA.Marshaling.File.ParameterKeys.FileType },
  7436. { name: Microsoft.Office.WebExtension.Parameters.SliceSize, value: OSF.DDA.Marshaling.File.ParameterKeys.SliceSize }
  7437. ],
  7438. fromHost: [
  7439. { name: OSF.DDA.PropertyDescriptors.FileProperties, value: OSF.DDA.WAC.Delegate.ParameterMap.self }
  7440. ]
  7441. });
  7442. OSF.DDA.WAC.Delegate.ParameterMap.define({
  7443. type: OSF.DDA.MethodDispId.dispidGetDocumentCopyChunkMethod,
  7444. toHost: [
  7445. { name: OSF.DDA.FileProperties.Handle, value: OSF.DDA.Marshaling.File.ParameterKeys.Handle },
  7446. { name: Microsoft.Office.WebExtension.Parameters.SliceIndex, value: OSF.DDA.Marshaling.File.ParameterKeys.SliceIndex }
  7447. ],
  7448. fromHost: [
  7449. { name: OSF.DDA.PropertyDescriptors.FileSliceProperties, value: OSF.DDA.WAC.Delegate.ParameterMap.self }
  7450. ]
  7451. });
  7452. OSF.DDA.WAC.Delegate.ParameterMap.define({
  7453. type: OSF.DDA.MethodDispId.dispidReleaseDocumentCopyMethod,
  7454. toHost: [{ name: OSF.DDA.FileProperties.Handle, value: OSF.DDA.Marshaling.File.ParameterKeys.Handle }]
  7455. });
  7456. OSF.DDA.FilePropertiesDescriptor = {
  7457. Url: "Url"
  7458. };
  7459. OSF.OUtil.augmentList(OSF.DDA.PropertyDescriptors, {
  7460. FilePropertiesDescriptor: "FilePropertiesDescriptor"
  7461. });
  7462. Microsoft.Office.WebExtension.FileProperties = function Microsoft_Office_WebExtension_FileProperties(filePropertiesDescriptor) {
  7463. OSF.OUtil.defineEnumerableProperties(this, {
  7464. "url": {
  7465. value: filePropertiesDescriptor[OSF.DDA.FilePropertiesDescriptor.Url]
  7466. }
  7467. });
  7468. };
  7469. OSF.DDA.AsyncMethodNames.addNames({ GetFilePropertiesAsync: "getFilePropertiesAsync" });
  7470. OSF.DDA.AsyncMethodCalls.define({
  7471. method: OSF.DDA.AsyncMethodNames.GetFilePropertiesAsync,
  7472. fromHost: [
  7473. { name: OSF.DDA.PropertyDescriptors.FilePropertiesDescriptor, value: 0 }
  7474. ],
  7475. requiredArguments: [],
  7476. supportedOptions: [],
  7477. onSucceeded: function (filePropertiesDescriptor, caller, callArgs) {
  7478. return new Microsoft.Office.WebExtension.FileProperties(filePropertiesDescriptor);
  7479. }
  7480. });
  7481. OSF.OUtil.setNamespace("Marshaling", OSF.DDA);
  7482. var OSF_DDA_Marshaling_FilePropertiesKeys;
  7483. (function (OSF_DDA_Marshaling_FilePropertiesKeys) {
  7484. OSF_DDA_Marshaling_FilePropertiesKeys[OSF_DDA_Marshaling_FilePropertiesKeys["Properties"] = 0] = "Properties";
  7485. OSF_DDA_Marshaling_FilePropertiesKeys[OSF_DDA_Marshaling_FilePropertiesKeys["Url"] = 1] = "Url";
  7486. })(OSF_DDA_Marshaling_FilePropertiesKeys || (OSF_DDA_Marshaling_FilePropertiesKeys = {}));
  7487. ;
  7488. OSF.DDA.Marshaling.FilePropertiesKeys = OSF_DDA_Marshaling_FilePropertiesKeys;
  7489. OSF.DDA.WAC.Delegate.ParameterMap.addComplexType(OSF.DDA.PropertyDescriptors.FilePropertiesDescriptor);
  7490. OSF.DDA.WAC.Delegate.ParameterMap.define({
  7491. type: OSF.DDA.PropertyDescriptors.FilePropertiesDescriptor,
  7492. fromHost: [
  7493. { name: OSF.DDA.FilePropertiesDescriptor.Url, value: OSF.DDA.Marshaling.FilePropertiesKeys.Url }
  7494. ]
  7495. });
  7496. OSF.DDA.WAC.Delegate.ParameterMap.define({
  7497. type: OSF.DDA.MethodDispId.dispidGetFilePropertiesMethod,
  7498. fromHost: [
  7499. { name: OSF.DDA.PropertyDescriptors.FilePropertiesDescriptor, value: OSF.DDA.Marshaling.FilePropertiesKeys.Properties }
  7500. ]
  7501. });
  7502. OSF.DDA.AsyncMethodNames.addNames({
  7503. GetOfficeThemeAsync: "getOfficeThemeAsync",
  7504. GetDocumentThemeAsync: "getDocumentThemeAsync"
  7505. });
  7506. OSF.OUtil.augmentList(Microsoft.Office.WebExtension.EventType, {
  7507. OfficeThemeChanged: "officeThemeChanged",
  7508. DocumentThemeChanged: "documentThemeChanged"
  7509. });
  7510. OSF.OUtil.augmentList(Microsoft.Office.WebExtension.Parameters, {
  7511. DocumentTheme: "documentTheme",
  7512. OfficeTheme: "officeTheme"
  7513. });
  7514. OSF.OUtil.augmentList(OSF.DDA.EventDescriptors, {
  7515. DocumentThemeChangedEvent: "DocumentThemeChangedEvent",
  7516. OfficeThemeChangedEvent: "OfficeThemeChangedEvent"
  7517. });
  7518. OSF.OUtil.setNamespace("Theming", OSF.DDA);
  7519. OSF.DDA.Theming.OfficeThemeEnum = {
  7520. PrimaryFontColor: "primaryFontColor",
  7521. PrimaryBackgroundColor: "primaryBackgroundColor",
  7522. SecondaryFontColor: "secondaryFontColor",
  7523. SecondaryBackgroundColor: "secondaryBackgroundColor"
  7524. };
  7525. OSF.DDA.Theming.DocumentThemeEnum = {
  7526. PrimaryFontColor: "primaryFontColor",
  7527. PrimaryBackgroundColor: "primaryBackgroundColor",
  7528. SecondaryFontColor: "secondaryFontColor",
  7529. SecondaryBackgroundColor: "secondaryBackgroundColor",
  7530. Accent1: "accent1",
  7531. Accent2: "accent2",
  7532. Accent3: "accent3",
  7533. Accent4: "accent4",
  7534. Accent5: "accent5",
  7535. Accent6: "accent6",
  7536. Hyperlink: "hyperlink",
  7537. FollowedHyperlink: "followedHyperlink",
  7538. HeaderLatinFont: "headerLatinFont",
  7539. HeaderEastAsianFont: "headerEastAsianFont",
  7540. HeaderScriptFont: "headerScriptFont",
  7541. HeaderLocalizedFont: "headerLocalizedFont",
  7542. BodyLatinFont: "bodyLatinFont",
  7543. BodyEastAsianFont: "bodyEastAsianFont",
  7544. BodyScriptFont: "bodyScriptFont",
  7545. BodyLocalizedFont: "bodyLocalizedFont"
  7546. };
  7547. OSF.DDA.Theming.ConvertToDocumentTheme = function OSF_DDA_Theming_ConvertToDocumentTheme(response) {
  7548. var mappingDocumentTheme = [
  7549. { name: "primaryFontColor", needToConvertToHex: true },
  7550. { name: "primaryBackgroundColor", needToConvertToHex: true },
  7551. { name: "secondaryFontColor", needToConvertToHex: true },
  7552. { name: "secondaryBackgroundColor", needToConvertToHex: true },
  7553. { name: "accent1", needToConvertToHex: true },
  7554. { name: "accent2", needToConvertToHex: true },
  7555. { name: "accent3", needToConvertToHex: true },
  7556. { name: "accent4", needToConvertToHex: true },
  7557. { name: "accent5", needToConvertToHex: true },
  7558. { name: "accent6", needToConvertToHex: true },
  7559. { name: "hyperlink", needToConvertToHex: true },
  7560. { name: "followedHyperlink", needToConvertToHex: true },
  7561. { name: "headerLatinFont", needToConvertToHex: false },
  7562. { name: "headerEastAsianFont", needToConvertToHex: false },
  7563. { name: "headerScriptFont", needToConvertToHex: false },
  7564. { name: "headerLocalizedFont", needToConvertToHex: false },
  7565. { name: "bodyLatinFont", needToConvertToHex: false },
  7566. { name: "bodyEastAsianFont", needToConvertToHex: false },
  7567. { name: "bodyScriptFont", needToConvertToHex: false },
  7568. { name: "bodyLocalizedFont", needToConvertToHex: false }
  7569. ];
  7570. var result = {};
  7571. for (var i = 0; i < mappingDocumentTheme.length; i++) {
  7572. if (mappingDocumentTheme[i].needToConvertToHex) {
  7573. result[mappingDocumentTheme[i].name] = OSF.OUtil.convertIntToCssHexColor(response[mappingDocumentTheme[i].name]);
  7574. }
  7575. else {
  7576. result[mappingDocumentTheme[i].name] = response[mappingDocumentTheme[i].name];
  7577. }
  7578. }
  7579. return result;
  7580. };
  7581. OSF.DDA.Theming.ConvertToOfficeTheme = function OSF_DDA_Theming_ConvertToOfficeTheme(response) {
  7582. var result = {};
  7583. for (var key in response) {
  7584. result[key] = OSF.OUtil.convertIntToCssHexColor(response[key]);
  7585. }
  7586. return result;
  7587. };
  7588. OSF.DDA.AsyncMethodCalls.define({
  7589. method: OSF.DDA.AsyncMethodNames.GetDocumentThemeAsync,
  7590. requiredArguments: [],
  7591. supportedOptions: [],
  7592. privateStateCallbacks: [],
  7593. onSucceeded: OSF.DDA.Theming.ConvertToDocumentTheme
  7594. });
  7595. OSF.DDA.AsyncMethodCalls.define({
  7596. method: OSF.DDA.AsyncMethodNames.GetOfficeThemeAsync,
  7597. requiredArguments: [],
  7598. supportedOptions: [],
  7599. privateStateCallbacks: [],
  7600. onSucceeded: OSF.DDA.Theming.ConvertToOfficeTheme
  7601. });
  7602. OSF.DDA.Theming.OfficeThemeChangedEventArgs = function OSF_DDA_Theming_OfficeThemeChangedEventArgs(officeTheme) {
  7603. var ret = OSF.DDA.Theming.ConvertToOfficeTheme(officeTheme);
  7604. OSF.OUtil.defineEnumerableProperties(this, {
  7605. "type": {
  7606. value: Microsoft.Office.WebExtension.EventType.OfficeThemeChanged
  7607. },
  7608. "officeTheme": {
  7609. value: ret
  7610. }
  7611. });
  7612. };
  7613. OSF.DDA.Theming.DocumentThemeChangedEventArgs = function OSF_DDA_Theming_DocumentThemeChangedEventArgs(documentTheme) {
  7614. var ret = OSF.DDA.Theming.ConvertToDocumentTheme(documentTheme);
  7615. OSF.OUtil.defineEnumerableProperties(this, {
  7616. "type": {
  7617. value: Microsoft.Office.WebExtension.EventType.DocumentThemeChanged
  7618. },
  7619. "documentTheme": {
  7620. value: ret
  7621. }
  7622. });
  7623. };
  7624. var OSF_DDA_Theming_InternalThemeHandler = (function () {
  7625. function OSF_DDA_Theming_InternalThemeHandler() {
  7626. this._pseudoDocumentObject = null;
  7627. this._previousDocumentThemeData = null;
  7628. this._previousOfficeThemeData = null;
  7629. this._officeCss = null;
  7630. this._asyncCallsCompleted = null;
  7631. this._onAsyncCallsCompleted = null;
  7632. }
  7633. OSF_DDA_Theming_InternalThemeHandler.prototype.InitializeAndChangeOnce = function (callback) {
  7634. this._officeCss = this._getOfficeThemesCss();
  7635. if (!this._officeCss) {
  7636. if (callback) {
  7637. callback();
  7638. }
  7639. return;
  7640. }
  7641. this._onAsyncCallsCompleted = callback;
  7642. this._pseudoDocumentObject = {};
  7643. var pseudoDoc = this._pseudoDocumentObject;
  7644. OSF.DDA.DispIdHost.addAsyncMethods(pseudoDoc, [
  7645. OSF.DDA.AsyncMethodNames.GetOfficeThemeAsync,
  7646. OSF.DDA.AsyncMethodNames.GetDocumentThemeAsync
  7647. ]);
  7648. OSF.DDA.DispIdHost.addEventSupport(pseudoDoc, new OSF.EventDispatch([
  7649. Microsoft.Office.WebExtension.EventType.OfficeThemeChanged,
  7650. Microsoft.Office.WebExtension.EventType.DocumentThemeChanged
  7651. ]));
  7652. this._asyncCallsCompleted = {};
  7653. this._asyncCallsCompleted[OSF.DDA.AsyncMethodNames.GetOfficeThemeAsync] = false;
  7654. this._asyncCallsCompleted[OSF.DDA.AsyncMethodNames.GetDocumentThemeAsync] = false;
  7655. this._getAndProcessThemeData(pseudoDoc.getDocumentThemeAsync, Function.createDelegate(this, this._processDocumentThemeData), OSF.DDA.AsyncMethodNames.GetDocumentThemeAsync);
  7656. this._getAndProcessThemeData(pseudoDoc.getOfficeThemeAsync, Function.createDelegate(this, this._processOfficeThemeData), OSF.DDA.AsyncMethodNames.GetOfficeThemeAsync);
  7657. };
  7658. OSF_DDA_Theming_InternalThemeHandler.prototype._getOfficeThemesCss = function () {
  7659. function getOfficeThemesCssInternal() {
  7660. var cssFileName = "officethemes.css";
  7661. for (var i = 0; i < document.styleSheets.length; i++) {
  7662. var ss = document.styleSheets[i];
  7663. if (!ss.disabled
  7664. && ss.href
  7665. && cssFileName == ss.href.substring(ss.href.length - cssFileName.length, ss.href.length).toLowerCase()) {
  7666. if ((!ss.cssRules) && (!ss.rules)) {
  7667. return null;
  7668. }
  7669. else {
  7670. return ss;
  7671. }
  7672. }
  7673. }
  7674. }
  7675. try {
  7676. return getOfficeThemesCssInternal();
  7677. }
  7678. catch (e) {
  7679. return null;
  7680. }
  7681. };
  7682. OSF_DDA_Theming_InternalThemeHandler.prototype._changeCss = function (officeCss, selector, newRule) {
  7683. var length = officeCss.cssRules ? officeCss.cssRules.length : officeCss.rules.length;
  7684. for (var i = 0; i < length; i++) {
  7685. var rule;
  7686. if (officeCss.cssRules) {
  7687. rule = officeCss.cssRules[i];
  7688. }
  7689. else {
  7690. rule = officeCss.rules[i];
  7691. }
  7692. var ruleSelector = rule.selectorText;
  7693. if (ruleSelector && ruleSelector.toLowerCase() == selector.toLowerCase()) {
  7694. if (officeCss.cssRules) {
  7695. officeCss.deleteRule(i);
  7696. officeCss.insertRule(ruleSelector + newRule, i);
  7697. }
  7698. else {
  7699. officeCss.removeRule(i);
  7700. officeCss.addRule(ruleSelector, newRule, i);
  7701. }
  7702. }
  7703. }
  7704. };
  7705. OSF_DDA_Theming_InternalThemeHandler.prototype._changeDocumentThemeData = function (data) {
  7706. var documentThemeCssMapping = [
  7707. { name: "primaryFontColor", cssSelector: ".office-docTheme-primary-fontColor", cssProperty: "color" },
  7708. { name: "primaryBackgroundColor", cssSelector: ".office-docTheme-primary-bgColor", cssProperty: "background-color" },
  7709. { name: "secondaryFontColor", cssSelector: ".office-docTheme-secondary-fontColor", cssProperty: "color" },
  7710. { name: "secondaryBackgroundColor", cssSelector: ".office-docTheme-secondary-bgColor", cssProperty: "background-color" },
  7711. { name: "accent1", cssSelector: ".office-contentAccent1-color", cssProperty: "color" },
  7712. { name: "accent2", cssSelector: ".office-contentAccent2-color", cssProperty: "color" },
  7713. { name: "accent3", cssSelector: ".office-contentAccent3-color", cssProperty: "color" },
  7714. { name: "accent4", cssSelector: ".office-contentAccent4-color", cssProperty: "color" },
  7715. { name: "accent5", cssSelector: ".office-contentAccent5-color", cssProperty: "color" },
  7716. { name: "accent6", cssSelector: ".office-contentAccent6-color", cssProperty: "color" },
  7717. { name: "accent1", cssSelector: ".office-contentAccent1-bgColor", cssProperty: "background-color" },
  7718. { name: "accent2", cssSelector: ".office-contentAccent2-bgColor", cssProperty: "background-color" },
  7719. { name: "accent3", cssSelector: ".office-contentAccent3-bgColor", cssProperty: "background-color" },
  7720. { name: "accent4", cssSelector: ".office-contentAccent4-bgColor", cssProperty: "background-color" },
  7721. { name: "accent5", cssSelector: ".office-contentAccent5-bgColor", cssProperty: "background-color" },
  7722. { name: "accent6", cssSelector: ".office-contentAccent6-bgColor", cssProperty: "background-color" },
  7723. { name: "accent1", cssSelector: ".office-contentAccent1-borderColor", cssProperty: "border-color" },
  7724. { name: "accent2", cssSelector: ".office-contentAccent2-borderColor", cssProperty: "border-color" },
  7725. { name: "accent3", cssSelector: ".office-contentAccent3-borderColor", cssProperty: "border-color" },
  7726. { name: "accent4", cssSelector: ".office-contentAccent4-borderColor", cssProperty: "border-color" },
  7727. { name: "accent5", cssSelector: ".office-contentAccent5-borderColor", cssProperty: "border-color" },
  7728. { name: "accent6", cssSelector: ".office-contentAccent6-borderColor", cssProperty: "border-color" },
  7729. { name: "hyperlink", cssSelector: ".office-a", cssProperty: "color" },
  7730. { name: "followedHyperlink", cssSelector: ".office-a:visited", cssProperty: "color" },
  7731. { name: "headerLatinFont", cssSelector: ".office-headerFont-latin", cssProperty: "font-family" },
  7732. { name: "headerEastAsianFont", cssSelector: ".office-headerFont-eastAsian", cssProperty: "font-family" },
  7733. { name: "headerScriptFont", cssSelector: ".office-headerFont-script", cssProperty: "font-family" },
  7734. { name: "headerLocalizedFont", cssSelector: ".office-headerFont-localized", cssProperty: "font-family" },
  7735. { name: "bodyLatinFont", cssSelector: ".office-bodyFont-latin", cssProperty: "font-family" },
  7736. { name: "bodyEastAsianFont", cssSelector: ".office-bodyFont-eastAsian", cssProperty: "font-family" },
  7737. { name: "bodyScriptFont", cssSelector: ".office-bodyFont-script", cssProperty: "font-family" },
  7738. { name: "bodyLocalizedFont", cssSelector: ".office-bodyFont-localized", cssProperty: "font-family" }
  7739. ];
  7740. var realData = data.type == "documentThemeChanged" ? data.documentTheme : data;
  7741. for (var i = 0; i < documentThemeCssMapping.length; i++) {
  7742. if (this._previousDocumentThemeData === null || this._previousDocumentThemeData[documentThemeCssMapping[i].name] != realData[documentThemeCssMapping[i].name]) {
  7743. if (realData[documentThemeCssMapping[i].name] != null && realData[documentThemeCssMapping[i].name] != "") {
  7744. var insertableText = realData[documentThemeCssMapping[i].name];
  7745. if (documentThemeCssMapping[i].cssProperty === "font-family") {
  7746. insertableText = '"' + insertableText.replace(/"/g, '\\"') + '"';
  7747. }
  7748. this._changeCss(this._officeCss, documentThemeCssMapping[i].cssSelector, "{" + documentThemeCssMapping[i].cssProperty + ":" + insertableText + ";}");
  7749. }
  7750. else {
  7751. this._changeCss(this._officeCss, documentThemeCssMapping[i].cssSelector, "{}");
  7752. }
  7753. }
  7754. }
  7755. this._previousDocumentThemeData = realData;
  7756. };
  7757. OSF_DDA_Theming_InternalThemeHandler.prototype._changeOfficeThemeData = function (data) {
  7758. var officeThemeCssMapping = [
  7759. { name: "primaryFontColor", cssSelector: ".office-officeTheme-primary-fontColor", cssProperty: "color" },
  7760. { name: "primaryBackgroundColor", cssSelector: ".office-officeTheme-primary-bgColor", cssProperty: "background-color" },
  7761. { name: "secondaryFontColor", cssSelector: ".office-officeTheme-secondary-fontColor", cssProperty: "color" },
  7762. { name: "secondaryBackgroundColor", cssSelector: ".office-officeTheme-secondary-bgColor", cssProperty: "background-color" }
  7763. ];
  7764. var realData = data.type == "officeThemeChanged" ? data.officeTheme : data;
  7765. for (var i = 0; i < officeThemeCssMapping.length; i++) {
  7766. if (this._previousOfficeThemeData === null || this._previousOfficeThemeData[officeThemeCssMapping[i].name] != realData[officeThemeCssMapping[i].name]) {
  7767. if (realData[officeThemeCssMapping[i].name] !== undefined) {
  7768. this._changeCss(this._officeCss, officeThemeCssMapping[i].cssSelector, "{" + officeThemeCssMapping[i].cssProperty + ":" + realData[officeThemeCssMapping[i].name] + ";}");
  7769. }
  7770. }
  7771. }
  7772. this._previousOfficeThemeData = realData;
  7773. };
  7774. OSF_DDA_Theming_InternalThemeHandler.prototype._getAndProcessThemeData = function (getThemeMethod, processResultCallback, getThemeMethodIdentifier) {
  7775. getThemeMethod(Function.createDelegate(this, function (asyncResult) {
  7776. if (asyncResult.status == "succeeded") {
  7777. var data = asyncResult.value;
  7778. processResultCallback(data);
  7779. }
  7780. if (this._areAllCallsCompleted(getThemeMethodIdentifier) && this._onAsyncCallsCompleted) {
  7781. this._onAsyncCallsCompleted();
  7782. this._onAsyncCallsCompleted = null;
  7783. }
  7784. }));
  7785. };
  7786. OSF_DDA_Theming_InternalThemeHandler.prototype._processOfficeThemeData = function (data) {
  7787. this._changeOfficeThemeData(data);
  7788. this._pseudoDocumentObject.addHandlerAsync(Microsoft.Office.WebExtension.EventType.OfficeThemeChanged, Function.createDelegate(this, this._changeOfficeThemeData), null);
  7789. };
  7790. OSF_DDA_Theming_InternalThemeHandler.prototype._processDocumentThemeData = function (data) {
  7791. this._changeDocumentThemeData(data);
  7792. this._pseudoDocumentObject.addHandlerAsync(Microsoft.Office.WebExtension.EventType.DocumentThemeChanged, Function.createDelegate(this, this._changeDocumentThemeData), null);
  7793. };
  7794. OSF_DDA_Theming_InternalThemeHandler.prototype._areAllCallsCompleted = function (completedCall) {
  7795. var asyncCallsCompleted;
  7796. if (!(asyncCallsCompleted = this._asyncCallsCompleted)) {
  7797. return true;
  7798. }
  7799. if (completedCall && asyncCallsCompleted.hasOwnProperty(completedCall)) {
  7800. asyncCallsCompleted[completedCall] = true;
  7801. }
  7802. for (var call in asyncCallsCompleted) {
  7803. if (asyncCallsCompleted.hasOwnProperty(call) && asyncCallsCompleted[call]) {
  7804. continue;
  7805. }
  7806. return false;
  7807. }
  7808. return true;
  7809. };
  7810. return OSF_DDA_Theming_InternalThemeHandler;
  7811. })();
  7812. OSF.DDA.Theming.InternalThemeHandler = OSF_DDA_Theming_InternalThemeHandler;
  7813. OSF.OUtil.setNamespace("Marshaling", OSF.DDA);
  7814. var OSF_DDA_Marshaling_ThemingKeys;
  7815. (function (OSF_DDA_Marshaling_ThemingKeys) {
  7816. OSF_DDA_Marshaling_ThemingKeys[OSF_DDA_Marshaling_ThemingKeys["DocumentTheme"] = 0] = "DocumentTheme";
  7817. OSF_DDA_Marshaling_ThemingKeys[OSF_DDA_Marshaling_ThemingKeys["OfficeTheme"] = 1] = "OfficeTheme";
  7818. OSF_DDA_Marshaling_ThemingKeys[OSF_DDA_Marshaling_ThemingKeys["Background1"] = 2] = "Background1";
  7819. OSF_DDA_Marshaling_ThemingKeys[OSF_DDA_Marshaling_ThemingKeys["Text1"] = 3] = "Text1";
  7820. OSF_DDA_Marshaling_ThemingKeys[OSF_DDA_Marshaling_ThemingKeys["Background2"] = 4] = "Background2";
  7821. OSF_DDA_Marshaling_ThemingKeys[OSF_DDA_Marshaling_ThemingKeys["Text2"] = 5] = "Text2";
  7822. OSF_DDA_Marshaling_ThemingKeys[OSF_DDA_Marshaling_ThemingKeys["Accent1"] = 6] = "Accent1";
  7823. OSF_DDA_Marshaling_ThemingKeys[OSF_DDA_Marshaling_ThemingKeys["Accent2"] = 7] = "Accent2";
  7824. OSF_DDA_Marshaling_ThemingKeys[OSF_DDA_Marshaling_ThemingKeys["Accent3"] = 8] = "Accent3";
  7825. OSF_DDA_Marshaling_ThemingKeys[OSF_DDA_Marshaling_ThemingKeys["Accent4"] = 9] = "Accent4";
  7826. OSF_DDA_Marshaling_ThemingKeys[OSF_DDA_Marshaling_ThemingKeys["Accent5"] = 10] = "Accent5";
  7827. OSF_DDA_Marshaling_ThemingKeys[OSF_DDA_Marshaling_ThemingKeys["Accent6"] = 11] = "Accent6";
  7828. OSF_DDA_Marshaling_ThemingKeys[OSF_DDA_Marshaling_ThemingKeys["Hyperlink"] = 12] = "Hyperlink";
  7829. OSF_DDA_Marshaling_ThemingKeys[OSF_DDA_Marshaling_ThemingKeys["FollowedHyperlink"] = 13] = "FollowedHyperlink";
  7830. OSF_DDA_Marshaling_ThemingKeys[OSF_DDA_Marshaling_ThemingKeys["HdLatin"] = 14] = "HdLatin";
  7831. OSF_DDA_Marshaling_ThemingKeys[OSF_DDA_Marshaling_ThemingKeys["HdEastAsian"] = 15] = "HdEastAsian";
  7832. OSF_DDA_Marshaling_ThemingKeys[OSF_DDA_Marshaling_ThemingKeys["HdScript"] = 16] = "HdScript";
  7833. OSF_DDA_Marshaling_ThemingKeys[OSF_DDA_Marshaling_ThemingKeys["HdLocalized"] = 17] = "HdLocalized";
  7834. OSF_DDA_Marshaling_ThemingKeys[OSF_DDA_Marshaling_ThemingKeys["BdLatin"] = 18] = "BdLatin";
  7835. OSF_DDA_Marshaling_ThemingKeys[OSF_DDA_Marshaling_ThemingKeys["BdEastAsian"] = 19] = "BdEastAsian";
  7836. OSF_DDA_Marshaling_ThemingKeys[OSF_DDA_Marshaling_ThemingKeys["BdScript"] = 20] = "BdScript";
  7837. OSF_DDA_Marshaling_ThemingKeys[OSF_DDA_Marshaling_ThemingKeys["BdLocalized"] = 21] = "BdLocalized";
  7838. OSF_DDA_Marshaling_ThemingKeys[OSF_DDA_Marshaling_ThemingKeys["BackgroundColor"] = 22] = "BackgroundColor";
  7839. OSF_DDA_Marshaling_ThemingKeys[OSF_DDA_Marshaling_ThemingKeys["PrimaryText"] = 23] = "PrimaryText";
  7840. OSF_DDA_Marshaling_ThemingKeys[OSF_DDA_Marshaling_ThemingKeys["PrimaryBackground"] = 24] = "PrimaryBackground";
  7841. OSF_DDA_Marshaling_ThemingKeys[OSF_DDA_Marshaling_ThemingKeys["SecondaryText"] = 25] = "SecondaryText";
  7842. OSF_DDA_Marshaling_ThemingKeys[OSF_DDA_Marshaling_ThemingKeys["SecondaryBackground"] = 26] = "SecondaryBackground";
  7843. })(OSF_DDA_Marshaling_ThemingKeys || (OSF_DDA_Marshaling_ThemingKeys = {}));
  7844. ;
  7845. OSF.DDA.Marshaling.ThemingKeys = OSF_DDA_Marshaling_ThemingKeys;
  7846. var parameterMap = OSF.DDA.WAC.Delegate.ParameterMap;
  7847. var hostKeys = OSF.DDA.Marshaling.ThemingKeys;
  7848. parameterMap.addComplexType(Microsoft.Office.WebExtension.Parameters.DocumentTheme);
  7849. parameterMap.addComplexType(Microsoft.Office.WebExtension.Parameters.OfficeTheme);
  7850. parameterMap.define({
  7851. type: OSF.DDA.MethodDispId.dispidGetDocumentThemeMethod,
  7852. fromHost: [
  7853. { name: Microsoft.Office.WebExtension.Parameters.DocumentTheme, value: hostKeys.DocumentTheme }
  7854. ]
  7855. });
  7856. parameterMap.define({
  7857. type: OSF.DDA.MethodDispId.dispidGetOfficeThemeMethod,
  7858. fromHost: [
  7859. { name: Microsoft.Office.WebExtension.Parameters.OfficeTheme, value: hostKeys.OfficeTheme }
  7860. ]
  7861. });
  7862. parameterMap.define({
  7863. type: OSF.DDA.EventDispId.dispidDocumentThemeChangedEvent,
  7864. fromHost: [
  7865. { name: Microsoft.Office.WebExtension.Parameters.DocumentTheme, value: hostKeys.DocumentTheme }
  7866. ]
  7867. });
  7868. parameterMap.define({
  7869. type: OSF.DDA.EventDispId.dispidOfficeThemeChangedEvent,
  7870. fromHost: [
  7871. { name: Microsoft.Office.WebExtension.Parameters.OfficeTheme, value: hostKeys.OfficeTheme }
  7872. ]
  7873. });
  7874. var destKeys = OSF.DDA.Theming.DocumentThemeEnum;
  7875. parameterMap.define({
  7876. type: Microsoft.Office.WebExtension.Parameters.DocumentTheme,
  7877. fromHost: [
  7878. { name: destKeys.PrimaryBackgroundColor, value: hostKeys.Background1 },
  7879. { name: destKeys.PrimaryFontColor, value: hostKeys.Text1 },
  7880. { name: destKeys.SecondaryBackgroundColor, value: hostKeys.Background2 },
  7881. { name: destKeys.SecondaryFontColor, value: hostKeys.Text2 },
  7882. { name: destKeys.Accent1, value: hostKeys.Accent1 },
  7883. { name: destKeys.Accent2, value: hostKeys.Accent2 },
  7884. { name: destKeys.Accent3, value: hostKeys.Accent3 },
  7885. { name: destKeys.Accent4, value: hostKeys.Accent4 },
  7886. { name: destKeys.Accent5, value: hostKeys.Accent5 },
  7887. { name: destKeys.Accent6, value: hostKeys.Accent6 },
  7888. { name: destKeys.Hyperlink, value: hostKeys.Hyperlink },
  7889. { name: destKeys.FollowedHyperlink, value: hostKeys.FollowedHyperlink },
  7890. { name: destKeys.HeaderLatinFont, value: hostKeys.HdLatin },
  7891. { name: destKeys.HeaderEastAsianFont, value: hostKeys.HdEastAsian },
  7892. { name: destKeys.HeaderScriptFont, value: hostKeys.HdScript },
  7893. { name: destKeys.HeaderLocalizedFont, value: hostKeys.HdLocalized },
  7894. { name: destKeys.BodyLatinFont, value: hostKeys.BdLatin },
  7895. { name: destKeys.BodyEastAsianFont, value: hostKeys.BdEastAsian },
  7896. { name: destKeys.BodyScriptFont, value: hostKeys.BdScript },
  7897. { name: destKeys.BodyLocalizedFont, value: hostKeys.BdLocalized }
  7898. ]
  7899. });
  7900. destKeys = OSF.DDA.Theming.OfficeThemeEnum;
  7901. parameterMap.define({
  7902. type: Microsoft.Office.WebExtension.Parameters.OfficeTheme,
  7903. fromHost: [
  7904. { name: destKeys.PrimaryFontColor, value: hostKeys.PrimaryText },
  7905. { name: destKeys.PrimaryBackgroundColor, value: hostKeys.PrimaryBackground },
  7906. { name: destKeys.SecondaryFontColor, value: hostKeys.SecondaryText },
  7907. { name: destKeys.SecondaryBackgroundColor, value: hostKeys.SecondaryBackground }
  7908. ]
  7909. });
  7910. OSF.DDA.SettingsManager = {
  7911. SerializedSettings: "serializedSettings",
  7912. RefreshingSettings: "refreshingSettings",
  7913. DateJSONPrefix: "Date(",
  7914. DataJSONSuffix: ")",
  7915. serializeSettings: function OSF_DDA_SettingsManager$serializeSettings(settingsCollection) {
  7916. var ret = {};
  7917. for (var key in settingsCollection) {
  7918. var value = settingsCollection[key];
  7919. try {
  7920. if (JSON) {
  7921. value = JSON.stringify(value, function dateReplacer(k, v) {
  7922. return OSF.OUtil.isDate(this[k]) ? OSF.DDA.SettingsManager.DateJSONPrefix + this[k].getTime() + OSF.DDA.SettingsManager.DataJSONSuffix : v;
  7923. });
  7924. }
  7925. else {
  7926. value = Sys.Serialization.JavaScriptSerializer.serialize(value);
  7927. }
  7928. ret[key] = value;
  7929. }
  7930. catch (ex) {
  7931. }
  7932. }
  7933. return ret;
  7934. },
  7935. deserializeSettings: function OSF_DDA_SettingsManager$deserializeSettings(serializedSettings) {
  7936. var ret = {};
  7937. serializedSettings = serializedSettings || {};
  7938. for (var key in serializedSettings) {
  7939. var value = serializedSettings[key];
  7940. try {
  7941. if (JSON) {
  7942. value = JSON.parse(value, function dateReviver(k, v) {
  7943. var d;
  7944. if (typeof v === 'string' && v && v.length > 6 && v.slice(0, 5) === OSF.DDA.SettingsManager.DateJSONPrefix && v.slice(-1) === OSF.DDA.SettingsManager.DataJSONSuffix) {
  7945. d = new Date(parseInt(v.slice(5, -1)));
  7946. if (d) {
  7947. return d;
  7948. }
  7949. }
  7950. return v;
  7951. });
  7952. }
  7953. else {
  7954. value = Sys.Serialization.JavaScriptSerializer.deserialize(value, true);
  7955. }
  7956. ret[key] = value;
  7957. }
  7958. catch (ex) {
  7959. }
  7960. }
  7961. return ret;
  7962. }
  7963. };
  7964. OSF.DDA.Settings = function OSF_DDA_Settings(settings) {
  7965. settings = settings || {};
  7966. var cacheSessionSettings = function (settings) {
  7967. var osfSessionStorage = OSF.OUtil.getSessionStorage();
  7968. if (osfSessionStorage) {
  7969. var serializedSettings = OSF.DDA.SettingsManager.serializeSettings(settings);
  7970. var storageSettings = JSON ? JSON.stringify(serializedSettings) : Sys.Serialization.JavaScriptSerializer.serialize(serializedSettings);
  7971. osfSessionStorage.setItem(OSF._OfficeAppFactory.getCachedSessionSettingsKey(), storageSettings);
  7972. }
  7973. };
  7974. OSF.OUtil.defineEnumerableProperties(this, {
  7975. "get": {
  7976. value: function OSF_DDA_Settings$get(name) {
  7977. var e = Function._validateParams(arguments, [
  7978. { name: "name", type: String, mayBeNull: false }
  7979. ]);
  7980. if (e)
  7981. throw e;
  7982. var setting = settings[name];
  7983. return typeof (setting) === 'undefined' ? null : setting;
  7984. }
  7985. },
  7986. "set": {
  7987. value: function OSF_DDA_Settings$set(name, value) {
  7988. var e = Function._validateParams(arguments, [
  7989. { name: "name", type: String, mayBeNull: false },
  7990. { name: "value", mayBeNull: true }
  7991. ]);
  7992. if (e)
  7993. throw e;
  7994. settings[name] = value;
  7995. cacheSessionSettings(settings);
  7996. }
  7997. },
  7998. "remove": {
  7999. value: function OSF_DDA_Settings$remove(name) {
  8000. var e = Function._validateParams(arguments, [
  8001. { name: "name", type: String, mayBeNull: false }
  8002. ]);
  8003. if (e)
  8004. throw e;
  8005. delete settings[name];
  8006. cacheSessionSettings(settings);
  8007. }
  8008. }
  8009. });
  8010. OSF.DDA.DispIdHost.addAsyncMethods(this, [OSF.DDA.AsyncMethodNames.SaveAsync], settings);
  8011. };
  8012. OSF.DDA.RefreshableSettings = function OSF_DDA_RefreshableSettings(settings) {
  8013. OSF.DDA.RefreshableSettings.uber.constructor.call(this, settings);
  8014. OSF.DDA.DispIdHost.addAsyncMethods(this, [OSF.DDA.AsyncMethodNames.RefreshAsync], settings);
  8015. OSF.DDA.DispIdHost.addEventSupport(this, new OSF.EventDispatch([Microsoft.Office.WebExtension.EventType.SettingsChanged]));
  8016. };
  8017. OSF.OUtil.extend(OSF.DDA.RefreshableSettings, OSF.DDA.Settings);
  8018. OSF.OUtil.augmentList(Microsoft.Office.WebExtension.EventType, {
  8019. SettingsChanged: "settingsChanged"
  8020. });
  8021. OSF.DDA.SettingsChangedEventArgs = function OSF_DDA_SettingsChangedEventArgs(settingsInstance) {
  8022. OSF.OUtil.defineEnumerableProperties(this, {
  8023. "type": {
  8024. value: Microsoft.Office.WebExtension.EventType.SettingsChanged
  8025. },
  8026. "settings": {
  8027. value: settingsInstance
  8028. }
  8029. });
  8030. };
  8031. OSF.DDA.AsyncMethodNames.addNames({
  8032. RefreshAsync: "refreshAsync",
  8033. SaveAsync: "saveAsync"
  8034. });
  8035. OSF.DDA.AsyncMethodCalls.define({
  8036. method: OSF.DDA.AsyncMethodNames.RefreshAsync,
  8037. requiredArguments: [],
  8038. supportedOptions: [],
  8039. privateStateCallbacks: [
  8040. {
  8041. name: OSF.DDA.SettingsManager.RefreshingSettings,
  8042. value: function getRefreshingSettings(settingsInstance, settingsCollection) {
  8043. return settingsCollection;
  8044. }
  8045. }
  8046. ],
  8047. onSucceeded: function deserializeSettings(serializedSettingsDescriptor, refreshingSettings, refreshingSettingsArgs) {
  8048. var serializedSettings = serializedSettingsDescriptor[OSF.DDA.SettingsManager.SerializedSettings];
  8049. var newSettings = OSF.DDA.SettingsManager.deserializeSettings(serializedSettings);
  8050. var oldSettings = refreshingSettingsArgs[OSF.DDA.SettingsManager.RefreshingSettings];
  8051. for (var setting in oldSettings) {
  8052. refreshingSettings.remove(setting);
  8053. }
  8054. for (var setting in newSettings) {
  8055. refreshingSettings.set(setting, newSettings[setting]);
  8056. }
  8057. return refreshingSettings;
  8058. }
  8059. });
  8060. OSF.DDA.AsyncMethodCalls.define({
  8061. method: OSF.DDA.AsyncMethodNames.SaveAsync,
  8062. requiredArguments: [],
  8063. supportedOptions: [
  8064. {
  8065. name: Microsoft.Office.WebExtension.Parameters.OverwriteIfStale,
  8066. value: {
  8067. "types": ["boolean"],
  8068. "defaultValue": true
  8069. }
  8070. }
  8071. ],
  8072. privateStateCallbacks: [
  8073. {
  8074. name: OSF.DDA.SettingsManager.SerializedSettings,
  8075. value: function serializeSettings(settingsInstance, settingsCollection) {
  8076. return OSF.DDA.SettingsManager.serializeSettings(settingsCollection);
  8077. }
  8078. }
  8079. ]
  8080. });
  8081. OSF.DDA.WAC.SettingsTranslator = (function () {
  8082. var keyIndex = 0;
  8083. var valueIndex = 1;
  8084. return {
  8085. read: function OSF_DDA_WAC_SettingsTranslator$read(payload) {
  8086. var serializedSettings = {};
  8087. var settingsPayload = payload.Settings;
  8088. for (var index in settingsPayload) {
  8089. var setting = settingsPayload[index];
  8090. serializedSettings[setting[keyIndex]] = setting[valueIndex];
  8091. }
  8092. return serializedSettings;
  8093. },
  8094. write: function OSF_DDA_WAC_SettingsTranslator$write(serializedSettings) {
  8095. var settingsPayload = [];
  8096. for (var key in serializedSettings) {
  8097. var setting = [];
  8098. setting[keyIndex] = key;
  8099. setting[valueIndex] = serializedSettings[key];
  8100. settingsPayload.push(setting);
  8101. }
  8102. return settingsPayload;
  8103. }
  8104. };
  8105. })();
  8106. OSF.DDA.WAC.Delegate.ParameterMap.setDynamicType(OSF.DDA.SettingsManager.SerializedSettings, {
  8107. toHost: OSF.DDA.WAC.SettingsTranslator.write,
  8108. fromHost: OSF.DDA.WAC.SettingsTranslator.read
  8109. });
  8110. OSF.DDA.WAC.Delegate.ParameterMap.define({
  8111. type: OSF.DDA.WAC.UniqueArguments.SettingsRequest,
  8112. toHost: [
  8113. { name: Microsoft.Office.WebExtension.Parameters.OverwriteIfStale, value: "OverwriteIfStale" },
  8114. { name: OSF.DDA.SettingsManager.SerializedSettings, value: OSF.DDA.WAC.UniqueArguments.Properties }
  8115. ],
  8116. invertible: true
  8117. });
  8118. OSF.DDA.WAC.Delegate.ParameterMap.define({
  8119. type: OSF.DDA.MethodDispId.dispidLoadSettingsMethod,
  8120. fromHost: [
  8121. { name: OSF.DDA.SettingsManager.SerializedSettings, value: OSF.DDA.WAC.UniqueArguments.Properties }
  8122. ]
  8123. });
  8124. OSF.DDA.WAC.Delegate.ParameterMap.define({
  8125. type: OSF.DDA.MethodDispId.dispidSaveSettingsMethod,
  8126. toHost: [
  8127. { name: OSF.DDA.WAC.UniqueArguments.SettingsRequest, value: OSF.DDA.WAC.Delegate.ParameterMap.self }
  8128. ]
  8129. });
  8130. OSF.DDA.WAC.Delegate.ParameterMap.define({ type: OSF.DDA.EventDispId.dispidSettingsChangedEvent });
  8131. var OfficeExt;
  8132. (function (OfficeExt) {
  8133. var AppCommand;
  8134. (function (AppCommand) {
  8135. var AppCommandManager = (function () {
  8136. function AppCommandManager() {
  8137. var _this = this;
  8138. this._pseudoDocument = null;
  8139. this._eventDispatch = null;
  8140. this._processAppCommandInvocation = function (args) {
  8141. var verifyResult = _this._verifyManifestCallback(args.callbackName);
  8142. if (verifyResult.errorCode != OSF.DDA.ErrorCodeManager.errorCodes.ooeSuccess) {
  8143. _this._invokeAppCommandCompletedMethod(args.appCommandId, verifyResult.errorCode, "");
  8144. return;
  8145. }
  8146. var eventObj = _this._constructEventObjectForCallback(args);
  8147. if (eventObj) {
  8148. window.setTimeout(function () { verifyResult.callback(eventObj); }, 0);
  8149. }
  8150. else {
  8151. _this._invokeAppCommandCompletedMethod(args.appCommandId, OSF.DDA.ErrorCodeManager.errorCodes.ooeInternalError, "");
  8152. }
  8153. };
  8154. }
  8155. AppCommandManager.initializeOsfDda = function () {
  8156. OSF.DDA.AsyncMethodNames.addNames({
  8157. AppCommandInvocationCompletedAsync: "appCommandInvocationCompletedAsync"
  8158. });
  8159. OSF.DDA.AsyncMethodCalls.define({
  8160. method: OSF.DDA.AsyncMethodNames.AppCommandInvocationCompletedAsync,
  8161. requiredArguments: [{
  8162. "name": Microsoft.Office.WebExtension.Parameters.Id,
  8163. "types": ["string"]
  8164. },
  8165. {
  8166. "name": Microsoft.Office.WebExtension.Parameters.Status,
  8167. "types": ["number"]
  8168. },
  8169. {
  8170. "name": Microsoft.Office.WebExtension.Parameters.Data,
  8171. "types": ["string"]
  8172. }
  8173. ]
  8174. });
  8175. OSF.OUtil.augmentList(OSF.DDA.EventDescriptors, {
  8176. AppCommandInvokedEvent: "AppCommandInvokedEvent"
  8177. });
  8178. OSF.OUtil.augmentList(Microsoft.Office.WebExtension.EventType, {
  8179. AppCommandInvoked: "appCommandInvoked"
  8180. });
  8181. OSF.OUtil.setNamespace("AppCommand", OSF.DDA);
  8182. OSF.DDA.AppCommand.AppCommandInvokedEventArgs = OfficeExt.AppCommand.AppCommandInvokedEventArgs;
  8183. };
  8184. AppCommandManager.prototype.initializeAndChangeOnce = function (callback) {
  8185. AppCommand.registerDdaFacade();
  8186. this._pseudoDocument = {};
  8187. OSF.DDA.DispIdHost.addAsyncMethods(this._pseudoDocument, [
  8188. OSF.DDA.AsyncMethodNames.AppCommandInvocationCompletedAsync,
  8189. ]);
  8190. this._eventDispatch = new OSF.EventDispatch([
  8191. Microsoft.Office.WebExtension.EventType.AppCommandInvoked,
  8192. ]);
  8193. var onRegisterCompleted = function (result) {
  8194. if (callback) {
  8195. if (result.status == "succeeded") {
  8196. callback(OSF.DDA.ErrorCodeManager.errorCodes.ooeSuccess);
  8197. }
  8198. else {
  8199. callback(OSF.DDA.ErrorCodeManager.errorCodes.ooeInternalError);
  8200. }
  8201. }
  8202. };
  8203. OSF.DDA.DispIdHost.addEventSupport(this._pseudoDocument, this._eventDispatch);
  8204. this._pseudoDocument.addHandlerAsync(Microsoft.Office.WebExtension.EventType.AppCommandInvoked, this._processAppCommandInvocation, onRegisterCompleted);
  8205. };
  8206. AppCommandManager.prototype._verifyManifestCallback = function (callbackName) {
  8207. var defaultResult = { callback: null, errorCode: OSF.DDA.ErrorCodeManager.errorCodes.ooeInvalidCallback };
  8208. callbackName = callbackName.trim();
  8209. try {
  8210. var callList = callbackName.split(".");
  8211. var parentObject = window;
  8212. for (var i = 0; i < callList.length - 1; i++) {
  8213. if (parentObject[callList[i]] && (typeof parentObject[callList[i]] == "object" || typeof parentObject[callList[i]] == "function")) {
  8214. parentObject = parentObject[callList[i]];
  8215. }
  8216. else {
  8217. return defaultResult;
  8218. }
  8219. }
  8220. var callbackFunc = parentObject[callList[callList.length - 1]];
  8221. if (typeof callbackFunc != "function") {
  8222. return defaultResult;
  8223. }
  8224. }
  8225. catch (e) {
  8226. return defaultResult;
  8227. }
  8228. return { callback: callbackFunc, errorCode: OSF.DDA.ErrorCodeManager.errorCodes.ooeSuccess };
  8229. };
  8230. AppCommandManager.prototype._invokeAppCommandCompletedMethod = function (appCommandId, resultCode, data) {
  8231. this._pseudoDocument.appCommandInvocationCompletedAsync(appCommandId, resultCode, data);
  8232. };
  8233. AppCommandManager.prototype._constructEventObjectForCallback = function (args) {
  8234. var _this = this;
  8235. var eventObj = new AppCommandCallbackEventArgs();
  8236. try {
  8237. var jsonData = JSON.parse(args.eventObjStr);
  8238. this._translateEventObjectInternal(jsonData, eventObj);
  8239. Object.defineProperty(eventObj, 'completed', {
  8240. value: function (completedContext) {
  8241. eventObj.completedContext = completedContext;
  8242. var jsonString = JSON.stringify(eventObj);
  8243. _this._invokeAppCommandCompletedMethod(args.appCommandId, OSF.DDA.ErrorCodeManager.errorCodes.ooeSuccess, jsonString);
  8244. },
  8245. enumerable: true
  8246. });
  8247. }
  8248. catch (e) {
  8249. eventObj = null;
  8250. }
  8251. return eventObj;
  8252. };
  8253. AppCommandManager.prototype._translateEventObjectInternal = function (input, output) {
  8254. for (var key in input) {
  8255. if (!input.hasOwnProperty(key))
  8256. continue;
  8257. var inputChild = input[key];
  8258. if (typeof inputChild == "object" && inputChild != null) {
  8259. OSF.OUtil.defineEnumerableProperty(output, key, {
  8260. value: {}
  8261. });
  8262. this._translateEventObjectInternal(inputChild, output[key]);
  8263. }
  8264. else {
  8265. Object.defineProperty(output, key, {
  8266. value: inputChild,
  8267. enumerable: true,
  8268. writable: true
  8269. });
  8270. }
  8271. }
  8272. };
  8273. AppCommandManager.prototype._constructObjectByTemplate = function (template, input) {
  8274. var output = {};
  8275. if (!template || !input)
  8276. return output;
  8277. for (var key in template) {
  8278. if (template.hasOwnProperty(key)) {
  8279. output[key] = null;
  8280. if (input[key] != null) {
  8281. var templateChild = template[key];
  8282. var inputChild = input[key];
  8283. var inputChildType = typeof inputChild;
  8284. if (typeof templateChild == "object" && templateChild != null) {
  8285. output[key] = this._constructObjectByTemplate(templateChild, inputChild);
  8286. }
  8287. else if (inputChildType == "number" || inputChildType == "string" || inputChildType == "boolean") {
  8288. output[key] = inputChild;
  8289. }
  8290. }
  8291. }
  8292. }
  8293. return output;
  8294. };
  8295. AppCommandManager.instance = function () {
  8296. if (AppCommandManager._instance == null) {
  8297. AppCommandManager._instance = new AppCommandManager();
  8298. }
  8299. return AppCommandManager._instance;
  8300. };
  8301. AppCommandManager._instance = null;
  8302. return AppCommandManager;
  8303. })();
  8304. AppCommand.AppCommandManager = AppCommandManager;
  8305. var AppCommandInvokedEventArgs = (function () {
  8306. function AppCommandInvokedEventArgs(appCommandId, callbackName, eventObjStr) {
  8307. this.type = Microsoft.Office.WebExtension.EventType.AppCommandInvoked;
  8308. this.appCommandId = appCommandId;
  8309. this.callbackName = callbackName;
  8310. this.eventObjStr = eventObjStr;
  8311. }
  8312. AppCommandInvokedEventArgs.create = function (eventProperties) {
  8313. return new AppCommandInvokedEventArgs(eventProperties[AppCommand.AppCommandInvokedEventEnums.AppCommandId], eventProperties[AppCommand.AppCommandInvokedEventEnums.CallbackName], eventProperties[AppCommand.AppCommandInvokedEventEnums.EventObjStr]);
  8314. };
  8315. return AppCommandInvokedEventArgs;
  8316. })();
  8317. AppCommand.AppCommandInvokedEventArgs = AppCommandInvokedEventArgs;
  8318. var AppCommandCallbackEventArgs = (function () {
  8319. function AppCommandCallbackEventArgs() {
  8320. }
  8321. return AppCommandCallbackEventArgs;
  8322. })();
  8323. AppCommand.AppCommandCallbackEventArgs = AppCommandCallbackEventArgs;
  8324. AppCommand.AppCommandInvokedEventEnums = {
  8325. AppCommandId: "appCommandId",
  8326. CallbackName: "callbackName",
  8327. EventObjStr: "eventObjStr"
  8328. };
  8329. })(AppCommand = OfficeExt.AppCommand || (OfficeExt.AppCommand = {}));
  8330. })(OfficeExt || (OfficeExt = {}));
  8331. OfficeExt.AppCommand.AppCommandManager.initializeOsfDda();
  8332. OSF.OUtil.setNamespace("Marshaling", OSF.DDA);
  8333. OSF.OUtil.setNamespace("AppCommand", OSF.DDA.Marshaling);
  8334. var OSF_DDA_Marshaling_AppCommand_AppCommandInvokedEventKeys;
  8335. (function (OSF_DDA_Marshaling_AppCommand_AppCommandInvokedEventKeys) {
  8336. OSF_DDA_Marshaling_AppCommand_AppCommandInvokedEventKeys[OSF_DDA_Marshaling_AppCommand_AppCommandInvokedEventKeys["AppCommandId"] = 0] = "AppCommandId";
  8337. OSF_DDA_Marshaling_AppCommand_AppCommandInvokedEventKeys[OSF_DDA_Marshaling_AppCommand_AppCommandInvokedEventKeys["CallbackName"] = 1] = "CallbackName";
  8338. OSF_DDA_Marshaling_AppCommand_AppCommandInvokedEventKeys[OSF_DDA_Marshaling_AppCommand_AppCommandInvokedEventKeys["EventObjStr"] = 2] = "EventObjStr";
  8339. })(OSF_DDA_Marshaling_AppCommand_AppCommandInvokedEventKeys || (OSF_DDA_Marshaling_AppCommand_AppCommandInvokedEventKeys = {}));
  8340. ;
  8341. OSF.DDA.Marshaling.AppCommand.AppCommandInvokedEventKeys = OSF_DDA_Marshaling_AppCommand_AppCommandInvokedEventKeys;
  8342. var OSF_DDA_Marshaling_AppCommand_AppCommandCompletedMethodParameterKeys;
  8343. (function (OSF_DDA_Marshaling_AppCommand_AppCommandCompletedMethodParameterKeys) {
  8344. OSF_DDA_Marshaling_AppCommand_AppCommandCompletedMethodParameterKeys[OSF_DDA_Marshaling_AppCommand_AppCommandCompletedMethodParameterKeys["Id"] = 0] = "Id";
  8345. OSF_DDA_Marshaling_AppCommand_AppCommandCompletedMethodParameterKeys[OSF_DDA_Marshaling_AppCommand_AppCommandCompletedMethodParameterKeys["Status"] = 1] = "Status";
  8346. OSF_DDA_Marshaling_AppCommand_AppCommandCompletedMethodParameterKeys[OSF_DDA_Marshaling_AppCommand_AppCommandCompletedMethodParameterKeys["Data"] = 2] = "Data";
  8347. })(OSF_DDA_Marshaling_AppCommand_AppCommandCompletedMethodParameterKeys || (OSF_DDA_Marshaling_AppCommand_AppCommandCompletedMethodParameterKeys = {}));
  8348. ;
  8349. OSF.DDA.Marshaling.AppCommand.AppCommandCompletedMethodParameterKeys = OSF_DDA_Marshaling_AppCommand_AppCommandCompletedMethodParameterKeys;
  8350. var OfficeExt;
  8351. (function (OfficeExt) {
  8352. var AppCommand;
  8353. (function (AppCommand) {
  8354. function registerDdaFacade() {
  8355. if (OSF.DDA.WAC) {
  8356. var parameterMap = OSF.DDA.WAC.Delegate.ParameterMap;
  8357. parameterMap.define({
  8358. type: OSF.DDA.MethodDispId.dispidAppCommandInvocationCompletedMethod,
  8359. toHost: [
  8360. { name: Microsoft.Office.WebExtension.Parameters.Id, value: OSF.DDA.Marshaling.AppCommand.AppCommandCompletedMethodParameterKeys.Id },
  8361. { name: Microsoft.Office.WebExtension.Parameters.Status, value: OSF.DDA.Marshaling.AppCommand.AppCommandCompletedMethodParameterKeys.Status },
  8362. { name: Microsoft.Office.WebExtension.Parameters.Data, value: OSF.DDA.Marshaling.AppCommand.AppCommandCompletedMethodParameterKeys.Data }
  8363. ]
  8364. });
  8365. parameterMap.define({
  8366. type: OSF.DDA.EventDispId.dispidAppCommandInvokedEvent,
  8367. fromHost: [
  8368. { name: OSF.DDA.EventDescriptors.AppCommandInvokedEvent, value: parameterMap.self }
  8369. ]
  8370. });
  8371. parameterMap.addComplexType(OSF.DDA.EventDescriptors.AppCommandInvokedEvent);
  8372. parameterMap.define({
  8373. type: OSF.DDA.EventDescriptors.AppCommandInvokedEvent,
  8374. fromHost: [
  8375. { name: OfficeExt.AppCommand.AppCommandInvokedEventEnums.AppCommandId, value: OSF.DDA.Marshaling.AppCommand.AppCommandInvokedEventKeys.AppCommandId },
  8376. { name: OfficeExt.AppCommand.AppCommandInvokedEventEnums.CallbackName, value: OSF.DDA.Marshaling.AppCommand.AppCommandInvokedEventKeys.CallbackName },
  8377. { name: OfficeExt.AppCommand.AppCommandInvokedEventEnums.EventObjStr, value: OSF.DDA.Marshaling.AppCommand.AppCommandInvokedEventKeys.EventObjStr },
  8378. ]
  8379. });
  8380. }
  8381. }
  8382. AppCommand.registerDdaFacade = registerDdaFacade;
  8383. })(AppCommand = OfficeExt.AppCommand || (OfficeExt.AppCommand = {}));
  8384. })(OfficeExt || (OfficeExt = {}));
  8385. OSF.OUtil.augmentList(Microsoft.Office.WebExtension.CoercionType, { Image: "image" });
  8386. OSF.OUtil.augmentList(Microsoft.Office.WebExtension.EventType, { DocumentSelectionChanged: "documentSelectionChanged" });
  8387. OSF.DDA.DocumentSelectionChangedEventArgs = function OSF_DDA_DocumentSelectionChangedEventArgs(docInstance) {
  8388. OSF.OUtil.defineEnumerableProperties(this, {
  8389. "type": {
  8390. value: Microsoft.Office.WebExtension.EventType.DocumentSelectionChanged
  8391. },
  8392. "document": {
  8393. value: docInstance
  8394. }
  8395. });
  8396. };
  8397. OSF.DDA.WAC.Delegate.ParameterMap.define({ type: OSF.DDA.EventDispId.dispidDocumentSelectionChangedEvent });
  8398. OSF.DialogShownStatus = { hasDialogShown: false, isWindowDialog: false };
  8399. OSF.OUtil.augmentList(OSF.DDA.EventDescriptors, {
  8400. DialogMessageReceivedEvent: "DialogMessageReceivedEvent"
  8401. });
  8402. OSF.OUtil.augmentList(Microsoft.Office.WebExtension.EventType, {
  8403. DialogMessageReceived: "dialogMessageReceived",
  8404. DialogEventReceived: "dialogEventReceived"
  8405. });
  8406. OSF.OUtil.augmentList(OSF.DDA.PropertyDescriptors, {
  8407. MessageType: "messageType",
  8408. MessageContent: "messageContent"
  8409. });
  8410. OSF.DDA.DialogEventType = {};
  8411. OSF.OUtil.augmentList(OSF.DDA.DialogEventType, {
  8412. DialogClosed: "dialogClosed",
  8413. NavigationFailed: "naviationFailed"
  8414. });
  8415. OSF.DDA.AsyncMethodNames.addNames({
  8416. DisplayDialogAsync: "displayDialogAsync",
  8417. CloseAsync: "close"
  8418. });
  8419. OSF.DDA.SyncMethodNames.addNames({
  8420. MessageParent: "messageParent",
  8421. AddMessageHandler: "addEventHandler",
  8422. SendMessage: "sendMessage"
  8423. });
  8424. OSF.DDA.UI.ParentUI = function OSF_DDA_ParentUI() {
  8425. var eventDispatch = new OSF.EventDispatch([
  8426. Microsoft.Office.WebExtension.EventType.DialogMessageReceived,
  8427. Microsoft.Office.WebExtension.EventType.DialogEventReceived,
  8428. Microsoft.Office.WebExtension.EventType.DialogParentMessageReceived
  8429. ]);
  8430. var openDialogName = OSF.DDA.AsyncMethodNames.DisplayDialogAsync.displayName;
  8431. var target = this;
  8432. if (!target[openDialogName]) {
  8433. OSF.OUtil.defineEnumerableProperty(target, openDialogName, {
  8434. value: function () {
  8435. var openDialog = OSF._OfficeAppFactory.getHostFacade()[OSF.DDA.DispIdHost.Methods.OpenDialog];
  8436. openDialog(arguments, eventDispatch, target);
  8437. }
  8438. });
  8439. }
  8440. OSF.OUtil.finalizeProperties(this);
  8441. };
  8442. OSF.DDA.UI.ChildUI = function OSF_DDA_ChildUI(isPopupWindow) {
  8443. var messageParentName = OSF.DDA.SyncMethodNames.MessageParent.displayName;
  8444. var target = this;
  8445. if (!target[messageParentName]) {
  8446. OSF.OUtil.defineEnumerableProperty(target, messageParentName, {
  8447. value: function () {
  8448. var messageParent = OSF._OfficeAppFactory.getHostFacade()[OSF.DDA.DispIdHost.Methods.MessageParent];
  8449. return messageParent(arguments, target);
  8450. }
  8451. });
  8452. }
  8453. var addEventHandler = OSF.DDA.SyncMethodNames.AddMessageHandler.displayName;
  8454. if (!target[addEventHandler] && typeof OSF.DialogParentMessageEventDispatch != "undefined") {
  8455. OSF.DDA.DispIdHost.addEventSupport(target, OSF.DialogParentMessageEventDispatch, isPopupWindow);
  8456. }
  8457. OSF.OUtil.finalizeProperties(this);
  8458. };
  8459. OSF.DialogHandler = function OSF_DialogHandler() { };
  8460. OSF.DDA.DialogEventArgs = function OSF_DDA_DialogEventArgs(message) {
  8461. if (message[OSF.DDA.PropertyDescriptors.MessageType] == OSF.DialogMessageType.DialogMessageReceived) {
  8462. OSF.OUtil.defineEnumerableProperties(this, {
  8463. "type": {
  8464. value: Microsoft.Office.WebExtension.EventType.DialogMessageReceived
  8465. },
  8466. "message": {
  8467. value: message[OSF.DDA.PropertyDescriptors.MessageContent]
  8468. }
  8469. });
  8470. }
  8471. else {
  8472. OSF.OUtil.defineEnumerableProperties(this, {
  8473. "type": {
  8474. value: Microsoft.Office.WebExtension.EventType.DialogEventReceived
  8475. },
  8476. "error": {
  8477. value: message[OSF.DDA.PropertyDescriptors.MessageType]
  8478. }
  8479. });
  8480. }
  8481. };
  8482. OSF.DDA.DialogParentEventArgs = function OSF_DDA_DialogParentEventArgs(message) {
  8483. OSF.OUtil.defineEnumerableProperties(this, {
  8484. "type": {
  8485. value: Microsoft.Office.WebExtension.EventType.DialogParentMessageReceived
  8486. },
  8487. "message": {
  8488. value: message[OSF.DDA.PropertyDescriptors.MessageContent]
  8489. }
  8490. });
  8491. };
  8492. OSF.DDA.AsyncMethodCalls.define({
  8493. method: OSF.DDA.AsyncMethodNames.DisplayDialogAsync,
  8494. requiredArguments: [
  8495. {
  8496. "name": Microsoft.Office.WebExtension.Parameters.Url,
  8497. "types": ["string"]
  8498. }
  8499. ],
  8500. supportedOptions: [
  8501. {
  8502. name: Microsoft.Office.WebExtension.Parameters.Width,
  8503. value: {
  8504. "types": ["number"],
  8505. "defaultValue": 99
  8506. }
  8507. },
  8508. {
  8509. name: Microsoft.Office.WebExtension.Parameters.Height,
  8510. value: {
  8511. "types": ["number"],
  8512. "defaultValue": 99
  8513. }
  8514. },
  8515. {
  8516. name: Microsoft.Office.WebExtension.Parameters.RequireHTTPs,
  8517. value: {
  8518. "types": ["boolean"],
  8519. "defaultValue": true
  8520. }
  8521. },
  8522. {
  8523. name: Microsoft.Office.WebExtension.Parameters.DisplayInIframe,
  8524. value: {
  8525. "types": ["boolean"],
  8526. "defaultValue": false
  8527. }
  8528. }
  8529. ],
  8530. privateStateCallbacks: [],
  8531. onSucceeded: function (args, caller, callArgs) {
  8532. var targetId = args[Microsoft.Office.WebExtension.Parameters.Id];
  8533. var eventDispatch = args[Microsoft.Office.WebExtension.Parameters.Data];
  8534. var dialog = new OSF.DialogHandler();
  8535. var closeDialog = OSF.DDA.AsyncMethodNames.CloseAsync.displayName;
  8536. OSF.OUtil.defineEnumerableProperty(dialog, closeDialog, {
  8537. value: function () {
  8538. var closeDialogfunction = OSF._OfficeAppFactory.getHostFacade()[OSF.DDA.DispIdHost.Methods.CloseDialog];
  8539. closeDialogfunction(arguments, targetId, eventDispatch, dialog);
  8540. }
  8541. });
  8542. var addHandler = OSF.DDA.SyncMethodNames.AddMessageHandler.displayName;
  8543. OSF.OUtil.defineEnumerableProperty(dialog, addHandler, {
  8544. value: function () {
  8545. var syncMethodCall = OSF.DDA.SyncMethodCalls[OSF.DDA.SyncMethodNames.AddMessageHandler.id];
  8546. var callArgs = syncMethodCall.verifyAndExtractCall(arguments, dialog, eventDispatch);
  8547. var eventType = callArgs[Microsoft.Office.WebExtension.Parameters.EventType];
  8548. var handler = callArgs[Microsoft.Office.WebExtension.Parameters.Handler];
  8549. return eventDispatch.addEventHandlerAndFireQueuedEvent(eventType, handler);
  8550. }
  8551. });
  8552. var sendMessage = OSF.DDA.SyncMethodNames.SendMessage.displayName;
  8553. OSF.OUtil.defineEnumerableProperty(dialog, sendMessage, {
  8554. value: function () {
  8555. var execute = OSF._OfficeAppFactory.getHostFacade()[OSF.DDA.DispIdHost.Methods.SendMessage];
  8556. return execute(arguments, eventDispatch, dialog);
  8557. }
  8558. });
  8559. return dialog;
  8560. },
  8561. checkCallArgs: function (callArgs, caller, stateInfo) {
  8562. if (callArgs[Microsoft.Office.WebExtension.Parameters.Width] <= 0) {
  8563. callArgs[Microsoft.Office.WebExtension.Parameters.Width] = 1;
  8564. }
  8565. if (callArgs[Microsoft.Office.WebExtension.Parameters.Width] > 100) {
  8566. callArgs[Microsoft.Office.WebExtension.Parameters.Width] = 99;
  8567. }
  8568. if (callArgs[Microsoft.Office.WebExtension.Parameters.Height] <= 0) {
  8569. callArgs[Microsoft.Office.WebExtension.Parameters.Height] = 1;
  8570. }
  8571. if (callArgs[Microsoft.Office.WebExtension.Parameters.Height] > 100) {
  8572. callArgs[Microsoft.Office.WebExtension.Parameters.Height] = 99;
  8573. }
  8574. if (!callArgs[Microsoft.Office.WebExtension.Parameters.RequireHTTPs]) {
  8575. callArgs[Microsoft.Office.WebExtension.Parameters.RequireHTTPs] = true;
  8576. }
  8577. return callArgs;
  8578. }
  8579. });
  8580. OSF.DDA.AsyncMethodCalls.define({
  8581. method: OSF.DDA.AsyncMethodNames.CloseAsync,
  8582. requiredArguments: [],
  8583. supportedOptions: [],
  8584. privateStateCallbacks: []
  8585. });
  8586. OSF.DDA.SyncMethodCalls.define({
  8587. method: OSF.DDA.SyncMethodNames.MessageParent,
  8588. requiredArguments: [
  8589. {
  8590. "name": Microsoft.Office.WebExtension.Parameters.MessageToParent,
  8591. "types": ["string", "number", "boolean"]
  8592. }
  8593. ],
  8594. supportedOptions: []
  8595. });
  8596. OSF.DDA.SyncMethodCalls.define({
  8597. method: OSF.DDA.SyncMethodNames.AddMessageHandler,
  8598. requiredArguments: [
  8599. {
  8600. "name": Microsoft.Office.WebExtension.Parameters.EventType,
  8601. "enum": Microsoft.Office.WebExtension.EventType,
  8602. "verify": function (eventType, caller, eventDispatch) { return eventDispatch.supportsEvent(eventType); }
  8603. },
  8604. {
  8605. "name": Microsoft.Office.WebExtension.Parameters.Handler,
  8606. "types": ["function"]
  8607. }
  8608. ],
  8609. supportedOptions: []
  8610. });
  8611. OSF.DDA.SyncMethodCalls.define({
  8612. method: OSF.DDA.SyncMethodNames.SendMessage,
  8613. requiredArguments: [
  8614. {
  8615. "name": Microsoft.Office.WebExtension.Parameters.MessageContent,
  8616. "types": ["string"]
  8617. }
  8618. ],
  8619. supportedOptions: [],
  8620. privateStateCallbacks: []
  8621. });
  8622. OSF.OUtil.setNamespace("Marshaling", OSF.DDA);
  8623. OSF.OUtil.setNamespace("Dialog", OSF.DDA.Marshaling);
  8624. OSF.DDA.Marshaling.Dialog.DialogMessageReceivedEventKeys = {
  8625. MessageType: "messageType",
  8626. MessageContent: "messageContent"
  8627. };
  8628. OSF.DDA.Marshaling.Dialog.DialogParentMessageReceivedEventKeys = {
  8629. MessageType: "messageType",
  8630. MessageContent: "messageContent"
  8631. };
  8632. OSF.DDA.Marshaling.MessageParentKeys = {
  8633. MessageToParent: "messageToParent"
  8634. };
  8635. OSF.DDA.Marshaling.DialogNotificationShownEventType = {
  8636. DialogNotificationShown: "dialogNotificationShown"
  8637. };
  8638. OSF.DDA.Marshaling.SendMessageKeys = {
  8639. MessageContent: "messageContent"
  8640. };
  8641. var OfficeExt;
  8642. (function (OfficeExt) {
  8643. var WacCommonUICssManager;
  8644. (function (WacCommonUICssManager) {
  8645. var hostType = {
  8646. Excel: "excel",
  8647. Word: "word",
  8648. PowerPoint: "powerpoint",
  8649. Outlook: "outlook"
  8650. };
  8651. function getDialogCssManager(applicationHostType) {
  8652. switch (applicationHostType) {
  8653. case hostType.Excel:
  8654. case hostType.Word:
  8655. case hostType.PowerPoint:
  8656. case hostType.Outlook:
  8657. return new DefaultDialogCSSManager();
  8658. default:
  8659. return new DefaultDialogCSSManager();
  8660. }
  8661. return null;
  8662. }
  8663. WacCommonUICssManager.getDialogCssManager = getDialogCssManager;
  8664. var DefaultDialogCSSManager = (function () {
  8665. function DefaultDialogCSSManager() {
  8666. this.overlayElementCSS = [
  8667. "position: absolute",
  8668. "top: 0",
  8669. "left: 0",
  8670. "width: 100%",
  8671. "height: 100%",
  8672. "background-color: rgba(198, 198, 198, 0.5)",
  8673. "z-index: 99998"
  8674. ];
  8675. this.dialogNotificationPanelCSS = [
  8676. "width: 100%",
  8677. "height: 190px",
  8678. "position: absolute",
  8679. "z-index: 99999",
  8680. "background-color: rgba(255, 255, 255, 1)",
  8681. "left: 0px",
  8682. "top: 50%",
  8683. "margin-top: -95px"
  8684. ];
  8685. this.newWindowNotificationTextPanelCSS = [
  8686. "margin: 20px 14px",
  8687. "font-family: Segoe UI,Arial,Verdana,sans-serif",
  8688. "font-size: 14px",
  8689. "height: 100px",
  8690. "line-height: 100px"
  8691. ];
  8692. this.newWindowNotificationTextSpanCSS = [
  8693. "display: inline-block",
  8694. "line-height: normal",
  8695. "vertical-align: middle"
  8696. ];
  8697. this.crossZoneNotificationTextPanelCSS = [
  8698. "margin: 20px 14px",
  8699. "font-family: Segoe UI,Arial,Verdana,sans-serif",
  8700. "font-size: 14px",
  8701. "height: 100px",
  8702. ];
  8703. this.dialogNotificationButtonPanelCSS = "margin:0px 9px";
  8704. this.buttonStyleCSS = [
  8705. "text-align: center",
  8706. "width: 70px",
  8707. "height: 25px",
  8708. "font-size: 14px",
  8709. "font-family: Segoe UI,Arial,Verdana,sans-serif",
  8710. "margin: 0px 5px",
  8711. "border-width: 1px",
  8712. "border-style: solid"
  8713. ];
  8714. }
  8715. DefaultDialogCSSManager.prototype.getOverlayElementCSS = function () {
  8716. return this.overlayElementCSS.join(";");
  8717. };
  8718. DefaultDialogCSSManager.prototype.getDialogNotificationPanelCSS = function () {
  8719. return this.dialogNotificationPanelCSS.join(";");
  8720. };
  8721. DefaultDialogCSSManager.prototype.getNewWindowNotificationTextPanelCSS = function () {
  8722. return this.newWindowNotificationTextPanelCSS.join(";");
  8723. };
  8724. DefaultDialogCSSManager.prototype.getNewWindowNotificationTextSpanCSS = function () {
  8725. return this.newWindowNotificationTextSpanCSS.join(";");
  8726. };
  8727. DefaultDialogCSSManager.prototype.getCrossZoneNotificationTextPanelCSS = function () {
  8728. return this.crossZoneNotificationTextPanelCSS.join(";");
  8729. };
  8730. DefaultDialogCSSManager.prototype.getDialogNotificationButtonPanelCSS = function () {
  8731. return this.dialogNotificationButtonPanelCSS;
  8732. };
  8733. DefaultDialogCSSManager.prototype.getDialogButtonCSS = function () {
  8734. return this.buttonStyleCSS.join(";");
  8735. };
  8736. return DefaultDialogCSSManager;
  8737. })();
  8738. WacCommonUICssManager.DefaultDialogCSSManager = DefaultDialogCSSManager;
  8739. })(WacCommonUICssManager = OfficeExt.WacCommonUICssManager || (OfficeExt.WacCommonUICssManager = {}));
  8740. })(OfficeExt || (OfficeExt = {}));
  8741. var OfficeExt;
  8742. (function (OfficeExt) {
  8743. var AddinNativeAction;
  8744. (function (AddinNativeAction) {
  8745. var Dialog;
  8746. (function (Dialog) {
  8747. var windowInstance = null;
  8748. var handler = null;
  8749. var overlayElement = null;
  8750. var dialogNotificationPanel = null;
  8751. var closeDialogKey = "osfDialogInternal:action=closeDialog";
  8752. var showDialogCallback = null;
  8753. var hasCrossZoneNotification = false;
  8754. var checkWindowDialogCloseInterval = -1;
  8755. var hostThemeButtonStyle = null;
  8756. var commonButtonBorderColor = "#ababab";
  8757. var commonButtonBackgroundColor = "#ffffff";
  8758. var commonEventInButtonBackgroundColor = "#ccc";
  8759. var newWindowNotificationId = "newWindowNotificaiton";
  8760. var crossZoneNotificationId = "crossZoneNotification";
  8761. var configureBrowserLinkId = "configureBrowserLink";
  8762. var registerDialogNotificationShownArgs = {
  8763. "dispId": OSF.DDA.EventDispId.dispidDialogNotificationShownInAddinEvent,
  8764. "eventType": OSF.DDA.Marshaling.DialogNotificationShownEventType.DialogNotificationShown,
  8765. "onComplete": null
  8766. };
  8767. function setHostThemeButtonStyle(args) {
  8768. var hostThemeButtonStyleArgs = args.input;
  8769. if (hostThemeButtonStyleArgs != null) {
  8770. hostThemeButtonStyle = {
  8771. HostButtonBorderColor: hostThemeButtonStyleArgs[OSF.HostThemeButtonStyleKeys.ButtonBorderColor],
  8772. HostButtonBackgroundColor: hostThemeButtonStyleArgs[OSF.HostThemeButtonStyleKeys.ButtonBackgroundColor]
  8773. };
  8774. }
  8775. args.completed();
  8776. }
  8777. Dialog.setHostThemeButtonStyle = setHostThemeButtonStyle;
  8778. function handleNewWindowDialog(dialogInfo) {
  8779. try {
  8780. hasCrossZoneNotification = false;
  8781. var ignoreButtonKeyDownClick = false;
  8782. var hostInfoObj = OSF._OfficeAppFactory.getInitializationHelper()._hostInfo;
  8783. var dialogCssManager = OfficeExt.WacCommonUICssManager.getDialogCssManager(hostInfoObj.hostType);
  8784. var notificationText = OSF.OUtil.formatString(Strings.OfficeOM.L_ShowWindowDialogNotification, OSF._OfficeAppFactory.getInitializationHelper()._appContext._addinName);
  8785. overlayElement = createOverlayElement(dialogCssManager);
  8786. document.body.insertBefore(overlayElement, document.body.firstChild);
  8787. dialogNotificationPanel = createNotificationPanel(dialogCssManager, notificationText);
  8788. dialogNotificationPanel.id = newWindowNotificationId;
  8789. var dialogNotificationButtonPanel = createButtonPanel(dialogCssManager);
  8790. var allowButton = createButtonControl(dialogCssManager, Strings.OfficeOM.L_ShowWindowDialogNotificationAllow);
  8791. var ignoreButton = createButtonControl(dialogCssManager, Strings.OfficeOM.L_ShowWindowDialogNotificationIgnore);
  8792. dialogNotificationButtonPanel.appendChild(allowButton);
  8793. dialogNotificationButtonPanel.appendChild(ignoreButton);
  8794. dialogNotificationPanel.appendChild(dialogNotificationButtonPanel);
  8795. document.body.insertBefore(dialogNotificationPanel, document.body.firstChild);
  8796. allowButton.onclick = function () {
  8797. showDialog(dialogInfo);
  8798. if (!hasCrossZoneNotification) {
  8799. dismissDialogNotification();
  8800. }
  8801. };
  8802. function ignoreButtonClickEventHandler() {
  8803. function unregisterDialogNotificationShownEventCallback(status) {
  8804. removeDialogNotificationElement();
  8805. setFocusOnFirstElement(status);
  8806. showDialogCallback(OSF.DDA.ErrorCodeManager.errorCodes.ooeEndUserIgnore);
  8807. }
  8808. registerDialogNotificationShownArgs.onComplete = unregisterDialogNotificationShownEventCallback;
  8809. OSF.DDA.WAC.Delegate.unregisterEventAsync(registerDialogNotificationShownArgs);
  8810. }
  8811. ignoreButton.onclick = ignoreButtonClickEventHandler;
  8812. allowButton.addEventListener("keydown", function (event) {
  8813. if (event.shiftKey && event.keyCode == 9) {
  8814. handleButtonControlEventOut(allowButton);
  8815. handleButtonControlEventIn(ignoreButton);
  8816. ignoreButton.focus();
  8817. event.preventDefault();
  8818. event.stopPropagation();
  8819. }
  8820. }, false);
  8821. ignoreButton.addEventListener("keydown", function (event) {
  8822. if (!event.shiftKey && event.keyCode == 9) {
  8823. handleButtonControlEventOut(ignoreButton);
  8824. handleButtonControlEventIn(allowButton);
  8825. allowButton.focus();
  8826. event.preventDefault();
  8827. event.stopPropagation();
  8828. }
  8829. else if (event.keyCode == 13) {
  8830. ignoreButtonKeyDownClick = true;
  8831. event.preventDefault();
  8832. event.stopPropagation();
  8833. }
  8834. }, false);
  8835. ignoreButton.addEventListener("keyup", function (event) {
  8836. if (event.keyCode == 13 && ignoreButtonKeyDownClick) {
  8837. ignoreButtonKeyDownClick = false;
  8838. ignoreButtonClickEventHandler();
  8839. event.preventDefault();
  8840. event.stopPropagation();
  8841. }
  8842. }, false);
  8843. window.focus();
  8844. function registerDialogNotificationShownEventCallback(status) {
  8845. allowButton.focus();
  8846. }
  8847. registerDialogNotificationShownArgs.onComplete = registerDialogNotificationShownEventCallback;
  8848. OSF.DDA.WAC.Delegate.registerEventAsync(registerDialogNotificationShownArgs);
  8849. }
  8850. catch (e) {
  8851. if (OSF.AppTelemetry) {
  8852. OSF.AppTelemetry.logAppException("Exception happens at new window dialog." + e);
  8853. }
  8854. showDialogCallback(OSF.DDA.ErrorCodeManager.errorCodes.ooeInternalError);
  8855. }
  8856. }
  8857. Dialog.handleNewWindowDialog = handleNewWindowDialog;
  8858. function closeDialog(callback) {
  8859. try {
  8860. if (windowInstance != null) {
  8861. var appDomains = OSF._OfficeAppFactory.getInitializationHelper()._appContext._appDomains;
  8862. if (appDomains) {
  8863. for (var i = 0; i < appDomains.length && appDomains[i].indexOf("://") !== -1; i++) {
  8864. windowInstance.postMessage(closeDialogKey, appDomains[i]);
  8865. }
  8866. }
  8867. if (windowInstance != null && !windowInstance.closed) {
  8868. windowInstance.close();
  8869. }
  8870. window.removeEventListener("message", receiveMessage);
  8871. window.clearInterval(checkWindowDialogCloseInterval);
  8872. windowInstance = null;
  8873. callback(OSF.DDA.ErrorCodeManager.errorCodes.ooeSuccess);
  8874. }
  8875. else {
  8876. callback(OSF.DDA.ErrorCodeManager.errorCodes.ooeInternalError);
  8877. }
  8878. }
  8879. catch (e) {
  8880. if (OSF.AppTelemetry) {
  8881. OSF.AppTelemetry.logAppException("Exception happens at close window dialog." + e);
  8882. }
  8883. callback(OSF.DDA.ErrorCodeManager.errorCodes.ooeInternalError);
  8884. }
  8885. }
  8886. Dialog.closeDialog = closeDialog;
  8887. function messageParent(params) {
  8888. var message = params.hostCallArgs[Microsoft.Office.WebExtension.Parameters.MessageToParent];
  8889. var appDomains = OSF._OfficeAppFactory.getInitializationHelper()._appContext._appDomains;
  8890. if (appDomains) {
  8891. for (var i = 0; i < appDomains.length && appDomains[i].indexOf("://") !== -1; i++) {
  8892. window.opener.postMessage(message, appDomains[i]);
  8893. }
  8894. }
  8895. }
  8896. Dialog.messageParent = messageParent;
  8897. function sendMessage(params) {
  8898. if (windowInstance != null) {
  8899. var message = params.hostCallArgs, appDomains = OSF._OfficeAppFactory.getInitializationHelper()._appContext._appDomains;
  8900. if (appDomains) {
  8901. for (var i = 0; i < appDomains.length && appDomains[i].indexOf("://") !== -1; i++) {
  8902. if (typeof message != "string") {
  8903. message = JSON.stringify(message);
  8904. }
  8905. windowInstance.postMessage(message, appDomains[i]);
  8906. }
  8907. }
  8908. }
  8909. }
  8910. Dialog.sendMessage = sendMessage;
  8911. function registerMessageReceivedEvent() {
  8912. function receiveCloseDialogMessage(event) {
  8913. if (event.source == window.opener) {
  8914. if (typeof event.data === "string" && event.data.indexOf(closeDialogKey) > -1) {
  8915. window.close();
  8916. }
  8917. else {
  8918. var messageContent = event.data, type = typeof messageContent;
  8919. if (messageContent && (type == "object" || type == "string")) {
  8920. if (type == "string") {
  8921. messageContent = JSON.parse(messageContent);
  8922. }
  8923. var eventArgs = OSF.DDA.OMFactory.manufactureEventArgs(Microsoft.Office.WebExtension.EventType.DialogParentMessageReceived, null, messageContent);
  8924. OSF.DialogParentMessageEventDispatch.fireEvent(eventArgs);
  8925. }
  8926. }
  8927. }
  8928. }
  8929. window.addEventListener("message", receiveCloseDialogMessage);
  8930. }
  8931. Dialog.registerMessageReceivedEvent = registerMessageReceivedEvent;
  8932. function setHandlerAndShowDialogCallback(onEventHandler, callback) {
  8933. handler = onEventHandler;
  8934. showDialogCallback = callback;
  8935. }
  8936. Dialog.setHandlerAndShowDialogCallback = setHandlerAndShowDialogCallback;
  8937. function escDismissDialogNotification() {
  8938. try {
  8939. if (dialogNotificationPanel && (dialogNotificationPanel.id == newWindowNotificationId) && showDialogCallback) {
  8940. showDialogCallback(OSF.DDA.ErrorCodeManager.errorCodes.ooeEndUserIgnore);
  8941. }
  8942. }
  8943. catch (e) {
  8944. if (OSF.AppTelemetry) {
  8945. OSF.AppTelemetry.logAppException("Error happened during executing displayDialogAsync callback." + e);
  8946. }
  8947. }
  8948. dismissDialogNotification();
  8949. }
  8950. Dialog.escDismissDialogNotification = escDismissDialogNotification;
  8951. function showCrossZoneNotification(windowUrl, hostType) {
  8952. var okButtonKeyDownClick = false;
  8953. var dialogCssManager = OfficeExt.WacCommonUICssManager.getDialogCssManager(hostType);
  8954. overlayElement = createOverlayElement(dialogCssManager);
  8955. document.body.insertBefore(overlayElement, document.body.firstChild);
  8956. dialogNotificationPanel = createNotificationPanelForCrossZoneIssue(dialogCssManager, windowUrl);
  8957. dialogNotificationPanel.id = crossZoneNotificationId;
  8958. var dialogNotificationButtonPanel = createButtonPanel(dialogCssManager);
  8959. var okButton = createButtonControl(dialogCssManager, "OK");
  8960. dialogNotificationButtonPanel.appendChild(okButton);
  8961. dialogNotificationPanel.appendChild(dialogNotificationButtonPanel);
  8962. document.body.insertBefore(dialogNotificationPanel, document.body.firstChild);
  8963. hasCrossZoneNotification = true;
  8964. okButton.onclick = function () {
  8965. dismissDialogNotification();
  8966. };
  8967. okButton.addEventListener("keydown", function (event) {
  8968. if (event.keyCode == 9) {
  8969. document.getElementById(configureBrowserLinkId).focus();
  8970. event.preventDefault();
  8971. event.stopPropagation();
  8972. }
  8973. else if (event.keyCode == 13) {
  8974. okButtonKeyDownClick = true;
  8975. event.preventDefault();
  8976. event.stopPropagation();
  8977. }
  8978. }, false);
  8979. okButton.addEventListener("keyup", function (event) {
  8980. if (event.keyCode == 13 && okButtonKeyDownClick) {
  8981. okButtonKeyDownClick = false;
  8982. dismissDialogNotification();
  8983. event.preventDefault();
  8984. event.stopPropagation();
  8985. }
  8986. }, false);
  8987. document.getElementById(configureBrowserLinkId).addEventListener("keydown", function (event) {
  8988. if (event.keyCode == 9) {
  8989. okButton.focus();
  8990. event.preventDefault();
  8991. event.stopPropagation();
  8992. }
  8993. }, false);
  8994. window.focus();
  8995. okButton.focus();
  8996. }
  8997. Dialog.showCrossZoneNotification = showCrossZoneNotification;
  8998. function receiveMessage(event) {
  8999. if (event.source == windowInstance) {
  9000. try {
  9001. var dialogMessageReceivedArgs = {};
  9002. dialogMessageReceivedArgs[OSF.DDA.Marshaling.Dialog.DialogMessageReceivedEventKeys.MessageType] = OSF.DialogMessageType.DialogMessageReceived;
  9003. dialogMessageReceivedArgs[OSF.DDA.Marshaling.Dialog.DialogMessageReceivedEventKeys.MessageContent] = event.data;
  9004. handler(dialogMessageReceivedArgs);
  9005. }
  9006. catch (e) {
  9007. if (OSF.AppTelemetry) {
  9008. OSF.AppTelemetry.logAppException("Error happened during receive message handler." + e);
  9009. }
  9010. }
  9011. }
  9012. }
  9013. function showDialog(dialogInfo) {
  9014. var hostInfoObj = OSF._OfficeAppFactory.getInitializationHelper()._hostInfo;
  9015. var hostInfoVals = [
  9016. hostInfoObj.hostType,
  9017. hostInfoObj.hostPlatform,
  9018. hostInfoObj.hostSpecificFileVersion,
  9019. hostInfoObj.hostLocale,
  9020. hostInfoObj.osfControlAppCorrelationId,
  9021. "isDialog"
  9022. ];
  9023. var hostInfo = hostInfoVals.join("|");
  9024. var appContext = OSF._OfficeAppFactory.getInitializationHelper()._appContext;
  9025. var windowUrl = dialogInfo[OSF.ShowWindowDialogParameterKeys.Url];
  9026. windowUrl = OfficeExt.WACUtils.addHostInfoAsQueryParam(windowUrl, hostInfo);
  9027. var windowName = JSON.parse(window.name);
  9028. windowName[OSF.WindowNameItemKeys.HostInfo] = hostInfo;
  9029. windowName[OSF.WindowNameItemKeys.AppContext] = appContext;
  9030. var width = dialogInfo[OSF.ShowWindowDialogParameterKeys.Width] * appContext._clientWindowWidth / 100;
  9031. var height = dialogInfo[OSF.ShowWindowDialogParameterKeys.Height] * appContext._clientWindowHeight / 100;
  9032. var left = appContext._clientWindowWidth / 2 - width / 2;
  9033. var top = appContext._clientWindowHeight / 2 - height / 2;
  9034. var windowSpecs = "width=" + width + ", height=" + height + ", left=" + left + ", top=" + top + ",channelmode=no,directories=no,fullscreen=no,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,titlebar=yes,toolbar=no";
  9035. windowInstance = window.open(windowUrl, OfficeExt.WACUtils.serializeObjectToString(windowName), windowSpecs);
  9036. if (windowInstance == null) {
  9037. OSF.AppTelemetry.logAppCommonMessage("Encountered cross zone issue in displayDialogAsync api.");
  9038. removeDialogNotificationElement();
  9039. showCrossZoneNotification(windowUrl, hostInfoObj.hostType);
  9040. showDialogCallback(OSF.DDA.ErrorCodeManager.errorCodes.ooeCrossZone);
  9041. return;
  9042. }
  9043. window.addEventListener("message", receiveMessage);
  9044. function checkWindowClose() {
  9045. try {
  9046. if (windowInstance == null || windowInstance.closed) {
  9047. window.clearInterval(checkWindowDialogCloseInterval);
  9048. window.removeEventListener("message", receiveMessage);
  9049. var dialogClosedArgs = {};
  9050. dialogClosedArgs[OSF.DDA.Marshaling.Dialog.DialogMessageReceivedEventKeys.MessageType] = OSF.DialogMessageType.DialogClosed;
  9051. handler(dialogClosedArgs);
  9052. }
  9053. }
  9054. catch (e) {
  9055. if (OSF.AppTelemetry) {
  9056. OSF.AppTelemetry.logAppException("Error happened during check or handle window close." + e);
  9057. }
  9058. }
  9059. }
  9060. checkWindowDialogCloseInterval = window.setInterval(checkWindowClose, 1000);
  9061. if (showDialogCallback != null) {
  9062. showDialogCallback(OSF.DDA.ErrorCodeManager.errorCodes.ooeSuccess);
  9063. }
  9064. else {
  9065. if (OSF.AppTelemetry) {
  9066. OSF.AppTelemetry.logAppException("showDialogCallback can not be null.");
  9067. }
  9068. }
  9069. }
  9070. function createButtonControl(dialogCssManager, buttonValue) {
  9071. var buttonControl = document.createElement("input");
  9072. buttonControl.setAttribute("type", "button");
  9073. buttonControl.style.cssText = dialogCssManager.getDialogButtonCSS();
  9074. buttonControl.style.borderColor = commonButtonBorderColor;
  9075. buttonControl.style.backgroundColor = commonButtonBackgroundColor;
  9076. buttonControl.setAttribute("value", buttonValue);
  9077. var buttonControlEventInHandler = function () {
  9078. handleButtonControlEventIn(buttonControl);
  9079. };
  9080. var buttonControlEventOutHandler = function () {
  9081. handleButtonControlEventOut(buttonControl);
  9082. };
  9083. buttonControl.addEventListener("mouseover", buttonControlEventInHandler);
  9084. buttonControl.addEventListener("focus", buttonControlEventInHandler);
  9085. buttonControl.addEventListener("mouseout", buttonControlEventOutHandler);
  9086. buttonControl.addEventListener("focusout", buttonControlEventOutHandler);
  9087. return buttonControl;
  9088. }
  9089. function handleButtonControlEventIn(buttonControl) {
  9090. if (hostThemeButtonStyle != null) {
  9091. buttonControl.style.borderColor = hostThemeButtonStyle.HostButtonBorderColor;
  9092. buttonControl.style.backgroundColor = hostThemeButtonStyle.HostButtonBackgroundColor;
  9093. }
  9094. else if (OSF.CommonUI && OSF.CommonUI.HostButtonBorderColor && OSF.CommonUI.HostButtonBackgroundColor) {
  9095. buttonControl.style.borderColor = OSF.CommonUI.HostButtonBorderColor;
  9096. buttonControl.style.backgroundColor = OSF.CommonUI.HostButtonBackgroundColor;
  9097. }
  9098. else {
  9099. buttonControl.style.backgroundColor = commonEventInButtonBackgroundColor;
  9100. }
  9101. }
  9102. function handleButtonControlEventOut(buttonControl) {
  9103. buttonControl.style.borderColor = commonButtonBorderColor;
  9104. buttonControl.style.backgroundColor = commonButtonBackgroundColor;
  9105. }
  9106. function dismissDialogNotification() {
  9107. function unregisterDialogNotificationShownEventCallback(status) {
  9108. removeDialogNotificationElement();
  9109. setFocusOnFirstElement(status);
  9110. }
  9111. registerDialogNotificationShownArgs.onComplete = unregisterDialogNotificationShownEventCallback;
  9112. OSF.DDA.WAC.Delegate.unregisterEventAsync(registerDialogNotificationShownArgs);
  9113. }
  9114. function removeDialogNotificationElement() {
  9115. if (dialogNotificationPanel != null) {
  9116. document.body.removeChild(dialogNotificationPanel);
  9117. dialogNotificationPanel = null;
  9118. }
  9119. if (overlayElement != null) {
  9120. document.body.removeChild(overlayElement);
  9121. overlayElement = null;
  9122. }
  9123. }
  9124. function createOverlayElement(dialogCssManager) {
  9125. var overlayElement = document.createElement("div");
  9126. overlayElement.style.cssText = dialogCssManager.getOverlayElementCSS();
  9127. return overlayElement;
  9128. }
  9129. function createNotificationPanel(dialogCssManager, notificationString) {
  9130. var dialogNotificationPanel = document.createElement("div");
  9131. dialogNotificationPanel.style.cssText = dialogCssManager.getDialogNotificationPanelCSS();
  9132. var dialogNotificationTextPanel = document.createElement("div");
  9133. dialogNotificationTextPanel.style.cssText = dialogCssManager.getNewWindowNotificationTextPanelCSS();
  9134. if (document.documentElement.getAttribute("dir") == "rtl") {
  9135. dialogNotificationTextPanel.style.paddingRight = "30px";
  9136. }
  9137. else {
  9138. dialogNotificationTextPanel.style.paddingLeft = "30px";
  9139. }
  9140. var dialogNotificationTextSpan = document.createElement("span");
  9141. dialogNotificationTextSpan.style.cssText = dialogCssManager.getNewWindowNotificationTextSpanCSS();
  9142. dialogNotificationTextSpan.innerText = notificationString;
  9143. dialogNotificationTextPanel.appendChild(dialogNotificationTextSpan);
  9144. dialogNotificationPanel.appendChild(dialogNotificationTextPanel);
  9145. return dialogNotificationPanel;
  9146. }
  9147. function createButtonPanel(dialogCssManager) {
  9148. var dialogNotificationButtonPanel = document.createElement("div");
  9149. dialogNotificationButtonPanel.style.cssText = dialogCssManager.getDialogNotificationButtonPanelCSS();
  9150. if (document.documentElement.getAttribute("dir") == "rtl") {
  9151. dialogNotificationButtonPanel.style.cssFloat = "left";
  9152. }
  9153. else {
  9154. dialogNotificationButtonPanel.style.cssFloat = "right";
  9155. }
  9156. return dialogNotificationButtonPanel;
  9157. }
  9158. function setFocusOnFirstElement(status) {
  9159. if (status != OSF.DDA.ErrorCodeManager.errorCodes.ooeSuccess) {
  9160. var list = document.querySelectorAll(OSF._OfficeAppFactory.getInitializationHelper()._tabbableElements);
  9161. OSF.OUtil.focusToFirstTabbable(list, false);
  9162. }
  9163. }
  9164. function createNotificationPanelForCrossZoneIssue(dialogCssManager, windowUrl) {
  9165. var dialogNotificationPanel = document.createElement("div");
  9166. dialogNotificationPanel.style.cssText = dialogCssManager.getDialogNotificationPanelCSS();
  9167. var dialogNotificationTextPanel = document.createElement("div");
  9168. dialogNotificationTextPanel.style.cssText = dialogCssManager.getCrossZoneNotificationTextPanelCSS();
  9169. var configureBrowserLink = document.createElement("a");
  9170. configureBrowserLink.id = configureBrowserLinkId;
  9171. configureBrowserLink.href = "#";
  9172. configureBrowserLink.innerText = Strings.OfficeOM.L_NewWindowCrossZoneConfigureBrowserLink;
  9173. configureBrowserLink.setAttribute("onclick", "window.open('https://support.microsoft.com/en-us/help/17479/windows-internet-explorer-11-change-security-privacy-settings', '_blank', 'fullscreen=1')");
  9174. var dialogNotificationTextSpan = document.createElement("span");
  9175. if (Strings.OfficeOM.L_NewWindowCrossZone) {
  9176. dialogNotificationTextSpan.innerHTML = OSF.OUtil.formatString(Strings.OfficeOM.L_NewWindowCrossZone, configureBrowserLink.outerHTML, OfficeExt.WACUtils.getDomainForUrl(windowUrl));
  9177. }
  9178. dialogNotificationTextPanel.appendChild(dialogNotificationTextSpan);
  9179. dialogNotificationPanel.appendChild(dialogNotificationTextPanel);
  9180. return dialogNotificationPanel;
  9181. }
  9182. })(Dialog = AddinNativeAction.Dialog || (AddinNativeAction.Dialog = {}));
  9183. })(AddinNativeAction = OfficeExt.AddinNativeAction || (OfficeExt.AddinNativeAction = {}));
  9184. })(OfficeExt || (OfficeExt = {}));
  9185. OSF.DDA.WAC.Delegate.ParameterMap.define({
  9186. type: OSF.DDA.EventDispId.dispidDialogMessageReceivedEvent,
  9187. fromHost: [
  9188. { name: OSF.DDA.EventDescriptors.DialogMessageReceivedEvent, value: OSF.DDA.WAC.Delegate.ParameterMap.self }
  9189. ]
  9190. });
  9191. OSF.DDA.WAC.Delegate.ParameterMap.addComplexType(OSF.DDA.EventDescriptors.DialogMessageReceivedEvent);
  9192. OSF.DDA.WAC.Delegate.ParameterMap.define({
  9193. type: OSF.DDA.EventDescriptors.DialogMessageReceivedEvent,
  9194. fromHost: [
  9195. { name: OSF.DDA.PropertyDescriptors.MessageType, value: OSF.DDA.Marshaling.Dialog.DialogMessageReceivedEventKeys.MessageType },
  9196. { name: OSF.DDA.PropertyDescriptors.MessageContent, value: OSF.DDA.Marshaling.Dialog.DialogMessageReceivedEventKeys.MessageContent }
  9197. ]
  9198. });
  9199. OSF.DDA.WAC.Delegate.ParameterMap.define({
  9200. type: OSF.DDA.EventDispId.dispidDialogParentMessageReceivedEvent,
  9201. fromHost: [
  9202. { name: OSF.DDA.EventDescriptors.DialogParentMessageReceivedEvent, value: OSF.DDA.WAC.Delegate.ParameterMap.self }
  9203. ]
  9204. });
  9205. OSF.DDA.WAC.Delegate.ParameterMap.addComplexType(OSF.DDA.EventDescriptors.DialogParentMessageReceivedEvent);
  9206. OSF.DDA.WAC.Delegate.ParameterMap.define({
  9207. type: OSF.DDA.EventDescriptors.DialogParentMessageReceivedEvent,
  9208. fromHost: [
  9209. { name: OSF.DDA.PropertyDescriptors.MessageType, value: OSF.DDA.Marshaling.Dialog.DialogParentMessageReceivedEventKeys.MessageType },
  9210. { name: OSF.DDA.PropertyDescriptors.MessageContent, value: OSF.DDA.Marshaling.Dialog.DialogParentMessageReceivedEventKeys.MessageContent }
  9211. ]
  9212. });
  9213. OSF.DDA.WAC.Delegate.ParameterMap.define({
  9214. type: OSF.DDA.MethodDispId.dispidMessageParentMethod,
  9215. toHost: [
  9216. { name: Microsoft.Office.WebExtension.Parameters.MessageToParent, value: OSF.DDA.Marshaling.MessageParentKeys.MessageToParent }
  9217. ]
  9218. });
  9219. OSF.DDA.WAC.Delegate.ParameterMap.define({
  9220. type: OSF.DDA.MethodDispId.dispidSendMessageMethod,
  9221. toHost: [
  9222. { name: Microsoft.Office.WebExtension.Parameters.MessageContent, value: OSF.DDA.Marshaling.SendMessageKeys.MessageContent }
  9223. ]
  9224. });
  9225. OSF.DDA.WAC.Delegate.openDialog = function OSF_DDA_WAC_Delegate$OpenDialog(args) {
  9226. var httpsIdentifyString = "https://";
  9227. var httpIdentifyString = "http://";
  9228. var dialogInfo = JSON.parse(args.targetId);
  9229. var callback = OSF.DDA.WAC.Delegate._getOnAfterRegisterEvent(true, args);
  9230. function showDialogCallback(status) {
  9231. var payload = { "Error": status };
  9232. callback(Microsoft.Office.Common.InvokeResultCode.noError, payload);
  9233. }
  9234. if (OSF.DialogShownStatus.hasDialogShown) {
  9235. showDialogCallback(OSF.DDA.ErrorCodeManager.errorCodes.ooeDialogAlreadyOpened);
  9236. return;
  9237. }
  9238. var dialogUrl = dialogInfo[OSF.ShowWindowDialogParameterKeys.Url].toLowerCase();
  9239. if (dialogUrl == null || !(dialogUrl.substr(0, httpsIdentifyString.length) === httpsIdentifyString)) {
  9240. if (dialogUrl.substr(0, httpIdentifyString.length) === httpIdentifyString) {
  9241. showDialogCallback(OSF.DDA.ErrorCodeManager.errorCodes.ooeRequireHTTPS);
  9242. }
  9243. else {
  9244. showDialogCallback(OSF.DDA.ErrorCodeManager.errorCodes.ooeInvalidScheme);
  9245. }
  9246. return;
  9247. }
  9248. if (!dialogInfo[OSF.ShowWindowDialogParameterKeys.DisplayInIframe]) {
  9249. OSF.DialogShownStatus.isWindowDialog = true;
  9250. OfficeExt.AddinNativeAction.Dialog.setHandlerAndShowDialogCallback(function OSF_DDA_WACDelegate$RegisterEventAsync_OnEvent(payload) {
  9251. if (args.onEvent) {
  9252. args.onEvent(payload);
  9253. }
  9254. if (OSF.AppTelemetry) {
  9255. OSF.AppTelemetry.onEventDone(args.dispId);
  9256. }
  9257. }, showDialogCallback);
  9258. OfficeExt.AddinNativeAction.Dialog.handleNewWindowDialog(dialogInfo);
  9259. }
  9260. else {
  9261. OSF.DialogShownStatus.isWindowDialog = false;
  9262. OSF.DDA.WAC.Delegate.registerEventAsync(args);
  9263. }
  9264. };
  9265. OSF.DDA.WAC.Delegate.messageParent = function OSF_DDA_WAC_Delegate$MessageParent(args) {
  9266. if (window.opener != null) {
  9267. OfficeExt.AddinNativeAction.Dialog.messageParent(args);
  9268. }
  9269. else {
  9270. OSF.DDA.WAC.Delegate.executeAsync(args);
  9271. }
  9272. };
  9273. OSF.DDA.WAC.Delegate.sendMessage = function OSF_DDA_WAC_Delegate$SendMessage(args) {
  9274. if (OSF.DialogShownStatus.hasDialogShown) {
  9275. if (OSF.DialogShownStatus.isWindowDialog) {
  9276. OfficeExt.AddinNativeAction.Dialog.sendMessage(args);
  9277. }
  9278. else {
  9279. OSF.DDA.WAC.Delegate.executeAsync(args);
  9280. }
  9281. }
  9282. };
  9283. OSF.DDA.WAC.Delegate.closeDialog = function OSF_DDA_WAC_Delegate$CloseDialog(args) {
  9284. var callback = OSF.DDA.WAC.Delegate._getOnAfterRegisterEvent(false, args);
  9285. function closeDialogCallback(status) {
  9286. var payload = { "Error": status };
  9287. callback(Microsoft.Office.Common.InvokeResultCode.noError, payload);
  9288. }
  9289. if (!OSF.DialogShownStatus.hasDialogShown) {
  9290. closeDialogCallback(OSF.DDA.ErrorCodeManager.errorCodes.ooeWebDialogClosed);
  9291. }
  9292. else {
  9293. if (OSF.DialogShownStatus.isWindowDialog) {
  9294. if (args.onCalling) {
  9295. args.onCalling();
  9296. }
  9297. OfficeExt.AddinNativeAction.Dialog.closeDialog(closeDialogCallback);
  9298. }
  9299. else {
  9300. OSF.DDA.WAC.Delegate.unregisterEventAsync(args);
  9301. }
  9302. }
  9303. };
  9304. OSF.InitializationHelper.prototype.dismissDialogNotification = function OSF_InitializationHelper$dismissDialogNotification() {
  9305. OfficeExt.AddinNativeAction.Dialog.escDismissDialogNotification();
  9306. };
  9307. OSF.InitializationHelper.prototype.registerMessageReceivedEventForWindowDialog = function OSF_InitializationHelper$registerMessageReceivedEventForWindowDialog() {
  9308. OfficeExt.AddinNativeAction.Dialog.registerMessageReceivedEvent();
  9309. };
  9310. var OfficeExt;
  9311. (function (OfficeExt) {
  9312. var AddinNativeAction;
  9313. (function (AddinNativeAction) {
  9314. var Snapshot;
  9315. (function (Snapshot) {
  9316. var SnapshotActionArgs = (function () {
  9317. function SnapshotActionArgs() {
  9318. }
  9319. return SnapshotActionArgs;
  9320. })();
  9321. function loadHtml2CanvasWithOnCompleted(onAllCompleted, onError) {
  9322. var html2canvasLoaded = function () {
  9323. return typeof (Html2canvas) !== "undefined" && typeof (Html2canvas.html2canvas) !== "undefined";
  9324. };
  9325. var promiseLoaded = function () {
  9326. return typeof (window.Promise) !== "undefined" || (typeof (OfficeExtension) !== "undefined" && typeof (OfficeExtension.Promise) !== "undefined");
  9327. };
  9328. if (html2canvasLoaded() && promiseLoaded()) {
  9329. onAllCompleted();
  9330. return;
  9331. }
  9332. var loadScriptHelper = new ScriptLoading.LoadScriptHelper();
  9333. var basePath = loadScriptHelper.getOfficeJsBasePath();
  9334. var files = {
  9335. html2canvasJs: 'Html2canvas.debug.js',
  9336. promiseJs: 'es6-promise.debug.js'
  9337. };
  9338. var onScriptsLoad = function () {
  9339. if (html2canvasLoaded() && promiseLoaded()) {
  9340. onAllCompleted();
  9341. }
  9342. else {
  9343. onError();
  9344. }
  9345. };
  9346. if (!promiseLoaded()) {
  9347. loadScriptHelper.loadScript(basePath + files.promiseJs, null, function () {
  9348. loadScriptHelper.loadScript(basePath + files.html2canvasJs, null, onScriptsLoad);
  9349. });
  9350. }
  9351. else {
  9352. loadScriptHelper.loadScript(basePath + files.html2canvasJs, null, onScriptsLoad);
  9353. }
  9354. }
  9355. ;
  9356. function generateLatestSnapshot(args) {
  9357. if (!OfficeExt.WACUtils.isHostTrusted || !OfficeExt.WACUtils.isHostTrusted()) {
  9358. args.completed();
  9359. }
  9360. else {
  9361. var onFailed = function () {
  9362. args.completed();
  9363. };
  9364. var onRendered = function (canvas) {
  9365. try {
  9366. args.result = canvas.toDataURL("image/png").replace("image/png", "image/octet-stream");
  9367. }
  9368. catch (e) {
  9369. }
  9370. args.completed();
  9371. };
  9372. var onLoadCompleted = function () {
  9373. try {
  9374. Html2canvas.html2canvas(document.body, { onrendered: onRendered });
  9375. }
  9376. catch (e) {
  9377. onFailed();
  9378. }
  9379. };
  9380. loadHtml2CanvasWithOnCompleted(onLoadCompleted, onFailed);
  9381. }
  9382. }
  9383. Snapshot.generateLatestSnapshot = generateLatestSnapshot;
  9384. })(Snapshot = AddinNativeAction.Snapshot || (AddinNativeAction.Snapshot = {}));
  9385. })(AddinNativeAction = OfficeExt.AddinNativeAction || (OfficeExt.AddinNativeAction = {}));
  9386. })(OfficeExt || (OfficeExt = {}));
  9387. var OSFPPTWAC;
  9388. (function (OSFPPTWAC) {
  9389. var PowerPointDocument = (function () {
  9390. function PowerPointDocument(officeAppContext, settings) {
  9391. OSF.DDA.DispIdHost.addEventSupport(this, new OSF.EventDispatch([Microsoft.Office.WebExtension.EventType.ActiveViewChanged,
  9392. Microsoft.Office.WebExtension.EventType.DocumentSelectionChanged]));
  9393. OSF.DDA.PowerPointDocument.uber.constructor.call(this, officeAppContext, settings);
  9394. OSF.DDA.DispIdHost.addAsyncMethods(this, [
  9395. OSF.DDA.AsyncMethodNames.GetSelectedDataAsync,
  9396. OSF.DDA.AsyncMethodNames.SetSelectedDataAsync,
  9397. OSF.DDA.AsyncMethodNames.GoToByIdAsync,
  9398. OSF.DDA.AsyncMethodNames.GetActiveViewAsync,
  9399. OSF.DDA.AsyncMethodNames.GetDocumentCopyAsync,
  9400. OSF.DDA.AsyncMethodNames.GetFilePropertiesAsync,
  9401. OSF.DDA.SyncMethodNames.MessageParent
  9402. ]);
  9403. OSF.OUtil.finalizeProperties(this);
  9404. }
  9405. return PowerPointDocument;
  9406. })();
  9407. OSFPPTWAC.PowerPointDocument = PowerPointDocument;
  9408. })(OSFPPTWAC || (OSFPPTWAC = {}));
  9409. OSF.DDA.PowerPointDocument = OSFPPTWAC.PowerPointDocument;
  9410. OSF.OUtil.extend(OSF.DDA.PowerPointDocument, OSF.DDA.Document);
  9411. OSF.OUtil.redefineList(Microsoft.Office.WebExtension.GoToType, {
  9412. Slide: "slide",
  9413. Index: "index"
  9414. });
  9415. OSF.InitializationHelper.prototype.loadAppSpecificScriptAndCreateOM = function OSF_InitializationHelper$loadAppSpecificScriptAndCreateOM(appContext, appReady, basePath) {
  9416. OSF.DDA.ErrorCodeManager.initializeErrorMessages(Strings.OfficeOM);
  9417. appContext.doc = new OSF.DDA.PowerPointDocument(appContext, this._initializeSettings(appContext, true));
  9418. appReady();
  9419. };
  9420. OSF.InitializationHelper.prototype.prepareRightBeforeWebExtensionInitialize = function OSF_InitializationHelper$prepareRightBeforeWebExtensionInitialize(appContext) {
  9421. OSF.WebApp._UpdateLinksForHostAndXdmInfo();
  9422. var license = new OSF.DDA.License(appContext.get_eToken());
  9423. this.initWebDialog(appContext);
  9424. OSF._OfficeAppFactory.setContext(new OSF.DDA.Context(appContext, appContext.doc, license));
  9425. var getActivationCompletedStatusCallback;
  9426. OSF._OfficeAppFactory.setHostFacade(new OSF.DDA.DispIdHost.Facade(OSF.DDA.WAC.getDelegateMethods, OSF.DDA.WAC.Delegate.ParameterMap));
  9427. getActivationCompletedStatusCallback = function (invokeResultCode, status) {
  9428. if (invokeResultCode == 0 && status != true) {
  9429. OSF.getClientEndPoint().registerForEvent("activationCompleted", function () {
  9430. var reason = appContext.get_reason();
  9431. Microsoft.Office.WebExtension.initialize(reason);
  9432. }, null, {
  9433. "controlId": OSF._OfficeAppFactory.getId(),
  9434. "eventDispId": OSF.DDA.EventDispId.dispidActivationStatusChangedEvent,
  9435. "targetId": ""
  9436. });
  9437. }
  9438. else {
  9439. var reason = appContext.get_reason();
  9440. Microsoft.Office.WebExtension.initialize(reason);
  9441. }
  9442. };
  9443. OSF.getClientEndPoint().invoke("getActivationCompletedStatus", getActivationCompletedStatusCallback, this._webAppState.id);
  9444. var themeHandler = new OSF.DDA.Theming.InternalThemeHandler();
  9445. themeHandler.InitializeAndChangeOnce();
  9446. var appCommandHandler = OfficeExt.AppCommand.AppCommandManager.instance();
  9447. appCommandHandler.initializeAndChangeOnce();
  9448. };