/* This is a generated file. DO NOT EDIT. Copyright (C) 2010-2014 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.4";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,d){};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(d){var a="",c,m=d.length;for(c=0;cr?l.push(r):(c+=1,b=d[c],194<=r&&224>r?l.push((r&31)<<6|b&63):(c+=1,e=d[c],224<=r&&240>r?l.push((r&15)<<12|(b&63)<<6|e&63):(c+=1,n=d[c],240<=r&&245>r&&(r=(r&7)<<18|(b&63)<<12|(e&63)<<6|n&63,r-=65536,l.push((r>>10)+55296,(r&1023)+56320))))),1E3<=l.length&&(a+=String.fromCharCode.apply(null, l),l.length=0);return a+String.fromCharCode.apply(null,l)}var c;"utf8"===k?c=d(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(f){function k(d){var a=d.length,b,e,n=0;for(b=0;be&&(n+=1,b+=1);return n}function a(d,a,b){var e=d.length,n,g;a=new Uint8Array(new ArrayBuffer(a));b?(a[0]=239,a[1]=187,a[2]=191,g=3):g=0;for(b=0;bn?(a[g]=n,g+=1):2048>n?(a[g]=192|n>>>6,a[g+1]=128|n&63,g+=2):55040>=n||57344<=n?(a[g]=224|n>>>12&15,a[g+1]=128|n>>>6&63,a[g+2]=128|n&63,g+=3):(b+=1,n=(n-55296<<10|d.charCodeAt(b)-56320)+65536, a[g]=240|n>>>18&7,a[g+1]=128|n>>>12&63,a[g+2]=128|n>>>6&63,a[g+3]=128|n&63,g+=4);return a}function d(a){var d=a.length,b=new Uint8Array(new ArrayBuffer(d)),e;for(e=0;ee.status||0===e.status?b(null):b("Status "+String(e.status)+": "+e.responseText||e.statusText):b("File "+d+" is empty."))};n=a.buffer&&!e.sendAsBinary?a.buffer:m.byteArrayToString(a,"binary");try{e.sendAsBinary?e.sendAsBinary(n):e.send(n)}catch(g){m.log("HUH? "+g+" "+a),b(g.message)}};this.deleteFile=function(d,a){var b=new XMLHttpRequest;b.open("DELETE",d,!0);b.onreadystatechange=function(){4=== b.readyState&&(200>b.status&&300<=b.status?a(b.responseText):a(null))};b.send(null)};this.loadXML=function(d,a){var b=new XMLHttpRequest;b.open("GET",d,!0);b.overrideMimeType&&b.overrideMimeType("text/xml");b.onreadystatechange=function(){4===b.readyState&&(0!==b.status||b.responseText?200===b.status||0===b.status?a(null,b.responseXML):a(b.responseText,null):a("File "+d+" is empty.",null))};try{b.send(null)}catch(e){a(e.message,null)}};this.log=c;this.enableAlerts=!0;this.assert=Runtime.assert;this.setTimeout= function(d,a){return setTimeout(function(){d()},a)};this.clearTimeout=function(d){clearTimeout(d)};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(d){return(new DOMParser).parseFromString(d,"text/xml")};this.exit=function(d){c("Calling exit with code "+String(d)+", but exit() is not implemented.")}; this.getWindow=function(){return window};this.requestAnimationFrame=function(d){var a=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame,b=0;if(a)a.bind(window),b=a(d);else return setTimeout(d,15);return b};this.cancelAnimationFrame=function(d){var a=window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.msCancelAnimationFrame;a?(a.bind(window),a(d)):clearTimeout(d)}} function NodeJSRuntime(){function f(d){var a=d.length,c,b=new Uint8Array(new ArrayBuffer(a));for(c=0;c").implementation} function RhinoRuntime(){var f=this,k={},a=k.javax.xml.parsers.DocumentBuilderFactory.newInstance(),d,c,h="";a.setValidating(!1);a.setNamespaceAware(!0);a.setExpandEntityReferences(!1);a.setSchema(null);c=k.org.xml.sax.EntityResolver({resolveEntity:function(a,d){var c=new k.java.io.FileReader(d);return new k.org.xml.sax.InputSource(c)}});d=a.newDocumentBuilder();d.setEntityResolver(c);this.byteArrayFromString=function(a,d){var c,h=a.length,r=new Uint8Array(new ArrayBuffer(h));for(c=0;c>>18],n+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[b>>>12&63],n+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[b>>>6&63],n+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[b& 63];e===a+1?(b=g[e]<<4,n+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[b>>>6],n+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[b&63],n+="=="):e===a&&(b=g[e]<<10|g[e+1]<<2,n+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[b>>>12],n+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[b>>>6&63],n+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[b&63],n+="=");return n}function a(b){b=b.replace(/[^A-Za-z0-9+\/]+/g, "");var n=b.length,e=new Uint8Array(new ArrayBuffer(3*n)),a=b.length%4,d=0,c,J;for(c=0;c>16,e[d+1]=J>>8&255,e[d+2]=J&255,d+=3;n=3*n-[0,0,2,1][a];return e.subarray(0,n)}function d(b){var g,n,e=b.length,a=0,d=new Uint8Array(new ArrayBuffer(3*e));for(g=0;gn?d[a++]=n:(2048>n?d[a++]=192|n>>>6:(d[a++]=224|n>>>12&15,d[a++]=128|n>>>6&63),d[a++]=128|n&63);return d.subarray(0, a)}function c(b){var g,n,e,a,d=b.length,c=new Uint8Array(new ArrayBuffer(d)),h=0;for(g=0;gn?c[h++]=n:(g+=1,e=b[g],224>n?c[h++]=(n&31)<<6|e&63:(g+=1,a=b[g],c[h++]=(n&15)<<12|(e&63)<<6|a&63));return c.subarray(0,h)}function h(b){return k(f(b))}function q(b){return String.fromCharCode.apply(String,a(b))}function p(b){return c(f(b))}function m(b){b=c(b);for(var g="",n=0;ng?c+=String.fromCharCode(g):(d+=1,e=b.charCodeAt(d)&255,224>g?c+=String.fromCharCode((g&31)<<6|e&63):(d+=1,a=b.charCodeAt(d)&255,c+=String.fromCharCode((g&15)<<12|(e&63)<<6|a&63)));return c}function r(b,g){function n(){var d=a+1E5;d>b.length&&(d=b.length);e+=l(b,a,d);a=d;d=a===b.length;g(e,d)&&!d&&runtime.setTimeout(n,0)}var e="",a=0;1E5>b.length?g(l(b,0,b.length),!0):("string"!==typeof b&&(b=b.slice()),n())}function b(b){return d(f(b))}function e(b){return String.fromCharCode.apply(String, d(b))}function n(b){return String.fromCharCode.apply(String,d(f(b)))}var g=function(b){var g={},n,e;n=0;for(e=b.length;nc-d&&(c=Math.max(2*c,d+a),a=new Uint8Array(new ArrayBuffer(c)),a.set(h),h=a)}var a=this,d=0,c=1024,h=new Uint8Array(new ArrayBuffer(c));this.appendByteArrayWriter=function(d){a.appendByteArray(d.getByteArray())};this.appendByteArray=function(a){var c=a.length;k(c);h.set(a,d);d+=c};this.appendArray=function(a){var c=a.length;k(c);h.set(a,d);d+=c};this.appendUInt16LE=function(d){a.appendArray([d&255,d>>8&255])};this.appendUInt32LE=function(d){a.appendArray([d& 255,d>>8&255,d>>16&255,d>>24&255])};this.appendString=function(d){a.appendByteArray(runtime.byteArrayFromString(d,f))};this.getLength=function(){return d};this.getByteArray=function(){var a=new Uint8Array(new ArrayBuffer(d));a.set(h.subarray(0,d));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,d,c){return a*k[c]/k[d]};this.convertMeasure=function(a,d){var c,h;a&&d&&(c=parseFloat(a),h=a.replace(c.toString(),""),c=f.convert(c,h,d));return c};this.getUnits=function(a){return a.substr(a.length-2,a.length)}};(function(){function f(){var d,c,h,f,p,k,l,r,b;void 0===a&&(c=(d=runtime.getWindow())&&d.document,k=c.documentElement,l=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),l.appendChild(f),d=c.createRange(),d.selectNode(p),a.rangeBCRIgnoresElementBCR=0===d.getClientRects().length, p.appendChild(c.createTextNode("Rect transform test")),c=p.getBoundingClientRect(),h=d.getBoundingClientRect(),a.unscaledRangeClientRects=2=b.compareBoundaryPoints(Range.START_TO_START,g)&&0<=b.compareBoundaryPoints(Range.END_TO_END,g)}function h(b,g){return 0>=b.compareBoundaryPoints(Range.END_TO_START,g)&&0<=b.compareBoundaryPoints(Range.START_TO_END,g)}function q(b,g){var e=null;b.nodeType===Node.TEXT_NODE&&(0===b.length?(b.parentNode.removeChild(b),g.nodeType===Node.TEXT_NODE&&(e=g)):(g.nodeType===Node.TEXT_NODE&&(b.appendData(g.data),g.parentNode.removeChild(g)),e=b));return e} function p(b){for(var g=b.parentNode;b.firstChild;)g.insertBefore(b.firstChild,b);g.removeChild(b);return g}function m(b,g){for(var e=b.parentNode,a=b.firstChild,d;a;)d=a.nextSibling,m(a,g),a=d;e&&g(b)&&p(b);return e}function l(b,g){return b===g||Boolean(b.compareDocumentPosition(g)&Node.DOCUMENT_POSITION_CONTAINED_BY)}function r(b,g){return f().unscaledRangeClientRects?b:b/g}function b(n,g,e){Object.keys(g).forEach(function(a){var d=a.split(":"),c=d[1],h=e(d[0]),d=g[a],f=typeof d;"object"===f?Object.keys(d).length&& (a=h?n.getElementsByTagNameNS(h,c)[0]||n.ownerDocument.createElementNS(h,a):n.getElementsByTagName(c)[0]||n.ownerDocument.createElement(a),n.appendChild(a),b(a,d,e)):h&&(runtime.assert("number"===f||"string"===f,"attempting to map unsupported type '"+f+"' (key: "+a+")"),n.setAttributeNS(h,a,String(d)))})}var e=null;this.splitBoundaries=function(b){var g,e=[],c,h,f;if(b.startContainer.nodeType===Node.TEXT_NODE||b.endContainer.nodeType===Node.TEXT_NODE){c=b.endContainer;h=b.endContainer.nodeType!== Node.TEXT_NODE?b.endOffset===b.endContainer.childNodes.length:!1;f=b.endOffset;g=b.endContainer;if(ff))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(d){var c;for(c=0;c "+g.length),runtime.assert(0<=e,"Error in setPosition: "+e+" < 0"),e===g.length&&(r.nextSibling()?b=0:r.parentNode()?b=1:runtime.assert(!1,"Error in setUnfilteredPosition: position not valid."))):ea.windowBits&&(a.windowBits=-a.windowBits,0===a.windowBits&&(a.windowBits=-15));!(0<=a.windowBits&&16>a.windowBits)||g&&g.windowBits||(a.windowBits+=32);15a.windowBits&&0===(a.windowBits&15)&&(a.windowBits|=15);this.err=0;this.msg="";this.ended=!1;this.chunks= [];this.strm=new b;this.strm.avail_out=0;g=f.inflateInit2(this.strm,a.windowBits);if(g!==l.Z_OK)throw Error(r[g]);this.header=new e;f.inflateGetHeader(this.strm,this.header)};n.prototype.push=function(b,e){var a=this.strm,d=this.options.chunkSize,n,c,h,r,B;if(this.ended)return!1;c=e===~~e?e:!0===e?l.Z_FINISH:l.Z_NO_FLUSH;a.input="string"===typeof b?m.binstring2buf(b):b;a.next_in=0;a.avail_in=a.input.length;do{0===a.avail_out&&(a.output=new p.Buf8(d),a.next_out=0,a.avail_out=d);n=f.inflate(a,l.Z_NO_FLUSH); if(n!==l.Z_STREAM_END&&n!==l.Z_OK)return this.onEnd(n),this.ended=!0,!1;if(a.next_out&&(0===a.avail_out||n===l.Z_STREAM_END||0===a.avail_in&&c===l.Z_FINISH))if("string"===this.options.to)h=m.utf8border(a.output,a.next_out),r=a.next_out-h,B=m.buf2string(a.output,h),a.next_out=r,a.avail_out=d-r,r&&p.arraySet(a.output,a.output,h,r,0),this.onData(B);else this.onData(p.shrinkBuf(a.output,a.next_out))}while((0a&&(b.subarray&&m||!b.subarray&&p))return String.fromCharCode.apply(null,f.shrinkBuf(b,a));for(var g="",d=0;da;a++)b[a]=252<=a?6:248<= a?5:240<=a?4:224<=a?3:192<=a?2:1;b[254]=b[254]=1;c.string2buf=function(b){var a,g,d,c,h,r=b.length,p=0;for(c=0;cg?1:2048>g?2:65536>g?3:4;a=new f.Buf8(p);for(c=h=0;hg?a[h++]=g:(2048>g?a[h++]=192|g>>>6:(65536>g?a[h++]=224|g>>>12:(a[h++]= 240|g>>>18,a[h++]=128|g>>>12&63),a[h++]=128|g>>>6&63),a[h++]=128|g&63);return a};c.buf2binstring=function(b){return h(b,b.length)};c.binstring2buf=function(b){for(var a=new f.Buf8(b.length),g=0,d=a.length;gf)q[c++]=f;else if(r=b[f],4f?q[c++]=f:(f-=65536,q[c++]= 55296|f>>10&1023,q[c++]=56320|f&1023)}return h(q,c)};c.utf8border=function(a,d){var g;d=d||a.length;d>a.length&&(d=a.length);for(g=d-1;0<=g&&128===(a[g]&192);)g--;return 0>g||0===g?d:g+b[a[g]]>d?g:d}},{"./common":2}],4:[function(a,d,c){d.exports=function(a,d,c,f){var l=a&65535|0;a=a>>>16&65535|0;for(var r=0;0!==c;){r=2E3c;c++){a=c;for(var h=0;8>h;h++)a=a&1?3988292384^a>>>1:a>>>1;d[c]=a}return d}();d.exports=function(a,d,c,f){c=f+c;for(a^= -1;f>>8^h[(a^d[f])&255];return a^-1}},{}],7:[function(a,d,c){d.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,d,c){d.exports=function(a,d){var c,f,l,r,b,e,n,g,u,t,y,v,s,x,w,B,I,C,F,J,N,K,H,z;c=a.state;f=a.next_in;H=a.input;l=f+(a.avail_in-5);r=a.next_out;z=a.output;b=r-(d-a.avail_out);e=r+(a.avail_out-257);n=c.dmax;g=c.wsize;u=c.whave;t=c.wnext;y=c.window;v=c.hold;s=c.bits; x=c.lencode;w=c.distcode;B=(1<s&&(v+=H[f++]<>>24;v>>>=F;s-=F;F=C>>>16&255;if(0===F)z[r++]=C&65535;else if(F&16){J=C&65535;if(F&=15)s>>=F,s-=F;15>s&&(v+=H[f++]<>>24;v>>>=F;s-=F;F=C>>>16&255;if(F&16){C&=65535;F&=15;sn){a.msg="invalid distance too far back"; c.mode=30;break a}v>>>=F;s-=F;F=r-b;if(C>F){F=C-F;if(F>u&&c.sane){a.msg="invalid distance too far back";c.mode=30;break a}N=0;K=y;if(0===t){if(N+=g-F,F>3;f-=J;s-=J<<3;a.next_in=f;a.next_out=r;a.avail_in=f>>24&255)+(b>>>8&65280)+((b&65280)<<8)+((b&255)<<24)}function q(){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 b.Buf16(320);this.work= new b.Buf16(288);this.distdyn=this.lendyn=null;this.was=this.back=this.sane=0}function p(a){var g;if(!a||!a.state)return y;g=a.state;a.total_in=a.total_out=g.total=0;a.msg="";g.wrap&&(a.adler=g.wrap&1);g.mode=v;g.last=0;g.havedict=0;g.dmax=32768;g.head=null;g.hold=0;g.bits=0;g.lencode=g.lendyn=new b.Buf32(s);g.distcode=g.distdyn=new b.Buf32(x);g.sane=1;g.back=-1;return t}function m(b){var a;if(!b||!b.state)return y;a=b.state;a.wsize=0;a.whave=0;a.wnext=0;return p(b)}function l(b,a){var g,e;if(!b|| !b.state)return y;e=b.state;0>a?(g=0,a=-a):(g=(a>>4)+1,48>a&&(a&=15));if(a&&(8>a||15s;){if(0===l)break a;l--;m+=r[H++]<>>8&255;c.check=n(c.check,X,2,0);s=m=0;c.mode=2;break}c.flags=0;c.head&&(c.head.done=!1);if(!(c.wrap&1)||(((m&255)<<8)+(m>>8))%31){a.msg="incorrect header check";c.mode=30;break}if(8!==(m&15)){a.msg="unknown compression method";c.mode=30;break}m>>>=4;s-=4;Q=(m&15)+8;if(0===c.wbits)c.wbits=Q;else if(Q>c.wbits){a.msg="invalid window size";c.mode=30;break}c.dmax=1<s;){if(0===l)break a;l--;m+=r[H++]<>8&1);c.flags&512&&(X[0]=m&255,X[1]=m>>>8&255,c.check=n(c.check,X,2,0));s=m=0;c.mode=3;case 3:for(;32>s;){if(0===l)break a;l--;m+=r[H++]<>>8&255,X[2]=m>>>16&255,X[3]=m>>>24&255,c.check=n(c.check,X,4,0));s=m=0;c.mode=4;case 4:for(;16>s;){if(0===l)break a;l--;m+=r[H++]<>8);c.flags&512&&(X[0]=m&255,X[1]=m>>>8&255,c.check=n(c.check,X,2,0));s=m=0;c.mode=5;case 5:if(c.flags&1024){for(;16>s;){if(0===l)break a;l--;m+=r[H++]<>>8&255,c.check=n(c.check,X,2,0));s=m=0}else c.head&&(c.head.extra=null);c.mode=6;case 6:if(c.flags&1024&&(D=c.length,D>l&&(D=l),D&&(c.head&&(Q=c.head.extra_len-c.length,c.head.extra||(c.head.extra=Array(c.head.extra_len)),b.arraySet(c.head.extra, r,H,D,Q)),c.flags&512&&(c.check=n(c.check,r,D,H)),l-=D,H+=D,c.length-=D),c.length))break a;c.length=0;c.mode=7;case 7:if(c.flags&2048){if(0===l)break a;D=0;do Q=r[H+D++],c.head&&Q&&65536>c.length&&(c.head.name+=String.fromCharCode(Q));while(Q&&Dc.length&&(c.head.comment+=String.fromCharCode(Q));while(Q&&D< l);c.flags&512&&(c.check=n(c.check,r,D,H));l-=D;H+=D;if(Q)break a}else c.head&&(c.head.comment=null);c.mode=9;case 9:if(c.flags&512){for(;16>s;){if(0===l)break a;l--;m+=r[H++]<>9&1,c.head.done=!0);a.adler=c.check=0;c.mode=12;break;case 10:for(;32>s;){if(0===l)break a;l--;m+=r[H++]<>>=s&7;s-=s&7;c.mode=27;break}for(;3>s;){if(0===l)break a;l--;m+=r[H++]<>>=1;s-=1;switch(m&3){case 0:c.mode=14;break;case 1:D=c;if(w){Q=void 0;B=new b.Buf32(512);I=new b.Buf32(32);for(Q=0;144>Q;)D.lens[Q++]=8;for(;256>Q;)D.lens[Q++]=9;for(;280>Q;)D.lens[Q++]=7;for(;288>Q;)D.lens[Q++]=8;u(1,D.lens,0,288,B,0,D.work,{bits:9});for(Q=0;32>Q;)D.lens[Q++]=5;u(2,D.lens, 0,32,I,0,D.work,{bits:5});w=!1}D.lencode=B;D.lenbits=9;D.distcode=I;D.distbits=5;c.mode=20;if(6===d){m>>>=2;s-=2;break a}break;case 2:c.mode=17;break;case 3:a.msg="invalid block type",c.mode=30}m>>>=2;s-=2;break;case 14:m>>>=s&7;for(s-=s&7;32>s;){if(0===l)break a;l--;m+=r[H++]<>>16^65535)){a.msg="invalid stored block lengths";c.mode=30;break}c.length=m&65535;s=m=0;c.mode=15;if(6===d)break a;case 15:c.mode=16;case 16:if(D=c.length){D>l&&(D=l);D>p&&(D=p);if(0===D)break a;b.arraySet(K, r,H,D,q);l-=D;H+=D;p-=D;q+=D;c.length-=D;break}c.mode=12;break;case 17:for(;14>s;){if(0===l)break a;l--;m+=r[H++]<>>=5;s-=5;c.ndist=(m&31)+1;m>>>=5;s-=5;c.ncode=(m&15)+4;m>>>=4;s-=4;if(286s;){if(0===l)break a;l--;m+=r[H++]<>>=3;s-=3}for(;19>c.have;)c.lens[R[c.have++]]=0;c.lencode=c.lendyn;c.lenbits=7; D={bits:c.lenbits};E=u(0,c.lens,0,19,c.lencode,0,c.work,D);c.lenbits=D.bits;if(E){a.msg="invalid code lengths set";c.mode=30;break}c.have=0;c.mode=19;case 19:for(;c.have>>24;V=D>>>16&255;ba=D&65535;if(A<=s)break;if(0===l)break a;l--;m+=r[H++]<ba)m>>>=A,s-=A,c.lens[c.have++]=ba;else{if(16===ba){for(D=A+2;s>>=A;s-=A;if(0===c.have){a.msg="invalid bit length repeat";c.mode=30;break}Q= c.lens[c.have-1];D=3+(m&3);m>>>=2;s-=2}else if(17===ba){for(D=A+3;s>>=A;s-=A;Q=0;D=3+(m&7);m>>>=3;s-=3}else{for(D=A+7;s>>=A;s-=A;Q=0;D=11+(m&127);m>>>=7;s-=7}if(c.have+D>c.nlen+c.ndist){a.msg="invalid bit length repeat";c.mode=30;break}for(;D--;)c.lens[c.have++]=Q}}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;D={bits:c.lenbits};E=u(1,c.lens, 0,c.nlen,c.lencode,0,c.work,D);c.lenbits=D.bits;if(E){a.msg="invalid literal/lengths set";c.mode=30;break}c.distbits=6;c.distcode=c.distdyn;D={bits:c.distbits};E=u(2,c.lens,c.nlen,c.ndist,c.distcode,0,c.work,D);c.distbits=D.bits;if(E){a.msg="invalid distances set";c.mode=30;break}c.mode=20;if(6===d)break a;case 20:c.mode=21;case 21:if(6<=l&&258<=p){a.next_out=q;a.avail_out=p;a.next_in=H;a.avail_in=l;c.hold=m;c.bits=s;g(a,P);q=a.next_out;K=a.output;p=a.avail_out;H=a.next_in;r=a.input;l=a.avail_in; m=c.hold;s=c.bits;12===c.mode&&(c.back=-1);break}for(c.back=0;;){D=c.lencode[m&(1<>>24;V=D>>>16&255;ba=D&65535;if(A<=s)break;if(0===l)break a;l--;m+=r[H++]<>Q)];A=D>>>24;V=D>>>16&255;ba=D&65535;if(Q+A<=s)break;if(0===l)break a;l--;m+=r[H++]<>>=Q;s-=Q;c.back+=Q}m>>>=A;s-=A;c.back+=A;c.length=ba;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(D=c.extra;s>>=c.extra;s-=c.extra;c.back+=c.extra}c.was=c.length;c.mode=23;case 23:for(;;){D=c.distcode[m&(1<>>24;V=D>>>16&255;ba=D&65535;if(A<=s)break;if(0===l)break a;l--;m+=r[H++]<>Q)];A=D>>>24;V=D>>>16&255;ba=D&65535;if(Q+A<=s)break;if(0===l)break a;l--;m+=r[H++]<>>=Q;s-=Q;c.back+=Q}m>>>=A;s-=A;c.back+=A;if(V&64){a.msg="invalid distance code";c.mode=30;break}c.offset=ba;c.extra=V&15;c.mode=24;case 24:if(c.extra){for(D=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===p)break a;D=P-p;if(c.offset>D){D=c.offset-D;if(D>c.whave&&c.sane){a.msg="invalid distance too far back";c.mode=30;break}D> c.wnext?(D-=c.wnext,Q=c.wsize-D):Q=c.wnext-D;D>c.length&&(D=c.length);$=c.window}else $=K,Q=q-c.offset,D=c.length;D>p&&(D=p);p-=D;c.length-=D;do K[q++]=$[Q++];while(--D);0===c.length&&(c.mode=21);break;case 26:if(0===p)break a;K[q++]=c.length;p--;c.mode=21;break;case 27:if(c.wrap){for(;32>s;){if(0===l)break a;l--;m|=r[H++]<s;){if(0===l)break a;l--;m+=r[H++]<c.mode&&(27>c.mode||4!==d))r=a.output,H=a.next_out,q=P-a.avail_out,p=a.state,null===p.window&&(p.wsize=1<=p.wsize?(b.arraySet(p.window,r,H-p.wsize,p.wsize,0),p.wnext=0,p.whave=p.wsize):(l=p.wsize-p.wnext,l>q&&(l=q),b.arraySet(p.window,r,H-q,l,p.wnext),(q-=l)?(b.arraySet(p.window,r,H-q,q,0),p.wnext=q,p.whave=p.wsize):(p.wnext+=l,p.wnext===p.wsize&&(p.wnext=0),p.whave=s;s++)U[s]=0;for(x=0;xB&&(I=B);if(0===B)return g[u++]=20971520,g[u++]=20971520,y.bits=1,0;for(w=1;w=s;s++)if(J<<=1,J-=U[s],0>J)return-1;if(0s;s++)C[s+1]=C[s]+U[s];for(x=0;xG?(Q=aa[P+t[x]],$=Z[T+t[x]]):(Q=96,$=0);J=1<>F)+H]=D<<24|Q<<16|$|0;while(0!==H);for(J=1<>=1;0!==J?(K&=J-1,K+=J):K=0;x++;if(0===--U[s]){if(s===B)break;s=b[c+t[x]]}if(s>I&&(K&d)!==z){0===F&&(F=I);v+=w;C=s-F;for(J=1<=J)break;C++;J<<=1}N+=1<";return runtime.parseXML(d)}; core.UnitTest.createOdtDocument=function(f,k){return core.UnitTest.createXmlDocument("office:document",f,k)}; core.UnitTestLogger=function(){var f=[],k=0,a=0,d="",c="";this.startTest=function(h,q){f=[];k=0;d=h;c=q;a=Date.now()};this.endTest=function(){var h=Date.now();return{description:c,suite:[d,c],success:0===k,log:f,time:h-a}};this.debug=function(a){f.push({category:"debug",message:a})};this.fail=function(a){k+=1;f.push({category:"fail",message:a})};this.pass=function(a){f.push({category:"pass",message:a})}}; core.UnitTestRunner=function(f,k){function a(b){l+=1;e?k.debug(b):k.fail(b)}function d(b,c){var e;try{if(b.length!==c.length)return a("array of length "+b.length+" should be "+c.length+" long"),!1;for(e=0;e1/b)return"-0";if("object"===typeof b)try{return JSON.stringify(b)}catch(a){}return String(b)}function m(b,c,e,d){"string"===typeof c&&"string"===typeof e||k.debug("WARN: shouldBe() expects string arguments");var f,h;try{h=eval(c)}catch(m){f=m}b=eval(e);f?a(c+" should be "+b+". Threw exception "+f):q(h,b,d)?k.pass(c+" is "+e):String(typeof h)===String(typeof b)? a(c+" should be "+p(b)+". Was "+p(h)+"."):a(c+" should be "+b+" (of type "+typeof b+"). Was "+h+" (of type "+typeof h+").")}var l=0,r,b,e=!1;this.resourcePrefix=function(){return f};this.beginExpectFail=function(){r=l;e=!0};this.endExpectFail=function(){var b=r===l;e=!1;l=r;b&&(l+=1,k.fail("Expected at least one failed test, but none registered."))};b=function(b,c){var e=Object.keys(b),f=Object.keys(c);e.sort();f.sort();return d(e,f)&&Object.keys(b).every(function(e){var d=b[e],f=c[e];return q(d, f)?!0:(a(d+" should be "+f+" for key "+e),!1)})};this.areNodesEqual=h;this.shouldBeNull=function(b,a){m(b,a,"null")};this.shouldBeNonNull=function(b,c){var e,d;try{d=eval(c)}catch(f){e=f}e?a(c+" should be non-null. Threw exception "+e):null!==d?k.pass(c+" is non-null."):a(c+" should be non-null. Was "+d)};this.shouldBe=m;this.testFailed=a;this.countFailedTests=function(){return l};this.name=function(b){var a,c,e=[],d=b.length;e.length=d;for(a=0;a"+a+""}function k(c){a.reporter&&a.reporter(c)}var a=this,d=0,c=new core.UnitTestLogger,h={},q="BrowserRuntime"===runtime.type();this.resourcePrefix="";this.reporter=function(a){var c,d;q?runtime.log("Running "+f(a.description,'runTest("'+a.suite[0]+'","'+a.description+'")')+""):runtime.log("Running "+a.description);if(!a.success)for(c=0;cRunning "+f(b,'runSuite("'+b+'");')+": "+n.description()+""):runtime.log("Running "+b+": "+n.description);y=n.tests();for(u=0;u>>8^d;return c^-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 h(b){var a=b.getFullYear();return 1980>a?0:a-1980<<25|b.getMonth()+1<<21|b.getDate()<<16|b.getHours()<<11|b.getMinutes()<<5|b.getSeconds()>>1}function q(b,e){var g,d,n,f,h,m,l,r=this;this.load=function(c){if(null!==r.data)c(null,r.data);else{var e=h+34+d+n+256;e+l>t&&(e=t-l);a(l,e,function(a,e){if(a||null===e)c(a,e);else a:{var g=e,d=new core.ByteArray(g),n=d.readUInt32LE(),l;if(67324752!==n)c("File entry signature is wrong."+n.toString()+" "+g.length.toString(),null); else{d.pos+=22;n=d.readUInt16LE();l=d.readUInt16LE();d.pos+=n+l;if(f){g=g.subarray(d.pos,d.pos+h);if(h!==g.length){c("The amount of compressed bytes read was "+g.length.toString()+" instead of "+h.toString()+" for "+r.filename+" in "+b+".",null);break a}g=v(g,m)}else g=g.subarray(d.pos,d.pos+m);m!==g.length?c("The amount of bytes read was "+g.length.toString()+" instead of "+m.toString()+" for "+r.filename+" in "+b+".",null):(r.data=g,c(null,g))}}})}};this.set=function(b,a,c,e){r.filename=b;r.data= a;r.compressed=c;r.date=e};this.error=null;e&&(g=e.readUInt32LE(),33639248!==g?this.error="Central directory entry has wrong signature at position "+(e.pos-4).toString()+' for file "'+b+'": '+e.data.length.toString():(e.pos+=6,f=e.readUInt16LE(),this.date=c(e.readUInt32LE()),e.readUInt32LE(),h=e.readUInt32LE(),m=e.readUInt32LE(),d=e.readUInt16LE(),n=e.readUInt16LE(),g=e.readUInt16LE(),e.pos+=8,l=e.readUInt32LE(),this.filename=runtime.byteArrayToString(e.data.subarray(e.pos,e.pos+d),"utf8"),this.data= null,e.pos+=d+n+g))}function p(b,c){if(22!==b.length)c("Central directory length should be 22.",s);else{var e=new core.ByteArray(b),d;d=e.readUInt32LE();101010256!==d?c("Central directory signature is wrong: "+d.toString(),s):(d=e.readUInt16LE(),0!==d?c("Zip files with non-zero disk numbers are not supported.",s):(d=e.readUInt16LE(),0!==d?c("Zip files with non-zero disk numbers are not supported.",s):(d=e.readUInt16LE(),y=e.readUInt16LE(),d!==y?c("Number of entries is inconsistent.",s):(d=e.readUInt32LE(), e=e.readUInt16LE(),e=t-22-d,a(e,t-e,function(b,a){if(b||null===a)c(b,s);else a:{var e=new core.ByteArray(a),d,n;g=[];for(d=0;db.value||"%"===b.unit)?null:b}function F(b){return(b=I(b))&&"%"!==b.unit?null:b}function J(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 N(b,a){for(;0=a.value||"%"===a.unit)?null:a;return a||F(b)};this.parseFoLineHeight= function(b){return C(b)||F(b)};this.isTextContentContainingNode=J;this.getTextNodes=function(b,a){var c;c=U.getNodesInRange(b,function(b){var a=NodeFilter.FILTER_REJECT;b.nodeType===Node.TEXT_NODE?Boolean(h(b)&&(!p(b.textContent)||B(b,0)))&&(a=NodeFilter.FILTER_ACCEPT):J(b)&&(a=NodeFilter.FILTER_SKIP);return a},NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT);a||N(b,c);return c};this.getTextElements=K;this.getParagraphElements=function(b){var a;a=U.getNodesInRange(b,function(b){var a=NodeFilter.FILTER_REJECT; if(c(b))a=NodeFilter.FILTER_ACCEPT;else if(J(b)||m(b))a=NodeFilter.FILTER_SKIP;return a},NodeFilter.SHOW_ELEMENT);H(b.startContainer,a,c);return a};this.getImageElements=function(b){var a;a=U.getNodesInRange(b,function(b){var a=NodeFilter.FILTER_SKIP;f(b)&&(a=NodeFilter.FILTER_ACCEPT);return a},NodeFilter.SHOW_ELEMENT);H(b.startContainer,a,f);return a};this.getHyperlinkElements=function(b){var a=[],e=b.cloneRange();b.collapsed&&b.endContainer.nodeType===Node.ELEMENT_NODE&&(b=z(b.endContainer,b.endOffset), b.nodeType===Node.TEXT_NODE&&e.setEnd(b,1));K(e,!0,!1).forEach(function(b){for(b=b.parentNode;!c(b);){if(d(b)&&-1===a.indexOf(b)){a.push(b);break}b=b.parentNode}});e.detach();return a};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,d=NodeFilter.FILTER_ACCEPT,c=odf.Namespaces.textns;this.acceptNode=function(h){if(h.nodeType===k){if(!f.isGroupingElement(h.parentNode))return a}else if(h.namespaceURI===c&&"tracked-changes"===h.localName)return a;return d}};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,b,c){return-1!==a&&(a=f&&c.push(k(a.substring(b,d)))):"["===a[d]&&(0>=f&&(b=d+1),f+=1),d+=1;return d};m=function(a,b,e){var f,g,h,m;for(f=0;f/g,">").replace(/'/g,"'").replace(/"/g,""")}function a(c,f){var q="",p=d.filter?d.filter.acceptNode(f):NodeFilter.FILTER_ACCEPT,m;if(p===NodeFilter.FILTER_ACCEPT&&f.nodeType===Node.ELEMENT_NODE){c.push();m=c.getQName(f);var l,r=f.attributes,b,e,n,g="",u;l="<"+m;b=r.length;for(e=0;e")}if(p===NodeFilter.FILTER_ACCEPT||p===NodeFilter.FILTER_SKIP){for(p=f.firstChild;p;)q+=a(c,p),p=p.nextSibling;f.nodeValue&&(q+=k(f.nodeValue))}m&&(q+="",c.pop());return q}var d=this;this.filter=null;this.writeToString=function(c,d){if(!c)return"";var q=new f(d);return a(q,c)}};(function(){function f(a){var b,c=p.length;for(b=0;bc)break;g=g.nextSibling}a.insertBefore(b,g)}}}var c=new odf.StyleInfo,h=core.DomUtils,q=odf.Namespaces.stylens,p="meta settings scripts font-face-decls styles automatic-styles master-styles body".split(" "), m=Date.now()+"_webodf_",l=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,b,c,d){var g=this;this.size=0;this.type=null;this.name=a;this.container=c;this.url=null;this.mimetype=b;this.onstatereadychange=this.document=null;this.EMPTY=0;this.LOADING=1;this.DONE=2;this.state=this.EMPTY;this.data="";this.load=function(){null!==d&&(this.mimetype=b,d.loadAsDataURL(a,b,function(b,a){b&&runtime.log(b);g.url=a;if(g.onchange)g.onchange(g);if(g.onstatereadychange)g.onstatereadychange(g)}))}};odf.OdfPart.prototype.load=function(){}; odf.OdfPart.prototype.getUrl=function(){return this.data?"data:;base64,"+l.toBase64(this.data):null};odf.OdfContainer=function b(e,f){function g(b){for(var a=b.firstChild,c;a;)c=a.nextSibling,a.nodeType===Node.ELEMENT_NODE?g(a):a.nodeType===Node.PROCESSING_INSTRUCTION_NODE&&b.removeChild(a),a=c}function p(b){var a={},c,e,d=b.ownerDocument.createNodeIterator(b,NodeFilter.SHOW_ELEMENT,null,!1);for(b=d.nextNode();b;)"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===b.namespaceURI&&("annotation"=== b.localName?(c=b.getAttributeNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0","name"))&&(a.hasOwnProperty(c)?runtime.log("Warning: annotation name used more than once with : '"+c+"'"):a[c]=b):"annotation-end"===b.localName&&((c=b.getAttributeNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0","name"))?a.hasOwnProperty(c)?(e=a[c],e.annotationEndElement?runtime.log("Warning: annotation name used more than once with : '"+c+"'"):e.annotationEndElement= b):runtime.log("Warning: annotation end without an annotation start, name: '"+c+"'"):runtime.log("Warning: annotation end without a name found"))),b=d.nextNode()}function t(b,a){for(var c=b&&b.firstChild;c;)c.nodeType===Node.ELEMENT_NODE&&c.setAttributeNS("urn:webodf:names:scope","scope",a),c=c.nextSibling}function y(b,a){for(var c=E.rootElement.meta,c=c&&c.firstChild;c&&(c.namespaceURI!==b||c.localName!==a);)c=c.nextSibling;for(c=c&&c.firstChild;c&&c.nodeType!==Node.TEXT_NODE;)c=c.nextSibling;return c? c.data:null}function v(b){var a={},c;for(b=b.firstChild;b;)b.nodeType===Node.ELEMENT_NODE&&b.namespaceURI===q&&"font-face"===b.localName&&(c=b.getAttributeNS(q,"name"),a[c]=b),b=b.nextSibling;return a}function s(b,a){var c=null,e,d,g;if(b)for(c=b.cloneNode(!0),e=c.firstElementChild;e;)d=e.nextElementSibling,(g=e.getAttributeNS("urn:webodf:names:scope","scope"))&&g!==a&&c.removeChild(e),e=d;return c}function x(b,a){var e,d,g,f=null,n={};if(b)for(a.forEach(function(b){c.collectUsedFontFaces(n,b)}), f=b.cloneNode(!0),e=f.firstElementChild;e;)d=e.nextElementSibling,g=e.getAttributeNS(q,"name"),n[g]||f.removeChild(e),e=d;return f}function w(b){var a=E.rootElement.ownerDocument,c;if(b){g(b.documentElement);try{c=a.importNode(b.documentElement,!0)}catch(e){}}return c}function B(b){E.state=b;if(E.onchange)E.onchange(E);if(E.onstatereadychange)E.onstatereadychange(E)}function I(b){da=null;E.rootElement=b;b.fontFaceDecls=h.getDirectChild(b,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","font-face-decls"); b.styles=h.getDirectChild(b,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","styles");b.automaticStyles=h.getDirectChild(b,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","automatic-styles");b.masterStyles=h.getDirectChild(b,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","master-styles");b.body=h.getDirectChild(b,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","body");b.meta=h.getDirectChild(b,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","meta");b.settings=h.getDirectChild(b,"urn:oasis:names:tc:opendocument:xmlns:office:1.0", "settings");b.scripts=h.getDirectChild(b,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","scripts");p(b)}function C(a){var e=w(a),g=E.rootElement,f;e&&"document-styles"===e.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===e.namespaceURI?(g.fontFaceDecls=h.getDirectChild(e,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","font-face-decls"),d(g,g.fontFaceDecls),f=h.getDirectChild(e,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","styles"),g.styles=f||a.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0", "styles"),d(g,g.styles),f=h.getDirectChild(e,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","automatic-styles"),g.automaticStyles=f||a.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0","automatic-styles"),t(g.automaticStyles,"document-styles"),d(g,g.automaticStyles),e=h.getDirectChild(e,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","master-styles"),g.masterStyles=e||a.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0","master-styles"),d(g,g.masterStyles), c.prefixStyleNames(g.automaticStyles,m,g.masterStyles)):B(b.INVALID)}function F(a){a=w(a);var e,g,f,n;if(a&&"document-content"===a.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===a.namespaceURI){e=E.rootElement;f=h.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","font-face-decls");if(e.fontFaceDecls&&f){n=e.fontFaceDecls;var m,l,p,k,H={};g=v(n);k=v(f);for(f=f.firstElementChild;f;){m=f.nextElementSibling;if(f.namespaceURI===q&&"font-face"===f.localName)if(l=f.getAttributeNS(q, "name"),g.hasOwnProperty(l)){if(!f.isEqualNode(g[l])){p=l;for(var K=g,s=k,u=0,z=void 0,z=p=p.replace(/\d+$/,"");K.hasOwnProperty(z)||s.hasOwnProperty(z);)u+=1,z=p+u;p=z;f.setAttributeNS(q,"style:name",p);n.appendChild(f);g[p]=f;delete k[l];H[l]=p}}else n.appendChild(f),g[l]=f,delete k[l];f=m}n=H}else f&&(e.fontFaceDecls=f,d(e,f));g=h.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","automatic-styles");t(g,"document-content");n&&c.changeFontFaceNames(g,n);if(e.automaticStyles&&g)for(n= g.firstChild;n;)e.automaticStyles.appendChild(n),n=g.firstChild;else g&&(e.automaticStyles=g,d(e,g));a=h.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","body");if(null===a)throw" tag is mising.";e.body=a;d(e,e.body)}else B(b.INVALID)}function J(b){b=w(b);var a;b&&"document-meta"===b.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===b.namespaceURI&&(a=E.rootElement,a.meta=h.getDirectChild(b,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","meta"), d(a,a.meta))}function N(b){b=w(b);var a;b&&"document-settings"===b.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===b.namespaceURI&&(a=E.rootElement,a.settings=h.getDirectChild(b,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","settings"),d(a,a.settings))}function K(b){b=w(b);var a;if(b&&"manifest"===b.localName&&"urn:oasis:names:tc:opendocument:xmlns:manifest:1.0"===b.namespaceURI)for(a=E.rootElement,a.manifest=b,b=a.manifest.firstElementChild;b;)"file-entry"===b.localName&&"urn:oasis:names:tc:opendocument:xmlns:manifest:1.0"=== b.namespaceURI&&(R[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 H(b,a,c){b=h.getElementsByTagName(b,a);var e;for(e=0;e'}function U(){var b=new xmldom.LSSerializer,a=G("document-meta");b.filter=new odf.OdfNodeFilter;a+=b.writeToString(E.rootElement.meta,odf.Namespaces.namespaceMap);return a+""}function aa(b,a){var c=document.createElementNS("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0","manifest:file-entry");c.setAttributeNS("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0","manifest:full-path",b);c.setAttributeNS("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0", "manifest:media-type",a);return c}function P(){var b=runtime.parseXML(''),a=b.documentElement,c=new xmldom.LSSerializer,e;for(e in R)R.hasOwnProperty(e)&&a.appendChild(aa(e,R[e]));c.filter=new odf.OdfNodeFilter;return'\n'+c.writeToString(b,odf.Namespaces.namespaceMap)}function D(){var b,a,e,d=odf.Namespaces.namespaceMap, g=new xmldom.LSSerializer,f=G("document-styles");a=s(E.rootElement.automaticStyles,"document-styles");e=E.rootElement.masterStyles.cloneNode(!0);b=x(E.rootElement.fontFaceDecls,[e,E.rootElement.styles,a]);c.removePrefixFromStyleNames(a,m,e);g.filter=new k(e,a);f+=g.writeToString(b,d);f+=g.writeToString(E.rootElement.styles,d);f+=g.writeToString(a,d);f+=g.writeToString(e,d);return f+""}function Q(){var b,c,e=odf.Namespaces.namespaceMap,d=new xmldom.LSSerializer,g=G("document-content"); c=s(E.rootElement.automaticStyles,"document-content");b=x(E.rootElement.fontFaceDecls,[c]);d.filter=new a(E.rootElement.body,c);g+=d.writeToString(b,e);g+=d.writeToString(c,e);g+=d.writeToString(E.rootElement.body,e);return g+""}function $(a,c){runtime.loadXML(a,function(a,e){if(a)c(a);else if(e){z(e);Z(e.documentElement);var d=w(e);d&&"document"===d.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===d.namespaceURI?(I(d),B(b.DONE)):B(b.INVALID)}else c("No DOM was loaded.")})} function A(b,a){var c;c=E.rootElement;var e=c.meta;e||(c.meta=e=document.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0","meta"),d(c,e));c=e;b&&h.mapKeyValObjOntoNode(c,b,odf.Namespaces.lookupNamespaceURI);a&&h.removeKeyElementsFromNode(c,a,odf.Namespaces.lookupNamespaceURI)}function V(a,c){function e(b,a){var c;a||(a=b);c=document.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0",a);n[b]=c;n.appendChild(c)}var d=new core.Zip("",null),g="application/vnd.oasis.opendocument."+ a+(!0===c?"-template":""),f=runtime.byteArrayFromString(g,"utf8"),n=E.rootElement,h=document.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0",a);d.save("mimetype",f,!1,new Date);e("meta");e("settings");e("scripts");e("fontFaceDecls","font-face-decls");e("styles");e("automaticStyles","automatic-styles");e("masterStyles","master-styles");e("body");n.body.appendChild(h);R["/"]=g;R["settings.xml"]="text/xml";R["meta.xml"]="text/xml";R["styles.xml"]="text/xml";R["content.xml"]="text/xml"; B(b.DONE);return d}function ba(){var b,a=new Date,c="";E.rootElement.settings&&E.rootElement.settings.firstElementChild&&(b=new xmldom.LSSerializer,c=G("document-settings"),b.filter=new odf.OdfNodeFilter,c+=b.writeToString(E.rootElement.settings,odf.Namespaces.namespaceMap),c+="");(b=c)?(b=runtime.byteArrayFromString(b,"utf8"),X.save("settings.xml",b,!0,a)):X.remove("settings.xml");c=runtime.getWindow();b="WebODF/"+webodf.Version;c&&(b=b+" "+c.navigator.userAgent);A({"meta:generator":b}, null);b=runtime.byteArrayFromString(U(),"utf8");X.save("meta.xml",b,!0,a);b=runtime.byteArrayFromString(D(),"utf8");X.save("styles.xml",b,!0,a);b=runtime.byteArrayFromString(Q(),"utf8");X.save("content.xml",b,!0,a);b=runtime.byteArrayFromString(P(),"utf8");X.save("META-INF/manifest.xml",b,!0,a)}function Y(b,a){ba();X.writeAs(b,function(b){a(b)})}var E=this,X,R={},da,S="";this.onstatereadychange=f;this.state=this.onchange=null;this.getMetadata=y;this.setRootElement=I;this.getContentElement=function(){var b; da||(b=E.rootElement.body,da=h.getDirectChild(b,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","text")||h.getDirectChild(b,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","presentation")||h.getDirectChild(b,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","spreadsheet"));if(!da)throw"Could not find content element in .";return da};this.getDocumentType=function(){var b=E.getContentElement();return b&&b.localName};this.isTemplate=function(){return"-template"===R["/"].substr(-9)}; this.setIsTemplate=function(b){var a=R["/"],c="-template"===a.substr(-9);b!==c&&(a=b?a+"-template":a.substr(0,a.length-9),R["/"]=a,b=runtime.byteArrayFromString(a,"utf8"),X.save("mimetype",b,!1,new Date))};this.getPart=function(b){return new odf.OdfPart(b,R[b],E,X)};this.getPartData=function(b,a){X.load(b,a)};this.setMetadata=A;this.incrementEditingCycles=function(){var b=y(odf.Namespaces.metans,"editing-cycles"),b=b?parseInt(b,10):0;isNaN(b)&&(b=0);A({"meta:editing-cycles":b+1},null);return b+1}; this.createByteArray=function(b,a){ba();X.createByteArray(b,a)};this.saveAs=Y;this.save=function(b){Y(S,b)};this.getUrl=function(){return S};this.setBlob=function(b,a,c){c=l.convertBase64ToByteArray(c);X.save(b,c,!1,new Date);R.hasOwnProperty(b)&&runtime.log(b+" has been overwritten.");R[b]=a};this.removeBlob=function(b){var a=X.remove(b);runtime.assert(a,"file is not found: "+b);delete R[b]};this.state=b.LOADING;this.rootElement=function(b){var a=document.createElementNS(b.namespaceURI,b.localName), c;b=new b.Type;for(c in b)b.hasOwnProperty(c)&&(a[c]=b[c]);return a}({Type:odf.ODFDocumentElement,namespaceURI:odf.ODFDocumentElement.namespaceURI,localName:odf.ODFDocumentElement.localName});e===odf.OdfContainer.DocumentType.TEXT?X=V("text"):e===odf.OdfContainer.DocumentType.TEXT_TEMPLATE?X=V("text",!0):e===odf.OdfContainer.DocumentType.PRESENTATION?X=V("presentation"):e===odf.OdfContainer.DocumentType.PRESENTATION_TEMPLATE?X=V("presentation",!0):e===odf.OdfContainer.DocumentType.SPREADSHEET?X=V("spreadsheet"): e===odf.OdfContainer.DocumentType.SPREADSHEET_TEMPLATE?X=V("spreadsheet",!0):(S=e,X=new core.Zip(S,function(a,c){X=c;a?$(S,function(c){a&&(X.error=a+"\n"+c,B(b.INVALID))}):T([{path:"styles.xml",handler:C},{path:"content.xml",handler:F},{path:"meta.xml",handler:J},{path:"settings.xml",handler:N},{path:"META-INF/manifest.xml",handler:K}])}))};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(b){return new odf.OdfContainer(b,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,d){function c(b){var a=b.annotationEndElement,c=l.createRange(),d=b.getAttributeNS(odf.Namespaces.officens,"name");a&&(c.setStart(b,b.childNodes.length),c.setEnd(a,0),b=r.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===e&&"webodf-annotationHighlight"===a.className&&a.getAttribute("annotation")===d){a=!0;break a}a=a.parentNode}a=!1}a||(a=l.createElement("span"), a.className="webodf-annotationHighlight",a.setAttribute("annotation",d),b.parentNode.replaceChild(a,b),a.appendChild(b))}));c.detach()}function h(c){var e=f.getSizer();c?(a.style.display="inline-block",e.style.paddingRight=b.getComputedStyle(a).width):(a.style.display="none",e.style.paddingRight=0);f.refreshSize()}function q(){m.sort(function(b,a){return 0!==(b.compareDocumentPosition(a)&Node.DOCUMENT_POSITION_FOLLOWING)?-1:1})}function p(){var b;for(b=0;b=(l.getBoundingClientRect().top-q.bottom)/c?e.style.top=Math.abs(l.getBoundingClientRect().top-q.bottom)/c+20+"px":e.style.top="0px");h.style.left=d.getBoundingClientRect().width/ c+"px";var d=h.style,l=h.getBoundingClientRect().left/c,p=h.getBoundingClientRect().top/c,q=e.getBoundingClientRect().left/c,k=e.getBoundingClientRect().top/c,r=0,I=0,r=q-l,r=r*r,I=k-p,I=I*I,l=Math.sqrt(r+I);d.width=l+"px";p=Math.asin((e.getBoundingClientRect().top-h.getBoundingClientRect().top)/(c*parseFloat(h.style.width)));h.style.transform="rotate("+p+"rad)";h.style.MozTransform="rotate("+p+"rad)";h.style.WebkitTransform="rotate("+p+"rad)";h.style.msTransform="rotate("+p+"rad)"}}var m=[],l=k.ownerDocument, r=odf.OdfUtils,b=runtime.getWindow(),e="http://www.w3.org/1999/xhtml";runtime.assert(Boolean(b),"Expected to be run in an environment which has a global window, like a browser.");this.rerenderAnnotations=p;this.rehighlightAnnotations=function(){m.forEach(function(b){c(b)})};this.getMinimumHeightForAnnotationPane=function(){return"none"!==a.style.display&&0q||k.bottom>q)f.scrollTop=k.bottom-k.top<=q-c?f.scrollTop+(k.bottom-q):f.scrollTop+(k.top-c);k.lefth&&(f.scrollLeft=k.right-k.left<=h-d?f.scrollLeft+(k.right-h):f.scrollLeft-(d-k.left))}}};(function(){function f(a,h,q,p,m){var l,k=0,b;for(b in a)if(a.hasOwnProperty(b)){if(k===q){l=b;break}k+=1}l?h.getPartData(a[l].href,function(b,n){if(b)runtime.log(b);else if(n){var g="@font-face { font-family: "+(a[l].family||l)+"; src: url(data:application/x-font-ttf;charset=binary;base64,"+d.convertUTF8ArrayToBase64(n)+') format("truetype"); }';try{p.insertRule(g,p.cssRules.length)}catch(k){runtime.log("Problem inserting rule in CSS: "+runtime.toJson(k)+"\nRule: "+g)}}else runtime.log("missing font data for "+ a[l].href);f(a,h,q+1,p,m)}):m&&m()}var k=xmldom.XPath,a=odf.OdfUtils,d=new core.Base64;odf.FontLoader=function(){this.loadFonts=function(c,d){for(var q=c.rootElement.fontFaceDecls;d.cssRules.length;)d.deleteRule(d.cssRules.length-1);if(q){var p={},m,l,r,b;if(q)for(q=k.getODFElementsWithXPath(q,"style:font-face[svg:font-face-src]",odf.Namespaces.lookupNamespaceURI),m=0;m text|list-item:first-child > :not(text|list):first-child:before',x+="{",x+="counter-increment: "+s+" 0;",x+="}",f(a,x));for(;k.counterIdStack.length>=q;)k.counterIdStack.pop();k.counterIdStack.push(s);w=k.contentRules[q.toString()]||"";for(x=1;x<=q;x+=1)w=w.replace(x+"webodf-listLevel",k.counterIdStack[x-1]);x='text|list[webodfhelper|counter-id="'+r+'"] > text|list-item > :not(text|list):first-child:before'; x+="{";x+=w;x+="counter-increment: "+s+";";x+="}";f(a,x)}for(d=d.firstElementChild;d;)c(e,d,p,k),d=d.nextElementSibling}else k.continuedCounterIdStack=[]}var d=0,b="",e={};this.createCounterRules=function(b,a,f){var h=a.getAttributeNS(q,"id"),m=[];f&&(f=f.getAttributeNS("urn:webodf:names:helper","counter-id"),m=e[f].slice(0));b=new k(b,m);h?h="Y"+h:(d+=1,h="X"+d);c(h,a,0,b);e[h+"-level1-1"]=b.counterIdStack};this.initialiseCreatedCounters=function(){var c;c="office|document{"+("counter-reset: "+b+ ";");c+="}";f(a,c)}}var d=odf.Namespaces.fons,c=odf.Namespaces.stylens,h=odf.Namespaces.textns,q=odf.Namespaces.xmlns,p={1:"decimal",a:"lower-latin",A:"upper-latin",i:"lower-roman",I:"upper-roman"};odf.ListStyleToCss=function(){function m(b){var a=n.parseLength(b);return a?e.convert(a.value,a.unit,"px"):(runtime.log("Could not parse value '"+b+"'."),0)}function l(b){return b.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}function k(b,a){var c;b&&(c=b.getAttributeNS(h,"style-name"));return c===a}function b(b, e,d){e=e.getElementsByTagNameNS(h,"list");b=new a(b);var f,n,m,x,w,B,I={},C;for(C=0;C text|list-item > text|list",t-=1;t=u&&u.getAttributeNS(d,"text-align")||"left";switch(t){case "end":t="right";break;case "start":t="left"}"label-alignment"===N?(H=K&&K.getAttributeNS(d,"margin-left")||"0px",T=K&&K.getAttributeNS(d,"text-indent")||"0px",G=K&&K.getAttributeNS(h,"label-followed-by"),K=m(H)):(H=u&&u.getAttributeNS(h,"space-before")||"0px",z=u&&u.getAttributeNS(h,"min-label-width")||"0px", Z=u&&u.getAttributeNS(h,"min-label-distance")||"0px",K=m(H)+m(z));u=q+" > text|list-item";u+="{";u+="margin-left: "+K+"px;";u+="}";f(n,u);u=q+" > text|list-item > text|list";u+="{";u+="margin-left: "+-K+"px;";u+="}";f(n,u);u=q+" > text|list-item > :not(text|list):first-child:before";u+="{";u+="text-align: "+t+";";u+="display: inline-block;";"label-alignment"===N?(u+="margin-left: "+T+";","listtab"===G&&(u+="padding-right: 0.2cm;")):(u+="min-width: "+z+";",u+="margin-left: "+(0===parseFloat(z)?"": "-")+z+";",u+="padding-right: "+Z+";");u+="}";f(n,u)}e=e.nextElementSibling}});b(a,n,l)}}})();odf.LazyStyleProperties=function(f,k){var a={};this.value=function(d){var c;a.hasOwnProperty(d)?c=a[d]:(c=k[d](),void 0===c&&f&&(c=f.value(d)),a[d]=c);return c};this.reset=function(d){f=d;a={}}}; odf.StyleParseUtils=function(){function f(a){var d,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?d=a.value:"cm"===c?d=96*(a.value/2.54):"mm"===c?d=96*(a.value/25.4):"in"===c?d=96*a.value:"pt"===c?d=a.value/0.75:"pc"===c&&(d=16*a.value);return d}var k=odf.Namespaces.stylens;this.parseLength=f;this.parsePositiveLengthOrPercent=function(a,d,c){var h;a&&(h=parseFloat(a.substr(0, a.indexOf("%"))),isNaN(h)&&(h=void 0));var k;void 0!==h?(c&&(k=c.value(d)),h=void 0===k?void 0:h*(k/100)):h=f(a);return h};this.getPropertiesElement=function(a,d,c){for(d=c?c.nextElementSibling:d.firstElementChild;null!==d&&(d.localName!==a||d.namespaceURI!==k);)d=d.nextElementSibling;return d};this.parseAttributeList=function(a){a&&(a=a.replace(/^\s*(.*?)\s*$/g,"$1"));return a&&0n.value&&(f="0.75pt"+g);g=f}else if(z.hasOwnProperty(d[1])){var f= b,h=d[0],n=d[1],m=T.parseLength(g),l=void 0,p=void 0,q=void 0,K=void 0,q=void 0;if(m&&"%"===m.unit){l=m.value/100;p=k(f.parentNode);for(K="0";p;){if(q=u.getDirectChild(p,r,"paragraph-properties"))if(q=T.parseLength(q.getAttributeNS(h,n))){if("%"!==q.unit){K=q.value*l+q.unit;break}l*=q.value/100}p=k(p)}g=K}}d[2]&&(c+=d[2]+":"+g+";")}return c}function d(b,a,c,e){return a+a+c+c+e+e}function c(b,a){var e=[b],d=a.derivedStyles;Object.keys(d).forEach(function(b){b=c(b,d[b]);e=e.concat(b)});return e}function h(b, a,e,d){function f(a,c){var e=[],d;a.forEach(function(b){h.forEach(function(a){e.push("draw|page[webodfhelper|page-style-name='"+a+"'] draw|frame[presentation|class='"+b+"']")})});0v&&(b=v);for(c=Math.floor(b/a)*a;!e&&0<=c;)e=g[c],c-=a;for(e=e||y;e.nextBookmark&&e.nextBookmark.steps<= b;)d.check(),e=e.nextBookmark;runtime.assert(-1===b||e.steps<=b,"Bookmark @"+q(e)+" at step "+e.steps+" exceeds requested step of "+b);return e}function b(b){b.previousBookmark&&(b.previousBookmark.nextBookmark=b.nextBookmark);b.nextBookmark&&(b.nextBookmark.previousBookmark=b.previousBookmark)}function e(b){for(var a,c=null;!c&&b&&b!==k;)(a=m(b))&&(c=u[a])&&c.node!==b&&(runtime.log("Cloned node detected. Creating new bookmark"),c=null,b.removeAttributeNS(n,"nodeId")),b=b.parentNode;return c}var n= "urn:webodf:names:steps",g={},u={},t=core.DomUtils,y,v,s=Node.DOCUMENT_POSITION_FOLLOWING,x=Node.DOCUMENT_POSITION_PRECEDING,w;this.updateBookmark=function(e,d){var f,h=Math.ceil(e/a)*a,n,p,q;if(void 0!==v&&vn.steps)g[h]=p;w()};this.setToClosestStep=function(b,a){var c;w();c=r(b);c.setIteratorPosition(a); return c.steps};this.setToClosestDomPoint=function(b,a,c){var d,f;w();if(b===k&&0===a)d=y;else if(b===k&&a===k.childNodes.length)for(f in d=y,g)g.hasOwnProperty(f)&&(b=g[f],b.steps>d.steps&&(d=b));else if(d=e(b.childNodes.item(a)||b),!d)for(c.setUnfilteredPosition(b,a);!d&&c.previousNode();)d=e(c.getCurrentNode());d=d||y;void 0!==v&&d.steps>v&&(d=r(v));d.setIteratorPosition(c);return d.steps};this.damageCacheAfterStep=function(b){0>b&&(b=-1);void 0===v?v=b:bb)throw new RangeError("Requested steps is negative ("+ b+")");q();for(d=l.setToClosestStep(b,e);db.comparePoints(m,0,d,g),d=m,g=g?0:m.childNodes.length);e.setUnfilteredPosition(d,g);p(e,f)||e.setUnfilteredPosition(d,g);f=e.container();g=e.unfilteredDomOffset(); d=l.setToClosestDomPoint(f,g,e);if(0>b.comparePoints(e.container(),e.unfilteredDomOffset(),f,g))return 0=l.textNode.length?null:l.textNode.splitText(l.offset));for(e=l.textNode;e!==b;){e=e.parentNode;n=e.cloneNode(!1);g&&n.appendChild(g);if(u)for(;u&&u.nextSibling;)n.appendChild(u.nextSibling);else for(;e.firstChild;)n.appendChild(e.firstChild);e.parentNode.insertBefore(n,e.nextSibling);u=e;g=n}q.isListItem(g)&&(g=g.childNodes.item(0));h?g.setAttributeNS(p,"text:style-name",h):g.removeAttributeNS(p,"style-name");0===l.textNode.length&& l.textNode.parentNode.removeChild(l.textNode);a.emit(ops.OdtDocument.signalStepsInserted,{position:d});t&&c&&(a.moveCursor(f,d+1,0),a.emit(ops.Document.signalCursorMoved,t));a.fixCursorPositions();a.getOdfCanvas().refreshSize();a.emit(ops.OdtDocument.signalParagraphChanged,{paragraphElement:r,memberId:f,timeStamp:k});a.emit(ops.OdtDocument.signalParagraphChanged,{paragraphElement:g,memberId:f,timeStamp:k});a.getOdfCanvas().rerenderAnnotations();return!0};this.spec=function(){return{optype:"SplitParagraph", memberid:f,timestamp:k,position:d,sourceParagraphPosition:a,paragraphStyleName:h,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=h.width&&(h=null),f.detach();else if(k.isCharacterElement(c.container)||k.isCharacterFrame(c.container))h=d.getBoundingClientRect(c.container); return h}var k=odf.OdfUtils,a=new odf.StepUtils,d=core.DomUtils,c=core.StepDirection.NEXT,h=gui.StepInfo.VisualDirection.LEFT_TO_RIGHT,q=gui.StepInfo.VisualDirection.RIGHT_TO_LEFT;this.getContentRect=f;this.moveToFilteredStep=function(a,d,k){function r(b,a){a.process(v,g,u)&&(b=!0,!t&&a.token&&(t=a.token));return b}var b=d===c,e,n,g,u,t,y=a.snapshot();e=!1;var v;do e=f(a),v={token:a.snapshot(),container:a.container,offset:a.offset,direction:d,visualDirection:d===c?h:q},n=a.nextStep()?f(a):null,a.restore(v.token), b?(g=e,u=n):(g=n,u=e),e=k.reduce(r,!1);while(!e&&a.advanceStep(d));e||k.forEach(function(b){!t&&b.token&&(t=b.token)});a.restore(t||y);return Boolean(t)}};gui.Caret=function(f,k,a,d){function c(){r.style.opacity="0"===r.style.opacity?"1":"0";x.trigger()}function h(){g.selectNodeContents(n);return g.getBoundingClientRect()}function q(){Object.keys(C).forEach(function(b){F[b]=C[b]})}function p(){if(!1===C.isShown||f.getSelectionType()!==ops.OdtCursor.RangeSelection||!d&&!f.getSelectedRange().collapsed)C.visibility="hidden",r.style.visibility="hidden",x.cancel();else if(C.visibility="visible",r.style.visibility="visible",!1===C.isFocused)r.style.opacity= "1",x.cancel();else{if(w||F.visibility!==C.visibility)r.style.opacity="1",x.cancel();x.trigger()}if(I||B){var a;a=f.getNode();var c,g,n=t.getBoundingClientRect(u.getSizer()),m=!1,p=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});l.style.height=a.height+"px";l.style.top=a.top+"px";l.style.left=a.right- a.width+"px";l.style.width=a.width?a.width+"px":"";e&&(a=runtime.getWindow().getComputedStyle(f.getNode(),null),a.font?e.style.font=a.font:(e.style.fontStyle=a.fontStyle,e.style.fontVariant=a.fontVariant,e.style.fontWeight=a.fontWeight,e.style.fontSize=a.fontSize,e.style.lineHeight=a.lineHeight,e.style.fontFamily=a.fontFamily))}C.isShown&&B&&k.scrollIntoView(r.getBoundingClientRect());F.isFocused!==C.isFocused&&b.markAsFocussed(C.isFocused);q();I=B=w=!1}function m(b){l.parentNode.removeChild(l);n.parentNode.removeChild(n); b()}var l,r,b,e,n,g,u=f.getDocument().getCanvas(),t=core.DomUtils,y=new gui.GuiStepUtils,v,s,x,w=!1,B=!1,I=!1,C={isFocused:!1,isShown:!0,visibility:"hidden"},F={isFocused:!C.isFocused,isShown:!C.isShown,visibility:"hidden"};this.handleUpdate=function(){I=!0;s.trigger()};this.refreshCursorBlinking=function(){w=!0;s.trigger()};this.setFocus=function(){C.isFocused=!0;s.trigger()};this.removeFocus=function(){C.isFocused=!1;s.trigger()};this.show=function(){C.isShown=!0;s.trigger()};this.hide=function(){C.isShown= !1;s.trigger()};this.setAvatarImageUrl=function(a){b.setImageUrl(a)};this.setColor=function(a){r.style.borderColor=a;b.setColor(a)};this.getCursor=function(){return f};this.getFocusElement=function(){return r};this.toggleHandleVisibility=function(){b.isVisible()?b.hide():b.show()};this.showHandle=function(){b.show()};this.hideHandle=function(){b.hide()};this.setOverlayElement=function(b){e=b;l.appendChild(b);I=!0;s.trigger()};this.ensureVisible=function(){B=!0;s.trigger()};this.getBoundingClientRect= function(){return t.getBoundingClientRect(l)};this.destroy=function(a){core.Async.destroyAll([s.destroy,x.destroy,b.destroy,m],a)};(function(){var e=f.getDocument(),d=[e.createRootFilter(f.getMemberId()),e.getPositionFilter()],h=e.getDOMDocument();g=h.createRange();n=h.createElement("span");n.className="webodf-caretSizer";n.textContent="|";f.getNode().appendChild(n);l=h.createElement("div");l.setAttributeNS("urn:webodf:names:editinfo","editinfo:memberid",f.getMemberId());l.className="webodf-caretOverlay"; r=h.createElement("div");r.className="caret";l.appendChild(r);b=new gui.Avatar(l,a);u.getSizer().appendChild(l);v=e.createStepIterator(f.getNode(),0,d,e.getRootNode());s=core.Task.createRedrawTask(p);x=core.Task.createTimeoutTask(c,500);s.triggerImmediate()})()};odf.TextSerializer=function(){function f(d){var c="",h=k.filter?k.filter.acceptNode(d):NodeFilter.FILTER_ACCEPT,q=d.nodeType,p;if((h===NodeFilter.FILTER_ACCEPT||h===NodeFilter.FILTER_SKIP)&&a.isTextContentContainingNode(d))for(p=d.firstChild;p;)c+=f(p),p=p.nextSibling;h===NodeFilter.FILTER_ACCEPT&&(q===Node.ELEMENT_NODE&&a.isParagraph(d)?c+="\n":q===Node.TEXT_NODE&&d.textContent&&(c+=d.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 d;d=a.startContainer.ownerDocument.createElement("span");d.appendChild(a.cloneContents());d=f.writeToString(d);try{k.setData("text/plain",d)}catch(c){k.setData("Text",d)}};f=new odf.TextSerializer;f.filter=new odf.OdfNodeFilter};gui.Clipboard=function(f){this.setDataFromRange=function(k,a){var d,c=k.clipboardData;d=runtime.getWindow();!c&&d&&(c=d.clipboardData);c?(d=!0,f.exportRangeToDataTransfer(c,a),k.preventDefault()):d=!1;return d}};gui.SessionContext=function(f,k){var a=f.getOdtDocument(),d=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=d.getParentAnnotation(f,a.getRootNode()))&&d.getAnnotationCreator(f)===c?!0:!1}};gui.StyleSummary=function(f){function k(a,d){var k=a+"|"+d,m;c.hasOwnProperty(k)||(m=[],f.forEach(function(c){c=(c=c.styleProperties[a])&&c[d];-1===m.indexOf(c)&&m.push(c)}),c[k]=m);return c[k]}function a(a,c,d){return function(){var f=k(a,c);return d.length>=f.length&&f.every(function(a){return-1!==d.indexOf(a)})}}function d(a,c){var d=k(a,c);return 1===d.length?d[0]:void 0}var c={};this.getPropertyValues=k;this.getCommonValue=d;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=d("style:text-properties","fo:font-size");return a&&parseFloat(a)};this.fontName=function(){return d("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,d,c,h,q){function p(){return V.value().styleSummary}function m(){return V.value().enabledFeatures}function l(b){var a;b.collapsed?(a=b.startContainer,a.hasChildNodes()&&b.startOffsetb.clientWidth||b.scrollHeight>b.clientHeight)&&a.push(new r(b)),b=b.parentNode;a.push(new l(s));return a}function v(){var b; g()||(b=y(C),t(),C.focus(),b.forEach(function(b){b.restore()}))}var s=runtime.getWindow(),x={beforecut:!0,beforepaste:!0,longpress:!0,drag:!0,dragstop:!0},w={mousedown:!0,mouseup:!0,focus:!0},B={},I={},C,F=f.getCanvas().getElement(),J=this,N={};this.addFilter=function(a,c){b(a,!0).filters.push(c)};this.removeFilter=function(a,c){var e=b(a,!0),d=e.filters.indexOf(c);-1!==d&&e.filters.splice(d,1)};this.subscribe=e;this.unsubscribe=n;this.hasFocus=g;this.focus=v;this.getEventTrap=function(){return C}; this.setEditing=function(b){var a=g();a&&C.blur();b?C.removeAttribute("readOnly"):C.setAttribute("readOnly","true");a&&v()};this.destroy=function(b){n("touchstart",m);Object.keys(N).forEach(function(b){d(parseInt(b,10))});N.length=0;Object.keys(B).forEach(function(b){B[b].destroy()});B={};n("mousedown",u);n("mouseup",t);n("contextmenu",t);Object.keys(I).forEach(function(b){I[b].destroy()});I={};C.parentNode.removeChild(C);b()};(function(){var b=f.getOdfCanvas().getSizer(),c=b.ownerDocument;runtime.assert(Boolean(s), "EventManager requires a window object to operate correctly");C=c.createElement("textarea");C.id="eventTrap";C.setAttribute("tabindex","-1");C.setAttribute("readOnly","true");C.setAttribute("rows","1");b.appendChild(C);e("mousedown",u);e("mouseup",t);e("contextmenu",t);B.longpress=new a("longpress",["touchstart","touchmove","touchend"],h);B.drag=new a("drag",["touchstart","touchmove","touchend"],q);B.dragstop=new a("dragstop",["drag","touchend"],p);e("touchstart",m)})()};gui.IOSSafariSupport=function(f){function k(){a.innerHeight!==a.outerHeight&&(d.style.display="none",runtime.requestAnimationFrame(function(){d.style.display="block"}))}var a=runtime.getWindow(),d=f.getEventTrap();this.destroy=function(a){f.unsubscribe("focus",k);d.removeAttribute("autocapitalize");d.style.WebkitTransform="";a()};f.subscribe("focus",k);d.setAttribute("autocapitalize","off");d.style.WebkitTransform="translateX(-10000px)"};gui.HyperlinkController=function(f,k,a,d){function c(){var c=!0;!0===k.getState(gui.CommonConstraints.EDIT.REVIEW_MODE)&&(c=a.isLocalCursorWithinOwnAnnotation());c!==l&&(l=c,m.emit(gui.HyperlinkController.enabledChanged,l))}function h(a){a.getMemberId()===d&&c()}var q=odf.OdfUtils,p=f.getOdtDocument(),m=new core.EventNotifier([gui.HyperlinkController.enabledChanged]),l=!1;this.isEnabled=function(){return l};this.subscribe=function(a,b){m.subscribe(a,b)};this.unsubscribe=function(a,b){m.unsubscribe(a, b)};this.addHyperlink=function(a,b){if(l){var c=p.getCursorSelection(d),h=new ops.OpApplyHyperlink,g=[];if(0===c.length||b)b=b||a,h=new ops.OpInsertText,h.init({memberid:d,position:c.position,text:b}),c.length=b.length,g.push(h);h=new ops.OpApplyHyperlink;h.init({memberid:d,position:c.position,length:c.length,hyperlink:a});g.push(h);f.enqueue(g)}};this.removeHyperlinks=function(){if(l){var a=p.createPositionIterator(p.getRootNode()),b=p.getCursor(d).getSelectedRange(),c=q.getHyperlinkElements(b), h=b.collapsed&&1===c.length,g=p.getDOMDocument().createRange(),k=[],m,y;0!==c.length&&(c.forEach(function(b){g.selectNodeContents(b);m=p.convertDomToCursorRange({anchorNode:g.startContainer,anchorOffset:g.startOffset,focusNode:g.endContainer,focusOffset:g.endOffset});y=new ops.OpRemoveHyperlink;y.init({memberid:d,position:m.position,length:m.length});k.push(y)}),h||(h=c[0],-1===b.comparePoint(h,0)&&(g.setStart(h,0),g.setEnd(b.startContainer,b.startOffset),m=p.convertDomToCursorRange({anchorNode:g.startContainer, anchorOffset:g.startOffset,focusNode:g.endContainer,focusOffset:g.endOffset}),0h.width&&(q=h.width/k.width);k.height>h.height&&(s=h.height/k.height);h=Math.min(q,s);k={width:k.width*h,height:k.height* h}}h=k.width+"px";k=k.height+"px";var x=l.getOdfCanvas().odfContainer().rootElement.styles,q=a.toLowerCase(),s=p.hasOwnProperty(q)?p[q]:null,w,q=[];runtime.assert(null!==s,"Image type is not supported: "+a);s="Pictures/"+c.generateImageName()+s;w=new ops.OpSetBlob;w.init({memberid:d,filename:s,mimetype:a,content:e});q.push(w);b.getStyleElement("Graphics","graphic",[x])||(a=new ops.OpAddStyle,a.init({memberid:d,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"}}}),q.push(a));a=c.generateStyleName();e=new ops.OpAddStyle;e.init({memberid:d,styleName:a,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"}}});q.push(e);w=new ops.OpInsertImage;w.init({memberid:d,position:l.getCursorPosition(d), filename:s,frameWidth:h,frameHeight:k,frameStyleName:a,frameName:c.generateFrameName()});q.push(w);f.enqueue(q)}};this.destroy=function(b){l.unsubscribe(ops.Document.signalCursorMoved,q);k.unsubscribe(gui.CommonConstraints.EDIT.REVIEW_MODE,h);b()};l.subscribe(ops.Document.signalCursorMoved,q);k.subscribe(gui.CommonConstraints.EDIT.REVIEW_MODE,h);h()};gui.ImageController.enabledChanged="enabled/changed";gui.ImageSelector=function(f){function k(){var a=f.getSizer(),h=c.createElement("div");h.id="imageSelector";h.style.borderWidth="1px";a.appendChild(h);d.forEach(function(a){var d=c.createElement("div");d.className=a;h.appendChild(d)});return h}var a=odf.Namespaces.svgns,d="topLeft topRight bottomRight bottomLeft topMiddle rightMiddle bottomMiddle leftMiddle".split(" "),c=f.getElement().ownerDocument,h=!1;this.select=function(d){var p,m,l=c.getElementById("imageSelector");l||(l=k());h=!0;p=l.parentNode; m=d.getBoundingClientRect();var r=p.getBoundingClientRect(),b=f.getZoomLevel();p=(m.left-r.left)/b-1;m=(m.top-r.top)/b-1;l.style.display="block";l.style.left=p+"px";l.style.top=m+"px";l.style.width=d.getAttributeNS(a,"width");l.style.height=d.getAttributeNS(a,"height")};this.clearSelection=function(){var a;h&&(a=c.getElementById("imageSelector"))&&(a.style.display="none");h=!1};this.isSelectorElement=function(a){var d=c.getElementById("imageSelector");return d?a===d||a.parentNode===d:!1}};(function(){function f(f){function a(a){q=a.which&&String.fromCharCode(a.which)===h;h=void 0;return!1===q}function d(){q=!1}function c(a){h=a.data;q=!1}var h,q=!1;this.destroy=function(h){f.unsubscribe("textInput",d);f.unsubscribe("compositionend",c);f.removeFilter("keypress",a);h()};f.subscribe("textInput",d);f.subscribe("compositionend",c);f.addFilter("keypress",a)}gui.InputMethodEditor=function(k,a){function d(a){e&&(a?e.getNode().setAttributeNS(b,"composing","true"):(e.getNode().removeAttributeNS(b, "composing"),u.textContent=""))}function c(){y&&(y=!1,d(!1),s.emit(gui.InputMethodEditor.signalCompositionEnd,{data:v}),v="")}function h(){C||(C=!0,c(),e&&e.getSelectedRange().collapsed?n.value="":n.value=w.writeToString(e.getSelectedRange().cloneContents()),n.setSelectionRange(0,n.value.length),C=!1)}function q(){a.hasFocus()&&t.trigger()}function p(){x=void 0;t.cancel();d(!0);y||s.emit(gui.InputMethodEditor.signalCompositionStart,{data:""})}function m(b){b=x=b.data;y=!0;v+=b;t.trigger()}function l(b){b.data!== x&&(b=b.data,y=!0,v+=b,t.trigger());x=void 0}function r(){u.textContent=n.value}var b="urn:webodf:names:cursor",e=null,n=a.getEventTrap(),g=n.ownerDocument,u,t,y=!1,v="",s=new core.EventNotifier([gui.InputMethodEditor.signalCompositionStart,gui.InputMethodEditor.signalCompositionEnd]),x,w,B=[],I,C=!1;this.subscribe=s.subscribe;this.unsubscribe=s.unsubscribe;this.registerCursor=function(b){b.getMemberId()===k&&(e=b,e.getNode().appendChild(u),b.subscribe(ops.OdtCursor.signalCursorUpdated,q),a.subscribe("input", r),a.subscribe("compositionupdate",r))};this.removeCursor=function(b){e&&b===k&&(e.getNode().removeChild(u),e.unsubscribe(ops.OdtCursor.signalCursorUpdated,q),a.unsubscribe("input",r),a.unsubscribe("compositionupdate",r),e=null)};this.destroy=function(b){a.unsubscribe("compositionstart",p);a.unsubscribe("compositionend",m);a.unsubscribe("textInput",l);a.unsubscribe("keypress",c);a.unsubscribe("focus",h);core.Async.destroyAll(I,b)};(function(){w=new odf.TextSerializer;w.filter=new odf.OdfNodeFilter; a.subscribe("compositionstart",p);a.subscribe("compositionend",m);a.subscribe("textInput",l);a.subscribe("keypress",c);a.subscribe("focus",h);B.push(new f(a));I=B.map(function(b){return b.destroy});u=g.createElement("span");u.setAttribute("id","composer");t=core.Task.createTimeoutTask(h,1);I.push(t.destroy)})()};gui.InputMethodEditor.signalCompositionStart="input/compositionstart";gui.InputMethodEditor.signalCompositionEnd="input/compositionend"})();gui.MetadataController=function(f,k){function a(a){h.emit(gui.MetadataController.signalMetadataChanged,a)}function d(a){var c=-1===q.indexOf(a);c||runtime.log("Setting "+a+" is restricted.");return c}var c=f.getOdtDocument(),h=new core.EventNotifier([gui.MetadataController.signalMetadataChanged]),q=["dc:creator","dc:date","meta:editing-cycles","meta:editing-duration","meta:document-statistic"];this.setMetadata=function(a,c){var h={},q="",b;a&&Object.keys(a).filter(d).forEach(function(b){h[b]=a[b]}); c&&(q=c.filter(d).join(","));if(0c:!1}function a(a){null!==a&&!1===k(a)&&(c=Math.abs(a-f))}var d=this,c,h=gui.StepInfo.VisualDirection.LEFT_TO_RIGHT;this.token=void 0;this.process=function(c,f,m){var l,r;c.visualDirection===h?(l=f&&f.right,r=m&&m.left):(l=f&&f.left,r=m&&m.right);if(k(l)||k(r))return!0;if(f||m)a(l),a(r),d.token=c.token;return!1}};gui.LineBoundaryScanner=function(){var f=this,k=null;this.token=void 0;this.process=function(a,d,c){var h;if(h=c)if(k){var q=k;h=Math.min(q.bottom-q.top,c.bottom-c.top);var p=Math.max(q.top,c.top),q=Math.min(q.bottom,c.bottom)-p;h=0.4>=(0a?b.previousSibling:b.nextSibling,c(h)===NodeFilter.FILTER_ACCEPT&&(e=h),b=b.parentNode;return e}function d(b,a){var e;return null===b?n.NO_NEIGHBOUR:q.isCharacterElement(b)?n.SPACE_CHAR:b.nodeType===c||q.isTextSpan(b)||q.isHyperlink(b)?(e=b.textContent.charAt(a()),m.test(e)?n.SPACE_CHAR:p.test(e)?n.PUNCTUATION_CHAR:n.WORD_CHAR):n.OTHER}var c=Node.TEXT_NODE,h=Node.ELEMENT_NODE, q=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]/, m=/\s/,l=core.PositionFilter.FilterResult.FILTER_ACCEPT,r=core.PositionFilter.FilterResult.FILTER_REJECT,b=odf.WordBoundaryFilter.IncludeWhitespace.TRAILING,e=odf.WordBoundaryFilter.IncludeWhitespace.LEADING,n={NO_NEIGHBOUR:0,SPACE_CHAR:1,PUNCTUATION_CHAR:2,WORD_CHAR:3,OTHER:4};this.acceptPosition=function(c){var f=c.container(),m=c.leftNode(),q=c.rightNode(),p=c.unfilteredDomOffset,s=function(){return c.unfilteredDomOffset()-1};f.nodeType===h&&(null===q&&(q=a(f,1,c.getNodeFilter())),null===m&&(m= a(f,-1,c.getNodeFilter())));f!==q&&(p=function(){return 0});f!==m&&null!==m&&(s=function(){return m.textContent.length-1});f=d(m,s);q=d(q,p);return f===n.WORD_CHAR&&q===n.WORD_CHAR||f===n.PUNCTUATION_CHAR&&q===n.PUNCTUATION_CHAR||k===b&&f!==n.NO_NEIGHBOUR&&q===n.SPACE_CHAR||k===e&&f===n.SPACE_CHAR&&q!==n.NO_NEIGHBOUR?r:l}};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)I=void 0,C.cancel()}function d(){var b=t.getCursor(k).getNode();return t.createStepIterator(b,0,[s,w],t.getRootElement(b))}function c(b,a,c){c=new odf.WordBoundaryFilter(t,c);var e=t.getRootElement(b)||t.getRootNode(),d=t.createRootFilter(e);return t.createStepIterator(b,a,[s,d,c],e)}function h(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 q(b,a,c){var e=new ops.OpMoveCursor;e.init({memberid:k,position:b,length:a||0,selectionType:c});return e}function p(b,a,c){var e;e=t.getCursor(k);e=h(e.getSelectedRange(),e.hasForwardSelection());e.focusNode=b;e.focusOffset=a;c||(e.anchorNode=e.focusNode,e.anchorOffset=e.focusOffset);b=t.convertDomToCursorRange(e);f.enqueue([q(b.position,b.length)])}function m(b){var a;a=c(b.startContainer, b.startOffset,F);a.roundToPreviousStep()&&b.setStart(a.container(),a.offset());a=c(b.endContainer,b.endOffset,J);a.roundToNextStep()&&b.setEnd(a.container(),a.offset())}function l(b){var a=v.getParagraphElements(b),c=a[0],a=a[a.length-1];c&&b.setStart(c,0);a&&(v.isParagraph(b.endContainer)&&0===b.endOffset?b.setEndBefore(a):b.setEnd(a,a.childNodes.length))}function r(b,a,c,e){var d,f;e?(d=c.startContainer,f=c.startOffset):(d=c.endContainer,f=c.endOffset);y.containsNode(b,d)||(f=0>y.comparePoints(b, 0,d,f)?0:b.childNodes.length,d=b);b=t.createStepIterator(d,f,a,v.getParagraphElement(d)||b);b.roundToClosestStep()||runtime.assert(!1,"No step found in requested range");e?c.setStart(b.container(),b.offset()):c.setEnd(b.container(),b.offset())}function b(b,a){var c=d();c.advanceStep(b)&&p(c.container(),c.offset(),a)}function e(b,a){var c,e=I,f=[new gui.LineBoundaryScanner,new gui.ParagraphBoundaryScanner];void 0===e&&B&&(e=B());isNaN(e)||(c=d(),x.moveToFilteredStep(c,b,f)&&c.advanceStep(b)&&(f=[new gui.ClosestXOffsetScanner(e), new gui.LineBoundaryScanner,new gui.ParagraphBoundaryScanner],x.moveToFilteredStep(c,b,f)&&(p(c.container(),c.offset(),a),I=e,C.restart())))}function n(b,a){var c=d(),e=[new gui.LineBoundaryScanner,new gui.ParagraphBoundaryScanner];x.moveToFilteredStep(c,b,e)&&p(c.container(),c.offset(),a)}function g(b,a){var e=t.getCursor(k),e=h(e.getSelectedRange(),e.hasForwardSelection()),e=c(e.focusNode,e.focusOffset,F);e.advanceStep(b)&&p(e.container(),e.offset(),a)}function u(b,a,c){var e=!1,d=t.getCursor(k), d=h(d.getSelectedRange(),d.hasForwardSelection()),e=t.getRootElement(d.focusNode);runtime.assert(Boolean(e),"SelectionController: Cursor outside root");d=t.createStepIterator(d.focusNode,d.focusOffset,[s,w],e);d.roundToClosestStep();d.advanceStep(b)&&(c=c(d.container()))&&(b===N?(d.setPosition(c,0),e=d.roundToNextStep()):(d.setPosition(c,c.childNodes.length),e=d.roundToPreviousStep()),e&&p(d.container(),d.offset(),a))}var t=f.getOdtDocument(),y=core.DomUtils,v=odf.OdfUtils,s=t.getPositionFilter(), x=new gui.GuiStepUtils,w=t.createRootFilter(k),B=null,I,C,F=odf.WordBoundaryFilter.IncludeWhitespace.TRAILING,J=odf.WordBoundaryFilter.IncludeWhitespace.LEADING,N=core.StepDirection.PREVIOUS,K=core.StepDirection.NEXT;this.selectionToRange=function(b){var a=0<=y.comparePoints(b.anchorNode,b.anchorOffset,b.focusNode,b.focusOffset),c=b.focusNode.ownerDocument.createRange();a?(c.setStart(b.anchorNode,b.anchorOffset),c.setEnd(b.focusNode,b.focusOffset)):(c.setStart(b.focusNode,b.focusOffset),c.setEnd(b.anchorNode, b.anchorOffset));return{range:c,hasForwardSelection:a}};this.rangeToSelection=h;this.selectImage=function(b){var a=t.getRootElement(b),c=t.createRootFilter(a),a=t.createStepIterator(b,0,[c,t.getPositionFilter()],a),e;a.roundToPreviousStep()||runtime.assert(!1,"No walkable position before frame");c=a.container();e=a.offset();a.setPosition(b,b.childNodes.length);a.roundToNextStep()||runtime.assert(!1,"No walkable position after frame");b=t.convertDomToCursorRange({anchorNode:c,anchorOffset:e,focusNode:a.container(), focusOffset:a.offset()});b=q(b.position,b.length,ops.OdtCursor.RegionSelection);f.enqueue([b])};this.expandToWordBoundaries=m;this.expandToParagraphBoundaries=l;this.selectRange=function(b,a,c){var e=t.getOdfCanvas().getElement(),d,g=[s];d=y.containsNode(e,b.startContainer);e=y.containsNode(e,b.endContainer);if(d||e)if(d&&e&&(2===c?m(b):3<=c&&l(b)),(c=a?t.getRootElement(b.startContainer):t.getRootElement(b.endContainer))||(c=t.getRootNode()),g.push(t.createRootFilter(c)),r(c,g,b,!0),r(c,g,b,!1),b= h(b,a),a=t.convertDomToCursorRange(b),b=t.getCursorSelection(k),a.position!==b.position||a.length!==b.length)b=q(a.position,a.length,ops.OdtCursor.RangeSelection),f.enqueue([b])};this.moveCursorToLeft=function(){b(N,!1);return!0};this.moveCursorToRight=function(){b(K,!1);return!0};this.extendSelectionToLeft=function(){b(N,!0);return!0};this.extendSelectionToRight=function(){b(K,!0);return!0};this.setCaretXPositionLocator=function(b){B=b};this.moveCursorUp=function(){e(N,!1);return!0};this.moveCursorDown= function(){e(K,!1);return!0};this.extendSelectionUp=function(){e(N,!0);return!0};this.extendSelectionDown=function(){e(K,!0);return!0};this.moveCursorBeforeWord=function(){g(N,!1);return!0};this.moveCursorPastWord=function(){g(K,!1);return!0};this.extendSelectionBeforeWord=function(){g(N,!0);return!0};this.extendSelectionPastWord=function(){g(K,!0);return!0};this.moveCursorToLineStart=function(){n(N,!1);return!0};this.moveCursorToLineEnd=function(){n(K,!1);return!0};this.extendSelectionToLineStart= function(){n(N,!0);return!0};this.extendSelectionToLineEnd=function(){n(K,!0);return!0};this.extendSelectionToParagraphStart=function(){u(N,!0,v.getParagraphElement);return!0};this.extendSelectionToParagraphEnd=function(){u(K,!0,v.getParagraphElement);return!0};this.moveCursorToParagraphStart=function(){u(N,!1,v.getParagraphElement);return!0};this.moveCursorToParagraphEnd=function(){u(K,!1,v.getParagraphElement);return!0};this.moveCursorToDocumentStart=function(){u(N,!1,t.getRootElement);return!0}; this.moveCursorToDocumentEnd=function(){u(K,!1,t.getRootElement);return!0};this.extendSelectionToDocumentStart=function(){u(N,!0,t.getRootElement);return!0};this.extendSelectionToDocumentEnd=function(){u(K,!0,t.getRootElement);return!0};this.extendSelectionToEntireDocument=function(){var b=t.getCursor(k),b=t.getRootElement(b.getNode()),a,c,e;runtime.assert(Boolean(b),"SelectionController: Cursor outside root");e=t.createStepIterator(b,0,[s,w],b);e.roundToClosestStep();a=e.container();c=e.offset(); e.setPosition(b,b.childNodes.length);e.roundToClosestStep();b=t.convertDomToCursorRange({anchorNode:a,anchorOffset:c,focusNode:e.container(),focusOffset:e.offset()});f.enqueue([q(b.position,b.length)]);return!0};this.destroy=function(b){t.unsubscribe(ops.OdtDocument.signalOperationStart,a);core.Async.destroyAll([C.destroy],b)};(function(){C=core.Task.createTimeoutTask(function(){I=void 0},2E3);t.subscribe(ops.OdtDocument.signalOperationStart,a)})()};gui.TextController=function(f,k,a,d,c,h){function q(){u=!0===k.getState(gui.CommonConstraints.EDIT.REVIEW_MODE)?a.isLocalCursorWithinOwnAnnotation():!0}function p(b){b.getMemberId()===d&&q()}function m(b,a,c){var d=[e.getPositionFilter()];c&&d.push(e.createRootFilter(b.startContainer));c=e.createStepIterator(b.startContainer,b.startOffset,d,a);c.roundToClosestStep()||runtime.assert(!1,"No walkable step found in paragraph element at range start");a=e.convertDomPointToCursorStep(c.container(),c.offset()); b.collapsed?b=a:(c.setPosition(b.endContainer,b.endOffset),c.roundToClosestStep()||runtime.assert(!1,"No walkable step found in paragraph element at range end"),b=e.convertDomPointToCursorStep(c.container(),c.offset()));return{position:a,length:b-a}}function l(b){var a,c,e,f=n.getParagraphElements(b),h=b.cloneRange(),k=[];a=f[0];1b.length&&(b.position+=b.length,b.length=-b.length);return b}function b(b){if(!u)return!1;var a,c=e.getCursor(d).getSelectedRange().cloneRange(), g=r(e.getCursorSelection(d)),h;if(0===g.length){g=void 0;a=e.getCursor(d).getNode();h=e.getRootElement(a);var k=[e.getPositionFilter(),e.createRootFilter(h)];h=e.createStepIterator(a,0,k,h);h.roundToClosestStep()&&(b?h.nextStep():h.previousStep())&&(g=r(e.convertDomToCursorRange({anchorNode:a,anchorOffset:0,focusNode:h.container(),focusOffset:h.offset()})),b?(c.setStart(a,0),c.setEnd(h.container(),h.offset())):(c.setStart(h.container(),h.offset()),c.setEnd(a,0)))}g&&f.enqueue(l(c));return void 0!== g}var e=f.getOdtDocument(),n=odf.OdfUtils,g=core.DomUtils,u=!1,t=odf.Namespaces.textns,y=core.StepDirection.NEXT;this.isEnabled=function(){return u};this.enqueueParagraphSplittingOps=function(){if(!u)return!1;var b=e.getCursor(d),a=b.getSelectedRange(),c=r(e.getCursorSelection(d)),g=[],b=n.getParagraphElement(b.getNode()),k=b.getAttributeNS(t,"style-name")||"";0e.left&&(e=x(d)))a.focusNode=e.container,a.focusOffset=e.offset,c&&(a.anchorNode=a.focusNode,a.anchorOffset=a.focusOffset)}else D.isImage(a.focusNode.firstChild)&&1===a.focusOffset&&D.isCharacterFrame(a.focusNode)&&(e=x(a.focusNode))&&(a.anchorNode=a.focusNode=e.container,a.anchorOffset=a.focusOffset=e.offset);a.anchorNode&&a.focusNode&&(a=W.selectionToRange(a),W.selectRange(a.range,a.hasForwardSelection,0===b.button?b.detail:0));M.focus()}function B(b){var a;if(a=q(b.clientX,b.clientY))b= a.container,a=a.offset,b={anchorNode:b,anchorOffset:a,focusNode:b,focusOffset:a},b=W.selectionToRange(b),W.selectRange(b.range,b.hasForwardSelection,2),M.focus()}function I(b){var a=h(b),c,e,f;la.processRequests();Y&&(D.isImage(a)&&D.isCharacterFrame(a.parentNode)&&T.getSelection().isCollapsed?(W.selectImage(a.parentNode),M.focus()):ka.isSelectorElement(a)?M.focus():X?(a=d.getSelectedRange(),e=a.collapsed,D.isImage(a.endContainer)&&0===a.endOffset&&D.isCharacterFrame(a.endContainer.parentNode)&&(f= a.endContainer.parentNode,f=x(f))&&(a.setEnd(f.container,f.offset),e&&a.collapse(!1)),W.selectRange(a,d.hasForwardSelection(),0===b.button?b.detail:0),M.focus()):ta?w(b):(c=P.cloneEvent(b),da=runtime.setTimeout(function(){w(c)},0)),na=0,X=Y=!1)}function C(b){var c=G.getCursor(a).getSelectedRange();c.collapsed||Q.exportRangeToDataTransfer(b.dataTransfer,c)}function F(){Y&&M.focus();na=0;X=Y=!1}function J(b){I(b)}function N(b){var a=h(b),c=null;"annotationRemoveButton"===a.className?(runtime.assert(ea, "Remove buttons are displayed on annotations while annotation editing is disabled in the controller."),c=a.parentNode.getElementsByTagNameNS(odf.Namespaces.officens,"annotation").item(0),ha.removeAnnotation(c),M.focus()):"webodf-draggable"!==a.getAttribute("class")&&I(b)}function K(b){(b=b.data)&&(-1===b.indexOf("\n")?fa.insertText(b):ga.paste(b))}function H(b){return function(){b();return!0}}function z(b){return function(c){return G.getCursor(a).getSelectionType()===ops.OdtCursor.RangeSelection? b(c):!0}}function Z(b){M.unsubscribe("keydown",A.handleEvent);M.unsubscribe("keypress",V.handleEvent);M.unsubscribe("keyup",ba.handleEvent);M.unsubscribe("copy",l);M.unsubscribe("mousedown",s);M.unsubscribe("mousemove",la.trigger);M.unsubscribe("mouseup",N);M.unsubscribe("contextmenu",J);M.unsubscribe("dragstart",C);M.unsubscribe("dragend",F);M.unsubscribe("click",oa.handleClick);M.unsubscribe("longpress",B);M.unsubscribe("drag",t);M.unsubscribe("dragstop",y);G.unsubscribe(ops.OdtDocument.signalOperationEnd, ma.trigger);G.unsubscribe(ops.Document.signalCursorAdded,ja.registerCursor);G.unsubscribe(ops.Document.signalCursorRemoved,ja.removeCursor);G.unsubscribe(ops.OdtDocument.signalOperationEnd,e);b()}var T=runtime.getWindow(),G=k.getOdtDocument(),U=new gui.SessionConstraints,aa=new gui.SessionContext(k,a),P=core.DomUtils,D=odf.OdfUtils,Q=new gui.MimeDataExporter,$=new gui.Clipboard(Q),A=new gui.KeyboardHandler,V=new gui.KeyboardHandler,ba=new gui.KeyboardHandler,Y=!1,E=new odf.ObjectNameGenerator(G.getOdfCanvas().odfContainer(), a),X=!1,R=null,da,S=null,M=new gui.EventManager(G),ea=c.annotationsEnabled,ha=new gui.AnnotationController(k,U,a),ca=new gui.DirectFormattingController(k,U,aa,a,E,c.directTextStylingEnabled,c.directParagraphStylingEnabled),fa=new gui.TextController(k,U,aa,a,ca.createCursorStyleOp,ca.createParagraphStyleOps),pa=new gui.ImageController(k,U,aa,a,E),ka=new gui.ImageSelector(G.getOdfCanvas()),ia=G.createPositionIterator(G.getRootNode()),la,ma,ga=new gui.PasteController(k,U,aa,a),ja=new gui.InputMethodEditor(a, M),na=0,oa=new gui.HyperlinkClickHandler(G.getOdfCanvas().getElement,A,ba),sa=new gui.HyperlinkController(k,U,aa,a),W=new gui.SelectionController(k,a),ua=new gui.MetadataController(k,a),L=gui.KeyboardHandler.Modifier,O=gui.KeyboardHandler.KeyCode,qa=-1!==T.navigator.appVersion.toLowerCase().indexOf("mac"),ta=-1!==["iPad","iPod","iPhone"].indexOf(T.navigator.platform),ra;runtime.assert(null!==T,"Expected to be run in an environment which has a global window, like a browser.");this.undo=g;this.redo= u;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]);M.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(){ja.subscribe(gui.InputMethodEditor.signalCompositionStart,fa.removeCurrentSelection); ja.subscribe(gui.InputMethodEditor.signalCompositionEnd,K);M.subscribe("beforecut",m);M.subscribe("cut",p);M.subscribe("beforepaste",b);M.subscribe("paste",r);S&&S.initialize();M.setEditing(!0);oa.setModifier(qa?L.Meta:L.Ctrl);A.bind(O.Backspace,L.None,H(fa.removeTextByBackspaceKey),!0);A.bind(O.Delete,L.None,fa.removeTextByDeleteKey);A.bind(O.Tab,L.None,z(function(){fa.insertText("\t");return!0}));qa?(A.bind(O.Clear,L.None,fa.removeCurrentSelection),A.bind(O.B,L.Meta,z(ca.toggleBold)),A.bind(O.I, L.Meta,z(ca.toggleItalic)),A.bind(O.U,L.Meta,z(ca.toggleUnderline)),A.bind(O.L,L.MetaShift,z(ca.alignParagraphLeft)),A.bind(O.E,L.MetaShift,z(ca.alignParagraphCenter)),A.bind(O.R,L.MetaShift,z(ca.alignParagraphRight)),A.bind(O.J,L.MetaShift,z(ca.alignParagraphJustified)),ea&&A.bind(O.C,L.MetaShift,ha.addAnnotation),A.bind(O.Z,L.Meta,g),A.bind(O.Z,L.MetaShift,u)):(A.bind(O.B,L.Ctrl,z(ca.toggleBold)),A.bind(O.I,L.Ctrl,z(ca.toggleItalic)),A.bind(O.U,L.Ctrl,z(ca.toggleUnderline)),A.bind(O.L,L.CtrlShift, z(ca.alignParagraphLeft)),A.bind(O.E,L.CtrlShift,z(ca.alignParagraphCenter)),A.bind(O.R,L.CtrlShift,z(ca.alignParagraphRight)),A.bind(O.J,L.CtrlShift,z(ca.alignParagraphJustified)),ea&&A.bind(O.C,L.CtrlAlt,ha.addAnnotation),A.bind(O.Z,L.Ctrl,g),A.bind(O.Z,L.CtrlShift,u));V.setDefault(z(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:(fa.insertText(a),!0)})); V.bind(O.Enter,L.None,z(fa.enqueueParagraphSplittingOps))};this.endEditing=function(){ja.unsubscribe(gui.InputMethodEditor.signalCompositionStart,fa.removeCurrentSelection);ja.unsubscribe(gui.InputMethodEditor.signalCompositionEnd,K);M.unsubscribe("cut",p);M.unsubscribe("beforecut",m);M.unsubscribe("paste",r);M.unsubscribe("beforepaste",b);M.setEditing(!1);oa.setModifier(L.None);A.bind(O.Backspace,L.None,function(){return!0},!0);A.unbind(O.Delete,L.None);A.unbind(O.Tab,L.None);qa?(A.unbind(O.Clear, L.None),A.unbind(O.B,L.Meta),A.unbind(O.I,L.Meta),A.unbind(O.U,L.Meta),A.unbind(O.L,L.MetaShift),A.unbind(O.E,L.MetaShift),A.unbind(O.R,L.MetaShift),A.unbind(O.J,L.MetaShift),ea&&A.unbind(O.C,L.MetaShift),A.unbind(O.Z,L.Meta),A.unbind(O.Z,L.MetaShift)):(A.unbind(O.B,L.Ctrl),A.unbind(O.I,L.Ctrl),A.unbind(O.U,L.Ctrl),A.unbind(O.L,L.CtrlShift),A.unbind(O.E,L.CtrlShift),A.unbind(O.R,L.CtrlShift),A.unbind(O.J,L.CtrlShift),ea&&A.unbind(O.C,L.CtrlAlt),A.unbind(O.Z,L.Ctrl),A.unbind(O.Z,L.CtrlShift));V.setDefault(null); V.unbind(O.Enter,L.None)};this.getInputMemberId=function(){return a};this.getSession=function(){return k};this.getSessionConstraints=function(){return U};this.setUndoManager=function(b){S&&S.unsubscribe(gui.UndoManager.signalUndoStackChanged,n);if(S=b)S.setDocument(G),S.setPlaybackFunction(k.enqueue),S.subscribe(gui.UndoManager.signalUndoStackChanged,n)};this.getUndoManager=function(){return S};this.getMetadataController=function(){return ua};this.getAnnotationController=function(){return ha};this.getDirectFormattingController= function(){return ca};this.getHyperlinkClickHandler=function(){return oa};this.getHyperlinkController=function(){return sa};this.getImageController=function(){return pa};this.getSelectionController=function(){return W};this.getTextController=function(){return fa};this.getEventManager=function(){return M};this.getKeyboardHandlers=function(){return{keydown:A,keypress:V}};this.destroy=function(b){var a=[la.destroy,ma.destroy,ca.destroy,ja.destroy,M.destroy,oa.destroy,sa.destroy,ua.destroy,W.destroy, fa.destroy,Z];ra&&a.unshift(ra.destroy);runtime.clearTimeout(da);core.Async.destroyAll(a,b)};la=core.Task.createRedrawTask(v);ma=core.Task.createRedrawTask(function(){var b=G.getCursor(a);if(b&&b.getSelectionType()===ops.OdtCursor.RegionSelection&&(b=D.getImageElements(b.getSelectedRange())[0])){ka.select(b.parentNode);return}ka.clearSelection()});A.bind(O.Left,L.None,z(W.moveCursorToLeft));A.bind(O.Right,L.None,z(W.moveCursorToRight));A.bind(O.Up,L.None,z(W.moveCursorUp));A.bind(O.Down,L.None,z(W.moveCursorDown)); A.bind(O.Left,L.Shift,z(W.extendSelectionToLeft));A.bind(O.Right,L.Shift,z(W.extendSelectionToRight));A.bind(O.Up,L.Shift,z(W.extendSelectionUp));A.bind(O.Down,L.Shift,z(W.extendSelectionDown));A.bind(O.Home,L.None,z(W.moveCursorToLineStart));A.bind(O.End,L.None,z(W.moveCursorToLineEnd));A.bind(O.Home,L.Ctrl,z(W.moveCursorToDocumentStart));A.bind(O.End,L.Ctrl,z(W.moveCursorToDocumentEnd));A.bind(O.Home,L.Shift,z(W.extendSelectionToLineStart));A.bind(O.End,L.Shift,z(W.extendSelectionToLineEnd));A.bind(O.Up, L.CtrlShift,z(W.extendSelectionToParagraphStart));A.bind(O.Down,L.CtrlShift,z(W.extendSelectionToParagraphEnd));A.bind(O.Home,L.CtrlShift,z(W.extendSelectionToDocumentStart));A.bind(O.End,L.CtrlShift,z(W.extendSelectionToDocumentEnd));qa?(A.bind(O.Left,L.Alt,z(W.moveCursorBeforeWord)),A.bind(O.Right,L.Alt,z(W.moveCursorPastWord)),A.bind(O.Left,L.Meta,z(W.moveCursorToLineStart)),A.bind(O.Right,L.Meta,z(W.moveCursorToLineEnd)),A.bind(O.Home,L.Meta,z(W.moveCursorToDocumentStart)),A.bind(O.End,L.Meta, z(W.moveCursorToDocumentEnd)),A.bind(O.Left,L.AltShift,z(W.extendSelectionBeforeWord)),A.bind(O.Right,L.AltShift,z(W.extendSelectionPastWord)),A.bind(O.Left,L.MetaShift,z(W.extendSelectionToLineStart)),A.bind(O.Right,L.MetaShift,z(W.extendSelectionToLineEnd)),A.bind(O.Up,L.AltShift,z(W.extendSelectionToParagraphStart)),A.bind(O.Down,L.AltShift,z(W.extendSelectionToParagraphEnd)),A.bind(O.Up,L.MetaShift,z(W.extendSelectionToDocumentStart)),A.bind(O.Down,L.MetaShift,z(W.extendSelectionToDocumentEnd)), A.bind(O.A,L.Meta,z(W.extendSelectionToEntireDocument))):(A.bind(O.Left,L.Ctrl,z(W.moveCursorBeforeWord)),A.bind(O.Right,L.Ctrl,z(W.moveCursorPastWord)),A.bind(O.Left,L.CtrlShift,z(W.extendSelectionBeforeWord)),A.bind(O.Right,L.CtrlShift,z(W.extendSelectionPastWord)),A.bind(O.A,L.Ctrl,z(W.extendSelectionToEntireDocument)));ta&&(ra=new gui.IOSSafariSupport(M));M.subscribe("keydown",A.handleEvent);M.subscribe("keypress",V.handleEvent);M.subscribe("keyup",ba.handleEvent);M.subscribe("copy",l);M.subscribe("mousedown", s);M.subscribe("mousemove",la.trigger);M.subscribe("mouseup",N);M.subscribe("contextmenu",J);M.subscribe("dragstart",C);M.subscribe("dragend",F);M.subscribe("click",oa.handleClick);M.subscribe("longpress",B);M.subscribe("drag",t);M.subscribe("dragstop",y);G.subscribe(ops.OdtDocument.signalOperationEnd,ma.trigger);G.subscribe(ops.Document.signalCursorAdded,ja.registerCursor);G.subscribe(ops.Document.signalCursorRemoved,ja.removeCursor);G.subscribe(ops.OdtDocument.signalOperationEnd,e)}})();gui.CaretManager=function(f,k){function a(a){return h.hasOwnProperty(a)?h[a]:null}function d(){return Object.keys(h).map(function(a){return h[a]})}function c(a){var c=h[a];c&&(delete h[a],a===f.getInputMemberId()?(p.unsubscribe(ops.OdtDocument.signalProcessingBatchEnd,c.ensureVisible),p.unsubscribe(ops.Document.signalCursorMoved,c.refreshCursorBlinking),m.unsubscribe("compositionupdate",c.handleUpdate),m.unsubscribe("compositionend",c.handleUpdate),m.unsubscribe("focus",c.setFocus),m.unsubscribe("blur", c.removeFocus),q.removeEventListener("focus",c.show,!1),q.removeEventListener("blur",c.hide,!1)):p.unsubscribe(ops.OdtDocument.signalProcessingBatchEnd,c.handleUpdate),c.destroy(function(){}))}var h={},q=runtime.getWindow(),p=f.getSession().getOdtDocument(),m=f.getEventManager();this.registerCursor=function(a,c,b){var e=a.getMemberId();a=new gui.Caret(a,k,c,b);h[e]=a;e===f.getInputMemberId()?(runtime.log("Starting to track input on new cursor of "+e),p.subscribe(ops.OdtDocument.signalProcessingBatchEnd, a.ensureVisible),p.subscribe(ops.Document.signalCursorMoved,a.refreshCursorBlinking),m.subscribe("compositionupdate",a.handleUpdate),m.subscribe("compositionend",a.handleUpdate),m.subscribe("focus",a.setFocus),m.subscribe("blur",a.removeFocus),q.addEventListener("focus",a.show,!1),q.addEventListener("blur",a.hide,!1),a.setOverlayElement(m.getEventTrap())):p.subscribe(ops.OdtDocument.signalProcessingBatchEnd,a.handleUpdate);return a};this.getCaret=a;this.getCarets=d;this.destroy=function(a){var k= d().map(function(b){return b.destroy});f.getSelectionController().setCaretXPositionLocator(null);p.unsubscribe(ops.Document.signalCursorRemoved,c);h={};core.Async.destroyAll(k,a)};f.getSelectionController().setCaretXPositionLocator(function(){var c=a(f.getInputMemberId()),d;c&&(d=c.getBoundingClientRect());return d?d.right:void 0});p.subscribe(ops.Document.signalCursorRemoved,c)};gui.EditInfoHandle=function(f){var k=[],a,d=f.ownerDocument,c=d.documentElement.namespaceURI;this.setEdits=function(f){k=f;var q,p,m,l;a.innerHTML="";for(f=0;fe?(p=a(1,0),m=a(0.5,1E4-e),l=a(0.2,2E4-e)):1E4<=e&&2E4>e?(p=a(0.5,0),l=a(0.2,2E4-e)):p=a(0.2,0)};this.getEdits=function(){return f.getEdits()};this.clearEdits= function(){f.clearEdits();h.setEdits([]);q.hasAttributeNS("urn:webodf:names:editinfo","editinfo:memberid")&&q.removeAttributeNS("urn:webodf:names:editinfo","editinfo:memberid")};this.getEditInfo=function(){return f};this.show=function(){q.style.display="block"};this.hide=function(){d.hideHandle();q.style.display="none"};this.showHandle=function(){h.show()};this.hideHandle=function(){h.hide()};this.destroy=function(a){runtime.clearTimeout(p);runtime.clearTimeout(m);runtime.clearTimeout(l);c.removeChild(q); h.destroy(function(b){b?a(b):f.destroy(a)})};(function(){var a=f.getOdtDocument().getDOMDocument();q=a.createElementNS(a.documentElement.namespaceURI,"div");q.setAttribute("class","editInfoMarker");q.onmouseover=function(){d.showHandle()};q.onmouseout=function(){d.hideHandle()};c=f.getNode();c.appendChild(q);h=new gui.EditInfoHandle(c);k||d.hide()})()};gui.HyperlinkTooltipView=function(f,k){var a=core.DomUtils,d=odf.OdfUtils,c=runtime.getWindow(),h,q,p;runtime.assert(null!==c,"Expected to be run in an environment which has a global window, like a browser.");this.showTooltip=function(m){var l=m.target||m.srcElement,r=f.getSizer(),b=f.getZoomLevel(),e;a:{for(;l;){if(d.isHyperlink(l))break a;if(d.isParagraph(l)||d.isInlineRoot(l))break;l=l.parentNode}l=null}if(l){a.containsNode(r,p)||r.appendChild(p);e=q;var n;switch(k()){case gui.KeyboardHandler.Modifier.Ctrl:n= runtime.tr("Ctrl-click to follow link");break;case gui.KeyboardHandler.Modifier.Meta:n=runtime.tr("\u2318-click to follow link");break;default:n=""}e.textContent=n;h.textContent=d.getHyperlinkTarget(l);p.style.display="block";e=c.innerWidth-p.offsetWidth-15;l=m.clientX>e?e:m.clientX+15;e=c.innerHeight-p.offsetHeight-10;m=m.clientY>e?e:m.clientY+10;r=r.getBoundingClientRect();l=(l-r.left)/b;m=(m-r.top)/b;p.style.left=l+"px";p.style.top=m+"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;h=a.createElement("span");q=a.createElement("span");h.className="webodf-hyperlinkTooltipLink";q.className="webodf-hyperlinkTooltipText";p=a.createElement("div");p.className="webodf-hyperlinkTooltip";p.appendChild(h);p.appendChild(q);f.getElement().appendChild(p)})()};gui.OdfFieldView=function(f){function k(){var a=odf.OdfSchema.getFields().map(function(a){return a.replace(":","|")}),d=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 d+"\n"+a}var a,d=f.getElement().ownerDocument;this.showFieldHighlight=function(){a.appendChild(d.createTextNode(k()))};this.hideFieldHighlight=function(){for(var c=a.sheet,d=c.cssRules;d.length;)c.deleteRule(d.length-1)};this.destroy= function(c){a.parentNode&&a.parentNode.removeChild(a);c()};a=function(){var a=d.getElementsByTagName("head").item(0),f=d.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(d.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(d,c){k=d;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(d){return a[d]})}var a={};this.getSelectionView=function(d){return a.hasOwnProperty(d)?a[d]:null};this.getSelectionViews=k;this.removeSelectionView=function(d){a.hasOwnProperty(d)&&(a[d].destroy(function(){}),delete a[d])};this.hideSelectionView=function(d){a.hasOwnProperty(d)&&a[d].hide()};this.showSelectionView=function(d){a.hasOwnProperty(d)&&a[d].show()};this.rerenderSelectionViews=function(){Object.keys(a).forEach(function(d){a[d].rerender()})}; this.registerCursor=function(d,c){var h=d.getMemberId(),k=new f(d);c?k.show():k.hide();return a[h]=k};this.destroy=function(a){function c(k,p){p?a(p):k .webodf-draggable"), b=gui.ShadowCursor.ShadowCursorMemberId,e(".webodf-selectionOverlay","{ fill: "+c+"; stroke: "+c+";}",""),e(".webodf-touchEnabled .webodf-selectionOverlay","{ display: block; }"," > .webodf-draggable"))}function l(b){var a,c;for(c in w)w.hasOwnProperty(c)&&(a=w[c],b?a.show():a.hide())}function r(b){c.getCarets().forEach(function(a){b?a.showHandle():a.hideHandle()})}function b(b){var a=b.getMemberId();b=b.getProperties();m(a,b.fullName,b.color)}function e(b){var e=b.getMemberId(),d=a.getOdtDocument().getMember(e).getProperties(); c.registerCursor(b,J,N);h.registerCursor(b,!0);if(b=c.getCaret(e))b.setAvatarImageUrl(d.imageUrl),b.setColor(d.color);runtime.log("+++ View here +++ eagerly created an Caret for '"+e+"'! +++")}function n(b){b=b.getMemberId();var a=h.getSelectionView(k),e=h.getSelectionView(gui.ShadowCursor.ShadowCursorMemberId),d=c.getCaret(k);b===k?(e.hide(),a&&a.show(),d&&d.show()):b===gui.ShadowCursor.ShadowCursorMemberId&&(e.show(),a&&a.hide(),d&&d.hide())}function g(b){h.removeSelectionView(b)}function u(b){var c= b.paragraphElement,e=b.memberId;b=b.timeStamp;var d,f="",g=c.getElementsByTagNameNS(x,"editinfo").item(0);g?(f=g.getAttributeNS(x,"id"),d=w[f]):(f=Math.random().toString(),d=new ops.EditInfo(c,a.getOdtDocument()),d=new gui.EditInfoMarker(d,F),g=c.getElementsByTagNameNS(x,"editinfo").item(0),g.setAttributeNS(x,"id",f),w[f]=d);d.addEdit(e,new Date(b));C.trigger()}function t(){var b;""!==s.innerHTML&&(s.innerHTML="");!0===d.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 y(a){var c=Object.keys(w).map(function(b){return w[b]});B.unsubscribe(ops.Document.signalMemberAdded,b);B.unsubscribe(ops.Document.signalMemberUpdated,b);B.unsubscribe(ops.Document.signalCursorAdded,e);B.unsubscribe(ops.Document.signalCursorRemoved,g);B.unsubscribe(ops.OdtDocument.signalParagraphChanged,u);B.unsubscribe(ops.Document.signalCursorMoved, n);B.unsubscribe(ops.OdtDocument.signalParagraphChanged,h.rerenderSelectionViews);B.unsubscribe(ops.OdtDocument.signalTableAdded,h.rerenderSelectionViews);B.unsubscribe(ops.OdtDocument.signalParagraphStyleModified,h.rerenderSelectionViews);d.unsubscribe(gui.CommonConstraints.EDIT.ANNOTATIONS.ONLY_DELETE_OWN,t);B.unsubscribe(ops.Document.signalMemberAdded,t);B.unsubscribe(ops.Document.signalMemberUpdated,t);v.parentNode.removeChild(v);s.parentNode.removeChild(s);(function Z(b,e){e?a(e):bb.length;a&&f(b);return a}function a(b,a){function c(f){b[f]===a&&d.push(f)}var d=[];b&&["style:parent-style-name","style:next-style-name"].forEach(c);return d}function d(b,a){function c(d){b[d]===a&&delete b[d]}b&&["style:parent-style-name","style:next-style-name"].forEach(c)}function c(b){var a={};Object.keys(b).forEach(function(d){a[d]="object"===typeof b[d]?c(b[d]):b[d]});return a}function h(b, a,c,d){var f,h=!1,k=!1,m,l=[];d&&d.attributes&&(l=d.attributes.split(","));b&&(c||0=a.position+a.length)){f=d?b:a;h=d?a:b;if(b.position!==a.position||b.length!==a.length)r=c(f),x=c(h);a=m(h.setProperties,null,f.setProperties,null,"style:text-properties");if(a.majorChanged||a.minorChanged)k=[],b=[],l=f.position+f.length,p=h.position+h.length,h.positionl?a.minorChanged&&(r=x,r.position=l,r.length=p-l,b.push(r),h.length=l-h.position):l>p&&a.majorChanged&&(r.position=p,r.length=l-p,k.push(r),f.length=p-f.position),f.setProperties&&q(f.setProperties)&&k.push(f),h.setProperties&&q(h.setProperties)&&b.push(h),d?(l=k,k=b):l=b}return{opSpecsA:l,opSpecsB:k}},InsertText:function(b,a){a.position<=b.position?b.position+=a.text.length:a.position<=b.position+b.length&& (b.length+=a.text.length);return{opSpecsA:[b],opSpecsB:[a]}},MergeParagraph:function(b,a){var c=b.position,d=b.position+b.length;c>=a.sourceStartPosition&&(c-=1);d>=a.sourceStartPosition&&(d-=1);b.position=c;b.length=d-c;return{opSpecsA:[b],opSpecsB:[a]}},MoveCursor:l,RemoveCursor:l,RemoveMember:l,RemoveStyle:l,RemoveText:function(b,a){var c=b.position+b.length,d=a.position+a.length,f=[b],h=[a];d<=b.position?b.position-=a.length:a.positiona.position?b.position+=a.text.length:c?a.position+=b.text.length:b.position+=a.text.length; return{opSpecsA:[b],opSpecsB:[a]}},MergeParagraph:function(b,a){b.position>=a.sourceStartPosition?b.position-=1:(b.positionb.position&&(a.position+=b.text.length);return{opSpecsA:[b], opSpecsB:[a]}},SplitParagraph:function(b,a){b.position=b.sourceStartPosition&&(f-=1);c>=b.sourceStartPosition&& (c-=1);0<=a.length?(a.position=f,a.length=c-f):(a.position=c,a.length=f-c);return{opSpecsA:[b],opSpecsB:[a]}},RemoveCursor:l,RemoveMember:l,RemoveStyle:l,RemoveText:function(b,a){a.position>=b.sourceStartPosition?a.position-=1:(a.positionb.sourceStartPosition)a.position-= 1;else if(a.position===b.destinationStartPosition||a.position===b.sourceStartPosition)a.position=b.destinationStartPosition,b.paragraphStyleName=a.styleName;return{opSpecsA:c,opSpecsB:d}},SplitParagraph:function(b,a){var c,d=[b],f=[a];a.position=b.destinationStartPosition&&a.position=b.sourceStartPosition&&(a.position-=1,a.sourceParagraphPosition-=1);return{opSpecsA:d,opSpecsB:f}},UpdateMember:l,UpdateMetadata:l,UpdateParagraphStyle:l},MoveCursor:{MoveCursor:l,RemoveCursor:function(b, a){return{opSpecsA:b.memberid===a.memberid?[]:[b],opSpecsB:[a]}},RemoveMember:l,RemoveStyle:l,RemoveText:function(b,a){var c=k(b),d=b.position+b.length,h=a.position+a.length;h<=b.position?b.position-=a.length:a.positiond.position?a.position+=1:a.position===d.sourceParagraphPosition&&(d.paragraphStyleName=a.styleName,h=c(a),h.position=d.position+1,f.push(h));return{opSpecsA:f,opSpecsB:g}},UpdateMember:l,UpdateMetadata:l,UpdateParagraphStyle:l},SplitParagraph:{SplitParagraph:function(a,c,d){var f,h;a.position