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