2023-01-01 01:54:04 +01:00
|
|
|
var OS;!function(e){let t;!function(e){class t extends e.BaseApplication{constructor(e){super("LibreOffice",e),this.access_token=void 0,this.curr_file=void 0,this.eid="id"+Math.random().toString(36).replace(".",""),this.iframe=void 0,this.mimes=this.meta().mimes.map(e=>e),this.current_mode=void 0,this.post_msg_handle=e=>{this.process_iframe_msg(e)}}main(){this.args&&this.args.length>0&&(this.curr_file=this.args[0].path.asFileHandle()),this.placeholder=this.find("editor-area"),this.placeholder.id=this.eid,this.find("btn-open-file").onbtclick=e=>{this.openFile()},this.find("btn-new-doc").onbtclick=e=>{this.create("word")},this.find("btn-new-cell").onbtclick=e=>{this.create("sheet")},this.find("btn-new-slide").onbtclick=e=>{this.create("slide")},$(window).on("message",this.post_msg_handle),this.discover().then(e=>{this.editor_meta=e,this.curr_file&&this.open()}).catch(e=>{this.error(__("Unable to discover LibreOffice service: {0}",e.toString()),e),this.quit(!0)})}menu(){const e=[{text:"__(New)",dataid:"new"},{text:"__(Open)",dataid:"open"}];return"edit"==this.current_mode&&(e.push({text:"__(Save)",dataid:"save"}),e.push({text:"__(Save As)",dataid:"saveas"})),[{text:"__(File)",nodes:e,onchildselect:e=>{switch(e.data.item.data.dataid){case"new":this.check_dirty().then(e=>this.new_document());break;case"open":this.check_dirty().then(e=>this.openFile());break;case"save":this.post_message("Action_Save",{DontTerminateEdit:!0,DontSaveIfUnmodified:!0,Notify:!0});break;case"saveas":this.check_dirty().then(e=>this.save_as())}}}]}update_title(){let e=this.curr_file.path;this.curr_file.dirty&&(e+=" "+__("(modified)")),this.scheme.apptitle=e}post_message(e,t){let i={MessageId:e,SendTime:Date.now()};t&&(i.Values=t),this.iframe.contentWindow.postMessage(JSON.stringify(i),"*")}process_iframe_msg(e){if(e.originalEvent.source!=this.iframe.contentWindow)return;let t=e.originalEvent,i=JSON.parse(t.data);switch(i.MessageId){case"Action_Load_Resp":i.Values.success||this.error(i.Values.errorMsg);break;case"App_LoadingStatus":"Document_Loaded"==i.Values.Status&&(this.post_message("Host_PostmessageReady"),this.trigger("document_file_loaded"),"edit"==this.current_mode&&(this.post_message("Insert_Button",{id:"lool_new_file",imgurl:"data:image/x-icon;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAABmJLR0QA/wD/AP+gvaeTAAABmklEQVRIie2Vv0tbURTHP+fmJTGpIYM/KEoUHItOEtIu6uTk2r9BcNMWuro62X9D6OTWIhp00baLCI2giKKYVoMtJtTE93JPhyLSpyavLxE69Due+73nwzn3nnvhkSX+wNut2pugm9XapdkXicO/A3ysaZDk3UnD9yt77KETs9mOg4d8Jkiy+9TTCc8HIpmoSH7xU3Wo7QCA3k5DLtMY0hIgCKRlwB8QI6v+NSds0sKZpXBm/eFBf6AtFTTSf0BThT5kvxRw620G1FUREQxwUraUa3c9LbXoa0XZLbkUSpYBd4Pp+Bz6eTQJoPo7d0sVVD14FZ8mbc5JU8IRF6/CnpsfSXlr5iVsvw9VQa0Ox5eWRP0b/ZF9uqSII+7Nch+QwthJVSTUc31aUXqvN5npeE2Uexp/q5VQFfQkhCN9hquxZtb1f3PQzq+UQflCVK6bWcdCAboSQtHJMf/zHVV98pBt0Rnfmbx7TYWFZoC4A5m0oVh+mr2gP5viIpbUH7GIeAKcAilUPogQ6H9vqJuB8taGp9z88LJ/0H4BR3aNW1eB/4cAAAAASUVORK5CYII=",label:__("New file").__(),hint:__("Create new document").__(),insertBefore:"save"}),this.post_message("Insert_Button",{id:"lool_open_file",imgurl:"data:image/x-icon;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAD8UlEQVR42q1Va2gcVRQ+587s7mRItNskfaY1trRi2sZHNYoQHzGmQkAMlNZK1R+l0R+K/REhRAmzIEElaqX2R/tDhZamov4QbV0a6V9Nm9DiI8QEEtpI8zDbPPfh7sw93juzOzv7Ugge2L3nztz7fed859w7CHmGiKocYHVGwswcvLwFWnNzc3tLS8sjaTIvcX4kBZvD4fBAf3//aeEmShGUd3Z2nu7q6noBHZPABOjA2/9ijs4+wiwrydehUKivp6fnqPCjOQSHPhrTmKI2XP/uA33/k9s6Ot58rSkNnvPzZlKQkTDDMM4XJXjp08m3aiqV9xUex3sqZqCtqZ6QMSeDdKQeEoISGQiCvo9PfnY0tjBVQNC9d7vf0Fkcq2AK9jXeR8wrEQB6Ii8gkJWV/skz4ZlLI8posKbOQmQfnnl9y/f2gsMnbnbvuctnaCwOm9QZaH3ifmAlpCklj7RvLw/Bn8lqSPAy+PVGKnT2ja0hN4MdmxTDDzGs1Wbh+aYHXVm8kebNM5m4En3TfxXGY1WUBB3HblmGyCBLsLUaDZViuLN8DvY/s9cL+p8SZQi+DF+BkaW1ZKKON/+iLIGUaEMQDMZjsHtNBA7ue6hAnlISCfldv++HK/DL7SBwpsP0PGQlOnh8onttBRpgruDD6xbgcGtDTgb5EkmXc27XVozus7MXr8Lg7BoCtRznlyF0/litgfUdAxcCqnovAK/l3IRKnWBz9Z155ZMZQEHUcnRcZz41twyROAJj8rZhN5KmOYxtvcMLLz5egxanCimrIiT2qUpBAT1sztzGppw1psXBIlkj0aQIsYHRSAqffnd4fOeWDRoRXy8iYgGBXab5PKDu1SAxwQXOji5BPGlCirNMB94em5xdxGffGx3as23zRotbLoGu+XMzQEgDOagZAqE/SplknUzLwtjfFqDiJ9kTDNn8bxO3JvC53vEfG+
|