/* This is a generated file. DO NOT EDIT. Copyright (C) 2010-2015 KO GmbH @licstart The code in this file is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License (GNU AGPL) as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. The code in this file is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with WebODF. If not, see . As additional permission under GNU AGPL version 3 section 7, you may distribute UNMODIFIED VERSIONS OF THIS file without the copy of the GNU AGPL normally required by section 4, provided you include this license notice and a URL through which recipients can access the Corresponding Source. As a special exception to the AGPL, any HTML file which merely makes function calls to this code, and for that purpose includes it in unmodified form by reference or in-line shall be deemed a separate work for copyright law purposes. In addition, the copyright holders of this code give you permission to combine this code with free software libraries that are released under the GNU LGPL. You may copy and distribute such a system following the terms of the GNU AGPL for this code and the LGPL for the libraries. If you modify this code, you may extend this exception to your version of the code, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. This license applies to this entire compilation. @licend @source: http://www.webodf.org/ @source: https://github.com/kogmbh/WebODF/ */ var webodf_version="0.5.8.preview1";function Runtime(){}Runtime.prototype.getVariable=function(f){};Runtime.prototype.toJson=function(f){};Runtime.prototype.fromJson=function(f){};Runtime.prototype.byteArrayFromString=function(f,k){};Runtime.prototype.byteArrayToString=function(f,k){};Runtime.prototype.read=function(f,k,a,e){};Runtime.prototype.readFile=function(f,k,a){};Runtime.prototype.readFileSync=function(f,k){};Runtime.prototype.loadXML=function(f,k){};Runtime.prototype.writeFile=function(f,k,a){}; Runtime.prototype.deleteFile=function(f,k){};Runtime.prototype.log=function(f,k){};Runtime.prototype.setTimeout=function(f,k){};Runtime.prototype.clearTimeout=function(f){};Runtime.prototype.libraryPaths=function(){};Runtime.prototype.currentDirectory=function(){};Runtime.prototype.setCurrentDirectory=function(f){};Runtime.prototype.type=function(){};Runtime.prototype.getDOMImplementation=function(){};Runtime.prototype.parseXML=function(f){};Runtime.prototype.exit=function(f){}; Runtime.prototype.getWindow=function(){};Runtime.prototype.requestAnimationFrame=function(f){};Runtime.prototype.cancelAnimationFrame=function(f){};Runtime.prototype.assert=function(f,k){};var IS_COMPILED_CODE=!0; Runtime.byteArrayToString=function(f,k){function a(a){var e="",c,q=a.length;for(c=0;ch?g.push(h):(c+=1,d=a[c],194<=h&&224>h?g.push((h&31)<<6|d&63):(c+=1,b=a[c],224<=h&&240>h?g.push((h&15)<<12|(d&63)<<6|b&63):(c+=1,r=a[c],240<=h&&245>h&&(h=(h&7)<<18|(d&63)<<12|(b&63)<<6|r&63,h-=65536,g.push((h>>10)+55296,(h&1023)+56320))))),1E3<=g.length&& (e+=String.fromCharCode.apply(null,g),g.length=0);return e+String.fromCharCode.apply(null,g)}var c;"utf8"===k?c=e(f):("binary"!==k&&this.log("Unsupported encoding: "+k),c=a(f));return c};Runtime.getVariable=function(f){try{return eval(f)}catch(k){}};Runtime.toJson=function(f){return JSON.stringify(f)};Runtime.fromJson=function(f){return JSON.parse(f)};Runtime.getFunctionName=function(f){return void 0===f.name?(f=/function\s+(\w+)/.exec(f))&&f[1]:f.name}; Runtime.assert=function(f,k){if(!f)throw this.log("alert","ASSERTION FAILED:\n"+k),Error(k);}; function BrowserRuntime(){function f(a){var g=a.length,h,d,b=0;for(h=0;hd&&(b+=1,h+=1);return b}function k(a,g,h){var d=a.length,b,r;g=new Uint8Array(new ArrayBuffer(g));h?(g[0]=239,g[1]=187,g[2]=191,r=3):r=0;for(h=0;hb?(g[r]=b,r+=1):2048>b?(g[r]=192|b>>>6,g[r+1]=128|b&63,r+=2):55040>=b||57344<=b?(g[r]=224|b>>>12&15,g[r+1]=128|b>>>6&63,g[r+2]=128|b&63,r+=3):(h+=1,b=(b-55296<<10|a.charCodeAt(h)-56320)+65536, g[r]=240|b>>>18&7,g[r+1]=128|b>>>12&63,g[r+2]=128|b>>>6&63,g[r+3]=128|b&63,r+=4);return g}function a(a){var g=a.length,h=new Uint8Array(new ArrayBuffer(g)),d;for(d=0;dd.status||0===d.status?h(null):h("Status "+String(d.status)+": "+d.responseText||d.statusText):h("File "+a+" is empty."))};b=g.buffer&&!d.sendAsBinary?g.buffer:p.byteArrayToString(g,"binary");try{d.sendAsBinary?d.sendAsBinary(b):d.send(b)}catch(r){p.log("HUH? "+ r+" "+g),h(r.message)}};this.deleteFile=function(a,g){var h=new XMLHttpRequest;h.open("DELETE",a,!0);h.onreadystatechange=function(){4===h.readyState&&(200>h.status&&300<=h.status?g(h.responseText):g(null))};h.send(null)};this.loadXML=function(a,g){var h=new XMLHttpRequest;h.open("GET",a,!0);h.overrideMimeType&&h.overrideMimeType("text/xml");h.onreadystatechange=function(){4===h.readyState&&(0!==h.status||h.responseText?200===h.status||0===h.status?g(null,h.responseXML):g(h.responseText,null):g("File "+ a+" is empty.",null))};try{h.send(null)}catch(d){g(d.message,null)}};this.log=e;this.enableAlerts=!0;this.assert=Runtime.assert;this.setTimeout=function(a,g){return setTimeout(function(){a()},g)};this.clearTimeout=function(a){clearTimeout(a)};this.libraryPaths=function(){return["lib"]};this.setCurrentDirectory=function(){};this.currentDirectory=function(){return""};this.type=function(){return"BrowserRuntime"};this.getDOMImplementation=function(){return window.document.implementation};this.parseXML= function(a){return(new DOMParser).parseFromString(a,"text/xml")};this.exit=function(a){e("Calling exit with code "+String(a)+", but exit() is not implemented.")};this.getWindow=function(){return window};this.requestAnimationFrame=function(a){var g=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame,h=0;if(g)g.bind(window),h=g(a);else return setTimeout(a,15);return h};this.cancelAnimationFrame=function(a){var g=window.cancelAnimationFrame|| window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.msCancelAnimationFrame;g?(g.bind(window),g(a)):clearTimeout(a)}} function NodeJSRuntime(){function f(a){var g=a.length,h,d=new Uint8Array(new ArrayBuffer(g));for(h=0;h").implementation} function RhinoRuntime(){var f=this,k={},a=k.javax.xml.parsers.DocumentBuilderFactory.newInstance(),e,c,m="";a.setValidating(!1);a.setNamespaceAware(!0);a.setExpandEntityReferences(!1);a.setSchema(null);c=k.org.xml.sax.EntityResolver({resolveEntity:function(a,e){var c=new k.java.io.FileReader(e);return new k.org.xml.sax.InputSource(c)}});e=a.newDocumentBuilder();e.setEntityResolver(c);this.byteArrayFromString=function(a,e){var c,g=a.length,h=new Uint8Array(new ArrayBuffer(g));for(c=0;c>>18],l+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[b>>>12&63],l+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[b>>>6&63],l+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[b& 63];r===a+1?(b=d[r]<<4,l+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[b>>>6],l+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[b&63],l+="=="):r===a&&(b=d[r]<<10|d[r+1]<<2,l+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[b>>>12],l+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[b>>>6&63],l+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[b&63],l+="=");return l}function a(d){d=d.replace(/[^A-Za-z0-9+\/]+/g, "");var b=d.length,r=new Uint8Array(new ArrayBuffer(3*b)),a=d.length%4,e=0,c,B;for(c=0;c>16,r[e+1]=B>>8&255,r[e+2]=B&255,e+=3;b=3*b-[0,0,2,1][a];return r.subarray(0,b)}function e(d){var b,l,r=d.length,a=0,e=new Uint8Array(new ArrayBuffer(3*r));for(b=0;bl?e[a++]=l:(2048>l?e[a++]=192|l>>>6:(e[a++]=224|l>>>12&15,e[a++]=128|l>>>6&63),e[a++]=128|l&63);return e.subarray(0, a)}function c(d){var b,l,r,a,e=d.length,B=new Uint8Array(new ArrayBuffer(e)),c=0;for(b=0;bl?B[c++]=l:(b+=1,r=d[b],224>l?B[c++]=(l&31)<<6|r&63:(b+=1,a=d[b],B[c++]=(l&15)<<12|(r&63)<<6|a&63));return B.subarray(0,c)}function m(b){return k(f(b))}function n(b){return String.fromCharCode.apply(String,a(b))}function p(b){return c(f(b))}function q(b){b=c(b);for(var d="",l=0;ld?B+=String.fromCharCode(d):(e+=1,r=b.charCodeAt(e)&255,224>d?B+=String.fromCharCode((d&31)<<6|r&63):(e+=1,a=b.charCodeAt(e)&255,B+=String.fromCharCode((d&15)<<12|(r&63)<<6|a&63)));return B}function h(b,d){function l(){var e=a+1E5;e>b.length&&(e=b.length);r+=g(b,a,e);a=e;e=a===b.length;d(r,e)&&!e&&runtime.setTimeout(l,0)}var r="",a=0;1E5>b.length?d(g(b,0,b.length),!0):("string"!==typeof b&&(b=b.slice()),l())}function d(b){return e(f(b))}function b(b){return String.fromCharCode.apply(String, e(b))}function r(b){return String.fromCharCode.apply(String,e(f(b)))}var l=function(b){var d={},l,r;l=0;for(r=b.length;lc-e&&(c=Math.max(2*c,e+a),a=new Uint8Array(new ArrayBuffer(c)),a.set(m),m=a)}var a=this,e=0,c=1024,m=new Uint8Array(new ArrayBuffer(c));this.appendByteArrayWriter=function(e){a.appendByteArray(e.getByteArray())};this.appendByteArray=function(a){var c=a.length;k(c);m.set(a,e);e+=c};this.appendArray=function(a){var c=a.length;k(c);m.set(a,e);e+=c};this.appendUInt16LE=function(e){a.appendArray([e&255,e>>8&255])};this.appendUInt32LE=function(e){a.appendArray([e& 255,e>>8&255,e>>16&255,e>>24&255])};this.appendString=function(e){a.appendByteArray(runtime.byteArrayFromString(e,f))};this.getLength=function(){return e};this.getByteArray=function(){var a=new Uint8Array(new ArrayBuffer(e));a.set(m.subarray(0,e));return a}};core.CSSUnits=function(){var f=this,k={"in":1,cm:2.54,mm:25.4,pt:72,pc:12,px:96};this.convert=function(a,e,c){return a*k[c]/k[e]};this.convertMeasure=function(a,e){var c,m;a&&e&&(c=parseFloat(a),m=a.replace(c.toString(),""),c=f.convert(c,m,e));return c};this.getUnits=function(a){return a.substr(a.length-2,a.length)}};(function(){function f(){var e,c,m,f,p,k,g,h,d;void 0===a&&(c=(e=runtime.getWindow())&&e.document,k=c.documentElement,g=c.body,a={rangeBCRIgnoresElementBCR:!1,unscaledRangeClientRects:!1,elementBCRIgnoresBodyScroll:!1},c&&(f=c.createElement("div"),f.style.position="absolute",f.style.left="-99999px",f.style.transform="scale(2)",f.style["-webkit-transform"]="scale(2)",p=c.createElement("div"),f.appendChild(p),g.appendChild(f),e=c.createRange(),e.selectNode(p),a.rangeBCRIgnoresElementBCR=0===e.getClientRects().length, p.appendChild(c.createTextNode("Rect transform test")),c=p.getBoundingClientRect(),m=e.getBoundingClientRect(),a.unscaledRangeClientRects=2=b.compareBoundaryPoints(Range.START_TO_START,d)&&0<=b.compareBoundaryPoints(Range.END_TO_END,d)}function m(b,d){return 0>=b.compareBoundaryPoints(Range.END_TO_START,d)&&0<=b.compareBoundaryPoints(Range.START_TO_END,d)}function n(b,d){var a=null;b.nodeType===Node.TEXT_NODE&&(0===b.length?(b.parentNode.removeChild(b),d.nodeType===Node.TEXT_NODE&&(a=d)):(d.nodeType===Node.TEXT_NODE&&(b.appendData(d.data),d.parentNode.removeChild(d)),a=b));return a} function p(b){for(var d=b.parentNode;b.firstChild;)d.insertBefore(b.firstChild,b);d.removeChild(b);return d}function q(b,d){var a=b.parentNode,e=b.firstChild,c=d(b),h;if(c===NodeFilter.FILTER_SKIP)return a;for(;e;)h=e.nextSibling,q(e,d),e=h;a&&c===NodeFilter.FILTER_REJECT&&p(b);return a}function g(b,d){return b===d||Boolean(b.compareDocumentPosition(d)&Node.DOCUMENT_POSITION_CONTAINED_BY)}function h(b,d){return f().unscaledRangeClientRects?b:b/d}function d(b,l,a){Object.keys(l).forEach(function(e){var c= e.split(":"),h=c[1],g=a(c[0]),c=l[e],m=typeof c;"object"===m?Object.keys(c).length&&(e=g?b.getElementsByTagNameNS(g,h)[0]||b.ownerDocument.createElementNS(g,e):b.getElementsByTagName(h)[0]||b.ownerDocument.createElement(e),b.appendChild(e),d(e,c,a)):g&&(runtime.assert("number"===m||"string"===m,"attempting to map unsupported type '"+m+"' (key: "+e+")"),b.setAttributeNS(g,e,String(c)))})}var b=null;this.splitBoundaries=function(b){var d,c=[],h,g,m;if(b.startContainer.nodeType===Node.TEXT_NODE||b.endContainer.nodeType=== Node.TEXT_NODE){h=b.endContainer;g=b.endContainer.nodeType!==Node.TEXT_NODE?b.endOffset===b.endContainer.childNodes.length:!1;m=b.endOffset;d=b.endContainer;if(mf))throw runtime.log("alert","watchdog timeout"),"timeout!";if(0k))throw runtime.log("alert","watchdog loop overflow"),"loop overflow";}};core.NodeFilterChain=function(f){var k=NodeFilter.FILTER_REJECT,a=NodeFilter.FILTER_ACCEPT;this.acceptNode=function(e){var c;for(c=0;c "+b.length),runtime.assert(0<=a,"Error in setPosition: "+a+" < 0"),a===b.length&&(h.nextSibling()?d=0:h.parentNode()?d=1:runtime.assert(!1,"Error in setUnfilteredPosition: position not valid."))):ae.windowBits&&(e.windowBits=-e.windowBits,0===e.windowBits&&(e.windowBits=-15));!(0<=e.windowBits&&16>e.windowBits)||a&&a.windowBits||(e.windowBits+=32);15e.windowBits&&0===(e.windowBits&15)&&(e.windowBits|=15);this.err=0;this.msg="";this.ended=!1;this.chunks= [];this.strm=new d;this.strm.avail_out=0;a=f.inflateInit2(this.strm,e.windowBits);if(a!==g.Z_OK)throw Error(h[a]);this.header=new b;f.inflateGetHeader(this.strm,this.header)};r.prototype.push=function(b,d){var a=this.strm,e=this.options.chunkSize,c,r,h,m,C;if(this.ended)return!1;r=d===~~d?d:!0===d?g.Z_FINISH:g.Z_NO_FLUSH;a.input="string"===typeof b?q.binstring2buf(b):b;a.next_in=0;a.avail_in=a.input.length;do{0===a.avail_out&&(a.output=new p.Buf8(e),a.next_out=0,a.avail_out=e);c=f.inflate(a,g.Z_NO_FLUSH); if(c!==g.Z_STREAM_END&&c!==g.Z_OK)return this.onEnd(c),this.ended=!0,!1;if(a.next_out&&(0===a.avail_out||c===g.Z_STREAM_END||0===a.avail_in&&r===g.Z_FINISH))if("string"===this.options.to)h=q.utf8border(a.output,a.next_out),m=a.next_out-h,C=q.buf2string(a.output,h),a.next_out=m,a.avail_out=e-m,m&&p.arraySet(a.output,a.output,h,m,0),this.onData(C);else this.onData(p.shrinkBuf(a.output,a.next_out))}while((0d&&(b.subarray&&q||!b.subarray&&p))return String.fromCharCode.apply(null,f.shrinkBuf(b,d));for(var a="",e=0;ea;a++)d[a]=252<=a?6:248<= a?5:240<=a?4:224<=a?3:192<=a?2:1;d[254]=d[254]=1;c.string2buf=function(b){var d,a,e,c,h,g=b.length,m=0;for(c=0;ca?1:2048>a?2:65536>a?3:4;d=new f.Buf8(m);for(c=h=0;ha?d[h++]=a:(2048>a?d[h++]=192|a>>>6:(65536>a?d[h++]=224|a>>>12:(d[h++]= 240|a>>>18,d[h++]=128|a>>>12&63),d[h++]=128|a>>>6&63),d[h++]=128|a&63);return d};c.buf2binstring=function(b){return m(b,b.length)};c.binstring2buf=function(b){for(var d=new f.Buf8(b.length),a=0,e=d.length;ah)p[c++]=h;else if(g=d[h],4h?p[c++]=h:(h-=65536,p[c++]= 55296|h>>10&1023,p[c++]=56320|h&1023)}return m(p,c)};c.utf8border=function(b,a){var e;a=a||b.length;a>b.length&&(a=b.length);for(e=a-1;0<=e&&128===(b[e]&192);)e--;return 0>e||0===e?a:e+d[b[e]]>a?e:a}},{"./common":2}],4:[function(a,e,c){e.exports=function(a,e,c,f){var g=a&65535|0;a=a>>>16&65535|0;for(var h=0;0!==c;){h=2E3c;c++){a=c;for(var g=0;8>g;g++)a=a&1?3988292384^a>>>1:a>>>1;e[c]=a}return e}();e.exports=function(a,e,c,g){c=g+c;for(a^= -1;g>>8^m[(a^e[g])&255];return a^-1}},{}],7:[function(a,e,c){e.exports=function(){this.os=this.xflags=this.time=this.text=0;this.extra=null;this.extra_len=0;this.comment=this.name="";this.hcrc=0;this.done=!1}},{}],8:[function(a,e,c){e.exports=function(a,e){var c,f,g,h,d,b,r,l,y,t,z,w,s,x,u,C,H,D,G,B,J,P,Q,A;c=a.state;f=a.next_in;Q=a.input;g=f+(a.avail_in-5);h=a.next_out;A=a.output;d=h-(e-a.avail_out);b=h+(a.avail_out-257);r=c.dmax;l=c.wsize;y=c.whave;t=c.wnext;z=c.window;w=c.hold;s=c.bits; x=c.lencode;u=c.distcode;C=(1<s&&(w+=Q[f++]<>>24;w>>>=G;s-=G;G=D>>>16&255;if(0===G)A[h++]=D&65535;else if(G&16){B=D&65535;if(G&=15)s>>=G,s-=G;15>s&&(w+=Q[f++]<>>24;w>>>=G;s-=G;G=D>>>16&255;if(G&16){D&=65535;G&=15;sr){a.msg="invalid distance too far back"; c.mode=30;break a}w>>>=G;s-=G;G=h-d;if(D>G){G=D-G;if(G>y&&c.sane){a.msg="invalid distance too far back";c.mode=30;break a}J=0;P=z;if(0===t){if(J+=l-G,G>3;f-=B;s-=B<<3;a.next_in=f;a.next_out=h;a.avail_in=f>>24&255)+(b>>>8&65280)+((b&65280)<<8)+((b&255)<<24)}function n(){this.mode=0;this.last=!1;this.wrap=0;this.havedict=!1;this.total=this.check=this.dmax=this.flags=0;this.head=null;this.wnext=this.whave=this.wsize=this.wbits=0;this.window=null;this.extra=this.offset=this.length=this.bits=this.hold=0;this.distcode=this.lencode=null;this.have=this.ndist=this.nlen=this.ncode=this.distbits=this.lenbits=0;this.next=null;this.lens=new d.Buf16(320);this.work= new d.Buf16(288);this.distdyn=this.lendyn=null;this.was=this.back=this.sane=0}function p(b){var a;if(!b||!b.state)return z;a=b.state;b.total_in=b.total_out=a.total=0;b.msg="";a.wrap&&(b.adler=a.wrap&1);a.mode=w;a.last=0;a.havedict=0;a.dmax=32768;a.head=null;a.hold=0;a.bits=0;a.lencode=a.lendyn=new d.Buf32(s);a.distcode=a.distdyn=new d.Buf32(x);a.sane=1;a.back=-1;return t}function q(b){var d;if(!b||!b.state)return z;d=b.state;d.wsize=0;d.whave=0;d.wnext=0;return p(b)}function g(b,d){var a,e;if(!b|| !b.state)return z;e=b.state;0>d?(a=0,d=-d):(a=(d>>4)+1,48>d&&(d&=15));if(d&&(8>d||15s;){if(0===n)break a;n--;v+=h[p++]<>>8&255;c.check=r(c.check,W,2,0);s=v=0;c.mode=2;break}c.flags=0;c.head&&(c.head.done=!1);if(!(c.wrap&1)||(((v&255)<<8)+(v>>8))%31){a.msg="incorrect header check";c.mode=30;break}if(8!==(v&15)){a.msg="unknown compression method";c.mode=30;break}v>>>=4;s-=4;N=(v&15)+8;if(0===c.wbits)c.wbits=N;else if(N>c.wbits){a.msg="invalid window size";c.mode=30;break}c.dmax=1<s;){if(0===n)break a;n--;v+=h[p++]<>8&1);c.flags&512&&(W[0]=v&255,W[1]=v>>>8&255,c.check=r(c.check,W,2,0));s=v=0;c.mode=3;case 3:for(;32>s;){if(0===n)break a;n--;v+=h[p++]<>>8&255,W[2]=v>>>16&255,W[3]=v>>>24&255,c.check=r(c.check,W,4,0));s=v=0;c.mode=4;case 4:for(;16>s;){if(0===n)break a;n--;v+=h[p++]<>8);c.flags&512&&(W[0]=v&255,W[1]=v>>>8&255,c.check=r(c.check,W,2,0));s=v=0;c.mode=5;case 5:if(c.flags&1024){for(;16>s;){if(0===n)break a;n--;v+=h[p++]<>>8&255,c.check=r(c.check,W,2,0));s=v=0}else c.head&&(c.head.extra=null);c.mode=6;case 6:if(c.flags&1024&&(F=c.length,F>n&&(F=n),F&&(c.head&&(N=c.head.extra_len-c.length,c.head.extra||(c.head.extra=Array(c.head.extra_len)),d.arraySet(c.head.extra, h,p,F,N)),c.flags&512&&(c.check=r(c.check,h,F,p)),n-=F,p+=F,c.length-=F),c.length))break a;c.length=0;c.mode=7;case 7:if(c.flags&2048){if(0===n)break a;F=0;do N=h[p+F++],c.head&&N&&65536>c.length&&(c.head.name+=String.fromCharCode(N));while(N&&Fc.length&&(c.head.comment+=String.fromCharCode(N));while(N&&F< n);c.flags&512&&(c.check=r(c.check,h,F,p));n-=F;p+=F;if(N)break a}else c.head&&(c.head.comment=null);c.mode=9;case 9:if(c.flags&512){for(;16>s;){if(0===n)break a;n--;v+=h[p++]<>9&1,c.head.done=!0);a.adler=c.check=0;c.mode=12;break;case 10:for(;32>s;){if(0===n)break a;n--;v+=h[p++]<>>=s&7;s-=s&7;c.mode=27;break}for(;3>s;){if(0===n)break a;n--;v+=h[p++]<>>=1;s-=1;switch(v&3){case 0:c.mode=14;break;case 1:F=c;if(u){N=void 0;C=new d.Buf32(512);H=new d.Buf32(32);for(N=0;144>N;)F.lens[N++]=8;for(;256>N;)F.lens[N++]=9;for(;280>N;)F.lens[N++]=7;for(;288>N;)F.lens[N++]=8;y(1,F.lens,0,288,C,0,F.work,{bits:9});for(N=0;32>N;)F.lens[N++]=5;y(2,F.lens, 0,32,H,0,F.work,{bits:5});u=!1}F.lencode=C;F.lenbits=9;F.distcode=H;F.distbits=5;c.mode=20;if(6===e){v>>>=2;s-=2;break a}break;case 2:c.mode=17;break;case 3:a.msg="invalid block type",c.mode=30}v>>>=2;s-=2;break;case 14:v>>>=s&7;for(s-=s&7;32>s;){if(0===n)break a;n--;v+=h[p++]<>>16^65535)){a.msg="invalid stored block lengths";c.mode=30;break}c.length=v&65535;s=v=0;c.mode=15;if(6===e)break a;case 15:c.mode=16;case 16:if(F=c.length){F>n&&(F=n);F>q&&(F=q);if(0===F)break a;d.arraySet(g, h,p,F,A);n-=F;p+=F;q-=F;A+=F;c.length-=F;break}c.mode=12;break;case 17:for(;14>s;){if(0===n)break a;n--;v+=h[p++]<>>=5;s-=5;c.ndist=(v&31)+1;v>>>=5;s-=5;c.ncode=(v&15)+4;v>>>=4;s-=4;if(286s;){if(0===n)break a;n--;v+=h[p++]<>>=3;s-=3}for(;19>c.have;)c.lens[O[c.have++]]=0;c.lencode=c.lendyn;c.lenbits=7; F={bits:c.lenbits};U=y(0,c.lens,0,19,c.lencode,0,c.work,F);c.lenbits=F.bits;if(U){a.msg="invalid code lengths set";c.mode=30;break}c.have=0;c.mode=19;case 19:for(;c.have>>24;V=F>>>16&255;$=F&65535;if(E<=s)break;if(0===n)break a;n--;v+=h[p++]<$)v>>>=E,s-=E,c.lens[c.have++]=$;else{if(16===$){for(F=E+2;s>>=E;s-=E;if(0===c.have){a.msg="invalid bit length repeat";c.mode=30;break}N= c.lens[c.have-1];F=3+(v&3);v>>>=2;s-=2}else if(17===$){for(F=E+3;s>>=E;s-=E;N=0;F=3+(v&7);v>>>=3;s-=3}else{for(F=E+7;s>>=E;s-=E;N=0;F=11+(v&127);v>>>=7;s-=7}if(c.have+F>c.nlen+c.ndist){a.msg="invalid bit length repeat";c.mode=30;break}for(;F--;)c.lens[c.have++]=N}}if(30===c.mode)break;if(0===c.lens[256]){a.msg="invalid code -- missing end-of-block";c.mode=30;break}c.lenbits=9;F={bits:c.lenbits};U=y(1,c.lens, 0,c.nlen,c.lencode,0,c.work,F);c.lenbits=F.bits;if(U){a.msg="invalid literal/lengths set";c.mode=30;break}c.distbits=6;c.distcode=c.distdyn;F={bits:c.distbits};U=y(2,c.lens,c.nlen,c.ndist,c.distcode,0,c.work,F);c.distbits=F.bits;if(U){a.msg="invalid distances set";c.mode=30;break}c.mode=20;if(6===e)break a;case 20:c.mode=21;case 21:if(6<=n&&258<=q){a.next_out=A;a.avail_out=q;a.next_in=p;a.avail_in=n;c.hold=v;c.bits=s;l(a,T);A=a.next_out;g=a.output;q=a.avail_out;p=a.next_in;h=a.input;n=a.avail_in; v=c.hold;s=c.bits;12===c.mode&&(c.back=-1);break}for(c.back=0;;){F=c.lencode[v&(1<>>24;V=F>>>16&255;$=F&65535;if(E<=s)break;if(0===n)break a;n--;v+=h[p++]<>N)];E=F>>>24;V=F>>>16&255;$=F&65535;if(N+E<=s)break;if(0===n)break a;n--;v+=h[p++]<>>=N;s-=N;c.back+=N}v>>>=E;s-=E;c.back+=E;c.length=$;if(0===V){c.mode=26;break}if(V&32){c.back=-1;c.mode=12;break}if(V&64){a.msg="invalid literal/length code"; c.mode=30;break}c.extra=V&15;c.mode=22;case 22:if(c.extra){for(F=c.extra;s>>=c.extra;s-=c.extra;c.back+=c.extra}c.was=c.length;c.mode=23;case 23:for(;;){F=c.distcode[v&(1<>>24;V=F>>>16&255;$=F&65535;if(E<=s)break;if(0===n)break a;n--;v+=h[p++]<>N)];E=F>>>24;V=F>>>16&255;$=F&65535;if(N+E<=s)break;if(0===n)break a;n--;v+=h[p++]<>>=N;s-=N;c.back+=N}v>>>=E;s-=E;c.back+=E;if(V&64){a.msg="invalid distance code";c.mode=30;break}c.offset=$;c.extra=V&15;c.mode=24;case 24:if(c.extra){for(F=c.extra;s>>=c.extra;s-=c.extra;c.back+=c.extra}if(c.offset>c.dmax){a.msg="invalid distance too far back";c.mode=30;break}c.mode=25;case 25:if(0===q)break a;F=T-q;if(c.offset>F){F=c.offset-F;if(F>c.whave&&c.sane){a.msg="invalid distance too far back";c.mode=30;break}F> c.wnext?(F-=c.wnext,N=c.wsize-F):N=c.wnext-F;F>c.length&&(F=c.length);Z=c.window}else Z=g,N=A-c.offset,F=c.length;F>q&&(F=q);q-=F;c.length-=F;do g[A++]=Z[N++];while(--F);0===c.length&&(c.mode=21);break;case 26:if(0===q)break a;g[A++]=c.length;q--;c.mode=21;break;case 27:if(c.wrap){for(;32>s;){if(0===n)break a;n--;v|=h[p++]<s;){if(0===n)break a;n--;v+=h[p++]<c.mode&&(27>c.mode||4!==e))h=a.output,p=a.next_out,A=T-a.avail_out,q=a.state,null===q.window&&(q.wsize=1<=q.wsize?(d.arraySet(q.window,h,p-q.wsize,q.wsize,0),q.wnext=0,q.whave=q.wsize):(n=q.wsize-q.wnext,n>A&&(n=A),d.arraySet(q.window,h,p-A,n,q.wnext),(A-=n)?(d.arraySet(q.window,h,p-A,A,0),q.wnext=A,q.whave=q.wsize):(q.wnext+=n,q.wnext===q.wsize&&(q.wnext=0),q.whave=s;s++)I[s]=0;for(x=0;xC&&(H=C);if(0===C)return e[y++]=20971520,e[y++]=20971520,z.bits=1,0;for(u=1;u=s;s++)if(B<<=1,B-=I[s],0>B)return-1;if(0s;s++)D[s+1]=D[s]+I[s];for(x=0;xv?(N=ba[T+t[x]],Z=Y[S+t[x]]):(N=96,Z=0);B=1<>G)+Q]=F<<24|N<<16|Z|0;while(0!==Q);for(B=1<>=1;0!==B?(P&=B-1,P+=B):P=0;x++;if(0===--I[s]){if(s===C)break;s=d[b+t[x]]}if(s>H&&(P&c)!==A){0===G&&(G=H);w+=u;D=s-G;for(B=1<=B)break;D++;B<<=1}J+=1<>>8^h;return d^-1}function c(b){return new Date((b>>25&127)+1980,(b>>21&15)-1,b>>16&31,b>>11&15, b>>5&63,(b&31)<<1)}function m(b){var d=b.getFullYear();return 1980>d?0:d-1980<<25|b.getMonth()+1<<21|b.getDate()<<16|b.getHours()<<11|b.getMinutes()<<5|b.getSeconds()>>1}function n(b,d){var e,h,l,g,r,f,m,n=this;this.load=function(d){if(null!==n.data)d(null,n.data);else{var c=r+34+h+l+256;c+m>t&&(c=t-m);a(m,c,function(a,c){if(a||null===c)d(a,c);else a:{var e=c,h=new core.ByteArray(e),l=h.readUInt32LE(),m;if(67324752!==l)d("File entry signature is wrong."+l.toString()+" "+e.length.toString(),null); else{h.pos+=22;l=h.readUInt16LE();m=h.readUInt16LE();h.pos+=l+m;if(g){e=e.subarray(h.pos,h.pos+r);if(r!==e.length){d("The amount of compressed bytes read was "+e.length.toString()+" instead of "+r.toString()+" for "+n.filename+" in "+b+".",null);break a}e=w(e,f)}else e=e.subarray(h.pos,h.pos+f);f!==e.length?d("The amount of bytes read was "+e.length.toString()+" instead of "+f.toString()+" for "+n.filename+" in "+b+".",null):(n.data=e,d(null,e))}}})}};this.set=function(b,d,a,c){n.filename=b;n.data= d;n.compressed=a;n.date=c};this.error=null;d&&(e=d.readUInt32LE(),33639248!==e?this.error="Central directory entry has wrong signature at position "+(d.pos-4).toString()+' for file "'+b+'": '+d.data.length.toString():(d.pos+=6,g=d.readUInt16LE(),this.date=c(d.readUInt32LE()),d.readUInt32LE(),r=d.readUInt32LE(),f=d.readUInt32LE(),h=d.readUInt16LE(),l=d.readUInt16LE(),e=d.readUInt16LE(),d.pos+=8,m=d.readUInt32LE(),this.filename=runtime.byteArrayToString(d.data.subarray(d.pos,d.pos+h),"utf8"),this.data= null,d.pos+=h+l+e))}function p(b,d){if(22!==b.length)d("Central directory length should be 22.",s);else{var c=new core.ByteArray(b),e;e=c.readUInt32LE();101010256!==e?d("Central directory signature is wrong: "+e.toString(),s):(e=c.readUInt16LE(),0!==e?d("Zip files with non-zero disk numbers are not supported.",s):(e=c.readUInt16LE(),0!==e?d("Zip files with non-zero disk numbers are not supported.",s):(e=c.readUInt16LE(),z=c.readUInt16LE(),e!==z?d("Number of entries is inconsistent.",s):(e=c.readUInt32LE(), c=c.readUInt16LE(),c=t-22-e,a(c,t-c,function(b,a){if(b||null===a)d(b,s);else a:{var c=new core.ByteArray(a),e,h;l=[];for(e=0;eb.value||"%"===b.unit)?null:b}function G(b){return(b=H(b))&&"%"!==b.unit?null:b}function B(b){switch(b.namespaceURI){case odf.Namespaces.drawns:case odf.Namespaces.svgns:case odf.Namespaces.dr3dns:return!1;case odf.Namespaces.textns:switch(b.localName){case "note-body":case "ruby-text":return!1}break;case odf.Namespaces.officens:switch(b.localName){case "annotation":case "binary-data":case "event-listeners":return!1}break;default:switch(b.localName){case "cursor":case "editinfo":return!1}}return!0} function J(b,d){for(;0=d.value||"%"===d.unit)?null:d;return d||G(b)};this.parseFoLineHeight= function(b){return D(b)||G(b)};this.isTextContentContainingNode=B;this.getTextNodes=function(b,d){var a;a=I.getNodesInRange(b,function(b){var d=NodeFilter.FILTER_REJECT;b.nodeType===Node.TEXT_NODE?Boolean(m(b)&&(!p(b.textContent)||C(b,0)))&&(d=NodeFilter.FILTER_ACCEPT):B(b)&&(d=NodeFilter.FILTER_SKIP);return d},NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT);d||J(b,a);return a};this.getTextElements=P;this.getParagraphElements=function(b){var d;d=I.getNodesInRange(b,function(b){var d=NodeFilter.FILTER_REJECT; if(c(b))d=NodeFilter.FILTER_ACCEPT;else if(B(b)||q(b))d=NodeFilter.FILTER_SKIP;return d},NodeFilter.SHOW_ELEMENT);Q(b.startContainer,d,c);return d};this.getImageElements=function(b){var d;d=I.getNodesInRange(b,function(b){var d=NodeFilter.FILTER_SKIP;f(b)&&(d=NodeFilter.FILTER_ACCEPT);return d},NodeFilter.SHOW_ELEMENT);Q(b.startContainer,d,f);return d};this.getHyperlinkElements=function(b){var d=[],a=b.cloneRange();b.collapsed&&b.endContainer.nodeType===Node.ELEMENT_NODE&&(b=A(b.endContainer,b.endOffset), b.nodeType===Node.TEXT_NODE&&a.setEnd(b,1));P(a,!0,!1).forEach(function(b){for(b=b.parentNode;!c(b);){if(e(b)&&-1===d.indexOf(b)){d.push(b);break}b=b.parentNode}});a.detach();return d};this.getNormalizedFontFamilyName=function(b){/^(["'])(?:.|[\n\r])*?\1$/.test(b)||(b=b.replace(/^[ \t\r\n\f]*((?:.|[\n\r])*?)[ \t\r\n\f]*$/,"$1"),/[ \t\r\n\f]/.test(b)&&(b="'"+b.replace(/[ \t\r\n\f]+/g," ")+"'"));return b}};odf.OdfUtils=new odf.OdfUtilsImpl;gui.OdfTextBodyNodeFilter=function(){var f=odf.OdfUtils,k=Node.TEXT_NODE,a=NodeFilter.FILTER_REJECT,e=NodeFilter.FILTER_ACCEPT,c=odf.Namespaces.textns;this.acceptNode=function(m){if(m.nodeType===k){if(!f.isGroupingElement(m.parentNode))return a}else if(m.namespaceURI===c&&"tracked-changes"===m.localName)return a;return e}};xmldom.LSSerializerFilter=function(){};xmldom.LSSerializerFilter.prototype.acceptNode=function(f){};odf.OdfNodeFilter=function(){this.acceptNode=function(f){return"http://www.w3.org/1999/xhtml"===f.namespaceURI?NodeFilter.FILTER_SKIP:f.namespaceURI&&f.namespaceURI.match(/^urn:webodf:/)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}};xmldom.XPathIterator=function(){};xmldom.XPathIterator.prototype.next=function(){};xmldom.XPathIterator.prototype.reset=function(){}; function createXPathSingleton(){function f(a,d,b){return-1!==a&&(a=g&&b.push(k(a.substring(d,c)))):"["===a[c]&&(0>=g&&(d=c+1),g+=1),c+=1;return c};q=function(a,d,b){var g,l,f,m;for(g=0;g/g,">").replace(/'/g,"'").replace(/"/g,""")}function a(c,f){var n="",p=e.filter?e.filter.acceptNode(f):NodeFilter.FILTER_ACCEPT,q;if(p===NodeFilter.FILTER_ACCEPT&&f.nodeType===Node.ELEMENT_NODE){c.push();q=c.getQName(f);var g,h=f.attributes,d,b,r,l="",y;g="<"+q;d=h.length;for(b=0;b")}if(p===NodeFilter.FILTER_ACCEPT||p===NodeFilter.FILTER_SKIP){for(p=f.firstChild;p;)n+=a(c,p),p=p.nextSibling;f.nodeValue&&(n+=k(f.nodeValue))}q&&(n+="",c.pop());return n}var e=this;this.filter=null;this.writeToString=function(c,e){if(!c)return"";var n=new f(e);return a(n,c)}};(function(){function f(a){var d,b=p.length;for(d=0;db)break;e=e.nextSibling}a.insertBefore(d,e)}}}var c=new odf.StyleInfo,m=core.DomUtils,n=odf.Namespaces.stylens,p="meta settings scripts font-face-decls styles automatic-styles master-styles body".split(" "), q=Date.now()+"_webodf_",g=new core.Base64;odf.ODFElement=function(){};odf.ODFDocumentElement=function(){};odf.ODFDocumentElement.prototype=new odf.ODFElement;odf.ODFDocumentElement.prototype.constructor=odf.ODFDocumentElement;odf.ODFDocumentElement.prototype.fontFaceDecls=null;odf.ODFDocumentElement.prototype.manifest=null;odf.ODFDocumentElement.prototype.settings=null;odf.ODFDocumentElement.namespaceURI="urn:oasis:names:tc:opendocument:xmlns:office:1.0";odf.ODFDocumentElement.localName="document"; odf.AnnotationElement=function(){};odf.OdfPart=function(a,d,b,c){var e=this;this.size=0;this.type=null;this.name=a;this.container=b;this.url=null;this.mimetype=d;this.onstatereadychange=this.document=null;this.EMPTY=0;this.LOADING=1;this.DONE=2;this.state=this.EMPTY;this.data="";this.load=function(){null!==c&&(this.mimetype=d,c.loadAsDataURL(a,d,function(b,a){b&&runtime.log(b);e.url=a;if(e.onchange)e.onchange(e);if(e.onstatereadychange)e.onstatereadychange(e)}))}};odf.OdfPart.prototype.load=function(){}; odf.OdfPart.prototype.getUrl=function(){return this.data?"data:;base64,"+g.toBase64(this.data):null};odf.OdfContainer=function d(b,f){function l(b){for(var a=b.firstChild,d;a;)d=a.nextSibling,a.nodeType===Node.ELEMENT_NODE?l(a):a.nodeType===Node.PROCESSING_INSTRUCTION_NODE&&b.removeChild(a),a=d}function p(b){var a={},d,c,e=b.ownerDocument.createNodeIterator(b,NodeFilter.SHOW_ELEMENT,null,!1);for(b=e.nextNode();b;)"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===b.namespaceURI&&("annotation"=== b.localName?(d=b.getAttributeNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0","name"))&&(a.hasOwnProperty(d)?runtime.log("Warning: annotation name used more than once with : '"+d+"'"):a[d]=b):"annotation-end"===b.localName&&((d=b.getAttributeNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0","name"))?a.hasOwnProperty(d)?(c=a[d],c.annotationEndElement?runtime.log("Warning: annotation name used more than once with : '"+d+"'"):c.annotationEndElement= b):runtime.log("Warning: annotation end without an annotation start, name: '"+d+"'"):runtime.log("Warning: annotation end without a name found"))),b=e.nextNode()}function t(b,a){for(var d=b&&b.firstChild;d;)d.nodeType===Node.ELEMENT_NODE&&d.setAttributeNS("urn:webodf:names:scope","scope",a),d=d.nextSibling}function z(b,a){for(var d=U.rootElement.meta,d=d&&d.firstChild;d&&(d.namespaceURI!==b||d.localName!==a);)d=d.nextSibling;for(d=d&&d.firstChild;d&&d.nodeType!==Node.TEXT_NODE;)d=d.nextSibling;return d? d.data:null}function w(b){var a={},d;for(b=b.firstChild;b;)b.nodeType===Node.ELEMENT_NODE&&b.namespaceURI===n&&"font-face"===b.localName&&(d=b.getAttributeNS(n,"name"),a[d]=b),b=b.nextSibling;return a}function s(b,a){var d=null,c,e,l;if(b)for(d=b.cloneNode(!0),c=d.firstElementChild;c;)e=c.nextElementSibling,(l=c.getAttributeNS("urn:webodf:names:scope","scope"))&&l!==a&&d.removeChild(c),c=e;return d}function x(b,a){var d,e,l,g=null,f={};if(b)for(a.forEach(function(b){c.collectUsedFontFaces(f,b)}), g=b.cloneNode(!0),d=g.firstElementChild;d;)e=d.nextElementSibling,l=d.getAttributeNS(n,"name"),f[l]||g.removeChild(d),d=e;return g}function u(b){var d=U.rootElement.ownerDocument,a;if(b){l(b.documentElement);try{a=d.importNode(b.documentElement,!0)}catch(c){}}return a}function C(b){U.state=b;if(U.onchange)U.onchange(U);if(U.onstatereadychange)U.onstatereadychange(U)}function H(b){aa=null;U.rootElement=b;b.fontFaceDecls=m.getDirectChild(b,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","font-face-decls"); b.styles=m.getDirectChild(b,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","styles");b.automaticStyles=m.getDirectChild(b,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","automatic-styles");b.masterStyles=m.getDirectChild(b,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","master-styles");b.body=m.getDirectChild(b,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","body");b.meta=m.getDirectChild(b,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","meta");b.settings=m.getDirectChild(b,"urn:oasis:names:tc:opendocument:xmlns:office:1.0", "settings");b.scripts=m.getDirectChild(b,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","scripts");p(b)}function D(b){var a=u(b),l=U.rootElement,g;a&&"document-styles"===a.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===a.namespaceURI?(l.fontFaceDecls=m.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","font-face-decls"),e(l,l.fontFaceDecls),g=m.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","styles"),l.styles=g||b.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0", "styles"),e(l,l.styles),g=m.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","automatic-styles"),l.automaticStyles=g||b.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0","automatic-styles"),t(l.automaticStyles,"document-styles"),e(l,l.automaticStyles),a=m.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","master-styles"),l.masterStyles=a||b.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0","master-styles"),e(l,l.masterStyles), c.prefixStyleNames(l.automaticStyles,q,l.masterStyles)):C(d.INVALID)}function G(b){b=u(b);var a,l,g,f;if(b&&"document-content"===b.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===b.namespaceURI){a=U.rootElement;g=m.getDirectChild(b,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","font-face-decls");if(a.fontFaceDecls&&g){f=a.fontFaceDecls;var r,p,k,q,A={};l=w(f);q=w(g);for(g=g.firstElementChild;g;){r=g.nextElementSibling;if(g.namespaceURI===n&&"font-face"===g.localName)if(p=g.getAttributeNS(n, "name"),l.hasOwnProperty(p)){if(!g.isEqualNode(l[p])){k=p;for(var s=l,P=q,y=0,Y=void 0,Y=k=k.replace(/\d+$/,"");s.hasOwnProperty(Y)||P.hasOwnProperty(Y);)y+=1,Y=k+y;k=Y;g.setAttributeNS(n,"style:name",k);f.appendChild(g);l[k]=g;delete q[p];A[p]=k}}else f.appendChild(g),l[p]=g,delete q[p];g=r}f=A}else g&&(a.fontFaceDecls=g,e(a,g));l=m.getDirectChild(b,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","automatic-styles");t(l,"document-content");f&&c.changeFontFaceNames(l,f);if(a.automaticStyles&&l)for(f= l.firstChild;f;)a.automaticStyles.appendChild(f),f=l.firstChild;else l&&(a.automaticStyles=l,e(a,l));b=m.getDirectChild(b,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","body");if(null===b)throw" tag is mising.";a.body=b;e(a,a.body)}else C(d.INVALID)}function B(b){b=u(b);var a;b&&"document-meta"===b.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===b.namespaceURI&&(a=U.rootElement,a.meta=m.getDirectChild(b,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","meta"), e(a,a.meta))}function J(b){b=u(b);var a;b&&"document-settings"===b.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===b.namespaceURI&&(a=U.rootElement,a.settings=m.getDirectChild(b,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","settings"),e(a,a.settings))}function P(b){b=u(b);var a;if(b&&"manifest"===b.localName&&"urn:oasis:names:tc:opendocument:xmlns:manifest:1.0"===b.namespaceURI)for(a=U.rootElement,a.manifest=b,b=a.manifest.firstElementChild;b;)"file-entry"===b.localName&&"urn:oasis:names:tc:opendocument:xmlns:manifest:1.0"=== b.namespaceURI&&(O[b.getAttributeNS("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0","full-path")]=b.getAttributeNS("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0","media-type")),b=b.nextElementSibling}function Q(b,a,d){b=m.getElementsByTagName(b,a);var c;for(c=0;c'}function I(){var b=new xmldom.LSSerializer,a=v("document-meta");b.filter=new odf.OdfNodeFilter;a+=b.writeToString(U.rootElement.meta,odf.Namespaces.namespaceMap);return a+""}function ba(b,a){var d=document.createElementNS("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0","manifest:file-entry");d.setAttributeNS("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0","manifest:full-path",b);d.setAttributeNS("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0", "manifest:media-type",a);return d}function T(){var b=runtime.parseXML(''),a=b.documentElement,d=new xmldom.LSSerializer,c;for(c in O)O.hasOwnProperty(c)&&a.appendChild(ba(c,O[c]));d.filter=new odf.OdfNodeFilter;return'\n'+d.writeToString(b,odf.Namespaces.namespaceMap)}function F(){var b,a,d,e=odf.Namespaces.namespaceMap, l=new xmldom.LSSerializer,g=v("document-styles");a=s(U.rootElement.automaticStyles,"document-styles");d=U.rootElement.masterStyles.cloneNode(!0);b=x(U.rootElement.fontFaceDecls,[d,U.rootElement.styles,a]);c.removePrefixFromStyleNames(a,q,d);l.filter=new k(d,a);g+=l.writeToString(b,e);g+=l.writeToString(U.rootElement.styles,e);g+=l.writeToString(a,e);g+=l.writeToString(d,e);return g+""}function N(){var b,d,c=odf.Namespaces.namespaceMap,e=new xmldom.LSSerializer,l=v("document-content"); d=s(U.rootElement.automaticStyles,"document-content");b=x(U.rootElement.fontFaceDecls,[d]);e.filter=new a(U.rootElement.body,d);l+=e.writeToString(b,c);l+=e.writeToString(d,c);l+=e.writeToString(U.rootElement.body,c);return l+""}function Z(b,a){runtime.loadXML(b,function(b,c){if(b)a(b);else if(c){A(c);Y(c.documentElement);var e=u(c);e&&"document"===e.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===e.namespaceURI?(H(e),C(d.DONE)):C(d.INVALID)}else a("No DOM was loaded.")})} function E(b,a){var d;d=U.rootElement;var c=d.meta;c||(d.meta=c=document.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0","meta"),e(d,c));d=c;b&&m.mapKeyValObjOntoNode(d,b,odf.Namespaces.lookupNamespaceURI);a&&m.removeKeyElementsFromNode(d,a,odf.Namespaces.lookupNamespaceURI)}function V(b,a){function c(b,a){var d;a||(a=b);d=document.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0",a);f[b]=d;f.appendChild(d)}var e=new core.Zip("",null),l="application/vnd.oasis.opendocument."+ b+(!0===a?"-template":""),g=runtime.byteArrayFromString(l,"utf8"),f=U.rootElement,r=document.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0",b);e.save("mimetype",g,!1,new Date);c("meta");c("settings");c("scripts");c("fontFaceDecls","font-face-decls");c("styles");c("automaticStyles","automatic-styles");c("masterStyles","master-styles");c("body");f.body.appendChild(r);O["/"]=l;O["settings.xml"]="text/xml";O["meta.xml"]="text/xml";O["styles.xml"]="text/xml";O["content.xml"]="text/xml"; C(d.DONE);return e}function $(){var b,a=new Date,d="";U.rootElement.settings&&U.rootElement.settings.firstElementChild&&(b=new xmldom.LSSerializer,d=v("document-settings"),b.filter=new odf.OdfNodeFilter,d+=b.writeToString(U.rootElement.settings,odf.Namespaces.namespaceMap),d+="");(b=d)?(b=runtime.byteArrayFromString(b,"utf8"),W.save("settings.xml",b,!0,a)):W.remove("settings.xml");d=runtime.getWindow();b="WebODF/"+webodf.Version;d&&(b=b+" "+d.navigator.userAgent);E({"meta:generator":b}, null);b=runtime.byteArrayFromString(I(),"utf8");W.save("meta.xml",b,!0,a);b=runtime.byteArrayFromString(F(),"utf8");W.save("styles.xml",b,!0,a);b=runtime.byteArrayFromString(N(),"utf8");W.save("content.xml",b,!0,a);b=runtime.byteArrayFromString(T(),"utf8");W.save("META-INF/manifest.xml",b,!0,a)}function ca(b,a){$();W.writeAs(b,function(b){a(b)})}var U=this,W,O={},aa,R="";this.onstatereadychange=f;this.state=this.onchange=null;this.getMetadata=z;this.setRootElement=H;this.getContentElement=function(){var b; aa||(b=U.rootElement.body,aa=m.getDirectChild(b,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","text")||m.getDirectChild(b,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","presentation")||m.getDirectChild(b,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","spreadsheet"));if(!aa)throw"Could not find content element in .";return aa};this.getDocumentType=function(){var b=U.getContentElement();return b&&b.localName};this.isTemplate=function(){return"-template"===O["/"].substr(-9)}; this.setIsTemplate=function(b){var a=O["/"],d="-template"===a.substr(-9);b!==d&&(a=b?a+"-template":a.substr(0,a.length-9),O["/"]=a,b=runtime.byteArrayFromString(a,"utf8"),W.save("mimetype",b,!1,new Date))};this.getPart=function(b){return new odf.OdfPart(b,O[b],U,W)};this.getPartData=function(b,a){W.load(b,a)};this.setMetadata=E;this.incrementEditingCycles=function(){var b=z(odf.Namespaces.metans,"editing-cycles"),b=b?parseInt(b,10):0;isNaN(b)&&(b=0);E({"meta:editing-cycles":b+1},null);return b+1}; this.createByteArray=function(b,a){$();W.createByteArray(b,a)};this.saveAs=ca;this.save=function(b){ca(R,b)};this.getUrl=function(){return R};this.setBlob=function(b,a,d){d=g.convertBase64ToByteArray(d);W.save(b,d,!1,new Date);O.hasOwnProperty(b)&&runtime.log(b+" has been overwritten.");O[b]=a};this.removeBlob=function(b){var a=W.remove(b);runtime.assert(a,"file is not found: "+b);delete O[b]};this.state=d.LOADING;this.rootElement=function(b){var a=document.createElementNS(b.namespaceURI,b.localName), d;b=new b.Type;for(d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);return a}({Type:odf.ODFDocumentElement,namespaceURI:odf.ODFDocumentElement.namespaceURI,localName:odf.ODFDocumentElement.localName});b===odf.OdfContainer.DocumentType.TEXT?W=V("text"):b===odf.OdfContainer.DocumentType.TEXT_TEMPLATE?W=V("text",!0):b===odf.OdfContainer.DocumentType.PRESENTATION?W=V("presentation"):b===odf.OdfContainer.DocumentType.PRESENTATION_TEMPLATE?W=V("presentation",!0):b===odf.OdfContainer.DocumentType.SPREADSHEET?W=V("spreadsheet"): b===odf.OdfContainer.DocumentType.SPREADSHEET_TEMPLATE?W=V("spreadsheet",!0):(R=b,W=new core.Zip(R,function(b,a){W=a;b?Z(R,function(a){b&&(W.error=b+"\n"+a,C(d.INVALID))}):S([{path:"styles.xml",handler:D},{path:"content.xml",handler:G},{path:"meta.xml",handler:B},{path:"settings.xml",handler:J},{path:"META-INF/manifest.xml",handler:P}])}))};odf.OdfContainer.EMPTY=0;odf.OdfContainer.LOADING=1;odf.OdfContainer.DONE=2;odf.OdfContainer.INVALID=3;odf.OdfContainer.SAVING=4;odf.OdfContainer.MODIFIED=5;odf.OdfContainer.getContainer= function(a){return new odf.OdfContainer(a,null)}})();odf.OdfContainer.DocumentType={TEXT:1,TEXT_TEMPLATE:2,PRESENTATION:3,PRESENTATION_TEMPLATE:4,SPREADSHEET:5,SPREADSHEET_TEMPLATE:6};gui.AnnotatableCanvas=function(){};gui.AnnotatableCanvas.prototype.refreshSize=function(){};gui.AnnotatableCanvas.prototype.getZoomLevel=function(){};gui.AnnotatableCanvas.prototype.getSizer=function(){}; gui.AnnotationViewManager=function(f,k,a,e){function c(b){var a=b.annotationEndElement,c=h.createRange(),e=b.getAttributeNS(odf.Namespaces.officens,"name");a&&(c.setStart(b,b.childNodes.length),c.setEnd(a,0),b=d.getTextNodes(c,!1),b.forEach(function(b){var a;a:{for(a=b.parentNode;a.namespaceURI!==odf.Namespaces.officens||"body"!==a.localName;){if(a.namespaceURI===r&&"webodf-annotationHighlight"===a.className&&a.getAttribute("annotation")===e){a=!0;break a}a=a.parentNode}a=!1}a||(a=h.createElement("span"), a.className="webodf-annotationHighlight",a.setAttribute("annotation",e),b.parentNode.replaceChild(a,b),a.appendChild(b))}));c.detach()}function m(d){var c=f.getSizer();d?(a.style.display="inline-block",c.style.paddingRight=b.getComputedStyle(a).width):(a.style.display="none",c.style.paddingRight=0);f.refreshSize()}function n(){g.sort(function(b,a){return 0!==(b.compareDocumentPosition(a)&Node.DOCUMENT_POSITION_FOLLOWING)?-1:1})}function p(){var b;for(b=0;b=(r.getBoundingClientRect().top-n.bottom)/d?c.style.top=Math.abs(r.getBoundingClientRect().top-n.bottom)/d+20+"px":c.style.top="0px"):c.style.top="0px";h.style.left= e.getBoundingClientRect().width/d+"px";var e=h.style,r=h.getBoundingClientRect().left/d,m=h.getBoundingClientRect().top/d,n=c.getBoundingClientRect().left/d,p=c.getBoundingClientRect().top/d,k=0,q=0,k=n-r,k=k*k,q=p-m,q=q*q,r=Math.sqrt(k+q);e.width=r+"px";m=Math.asin((c.getBoundingClientRect().top-h.getBoundingClientRect().top)/(d*parseFloat(h.style.width)));h.style.transform="rotate("+m+"rad)";h.style.MozTransform="rotate("+m+"rad)";h.style.WebkitTransform="rotate("+m+"rad)";h.style.msTransform="rotate("+ m+"rad)"}}function q(b){var a=g.indexOf(b),d=b.parentNode.parentNode;"div"===d.localName&&(d.parentNode.insertBefore(b,d),d.parentNode.removeChild(d));b=b.getAttributeNS(odf.Namespaces.officens,"name");b=h.querySelectorAll('span.webodf-annotationHighlight[annotation="'+b+'"]');for(var c,d=0;dn||k.bottom>n)f.scrollTop=k.bottom-k.top<=n-c?f.scrollTop+(k.bottom-n):f.scrollTop+(k.top-c);k.leftm&&(f.scrollLeft=k.right-k.left<=m-e?f.scrollLeft+(k.right-m):f.scrollLeft-(e-k.left))}}};(function(){function f(a,m,n,p,k){var g,h=0,d;for(d in a)if(a.hasOwnProperty(d)){if(h===n){g=d;break}h+=1}g?m.getPartData(a[g].href,function(b,d){if(b)runtime.log(b);else if(d){var l="@font-face { font-family: "+(a[g].family||g)+"; src: url(data:application/x-font-ttf;charset=binary;base64,"+e.convertUTF8ArrayToBase64(d)+') format("truetype"); }';try{p.insertRule(l,p.cssRules.length)}catch(h){runtime.log("Problem inserting rule in CSS: "+runtime.toJson(h)+"\nRule: "+l)}}else runtime.log("missing font data for "+ a[g].href);f(a,m,n+1,p,k)}):k&&k()}var k=xmldom.XPath,a=odf.OdfUtils,e=new core.Base64;odf.FontLoader=function(){this.loadFonts=function(c,e){for(var n=c.rootElement.fontFaceDecls;e.cssRules.length;)e.deleteRule(e.cssRules.length-1);if(n){var p={},q,g,h,d;if(n)for(n=k.getODFElementsWithXPath(n,"style:font-face[svg:font-face-src]",odf.Namespaces.lookupNamespaceURI),q=0;q text|list-item:first-child > :not(text|list):first-child:before',x+="{",x+="counter-increment: "+s+" 0;",x+="}",f(a,x));for(;n.counterIdStack.length>=p;)n.counterIdStack.pop();n.counterIdStack.push(s);u=n.contentRules[p.toString()]||"";for(x=1;x<=p;x+=1)u=u.replace(x+"webodf-listLevel",n.counterIdStack[x-1]);x='text|list[webodfhelper|counter-id="'+k+'"] > text|list-item > :not(text|list):first-child:before'; x+="{";x+=u;x+="counter-increment: "+s+";";x+="}";f(a,x)}for(e=e.firstElementChild;e;)c(b,e,h,n),e=e.nextElementSibling}else n.continuedCounterIdStack=[]}var e=0,d="",b={};this.createCounterRules=function(a,d,f){var m=d.getAttributeNS(n,"id"),p=[];f&&(f=f.getAttributeNS("urn:webodf:names:helper","counter-id"),p=b[f].slice(0));a=new k(a,p);m?m="Y"+m:(e+=1,m="X"+e);c(m,d,0,a);b[m+"-level1-1"]=a.counterIdStack};this.initialiseCreatedCounters=function(){var b;b="office|document{"+("counter-reset: "+d+ ";");b+="}";f(a,b)}}var e=odf.Namespaces.fons,c=odf.Namespaces.stylens,m=odf.Namespaces.textns,n=odf.Namespaces.xmlns,p={1:"decimal",a:"lower-latin",A:"upper-latin",i:"lower-roman",I:"upper-roman"};odf.ListStyleToCss=function(){function k(a){var d=r.parseLength(a);return d?b.convert(d.value,d.unit,"px"):(runtime.log("Could not parse value '"+a+"'."),0)}function g(b){return b.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}function h(b,a){var d;b&&(d=b.getAttributeNS(m,"style-name"));return d===a}function d(b, d,e){d=d.getElementsByTagNameNS(m,"list");b=new a(b);var f,r,k,q,u,C,H={},D;for(D=0;D text|list-item > text|list",t-=1;t=B&&B.getAttributeNS(e,"text-align")||"left";switch(t){case "end":t="right";break;case "start":t="left"}"label-alignment"===J?(Q=P&&P.getAttributeNS(e,"margin-left")||"0px",S=P&&P.getAttributeNS(e,"text-indent")||"0px",v=P&&P.getAttributeNS(m,"label-followed-by"),P=k(Q)):(Q=B&&B.getAttributeNS(m,"space-before")||"0px",A=B&&B.getAttributeNS(m,"min-label-width")||"0px", Y=B&&B.getAttributeNS(m,"min-label-distance")||"0px",P=k(Q)+k(A));B=p+" > text|list-item";B+="{";B+="margin-left: "+P+"px;";B+="}";f(g,B);B=p+" > text|list-item > text|list";B+="{";B+="margin-left: "+-P+"px;";B+="}";f(g,B);B=p+" > text|list-item > :not(text|list):first-child:before";B+="{";B+="text-align: "+t+";";B+="display: inline-block;";"label-alignment"===J?(B+="margin-left: "+S+";","listtab"===v&&(B+="padding-right: 0.2cm;")):(B+="min-width: "+A+";",B+="margin-left: "+(0===parseFloat(A)?"": "-")+A+";",B+="padding-right: "+Y+";");B+="}";f(g,B)}d=d.nextElementSibling}});d(b,g,h)}}})();odf.LazyStyleProperties=function(f,k){var a={};this.value=function(e){var c;a.hasOwnProperty(e)?c=a[e]:(c=k[e](),void 0===c&&f&&(c=f.value(e)),a[e]=c);return c};this.reset=function(e){f=e;a={}}}; odf.StyleParseUtils=function(){function f(a){var e,c;a=(a=/(-?[0-9]*[0-9][0-9]*(\.[0-9]*)?|0+\.[0-9]*[1-9][0-9]*|\.[0-9]*[1-9][0-9]*)((cm)|(mm)|(in)|(pt)|(pc)|(px))/.exec(a))?{value:parseFloat(a[1]),unit:a[3]}:null;c=a&&a.unit;"px"===c?e=a.value:"cm"===c?e=96*(a.value/2.54):"mm"===c?e=96*(a.value/25.4):"in"===c?e=96*a.value:"pt"===c?e=a.value/0.75:"pc"===c&&(e=16*a.value);return e}var k=odf.Namespaces.stylens;this.parseLength=f;this.parsePositiveLengthOrPercent=function(a,e,c){var m;a&&(m=parseFloat(a.substr(0, a.indexOf("%"))),isNaN(m)&&(m=void 0));var n;void 0!==m?(c&&(n=c.value(e)),m=void 0===n?void 0:m*(n/100)):m=f(a);return m};this.getPropertiesElement=function(a,e,c){for(e=c?c.nextElementSibling:e.firstElementChild;null!==e&&(e.localName!==a||e.namespaceURI!==k);)e=e.nextElementSibling;return e};this.parseAttributeList=function(a){a&&(a=a.replace(/^\s*(.*?)\s*$/g,"$1"));return a&&0r.value&&(l="0.75pt"+g);g=l}else if(A.hasOwnProperty(e[1])){var l= b,f=e[0],r=e[1],m=S.parseLength(g),n=void 0,p=void 0,q=void 0,s=void 0,q=void 0;if(m&&"%"===m.unit){n=m.value/100;p=k(l.parentNode);for(s="0";p;){if(q=y.getDirectChild(p,h,"paragraph-properties"))if(q=S.parseLength(q.getAttributeNS(f,r))){if("%"!==q.unit){s=q.value*n+q.unit;break}n*=q.value/100}p=k(p)}g=s}}e[2]&&(d+=e[2]+":"+g+";")}return d}function e(b,a,d,c){return a+a+d+d+c+c}function c(b,a){var d=[b],e=a.derivedStyles;Object.keys(e).forEach(function(b){b=c(b,e[b]);d=d.concat(b)});return d}function m(b, a,d,e){function g(a,d){var c=[],e;a.forEach(function(b){h.forEach(function(a){c.push('draw|page[webodfhelper|page-style-name="'+a+'"] draw|frame[presentation|class="'+b+'"]')})});0w&&(b=w);for(d=Math.floor(b/a)*a;!c&&0<=d;)c=l[d],d-=a;for(c=c||z;c.nextBookmark&&c.nextBookmark.steps<= b;)e.check(),c=c.nextBookmark;runtime.assert(-1===b||c.steps<=b,"Bookmark @"+n(c)+" at step "+c.steps+" exceeds requested step of "+b);return c}function d(b){b.previousBookmark&&(b.previousBookmark.nextBookmark=b.nextBookmark);b.nextBookmark&&(b.nextBookmark.previousBookmark=b.previousBookmark)}function b(b){for(var a,d=null;!d&&b&&b!==k;)(a=q(b))&&(d=y[a])&&d.node!==b&&(runtime.log("Cloned node detected. Creating new bookmark"),d=null,b.removeAttributeNS(r,"nodeId")),b=b.parentNode;return d}var r= "urn:webodf:names:steps",l={},y={},t=core.DomUtils,z,w,s=Node.DOCUMENT_POSITION_FOLLOWING,x=Node.DOCUMENT_POSITION_PRECEDING,u;this.updateBookmark=function(b,e){var f,r=Math.ceil(b/a)*a,m,n,p;if(void 0!==w&&wm.steps)l[r]=n;u()};this.setToClosestStep=function(b,a){var d;u();d=h(b);d.setIteratorPosition(a); return d.steps};this.setToClosestDomPoint=function(a,d,c){var e,g;u();if(a===k&&0===d)e=z;else if(a===k&&d===k.childNodes.length)for(g in e=z,l)l.hasOwnProperty(g)&&(a=l[g],a.steps>e.steps&&(e=a));else if(e=b(a.childNodes.item(d)||a),!e)for(c.setUnfilteredPosition(a,d);!e&&c.previousNode();)e=b(c.getCurrentNode());e=e||z;void 0!==w&&e.steps>w&&(e=h(w));e.setIteratorPosition(c);return e.steps};this.damageCacheAfterStep=function(b){0>b&&(b=-1);void 0===w?w=b:bb)throw new RangeError("Requested steps is negative ("+b+")");for(d=n.setToClosestStep(b,k);dq.comparePoints(f,0,b,d),b=f,d=d?0:f.childNodes.length);k.setUnfilteredPosition(b,d);m(k,e)||k.setUnfilteredPosition(b,d);e=k.container();d=k.unfilteredDomOffset();b=n.setToClosestDomPoint(e,d,k);if(0>q.comparePoints(k.container(),k.unfilteredDomOffset(),e,d))return 0=g.textNode.length?null:g.textNode.splitText(g.offset));for(b=g.textNode;b!==d;){b=b.parentNode;r=b.cloneNode(!1);l&&r.appendChild(l);if(y)for(;y&&y.nextSibling;)r.appendChild(y.nextSibling);else for(;b.firstChild;)r.appendChild(b.firstChild);b.parentNode.insertBefore(r,b.nextSibling);y=b;l=r}n.isListItem(l)&&(l=l.childNodes.item(0));m?l.setAttributeNS(p,"text:style-name",m):l.removeAttributeNS(p,"style-name");0===g.textNode.length&& g.textNode.parentNode.removeChild(g.textNode);a.emit(ops.OdtDocument.signalStepsInserted,{position:e});t&&c&&(a.moveCursor(f,e+1,0),a.emit(ops.Document.signalCursorMoved,t));a.fixCursorPositions();a.getOdfCanvas().refreshSize();a.emit(ops.OdtDocument.signalParagraphChanged,{paragraphElement:h,memberId:f,timeStamp:k});a.emit(ops.OdtDocument.signalParagraphChanged,{paragraphElement:l,memberId:f,timeStamp:k});a.getOdfCanvas().rerenderAnnotations();return!0};this.spec=function(){return{optype:"SplitParagraph", memberid:f,timestamp:k,position:e,sourceParagraphPosition:a,paragraphStyleName:m,moveCursor:c}}};ops.OpUpdateMember=function(){function f(a){var c="//dc:creator[@editinfo:memberid='"+k+"']";a=xmldom.XPath.getODFElementsWithXPath(a.getRootNode(),c,function(a){return"editinfo"===a?"urn:webodf:names:editinfo":odf.Namespaces.lookupNamespaceURI(a)});for(c=0;c=g.width&&(g=null),f.detach();else if(k.isCharacterElement(c.container)||k.isCharacterFrame(c.container))g=e.getBoundingClientRect(c.container); return g}var k=odf.OdfUtils,a=new odf.StepUtils,e=core.DomUtils,c=core.StepDirection.NEXT,m=gui.StepInfo.VisualDirection.LEFT_TO_RIGHT,n=gui.StepInfo.VisualDirection.RIGHT_TO_LEFT;this.getContentRect=f;this.moveToFilteredStep=function(a,e,g){function h(b,a){a.process(w,l,y)&&(b=!0,!t&&a.token&&(t=a.token));return b}var d=e===c,b,k,l,y,t,z=a.snapshot();b=!1;var w;do b=f(a),w={token:a.snapshot(),container:a.container,offset:a.offset,direction:e,visualDirection:e===c?m:n},k=a.nextStep()?f(a):null,a.restore(w.token), d?(l=b,y=k):(l=k,y=b),b=g.reduce(h,!1);while(!b&&a.advanceStep(e));b||g.forEach(function(b){!t&&b.token&&(t=b.token)});a.restore(t||z);return Boolean(t)}};gui.Caret=function(f,k,a,e){function c(){h.style.opacity="0"===h.style.opacity?"1":"0";x.trigger()}function m(){l.selectNodeContents(r);return l.getBoundingClientRect()}function n(){Object.keys(D).forEach(function(b){G[b]=D[b]})}function p(){if(!1===D.isShown||f.getSelectionType()!==ops.OdtCursor.RangeSelection||!e&&!f.getSelectedRange().collapsed)D.visibility="hidden",h.style.visibility="hidden",x.cancel();else if(D.visibility="visible",h.style.visibility="visible",!1===D.isFocused)h.style.opacity= "1",x.cancel();else{if(u||G.visibility!==D.visibility)h.style.opacity="1",x.cancel();x.trigger()}if(H||C){var a;a=f.getNode();var c,l,r=t.getBoundingClientRect(y.getSizer()),p=!1,q=0;a.removeAttributeNS("urn:webodf:names:cursor","caret-sizer-active");if(0a.height&&(a={top:a.top-(8-a.height)/2,height:8,right:a.right});g.style.height=a.height+"px";g.style.top=a.top+"px";g.style.left=a.right- a.width+"px";g.style.width=a.width?a.width+"px":"";b&&(a=runtime.getWindow().getComputedStyle(f.getNode(),null),a.font?b.style.font=a.font:(b.style.fontStyle=a.fontStyle,b.style.fontVariant=a.fontVariant,b.style.fontWeight=a.fontWeight,b.style.fontSize=a.fontSize,b.style.lineHeight=a.lineHeight,b.style.fontFamily=a.fontFamily))}D.isShown&&C&&k.scrollIntoView(h.getBoundingClientRect());G.isFocused!==D.isFocused&&d.markAsFocussed(D.isFocused);n();H=C=u=!1}function q(b){g.parentNode.removeChild(g);r.parentNode.removeChild(r); b()}var g,h,d,b,r,l,y=f.getDocument().getCanvas(),t=core.DomUtils,z=new gui.GuiStepUtils,w,s,x,u=!1,C=!1,H=!1,D={isFocused:!1,isShown:!0,visibility:"hidden"},G={isFocused:!D.isFocused,isShown:!D.isShown,visibility:"hidden"};this.handleUpdate=function(){H=!0;s.trigger()};this.refreshCursorBlinking=function(){u=!0;s.trigger()};this.setFocus=function(){D.isFocused=!0;s.trigger()};this.removeFocus=function(){D.isFocused=!1;s.trigger()};this.show=function(){D.isShown=!0;s.trigger()};this.hide=function(){D.isShown= !1;s.trigger()};this.setAvatarImageUrl=function(b){d.setImageUrl(b)};this.setColor=function(b){h.style.borderColor=b;d.setColor(b)};this.getCursor=function(){return f};this.getFocusElement=function(){return h};this.toggleHandleVisibility=function(){d.isVisible()?d.hide():d.show()};this.showHandle=function(){d.show()};this.hideHandle=function(){d.hide()};this.setOverlayElement=function(a){b=a;g.appendChild(a);H=!0;s.trigger()};this.ensureVisible=function(){C=!0;s.trigger()};this.getBoundingClientRect= function(){return t.getBoundingClientRect(g)};this.destroy=function(b){core.Async.destroyAll([s.destroy,x.destroy,d.destroy,q],b)};(function(){var b=f.getDocument(),e=[b.createRootFilter(f.getMemberId()),b.getPositionFilter()],m=b.getDOMDocument();l=m.createRange();r=m.createElement("span");r.className="webodf-caretSizer";r.textContent="|";f.getNode().appendChild(r);g=m.createElement("div");g.setAttributeNS("urn:webodf:names:editinfo","editinfo:memberid",f.getMemberId());g.className="webodf-caretOverlay"; h=m.createElement("div");h.className="caret";g.appendChild(h);d=new gui.Avatar(g,a);y.getSizer().appendChild(g);w=b.createStepIterator(f.getNode(),0,e,b.getRootNode());s=core.Task.createRedrawTask(p);x=core.Task.createTimeoutTask(c,500);s.triggerImmediate()})()};odf.TextSerializer=function(){function f(e){var c="",m=k.filter?k.filter.acceptNode(e):NodeFilter.FILTER_ACCEPT,n=e.nodeType,p;if((m===NodeFilter.FILTER_ACCEPT||m===NodeFilter.FILTER_SKIP)&&a.isTextContentContainingNode(e))for(p=e.firstChild;p;)c+=f(p),p=p.nextSibling;m===NodeFilter.FILTER_ACCEPT&&(n===Node.ELEMENT_NODE&&a.isParagraph(e)?c+="\n":n===Node.TEXT_NODE&&e.textContent&&(c+=e.textContent));return c}var k=this,a=odf.OdfUtils;this.filter=null;this.writeToString=function(a){if(!a)return""; a=f(a);"\n"===a[a.length-1]&&(a=a.substr(0,a.length-1));return a}};gui.MimeDataExporter=function(){var f;this.exportRangeToDataTransfer=function(k,a){var e;e=a.startContainer.ownerDocument.createElement("span");e.appendChild(a.cloneContents());e=f.writeToString(e);try{k.setData("text/plain",e)}catch(c){k.setData("Text",e)}};f=new odf.TextSerializer;f.filter=new odf.OdfNodeFilter};gui.Clipboard=function(f){this.setDataFromRange=function(k,a){var e,c=k.clipboardData;e=runtime.getWindow();!c&&e&&(c=e.clipboardData);c?(e=!0,f.exportRangeToDataTransfer(c,a),k.preventDefault()):e=!1;return e}};gui.SessionContext=function(f,k){var a=f.getOdtDocument(),e=odf.OdfUtils;this.isLocalCursorWithinOwnAnnotation=function(){var c=a.getCursor(k),f;if(!c)return!1;f=c&&c.getNode();c=a.getMember(k).getProperties().fullName;return(f=e.getParentAnnotation(f,a.getRootNode()))&&e.getAnnotationCreator(f)===c?!0:!1}};gui.StyleSummary=function(f){function k(a,e){var k=a+"|"+e,q;c.hasOwnProperty(k)||(q=[],f.forEach(function(c){c=(c=c.styleProperties[a])&&c[e];-1===q.indexOf(c)&&q.push(c)}),c[k]=q);return c[k]}function a(a,c,e){return function(){var f=k(a,c);return e.length>=f.length&&f.every(function(a){return-1!==e.indexOf(a)})}}function e(a,c){var e=k(a,c);return 1===e.length?e[0]:void 0}var c={};this.getPropertyValues=k;this.getCommonValue=e;this.isBold=a("style:text-properties","fo:font-weight",["bold"]);this.isItalic= a("style:text-properties","fo:font-style",["italic"]);this.hasUnderline=a("style:text-properties","style:text-underline-style",["solid"]);this.hasStrikeThrough=a("style:text-properties","style:text-line-through-style",["solid"]);this.fontSize=function(){var a=e("style:text-properties","fo:font-size");return a&&parseFloat(a)};this.fontName=function(){return e("style:text-properties","style:font-name")};this.isAlignedLeft=a("style:paragraph-properties","fo:text-align",["left","start"]);this.isAlignedCenter= a("style:paragraph-properties","fo:text-align",["center"]);this.isAlignedRight=a("style:paragraph-properties","fo:text-align",["right","end"]);this.isAlignedJustified=a("style:paragraph-properties","fo:text-align",["justify"]);this.text={isBold:this.isBold,isItalic:this.isItalic,hasUnderline:this.hasUnderline,hasStrikeThrough:this.hasStrikeThrough,fontSize:this.fontSize,fontName:this.fontName};this.paragraph={isAlignedLeft:this.isAlignedLeft,isAlignedCenter:this.isAlignedCenter,isAlignedRight:this.isAlignedRight, isAlignedJustified:this.isAlignedJustified}};gui.DirectFormattingController=function(f,k,a,e,c,m,n){function p(){return V.value().styleSummary}function q(){return V.value().enabledFeatures}function g(b){var a;b.collapsed?(a=b.startContainer,a.hasChildNodes()&&b.startOffsetb.clientWidth||b.scrollHeight>b.clientHeight)&&a.push(new h(b)),b=b.parentNode;a.push(new g(s));return a}function w(){var b; l()||(b=z(D),t(),D.focus(),b.forEach(function(b){b.restore()}))}var s=runtime.getWindow(),x={beforecut:!0,beforepaste:!0,longpress:!0,drag:!0,dragstop:!0},u={mousedown:!0,mouseup:!0,focus:!0},C={},H={},D,G=f.getCanvas().getElement(),B=this,J={};this.addFilter=function(b,a){d(b,!0).filters.push(a)};this.removeFilter=function(b,a){var c=d(b,!0),e=c.filters.indexOf(a);-1!==e&&c.filters.splice(e,1)};this.subscribe=b;this.unsubscribe=r;this.hasFocus=l;this.focus=w;this.getEventTrap=function(){return D}; this.setEditing=function(b){var a=l();a&&D.blur();b?D.removeAttribute("readOnly"):D.setAttribute("readOnly","true");a&&w()};this.destroy=function(b){r("touchstart",q);Object.keys(J).forEach(function(b){e(parseInt(b,10))});J.length=0;Object.keys(C).forEach(function(b){C[b].destroy()});C={};r("mousedown",y);r("mouseup",t);r("contextmenu",t);Object.keys(H).forEach(function(b){H[b].destroy()});H={};D.parentNode.removeChild(D);b()};(function(){var d=f.getOdfCanvas().getSizer(),c=d.ownerDocument;runtime.assert(Boolean(s), "EventManager requires a window object to operate correctly");D=c.createElement("textarea");D.id="eventTrap";D.setAttribute("tabindex","-1");D.setAttribute("readOnly","true");D.setAttribute("rows","1");d.appendChild(D);b("mousedown",y);b("mouseup",t);b("contextmenu",t);C.longpress=new a("longpress",["touchstart","touchmove","touchend"],m);C.drag=new a("drag",["touchstart","touchmove","touchend"],n);C.dragstop=new a("dragstop",["drag","touchend"],p);b("touchstart",q)})()};gui.IOSSafariSupport=function(f){function k(){a.innerHeight!==a.outerHeight&&(e.style.display="none",runtime.requestAnimationFrame(function(){e.style.display="block"}))}var a=runtime.getWindow(),e=f.getEventTrap();this.destroy=function(a){f.unsubscribe("focus",k);e.removeAttribute("autocapitalize");e.style.WebkitTransform="";a()};f.subscribe("focus",k);e.setAttribute("autocapitalize","off");e.style.WebkitTransform="translateX(-10000px)"};gui.HyperlinkController=function(f,k,a,e){function c(){var c=!0;!0===k.getState(gui.CommonConstraints.EDIT.REVIEW_MODE)&&(c=a.isLocalCursorWithinOwnAnnotation());c!==g&&(g=c,q.emit(gui.HyperlinkController.enabledChanged,g))}function m(a){a.getMemberId()===e&&c()}var n=odf.OdfUtils,p=f.getOdtDocument(),q=new core.EventNotifier([gui.HyperlinkController.enabledChanged]),g=!1;this.isEnabled=function(){return g};this.subscribe=function(a,d){q.subscribe(a,d)};this.unsubscribe=function(a,d){q.unsubscribe(a, d)};this.addHyperlink=function(a,d){if(g){var b=p.getCursorSelection(e),c=new ops.OpApplyHyperlink,l=[];if(0===b.length||d)d=d||a,c=new ops.OpInsertText,c.init({memberid:e,position:b.position,text:d}),b.length=d.length,l.push(c);c=new ops.OpApplyHyperlink;c.init({memberid:e,position:b.position,length:b.length,hyperlink:a});l.push(c);f.enqueue(l)}};this.removeHyperlinks=function(){if(g){var a=p.createPositionIterator(p.getRootNode()),d=p.getCursor(e).getSelectedRange(),b=n.getHyperlinkElements(d), c=d.collapsed&&1===b.length,l=p.getDOMDocument().createRange(),m=[],k,q;0!==b.length&&(b.forEach(function(b){l.selectNodeContents(b);k=p.convertDomToCursorRange({anchorNode:l.startContainer,anchorOffset:l.startOffset,focusNode:l.endContainer,focusOffset:l.endOffset});q=new ops.OpRemoveHyperlink;q.init({memberid:e,position:k.position,length:k.length});m.push(q)}),c||(c=b[0],-1===d.comparePoint(c,0)&&(l.setStart(c,0),l.setEnd(d.startContainer,d.startOffset),k=p.convertDomToCursorRange({anchorNode:l.startContainer, anchorOffset:l.startOffset,focusNode:l.endContainer,focusOffset:l.endOffset}),0m.width&&(n=m.width/k.width);k.height>m.height&&(s=m.height/k.height);m=Math.min(n,s);k={width:k.width*m,height:k.height* m}}m=k.width+"px";k=k.height+"px";var x=g.getOdfCanvas().odfContainer().rootElement.styles,n=b.toLowerCase(),s=p.hasOwnProperty(n)?p[n]:null,u,n=[];runtime.assert(null!==s,"Image type is not supported: "+b);s="Pictures/"+c.generateImageName()+s;u=new ops.OpSetBlob;u.init({memberid:e,filename:s,mimetype:b,content:a});n.push(u);d.getStyleElement("Graphics","graphic",[x])||(b=new ops.OpAddStyle,b.init({memberid:e,styleName:"Graphics",styleFamily:"graphic",isAutomaticStyle:!1,setProperties:{"style:graphic-properties":{"text:anchor-type":"paragraph", "svg:x":"0cm","svg:y":"0cm","style:wrap":"dynamic","style:number-wrapped-paragraphs":"no-limit","style:wrap-contour":"false","style:vertical-pos":"top","style:vertical-rel":"paragraph","style:horizontal-pos":"center","style:horizontal-rel":"paragraph"}}}),n.push(b));b=c.generateStyleName();a=new ops.OpAddStyle;a.init({memberid:e,styleName:b,styleFamily:"graphic",isAutomaticStyle:!0,setProperties:{"style:parent-style-name":"Graphics","style:graphic-properties":{"style:vertical-pos":"top","style:vertical-rel":"baseline", "style:horizontal-pos":"center","style:horizontal-rel":"paragraph","fo:background-color":"transparent","style:background-transparency":"100%","style:shadow":"none","style:mirror":"none","fo:clip":"rect(0cm, 0cm, 0cm, 0cm)","draw:luminance":"0%","draw:contrast":"0%","draw:red":"0%","draw:green":"0%","draw:blue":"0%","draw:gamma":"100%","draw:color-inversion":"false","draw:image-opacity":"100%","draw:color-mode":"standard"}}});n.push(a);u=new ops.OpInsertImage;u.init({memberid:e,position:g.getCursorPosition(e), filename:s,frameWidth:m,frameHeight:k,frameStyleName:b,frameName:c.generateFrameName()});n.push(u);f.enqueue(n)}};this.destroy=function(b){g.unsubscribe(ops.Document.signalCursorMoved,n);k.unsubscribe(gui.CommonConstraints.EDIT.REVIEW_MODE,m);b()};g.subscribe(ops.Document.signalCursorMoved,n);k.subscribe(gui.CommonConstraints.EDIT.REVIEW_MODE,m);m()};gui.ImageController.enabledChanged="enabled/changed";gui.ImageSelector=function(f){function k(){var a=f.getSizer(),m=c.createElement("div");m.id="imageSelector";m.style.borderWidth="1px";a.appendChild(m);e.forEach(function(a){var e=c.createElement("div");e.className=a;m.appendChild(e)});return m}var a=odf.Namespaces.svgns,e="topLeft topRight bottomRight bottomLeft topMiddle rightMiddle bottomMiddle leftMiddle".split(" "),c=f.getElement().ownerDocument,m=!1;this.select=function(e){var p,q,g=c.getElementById("imageSelector");g||(g=k());m=!0;p=g.parentNode; q=e.getBoundingClientRect();var h=p.getBoundingClientRect(),d=f.getZoomLevel();p=(q.left-h.left)/d-1;q=(q.top-h.top)/d-1;g.style.display="block";g.style.left=p+"px";g.style.top=q+"px";g.style.width=e.getAttributeNS(a,"width");g.style.height=e.getAttributeNS(a,"height")};this.clearSelection=function(){var a;m&&(a=c.getElementById("imageSelector"))&&(a.style.display="none");m=!1};this.isSelectorElement=function(a){var e=c.getElementById("imageSelector");return e?a===e||a.parentNode===e:!1}};(function(){function f(f){function a(a){n=a.which&&String.fromCharCode(a.which)===m;m=void 0;return!1===n}function e(){n=!1}function c(a){m=a.data;n=!1}var m,n=!1;this.destroy=function(m){f.unsubscribe("textInput",e);f.unsubscribe("compositionend",c);f.removeFilter("keypress",a);m()};f.subscribe("textInput",e);f.subscribe("compositionend",c);f.addFilter("keypress",a)}gui.InputMethodEditor=function(k,a){function e(a){b&&(a?b.getNode().setAttributeNS(d,"composing","true"):(b.getNode().removeAttributeNS(d, "composing"),y.textContent=""))}function c(){z&&(z=!1,e(!1),s.emit(gui.InputMethodEditor.signalCompositionEnd,{data:w}),w="")}function m(){D||(D=!0,c(),b&&b.getSelectedRange().collapsed?r.value="":r.value=u.writeToString(b.getSelectedRange().cloneContents()),r.setSelectionRange(0,r.value.length),D=!1)}function n(){a.hasFocus()&&t.trigger()}function p(){x=void 0;t.cancel();e(!0);z||s.emit(gui.InputMethodEditor.signalCompositionStart,{data:""})}function q(b){b=x=b.data;z=!0;w+=b;t.trigger()}function g(b){b.data!== x&&(b=b.data,z=!0,w+=b,t.trigger());x=void 0}function h(){y.textContent=r.value}var d="urn:webodf:names:cursor",b=null,r=a.getEventTrap(),l=r.ownerDocument,y,t,z=!1,w="",s=new core.EventNotifier([gui.InputMethodEditor.signalCompositionStart,gui.InputMethodEditor.signalCompositionEnd]),x,u,C=[],H,D=!1;this.subscribe=s.subscribe;this.unsubscribe=s.unsubscribe;this.registerCursor=function(d){d.getMemberId()===k&&(b=d,b.getNode().appendChild(y),d.subscribe(ops.OdtCursor.signalCursorUpdated,n),a.subscribe("input", h),a.subscribe("compositionupdate",h))};this.removeCursor=function(d){b&&d===k&&(b.getNode().removeChild(y),b.unsubscribe(ops.OdtCursor.signalCursorUpdated,n),a.unsubscribe("input",h),a.unsubscribe("compositionupdate",h),b=null)};this.destroy=function(b){a.unsubscribe("compositionstart",p);a.unsubscribe("compositionend",q);a.unsubscribe("textInput",g);a.unsubscribe("keypress",c);a.unsubscribe("focus",m);core.Async.destroyAll(H,b)};(function(){u=new odf.TextSerializer;u.filter=new odf.OdfNodeFilter; a.subscribe("compositionstart",p);a.subscribe("compositionend",q);a.subscribe("textInput",g);a.subscribe("keypress",c);a.subscribe("focus",m);C.push(new f(a));H=C.map(function(b){return b.destroy});y=l.createElement("span");y.setAttribute("id","composer");t=core.Task.createTimeoutTask(m,1);H.push(t.destroy)})()};gui.InputMethodEditor.signalCompositionStart="input/compositionstart";gui.InputMethodEditor.signalCompositionEnd="input/compositionend"})();gui.MetadataController=function(f,k){function a(a){m.emit(gui.MetadataController.signalMetadataChanged,a)}function e(a){var c=-1===n.indexOf(a);c||runtime.log("Setting "+a+" is restricted.");return c}var c=f.getOdtDocument(),m=new core.EventNotifier([gui.MetadataController.signalMetadataChanged]),n=["dc:creator","dc:date","meta:editing-cycles","meta:editing-duration","meta:document-statistic"];this.setMetadata=function(a,c){var g={},h="",d;a&&Object.keys(a).filter(e).forEach(function(b){g[b]=a[b]}); c&&(h=c.filter(e).join(","));if(0c:!1}function a(a){null!==a&&!1===k(a)&&(c=Math.abs(a-f))}var e=this,c,m=gui.StepInfo.VisualDirection.LEFT_TO_RIGHT;this.token=void 0;this.process=function(c,f,q){var g,h;c.visualDirection===m?(g=f&&f.right,h=q&&q.left):(g=f&&f.left,h=q&&q.right);if(k(g)||k(h))return!0;if(f||q)a(g),a(h),e.token=c.token;return!1}};gui.LineBoundaryScanner=function(){var f=this,k=null;this.token=void 0;this.process=function(a,e,c){var m;if(m=c)if(k){var n=k;m=Math.min(n.bottom-n.top,c.bottom-c.top);var p=Math.max(n.top,c.top),n=Math.min(n.bottom,c.bottom)-p;m=0.4>=(0a?b.previousSibling:b.nextSibling,d(g)===NodeFilter.FILTER_ACCEPT&&(c=g),b=b.parentNode;return c}function e(b,a){var d;return null===b?r.NO_NEIGHBOUR:n.isCharacterElement(b)?r.SPACE_CHAR:b.nodeType===c||n.isTextSpan(b)||n.isHyperlink(b)?(d=b.textContent.charAt(a()),q.test(d)?r.SPACE_CHAR:p.test(d)?r.PUNCTUATION_CHAR:r.WORD_CHAR):r.OTHER}var c=Node.TEXT_NODE,m=Node.ELEMENT_NODE, n=odf.OdfUtils,p=/[!-#%-*,-\/:-;?-@\[-\]_{}\u00a1\u00ab\u00b7\u00bb\u00bf;\u00b7\u055a-\u055f\u0589-\u058a\u05be\u05c0\u05c3\u05c6\u05f3-\u05f4\u0609-\u060a\u060c-\u060d\u061b\u061e-\u061f\u066a-\u066d\u06d4\u0700-\u070d\u07f7-\u07f9\u0964-\u0965\u0970\u0df4\u0e4f\u0e5a-\u0e5b\u0f04-\u0f12\u0f3a-\u0f3d\u0f85\u0fd0-\u0fd4\u104a-\u104f\u10fb\u1361-\u1368\u166d-\u166e\u169b-\u169c\u16eb-\u16ed\u1735-\u1736\u17d4-\u17d6\u17d8-\u17da\u1800-\u180a\u1944-\u1945\u19de-\u19df\u1a1e-\u1a1f\u1b5a-\u1b60\u1c3b-\u1c3f\u1c7e-\u1c7f\u2000-\u206e\u207d-\u207e\u208d-\u208e\u3008-\u3009\u2768-\u2775\u27c5-\u27c6\u27e6-\u27ef\u2983-\u2998\u29d8-\u29db\u29fc-\u29fd\u2cf9-\u2cfc\u2cfe-\u2cff\u2e00-\u2e7e\u3000-\u303f\u30a0\u30fb\ua60d-\ua60f\ua673\ua67e\ua874-\ua877\ua8ce-\ua8cf\ua92e-\ua92f\ua95f\uaa5c-\uaa5f\ufd3e-\ufd3f\ufe10-\ufe19\ufe30-\ufe52\ufe54-\ufe61\ufe63\ufe68\ufe6a-\ufe6b\uff01-\uff03\uff05-\uff0a\uff0c-\uff0f\uff1a-\uff1b\uff1f-\uff20\uff3b-\uff3d\uff3f\uff5b\uff5d\uff5f-\uff65]|\ud800[\udd00-\udd01\udf9f\udfd0]|\ud802[\udd1f\udd3f\ude50-\ude58]|\ud809[\udc00-\udc7e]/, q=/\s/,g=core.PositionFilter.FilterResult.FILTER_ACCEPT,h=core.PositionFilter.FilterResult.FILTER_REJECT,d=odf.WordBoundaryFilter.IncludeWhitespace.TRAILING,b=odf.WordBoundaryFilter.IncludeWhitespace.LEADING,r={NO_NEIGHBOUR:0,SPACE_CHAR:1,PUNCTUATION_CHAR:2,WORD_CHAR:3,OTHER:4};this.acceptPosition=function(c){var f=c.container(),n=c.leftNode(),p=c.rightNode(),q=c.unfilteredDomOffset,s=function(){return c.unfilteredDomOffset()-1};f.nodeType===m&&(null===p&&(p=a(f,1,c.getNodeFilter())),null===n&&(n= a(f,-1,c.getNodeFilter())));f!==p&&(q=function(){return 0});f!==n&&null!==n&&(s=function(){return n.textContent.length-1});f=e(n,s);p=e(p,q);return f===r.WORD_CHAR&&p===r.WORD_CHAR||f===r.PUNCTUATION_CHAR&&p===r.PUNCTUATION_CHAR||k===d&&f!==r.NO_NEIGHBOUR&&p===r.SPACE_CHAR||k===b&&f===r.SPACE_CHAR&&p!==r.NO_NEIGHBOUR?h:g}};odf.WordBoundaryFilter.IncludeWhitespace={None:0,TRAILING:1,LEADING:2};gui.SelectionController=function(f,k){function a(b){var a=b.spec();if(b.isEdit||a.memberid===k)H=void 0,D.cancel()}function e(){var b=t.getCursor(k).getNode();return t.createStepIterator(b,0,[s,u],t.getRootElement(b))}function c(b,a,d){d=new odf.WordBoundaryFilter(t,d);var c=t.getRootElement(b)||t.getRootNode(),e=t.createRootFilter(c);return t.createStepIterator(b,a,[s,e,d],c)}function m(b,a){return a?{anchorNode:b.startContainer,anchorOffset:b.startOffset,focusNode:b.endContainer,focusOffset:b.endOffset}: {anchorNode:b.endContainer,anchorOffset:b.endOffset,focusNode:b.startContainer,focusOffset:b.startOffset}}function n(b,a,d){var c=new ops.OpMoveCursor;c.init({memberid:k,position:b,length:a||0,selectionType:d});return c}function p(b,a,d){var c;c=t.getCursor(k);c=m(c.getSelectedRange(),c.hasForwardSelection());c.focusNode=b;c.focusOffset=a;d||(c.anchorNode=c.focusNode,c.anchorOffset=c.focusOffset);b=t.convertDomToCursorRange(c);f.enqueue([n(b.position,b.length)])}function q(b){var a;a=c(b.startContainer, b.startOffset,G);a.roundToPreviousStep()&&b.setStart(a.container(),a.offset());a=c(b.endContainer,b.endOffset,B);a.roundToNextStep()&&b.setEnd(a.container(),a.offset())}function g(b){var a=w.getParagraphElements(b),d=a[0],a=a[a.length-1];d&&b.setStart(d,0);a&&(w.isParagraph(b.endContainer)&&0===b.endOffset?b.setEndBefore(a):b.setEnd(a,a.childNodes.length))}function h(b,a,d,c){var e,f;c?(e=d.startContainer,f=d.startOffset):(e=d.endContainer,f=d.endOffset);z.containsNode(b,e)||(f=0>z.comparePoints(b, 0,e,f)?0:b.childNodes.length,e=b);b=t.createStepIterator(e,f,a,w.getParagraphElement(e)||b);b.roundToClosestStep()||runtime.assert(!1,"No step found in requested range");c?d.setStart(b.container(),b.offset()):d.setEnd(b.container(),b.offset())}function d(b,a){var d=e();d.advanceStep(b)&&p(d.container(),d.offset(),a)}function b(b,a){var d,c=H,f=[new gui.LineBoundaryScanner,new gui.ParagraphBoundaryScanner];void 0===c&&C&&(c=C());isNaN(c)||(d=e(),x.moveToFilteredStep(d,b,f)&&d.advanceStep(b)&&(f=[new gui.ClosestXOffsetScanner(c), new gui.LineBoundaryScanner,new gui.ParagraphBoundaryScanner],x.moveToFilteredStep(d,b,f)&&(p(d.container(),d.offset(),a),H=c,D.restart())))}function r(b,a){var d=e(),c=[new gui.LineBoundaryScanner,new gui.ParagraphBoundaryScanner];x.moveToFilteredStep(d,b,c)&&p(d.container(),d.offset(),a)}function l(b,a){var d=t.getCursor(k),d=m(d.getSelectedRange(),d.hasForwardSelection()),d=c(d.focusNode,d.focusOffset,G);d.advanceStep(b)&&p(d.container(),d.offset(),a)}function y(b,a,d){var c=!1,e=t.getCursor(k), e=m(e.getSelectedRange(),e.hasForwardSelection()),c=t.getRootElement(e.focusNode);runtime.assert(Boolean(c),"SelectionController: Cursor outside root");e=t.createStepIterator(e.focusNode,e.focusOffset,[s,u],c);e.roundToClosestStep();e.advanceStep(b)&&(d=d(e.container()))&&(b===J?(e.setPosition(d,0),c=e.roundToNextStep()):(e.setPosition(d,d.childNodes.length),c=e.roundToPreviousStep()),c&&p(e.container(),e.offset(),a))}var t=f.getOdtDocument(),z=core.DomUtils,w=odf.OdfUtils,s=t.getPositionFilter(), x=new gui.GuiStepUtils,u=t.createRootFilter(k),C=null,H,D,G=odf.WordBoundaryFilter.IncludeWhitespace.TRAILING,B=odf.WordBoundaryFilter.IncludeWhitespace.LEADING,J=core.StepDirection.PREVIOUS,P=core.StepDirection.NEXT;this.selectionToRange=function(b){var a=0<=z.comparePoints(b.anchorNode,b.anchorOffset,b.focusNode,b.focusOffset),d=b.focusNode.ownerDocument.createRange();a?(d.setStart(b.anchorNode,b.anchorOffset),d.setEnd(b.focusNode,b.focusOffset)):(d.setStart(b.focusNode,b.focusOffset),d.setEnd(b.anchorNode, b.anchorOffset));return{range:d,hasForwardSelection:a}};this.rangeToSelection=m;this.selectImage=function(b){var a=t.getRootElement(b),d=t.createRootFilter(a),a=t.createStepIterator(b,0,[d,t.getPositionFilter()],a),c;a.roundToPreviousStep()||runtime.assert(!1,"No walkable position before frame");d=a.container();c=a.offset();a.setPosition(b,b.childNodes.length);a.roundToNextStep()||runtime.assert(!1,"No walkable position after frame");b=t.convertDomToCursorRange({anchorNode:d,anchorOffset:c,focusNode:a.container(), focusOffset:a.offset()});b=n(b.position,b.length,ops.OdtCursor.RegionSelection);f.enqueue([b])};this.expandToWordBoundaries=q;this.expandToParagraphBoundaries=g;this.selectRange=function(b,a,d){var c=t.getOdfCanvas().getElement(),e,l=[s];e=z.containsNode(c,b.startContainer);c=z.containsNode(c,b.endContainer);if(e||c)if(e&&c&&(2===d?q(b):3<=d&&g(b)),(d=a?t.getRootElement(b.startContainer):t.getRootElement(b.endContainer))||(d=t.getRootNode()),l.push(t.createRootFilter(d)),h(d,l,b,!0),h(d,l,b,!1),b= m(b,a),a=t.convertDomToCursorRange(b),b=t.getCursorSelection(k),a.position!==b.position||a.length!==b.length)b=n(a.position,a.length,ops.OdtCursor.RangeSelection),f.enqueue([b])};this.moveCursorToLeft=function(){d(J,!1);return!0};this.moveCursorToRight=function(){d(P,!1);return!0};this.extendSelectionToLeft=function(){d(J,!0);return!0};this.extendSelectionToRight=function(){d(P,!0);return!0};this.setCaretXPositionLocator=function(b){C=b};this.moveCursorUp=function(){b(J,!1);return!0};this.moveCursorDown= function(){b(P,!1);return!0};this.extendSelectionUp=function(){b(J,!0);return!0};this.extendSelectionDown=function(){b(P,!0);return!0};this.moveCursorBeforeWord=function(){l(J,!1);return!0};this.moveCursorPastWord=function(){l(P,!1);return!0};this.extendSelectionBeforeWord=function(){l(J,!0);return!0};this.extendSelectionPastWord=function(){l(P,!0);return!0};this.moveCursorToLineStart=function(){r(J,!1);return!0};this.moveCursorToLineEnd=function(){r(P,!1);return!0};this.extendSelectionToLineStart= function(){r(J,!0);return!0};this.extendSelectionToLineEnd=function(){r(P,!0);return!0};this.extendSelectionToParagraphStart=function(){y(J,!0,w.getParagraphElement);return!0};this.extendSelectionToParagraphEnd=function(){y(P,!0,w.getParagraphElement);return!0};this.moveCursorToParagraphStart=function(){y(J,!1,w.getParagraphElement);return!0};this.moveCursorToParagraphEnd=function(){y(P,!1,w.getParagraphElement);return!0};this.moveCursorToDocumentStart=function(){y(J,!1,t.getRootElement);return!0}; this.moveCursorToDocumentEnd=function(){y(P,!1,t.getRootElement);return!0};this.extendSelectionToDocumentStart=function(){y(J,!0,t.getRootElement);return!0};this.extendSelectionToDocumentEnd=function(){y(P,!0,t.getRootElement);return!0};this.extendSelectionToEntireDocument=function(){var b=t.getCursor(k),b=t.getRootElement(b.getNode()),a,d,c;runtime.assert(Boolean(b),"SelectionController: Cursor outside root");c=t.createStepIterator(b,0,[s,u],b);c.roundToClosestStep();a=c.container();d=c.offset(); c.setPosition(b,b.childNodes.length);c.roundToClosestStep();b=t.convertDomToCursorRange({anchorNode:a,anchorOffset:d,focusNode:c.container(),focusOffset:c.offset()});f.enqueue([n(b.position,b.length)]);return!0};this.destroy=function(b){t.unsubscribe(ops.OdtDocument.signalOperationStart,a);core.Async.destroyAll([D.destroy],b)};(function(){D=core.Task.createTimeoutTask(function(){H=void 0},2E3);t.subscribe(ops.OdtDocument.signalOperationStart,a)})()};gui.TextController=function(f,k,a,e,c,m){function n(){y=!0===k.getState(gui.CommonConstraints.EDIT.REVIEW_MODE)?a.isLocalCursorWithinOwnAnnotation():!0}function p(b){b.getMemberId()===e&&n()}function q(a,d,c){var e=[b.getPositionFilter()];c&&e.push(b.createRootFilter(a.startContainer));c=b.createStepIterator(a.startContainer,a.startOffset,e,d);c.roundToClosestStep()||runtime.assert(!1,"No walkable step found in paragraph element at range start");d=b.convertDomPointToCursorStep(c.container(),c.offset()); a.collapsed?a=d:(c.setPosition(a.endContainer,a.endOffset),c.roundToClosestStep()||runtime.assert(!1,"No walkable step found in paragraph element at range end"),a=b.convertDomPointToCursorStep(c.container(),c.offset()));return{position:d,length:a-d}}function g(b){var a,d,c,f=r.getParagraphElements(b),g=b.cloneRange(),h=[];a=f[0];1b.length&&(b.position+=b.length,b.length=-b.length);return b}function d(a){if(!y)return!1;var d,c=b.getCursor(e).getSelectedRange().cloneRange(), l=h(b.getCursorSelection(e)),m;if(0===l.length){l=void 0;d=b.getCursor(e).getNode();m=b.getRootElement(d);var k=[b.getPositionFilter(),b.createRootFilter(m)];m=b.createStepIterator(d,0,k,m);m.roundToClosestStep()&&(a?m.nextStep():m.previousStep())&&(l=h(b.convertDomToCursorRange({anchorNode:d,anchorOffset:0,focusNode:m.container(),focusOffset:m.offset()})),a?(c.setStart(d,0),c.setEnd(m.container(),m.offset())):(c.setStart(m.container(),m.offset()),c.setEnd(d,0)))}l&&f.enqueue(g(c));return void 0!== l}var b=f.getOdtDocument(),r=odf.OdfUtils,l=core.DomUtils,y=!1,t=odf.Namespaces.textns,z=core.StepDirection.NEXT;this.isEnabled=function(){return y};this.enqueueParagraphSplittingOps=function(){if(!y)return!1;var a=b.getCursor(e),d=a.getSelectedRange(),c=h(b.getCursorSelection(e)),l=[],a=r.getParagraphElement(a.getNode()),k=a.getAttributeNS(t,"style-name")||"";0c.left&&(c=x(e)))a.focusNode=c.container,a.focusOffset=c.offset,d&&(a.anchorNode=a.focusNode,a.anchorOffset=a.focusOffset)}else F.isImage(a.focusNode.firstChild)&&1===a.focusOffset&&F.isCharacterFrame(a.focusNode)&&(c=x(a.focusNode))&&(a.anchorNode=a.focusNode=c.container,a.anchorOffset=a.focusOffset=c.offset);a.anchorNode&&a.focusNode&&(a=X.selectionToRange(a),X.selectRange(a.range,a.hasForwardSelection,0===b.button?b.detail:0));L.focus()}function C(b){var a;if(a=n(b.clientX,b.clientY))b= a.container,a=a.offset,b={anchorNode:b,anchorOffset:a,focusNode:b,focusOffset:a},b=X.selectionToRange(b),X.selectRange(b.range,b.hasForwardSelection,2),L.focus()}function H(b){var a=m(b),d,c,f;ja.processRequests();ca&&(F.isImage(a)&&F.isCharacterFrame(a.parentNode)&&S.getSelection().isCollapsed?(X.selectImage(a.parentNode),L.focus()):la.isSelectorElement(a)?L.focus():W?(a=e.getSelectedRange(),c=a.collapsed,F.isImage(a.endContainer)&&0===a.endOffset&&F.isCharacterFrame(a.endContainer.parentNode)&& (f=a.endContainer.parentNode,f=x(f))&&(a.setEnd(f.container,f.offset),c&&a.collapse(!1)),X.selectRange(a,e.hasForwardSelection(),0===b.button?b.detail:0),L.focus()):ta?u(b):(d=T.cloneEvent(b),aa=runtime.setTimeout(function(){u(d)},0)),na=0,W=ca=!1)}function D(b){var d=v.getCursor(a).getSelectedRange();d.collapsed||N.exportRangeToDataTransfer(b.dataTransfer,d)}function G(){ca&&L.focus();na=0;W=ca=!1}function B(b){H(b)}function J(b){var a=m(b),d=null;"annotationRemoveButton"===a.className?(runtime.assert(ea, "Remove buttons are displayed on annotations while annotation editing is disabled in the controller."),d=a.parentNode.getElementsByTagNameNS(odf.Namespaces.officens,"annotation").item(0),ga.removeAnnotation(d),L.focus()):"webodf-draggable"!==a.getAttribute("class")&&H(b)}function P(b){(b=b.data)&&(-1===b.indexOf("\n")?ha.insertText(b):pa.paste(b))}function Q(b){return function(){b();return!0}}function A(b){return function(d){return v.getCursor(a).getSelectionType()===ops.OdtCursor.RangeSelection? b(d):!0}}function Y(a){L.unsubscribe("keydown",E.handleEvent);L.unsubscribe("keypress",V.handleEvent);L.unsubscribe("keyup",$.handleEvent);L.unsubscribe("copy",g);L.unsubscribe("mousedown",s);L.unsubscribe("mousemove",ja.trigger);L.unsubscribe("mouseup",J);L.unsubscribe("contextmenu",B);L.unsubscribe("dragstart",D);L.unsubscribe("dragend",G);L.unsubscribe("click",oa.handleClick);L.unsubscribe("longpress",C);L.unsubscribe("drag",t);L.unsubscribe("dragstop",z);v.unsubscribe(ops.OdtDocument.signalOperationEnd, fa.trigger);v.unsubscribe(ops.Document.signalCursorAdded,ka.registerCursor);v.unsubscribe(ops.Document.signalCursorRemoved,ka.removeCursor);v.unsubscribe(ops.OdtDocument.signalOperationEnd,b);a()}var S=runtime.getWindow(),v=k.getOdtDocument(),I=new gui.SessionConstraints,ba=new gui.SessionContext(k,a),T=core.DomUtils,F=odf.OdfUtils,N=new gui.MimeDataExporter,Z=new gui.Clipboard(N),E=new gui.KeyboardHandler,V=new gui.KeyboardHandler,$=new gui.KeyboardHandler,ca=!1,U=new odf.ObjectNameGenerator(v.getOdfCanvas().odfContainer(), a),W=!1,O=null,aa,R=null,L=new gui.EventManager(v),ea=c.annotationsEnabled,ga=new gui.AnnotationController(k,I,a),da=new gui.DirectFormattingController(k,I,ba,a,U,c.directTextStylingEnabled,c.directParagraphStylingEnabled),ha=new gui.TextController(k,I,ba,a,da.createCursorStyleOp,da.createParagraphStyleOps),ma=new gui.ImageController(k,I,ba,a,U),la=new gui.ImageSelector(v.getOdfCanvas()),ia=v.createPositionIterator(v.getRootNode()),ja,fa,pa=new gui.PasteController(k,I,ba,a),ka=new gui.InputMethodEditor(a, L),na=0,oa=new gui.HyperlinkClickHandler(v.getOdfCanvas().getElement,E,$),qa=new gui.HyperlinkController(k,I,ba,a),X=new gui.SelectionController(k,a),ua=new gui.MetadataController(k,a),K=gui.KeyboardHandler.Modifier,M=gui.KeyboardHandler.KeyCode,ra=-1!==S.navigator.appVersion.toLowerCase().indexOf("mac"),ta=-1!==["iPad","iPod","iPhone"].indexOf(S.navigator.platform),sa;runtime.assert(null!==S,"Expected to be run in an environment which has a global window, like a browser.");this.undo=l;this.redo= y;this.insertLocalCursor=function(){runtime.assert(void 0===k.getOdtDocument().getCursor(a),"Inserting local cursor a second time.");var b=new ops.OpAddCursor;b.init({memberid:a});k.enqueue([b]);L.focus()};this.removeLocalCursor=function(){runtime.assert(void 0!==k.getOdtDocument().getCursor(a),"Removing local cursor without inserting before.");var b=new ops.OpRemoveCursor;b.init({memberid:a});k.enqueue([b])};this.startEditing=function(){ka.subscribe(gui.InputMethodEditor.signalCompositionStart,ha.removeCurrentSelection); ka.subscribe(gui.InputMethodEditor.signalCompositionEnd,P);L.subscribe("beforecut",q);L.subscribe("cut",p);L.subscribe("beforepaste",d);L.subscribe("paste",h);R&&R.initialize();L.setEditing(!0);oa.setModifier(ra?K.Meta:K.Ctrl);E.bind(M.Backspace,K.None,Q(ha.removeTextByBackspaceKey),!0);E.bind(M.Delete,K.None,ha.removeTextByDeleteKey);E.bind(M.Tab,K.None,A(function(){ha.insertText("\t");return!0}));ra?(E.bind(M.Clear,K.None,ha.removeCurrentSelection),E.bind(M.B,K.Meta,A(da.toggleBold)),E.bind(M.I, K.Meta,A(da.toggleItalic)),E.bind(M.U,K.Meta,A(da.toggleUnderline)),E.bind(M.L,K.MetaShift,A(da.alignParagraphLeft)),E.bind(M.E,K.MetaShift,A(da.alignParagraphCenter)),E.bind(M.R,K.MetaShift,A(da.alignParagraphRight)),E.bind(M.J,K.MetaShift,A(da.alignParagraphJustified)),ea&&E.bind(M.C,K.MetaShift,ga.addAnnotation),E.bind(M.Z,K.Meta,l),E.bind(M.Z,K.MetaShift,y)):(E.bind(M.B,K.Ctrl,A(da.toggleBold)),E.bind(M.I,K.Ctrl,A(da.toggleItalic)),E.bind(M.U,K.Ctrl,A(da.toggleUnderline)),E.bind(M.L,K.CtrlShift, A(da.alignParagraphLeft)),E.bind(M.E,K.CtrlShift,A(da.alignParagraphCenter)),E.bind(M.R,K.CtrlShift,A(da.alignParagraphRight)),E.bind(M.J,K.CtrlShift,A(da.alignParagraphJustified)),ea&&E.bind(M.C,K.CtrlAlt,ga.addAnnotation),E.bind(M.Z,K.Ctrl,l),E.bind(M.Z,K.CtrlShift,y));V.setDefault(A(function(b){var a;a=null===b.which||void 0===b.which?String.fromCharCode(b.keyCode):0!==b.which&&0!==b.charCode?String.fromCharCode(b.which):null;return!a||b.altKey||b.ctrlKey||b.metaKey?!1:(ha.insertText(a),!0)})); V.bind(M.Enter,K.None,A(ha.enqueueParagraphSplittingOps))};this.endEditing=function(){ka.unsubscribe(gui.InputMethodEditor.signalCompositionStart,ha.removeCurrentSelection);ka.unsubscribe(gui.InputMethodEditor.signalCompositionEnd,P);L.unsubscribe("cut",p);L.unsubscribe("beforecut",q);L.unsubscribe("paste",h);L.unsubscribe("beforepaste",d);L.setEditing(!1);oa.setModifier(K.None);E.bind(M.Backspace,K.None,function(){return!0},!0);E.unbind(M.Delete,K.None);E.unbind(M.Tab,K.None);ra?(E.unbind(M.Clear, K.None),E.unbind(M.B,K.Meta),E.unbind(M.I,K.Meta),E.unbind(M.U,K.Meta),E.unbind(M.L,K.MetaShift),E.unbind(M.E,K.MetaShift),E.unbind(M.R,K.MetaShift),E.unbind(M.J,K.MetaShift),ea&&E.unbind(M.C,K.MetaShift),E.unbind(M.Z,K.Meta),E.unbind(M.Z,K.MetaShift)):(E.unbind(M.B,K.Ctrl),E.unbind(M.I,K.Ctrl),E.unbind(M.U,K.Ctrl),E.unbind(M.L,K.CtrlShift),E.unbind(M.E,K.CtrlShift),E.unbind(M.R,K.CtrlShift),E.unbind(M.J,K.CtrlShift),ea&&E.unbind(M.C,K.CtrlAlt),E.unbind(M.Z,K.Ctrl),E.unbind(M.Z,K.CtrlShift));V.setDefault(null); V.unbind(M.Enter,K.None)};this.getInputMemberId=function(){return a};this.getSession=function(){return k};this.getSessionConstraints=function(){return I};this.setUndoManager=function(b){R&&R.unsubscribe(gui.UndoManager.signalUndoStackChanged,r);if(R=b)R.setDocument(v),R.setPlaybackFunction(k.enqueue),R.subscribe(gui.UndoManager.signalUndoStackChanged,r)};this.getUndoManager=function(){return R};this.getMetadataController=function(){return ua};this.getAnnotationController=function(){return ga};this.getDirectFormattingController= function(){return da};this.getHyperlinkClickHandler=function(){return oa};this.getHyperlinkController=function(){return qa};this.getImageController=function(){return ma};this.getSelectionController=function(){return X};this.getTextController=function(){return ha};this.getEventManager=function(){return L};this.getKeyboardHandlers=function(){return{keydown:E,keypress:V}};this.destroy=function(b){var a=[ja.destroy,fa.destroy,da.destroy,ka.destroy,L.destroy,oa.destroy,qa.destroy,ua.destroy,X.destroy, ha.destroy,Y];sa&&a.unshift(sa.destroy);runtime.clearTimeout(aa);core.Async.destroyAll(a,b)};ja=core.Task.createRedrawTask(w);fa=core.Task.createRedrawTask(function(){var b=v.getCursor(a);if(b&&b.getSelectionType()===ops.OdtCursor.RegionSelection&&(b=F.getImageElements(b.getSelectedRange())[0])){la.select(b.parentNode);return}la.clearSelection()});E.bind(M.Left,K.None,A(X.moveCursorToLeft));E.bind(M.Right,K.None,A(X.moveCursorToRight));E.bind(M.Up,K.None,A(X.moveCursorUp));E.bind(M.Down,K.None,A(X.moveCursorDown)); E.bind(M.Left,K.Shift,A(X.extendSelectionToLeft));E.bind(M.Right,K.Shift,A(X.extendSelectionToRight));E.bind(M.Up,K.Shift,A(X.extendSelectionUp));E.bind(M.Down,K.Shift,A(X.extendSelectionDown));E.bind(M.Home,K.None,A(X.moveCursorToLineStart));E.bind(M.End,K.None,A(X.moveCursorToLineEnd));E.bind(M.Home,K.Ctrl,A(X.moveCursorToDocumentStart));E.bind(M.End,K.Ctrl,A(X.moveCursorToDocumentEnd));E.bind(M.Home,K.Shift,A(X.extendSelectionToLineStart));E.bind(M.End,K.Shift,A(X.extendSelectionToLineEnd));E.bind(M.Up, K.CtrlShift,A(X.extendSelectionToParagraphStart));E.bind(M.Down,K.CtrlShift,A(X.extendSelectionToParagraphEnd));E.bind(M.Home,K.CtrlShift,A(X.extendSelectionToDocumentStart));E.bind(M.End,K.CtrlShift,A(X.extendSelectionToDocumentEnd));ra?(E.bind(M.Left,K.Alt,A(X.moveCursorBeforeWord)),E.bind(M.Right,K.Alt,A(X.moveCursorPastWord)),E.bind(M.Left,K.Meta,A(X.moveCursorToLineStart)),E.bind(M.Right,K.Meta,A(X.moveCursorToLineEnd)),E.bind(M.Home,K.Meta,A(X.moveCursorToDocumentStart)),E.bind(M.End,K.Meta, A(X.moveCursorToDocumentEnd)),E.bind(M.Left,K.AltShift,A(X.extendSelectionBeforeWord)),E.bind(M.Right,K.AltShift,A(X.extendSelectionPastWord)),E.bind(M.Left,K.MetaShift,A(X.extendSelectionToLineStart)),E.bind(M.Right,K.MetaShift,A(X.extendSelectionToLineEnd)),E.bind(M.Up,K.AltShift,A(X.extendSelectionToParagraphStart)),E.bind(M.Down,K.AltShift,A(X.extendSelectionToParagraphEnd)),E.bind(M.Up,K.MetaShift,A(X.extendSelectionToDocumentStart)),E.bind(M.Down,K.MetaShift,A(X.extendSelectionToDocumentEnd)), E.bind(M.A,K.Meta,A(X.extendSelectionToEntireDocument))):(E.bind(M.Left,K.Ctrl,A(X.moveCursorBeforeWord)),E.bind(M.Right,K.Ctrl,A(X.moveCursorPastWord)),E.bind(M.Left,K.CtrlShift,A(X.extendSelectionBeforeWord)),E.bind(M.Right,K.CtrlShift,A(X.extendSelectionPastWord)),E.bind(M.A,K.Ctrl,A(X.extendSelectionToEntireDocument)));ta&&(sa=new gui.IOSSafariSupport(L));L.subscribe("keydown",E.handleEvent);L.subscribe("keypress",V.handleEvent);L.subscribe("keyup",$.handleEvent);L.subscribe("copy",g);L.subscribe("mousedown", s);L.subscribe("mousemove",ja.trigger);L.subscribe("mouseup",J);L.subscribe("contextmenu",B);L.subscribe("dragstart",D);L.subscribe("dragend",G);L.subscribe("click",oa.handleClick);L.subscribe("longpress",C);L.subscribe("drag",t);L.subscribe("dragstop",z);v.subscribe(ops.OdtDocument.signalOperationEnd,fa.trigger);v.subscribe(ops.Document.signalCursorAdded,ka.registerCursor);v.subscribe(ops.Document.signalCursorRemoved,ka.removeCursor);v.subscribe(ops.OdtDocument.signalOperationEnd,b)}})();gui.CaretManager=function(f,k){function a(a){return m.hasOwnProperty(a)?m[a]:null}function e(){return Object.keys(m).map(function(a){return m[a]})}function c(a){var c=m[a];c&&(delete m[a],a===f.getInputMemberId()?(p.unsubscribe(ops.OdtDocument.signalProcessingBatchEnd,c.ensureVisible),p.unsubscribe(ops.Document.signalCursorMoved,c.refreshCursorBlinking),q.unsubscribe("compositionupdate",c.handleUpdate),q.unsubscribe("compositionend",c.handleUpdate),q.unsubscribe("focus",c.setFocus),q.unsubscribe("blur", c.removeFocus),n.removeEventListener("focus",c.show,!1),n.removeEventListener("blur",c.hide,!1)):p.unsubscribe(ops.OdtDocument.signalProcessingBatchEnd,c.handleUpdate),c.destroy(function(){}))}var m={},n=runtime.getWindow(),p=f.getSession().getOdtDocument(),q=f.getEventManager();this.registerCursor=function(a,c,d){var b=a.getMemberId();a=new gui.Caret(a,k,c,d);m[b]=a;b===f.getInputMemberId()?(runtime.log("Starting to track input on new cursor of "+b),p.subscribe(ops.OdtDocument.signalProcessingBatchEnd, a.ensureVisible),p.subscribe(ops.Document.signalCursorMoved,a.refreshCursorBlinking),q.subscribe("compositionupdate",a.handleUpdate),q.subscribe("compositionend",a.handleUpdate),q.subscribe("focus",a.setFocus),q.subscribe("blur",a.removeFocus),n.addEventListener("focus",a.show,!1),n.addEventListener("blur",a.hide,!1),a.setOverlayElement(q.getEventTrap())):p.subscribe(ops.OdtDocument.signalProcessingBatchEnd,a.handleUpdate);return a};this.getCaret=a;this.getCarets=e;this.destroy=function(a){var h= e().map(function(a){return a.destroy});f.getSelectionController().setCaretXPositionLocator(null);p.unsubscribe(ops.Document.signalCursorRemoved,c);m={};core.Async.destroyAll(h,a)};f.getSelectionController().setCaretXPositionLocator(function(){var c=a(f.getInputMemberId()),e;c&&(e=c.getBoundingClientRect());return e?e.right:void 0});p.subscribe(ops.Document.signalCursorRemoved,c)};gui.EditInfoHandle=function(f){var k=[],a,e=f.ownerDocument,c=e.documentElement.namespaceURI;this.setEdits=function(f){k=f;var n,p,q,g;core.DomUtils.removeAllChildNodes(a);for(f=0;fb?(p=a(1,0),q=a(0.5,1E4-b),g=a(0.2,2E4-b)):1E4<=b&&2E4>b?(p=a(0.5,0),g=a(0.2,2E4-b)):p=a(0.2,0)};this.getEdits=function(){return f.getEdits()};this.clearEdits= function(){f.clearEdits();m.setEdits([]);n.hasAttributeNS("urn:webodf:names:editinfo","editinfo:memberid")&&n.removeAttributeNS("urn:webodf:names:editinfo","editinfo:memberid")};this.getEditInfo=function(){return f};this.show=function(){n.style.display="block"};this.hide=function(){e.hideHandle();n.style.display="none"};this.showHandle=function(){m.show()};this.hideHandle=function(){m.hide()};this.destroy=function(a){runtime.clearTimeout(p);runtime.clearTimeout(q);runtime.clearTimeout(g);c.removeChild(n); m.destroy(function(d){d?a(d):f.destroy(a)})};(function(){var a=f.getOdtDocument().getDOMDocument();n=a.createElementNS(a.documentElement.namespaceURI,"div");n.setAttribute("class","editInfoMarker");n.onmouseover=function(){e.showHandle()};n.onmouseout=function(){e.hideHandle()};c=f.getNode();c.appendChild(n);m=new gui.EditInfoHandle(c);k||e.hide()})()};gui.HyperlinkTooltipView=function(f,k){var a=core.DomUtils,e=odf.OdfUtils,c=runtime.getWindow(),m,n,p;runtime.assert(null!==c,"Expected to be run in an environment which has a global window, like a browser.");this.showTooltip=function(q){var g=q.target||q.srcElement,h=f.getSizer(),d=f.getZoomLevel(),b;a:{for(;g;){if(e.isHyperlink(g))break a;if(e.isParagraph(g)||e.isInlineRoot(g))break;g=g.parentNode}g=null}if(g){a.containsNode(h,p)||h.appendChild(p);b=n;var r;switch(k()){case gui.KeyboardHandler.Modifier.Ctrl:r= runtime.tr("Ctrl-click to follow link");break;case gui.KeyboardHandler.Modifier.Meta:r=runtime.tr("\u2318-click to follow link");break;default:r=""}b.textContent=r;m.textContent=e.getHyperlinkTarget(g);p.style.display="block";b=c.innerWidth-p.offsetWidth-15;g=q.clientX>b?b:q.clientX+15;b=c.innerHeight-p.offsetHeight-10;q=q.clientY>b?b:q.clientY+10;h=h.getBoundingClientRect();g=(g-h.left)/d;q=(q-h.top)/d;p.style.left=g+"px";p.style.top=q+"px"}};this.hideTooltip=function(){p.style.display="none"};this.destroy= function(a){p.parentNode&&p.parentNode.removeChild(p);a()};(function(){var a=f.getElement().ownerDocument;m=a.createElement("span");n=a.createElement("span");m.className="webodf-hyperlinkTooltipLink";n.className="webodf-hyperlinkTooltipText";p=a.createElement("div");p.className="webodf-hyperlinkTooltip";p.appendChild(m);p.appendChild(n);f.getElement().appendChild(p)})()};gui.OdfFieldView=function(f){function k(){var a=odf.OdfSchema.getFields().map(function(a){return a.replace(":","|")}),e=a.join(",\n")+"\n{ background-color: #D0D0D0; }\n",a=a.map(function(a){return a+":empty::after"}).join(",\n")+"\n{ content:' '; white-space: pre; }\n";return e+"\n"+a}var a,e=f.getElement().ownerDocument;this.showFieldHighlight=function(){a.appendChild(e.createTextNode(k()))};this.hideFieldHighlight=function(){for(var c=a.sheet,e=c.cssRules;e.length;)c.deleteRule(e.length-1)};this.destroy= function(c){a.parentNode&&a.parentNode.removeChild(a);c()};a=function(){var a=e.getElementsByTagName("head").item(0),f=e.createElement("style"),k="";f.type="text/css";f.media="screen, print, handheld, projection";odf.Namespaces.forEachPrefix(function(a,c){k+="@namespace "+a+" url("+c+");\n"});f.appendChild(e.createTextNode(k));a.appendChild(f);return f}()};gui.ShadowCursor=function(f){var k=f.getDOMDocument().createRange(),a=!0;this.removeFromDocument=function(){};this.getMemberId=function(){return gui.ShadowCursor.ShadowCursorMemberId};this.getSelectedRange=function(){return k};this.setSelectedRange=function(e,c){k=e;a=!1!==c};this.hasForwardSelection=function(){return a};this.getDocument=function(){return f};this.getSelectionType=function(){return ops.OdtCursor.RangeSelection};k.setStart(f.getRootNode(),0)};gui.ShadowCursor.ShadowCursorMemberId="";gui.SelectionView=function(f){};gui.SelectionView.prototype.rerender=function(){};gui.SelectionView.prototype.show=function(){};gui.SelectionView.prototype.hide=function(){};gui.SelectionView.prototype.destroy=function(f){};gui.SelectionViewManager=function(f){function k(){return Object.keys(a).map(function(e){return a[e]})}var a={};this.getSelectionView=function(e){return a.hasOwnProperty(e)?a[e]:null};this.getSelectionViews=k;this.removeSelectionView=function(e){a.hasOwnProperty(e)&&(a[e].destroy(function(){}),delete a[e])};this.hideSelectionView=function(e){a.hasOwnProperty(e)&&a[e].hide()};this.showSelectionView=function(e){a.hasOwnProperty(e)&&a[e].show()};this.rerenderSelectionViews=function(){Object.keys(a).forEach(function(e){a[e].rerender()})}; this.registerCursor=function(e,c){var m=e.getMemberId(),k=new f(e);c?k.show():k.hide();return a[m]=k};this.destroy=function(a){function c(k,p){p?a(p):k .webodf-draggable"), b=gui.ShadowCursor.ShadowCursorMemberId,c(".webodf-selectionOverlay","{ fill: "+d+"; stroke: "+d+";}",""),c(".webodf-touchEnabled .webodf-selectionOverlay","{ display: block; }"," > .webodf-draggable"))}function g(b){var a,d;for(d in u)u.hasOwnProperty(d)&&(a=u[d],b?a.show():a.hide())}function h(b){c.getCarets().forEach(function(a){b?a.showHandle():a.hideHandle()})}function d(b){var a=b.getMemberId();b=b.getProperties();q(a,b.fullName,b.color)}function b(b){var d=b.getMemberId(),e=a.getOdtDocument().getMember(d).getProperties(); c.registerCursor(b,B,J);m.registerCursor(b,!0);if(b=c.getCaret(d))b.setAvatarImageUrl(e.imageUrl),b.setColor(e.color);runtime.log("+++ View here +++ eagerly created an Caret for '"+d+"'! +++")}function r(b){b=b.getMemberId();var a=m.getSelectionView(k),d=m.getSelectionView(gui.ShadowCursor.ShadowCursorMemberId),e=c.getCaret(k);b===k?(d.hide(),a&&a.show(),e&&e.show()):b===gui.ShadowCursor.ShadowCursorMemberId&&(d.show(),a&&a.hide(),e&&e.hide())}function l(b){m.removeSelectionView(b)}function y(b){var d= b.paragraphElement,c=b.memberId;b=b.timeStamp;var e,f="",g=d.getElementsByTagNameNS(x,"editinfo").item(0);g?(f=g.getAttributeNS(x,"id"),e=u[f]):(f=Math.random().toString(),e=new ops.EditInfo(d,a.getOdtDocument()),e=new gui.EditInfoMarker(e,G),g=d.getElementsByTagNameNS(x,"editinfo").item(0),g.setAttributeNS(x,"id",f),u[f]=e);e.addEdit(c,new Date(b));D.trigger()}function t(){var b;s.hasChildNodes()&&core.DomUtils.removeAllChildNodes(s);!0===e.getState(gui.CommonConstraints.EDIT.ANNOTATIONS.ONLY_DELETE_OWN)&& (b=a.getOdtDocument().getMember(k))&&(b=b.getProperties().fullName,s.appendChild(document.createTextNode(".annotationWrapper:not([creator = '"+b+"']) .annotationRemoveButton { display: none; }")))}function z(a){var c=Object.keys(u).map(function(b){return u[b]});C.unsubscribe(ops.Document.signalMemberAdded,d);C.unsubscribe(ops.Document.signalMemberUpdated,d);C.unsubscribe(ops.Document.signalCursorAdded,b);C.unsubscribe(ops.Document.signalCursorRemoved,l);C.unsubscribe(ops.OdtDocument.signalParagraphChanged, y);C.unsubscribe(ops.Document.signalCursorMoved,r);C.unsubscribe(ops.OdtDocument.signalParagraphChanged,m.rerenderSelectionViews);C.unsubscribe(ops.OdtDocument.signalTableAdded,m.rerenderSelectionViews);C.unsubscribe(ops.OdtDocument.signalParagraphStyleModified,m.rerenderSelectionViews);e.unsubscribe(gui.CommonConstraints.EDIT.ANNOTATIONS.ONLY_DELETE_OWN,t);C.unsubscribe(ops.Document.signalMemberAdded,t);C.unsubscribe(ops.Document.signalMemberUpdated,t);w.parentNode.removeChild(w);s.parentNode.removeChild(s); (function Y(b,d){d?a(d):ba.length;b&&f(a);return b}function a(a,b){function c(f){a[f]===b&&e.push(f)}var e=[];a&&["style:parent-style-name","style:next-style-name"].forEach(c);return e}function e(a,b){function c(e){a[e]===b&&delete a[e]}a&&["style:parent-style-name","style:next-style-name"].forEach(c)}function c(a){var b={};Object.keys(a).forEach(function(e){b[e]="object"===typeof a[e]?c(a[e]):a[e]});return b}function m(a, b,c,e){var f,g=!1,h=!1,k,m=[];e&&e.attributes&&(m=e.attributes.split(","));a&&(c||0=a.length?0:a.length-f.length)):void 0!==a.length&&(f=a.position+a.length,e<=f?a.length-=b.length:c=b.position+b.length)){f=e?a:b;g=e?b:a;if(a.position!==b.position||a.length!==b.length)p=c(f),x=c(g);b=q(g.setProperties,null,f.setProperties, null,"style:text-properties");if(b.majorChanged||b.minorChanged)h=[],a=[],k=f.position+f.length,m=g.position+g.length,g.positionk?b.minorChanged&&(p=x,p.position=k,p.length=m-k,a.push(p),g.length=k-g.position):k>m&&b.majorChanged&&(p.position=m, p.length=k-m,h.push(p),f.length=m-f.position),f.setProperties&&n(f.setProperties)&&h.push(f),g.setProperties&&n(g.setProperties)&&a.push(g),e?(k=h,h=a):k=a}return{opSpecsA:k,opSpecsB:h}},InsertText:function(a,b){b.position<=a.position?a.position+=b.text.length:b.position<=a.position+a.length&&(a.length+=b.text.length);return{opSpecsA:[a],opSpecsB:[b]}},MergeParagraph:function(a,b){var c=a.position,e=a.position+a.length;c>=b.sourceStartPosition&&(c-=1);e>=b.sourceStartPosition&&(e-=1);a.position=c; a.length=e-c;return{opSpecsA:[a],opSpecsB:[b]}},MoveCursor:g,RemoveAnnotation:function(a,b){var c=a.position,e=a.position+a.length,f=b.position+b.length,g=[a],h=[b];b.position<=c&&e<=f?g=[]:(fb.position?a.position+=b.text.length:c?b.position+=a.text.length: a.position+=b.text.length;return{opSpecsA:[a],opSpecsB:[b]}},MergeParagraph:function(a,b){a.position>=b.sourceStartPosition?a.position-=1:(a.positiona.position&&(b.position+=a.text.length);return{opSpecsA:[a],opSpecsB:[b]}},SplitParagraph:function(a,b){a.position=a.sourceStartPosition&&(f-=1);c>=a.sourceStartPosition&&(c-=1);0<=b.length?(b.position=f,b.length=c-f):(b.position=c,b.length=f-c);return{opSpecsA:[a],opSpecsB:[b]}},RemoveAnnotation:function(a,b){var c=b.position+b.length,e=[a],f=[b];b.position<=a.destinationStartPosition&&a.sourceStartPosition<=c?(e=[],b.length-= 1):a.sourceStartPosition=a.sourceStartPosition?b.position-=1:(b.positiona.sourceStartPosition)b.position-=1;else if(b.position===a.destinationStartPosition||b.position===a.sourceStartPosition)b.position=a.destinationStartPosition,a.paragraphStyleName=b.styleName;return{opSpecsA:c,opSpecsB:e}},SplitParagraph:function(a,b){var c,e=[a],f=[b];b.position=a.destinationStartPosition&&b.position=a.sourceStartPosition&&(b.position-=1,b.sourceParagraphPosition-=1);return{opSpecsA:e,opSpecsB:f}}, UpdateMember:g,UpdateMetadata:g,UpdateParagraphStyle:g},MoveCursor:{MoveCursor:g,RemoveAnnotation:function(a,b){var c=k(a),e=a.position+a.length,g=b.position+b.length;b.position<=a.position&&e<=g?(a.position=b.position-1,a.length=0):(gb.position?a.position+= 1:a.position===b.sourceParagraphPosition&&(b.paragraphStyleName=a.styleName,g=c(a),g.position=b.position+1,e.push(g));return{opSpecsA:e,opSpecsB:f}},UpdateMember:g,UpdateMetadata:g,UpdateParagraphStyle:g},SplitParagraph:{SplitParagraph:function(a,b,c){var e,f;a.position