/* This is a generated file. DO NOT EDIT. Copyright (C) 2010-2014 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.2";function Runtime(){}Runtime.prototype.getVariable=function(f){};Runtime.prototype.toJson=function(f){};Runtime.prototype.fromJson=function(f){};Runtime.prototype.byteArrayFromString=function(f,k){};Runtime.prototype.byteArrayToString=function(f,k){};Runtime.prototype.read=function(f,k,d,b){};Runtime.prototype.readFile=function(f,k,d){};Runtime.prototype.readFileSync=function(f,k){};Runtime.prototype.loadXML=function(f,k){};Runtime.prototype.writeFile=function(f,k,d){}; Runtime.prototype.isFile=function(f,k){};Runtime.prototype.getFileSize=function(f,k){};Runtime.prototype.deleteFile=function(f,k){};Runtime.prototype.log=function(f,k){};Runtime.prototype.setTimeout=function(f,k){};Runtime.prototype.clearTimeout=function(f){};Runtime.prototype.libraryPaths=function(){};Runtime.prototype.currentDirectory=function(){};Runtime.prototype.setCurrentDirectory=function(f){};Runtime.prototype.type=function(){};Runtime.prototype.getDOMImplementation=function(){}; Runtime.prototype.parseXML=function(f){};Runtime.prototype.exit=function(f){};Runtime.prototype.getWindow=function(){};Runtime.prototype.requestAnimationFrame=function(f){};Runtime.prototype.cancelAnimationFrame=function(f){};Runtime.prototype.assert=function(f,k,d){};var IS_COMPILED_CODE=!0; Runtime.byteArrayToString=function(f,k){function d(d){var b="",l,p=d.length;for(l=0;lq?c.push(q):(l+=1,e=b[l],194<=q&&224>q?c.push((q&31)<<6|e&63):(l+=1,a=b[l],224<=q&&240>q?c.push((q&15)<<12|(e&63)<<6|a&63):(l+=1,m=b[l],240<=q&&245>q&&(q=(q&7)<<18|(e&63)<<12|(a&63)<<6|m&63,q-=65536,c.push((q>>10)+55296,(q&1023)+56320))))),1E3<=c.length&&(d+=String.fromCharCode.apply(null, c),c.length=0);return d+String.fromCharCode.apply(null,c)}var c;"utf8"===k?c=b(f):("binary"!==k&&this.log("Unsupported encoding: "+k),c=d(f));return c};Runtime.getVariable=function(f){try{return eval(f)}catch(k){}};Runtime.toJson=function(f){return JSON.stringify(f)};Runtime.fromJson=function(f){return JSON.parse(f)};Runtime.getFunctionName=function(f){return void 0===f.name?(f=/function\s+(\w+)/.exec(f))&&f[1]:f.name}; function BrowserRuntime(f){function k(q){var e=q.length,a,m,g=0;for(a=0;am&&(g+=1,a+=1);return g}function d(q,e,a){var m=q.length,g,b;e=new Uint8Array(new ArrayBuffer(e));a?(e[0]=239,e[1]=187,e[2]=191,b=3):b=0;for(a=0;ag?(e[b]=g,b+=1):2048>g?(e[b]=192|g>>>6,e[b+1]=128|g&63,b+=2):55040>=g||57344<=g?(e[b]=224|g>>>12&15,e[b+1]=128|g>>>6&63,e[b+2]=128|g&63,b+=3):(a+=1,g=(g-55296<<10|q.charCodeAt(a)-56320)+65536, e[b]=240|g>>>18&7,e[b+1]=128|g>>>12&63,e[b+2]=128|g>>>6&63,e[b+3]=128|g&63,b+=4);return e}function b(b){var e=b.length,a=new Uint8Array(new ArrayBuffer(e)),m;for(m=0;mm.status||0===m.status?a(null):a("Status "+String(m.status)+": "+m.responseText||m.statusText):a("File "+b+" is empty."))};g=e.buffer&&!m.sendAsBinary?e.buffer:p.byteArrayToString(e,"binary");try{m.sendAsBinary?m.sendAsBinary(g):m.send(g)}catch(d){p.log("HUH? "+d+" "+e),a(d.message)}};this.deleteFile=function(b,e){delete n[b];var a=new XMLHttpRequest;a.open("DELETE",b,!0);a.onreadystatechange= function(){4===a.readyState&&(200>a.status&&300<=a.status?e(a.responseText):e(null))};a.send(null)};this.loadXML=function(b,e){var a=new XMLHttpRequest;a.open("GET",b,!0);a.overrideMimeType&&a.overrideMimeType("text/xml");a.onreadystatechange=function(){4===a.readyState&&(0!==a.status||a.responseText?200===a.status||0===a.status?e(null,a.responseXML):e(a.responseText,null):e("File "+b+" is empty.",null))};try{a.send(null)}catch(m){e(m.message,null)}};this.isFile=function(b,e){p.getFileSize(b,function(a){e(-1!== a)})};this.getFileSize=function(b,e){if(n.hasOwnProperty(b)&&"string"!==typeof n[b])e(n[b].length);else{var a=new XMLHttpRequest;a.open("HEAD",b,!0);a.onreadystatechange=function(){if(4===a.readyState){var m=a.getResponseHeader("Content-Length");m?e(parseInt(m,10)):l(b,"binary",function(a,m){a?e(-1):e(m.length)})}};a.send(null)}};this.log=c;this.assert=function(b,e,a){if(!b)throw c("alert","ASSERTION FAILED:\n"+e),a&&a(),e;};this.setTimeout=function(b,e){return setTimeout(function(){b()},e)};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(b){c("Calling exit with code "+String(b)+", but exit() is not implemented.")};this.getWindow=function(){return window};this.requestAnimationFrame= function(b){var e=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame,a=0;if(e)e.bind(window),a=e(b);else return setTimeout(b,15);return a};this.cancelAnimationFrame=function(b){var e=window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.msCancelAnimationFrame;e?(e.bind(window),e(b)):clearTimeout(b)}} function NodeJSRuntime(){function f(b){var d=b.length,l,e=new Uint8Array(new ArrayBuffer(d));for(l=0;l").implementation} function RhinoRuntime(){function f(b,d){var c;void 0!==d?c=b:d=b;"alert"===c&&print("\n!!!!! ALERT !!!!!");print(d);"alert"===c&&print("!!!!! ALERT !!!!!")}var k=this,d={},b=d.javax.xml.parsers.DocumentBuilderFactory.newInstance(),c,h,r="";b.setValidating(!1);b.setNamespaceAware(!0);b.setExpandEntityReferences(!1);b.setSchema(null);h=d.org.xml.sax.EntityResolver({resolveEntity:function(b,c){var h=new d.java.io.FileReader(c);return new d.org.xml.sax.InputSource(h)}});c=b.newDocumentBuilder();c.setEntityResolver(h); this.byteArrayFromString=function(b,d){var c,q=b.length,e=new Uint8Array(new ArrayBuffer(q));for(c=0;c>>18],m+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[g>>>12&63],m+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[g>>>6&63],m+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[g& 63];e===b+1?(g=a[e]<<4,m+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[g>>>6],m+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[g&63],m+="=="):e===b&&(g=a[e]<<10|a[e+1]<<2,m+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[g>>>12],m+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[g>>>6&63],m+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[g&63],m+="=");return m}function d(a){a=a.replace(/[^A-Za-z0-9+\/]+/g, "");var m=a.length,e=new Uint8Array(new ArrayBuffer(3*m)),b=a.length%4,d=0,c,H;for(c=0;c>16,e[d+1]=H>>8&255,e[d+2]=H&255,d+=3;m=3*m-[0,0,2,1][b];return e.subarray(0,m)}function b(a){var g,m,e=a.length,b=0,d=new Uint8Array(new ArrayBuffer(3*e));for(g=0;gm?d[b++]=m:(2048>m?d[b++]=192|m>>>6:(d[b++]=224|m>>>12&15,d[b++]=128|m>>>6&63),d[b++]=128|m&63);return d.subarray(0, b)}function c(a){var g,m,e,b,d=a.length,H=new Uint8Array(new ArrayBuffer(d)),c=0;for(g=0;gm?H[c++]=m:(g+=1,e=a[g],224>m?H[c++]=(m&31)<<6|e&63:(g+=1,b=a[g],H[c++]=(m&15)<<12|(e&63)<<6|b&63));return H.subarray(0,c)}function h(a){return k(f(a))}function r(a){return String.fromCharCode.apply(String,d(a))}function l(a){return c(f(a))}function p(a){a=c(a);for(var g="",m=0;mg?H+=String.fromCharCode(g):(d+=1,e=a.charCodeAt(d)&255,224>g?H+=String.fromCharCode((g&31)<<6|e&63):(d+=1,b=a.charCodeAt(d)&255,H+=String.fromCharCode((g&15)<<12|(e&63)<<6|b&63)));return H}function q(a,g){function m(){var d=b+1E5;d>a.length&&(d=a.length);e+=n(a,b,d);b=d;d=b===a.length;g(e,d)&&!d&&runtime.setTimeout(m,0)}var e="",b=0;1E5>a.length?g(n(a,0,a.length),!0):("string"!==typeof a&&(a=a.slice()),m())}function e(a){return b(f(a))}function a(a){return String.fromCharCode.apply(String, b(a))}function m(a){return String.fromCharCode.apply(String,b(f(a)))}var g=function(a){var g={},m,e;m=0;for(e=a.length;mc-b&&(c=Math.max(2*c,b+d),d=new Uint8Array(new ArrayBuffer(c)),d.set(h),h=d)}var d=this,b=0,c=1024,h=new Uint8Array(new ArrayBuffer(c));this.appendByteArrayWriter=function(b){d.appendByteArray(b.getByteArray())};this.appendByteArray=function(d){var c=d.length;k(c);h.set(d,b);b+=c};this.appendArray=function(d){var c=d.length;k(c);h.set(d,b);b+=c};this.appendUInt16LE=function(b){d.appendArray([b&255,b>>8&255])};this.appendUInt32LE=function(b){d.appendArray([b& 255,b>>8&255,b>>16&255,b>>24&255])};this.appendString=function(b){d.appendByteArray(runtime.byteArrayFromString(b,f))};this.getLength=function(){return b};this.getByteArray=function(){var d=new Uint8Array(new ArrayBuffer(b));d.set(h.subarray(0,b));return d}};core.CSSUnits=function(){var f=this,k={"in":1,cm:2.54,mm:25.4,pt:72,pc:12,px:96};this.convert=function(d,b,c){return d*k[c]/k[b]};this.convertMeasure=function(d,b){var c,h;d&&b&&(c=parseFloat(d),h=d.replace(c.toString(),""),c=f.convert(c,h,b));return c};this.getUnits=function(d){return d.substr(d.length-2,d.length)}};(function(){function f(){var b,c,h,f,l,p,k,q,e;void 0===d&&(c=(b=runtime.getWindow())&&b.document,p=c.documentElement,k=c.body,d={rangeBCRIgnoresElementBCR:!1,unscaledRangeClientRects:!1,elementBCRIgnoresBodyScroll:!1},c&&(f=c.createElement("div"),f.style.position="absolute",f.style.left="-99999px",f.style.transform="scale(2)",f.style["-webkit-transform"]="scale(2)",l=c.createElement("div"),f.appendChild(l),k.appendChild(f),b=c.createRange(),b.selectNode(l),d.rangeBCRIgnoresElementBCR=0===b.getClientRects().length, l.appendChild(c.createTextNode("Rect transform test")),c=l.getBoundingClientRect(),h=b.getBoundingClientRect(),d.unscaledRangeClientRects=2=a.compareBoundaryPoints(Range.START_TO_START,g)&&0<=a.compareBoundaryPoints(Range.END_TO_END,g)}function h(a,g){return 0>=a.compareBoundaryPoints(Range.END_TO_START,g)&&0<=a.compareBoundaryPoints(Range.START_TO_END,g)}function r(a,g){var e=null;a.nodeType===Node.TEXT_NODE&&(0===a.length?(a.parentNode.removeChild(a),g.nodeType===Node.TEXT_NODE&&(e=g)):(g.nodeType===Node.TEXT_NODE&&(a.appendData(g.data),g.parentNode.removeChild(g)),e=a));return e} function l(a){for(var g=a.parentNode;a.firstChild;)g.insertBefore(a.firstChild,a);g.removeChild(a);return g}function p(a,g){for(var e=a.parentNode,b=a.firstChild,d;b;)d=b.nextSibling,p(b,g),b=d;e&&g(a)&&l(a);return e}function n(a,g){return a===g||Boolean(a.compareDocumentPosition(g)&Node.DOCUMENT_POSITION_CONTAINED_BY)}function q(a,g){return f().unscaledRangeClientRects?a:a/g}function e(a,g,b){Object.keys(g).forEach(function(d){var c=d.split(":"),h=c[1],l=b(c[0]),c=g[d],f=typeof c;"object"===f?Object.keys(c).length&& (d=l?a.getElementsByTagNameNS(l,h)[0]||a.ownerDocument.createElementNS(l,d):a.getElementsByTagName(h)[0]||a.ownerDocument.createElement(d),a.appendChild(d),e(d,c,b)):l&&(runtime.assert("number"===f||"string"===f,"attempting to map unsupported type '"+f+"' (key: "+d+")"),a.setAttributeNS(l,d,String(c)))})}var a=null;this.splitBoundaries=function(a){var g,e=[],d,c,h;if(a.startContainer.nodeType===Node.TEXT_NODE||a.endContainer.nodeType===Node.TEXT_NODE){d=a.endContainer;c=a.endContainer.nodeType!== Node.TEXT_NODE?a.endOffset===a.endContainer.childNodes.length:!1;h=a.endOffset;g=a.endContainer;if(hf))throw runtime.log("alert","watchdog timeout"),"timeout!";if(0k))throw runtime.log("alert","watchdog loop overflow"),"loop overflow";}};core.PositionIterator=function(f,k,d,b){function c(){this.acceptNode=function(a){return!a||a.nodeType===m&&0===a.length?t:z}}function h(a){this.acceptNode=function(e){return!e||e.nodeType===m&&0===e.length?t:a.acceptNode(e)}}function r(){var a=q.currentNode,b=a.nodeType;e=b===m?a.length-1:b===g?1:0}function l(){if(null===q.previousSibling()){if(!q.parentNode()||q.currentNode===f)return q.firstChild(),!1;e=0}else r();return!0}function p(){var g=q.currentNode,b;b=a(g);if(g!==f)for(g=g.parentNode;g&& g!==f;)a(g)===t&&(q.currentNode=g,b=t),g=g.parentNode;b===t?(e=1,g=n.nextPosition()):g=b===z?!0:n.nextPosition();g&&runtime.assert(a(q.currentNode)===z,"moveToAcceptedNode did not result in walker being on an accepted node");return g}var n=this,q,e,a,m=Node.TEXT_NODE,g=Node.ELEMENT_NODE,z=NodeFilter.FILTER_ACCEPT,t=NodeFilter.FILTER_REJECT;this.nextPosition=function(){var a=q.currentNode,b=a.nodeType;if(a===f)return!1;if(0===e&&b===g)null===q.firstChild()&&(e=1);else if(b===m&&e+1 "+a.length), runtime.assert(0<=g,"Error in setPosition: "+g+" < 0"),g===a.length&&(q.nextSibling()?e=0:q.parentNode()?e=1:runtime.assert(!1,"Error in setUnfilteredPosition: position not valid.")),!0;gb.windowBits&&(b.windowBits=-b.windowBits,0===b.windowBits&&(b.windowBits=-15));!(0<=b.windowBits&&16>b.windowBits)||g&&g.windowBits||(b.windowBits+=32);15b.windowBits&&0===(b.windowBits&15)&&(b.windowBits|=15);this.err=0;this.msg="";this.ended=!1;this.chunks= [];this.strm=new e;this.strm.avail_out=0;g=f.inflateInit2(this.strm,b.windowBits);if(g!==n.Z_OK)throw Error(q[g]);this.header=new a;f.inflateGetHeader(this.strm,this.header)};m.prototype.push=function(a,e){var b=this.strm,m=this.options.chunkSize,d,c,h,q,A;if(this.ended)return!1;c=e===~~e?e:!0===e?n.Z_FINISH:n.Z_NO_FLUSH;b.input="string"===typeof a?p.binstring2buf(a):a;b.next_in=0;b.avail_in=b.input.length;do{0===b.avail_out&&(b.output=new l.Buf8(m),b.next_out=0,b.avail_out=m);d=f.inflate(b,n.Z_NO_FLUSH); if(d!==n.Z_STREAM_END&&d!==n.Z_OK)return this.onEnd(d),this.ended=!0,!1;if(b.next_out&&(0===b.avail_out||d===n.Z_STREAM_END||0===b.avail_in&&c===n.Z_FINISH))if("string"===this.options.to)h=p.utf8border(b.output,b.next_out),q=b.next_out-h,A=p.buf2string(b.output,h),b.next_out=q,b.avail_out=m-q,q&&l.arraySet(b.output,b.output,h,q,0),this.onData(A);else this.onData(l.shrinkBuf(b.output,b.next_out))}while((0e&&(a.subarray&&p||!a.subarray&&l))return String.fromCharCode.apply(null,f.shrinkBuf(a,e));for(var b="",d=0;dd;d++)e[d]=252<=d?6:248<= d?5:240<=d?4:224<=d?3:192<=d?2:1;e[254]=e[254]=1;c.string2buf=function(a){var e,b,d,c,h,l=a.length,q=0;for(c=0;cb?1:2048>b?2:65536>b?3:4;e=new f.Buf8(q);for(c=h=0;hb?e[h++]=b:(2048>b?e[h++]=192|b>>>6:(65536>b?e[h++]=224|b>>>12:(e[h++]= 240|b>>>18,e[h++]=128|b>>>12&63),e[h++]=128|b>>>6&63),e[h++]=128|b&63);return e};c.buf2binstring=function(a){return h(a,a.length)};c.binstring2buf=function(a){for(var e=new f.Buf8(a.length),b=0,d=e.length;bc)q[d++]=c;else if(f=e[c],4c?q[d++]=c:(c-=65536,q[d++]= 55296|c>>10&1023,q[d++]=56320|c&1023)}return h(q,d)};c.utf8border=function(a,b){var g;b=b||a.length;b>a.length&&(b=a.length);for(g=b-1;0<=g&&128===(a[g]&192);)g--;return 0>g||0===g?b:g+e[a[g]]>b?g:b}},{"./common":2}],4:[function(d,b,c){b.exports=function(b,d,c,f){var n=b&65535|0;b=b>>>16&65535|0;for(var q=0;0!==c;){q=2E3c;c++){b=c;for(var h=0;8>h;h++)b=b&1?3988292384^b>>>1:b>>>1;d[c]=b}return d}();b.exports=function(b,d,c,f){c=f+c;for(b^= -1;f>>8^h[(b^d[f])&255];return b^-1}},{}],7:[function(d,b,c){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(d,b,c){b.exports=function(b,d){var c,f,n,q,e,a,m,g,z,t,v,y,s,x,w,A,G,E,F,H,N,I,U,B;c=b.state;f=b.next_in;U=b.input;n=f+(b.avail_in-5);q=b.next_out;B=b.output;e=q-(d-b.avail_out);a=q+(b.avail_out-257);m=c.dmax;g=c.wsize;z=c.whave;t=c.wnext;v=c.window;y=c.hold;s=c.bits; x=c.lencode;w=c.distcode;A=(1<s&&(y+=U[f++]<>>24;y>>>=F;s-=F;F=E>>>16&255;if(0===F)B[q++]=E&65535;else if(F&16){H=E&65535;if(F&=15)s>>=F,s-=F;15>s&&(y+=U[f++]<>>24;y>>>=F;s-=F;F=E>>>16&255;if(F&16){E&=65535;F&=15;sm){b.msg="invalid distance too far back"; c.mode=30;break a}y>>>=F;s-=F;F=q-e;if(E>F){F=E-F;if(F>z&&c.sane){b.msg="invalid distance too far back";c.mode=30;break a}N=0;I=v;if(0===t){if(N+=g-F,F>3;f-=H;s-=H<<3;b.next_in=f;b.next_out=q;b.avail_in=f>>24&255)+(a>>>8&65280)+((a&65280)<<8)+((a&255)<<24)}function f(){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 e.Buf16(320);this.work= new e.Buf16(288);this.distdyn=this.lendyn=null;this.was=this.back=this.sane=0}function l(a){var b;if(!a||!a.state)return v;b=a.state;a.total_in=a.total_out=b.total=0;a.msg="";b.wrap&&(a.adler=b.wrap&1);b.mode=y;b.last=0;b.havedict=0;b.dmax=32768;b.head=null;b.hold=0;b.bits=0;b.lencode=b.lendyn=new e.Buf32(s);b.distcode=b.distdyn=new e.Buf32(x);b.sane=1;b.back=-1;return t}function p(a){var b;if(!a||!a.state)return v;b=a.state;b.wsize=0;b.whave=0;b.wnext=0;return l(a)}function n(a,b){var e,g;if(!a|| !a.state)return v;g=a.state;0>b?(e=0,b=-b):(e=(b>>4)+1,48>b&&(b&=15));if(b&&(8>b||15s;){if(0===p)break a;p--;u+=f[l++]<>>8&255;c.check=m(c.check,O,2,0);s=u=0;c.mode=2;break}c.flags=0;c.head&&(c.head.done=!1);if(!(c.wrap&1)||(((u&255)<<8)+(u>>8))%31){b.msg="incorrect header check";c.mode=30;break}if(8!==(u&15)){b.msg="unknown compression method";c.mode=30;break}u>>>=4;s-=4;P=(u&15)+8;if(0===c.wbits)c.wbits=P;else if(P>c.wbits){b.msg="invalid window size";c.mode=30;break}c.dmax=1<s;){if(0===p)break a;p--;u+=f[l++]<>8&1);c.flags&512&&(O[0]=u&255,O[1]=u>>>8&255,c.check=m(c.check,O,2,0));s=u=0;c.mode=3;case 3:for(;32>s;){if(0===p)break a;p--;u+=f[l++]<>>8&255,O[2]=u>>>16&255,O[3]=u>>>24&255,c.check=m(c.check,O,4,0));s=u=0;c.mode=4;case 4:for(;16>s;){if(0===p)break a;p--;u+=f[l++]<>8);c.flags&512&&(O[0]=u&255,O[1]=u>>>8&255,c.check=m(c.check,O,2,0));s=u=0;c.mode=5;case 5:if(c.flags&1024){for(;16>s;){if(0===p)break a;p--;u+=f[l++]<>>8&255,c.check=m(c.check,O,2,0));s=u=0}else c.head&&(c.head.extra=null);c.mode=6;case 6:if(c.flags&1024&&(D=c.length,D>p&&(D=p),D&&(c.head&&(P=c.head.extra_len-c.length,c.head.extra||(c.head.extra=Array(c.head.extra_len)),e.arraySet(c.head.extra, f,l,D,P)),c.flags&512&&(c.check=m(c.check,f,D,l)),p-=D,l+=D,c.length-=D),c.length))break a;c.length=0;c.mode=7;case 7:if(c.flags&2048){if(0===p)break a;D=0;do P=f[l+D++],c.head&&P&&65536>c.length&&(c.head.name+=String.fromCharCode(P));while(P&&Dc.length&&(c.head.comment+=String.fromCharCode(P));while(P&&D< p);c.flags&512&&(c.check=m(c.check,f,D,l));p-=D;l+=D;if(P)break a}else c.head&&(c.head.comment=null);c.mode=9;case 9:if(c.flags&512){for(;16>s;){if(0===p)break a;p--;u+=f[l++]<>9&1,c.head.done=!0);b.adler=c.check=0;c.mode=12;break;case 10:for(;32>s;){if(0===p)break a;p--;u+=f[l++]<>>=s&7;s-=s&7;c.mode=27;break}for(;3>s;){if(0===p)break a;p--;u+=f[l++]<>>=1;s-=1;switch(u&3){case 0:c.mode=14;break;case 1:D=c;if(w){P=void 0;A=new e.Buf32(512);G=new e.Buf32(32);for(P=0;144>P;)D.lens[P++]=8;for(;256>P;)D.lens[P++]=9;for(;280>P;)D.lens[P++]=7;for(;288>P;)D.lens[P++]=8;z(1,D.lens,0,288,A,0,D.work,{bits:9});for(P=0;32>P;)D.lens[P++]=5;z(2,D.lens, 0,32,G,0,D.work,{bits:5});w=!1}D.lencode=A;D.lenbits=9;D.distcode=G;D.distbits=5;c.mode=20;if(6===d){u>>>=2;s-=2;break a}break;case 2:c.mode=17;break;case 3:b.msg="invalid block type",c.mode=30}u>>>=2;s-=2;break;case 14:u>>>=s&7;for(s-=s&7;32>s;){if(0===p)break a;p--;u+=f[l++]<>>16^65535)){b.msg="invalid stored block lengths";c.mode=30;break}c.length=u&65535;s=u=0;c.mode=15;if(6===d)break a;case 15:c.mode=16;case 16:if(D=c.length){D>p&&(D=p);D>n&&(D=n);if(0===D)break a;e.arraySet(q, f,l,D,r);p-=D;l+=D;n-=D;r+=D;c.length-=D;break}c.mode=12;break;case 17:for(;14>s;){if(0===p)break a;p--;u+=f[l++]<>>=5;s-=5;c.ndist=(u&31)+1;u>>>=5;s-=5;c.ncode=(u&15)+4;u>>>=4;s-=4;if(286s;){if(0===p)break a;p--;u+=f[l++]<>>=3;s-=3}for(;19>c.have;)c.lens[V[c.have++]]=0;c.lencode=c.lendyn;c.lenbits=7; D={bits:c.lenbits};J=z(0,c.lens,0,19,c.lencode,0,c.work,D);c.lenbits=D.bits;if(J){b.msg="invalid code lengths set";c.mode=30;break}c.have=0;c.mode=19;case 19:for(;c.have>>24;T=D>>>16&255;L=D&65535;if(C<=s)break;if(0===p)break a;p--;u+=f[l++]<L)u>>>=C,s-=C,c.lens[c.have++]=L;else{if(16===L){for(D=C+2;s>>=C;s-=C;if(0===c.have){b.msg="invalid bit length repeat";c.mode=30;break}P= c.lens[c.have-1];D=3+(u&3);u>>>=2;s-=2}else if(17===L){for(D=C+3;s>>=C;s-=C;P=0;D=3+(u&7);u>>>=3;s-=3}else{for(D=C+7;s>>=C;s-=C;P=0;D=11+(u&127);u>>>=7;s-=7}if(c.have+D>c.nlen+c.ndist){b.msg="invalid bit length repeat";c.mode=30;break}for(;D--;)c.lens[c.have++]=P}}if(30===c.mode)break;if(0===c.lens[256]){b.msg="invalid code -- missing end-of-block";c.mode=30;break}c.lenbits=9;D={bits:c.lenbits};J=z(1,c.lens, 0,c.nlen,c.lencode,0,c.work,D);c.lenbits=D.bits;if(J){b.msg="invalid literal/lengths set";c.mode=30;break}c.distbits=6;c.distcode=c.distdyn;D={bits:c.distbits};J=z(2,c.lens,c.nlen,c.ndist,c.distcode,0,c.work,D);c.distbits=D.bits;if(J){b.msg="invalid distances set";c.mode=30;break}c.mode=20;if(6===d)break a;case 20:c.mode=21;case 21:if(6<=p&&258<=n){b.next_out=r;b.avail_out=n;b.next_in=l;b.avail_in=p;c.hold=u;c.bits=s;g(b,x);r=b.next_out;q=b.output;n=b.avail_out;l=b.next_in;f=b.input;p=b.avail_in; u=c.hold;s=c.bits;12===c.mode&&(c.back=-1);break}for(c.back=0;;){D=c.lencode[u&(1<>>24;T=D>>>16&255;L=D&65535;if(C<=s)break;if(0===p)break a;p--;u+=f[l++]<>P)];C=D>>>24;T=D>>>16&255;L=D&65535;if(P+C<=s)break;if(0===p)break a;p--;u+=f[l++]<>>=P;s-=P;c.back+=P}u>>>=C;s-=C;c.back+=C;c.length=L;if(0===T){c.mode=26;break}if(T&32){c.back=-1;c.mode=12;break}if(T&64){b.msg="invalid literal/length code"; c.mode=30;break}c.extra=T&15;c.mode=22;case 22:if(c.extra){for(D=c.extra;s>>=c.extra;s-=c.extra;c.back+=c.extra}c.was=c.length;c.mode=23;case 23:for(;;){D=c.distcode[u&(1<>>24;T=D>>>16&255;L=D&65535;if(C<=s)break;if(0===p)break a;p--;u+=f[l++]<>P)];C=D>>>24;T=D>>>16&255;L=D&65535;if(P+C<=s)break;if(0===p)break a;p--;u+=f[l++]<>>=P;s-=P;c.back+=P}u>>>=C;s-=C;c.back+=C;if(T&64){b.msg="invalid distance code";c.mode=30;break}c.offset=L;c.extra=T&15;c.mode=24;case 24:if(c.extra){for(D=c.extra;s>>=c.extra;s-=c.extra;c.back+=c.extra}if(c.offset>c.dmax){b.msg="invalid distance too far back";c.mode=30;break}c.mode=25;case 25:if(0===n)break a;D=x-n;if(c.offset>D){D=c.offset-D;if(D>c.whave&&c.sane){b.msg="invalid distance too far back";c.mode=30;break}D> c.wnext?(D-=c.wnext,P=c.wsize-D):P=c.wnext-D;D>c.length&&(D=c.length);X=c.window}else X=q,P=r-c.offset,D=c.length;D>n&&(D=n);n-=D;c.length-=D;do q[r++]=X[P++];while(--D);0===c.length&&(c.mode=21);break;case 26:if(0===n)break a;q[r++]=c.length;n--;c.mode=21;break;case 27:if(c.wrap){for(;32>s;){if(0===p)break a;p--;u|=f[l++]<s;){if(0===p)break a;p--;u+=f[l++]<c.mode&&(27>c.mode||4!==d))f=b.output,l=b.next_out,r=x-b.avail_out,n=b.state,null===n.window&&(n.wsize=1<=n.wsize?(e.arraySet(n.window,f,l-n.wsize,n.wsize,0),n.wnext=0,n.whave=n.wsize):(p=n.wsize-n.wnext,p>r&&(p=r),e.arraySet(n.window,f,l-r,p,n.wnext),(r-=p)?(e.arraySet(n.window,f,l-r,r,0),n.wnext=r,n.whave=n.wsize):(n.wnext+=p,n.wnext===n.wsize&&(n.wnext=0),n.whave=s;s++)Y[s]=0;for(x=0;xA&&(G=A);if(0===A)return g[d++]=20971520,g[d++]=20971520,v.bits=1,0;for(w=1;w=s;s++)if(H<<=1,H-=Y[s],0>H)return-1;if(0s;s++)E[s+1]=E[s]+Y[s];for(x=0;xu?(P=$[ea+t[x]],X=Z[Q+t[x]]):(P=96,X=0);H=1<>F)+U]=D<<24|P<<16|X|0;while(0!==U);for(H=1<>=1;0!==H?(I&=H-1,I+=H):I=0;x++;if(0===--Y[s]){if(s===A)break;s=e[a+t[x]]}if(s>G&&(I&c)!==B){0===F&&(F=G);y+=w;E=s-F;for(H=1<=H)break;E++;H<<=1}N+=1<";return runtime.parseXML(b)}; core.UnitTest.createOdtDocument=function(f,k){return core.UnitTest.createXmlDocument("office:document",f,k)}; core.UnitTestLogger=function(){var f=[],k=0,d=0,b="",c="";this.startTest=function(h,r){f=[];k=0;b=h;c=r;d=Date.now()};this.endTest=function(){var h=Date.now();return{description:c,suite:[b,c],success:0===k,log:f,time:h-d}};this.debug=function(b){f.push({category:"debug",message:b})};this.fail=function(b){k+=1;f.push({category:"fail",message:b})};this.pass=function(b){f.push({category:"pass",message:b})}}; core.UnitTestRunner=function(f,k){function d(a){p+=1;e?k.debug(a):k.fail(a)}function b(a,b){var e;try{if(a.length!==b.length)return d("array of length "+a.length+" should be "+b.length+" long"),!1;for(e=0;e1/h?"-0":String(h),d(b+" should be "+a+". Was "+e+".")):d(b+" should be "+a+" (of type "+typeof a+"). Was "+ h+" (of type "+typeof h+").")}var p=0,n,q,e=!1;this.resourcePrefix=function(){return f};this.beginExpectFail=function(){n=p;e=!0};this.endExpectFail=function(){var a=n===p;e=!1;p=n;a&&(p+=1,k.fail("Expected at least one failed test, but none registered."))};q=function(a,e){var c=Object.keys(a),f=Object.keys(e);c.sort();f.sort();return b(c,f)&&Object.keys(a).every(function(b){var c=a[b],g=e[b];return r(c,g)?!0:(d(c+" should be "+g+" for key "+b),!1)})};this.areNodesEqual=h;this.shouldBeNull=function(a, b){l(a,b,"null")};this.shouldBeNonNull=function(a,b){var e,c;try{c=eval(b)}catch(f){e=f}e?d(b+" should be non-null. Threw exception "+e):null!==c?k.pass(b+" is non-null."):d(b+" should be non-null. Was "+c)};this.shouldBe=l;this.testFailed=d;this.countFailedTests=function(){return p};this.name=function(a){var b,e,c=[],d=a.length;c.length=d;for(b=0;b"+b+""}function k(b){d.reporter&&d.reporter(b)}var d=this,b=0,c=new core.UnitTestLogger,h={},r="BrowserRuntime"===runtime.type();this.resourcePrefix="";this.reporter=function(b){var c,d;r?runtime.log("Running "+f(b.description,'runTest("'+b.suite[0]+'","'+b.description+'")')+""):runtime.log("Running "+b.description);if(!b.success)for(c=0;cRunning "+f(e,'runSuite("'+e+'");')+": "+m.description()+""):runtime.log("Running "+e+": "+m.description);v=m.tests();for(z=0;z>>8^d;return e^-1}function b(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 c(a){var b=a.getFullYear();return 1980>b?0:b-1980<< 25|a.getMonth()+1<<21|a.getDate()<<16|a.getHours()<<11|a.getMinutes()<<5|a.getSeconds()>>1}function h(a,e){var c,d,m,f,h,l,q,p=this;this.load=function(b){if(null!==p.data)b(null,p.data);else{var e=h+34+d+m+256;e+q>g&&(e=g-q);runtime.read(a,q,e,function(e,c){if(e||null===c)b(e,c);else a:{var g=c,d=new core.ByteArray(g),m=d.readUInt32LE(),q;if(67324752!==m)b("File entry signature is wrong."+m.toString()+" "+g.length.toString(),null);else{d.pos+=22;m=d.readUInt16LE();q=d.readUInt16LE();d.pos+=m+q;if(f){g= g.subarray(d.pos,d.pos+h);if(h!==g.length){b("The amount of compressed bytes read was "+g.length.toString()+" instead of "+h.toString()+" for "+p.filename+" in "+a+".",null);break a}g=t(g,l)}else g=g.subarray(d.pos,d.pos+l);l!==g.length?b("The amount of bytes read was "+g.length.toString()+" instead of "+l.toString()+" for "+p.filename+" in "+a+".",null):(p.data=g,b(null,g))}}})}};this.set=function(a,b,e,c){p.filename=a;p.data=b;p.compressed=e;p.date=c};this.error=null;e&&(c=e.readUInt32LE(),33639248!== c?this.error="Central directory entry has wrong signature at position "+(e.pos-4).toString()+' for file "'+a+'": '+e.data.length.toString():(e.pos+=6,f=e.readUInt16LE(),this.date=b(e.readUInt32LE()),e.readUInt32LE(),h=e.readUInt32LE(),l=e.readUInt32LE(),d=e.readUInt16LE(),m=e.readUInt16LE(),c=e.readUInt16LE(),e.pos+=8,q=e.readUInt32LE(),this.filename=runtime.byteArrayToString(e.data.subarray(e.pos,e.pos+d),"utf8"),this.data=null,e.pos+=d+m+c))}function r(a,b){if(22!==a.length)b("Central directory length should be 22.", v);else{var e=new core.ByteArray(a),c;c=e.readUInt32LE();101010256!==c?b("Central directory signature is wrong: "+c.toString(),v):(c=e.readUInt16LE(),0!==c?b("Zip files with non-zero disk numbers are not supported.",v):(c=e.readUInt16LE(),0!==c?b("Zip files with non-zero disk numbers are not supported.",v):(c=e.readUInt16LE(),z=e.readUInt16LE(),c!==z?b("Number of entries is inconsistent.",v):(c=e.readUInt32LE(),e=e.readUInt16LE(),e=g-22-c,runtime.read(f,e,g-e,function(a,e){if(a||null===e)b(a,v);else a:{var c= new core.ByteArray(e),g,d;m=[];for(g=0;gg?k("File '"+f+"' cannot be read.",v):runtime.read(f,g-22,22,function(a,b){a||null===k||null===b?k(a,v): r(b,k)})})};gui.CommonConstraints={EDIT:{ANNOTATIONS:{ONLY_DELETE_OWN:"onlyDeleteOwn"},REVIEW_MODE:"reviewMode"}};gui.SessionConstraints=function(){function f(b){k.hasOwnProperty(b)||(k[b]=!1,d.register(b))}var k={},d=new core.EventNotifier;this.registerConstraint=f;this.subscribe=function(b,c){f(b);d.subscribe(b,c)};this.unsubscribe=function(b,c){d.unsubscribe(b,c)};this.setState=function(b,c){runtime.assert(!0===k.hasOwnProperty(b),"No such constraint");k[b]!==c&&(k[b]=c,d.emit(b,c))};this.getState=function(b){runtime.assert(!0===k.hasOwnProperty(b),"No such constraint");return k[b]}};xmldom.LSSerializerFilter=function(){};xmldom.LSSerializerFilter.prototype.acceptNode=function(f){};odf.OdfNodeFilter=function(){this.acceptNode=function(f){return"http://www.w3.org/1999/xhtml"===f.namespaceURI?NodeFilter.FILTER_SKIP:f.namespaceURI&&f.namespaceURI.match(/^urn:webodf:/)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}};odf.Namespaces={namespaceMap:{db:"urn:oasis:names:tc:opendocument:xmlns:database:1.0",dc:"http://purl.org/dc/elements/1.1/",dr3d:"urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0",draw:"urn:oasis:names:tc:opendocument:xmlns:drawing:1.0",chart:"urn:oasis:names:tc:opendocument:xmlns:chart:1.0",fo:"urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0",form:"urn:oasis:names:tc:opendocument:xmlns:form:1.0",meta:"urn:oasis:names:tc:opendocument:xmlns:meta:1.0",number:"urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0", office:"urn:oasis:names:tc:opendocument:xmlns:office:1.0",presentation:"urn:oasis:names:tc:opendocument:xmlns:presentation:1.0",style:"urn:oasis:names:tc:opendocument:xmlns:style:1.0",svg:"urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0",table:"urn:oasis:names:tc:opendocument:xmlns:table:1.0",text:"urn:oasis:names:tc:opendocument:xmlns:text:1.0",xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace"},prefixMap:{},dbns:"urn:oasis:names:tc:opendocument:xmlns:database:1.0", dcns:"http://purl.org/dc/elements/1.1/",dr3dns:"urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0",drawns:"urn:oasis:names:tc:opendocument:xmlns:drawing:1.0",chartns:"urn:oasis:names:tc:opendocument:xmlns:chart:1.0",fons:"urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0",formns:"urn:oasis:names:tc:opendocument:xmlns:form:1.0",metans:"urn:oasis:names:tc:opendocument:xmlns:meta:1.0",numberns:"urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0",officens:"urn:oasis:names:tc:opendocument:xmlns:office:1.0", presentationns:"urn:oasis:names:tc:opendocument:xmlns:presentation:1.0",stylens:"urn:oasis:names:tc:opendocument:xmlns:style:1.0",svgns:"urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0",tablens:"urn:oasis:names:tc:opendocument:xmlns:table:1.0",textns:"urn:oasis:names:tc:opendocument:xmlns:text:1.0",xlinkns:"http://www.w3.org/1999/xlink",xmlns:"http://www.w3.org/XML/1998/namespace"}; (function(){var f=odf.Namespaces.namespaceMap,k=odf.Namespaces.prefixMap,d;for(d in f)f.hasOwnProperty(d)&&(k[f[d]]=d)})();odf.Namespaces.forEachPrefix=function(f){var k=odf.Namespaces.namespaceMap,d;for(d in k)k.hasOwnProperty(d)&&f(d,k[d])};odf.Namespaces.lookupNamespaceURI=function(f){var k=null;odf.Namespaces.namespaceMap.hasOwnProperty(f)&&(k=odf.Namespaces.namespaceMap[f]);return k};odf.Namespaces.lookupPrefix=function(f){var k=odf.Namespaces.prefixMap;return k.hasOwnProperty(f)?k[f]:null}; odf.Namespaces.lookupNamespaceURI.lookupNamespaceURI=odf.Namespaces.lookupNamespaceURI;xmldom.XPathIterator=function(){};xmldom.XPathIterator.prototype.next=function(){};xmldom.XPathIterator.prototype.reset=function(){}; function createXPathSingleton(){function f(b,e,a){return-1!==b&&(b=d&&a.push(k(b.substring(e,c)))):"["===b[c]&&(0>=d&&(e=c+1),d+=1),c+=1;return c};p=function(d,e,a){var f,g,h,p;for(f=0;f/g,">").replace(/'/g,"'").replace(/"/g,""")}function d(c,f){var r="",l=b.filter?b.filter.acceptNode(f):NodeFilter.FILTER_ACCEPT,p;if(l===NodeFilter.FILTER_ACCEPT&&f.nodeType===Node.ELEMENT_NODE){c.push();p=c.getQName(f);var n,q=f.attributes,e,a,m,g="",z;n="<"+p;e=q.length;for(a=0;a")}if(l===NodeFilter.FILTER_ACCEPT||l===NodeFilter.FILTER_SKIP){for(l=f.firstChild;l;)r+=d(c,l),l=l.nextSibling;f.nodeValue&&(r+=k(f.nodeValue))}p&&(r+="",c.pop());return r}var b=this;this.filter=null;this.writeToString=function(b,h){if(!b)return"";var k=new f(h);return d(k,b)}};(function(){function f(b){var e,a=l.length;for(e=0;ea)break;d=d.nextSibling}b.insertBefore(e,d)}}}var c=new odf.StyleInfo,h=new core.DomUtils,r=odf.Namespaces.stylens,l="meta settings scripts font-face-decls styles automatic-styles master-styles body".split(" "), p=Date.now()+"_webodf_",n=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,e,a,c){var d=this;this.size=0;this.type=null;this.name=b;this.container=a;this.url=null;this.mimetype=e;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=e,c.loadAsDataURL(b,e,function(a,b){a&&runtime.log(a);d.url=b;if(d.onchange)d.onchange(d);if(d.onstatereadychange)d.onstatereadychange(d)}))}};odf.OdfPart.prototype.load=function(){}; odf.OdfPart.prototype.getUrl=function(){return this.data?"data:;base64,"+n.toBase64(this.data):null};odf.OdfContainer=function e(a,f){function g(a){for(var b=a.firstChild,e;b;)e=b.nextSibling,b.nodeType===Node.ELEMENT_NODE?g(b):b.nodeType===Node.PROCESSING_INSTRUCTION_NODE&&a.removeChild(b),b=e}function l(a){var b={},e,c,d=a.ownerDocument.createNodeIterator(a,NodeFilter.SHOW_ELEMENT,null,!1);for(a=d.nextNode();a;)"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===a.namespaceURI&&("annotation"=== a.localName?(e=a.getAttributeNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0","name"))&&(b.hasOwnProperty(e)?runtime.log("Warning: annotation name used more than once with : '"+e+"'"):b[e]=a):"annotation-end"===a.localName&&((e=a.getAttributeNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0","name"))?b.hasOwnProperty(e)?(c=b[e],c.annotationEndElement?runtime.log("Warning: annotation name used more than once with : '"+e+"'"):c.annotationEndElement= a):runtime.log("Warning: annotation end without an annotation start, name: '"+e+"'"):runtime.log("Warning: annotation end without a name found"))),a=d.nextNode()}function t(a,b){for(var e=a&&a.firstChild;e;)e.nodeType===Node.ELEMENT_NODE&&e.setAttributeNS("urn:webodf:names:scope","scope",b),e=e.nextSibling}function v(a,b){for(var e=J.rootElement.meta,e=e&&e.firstChild;e&&(e.namespaceURI!==a||e.localName!==b);)e=e.nextSibling;for(e=e&&e.firstChild;e&&e.nodeType!==Node.TEXT_NODE;)e=e.nextSibling;return e? e.data:null}function y(a){var b={},e;for(a=a.firstChild;a;)a.nodeType===Node.ELEMENT_NODE&&a.namespaceURI===r&&"font-face"===a.localName&&(e=a.getAttributeNS(r,"name"),b[e]=a),a=a.nextSibling;return b}function s(a,b){var e=null,c,d,g;if(a)for(e=a.cloneNode(!0),c=e.firstElementChild;c;)d=c.nextElementSibling,(g=c.getAttributeNS("urn:webodf:names:scope","scope"))&&g!==b&&e.removeChild(c),c=d;return e}function x(a,b){var e,d,g,f=null,m={};if(a)for(b.forEach(function(a){c.collectUsedFontFaces(m,a)}), f=a.cloneNode(!0),e=f.firstElementChild;e;)d=e.nextElementSibling,g=e.getAttributeNS(r,"name"),m[g]||f.removeChild(e),e=d;return f}function w(a){var b=J.rootElement.ownerDocument,e;if(a){g(a.documentElement);try{e=b.importNode(a.documentElement,!0)}catch(c){}}return e}function A(a){J.state=a;if(J.onchange)J.onchange(J);if(J.onstatereadychange)J.onstatereadychange(J)}function G(a){aa=null;J.rootElement=a;a.fontFaceDecls=h.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","font-face-decls"); a.styles=h.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","styles");a.automaticStyles=h.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","automatic-styles");a.masterStyles=h.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","master-styles");a.body=h.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","body");a.meta=h.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","meta");a.settings=h.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0", "settings");a.scripts=h.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","scripts");l(a)}function E(a){var d=w(a),g=J.rootElement,f;d&&"document-styles"===d.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===d.namespaceURI?(g.fontFaceDecls=h.getDirectChild(d,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","font-face-decls"),b(g,g.fontFaceDecls),f=h.getDirectChild(d,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","styles"),g.styles=f||a.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0", "styles"),b(g,g.styles),f=h.getDirectChild(d,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","automatic-styles"),g.automaticStyles=f||a.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0","automatic-styles"),t(g.automaticStyles,"document-styles"),b(g,g.automaticStyles),d=h.getDirectChild(d,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","master-styles"),g.masterStyles=d||a.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0","master-styles"),b(g,g.masterStyles), c.prefixStyleNames(g.automaticStyles,p,g.masterStyles)):A(e.INVALID)}function F(a){a=w(a);var d,g,f,m;if(a&&"document-content"===a.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===a.namespaceURI){d=J.rootElement;f=h.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","font-face-decls");if(d.fontFaceDecls&&f){m=d.fontFaceDecls;var l,p,k,n,E={};g=y(m);n=y(f);for(f=f.firstElementChild;f;){l=f.nextElementSibling;if(f.namespaceURI===r&&"font-face"===f.localName)if(p=f.getAttributeNS(r, "name"),g.hasOwnProperty(p)){if(!f.isEqualNode(g[p])){k=p;for(var s=g,z=n,U=0,F=void 0,F=k=k.replace(/\d+$/,"");s.hasOwnProperty(F)||z.hasOwnProperty(F);)U+=1,F=k+U;k=F;f.setAttributeNS(r,"style:name",k);m.appendChild(f);g[k]=f;delete n[p];E[p]=k}}else m.appendChild(f),g[p]=f,delete n[p];f=l}m=E}else f&&(d.fontFaceDecls=f,b(d,f));g=h.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","automatic-styles");t(g,"document-content");m&&c.changeFontFaceNames(g,m);if(d.automaticStyles&&g)for(m= g.firstChild;m;)d.automaticStyles.appendChild(m),m=g.firstChild;else g&&(d.automaticStyles=g,b(d,g));a=h.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","body");if(null===a)throw" tag is mising.";d.body=a;b(d,d.body)}else A(e.INVALID)}function H(a){a=w(a);var e;a&&"document-meta"===a.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===a.namespaceURI&&(e=J.rootElement,e.meta=h.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","meta"), b(e,e.meta))}function N(a){a=w(a);var e;a&&"document-settings"===a.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===a.namespaceURI&&(e=J.rootElement,e.settings=h.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","settings"),b(e,e.settings))}function I(a){a=w(a);var b;if(a&&"manifest"===a.localName&&"urn:oasis:names:tc:opendocument:xmlns:manifest:1.0"===a.namespaceURI)for(b=J.rootElement,b.manifest=a,a=b.manifest.firstElementChild;a;)"file-entry"===a.localName&&"urn:oasis:names:tc:opendocument:xmlns:manifest:1.0"=== a.namespaceURI&&(V[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,b,e){a=h.getElementsByTagName(a,b);var c;for(c=0;c'}function Y(){var a=new xmldom.LSSerializer,b=u("document-meta");a.filter=new odf.OdfNodeFilter;b+=a.writeToString(J.rootElement.meta,odf.Namespaces.namespaceMap);return b+""}function $(a,b){var e=document.createElementNS("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0","manifest:file-entry");e.setAttributeNS("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0","manifest:full-path",a);e.setAttributeNS("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0", "manifest:media-type",b);return e}function ea(){var a=runtime.parseXML(''),b=a.documentElement,e=new xmldom.LSSerializer,c;for(c in V)V.hasOwnProperty(c)&&b.appendChild($(c,V[c]));e.filter=new odf.OdfNodeFilter;return'\n'+e.writeToString(a,odf.Namespaces.namespaceMap)}function D(){var a,b,e,d=odf.Namespaces.namespaceMap, g=new xmldom.LSSerializer,f=u("document-styles");b=s(J.rootElement.automaticStyles,"document-styles");e=J.rootElement.masterStyles.cloneNode(!0);a=x(J.rootElement.fontFaceDecls,[e,J.rootElement.styles,b]);c.removePrefixFromStyleNames(b,p,e);g.filter=new k(e,b);f+=g.writeToString(a,d);f+=g.writeToString(J.rootElement.styles,d);f+=g.writeToString(b,d);f+=g.writeToString(e,d);return f+""}function P(){var a,b,e=odf.Namespaces.namespaceMap,c=new xmldom.LSSerializer,g=u("document-content"); b=s(J.rootElement.automaticStyles,"document-content");a=x(J.rootElement.fontFaceDecls,[b]);c.filter=new d(J.rootElement.body,b);g+=c.writeToString(a,e);g+=c.writeToString(b,e);g+=c.writeToString(J.rootElement.body,e);return g+""}function X(a,b){runtime.loadXML(a,function(a,c){if(a)b(a);else if(c){B(c);Z(c.documentElement);var d=w(c);d&&"document"===d.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===d.namespaceURI?(G(d),A(e.DONE)):A(e.INVALID)}else b("No DOM was loaded.")})} function C(a,e){var c;c=J.rootElement;var d=c.meta;d||(c.meta=d=document.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0","meta"),b(c,d));c=d;a&&h.mapKeyValObjOntoNode(c,a,odf.Namespaces.lookupNamespaceURI);e&&h.removeKeyElementsFromNode(c,e,odf.Namespaces.lookupNamespaceURI)}function T(a){function b(a,e){var c;e||(e=a);c=document.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0",e);g[a]=c;g.appendChild(c)}var c=new core.Zip("",null),d=runtime.byteArrayFromString("application/vnd.oasis.opendocument."+ a,"utf8"),g=J.rootElement,f=document.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0",a);c.save("mimetype",d,!1,new Date);b("meta");b("settings");b("scripts");b("fontFaceDecls","font-face-decls");b("styles");b("automaticStyles","automatic-styles");b("masterStyles","master-styles");b("body");g.body.appendChild(f);V["/"]="application/vnd.oasis.opendocument."+a;V["settings.xml"]="text/xml";V["meta.xml"]="text/xml";V["styles.xml"]="text/xml";V["content.xml"]="text/xml";A(e.DONE);return c} function L(){var a,b=new Date,e="";J.rootElement.settings&&J.rootElement.settings.firstElementChild&&(a=new xmldom.LSSerializer,e=u("document-settings"),a.filter=new odf.OdfNodeFilter,e+=a.writeToString(J.rootElement.settings,odf.Namespaces.namespaceMap),e+="");(a=e)?(a=runtime.byteArrayFromString(a,"utf8"),O.save("settings.xml",a,!0,b)):O.remove("settings.xml");e=runtime.getWindow();a="WebODF/"+webodf.Version;e&&(a=a+" "+e.navigator.userAgent);C({"meta:generator":a},null); a=runtime.byteArrayFromString(Y(),"utf8");O.save("meta.xml",a,!0,b);a=runtime.byteArrayFromString(D(),"utf8");O.save("styles.xml",a,!0,b);a=runtime.byteArrayFromString(P(),"utf8");O.save("content.xml",a,!0,b);a=runtime.byteArrayFromString(ea(),"utf8");O.save("META-INF/manifest.xml",a,!0,b)}function S(a,b){L();O.writeAs(a,function(a){b(a)})}var J=this,O,V={},aa,ba="";this.onstatereadychange=f;this.state=this.onchange=null;this.getMetadata=v;this.setRootElement=G;this.getContentElement=function(){var a; aa||(a=J.rootElement.body,aa=h.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","text")||h.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","presentation")||h.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","spreadsheet"));if(!aa)throw"Could not find content element in .";return aa};this.getDocumentType=function(){var a=J.getContentElement();return a&&a.localName};this.getPart=function(a){return new odf.OdfPart(a,V[a],J,O)};this.getPartData= function(a,b){O.load(a,b)};this.setMetadata=C;this.incrementEditingCycles=function(){var a=v(odf.Namespaces.metans,"editing-cycles"),a=a?parseInt(a,10):0;isNaN(a)&&(a=0);C({"meta:editing-cycles":a+1},null);return a+1};this.createByteArray=function(a,b){L();O.createByteArray(a,b)};this.saveAs=S;this.save=function(a){S(ba,a)};this.getUrl=function(){return ba};this.setBlob=function(a,b,e){e=n.convertBase64ToByteArray(e);O.save(a,e,!1,new Date);V.hasOwnProperty(a)&&runtime.log(a+" has been overwritten."); V[a]=b};this.removeBlob=function(a){var b=O.remove(a);runtime.assert(b,"file is not found: "+a);delete V[a]};this.state=e.LOADING;this.rootElement=function(a){var b=document.createElementNS(a.namespaceURI,a.localName),e;a=new a.Type;for(e in a)a.hasOwnProperty(e)&&(b[e]=a[e]);return b}({Type:odf.ODFDocumentElement,namespaceURI:odf.ODFDocumentElement.namespaceURI,localName:odf.ODFDocumentElement.localName});a===odf.OdfContainer.DocumentType.TEXT?O=T("text"):a===odf.OdfContainer.DocumentType.PRESENTATION? O=T("presentation"):a===odf.OdfContainer.DocumentType.SPREADSHEET?O=T("spreadsheet"):(ba=a,O=new core.Zip(ba,function(a,b){O=b;a?X(ba,function(b){a&&(O.error=a+"\n"+b,A(e.INVALID))}):Q([{path:"styles.xml",handler:E},{path:"content.xml",handler:F},{path:"meta.xml",handler:H},{path:"settings.xml",handler:N},{path:"META-INF/manifest.xml",handler:I}])}))};odf.OdfContainer.EMPTY=0;odf.OdfContainer.LOADING=1;odf.OdfContainer.DONE=2;odf.OdfContainer.INVALID=3;odf.OdfContainer.SAVING=4;odf.OdfContainer.MODIFIED= 5;odf.OdfContainer.getContainer=function(b){return new odf.OdfContainer(b,null)}})();odf.OdfContainer.DocumentType={TEXT:1,PRESENTATION:2,SPREADSHEET:3};odf.OdfUtils=function(){function f(a){return"image"===(a&&a.localName)&&a.namespaceURI===Z}function k(a){return null!==a&&a.nodeType===Node.ELEMENT_NODE&&"frame"===a.localName&&a.namespaceURI===Z&&"as-char"===a.getAttributeNS(B,"anchor-type")}function d(a){var b;(b="annotation"===(a&&a.localName)&&a.namespaceURI===odf.Namespaces.officens)||(b="div"===(a&&a.localName)&&"annotationWrapper"===a.className);return b}function b(a){return"a"===(a&&a.localName)&&a.namespaceURI===B}function c(a){var b=a&& a.localName;return("p"===b||"h"===b)&&a.namespaceURI===B}function h(a,b){for(a&&void 0!==b&&!c(a)&&a.childNodes.item(b)&&(a=a.childNodes.item(b));a&&!c(a);)a=a.parentNode;return a}function r(a,b){for(;a&&a!==b;){if(a.namespaceURI===odf.Namespaces.officens&&"annotation"===a.localName)return a;a=a.parentNode}return null}function l(a){return/^[ \t\r\n]+$/.test(a)}function p(a){if(null===a||a.nodeType!==Node.ELEMENT_NODE)return!1;var b=a.localName;return/^(span|p|h|a|meta)$/.test(b)&&a.namespaceURI=== B||"span"===b&&"webodf-annotationHighlight"===a.className}function n(a){var b=a&&a.localName,e=!1;b&&(a=a.namespaceURI,a===B&&(e="s"===b||"tab"===b||"line-break"===b));return e}function q(a){return n(a)||k(a)||d(a)}function e(a){var b=a&&a.localName,e=!1;b&&(a=a.namespaceURI,a===B&&(e="s"===b));return e}function a(a){return-1!==Y.indexOf(a.namespaceURI)}function m(b){if(n(b))return!1;if(p(b.parentNode)&&b.nodeType===Node.TEXT_NODE)return 0===b.textContent.length;for(b=b.firstChild;b;){if(a(b)||!m(b))return!1; b=b.nextSibling}return!0}function g(a){for(;null!==a.firstChild&&p(a);)a=a.firstChild;return a}function z(a){for(;null!==a.lastChild&&p(a);)a=a.lastChild;return a}function t(a){for(;!c(a)&&null===a.previousSibling;)a=a.parentNode;return c(a)?null:z(a.previousSibling)}function v(a){for(;!c(a)&&null===a.nextSibling;)a=a.parentNode;return c(a)?null:g(a.nextSibling)}function y(a){for(var b=!1;a;)if(a.nodeType===Node.TEXT_NODE)if(0===a.length)a=t(a);else return!l(a.data.substr(a.length-1,1));else q(a)? (b=!1===e(a),a=null):a=t(a);return b}function s(a){var b=!1,e;for(a=a&&g(a);a;){e=a.nodeType===Node.TEXT_NODE?a.length:0;if(0a.value||"%"===a.unit)?null:a}function E(a){return(a=A(a))&&"%"!==a.unit?null:a}function F(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 H(a,b){for(;0=b.value||"%"===b.unit)?null:b;return b||E(a)};this.parseFoLineHeight=function(a){return G(a)||E(a)};this.isTextContentContainingNode=F;this.getTextNodes=function(a,b){var e;e=u.getNodesInRange(a,function(a){var b=NodeFilter.FILTER_REJECT;a.nodeType===Node.TEXT_NODE?Boolean(h(a)&&(!l(a.textContent)||w(a,0)))&&(b=NodeFilter.FILTER_ACCEPT):F(a)&&(b=NodeFilter.FILTER_SKIP);return b},NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT);b||H(a,e);return e};this.getTextElements=N;this.getParagraphElements= function(a){var b;b=u.getNodesInRange(a,function(a){var b=NodeFilter.FILTER_REJECT;if(c(a))b=NodeFilter.FILTER_ACCEPT;else if(F(a)||p(a))b=NodeFilter.FILTER_SKIP;return b},NodeFilter.SHOW_ELEMENT);I(a.startContainer,b,c);return b};this.getImageElements=function(a){var b;b=u.getNodesInRange(a,function(a){var b=NodeFilter.FILTER_SKIP;f(a)&&(b=NodeFilter.FILTER_ACCEPT);return b},NodeFilter.SHOW_ELEMENT);I(a.startContainer,b,f);return b};this.getHyperlinkElements=function(a){var e=[],d=a.cloneRange(); a.collapsed&&a.endContainer.nodeType===Node.ELEMENT_NODE&&(a=U(a.endContainer,a.endOffset),a.nodeType===Node.TEXT_NODE&&d.setEnd(a,1));N(d,!0,!1).forEach(function(a){for(a=a.parentNode;!c(a);){if(b(a)&&-1===e.indexOf(a)){e.push(a);break}a=a.parentNode}});d.detach();return e};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}};gui.AnnotatableCanvas=function(){};gui.AnnotatableCanvas.prototype.refreshSize=function(){};gui.AnnotatableCanvas.prototype.getZoomLevel=function(){};gui.AnnotatableCanvas.prototype.getSizer=function(){}; gui.AnnotationViewManager=function(f,k,d,b){function c(b){var e=b.annotationEndElement,c=n.createRange(),d=b.getAttributeNS(odf.Namespaces.officens,"name");e&&(c.setStart(b,b.childNodes.length),c.setEnd(e,0),b=q.getTextNodes(c,!1),b.forEach(function(b){var e;a:{for(e=b.parentNode;e.namespaceURI!==odf.Namespaces.officens||"body"!==e.localName;){if(e.namespaceURI===a&&"webodf-annotationHighlight"===e.className&&e.getAttribute("annotation")===d){e=!0;break a}e=e.parentNode}e=!1}e||(e=n.createElement("span"), e.className="webodf-annotationHighlight",e.setAttribute("annotation",d),b.parentNode.replaceChild(e,b),e.appendChild(b))}));c.detach()}function h(a){var b=f.getSizer();a?(d.style.display="inline-block",b.style.paddingRight=e.getComputedStyle(d).width):(d.style.display="none",b.style.paddingRight=0);f.refreshSize()}function r(){p.sort(function(a,b){return 0!==(a.compareDocumentPosition(b)&Node.DOCUMENT_POSITION_FOLLOWING)?-1:1})}function l(){var a;for(a=0;a=(l.getBoundingClientRect().top-k.bottom)/b?e.style.top=Math.abs(l.getBoundingClientRect().top-k.bottom)/b+20+"px":e.style.top="0px");h.style.left=c.getBoundingClientRect().width/ b+"px";var c=h.style,l=h.getBoundingClientRect().left/b,q=h.getBoundingClientRect().top/b,k=e.getBoundingClientRect().left/b,n=e.getBoundingClientRect().top/b,r=0,G=0,r=k-l,r=r*r,G=n-q,G=G*G,l=Math.sqrt(r+G);c.width=l+"px";q=Math.asin((e.getBoundingClientRect().top-h.getBoundingClientRect().top)/(b*parseFloat(h.style.width)));h.style.transform="rotate("+q+"rad)";h.style.MozTransform="rotate("+q+"rad)";h.style.WebkitTransform="rotate("+q+"rad)";h.style.msTransform="rotate("+q+"rad)"}}var p=[],n=k.ownerDocument, q=new odf.OdfUtils,e=runtime.getWindow(),a="http://www.w3.org/1999/xhtml";runtime.assert(Boolean(e),"Expected to be run in an environment which has a global window, like a browser.");this.rerenderAnnotations=l;this.rehighlightAnnotations=function(){p.forEach(function(a){c(a)})};this.getMinimumHeightForAnnotationPane=function(){return"none"!==d.style.display&&0 text|list-item:first-child > :not(text|list):first-child:before',x+="{",x+="counter-increment: "+s+" 0;",x+="}",f(b,x));for(;k.counterIdStack.length>=r;)k.counterIdStack.pop();k.counterIdStack.push(s);w=k.contentRules[r.toString()]||"";for(x=1;x<=r;x+=1)w=w.replace(x+"webodf-listLevel",k.counterIdStack[x-1]);x='text|list[webodfhelper|counter-id="'+q+'"] > text|list-item > :not(text|list):first-child:before'; x+="{";x+=w;x+="counter-increment: "+s+";";x+="}";f(b,x)}for(d=d.firstElementChild;d;)c(a,d,l,k),d=d.nextElementSibling}else k.continuedCounterIdStack=[]}var d=0,e="",a={};this.createCounterRules=function(b,e,f){var h=e.getAttributeNS(r,"id"),l=[];f&&(f=f.getAttributeNS("urn:webodf:names:helper","counter-id"),l=a[f].slice(0));b=new k(b,l);h?h="Y"+h:(d+=1,h="X"+d);c(h,e,0,b);a[h+"-level1-1"]=b.counterIdStack};this.initialiseCreatedCounters=function(){var a;a="office|document{"+("counter-reset: "+e+ ";");a+="}";f(b,a)}}var b=odf.Namespaces.fons,c=odf.Namespaces.stylens,h=odf.Namespaces.textns,r=odf.Namespaces.xmlns,l={1:"decimal",a:"lower-latin",A:"upper-latin",i:"lower-roman",I:"upper-roman"};odf.ListStyleToCss=function(){function p(b){var e=m.parseLength(b);return e?a.convert(e.value,e.unit,"px"):(runtime.log("Could not parse value '"+b+"'."),0)}function k(a){return a.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}function q(a,b){var e;a&&(e=a.getAttributeNS(h,"style-name"));return e===b}function e(a, b,e){b=b.getElementsByTagNameNS(h,"list");a=new d(a);var f,m,p,x,w,A,G={},E;for(E=0;E text|list-item > text|list",z-=1;z=t&&t.getAttributeNS(b,"text-align")||"left";switch(z){case "end":z="right";break;case "start":z="left"}"label-alignment"===N?(U=I&&I.getAttributeNS(b,"margin-left")||"0px",Q=I&&I.getAttributeNS(b,"text-indent")||"0px",u=I&&I.getAttributeNS(h,"label-followed-by"),I=p(U)):(U=t&&t.getAttributeNS(h,"space-before")||"0px",B=t&&t.getAttributeNS(h,"min-label-width")||"0px", Z=t&&t.getAttributeNS(h,"min-label-distance")||"0px",I=p(U)+p(B));t=q+" > text|list-item";t+="{";t+="margin-left: "+I+"px;";t+="}";f(m,t);t=q+" > text|list-item > text|list";t+="{";t+="margin-left: "+-I+"px;";t+="}";f(m,t);t=q+" > text|list-item > :not(text|list):first-child:before";t+="{";t+="text-align: "+z+";";t+="display: inline-block;";"label-alignment"===N?(t+="margin-left: "+Q+";","listtab"===u&&(t+="padding-right: 0.2cm;")):(t+="min-width: "+B+";",t+="margin-left: "+(0===parseFloat(B)?"": "-")+B+";",t+="padding-right: "+Z+";");t+="}";f(m,t)}d=d.nextElementSibling}});e(a,m,l)}}})();odf.Style2CSS=function(){function f(a,b,e){var c=[];e=e.derivedStyles;var d;var g=t[a],h;void 0===g?b=null:(h=b?"["+g+'|style-name="'+b+'"]':"","presentation"===g&&(g="draw",h=b?'[presentation|style-name="'+b+'"]':""),b=g+"|"+v[a].join(h+","+g+"|")+h);null!==b&&c.push(b);for(d in e)e.hasOwnProperty(d)&&(b=f(a,d,e[d]),c=c.concat(b));return c}function k(a,b){var e="",c,d,g;for(c=0;ch.value&&(g="0.75pt"+m)}d[2]&&(e+=d[2]+":"+g+";")}return e}function d(a){return(a=z.getDirectChild(a,q,"text-properties"))?B.parseFoFontSize(a.getAttributeNS(p,"font-size")):null}function b(a,b,e,c){return b+b+e+e+c+c}function c(a,b){var e=[a],d=b.derivedStyles;Object.keys(d).forEach(function(a){a=c(a,d[a]);e=e.concat(a)});return e}function h(a,b,e,d){function f(b,e){var c=[],d;b.forEach(function(a){h.forEach(function(b){c.push("draw|page[webodfhelper|page-style-name='"+ b+"'] draw|frame[presentation|class='"+a+"']")})});0=e?f=c(a,e-1,d,!0):a.nodeType===Node.TEXT_NODE&& 0a?-1:1;for(a=Math.abs(a);0q?n.previousPosition():n.nextPosition());)if(Q.check(),p.acceptPosition(n)===e&&(A+=1,r=n.container(),H=c(r,n.unfilteredDomOffset(),Z),H.top!==I)){if(H.top!==B&&B!==I)break;B=H.top;H=Math.abs(U-H.left);if(null===G||Ha?(g=p.previousPosition, f=-1):(g=p.nextPosition,f=1);for(h=c(p.container(),p.unfilteredDomOffset(),w);g.call(p);)if(b.acceptPosition(p)===e){if(n.getParagraphElement(p.getCurrentNode())!==q)break;l=c(p.container(),p.unfilteredDomOffset(),w);if(l.bottom!==h.bottom&&(h=l.top>=h.top&&l.bottomh.bottom,!h))break;r+=f;h=l}w.detach();return r}var n=new odf.OdfUtils,q,e=core.PositionFilter.FilterResult.FILTER_ACCEPT;this.getStepCounter=function(){return{convertForwardStepsBetweenFilters:h,convertBackwardStepsBetweenFilters:r, countLinesSteps:l,countStepsToLineBoundary:p}};(function(){q=gui.SelectionMover.createPositionIterator(k);var a=k.ownerDocument.createRange();a.setStart(q.container(),q.unfilteredDomOffset());a.collapse(!0);f.setSelectedRange(a)})()}; gui.SelectionMover.createPositionIterator=function(f){var k=new function(){this.acceptNode=function(d){return d&&"urn:webodf:names:cursor"!==d.namespaceURI&&"urn:webodf:names:editinfo"!==d.namespaceURI?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT}};return new core.PositionIterator(f,5,k,!1)};ops.Document=function(){};ops.Document.prototype.getMemberIds=function(){};ops.Document.prototype.removeCursor=function(f){};ops.Document.prototype.getDocumentElement=function(){};ops.Document.prototype.getRootNode=function(){};ops.Document.prototype.getDOMDocument=function(){};ops.Document.prototype.cloneDocumentElement=function(){};ops.Document.prototype.setDocumentElement=function(f){};ops.Document.prototype.subscribe=function(f,k){};ops.Document.prototype.unsubscribe=function(f,k){}; ops.Document.prototype.getCanvas=function(){};ops.Document.prototype.createRootFilter=function(f){};ops.Document.signalCursorAdded="cursor/added";ops.Document.signalCursorRemoved="cursor/removed";ops.Document.signalCursorMoved="cursor/moved";ops.Document.signalMemberAdded="member/added";ops.Document.signalMemberUpdated="member/updated";ops.Document.signalMemberRemoved="member/removed";ops.OdtCursor=function(f,k){var d=this,b={},c,h,r,l=new core.EventNotifier([ops.OdtCursor.signalCursorUpdated]);this.removeFromDocument=function(){r.remove()};this.subscribe=function(b,c){l.subscribe(b,c)};this.unsubscribe=function(b,c){l.unsubscribe(b,c)};this.getStepCounter=function(){return h.getStepCounter()};this.getMemberId=function(){return f};this.getNode=function(){return r.getNode()};this.getAnchorNode=function(){return r.getAnchorNode()};this.getSelectedRange=function(){return r.getSelectedRange()}; this.setSelectedRange=function(b,c){r.setSelectedRange(b,c);l.emit(ops.OdtCursor.signalCursorUpdated,d)};this.hasForwardSelection=function(){return r.hasForwardSelection()};this.getDocument=function(){return k};this.getSelectionType=function(){return c};this.setSelectionType=function(d){b.hasOwnProperty(d)?c=d:runtime.log("Invalid selection type: "+d)};this.resetSelectionType=function(){d.setSelectionType(ops.OdtCursor.RangeSelection)};r=new core.Cursor(k.getDOMDocument(),f);h=new gui.SelectionMover(r, k.getRootNode());b[ops.OdtCursor.RangeSelection]=!0;b[ops.OdtCursor.RegionSelection]=!0;d.resetSelectionType()};ops.OdtCursor.RangeSelection="Range";ops.OdtCursor.RegionSelection="Region";ops.OdtCursor.signalCursorUpdated="cursorUpdated";(function(){var f=0;ops.StepsCache=function(k,d,b){function c(a,e){var c=this;this.nodeId=a;this.steps=-1;this.node=e;this.previousBookmark=this.nextBookmark=null;this.setIteratorPosition=function(a){a.setPositionBeforeElement(e);b(c.steps,a)}}function h(a,e,c){var d=this;this.nodeId=a;this.steps=e;this.node=c;this.previousBookmark=this.nextBookmark=null;this.setIteratorPosition=function(a){a.setUnfilteredPosition(c,0);b(d.steps,a)}}function r(a,b){var e="["+a.nodeId;b&&(e+=" => "+b.nodeId);return e+ "]"}function l(){for(var a=v,b,e,c,d=new core.LoopWatchDog(0,1E5),f={};a;){d.check();(b=a.previousBookmark)?runtime.assert(b.nextBookmark===a,"Broken bookmark link to previous @"+r(b,a)):(runtime.assert(a===v,"Broken bookmark link @"+r(a)),runtime.assert(void 0===y||v===v||v.steps<=y,"Base point is damaged @"+r(a)));(e=a.nextBookmark)&&runtime.assert(e.previousBookmark===a,"Broken bookmark link to next @"+r(a,e));if(void 0===y||a===v||a.steps<=y)runtime.assert(t.containsNode(k,a.node),"Disconnected node is being reported as undamaged @"+ r(a)),b&&(c=a.node.compareDocumentPosition(b.node),runtime.assert(0===c||0!==(c&x),"Bookmark order with previous does not reflect DOM order @"+r(b,a))),e&&t.containsNode(k,e.node)&&(c=a.node.compareDocumentPosition(e.node),runtime.assert(0===c||0!==(c&s),"Bookmark order with next does not reflect DOM order @"+r(a,e)));a=a.nextBookmark}Object.keys(g).forEach(function(a){var b=g[a];(void 0===y||a<=y)&&runtime.assert(b.steps<=a,"Bookmark step of "+b.steps+" exceeds cached step lookup for "+a+" @"+r(b)); runtime.assert(!1===f.hasOwnProperty(b.nodeId),"Bookmark "+r(b)+" appears twice in cached step lookup at steps "+f[b.nodeId]+" and "+a);f[b.nodeId]=a})}function p(a){var b="";a.nodeType===Node.ELEMENT_NODE&&(b=a.getAttributeNS(m,"nodeId")||"");return b}function n(a){var b=f.toString();a.setAttributeNS(m,"nodeId",b);f+=1;return b}function q(a){var b,e,c=new core.LoopWatchDog(0,1E4);void 0!==y&&a>y&&(a=y);for(b=Math.floor(a/d)*d;!e&&0<=b;)e=g[b],b-=d;for(e=e||v;e.nextBookmark&&e.nextBookmark.steps<= a;)c.check(),e=e.nextBookmark;runtime.assert(-1===a||e.steps<=a,"Bookmark @"+r(e)+" at step "+e.steps+" exceeds requested step of "+a);return e}function e(a){a.previousBookmark&&(a.previousBookmark.nextBookmark=a.nextBookmark);a.nextBookmark&&(a.nextBookmark.previousBookmark=a.previousBookmark)}function a(a){for(var b,e=null;!e&&a&&a!==k;)(b=p(a))&&(e=z[b])&&e.node!==a&&(runtime.log("Cloned node detected. Creating new bookmark"),e=null,a.removeAttributeNS(m,"nodeId")),a=a.parentNode;return e}var m= "urn:webodf:names:steps",g={},z={},t=new core.DomUtils,v,y,s=Node.DOCUMENT_POSITION_FOLLOWING,x=Node.DOCUMENT_POSITION_PRECEDING,w;this.updateBookmark=function(a,b){var f,h=Math.ceil(a/d)*d,l,m,r;if(void 0!==y&&yl.steps)g[h]=m;w()};this.setToClosestStep=function(a,b){var e;w();e=q(a);e.setIteratorPosition(b); return e.steps};this.setToClosestDomPoint=function(b,e,c){var d,f;w();if(b===k&&0===e)d=v;else if(b===k&&e===k.childNodes.length)for(f in d=v,g)g.hasOwnProperty(f)&&(b=g[f],b.steps>d.steps&&(d=b));else if(d=a(b.childNodes.item(e)||b),!d)for(c.setUnfilteredPosition(b,e);!d&&c.previousNode();)d=a(c.getCurrentNode());d=d||v;void 0!==y&&d.steps>y&&(d=q(y));d.setIteratorPosition(c);return d.steps};this.damageCacheAfterStep=function(a){0>a&&(a=-1);void 0===y?y=a:ab)throw new RangeError("Requested steps is negative ("+b+")");r();for(e=n.setToClosestStep(b,a);ee.comparePoints(p,0,b,f),b=p,f=f?0:p.childNodes.length);a.setUnfilteredPosition(b,f);l(a,h)||a.setUnfilteredPosition(b,f);h=a.container();f=a.unfilteredDomOffset();b=n.setToClosestDomPoint(h,f,a);if(0>e.comparePoints(a.container(), a.unfilteredDomOffset(),h,f))return 0=n.textNode.length?null:n.textNode.splitText(n.offset));for(a=n.textNode;a!==e;){a=a.parentNode;m=a.cloneNode(!1);g&&m.appendChild(g);if(z)for(;z&&z.nextSibling;)m.appendChild(z.nextSibling);else for(;a.firstChild;)m.appendChild(a.firstChild);a.parentNode.insertBefore(m,a.nextSibling);z=a;g=m}r.isListItem(g)&&(g=g.childNodes.item(0));h?g.setAttributeNS(l,"text:style-name",h):g.removeAttributeNS(l,"style-name");0===n.textNode.length&& n.textNode.parentNode.removeChild(n.textNode);d.emit(ops.OdtDocument.signalStepsInserted,{position:b});t&&c&&(d.moveCursor(f,b+1,0),d.emit(ops.Document.signalCursorMoved,t));d.fixCursorPositions();d.getOdfCanvas().refreshSize();d.emit(ops.OdtDocument.signalParagraphChanged,{paragraphElement:q,memberId:f,timeStamp:k});d.emit(ops.OdtDocument.signalParagraphChanged,{paragraphElement:g,memberId:f,timeStamp:k});d.getOdfCanvas().rerenderAnnotations();return!0};this.spec=function(){return{optype:"SplitParagraph", memberid:f,timestamp:k,position:b,sourceParagraphPosition:d,paragraphStyleName:h,moveCursor:c}}};ops.OpUpdateMember=function(){function f(c){var d="//dc:creator[@editinfo:memberid='"+k+"']";c=xmldom.XPath.getODFElementsWithXPath(c.getRootNode(),d,function(b){return"editinfo"===b?"urn:webodf:names:editinfo":odf.Namespaces.lookupNamespaceURI(b)});for(d=0;d=h.width&&(h=null),f.detach();else if(k.isCharacterElement(c.container)||k.isCharacterFrame(c.container))h=b.getBoundingClientRect(c.container); return h}var k=new odf.OdfUtils,d=new odf.StepUtils,b=new core.DomUtils,c=core.StepDirection.NEXT,h=gui.StepInfo.VisualDirection.LEFT_TO_RIGHT,r=gui.StepInfo.VisualDirection.RIGHT_TO_LEFT;this.getContentRect=f;this.moveToFilteredStep=function(b,d,k){function q(a,b){b.process(y,g,z)&&(a=!0,!t&&b.token&&(t=b.token));return a}var e=d===c,a,m,g,z,t,v=b.snapshot();a=!1;var y;do a=f(b),y={token:b.snapshot(),container:b.container,offset:b.offset,direction:d,visualDirection:d===c?h:r},m=b.nextStep()?f(b): null,b.restore(y.token),e?(g=a,z=m):(g=m,z=a),a=k.reduce(q,!1);while(!a&&b.advanceStep(d));a||k.forEach(function(a){!t&&a.token&&(t=a.token)});b.restore(t||v);return Boolean(t)}};gui.Caret=function(f,k,d){function b(){n.style.opacity="0"===n.style.opacity?"1":"0";s.trigger()}function c(){m.selectNodeContents(a);return m.getBoundingClientRect()}function h(){Object.keys(G).forEach(function(a){E[a]=G[a]})}function r(){var a,b,m,l;if(!1===G.isShown||f.getSelectionType()!==ops.OdtCursor.RangeSelection||!d&&!f.getSelectedRange().collapsed)G.visibility="hidden",n.style.visibility="hidden",s.cancel();else{G.visibility="visible";n.style.visibility="visible";if(!1===G.isFocused)n.style.opacity= "1",s.cancel();else{if(x||E.visibility!==G.visibility)n.style.opacity="1",s.cancel();s.trigger()}if(A||w||E.visibility!==G.visibility){a=f.getNode();var k;m=z.getBoundingClientRect(g.getSizer());l=!1;if(0a.height&&(a={top:a.top-(8-a.height)/2,height:8,right:a.right});p.style.height=a.height+"px";p.style.top=a.top+"px";p.style.left=a.right+"px";e&&(a=runtime.getWindow().getComputedStyle(f.getNode(),null),a.font?e.style.font=a.font:(e.style.fontStyle=a.fontStyle,e.style.fontVariant=a.fontVariant,e.style.fontWeight= a.fontWeight,e.style.fontSize=a.fontSize,e.style.lineHeight=a.lineHeight,e.style.fontFamily=a.fontFamily))}if(w){k=f.getDocument().getCanvas().getElement().parentNode;var r;m=k.offsetWidth-k.clientWidth+5;l=k.offsetHeight-k.clientHeight+5;r=n.getBoundingClientRect();a=r.left-m;b=r.top-l;m=r.right+m;l=r.bottom+l;r=k.getBoundingClientRect();br.bottom&&(k.scrollTop+=l-r.bottom);ar.right&&(k.scrollLeft+=m-r.right)}}E.isFocused!==G.isFocused&& q.markAsFocussed(G.isFocused);h();A=w=x=!1}function l(b){p.parentNode.removeChild(p);a.parentNode.removeChild(a);b()}var p,n,q,e,a,m,g=f.getDocument().getCanvas(),z=new core.DomUtils,t=new gui.GuiStepUtils,v,y,s,x=!1,w=!1,A=!1,G={isFocused:!1,isShown:!0,visibility:"hidden"},E={isFocused:!G.isFocused,isShown:!G.isShown,visibility:"hidden"};this.handleUpdate=function(){A=!0;"hidden"!==G.visibility&&(G.visibility="hidden",n.style.visibility="hidden",f.getNode().removeAttributeNS("urn:webodf:names:cursor", "caret-sizer-active"));y.trigger()};this.refreshCursorBlinking=function(){x=!0;y.trigger()};this.setFocus=function(){G.isFocused=!0;y.trigger()};this.removeFocus=function(){G.isFocused=!1;y.trigger()};this.show=function(){G.isShown=!0;y.trigger()};this.hide=function(){G.isShown=!1;y.trigger()};this.setAvatarImageUrl=function(a){q.setImageUrl(a)};this.setColor=function(a){n.style.borderColor=a;q.setColor(a)};this.getCursor=function(){return f};this.getFocusElement=function(){return n};this.toggleHandleVisibility= function(){q.isVisible()?q.hide():q.show()};this.showHandle=function(){q.show()};this.hideHandle=function(){q.hide()};this.setOverlayElement=function(a){e=a;p.appendChild(a);A=!0;y.trigger()};this.ensureVisible=function(){w=!0;y.trigger()};this.getBoundingClientRect=function(){return z.getBoundingClientRect(p)};this.destroy=function(a){core.Async.destroyAll([y.destroy,s.destroy,q.destroy,l],a)};(function(){var e=f.getDocument(),c=[e.createRootFilter(f.getMemberId()),e.getPositionFilter()],d=e.getDOMDocument(); m=d.createRange();a=d.createElement("span");a.className="webodf-caretSizer";a.textContent="|";f.getNode().appendChild(a);p=d.createElement("div");p.setAttributeNS("urn:webodf:names:editinfo","editinfo:memberid",f.getMemberId());p.className="webodf-caretOverlay";n=d.createElement("div");n.className="caret";p.appendChild(n);q=new gui.Avatar(p,k);g.getSizer().appendChild(p);v=e.createStepIterator(f.getNode(),0,c,e.getRootNode());y=core.Task.createRedrawTask(r);s=core.Task.createTimeoutTask(b,500);y.triggerImmediate()})()};odf.TextSerializer=function(){function f(b){var c="",h=k.filter?k.filter.acceptNode(b):NodeFilter.FILTER_ACCEPT,r=b.nodeType,l;if((h===NodeFilter.FILTER_ACCEPT||h===NodeFilter.FILTER_SKIP)&&d.isTextContentContainingNode(b))for(l=b.firstChild;l;)c+=f(l),l=l.nextSibling;h===NodeFilter.FILTER_ACCEPT&&(r===Node.ELEMENT_NODE&&d.isParagraph(b)?c+="\n":r===Node.TEXT_NODE&&b.textContent&&(c+=b.textContent));return c}var k=this,d=new odf.OdfUtils;this.filter=null;this.writeToString=function(b){if(!b)return""; b=f(b);"\n"===b[b.length-1]&&(b=b.substr(0,b.length-1));return b}};gui.MimeDataExporter=function(){var f;this.exportRangeToDataTransfer=function(k,d){var b;b=d.startContainer.ownerDocument.createElement("span");b.appendChild(d.cloneContents());b=f.writeToString(b);try{k.setData("text/plain",b)}catch(c){k.setData("Text",b)}};f=new odf.TextSerializer;f.filter=new odf.OdfNodeFilter};gui.Clipboard=function(f){this.setDataFromRange=function(k,d){var b,c=k.clipboardData;b=runtime.getWindow();!c&&b&&(c=b.clipboardData);c?(b=!0,f.exportRangeToDataTransfer(c,d),k.preventDefault()):b=!1;return b}};gui.SessionContext=function(f,k){var d=f.getOdtDocument(),b=new odf.OdfUtils;this.isLocalCursorWithinOwnAnnotation=function(){var c=d.getCursor(k),f;if(!c)return!1;f=c&&c.getNode();c=d.getMember(k).getProperties().fullName;return(f=b.getParentAnnotation(f,d.getRootNode()))&&b.getAnnotationCreator(f)===c?!0:!1}};gui.StyleSummary=function(f){function k(b,d){var k=b+"|"+d,p;c.hasOwnProperty(k)||(p=[],f.forEach(function(c){c=(c=c.styleProperties[b])&&c[d];-1===p.indexOf(c)&&p.push(c)}),c[k]=p);return c[k]}function d(b,c,d){return function(){var f=k(b,c);return d.length>=f.length&&f.every(function(b){return-1!==d.indexOf(b)})}}function b(b,c){var d=k(b,c);return 1===d.length?d[0]:void 0}var c={};this.getPropertyValues=k;this.getCommonValue=b;this.isBold=d("style:text-properties","fo:font-weight",["bold"]);this.isItalic= d("style:text-properties","fo:font-style",["italic"]);this.hasUnderline=d("style:text-properties","style:text-underline-style",["solid"]);this.hasStrikeThrough=d("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=d("style:paragraph-properties","fo:text-align",["left","start"]);this.isAlignedCenter= d("style:paragraph-properties","fo:text-align",["center"]);this.isAlignedRight=d("style:paragraph-properties","fo:text-align",["right","end"]);this.isAlignedJustified=d("style:paragraph-properties","fo:text-align",["justify"]);this.text={isBold:this.isBold,isItalic:this.isItalic,hasUnderline:this.hasUnderline,hasStrikeThrough:this.hasStrikeThrough,fontSize:this.fontSize,fontName:this.fontName};this.paragraph={isAlignedLeft:this.isAlignedLeft,isAlignedCenter:this.isAlignedCenter,isAlignedRight:this.isAlignedRight, isAlignedJustified:this.isAlignedJustified}};gui.DirectFormattingController=function(f,k,d,b,c,h,r){function l(){return T.value().styleSummary}function p(a){var b;a.collapsed?(b=a.startContainer,b.hasChildNodes()&&a.startOffseta.clientWidth||a.scrollHeight>a.clientHeight)&&b.push(new q(a)),a=a.parentNode;b.push(new n(s));return b}function y(){var a; g()||(a=v(E),t(),E.focus(),a.forEach(function(a){a.restore()}))}var s=runtime.getWindow(),x={beforecut:!0,beforepaste:!0,longpress:!0,drag:!0,dragstop:!0},w={mousedown:!0,mouseup:!0,focus:!0},A={},G={},E,F=f.getCanvas().getElement(),H=this,N={};this.addFilter=function(a,b){e(a,!0).filters.push(b)};this.removeFilter=function(a,b){var c=e(a,!0),d=c.filters.indexOf(b);-1!==d&&c.filters.splice(d,1)};this.subscribe=a;this.unsubscribe=m;this.hasFocus=g;this.focus=y;this.getEventTrap=function(){return E}; this.setEditing=function(a){var b=g();b&&E.blur();a?E.removeAttribute("readOnly"):E.setAttribute("readOnly","true");b&&y()};this.destroy=function(a){m("touchstart",p);Object.keys(N).forEach(function(a){b(parseInt(a,10))});N.length=0;Object.keys(A).forEach(function(a){A[a].destroy()});A={};m("mousedown",z);m("mouseup",t);m("contextmenu",t);Object.keys(G).forEach(function(a){G[a].destroy()});G={};E.parentNode.removeChild(E);a()};(function(){var b=f.getOdfCanvas().getSizer(),e=b.ownerDocument;runtime.assert(Boolean(s), "EventManager requires a window object to operate correctly");E=e.createElement("input");E.id="eventTrap";E.setAttribute("tabindex","-1");E.setAttribute("readOnly","true");b.appendChild(E);a("mousedown",z);a("mouseup",t);a("contextmenu",t);A.longpress=new d("longpress",["touchstart","touchmove","touchend"],h);A.drag=new d("drag",["touchstart","touchmove","touchend"],r);A.dragstop=new d("dragstop",["drag","touchend"],l);a("touchstart",p)})()};gui.IOSSafariSupport=function(f){function k(){d.innerHeight!==d.outerHeight&&(b.style.display="none",runtime.requestAnimationFrame(function(){b.style.display="block"}))}var d=runtime.getWindow(),b=f.getEventTrap();this.destroy=function(c){f.unsubscribe("focus",k);b.removeAttribute("autocapitalize");b.style.WebkitTransform="";c()};f.subscribe("focus",k);b.setAttribute("autocapitalize","off");b.style.WebkitTransform="translateX(-10000px)"};gui.HyperlinkController=function(f,k,d,b){function c(){var b=!0;!0===k.getState(gui.CommonConstraints.EDIT.REVIEW_MODE)&&(b=d.isLocalCursorWithinOwnAnnotation());b!==n&&(n=b,p.emit(gui.HyperlinkController.enabledChanged,n))}function h(d){d.getMemberId()===b&&c()}var r=new odf.OdfUtils,l=f.getOdtDocument(),p=new core.EventNotifier([gui.HyperlinkController.enabledChanged]),n=!1;this.isEnabled=function(){return n};this.subscribe=function(b,e){p.subscribe(b,e)};this.unsubscribe=function(b,e){p.unsubscribe(b, e)};this.addHyperlink=function(c,e){if(n){var a=l.getCursorSelection(b),d=new ops.OpApplyHyperlink,g=[];if(0===a.length||e)e=e||c,d=new ops.OpInsertText,d.init({memberid:b,position:a.position,text:e}),a.length=e.length,g.push(d);d=new ops.OpApplyHyperlink;d.init({memberid:b,position:a.position,length:a.length,hyperlink:c});g.push(d);f.enqueue(g)}};this.removeHyperlinks=function(){if(n){var c=gui.SelectionMover.createPositionIterator(l.getRootNode()),e=l.getCursor(b).getSelectedRange(),a=r.getHyperlinkElements(e), d=e.collapsed&&1===a.length,g=l.getDOMDocument().createRange(),h=[],k,p;0!==a.length&&(a.forEach(function(a){g.selectNodeContents(a);k=l.convertDomToCursorRange({anchorNode:g.startContainer,anchorOffset:g.startOffset,focusNode:g.endContainer,focusOffset:g.endOffset});p=new ops.OpRemoveHyperlink;p.init({memberid:b,position:k.position,length:k.length});h.push(p)}),d||(d=a[0],-1===e.comparePoint(d,0)&&(g.setStart(d,0),g.setEnd(e.startContainer,e.startOffset),k=l.convertDomToCursorRange({anchorNode:g.startContainer, anchorOffset:g.startOffset,focusNode:g.endContainer,focusOffset:g.endOffset}),0h.width&&(r=h.width/k.width);k.height>h.height&&(y=h.height/k.height);h=Math.min(r,y);k={width:k.width*h,height:k.height*h}}h=k.width+ "px";k=k.height+"px";var s=n.getOdfCanvas().odfContainer().rootElement.styles,r=e.toLowerCase(),y=l.hasOwnProperty(r)?l[r]:null,x,r=[];runtime.assert(null!==y,"Image type is not supported: "+e);y="Pictures/"+c.generateImageName()+y;x=new ops.OpSetBlob;x.init({memberid:b,filename:y,mimetype:e,content:d});r.push(x);q.getStyleElement("Graphics","graphic",[s])||(e=new ops.OpAddStyle,e.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"}}}),r.push(e));e=c.generateStyleName();d=new ops.OpAddStyle;d.init({memberid:b,styleName:e,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"}}});r.push(d);x=new ops.OpInsertImage;x.init({memberid:b,position:n.getCursorPosition(b), filename:y,frameWidth:h,frameHeight:k,frameStyleName:e,frameName:c.generateFrameName()});r.push(x);f.enqueue(r)}};this.destroy=function(a){n.unsubscribe(ops.Document.signalCursorMoved,r);k.unsubscribe(gui.CommonConstraints.EDIT.REVIEW_MODE,h);a()};n.subscribe(ops.Document.signalCursorMoved,r);k.subscribe(gui.CommonConstraints.EDIT.REVIEW_MODE,h);h()};gui.ImageController.enabledChanged="enabled/changed";gui.ImageSelector=function(f){function k(){var d=f.getSizer(),h=c.createElement("div");h.id="imageSelector";h.style.borderWidth="1px";d.appendChild(h);b.forEach(function(b){var d=c.createElement("div");d.className=b;h.appendChild(d)});return h}var d=odf.Namespaces.svgns,b="topLeft topRight bottomRight bottomLeft topMiddle rightMiddle bottomMiddle leftMiddle".split(" "),c=f.getElement().ownerDocument,h=!1;this.select=function(b){var l,p,n=c.getElementById("imageSelector");n||(n=k());h=!0;l=n.parentNode; p=b.getBoundingClientRect();var q=l.getBoundingClientRect(),e=f.getZoomLevel();l=(p.left-q.left)/e-1;p=(p.top-q.top)/e-1;n.style.display="block";n.style.left=l+"px";n.style.top=p+"px";n.style.width=b.getAttributeNS(d,"width");n.style.height=b.getAttributeNS(d,"height")};this.clearSelection=function(){var b;h&&(b=c.getElementById("imageSelector"))&&(b.style.display="none");h=!1};this.isSelectorElement=function(b){var d=c.getElementById("imageSelector");return d?b===d||b.parentNode===d:!1}};(function(){function f(f){function d(b){r=b.which&&String.fromCharCode(b.which)===h;h=void 0;return!1===r}function b(){r=!1}function c(b){h=b.data;r=!1}var h,r=!1;this.destroy=function(h){f.unsubscribe("textInput",b);f.unsubscribe("compositionend",c);f.removeFilter("keypress",d);h()};f.subscribe("textInput",b);f.subscribe("compositionend",c);f.addFilter("keypress",d)}gui.InputMethodEditor=function(k,d){function b(b){a&&(b?a.getNode().setAttributeNS(e,"composing","true"):(a.getNode().removeAttributeNS(e, "composing"),z.textContent=""))}function c(){y&&(y=!1,b(!1),x.emit(gui.InputMethodEditor.signalCompositionEnd,{data:s}),s="")}function h(){c();a&&a.getSelectedRange().collapsed?m.value="":m.value=t;m.setSelectionRange(0,m.value.length)}function r(){d.hasFocus()&&v.trigger()}function l(){w=void 0;v.cancel();b(!0);y||x.emit(gui.InputMethodEditor.signalCompositionStart,{data:""})}function p(a){a=w=a.data;y=!0;s+=a;v.trigger()}function n(a){a.data!==w&&(a=a.data,y=!0,s+=a,v.trigger());w=void 0}function q(){z.textContent= m.value}var e="urn:webodf:names:cursor",a=null,m=d.getEventTrap(),g=m.ownerDocument,z,t="b",v,y=!1,s="",x=new core.EventNotifier([gui.InputMethodEditor.signalCompositionStart,gui.InputMethodEditor.signalCompositionEnd]),w,A=[],G;this.subscribe=x.subscribe;this.unsubscribe=x.unsubscribe;this.registerCursor=function(b){b.getMemberId()===k&&(a=b,a.getNode().appendChild(z),b.subscribe(ops.OdtCursor.signalCursorUpdated,r),d.subscribe("input",q),d.subscribe("compositionupdate",q))};this.removeCursor=function(b){a&& b===k&&(a.getNode().removeChild(z),a.unsubscribe(ops.OdtCursor.signalCursorUpdated,r),d.unsubscribe("input",q),d.unsubscribe("compositionupdate",q),a=null)};this.destroy=function(a){d.unsubscribe("compositionstart",l);d.unsubscribe("compositionend",p);d.unsubscribe("textInput",n);d.unsubscribe("keypress",c);d.unsubscribe("focus",h);core.Async.destroyAll(G,a)};(function(){d.subscribe("compositionstart",l);d.subscribe("compositionend",p);d.subscribe("textInput",n);d.subscribe("keypress",c);d.subscribe("focus", h);A.push(new f(d));G=A.map(function(a){return a.destroy});z=g.createElement("span");z.setAttribute("id","composer");v=core.Task.createTimeoutTask(h,1);G.push(v.destroy)})()};gui.InputMethodEditor.signalCompositionStart="input/compositionstart";gui.InputMethodEditor.signalCompositionEnd="input/compositionend"})();gui.MetadataController=function(f,k){function d(b){h.emit(gui.MetadataController.signalMetadataChanged,b)}function b(b){var c=-1===r.indexOf(b);c||runtime.log("Setting "+b+" is restricted.");return c}var c=f.getOdtDocument(),h=new core.EventNotifier([gui.MetadataController.signalMetadataChanged]),r=["dc:creator","dc:date","meta:editing-cycles","meta:editing-duration","meta:document-statistic"];this.setMetadata=function(c,d){var h={},r="",e;c&&Object.keys(c).filter(b).forEach(function(a){h[a]=c[a]}); d&&(r=d.filter(b).join(","));if(0c:!1}function d(b){null!==b&&!1===k(b)&&(c=Math.abs(b-f))}var b=this,c,h=gui.StepInfo.VisualDirection.LEFT_TO_RIGHT;this.token=void 0;this.process=function(c,f,p){var n,q;c.visualDirection===h?(n=f&&f.right,q=p&&p.left):(n=f&&f.left,q=p&&p.right);if(k(n)||k(q))return!0;if(f||p)d(n),d(q),b.token=c.token;return!1}};gui.LineBoundaryScanner=function(){var f=this,k=null;this.token=void 0;this.process=function(d,b,c){var h;if(h=c)if(k){var r=k;h=Math.min(r.bottom-r.top,c.bottom-c.top);var l=Math.max(r.top,c.top),r=Math.min(r.bottom,c.bottom)-l;h=0.4>=(0b?a.previousSibling:a.nextSibling,e(h)===NodeFilter.FILTER_ACCEPT&&(c=h),a=a.parentNode;return c}function b(a,b){var e;return null===a?m.NO_NEIGHBOUR:r.isCharacterElement(a)?m.SPACE_CHAR:a.nodeType===c||r.isTextSpan(a)||r.isHyperlink(a)?(e=a.textContent.charAt(b()),p.test(e)?m.SPACE_CHAR:l.test(e)?m.PUNCTUATION_CHAR:m.WORD_CHAR):m.OTHER}var c=Node.TEXT_NODE,h=Node.ELEMENT_NODE, r=new odf.OdfUtils,l=/[!-#%-*,-\/:-;?-@\[-\]_{}\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]/, p=/\s/,n=core.PositionFilter.FilterResult.FILTER_ACCEPT,q=core.PositionFilter.FilterResult.FILTER_REJECT,e=odf.WordBoundaryFilter.IncludeWhitespace.TRAILING,a=odf.WordBoundaryFilter.IncludeWhitespace.LEADING,m={NO_NEIGHBOUR:0,SPACE_CHAR:1,PUNCTUATION_CHAR:2,WORD_CHAR:3,OTHER:4};this.acceptPosition=function(c){var f=c.container(),l=c.leftNode(),r=c.rightNode(),p=c.unfilteredDomOffset,s=function(){return c.unfilteredDomOffset()-1};f.nodeType===h&&(null===r&&(r=d(f,1,c.getNodeFilter())),null===l&&(l= d(f,-1,c.getNodeFilter())));f!==r&&(p=function(){return 0});f!==l&&null!==l&&(s=function(){return l.textContent.length-1});f=b(l,s);r=b(r,p);return f===m.WORD_CHAR&&r===m.WORD_CHAR||f===m.PUNCTUATION_CHAR&&r===m.PUNCTUATION_CHAR||k===e&&f!==m.NO_NEIGHBOUR&&r===m.SPACE_CHAR||k===a&&f===m.SPACE_CHAR&&r!==m.NO_NEIGHBOUR?q:n}};odf.WordBoundaryFilter.IncludeWhitespace={None:0,TRAILING:1,LEADING:2};gui.SelectionController=function(f,k){function d(a){var b=a.spec();if(a.isEdit||b.memberid===k)G=void 0,E.cancel()}function b(){var a=t.getCursor(k).getNode();return t.createStepIterator(a,0,[s,w],t.getRootElement(a))}function c(a,b,e){e=new odf.WordBoundaryFilter(t,e);var c=t.getRootElement(a)||t.getRootNode(),d=t.createRootFilter(c);return t.createStepIterator(a,b,[s,d,e],c)}function h(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 r(a,b,e){var c=new ops.OpMoveCursor;c.init({memberid:k,position:a,length:b||0,selectionType:e});return c}function l(a,b,e){var c;c=t.getCursor(k);c=h(c.getSelectedRange(),c.hasForwardSelection());c.focusNode=a;c.focusOffset=b;e||(c.anchorNode=c.focusNode,c.anchorOffset=c.focusOffset);a=t.convertDomToCursorRange(c);f.enqueue([r(a.position,a.length)])}function p(a){var b;b=c(a.startContainer, a.startOffset,F);b.roundToPreviousStep()&&a.setStart(b.container(),b.offset());b=c(a.endContainer,a.endOffset,H);b.roundToNextStep()&&a.setEnd(b.container(),b.offset())}function n(a){var b=y.getParagraphElements(a),e=b[0],b=b[b.length-1];e&&a.setStart(e,0);b&&(y.isParagraph(a.endContainer)&&0===a.endOffset?a.setEndBefore(b):a.setEnd(b,b.childNodes.length))}function q(a,b,e,c){var d,f;c?(d=e.startContainer,f=e.startOffset):(d=e.endContainer,f=e.endOffset);v.containsNode(a,d)||(f=0>v.comparePoints(a, 0,d,f)?0:a.childNodes.length,d=a);a=t.createStepIterator(d,f,b,y.getParagraphElement(d)||a);a.roundToClosestStep()||runtime.assert(!1,"No step found in requested range");c?e.setStart(a.container(),a.offset()):e.setEnd(a.container(),a.offset())}function e(a,e){var c=b();c.advanceStep(a)&&l(c.container(),c.offset(),e)}function a(a,e){var c,d=G,f=[new gui.LineBoundaryScanner,new gui.ParagraphBoundaryScanner];void 0===d&&A&&(d=A());isNaN(d)||(c=b(),x.moveToFilteredStep(c,a,f)&&c.advanceStep(a)&&(f=[new gui.ClosestXOffsetScanner(d), new gui.LineBoundaryScanner,new gui.ParagraphBoundaryScanner],x.moveToFilteredStep(c,a,f)&&(l(c.container(),c.offset(),e),G=d,E.restart())))}function m(a,e){var c=b(),d=[new gui.LineBoundaryScanner,new gui.ParagraphBoundaryScanner];x.moveToFilteredStep(c,a,d)&&l(c.container(),c.offset(),e)}function g(a,b){var e=t.getCursor(k),e=h(e.getSelectedRange(),e.hasForwardSelection()),e=c(e.focusNode,e.focusOffset,F);e.advanceStep(a)&&l(e.container(),e.offset(),b)}function z(a,b,e){var c=!1,d=t.getCursor(k), d=h(d.getSelectedRange(),d.hasForwardSelection()),c=t.getRootElement(d.focusNode);runtime.assert(Boolean(c),"SelectionController: Cursor outside root");d=t.createStepIterator(d.focusNode,d.focusOffset,[s,w],c);d.roundToClosestStep();d.advanceStep(a)&&(e=e(d.container()))&&(a===N?(d.setPosition(e,0),c=d.roundToNextStep()):(d.setPosition(e,e.childNodes.length),c=d.roundToPreviousStep()),c&&l(d.container(),d.offset(),b))}var t=f.getOdtDocument(),v=new core.DomUtils,y=new odf.OdfUtils,s=t.getPositionFilter(), x=new gui.GuiStepUtils,w=t.createRootFilter(k),A=null,G,E,F=odf.WordBoundaryFilter.IncludeWhitespace.TRAILING,H=odf.WordBoundaryFilter.IncludeWhitespace.LEADING,N=core.StepDirection.PREVIOUS,I=core.StepDirection.NEXT;this.selectionToRange=function(a){var b=0<=v.comparePoints(a.anchorNode,a.anchorOffset,a.focusNode,a.focusOffset),e=a.focusNode.ownerDocument.createRange();b?(e.setStart(a.anchorNode,a.anchorOffset),e.setEnd(a.focusNode,a.focusOffset)):(e.setStart(a.focusNode,a.focusOffset),e.setEnd(a.anchorNode, a.anchorOffset));return{range:e,hasForwardSelection:b}};this.rangeToSelection=h;this.selectImage=function(a){var b=t.getRootElement(a),e=t.createRootFilter(b),b=t.createStepIterator(a,0,[e,t.getPositionFilter()],b),c;b.roundToPreviousStep()||runtime.assert(!1,"No walkable position before frame");e=b.container();c=b.offset();b.setPosition(a,a.childNodes.length);b.roundToNextStep()||runtime.assert(!1,"No walkable position after frame");a=t.convertDomToCursorRange({anchorNode:e,anchorOffset:c,focusNode:b.container(), focusOffset:b.offset()});a=r(a.position,a.length,ops.OdtCursor.RegionSelection);f.enqueue([a])};this.expandToWordBoundaries=p;this.expandToParagraphBoundaries=n;this.selectRange=function(a,b,e){var c=t.getOdfCanvas().getElement(),d,g=[s];d=v.containsNode(c,a.startContainer);c=v.containsNode(c,a.endContainer);if(d||c)if(d&&c&&(2===e?p(a):3<=e&&n(a)),(e=b?t.getRootElement(a.startContainer):t.getRootElement(a.endContainer))||(e=t.getRootNode()),g.push(t.createRootFilter(e)),q(e,g,a,!0),q(e,g,a,!1),a= h(a,b),b=t.convertDomToCursorRange(a),a=t.getCursorSelection(k),b.position!==a.position||b.length!==a.length)a=r(b.position,b.length,ops.OdtCursor.RangeSelection),f.enqueue([a])};this.moveCursorToLeft=function(){e(N,!1);return!0};this.moveCursorToRight=function(){e(I,!1);return!0};this.extendSelectionToLeft=function(){e(N,!0);return!0};this.extendSelectionToRight=function(){e(I,!0);return!0};this.setCaretXPositionLocator=function(a){A=a};this.moveCursorUp=function(){a(N,!1);return!0};this.moveCursorDown= function(){a(I,!1);return!0};this.extendSelectionUp=function(){a(N,!0);return!0};this.extendSelectionDown=function(){a(I,!0);return!0};this.moveCursorBeforeWord=function(){g(N,!1);return!0};this.moveCursorPastWord=function(){g(I,!1);return!0};this.extendSelectionBeforeWord=function(){g(N,!0);return!0};this.extendSelectionPastWord=function(){g(I,!0);return!0};this.moveCursorToLineStart=function(){m(N,!1);return!0};this.moveCursorToLineEnd=function(){m(I,!1);return!0};this.extendSelectionToLineStart= function(){m(N,!0);return!0};this.extendSelectionToLineEnd=function(){m(I,!0);return!0};this.extendSelectionToParagraphStart=function(){z(N,!0,t.getParagraphElement);return!0};this.extendSelectionToParagraphEnd=function(){z(I,!0,t.getParagraphElement);return!0};this.moveCursorToParagraphStart=function(){z(N,!1,t.getParagraphElement);return!0};this.moveCursorToParagraphEnd=function(){z(I,!1,t.getParagraphElement);return!0};this.moveCursorToDocumentStart=function(){z(N,!1,t.getRootElement);return!0}; this.moveCursorToDocumentEnd=function(){z(I,!1,t.getRootElement);return!0};this.extendSelectionToDocumentStart=function(){z(N,!0,t.getRootElement);return!0};this.extendSelectionToDocumentEnd=function(){z(I,!0,t.getRootElement);return!0};this.extendSelectionToEntireDocument=function(){var a=t.getCursor(k),a=t.getRootElement(a.getNode()),b,e,c;runtime.assert(Boolean(a),"SelectionController: Cursor outside root");c=t.createStepIterator(a,0,[s,w],a);c.roundToClosestStep();b=c.container();e=c.offset(); c.setPosition(a,a.childNodes.length);c.roundToClosestStep();a=t.convertDomToCursorRange({anchorNode:b,anchorOffset:e,focusNode:c.container(),focusOffset:c.offset()});f.enqueue([r(a.position,a.length)]);return!0};this.destroy=function(a){t.unsubscribe(ops.OdtDocument.signalOperationStart,d);core.Async.destroyAll([E.destroy],a)};(function(){E=core.Task.createTimeoutTask(function(){G=void 0},2E3);t.subscribe(ops.OdtDocument.signalOperationStart,d)})()};gui.TextController=function(f,k,d,b,c,h){function r(){t=!0===k.getState(gui.CommonConstraints.EDIT.REVIEW_MODE)?d.isLocalCursorWithinOwnAnnotation():!0}function l(a){a.getMemberId()===b&&r()}function p(a){return a===ops.OdtStepsTranslator.NEXT_STEP}function n(a,b,e){var c=[m.getPositionFilter()];e&&c.push(m.createRootFilter(a.startContainer));e=m.createStepIterator(a.startContainer,a.startOffset,c,b);e.roundToClosestStep()||runtime.assert(!1,"No walkable step found in paragraph element at range start"); b=m.convertDomPointToCursorStep(e.container(),e.offset());a.collapsed?a=b:(e.setPosition(a.endContainer,a.endOffset),e.roundToClosestStep()||runtime.assert(!1,"No walkable step found in paragraph element at range end"),a=m.convertDomPointToCursorStep(e.container(),e.offset()));return{position:b,length:a-b}}function q(a){var e,c,d,f=g.getParagraphElements(a),h=a.cloneRange(),k=[];e=f[0];1a.length&&(a.position+=a.length,a.length=-a.length);return a} function a(a){if(!t)return!1;var c,d=m.getCursor(b).getSelectedRange().cloneRange(),g=e(m.getCursorSelection(b)),h;if(0===g.length){g=void 0;c=m.getCursor(b).getNode();h=m.getRootElement(c);var k=[m.getPositionFilter(),m.createRootFilter(h)];h=m.createStepIterator(c,0,k,h);h.roundToClosestStep()&&(a?h.nextStep():h.previousStep())&&(g=e(m.convertDomToCursorRange({anchorNode:c,anchorOffset:0,focusNode:h.container(),focusOffset:h.offset()})),a?(d.setStart(c,0),d.setEnd(h.container(),h.offset())):(d.setStart(h.container(), h.offset()),d.setEnd(c,0)))}g&&f.enqueue(q(d));return void 0!==g}var m=f.getOdtDocument(),g=new odf.OdfUtils,z=new core.DomUtils,t=!1,v=odf.Namespaces.textns;this.isEnabled=function(){return t};this.enqueueParagraphSplittingOps=function(){if(!t)return!1;var a=m.getCursor(b),c=a.getSelectedRange(),d=e(m.getCursorSelection(b)),g=[],a=m.getParagraphElement(a.getNode()),k=a.getAttributeNS(v,"style-name")||"";0c.left&&(c=x(d)))b.focusNode=c.container,b.focusOffset=c.offset,e&&(b.anchorNode=b.focusNode,b.anchorOffset=b.focusOffset)}else D.isImage(b.focusNode.firstChild)&&1===b.focusOffset&&D.isCharacterFrame(b.focusNode)&&(c=x(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));R.focus()}function A(a){var b;if(b=r(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),R.focus()}function G(a){var e=h(a),c,d,f;ja.processRequests();S&&(D.isImage(e)&&D.isCharacterFrame(e.parentNode)&&Q.getSelection().isCollapsed?(W.selectImage(e.parentNode),R.focus()):la.isSelectorElement(e)?R.focus():O?(e=b.getSelectedRange(),d=e.collapsed,D.isImage(e.endContainer)&&0===e.endOffset&&D.isCharacterFrame(e.endContainer.parentNode)&&(f= e.endContainer.parentNode,f=x(f))&&(e.setEnd(f.container,f.offset),d&&e.collapse(!1)),W.selectRange(e,b.hasForwardSelection(),0===a.button?a.detail:0),R.focus()):ua?w(a):(c=ea.cloneEvent(a),aa=runtime.setTimeout(function(){w(c)},0)),oa=0,O=S=!1)}function E(a){var b=u.getCursor(d).getSelectedRange();b.collapsed||P.exportRangeToDataTransfer(a.dataTransfer,b)}function F(){S&&R.focus();oa=0;O=S=!1}function H(a){G(a)}function N(a){var b=h(a),e=null;"annotationRemoveButton"===b.className?(runtime.assert(ha, "Remove buttons are displayed on annotations while annotation editing is disabled in the controller."),e=ea.getElementsByTagNameNS(b.parentNode,odf.Namespaces.officens,"annotation")[0],ga.removeAnnotation(e),R.focus()):"webodf-draggable"!==b.getAttribute("class")&&G(a)}function I(a){(a=a.data)&&(-1===a.indexOf("\n")?fa.insertText(a):ra.paste(a))}function U(a){return function(){a();return!0}}function B(a){return function(b){return u.getCursor(d).getSelectionType()===ops.OdtCursor.RangeSelection?a(b): !0}}function Z(b){R.unsubscribe("keydown",C.handleEvent);R.unsubscribe("keypress",T.handleEvent);R.unsubscribe("keyup",L.handleEvent);R.unsubscribe("copy",n);R.unsubscribe("mousedown",s);R.unsubscribe("mousemove",ja.trigger);R.unsubscribe("mouseup",N);R.unsubscribe("contextmenu",H);R.unsubscribe("dragstart",E);R.unsubscribe("dragend",F);R.unsubscribe("click",ma.handleClick);R.unsubscribe("longpress",A);R.unsubscribe("drag",t);R.unsubscribe("dragstop",v);u.unsubscribe(ops.OdtDocument.signalOperationEnd, da.trigger);u.unsubscribe(ops.Document.signalCursorAdded,ka.registerCursor);u.unsubscribe(ops.Document.signalCursorRemoved,ka.removeCursor);u.unsubscribe(ops.OdtDocument.signalOperationEnd,a);b()}var Q=runtime.getWindow(),u=k.getOdtDocument(),Y=new gui.SessionConstraints,$=new gui.SessionContext(k,d),ea=new core.DomUtils,D=new odf.OdfUtils,P=new gui.MimeDataExporter,X=new gui.Clipboard(P),C=new gui.KeyboardHandler,T=new gui.KeyboardHandler,L=new gui.KeyboardHandler,S=!1,J=new odf.ObjectNameGenerator(u.getOdfCanvas().odfContainer(), d),O=!1,V=null,aa,ba=null,R=new gui.EventManager(u),ha=c.annotationsEnabled,ga=new gui.AnnotationController(k,Y,d),ca=new gui.DirectFormattingController(k,Y,$,d,J,c.directTextStylingEnabled,c.directParagraphStylingEnabled),fa=new gui.TextController(k,Y,$,d,ca.createCursorStyleOp,ca.createParagraphStyleOps),na=new gui.ImageController(k,Y,$,d,J),la=new gui.ImageSelector(u.getOdfCanvas()),ia=gui.SelectionMover.createPositionIterator(u.getRootNode()),ja,da,ra=new gui.PasteController(k,Y,$,d),ka=new gui.InputMethodEditor(d, R),oa=0,ma=new gui.HyperlinkClickHandler(u.getOdfCanvas().getElement,C,L),ta=new gui.HyperlinkController(k,Y,$,d),W=new gui.SelectionController(k,d),sa=new gui.MetadataController(k,d),K=gui.KeyboardHandler.Modifier,M=gui.KeyboardHandler.KeyCode,pa=-1!==Q.navigator.appVersion.toLowerCase().indexOf("mac"),ua=-1!==["iPad","iPod","iPhone"].indexOf(Q.navigator.platform),qa;runtime.assert(null!==Q,"Expected to be run in an environment which has a global window, like a browser.");this.undo=g;this.redo=z; this.insertLocalCursor=function(){runtime.assert(void 0===k.getOdtDocument().getCursor(d),"Inserting local cursor a second time.");var a=new ops.OpAddCursor;a.init({memberid:d});k.enqueue([a]);R.focus()};this.removeLocalCursor=function(){runtime.assert(void 0!==k.getOdtDocument().getCursor(d),"Removing local cursor without inserting before.");var a=new ops.OpRemoveCursor;a.init({memberid:d});k.enqueue([a])};this.startEditing=function(){ka.subscribe(gui.InputMethodEditor.signalCompositionStart,fa.removeCurrentSelection); ka.subscribe(gui.InputMethodEditor.signalCompositionEnd,I);R.subscribe("beforecut",p);R.subscribe("cut",l);R.subscribe("beforepaste",e);R.subscribe("paste",q);ba&&ba.initialize();R.setEditing(!0);ma.setModifier(pa?K.Meta:K.Ctrl);C.bind(M.Backspace,K.None,U(fa.removeTextByBackspaceKey),!0);C.bind(M.Delete,K.None,fa.removeTextByDeleteKey);C.bind(M.Tab,K.None,B(function(){fa.insertText("\t");return!0}));pa?(C.bind(M.Clear,K.None,fa.removeCurrentSelection),C.bind(M.B,K.Meta,B(ca.toggleBold)),C.bind(M.I, K.Meta,B(ca.toggleItalic)),C.bind(M.U,K.Meta,B(ca.toggleUnderline)),C.bind(M.L,K.MetaShift,B(ca.alignParagraphLeft)),C.bind(M.E,K.MetaShift,B(ca.alignParagraphCenter)),C.bind(M.R,K.MetaShift,B(ca.alignParagraphRight)),C.bind(M.J,K.MetaShift,B(ca.alignParagraphJustified)),ha&&C.bind(M.C,K.MetaShift,ga.addAnnotation),C.bind(M.Z,K.Meta,g),C.bind(M.Z,K.MetaShift,z)):(C.bind(M.B,K.Ctrl,B(ca.toggleBold)),C.bind(M.I,K.Ctrl,B(ca.toggleItalic)),C.bind(M.U,K.Ctrl,B(ca.toggleUnderline)),C.bind(M.L,K.CtrlShift, B(ca.alignParagraphLeft)),C.bind(M.E,K.CtrlShift,B(ca.alignParagraphCenter)),C.bind(M.R,K.CtrlShift,B(ca.alignParagraphRight)),C.bind(M.J,K.CtrlShift,B(ca.alignParagraphJustified)),ha&&C.bind(M.C,K.CtrlAlt,ga.addAnnotation),C.bind(M.Z,K.Ctrl,g),C.bind(M.Z,K.CtrlShift,z));T.setDefault(B(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)})); T.bind(M.Enter,K.None,B(fa.enqueueParagraphSplittingOps))};this.endEditing=function(){ka.unsubscribe(gui.InputMethodEditor.signalCompositionStart,fa.removeCurrentSelection);ka.unsubscribe(gui.InputMethodEditor.signalCompositionEnd,I);R.unsubscribe("cut",l);R.unsubscribe("beforecut",p);R.unsubscribe("paste",q);R.unsubscribe("beforepaste",e);R.setEditing(!1);ma.setModifier(K.None);C.bind(M.Backspace,K.None,function(){return!0},!0);C.unbind(M.Delete,K.None);C.unbind(M.Tab,K.None);pa?(C.unbind(M.Clear, K.None),C.unbind(M.B,K.Meta),C.unbind(M.I,K.Meta),C.unbind(M.U,K.Meta),C.unbind(M.L,K.MetaShift),C.unbind(M.E,K.MetaShift),C.unbind(M.R,K.MetaShift),C.unbind(M.J,K.MetaShift),ha&&C.unbind(M.C,K.MetaShift),C.unbind(M.Z,K.Meta),C.unbind(M.Z,K.MetaShift)):(C.unbind(M.B,K.Ctrl),C.unbind(M.I,K.Ctrl),C.unbind(M.U,K.Ctrl),C.unbind(M.L,K.CtrlShift),C.unbind(M.E,K.CtrlShift),C.unbind(M.R,K.CtrlShift),C.unbind(M.J,K.CtrlShift),ha&&C.unbind(M.C,K.CtrlAlt),C.unbind(M.Z,K.Ctrl),C.unbind(M.Z,K.CtrlShift));T.setDefault(null); T.unbind(M.Enter,K.None)};this.getInputMemberId=function(){return d};this.getSession=function(){return k};this.getSessionConstraints=function(){return Y};this.setUndoManager=function(a){ba&&ba.unsubscribe(gui.UndoManager.signalUndoStackChanged,m);if(ba=a)ba.setDocument(u),ba.setPlaybackFunction(k.enqueue),ba.subscribe(gui.UndoManager.signalUndoStackChanged,m)};this.getUndoManager=function(){return ba};this.getMetadataController=function(){return sa};this.getAnnotationController=function(){return ga}; this.getDirectFormattingController=function(){return ca};this.getHyperlinkClickHandler=function(){return ma};this.getHyperlinkController=function(){return ta};this.getImageController=function(){return na};this.getSelectionController=function(){return W};this.getTextController=function(){return fa};this.getEventManager=function(){return R};this.getKeyboardHandlers=function(){return{keydown:C,keypress:T}};this.destroy=function(a){var b=[ja.destroy,da.destroy,ca.destroy,ka.destroy,R.destroy,ma.destroy, ta.destroy,sa.destroy,W.destroy,fa.destroy,Z];qa&&b.unshift(qa.destroy);runtime.clearTimeout(aa);core.Async.destroyAll(b,a)};ja=core.Task.createRedrawTask(y);da=core.Task.createRedrawTask(function(){var a=u.getCursor(d);if(a&&a.getSelectionType()===ops.OdtCursor.RegionSelection&&(a=D.getImageElements(a.getSelectedRange())[0])){la.select(a.parentNode);return}la.clearSelection()});C.bind(M.Left,K.None,B(W.moveCursorToLeft));C.bind(M.Right,K.None,B(W.moveCursorToRight));C.bind(M.Up,K.None,B(W.moveCursorUp)); C.bind(M.Down,K.None,B(W.moveCursorDown));C.bind(M.Left,K.Shift,B(W.extendSelectionToLeft));C.bind(M.Right,K.Shift,B(W.extendSelectionToRight));C.bind(M.Up,K.Shift,B(W.extendSelectionUp));C.bind(M.Down,K.Shift,B(W.extendSelectionDown));C.bind(M.Home,K.None,B(W.moveCursorToLineStart));C.bind(M.End,K.None,B(W.moveCursorToLineEnd));C.bind(M.Home,K.Ctrl,B(W.moveCursorToDocumentStart));C.bind(M.End,K.Ctrl,B(W.moveCursorToDocumentEnd));C.bind(M.Home,K.Shift,B(W.extendSelectionToLineStart));C.bind(M.End, K.Shift,B(W.extendSelectionToLineEnd));C.bind(M.Up,K.CtrlShift,B(W.extendSelectionToParagraphStart));C.bind(M.Down,K.CtrlShift,B(W.extendSelectionToParagraphEnd));C.bind(M.Home,K.CtrlShift,B(W.extendSelectionToDocumentStart));C.bind(M.End,K.CtrlShift,B(W.extendSelectionToDocumentEnd));pa?(C.bind(M.Left,K.Alt,B(W.moveCursorBeforeWord)),C.bind(M.Right,K.Alt,B(W.moveCursorPastWord)),C.bind(M.Left,K.Meta,B(W.moveCursorToLineStart)),C.bind(M.Right,K.Meta,B(W.moveCursorToLineEnd)),C.bind(M.Home,K.Meta, B(W.moveCursorToDocumentStart)),C.bind(M.End,K.Meta,B(W.moveCursorToDocumentEnd)),C.bind(M.Left,K.AltShift,B(W.extendSelectionBeforeWord)),C.bind(M.Right,K.AltShift,B(W.extendSelectionPastWord)),C.bind(M.Left,K.MetaShift,B(W.extendSelectionToLineStart)),C.bind(M.Right,K.MetaShift,B(W.extendSelectionToLineEnd)),C.bind(M.Up,K.AltShift,B(W.extendSelectionToParagraphStart)),C.bind(M.Down,K.AltShift,B(W.extendSelectionToParagraphEnd)),C.bind(M.Up,K.MetaShift,B(W.extendSelectionToDocumentStart)),C.bind(M.Down, K.MetaShift,B(W.extendSelectionToDocumentEnd)),C.bind(M.A,K.Meta,B(W.extendSelectionToEntireDocument))):(C.bind(M.Left,K.Ctrl,B(W.moveCursorBeforeWord)),C.bind(M.Right,K.Ctrl,B(W.moveCursorPastWord)),C.bind(M.Left,K.CtrlShift,B(W.extendSelectionBeforeWord)),C.bind(M.Right,K.CtrlShift,B(W.extendSelectionPastWord)),C.bind(M.A,K.Ctrl,B(W.extendSelectionToEntireDocument)));ua&&(qa=new gui.IOSSafariSupport(R));R.subscribe("keydown",C.handleEvent);R.subscribe("keypress",T.handleEvent);R.subscribe("keyup", L.handleEvent);R.subscribe("copy",n);R.subscribe("mousedown",s);R.subscribe("mousemove",ja.trigger);R.subscribe("mouseup",N);R.subscribe("contextmenu",H);R.subscribe("dragstart",E);R.subscribe("dragend",F);R.subscribe("click",ma.handleClick);R.subscribe("longpress",A);R.subscribe("drag",t);R.subscribe("dragstop",v);u.subscribe(ops.OdtDocument.signalOperationEnd,da.trigger);u.subscribe(ops.Document.signalCursorAdded,ka.registerCursor);u.subscribe(ops.Document.signalCursorRemoved,ka.removeCursor);u.subscribe(ops.OdtDocument.signalOperationEnd, a)}})();gui.CaretManager=function(f){function k(a){return m.hasOwnProperty(a)?m[a]:null}function d(){var a=k(f.getInputMemberId()),b;a&&(b=a.getBoundingClientRect());return b?b.right:void 0}function b(){return Object.keys(m).map(function(a){return m[a]})}function c(a){var b=m[a];b&&(delete m[a],a===f.getInputMemberId()&&f.getEventManager().unsubscribe("compositionupdate",b.handleUpdate),b.destroy(function(){}))}function h(a){a=a.getMemberId();a===f.getInputMemberId()&&(a=k(a))&&a.refreshCursorBlinking()} function r(){var a=k(f.getInputMemberId());t=!1;a&&a.ensureVisible()}function l(){var a=k(f.getInputMemberId());a&&(a.handleUpdate(),t||(t=!0,z=runtime.setTimeout(r,50)))}function p(a){a.memberId===f.getInputMemberId()&&l()}function n(){var a=k(f.getInputMemberId());a&&a.setFocus()}function q(){var a=k(f.getInputMemberId());a&&a.removeFocus()}function e(){var a=k(f.getInputMemberId());a&&a.show()}function a(){var a=k(f.getInputMemberId());a&&a.hide()}var m={},g=runtime.getWindow(),z,t=!1;this.registerCursor= function(a,b,e){var c=a.getMemberId();b=new gui.Caret(a,b,e);e=f.getEventManager();m[c]=b;c===f.getInputMemberId()?(runtime.log("Starting to track input on new cursor of "+c),a.subscribe(ops.OdtCursor.signalCursorUpdated,l),e.subscribe("compositionupdate",b.handleUpdate),b.setOverlayElement(e.getEventTrap())):a.subscribe(ops.OdtCursor.signalCursorUpdated,b.handleUpdate);return b};this.getCaret=k;this.getCarets=b;this.destroy=function(d){var k=f.getSession().getOdtDocument(),l=f.getEventManager(), r=b().map(function(a){return a.destroy});f.getSelectionController().setCaretXPositionLocator(null);runtime.clearTimeout(z);k.unsubscribe(ops.OdtDocument.signalParagraphChanged,p);k.unsubscribe(ops.Document.signalCursorMoved,h);k.unsubscribe(ops.Document.signalCursorRemoved,c);l.unsubscribe("focus",n);l.unsubscribe("blur",q);g.removeEventListener("focus",e,!1);g.removeEventListener("blur",a,!1);m={};core.Async.destroyAll(r,d)};(function(){var b=f.getSession().getOdtDocument(),k=f.getEventManager(); f.getSelectionController().setCaretXPositionLocator(d);b.subscribe(ops.OdtDocument.signalParagraphChanged,p);b.subscribe(ops.Document.signalCursorMoved,h);b.subscribe(ops.Document.signalCursorRemoved,c);k.subscribe("focus",n);k.subscribe("blur",q);g.addEventListener("focus",e,!1);g.addEventListener("blur",a,!1)})()};gui.EditInfoHandle=function(f){var k=[],d,b=f.ownerDocument,c=b.documentElement.namespaceURI;this.setEdits=function(f){k=f;var r,l,p,n;d.innerHTML="";for(f=0;fa?(l=d(1,0),p=d(0.5,1E4-a),n=d(0.2,2E4-a)):1E4<=a&&2E4>a?(l=d(0.5,0),n=d(0.2,2E4-a)):l=d(0.2,0)};this.getEdits=function(){return f.getEdits()};this.clearEdits= function(){f.clearEdits();h.setEdits([]);r.hasAttributeNS("urn:webodf:names:editinfo","editinfo:memberid")&&r.removeAttributeNS("urn:webodf:names:editinfo","editinfo:memberid")};this.getEditInfo=function(){return f};this.show=function(){r.style.display="block"};this.hide=function(){b.hideHandle();r.style.display="none"};this.showHandle=function(){h.show()};this.hideHandle=function(){h.hide()};this.destroy=function(b){runtime.clearTimeout(l);runtime.clearTimeout(p);runtime.clearTimeout(n);c.removeChild(r); h.destroy(function(e){e?b(e):f.destroy(b)})};(function(){var d=f.getOdtDocument().getDOMDocument();r=d.createElementNS(d.documentElement.namespaceURI,"div");r.setAttribute("class","editInfoMarker");r.onmouseover=function(){b.showHandle()};r.onmouseout=function(){b.hideHandle()};c=f.getNode();c.appendChild(r);h=new gui.EditInfoHandle(c);k||b.hide()})()};gui.HyperlinkTooltipView=function(f,k){var d=new core.DomUtils,b=new odf.OdfUtils,c=runtime.getWindow(),h,r,l;runtime.assert(null!==c,"Expected to be run in an environment which has a global window, like a browser.");this.showTooltip=function(p){var n=p.target||p.srcElement,q=f.getSizer(),e=f.getZoomLevel(),a;a:{for(;n;){if(b.isHyperlink(n))break a;if(b.isParagraph(n)||b.isInlineRoot(n))break;n=n.parentNode}n=null}if(n){d.containsNode(q,l)||q.appendChild(l);a=r;var m;switch(k()){case gui.KeyboardHandler.Modifier.Ctrl:m= runtime.tr("Ctrl-click to follow link");break;case gui.KeyboardHandler.Modifier.Meta:m=runtime.tr("\u2318-click to follow link");break;default:m=""}a.textContent=m;h.textContent=b.getHyperlinkTarget(n);l.style.display="block";a=c.innerWidth-l.offsetWidth-15;n=p.clientX>a?a:p.clientX+15;a=c.innerHeight-l.offsetHeight-10;p=p.clientY>a?a:p.clientY+10;q=q.getBoundingClientRect();n=(n-q.left)/e;p=(p-q.top)/e;l.style.left=n+"px";l.style.top=p+"px"}};this.hideTooltip=function(){l.style.display="none"};this.destroy= function(b){l.parentNode&&l.parentNode.removeChild(l);b()};(function(){var b=f.getElement().ownerDocument;h=b.createElement("span");r=b.createElement("span");h.className="webodf-hyperlinkTooltipLink";r.className="webodf-hyperlinkTooltipText";l=b.createElement("div");l.className="webodf-hyperlinkTooltip";l.appendChild(h);l.appendChild(r);f.getElement().appendChild(l)})()};gui.ShadowCursor=function(f){var k=f.getDOMDocument().createRange(),d=!0;this.removeFromDocument=function(){};this.getMemberId=function(){return gui.ShadowCursor.ShadowCursorMemberId};this.getSelectedRange=function(){return k};this.setSelectedRange=function(b,c){k=b;d=!1!==c};this.hasForwardSelection=function(){return d};this.getDocument=function(){return f};this.getSelectionType=function(){return ops.OdtCursor.RangeSelection};k.setStart(f.getRootNode(),0)};gui.ShadowCursor.ShadowCursorMemberId="";gui.SelectionView=function(f){};gui.SelectionView.prototype.rerender=function(){};gui.SelectionView.prototype.show=function(){};gui.SelectionView.prototype.hide=function(){};gui.SelectionView.prototype.destroy=function(f){};gui.SelectionViewManager=function(f){function k(){return Object.keys(d).map(function(b){return d[b]})}var d={};this.getSelectionView=function(b){return d.hasOwnProperty(b)?d[b]:null};this.getSelectionViews=k;this.removeSelectionView=function(b){d.hasOwnProperty(b)&&(d[b].destroy(function(){}),delete d[b])};this.hideSelectionView=function(b){d.hasOwnProperty(b)&&d[b].hide()};this.showSelectionView=function(b){d.hasOwnProperty(b)&&d[b].show()};this.rerenderSelectionViews=function(){Object.keys(d).forEach(function(b){d[b].rerender()})}; this.registerCursor=function(b,c){var h=b.getMemberId(),k=new f(b);c?k.show():k.hide();return d[h]=k};this.destroy=function(b){function c(f,k){k?b(k):f .webodf-draggable"),a=gui.ShadowCursor.ShadowCursorMemberId,c(".webodf-selectionOverlay","{ fill: "+e+"; stroke: "+e+";}",""), c(".webodf-touchEnabled .webodf-selectionOverlay","{ display: block; }"," > .webodf-draggable"))}function p(a){var b,e;for(e in x)x.hasOwnProperty(e)&&(b=x[e],a?b.show():b.hide())}function n(a){c.getCarets().forEach(function(b){a?b.showHandle():b.hideHandle()})}function q(a){var b=a.getMemberId();a=a.getProperties();l(b,a.fullName,a.color)}function e(a){var b=a.getMemberId(),e=d.getOdtDocument().getMember(b).getProperties();c.registerCursor(a,F,H);h.registerCursor(a,!0);if(a=c.getCaret(b))a.setAvatarImageUrl(e.imageUrl), a.setColor(e.color);runtime.log("+++ View here +++ eagerly created an Caret for '"+b+"'! +++")}function a(a){a=a.getMemberId();var b=h.getSelectionView(k),e=h.getSelectionView(gui.ShadowCursor.ShadowCursorMemberId),d=c.getCaret(k);a===k?(e.hide(),b&&b.show(),d&&d.show()):a===gui.ShadowCursor.ShadowCursorMemberId&&(e.show(),b&&b.hide(),d&&d.hide())}function m(a){h.removeSelectionView(a)}function g(a){var b=a.paragraphElement,e=a.memberId;a=a.timeStamp;var c,f="",g=b.getElementsByTagNameNS(s,"editinfo").item(0); g?(f=g.getAttributeNS(s,"id"),c=x[f]):(f=Math.random().toString(),c=new ops.EditInfo(b,d.getOdtDocument()),c=new gui.EditInfoMarker(c,E),g=b.getElementsByTagNameNS(s,"editinfo").item(0),g.setAttributeNS(s,"id",f),x[f]=c);c.addEdit(e,new Date(a));G.trigger()}function z(){var a;""!==y.innerHTML&&(y.innerHTML="");!0===b.getState(gui.CommonConstraints.EDIT.ANNOTATIONS.ONLY_DELETE_OWN)&&(a=d.getOdtDocument().getMember(k))&&(a=a.getProperties().fullName,y.appendChild(document.createTextNode(".annotationWrapper:not([creator = '"+ a+"']) .annotationRemoveButton { display: none; }")))}function t(c){var d=Object.keys(x).map(function(a){return x[a]});w.unsubscribe(ops.Document.signalMemberAdded,q);w.unsubscribe(ops.Document.signalMemberUpdated,q);w.unsubscribe(ops.Document.signalCursorAdded,e);w.unsubscribe(ops.Document.signalCursorRemoved,m);w.unsubscribe(ops.OdtDocument.signalParagraphChanged,g);w.unsubscribe(ops.Document.signalCursorMoved,a);w.unsubscribe(ops.OdtDocument.signalParagraphChanged,h.rerenderSelectionViews);w.unsubscribe(ops.OdtDocument.signalTableAdded, h.rerenderSelectionViews);w.unsubscribe(ops.OdtDocument.signalParagraphStyleModified,h.rerenderSelectionViews);b.unsubscribe(gui.CommonConstraints.EDIT.ANNOTATIONS.ONLY_DELETE_OWN,z);w.unsubscribe(ops.Document.signalMemberAdded,z);w.unsubscribe(ops.Document.signalMemberUpdated,z);v.parentNode.removeChild(v);y.parentNode.removeChild(y);(function B(a,b){b?c(b):ab.length;a&&f(b);return a}function d(b,a){function c(f){b[f]===a&&d.push(f)}var d=[];b&&["style:parent-style-name","style:next-style-name"].forEach(c);return d}function b(b,a){function c(d){b[d]===a&&delete b[d]}b&&["style:parent-style-name","style:next-style-name"].forEach(c)}function c(b){var a={};Object.keys(b).forEach(function(d){a[d]="object"===typeof b[d]?c(b[d]):b[d]});return a}function h(b, a,c,d){var f,h=!1,k=!1,l,n=[];d&&d.attributes&&(n=d.attributes.split(","));b&&(c||0=a.position+a.length)){f=d?b:a;h=d?a:b;if(b.position!==a.position||b.length!==a.length)q=c(f),x=c(h);a=p(h.setProperties,null,f.setProperties,null,"style:text-properties");if(a.majorChanged||a.minorChanged)k=[],b=[],l=f.position+f.length,n=h.position+h.length,h.positionl?a.minorChanged&&(q=x,q.position=l,q.length=n-l,b.push(q),h.length=l-h.position):l>n&&a.majorChanged&&(q.position=n,q.length=l-n,k.push(q),f.length=n-f.position),f.setProperties&&r(f.setProperties)&&k.push(f),h.setProperties&&r(h.setProperties)&&b.push(h),d?(l=k,k=b):l=b}return{opSpecsA:l,opSpecsB:k}},InsertText:function(b,a){a.position<=b.position?b.position+=a.text.length:a.position<=b.position+b.length&&(b.length+= a.text.length);return{opSpecsA:[b],opSpecsB:[a]}},MergeParagraph:function(b,a){var c=b.position,d=b.position+b.length;c>=a.sourceStartPosition&&(c-=1);d>=a.sourceStartPosition&&(d-=1);b.position=c;b.length=d-c;return{opSpecsA:[b],opSpecsB:[a]}},MoveCursor:n,RemoveCursor:n,RemoveStyle:n,RemoveText:function(b,a){var c=b.position+b.length,d=a.position+a.length,f=[b],h=[a];d<=b.position?b.position-=a.length:a.positiona.position?b.position+=a.text.length:c?a.position+=b.text.length:b.position+=a.text.length;return{opSpecsA:[b],opSpecsB:[a]}},MergeParagraph:function(b, a){b.position>=a.sourceStartPosition?b.position-=1:(b.positionb.position&&(a.position+=b.text.length);return{opSpecsA:[b],opSpecsB:[a]}},SplitParagraph:function(b,a){b.position=b.sourceStartPosition&&(f-=1);c>=b.sourceStartPosition&&(c-=1);0<=a.length?(a.position=f,a.length=c-f):(a.position=c,a.length=f-c);return{opSpecsA:[b],opSpecsB:[a]}},RemoveCursor:n,RemoveMember:n,RemoveStyle:n,RemoveText:function(b,a){a.position>=b.sourceStartPosition?a.position-=1:(a.positionb.sourceStartPosition)a.position-=1;else if(a.position===b.destinationStartPosition||a.position===b.sourceStartPosition)a.position=b.destinationStartPosition,b.paragraphStyleName=a.styleName;return{opSpecsA:c,opSpecsB:d}},SplitParagraph:function(b,a){var c,d=[b],f=[a];a.position=b.destinationStartPosition&&a.position=b.sourceStartPosition&&(a.position-=1,a.sourceParagraphPosition-=1);return{opSpecsA:d,opSpecsB:f}}, UpdateMember:n,UpdateMetadata:n,UpdateParagraphStyle:n},MoveCursor:{MoveCursor:n,RemoveCursor:function(b,a){return{opSpecsA:b.memberid===a.memberid?[]:[b],opSpecsB:[a]}},RemoveMember:n,RemoveStyle:n,RemoveText:function(b,a){var c=k(b),d=b.position+b.length,h=a.position+a.length;h<=b.position?b.position-=a.length:a.positiona.position?b.position+=1:b.position===a.sourceParagraphPosition&&(a.paragraphStyleName=b.styleName,h=c(b),h.position=a.position+1,d.push(h));return{opSpecsA:d,opSpecsB:f}},UpdateMember:n,UpdateMetadata:n,UpdateParagraphStyle:n},SplitParagraph:{SplitParagraph:function(b, a,c){var d,f;b.position img {\n box-shadow: 0px 0px 5px rgb(90, 90, 90) inset;\n background-color: rgb(200, 200, 200);\n border-radius: 5px;\n border: 2px solid;\n height: 60px !important;\n width: 60px !important;\n display: block;\n margin: auto;\n}\n\n.webodf-caretOverlay .handle.active {\n opacity: 0.8;\n}\n\n.webodf-caretOverlay .handle:after {\n content: ' ';\n position: absolute;\n width: 0px;\n height: 0px;\n border-style: solid;\n border-width: 8.7px 5px 0 5px;\n border-color: black transparent transparent transparent;\n\n top: 100%;\n left: 43%;\n}\n\n.webodf-caretSizer {\n display: inline-block; /* inline-block is necessary so the width can be set to 0 */\n width: 0; /* the caret sizer shouldn't take up any horizontal space */\n visibility: hidden; /* \"hidden\" means the client rects are still calculated, but the node content is not shown */\n}\n\n/** Input Method Editor input pane & behaviours */\n/* not within a cursor */\n#eventTrap {\n height: auto;\n display: block;\n position: absolute;\n bottom: 0;\n right: 0;\n width: 1px;\n outline: none;\n opacity: 0;\n color: rgba(255, 255, 255, 0); /* hide the blinking caret by setting the colour to fully transparent */\n overflow: hidden; /* The overflow visibility is used to hide and show characters being entered */\n pointer-events: none;\n}\n\n/* within a cursor */\ncursor|cursor > #composer {\n text-decoration: underline;\n}\n\ncursor|cursor[cursor|caret-sizer-active=\"true\"],\ncursor|cursor[cursor|composing=\"true\"] {\n display: inline;\n}\n\neditinfo|editinfo {\n /* Empty or invisible display:inline elements respond very badly to mouse selection.\n Inline blocks are much more reliably selectable in Chrome & friends */\n display: inline-block;\n}\n\n.editInfoMarker {\n position: absolute;\n width: 10px;\n height: 100%;\n left: -20px;\n opacity: 0.8;\n top: 0;\n border-radius: 5px;\n background-color: transparent;\n box-shadow: 0px 0px 5px rgba(50, 50, 50, 0.75);\n}\n.editInfoMarker:hover {\n box-shadow: 0px 0px 8px rgba(0, 0, 0, 1);\n}\n\n.editInfoHandle {\n position: absolute;\n background-color: black;\n padding: 5px;\n border-radius: 5px;\n opacity: 0.8;\n box-shadow: 0px 0px 5px rgba(50, 50, 50, 0.75);\n bottom: 100%;\n margin-bottom: 10px;\n z-index: 3;\n left: -25px;\n}\n.editInfoHandle:after {\n content: ' ';\n position: absolute;\n width: 0px;\n height: 0px;\n border-style: solid;\n border-width: 8.7px 5px 0 5px;\n border-color: black transparent transparent transparent;\n\n top: 100%;\n left: 5px;\n}\n.editInfo {\n font-family: sans-serif;\n font-weight: normal;\n font-style: normal;\n text-decoration: none;\n color: white;\n width: 100%;\n height: 12pt;\n}\n.editInfoColor {\n float: left;\n width: 10pt;\n height: 10pt;\n border: 1px solid white;\n}\n.editInfoAuthor {\n float: left;\n margin-left: 5pt;\n font-size: 10pt;\n text-align: left;\n height: 12pt;\n line-height: 12pt;\n}\n.editInfoTime {\n float: right;\n margin-left: 30pt;\n font-size: 8pt;\n font-style: italic;\n color: yellow;\n height: 12pt;\n line-height: 12pt;\n}\n\n.annotationWrapper {\n display: inline;\n position: relative;\n}\n\n.annotationRemoveButton:before {\n content: '\u00d7';\n color: white;\n padding: 5px;\n line-height: 1em;\n}\n\n.annotationRemoveButton {\n width: 20px;\n height: 20px;\n border-radius: 10px;\n background-color: black;\n box-shadow: 0px 0px 5px rgba(50, 50, 50, 0.75);\n position: absolute;\n top: -10px;\n left: -10px;\n z-index: 3;\n text-align: center;\n font-family: sans-serif;\n font-style: normal;\n font-weight: normal;\n text-decoration: none;\n font-size: 15px;\n}\n.annotationRemoveButton:hover {\n cursor: pointer;\n box-shadow: 0px 0px 5px rgba(0, 0, 0, 1);\n}\n\n.annotationNote {\n width: 4cm;\n position: absolute;\n display: inline;\n z-index: 10;\n top: 0;\n}\n.annotationNote > office|annotation {\n display: block;\n text-align: left;\n}\n\n.annotationConnector {\n position: absolute;\n display: inline;\n top: 0;\n z-index: 2;\n border-top: 1px dashed brown;\n}\n.annotationConnector.angular {\n -moz-transform-origin: left top;\n -webkit-transform-origin: left top;\n -ms-transform-origin: left top;\n transform-origin: left top;\n}\n.annotationConnector.horizontal {\n left: 0;\n}\n.annotationConnector.horizontal:before {\n content: '';\n display: inline;\n position: absolute;\n width: 0px;\n height: 0px;\n border-style: solid;\n border-width: 8.7px 5px 0 5px;\n border-color: brown transparent transparent transparent;\n top: -1px;\n left: -5px;\n}\n\noffice|annotation {\n width: 100%;\n height: 100%;\n display: none;\n background: rgb(198, 238, 184);\n background: -moz-linear-gradient(90deg, rgb(198, 238, 184) 30%, rgb(180, 196, 159) 100%);\n background: -webkit-linear-gradient(90deg, rgb(198, 238, 184) 30%, rgb(180, 196, 159) 100%);\n background: -o-linear-gradient(90deg, rgb(198, 238, 184) 30%, rgb(180, 196, 159) 100%);\n background: -ms-linear-gradient(90deg, rgb(198, 238, 184) 30%, rgb(180, 196, 159) 100%);\n background: linear-gradient(180deg, rgb(198, 238, 184) 30%, rgb(180, 196, 159) 100%);\n box-shadow: 0 3px 4px -3px #ccc;\n}\n\noffice|annotation > dc|creator {\n display: block;\n font-size: 10pt;\n font-weight: normal;\n font-style: normal;\n font-family: sans-serif;\n color: white;\n background-color: brown;\n padding: 4px;\n}\noffice|annotation > dc|date {\n display: block;\n font-size: 10pt;\n font-weight: normal;\n font-style: normal;\n font-family: sans-serif;\n border: 4px solid transparent;\n color: black;\n}\noffice|annotation > text|list {\n display: block;\n padding: 5px;\n}\n\n/* This is very temporary CSS. This must go once\n * we start bundling webodf-default ODF styles for annotations.\n */\noffice|annotation text|p {\n font-size: 10pt;\n color: black;\n font-weight: normal;\n font-style: normal;\n text-decoration: none;\n font-family: sans-serif;\n}\n\n#annotationsPane {\n background-color: #EAEAEA;\n width: 4cm;\n height: 100%;\n display: none;\n position: absolute;\n outline: 1px solid #ccc;\n}\n\n.webodf-annotationHighlight {\n background-color: yellow;\n position: relative;\n}\n\n.webodf-selectionOverlay {\n position: absolute;\n pointer-events: none;\n top: 0;\n left: 0;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n z-index: 15;\n}\n.webodf-selectionOverlay > polygon {\n fill-opacity: 0.3;\n stroke-opacity: 0.8;\n stroke-width: 1;\n fill-rule: evenodd;\n}\n\n.webodf-selectionOverlay > .webodf-draggable {\n fill-opacity: 0.8;\n stroke-opacity: 0;\n stroke-width: 8;\n pointer-events: all;\n display: none;\n\n -moz-transform-origin: center center;\n -webkit-transform-origin: center center;\n -ms-transform-origin: center center;\n transform-origin: center center;\n}\n\n#imageSelector {\n display: none;\n position: absolute;\n border-style: solid;\n border-color: black;\n}\n\n#imageSelector > div {\n width: 5px;\n height: 5px;\n display: block;\n position: absolute;\n border: 1px solid black;\n background-color: #ffffff;\n}\n\n#imageSelector > .topLeft {\n top: -4px;\n left: -4px;\n}\n\n#imageSelector > .topRight {\n top: -4px;\n right: -4px;\n}\n\n#imageSelector > .bottomRight {\n right: -4px;\n bottom: -4px;\n}\n\n#imageSelector > .bottomLeft {\n bottom: -4px;\n left: -4px;\n}\n\n#imageSelector > .topMiddle {\n top: -4px;\n left: 50%;\n margin-left: -2.5px; /* half of the width defined in #imageSelector > div */\n}\n\n#imageSelector > .rightMiddle {\n top: 50%;\n right: -4px;\n margin-top: -2.5px; /* half of the height defined in #imageSelector > div */\n}\n\n#imageSelector > .bottomMiddle {\n bottom: -4px;\n left: 50%;\n margin-left: -2.5px; /* half of the width defined in #imageSelector > div */\n}\n\n#imageSelector > .leftMiddle {\n top: 50%;\n left: -4px;\n margin-top: -2.5px; /* half of the height defined in #imageSelector > div */\n}\n\ndiv.webodf-customScrollbars::-webkit-scrollbar\n{\n width: 8px;\n height: 8px;\n background-color: transparent;\n}\n\ndiv.webodf-customScrollbars::-webkit-scrollbar-track\n{\n background-color: transparent;\n}\n\ndiv.webodf-customScrollbars::-webkit-scrollbar-thumb\n{\n background-color: #444;\n border-radius: 4px;\n}\n\n.webodf-hyperlinkTooltip {\n display: none;\n color: white;\n background-color: black;\n border-radius: 5px;\n box-shadow: 2px 2px 5px gray;\n padding: 3px;\n position: absolute;\n max-width: 210px;\n text-align: left;\n word-break: break-all;\n z-index: 16;\n}\n\n.webodf-hyperlinkTooltipText {\n display: block;\n font-weight: bold;\n}\n";