mirror of
https://git.henryfjordan.com/henry/web
synced 2019-01-16 02:39:46 +00:00
625 lines
341 KiB
JavaScript
625 lines
341 KiB
JavaScript
|
/*
|
||
|
|
||
|
This is a generated file. DO NOT EDIT.
|
||
|
|
||
|
Copyright (C) 2010-2015 KO GmbH <copyright@kogmbh.com>
|
||
|
|
||
|
@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 <http://www.gnu.org/licenses/>.
|
||
|
@licend
|
||
|
|
||
|
@source: http://www.webodf.org/
|
||
|
@source: https://github.com/kogmbh/WebODF/
|
||
|
*/
|
||
|
var webodf_version="0.5.6";function Runtime(){}Runtime.prototype.getVariable=function(f){};Runtime.prototype.toJson=function(f){};Runtime.prototype.fromJson=function(f){};Runtime.prototype.byteArrayFromString=function(f,l){};Runtime.prototype.byteArrayToString=function(f,l){};Runtime.prototype.read=function(f,l,a,d){};Runtime.prototype.readFile=function(f,l,a){};Runtime.prototype.readFileSync=function(f,l){};Runtime.prototype.loadXML=function(f,l){};Runtime.prototype.writeFile=function(f,l,a){};
|
||
|
Runtime.prototype.deleteFile=function(f,l){};Runtime.prototype.log=function(f,l){};Runtime.prototype.setTimeout=function(f,l){};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,l){};var IS_COMPILED_CODE=!0;
|
||
|
Runtime.byteArrayToString=function(f,l){function a(a){var d="",b,n=a.length;for(b=0;b<n;b+=1)d+=String.fromCharCode(a[b]&255);return d}function d(a){var d="",b,n=a.length,m=[],g,e,c,r;for(b=3<=n&&239===a[0]&&187===a[1]&&191===a[2]?3:0;b<n;b+=1)g=a[b],128>g?m.push(g):(b+=1,e=a[b],194<=g&&224>g?m.push((g&31)<<6|e&63):(b+=1,c=a[b],224<=g&&240>g?m.push((g&15)<<12|(e&63)<<6|c&63):(b+=1,r=a[b],240<=g&&245>g&&(g=(g&7)<<18|(e&63)<<12|(c&63)<<6|r&63,g-=65536,m.push((g>>10)+55296,(g&1023)+56320))))),1E3<=m.length&&
|
||
|
(d+=String.fromCharCode.apply(null,m),m.length=0);return d+String.fromCharCode.apply(null,m)}var b;"utf8"===l?b=d(f):("binary"!==l&&this.log("Unsupported encoding: "+l),b=a(f));return b};Runtime.getVariable=function(f){try{return eval(f)}catch(l){}};Runtime.toJson=function(f){return JSON.stringify(f)};Runtime.fromJson=function(f){return JSON.parse(f)};Runtime.getFunctionName=function(f){return void 0===f.name?(f=/function\s+(\w+)/.exec(f))&&f[1]:f.name};
|
||
|
Runtime.assert=function(f,l){if(!f)throw this.log("alert","ASSERTION FAILED:\n"+l),Error(l);};
|
||
|
function BrowserRuntime(){function f(a){var d=a.length,g,e,c=0;for(g=0;g<d;g+=1)e=a.charCodeAt(g),c+=1+(128<e)+(2048<e),55040<e&&57344>e&&(c+=1,g+=1);return c}function l(a,d,g){var e=a.length,c,r;d=new Uint8Array(new ArrayBuffer(d));g?(d[0]=239,d[1]=187,d[2]=191,r=3):r=0;for(g=0;g<e;g+=1)c=a.charCodeAt(g),128>c?(d[r]=c,r+=1):2048>c?(d[r]=192|c>>>6,d[r+1]=128|c&63,r+=2):55040>=c||57344<=c?(d[r]=224|c>>>12&15,d[r+1]=128|c>>>6&63,d[r+2]=128|c&63,r+=3):(g+=1,c=(c-55296<<10|a.charCodeAt(g)-56320)+65536,
|
||
|
d[r]=240|c>>>18&7,d[r+1]=128|c>>>12&63,d[r+2]=128|c>>>6&63,d[r+3]=128|c&63,r+=4);return d}function a(d){var a=d.length,g=new Uint8Array(new ArrayBuffer(a)),e;for(e=0;e<a;e+=1)g[e]=d.charCodeAt(e)&255;return g}function d(d,a){var g;void 0!==a?g=d:a=d;console.log(a);q.enableAlerts&&"alert"===g&&alert(a)}function b(d,b,g){if(0!==g.status||g.responseText)if(200===g.status||0===g.status){if(g.response&&"string"!==typeof g.response)"binary"===b?(g=g.response,g=new Uint8Array(g)):g=String(g.response);else if("binary"===
|
||
|
b)if(null!==g.responseBody&&"undefined"!==String(typeof VBArray)){g=(new VBArray(g.responseBody)).toArray();var e=g.length;b=new Uint8Array(new ArrayBuffer(e));for(d=0;d<e;d+=1)b[d]=g[d];g=b}else{(d=g.getResponseHeader("Content-Length"))&&(d=parseInt(d,10));if(d&&d!==g.responseText.length)a:{e=g.responseText;b=!1;var c=f(e);if("number"===typeof d){if(d!==c&&d!==c+3){e=void 0;break a}b=c+3===d;c=d}e=l(e,c,b)}void 0===e&&(e=a(g.responseText));g=e}else g=g.responseText;g={err:null,data:g}}else g={err:g.responseText||
|
||
|
g.statusText,data:null};else g={err:"File "+d+" is empty.",data:null};return g}function h(d,a,g){var e=new XMLHttpRequest;e.open("GET",d,g);e.overrideMimeType&&("binary"!==a?e.overrideMimeType("text/plain; charset="+a):e.overrideMimeType("text/plain; charset=x-user-defined"));return e}function p(d,a,g){var e=h(d,a,!0);e.onreadystatechange=function(){var c;4===e.readyState&&(c=b(d,a,e),g(c.err,c.data))};try{e.send(null)}catch(c){g(c.message,null)}}var q=this;this.byteArrayFromString=function(d,b){var g;
|
||
|
"utf8"===b?g=l(d,f(d),!1):("binary"!==b&&q.log("unknown encoding: "+b),g=a(d));return g};this.byteArrayToString=Runtime.byteArrayToString;this.getVariable=Runtime.getVariable;this.fromJson=Runtime.fromJson;this.toJson=Runtime.toJson;this.readFile=p;this.read=function(d,a,g,e){p(d,"binary",function(c,r){var k=null;if(r){if("string"===typeof r)throw"This should not happen.";k=r.subarray(a,a+g)}e(c,k)})};this.readFileSync=function(d,a){var g=h(d,a,!1),e;try{g.send(null);e=b(d,a,g);if(e.err)throw e.err;
|
||
|
if(null===e.data)throw"No data read from "+d+".";}catch(c){throw c;}return e.data};this.writeFile=function(d,a,g){var e=new XMLHttpRequest,c;e.open("PUT",d,!0);e.onreadystatechange=function(){4===e.readyState&&(0!==e.status||e.responseText?200<=e.status&&300>e.status||0===e.status?g(null):g("Status "+String(e.status)+": "+e.responseText||e.statusText):g("File "+d+" is empty."))};c=a.buffer&&!e.sendAsBinary?a.buffer:q.byteArrayToString(a,"binary");try{e.sendAsBinary?e.sendAsBinary(c):e.send(c)}catch(r){q.log("HUH? "+
|
||
|
r+" "+a),g(r.message)}};this.deleteFile=function(d,a){var g=new XMLHttpRequest;g.open("DELETE",d,!0);g.onreadystatechange=function(){4===g.readyState&&(200>g.status&&300<=g.status?a(g.responseText):a(null))};g.send(null)};this.loadXML=function(d,a){var g=new XMLHttpRequest;g.open("GET",d,!0);g.overrideMimeType&&g.overrideMimeType("text/xml");g.onreadystatechange=function(){4===g.readyState&&(0!==g.status||g.responseText?200===g.status||0===g.status?a(null,g.responseXML):a(g.responseText,null):a("File "+
|
||
|
d+" is empty.",null))};try{g.send(null)}catch(e){a(e.message,null)}};this.log=d;this.enableAlerts=!0;this.assert=Runtime.assert;this.setTimeout=function(d,a){return setTimeout(function(){d()},a)};this.clearTimeout=function(d){clearTimeout(d)};this.libraryPaths=function(){return["lib"]};this.setCurrentDirectory=function(){};this.currentDirectory=function(){return""};this.type=function(){return"BrowserRuntime"};this.getDOMImplementation=function(){return window.document.implementation};this.parseXML=
|
||
|
function(d){return(new DOMParser).parseFromString(d,"text/xml")};this.exit=function(a){d("Calling exit with code "+String(a)+", but exit() is not implemented.")};this.getWindow=function(){return window};this.requestAnimationFrame=function(d){var a=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame,g=0;if(a)a.bind(window),g=a(d);else return setTimeout(d,15);return g};this.cancelAnimationFrame=function(d){var a=window.cancelAnimationFrame||
|
||
|
window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.msCancelAnimationFrame;a?(a.bind(window),a(d)):clearTimeout(d)}}
|
||
|
function NodeJSRuntime(){function f(d){var a=d.length,g,e=new Uint8Array(new ArrayBuffer(a));for(g=0;g<a;g+=1)e[g]=d[g];return e}function l(a,p,g){function e(c,e){if(c)return g(c,null);if(!e)return g("No data for "+a+".",null);if("string"===typeof e)return g(c,e);g(c,f(e))}a=b.resolve(h,a);"binary"!==p?d.readFile(a,p,e):d.readFile(a,null,e)}var a=this,d=require("fs"),b=require("path"),h="",p,q;this.byteArrayFromString=function(d,a){var g=new Buffer(d,a),e,c=g.length,r=new Uint8Array(new ArrayBuffer(c));
|
||
|
for(e=0;e<c;e+=1)r[e]=g[e];return r};this.byteArrayToString=Runtime.byteArrayToString;this.getVariable=Runtime.getVariable;this.fromJson=Runtime.fromJson;this.toJson=Runtime.toJson;this.readFile=l;this.loadXML=function(d,b){l(d,"utf-8",function(g,e){if(g)return b(g,null);if(!e)return b("No data for "+d+".",null);b(null,a.parseXML(e))})};this.writeFile=function(a,p,g){p=new Buffer(p);a=b.resolve(h,a);d.writeFile(a,p,"binary",function(e){g(e||null)})};this.deleteFile=function(a,p){a=b.resolve(h,a);
|
||
|
d.unlink(a,p)};this.read=function(a,p,g,e){a=b.resolve(h,a);d.open(a,"r+",666,function(c,r){if(c)e(c,null);else{var k=new Buffer(g);d.read(r,k,0,g,p,function(c){d.close(r);e(c,f(k))})}})};this.readFileSync=function(a,b){var g;g=d.readFileSync(a,"binary"===b?null:b);if(null===g)throw"File "+a+" could not be read.";"binary"===b&&(g=f(g));return g};this.log=function(d,a){var g;void 0!==a?g=d:a=d;"alert"===g&&process.stderr.write("\n!!!!! ALERT !!!!!\n");process.stderr.write(a+"\n");"alert"===g&&process.stderr.write("!!!!! ALERT !!!!!\n")};
|
||
|
this.assert=Runtime.assert;this.setTimeout=function(d,a){return setTimeout(function(){d()},a)};this.clearTimeout=function(d){clearTimeout(d)};this.libraryPaths=function(){return[__dirname]};this.setCurrentDirectory=function(d){h=d};this.currentDirectory=function(){return h};this.type=function(){return"NodeJSRuntime"};this.getDOMImplementation=function(){return q};this.parseXML=function(d){return p.parseFromString(d,"text/xml")};this.exit=process.exit;this.getWindow=function(){return null};this.requestAnimationFrame=
|
||
|
function(d){return setTimeout(d,15)};this.cancelAnimationFrame=function(d){clearTimeout(d)};p=new (require("xmldom").DOMParser);q=a.parseXML("<a/>").implementation}
|
||
|
function RhinoRuntime(){var f=this,l={},a=l.javax.xml.parsers.DocumentBuilderFactory.newInstance(),d,b,h="";a.setValidating(!1);a.setNamespaceAware(!0);a.setExpandEntityReferences(!1);a.setSchema(null);b=l.org.xml.sax.EntityResolver({resolveEntity:function(d,a){var b=new l.java.io.FileReader(a);return new l.org.xml.sax.InputSource(b)}});d=a.newDocumentBuilder();d.setEntityResolver(b);this.byteArrayFromString=function(d,a){var b,h=d.length,g=new Uint8Array(new ArrayBuffer(h));for(b=0;b<h;b+=1)g[b]=
|
||
|
d.charCodeAt(b)&255;return g};this.byteArrayToString=Runtime.byteArrayToString;this.getVariable=Runtime.getVariable;this.fromJson=Runtime.fromJson;this.toJson=Runtime.toJson;this.loadXML=function(a,b){var h=new l.java.io.File(a),m=null;try{m=d.parse(h)}catch(g){return print(g),b(g,null)}b(null,m)};this.readFile=function(d,a,b){h&&(d=h+"/"+d);var m=new l.java.io.File(d),g="binary"===a?"latin1":a;m.isFile()?((d=readFile(d,g))&&"binary"===a&&(d=f.byteArrayFromString(d,"binary")),b(null,d)):b(d+" is not a file.",
|
||
|
null)};this.writeFile=function(d,a,b){h&&(d=h+"/"+d);d=new l.java.io.FileOutputStream(d);var m,g=a.length;for(m=0;m<g;m+=1)d.write(a[m]);d.close();b(null)};this.deleteFile=function(d,a){h&&(d=h+"/"+d);var b=new l.java.io.File(d),m=d+Math.random(),m=new l.java.io.File(m);b.rename(m)?(m.deleteOnExit(),a(null)):a("Could not delete "+d)};this.read=function(d,a,b,m){h&&(d=h+"/"+d);var g;g=d;var e="binary";(new l.java.io.File(g)).isFile()?("binary"===e&&(e="latin1"),g=readFile(g,e)):g=null;g?m(null,this.byteArrayFromString(g.substring(a,
|
||
|
a+b),"binary")):m("Cannot read "+d,null)};this.readFileSync=function(d,a){if(!a)return"";var b=readFile(d,a);if(null===b)throw"File could not be read.";return b};this.log=function(d,a){var b;void 0!==a?b=d:a=d;"alert"===b&&print("\n!!!!! ALERT !!!!!");print(a);"alert"===b&&print("!!!!! ALERT !!!!!")};this.assert=Runtime.assert;this.setTimeout=function(d){d();return 0};this.clearTimeout=function(){};this.libraryPaths=function(){return["lib"]};this.setCurrentDirectory=function(d){h=d};this.currentDirectory=
|
||
|
function(){return h};this.type=function(){return"RhinoRuntime"};this.getDOMImplementation=function(){return d.getDOMImplementation()};this.parseXML=function(a){a=new l.java.io.StringReader(a);a=new l.org.xml.sax.InputSource(a);return d.parse(a)};this.exit=quit;this.getWindow=function(){return null};this.requestAnimationFrame=function(d){d();return 0};this.cancelAnimationFrame=function(){}}
|
||
|
Runtime.create=function(){return"undefined"!==String(typeof window)?new BrowserRuntime:"undefined"!==String(typeof require)?new NodeJSRuntime:new RhinoRuntime};var runtime=Runtime.create(),core={},gui={},xmldom={},odf={},ops={},webodf={};(function(){webodf.Version="undefined"!==String(typeof webodf_version)?webodf_version:"From Source"})();
|
||
|
(function(){function f(d,a,b){var g=d+"/manifest.json",e,c;runtime.log("Loading manifest: "+g);try{e=runtime.readFileSync(g,"utf-8")}catch(r){if(b)runtime.log("No loadable manifest found.");else throw console.log(String(r)),r;return}b=JSON.parse(e);for(c in b)b.hasOwnProperty(c)&&(a[c]={dir:d,deps:b[c]})}function l(d,a,b){function g(k){if(!r[k]&&!b(k)){if(c[k])throw"Circular dependency detected for "+k+".";c[k]=!0;if(!a[k])throw"Missing dependency information for class "+k+".";var d=a[k],h=d.deps,
|
||
|
p,q=h.length;for(p=0;p<q;p+=1)g(h[p]);c[k]=!1;r[k]=!0;e.push(d.dir+"/"+k.replace(".","/")+".js")}}var e=[],c={},r={};d.forEach(g);return e}function a(d,a){return a+("\n//# sourceURL="+d)}function d(d){var b,h;for(b=0;b<d.length;b+=1)h=runtime.readFileSync(d[b],"utf-8"),h=a(d[b],h),eval(h)}function b(d){d=d.split(".");var a,b=p,g=d.length;for(a=0;a<g;a+=1){if(!b.hasOwnProperty(d[a]))return!1;b=b[d[a]]}return!0}var h,p={core:core,gui:gui,xmldom:xmldom,odf:odf,ops:ops};runtime.loadClasses=function(a,
|
||
|
p){if(IS_COMPILED_CODE||0===a.length)return p&&p();var m;if(!(m=h)){m=[];var g=runtime.libraryPaths(),e;runtime.currentDirectory()&&-1===g.indexOf(runtime.currentDirectory())&&f(runtime.currentDirectory(),m,!0);for(e=0;e<g.length;e+=1)f(g[e],m)}h=m;a=l(a,h,b);if(0===a.length)return p&&p();if("BrowserRuntime"===runtime.type()&&p){m=a;g=document.currentScript||document.documentElement.lastChild;e=document.createDocumentFragment();var c,r;for(r=0;r<m.length;r+=1)c=document.createElement("script"),c.type=
|
||
|
"text/javascript",c.charset="utf-8",c.async=!1,c.setAttribute("src",m[r]),e.appendChild(c);p&&(c.onload=p);g.parentNode.insertBefore(e,g)}else d(a),p&&p()};runtime.loadClass=function(d,a){runtime.loadClasses([d],a)}})();(function(){var f=function(f){return f};runtime.getTranslator=function(){return f};runtime.setTranslator=function(l){f=l};runtime.tr=function(l){var a=f(l);return a&&"string"===String(typeof a)?a:l}})();
|
||
|
(function(f){function l(a){if(a.length){var d=a[0];runtime.readFile(d,"utf8",function(b,h){function p(){var d;(d=eval(f))&&runtime.exit(d)}var q="",q=d.lastIndexOf("/"),f=h,q=-1!==q?d.substring(0,q):".";runtime.setCurrentDirectory(q);b?(runtime.log(b),runtime.exit(1)):null===f?(runtime.log("No code found for "+d),runtime.exit(1)):p.apply(null,a)})}}f=f?Array.prototype.slice.call(f):[];"NodeJSRuntime"===runtime.type()?l(process.argv.slice(2)):"RhinoRuntime"===runtime.type()?l(f):l(f.slice(1))})("undefined"!==
|
||
|
String(typeof arguments)&&arguments);(function(){core.Async=function(){return{forEach:function(f,l,a){function d(d){p!==h&&(d?(p=h,a(d)):(p+=1,p===h&&a(null)))}var b,h=f.length,p=0;for(b=0;b<h;b+=1)l(f[b],d)},destroyAll:function(f,l){function a(d,b){if(b)l(b);else if(d<f.length)f[d](function(b){a(d+1,b)});else l()}a(0,void 0)}}}()})();function makeBase64(){function f(e){var c,k=e.length,r=new Uint8Array(new ArrayBuffer(k));for(c=0;c<k;c+=1)r[c]=e.charCodeAt(c)&255;return r}function l(c){var e,k="",r,d=c.length-2;for(r=0;r<d;r+=3)e=c[r]<<16|c[r+1]<<8|c[r+2],k+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[e>>>18],k+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[e>>>12&63],k+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[e>>>6&63],k+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[e&
|
||
|
63];r===d+1?(e=c[r]<<4,k+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[e>>>6],k+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[e&63],k+="=="):r===d&&(e=c[r]<<10|c[r+1]<<2,k+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[e>>>12],k+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[e>>>6&63],k+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[e&63],k+="=");return k}function a(e){e=e.replace(/[^A-Za-z0-9+\/]+/g,
|
||
|
"");var c=e.length,r=new Uint8Array(new ArrayBuffer(3*c)),d=e.length%4,a=0,b,J;for(b=0;b<c;b+=4)J=(k[e.charAt(b)]||0)<<18|(k[e.charAt(b+1)]||0)<<12|(k[e.charAt(b+2)]||0)<<6|(k[e.charAt(b+3)]||0),r[a]=J>>16,r[a+1]=J>>8&255,r[a+2]=J&255,a+=3;c=3*c-[0,0,2,1][d];return r.subarray(0,c)}function d(e){var c,k,r=e.length,d=0,a=new Uint8Array(new ArrayBuffer(3*r));for(c=0;c<r;c+=1)k=e[c],128>k?a[d++]=k:(2048>k?a[d++]=192|k>>>6:(a[d++]=224|k>>>12&15,a[d++]=128|k>>>6&63),a[d++]=128|k&63);return a.subarray(0,
|
||
|
d)}function b(e){var c,k,r,d,a=e.length,b=new Uint8Array(new ArrayBuffer(a)),g=0;for(c=0;c<a;c+=1)k=e[c],128>k?b[g++]=k:(c+=1,r=e[c],224>k?b[g++]=(k&31)<<6|r&63:(c+=1,d=e[c],b[g++]=(k&15)<<12|(r&63)<<6|d&63));return b.subarray(0,g)}function h(c){return l(f(c))}function p(c){return String.fromCharCode.apply(String,a(c))}function q(c){return b(f(c))}function n(c){c=b(c);for(var e="",k=0;k<c.length;)e+=String.fromCharCode.apply(String,c.subarray(k,k+45E3)),k+=45E3;return e}function m(c,e,k){var r,d,
|
||
|
a,b="";for(a=e;a<k;a+=1)e=c.charCodeAt(a)&255,128>e?b+=String.fromCharCode(e):(a+=1,r=c.charCodeAt(a)&255,224>e?b+=String.fromCharCode((e&31)<<6|r&63):(a+=1,d=c.charCodeAt(a)&255,b+=String.fromCharCode((e&15)<<12|(r&63)<<6|d&63)));return b}function g(c,e){function k(){var a=d+1E5;a>c.length&&(a=c.length);r+=m(c,d,a);d=a;a=d===c.length;e(r,a)&&!a&&runtime.setTimeout(k,0)}var r="",d=0;1E5>c.length?e(m(c,0,c.length),!0):("string"!==typeof c&&(c=c.slice()),k())}function e(c){return d(f(c))}function c(c){return String.fromCharCode.apply(String,
|
||
|
d(c))}function r(c){return String.fromCharCode.apply(String,d(f(c)))}var k=function(c){var e={},k,r;k=0;for(r=c.length;k<r;k+=1)e[c.charAt(k)]=k;return e}("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),x,t,y=runtime.getWindow(),v,s;y&&y.btoa?(v=y.btoa,x=function(c){return v(r(c))}):(v=h,x=function(c){return l(e(c))});y&&y.atob?(s=y.atob,t=function(c){c=s(c);return m(c,0,c.length)}):(s=p,t=function(c){return n(a(c))});core.Base64=function(){this.convertByteArrayToBase64=this.convertUTF8ArrayToBase64=
|
||
|
l;this.convertBase64ToByteArray=this.convertBase64ToUTF8Array=a;this.convertUTF16ArrayToByteArray=this.convertUTF16ArrayToUTF8Array=d;this.convertByteArrayToUTF16Array=this.convertUTF8ArrayToUTF16Array=b;this.convertUTF8StringToBase64=h;this.convertBase64ToUTF8String=p;this.convertUTF8StringToUTF16Array=q;this.convertByteArrayToUTF16String=this.convertUTF8ArrayToUTF16String=n;this.convertUTF8StringToUTF16String=g;this.convertUTF16StringToByteArray=this.convertUTF16StringToUTF8Array=e;this.convertUTF16ArrayToUTF8String=
|
||
|
c;this.convertUTF16StringToUTF8String=r;this.convertUTF16StringToBase64=x;this.convertBase64ToUTF16String=t;this.fromBase64=p;this.toBase64=h;this.atob=s;this.btoa=v;this.utob=r;this.btou=g;this.encode=x;this.encodeURI=function(c){return x(c).replace(/[+\/]/g,function(c){return"+"===c?"-":"_"}).replace(/\\=+$/,"")};this.decode=function(c){return t(c.replace(/[\-_]/g,function(c){return"-"===c?"+":"/"}))};return this};return core.Base64}core.Base64=makeBase64();core.ByteArray=function(f){this.pos=0;this.data=f;this.readUInt32LE=function(){this.pos+=4;var f=this.data,a=this.pos;return f[--a]<<24|f[--a]<<16|f[--a]<<8|f[--a]};this.readUInt16LE=function(){this.pos+=2;var f=this.data,a=this.pos;return f[--a]<<8|f[--a]}};core.ByteArrayWriter=function(f){function l(a){a>b-d&&(b=Math.max(2*b,d+a),a=new Uint8Array(new ArrayBuffer(b)),a.set(h),h=a)}var a=this,d=0,b=1024,h=new Uint8Array(new ArrayBuffer(b));this.appendByteArrayWriter=function(d){a.appendByteArray(d.getByteArray())};this.appendByteArray=function(a){var b=a.length;l(b);h.set(a,d);d+=b};this.appendArray=function(a){var b=a.length;l(b);h.set(a,d);d+=b};this.appendUInt16LE=function(d){a.appendArray([d&255,d>>8&255])};this.appendUInt32LE=function(d){a.appendArray([d&
|
||
|
255,d>>8&255,d>>16&255,d>>24&255])};this.appendString=function(d){a.appendByteArray(runtime.byteArrayFromString(d,f))};this.getLength=function(){return d};this.getByteArray=function(){var a=new Uint8Array(new ArrayBuffer(d));a.set(h.subarray(0,d));return a}};core.CSSUnits=function(){var f=this,l={"in":1,cm:2.54,mm:25.4,pt:72,pc:12,px:96};this.convert=function(a,d,b){return a*l[b]/l[d]};this.convertMeasure=function(a,d){var b,h;a&&d&&(b=parseFloat(a),h=a.replace(b.toString(),""),b=f.convert(b,h,d));return b};this.getUnits=function(a){return a.substr(a.length-2,a.length)}};(function(){function f(){var d,b,h,p,f,l,m,g,e;void 0===a&&(b=(d=runtime.getWindow())&&d.document,l=b.documentElement,m=b.body,a={rangeBCRIgnoresElementBCR:!1,unscaledRangeClientRects:!1,elementBCRIgnoresBodyScroll:!1},b&&(p=b.createElement("div"),p.style.position="absolute",p.style.left="-99999px",p.style.transform="scale(2)",p.style["-webkit-transform"]="scale(2)",f=b.createElement("div"),p.appendChild(f),m.appendChild(p),d=b.createRange(),d.selectNode(f),a.rangeBCRIgnoresElementBCR=0===d.getClientRects().length,
|
||
|
f.appendChild(b.createTextNode("Rect transform test")),b=f.getBoundingClientRect(),h=d.getBoundingClientRect(),a.unscaledRangeClientRects=2<Math.abs(b.height-h.height),p.style.transform="",p.style["-webkit-transform"]="",b=l.style.overflow,h=m.style.overflow,g=m.style.height,e=m.scrollTop,l.style.overflow="visible",m.style.overflow="visible",m.style.height="200%",m.scrollTop=m.scrollHeight,a.elementBCRIgnoresBodyScroll=d.getBoundingClientRect().top!==f.getBoundingClientRect().top,m.scrollTop=e,m.style.height=
|
||
|
g,m.style.overflow=h,l.style.overflow=b,d.detach(),m.removeChild(p),d=Object.keys(a).map(function(c){return c+":"+String(a[c])}).join(", "),runtime.log("Detected browser quirks - "+d)));return a}function l(d,a,h){for(d=d?d.firstElementChild:null;d;){if(d.localName===h&&d.namespaceURI===a)return d;d=d.nextElementSibling}return null}var a;core.DomUtilsImpl=function(){function d(c,e){for(var d=0,a;c.parentNode!==e;)runtime.assert(null!==c.parentNode,"parent is null"),c=c.parentNode;for(a=e.firstChild;a!==
|
||
|
c;)d+=1,a=a.nextSibling;return d}function a(c,e){return 0>=c.compareBoundaryPoints(Range.START_TO_START,e)&&0<=c.compareBoundaryPoints(Range.END_TO_END,e)}function h(c,e){return 0>=c.compareBoundaryPoints(Range.END_TO_START,e)&&0<=c.compareBoundaryPoints(Range.START_TO_END,e)}function p(c,e){var d=null;c.nodeType===Node.TEXT_NODE&&(0===c.length?(c.parentNode.removeChild(c),e.nodeType===Node.TEXT_NODE&&(d=e)):(e.nodeType===Node.TEXT_NODE&&(c.appendData(e.data),e.parentNode.removeChild(e)),d=c));return d}
|
||
|
function q(c){for(var e=c.parentNode;c.firstChild;)e.insertBefore(c.firstChild,c);e.removeChild(c);return e}function n(c,e){for(var d=c.parentNode,a=c.firstChild,b;a;)b=a.nextSibling,n(a,e),a=b;d&&e(c)&&q(c);return d}function m(c,e){return c===e||Boolean(c.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_CONTAINED_BY)}function g(c,e){return f().unscaledRangeClientRects?c:c/e}function e(c,k,d){Object.keys(k).forEach(function(a){var b=a.split(":"),g=b[1],h=d(b[0]),b=k[a],p=typeof b;"object"===p?Object.keys(b).length&&
|
||
|
(a=h?c.getElementsByTagNameNS(h,g)[0]||c.ownerDocument.createElementNS(h,a):c.getElementsByTagName(g)[0]||c.ownerDocument.createElement(a),c.appendChild(a),e(a,b,d)):h&&(runtime.assert("number"===p||"string"===p,"attempting to map unsupported type '"+p+"' (key: "+a+")"),c.setAttributeNS(h,a,String(b)))})}var c=null;this.splitBoundaries=function(c){var e,a=[],b,g,h;if(c.startContainer.nodeType===Node.TEXT_NODE||c.endContainer.nodeType===Node.TEXT_NODE){b=c.endContainer;g=c.endContainer.nodeType!==
|
||
|
Node.TEXT_NODE?c.endOffset===c.endContainer.childNodes.length:!1;h=c.endOffset;e=c.endContainer;if(h<e.childNodes.length)for(e=e.childNodes.item(h),h=0;e.firstChild;)e=e.firstChild;else for(;e.lastChild;)e=e.lastChild,h=e.nodeType===Node.TEXT_NODE?e.textContent.length:e.childNodes.length;e===b&&(b=null);c.setEnd(e,h);h=c.endContainer;0!==c.endOffset&&h.nodeType===Node.TEXT_NODE&&(e=h,c.endOffset!==e.length&&(a.push(e.splitText(c.endOffset)),a.push(e)));h=c.startContainer;0!==c.startOffset&&h.nodeType===
|
||
|
Node.TEXT_NODE&&(e=h,c.startOffset!==e.length&&(h=e.splitText(c.startOffset),a.push(e),a.push(h),c.setStart(h,0)));if(null!==b){for(h=c.endContainer;h.parentNode&&h.parentNode!==b;)h=h.parentNode;g=g?b.childNodes.length:d(h,b);c.setEnd(b,g)}}return a};this.containsRange=a;this.rangesIntersect=h;this.rangeIntersection=function(c,e){var a;h(c,e)&&(a=c.cloneRange(),-1===c.compareBoundaryPoints(Range.START_TO_START,e)&&a.setStart(e.startContainer,e.startOffset),1===c.compareBoundaryPoints(Range.END_TO_END,
|
||
|
e)&&a.setEnd(e.endContainer,e.endOffset));return a};this.getNodesInRange=function(c,e,a){var d=[],b=c.commonAncestorContainer,b=b.nodeType===Node.TEXT_NODE?b.parentNode:b;a=c.startContainer.ownerDocument.createTreeWalker(b,a,e,!1);var g,h;c.endContainer.childNodes[c.endOffset-1]?(g=c.endContainer.childNodes[c.endOffset-1],h=Node.DOCUMENT_POSITION_PRECEDING|Node.DOCUMENT_POSITION_CONTAINED_BY):(g=c.endContainer,h=Node.DOCUMENT_POSITION_PRECEDING);c.startContainer.childNodes[c.startOffset]?(c=c.startContainer.childNodes[c.startOffset],
|
||
|
a.currentNode=c):c.startOffset===(c.startContainer.nodeType===Node.TEXT_NODE?c.startContainer.length:c.startContainer.childNodes.length)?(c=c.startContainer,a.currentNode=c,a.lastChild(),c=a.nextNode()):(c=c.startContainer,a.currentNode=c);if(c){c=a.currentNode;if(c!==b)for(c=c.parentNode;c&&c!==b;)e(c)===NodeFilter.FILTER_REJECT&&(a.currentNode=c),c=c.parentNode;c=a.currentNode;switch(e(c)){case NodeFilter.FILTER_REJECT:for(c=a.nextSibling();!c&&a.parentNode();)c=a.nextSibling();break;case NodeFilter.FILTER_SKIP:c=
|
||
|
a.nextNode()}for(;c;){e=g.compareDocumentPosition(c);if(0!==e&&0===(e&h))break;d.push(c);c=a.nextNode()}}return d};this.normalizeTextNodes=function(c){c&&c.nextSibling&&(c=p(c,c.nextSibling));c&&c.previousSibling&&p(c.previousSibling,c)};this.rangeContainsNode=function(c,e){var d=e.ownerDocument.createRange(),g=e.ownerDocument.createRange(),h;d.setStart(c.startContainer,c.startOffset);d.setEnd(c.endContainer,c.endOffset);g.selectNodeContents(e);h=a(d,g);d.detach();g.detach();return h};this.mergeIntoParent=
|
||
|
q;this.removeUnwantedNodes=n;this.removeAllChildNodes=function(c){for(;c.firstChild;)c.removeChild(c.firstChild)};this.getElementsByTagNameNS=function(c,e,a){var d=[];c=c.getElementsByTagNameNS(e,a);d.length=a=c.length;for(e=0;e<a;e+=1)d[e]=c.item(e);return d};this.getElementsByTagName=function(c,e){var a=[],d,b,g;d=c.getElementsByTagName(e);a.length=g=d.length;for(b=0;b<g;b+=1)a[b]=d.item(b);return a};this.containsNode=function(c,e){return c===e||c.contains(e)};this.comparePoints=function(c,e,a,
|
||
|
b){if(c===a)return b-e;var g=c.compareDocumentPosition(a);2===g?g=-1:4===g?g=1:10===g?(e=d(c,a),g=e<b?1:-1):(b=d(a,c),g=b<e?-1:1);return g};this.adaptRangeDifferenceToZoomLevel=g;this.translateRect=function(c,e,a){return{top:g(c.top-e.top,a),left:g(c.left-e.left,a),bottom:g(c.bottom-e.top,a),right:g(c.right-e.left,a),width:g(c.width,a),height:g(c.height,a)}};this.getBoundingClientRect=function(e){var a=e.ownerDocument,d=f(),b=a.body;if((!1===d.unscaledRangeClientRects||d.rangeBCRIgnoresElementBCR)&&
|
||
|
e.nodeType===Node.ELEMENT_NODE)return e=e.getBoundingClientRect(),d.elementBCRIgnoresBodyScroll?{left:e.left+b.scrollLeft,right:e.right+b.scrollLeft,top:e.top+b.scrollTop,bottom:e.bottom+b.scrollTop,width:e.width,height:e.height}:e;var g;c?g=c:c=g=a.createRange();d=g;d.selectNode(e);return d.getBoundingClientRect()};this.mapKeyValObjOntoNode=function(c,e,a){Object.keys(e).forEach(function(d){var b=d.split(":"),g=b[1],b=a(b[0]),h=e[d];b?(g=c.getElementsByTagNameNS(b,g)[0],g||(g=c.ownerDocument.createElementNS(b,
|
||
|
d),c.appendChild(g)),g.textContent=h):runtime.log("Key ignored: "+d)})};this.removeKeyElementsFromNode=function(c,e,a){e.forEach(function(e){var d=e.split(":"),k=d[1];(d=a(d[0]))?(k=c.getElementsByTagNameNS(d,k)[0])?k.parentNode.removeChild(k):runtime.log("Element for "+e+" not found."):runtime.log("Property Name ignored: "+e)})};this.getKeyValRepresentationOfNode=function(c,e){for(var a={},d=c.firstElementChild,b;d;){if(b=e(d.namespaceURI))a[b+":"+d.localName]=d.textContent;d=d.nextElementSibling}return a};
|
||
|
this.mapObjOntoNode=e;this.cloneEvent=function(c){var e=Object.create(null);Object.keys(c).forEach(function(a){e[a]=c[a]});e.prototype=c.constructor.prototype;return e};this.getDirectChild=l;(function(c){var e,a;a=runtime.getWindow();null!==a&&(e=a.navigator.appVersion.toLowerCase(),a=-1===e.indexOf("chrome")&&(-1!==e.indexOf("applewebkit")||-1!==e.indexOf("safari")),e=-1!==e.indexOf("msie")||-1!==e.indexOf("trident"),a||e)&&(c.containsNode=m)})(this)};core.DomUtils=new core.DomUtilsImpl})();core.Cursor=function(f,l){function a(e){e.parentNode&&(q.push(e.previousSibling),q.push(e.nextSibling),e.parentNode.removeChild(e))}function d(e,c,a){if(c.nodeType===Node.TEXT_NODE){runtime.assert(Boolean(c),"putCursorIntoTextNode: invalid container");var d=c.parentNode;runtime.assert(Boolean(d),"putCursorIntoTextNode: container without parent");runtime.assert(0<=a&&a<=c.length,"putCursorIntoTextNode: offset is out of bounds");0===a?d.insertBefore(e,c):(a!==c.length&&c.splitText(a),d.insertBefore(e,
|
||
|
c.nextSibling))}else c.nodeType===Node.ELEMENT_NODE&&c.insertBefore(e,c.childNodes.item(a));q.push(e.previousSibling);q.push(e.nextSibling)}var b=f.createElementNS("urn:webodf:names:cursor","cursor"),h=f.createElementNS("urn:webodf:names:cursor","anchor"),p,q=[],n=f.createRange(),m,g=core.DomUtils;this.getNode=function(){return b};this.getAnchorNode=function(){return h.parentNode?h:b};this.getSelectedRange=function(){m?(n.setStartBefore(b),n.collapse(!0)):(n.setStartAfter(p?h:b),n.setEndBefore(p?
|
||
|
b:h));return n};this.setSelectedRange=function(e,c){n&&n!==e&&n.detach();n=e;p=!1!==c;(m=e.collapsed)?(a(h),a(b),d(b,e.startContainer,e.startOffset)):(a(h),a(b),d(p?b:h,e.endContainer,e.endOffset),d(p?h:b,e.startContainer,e.startOffset));q.forEach(g.normalizeTextNodes);q.length=0};this.hasForwardSelection=function(){return p};this.remove=function(){a(b);q.forEach(g.normalizeTextNodes);q.length=0};b.setAttributeNS("urn:webodf:names:cursor","memberId",l);h.setAttributeNS("urn:webodf:names:cursor","memberId",
|
||
|
l)};core.Destroyable=function(){};core.Destroyable.prototype.destroy=function(f){};core.EventSource=function(){};core.EventSource.prototype.subscribe=function(f,l){};core.EventSource.prototype.unsubscribe=function(f,l){};core.EventNotifier=function(f){function l(d){runtime.assert(!a.hasOwnProperty(d),'Duplicated event ids: "'+d+'" registered more than once.');a[d]=[]}var a={};this.emit=function(d,b){var h,p;runtime.assert(a.hasOwnProperty(d),'unknown event fired "'+d+'"');p=a[d];for(h=0;h<p.length;h+=1)p[h](b)};this.subscribe=function(d,b){runtime.assert(a.hasOwnProperty(d),'tried to subscribe to unknown event "'+d+'"');a[d].push(b)};this.unsubscribe=function(d,b){var h;runtime.assert(a.hasOwnProperty(d),'tried to unsubscribe from unknown event "'+
|
||
|
d+'"');h=a[d].indexOf(b);runtime.assert(-1!==h,'tried to unsubscribe unknown callback from event "'+d+'"');-1!==h&&a[d].splice(h,1)};this.register=l;f&&f.forEach(l)};core.ScheduledTask=function(f,l,a){function d(){p&&(a(h),p=!1)}function b(){d();f.apply(void 0,q);q=null}var h,p=!1,q=[],n=!1;this.trigger=function(){runtime.assert(!1===n,"Can't trigger destroyed ScheduledTask instance");q=Array.prototype.slice.call(arguments);p||(p=!0,h=l(b))};this.triggerImmediate=function(){runtime.assert(!1===n,"Can't trigger destroyed ScheduledTask instance");q=Array.prototype.slice.call(arguments);b()};this.processRequests=function(){p&&b()};this.cancel=d;this.restart=function(){runtime.assert(!1===
|
||
|
n,"Can't trigger destroyed ScheduledTask instance");d();p=!0;h=l(b)};this.destroy=function(a){d();n=!0;a()}};(function(){var f;core.Task={};core.Task.SUPPRESS_MANUAL_PROCESSING=!1;core.Task.processTasks=function(){core.Task.SUPPRESS_MANUAL_PROCESSING||f.performRedraw()};core.Task.createRedrawTask=function(l){return new core.ScheduledTask(l,f.requestRedrawTask,f.cancelRedrawTask)};core.Task.createTimeoutTask=function(f,a){return new core.ScheduledTask(f,function(d){return runtime.setTimeout(d,a)},runtime.clearTimeout)};f=new function(){var f={};this.requestRedrawTask=function(a){var d=runtime.requestAnimationFrame(function(){a();
|
||
|
delete f[d]});f[d]=a;return d};this.performRedraw=function(){Object.keys(f).forEach(function(a){f[a]();runtime.cancelAnimationFrame(parseInt(a,10))});f={}};this.cancelRedrawTask=function(a){runtime.cancelAnimationFrame(a);delete f[a]}}})();core.EventSubscriptions=function(){function f(d,b,h){d.subscribe(b,h);a.push({eventSource:d,eventid:b,callback:h})}function l(){var h=[];a.forEach(function(a){a.eventSource.unsubscribe(a.eventid,a.callback)});a.length=0;Object.keys(b).forEach(function(a){b[a].forEach(function(a){h.push(a.task.destroy)});delete b[a]});core.Async.destroyAll(h,function(){});d=new core.EventNotifier}var a=[],d=new core.EventNotifier,b={},h=0;this.addSubscription=f;this.addFrameSubscription=function(a,q,l){var m,g,e,c;
|
||
|
b.hasOwnProperty(q)||(b[q]=[]);e=b[q];for(c=0;c<e.length;c+=1)if(e[c].eventSource===a){m=e[c];break}m||(g="s"+h,h+=1,d.register(g),m={frameEventId:g,eventSource:a,task:core.Task.createRedrawTask(function(){d.emit(g,void 0)})},e.push(m),f(a,q,m.task.trigger));d.subscribe(m.frameEventId,l)};this.unsubscribeAll=l;this.destroy=function(a){l();a()}};core.LazyProperty=function(f){var l,a=!1;this.value=function(){a||(l=f(),a=!0);return l};this.reset=function(){a=!1}};core.LoopWatchDog=function(f,l){var a=Date.now(),d=0;this.check=function(){var b;if(f&&(b=Date.now(),b-a>f))throw runtime.log("alert","watchdog timeout"),"timeout!";if(0<l&&(d+=1,d>l))throw runtime.log("alert","watchdog loop overflow"),"loop overflow";}};core.NodeFilterChain=function(f){var l=NodeFilter.FILTER_REJECT,a=NodeFilter.FILTER_ACCEPT;this.acceptNode=function(d){var b;for(b=0;b<f.length;b+=1)if(f[b].acceptNode(d)===l)return l;return a}};core.PositionIterator=function(f,l,a,d){function b(){this.acceptNode=function(c){return!c||c.nodeType===r&&0===c.length?t:x}}function h(c){this.acceptNode=function(e){return!e||e.nodeType===r&&0===e.length?t:c.acceptNode(e)}}function p(){var c=g.currentNode,a=c.nodeType;e=a===r?c.length-1:a===k?1:0}function q(){if(null===g.previousSibling()){if(!g.parentNode()||g.currentNode===f)return g.firstChild(),!1;e=0}else p();return!0}function n(){var a=g.currentNode,d;d=c(a);if(a!==f)for(a=a.parentNode;a&&
|
||
|
a!==f;)c(a)===t&&(g.currentNode=a,d=t),a=a.parentNode;d===t?(e=g.currentNode.nodeType===r?a.length:1,a=m.nextPosition()):a=d===x?!0:m.nextPosition();a&&runtime.assert(c(g.currentNode)===x,"moveToAcceptedNode did not result in walker being on an accepted node");return a}var m=this,g,e,c,r=Node.TEXT_NODE,k=Node.ELEMENT_NODE,x=NodeFilter.FILTER_ACCEPT,t=NodeFilter.FILTER_REJECT;this.nextPosition=function(){var c=g.currentNode,a=c.nodeType;if(c===f)return!1;if(0===e&&a===k)null===g.firstChild()&&(e=1);
|
||
|
else if(a===r&&e+1<c.length)e+=1;else if(null!==g.nextSibling())e=0;else if(g.parentNode())e=1;else return!1;return!0};this.previousPosition=function(){var c=!0,a=g.currentNode;0===e?c=q():a.nodeType===r?e-=1:null!==g.lastChild()?p():a===f?c=!1:e=0;return c};this.previousNode=q;this.container=function(){var c=g.currentNode,a=c.nodeType;0===e&&a!==r&&(c=c.parentNode);return c};this.rightNode=function(){var a=g.currentNode,d=a.nodeType;if(d===r&&e===a.length)for(a=a.nextSibling;a&&c(a)!==x;)a=a.nextSibling;
|
||
|
else d===k&&1===e&&(a=null);return a};this.leftNode=function(){var a=g.currentNode;if(0===e)for(a=a.previousSibling;a&&c(a)!==x;)a=a.previousSibling;else if(a.nodeType===k)for(a=a.lastChild;a&&c(a)!==x;)a=a.previousSibling;return a};this.getCurrentNode=function(){return g.currentNode};this.unfilteredDomOffset=function(){if(g.currentNode.nodeType===r)return e;for(var c=0,a=g.currentNode,a=1===e?a.lastChild:a.previousSibling;a;)c+=1,a=a.previousSibling;return c};this.getPreviousSibling=function(){var c=
|
||
|
g.currentNode,e=g.previousSibling();g.currentNode=c;return e};this.getNextSibling=function(){var c=g.currentNode,e=g.nextSibling();g.currentNode=c;return e};this.setPositionBeforeElement=function(c){runtime.assert(Boolean(c),"setPositionBeforeElement called without element");g.currentNode=c;e=0;return n()};this.setUnfilteredPosition=function(c,a){runtime.assert(Boolean(c),"PositionIterator.setUnfilteredPosition called without container");g.currentNode=c;c.nodeType===r?(e=a,runtime.assert(a<=c.length,
|
||
|
"Error in setPosition: "+a+" > "+c.length),runtime.assert(0<=a,"Error in setPosition: "+a+" < 0"),a===c.length&&(g.nextSibling()?e=0:g.parentNode()?e=1:runtime.assert(!1,"Error in setUnfilteredPosition: position not valid."))):a<c.childNodes.length?(g.currentNode=c.childNodes.item(a),e=0):e=1;return n()};this.moveToEnd=function(){g.currentNode=f;e=1};this.moveToEndOfNode=function(c){c.nodeType===r?m.setUnfilteredPosition(c,c.length):(g.currentNode=c,e=1)};this.isBeforeNode=function(){return 0===e};
|
||
|
this.getNodeFilter=function(){return c};c=(a?new h(a):new b).acceptNode;c.acceptNode=c;l=l||NodeFilter.SHOW_ALL;runtime.assert(f.nodeType!==Node.TEXT_NODE,"Internet Explorer doesn't allow tree walker roots to be text nodes");g=f.ownerDocument.createTreeWalker(f,l,c,d);e=0;null===g.firstChild()&&(e=1)};core.PositionFilter=function(){};core.PositionFilter.FilterResult={FILTER_ACCEPT:1,FILTER_REJECT:2,FILTER_SKIP:3};core.PositionFilter.prototype.acceptPosition=function(f){};core.PositionFilterChain=function(){var f=[],l=core.PositionFilter.FilterResult.FILTER_ACCEPT,a=core.PositionFilter.FilterResult.FILTER_REJECT;this.acceptPosition=function(d){var b;for(b=0;b<f.length;b+=1)if(f[b].acceptPosition(d)===a)return a;return l};this.addFilter=function(a){f.push(a)}};(function(){core.RawInflate=function(){var f;(function(l){f=l()})(function(){return function a(d,b,h){function f(q,m){if(!b[q]){if(!d[q])throw Error("Cannot find module '"+q+"'");var g=b[q]={exports:{}};d[q][0].call(g.exports,function(e){var c=d[q][1][e];return f(c?c:e)},g,g.exports,a,d,b,h)}return b[q].exports}for(var q=0;q<h.length;q++)f(h[q]);return f}({1:[function(a,d,b){function h(c,e){var a=new r(e);a.push(c,!0);if(a.err)throw a.msg;return a.result}var f=a("./zlib/inflate.js"),q=a("./utils/common"),
|
||
|
n=a("./utils/strings"),m=a("./zlib/constants"),g=a("./zlib/messages"),e=a("./zlib/zstream"),c=a("./zlib/gzheader"),r=function(a){var d=this.options=q.assign({chunkSize:16384,windowBits:0,to:""},a||{});d.raw&&0<=d.windowBits&&16>d.windowBits&&(d.windowBits=-d.windowBits,0===d.windowBits&&(d.windowBits=-15));!(0<=d.windowBits&&16>d.windowBits)||a&&a.windowBits||(d.windowBits+=32);15<d.windowBits&&48>d.windowBits&&0===(d.windowBits&15)&&(d.windowBits|=15);this.err=0;this.msg="";this.ended=!1;this.chunks=
|
||
|
[];this.strm=new e;this.strm.avail_out=0;a=f.inflateInit2(this.strm,d.windowBits);if(a!==m.Z_OK)throw Error(g[a]);this.header=new c;f.inflateGetHeader(this.strm,this.header)};r.prototype.push=function(c,e){var a=this.strm,d=this.options.chunkSize,b,g,r,h,A;if(this.ended)return!1;g=e===~~e?e:!0===e?m.Z_FINISH:m.Z_NO_FLUSH;a.input="string"===typeof c?n.binstring2buf(c):c;a.next_in=0;a.avail_in=a.input.length;do{0===a.avail_out&&(a.output=new q.Buf8(d),a.next_out=0,a.avail_out=d);b=f.inflate(a,m.Z_NO_FLUSH);
|
||
|
if(b!==m.Z_STREAM_END&&b!==m.Z_OK)return this.onEnd(b),this.ended=!0,!1;if(a.next_out&&(0===a.avail_out||b===m.Z_STREAM_END||0===a.avail_in&&g===m.Z_FINISH))if("string"===this.options.to)r=n.utf8border(a.output,a.next_out),h=a.next_out-r,A=n.buf2string(a.output,r),a.next_out=h,a.avail_out=d-h,h&&q.arraySet(a.output,a.output,r,h,0),this.onData(A);else this.onData(q.shrinkBuf(a.output,a.next_out))}while((0<a.avail_in||0===a.avail_out)&&b!==m.Z_STREAM_END);b===m.Z_STREAM_END&&(g=m.Z_FINISH);return g===
|
||
|
m.Z_FINISH?(b=f.inflateEnd(this.strm),this.onEnd(b),this.ended=!0,b===m.Z_OK):!0};r.prototype.onData=function(c){this.chunks.push(c)};r.prototype.onEnd=function(c){c===m.Z_OK&&(this.result="string"===this.options.to?this.chunks.join(""):q.flattenChunks(this.chunks));this.chunks=[];this.err=c;this.msg=this.strm.msg};b.Inflate=r;b.inflate=h;b.inflateRaw=function(c,e){e=e||{};e.raw=!0;return h(c,e)};b.ungzip=h},{"./utils/common":2,"./utils/strings":3,"./zlib/constants":5,"./zlib/gzheader":7,"./zlib/inflate.js":9,
|
||
|
"./zlib/messages":11,"./zlib/zstream":12}],2:[function(a,d,b){a="undefined"!==typeof Uint8Array&&"undefined"!==typeof Uint16Array&&"undefined"!==typeof Int32Array;b.assign=function(a){for(var d=Array.prototype.slice.call(arguments,1);d.length;){var b=d.shift();if(b){if("object"!==typeof b)throw new TypeError(b+"must be non-object");for(var g in b)b.hasOwnProperty(g)&&(a[g]=b[g])}}return a};b.shrinkBuf=function(a,d){if(a.length===d)return a;if(a.subarray)return a.subarray(0,d);a.length=d;return a};
|
||
|
var h={arraySet:function(a,d,b,g,e){if(d.subarray&&a.subarray)a.set(d.subarray(b,b+g),e);else for(var c=0;c<g;c++)a[e+c]=d[b+c]},flattenChunks:function(a){var d,b,g,e,c;d=g=0;for(b=a.length;d<b;d++)g+=a[d].length;c=new Uint8Array(g);d=g=0;for(b=a.length;d<b;d++)e=a[d],c.set(e,g),g+=e.length;return c}},f={arraySet:function(a,d,b,g,e){for(var c=0;c<g;c++)a[e+c]=d[b+c]},flattenChunks:function(a){return[].concat.apply([],a)}};b.setTyped=function(a){a?(b.Buf8=Uint8Array,b.Buf16=Uint16Array,b.Buf32=Int32Array,
|
||
|
b.assign(b,h)):(b.Buf8=Array,b.Buf16=Array,b.Buf32=Array,b.assign(b,f))};b.setTyped(a)},{}],3:[function(a,d,b){function h(c,e){if(65537>e&&(c.subarray&&n||!c.subarray&&q))return String.fromCharCode.apply(null,f.shrinkBuf(c,e));for(var a="",d=0;d<e;d++)a+=String.fromCharCode(c[d]);return a}var f=a("./common"),q=!0,n=!0;try{String.fromCharCode.apply(null,[0])}catch(m){q=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(g){n=!1}var e=new f.Buf8(256);for(a=0;256>a;a++)e[a]=252<=a?6:248<=
|
||
|
a?5:240<=a?4:224<=a?3:192<=a?2:1;e[254]=e[254]=1;b.string2buf=function(c){var e,a,d,b,g,h=c.length,m=0;for(b=0;b<h;b++)a=c.charCodeAt(b),55296===(a&64512)&&b+1<h&&(d=c.charCodeAt(b+1),56320===(d&64512)&&(a=65536+(a-55296<<10)+(d-56320),b++)),m+=128>a?1:2048>a?2:65536>a?3:4;e=new f.Buf8(m);for(b=g=0;g<m;b++)a=c.charCodeAt(b),55296===(a&64512)&&b+1<h&&(d=c.charCodeAt(b+1),56320===(d&64512)&&(a=65536+(a-55296<<10)+(d-56320),b++)),128>a?e[g++]=a:(2048>a?e[g++]=192|a>>>6:(65536>a?e[g++]=224|a>>>12:(e[g++]=
|
||
|
240|a>>>18,e[g++]=128|a>>>12&63),e[g++]=128|a>>>6&63),e[g++]=128|a&63);return e};b.buf2binstring=function(c){return h(c,c.length)};b.binstring2buf=function(c){for(var a=new f.Buf8(c.length),e=0,d=a.length;e<d;e++)a[e]=c.charCodeAt(e);return a};b.buf2string=function(c,a){var d,b,g,f,p=a||c.length,m=Array(2*p);for(d=b=0;d<p;)if(g=c[d++],128>g)m[b++]=g;else if(f=e[g],4<f)m[b++]=65533,d+=f-1;else{for(g&=2===f?31:3===f?15:7;1<f&&d<p;)g=g<<6|c[d++]&63,f--;1<f?m[b++]=65533:65536>g?m[b++]=g:(g-=65536,m[b++]=
|
||
|
55296|g>>10&1023,m[b++]=56320|g&1023)}return h(m,b)};b.utf8border=function(c,a){var d;a=a||c.length;a>c.length&&(a=c.length);for(d=a-1;0<=d&&128===(c[d]&192);)d--;return 0>d||0===d?a:d+e[c[d]]>a?d:a}},{"./common":2}],4:[function(a,d,b){d.exports=function(a,d,b,f){var m=a&65535|0;a=a>>>16&65535|0;for(var g=0;0!==b;){g=2E3<b?2E3:b;b-=g;do m=m+d[f++]|0,a=a+m|0;while(--g);m%=65521;a%=65521}return m|a<<16|0}},{}],5:[function(a,d,b){d.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,
|
||
|
Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],6:[function(a,d,b){var h=function(){for(var a,d=[],b=0;256>b;b++){a=b;for(var h=0;8>h;h++)a=a&1?3988292384^a>>>1:a>>>1;d[b]=a}return d}();d.exports=function(a,d,b,f){b=f+b;for(a^=
|
||
|
-1;f<b;f++)a=a>>>8^h[(a^d[f])&255];return a^-1}},{}],7:[function(a,d,b){d.exports=function(){this.os=this.xflags=this.time=this.text=0;this.extra=null;this.extra_len=0;this.comment=this.name="";this.hcrc=0;this.done=!1}},{}],8:[function(a,d,b){d.exports=function(a,d){var b,f,m,g,e,c,r,k,x,t,y,v,s,w,u,A,E,B,F,J,H,Q,N,z;b=a.state;f=a.next_in;N=a.input;m=f+(a.avail_in-5);g=a.next_out;z=a.output;e=g-(d-a.avail_out);c=g+(a.avail_out-257);r=b.dmax;k=b.wsize;x=b.whave;t=b.wnext;y=b.window;v=b.hold;s=b.bits;
|
||
|
w=b.lencode;u=b.distcode;A=(1<<b.lenbits)-1;E=(1<<b.distbits)-1;a:do b:for(15>s&&(v+=N[f++]<<s,s+=8,v+=N[f++]<<s,s+=8),B=w[v&A];;){F=B>>>24;v>>>=F;s-=F;F=B>>>16&255;if(0===F)z[g++]=B&65535;else if(F&16){J=B&65535;if(F&=15)s<F&&(v+=N[f++]<<s,s+=8),J+=v&(1<<F)-1,v>>>=F,s-=F;15>s&&(v+=N[f++]<<s,s+=8,v+=N[f++]<<s,s+=8);B=u[v&E];c:for(;;){F=B>>>24;v>>>=F;s-=F;F=B>>>16&255;if(F&16){B&=65535;F&=15;s<F&&(v+=N[f++]<<s,s+=8,s<F&&(v+=N[f++]<<s,s+=8));B+=v&(1<<F)-1;if(B>r){a.msg="invalid distance too far back";
|
||
|
b.mode=30;break a}v>>>=F;s-=F;F=g-e;if(B>F){F=B-F;if(F>x&&b.sane){a.msg="invalid distance too far back";b.mode=30;break a}H=0;Q=y;if(0===t){if(H+=k-F,F<J){J-=F;do z[g++]=y[H++];while(--F);H=g-B;Q=z}}else if(t<F){if(H+=k+t-F,F-=t,F<J){J-=F;do z[g++]=y[H++];while(--F);H=0;if(t<J){F=t;J-=F;do z[g++]=y[H++];while(--F);H=g-B;Q=z}}}else if(H+=t-F,F<J){J-=F;do z[g++]=y[H++];while(--F);H=g-B;Q=z}for(;2<J;)z[g++]=Q[H++],z[g++]=Q[H++],z[g++]=Q[H++],J-=3;J&&(z[g++]=Q[H++],1<J&&(z[g++]=Q[H++]))}else{H=g-B;do z[g++]=
|
||
|
z[H++],z[g++]=z[H++],z[g++]=z[H++],J-=3;while(2<J);J&&(z[g++]=z[H++],1<J&&(z[g++]=z[H++]))}}else if(0===(F&64)){B=u[(B&65535)+(v&(1<<F)-1)];continue c}else{a.msg="invalid distance code";b.mode=30;break a}break}}else if(0===(F&64)){B=w[(B&65535)+(v&(1<<F)-1)];continue b}else{F&32?b.mode=12:(a.msg="invalid literal/length code",b.mode=30);break a}break}while(f<m&&g<c);J=s>>3;f-=J;s-=J<<3;a.next_in=f;a.next_out=g;a.avail_in=f<m?5+(m-f):5-(f-m);a.avail_out=g<c?257+(c-g):257-(g-c);b.hold=v&(1<<s)-1;b.bits=
|
||
|
s}},{}],9:[function(a,d,b){function h(c){return(c>>>24&255)+(c>>>8&65280)+((c&65280)<<8)+((c&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 q(c){var a;if(!c||!c.state)return y;a=c.state;c.total_in=c.total_out=a.total=0;c.msg="";a.wrap&&(c.adler=a.wrap&1);a.mode=v;a.last=0;a.havedict=0;a.dmax=32768;a.head=null;a.hold=0;a.bits=0;a.lencode=a.lendyn=new e.Buf32(s);a.distcode=a.distdyn=new e.Buf32(w);a.sane=1;a.back=-1;return t}function n(c){var a;if(!c||!c.state)return y;a=c.state;a.wsize=0;a.whave=0;a.wnext=0;return q(c)}function m(c,a){var e,d;if(!c||
|
||
|
!c.state)return y;d=c.state;0>a?(e=0,a=-a):(e=(a>>4)+1,48>a&&(a&=15));if(a&&(8>a||15<a))return y;null!==d.window&&d.wbits!==a&&(d.window=null);d.wrap=e;d.wbits=a;return n(c)}function g(c,a){var e;if(!c)return y;e=new f;c.state=e;e.window=null;e=m(c,a);e!==t&&(c.state=null);return e}var e=a("../utils/common"),c=a("./adler32"),r=a("./crc32"),k=a("./inffast"),x=a("./inftrees"),t=0,y=-2,v=1,s=852,w=592,u=!0,A,E;b.inflateReset=n;b.inflateReset2=m;b.inflateResetKeep=q;b.inflateInit=function(c){return g(c,
|
||
|
15)};b.inflateInit2=g;b.inflate=function(a,d){var b,g,f,p,z,m,q,n,s,w,T,D,P,Z;D=0;var C,V,$,ca,U,W=new e.Buf8(4),O=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!a||!a.state||!a.output||!a.input&&0!==a.avail_in)return y;b=a.state;12===b.mode&&(b.mode=13);z=a.next_out;f=a.output;q=a.avail_out;p=a.next_in;g=a.input;m=a.avail_in;n=b.hold;s=b.bits;w=m;T=q;U=t;a:for(;;)switch(b.mode){case v:if(0===b.wrap){b.mode=13;break}for(;16>s;){if(0===m)break a;m--;n+=g[p++]<<s;s+=8}if(b.wrap&2&&35615===n){b.check=
|
||
|
0;W[0]=n&255;W[1]=n>>>8&255;b.check=r(b.check,W,2,0);s=n=0;b.mode=2;break}b.flags=0;b.head&&(b.head.done=!1);if(!(b.wrap&1)||(((n&255)<<8)+(n>>8))%31){a.msg="incorrect header check";b.mode=30;break}if(8!==(n&15)){a.msg="unknown compression method";b.mode=30;break}n>>>=4;s-=4;P=(n&15)+8;if(0===b.wbits)b.wbits=P;else if(P>b.wbits){a.msg="invalid window size";b.mode=30;break}b.dmax=1<<P;a.adler=b.check=1;b.mode=n&512?10:12;s=n=0;break;case 2:for(;16>s;){if(0===m)break a;m--;n+=g[p++]<<s;s+=8}b.flags=
|
||
|
n;if(8!==(b.flags&255)){a.msg="unknown compression method";b.mode=30;break}if(b.flags&57344){a.msg="unknown header flags set";b.mode=30;break}b.head&&(b.head.text=n>>8&1);b.flags&512&&(W[0]=n&255,W[1]=n>>>8&255,b.check=r(b.check,W,2,0));s=n=0;b.mode=3;case 3:for(;32>s;){if(0===m)break a;m--;n+=g[p++]<<s;s+=8}b.head&&(b.head.time=n);b.flags&512&&(W[0]=n&255,W[1]=n>>>8&255,W[2]=n>>>16&255,W[3]=n>>>24&255,b.check=r(b.check,W,4,0));s=n=0;b.mode=4;case 4:for(;16>s;){if(0===m)break a;m--;n+=g[p++]<<s;s+=
|
||
|
8}b.head&&(b.head.xflags=n&255,b.head.os=n>>8);b.flags&512&&(W[0]=n&255,W[1]=n>>>8&255,b.check=r(b.check,W,2,0));s=n=0;b.mode=5;case 5:if(b.flags&1024){for(;16>s;){if(0===m)break a;m--;n+=g[p++]<<s;s+=8}b.length=n;b.head&&(b.head.extra_len=n);b.flags&512&&(W[0]=n&255,W[1]=n>>>8&255,b.check=r(b.check,W,2,0));s=n=0}else b.head&&(b.head.extra=null);b.mode=6;case 6:if(b.flags&1024&&(D=b.length,D>m&&(D=m),D&&(b.head&&(P=b.head.extra_len-b.length,b.head.extra||(b.head.extra=Array(b.head.extra_len)),e.arraySet(b.head.extra,
|
||
|
g,p,D,P)),b.flags&512&&(b.check=r(b.check,g,D,p)),m-=D,p+=D,b.length-=D),b.length))break a;b.length=0;b.mode=7;case 7:if(b.flags&2048){if(0===m)break a;D=0;do P=g[p+D++],b.head&&P&&65536>b.length&&(b.head.name+=String.fromCharCode(P));while(P&&D<m);b.flags&512&&(b.check=r(b.check,g,D,p));m-=D;p+=D;if(P)break a}else b.head&&(b.head.name=null);b.length=0;b.mode=8;case 8:if(b.flags&4096){if(0===m)break a;D=0;do P=g[p+D++],b.head&&P&&65536>b.length&&(b.head.comment+=String.fromCharCode(P));while(P&&D<
|
||
|
m);b.flags&512&&(b.check=r(b.check,g,D,p));m-=D;p+=D;if(P)break a}else b.head&&(b.head.comment=null);b.mode=9;case 9:if(b.flags&512){for(;16>s;){if(0===m)break a;m--;n+=g[p++]<<s;s+=8}if(n!==(b.check&65535)){a.msg="header crc mismatch";b.mode=30;break}s=n=0}b.head&&(b.head.hcrc=b.flags>>9&1,b.head.done=!0);a.adler=b.check=0;b.mode=12;break;case 10:for(;32>s;){if(0===m)break a;m--;n+=g[p++]<<s;s+=8}a.adler=b.check=h(n);s=n=0;b.mode=11;case 11:if(0===b.havedict)return a.next_out=z,a.avail_out=q,a.next_in=
|
||
|
p,a.avail_in=m,b.hold=n,b.bits=s,2;a.adler=b.check=1;b.mode=12;case 12:if(5===d||6===d)break a;case 13:if(b.last){n>>>=s&7;s-=s&7;b.mode=27;break}for(;3>s;){if(0===m)break a;m--;n+=g[p++]<<s;s+=8}b.last=n&1;n>>>=1;s-=1;switch(n&3){case 0:b.mode=14;break;case 1:D=b;if(u){P=void 0;A=new e.Buf32(512);E=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;x(1,D.lens,0,288,A,0,D.work,{bits:9});for(P=0;32>P;)D.lens[P++]=5;x(2,D.lens,
|
||
|
0,32,E,0,D.work,{bits:5});u=!1}D.lencode=A;D.lenbits=9;D.distcode=E;D.distbits=5;b.mode=20;if(6===d){n>>>=2;s-=2;break a}break;case 2:b.mode=17;break;case 3:a.msg="invalid block type",b.mode=30}n>>>=2;s-=2;break;case 14:n>>>=s&7;for(s-=s&7;32>s;){if(0===m)break a;m--;n+=g[p++]<<s;s+=8}if((n&65535)!==(n>>>16^65535)){a.msg="invalid stored block lengths";b.mode=30;break}b.length=n&65535;s=n=0;b.mode=15;if(6===d)break a;case 15:b.mode=16;case 16:if(D=b.length){D>m&&(D=m);D>q&&(D=q);if(0===D)break a;e.arraySet(f,
|
||
|
g,p,D,z);m-=D;p+=D;q-=D;z+=D;b.length-=D;break}b.mode=12;break;case 17:for(;14>s;){if(0===m)break a;m--;n+=g[p++]<<s;s+=8}b.nlen=(n&31)+257;n>>>=5;s-=5;b.ndist=(n&31)+1;n>>>=5;s-=5;b.ncode=(n&15)+4;n>>>=4;s-=4;if(286<b.nlen||30<b.ndist){a.msg="too many length or distance symbols";b.mode=30;break}b.have=0;b.mode=18;case 18:for(;b.have<b.ncode;){for(;3>s;){if(0===m)break a;m--;n+=g[p++]<<s;s+=8}b.lens[O[b.have++]]=n&7;n>>>=3;s-=3}for(;19>b.have;)b.lens[O[b.have++]]=0;b.lencode=b.lendyn;b.lenbits=7;
|
||
|
D={bits:b.lenbits};U=x(0,b.lens,0,19,b.lencode,0,b.work,D);b.lenbits=D.bits;if(U){a.msg="invalid code lengths set";b.mode=30;break}b.have=0;b.mode=19;case 19:for(;b.have<b.nlen+b.ndist;){for(;;){D=b.lencode[n&(1<<b.lenbits)-1];C=D>>>24;V=D>>>16&255;$=D&65535;if(C<=s)break;if(0===m)break a;m--;n+=g[p++]<<s;s+=8}if(16>$)n>>>=C,s-=C,b.lens[b.have++]=$;else{if(16===$){for(D=C+2;s<D;){if(0===m)break a;m--;n+=g[p++]<<s;s+=8}n>>>=C;s-=C;if(0===b.have){a.msg="invalid bit length repeat";b.mode=30;break}P=
|
||
|
b.lens[b.have-1];D=3+(n&3);n>>>=2;s-=2}else if(17===$){for(D=C+3;s<D;){if(0===m)break a;m--;n+=g[p++]<<s;s+=8}n>>>=C;s-=C;P=0;D=3+(n&7);n>>>=3;s-=3}else{for(D=C+7;s<D;){if(0===m)break a;m--;n+=g[p++]<<s;s+=8}n>>>=C;s-=C;P=0;D=11+(n&127);n>>>=7;s-=7}if(b.have+D>b.nlen+b.ndist){a.msg="invalid bit length repeat";b.mode=30;break}for(;D--;)b.lens[b.have++]=P}}if(30===b.mode)break;if(0===b.lens[256]){a.msg="invalid code -- missing end-of-block";b.mode=30;break}b.lenbits=9;D={bits:b.lenbits};U=x(1,b.lens,
|
||
|
0,b.nlen,b.lencode,0,b.work,D);b.lenbits=D.bits;if(U){a.msg="invalid literal/lengths set";b.mode=30;break}b.distbits=6;b.distcode=b.distdyn;D={bits:b.distbits};U=x(2,b.lens,b.nlen,b.ndist,b.distcode,0,b.work,D);b.distbits=D.bits;if(U){a.msg="invalid distances set";b.mode=30;break}b.mode=20;if(6===d)break a;case 20:b.mode=21;case 21:if(6<=m&&258<=q){a.next_out=z;a.avail_out=q;a.next_in=p;a.avail_in=m;b.hold=n;b.bits=s;k(a,T);z=a.next_out;f=a.output;q=a.avail_out;p=a.next_in;g=a.input;m=a.avail_in;
|
||
|
n=b.hold;s=b.bits;12===b.mode&&(b.back=-1);break}for(b.back=0;;){D=b.lencode[n&(1<<b.lenbits)-1];C=D>>>24;V=D>>>16&255;$=D&65535;if(C<=s)break;if(0===m)break a;m--;n+=g[p++]<<s;s+=8}if(V&&0===(V&240)){P=C;Z=V;for(ca=$;;){D=b.lencode[ca+((n&(1<<P+Z)-1)>>P)];C=D>>>24;V=D>>>16&255;$=D&65535;if(P+C<=s)break;if(0===m)break a;m--;n+=g[p++]<<s;s+=8}n>>>=P;s-=P;b.back+=P}n>>>=C;s-=C;b.back+=C;b.length=$;if(0===V){b.mode=26;break}if(V&32){b.back=-1;b.mode=12;break}if(V&64){a.msg="invalid literal/length code";
|
||
|
b.mode=30;break}b.extra=V&15;b.mode=22;case 22:if(b.extra){for(D=b.extra;s<D;){if(0===m)break a;m--;n+=g[p++]<<s;s+=8}b.length+=n&(1<<b.extra)-1;n>>>=b.extra;s-=b.extra;b.back+=b.extra}b.was=b.length;b.mode=23;case 23:for(;;){D=b.distcode[n&(1<<b.distbits)-1];C=D>>>24;V=D>>>16&255;$=D&65535;if(C<=s)break;if(0===m)break a;m--;n+=g[p++]<<s;s+=8}if(0===(V&240)){P=C;Z=V;for(ca=$;;){D=b.distcode[ca+((n&(1<<P+Z)-1)>>P)];C=D>>>24;V=D>>>16&255;$=D&65535;if(P+C<=s)break;if(0===m)break a;m--;n+=g[p++]<<s;s+=
|
||
|
8}n>>>=P;s-=P;b.back+=P}n>>>=C;s-=C;b.back+=C;if(V&64){a.msg="invalid distance code";b.mode=30;break}b.offset=$;b.extra=V&15;b.mode=24;case 24:if(b.extra){for(D=b.extra;s<D;){if(0===m)break a;m--;n+=g[p++]<<s;s+=8}b.offset+=n&(1<<b.extra)-1;n>>>=b.extra;s-=b.extra;b.back+=b.extra}if(b.offset>b.dmax){a.msg="invalid distance too far back";b.mode=30;break}b.mode=25;case 25:if(0===q)break a;D=T-q;if(b.offset>D){D=b.offset-D;if(D>b.whave&&b.sane){a.msg="invalid distance too far back";b.mode=30;break}D>
|
||
|
b.wnext?(D-=b.wnext,P=b.wsize-D):P=b.wnext-D;D>b.length&&(D=b.length);Z=b.window}else Z=f,P=z-b.offset,D=b.length;D>q&&(D=q);q-=D;b.length-=D;do f[z++]=Z[P++];while(--D);0===b.length&&(b.mode=21);break;case 26:if(0===q)break a;f[z++]=b.length;q--;b.mode=21;break;case 27:if(b.wrap){for(;32>s;){if(0===m)break a;m--;n|=g[p++]<<s;s+=8}T-=q;a.total_out+=T;b.total+=T;T&&(a.adler=b.check=b.flags?r(b.check,f,T,z-T):c(b.check,f,T,z-T));T=q;if((b.flags?n:h(n))!==b.check){a.msg="incorrect data check";b.mode=
|
||
|
30;break}s=n=0}b.mode=28;case 28:if(b.wrap&&b.flags){for(;32>s;){if(0===m)break a;m--;n+=g[p++]<<s;s+=8}if(n!==(b.total&4294967295)){a.msg="incorrect length check";b.mode=30;break}s=n=0}b.mode=29;case 29:U=1;break a;case 30:U=-3;break a;case 31:return-4;default:return y}a.next_out=z;a.avail_out=q;a.next_in=p;a.avail_in=m;b.hold=n;b.bits=s;if(b.wsize||T!==a.avail_out&&30>b.mode&&(27>b.mode||4!==d))g=a.output,p=a.next_out,z=T-a.avail_out,q=a.state,null===q.window&&(q.wsize=1<<q.wbits,q.wnext=0,q.whave=
|
||
|
0,q.window=new e.Buf8(q.wsize)),z>=q.wsize?(e.arraySet(q.window,g,p-q.wsize,q.wsize,0),q.wnext=0,q.whave=q.wsize):(m=q.wsize-q.wnext,m>z&&(m=z),e.arraySet(q.window,g,p-z,m,q.wnext),(z-=m)?(e.arraySet(q.window,g,p-z,z,0),q.wnext=z,q.whave=q.wsize):(q.wnext+=m,q.wnext===q.wsize&&(q.wnext=0),q.whave<q.wsize&&(q.whave+=m)));w-=a.avail_in;T-=a.avail_out;a.total_in+=w;a.total_out+=T;b.total+=T;b.wrap&&T&&(a.adler=b.check=b.flags?r(b.check,f,T,a.next_out-T):c(b.check,f,T,a.next_out-T));a.data_type=b.bits+
|
||
|
(b.last?64:0)+(12===b.mode?128:0)+(20===b.mode||15===b.mode?256:0);(0===w&&0===T||4===d)&&U===t&&(U=-5);return U};b.inflateEnd=function(a){if(!a||!a.state)return y;var c=a.state;c.window&&(c.window=null);a.state=null;return t};b.inflateGetHeader=function(a,c){var b;if(!a||!a.state)return y;b=a.state;if(0===(b.wrap&2))return y;b.head=c;c.done=!1;return t};b.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":2,"./adler32":4,"./crc32":6,"./inffast":8,"./inftrees":10}],10:[function(a,
|
||
|
d,b){var h=a("../utils/common"),f=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],q=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],n=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],m=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];d.exports=function(a,b,c,d,k,x,t,y){for(var v=y.bits,s=0,w=
|
||
|
0,u=0,A=0,E=0,B=0,F=0,J=0,H=0,Q=0,N,z,Y=null,R=0,I,G=new h.Buf16(16),B=new h.Buf16(16),ba=null,T=0,D,P,Z,s=0;15>=s;s++)G[s]=0;for(w=0;w<d;w++)G[b[c+w]]++;E=v;for(A=15;1<=A&&0===G[A];A--);E>A&&(E=A);if(0===A)return k[x++]=20971520,k[x++]=20971520,y.bits=1,0;for(u=1;u<A&&0===G[u];u++);E<u&&(E=u);for(s=J=1;15>=s;s++)if(J<<=1,J-=G[s],0>J)return-1;if(0<J&&(0===a||1!==A))return-1;B[1]=0;for(s=1;15>s;s++)B[s+1]=B[s]+G[s];for(w=0;w<d;w++)0!==b[c+w]&&(t[B[b[c+w]]++]=w);switch(a){case 0:Y=ba=t;I=19;break;case 1:Y=
|
||
|
f;R-=257;ba=q;T-=257;I=256;break;default:Y=n,ba=m,I=-1}w=Q=0;s=u;v=x;B=E;F=0;z=-1;H=1<<E;d=H-1;if(1===a&&852<H||2===a&&592<H)return 1;for(var C=0;;){C++;D=s-F;t[w]<I?(P=0,Z=t[w]):t[w]>I?(P=ba[T+t[w]],Z=Y[R+t[w]]):(P=96,Z=0);J=1<<s-F;u=N=1<<B;do N-=J,k[v+(Q>>F)+N]=D<<24|P<<16|Z|0;while(0!==N);for(J=1<<s-1;Q&J;)J>>=1;0!==J?(Q&=J-1,Q+=J):Q=0;w++;if(0===--G[s]){if(s===A)break;s=b[c+t[w]]}if(s>E&&(Q&d)!==z){0===F&&(F=E);v+=u;B=s-F;for(J=1<<B;B+F<A;){J-=G[B+F];if(0>=J)break;B++;J<<=1}H+=1<<B;if(1===a&&
|
||
|
852<H||2===a&&592<H)return 1;z=Q&d;k[z]=E<<24|B<<16|v-x|0}}0!==Q&&(k[v+Q]=s-F<<24|4194304);y.bits=E;return 0}},{"../utils/common":2}],11:[function(a,d,b){d.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],12:[function(a,d,b){d.exports=function(){this.input=null;this.total_in=this.avail_in=this.next_in=0;this.output=null;this.total_out=this.avail_out=this.next_out=
|
||
|
0;this.msg="";this.state=null;this.data_type=2;this.adler=0}},{}]},{},[1])(1)});return{inflate:function(l,a){return f.inflateRaw(l)}}}()})();core.StepDirection={PREVIOUS:1,NEXT:2};core.StepIterator=function(f,l){function a(){e=null;r=c=void 0}function d(){void 0===r&&(r=f.acceptPosition(l)===m);return r}function b(c,b){a();return l.setUnfilteredPosition(c,b)}function h(){e||(e=l.container());return e}function p(){void 0===c&&(c=l.unfilteredDomOffset());return c}function q(){for(a();l.nextPosition();)if(a(),d())return!0;return!1}function n(){for(a();l.previousPosition();)if(a(),d())return!0;return!1}var m=core.PositionFilter.FilterResult.FILTER_ACCEPT,g=core.StepDirection.NEXT,
|
||
|
e,c,r;this.isStep=d;this.setPosition=b;this.container=h;this.offset=p;this.nextStep=q;this.previousStep=n;this.advanceStep=function(a){return a===g?q():n()};this.roundToClosestStep=function(){var a,c,e=d();e||(a=h(),c=p(),e=n(),e||(b(a,c),e=q()));return e};this.roundToPreviousStep=function(){var a=d();a||(a=n());return a};this.roundToNextStep=function(){var a=d();a||(a=q());return a};this.leftNode=function(){return l.leftNode()};this.snapshot=function(){return new core.StepIterator.StepSnapshot(h(),
|
||
|
p())};this.restore=function(a){b(a.container,a.offset)}};core.StepIterator.StepSnapshot=function(f,l){this.container=f;this.offset=l};core.Utils=function(){function f(l,a){if(a&&Array.isArray(a)){l=l||[];if(!Array.isArray(l))throw"Destination is not an array.";l=l.concat(a.map(function(a){return f(null,a)}))}else if(a&&"object"===typeof a){l=l||{};if("object"!==typeof l)throw"Destination is not an object.";Object.keys(a).forEach(function(d){l[d]=f(l[d],a[d])})}else l=a;return l}this.hashString=function(f){var a=0,d,b;d=0;for(b=f.length;d<b;d+=1)a=(a<<5)-a+f.charCodeAt(d),a|=0;return a};this.mergeObjects=function(l,a){Object.keys(a).forEach(function(d){l[d]=
|
||
|
f(l[d],a[d])});return l}};core.Zip=function(f,l){function a(a,c,b){x?b(null,x.subarray(a,a+c)):b("File data not loaded",null)}function d(a){var c=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,
|
||
|
1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,
|
||
|
1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,
|
||
|
1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,
|
||
|
628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,
|
||
|
3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918E3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117],b,e,d=a.length,g=0,g=0;b=-1;for(e=0;e<d;e+=1)g=(b^a[e])&255,g=c[g],b=b>>>8^g;return b^-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 h(a){var c=a.getFullYear();return 1980>c?0:c-1980<<25|a.getMonth()+1<<21|a.getDate()<<16|a.getHours()<<11|a.getMinutes()<<5|a.getSeconds()>>1}function p(c,e){var d,g,k,r,f,h,m,n=this;this.load=function(b){if(null!==n.data)b(null,n.data);else{var e=f+34+g+k+256;e+m>t&&(e=t-m);a(m,e,function(a,e){if(a||null===e)b(a,e);else a:{var d=e,g=new core.ByteArray(d),k=g.readUInt32LE(),m;if(67324752!==k)b("File entry signature is wrong."+k.toString()+" "+d.length.toString(),null);
|
||
|
else{g.pos+=22;k=g.readUInt16LE();m=g.readUInt16LE();g.pos+=k+m;if(r){d=d.subarray(g.pos,g.pos+f);if(f!==d.length){b("The amount of compressed bytes read was "+d.length.toString()+" instead of "+f.toString()+" for "+n.filename+" in "+c+".",null);break a}d=v(d,h)}else d=d.subarray(g.pos,g.pos+h);h!==d.length?b("The amount of bytes read was "+d.length.toString()+" instead of "+h.toString()+" for "+n.filename+" in "+c+".",null):(n.data=d,b(null,d))}}})}};this.set=function(a,c,b,e){n.filename=a;n.data=
|
||
|
c;n.compressed=b;n.date=e};this.error=null;e&&(d=e.readUInt32LE(),33639248!==d?this.error="Central directory entry has wrong signature at position "+(e.pos-4).toString()+' for file "'+c+'": '+e.data.length.toString():(e.pos+=6,r=e.readUInt16LE(),this.date=b(e.readUInt32LE()),e.readUInt32LE(),f=e.readUInt32LE(),h=e.readUInt32LE(),g=e.readUInt16LE(),k=e.readUInt16LE(),d=e.readUInt16LE(),e.pos+=8,m=e.readUInt32LE(),this.filename=runtime.byteArrayToString(e.data.subarray(e.pos,e.pos+g),"utf8"),this.data=
|
||
|
null,e.pos+=g+k+d))}function q(c,b){if(22!==c.length)b("Central directory length should be 22.",s);else{var e=new core.ByteArray(c),d;d=e.readUInt32LE();101010256!==d?b("Central directory signature is wrong: "+d.toString(),s):(d=e.readUInt16LE(),0!==d?b("Zip files with non-zero disk numbers are not supported.",s):(d=e.readUInt16LE(),0!==d?b("Zip files with non-zero disk numbers are not supported.",s):(d=e.readUInt16LE(),y=e.readUInt16LE(),d!==y?b("Number of entries is inconsistent.",s):(d=e.readUInt32LE(),
|
||
|
e=e.readUInt16LE(),e=t-22-d,a(e,t-e,function(a,c){if(a||null===c)b(a,s);else a:{var e=new core.ByteArray(c),d,g;k=[];for(d=0;d<y;d+=1){g=new p(f,e);if(g.error){b(g.error,s);break a}k[k.length]=g}b(null,s)}})))))}}function n(a,c){var b=null,e,d;for(d=0;d<k.length;d+=1)if(e=k[d],e.filename===a){b=e;break}b?b.data?c(null,b.data):b.load(c):c(a+" not found.",null)}function m(a){var c=new core.ByteArrayWriter("utf8"),b=0;c.appendArray([80,75,3,4,20,0,0,0,0,0]);a.data&&(b=a.data.length);c.appendUInt32LE(h(a.date));
|
||
|
c.appendUInt32LE(a.data?d(a.data):0);c.appendUInt32LE(b);c.appendUInt32LE(b);c.appendUInt16LE(a.filename.length);c.appendUInt16LE(0);c.appendString(a.filename);a.data&&c.appendByteArray(a.data);return c}function g(a,c){var b=new core.ByteArrayWriter("utf8"),e=0;b.appendArray([80,75,1,2,20,0,20,0,0,0,0,0]);a.data&&(e=a.data.length);b.appendUInt32LE(h(a.date));b.appendUInt32LE(a.data?d(a.data):0);b.appendUInt32LE(e);b.appendUInt32LE(e);b.appendUInt16LE(a.filename.length);b.appendArray([0,0,0,0,0,0,
|
||
|
0,0,0,0,0,0]);b.appendUInt32LE(c);b.appendString(a.filename);return b}function e(a,c){if(a===k.length)c(null);else{var b=k[a];null!==b.data?e(a+1,c):b.load(function(b){b?c(b):e(a+1,c)})}}function c(a,c){e(0,function(b){if(b)c(b);else{var e,d,r=new core.ByteArrayWriter("utf8"),f=[0];for(e=0;e<k.length;e+=1)r.appendByteArrayWriter(m(k[e])),f.push(r.getLength());b=r.getLength();for(e=0;e<k.length;e+=1)d=k[e],r.appendByteArrayWriter(g(d,f[e]));e=r.getLength()-b;r.appendArray([80,75,5,6,0,0,0,0]);r.appendUInt16LE(k.length);
|
||
|
r.appendUInt16LE(k.length);r.appendUInt32LE(e);r.appendUInt32LE(b);r.appendArray([0,0]);a(r.getByteArray())}})}function r(a,b){c(function(c){runtime.writeFile(a,c,function(a){a||(x=c,t=x.length);b(a)})},b)}var k,x,t,y,v=core.RawInflate.inflate,s=this,w=new core.Base64;this.load=n;this.save=function(a,c,b,e){var d,g;for(d=0;d<k.length;d+=1)if(g=k[d],g.filename===a){g.set(a,c,b,e);return}g=new p(f);g.set(a,c,b,e);k.push(g)};this.remove=function(a){var c,b;for(c=0;c<k.length;c+=1)if(b=k[c],b.filename===
|
||
|
a)return k.splice(c,1),!0;return!1};this.write=function(a){r(f,a)};this.writeAs=r;this.createByteArray=c;this.loadContentXmlAsFragments=function(a,c){s.loadAsString(a,function(a,b){if(a)return c.rootElementReady(a);c.rootElementReady(null,b,!0)})};this.loadAsString=function(a,c){n(a,function(a,b){if(a||null===b)return c(a,null);var e=runtime.byteArrayToString(b,"utf8");c(null,e)})};this.loadAsDOM=function(a,c){s.loadAsString(a,function(a,b){if(a||null===b)c(a,null);else{var e=(new DOMParser).parseFromString(b,
|
||
|
"text/xml");c(null,e)}})};this.loadAsDataURL=function(a,c,b){n(a,function(a,e){if(a||!e)return b(a,null);var d=0,g;c||(c=80===e[1]&&78===e[2]&&71===e[3]?"image/png":255===e[0]&&216===e[1]&&255===e[2]?"image/jpeg":71===e[0]&&73===e[1]&&70===e[2]?"image/gif":"");for(g="data:"+c+";base64,";d<e.length;)g+=w.convertUTF8ArrayToBase64(e.subarray(d,Math.min(d+45E3,e.length))),d+=45E3;b(null,g)})};this.getEntries=function(){return k.slice()};t=-1;null===l?k=[]:runtime.readFile(f,"binary",function(c,b){"string"===
|
||
|
typeof b&&(c="file was read as a string. Should be Uint8Array.");c||!b||0===b.length?l("File '"+f+"' cannot be read. Err: "+(c||"[none]"),s):(x=b,t=x.length,a(t-22,22,function(a,c){a||null===c?l(a,s):q(c,l)}))})};core.SimpleClientRect=null;gui.CommonConstraints={EDIT:{ANNOTATIONS:{ONLY_DELETE_OWN:"onlyDeleteOwn"},REVIEW_MODE:"reviewMode"}};gui.SessionConstraints=function(){function f(d){l.hasOwnProperty(d)||(l[d]=!1,a.register(d))}var l={},a=new core.EventNotifier;this.registerConstraint=f;this.subscribe=function(d,b){f(d);a.subscribe(d,b)};this.unsubscribe=function(d,b){a.unsubscribe(d,b)};this.setState=function(d,b){runtime.assert(!0===l.hasOwnProperty(d),"No such constraint");l[d]!==b&&(l[d]=b,a.emit(d,b))};this.getState=function(a){runtime.assert(!0===l.hasOwnProperty(a),"No such constraint");return l[a]}};gui.BlacklistNamespaceNodeFilter=function(f){var l={},a=NodeFilter.FILTER_REJECT,d=NodeFilter.FILTER_ACCEPT;this.acceptNode=function(b){return!b||l.hasOwnProperty(b.namespaceURI)?a:d};(function(){f.forEach(function(a){l[a]=!0})})()};odf.Namespaces={namespaceMap:{config:"urn:oasis:names:tc:opendocument:xmlns:config:1.0",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",math:"http://www.w3.org/1998/Math/MathML",
|
||
|
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",xforms:"http://www.w3.org/2002/xforms",
|
||
|
xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace"},prefixMap:{},configns:"urn:oasis:names:tc:opendocument:xmlns:config:1.0",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",
|
||
|
mathns:"http://www.w3.org/1998/Math/MathML",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",
|
||
|
xformsns:"http://www.w3.org/2002/xforms",xlinkns:"http://www.w3.org/1999/xlink",xmlns:"http://www.w3.org/XML/1998/namespace"};(function(){var f=odf.Namespaces.namespaceMap,l=odf.Namespaces.prefixMap,a;for(a in f)f.hasOwnProperty(a)&&(l[f[a]]=a)})();odf.Namespaces.forEachPrefix=function(f){var l=odf.Namespaces.namespaceMap,a;for(a in l)l.hasOwnProperty(a)&&f(a,l[a])};
|
||
|
odf.Namespaces.lookupNamespaceURI=function(f){var l=null;odf.Namespaces.namespaceMap.hasOwnProperty(f)&&(l=odf.Namespaces.namespaceMap[f]);return l};odf.Namespaces.lookupPrefix=function(f){var l=odf.Namespaces.prefixMap;return l.hasOwnProperty(f)?l[f]:null};odf.Namespaces.lookupNamespaceURI.lookupNamespaceURI=odf.Namespaces.lookupNamespaceURI;(function(){odf.OdfSchemaImpl=function(){var f=[["config:config-item","uncategorized"],["form:item","object"],["form:option","uncategorized"],["math:math","field"],["meta:user-defined","uncategorized"],["number:currency-symbol","uncategorized"],["number:embedded-text","uncategorized"],["number:text","uncategorized"],["presentation:date-time-decl","uncategorized"],["presentation:footer-decl","uncategorized"],["presentation:header-decl","uncategorized"],["svg:desc","text"],["svg:title","text"],["table:desc",
|
||
|
"uncategorized"],["table:title","uncategorized"],["text:a","text"],["text:author-initials","field"],["text:author-name","field"],["text:bibliography-mark","field"],["text:bookmark-ref","field"],["text:chapter","field"],["text:character-count","field"],["text:conditional-text","field"],["text:creation-date","field"],["text:creation-time","field"],["text:creator","field"],["text:database-display","field"],["text:database-name","field"],["text:database-row-number","field"],["text:date","field"],["text:dde-connection",
|
||
|
"field"],["text:description","field"],["text:editing-cycles","field"],["text:editing-duration","field"],["text:execute-macro","uncategorized"],["text:expression","uncategorized"],["text:file-name","field"],["text:h","text"],["text:hidden-paragraph","text"],["text:hidden-text","text"],["text:image-count","field"],["text:index-entry-span","uncategorized"],["text:index-title-template","uncategorized"],["text:initial-creator","field"],["text:keywords","field"],["text:linenumbering-separator","style"],
|
||
|
["text:measure","uncategorized"],["text:meta","uncategorized"],["text:meta-field","uncategorized"],["text:modification-date","field"],["text:modification-time","field"],["text:note-citation","field"],["text:note-continuation-notice-backward","style"],["text:note-continuation-notice-forward","style"],["text:note-ref","field"],["text:object-count","field"],["text:p","text"],["text:page-continuation","uncategorized"],["text:page-count","field"],["text:page-number","field"],["text:page-variable-get",
|
||
|
"field"],["text:page-variable-set","field"],["text:paragraph-count","field"],["text:placeholder","field"],["text:print-date","field"],["text:print-time","field"],["text:printed-by","field"],["text:reference-ref","field"],["text:ruby-base","text"],["text:ruby-text","text"],["text:script","text"],["text:sender-city","field"],["text:sender-company","field"],["text:sender-country","field"],["text:sender-email","field"],["text:sender-fax","field"],["text:sender-firstname","field"],["text:sender-initials",
|
||
|
"field"],["text:sender-lastname","field"],["text:sender-phone-private","field"],["text:sender-phone-work","field"],["text:sender-position","field"],["text:sender-postal-code","field"],["text:sender-state-or-province","field"],["text:sender-street","field"],["text:sender-title","field"],["text:sequence","uncategorized"],["text:sequence-ref","uncategorized"],["text:sheet-name","uncategorized"],["text:span","text"],["text:subject","field"],["text:table-count","field"],["text:table-formula","deprecated"],
|
||
|
["text:template-name","uncategorized"],["text:text-input","field"],["text:time","field"],["text:title","field"],["text:user-defined","field"],["text:user-field-get","field"],["text:user-field-input","field"],["text:variable-get","field"],["text:variable-input","field"],["text:variable-set","field"],["text:word-count","field"],["xforms:model","uncategorized"]],l={};this.isTextContainer=function(a,d){return"text"===l[a+":"+d]};this.isField=function(a,d){return"field"===l[a+":"+d]};this.getFields=function(){return f.filter(function(a){return"field"===
|
||
|
a[1]}).map(function(a){return a[0]})};(function(){f.forEach(function(a){var d=a[1],b=a[0].split(":");a=b[0];var b=b[1],f=odf.Namespaces.lookupNamespaceURI(a);f?l[f+":"+b]=d:runtime.log("DEBUG: OdfSchema - unknown prefix '"+a+"'")})})()};odf.OdfSchema=new odf.OdfSchemaImpl})();odf.OdfUtilsImpl=function(){function f(a){return"image"===(a&&a.localName)&&a.namespaceURI===R}function l(a){return null!==a&&a.nodeType===Node.ELEMENT_NODE&&"frame"===a.localName&&a.namespaceURI===R&&"as-char"===a.getAttributeNS(Y,"anchor-type")}function a(a){var c;(c="annotation"===(a&&a.localName)&&a.namespaceURI===odf.Namespaces.officens)||(c="div"===(a&&a.localName)&&"annotationWrapper"===a.className);return c}function d(a){return"a"===(a&&a.localName)&&a.namespaceURI===Y}function b(a){var c=
|
||
|
a&&a.localName;return("p"===c||"h"===c)&&a.namespaceURI===Y}function h(a,c){for(a&&void 0!==c&&!b(a)&&a.childNodes.item(c)&&(a=a.childNodes.item(c));a&&!b(a);)a=a.parentNode;return a}function p(a,c){for(;a&&a!==c;){if(a.namespaceURI===odf.Namespaces.officens&&"annotation"===a.localName)return a;a=a.parentNode}return null}function q(a){return/^[ \t\r\n]+$/.test(a)}function n(a){if(null===a||a.nodeType!==Node.ELEMENT_NODE)return!1;var c=a.localName;return T.isTextContainer(a.namespaceURI,c)||"span"===
|
||
|
c&&"webodf-annotationHighlight"===a.className}function m(a){return null===a||a.nodeType!==Node.ELEMENT_NODE?!1:T.isField(a.namespaceURI,a.localName)}function g(a){var c=a&&a.localName,b=!1;c&&(a=a.namespaceURI,a===Y&&(b="s"===c||"tab"===c||"line-break"===c));return b}function e(c){return g(c)||m(c)||l(c)||a(c)}function c(a){var c=a&&a.localName,b=!1;c&&(a=a.namespaceURI,a===Y&&(b="s"===c));return b}function r(a){return-1!==ba.indexOf(a.namespaceURI)}function k(a){if(g(a)||m(a))return!1;if(n(a.parentNode)&&
|
||
|
a.nodeType===Node.TEXT_NODE)return 0===a.textContent.length;for(a=a.firstChild;a;){if(r(a)||!k(a))return!1;a=a.nextSibling}return!0}function x(a){for(;null!==a.firstChild&&n(a);)a=a.firstChild;return a}function t(a){for(;null!==a.lastChild&&n(a);)a=a.lastChild;return a}function y(a){for(;!b(a)&&null===a.previousSibling;)a=a.parentNode;return b(a)?null:t(a.previousSibling)}function v(a){for(;!b(a)&&null===a.nextSibling;)a=a.parentNode;return b(a)?null:x(a.nextSibling)}function s(a){for(var b=!1;a;)if(a.nodeType===
|
||
|
Node.TEXT_NODE)if(0===a.length)a=y(a);else return!q(a.data.substr(a.length-1,1));else e(a)?(b=!1===c(a),a=null):a=y(a);return b}function w(a){var c=!1,b;for(a=a&&x(a);a;){b=a.nodeType===Node.TEXT_NODE?a.length:0;if(0<b&&!q(a.data)){c=!0;break}if(e(a)){c=!0;break}a=v(a)}return c}function u(a,c){return q(a.data.substr(c))?!w(v(a)):!1}function A(a,c){var b=a.data,d;if(!q(b[c])||e(a.parentNode))return!1;0<c?q(b[c-1])||(d=!0):s(y(a))&&(d=!0);return!0===d?u(a,c)?!1:!0:!1}function E(a){return(a=/(-?[0-9]*[0-9][0-9]*(\.[0-9]*)?|0+\.[0-9]*[1-9][0-9]*|\.[0-9]*[1-9][0-9]*)((cm)|(mm)|(in)|(pt)|(pc)|(px)|(%))/.exec(a))?
|
||
|
{value:parseFloat(a[1]),unit:a[3]}:null}function B(a){return(a=E(a))&&(0>a.value||"%"===a.unit)?null:a}function F(a){return(a=E(a))&&"%"!==a.unit?null:a}function J(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,c){for(;0<c.length&&!G.rangeContainsNode(a,c[0]);)c.shift();for(;0<c.length&&!G.rangeContainsNode(a,c[c.length-1]);)c.pop()}function Q(c,b,d){var k;k=G.getNodesInRange(c,function(c){var b=NodeFilter.FILTER_REJECT;if(g(c.parentNode)||m(c.parentNode)||a(c))b=NodeFilter.FILTER_REJECT;else if(c.nodeType===Node.TEXT_NODE){if(d||Boolean(h(c)&&(!q(c.textContent)||A(c,0))))b=NodeFilter.FILTER_ACCEPT}else if(e(c))b=NodeFilter.FILTER_ACCEPT;else if(J(c)||n(c))b=NodeFilter.FILTER_SKIP;return b},
|
||
|
NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT);b||H(c,k);return k}function N(c,b,e){for(;c;){if(e(c)){b[0]!==c&&b.unshift(c);break}if(a(c))break;c=c.parentNode}}function z(a,c){var b=a;if(c<b.childNodes.length-1)b=b.childNodes[c+1];else{for(;!b.nextSibling;)b=b.parentNode;b=b.nextSibling}for(;b.firstChild;)b=b.firstChild;return b}var Y=odf.Namespaces.textns,R=odf.Namespaces.drawns,I=odf.Namespaces.xlinkns,G=core.DomUtils,ba=[odf.Namespaces.dbns,odf.Namespaces.dcns,odf.Namespaces.dr3dns,odf.Namespaces.drawns,
|
||
|
odf.Namespaces.chartns,odf.Namespaces.formns,odf.Namespaces.numberns,odf.Namespaces.officens,odf.Namespaces.presentationns,odf.Namespaces.stylens,odf.Namespaces.svgns,odf.Namespaces.tablens,odf.Namespaces.textns],T=odf.OdfSchema;this.isImage=f;this.isCharacterFrame=l;this.isInlineRoot=a;this.isTextSpan=function(a){return"span"===(a&&a.localName)&&a.namespaceURI===Y};this.isHyperlink=d;this.getHyperlinkTarget=function(a){return a.getAttributeNS(I,"href")||""};this.isParagraph=b;this.getParagraphElement=
|
||
|
h;this.getParentAnnotation=p;this.isWithinAnnotation=function(a,c){return Boolean(p(a,c))};this.getAnnotationCreator=function(a){return a.getElementsByTagNameNS(odf.Namespaces.dcns,"creator")[0].textContent};this.isListItem=function(a){return"list-item"===(a&&a.localName)&&a.namespaceURI===Y};this.isLineBreak=function(a){return"line-break"===(a&&a.localName)&&a.namespaceURI===Y};this.isODFWhitespace=q;this.isGroupingElement=n;this.isFieldElement=m;this.isCharacterElement=g;this.isAnchoredAsCharacterElement=
|
||
|
e;this.isSpaceElement=c;this.isODFNode=r;this.hasNoODFContent=k;this.firstChild=x;this.lastChild=t;this.previousNode=y;this.nextNode=v;this.scanLeftForNonSpace=s;this.lookLeftForCharacter=function(a){var c,b=c=0;a.nodeType===Node.TEXT_NODE&&(b=a.length);0<b?(c=a.data,c=q(c.substr(b-1,1))?1===b?s(y(a))?2:0:q(c.substr(b-2,1))?0:2:1):e(a)&&(c=1);return c};this.lookRightForCharacter=function(a){var c=!1,b=0;a&&a.nodeType===Node.TEXT_NODE&&(b=a.length);0<b?c=!q(a.data.substr(0,1)):e(a)&&(c=!0);return c};
|
||
|
this.scanLeftForAnyCharacter=function(a){var c=!1,b;for(a=a&&t(a);a;){b=a.nodeType===Node.TEXT_NODE?a.length:0;if(0<b&&!q(a.data)){c=!0;break}if(e(a)){c=!0;break}a=y(a)}return c};this.scanRightForAnyCharacter=w;this.isTrailingWhitespace=u;this.isSignificantWhitespace=A;this.isDowngradableSpaceElement=function(a){return c(a)?s(y(a))&&w(v(a)):!1};this.parseLength=E;this.parseNonNegativeLength=B;this.parseFoFontSize=function(a){var c;c=(c=E(a))&&(0>=c.value||"%"===c.unit)?null:c;return c||F(a)};this.parseFoLineHeight=
|
||
|
function(a){return B(a)||F(a)};this.isTextContentContainingNode=J;this.getTextNodes=function(a,c){var b;b=G.getNodesInRange(a,function(a){var c=NodeFilter.FILTER_REJECT;a.nodeType===Node.TEXT_NODE?Boolean(h(a)&&(!q(a.textContent)||A(a,0)))&&(c=NodeFilter.FILTER_ACCEPT):J(a)&&(c=NodeFilter.FILTER_SKIP);return c},NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT);c||H(a,b);return b};this.getTextElements=Q;this.getParagraphElements=function(a){var c;c=G.getNodesInRange(a,function(a){var c=NodeFilter.FILTER_REJECT;
|
||
|
if(b(a))c=NodeFilter.FILTER_ACCEPT;else if(J(a)||n(a))c=NodeFilter.FILTER_SKIP;return c},NodeFilter.SHOW_ELEMENT);N(a.startContainer,c,b);return c};this.getImageElements=function(a){var c;c=G.getNodesInRange(a,function(a){var c=NodeFilter.FILTER_SKIP;f(a)&&(c=NodeFilter.FILTER_ACCEPT);return c},NodeFilter.SHOW_ELEMENT);N(a.startContainer,c,f);return c};this.getHyperlinkElements=function(a){var c=[],e=a.cloneRange();a.collapsed&&a.endContainer.nodeType===Node.ELEMENT_NODE&&(a=z(a.endContainer,a.endOffset),
|
||
|
a.nodeType===Node.TEXT_NODE&&e.setEnd(a,1));Q(e,!0,!1).forEach(function(a){for(a=a.parentNode;!b(a);){if(d(a)&&-1===c.indexOf(a)){c.push(a);break}a=a.parentNode}});e.detach();return c};this.getNormalizedFontFamilyName=function(a){/^(["'])(?:.|[\n\r])*?\1$/.test(a)||(a=a.replace(/^[ \t\r\n\f]*((?:.|[\n\r])*?)[ \t\r\n\f]*$/,"$1"),/[ \t\r\n\f]/.test(a)&&(a="'"+a.replace(/[ \t\r\n\f]+/g," ")+"'"));return a}};odf.OdfUtils=new odf.OdfUtilsImpl;gui.OdfTextBodyNodeFilter=function(){var f=odf.OdfUtils,l=Node.TEXT_NODE,a=NodeFilter.FILTER_REJECT,d=NodeFilter.FILTER_ACCEPT,b=odf.Namespaces.textns;this.acceptNode=function(h){if(h.nodeType===l){if(!f.isGroupingElement(h.parentNode))return a}else if(h.namespaceURI===b&&"tracked-changes"===h.localName)return a;return d}};xmldom.LSSerializerFilter=function(){};xmldom.LSSerializerFilter.prototype.acceptNode=function(f){};odf.OdfNodeFilter=function(){this.acceptNode=function(f){return"http://www.w3.org/1999/xhtml"===f.namespaceURI?NodeFilter.FILTER_SKIP:f.namespaceURI&&f.namespaceURI.match(/^urn:webodf:/)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}};xmldom.XPathIterator=function(){};xmldom.XPathIterator.prototype.next=function(){};xmldom.XPathIterator.prototype.reset=function(){};
|
||
|
function createXPathSingleton(){function f(a,b,c){return-1!==a&&(a<b||-1===b)&&(a<c||-1===c)}function l(a){for(var b=[],c=0,d=a.length,k;c<d;){var h=a,n=d,p=b,q="",l=[],w=h.indexOf("[",c),u=h.indexOf("/",c),A=h.indexOf("=",c);f(u,w,A)?(q=h.substring(c,u),c=u+1):f(w,u,A)?(q=h.substring(c,w),c=m(h,w,l)):f(A,u,w)?(q=h.substring(c,A),c=A):(q=h.substring(c,n),c=n);p.push({location:q,predicates:l});if(c<d&&"="===a[c]){k=a.substring(c+1,d);if(2<k.length&&("'"===k[0]||'"'===k[0]))k=k.slice(1,k.length-1);
|
||
|
else try{k=parseInt(k,10)}catch(E){}c=d}}return{steps:b,value:k}}function a(){var a=null,b=!1;this.setNode=function(c){a=c};this.reset=function(){b=!1};this.next=function(){var c=b?null:a;b=!0;return c}}function d(a,b,c){this.reset=function(){a.reset()};this.next=function(){for(var d=a.next();d;){d.nodeType===Node.ELEMENT_NODE&&(d=d.getAttributeNodeNS(b,c));if(d)break;d=a.next()}return d}}function b(a,b){var c=a.next(),d=null;this.reset=function(){a.reset();c=a.next();d=null};this.next=function(){for(;c;){if(d)if(b&&
|
||
|
d.firstChild)d=d.firstChild;else{for(;!d.nextSibling&&d!==c;)d=d.parentNode;d===c?c=a.next():d=d.nextSibling}else{do(d=c.firstChild)||(c=a.next());while(c&&!d)}if(d&&d.nodeType===Node.ELEMENT_NODE)return d}return null}}function h(a,b){this.reset=function(){a.reset()};this.next=function(){for(var c=a.next();c&&!b(c);)c=a.next();return c}}function p(a,b,c){b=b.split(":",2);var d=c(b[0]),k=b[1];return new h(a,function(a){return a.localName===k&&a.namespaceURI===d})}function q(b,e,c){var d=new a,k=n(d,
|
||
|
e,c),f=e.value;return void 0===f?new h(b,function(a){d.setNode(a);k.reset();return null!==k.next()}):new h(b,function(a){d.setNode(a);k.reset();return(a=k.next())?a.nodeValue===f:!1})}var n,m;m=function(a,b,c){for(var d=b,k=a.length,f=0;d<k;)"]"===a[d]?(f-=1,0>=f&&c.push(l(a.substring(b,d)))):"["===a[d]&&(0>=f&&(b=d+1),f+=1),d+=1;return d};n=function(a,e,c){var r,k,f,h;for(r=0;r<e.steps.length;r+=1){f=e.steps[r];k=f.location;if(""===k)a=new b(a,!1);else if("@"===k[0]){k=k.substr(1).split(":",2);h=
|
||
|
c(k[0]);if(!h)throw"No namespace associated with the prefix "+k[0];a=new d(a,h,k[1])}else"."!==k&&(a=new b(a,!1),-1!==k.indexOf(":")&&(a=p(a,k,c)));for(k=0;k<f.predicates.length;k+=1)h=f.predicates[k],a=q(a,h,c)}return a};return{getODFElementsWithXPath:function(b,e,c){var d=b.ownerDocument,k=[],f=null;if(d&&"function"===typeof d.evaluate)for(c=d.evaluate(e,b,c,XPathResult.UNORDERED_NODE_ITERATOR_TYPE,null),f=c.iterateNext();null!==f;)f.nodeType===Node.ELEMENT_NODE&&k.push(f),f=c.iterateNext();else{k=
|
||
|
new a;k.setNode(b);b=l(e);k=n(k,b,c);b=[];for(c=k.next();c;)b.push(c),c=k.next();k=b}return k}}}xmldom.XPath=createXPathSingleton();odf.StyleInfo=function(){function f(a,c){var b,e,d,g,k,r=0;if(b=B[a.localName])if(d=b[a.namespaceURI])r=d.length;for(b=0;b<r;b+=1)e=d[b],g=e.ns,k=e.localname,(e=a.getAttributeNS(g,k))&&a.setAttributeNS(g,A[g]+k,c+e);for(d=a.firstElementChild;d;)f(d,c),d=d.nextElementSibling}function l(a,c){var b,e,d,g,k,f=0;if(b=B[a.localName])if(d=b[a.namespaceURI])f=d.length;for(b=0;b<f;b+=1)if(e=d[b],g=e.ns,k=e.localname,e=a.getAttributeNS(g,k))e=e.replace(c,""),a.setAttributeNS(g,A[g]+k,e);for(d=a.firstElementChild;d;)l(d,
|
||
|
c),d=d.nextElementSibling}function a(a,c){var b,e,d,g,k,f=0;if(b=B[a.localName])if(d=b[a.namespaceURI])f=d.length;for(b=0;b<f;b+=1)if(g=d[b],e=g.ns,k=g.localname,e=a.getAttributeNS(e,k))c=c||{},g=g.keyname,c.hasOwnProperty(g)?c[g][e]=1:(k={},k[e]=1,c[g]=k);return c}function d(c,b){var e,g;a(c,b);for(e=c.firstChild;e;)e.nodeType===Node.ELEMENT_NODE&&(g=e,d(g,b)),e=e.nextSibling}function b(a,c,b){this.key=a;this.name=c;this.family=b;this.requires={}}function h(a,c,e){var d=a+'"'+c,g=e[d];g||(g=e[d]=
|
||
|
new b(d,a,c));return g}function p(a,c,b){var e,d,g,k,f,r=0;e=a.getAttributeNS(s,"name");k=a.getAttributeNS(s,"family");e&&k&&(c=h(e,k,b));if(c){if(e=B[a.localName])if(g=e[a.namespaceURI])r=g.length;for(e=0;e<r;e+=1)if(k=g[e],d=k.ns,f=k.localname,d=a.getAttributeNS(d,f))k=k.keyname,k=h(d,k,b),c.requires[k.key]=k}for(a=a.firstElementChild;a;)p(a,c,b),a=a.nextElementSibling;return b}function q(a,c){var b=c[a.family];b||(b=c[a.family]={});b[a.name]=1;Object.keys(a.requires).forEach(function(b){q(a.requires[b],
|
||
|
c)})}function n(a,c){var b=p(a,null,{});Object.keys(b).forEach(function(a){a=b[a];var e=c[a.family];e&&e.hasOwnProperty(a.name)&&q(a,c)})}function m(a,c){function b(c){(c=g.getAttributeNS(s,c))&&(a[c]=!0)}var e=["font-name","font-name-asian","font-name-complex"],d,g;for(d=c&&c.firstElementChild;d;)g=d,e.forEach(b),m(a,g),d=d.nextElementSibling}function g(a,c){function b(a){var e=k.getAttributeNS(s,a);e&&c.hasOwnProperty(e)&&k.setAttributeNS(s,"style:"+a,c[e])}var e=["font-name","font-name-asian",
|
||
|
"font-name-complex"],d,k;for(d=a&&a.firstElementChild;d;)k=d,e.forEach(b),g(k,c),d=d.nextElementSibling}var e=odf.Namespaces.chartns,c=odf.Namespaces.dbns,r=odf.Namespaces.dr3dns,k=odf.Namespaces.drawns,x=odf.Namespaces.formns,t=odf.Namespaces.numberns,y=odf.Namespaces.officens,v=odf.Namespaces.presentationns,s=odf.Namespaces.stylens,w=odf.Namespaces.tablens,u=odf.Namespaces.textns,A={"urn:oasis:names:tc:opendocument:xmlns:chart:1.0":"chart:","urn:oasis:names:tc:opendocument:xmlns:database:1.0":"db:",
|
||
|
"urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0":"dr3d:","urn:oasis:names:tc:opendocument:xmlns:drawing:1.0":"draw:","urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0":"fo:","urn:oasis:names:tc:opendocument:xmlns:form:1.0":"form:","urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0":"number:","urn:oasis:names:tc:opendocument:xmlns:office:1.0":"office:","urn:oasis:names:tc:opendocument:xmlns:presentation:1.0":"presentation:","urn:oasis:names:tc:opendocument:xmlns:style:1.0":"style:","urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0":"svg:",
|
||
|
"urn:oasis:names:tc:opendocument:xmlns:table:1.0":"table:","urn:oasis:names:tc:opendocument:xmlns:text:1.0":"chart:","http://www.w3.org/XML/1998/namespace":"xml:"},E={text:[{ens:s,en:"tab-stop",ans:s,a:"leader-text-style"},{ens:s,en:"drop-cap",ans:s,a:"style-name"},{ens:u,en:"notes-configuration",ans:u,a:"citation-body-style-name"},{ens:u,en:"notes-configuration",ans:u,a:"citation-style-name"},{ens:u,en:"a",ans:u,a:"style-name"},{ens:u,en:"alphabetical-index",ans:u,a:"style-name"},{ens:u,en:"linenumbering-configuration",
|
||
|
ans:u,a:"style-name"},{ens:u,en:"list-level-style-number",ans:u,a:"style-name"},{ens:u,en:"ruby-text",ans:u,a:"style-name"},{ens:u,en:"span",ans:u,a:"style-name"},{ens:u,en:"a",ans:u,a:"visited-style-name"},{ens:s,en:"text-properties",ans:s,a:"text-line-through-text-style"},{ens:u,en:"alphabetical-index-source",ans:u,a:"main-entry-style-name"},{ens:u,en:"index-entry-bibliography",ans:u,a:"style-name"},{ens:u,en:"index-entry-chapter",ans:u,a:"style-name"},{ens:u,en:"index-entry-link-end",ans:u,a:"style-name"},
|
||
|
{ens:u,en:"index-entry-link-start",ans:u,a:"style-name"},{ens:u,en:"index-entry-page-number",ans:u,a:"style-name"},{ens:u,en:"index-entry-span",ans:u,a:"style-name"},{ens:u,en:"index-entry-tab-stop",ans:u,a:"style-name"},{ens:u,en:"index-entry-text",ans:u,a:"style-name"},{ens:u,en:"index-title-template",ans:u,a:"style-name"},{ens:u,en:"list-level-style-bullet",ans:u,a:"style-name"},{ens:u,en:"outline-level-style",ans:u,a:"style-name"}],paragraph:[{ens:k,en:"caption",ans:k,a:"text-style-name"},{ens:k,
|
||
|
en:"circle",ans:k,a:"text-style-name"},{ens:k,en:"connector",ans:k,a:"text-style-name"},{ens:k,en:"control",ans:k,a:"text-style-name"},{ens:k,en:"custom-shape",ans:k,a:"text-style-name"},{ens:k,en:"ellipse",ans:k,a:"text-style-name"},{ens:k,en:"frame",ans:k,a:"text-style-name"},{ens:k,en:"line",ans:k,a:"text-style-name"},{ens:k,en:"measure",ans:k,a:"text-style-name"},{ens:k,en:"path",ans:k,a:"text-style-name"},{ens:k,en:"polygon",ans:k,a:"text-style-name"},{ens:k,en:"polyline",ans:k,a:"text-style-name"},
|
||
|
{ens:k,en:"rect",ans:k,a:"text-style-name"},{ens:k,en:"regular-polygon",ans:k,a:"text-style-name"},{ens:y,en:"annotation",ans:k,a:"text-style-name"},{ens:x,en:"column",ans:x,a:"text-style-name"},{ens:s,en:"style",ans:s,a:"next-style-name"},{ens:w,en:"body",ans:w,a:"paragraph-style-name"},{ens:w,en:"even-columns",ans:w,a:"paragraph-style-name"},{ens:w,en:"even-rows",ans:w,a:"paragraph-style-name"},{ens:w,en:"first-column",ans:w,a:"paragraph-style-name"},{ens:w,en:"first-row",ans:w,a:"paragraph-style-name"},
|
||
|
{ens:w,en:"last-column",ans:w,a:"paragraph-style-name"},{ens:w,en:"last-row",ans:w,a:"paragraph-style-name"},{ens:w,en:"odd-columns",ans:w,a:"paragraph-style-name"},{ens:w,en:"odd-rows",ans:w,a:"paragraph-style-name"},{ens:u,en:"notes-configuration",ans:u,a:"default-style-name"},{ens:u,en:"alphabetical-index-entry-template",ans:u,a:"style-name"},{ens:u,en:"bibliography-entry-template",ans:u,a:"style-name"},{ens:u,en:"h",ans:u,a:"style-name"},{ens:u,en:"illustration-index-entry-template",ans:u,a:"style-name"},
|
||
|
{ens:u,en:"index-source-style",ans:u,a:"style-name"},{ens:u,en:"object-index-entry-template",ans:u,a:"style-name"},{ens:u,en:"p",ans:u,a:"style-name"},{ens:u,en:"table-index-entry-template",ans:u,a:"style-name"},{ens:u,en:"table-of-content-entry-template",ans:u,a:"style-name"},{ens:u,en:"table-index-entry-template",ans:u,a:"style-name"},{ens:u,en:"user-index-entry-template",ans:u,a:"style-name"},{ens:s,en:"page-layout-properties",ans:s,a:"register-truth-ref-style-name"}],chart:[{ens:e,en:"axis",ans:e,
|
||
|
a:"style-name"},{ens:e,en:"chart",ans:e,a:"style-name"},{ens:e,en:"data-label",ans:e,a:"style-name"},{ens:e,en:"data-point",ans:e,a:"style-name"},{ens:e,en:"equation",ans:e,a:"style-name"},{ens:e,en:"error-indicator",ans:e,a:"style-name"},{ens:e,en:"floor",ans:e,a:"style-name"},{ens:e,en:"footer",ans:e,a:"style-name"},{ens:e,en:"grid",ans:e,a:"style-name"},{ens:e,en:"legend",ans:e,a:"style-name"},{ens:e,en:"mean-value",ans:e,a:"style-name"},{ens:e,en:"plot-area",ans:e,a:"style-name"},{ens:e,en:"regression-curve",
|
||
|
ans:e,a:"style-name"},{ens:e,en:"series",ans:e,a:"style-name"},{ens:e,en:"stock-gain-marker",ans:e,a:"style-name"},{ens:e,en:"stock-loss-marker",ans:e,a:"style-name"},{ens:e,en:"stock-range-line",ans:e,a:"style-name"},{ens:e,en:"subtitle",ans:e,a:"style-name"},{ens:e,en:"title",ans:e,a:"style-name"},{ens:e,en:"wall",ans:e,a:"style-name"}],section:[{ens:u,en:"alphabetical-index",ans:u,a:"style-name"},{ens:u,en:"bibliography",ans:u,a:"style-name"},{ens:u,en:"illustration-index",ans:u,a:"style-name"},
|
||
|
{ens:u,en:"index-title",ans:u,a:"style-name"},{ens:u,en:"object-index",ans:u,a:"style-name"},{ens:u,en:"section",ans:u,a:"style-name"},{ens:u,en:"table-of-content",ans:u,a:"style-name"},{ens:u,en:"table-index",ans:u,a:"style-name"},{ens:u,en:"user-index",ans:u,a:"style-name"}],ruby:[{ens:u,en:"ruby",ans:u,a:"style-name"}],table:[{ens:c,en:"query",ans:c,a:"style-name"},{ens:c,en:"table-representation",ans:c,a:"style-name"},{ens:w,en:"background",ans:w,a:"style-name"},{ens:w,en:"table",ans:w,a:"style-name"}],
|
||
|
"table-column":[{ens:c,en:"column",ans:c,a:"style-name"},{ens:w,en:"table-column",ans:w,a:"style-name"}],"table-row":[{ens:c,en:"query",ans:c,a:"default-row-style-name"},{ens:c,en:"table-representation",ans:c,a:"default-row-style-name"},{ens:w,en:"table-row",ans:w,a:"style-name"}],"table-cell":[{ens:c,en:"column",ans:c,a:"default-cell-style-name"},{ens:w,en:"table-column",ans:w,a:"default-cell-style-name"},{ens:w,en:"table-row",ans:w,a:"default-cell-style-name"},{ens:w,en:"body",ans:w,a:"style-name"},
|
||
|
{ens:w,en:"covered-table-cell",ans:w,a:"style-name"},{ens:w,en:"even-columns",ans:w,a:"style-name"},{ens:w,en:"covered-table-cell",ans:w,a:"style-name"},{ens:w,en:"even-columns",ans:w,a:"style-name"},{ens:w,en:"even-rows",ans:w,a:"style-name"},{ens:w,en:"first-column",ans:w,a:"style-name"},{ens:w,en:"first-row",ans:w,a:"style-name"},{ens:w,en:"last-column",ans:w,a:"style-name"},{ens:w,en:"last-row",ans:w,a:"style-name"},{ens:w,en:"odd-columns",ans:w,a:"style-name"},{ens:w,en:"odd-rows",ans:w,a:"style-name"},
|
||
|
{ens:w,en:"table-cell",ans:w,a:"style-name"}],graphic:[{ens:r,en:"cube",ans:k,a:"style-name"},{ens:r,en:"extrude",ans:k,a:"style-name"},{ens:r,en:"rotate",ans:k,a:"style-name"},{ens:r,en:"scene",ans:k,a:"style-name"},{ens:r,en:"sphere",ans:k,a:"style-name"},{ens:k,en:"caption",ans:k,a:"style-name"},{ens:k,en:"circle",ans:k,a:"style-name"},{ens:k,en:"connector",ans:k,a:"style-name"},{ens:k,en:"control",ans:k,a:"style-name"},{ens:k,en:"custom-shape",ans:k,a:"style-name"},{ens:k,en:"ellipse",ans:k,a:"style-name"},
|
||
|
{ens:k,en:"frame",ans:k,a:"style-name"},{ens:k,en:"g",ans:k,a:"style-name"},{ens:k,en:"line",ans:k,a:"style-name"},{ens:k,en:"measure",ans:k,a:"style-name"},{ens:k,en:"page-thumbnail",ans:k,a:"style-name"},{ens:k,en:"path",ans:k,a:"style-name"},{ens:k,en:"polygon",ans:k,a:"style-name"},{ens:k,en:"polyline",ans:k,a:"style-name"},{ens:k,en:"rect",ans:k,a:"style-name"},{ens:k,en:"regular-polygon",ans:k,a:"style-name"},{ens:y,en:"annotation",ans:k,a:"style-name"}],presentation:[{ens:r,en:"cube",ans:v,
|
||
|
a:"style-name"},{ens:r,en:"extrude",ans:v,a:"style-name"},{ens:r,en:"rotate",ans:v,a:"style-name"},{ens:r,en:"scene",ans:v,a:"style-name"},{ens:r,en:"sphere",ans:v,a:"style-name"},{ens:k,en:"caption",ans:v,a:"style-name"},{ens:k,en:"circle",ans:v,a:"style-name"},{ens:k,en:"connector",ans:v,a:"style-name"},{ens:k,en:"control",ans:v,a:"style-name"},{ens:k,en:"custom-shape",ans:v,a:"style-name"},{ens:k,en:"ellipse",ans:v,a:"style-name"},{ens:k,en:"frame",ans:v,a:"style-name"},{ens:k,en:"g",ans:v,a:"style-name"},
|
||
|
{ens:k,en:"line",ans:v,a:"style-name"},{ens:k,en:"measure",ans:v,a:"style-name"},{ens:k,en:"page-thumbnail",ans:v,a:"style-name"},{ens:k,en:"path",ans:v,a:"style-name"},{ens:k,en:"polygon",ans:v,a:"style-name"},{ens:k,en:"polyline",ans:v,a:"style-name"},{ens:k,en:"rect",ans:v,a:"style-name"},{ens:k,en:"regular-polygon",ans:v,a:"style-name"},{ens:y,en:"annotation",ans:v,a:"style-name"}],"drawing-page":[{ens:k,en:"page",ans:k,a:"style-name"},{ens:v,en:"notes",ans:k,a:"style-name"},{ens:s,en:"handout-master",
|
||
|
ans:k,a:"style-name"},{ens:s,en:"master-page",ans:k,a:"style-name"}],"list-style":[{ens:u,en:"list",ans:u,a:"style-name"},{ens:u,en:"numbered-paragraph",ans:u,a:"style-name"},{ens:u,en:"list-item",ans:u,a:"style-override"},{ens:s,en:"style",ans:s,a:"list-style-name"}],data:[{ens:s,en:"style",ans:s,a:"data-style-name"},{ens:s,en:"style",ans:s,a:"percentage-data-style-name"},{ens:v,en:"date-time-decl",ans:s,a:"data-style-name"},{ens:u,en:"creation-date",ans:s,a:"data-style-name"},{ens:u,en:"creation-time",
|
||
|
ans:s,a:"data-style-name"},{ens:u,en:"database-display",ans:s,a:"data-style-name"},{ens:u,en:"date",ans:s,a:"data-style-name"},{ens:u,en:"editing-duration",ans:s,a:"data-style-name"},{ens:u,en:"expression",ans:s,a:"data-style-name"},{ens:u,en:"meta-field",ans:s,a:"data-style-name"},{ens:u,en:"modification-date",ans:s,a:"data-style-name"},{ens:u,en:"modification-time",ans:s,a:"data-style-name"},{ens:u,en:"print-date",ans:s,a:"data-style-name"},{ens:u,en:"print-time",ans:s,a:"data-style-name"},{ens:u,
|
||
|
en:"table-formula",ans:s,a:"data-style-name"},{ens:u,en:"time",ans:s,a:"data-style-name"},{ens:u,en:"user-defined",ans:s,a:"data-style-name"},{ens:u,en:"user-field-get",ans:s,a:"data-style-name"},{ens:u,en:"user-field-input",ans:s,a:"data-style-name"},{ens:u,en:"variable-get",ans:s,a:"data-style-name"},{ens:u,en:"variable-input",ans:s,a:"data-style-name"},{ens:u,en:"variable-set",ans:s,a:"data-style-name"}],"page-layout":[{ens:v,en:"notes",ans:s,a:"page-layout-name"},{ens:s,en:"handout-master",ans:s,
|
||
|
a:"page-layout-name"},{ens:s,en:"master-page",ans:s,a:"page-layout-name"}]},B,F=xmldom.XPath;this.collectUsedFontFaces=m;this.changeFontFaceNames=g;this.UsedStyleList=function(a,c){var b={};this.uses=function(a){var c=a.localName,e=a.getAttributeNS(k,"name")||a.getAttributeNS(s,"name");a="style"===c?a.getAttributeNS(s,"family"):a.namespaceURI===t?"data":c;return(a=b[a])?0<a[e]:!1};d(a,b);c&&n(c,b)};this.getStyleName=function(a,c){var b,e,d=B[c.localName];if(d&&(d=d[c.namespaceURI]))for(e=0;e<d.length;e+=
|
||
|
1)if(d[e].keyname===a&&(d=d[e],c.hasAttributeNS(d.ns,d.localname))){b=c.getAttributeNS(d.ns,d.localname);break}return b};this.hasDerivedStyles=function(a,c,b){var e=b.getAttributeNS(s,"name");b=b.getAttributeNS(s,"family");return F.getODFElementsWithXPath(a,'//style:*[@style:parent-style-name="'+e+'"][@style:family="'+b+'"]',c).length?!0:!1};this.prefixStyleNames=function(a,c,b){var e;if(a){for(e=a.firstChild;e;){if(e.nodeType===Node.ELEMENT_NODE){var d=e,g=c,r=d.getAttributeNS(k,"name"),h=void 0;
|
||
|
r?h=k:(r=d.getAttributeNS(s,"name"))&&(h=s);h&&d.setAttributeNS(h,A[h]+"name",g+r)}e=e.nextSibling}f(a,c);b&&f(b,c)}};this.removePrefixFromStyleNames=function(a,c,b){var e=RegExp("^"+c);if(a){for(c=a.firstChild;c;){if(c.nodeType===Node.ELEMENT_NODE){var d=c,g=e,f=d.getAttributeNS(k,"name"),r=void 0;f?r=k:(f=d.getAttributeNS(s,"name"))&&(r=s);r&&(f=f.replace(g,""),d.setAttributeNS(r,A[r]+"name",f))}c=c.nextSibling}l(a,e);b&&l(b,e)}};this.determineStylesForNode=a;B=function(){var a,c,b,e,d,g={},k,f,
|
||
|
r,h;for(b in E)if(E.hasOwnProperty(b))for(e=E[b],c=e.length,a=0;a<c;a+=1)d=e[a],r=d.en,h=d.ens,g.hasOwnProperty(r)?k=g[r]:g[r]=k={},k.hasOwnProperty(h)?f=k[h]:k[h]=f=[],f.push({ns:d.ans,localname:d.a,keyname:b});return g}()};"function"!==typeof Object.create&&(Object.create=function(f){var l=function(){};l.prototype=f;return new l});
|
||
|
xmldom.LSSerializer=function(){function f(a){var d=a||{},f=function(a){var b={},c;for(c in a)a.hasOwnProperty(c)&&(b[a[c]]=c);return b}(a),q=[d],n=[f],m=0;this.push=function(){m+=1;d=q[m]=Object.create(d);f=n[m]=Object.create(f)};this.pop=function(){q.pop();n.pop();m-=1;d=q[m];f=n[m]};this.getLocalNamespaceDefinitions=function(){return f};this.getQName=function(a){var b=a.namespaceURI,c=0,r;if(!b)return a.localName;if(r=f[b])return r+":"+a.localName;do{r||!a.prefix?(r="ns"+c,c+=1):r=a.prefix;if(d[r]===
|
||
|
b)break;if(!d[r]){d[r]=b;f[b]=r;break}r=null}while(null===r);return r+":"+a.localName}}function l(a){return a.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/'/g,"'").replace(/"/g,""")}function a(b,f){var p="",q=d.filter?d.filter.acceptNode(f):NodeFilter.FILTER_ACCEPT,n;if(q===NodeFilter.FILTER_ACCEPT&&f.nodeType===Node.ELEMENT_NODE){b.push();n=b.getQName(f);var m,g=f.attributes,e,c,r,k="",x;m="<"+n;e=g.length;for(c=0;c<e;c+=1)r=g.item(c),"http://www.w3.org/2000/xmlns/"!==
|
||
|
r.namespaceURI&&(x=d.filter?d.filter.acceptNode(r):NodeFilter.FILTER_ACCEPT,x===NodeFilter.FILTER_ACCEPT&&(x=b.getQName(r),r="string"===typeof r.value?l(r.value):r.value,k+=" "+(x+'="'+r+'"')));e=b.getLocalNamespaceDefinitions();for(c in e)e.hasOwnProperty(c)&&((g=e[c])?"xmlns"!==g&&(m+=" xmlns:"+e[c]+'="'+c+'"'):m+=' xmlns="'+c+'"');p+=m+(k+">")}if(q===NodeFilter.FILTER_ACCEPT||q===NodeFilter.FILTER_SKIP){for(q=f.firstChild;q;)p+=a(b,q),q=q.nextSibling;f.nodeValue&&(p+=l(f.nodeValue))}n&&(p+="</"+
|
||
|
n+">",b.pop());return p}var d=this;this.filter=null;this.writeToString=function(b,d){if(!b)return"";var p=new f(d);return a(p,b)}};(function(){function f(a){var b,c=q.length;for(b=0;b<c;b+=1)if("urn:oasis:names:tc:opendocument:xmlns:office:1.0"===a.namespaceURI&&a.localName===q[b])return b;return-1}function l(a,e){var c=new b.UsedStyleList(a,e),d=new odf.OdfNodeFilter;this.acceptNode=function(a){var b=d.acceptNode(a);b===NodeFilter.FILTER_ACCEPT&&a.parentNode===e&&a.nodeType===Node.ELEMENT_NODE&&(b=c.uses(a)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT);return b}}function a(a,b){var c=new l(a,b);this.acceptNode=function(a){var b=
|
||
|
c.acceptNode(a);b!==NodeFilter.FILTER_ACCEPT||!a.parentNode||a.parentNode.namespaceURI!==odf.Namespaces.textns||"s"!==a.parentNode.localName&&"tab"!==a.parentNode.localName||(b=NodeFilter.FILTER_REJECT);return b}}function d(a,b){if(b){var c=f(b),d,k=a.firstChild;if(-1!==c){for(;k;){d=f(k);if(-1!==d&&d>c)break;k=k.nextSibling}a.insertBefore(b,k)}}}var b=new odf.StyleInfo,h=core.DomUtils,p=odf.Namespaces.stylens,q="meta settings scripts font-face-decls styles automatic-styles master-styles body".split(" "),
|
||
|
n=Date.now()+"_webodf_",m=new core.Base64;odf.ODFElement=function(){};odf.ODFDocumentElement=function(){};odf.ODFDocumentElement.prototype=new odf.ODFElement;odf.ODFDocumentElement.prototype.constructor=odf.ODFDocumentElement;odf.ODFDocumentElement.prototype.fontFaceDecls=null;odf.ODFDocumentElement.prototype.manifest=null;odf.ODFDocumentElement.prototype.settings=null;odf.ODFDocumentElement.namespaceURI="urn:oasis:names:tc:opendocument:xmlns:office:1.0";odf.ODFDocumentElement.localName="document";
|
||
|
odf.AnnotationElement=function(){};odf.OdfPart=function(a,b,c,d){var k=this;this.size=0;this.type=null;this.name=a;this.container=c;this.url=null;this.mimetype=b;this.onstatereadychange=this.document=null;this.EMPTY=0;this.LOADING=1;this.DONE=2;this.state=this.EMPTY;this.data="";this.load=function(){null!==d&&(this.mimetype=b,d.loadAsDataURL(a,b,function(a,c){a&&runtime.log(a);k.url=c;if(k.onchange)k.onchange(k);if(k.onstatereadychange)k.onstatereadychange(k)}))}};odf.OdfPart.prototype.load=function(){};
|
||
|
odf.OdfPart.prototype.getUrl=function(){return this.data?"data:;base64,"+m.toBase64(this.data):null};odf.OdfContainer=function e(c,f){function k(a){for(var c=a.firstChild,b;c;)b=c.nextSibling,c.nodeType===Node.ELEMENT_NODE?k(c):c.nodeType===Node.PROCESSING_INSTRUCTION_NODE&&a.removeChild(c),c=b}function q(a){var c={},b,e,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?(b=a.getAttributeNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0","name"))&&(c.hasOwnProperty(b)?runtime.log("Warning: annotation name used more than once with <office:annotation/>: '"+b+"'"):c[b]=a):"annotation-end"===a.localName&&((b=a.getAttributeNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0","name"))?c.hasOwnProperty(b)?(e=c[b],e.annotationEndElement?runtime.log("Warning: annotation name used more than once with <office:annotation-end/>: '"+b+"'"):e.annotationEndElement=
|
||
|
a):runtime.log("Warning: annotation end without an annotation start, name: '"+b+"'"):runtime.log("Warning: annotation end without a name found"))),a=d.nextNode()}function t(a,c){for(var b=a&&a.firstChild;b;)b.nodeType===Node.ELEMENT_NODE&&b.setAttributeNS("urn:webodf:names:scope","scope",c),b=b.nextSibling}function y(a,c){for(var b=U.rootElement.meta,b=b&&b.firstChild;b&&(b.namespaceURI!==a||b.localName!==c);)b=b.nextSibling;for(b=b&&b.firstChild;b&&b.nodeType!==Node.TEXT_NODE;)b=b.nextSibling;return b?
|
||
|
b.data:null}function v(a){var c={},b;for(a=a.firstChild;a;)a.nodeType===Node.ELEMENT_NODE&&a.namespaceURI===p&&"font-face"===a.localName&&(b=a.getAttributeNS(p,"name"),c[b]=a),a=a.nextSibling;return c}function s(a,c){var b=null,e,d,k;if(a)for(b=a.cloneNode(!0),e=b.firstElementChild;e;)d=e.nextElementSibling,(k=e.getAttributeNS("urn:webodf:names:scope","scope"))&&k!==c&&b.removeChild(e),e=d;return b}function w(a,c){var e,d,k,f=null,r={};if(a)for(c.forEach(function(a){b.collectUsedFontFaces(r,a)}),
|
||
|
f=a.cloneNode(!0),e=f.firstElementChild;e;)d=e.nextElementSibling,k=e.getAttributeNS(p,"name"),r[k]||f.removeChild(e),e=d;return f}function u(a){var c=U.rootElement.ownerDocument,b;if(a){k(a.documentElement);try{b=c.importNode(a.documentElement,!0)}catch(e){}}return b}function A(a){U.state=a;if(U.onchange)U.onchange(U);if(U.onstatereadychange)U.onstatereadychange(U)}function E(a){aa=null;U.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");q(a)}function B(a){var c=u(a),k=U.rootElement,f;c&&"document-styles"===c.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===c.namespaceURI?(k.fontFaceDecls=h.getDirectChild(c,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","font-face-decls"),d(k,k.fontFaceDecls),f=h.getDirectChild(c,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","styles"),k.styles=f||a.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0",
|
||
|
"styles"),d(k,k.styles),f=h.getDirectChild(c,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","automatic-styles"),k.automaticStyles=f||a.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0","automatic-styles"),t(k.automaticStyles,"document-styles"),d(k,k.automaticStyles),c=h.getDirectChild(c,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","master-styles"),k.masterStyles=c||a.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0","master-styles"),d(k,k.masterStyles),
|
||
|
b.prefixStyleNames(k.automaticStyles,n,k.masterStyles)):A(e.INVALID)}function F(a){a=u(a);var c,k,f,r;if(a&&"document-content"===a.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===a.namespaceURI){c=U.rootElement;f=h.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","font-face-decls");if(c.fontFaceDecls&&f){r=c.fontFaceDecls;var m,n,q,l,z={};k=v(r);l=v(f);for(f=f.firstElementChild;f;){m=f.nextElementSibling;if(f.namespaceURI===p&&"font-face"===f.localName)if(n=f.getAttributeNS(p,
|
||
|
"name"),k.hasOwnProperty(n)){if(!f.isEqualNode(k[n])){q=n;for(var Q=k,s=l,x=0,Y=void 0,Y=q=q.replace(/\d+$/,"");Q.hasOwnProperty(Y)||s.hasOwnProperty(Y);)x+=1,Y=q+x;q=Y;f.setAttributeNS(p,"style:name",q);r.appendChild(f);k[q]=f;delete l[n];z[n]=q}}else r.appendChild(f),k[n]=f,delete l[n];f=m}r=z}else f&&(c.fontFaceDecls=f,d(c,f));k=h.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","automatic-styles");t(k,"document-content");r&&b.changeFontFaceNames(k,r);if(c.automaticStyles&&k)for(r=
|
||
|
k.firstChild;r;)c.automaticStyles.appendChild(r),r=k.firstChild;else k&&(c.automaticStyles=k,d(c,k));a=h.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","body");if(null===a)throw"<office:body/> tag is mising.";c.body=a;d(c,c.body)}else A(e.INVALID)}function J(a){a=u(a);var c;a&&"document-meta"===a.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===a.namespaceURI&&(c=U.rootElement,c.meta=h.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","meta"),
|
||
|
d(c,c.meta))}function H(a){a=u(a);var c;a&&"document-settings"===a.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===a.namespaceURI&&(c=U.rootElement,c.settings=h.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","settings"),d(c,c.settings))}function Q(a){a=u(a);var c;if(a&&"manifest"===a.localName&&"urn:oasis:names:tc:opendocument:xmlns:manifest:1.0"===a.namespaceURI)for(c=U.rootElement,c.manifest=a,a=c.manifest.firstElementChild;a;)"file-entry"===a.localName&&"urn:oasis:names:tc:opendocument:xmlns:manifest:1.0"===
|
||
|
a.namespaceURI&&(O[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 N(a,c,b){a=h.getElementsByTagName(a,c);var e;for(e=0;e<a.length;e+=1)c=a[e],b.hasOwnProperty(c.namespaceURI)||c.parentNode.removeChild(c)}function z(a){N(a,"script",{"urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0":!0,"urn:oasis:names:tc:opendocument:xmlns:office:1.0":!0,"urn:oasis:names:tc:opendocument:xmlns:table:1.0":!0,
|
||
|
"urn:oasis:names:tc:opendocument:xmlns:text:1.0":!0,"urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0":!0});N(a,"style",{"urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0":!0,"urn:oasis:names:tc:opendocument:xmlns:drawing:1.0":!0,"urn:oasis:names:tc:opendocument:xmlns:style:1.0":!0})}function Y(a){var c=a.firstElementChild,b=[],e,d,k,f=a.attributes,r=f.length;for(e=0;e<r;e+=1)k=f.item(e),d=k.localName.substr(0,2).toLowerCase(),null===k.namespaceURI&&"on"===d&&b.push(k);r=b.length;for(e=
|
||
|
0;e<r;e+=1)a.removeAttributeNode(b[e]);for(;c;)Y(c),c=c.nextElementSibling}function R(a){var c=a.shift();c?W.loadAsDOM(c.path,function(b,d){d&&(z(d),Y(d.documentElement));c.handler(d);U.state===e.INVALID?b?runtime.log("ERROR: Unable to load "+c.path+" - "+b):runtime.log("ERROR: Unable to load "+c.path):(b&&runtime.log("DEBUG: Unable to load "+c.path+" - "+b),R(a))}):(q(U.rootElement),A(e.DONE))}function I(a){var c="";odf.Namespaces.forEachPrefix(function(a,b){c+=" xmlns:"+a+'="'+b+'"'});return'<?xml version="1.0" encoding="UTF-8"?><office:'+
|
||
|
a+" "+c+' office:version="1.2">'}function G(){var a=new xmldom.LSSerializer,c=I("document-meta");a.filter=new odf.OdfNodeFilter;c+=a.writeToString(U.rootElement.meta,odf.Namespaces.namespaceMap);return c+"</office:document-meta>"}function ba(a,c){var b=document.createElementNS("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0","manifest:file-entry");b.setAttributeNS("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0","manifest:full-path",a);b.setAttributeNS("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0",
|
||
|
"manifest:media-type",c);return b}function T(){var a=runtime.parseXML('<manifest:manifest xmlns:manifest="urn:oasis:names:tc:opendocument:xmlns:manifest:1.0" manifest:version="1.2"></manifest:manifest>'),c=a.documentElement,b=new xmldom.LSSerializer,e;for(e in O)O.hasOwnProperty(e)&&c.appendChild(ba(e,O[e]));b.filter=new odf.OdfNodeFilter;return'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n'+b.writeToString(a,odf.Namespaces.namespaceMap)}function D(){var a,c,e,d=odf.Namespaces.namespaceMap,
|
||
|
k=new xmldom.LSSerializer,f=I("document-styles");c=s(U.rootElement.automaticStyles,"document-styles");e=U.rootElement.masterStyles.cloneNode(!0);a=w(U.rootElement.fontFaceDecls,[e,U.rootElement.styles,c]);b.removePrefixFromStyleNames(c,n,e);k.filter=new l(e,c);f+=k.writeToString(a,d);f+=k.writeToString(U.rootElement.styles,d);f+=k.writeToString(c,d);f+=k.writeToString(e,d);return f+"</office:document-styles>"}function P(){var c,b,e=odf.Namespaces.namespaceMap,d=new xmldom.LSSerializer,k=I("document-content");
|
||
|
b=s(U.rootElement.automaticStyles,"document-content");c=w(U.rootElement.fontFaceDecls,[b]);d.filter=new a(U.rootElement.body,b);k+=d.writeToString(c,e);k+=d.writeToString(b,e);k+=d.writeToString(U.rootElement.body,e);return k+"</office:document-content>"}function Z(a,c){runtime.loadXML(a,function(a,b){if(a)c(a);else if(b){z(b);Y(b.documentElement);var d=u(b);d&&"document"===d.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===d.namespaceURI?(E(d),A(e.DONE)):A(e.INVALID)}else c("No DOM was loaded.")})}
|
||
|
function C(a,c){var b;b=U.rootElement;var e=b.meta;e||(b.meta=e=document.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0","meta"),d(b,e));b=e;a&&h.mapKeyValObjOntoNode(b,a,odf.Namespaces.lookupNamespaceURI);c&&h.removeKeyElementsFromNode(b,c,odf.Namespaces.lookupNamespaceURI)}function V(a,c){function b(a,c){var e;c||(c=a);e=document.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0",c);r[a]=e;r.appendChild(e)}var d=new core.Zip("",null),k="application/vnd.oasis.opendocument."+
|
||
|
a+(!0===c?"-template":""),f=runtime.byteArrayFromString(k,"utf8"),r=U.rootElement,h=document.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0",a);d.save("mimetype",f,!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");r.body.appendChild(h);O["/"]=k;O["settings.xml"]="text/xml";O["meta.xml"]="text/xml";O["styles.xml"]="text/xml";O["content.xml"]="text/xml";
|
||
|
A(e.DONE);return d}function $(){var a,c=new Date,b="";U.rootElement.settings&&U.rootElement.settings.firstElementChild&&(a=new xmldom.LSSerializer,b=I("document-settings"),a.filter=new odf.OdfNodeFilter,b+=a.writeToString(U.rootElement.settings,odf.Namespaces.namespaceMap),b+="</office:document-settings>");(a=b)?(a=runtime.byteArrayFromString(a,"utf8"),W.save("settings.xml",a,!0,c)):W.remove("settings.xml");b=runtime.getWindow();a="WebODF/"+webodf.Version;b&&(a=a+" "+b.navigator.userAgent);C({"meta:generator":a},
|
||
|
null);a=runtime.byteArrayFromString(G(),"utf8");W.save("meta.xml",a,!0,c);a=runtime.byteArrayFromString(D(),"utf8");W.save("styles.xml",a,!0,c);a=runtime.byteArrayFromString(P(),"utf8");W.save("content.xml",a,!0,c);a=runtime.byteArrayFromString(T(),"utf8");W.save("META-INF/manifest.xml",a,!0,c)}function ca(a,c){$();W.writeAs(a,function(a){c(a)})}var U=this,W,O={},aa,S="";this.onstatereadychange=f;this.state=this.onchange=null;this.getMetadata=y;this.setRootElement=E;this.getContentElement=function(){var a;
|
||
|
aa||(a=U.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 <office:body/>.";return aa};this.getDocumentType=function(){var a=U.getContentElement();return a&&a.localName};this.isTemplate=function(){return"-template"===O["/"].substr(-9)};
|
||
|
this.setIsTemplate=function(a){var c=O["/"],b="-template"===c.substr(-9);a!==b&&(c=a?c+"-template":c.substr(0,c.length-9),O["/"]=c,a=runtime.byteArrayFromString(c,"utf8"),W.save("mimetype",a,!1,new Date))};this.getPart=function(a){return new odf.OdfPart(a,O[a],U,W)};this.getPartData=function(a,c){W.load(a,c)};this.setMetadata=C;this.incrementEditingCycles=function(){var a=y(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,c){$();W.createByteArray(a,c)};this.saveAs=ca;this.save=function(a){ca(S,a)};this.getUrl=function(){return S};this.setBlob=function(a,c,b){b=m.convertBase64ToByteArray(b);W.save(a,b,!1,new Date);O.hasOwnProperty(a)&&runtime.log(a+" has been overwritten.");O[a]=c};this.removeBlob=function(a){var c=W.remove(a);runtime.assert(c,"file is not found: "+a);delete O[a]};this.state=e.LOADING;this.rootElement=function(a){var c=document.createElementNS(a.namespaceURI,a.localName),
|
||
|
b;a=new a.Type;for(b in a)a.hasOwnProperty(b)&&(c[b]=a[b]);return c}({Type:odf.ODFDocumentElement,namespaceURI:odf.ODFDocumentElement.namespaceURI,localName:odf.ODFDocumentElement.localName});c===odf.OdfContainer.DocumentType.TEXT?W=V("text"):c===odf.OdfContainer.DocumentType.TEXT_TEMPLATE?W=V("text",!0):c===odf.OdfContainer.DocumentType.PRESENTATION?W=V("presentation"):c===odf.OdfContainer.DocumentType.PRESENTATION_TEMPLATE?W=V("presentation",!0):c===odf.OdfContainer.DocumentType.SPREADSHEET?W=V("spreadsheet"):
|
||
|
c===odf.OdfContainer.DocumentType.SPREADSHEET_TEMPLATE?W=V("spreadsheet",!0):(S=c,W=new core.Zip(S,function(a,c){W=c;a?Z(S,function(c){a&&(W.error=a+"\n"+c,A(e.INVALID))}):R([{path:"styles.xml",handler:B},{path:"content.xml",handler:F},{path:"meta.xml",handler:J},{path:"settings.xml",handler:H},{path:"META-INF/manifest.xml",handler:Q}])}))};odf.OdfContainer.EMPTY=0;odf.OdfContainer.LOADING=1;odf.OdfContainer.DONE=2;odf.OdfContainer.INVALID=3;odf.OdfContainer.SAVING=4;odf.OdfContainer.MODIFIED=5;odf.OdfContainer.getContainer=
|
||
|
function(a){return new odf.OdfContainer(a,null)}})();odf.OdfContainer.DocumentType={TEXT:1,TEXT_TEMPLATE:2,PRESENTATION:3,PRESENTATION_TEMPLATE:4,SPREADSHEET:5,SPREADSHEET_TEMPLATE:6};gui.AnnotatableCanvas=function(){};gui.AnnotatableCanvas.prototype.refreshSize=function(){};gui.AnnotatableCanvas.prototype.getZoomLevel=function(){};gui.AnnotatableCanvas.prototype.getSizer=function(){};
|
||
|
gui.AnnotationViewManager=function(f,l,a,d){function b(a){var b=a.annotationEndElement,e=m.createRange(),d=a.getAttributeNS(odf.Namespaces.officens,"name");b&&(e.setStart(a,a.childNodes.length),e.setEnd(b,0),a=g.getTextNodes(e,!1),a.forEach(function(a){var b;a:{for(b=a.parentNode;b.namespaceURI!==odf.Namespaces.officens||"body"!==b.localName;){if(b.namespaceURI===c&&"webodf-annotationHighlight"===b.className&&b.getAttribute("annotation")===d){b=!0;break a}b=b.parentNode}b=!1}b||(b=m.createElement("span"),
|
||
|
b.className="webodf-annotationHighlight",b.setAttribute("annotation",d),a.parentNode.replaceChild(b,a),b.appendChild(a))}));e.detach()}function h(c){var b=f.getSizer();c?(a.style.display="inline-block",b.style.paddingRight=e.getComputedStyle(a).width):(a.style.display="none",b.style.paddingRight=0);f.refreshSize()}function p(){n.sort(function(a,c){return 0!==(a.compareDocumentPosition(c)&Node.DOCUMENT_POSITION_FOLLOWING)?-1:1})}function q(){var c;for(c=0;c<n.length;c+=1){var b=n[c],e=b.parentNode,
|
||
|
d=e.nextElementSibling,g=d.nextElementSibling,h=e.parentNode,m=0,m=n[n.indexOf(b)-1],p=void 0,b=f.getZoomLevel();e.style.left=(a.getBoundingClientRect().left-h.getBoundingClientRect().left)/b+"px";e.style.width=a.getBoundingClientRect().width/b+"px";d.style.width=parseFloat(e.style.left)-30+"px";m&&(p=m.parentNode.getBoundingClientRect(),20>=(h.getBoundingClientRect().top-p.bottom)/b?e.style.top=Math.abs(h.getBoundingClientRect().top-p.bottom)/b+20+"px":e.style.top="0px");g.style.left=d.getBoundingClientRect().width/
|
||
|
b+"px";var d=g.style,h=g.getBoundingClientRect().left/b,m=g.getBoundingClientRect().top/b,p=e.getBoundingClientRect().left/b,q=e.getBoundingClientRect().top/b,l=0,E=0,l=p-h,l=l*l,E=q-m,E=E*E,h=Math.sqrt(l+E);d.width=h+"px";m=Math.asin((e.getBoundingClientRect().top-g.getBoundingClientRect().top)/(b*parseFloat(g.style.width)));g.style.transform="rotate("+m+"rad)";g.style.MozTransform="rotate("+m+"rad)";g.style.WebkitTransform="rotate("+m+"rad)";g.style.msTransform="rotate("+m+"rad)"}}var n=[],m=l.ownerDocument,
|
||
|
g=odf.OdfUtils,e=runtime.getWindow(),c="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=q;this.rehighlightAnnotations=function(){n.forEach(function(a){b(a)})};this.getMinimumHeightForAnnotationPane=function(){return"none"!==a.style.display&&0<n.length?(n[n.length-1].parentNode.getBoundingClientRect().bottom-a.getBoundingClientRect().top)/f.getZoomLevel()+"px":null};this.addAnnotation=
|
||
|
function(a){h(!0);n.push(a);p();var c=m.createElement("div"),e=m.createElement("div"),f=m.createElement("div"),l=m.createElement("div"),v;c.className="annotationWrapper";c.setAttribute("creator",g.getAnnotationCreator(a));a.parentNode.insertBefore(c,a);e.className="annotationNote";e.appendChild(a);d&&(v=m.createElement("div"),v.className="annotationRemoveButton",e.appendChild(v));f.className="annotationConnector horizontal";l.className="annotationConnector angular";c.appendChild(e);c.appendChild(f);
|
||
|
c.appendChild(l);a.annotationEndElement&&b(a);q()};this.forgetAnnotations=function(){for(;n.length;){var a=n[0],c=n.indexOf(a),b=a.parentNode.parentNode;"div"===b.localName&&(b.parentNode.insertBefore(a,b),b.parentNode.removeChild(b));for(var a=a.getAttributeNS(odf.Namespaces.officens,"name"),a=m.querySelectorAll('span.webodf-annotationHighlight[annotation="'+a+'"]'),e=b=void 0,b=0;b<a.length;b+=1){for(e=a.item(b);e.firstChild;)e.parentNode.insertBefore(e.firstChild,e);e.parentNode.removeChild(e)}-1!==
|
||
|
c&&n.splice(c,1);0===n.length&&h(!1)}}};gui.Viewport=function(){};gui.Viewport.prototype.scrollIntoView=function(f,l){};gui.SingleScrollViewport=function(f){this.scrollIntoView=function(l,a){var d,b,h,p;p=f.offsetHeight-f.clientHeight;h=f.offsetWidth-f.clientWidth;var q=f.getBoundingClientRect();if(l&&q){d=q.left+5;b=q.top+5;h=q.right-(h+5);p=q.bottom-(p+5);if(a||l.top<b)f.scrollTop-=b-l.top;else if(l.top>p||l.bottom>p)f.scrollTop=l.bottom-l.top<=p-b?f.scrollTop+(l.bottom-p):f.scrollTop+(l.top-b);l.left<d?f.scrollLeft-=d-l.left:l.right>h&&(f.scrollLeft=l.right-l.left<=h-d?f.scrollLeft+(l.right-h):f.scrollLeft-(d-l.left))}}};(function(){function f(a,h,p,q,n){var m,g=0,e;for(e in a)if(a.hasOwnProperty(e)){if(g===p){m=e;break}g+=1}m?h.getPartData(a[m].href,function(c,e){if(c)runtime.log(c);else if(e){var k="@font-face { font-family: "+(a[m].family||m)+"; src: url(data:application/x-font-ttf;charset=binary;base64,"+d.convertUTF8ArrayToBase64(e)+') format("truetype"); }';try{q.insertRule(k,q.cssRules.length)}catch(g){runtime.log("Problem inserting rule in CSS: "+runtime.toJson(g)+"\nRule: "+k)}}else runtime.log("missing font data for "+
|
||
|
a[m].href);f(a,h,p+1,q,n)}):n&&n()}var l=xmldom.XPath,a=odf.OdfUtils,d=new core.Base64;odf.FontLoader=function(){this.loadFonts=function(b,d){for(var p=b.rootElement.fontFaceDecls;d.cssRules.length;)d.deleteRule(d.cssRules.length-1);if(p){var q={},n,m,g,e;if(p)for(p=l.getODFElementsWithXPath(p,"style:font-face[svg:font-face-src]",odf.Namespaces.lookupNamespaceURI),n=0;n<p.length;n+=1)m=p[n],g=m.getAttributeNS(odf.Namespaces.stylens,"name"),e=a.getNormalizedFontFamilyName(m.getAttributeNS(odf.Namespaces.svgns,
|
||
|
"font-family")),m=l.getODFElementsWithXPath(m,"svg:font-face-src/svg:font-face-uri",odf.Namespaces.lookupNamespaceURI),0<m.length&&(m=m[0].getAttributeNS(odf.Namespaces.xlinkns,"href"),q[g]={href:m,family:e});f(q,b,0,d)}}}})();odf.Formatting=function(){function f(a){return(a=A[a])?w.mergeObjects({},a):{}}function l(){for(var a=e.rootElement.fontFaceDecls,c={},b,d,a=a&&a.firstElementChild;a;){if(b=a.getAttributeNS(k,"name"))if((d=a.getAttributeNS(r,"font-family"))||0<a.getElementsByTagNameNS(r,"font-face-uri").length)c[b]=d;a=a.nextElementSibling}return c}function a(a){for(var c=e.rootElement.styles.firstElementChild;c;){if(c.namespaceURI===k&&"default-style"===c.localName&&c.getAttributeNS(k,"family")===a)return c;c=c.nextElementSibling}return null}
|
||
|
function d(a,c,b){var d,g,f;b=b||[e.rootElement.automaticStyles,e.rootElement.styles];for(f=0;f<b.length;f+=1)for(d=b[f],d=d.firstElementChild;d;){g=d.getAttributeNS(k,"name");if(d.namespaceURI===k&&"style"===d.localName&&d.getAttributeNS(k,"family")===c&&g===a||"list-style"===c&&d.namespaceURI===x&&"list-style"===d.localName&&g===a||"data"===c&&d.namespaceURI===t&&g===a)return d;d=d.nextElementSibling}return null}function b(a){for(var c,b,e,d,g={},f=a.firstElementChild;f;){if(f.namespaceURI===k)for(e=
|
||
|
g[f.nodeName]={},b=f.attributes,c=0;c<b.length;c+=1)d=b.item(c),e[d.name]=d.value;f=f.nextElementSibling}b=a.attributes;for(c=0;c<b.length;c+=1)d=b.item(c),g[d.name]=d.value;return g}function h(c,g){for(var h=e.rootElement.styles,r,m={},n=c.getAttributeNS(k,"family"),p=c;p;)r=b(p),m=w.mergeObjects(r,m),p=(r=p.getAttributeNS(k,"parent-style-name"))?d(r,n,[h]):null;if(p=a(n))r=b(p),m=w.mergeObjects(r,m);!1!==g&&(r=f(n),m=w.mergeObjects(r,m));return m}function p(a,b){function e(a){Object.keys(a).forEach(function(c){Object.keys(a[c]).forEach(function(a){f+=
|
||
|
"|"+c+":"+a+"|"})})}for(var d=a.nodeType===Node.TEXT_NODE?a.parentNode:a,g,k=[],f="",r=!1;d;)!r&&v.isGroupingElement(d)&&(r=!0),(g=c.determineStylesForNode(d))&&k.push(g),d=d.parentNode;r&&(k.forEach(e),b&&(b[f]=k));return r?k:void 0}function q(a){var c={orderedStyles:[],styleProperties:{}};a.forEach(function(a){Object.keys(a).forEach(function(b){var g=Object.keys(a[b])[0],f={name:g,family:b,displayName:void 0,isCommonStyle:!1},r;(r=d(g,b))?(b=h(r),c.styleProperties=w.mergeObjects(b,c.styleProperties),
|
||
|
f.displayName=r.getAttributeNS(k,"display-name")||void 0,f.isCommonStyle=r.parentNode===e.rootElement.styles):runtime.log("No style element found for '"+g+"' of family '"+b+"'");c.orderedStyles.push(f)})});return c}function n(a,c){var b={},e=[];c||(c={});a.forEach(function(a){p(a,b)});Object.keys(b).forEach(function(a){c[a]||(c[a]=q(b[a]));e.push(c[a])});return e}function m(a){for(var c=e.rootElement.masterStyles.firstElementChild;c&&(c.namespaceURI!==k||"master-page"!==c.localName||c.getAttributeNS(k,
|
||
|
"name")!==a);)c=c.nextElementSibling;return c}function g(a,c){var b;a&&(b=u.convertMeasure(a,"px"));void 0===b&&c&&(b=u.convertMeasure(c,"px"));return b}var e,c=new odf.StyleInfo,r=odf.Namespaces.svgns,k=odf.Namespaces.stylens,x=odf.Namespaces.textns,t=odf.Namespaces.numberns,y=odf.Namespaces.fons,v=odf.OdfUtils,s=core.DomUtils,w=new core.Utils,u=new core.CSSUnits,A={paragraph:{"style:paragraph-properties":{"fo:text-align":"left"}}};this.getSystemDefaultStyleAttributes=f;this.setOdfContainer=function(a){e=
|
||
|
a};this.getFontMap=l;this.getAvailableParagraphStyles=function(){for(var a=e.rootElement.styles,c,b,d=[],a=a&&a.firstElementChild;a;)"style"===a.localName&&a.namespaceURI===k&&(c=a.getAttributeNS(k,"family"),"paragraph"===c&&(c=a.getAttributeNS(k,"name"),b=a.getAttributeNS(k,"display-name")||c,c&&b&&d.push({name:c,displayName:b}))),a=a.nextElementSibling;return d};this.isStyleUsed=function(a){var b,d=e.rootElement;b=c.hasDerivedStyles(d,odf.Namespaces.lookupNamespaceURI,a);a=(new c.UsedStyleList(d.styles)).uses(a)||
|
||
|
(new c.UsedStyleList(d.automaticStyles)).uses(a)||(new c.UsedStyleList(d.body)).uses(a);return b||a};this.getDefaultStyleElement=a;this.getStyleElement=d;this.getStyleAttributes=b;this.getInheritedStyleAttributes=h;this.getFirstCommonParentStyleNameOrSelf=function(a){var c=e.rootElement.styles,b;if(b=d(a,"paragraph",[e.rootElement.automaticStyles]))if(a=b.getAttributeNS(k,"parent-style-name"),!a)return null;return(b=d(a,"paragraph",[c]))?a:null};this.hasParagraphStyle=function(a){return Boolean(d(a,
|
||
|
"paragraph"))};this.getAppliedStyles=n;this.getAppliedStylesForElement=function(a,c){return n([a],c)[0]};this.updateStyle=function(a,c){var b,d;s.mapObjOntoNode(a,c,odf.Namespaces.lookupNamespaceURI);(b=(b=c["style:text-properties"])&&b["style:font-name"])&&!l().hasOwnProperty(b)&&(d=a.ownerDocument.createElementNS(k,"style:font-face"),d.setAttributeNS(k,"style:name",b),d.setAttributeNS(r,"svg:font-family",b),e.rootElement.fontFaceDecls.appendChild(d))};this.createDerivedStyleObject=function(a,c,
|
||
|
g){var k=d(a,c);runtime.assert(Boolean(k),"No style element found for '"+a+"' of family '"+c+"'");a=k.parentNode===e.rootElement.styles?{"style:parent-style-name":a}:b(k);a["style:family"]=c;w.mergeObjects(a,g);return a};this.getDefaultTabStopDistance=function(){for(var c=a("paragraph"),c=c&&c.firstElementChild,b;c;)c.namespaceURI===k&&"paragraph-properties"===c.localName&&(b=c.getAttributeNS(k,"tab-stop-distance")),c=c.nextElementSibling;b||(b="1.25cm");return v.parseNonNegativeLength(b)};this.getMasterPageElement=
|
||
|
m;this.getContentSize=function(a,c){var b,f,r,h,n,p,q,l,x,t;a:{f=d(a,c);runtime.assert("paragraph"===c||"table"===c,"styleFamily must be either paragraph or table");if(f){if(f=f.getAttributeNS(k,"master-page-name"))(b=m(f))||runtime.log("WARN: No master page definition found for "+f);b||(b=m("Standard"));b||(b=e.rootElement.masterStyles.getElementsByTagNameNS(k,"master-page")[0])||runtime.log("WARN: Document has no master pages defined");if(b)for(f=b.getAttributeNS(k,"page-layout-name"),r=e.rootElement.automaticStyles.getElementsByTagNameNS(k,
|
||
|
"page-layout"),h=0;h<r.length;h+=1)if(b=r.item(h),b.getAttributeNS(k,"name")===f)break a}b=null}b||(b=s.getDirectChild(e.rootElement.styles,k,"default-page-layout"));(b=s.getDirectChild(b,k,"page-layout-properties"))?("landscape"===b.getAttributeNS(k,"print-orientation")?(f="29.7cm",r="21.001cm"):(f="21.001cm",r="29.7cm"),f=g(b.getAttributeNS(y,"page-width"),f),r=g(b.getAttributeNS(y,"page-height"),r),h=g(b.getAttributeNS(y,"margin")),void 0===h?(h=g(b.getAttributeNS(y,"margin-left"),"2cm"),n=g(b.getAttributeNS(y,
|
||
|
"margin-right"),"2cm"),p=g(b.getAttributeNS(y,"margin-top"),"2cm"),q=g(b.getAttributeNS(y,"margin-bottom"),"2cm")):h=n=p=q=h,l=g(b.getAttributeNS(y,"padding")),void 0===l?(l=g(b.getAttributeNS(y,"padding-left"),"0cm"),x=g(b.getAttributeNS(y,"padding-right"),"0cm"),t=g(b.getAttributeNS(y,"padding-top"),"0cm"),b=g(b.getAttributeNS(y,"padding-bottom"),"0cm")):l=x=t=b=l):(f=g("21.001cm"),r=g("29.7cm"),h=n=p=q=h=g("2cm"),l=x=t=b=l=g("0cm"));return{width:f-h-n-l-x,height:r-p-q-t-b}}};(function(){var f=odf.Namespaces.stylens,l=odf.Namespaces.textns,a={graphic:"draw","drawing-page":"draw",paragraph:"text",presentation:"presentation",ruby:"text",section:"text",table:"table","table-cell":"table","table-column":"table","table-row":"table",text:"text",list:"text",page:"office"};odf.StyleTreeNode=function(a){this.derivedStyles={};this.element=a};odf.StyleTree=function(d,b){function h(a){var b,c,d,k={};if(!a)return k;for(a=a.firstElementChild;a;){if(c=a.namespaceURI!==f||"style"!==a.localName&&
|
||
|
"default-style"!==a.localName?a.namespaceURI===l&&"list-style"===a.localName?"list":a.namespaceURI!==f||"page-layout"!==a.localName&&"default-page-layout"!==a.localName?void 0:"page":a.getAttributeNS(f,"family"))(b=a.getAttributeNS(f,"name"))||(b=""),k.hasOwnProperty(c)?d=k[c]:k[c]=d={},d[b]=a;a=a.nextElementSibling}return k}function p(a,b){if(a.hasOwnProperty(b))return a[b];var c=null,d=Object.keys(a),k;for(k=0;k<d.length&&!(c=p(a[d[k]].derivedStyles,b));k+=1);return c}function q(a,b,c){var d,k,
|
||
|
h;if(!b.hasOwnProperty(a))return null;d=new odf.StyleTreeNode(b[a]);k=d.element.getAttributeNS(f,"parent-style-name");h=null;k&&(h=p(c,k)||q(k,b,c));h?h.derivedStyles[a]=d:c[a]=d;delete b[a];return d}function n(a,b){a&&Object.keys(a).forEach(function(c){q(c,a,b)})}var m={};this.getStyleTree=function(){return m};(function(){var f,e,c;e=h(d);c=h(b);Object.keys(a).forEach(function(a){f=m[a]={};n(e[a],f);n(c[a],f)})})()}})();(function(){function f(a,b){try{a.insertRule(b,a.cssRules.length)}catch(d){runtime.log("cannot load rule: "+b+" - "+d)}}function l(a,b){this.listCounterCount=0;this.contentRules=a;this.counterIdStack=[];this.continuedCounterIdStack=b}function a(a){function b(c,d,g,p){var q=d.namespaceURI===h&&"list"===d.localName,l=d.namespaceURI===h&&"list-item"===d.localName;if(q||l){if(q){var q=g+=1,s,w,u;p.listCounterCount+=1;l=c+"-level"+q+"-"+p.listCounterCount;d.setAttributeNS("urn:webodf:names:helper","counter-id",
|
||
|
l);s=p.continuedCounterIdStack.shift();s||(s=l,e+=l+" 1 ",w='text|list[webodfhelper|counter-id="'+l+'"] > text|list-item:first-child > :not(text|list):first-child:before',w+="{",w+="counter-increment: "+s+" 0;",w+="}",f(a,w));for(;p.counterIdStack.length>=q;)p.counterIdStack.pop();p.counterIdStack.push(s);u=p.contentRules[q.toString()]||"";for(w=1;w<=q;w+=1)u=u.replace(w+"webodf-listLevel",p.counterIdStack[w-1]);w='text|list[webodfhelper|counter-id="'+l+'"] > text|list-item > :not(text|list):first-child:before';
|
||
|
w+="{";w+=u;w+="counter-increment: "+s+";";w+="}";f(a,w)}for(d=d.firstElementChild;d;)b(c,d,g,p),d=d.nextElementSibling}else p.continuedCounterIdStack=[]}var d=0,e="",c={};this.createCounterRules=function(a,e,f){var h=e.getAttributeNS(p,"id"),n=[];f&&(f=f.getAttributeNS("urn:webodf:names:helper","counter-id"),n=c[f].slice(0));a=new l(a,n);h?h="Y"+h:(d+=1,h="X"+d);b(h,e,0,a);c[h+"-level1-1"]=a.counterIdStack};this.initialiseCreatedCounters=function(){var c;c="office|document{"+("counter-reset: "+e+
|
||
|
";");c+="}";f(a,c)}}var d=odf.Namespaces.fons,b=odf.Namespaces.stylens,h=odf.Namespaces.textns,p=odf.Namespaces.xmlns,q={1:"decimal",a:"lower-latin",A:"upper-latin",i:"lower-roman",I:"upper-roman"};odf.ListStyleToCss=function(){function n(a){var b=r.parseLength(a);return b?c.convert(b.value,b.unit,"px"):(runtime.log("Could not parse value '"+a+"'."),0)}function m(a){return a.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}function g(a,c){var b;a&&(b=a.getAttributeNS(h,"style-name"));return b===c}function e(c,
|
||
|
d,e){d=d.getElementsByTagNameNS(h,"list");c=new a(c);var f,r,n,l,u,A,E={},B;for(B=0;B<d.length;B+=1)if(f=d.item(B),A=f.getAttributeNS(h,"style-name")){n=f.getAttributeNS(h,"continue-numbering");l=f.getAttributeNS(h,"continue-list");(u=f.getAttributeNS(p,"id"))&&(E[u]=f);u=e[A].element.firstElementChild;for(var F=void 0,J={};u;){var F=(F=u.getAttributeNS(h,"level"))&&parseInt(F,10),H=J,Q=u,N="",z=void 0,Y=void 0,R=z=void 0;if("list-level-style-number"===Q.localName){var I=Q,N=I.getAttributeNS(b,"num-format"),
|
||
|
z=I.getAttributeNS(b,"num-suffix")||"",Y=I.getAttributeNS(b,"num-prefix")||"",G="",ba=I.getAttributeNS(h,"level"),I=I.getAttributeNS(h,"display-levels");Y&&(G+='"'+m(Y)+'"\n');if(q.hasOwnProperty(N))for(ba=ba?parseInt(ba,10):1,I=I?parseInt(I,10):1;0<I;)G+=" counter("+(ba-I+1)+"webodf-listLevel,"+q[N]+")",1<I&&(G+='"."'),I-=1;else G=N?G+(' "'+N+'"'):G+' ""';N="content:"+G+' "'+m(z)+'"'}else"list-level-style-image"===Q.localName?N="content: none":"list-level-style-bullet"===Q.localName&&(N=Q.getAttributeNS(h,
|
||
|
"bullet-char"),N='content: "'+m(N)+'"');if(z=Q.getElementsByTagNameNS(b,"list-level-properties")[0])Y=z.getAttributeNS(h,"list-level-position-and-space-mode"),"label-alignment"===Y&&((z=z.getElementsByTagNameNS(b,"list-level-label-alignment")[0])&&(R=z.getAttributeNS(h,"label-followed-by")),"space"===R&&(N+=' "\\a0"'));H[F]="\n"+N+";\n";u=u.nextElementSibling}u=J;n&&!l&&g(r,A)?c.createCounterRules(u,f,r):l&&g(E[l],A)?c.createCounterRules(u,f,E[l]):c.createCounterRules(u,f);r=f}c.initialiseCreatedCounters()}
|
||
|
var c=new core.CSSUnits,r=odf.OdfUtils;this.applyListStyles=function(a,c,g){var r,m;(r=c.list)&&Object.keys(r).forEach(function(c){m=r[c];for(var e=m.element.firstElementChild;e;){if(e.namespaceURI===h){for(var g=a,p=e,q='text|list[text|style-name="'+c+'"]',l=p.getAttributeNS(h,"level"),x=void 0,t=void 0,H=t=void 0,Q=void 0,N=void 0,z=x=void 0,Y=void 0,R=void 0,I=void 0,Q=void 0,H=(t=p.getElementsByTagNameNS(b,"list-level-properties")[0])&&t.getAttributeNS(h,"list-level-position-and-space-mode"),
|
||
|
Q=t&&t.getElementsByTagNameNS(b,"list-level-label-alignment")[0],x=l=l&&parseInt(l,10);1<x;)q+=" > text|list-item > text|list",x-=1;x=t&&t.getAttributeNS(d,"text-align")||"left";switch(x){case "end":x="right";break;case "start":x="left"}"label-alignment"===H?(N=Q&&Q.getAttributeNS(d,"margin-left")||"0px",R=Q&&Q.getAttributeNS(d,"text-indent")||"0px",I=Q&&Q.getAttributeNS(h,"label-followed-by"),Q=n(N)):(N=t&&t.getAttributeNS(h,"space-before")||"0px",z=t&&t.getAttributeNS(h,"min-label-width")||"0px",
|
||
|
Y=t&&t.getAttributeNS(h,"min-label-distance")||"0px",Q=n(N)+n(z));t=q+" > text|list-item";t+="{";t+="margin-left: "+Q+"px;";t+="}";f(g,t);t=q+" > text|list-item > text|list";t+="{";t+="margin-left: "+-Q+"px;";t+="}";f(g,t);t=q+" > text|list-item > :not(text|list):first-child:before";t+="{";t+="text-align: "+x+";";t+="display: inline-block;";"label-alignment"===H?(t+="margin-left: "+R+";","listtab"===I&&(t+="padding-right: 0.2cm;")):(t+="min-width: "+z+";",t+="margin-left: "+(0===parseFloat(z)?"":
|
||
|
"-")+z+";",t+="padding-right: "+Y+";");t+="}";f(g,t)}e=e.nextElementSibling}});e(a,g,r)}}})();odf.LazyStyleProperties=function(f,l){var a={};this.value=function(d){var b;a.hasOwnProperty(d)?b=a[d]:(b=l[d](),void 0===b&&f&&(b=f.value(d)),a[d]=b);return b};this.reset=function(d){f=d;a={}}};
|
||
|
odf.StyleParseUtils=function(){function f(a){var d,b;a=(a=/(-?[0-9]*[0-9][0-9]*(\.[0-9]*)?|0+\.[0-9]*[1-9][0-9]*|\.[0-9]*[1-9][0-9]*)((cm)|(mm)|(in)|(pt)|(pc)|(px))/.exec(a))?{value:parseFloat(a[1]),unit:a[3]}:null;b=a&&a.unit;"px"===b?d=a.value:"cm"===b?d=96*(a.value/2.54):"mm"===b?d=96*(a.value/25.4):"in"===b?d=96*a.value:"pt"===b?d=a.value/0.75:"pc"===b&&(d=16*a.value);return d}var l=odf.Namespaces.stylens;this.parseLength=f;this.parsePositiveLengthOrPercent=function(a,d,b){var h;a&&(h=parseFloat(a.substr(0,
|
||
|
a.indexOf("%"))),isNaN(h)&&(h=void 0));var p;void 0!==h?(b&&(p=b.value(d)),h=void 0===p?void 0:h*(p/100)):h=f(a);return h};this.getPropertiesElement=function(a,d,b){for(d=b?b.nextElementSibling:d.firstElementChild;null!==d&&(d.localName!==a||d.namespaceURI!==l);)d=d.nextElementSibling;return d};this.parseAttributeList=function(a){a&&(a=a.replace(/^\s*(.*?)\s*$/g,"$1"));return a&&0<a.length?a.split(/\s+/):[]}};odf.Style2CSS=function(){function f(a,c,b){var d=[];b=b.derivedStyles;var e;var g=y[a],k;void 0===g?c=null:(k=c?"["+g+'|style-name="'+c+'"]':"","presentation"===g&&(g="draw",k=c?'[presentation|style-name="'+c+'"]':""),c=g+"|"+v[a].join(k+","+g+"|")+k);null!==c&&d.push(c);for(e in b)b.hasOwnProperty(e)&&(c=f(a,e,b[e]),d=d.concat(c));return d}function l(a){var c="",b="",c=null;if("default-style"===a.localName)return null;c=a.getAttributeNS(g,"parent-style-name");b=a.getAttributeNS(g,"family");return c=
|
||
|
T.getODFElementsWithXPath(G,c?"//style:*[@style:name='"+c+"'][@style:family='"+b+"']":"//style:default-style[@style:family='"+b+"']",odf.Namespaces.lookupNamespaceURI)[0]}function a(a,c){var b="",d,e,f;for(d=0;d<c.length;d+=1)if(e=c[d],f=a.getAttributeNS(e[0],e[1])){f=f.trim();if(N.hasOwnProperty(e[1])){var k=f,h=k.indexOf(" "),r=void 0;f=void 0;-1!==h?(r=k.substring(0,h),f=k.substring(h)):(r=k,f="");(r=R.parseLength(r))&&"pt"===r.unit&&0.75>r.value&&(k="0.75pt"+f);f=k}else if(z.hasOwnProperty(e[1])){var k=
|
||
|
a,h=e[0],r=e[1],m=R.parseLength(f),n=void 0,p=void 0,q=void 0,s=void 0,q=void 0;if(m&&"%"===m.unit){n=m.value/100;p=l(k.parentNode);for(s="0";p;){if(q=x.getDirectChild(p,g,"paragraph-properties"))if(q=R.parseLength(q.getAttributeNS(h,r))){if("%"!==q.unit){s=q.value*n+q.unit;break}n*=q.value/100}p=l(p)}f=s}}e[2]&&(b+=e[2]+":"+f+";")}return b}function d(a,c,b,e){return c+c+b+b+e+e}function b(a,c){var e=[a],d=c.derivedStyles;Object.keys(d).forEach(function(a){a=b(a,d[a]);e=e.concat(a)});return e}function h(a,
|
||
|
c,e,d){function f(c,b){var e=[],d;c.forEach(function(a){g.forEach(function(c){e.push('draw|page[webodfhelper|page-style-name="'+c+'"] draw|frame[presentation|class="'+a+'"]')})});0<e.length&&(d=e.join(",")+"{visibility:"+b+";}",a.insertRule(d,a.cssRules.length))}var g=b(c,d),h=[],r=[];["page-number","date-time","header","footer"].forEach(function(a){var c;c=e.getAttributeNS(k,"display-"+a);"true"===c?h.push(a):"false"===c&&r.push(a)});f(h,"visible");f(r,"hidden")}function p(b,e,z,N){var v,y;if("page"===
|
||
|
e){var G=N.element,T="",O,aa;aa=O="";z=x.getDirectChild(G,g,"page-layout-properties");var S;if(z)if(S=G.getAttributeNS(g,"name"),T+=a(z,H),(O=x.getDirectChild(z,g,"background-image"))&&(aa=O.getAttributeNS(r,"href"))&&(T=T+("background-image: url('odfkit:"+aa+"');")+a(O,w)),"presentation"===I)for(G=(G=x.getDirectChild(G.parentNode.parentNode,m,"master-styles"))&&G.firstElementChild;G;)G.namespaceURI===g&&"master-page"===G.localName&&G.getAttributeNS(g,"page-layout-name")===S&&(aa=G.getAttributeNS(g,
|
||
|
"name"),O='draw|page[draw|master-page-name="'+aa+'"] {'+T+"}",aa='office|body, draw|page[draw|master-page-name="'+aa+'"] {'+a(z,Q)+" }",b.insertRule(O,b.cssRules.length),b.insertRule(aa,b.cssRules.length)),G=G.nextElementSibling;else"text"===I&&(O="office|text {"+T+"}",aa="office|body {width: "+z.getAttributeNS(n,"page-width")+";}",b.insertRule(O,b.cssRules.length),b.insertRule(aa,b.cssRules.length))}else{T=f(e,z,N).join(",");S="";if(G=x.getDirectChild(N.element,g,"text-properties")){var L=G,ea=y=
|
||
|
"";O="";aa=1;G=""+a(L,s);v=L.getAttributeNS(g,"text-underline-style");"solid"===v&&(y+=" underline");v=L.getAttributeNS(g,"text-line-through-style");"solid"===v&&(y+=" line-through");y.length&&(G=G+("text-decoration:"+y+";\n")+("text-decoration-line:"+y+";\n"),G+="-moz-text-decoration-line:"+y+";\n");v=L.getAttributeNS(g,"text-line-through-type");switch(v){case "double":ea+=" double";break;case "single":ea+=" single"}ea&&(G+="text-decoration-style:"+ea+";\n",G+="-moz-text-decoration-style:"+ea+";\n");
|
||
|
if(y=L.getAttributeNS(g,"font-name")||L.getAttributeNS(n,"font-family"))v=Y[y],G+="font-family: "+(v||y)+";";if(v=L.getAttributeNS(g,"text-position"))y=t.parseAttributeList(v),v=y[0],y=y[1],G+="vertical-align: "+v+"\n; ",y&&(aa=parseFloat(y)/100);if(L.hasAttributeNS(n,"font-size")||1!==aa){for(L=L.parentNode;L;){if(v=(v=x.getDirectChild(L,g,"text-properties"))?R.parseFoFontSize(v.getAttributeNS(n,"font-size")):null){if("%"!==v.unit){O="font-size: "+v.value*aa+v.unit+";";break}aa*=v.value/100}L=l(L)}O||
|
||
|
(O="font-size: "+parseFloat(ba)*aa+D.getUnits(ba)+";")}G+=O;S+=G}if(G=x.getDirectChild(N.element,g,"paragraph-properties"))O=G,G=""+a(O,u),(aa=x.getDirectChild(O,g,"background-image"))&&(L=aa.getAttributeNS(r,"href"))&&(G=G+("background-image: url('odfkit:"+L+"');")+a(aa,w)),(O=O.getAttributeNS(n,"line-height"))&&"normal"!==O&&(O=R.parseFoLineHeight(O),G="%"!==O.unit?G+("line-height: "+O.value+O.unit+";"):G+("line-height: "+O.value/100+";")),S+=G;if(G=x.getDirectChild(N.element,g,"graphic-properties"))L=
|
||
|
G,G=""+a(L,A),O=L.getAttributeNS(q,"opacity"),aa=L.getAttributeNS(q,"fill"),L=L.getAttributeNS(q,"fill-color"),"solid"===aa||"hatch"===aa?L&&"none"!==L?(O=isNaN(parseFloat(O))?1:parseFloat(O)/100,aa=L.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i,d),(L=(aa=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(aa))?{r:parseInt(aa[1],16),g:parseInt(aa[2],16),b:parseInt(aa[3],16)}:null)&&(G+="background-color: rgba("+L.r+","+L.g+","+L.b+","+O+");")):G+="background: none;":"none"===aa&&(G+="background: none;"),
|
||
|
S+=G;if(G=x.getDirectChild(N.element,g,"drawing-page-properties"))O=G,aa=""+a(O,A),"true"===O.getAttributeNS(k,"background-visible")&&(aa+="background: none;"),S+=aa,h(b,z,G,N);if(G=x.getDirectChild(N.element,g,"table-cell-properties"))z=S,S=""+a(G,E),S=z+S;if(G=x.getDirectChild(N.element,g,"table-row-properties"))z=S,S=""+a(G,F),S=z+S;if(G=x.getDirectChild(N.element,g,"table-column-properties"))z=S,S=""+a(G,B),S=z+S;if(G=x.getDirectChild(N.element,g,"table-properties"))z=S,S=""+a(G,J),G=G.getAttributeNS(c,
|
||
|
"border-model"),"collapsing"===G?S+="border-collapse:collapse;":"separating"===G&&(S+="border-collapse:separate;"),S=z+S;0!==S.length&&b.insertRule(T+"{"+S+"}",b.cssRules.length)}for(var ga in N.derivedStyles)N.derivedStyles.hasOwnProperty(ga)&&p(b,e,ga,N.derivedStyles[ga])}var q=odf.Namespaces.drawns,n=odf.Namespaces.fons,m=odf.Namespaces.officens,g=odf.Namespaces.stylens,e=odf.Namespaces.svgns,c=odf.Namespaces.tablens,r=odf.Namespaces.xlinkns,k=odf.Namespaces.presentationns,x=core.DomUtils,t=new odf.StyleParseUtils,
|
||
|
y={graphic:"draw","drawing-page":"draw",paragraph:"text",presentation:"presentation",ruby:"text",section:"text",table:"table","table-cell":"table","table-column":"table","table-row":"table",text:"text",list:"text",page:"office"},v={graphic:"circle connected control custom-shape ellipse frame g line measure page page-thumbnail path polygon polyline rect regular-polygon".split(" "),paragraph:"alphabetical-index-entry-template h illustration-index-entry-template index-source-style object-index-entry-template p table-index-entry-template table-of-content-entry-template user-index-entry-template".split(" "),
|
||
|
presentation:"caption circle connector control custom-shape ellipse frame g line measure page-thumbnail path polygon polyline rect regular-polygon".split(" "),"drawing-page":"caption circle connector control page custom-shape ellipse frame g line measure page-thumbnail path polygon polyline rect regular-polygon".split(" "),ruby:["ruby","ruby-text"],section:"alphabetical-index bibliography illustration-index index-title object-index section table-of-content table-index user-index".split(" "),table:["background",
|
||
|
"table"],"table-cell":"body covered-table-cell even-columns even-rows first-column first-row last-column last-row odd-columns odd-rows table-cell".split(" "),"table-column":["table-column"],"table-row":["table-row"],text:"a index-entry-chapter index-entry-link-end index-entry-link-start index-entry-page-number index-entry-span index-entry-tab-stop index-entry-text index-title-template linenumbering-configuration list-level-style-number list-level-style-bullet outline-level-style span".split(" "),
|
||
|
list:["list-item"]},s=[[n,"color","color"],[n,"background-color","background-color"],[n,"font-weight","font-weight"],[n,"font-style","font-style"]],w=[[g,"repeat","background-repeat"]],u=[[n,"background-color","background-color"],[n,"text-align","text-align"],[n,"text-indent","text-indent"],[n,"padding","padding"],[n,"padding-left","padding-left"],[n,"padding-right","padding-right"],[n,"padding-top","padding-top"],[n,"padding-bottom","padding-bottom"],[n,"border-left","border-left"],[n,"border-right",
|
||
|
"border-right"],[n,"border-top","border-top"],[n,"border-bottom","border-bottom"],[n,"margin","margin"],[n,"margin-left","margin-left"],[n,"margin-right","margin-right"],[n,"margin-top","margin-top"],[n,"margin-bottom","margin-bottom"],[n,"border","border"]],A=[[n,"background-color","background-color"],[n,"min-height","min-height"],[q,"stroke","border"],[e,"stroke-color","border-color"],[e,"stroke-width","border-width"],[n,"border","border"],[n,"border-left","border-left"],[n,"border-right","border-right"],
|
||
|
[n,"border-top","border-top"],[n,"border-bottom","border-bottom"]],E=[[n,"background-color","background-color"],[n,"border-left","border-left"],[n,"border-right","border-right"],[n,"border-top","border-top"],[n,"border-bottom","border-bottom"],[n,"border","border"]],B=[[g,"column-width","width"]],F=[[g,"row-height","height"],[n,"keep-together",null]],J=[[g,"width","width"],[n,"margin-left","margin-left"],[n,"margin-right","margin-right"],[n,"margin-top","margin-top"],[n,"margin-bottom","margin-bottom"]],
|
||
|
H=[[n,"background-color","background-color"],[n,"padding","padding"],[n,"padding-left","padding-left"],[n,"padding-right","padding-right"],[n,"padding-top","padding-top"],[n,"padding-bottom","padding-bottom"],[n,"border","border"],[n,"border-left","border-left"],[n,"border-right","border-right"],[n,"border-top","border-top"],[n,"border-bottom","border-bottom"],[n,"margin","margin"],[n,"margin-left","margin-left"],[n,"margin-right","margin-right"],[n,"margin-top","margin-top"],[n,"margin-bottom","margin-bottom"]],
|
||
|
Q=[[n,"page-width","width"],[n,"page-height","height"]],N={border:!0,"border-left":!0,"border-right":!0,"border-top":!0,"border-bottom":!0,"stroke-width":!0},z={margin:!0,"margin-left":!0,"margin-right":!0,"margin-top":!0,"margin-bottom":!0},Y={},R=odf.OdfUtils,I,G,ba,T=xmldom.XPath,D=new core.CSSUnits;this.style2css=function(a,c,b,e,d){function f(a,c){k="@namespace "+a+" url("+c+");";try{b.insertRule(k,b.cssRules.length)}catch(e){}}var k,g,h;for(G=c;b.cssRules.length;)b.deleteRule(b.cssRules.length-
|
||
|
1);odf.Namespaces.forEachPrefix(f);f("webodfhelper","urn:webodf:names:helper");Y=e;I=a;ba=runtime.getWindow().getComputedStyle(document.body,null).getPropertyValue("font-size")||"12pt";for(h in y)if(y.hasOwnProperty(h))for(g in a=d[h],a)a.hasOwnProperty(g)&&p(b,h,g,a[g])}};(function(){function f(l,a){var d=this;this.getDistance=function(a){var f=d.x-a.x;a=d.y-a.y;return Math.sqrt(f*f+a*a)};this.getCenter=function(a){return new f((d.x+a.x)/2,(d.y+a.y)/2)};d.x=l;d.y=a}gui.ZoomHelper=function(){function l(a,b,e,d){a=d?"translate3d("+a+"px, "+b+"px, 0) scale3d("+e+", "+e+", 1)":"translate("+a+"px, "+b+"px) scale("+e+")";c.style.WebkitTransform=a;c.style.MozTransform=a;c.style.msTransform=a;c.style.OTransform=a;c.style.transform=a}function a(a){a?l(-r.x,-r.y,t,!0):(l(0,
|
||
|
0,t,!0),l(0,0,t,!1))}function d(a){if(s&&B){var c=s.style.overflow,b=s.classList.contains("webodf-customScrollbars");a&&b||!a&&!b||(a?(s.classList.add("webodf-customScrollbars"),s.style.overflow="hidden",runtime.requestAnimationFrame(function(){s.style.overflow=c})):s.classList.remove("webodf-customScrollbars"))}}function b(){l(-r.x,-r.y,t,!0);s.scrollLeft=0;s.scrollTop=0;F=w.style.overflow;w.style.overflow="visible";d(!1)}function h(){l(0,0,t,!0);s.scrollLeft=r.x;s.scrollTop=r.y;w.style.overflow=
|
||
|
F||"";d(!0)}function p(a){return new f(a.pageX-c.offsetLeft,a.pageY-c.offsetTop)}function q(a){k&&(r.x-=a.x-k.x,r.y-=a.y-k.y,r=new f(Math.min(Math.max(r.x,c.offsetLeft),(c.offsetLeft+c.offsetWidth)*t-s.clientWidth),Math.min(Math.max(r.y,c.offsetTop),(c.offsetTop+c.offsetHeight)*t-s.clientHeight)));k=a}function n(a){var c=a.touches.length,e=0<c?p(a.touches[0]):null;a=1<c?p(a.touches[1]):null;e&&a?(x=e.getDistance(a),y=t,k=e.getCenter(a),b(),E=A.PINCH):e&&(k=e,E=A.SCROLL)}function m(e){var d=e.touches.length,
|
||
|
f=0<d?p(e.touches[0]):null,d=1<d?p(e.touches[1]):null;if(f&&d)if(e.preventDefault(),E===A.SCROLL)E=A.PINCH,b(),x=f.getDistance(d);else{e=f.getCenter(d);f=f.getDistance(d)/x;q(e);var d=t,k=Math.min(v,c.offsetParent.clientWidth/c.offsetWidth);t=y*f;t=Math.min(Math.max(t,k),v);f=t/d;r.x+=(f-1)*(e.x+r.x);r.y+=(f-1)*(e.y+r.y);a(!0)}else f&&(E===A.PINCH?(E=A.SCROLL,h()):q(f))}function g(){E===A.PINCH&&(u.emit(gui.ZoomHelper.signalZoomChanged,t),h(),a(!1));E=A.NONE}function e(){s&&(s.removeEventListener("touchstart",
|
||
|
n,!1),s.removeEventListener("touchmove",m,!1),s.removeEventListener("touchend",g,!1))}var c,r,k,x,t,y,v=4,s,w,u=new core.EventNotifier([gui.ZoomHelper.signalZoomChanged]),A={NONE:0,SCROLL:1,PINCH:2},E=A.NONE,B=runtime.getWindow().hasOwnProperty("ontouchstart"),F="";this.subscribe=function(a,c){u.subscribe(a,c)};this.unsubscribe=function(a,c){u.unsubscribe(a,c)};this.getZoomLevel=function(){return t};this.setZoomLevel=function(b){c&&(t=b,a(!1),u.emit(gui.ZoomHelper.signalZoomChanged,t))};this.destroy=
|
||
|
function(a){e();d(!1);a()};this.setZoomableElement=function(b){e();c=b;s=c.offsetParent;w=c.parentNode;a(!1);s&&(s.addEventListener("touchstart",n,!1),s.addEventListener("touchmove",m,!1),s.addEventListener("touchend",g,!1));d(!0)};y=t=1;r=new f(0,0)};gui.ZoomHelper.signalZoomChanged="zoomChanged"})();ops.Canvas=function(){};ops.Canvas.prototype.getZoomLevel=function(){};ops.Canvas.prototype.getElement=function(){};ops.Canvas.prototype.getSizer=function(){};ops.Canvas.prototype.getZoomHelper=function(){};(function(){function f(){function a(e){b=!0;runtime.setTimeout(function(){try{e()}catch(d){runtime.log(String(d)+"\n"+d.stack)}b=!1;0<c.length&&a(c.pop())},10)}var c=[],b=!1;this.clearQueue=function(){c.length=0};this.addToQueue=function(e){if(0===c.length&&!b)return a(e);c.push(e)}}function l(a){function c(){for(;0<b.cssRules.length;)b.deleteRule(0);b.insertRule("#shadowContent draw|page {display:none;}",0);b.insertRule("office|presentation draw|page {display:none;}",1);b.insertRule("#shadowContent draw|page:nth-of-type("+
|
||
|
e+") {display:block;}",2);b.insertRule("office|presentation draw|page:nth-of-type("+e+") {display:block;}",3)}var b=a.sheet,e=1;this.showFirstPage=function(){e=1;c()};this.showNextPage=function(){e+=1;c()};this.showPreviousPage=function(){1<e&&(e-=1,c())};this.showPage=function(a){0<a&&(e=a,c())};this.css=a;this.destroy=function(c){a.parentNode.removeChild(a);c()}}function a(a){a=a.sheet;for(var c=a.cssRules;c.length;)a.deleteRule(c.length-1)}function d(a,c,b){var e=new odf.Style2CSS,d=new odf.ListStyleToCss;
|
||
|
b=b.sheet;var f=(new odf.StyleTree(a.rootElement.styles,a.rootElement.automaticStyles)).getStyleTree();e.style2css(a.getDocumentType(),a.rootElement,b,c.getFontMap(),f);d.applyListStyles(b,f,a.rootElement.body)}function b(a,c){(new odf.FontLoader).loadFonts(a,c.sheet)}function h(a,c,b){var e=null;a=a.rootElement.body.getElementsByTagNameNS(F,b+"-decl");b=c.getAttributeNS(F,"use-"+b+"-name");var d;if(b&&0<a.length)for(c=0;c<a.length;c+=1)if(d=a[c],d.getAttributeNS(F,"name")===b){e=d.textContent;break}return e}
|
||
|
function p(a,c,b,e){var d=a.ownerDocument;c=H.getElementsByTagNameNS(a,c,b);for(a=0;a<c.length;a+=1)H.removeAllChildNodes(c[a]),e&&(b=c[a],b.appendChild(d.createTextNode(e)))}function q(a,c,b){c.setAttributeNS("urn:webodf:names:helper","styleid",a);var e,d=c.getAttributeNS(E,"anchor-type"),f=c.getAttributeNS(u,"x"),k=c.getAttributeNS(u,"y"),g=c.getAttributeNS(u,"width"),h=c.getAttributeNS(u,"height"),r=c.getAttributeNS(v,"min-height"),m=c.getAttributeNS(v,"min-width");if("as-char"===d)e="display: inline-block;";
|
||
|
else if(d||f||k)e="position: absolute;";else if(g||h||r||m)e="display: block;";f&&(e+="left: "+f+";");k&&(e+="top: "+k+";");g&&(e+="width: "+g+";");h&&(e+="height: "+h+";");r&&(e+="min-height: "+r+";");m&&(e+="min-width: "+m+";");e&&(e="draw|"+c.localName+'[webodfhelper|styleid="'+a+'"] {'+e+"}",b.insertRule(e,b.cssRules.length))}function n(a){for(a=a.firstChild;a;){if(a.namespaceURI===s&&"binary-data"===a.localName)return"data:image/png;base64,"+a.textContent.replace(/[\r\n\s]/g,"");a=a.nextSibling}return""}
|
||
|
function m(a,c,b,e){function d(c){c&&(c='draw|image[webodfhelper|styleid="'+a+'"] {'+("background-image: url("+c+");")+"}",e.insertRule(c,e.cssRules.length))}function f(a){d(a.url)}b.setAttributeNS("urn:webodf:names:helper","styleid",a);var k=b.getAttributeNS(B,"href"),g;if(k)try{g=c.getPart(k),g.onchange=f,g.load()}catch(h){runtime.log("slight problem: "+String(h))}else k=n(b),d(k)}function g(a){var c=a.ownerDocument;H.getElementsByTagNameNS(a,E,"line-break").forEach(function(a){a.hasChildNodes()||
|
||
|
a.appendChild(c.createElement("br"))})}function e(a){var c=a.ownerDocument;H.getElementsByTagNameNS(a,E,"s").forEach(function(a){var b,e;H.removeAllChildNodes(a);a.appendChild(c.createTextNode(" "));e=parseInt(a.getAttributeNS(E,"c"),10);if(1<e)for(a.removeAttributeNS(E,"c"),b=1;b<e;b+=1)a.parentNode.insertBefore(a.cloneNode(!0),a)})}function c(a){H.getElementsByTagNameNS(a,E,"tab").forEach(function(a){a.textContent="\t"})}function r(a,c){function b(a,e){var k=g.documentElement.namespaceURI;"video/"===
|
||
|
e.substr(0,6)?(d=g.createElementNS(k,"video"),d.setAttribute("controls","controls"),f=g.createElementNS(k,"source"),a&&f.setAttribute("src",a),f.setAttribute("type",e),d.appendChild(f),c.parentNode.appendChild(d)):c.innerHtml="Unrecognised Plugin"}function e(a){b(a.url,a.mimetype)}var d,f,k,g=c.ownerDocument,h;if(k=c.getAttributeNS(B,"href"))try{h=a.getPart(k),h.onchange=e,h.load()}catch(r){runtime.log("slight problem: "+String(r))}else runtime.log("using MP4 data fallback"),k=n(c),b(k,"video/mp4")}
|
||
|
function k(a){var c=a.getElementsByTagName("head")[0],b,e;b=a.styleSheets.length;for(e=c.firstElementChild;e&&("style"!==e.localName||!e.hasAttribute("webodfcss"));)e=e.nextElementSibling;if(e)return b=parseInt(e.getAttribute("webodfcss"),10),e.setAttribute("webodfcss",b+1),e;"string"===String(typeof webodf_css)?b=webodf_css:(e="webodf.css",runtime.currentDirectory&&(e=runtime.currentDirectory(),0<e.length&&"/"!==e.substr(-1)&&(e+="/"),e+="../webodf.css"),b=runtime.readFileSync(e,"utf-8"));e=a.createElementNS(c.namespaceURI,
|
||
|
"style");e.setAttribute("media","screen, print, handheld, projection");e.setAttribute("type","text/css");e.setAttribute("webodfcss","1");e.appendChild(a.createTextNode(b));c.appendChild(e);return e}function x(a){var c=parseInt(a.getAttribute("webodfcss"),10);1===c?a.parentNode.removeChild(a):a.setAttribute("count",c-1)}function t(a){var c=a.getElementsByTagName("head")[0],b=a.createElementNS(c.namespaceURI,"style"),e="";b.setAttribute("type","text/css");b.setAttribute("media","screen, print, handheld, projection");
|
||
|
odf.Namespaces.forEachPrefix(function(a,c){e+="@namespace "+a+" url("+c+");\n"});e+="@namespace webodfhelper url(urn:webodf:names:helper);\n";b.appendChild(a.createTextNode(e));c.appendChild(b);return b}var y=odf.Namespaces.drawns,v=odf.Namespaces.fons,s=odf.Namespaces.officens,w=odf.Namespaces.stylens,u=odf.Namespaces.svgns,A=odf.Namespaces.tablens,E=odf.Namespaces.textns,B=odf.Namespaces.xlinkns,F=odf.Namespaces.presentationns,J=xmldom.XPath,H=core.DomUtils;odf.OdfCanvas=function(n,v){function z(a,
|
||
|
c,b){function e(a,c,b,d){ja.addToQueue(function(){m(a,c,b,d)})}var d,f;d=c.getElementsByTagNameNS(y,"image");for(c=0;c<d.length;c+=1)f=d.item(c),e("image"+String(c),a,f,b)}function Y(a,c){function b(a,c){ja.addToQueue(function(){r(a,c)})}var e,d,f;d=c.getElementsByTagNameNS(y,"plugin");for(e=0;e<d.length;e+=1)f=d.item(e),b(a,f)}function u(){var a;a=$.firstChild;var c=fa.getZoomLevel();a&&($.style.WebkitTransformOrigin="0% 0%",$.style.MozTransformOrigin="0% 0%",$.style.msTransformOrigin="0% 0%",$.style.OTransformOrigin=
|
||
|
"0% 0%",$.style.transformOrigin="0% 0%",O&&((a=O.getMinimumHeightForAnnotationPane())?$.style.minHeight=a:$.style.removeProperty("min-height")),n.style.width=Math.round(c*$.offsetWidth)+"px",n.style.height=Math.round(c*$.offsetHeight)+"px",n.style.display="inline-block")}function B(a,b){var d=ea.sheet;H.removeAllChildNodes(n);$=P.createElementNS(n.namespaceURI,"div");$.style.display="inline-block";$.style.background="white";$.style.setProperty("float","left","important");$.appendChild(b);n.appendChild($);
|
||
|
ca=P.createElementNS(n.namespaceURI,"div");ca.id="annotationsPane";ga=P.createElementNS(n.namespaceURI,"div");ga.id="shadowContent";ga.style.position="absolute";ga.style.top=0;ga.style.left=0;a.getContentElement().appendChild(ga);var f=b.body,k,r=[],m;for(k=f.firstElementChild;k&&k!==f;)if(k.namespaceURI===y&&(r[r.length]=k),k.firstElementChild)k=k.firstElementChild;else{for(;k&&k!==f&&!k.nextElementSibling;)k=k.parentNode;k&&k.nextElementSibling&&(k=k.nextElementSibling)}for(m=0;m<r.length;m+=1)k=
|
||
|
r[m],q("frame"+String(m),k,d);r=J.getODFElementsWithXPath(f,".//*[*[@text:anchor-type='paragraph']]",odf.Namespaces.lookupNamespaceURI);for(k=0;k<r.length;k+=1)f=r[k],f.setAttributeNS&&f.setAttributeNS("urn:webodf:names:helper","containsparagraphanchor",!0);f=C;k=ga;var l,t,x,v,N=0,u;m=a.rootElement.ownerDocument;if((r=b.body.firstElementChild)&&r.namespaceURI===s&&("presentation"===r.localName||"drawing"===r.localName))for(r=r.firstElementChild;r;){if(l=(l=r.getAttributeNS(y,"master-page-name"))?
|
||
|
f.getMasterPageElement(l):null){t=r.getAttributeNS("urn:webodf:names:helper","styleid");x=m.createElementNS(y,"draw:page");u=l.firstElementChild;for(N=0;u;)"true"!==u.getAttributeNS(F,"placeholder")&&(v=u.cloneNode(!0),x.appendChild(v)),u=u.nextElementSibling,N+=1;u=v=N=void 0;for(var R=H.getElementsByTagNameNS(x,y,"frame"),N=0;N<R.length;N+=1)v=R[N],(u=v.getAttributeNS(F,"class"))&&!/^(date-time|footer|header|page-number)$/.test(u)&&v.parentNode.removeChild(v);v=H.getElementsByTagNameNS(x,y,"*");
|
||
|
for(N=0;N<v.length;N+=1)q(t+"_"+N,v[N],d);k.appendChild(x);N=String(k.getElementsByTagNameNS(y,"page").length);p(x,E,"page-number",N);p(x,F,"header",h(a,r,"header"));p(x,F,"footer",h(a,r,"footer"));q(t,x,d);x.setAttributeNS("urn:webodf:names:helper","page-style-name",r.getAttributeNS(y,"style-name"));x.setAttributeNS(y,"draw:master-page-name",l.getAttributeNS(w,"name"))}r=r.nextElementSibling}f=n.namespaceURI;r=H.getElementsByTagNameNS(b.body,A,"table-cell");for(k=0;k<r.length;k+=1)m=r[k],m.hasAttributeNS(A,
|
||
|
"number-columns-spanned")&&m.setAttributeNS(f,"colspan",m.getAttributeNS(A,"number-columns-spanned")),m.hasAttributeNS(A,"number-rows-spanned")&&m.setAttributeNS(f,"rowspan",m.getAttributeNS(A,"number-rows-spanned"));g(b.body);e(b.body);c(b.body);z(a,b.body,d);Y(a,b.body);$.insertBefore(ga,$.firstChild);fa.setZoomableElement($)}function G(a){U?(ca.parentNode||$.appendChild(ca),O&&O.forgetAnnotations(),O=new gui.AnnotationViewManager(D,a.body,ca,W),H.getElementsByTagNameNS(a.body,s,"annotation").forEach(O.addAnnotation),
|
||
|
O.rerenderAnnotations(),u()):ca.parentNode&&($.removeChild(ca),O.forgetAnnotations(),u())}function ba(c){function e(){a(S);a(L);a(ea);H.removeAllChildNodes(n);n.style.display="inline-block";var f=Z.rootElement;n.ownerDocument.importNode(f,!0);C.setOdfContainer(Z);b(Z,S);d(Z,C,L);B(Z,f);G(f);c||ja.addToQueue(function(){var a=[Z];if(da.hasOwnProperty("statereadychange")){var c=da.statereadychange,b;for(b=0;b<c.length;b+=1)c[b].apply(null,a)}})}Z.state===odf.OdfContainer.DONE?e():(runtime.log("WARNING: refreshOdf called but ODF was not DONE."),
|
||
|
ha=runtime.setTimeout(function qa(){Z.state===odf.OdfContainer.DONE?e():(runtime.log("will be back later..."),ha=runtime.setTimeout(qa,500))},100))}function T(a){ja.clearQueue();H.removeAllChildNodes(n);n.appendChild(n.ownerDocument.createTextNode(runtime.tr("Loading")+a+"..."));n.removeAttribute("style");Z=new odf.OdfContainer(a,function(a){Z=a;ba(!1)})}runtime.assert(null!==n&&void 0!==n,"odf.OdfCanvas constructor needs DOM element");runtime.assert(null!==n.ownerDocument&&void 0!==n.ownerDocument,
|
||
|
"odf.OdfCanvas constructor needs DOM");var D=this,P=n.ownerDocument,Z,C=new odf.Formatting,V,$=null,ca=null,U=!1,W=!1,O=null,aa,S,L,ea,ga,da={},ha,ma,la=!1,ia=!1,ja=new f,fa=new gui.ZoomHelper,pa=v||new gui.SingleScrollViewport(n.parentNode);this.refreshCSS=function(){la=!0;ma.trigger()};this.refreshSize=function(){ma.trigger()};this.odfContainer=function(){return Z};this.setOdfContainer=function(a,c){Z=a;ba(!0===c)};this.load=this.load=T;this.save=function(a){Z.save(a)};this.addListener=function(a,
|
||
|
c){switch(a){case "click":var b=n,e=a;b.addEventListener?b.addEventListener(e,c,!1):b.attachEvent?b.attachEvent("on"+e,c):b["on"+e]=c;break;default:b=da.hasOwnProperty(a)?da[a]:da[a]=[],c&&-1===b.indexOf(c)&&b.push(c)}};this.getFormatting=function(){return C};this.getAnnotationViewManager=function(){return O};this.refreshAnnotations=function(){G(Z.rootElement)};this.rerenderAnnotations=function(){O&&(ia=!0,ma.trigger())};this.getSizer=function(){return $};this.enableAnnotations=function(a,c){a!==
|
||
|
U&&(U=a,W=c,Z&&G(Z.rootElement))};this.addAnnotation=function(a){O&&(O.addAnnotation(a),u())};this.forgetAnnotations=function(){O&&(O.forgetAnnotations(),u())};this.getZoomHelper=function(){return fa};this.setZoomLevel=function(a){fa.setZoomLevel(a)};this.getZoomLevel=function(){return fa.getZoomLevel()};this.fitToContainingElement=function(a,c){var b=fa.getZoomLevel(),e=n.offsetHeight/b,b=a/(n.offsetWidth/b);c/e<b&&(b=c/e);fa.setZoomLevel(b)};this.fitToWidth=function(a){var c=n.offsetWidth/fa.getZoomLevel();
|
||
|
fa.setZoomLevel(a/c)};this.fitSmart=function(a,c){var b,e;e=fa.getZoomLevel();b=n.offsetWidth/e;e=n.offsetHeight/e;b=a/b;void 0!==c&&c/e<b&&(b=c/e);fa.setZoomLevel(Math.min(1,b))};this.fitToHeight=function(a){var c=n.offsetHeight/fa.getZoomLevel();fa.setZoomLevel(a/c)};this.showFirstPage=function(){V.showFirstPage()};this.showNextPage=function(){V.showNextPage()};this.showPreviousPage=function(){V.showPreviousPage()};this.showPage=function(a){V.showPage(a);u()};this.getElement=function(){return n};
|
||
|
this.getViewport=function(){return pa};this.addCssForFrameWithImage=function(a){var c=a.getAttributeNS(y,"name"),b=a.firstElementChild;q(c,a,ea.sheet);b&&m(c+"img",Z,b,ea.sheet)};this.destroy=function(a){var c=P.getElementsByTagName("head")[0],b=[V.destroy,ma.destroy];runtime.clearTimeout(ha);ca&&ca.parentNode&&ca.parentNode.removeChild(ca);fa.destroy(function(){$&&(n.removeChild($),$=null)});x(aa);c.removeChild(S);c.removeChild(L);c.removeChild(ea);core.Async.destroyAll(b,a)};aa=k(P);V=new l(t(P));
|
||
|
S=t(P);L=t(P);ea=t(P);ma=core.Task.createRedrawTask(function(){la&&(d(Z,C,L),la=!1);ia&&(O&&O.rerenderAnnotations(),ia=!1);u()});fa.subscribe(gui.ZoomHelper.signalZoomChanged,u)}})();odf.StepUtils=function(){this.getContentBounds=function(f){var l=f.container(),a,d;runtime.assert(f.isStep(),"Step iterator must be on a step");l.nodeType===Node.TEXT_NODE&&0<f.offset()?a=f.offset():(l=f.leftNode())&&l.nodeType===Node.TEXT_NODE&&(a=l.length);l&&(l.nodeType===Node.TEXT_NODE?(runtime.assert(0<a,"Empty text node found"),d={container:l,startOffset:a-1,endOffset:a}):d={container:l,startOffset:0,endOffset:l.childNodes.length});return d}};ops.MemberProperties=function(){};
|
||
|
ops.Member=function(f,l){var a=new ops.MemberProperties;this.getMemberId=function(){return f};this.getProperties=function(){return a};this.setProperties=function(d){Object.keys(d).forEach(function(b){a[b]=d[b]})};this.removeProperties=function(d){Object.keys(d).forEach(function(b){"fullName"!==b&&"color"!==b&&"imageUrl"!==b&&a.hasOwnProperty(b)&&delete a[b]})};runtime.assert(Boolean(f),"No memberId was supplied!");l.fullName||(l.fullName=runtime.tr("Unknown Author"));l.color||(l.color="black");l.imageUrl||
|
||
|
(l.imageUrl="avatar-joe.png");a=l};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,l){};ops.Document.prototype.unsubscribe=function(f,l){};
|
||
|
ops.Document.prototype.getCanvas=function(){};ops.Document.prototype.createRootFilter=function(f){};ops.Document.prototype.createPositionIterator=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,l){var a=this,d={},b,h,p=new core.EventNotifier([ops.OdtCursor.signalCursorUpdated]);this.removeFromDocument=function(){h.remove()};this.subscribe=function(a,b){p.subscribe(a,b)};this.unsubscribe=function(a,b){p.unsubscribe(a,b)};this.getMemberId=function(){return f};this.getNode=function(){return h.getNode()};this.getAnchorNode=function(){return h.getAnchorNode()};this.getSelectedRange=function(){return h.getSelectedRange()};this.setSelectedRange=function(b,d){h.setSelectedRange(b,
|
||
|
d);p.emit(ops.OdtCursor.signalCursorUpdated,a)};this.hasForwardSelection=function(){return h.hasForwardSelection()};this.getDocument=function(){return l};this.getSelectionType=function(){return b};this.setSelectionType=function(a){d.hasOwnProperty(a)?b=a:runtime.log("Invalid selection type: "+a)};this.resetSelectionType=function(){a.setSelectionType(ops.OdtCursor.RangeSelection)};h=new core.Cursor(l.getDOMDocument(),f);d[ops.OdtCursor.RangeSelection]=!0;d[ops.OdtCursor.RegionSelection]=!0;a.resetSelectionType()};
|
||
|
ops.OdtCursor.RangeSelection="Range";ops.OdtCursor.RegionSelection="Region";ops.OdtCursor.signalCursorUpdated="cursorUpdated";(function(){var f=0;ops.StepsCache=function(l,a,d){function b(a,c){var b=this;this.nodeId=a;this.steps=-1;this.node=c;this.previousBookmark=this.nextBookmark=null;this.setIteratorPosition=function(a){a.setPositionBeforeElement(c);d(b.steps,a)}}function h(a,c,b){var e=this;this.nodeId=a;this.steps=c;this.node=b;this.previousBookmark=this.nextBookmark=null;this.setIteratorPosition=function(a){a.setUnfilteredPosition(b,0);d(e.steps,a)}}function p(a,c){var b="["+a.nodeId;c&&(b+=" => "+c.nodeId);return b+
|
||
|
"]"}function q(){for(var a=y,c,b,e,d=new core.LoopWatchDog(0,1E5),f={};a;){d.check();(c=a.previousBookmark)?runtime.assert(c.nextBookmark===a,"Broken bookmark link to previous @"+p(c,a)):(runtime.assert(a===y,"Broken bookmark link @"+p(a)),runtime.assert(void 0===v||y===y||y.steps<=v,"Base point is damaged @"+p(a)));(b=a.nextBookmark)&&runtime.assert(b.previousBookmark===a,"Broken bookmark link to next @"+p(a,b));if(void 0===v||a===y||a.steps<=v)runtime.assert(t.containsNode(l,a.node),"Disconnected node is being reported as undamaged @"+
|
||
|
p(a)),c&&(e=a.node.compareDocumentPosition(c.node),runtime.assert(0===e||0!==(e&w),"Bookmark order with previous does not reflect DOM order @"+p(c,a))),b&&t.containsNode(l,b.node)&&(e=a.node.compareDocumentPosition(b.node),runtime.assert(0===e||0!==(e&s),"Bookmark order with next does not reflect DOM order @"+p(a,b)));a=a.nextBookmark}Object.keys(k).forEach(function(a){var c=k[a];(void 0===v||a<=v)&&runtime.assert(c.steps<=a,"Bookmark step of "+c.steps+" exceeds cached step lookup for "+a+" @"+p(c));
|
||
|
runtime.assert(!1===f.hasOwnProperty(c.nodeId),"Bookmark "+p(c)+" appears twice in cached step lookup at steps "+f[c.nodeId]+" and "+a);f[c.nodeId]=a})}function n(a){var c="";a.nodeType===Node.ELEMENT_NODE&&(c=a.getAttributeNS(r,"nodeId")||"");return c}function m(a){var c=f.toString();a.setAttributeNS(r,"nodeId",c);f+=1;return c}function g(c){var b,e,d=new core.LoopWatchDog(0,1E4);void 0!==v&&c>v&&(c=v);for(b=Math.floor(c/a)*a;!e&&0<=b;)e=k[b],b-=a;for(e=e||y;e.nextBookmark&&e.nextBookmark.steps<=
|
||
|
c;)d.check(),e=e.nextBookmark;runtime.assert(-1===c||e.steps<=c,"Bookmark @"+p(e)+" at step "+e.steps+" exceeds requested step of "+c);return e}function e(a){a.previousBookmark&&(a.previousBookmark.nextBookmark=a.nextBookmark);a.nextBookmark&&(a.nextBookmark.previousBookmark=a.previousBookmark)}function c(a){for(var c,b=null;!b&&a&&a!==l;)(c=n(a))&&(b=x[c])&&b.node!==a&&(runtime.log("Cloned node detected. Creating new bookmark"),b=null,a.removeAttributeNS(r,"nodeId")),a=a.parentNode;return b}var r=
|
||
|
"urn:webodf:names:steps",k={},x={},t=core.DomUtils,y,v,s=Node.DOCUMENT_POSITION_FOLLOWING,w=Node.DOCUMENT_POSITION_PRECEDING,u;this.updateBookmark=function(c,d){var f,h=Math.ceil(c/a)*a,r,p,q;if(void 0!==v&&v<c){r=g(v);for(p=r.nextBookmark;p&&p.steps<=c;)f=p.nextBookmark,q=Math.ceil(p.steps/a)*a,k[q]===p&&delete k[q],t.containsNode(l,p.node)?p.steps=c+1:(e(p),delete x[p.nodeId]),p=f;v=c}else r=g(c);p=n(d)||m(d);f=x[p];f?f.node!==d&&(runtime.log("Cloned node detected. Creating new bookmark"),p=m(d),
|
||
|
f=x[p]=new b(p,d)):f=x[p]=new b(p,d);p=f;p.steps!==c&&(f=Math.ceil(p.steps/a)*a,f!==h&&k[f]===p&&delete k[f],p.steps=c);if(r!==p&&r.nextBookmark!==p){if(r.steps===p.steps)for(;0!==(p.node.compareDocumentPosition(r.node)&s)&&r!==y;)r=r.previousBookmark;r!==p&&r.nextBookmark!==p&&(e(p),f=r.nextBookmark,p.nextBookmark=r.nextBookmark,p.previousBookmark=r,r.nextBookmark=p,f&&(f.previousBookmark=p))}r=k[h];if(!r||p.steps>r.steps)k[h]=p;u()};this.setToClosestStep=function(a,c){var b;u();b=g(a);b.setIteratorPosition(c);
|
||
|
return b.steps};this.setToClosestDomPoint=function(a,b,e){var d,f;u();if(a===l&&0===b)d=y;else if(a===l&&b===l.childNodes.length)for(f in d=y,k)k.hasOwnProperty(f)&&(a=k[f],a.steps>d.steps&&(d=a));else if(d=c(a.childNodes.item(b)||a),!d)for(e.setUnfilteredPosition(a,b);!d&&e.previousNode();)d=c(e.getCurrentNode());d=d||y;void 0!==v&&d.steps>v&&(d=g(v));d.setIteratorPosition(e);return d.steps};this.damageCacheAfterStep=function(a){0>a&&(a=-1);void 0===v?v=a:a<v&&(v=a);u()};(function(){var a=n(l)||
|
||
|
m(l);y=new h(a,0,l);u=ops.StepsCache.ENABLE_CACHE_VERIFICATION?q:function(){}})()};ops.StepsCache.ENABLE_CACHE_VERIFICATION=!1;ops.StepsCache.Bookmark=function(){};ops.StepsCache.Bookmark.prototype.setIteratorPosition=function(f){}})();(function(){ops.OdtStepsTranslator=function(f,l,a,d){function b(a,b,e){var d=b.getCurrentNode();b.isBeforeNode()&&q.isParagraph(d)&&(e||(a+=1),p.updateBookmark(a,d))}function h(c,b){if(!b||a.acceptPosition(c)===m)return!0;for(;c.previousPosition();)if(a.acceptPosition(c)===m){if(b(g,c.container(),c.unfilteredDomOffset()))return!0;break}for(;c.nextPosition();)if(a.acceptPosition(c)===m){if(b(e,c.container(),c.unfilteredDomOffset()))return!0;break}return!1}var p,q=odf.OdfUtils,n=core.DomUtils,m=core.PositionFilter.FilterResult.FILTER_ACCEPT,
|
||
|
g=core.StepDirection.PREVIOUS,e=core.StepDirection.NEXT;this.convertStepsToDomPoint=function(c){var e,d;if(isNaN(c))throw new TypeError("Requested steps is not numeric ("+c+")");if(0>c)throw new RangeError("Requested steps is negative ("+c+")");for(e=p.setToClosestStep(c,l);e<c&&l.nextPosition();)(d=a.acceptPosition(l)===m)&&(e+=1),b(e,l,d);if(e!==c)throw new RangeError("Requested steps ("+c+") exceeds available steps ("+e+")");return{node:l.container(),offset:l.unfilteredDomOffset()}};this.convertDomPointToSteps=
|
||
|
function(c,e,d){var g;n.containsNode(f,c)||(e=0>n.comparePoints(f,0,c,e),c=f,e=e?0:f.childNodes.length);l.setUnfilteredPosition(c,e);h(l,d)||l.setUnfilteredPosition(c,e);d=l.container();e=l.unfilteredDomOffset();c=p.setToClosestDomPoint(d,e,l);if(0>n.comparePoints(l.container(),l.unfilteredDomOffset(),d,e))return 0<c?c-1:c;for(;(l.container()!==d||l.unfilteredDomOffset()!==e)&&l.nextPosition();)(g=a.acceptPosition(l)===m)&&(c+=1),b(c,l,g);return c+0};this.prime=function(){var c,e;for(c=p.setToClosestStep(0,
|
||
|
l);l.nextPosition();)(e=a.acceptPosition(l)===m)&&(c+=1),b(c,l,e)};this.handleStepsInserted=function(a){p.damageCacheAfterStep(a.position)};this.handleStepsRemoved=function(a){p.damageCacheAfterStep(a.position-1)};p=new ops.StepsCache(f,d,function(c,e){do{if(a.acceptPosition(e)===m){b(c,e,!0);break}b(c-1,e,!1)}while(e.nextPosition())})}})();ops.Operation=function(){};ops.Operation.prototype.init=function(f){};ops.Operation.prototype.execute=function(f){};ops.Operation.prototype.spec=function(){};ops.TextPositionFilter=function(){function f(a,b){for(;a&&b(a)!==h;)a=a.previousSibling;return a}function l(b,d,m,g){var e;if(d){if(a.isInlineRoot(d)&&a.isGroupingElement(m))return p;g=a.lookLeftForCharacter(d);if(1===g||2===g&&(a.scanRightForAnyCharacter(m)||a.scanRightForAnyCharacter(a.nextNode(b))))return h}else if(a.isGroupingElement(b)&&a.isInlineRoot(f(b.previousSibling,g)))return h;g=null===d&&a.isParagraph(b);e=a.lookRightForCharacter(m);if(g)return e?h:a.scanRightForAnyCharacter(m)?p:h;if(!e)return p;
|
||
|
d=d||a.previousNode(b);return a.scanLeftForAnyCharacter(d)?p:h}var a=odf.OdfUtils,d=Node.ELEMENT_NODE,b=Node.TEXT_NODE,h=core.PositionFilter.FilterResult.FILTER_ACCEPT,p=core.PositionFilter.FilterResult.FILTER_REJECT;this.acceptPosition=function(f){var n=f.container(),m=n.nodeType,g,e,c;if(m!==d&&m!==b)return p;if(m===b){m=f.unfilteredDomOffset();g=n.data;runtime.assert(m!==g.length,"Unexpected offset.");if(0<m){f=g[m-1];if(!a.isODFWhitespace(f))return h;if(1<m)if(f=g[m-2],!a.isODFWhitespace(f))c=
|
||
|
h;else{if(!a.isODFWhitespace(g.substr(0,m)))return p}else e=a.previousNode(n),a.scanLeftForNonSpace(e)&&(c=h);if(c===h)return a.isTrailingWhitespace(n,m)?p:h;f=g[m];return a.isODFWhitespace(f)?p:a.scanLeftForAnyCharacter(a.previousNode(n))?p:h}e=f.leftNode();c=n;n=n.parentNode;c=l(n,e,c,f.getNodeFilter())}else a.isGroupingElement(n)?(e=f.leftNode(),c=f.rightNode(),c=l(n,e,c,f.getNodeFilter())):c=p;return c}};ops.OdtDocument=function(f){function l(a){return new core.PositionIterator(a,J,N,!1)}function a(){var a=f.odfContainer().getContentElement(),c=a&&a.localName;runtime.assert("text"===c,"Unsupported content element type '"+c+"' for OdtDocument");return a}function d(){return c.getDocumentElement().ownerDocument}function b(a){for(;a&&!(a.namespaceURI===odf.Namespaces.officens&&"text"===a.localName||a.namespaceURI===odf.Namespaces.officens&&"annotation"===a.localName);)a=a.parentNode;return a}function h(a){this.acceptPosition=
|
||
|
function(c){c=c.container();var e;e="string"===typeof a?t[a].getNode():a;return b(c)===b(e)?s:w}}function p(a,c,b,e){e=l(e);var d;1===b.length?d=b[0]:(d=new core.PositionFilterChain,b.forEach(d.addFilter));b=new core.StepIterator(d,e);b.setPosition(a,c);return b}function q(c){var b=l(a());c=E.convertStepsToDomPoint(c);b.setUnfilteredPosition(c.node,c.offset);return b}function n(a){return a===u}function m(a){var b=a.spec(),e=b.memberid,d=(new Date(b.timestamp)).toISOString(),b=f.odfContainer();a.isEdit&&
|
||
|
(e=c.getMember(e).getProperties().fullName,b.setMetadata({"dc:creator":e,"dc:date":d},null),e={setProperties:{"dc:creator":e,"dc:date":d},removedProperties:[]},B||(e.setProperties["meta:editing-cycles"]=b.incrementEditingCycles(),F||b.setMetadata(null,["meta:editing-duration","meta:document-statistic"])),B=a,c.emit(ops.OdtDocument.signalMetadataUpdated,e))}function g(a){var c,b=[],e,d=2;runtime.assert(a.isStep(),"positionIterator is not at a step");do{if(c=r.getContentBounds(a))if(c=c.container,k.isDowngradableSpaceElement(c)){for(e=
|
||
|
c.lastChild;c.firstChild;)b.push(c.firstChild),c.parentNode.insertBefore(c.firstChild,c);c.parentNode.removeChild(c);a.setPosition(e,e.nodeType===Node.TEXT_NODE?e.length:e.childNodes.length);a.roundToPreviousStep()}d-=1}while(0<d&&a.nextStep());b.forEach(x.normalizeTextNodes)}function e(a,c,b){a=a.childNodes.item(c)||a;return(a=k.getParagraphElement(a))&&x.containsNode(b,a)?a:b}var c=this,r,k=odf.OdfUtils,x=core.DomUtils,t={},y={},v=new core.EventNotifier([ops.Document.signalMemberAdded,ops.Document.signalMemberUpdated,
|
||
|
ops.Document.signalMemberRemoved,ops.Document.signalCursorAdded,ops.Document.signalCursorRemoved,ops.Document.signalCursorMoved,ops.OdtDocument.signalParagraphChanged,ops.OdtDocument.signalParagraphStyleModified,ops.OdtDocument.signalCommonStyleCreated,ops.OdtDocument.signalCommonStyleDeleted,ops.OdtDocument.signalTableAdded,ops.OdtDocument.signalOperationStart,ops.OdtDocument.signalOperationEnd,ops.OdtDocument.signalProcessingBatchStart,ops.OdtDocument.signalProcessingBatchEnd,ops.OdtDocument.signalUndoStackChanged,
|
||
|
ops.OdtDocument.signalStepsInserted,ops.OdtDocument.signalStepsRemoved,ops.OdtDocument.signalMetadataUpdated,ops.OdtDocument.signalAnnotationAdded]),s=core.PositionFilter.FilterResult.FILTER_ACCEPT,w=core.PositionFilter.FilterResult.FILTER_REJECT,u=core.StepDirection.NEXT,A,E,B,F=!1,J=NodeFilter.SHOW_ALL,H=new gui.BlacklistNamespaceNodeFilter(["urn:webodf:names:cursor","urn:webodf:names:editinfo"]),Q=new gui.OdfTextBodyNodeFilter,N=new core.NodeFilterChain([H,Q]);this.createPositionIterator=l;this.getDocumentElement=
|
||
|
function(){return f.odfContainer().rootElement};this.cloneDocumentElement=function(){var a=c.getDocumentElement(),b=f.getAnnotationViewManager();b&&b.forgetAnnotations();a=a.cloneNode(!0);f.refreshAnnotations();return a};this.setDocumentElement=function(c){var b=f.odfContainer();v.unsubscribe(ops.OdtDocument.signalStepsInserted,E.handleStepsInserted);v.unsubscribe(ops.OdtDocument.signalStepsRemoved,E.handleStepsRemoved);b.setRootElement(c);f.setOdfContainer(b,!0);f.refreshCSS();c=a();E=new ops.OdtStepsTranslator(c,
|
||
|
l(c),A,500);v.subscribe(ops.OdtDocument.signalStepsInserted,E.handleStepsInserted);v.subscribe(ops.OdtDocument.signalStepsRemoved,E.handleStepsRemoved)};this.getDOMDocument=d;this.getRootElement=b;this.createStepIterator=p;this.getIteratorAtPosition=q;this.convertCursorStepToDomPoint=function(a){return E.convertStepsToDomPoint(a)};this.convertDomPointToCursorStep=function(a,c,b){var e;b===u&&(e=n);return E.convertDomPointToSteps(a,c,e)};this.convertDomToCursorRange=function(a){var c;c=E.convertDomPointToSteps(a.anchorNode,
|
||
|
a.anchorOffset);a=a.anchorNode===a.focusNode&&a.anchorOffset===a.focusOffset?c:E.convertDomPointToSteps(a.focusNode,a.focusOffset);return{position:c,length:a-c}};this.convertCursorToDomRange=function(a,c){var b=d().createRange(),e,f;e=E.convertStepsToDomPoint(a);c?(f=E.convertStepsToDomPoint(a+c),0<c?(b.setStart(e.node,e.offset),b.setEnd(f.node,f.offset)):(b.setStart(f.node,f.offset),b.setEnd(e.node,e.offset))):b.setStart(e.node,e.offset);return b};this.upgradeWhitespacesAtPosition=function(a){var c=
|
||
|
q(a),c=new core.StepIterator(A,c),b,e=2;runtime.assert(c.isStep(),"positionIterator is not at a step (requested step: "+a+")");do{if(b=r.getContentBounds(c))if(a=b.container,b=b.startOffset,a.nodeType===Node.TEXT_NODE&&k.isSignificantWhitespace(a,b)){runtime.assert(" "===a.data[b],"upgradeWhitespaceToElement: textNode.data[offset] should be a literal space");var d=a.ownerDocument.createElementNS(odf.Namespaces.textns,"text:s"),f=a.parentNode,g=a;d.appendChild(a.ownerDocument.createTextNode(" "));
|
||
|
1===a.length?f.replaceChild(d,a):(a.deleteData(b,1),0<b&&(b<a.length&&a.splitText(b),g=a.nextSibling),f.insertBefore(d,g));a=d;c.setPosition(a,a.childNodes.length);c.roundToPreviousStep()}e-=1}while(0<e&&c.nextStep())};this.downgradeWhitespaces=g;this.downgradeWhitespacesAtPosition=function(a){a=q(a);a=new core.StepIterator(A,a);g(a)};this.getTextNodeAtStep=function(a,b){var e=q(a),f=e.container(),k,g=0,h=null;f.nodeType===Node.TEXT_NODE?(k=f,g=e.unfilteredDomOffset(),0<k.length&&(0<g&&(k=k.splitText(g)),
|
||
|
k.parentNode.insertBefore(d().createTextNode(""),k),k=k.previousSibling,g=0)):(k=d().createTextNode(""),g=0,f.insertBefore(k,e.rightNode()));if(b){if(t[b]&&c.getCursorPosition(b)===a){for(h=t[b].getNode();h.nextSibling&&"cursor"===h.nextSibling.localName;)h.parentNode.insertBefore(h.nextSibling,h);0<k.length&&k.nextSibling!==h&&(k=d().createTextNode(""),g=0);h.parentNode.insertBefore(k,h)}}else for(;k.nextSibling&&"cursor"===k.nextSibling.localName;)k.parentNode.insertBefore(k.nextSibling,k);for(;k.previousSibling&&
|
||
|
k.previousSibling.nodeType===Node.TEXT_NODE;)e=k.previousSibling,e.appendData(k.data),g=e.length,k=e,k.parentNode.removeChild(k.nextSibling);for(;k.nextSibling&&k.nextSibling.nodeType===Node.TEXT_NODE;)e=k.nextSibling,k.appendData(e.data),k.parentNode.removeChild(e);return{textNode:k,offset:g}};this.fixCursorPositions=function(){Object.keys(t).forEach(function(a){var d=t[a],f=b(d.getNode()),k=c.createRootFilter(f),g,h,r,m=!1;r=d.getSelectedRange();g=e(r.startContainer,r.startOffset,f);h=p(r.startContainer,
|
||
|
r.startOffset,[A,k],g);r.collapsed?f=h:(g=e(r.endContainer,r.endOffset,f),f=p(r.endContainer,r.endOffset,[A,k],g));h.isStep()&&f.isStep()?h.container()!==f.container()||h.offset()!==f.offset()||r.collapsed&&d.getAnchorNode()===d.getNode()||(m=!0,r.setStart(h.container(),h.offset()),r.collapse(!0)):(m=!0,runtime.assert(h.roundToClosestStep(),"No walkable step found for cursor owned by "+a),r.setStart(h.container(),h.offset()),runtime.assert(f.roundToClosestStep(),"No walkable step found for cursor owned by "+
|
||
|
a),r.setEnd(f.container(),f.offset()));m&&(d.setSelectedRange(r,d.hasForwardSelection()),c.emit(ops.Document.signalCursorMoved,d))})};this.getCursorPosition=function(a){return(a=t[a])?E.convertDomPointToSteps(a.getNode(),0):0};this.getCursorSelection=function(a){a=t[a];var c=0,b=0;a&&(c=E.convertDomPointToSteps(a.getNode(),0),b=E.convertDomPointToSteps(a.getAnchorNode(),0));return{position:b,length:c-b}};this.getPositionFilter=function(){return A};this.getOdfCanvas=function(){return f};this.getCanvas=
|
||
|
function(){return f};this.getRootNode=a;this.addMember=function(a){runtime.assert(void 0===y[a.getMemberId()],"This member already exists");y[a.getMemberId()]=a};this.getMember=function(a){return y.hasOwnProperty(a)?y[a]:null};this.removeMember=function(a){delete y[a]};this.getCursor=function(a){return t[a]};this.getMemberIds=function(){var a=[],c;for(c in t)t.hasOwnProperty(c)&&a.push(t[c].getMemberId());return a};this.addCursor=function(a){runtime.assert(Boolean(a),"OdtDocument::addCursor without cursor");
|
||
|
var b=a.getMemberId(),e=c.convertCursorToDomRange(0,0);runtime.assert("string"===typeof b,"OdtDocument::addCursor has cursor without memberid");runtime.assert(!t[b],"OdtDocument::addCursor is adding a duplicate cursor with memberid "+b);a.setSelectedRange(e,!0);t[b]=a};this.removeCursor=function(a){var b=t[a];return b?(b.removeFromDocument(),delete t[a],c.emit(ops.Document.signalCursorRemoved,a),!0):!1};this.moveCursor=function(a,b,e,d){a=t[a];b=c.convertCursorToDomRange(b,e);a&&(a.setSelectedRange(b,
|
||
|
0<=e),a.setSelectionType(d||ops.OdtCursor.RangeSelection))};this.getFormatting=function(){return f.getFormatting()};this.emit=function(a,c){v.emit(a,c)};this.subscribe=function(a,c){v.subscribe(a,c)};this.unsubscribe=function(a,c){v.unsubscribe(a,c)};this.createRootFilter=function(a){return new h(a)};this.close=function(a){a()};this.destroy=function(a){a()};(function(){var c=a();A=new ops.TextPositionFilter;r=new odf.StepUtils;E=new ops.OdtStepsTranslator(c,l(c),A,500);v.subscribe(ops.OdtDocument.signalStepsInserted,
|
||
|
E.handleStepsInserted);v.subscribe(ops.OdtDocument.signalStepsRemoved,E.handleStepsRemoved);v.subscribe(ops.OdtDocument.signalOperationEnd,m);v.subscribe(ops.OdtDocument.signalProcessingBatchEnd,core.Task.processTasks)})()};ops.OdtDocument.signalParagraphChanged="paragraph/changed";ops.OdtDocument.signalTableAdded="table/added";ops.OdtDocument.signalCommonStyleCreated="style/created";ops.OdtDocument.signalCommonStyleDeleted="style/deleted";ops.OdtDocument.signalParagraphStyleModified="paragraphstyle/modified";
|
||
|
ops.OdtDocument.signalOperationStart="operation/start";ops.OdtDocument.signalOperationEnd="operation/end";ops.OdtDocument.signalProcessingBatchStart="router/batchstart";ops.OdtDocument.signalProcessingBatchEnd="router/batchend";ops.OdtDocument.signalUndoStackChanged="undo/changed";ops.OdtDocument.signalStepsInserted="steps/inserted";ops.OdtDocument.signalStepsRemoved="steps/removed";ops.OdtDocument.signalMetadataUpdated="metadata/updated";ops.OdtDocument.signalAnnotationAdded="annotation/added";ops.OpAddAnnotation=function(){function f(a,b,d){var f=a.getTextNodeAtStep(d,l);f&&(a=f.textNode,d=a.parentNode,f.offset!==a.length&&a.splitText(f.offset),d.insertBefore(b,a.nextSibling),0===a.length&&d.removeChild(a))}var l,a,d,b,h,p;this.init=function(f){l=f.memberid;a=parseInt(f.timestamp,10);d=parseInt(f.position,10);b=parseInt(f.length,10)||0;h=f.name};this.isEdit=!0;this.group=void 0;this.execute=function(q){var n=q.getCursor(l),m,g;p=q.getDOMDocument();var e=new Date(a),c,r,k;c=p.createElementNS(odf.Namespaces.officens,
|
||
|
"office:annotation");c.setAttributeNS(odf.Namespaces.officens,"office:name",h);m=p.createElementNS(odf.Namespaces.dcns,"dc:creator");m.setAttributeNS("urn:webodf:names:editinfo","editinfo:memberid",l);m.textContent=q.getMember(l).getProperties().fullName;g=p.createElementNS(odf.Namespaces.dcns,"dc:date");g.appendChild(p.createTextNode(e.toISOString()));e=p.createElementNS(odf.Namespaces.textns,"text:list");r=p.createElementNS(odf.Namespaces.textns,"text:list-item");k=p.createElementNS(odf.Namespaces.textns,
|
||
|
"text:p");r.appendChild(k);e.appendChild(r);c.appendChild(m);c.appendChild(g);c.appendChild(e);b&&(m=p.createElementNS(odf.Namespaces.officens,"office:annotation-end"),m.setAttributeNS(odf.Namespaces.officens,"office:name",h),c.annotationEndElement=m,f(q,m,d+b));f(q,c,d);q.emit(ops.OdtDocument.signalStepsInserted,{position:d});n&&(m=p.createRange(),g=c.getElementsByTagNameNS(odf.Namespaces.textns,"p")[0],m.selectNodeContents(g),n.setSelectedRange(m,!1),n.setSelectionType(ops.OdtCursor.RangeSelection),
|
||
|
q.emit(ops.Document.signalCursorMoved,n));q.getOdfCanvas().addAnnotation(c);q.fixCursorPositions();q.emit(ops.OdtDocument.signalAnnotationAdded,{memberId:l,annotation:c});return!0};this.spec=function(){return{optype:"AddAnnotation",memberid:l,timestamp:a,position:d,length:b,name:h}}};ops.OpAddCursor=function(){var f,l;this.init=function(a){f=a.memberid;l=a.timestamp};this.isEdit=!1;this.group=void 0;this.execute=function(a){var d=a.getCursor(f);if(d)return!1;d=new ops.OdtCursor(f,a);a.addCursor(d);a.emit(ops.Document.signalCursorAdded,d);return!0};this.spec=function(){return{optype:"AddCursor",memberid:f,timestamp:l}}};ops.OpAddMember=function(){var f,l,a;this.init=function(d){f=d.memberid;l=parseInt(d.timestamp,10);a=d.setProperties};this.isEdit=!1;this.group=void 0;this.execute=function(d){var b;if(d.getMember(f))return!1;b=new ops.Member(f,a);d.addMember(b);d.emit(ops.Document.signalMemberAdded,b);return!0};this.spec=function(){return{optype:"AddMember",memberid:f,timestamp:l,setProperties:a}}};ops.OpAddStyle=function(){var f,l,a,d,b,h,p=odf.Namespaces.stylens;this.init=function(p){f=p.memberid;l=p.timestamp;a=p.styleName;d=p.styleFamily;b="true"===p.isAutomaticStyle||!0===p.isAutomaticStyle;h=p.setProperties};this.isEdit=!0;this.group=void 0;this.execute=function(f){var n=f.getOdfCanvas().odfContainer(),m=f.getFormatting(),g=f.getDOMDocument().createElementNS(p,"style:style");if(!g)return!1;h&&m.updateStyle(g,h);g.setAttributeNS(p,"style:family",d);g.setAttributeNS(p,"style:name",a);b?
|
||
|
n.rootElement.automaticStyles.appendChild(g):n.rootElement.styles.appendChild(g);f.getOdfCanvas().refreshCSS();b||f.emit(ops.OdtDocument.signalCommonStyleCreated,{name:a,family:d});return!0};this.spec=function(){return{optype:"AddStyle",memberid:f,timestamp:l,styleName:a,styleFamily:d,isAutomaticStyle:b,setProperties:h}}};odf.ObjectNameGenerator=function(f,l){function a(a,c){var b={};this.generateName=function(){var e=c(),d=0,f;do f=a+d,d+=1;while(b[f]||e[f]);b[f]=!0;return f}}function d(){var a={};[f.rootElement.automaticStyles,f.rootElement.styles].forEach(function(c){for(c=c.firstElementChild;c;)c.namespaceURI===b&&"style"===c.localName&&(a[c.getAttributeNS(b,"name")]=!0),c=c.nextElementSibling});return a}var b=odf.Namespaces.stylens,h=odf.Namespaces.drawns,p=odf.Namespaces.xlinkns,q=(new core.Utils).hashString(l),
|
||
|
n=null,m=null,g=null,e={},c={};this.generateStyleName=function(){null===n&&(n=new a("auto"+q+"_",function(){return d()}));return n.generateName()};this.generateFrameName=function(){var c,b,d;if(null===m){b=f.rootElement.body.getElementsByTagNameNS(h,"frame");for(c=0;c<b.length;c+=1)d=b.item(c),e[d.getAttributeNS(h,"name")]=!0;m=new a("fr"+q+"_",function(){return e})}return m.generateName()};this.generateImageName=function(){var b,e,d;if(null===g){d=f.rootElement.body.getElementsByTagNameNS(h,"image");
|
||
|
for(b=0;b<d.length;b+=1)e=d.item(b),e=e.getAttributeNS(p,"href"),e=e.substring(9,e.lastIndexOf(".")),c[e]=!0;g=new a("img"+q+"_",function(){return c})}return g.generateName()}};odf.TextStyleApplicator=function(f,l,a){function d(a){function b(a,e){return"object"===typeof a&&"object"===typeof e?Object.keys(a).every(function(d){return b(a[d],e[d])}):a===e}var e={};this.isStyleApplied=function(c){c=l.getAppliedStylesForElement(c,e).styleProperties;return b(a,c)}}function b(b){var d={};this.applyStyleToContainer=function(e){var c;c=e.getAttributeNS(q,"style-name");var h=e.ownerDocument;c=c||"";if(!d.hasOwnProperty(c)){var k=c,p;p=c?l.createDerivedStyleObject(c,"text",b):b;h=
|
||
|
h.createElementNS(n,"style:style");l.updateStyle(h,p);h.setAttributeNS(n,"style:name",f.generateStyleName());h.setAttributeNS(n,"style:family","text");h.setAttributeNS("urn:webodf:names:scope","scope","document-content");a.appendChild(h);d[k]=h}c=d[c].getAttributeNS(n,"name");e.setAttributeNS(q,"text:style-name",c)}}function h(a,b){var e=a.ownerDocument,c=a.parentNode,d,f,h,n=new core.LoopWatchDog(1E4);f=[];f.push(a);for(h=a.nextSibling;h&&p.rangeContainsNode(b,h);)n.check(),f.push(h),h=h.nextSibling;
|
||
|
"span"!==c.localName||c.namespaceURI!==q?(d=e.createElementNS(q,"text:span"),c.insertBefore(d,a),e=!1):(a.previousSibling&&!p.rangeContainsNode(b,c.firstChild)?(d=c.cloneNode(!1),c.parentNode.insertBefore(d,c.nextSibling)):d=c,e=!0);f.forEach(function(a){a.parentNode!==d&&d.appendChild(a)});if(h&&e)for(f=d.cloneNode(!1),d.parentNode.insertBefore(f,d.nextSibling);h;)n.check(),e=h.nextSibling,f.appendChild(h),h=e;return d}var p=core.DomUtils,q=odf.Namespaces.textns,n=odf.Namespaces.stylens;this.applyStyle=
|
||
|
function(a,f,e){var c={},r,k,p,n;runtime.assert(e&&e.hasOwnProperty("style:text-properties"),"applyStyle without any text properties");c["style:text-properties"]=e["style:text-properties"];p=new b(c);n=new d(c);a.forEach(function(a){r=n.isStyleApplied(a);!1===r&&(k=h(a,f),p.applyStyleToContainer(k))})}};ops.OpApplyDirectStyling=function(){function f(a,b,d){var e=a.getOdfCanvas().odfContainer(),c=q.splitBoundaries(b),f=p.getTextNodes(b,!1);(new odf.TextStyleApplicator(new odf.ObjectNameGenerator(e,l),a.getFormatting(),e.rootElement.automaticStyles)).applyStyle(f,b,d);c.forEach(q.normalizeTextNodes)}var l,a,d,b,h,p=odf.OdfUtils,q=core.DomUtils;this.init=function(f){l=f.memberid;a=f.timestamp;d=parseInt(f.position,10);b=parseInt(f.length,10);h=f.setProperties};this.isEdit=!0;this.group=void 0;this.execute=
|
||
|
function(n){var m=n.convertCursorToDomRange(d,b),g=p.getParagraphElements(m);f(n,m,h);m.detach();n.getOdfCanvas().refreshCSS();n.fixCursorPositions();g.forEach(function(b){n.emit(ops.OdtDocument.signalParagraphChanged,{paragraphElement:b,memberId:l,timeStamp:a})});n.getOdfCanvas().rerenderAnnotations();return!0};this.spec=function(){return{optype:"ApplyDirectStyling",memberid:l,timestamp:a,position:d,length:b,setProperties:h}}};ops.OpApplyHyperlink=function(){function f(a){for(;a;){if(q.isHyperlink(a))return!0;a=a.parentNode}return!1}var l,a,d,b,h,p=core.DomUtils,q=odf.OdfUtils;this.init=function(f){l=f.memberid;a=f.timestamp;d=f.position;b=f.length;h=f.hyperlink};this.isEdit=!0;this.group=void 0;this.execute=function(n){var m=n.getDOMDocument(),g=n.convertCursorToDomRange(d,b),e=p.splitBoundaries(g),c=[],r=q.getTextNodes(g,!1);if(0===r.length)return!1;r.forEach(function(a){var b=q.getParagraphElement(a);runtime.assert(!1===
|
||
|
f(a),"The given range should not contain any link.");var e=h,d=m.createElementNS(odf.Namespaces.textns,"text:a");d.setAttributeNS(odf.Namespaces.xlinkns,"xlink:type","simple");d.setAttributeNS(odf.Namespaces.xlinkns,"xlink:href",e);a.parentNode.insertBefore(d,a);d.appendChild(a);-1===c.indexOf(b)&&c.push(b)});e.forEach(p.normalizeTextNodes);g.detach();n.fixCursorPositions();n.getOdfCanvas().refreshSize();n.getOdfCanvas().rerenderAnnotations();c.forEach(function(c){n.emit(ops.OdtDocument.signalParagraphChanged,
|
||
|
{paragraphElement:c,memberId:l,timeStamp:a})});return!0};this.spec=function(){return{optype:"ApplyHyperlink",memberid:l,timestamp:a,position:d,length:b,hyperlink:h}}};ops.OpInsertImage=function(){var f,l,a,d,b,h,p,q,n=odf.Namespaces.drawns,m=odf.Namespaces.svgns,g=odf.Namespaces.textns,e=odf.Namespaces.xlinkns,c=odf.OdfUtils;this.init=function(c){f=c.memberid;l=c.timestamp;a=c.position;d=c.filename;b=c.frameWidth;h=c.frameHeight;p=c.frameStyleName;q=c.frameName};this.isEdit=!0;this.group=void 0;this.execute=function(r){var k=r.getOdfCanvas(),x=r.getTextNodeAtStep(a,f),t,y;if(!x)return!1;t=x.textNode;y=c.getParagraphElement(t);var x=x.offset!==t.length?t.splitText(x.offset):
|
||
|
t.nextSibling,v=r.getDOMDocument(),s=v.createElementNS(n,"draw:image"),v=v.createElementNS(n,"draw:frame");s.setAttributeNS(e,"xlink:href",d);s.setAttributeNS(e,"xlink:type","simple");s.setAttributeNS(e,"xlink:show","embed");s.setAttributeNS(e,"xlink:actuate","onLoad");v.setAttributeNS(n,"draw:style-name",p);v.setAttributeNS(n,"draw:name",q);v.setAttributeNS(g,"text:anchor-type","as-char");v.setAttributeNS(m,"svg:width",b);v.setAttributeNS(m,"svg:height",h);v.appendChild(s);t.parentNode.insertBefore(v,
|
||
|
x);r.emit(ops.OdtDocument.signalStepsInserted,{position:a});0===t.length&&t.parentNode.removeChild(t);k.addCssForFrameWithImage(v);k.refreshCSS();r.emit(ops.OdtDocument.signalParagraphChanged,{paragraphElement:y,memberId:f,timeStamp:l});k.rerenderAnnotations();return!0};this.spec=function(){return{optype:"InsertImage",memberid:f,timestamp:l,filename:d,position:a,frameWidth:b,frameHeight:h,frameStyleName:p,frameName:q}}};ops.OpInsertTable=function(){function f(a,c){var f;if(1===m.length)f=m[0];else if(3===m.length)switch(a){case 0:f=m[0];break;case d-1:f=m[2];break;default:f=m[1]}else f=m[a];if(1===f.length)return f[0];if(3===f.length)switch(c){case 0:return f[0];case b-1:return f[2];default:return f[1]}return f[c]}var l,a,d,b,h,p,q,n,m,g=odf.OdfUtils;this.init=function(e){l=e.memberid;a=e.timestamp;h=e.position;d=e.initialRows;b=e.initialColumns;p=e.tableName;q=e.tableStyleName;n=e.tableColumnStyleName;m=e.tableCellStyleMatrix};
|
||
|
this.isEdit=!0;this.group=void 0;this.execute=function(e){var c=e.getTextNodeAtStep(h),r=e.getRootNode();if(c){var k=e.getDOMDocument(),m=k.createElementNS("urn:oasis:names:tc:opendocument:xmlns:table:1.0","table:table"),t=k.createElementNS("urn:oasis:names:tc:opendocument:xmlns:table:1.0","table:table-column"),y,v,s,w;q&&m.setAttributeNS("urn:oasis:names:tc:opendocument:xmlns:table:1.0","table:style-name",q);p&&m.setAttributeNS("urn:oasis:names:tc:opendocument:xmlns:table:1.0","table:name",p);t.setAttributeNS("urn:oasis:names:tc:opendocument:xmlns:table:1.0",
|
||
|
"table:number-columns-repeated",b);n&&t.setAttributeNS("urn:oasis:names:tc:opendocument:xmlns:table:1.0","table:style-name",n);m.appendChild(t);for(s=0;s<d;s+=1){t=k.createElementNS("urn:oasis:names:tc:opendocument:xmlns:table:1.0","table:table-row");for(w=0;w<b;w+=1)y=k.createElementNS("urn:oasis:names:tc:opendocument:xmlns:table:1.0","table:table-cell"),(v=f(s,w))&&y.setAttributeNS("urn:oasis:names:tc:opendocument:xmlns:table:1.0","table:style-name",v),v=k.createElementNS("urn:oasis:names:tc:opendocument:xmlns:text:1.0",
|
||
|
"text:p"),y.appendChild(v),t.appendChild(y);m.appendChild(t)}c=g.getParagraphElement(c.textNode);r.insertBefore(m,c.nextSibling);e.emit(ops.OdtDocument.signalStepsInserted,{position:h});e.getOdfCanvas().refreshSize();e.emit(ops.OdtDocument.signalTableAdded,{tableElement:m,memberId:l,timeStamp:a});e.getOdfCanvas().rerenderAnnotations();return!0}return!1};this.spec=function(){return{optype:"InsertTable",memberid:l,timestamp:a,position:h,initialRows:d,initialColumns:b,tableName:p,tableStyleName:q,tableColumnStyleName:n,
|
||
|
tableCellStyleMatrix:m}}};ops.OpInsertText=function(){var f,l,a,d,b,h=odf.OdfUtils;this.init=function(h){f=h.memberid;l=h.timestamp;a=h.position;b=h.text;d="true"===h.moveCursor||!0===h.moveCursor};this.isEdit=!0;this.group=void 0;this.execute=function(p){var q,n,m,g=null,e=p.getDOMDocument(),c,r=0,k,x=p.getCursor(f),t;p.upgradeWhitespacesAtPosition(a);if(q=p.getTextNodeAtStep(a)){n=q.textNode;g=n.nextSibling;m=n.parentNode;c=h.getParagraphElement(n);for(t=0;t<b.length;t+=1)if("\t"===b[t]||"\t"!==b[t]&&h.isODFWhitespace(b[t])&&
|
||
|
(0===t||t===b.length-1||"\t"!==b[t-1]&&h.isODFWhitespace(b[t-1])))0===r?(q.offset!==n.length&&(g=n.splitText(q.offset)),0<t&&n.appendData(b.substring(0,t))):r<t&&(r=b.substring(r,t),m.insertBefore(e.createTextNode(r),g)),r=t+1,"\t"===b[t]?(k=e.createElementNS("urn:oasis:names:tc:opendocument:xmlns:text:1.0","text:tab"),k.appendChild(e.createTextNode("\t"))):(" "!==b[t]&&runtime.log("WARN: InsertText operation contains non-tab, non-space whitespace character (character code "+b.charCodeAt(t)+")"),
|
||
|
k=e.createElementNS("urn:oasis:names:tc:opendocument:xmlns:text:1.0","text:s"),k.appendChild(e.createTextNode(" "))),m.insertBefore(k,g);0===r?n.insertData(q.offset,b):r<b.length&&(q=b.substring(r),m.insertBefore(e.createTextNode(q),g));m=n.parentNode;g=n.nextSibling;m.removeChild(n);m.insertBefore(n,g);0===n.length&&n.parentNode.removeChild(n);p.emit(ops.OdtDocument.signalStepsInserted,{position:a});x&&d&&(p.moveCursor(f,a+b.length,0),p.emit(ops.Document.signalCursorMoved,x));p.downgradeWhitespacesAtPosition(a);
|
||
|
p.downgradeWhitespacesAtPosition(a+b.length);p.getOdfCanvas().refreshSize();p.emit(ops.OdtDocument.signalParagraphChanged,{paragraphElement:c,memberId:f,timeStamp:l});p.getOdfCanvas().rerenderAnnotations();return!0}return!1};this.spec=function(){return{optype:"InsertText",memberid:f,timestamp:l,position:a,text:b,moveCursor:d}}};odf.CollapsingRules=function(f){function l(a){return d.isODFNode(a)||"br"===a.localName&&d.isLineBreak(a.parentNode)||a.nodeType===Node.TEXT_NODE&&d.isODFNode(a.parentNode)}function a(h){var p;h.nodeType===Node.TEXT_NODE?(p=h.parentNode,p.removeChild(h)):p=b.removeUnwantedNodes(h,l);return p&&!d.isParagraph(p)&&p!==f&&d.hasNoODFContent(p)?a(p):p}var d=odf.OdfUtils,b=core.DomUtils;this.mergeChildrenIntoParent=a};ops.OpMergeParagraph=function(){function f(a){return g.isGroupingElement(a)&&g.hasNoODFContent(a)}function l(a){if(a.nodeType===Node.TEXT_NODE){if(0===a.length)return runtime.log("WARN: Empty text node found during merge operation"),!0;if(g.isODFWhitespace(a.data)&&!1===g.isSignificantWhitespace(a,0))return!0;a="#text"}else a=(a.prefix?a.prefix+":":"")+a.localName;runtime.log("WARN: Unexpected text element found near paragraph boundary ["+a+"]");return!1}function a(a){a.collapsed||(e.splitBoundaries(a),
|
||
|
a=g.getTextElements(a,!1,!0).filter(l),a.forEach(function(a){a.parentNode.removeChild(a)}))}function d(a,c,b){a=a.convertCursorStepToDomPoint(c);var e=g.getParagraphElement(a.node,a.offset);runtime.assert(Boolean(e),"Paragraph not found at step "+c);b&&b.setPosition(a.node,a.offset);return e}var b,h,p,q,n,m,g=odf.OdfUtils,e=core.DomUtils,c=odf.Namespaces.textns;this.init=function(a){b=a.memberid;h=a.timestamp;p=a.moveCursor;q=a.paragraphStyleName;n=parseInt(a.sourceStartPosition,10);m=parseInt(a.destinationStartPosition,
|
||
|
10)};this.isEdit=!0;this.group=void 0;this.execute=function(g){var k,l,t=g.getCursor(b);k=g.getRootNode();var y=new odf.CollapsingRules(k),v=g.createStepIterator(k,0,[g.getPositionFilter()],k),s;runtime.assert(m<n,"Destination paragraph ("+m+") must be before source paragraph ("+n+")");l=d(g,m);k=d(g,n,v);v.previousStep();runtime.assert(e.containsNode(l,v.container()),"Destination paragraph must be adjacent to the source paragraph");s=l.ownerDocument.createRange();v.setPosition(l,l.childNodes.length);
|
||
|
v.roundToPreviousStep();s.setStart(v.container(),v.offset());s.setEnd(l,l.childNodes.length);a(s);s=l.childNodes.length;var w=k.ownerDocument.createRange();v.setPosition(k,0);v.roundToNextStep();w.setStart(k,0);w.setEnd(v.container(),v.offset());a(w);for(w=k.firstChild;w;)"editinfo"===w.localName?k.removeChild(w):(l.appendChild(w),e.removeUnwantedNodes(w,f)),w=k.firstChild;runtime.assert(0===k.childNodes.length,"Source paragraph should be empty before it is removed");y.mergeChildrenIntoParent(k);
|
||
|
g.emit(ops.OdtDocument.signalStepsRemoved,{position:n-1});v.setPosition(l,s);v.roundToClosestStep();v.previousStep()||v.roundToNextStep();g.downgradeWhitespaces(v);q?l.setAttributeNS(c,"text:style-name",q):l.removeAttributeNS(c,"style-name");t&&p&&(g.moveCursor(b,n-1,0),g.emit(ops.Document.signalCursorMoved,t));g.fixCursorPositions();g.getOdfCanvas().refreshSize();g.emit(ops.OdtDocument.signalParagraphChanged,{paragraphElement:l,memberId:b,timeStamp:h});g.getOdfCanvas().rerenderAnnotations();return!0};
|
||
|
this.spec=function(){return{optype:"MergeParagraph",memberid:b,timestamp:h,moveCursor:p,paragraphStyleName:q,sourceStartPosition:n,destinationStartPosition:m}}};ops.OpMoveCursor=function(){var f,l,a,d,b;this.init=function(h){f=h.memberid;l=h.timestamp;a=h.position;d=h.length||0;b=h.selectionType||ops.OdtCursor.RangeSelection};this.isEdit=!1;this.group=void 0;this.execute=function(h){var p=h.getCursor(f),l;if(!p)return!1;l=h.convertCursorToDomRange(a,d);p.setSelectedRange(l,0<=d);p.setSelectionType(b);h.emit(ops.Document.signalCursorMoved,p);return!0};this.spec=function(){return{optype:"MoveCursor",memberid:f,timestamp:l,position:a,length:d,selectionType:b}}};ops.OpRemoveAnnotation=function(){var f,l,a,d,b=core.DomUtils;this.init=function(b){f=b.memberid;l=b.timestamp;a=parseInt(b.position,10);d=parseInt(b.length,10)};this.isEdit=!0;this.group=void 0;this.execute=function(d){function f(a){n.parentNode.insertBefore(a,n)}for(var l=d.getIteratorAtPosition(a).container(),n;l.namespaceURI!==odf.Namespaces.officens||"annotation"!==l.localName;)l=l.parentNode;if(null===l)return!1;n=l;l=n.annotationEndElement;d.getOdfCanvas().forgetAnnotations();b.getElementsByTagNameNS(n,
|
||
|
"urn:webodf:names:cursor","cursor").forEach(f);b.getElementsByTagNameNS(n,"urn:webodf:names:cursor","anchor").forEach(f);n.parentNode.removeChild(n);l&&l.parentNode.removeChild(l);d.emit(ops.OdtDocument.signalStepsRemoved,{position:0<a?a-1:a});d.fixCursorPositions();d.getOdfCanvas().refreshAnnotations();return!0};this.spec=function(){return{optype:"RemoveAnnotation",memberid:f,timestamp:l,position:a,length:d}}};ops.OpRemoveBlob=function(){var f,l,a;this.init=function(d){f=d.memberid;l=d.timestamp;a=d.filename};this.isEdit=!0;this.group=void 0;this.execute=function(d){d.getOdfCanvas().odfContainer().removeBlob(a);return!0};this.spec=function(){return{optype:"RemoveBlob",memberid:f,timestamp:l,filename:a}}};ops.OpRemoveCursor=function(){var f,l;this.init=function(a){f=a.memberid;l=a.timestamp};this.isEdit=!1;this.group=void 0;this.execute=function(a){return a.removeCursor(f)?!0:!1};this.spec=function(){return{optype:"RemoveCursor",memberid:f,timestamp:l}}};ops.OpRemoveHyperlink=function(){var f,l,a,d,b=core.DomUtils,h=odf.OdfUtils;this.init=function(b){f=b.memberid;l=b.timestamp;a=b.position;d=b.length};this.isEdit=!0;this.group=void 0;this.execute=function(p){var q=p.convertCursorToDomRange(a,d),n=h.getHyperlinkElements(q);runtime.assert(1===n.length,"The given range should only contain a single link.");n=b.mergeIntoParent(n[0]);q.detach();p.fixCursorPositions();p.getOdfCanvas().refreshSize();p.getOdfCanvas().rerenderAnnotations();p.emit(ops.OdtDocument.signalParagraphChanged,
|
||
|
{paragraphElement:h.getParagraphElement(n),memberId:f,timeStamp:l});return!0};this.spec=function(){return{optype:"RemoveHyperlink",memberid:f,timestamp:l,position:a,length:d}}};ops.OpRemoveMember=function(){var f,l;this.init=function(a){f=a.memberid;l=parseInt(a.timestamp,10)};this.isEdit=!1;this.group=void 0;this.execute=function(a){if(!a.getMember(f))return!1;a.removeMember(f);a.emit(ops.Document.signalMemberRemoved,f);return!0};this.spec=function(){return{optype:"RemoveMember",memberid:f,timestamp:l}}};ops.OpRemoveStyle=function(){var f,l,a,d;this.init=function(b){f=b.memberid;l=b.timestamp;a=b.styleName;d=b.styleFamily};this.isEdit=!0;this.group=void 0;this.execute=function(b){var f=b.getFormatting().getStyleElement(a,d);if(!f)return!1;f.parentNode.removeChild(f);b.getOdfCanvas().refreshCSS();b.emit(ops.OdtDocument.signalCommonStyleDeleted,{name:a,family:d});return!0};this.spec=function(){return{optype:"RemoveStyle",memberid:f,timestamp:l,styleName:a,styleFamily:d}}};ops.OpRemoveText=function(){var f,l,a,d,b=odf.OdfUtils,h=core.DomUtils;this.init=function(b){runtime.assert(0<=b.length,"OpRemoveText only supports positive lengths");f=b.memberid;l=b.timestamp;a=parseInt(b.position,10);d=parseInt(b.length,10)};this.isEdit=!0;this.group=void 0;this.execute=function(p){var q,n,m,g=p.getCursor(f),e=new odf.CollapsingRules(p.getRootNode());p.upgradeWhitespacesAtPosition(a);p.upgradeWhitespacesAtPosition(a+d);q=p.convertCursorToDomRange(a,d);h.splitBoundaries(q);n=b.getTextElements(q,
|
||
|
!1,!0);m=b.getParagraphElement(q.startContainer,q.startOffset);runtime.assert(void 0!==m,"Attempting to remove text outside a paragraph element");q.detach();n.forEach(function(a){a.parentNode?(runtime.assert(h.containsNode(m,a),"RemoveText only supports removing elements within the same paragraph"),e.mergeChildrenIntoParent(a)):runtime.log("WARN: text element has already been removed from it's container")});p.emit(ops.OdtDocument.signalStepsRemoved,{position:a});p.downgradeWhitespacesAtPosition(a);
|
||
|
p.fixCursorPositions();p.getOdfCanvas().refreshSize();p.emit(ops.OdtDocument.signalParagraphChanged,{paragraphElement:m,memberId:f,timeStamp:l});g&&(g.resetSelectionType(),p.emit(ops.Document.signalCursorMoved,g));p.getOdfCanvas().rerenderAnnotations();return!0};this.spec=function(){return{optype:"RemoveText",memberid:f,timestamp:l,position:a,length:d}}};ops.OpSetBlob=function(){var f,l,a,d,b;this.init=function(h){f=h.memberid;l=h.timestamp;a=h.filename;d=h.mimetype;b=h.content};this.isEdit=!0;this.group=void 0;this.execute=function(f){f.getOdfCanvas().odfContainer().setBlob(a,d,b);return!0};this.spec=function(){return{optype:"SetBlob",memberid:f,timestamp:l,filename:a,mimetype:d,content:b}}};ops.OpSetParagraphStyle=function(){function f(a,b,d){var f=[a.getPositionFilter()],g=d.container();d=d.unfilteredDomOffset();return!1===a.createStepIterator(g,d,f,b).previousStep()}var l,a,d,b,h=odf.OdfUtils;this.init=function(f){l=f.memberid;a=f.timestamp;d=f.position;b=f.styleName};this.isEdit=!0;this.group=void 0;this.execute=function(p){var q,n;q=p.getIteratorAtPosition(d);return(n=h.getParagraphElement(q.container()))?(runtime.assert(f(p,n,q),"SetParagraphStyle position should be the first position in the paragraph"),
|
||
|
b?n.setAttributeNS("urn:oasis:names:tc:opendocument:xmlns:text:1.0","text:style-name",b):n.removeAttributeNS("urn:oasis:names:tc:opendocument:xmlns:text:1.0","style-name"),p.getOdfCanvas().refreshSize(),p.emit(ops.OdtDocument.signalParagraphChanged,{paragraphElement:n,timeStamp:a,memberId:l}),p.getOdfCanvas().rerenderAnnotations(),!0):!1};this.spec=function(){return{optype:"SetParagraphStyle",memberid:l,timestamp:a,position:d,styleName:b}}};ops.OpSplitParagraph=function(){var f,l,a,d,b,h,p=odf.OdfUtils,q=odf.Namespaces.textns;this.init=function(p){f=p.memberid;l=p.timestamp;d=p.position;a=p.sourceParagraphPosition;h=p.paragraphStyleName;b="true"===p.moveCursor||!0===p.moveCursor};this.isEdit=!0;this.group=void 0;this.execute=function(a){var m,g,e,c,r,k,x,t=a.getCursor(f);a.upgradeWhitespacesAtPosition(d);m=a.getTextNodeAtStep(d);if(!m)return!1;g=p.getParagraphElement(m.textNode);if(!g)return!1;e=p.isListItem(g.parentNode)?g.parentNode:
|
||
|
g;0===m.offset?(x=m.textNode.previousSibling,k=null):(x=m.textNode,k=m.offset>=m.textNode.length?null:m.textNode.splitText(m.offset));for(c=m.textNode;c!==e;){c=c.parentNode;r=c.cloneNode(!1);k&&r.appendChild(k);if(x)for(;x&&x.nextSibling;)r.appendChild(x.nextSibling);else for(;c.firstChild;)r.appendChild(c.firstChild);c.parentNode.insertBefore(r,c.nextSibling);x=c;k=r}p.isListItem(k)&&(k=k.childNodes.item(0));h?k.setAttributeNS(q,"text:style-name",h):k.removeAttributeNS(q,"style-name");0===m.textNode.length&&
|
||
|
m.textNode.parentNode.removeChild(m.textNode);a.emit(ops.OdtDocument.signalStepsInserted,{position:d});t&&b&&(a.moveCursor(f,d+1,0),a.emit(ops.Document.signalCursorMoved,t));a.fixCursorPositions();a.getOdfCanvas().refreshSize();a.emit(ops.OdtDocument.signalParagraphChanged,{paragraphElement:g,memberId:f,timeStamp:l});a.emit(ops.OdtDocument.signalParagraphChanged,{paragraphElement:k,memberId:f,timeStamp:l});a.getOdfCanvas().rerenderAnnotations();return!0};this.spec=function(){return{optype:"SplitParagraph",
|
||
|
memberid:f,timestamp:l,position:d,sourceParagraphPosition:a,paragraphStyleName:h,moveCursor:b}}};ops.OpUpdateMember=function(){function f(a){var b="//dc:creator[@editinfo:memberid='"+l+"']";a=xmldom.XPath.getODFElementsWithXPath(a.getRootNode(),b,function(a){return"editinfo"===a?"urn:webodf:names:editinfo":odf.Namespaces.lookupNamespaceURI(a)});for(b=0;b<a.length;b+=1)a[b].textContent=d.fullName}var l,a,d,b;this.init=function(f){l=f.memberid;a=parseInt(f.timestamp,10);d=f.setProperties;b=f.removedProperties};this.isEdit=!1;this.group=void 0;this.execute=function(a){var p=a.getMember(l);if(!p)return!1;
|
||
|
b&&p.removeProperties(b);d&&(p.setProperties(d),d.fullName&&f(a));a.emit(ops.Document.signalMemberUpdated,p);return!0};this.spec=function(){return{optype:"UpdateMember",memberid:l,timestamp:a,setProperties:d,removedProperties:b}}};ops.OpUpdateMetadata=function(){var f,l,a,d;this.init=function(b){f=b.memberid;l=parseInt(b.timestamp,10);a=b.setProperties;d=b.removedProperties};this.isEdit=!0;this.group=void 0;this.execute=function(b){var f=b.getOdfCanvas().odfContainer(),p=null;d&&(p=d.attributes.split(","));f.setMetadata(a,p);b.emit(ops.OdtDocument.signalMetadataUpdated,{setProperties:null!==a?a:{},removedProperties:null!==p?p:[]});return!0};this.spec=function(){return{optype:"UpdateMetadata",memberid:f,timestamp:l,setProperties:a,
|
||
|
removedProperties:d}}};ops.OpUpdateParagraphStyle=function(){function f(a,b){var d,f,e=b?b.split(","):[];for(d=0;d<e.length;d+=1)f=e[d].split(":"),a.removeAttributeNS(odf.Namespaces.lookupNamespaceURI(f[0]),f[1])}var l,a,d,b,h,p=odf.Namespaces.stylens;this.init=function(f){l=f.memberid;a=f.timestamp;d=f.styleName;b=f.setProperties;h=f.removedProperties};this.isEdit=!0;this.group=void 0;this.execute=function(a){var n=a.getFormatting(),m,g,e;return(m=""!==d?n.getStyleElement(d,"paragraph"):n.getDefaultStyleElement("paragraph"))?
|
||
|
(g=m.getElementsByTagNameNS(p,"paragraph-properties").item(0),e=m.getElementsByTagNameNS(p,"text-properties").item(0),b&&n.updateStyle(m,b),h&&(n=h["style:paragraph-properties"],g&&n&&(f(g,n.attributes),0===g.attributes.length&&m.removeChild(g)),n=h["style:text-properties"],e&&n&&(f(e,n.attributes),0===e.attributes.length&&m.removeChild(e)),f(m,h.attributes)),a.getOdfCanvas().refreshCSS(),a.emit(ops.OdtDocument.signalParagraphStyleModified,d),a.getOdfCanvas().rerenderAnnotations(),!0):!1};this.spec=
|
||
|
function(){return{optype:"UpdateParagraphStyle",memberid:l,timestamp:a,styleName:d,setProperties:b,removedProperties:h}}};ops.OperationFactory=function(){function f(a){return function(d){return new a}}var l;this.register=function(a,d){l[a]=d};this.create=function(a){var d=null,b=l[a.optype];b&&(d=b(a),d.init(a));return d};l={AddMember:f(ops.OpAddMember),UpdateMember:f(ops.OpUpdateMember),RemoveMember:f(ops.OpRemoveMember),AddCursor:f(ops.OpAddCursor),ApplyDirectStyling:f(ops.OpApplyDirectStyling),SetBlob:f(ops.OpSetBlob),RemoveBlob:f(ops.OpRemoveBlob),InsertImage:f(ops.OpInsertImage),InsertTable:f(ops.OpInsertTable),
|
||
|
InsertText:f(ops.OpInsertText),RemoveText:f(ops.OpRemoveText),MergeParagraph:f(ops.OpMergeParagraph),SplitParagraph:f(ops.OpSplitParagraph),SetParagraphStyle:f(ops.OpSetParagraphStyle),UpdateParagraphStyle:f(ops.OpUpdateParagraphStyle),AddStyle:f(ops.OpAddStyle),RemoveStyle:f(ops.OpRemoveStyle),MoveCursor:f(ops.OpMoveCursor),RemoveCursor:f(ops.OpRemoveCursor),AddAnnotation:f(ops.OpAddAnnotation),RemoveAnnotation:f(ops.OpRemoveAnnotation),UpdateMetadata:f(ops.OpUpdateMetadata),ApplyHyperlink:f(ops.OpApplyHyperlink),
|
||
|
RemoveHyperlink:f(ops.OpRemoveHyperlink)}};ops.OperationRouter=function(){};ops.OperationRouter.prototype.setOperationFactory=function(f){};ops.OperationRouter.prototype.setPlaybackFunction=function(f){};ops.OperationRouter.prototype.push=function(f){};ops.OperationRouter.prototype.close=function(f){};ops.OperationRouter.prototype.subscribe=function(f,l){};ops.OperationRouter.prototype.unsubscribe=function(f,l){};ops.OperationRouter.prototype.hasLocalUnsyncedOps=function(){};ops.OperationRouter.prototype.hasSessionHostConnection=function(){};
|
||
|
ops.OperationRouter.signalProcessingBatchStart="router/batchstart";ops.OperationRouter.signalProcessingBatchEnd="router/batchend";ops.TrivialOperationRouter=function(){var f=new core.EventNotifier([ops.OperationRouter.signalProcessingBatchStart,ops.OperationRouter.signalProcessingBatchEnd]),l,a,d=0;this.setOperationFactory=function(a){l=a};this.setPlaybackFunction=function(b){a=b};this.push=function(b){d+=1;f.emit(ops.OperationRouter.signalProcessingBatchStart,{});b.forEach(function(b){b=b.spec();b.timestamp=Date.now();b=l.create(b);b.group="g"+d;a(b)});f.emit(ops.OperationRouter.signalProcessingBatchEnd,{})};this.close=function(a){a()};
|
||
|
this.subscribe=function(a,d){f.subscribe(a,d)};this.unsubscribe=function(a,d){f.unsubscribe(a,d)};this.hasLocalUnsyncedOps=function(){return!1};this.hasSessionHostConnection=function(){return!0}};ops.Session=function(f){function l(a){b.emit(ops.OdtDocument.signalProcessingBatchStart,a)}function a(a){b.emit(ops.OdtDocument.signalProcessingBatchEnd,a)}var d=new ops.OperationFactory,b=new ops.OdtDocument(f),h=null;this.setOperationFactory=function(a){d=a;h&&h.setOperationFactory(d)};this.setOperationRouter=function(f){h&&(h.unsubscribe(ops.OperationRouter.signalProcessingBatchStart,l),h.unsubscribe(ops.OperationRouter.signalProcessingBatchEnd,a));h=f;h.subscribe(ops.OperationRouter.signalProcessingBatchStart,
|
||
|
l);h.subscribe(ops.OperationRouter.signalProcessingBatchEnd,a);f.setPlaybackFunction(function(a){b.emit(ops.OdtDocument.signalOperationStart,a);return a.execute(b)?(b.emit(ops.OdtDocument.signalOperationEnd,a),!0):!1});f.setOperationFactory(d)};this.getOperationFactory=function(){return d};this.getOdtDocument=function(){return b};this.enqueue=function(a){h.push(a)};this.close=function(a){h.close(function(d){d?a(d):b.close(a)})};this.destroy=function(a){b.destroy(a)};this.setOperationRouter(new ops.TrivialOperationRouter)};gui.AnnotationController=function(f,l,a){function d(){var c=q.getCursor(a),c=c&&c.getNode(),b=!1;c&&(b=!g.isWithinAnnotation(c,q.getRootNode()));b!==n&&(n=b,m.emit(gui.AnnotationController.annotatableChanged,n))}function b(c){c.getMemberId()===a&&d()}function h(c){c===a&&d()}function p(c){c.getMemberId()===a&&d()}var q=f.getOdtDocument(),n=!1,m=new core.EventNotifier([gui.AnnotationController.annotatableChanged]),g=odf.OdfUtils,e=core.StepDirection.NEXT;this.isAnnotatable=function(){return n};this.addAnnotation=
|
||
|
function(){var c=new ops.OpAddAnnotation,b=q.getCursorSelection(a),e=b.length,b=b.position;n&&(b=0<=e?b:b+e,e=Math.abs(e),c.init({memberid:a,position:b,length:e,name:a+Date.now()}),f.enqueue([c]))};this.removeAnnotation=function(c){var b,d;b=q.getMember(a).getProperties().fullName;if(!0!==l.getState(gui.CommonConstraints.EDIT.ANNOTATIONS.ONLY_DELETE_OWN)||b===g.getAnnotationCreator(c))b=q.convertDomPointToCursorStep(c,0,e),d=q.convertDomPointToCursorStep(c,c.childNodes.length),c=new ops.OpRemoveAnnotation,
|
||
|
c.init({memberid:a,position:b,length:d-b}),d=new ops.OpMoveCursor,d.init({memberid:a,position:0<b?b-1:b,length:0}),f.enqueue([c,d])};this.subscribe=function(a,b){m.subscribe(a,b)};this.unsubscribe=function(a,b){m.unsubscribe(a,b)};this.destroy=function(a){q.unsubscribe(ops.Document.signalCursorAdded,b);q.unsubscribe(ops.Document.signalCursorRemoved,h);q.unsubscribe(ops.Document.signalCursorMoved,p);a()};l.registerConstraint(gui.CommonConstraints.EDIT.ANNOTATIONS.ONLY_DELETE_OWN);q.subscribe(ops.Document.signalCursorAdded,
|
||
|
b);q.subscribe(ops.Document.signalCursorRemoved,h);q.subscribe(ops.Document.signalCursorMoved,p);d()};gui.AnnotationController.annotatableChanged="annotatable/changed";gui.Avatar=function(f,l){var a=this,d,b,h;this.setColor=function(a){b.style.borderColor=a};this.setImageUrl=function(d){a.isVisible()?b.src=d:h=d};this.isVisible=function(){return"block"===d.style.display};this.show=function(){h&&(b.src=h,h=void 0);d.style.display="block"};this.hide=function(){d.style.display="none"};this.markAsFocussed=function(a){a?d.classList.add("active"):d.classList.remove("active")};this.destroy=function(a){f.removeChild(d);a()};(function(){var a=f.ownerDocument;d=a.createElement("div");
|
||
|
b=a.createElement("img");d.appendChild(b);d.style.display=l?"block":"none";d.className="handle";f.appendChild(d)})()};gui.StepInfo=function(){};gui.StepInfo.VisualDirection={LEFT_TO_RIGHT:0,RIGHT_TO_LEFT:1};gui.StepInfo.prototype.container=function(){};gui.StepInfo.prototype.offset=function(){};gui.VisualStepScanner=function(){};gui.VisualStepScanner.prototype.process=function(f,l,a){};gui.GuiStepUtils=function(){function f(b){b=a.getContentBounds(b);var f,h=null;if(b)if(b.container.nodeType===Node.TEXT_NODE)f=b.container.ownerDocument.createRange(),f.setStart(b.container,b.startOffset),f.setEnd(b.container,b.endOffset),(h=0<f.getClientRects().length?f.getBoundingClientRect():null)&&" "===b.container.data.substring(b.startOffset,b.endOffset)&&1>=h.width&&(h=null),f.detach();else if(l.isCharacterElement(b.container)||l.isCharacterFrame(b.container))h=d.getBoundingClientRect(b.container);
|
||
|
return h}var l=odf.OdfUtils,a=new odf.StepUtils,d=core.DomUtils,b=core.StepDirection.NEXT,h=gui.StepInfo.VisualDirection.LEFT_TO_RIGHT,p=gui.StepInfo.VisualDirection.RIGHT_TO_LEFT;this.getContentRect=f;this.moveToFilteredStep=function(a,d,m){function g(a,b){b.process(v,k,x)&&(a=!0,!t&&b.token&&(t=b.token));return a}var e=d===b,c,l,k,x,t,y=a.snapshot();c=!1;var v;do c=f(a),v={token:a.snapshot(),container:a.container,offset:a.offset,direction:d,visualDirection:d===b?h:p},l=a.nextStep()?f(a):null,a.restore(v.token),
|
||
|
e?(k=c,x=l):(k=l,x=c),c=m.reduce(g,!1);while(!c&&a.advanceStep(d));c||m.forEach(function(a){!t&&a.token&&(t=a.token)});a.restore(t||y);return Boolean(t)}};gui.Caret=function(f,l,a,d){function b(){g.style.opacity="0"===g.style.opacity?"1":"0";w.trigger()}function h(){k.selectNodeContents(r);return k.getBoundingClientRect()}function p(){Object.keys(B).forEach(function(a){F[a]=B[a]})}function q(){if(!1===B.isShown||f.getSelectionType()!==ops.OdtCursor.RangeSelection||!d&&!f.getSelectedRange().collapsed)B.visibility="hidden",g.style.visibility="hidden",w.cancel();else if(B.visibility="visible",g.style.visibility="visible",!1===B.isFocused)g.style.opacity=
|
||
|
"1",w.cancel();else{if(u||F.visibility!==B.visibility)g.style.opacity="1",w.cancel();w.trigger()}if(E||A){var a;a=f.getNode();var b,k,n=t.getBoundingClientRect(x.getSizer()),r=!1,q=0;a.removeAttributeNS("urn:webodf:names:cursor","caret-sizer-active");if(0<a.getClientRects().length)k=h(),q=k.left-t.getBoundingClientRect(a).left,r=!0;else if(v.setPosition(a,0),k=y.getContentRect(v),!k&&v.nextStep()&&(b=y.getContentRect(v))&&(k=b,r=!0),k||(a.setAttributeNS("urn:webodf:names:cursor","caret-sizer-active",
|
||
|
"true"),k=h(),r=!0),!k)for(runtime.log("WARN: No suitable client rectangle found for visual caret for "+f.getMemberId());a;){if(0<a.getClientRects().length){k=t.getBoundingClientRect(a);r=!0;break}a=a.parentNode}k=t.translateRect(k,n,x.getZoomLevel());a={top:k.top,height:k.height,right:r?k.left:k.right,width:t.adaptRangeDifferenceToZoomLevel(q,x.getZoomLevel())};8>a.height&&(a={top:a.top-(8-a.height)/2,height:8,right:a.right});m.style.height=a.height+"px";m.style.top=a.top+"px";m.style.left=a.right-
|
||
|
a.width+"px";m.style.width=a.width?a.width+"px":"";c&&(a=runtime.getWindow().getComputedStyle(f.getNode(),null),a.font?c.style.font=a.font:(c.style.fontStyle=a.fontStyle,c.style.fontVariant=a.fontVariant,c.style.fontWeight=a.fontWeight,c.style.fontSize=a.fontSize,c.style.lineHeight=a.lineHeight,c.style.fontFamily=a.fontFamily))}B.isShown&&A&&l.scrollIntoView(g.getBoundingClientRect());F.isFocused!==B.isFocused&&e.markAsFocussed(B.isFocused);p();E=A=u=!1}function n(a){m.parentNode.removeChild(m);r.parentNode.removeChild(r);
|
||
|
a()}var m,g,e,c,r,k,x=f.getDocument().getCanvas(),t=core.DomUtils,y=new gui.GuiStepUtils,v,s,w,u=!1,A=!1,E=!1,B={isFocused:!1,isShown:!0,visibility:"hidden"},F={isFocused:!B.isFocused,isShown:!B.isShown,visibility:"hidden"};this.handleUpdate=function(){E=!0;s.trigger()};this.refreshCursorBlinking=function(){u=!0;s.trigger()};this.setFocus=function(){B.isFocused=!0;s.trigger()};this.removeFocus=function(){B.isFocused=!1;s.trigger()};this.show=function(){B.isShown=!0;s.trigger()};this.hide=function(){B.isShown=
|
||
|
!1;s.trigger()};this.setAvatarImageUrl=function(a){e.setImageUrl(a)};this.setColor=function(a){g.style.borderColor=a;e.setColor(a)};this.getCursor=function(){return f};this.getFocusElement=function(){return g};this.toggleHandleVisibility=function(){e.isVisible()?e.hide():e.show()};this.showHandle=function(){e.show()};this.hideHandle=function(){e.hide()};this.setOverlayElement=function(a){c=a;m.appendChild(a);E=!0;s.trigger()};this.ensureVisible=function(){A=!0;s.trigger()};this.getBoundingClientRect=
|
||
|
function(){return t.getBoundingClientRect(m)};this.destroy=function(a){core.Async.destroyAll([s.destroy,w.destroy,e.destroy,n],a)};(function(){var c=f.getDocument(),d=[c.createRootFilter(f.getMemberId()),c.getPositionFilter()],h=c.getDOMDocument();k=h.createRange();r=h.createElement("span");r.className="webodf-caretSizer";r.textContent="|";f.getNode().appendChild(r);m=h.createElement("div");m.setAttributeNS("urn:webodf:names:editinfo","editinfo:memberid",f.getMemberId());m.className="webodf-caretOverlay";
|
||
|
g=h.createElement("div");g.className="caret";m.appendChild(g);e=new gui.Avatar(m,a);x.getSizer().appendChild(m);v=c.createStepIterator(f.getNode(),0,d,c.getRootNode());s=core.Task.createRedrawTask(q);w=core.Task.createTimeoutTask(b,500);s.triggerImmediate()})()};odf.TextSerializer=function(){function f(d){var b="",h=l.filter?l.filter.acceptNode(d):NodeFilter.FILTER_ACCEPT,p=d.nodeType,q;if((h===NodeFilter.FILTER_ACCEPT||h===NodeFilter.FILTER_SKIP)&&a.isTextContentContainingNode(d))for(q=d.firstChild;q;)b+=f(q),q=q.nextSibling;h===NodeFilter.FILTER_ACCEPT&&(p===Node.ELEMENT_NODE&&a.isParagraph(d)?b+="\n":p===Node.TEXT_NODE&&d.textContent&&(b+=d.textContent));return b}var l=this,a=odf.OdfUtils;this.filter=null;this.writeToString=function(a){if(!a)return"";
|
||
|
a=f(a);"\n"===a[a.length-1]&&(a=a.substr(0,a.length-1));return a}};gui.MimeDataExporter=function(){var f;this.exportRangeToDataTransfer=function(l,a){var d;d=a.startContainer.ownerDocument.createElement("span");d.appendChild(a.cloneContents());d=f.writeToString(d);try{l.setData("text/plain",d)}catch(b){l.setData("Text",d)}};f=new odf.TextSerializer;f.filter=new odf.OdfNodeFilter};gui.Clipboard=function(f){this.setDataFromRange=function(l,a){var d,b=l.clipboardData;d=runtime.getWindow();!b&&d&&(b=d.clipboardData);b?(d=!0,f.exportRangeToDataTransfer(b,a),l.preventDefault()):d=!1;return d}};gui.SessionContext=function(f,l){var a=f.getOdtDocument(),d=odf.OdfUtils;this.isLocalCursorWithinOwnAnnotation=function(){var b=a.getCursor(l),f;if(!b)return!1;f=b&&b.getNode();b=a.getMember(l).getProperties().fullName;return(f=d.getParentAnnotation(f,a.getRootNode()))&&d.getAnnotationCreator(f)===b?!0:!1}};gui.StyleSummary=function(f){function l(a,d){var l=a+"|"+d,n;b.hasOwnProperty(l)||(n=[],f.forEach(function(b){b=(b=b.styleProperties[a])&&b[d];-1===n.indexOf(b)&&n.push(b)}),b[l]=n);return b[l]}function a(a,b,d){return function(){var f=l(a,b);return d.length>=f.length&&f.every(function(a){return-1!==d.indexOf(a)})}}function d(a,b){var d=l(a,b);return 1===d.length?d[0]:void 0}var b={};this.getPropertyValues=l;this.getCommonValue=d;this.isBold=a("style:text-properties","fo:font-weight",["bold"]);this.isItalic=
|
||
|
a("style:text-properties","fo:font-style",["italic"]);this.hasUnderline=a("style:text-properties","style:text-underline-style",["solid"]);this.hasStrikeThrough=a("style:text-properties","style:text-line-through-style",["solid"]);this.fontSize=function(){var a=d("style:text-properties","fo:font-size");return a&&parseFloat(a)};this.fontName=function(){return d("style:text-properties","style:font-name")};this.isAlignedLeft=a("style:paragraph-properties","fo:text-align",["left","start"]);this.isAlignedCenter=
|
||
|
a("style:paragraph-properties","fo:text-align",["center"]);this.isAlignedRight=a("style:paragraph-properties","fo:text-align",["right","end"]);this.isAlignedJustified=a("style:paragraph-properties","fo:text-align",["justify"]);this.text={isBold:this.isBold,isItalic:this.isItalic,hasUnderline:this.hasUnderline,hasStrikeThrough:this.hasStrikeThrough,fontSize:this.fontSize,fontName:this.fontName};this.paragraph={isAlignedLeft:this.isAlignedLeft,isAlignedCenter:this.isAlignedCenter,isAlignedRight:this.isAlignedRight,
|
||
|
isAlignedJustified:this.isAlignedJustified}};gui.DirectFormattingController=function(f,l,a,d,b,h,p){function q(){return V.value().styleSummary}function n(){return V.value().enabledFeatures}function m(a){var b;a.collapsed?(b=a.startContainer,b.hasChildNodes()&&a.startOffset<b.childNodes.length&&(b=b.childNodes.item(a.startOffset)),a=[b]):a=ba.getTextElements(a,!0,!1);return a}function g(){var b=I.getCursor(d),c=b&&b.getSelectedRange(),e=[],e=[],f=!0,k={directTextStyling:!0,directParagraphStyling:!0};c&&(e=m(c),0===e.length&&(e=[c.startContainer,
|
||
|
c.endContainer],f=!1),e=I.getFormatting().getAppliedStyles(e));void 0!==e[0]&&Z&&(e[0].styleProperties=G.mergeObjects(e[0].styleProperties,Z));!0===l.getState(gui.CommonConstraints.EDIT.REVIEW_MODE)&&(k.directTextStyling=k.directParagraphStyling=a.isLocalCursorWithinOwnAnnotation());k.directTextStyling&&(k.directTextStyling=f&&void 0!==b&&b.getSelectionType()===ops.OdtCursor.RangeSelection);return{enabledFeatures:k,appliedStyles:e,styleSummary:new gui.StyleSummary(e)}}function e(a,b){var c={};Object.keys(a).forEach(function(e){var d=
|
||
|
a[e](),f=b[e]();d!==f&&(c[e]=f)});return c}function c(){var a,b;b=C.styleSummary;var c=V.value(),d=c.styleSummary,f=C.enabledFeatures,k=c.enabledFeatures;a=e(b.text,d.text);b=e(b.paragraph,d.paragraph);f=!(k.directTextStyling===f.directTextStyling&&k.directParagraphStyling===f.directParagraphStyling);C=c;f&&T.emit(gui.DirectFormattingController.enabledChanged,k);0<Object.keys(a).length&&T.emit(gui.DirectFormattingController.textStylingChanged,a);0<Object.keys(b).length&&T.emit(gui.DirectFormattingController.paragraphStylingChanged,
|
||
|
b)}function r(){V.reset();c()}function k(a){("string"===typeof a?a:a.getMemberId())===d&&V.reset()}function x(){V.reset()}function t(a){var b=I.getCursor(d);a=a.paragraphElement;b&&ba.getParagraphElement(b.getNode())===a&&V.reset()}function y(a,b){b(!a());return!0}function v(a){if(n().directTextStyling){var b=I.getCursorSelection(d),c={"style:text-properties":a};0!==b.length?(a=new ops.OpApplyDirectStyling,a.init({memberid:d,position:b.position,length:b.length,setProperties:c}),f.enqueue([a])):(Z=
|
||
|
G.mergeObjects(Z||{},c),V.reset())}}function s(a,b){var c={};c[a]=b;v(c)}function w(a){a=a.spec();Z&&a.memberid===d&&"SplitParagraph"!==a.optype&&(Z=null,V.reset())}function u(a){s("fo:font-weight",a?"bold":"normal")}function A(a){s("fo:font-style",a?"italic":"normal")}function E(a){s("style:text-underline-style",a?"solid":"none")}function B(a){s("style:text-line-through-style",a?"solid":"none")}function F(a){if(n().directParagraphStyling){var c=I.getCursor(d).getSelectedRange(),c=ba.getParagraphElements(c),
|
||
|
e=I.getFormatting(),k=[],g={},h;c.forEach(function(c){var f=I.convertDomPointToCursorStep(c,0,P),m=c.getAttributeNS(odf.Namespaces.textns,"style-name"),l;c=m?g.hasOwnProperty(m)?g[m]:void 0:h;c||(c=b.generateStyleName(),m?(g[m]=c,l=e.createDerivedStyleObject(m,"paragraph",{})):(h=c,l={}),l=a(l),m=new ops.OpAddStyle,m.init({memberid:d,styleName:c.toString(),styleFamily:"paragraph",isAutomaticStyle:!0,setProperties:l}),k.push(m));m=new ops.OpSetParagraphStyle;m.init({memberid:d,styleName:c.toString(),
|
||
|
position:f});k.push(m)});f.enqueue(k)}}function J(a){F(function(b){return G.mergeObjects(b,a)})}function H(a){J({"style:paragraph-properties":{"fo:text-align":a}})}function Q(a,b){var c=I.getFormatting().getDefaultTabStopDistance(),e=b["style:paragraph-properties"],d;e&&(e=e["fo:margin-left"],d=ba.parseLength(e));return G.mergeObjects(b,{"style:paragraph-properties":{"fo:margin-left":d&&d.unit===c.unit?d.value+a*c.value+d.unit:a*c.value+c.unit}})}function N(a,b){var c=m(a),c=0===c.length?[a.startContainer]:
|
||
|
c,c=I.getFormatting().getAppliedStyles(c),e=0<c.length?c[0].styleProperties:void 0,d=I.getFormatting().getAppliedStylesForElement(b).styleProperties;if(!e||"text"!==e["style:family"]||!e["style:text-properties"])return!1;if(!d||!d["style:text-properties"])return!0;e=e["style:text-properties"];d=d["style:text-properties"];return!Object.keys(e).every(function(a){return e[a]===d[a]})}function z(){}function Y(){return!1}var R=this,I=f.getOdtDocument(),G=new core.Utils,ba=odf.OdfUtils,T=new core.EventNotifier([gui.DirectFormattingController.enabledChanged,
|
||
|
gui.DirectFormattingController.textStylingChanged,gui.DirectFormattingController.paragraphStylingChanged]),D=odf.Namespaces.textns,P=core.StepDirection.NEXT,Z=null,C,V;this.enabledFeatures=n;this.formatTextSelection=v;this.createCursorStyleOp=function(a,b,c){var e=null,f=Z;c&&(f=(c=V.value().appliedStyles[0])&&c.styleProperties);f&&f["style:text-properties"]&&(e=new ops.OpApplyDirectStyling,e.init({memberid:d,position:a,length:b,setProperties:{"style:text-properties":f["style:text-properties"]}}),
|
||
|
Z=null,V.reset());return e};this.setBold=u;this.setItalic=A;this.setHasUnderline=E;this.setHasStrikethrough=B;this.setFontSize=function(a){s("fo:font-size",a+"pt")};this.setFontName=function(a){s("style:font-name",a)};this.getAppliedStyles=function(){return V.value().appliedStyles};this.toggleBold=y.bind(R,function(){return q().isBold()},u);this.toggleItalic=y.bind(R,function(){return q().isItalic()},A);this.toggleUnderline=y.bind(R,function(){return q().hasUnderline()},E);this.toggleStrikethrough=
|
||
|
y.bind(R,function(){return q().hasStrikeThrough()},B);this.isBold=function(){return q().isBold()};this.isItalic=function(){return q().isItalic()};this.hasUnderline=function(){return q().hasUnderline()};this.hasStrikeThrough=function(){return q().hasStrikeThrough()};this.fontSize=function(){return q().fontSize()};this.fontName=function(){return q().fontName()};this.isAlignedLeft=function(){return q().isAlignedLeft()};this.isAlignedCenter=function(){return q().isAlignedCenter()};this.isAlignedRight=
|
||
|
function(){return q().isAlignedRight()};this.isAlignedJustified=function(){return q().isAlignedJustified()};this.alignParagraphLeft=function(){H("left");return!0};this.alignParagraphCenter=function(){H("center");return!0};this.alignParagraphRight=function(){H("right");return!0};this.alignParagraphJustified=function(){H("justify");return!0};this.indent=function(){F(Q.bind(null,1));return!0};this.outdent=function(){F(Q.bind(null,-1));return!0};this.createParagraphStyleOps=function(a){if(!n().directParagraphStyling)return[];
|
||
|
var c=I.getCursor(d),e=c.getSelectedRange(),f=[],k,g;c.hasForwardSelection()?(k=c.getAnchorNode(),g=c.getNode()):(k=c.getNode(),g=c.getAnchorNode());c=ba.getParagraphElement(g);runtime.assert(Boolean(c),"DirectFormattingController: Cursor outside paragraph");var h=c,m=[I.getPositionFilter(),I.createRootFilter(d)];if(!1!==I.createStepIterator(e.endContainer,e.endOffset,m,h).nextStep())return f;g!==k&&(c=ba.getParagraphElement(k));if(!Z&&!N(e,c))return f;e=(e=V.value().appliedStyles[0])&&e.styleProperties;
|
||
|
if(!e)return f;if(c=c.getAttributeNS(D,"style-name"))e={"style:text-properties":e["style:text-properties"]},e=I.getFormatting().createDerivedStyleObject(c,"paragraph",e);k=b.generateStyleName();c=new ops.OpAddStyle;c.init({memberid:d,styleName:k,styleFamily:"paragraph",isAutomaticStyle:!0,setProperties:e});f.push(c);c=new ops.OpSetParagraphStyle;c.init({memberid:d,styleName:k,position:a});f.push(c);return f};this.subscribe=function(a,b){T.subscribe(a,b)};this.unsubscribe=function(a,b){T.unsubscribe(a,
|
||
|
b)};this.destroy=function(a){I.unsubscribe(ops.Document.signalCursorAdded,k);I.unsubscribe(ops.Document.signalCursorRemoved,k);I.unsubscribe(ops.Document.signalCursorMoved,k);I.unsubscribe(ops.OdtDocument.signalParagraphStyleModified,x);I.unsubscribe(ops.OdtDocument.signalParagraphChanged,t);I.unsubscribe(ops.OdtDocument.signalOperationEnd,w);I.unsubscribe(ops.OdtDocument.signalProcessingBatchEnd,c);l.unsubscribe(gui.CommonConstraints.EDIT.REVIEW_MODE,r);a()};(function(){I.subscribe(ops.Document.signalCursorAdded,
|
||
|
k);I.subscribe(ops.Document.signalCursorRemoved,k);I.subscribe(ops.Document.signalCursorMoved,k);I.subscribe(ops.OdtDocument.signalParagraphStyleModified,x);I.subscribe(ops.OdtDocument.signalParagraphChanged,t);I.subscribe(ops.OdtDocument.signalOperationEnd,w);I.subscribe(ops.OdtDocument.signalProcessingBatchEnd,c);l.subscribe(gui.CommonConstraints.EDIT.REVIEW_MODE,r);V=new core.LazyProperty(g);C=V.value();h||(R.formatTextSelection=z,R.setBold=z,R.setItalic=z,R.setHasUnderline=z,R.setHasStrikethrough=
|
||
|
z,R.setFontSize=z,R.setFontName=z,R.toggleBold=Y,R.toggleItalic=Y,R.toggleUnderline=Y,R.toggleStrikethrough=Y);p||(R.alignParagraphCenter=z,R.alignParagraphJustified=z,R.alignParagraphLeft=z,R.alignParagraphRight=z,R.createParagraphStyleOps=function(){return[]},R.indent=z,R.outdent=z)})()};gui.DirectFormattingController.enabledChanged="enabled/changed";gui.DirectFormattingController.textStylingChanged="textStyling/changed";gui.DirectFormattingController.paragraphStylingChanged="paragraphStyling/changed";
|
||
|
gui.DirectFormattingController.SelectionInfo=function(){};gui.KeyboardHandler=function(){function f(a,d){d||(d=l.None);switch(a){case gui.KeyboardHandler.KeyCode.LeftMeta:case gui.KeyboardHandler.KeyCode.RightMeta:case gui.KeyboardHandler.KeyCode.MetaInMozilla:d|=l.Meta;break;case gui.KeyboardHandler.KeyCode.Ctrl:d|=l.Ctrl;break;case gui.KeyboardHandler.KeyCode.Alt:d|=l.Alt;break;case gui.KeyboardHandler.KeyCode.Shift:d|=l.Shift}return a+":"+d}var l=gui.KeyboardHandler.Modifier,a=null,d={};this.setDefault=function(b){a=b};this.bind=function(a,h,l,q){a=f(a,
|
||
|
h);runtime.assert(q||!1===d.hasOwnProperty(a),"tried to overwrite the callback handler of key combo: "+a);d[a]=l};this.unbind=function(a,h){var l=f(a,h);delete d[l]};this.reset=function(){a=null;d={}};this.handleEvent=function(b){var h=b.keyCode,p=l.None;b.metaKey&&(p|=l.Meta);b.ctrlKey&&(p|=l.Ctrl);b.altKey&&(p|=l.Alt);b.shiftKey&&(p|=l.Shift);h=f(h,p);h=d[h];p=!1;h?p=h():null!==a&&(p=a(b));p&&(b.preventDefault?b.preventDefault():b.returnValue=!1)}};
|
||
|
gui.KeyboardHandler.Modifier={None:0,Meta:1,Ctrl:2,Alt:4,CtrlAlt:6,Shift:8,MetaShift:9,CtrlShift:10,AltShift:12};gui.KeyboardHandler.KeyCode={Backspace:8,Tab:9,Clear:12,Enter:13,Shift:16,Ctrl:17,Alt:18,End:35,Home:36,Left:37,Up:38,Right:39,Down:40,Delete:46,A:65,B:66,C:67,D:68,E:69,F:70,G:71,H:72,I:73,J:74,K:75,L:76,M:77,N:78,O:79,P:80,Q:81,R:82,S:83,T:84,U:85,V:86,W:87,X:88,Y:89,Z:90,LeftMeta:91,RightMeta:93,MetaInMozilla:224};gui.HyperlinkClickHandler=function(f,l,a){function d(){var a=f();runtime.assert(Boolean(a.classList),"Document container has no classList element");a.classList.remove("webodf-inactiveLinks")}function b(){var a=f();runtime.assert(Boolean(a.classList),"Document container has no classList element");a.classList.add("webodf-inactiveLinks")}function h(){e.removeEventListener("focus",b,!1);r.forEach(function(c){l.unbind(c.keyCode,c.modifier);a.unbind(c.keyCode,c.modifier)});r.length=0}function p(c){h();
|
||
|
if(c!==q.None){e.addEventListener("focus",b,!1);switch(c){case q.Ctrl:r.push({keyCode:n.Ctrl,modifier:q.None});break;case q.Meta:r.push({keyCode:n.LeftMeta,modifier:q.None}),r.push({keyCode:n.RightMeta,modifier:q.None}),r.push({keyCode:n.MetaInMozilla,modifier:q.None})}r.forEach(function(c){l.bind(c.keyCode,c.modifier,d);a.bind(c.keyCode,c.modifier,b)})}}var q=gui.KeyboardHandler.Modifier,n=gui.KeyboardHandler.KeyCode,m=xmldom.XPath,g=odf.OdfUtils,e=runtime.getWindow(),c=q.None,r=[];runtime.assert(null!==
|
||
|
e,"Expected to be run in an environment which has a global window, like a browser.");this.handleClick=function(a){var b=a.target||a.srcElement,d,h;a.ctrlKey?d=q.Ctrl:a.metaKey&&(d=q.Meta);if(c===q.None||c===d){a:{for(;null!==b;){if(g.isHyperlink(b))break a;if(g.isParagraph(b))break;b=b.parentNode}b=null}b&&(b=g.getHyperlinkTarget(b),""!==b&&("#"===b[0]?(b=b.substring(1),d=f(),h=m.getODFElementsWithXPath(d,"//text:bookmark-start[@text:name='"+b+"']",odf.Namespaces.lookupNamespaceURI),0===h.length&&
|
||
|
(h=m.getODFElementsWithXPath(d,"//text:bookmark[@text:name='"+b+"']",odf.Namespaces.lookupNamespaceURI)),0<h.length&&h[0].scrollIntoView(!0)):/^\s*(javascript|data):/.test(b)?runtime.log("WARN:","potentially malicious URL ignored"):e.open(b),a.preventDefault?a.preventDefault():a.returnValue=!1))}};this.setModifier=function(a){c!==a&&(runtime.assert(a===q.None||a===q.Ctrl||a===q.Meta,"Unsupported KeyboardHandler.Modifier value: "+a),c=a,c!==q.None?b():d(),p(c))};this.getModifier=function(){return c};
|
||
|
this.destroy=function(a){b();h();a()}};gui.EventManager=function(f){function l(a){function b(a,c,e){var d,f=!1;d="on"+c;a.attachEvent&&(a.attachEvent(d,e),f=!0);!f&&a.addEventListener&&(a.addEventListener(c,e,!1),f=!0);f&&!w[c]||!a.hasOwnProperty(d)||(a[d]=e)}function c(a,b,e){var d="on"+b;a.detachEvent&&a.detachEvent(d,e);a.removeEventListener&&a.removeEventListener(b,e,!1);a[d]===e&&(a[d]=null)}function e(b){if(-1===f.indexOf(b)){f.push(b);if(d.filters.every(function(a){return a(b)}))try{g.emit(a,b)}catch(c){runtime.log("Error occurred while processing "+
|
||
|
a+":\n"+c.message+"\n"+c.stack)}runtime.setTimeout(function(){f.splice(f.indexOf(b),1)},0)}}var d=this,f=[],g=new core.EventNotifier([a]);this.filters=[];this.subscribe=function(b){g.subscribe(a,b)};this.unsubscribe=function(b){g.unsubscribe(a,b)};this.destroy=function(){c(s,a,e);c(B,a,e);c(F,a,e)};u[a]&&b(s,a,e);b(B,a,e);b(F,a,e)}function a(a,b,c){function e(b){c(b,d,function(b){b.type=a;f.emit(a,b)})}var d={},f=new core.EventNotifier([a]);this.subscribe=function(b){f.subscribe(a,b)};this.unsubscribe=
|
||
|
function(b){f.unsubscribe(a,b)};this.destroy=function(){b.forEach(function(a){J.unsubscribe(a,e)})};(function(){b.forEach(function(a){J.subscribe(a,e)})})()}function d(a){runtime.clearTimeout(a);delete H[a]}function b(a,b){var c=runtime.setTimeout(function(){a();d(c)},b);H[c]=!0;return c}function h(a,c,e){var f=a.touches.length,g=a.touches[0],k=c.timer;"touchmove"===a.type||"touchend"===a.type?k&&d(k):"touchstart"===a.type&&(1!==f?runtime.clearTimeout(k):k=b(function(){e({clientX:g.clientX,clientY:g.clientY,
|
||
|
pageX:g.pageX,pageY:g.pageY,target:a.target||a.srcElement||null,detail:1})},400));c.timer=k}function p(a,b,c){var e=a.touches[0],d=a.target||a.srcElement||null,f=b.target;1!==a.touches.length||"touchend"===a.type?f=null:"touchstart"===a.type&&"webodf-draggable"===d.getAttribute("class")?f=d:"touchmove"===a.type&&f&&(a.preventDefault(),a.stopPropagation(),c({clientX:e.clientX,clientY:e.clientY,pageX:e.pageX,pageY:e.pageY,target:f,detail:1}));b.target=f}function q(a,b,c){var e=a.target||a.srcElement||
|
||
|
null,d=b.dragging;"drag"===a.type?d=!0:"touchend"===a.type&&d&&(d=!1,a=a.changedTouches[0],c({clientX:a.clientX,clientY:a.clientY,pageX:a.pageX,pageY:a.pageY,target:e,detail:1}));b.dragging=d}function n(){F.classList.add("webodf-touchEnabled");J.unsubscribe("touchstart",n)}function m(a){var b=a.scrollX,c=a.scrollY;this.restore=function(){a.scrollX===b&&a.scrollY===c||a.scrollTo(b,c)}}function g(a){var b=a.scrollTop,c=a.scrollLeft;this.restore=function(){if(a.scrollTop!==b||a.scrollLeft!==c)a.scrollTop=
|
||
|
b,a.scrollLeft=c}}function e(a,b){var c=E[a]||A[a]||null;!c&&b&&(c=E[a]=new l(a));return c}function c(a,b){e(a,!0).subscribe(b)}function r(a,b){var c=e(a,!1);c&&c.unsubscribe(b)}function k(){return f.getDOMDocument().activeElement===B}function x(){k()&&B.blur();B.setAttribute("disabled","true")}function t(){B.removeAttribute("disabled")}function y(a){for(var b=[];a;)(a.scrollWidth>a.clientWidth||a.scrollHeight>a.clientHeight)&&b.push(new g(a)),a=a.parentNode;b.push(new m(s));return b}function v(){var a;
|
||
|
k()||(a=y(B),t(),B.focus(),a.forEach(function(a){a.restore()}))}var s=runtime.getWindow(),w={beforecut:!0,beforepaste:!0,longpress:!0,drag:!0,dragstop:!0},u={mousedown:!0,mouseup:!0,focus:!0},A={},E={},B,F=f.getCanvas().getElement(),J=this,H={};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=c;this.unsubscribe=r;this.hasFocus=k;this.focus=v;this.getEventTrap=function(){return B};
|
||
|
this.setEditing=function(a){var b=k();b&&B.blur();a?B.removeAttribute("readOnly"):B.setAttribute("readOnly","true");b&&v()};this.destroy=function(a){r("touchstart",n);Object.keys(H).forEach(function(a){d(parseInt(a,10))});H.length=0;Object.keys(A).forEach(function(a){A[a].destroy()});A={};r("mousedown",x);r("mouseup",t);r("contextmenu",t);Object.keys(E).forEach(function(a){E[a].destroy()});E={};B.parentNode.removeChild(B);a()};(function(){var b=f.getOdfCanvas().getSizer(),e=b.ownerDocument;runtime.assert(Boolean(s),
|
||
|
"EventManager requires a window object to operate correctly");B=e.createElement("textarea");B.id="eventTrap";B.setAttribute("tabindex","-1");B.setAttribute("readOnly","true");B.setAttribute("rows","1");b.appendChild(B);c("mousedown",x);c("mouseup",t);c("contextmenu",t);A.longpress=new a("longpress",["touchstart","touchmove","touchend"],h);A.drag=new a("drag",["touchstart","touchmove","touchend"],p);A.dragstop=new a("dragstop",["drag","touchend"],q);c("touchstart",n)})()};gui.IOSSafariSupport=function(f){function l(){a.innerHeight!==a.outerHeight&&(d.style.display="none",runtime.requestAnimationFrame(function(){d.style.display="block"}))}var a=runtime.getWindow(),d=f.getEventTrap();this.destroy=function(a){f.unsubscribe("focus",l);d.removeAttribute("autocapitalize");d.style.WebkitTransform="";a()};f.subscribe("focus",l);d.setAttribute("autocapitalize","off");d.style.WebkitTransform="translateX(-10000px)"};gui.HyperlinkController=function(f,l,a,d){function b(){var b=!0;!0===l.getState(gui.CommonConstraints.EDIT.REVIEW_MODE)&&(b=a.isLocalCursorWithinOwnAnnotation());b!==m&&(m=b,n.emit(gui.HyperlinkController.enabledChanged,m))}function h(a){a.getMemberId()===d&&b()}var p=odf.OdfUtils,q=f.getOdtDocument(),n=new core.EventNotifier([gui.HyperlinkController.enabledChanged]),m=!1;this.isEnabled=function(){return m};this.subscribe=function(a,b){n.subscribe(a,b)};this.unsubscribe=function(a,b){n.unsubscribe(a,
|
||
|
b)};this.addHyperlink=function(a,b){if(m){var c=q.getCursorSelection(d),h=new ops.OpApplyHyperlink,k=[];if(0===c.length||b)b=b||a,h=new ops.OpInsertText,h.init({memberid:d,position:c.position,text:b}),c.length=b.length,k.push(h);h=new ops.OpApplyHyperlink;h.init({memberid:d,position:c.position,length:c.length,hyperlink:a});k.push(h);f.enqueue(k)}};this.removeHyperlinks=function(){if(m){var a=q.createPositionIterator(q.getRootNode()),b=q.getCursor(d).getSelectedRange(),c=p.getHyperlinkElements(b),
|
||
|
h=b.collapsed&&1===c.length,k=q.getDOMDocument().createRange(),l=[],n,y;0!==c.length&&(c.forEach(function(a){k.selectNodeContents(a);n=q.convertDomToCursorRange({anchorNode:k.startContainer,anchorOffset:k.startOffset,focusNode:k.endContainer,focusOffset:k.endOffset});y=new ops.OpRemoveHyperlink;y.init({memberid:d,position:n.position,length:n.length});l.push(y)}),h||(h=c[0],-1===b.comparePoint(h,0)&&(k.setStart(h,0),k.setEnd(b.startContainer,b.startOffset),n=q.convertDomToCursorRange({anchorNode:k.startContainer,
|
||
|
anchorOffset:k.startOffset,focusNode:k.endContainer,focusOffset:k.endOffset}),0<n.length&&(y=new ops.OpApplyHyperlink,y.init({memberid:d,position:n.position,length:n.length,hyperlink:p.getHyperlinkTarget(h)}),l.push(y))),c=c[c.length-1],a.moveToEndOfNode(c),a=a.unfilteredDomOffset(),1===b.comparePoint(c,a)&&(k.setStart(b.endContainer,b.endOffset),k.setEnd(c,a),n=q.convertDomToCursorRange({anchorNode:k.startContainer,anchorOffset:k.startOffset,focusNode:k.endContainer,focusOffset:k.endOffset}),0<n.length&&
|
||
|
(y=new ops.OpApplyHyperlink,y.init({memberid:d,position:n.position,length:n.length,hyperlink:p.getHyperlinkTarget(c)}),l.push(y)))),f.enqueue(l),k.detach())}};this.destroy=function(a){q.unsubscribe(ops.Document.signalCursorMoved,h);l.unsubscribe(gui.CommonConstraints.EDIT.REVIEW_MODE,b);a()};q.subscribe(ops.Document.signalCursorMoved,h);l.subscribe(gui.CommonConstraints.EDIT.REVIEW_MODE,b);b()};gui.HyperlinkController.enabledChanged="enabled/changed";gui.ImageController=function(f,l,a,d,b){function h(){var b=!0;!0===l.getState(gui.CommonConstraints.EDIT.REVIEW_MODE)&&(b=a.isLocalCursorWithinOwnAnnotation());b!==r&&(r=b,c.emit(gui.ImageController.enabledChanged,r))}function p(a){a.getMemberId()===d&&h()}var q={"image/gif":".gif","image/jpeg":".jpg","image/png":".png"},n=odf.Namespaces.textns,m=f.getOdtDocument(),g=odf.OdfUtils,e=m.getFormatting(),c=new core.EventNotifier([gui.HyperlinkController.enabledChanged]),r=!1;this.isEnabled=function(){return r};
|
||
|
this.subscribe=function(a,b){c.subscribe(a,b)};this.unsubscribe=function(a,b){c.unsubscribe(a,b)};this.insertImage=function(a,c,h,l){if(r){runtime.assert(0<h&&0<l,"Both width and height of the image should be greater than 0px.");l={width:h,height:l};if(h=g.getParagraphElement(m.getCursor(d).getNode()).getAttributeNS(n,"style-name")){h=e.getContentSize(h,"paragraph");var p=1,s=1;l.width>h.width&&(p=h.width/l.width);l.height>h.height&&(s=h.height/l.height);h=Math.min(p,s);l={width:l.width*h,height:l.height*
|
||
|
h}}h=l.width+"px";l=l.height+"px";var w=m.getOdfCanvas().odfContainer().rootElement.styles,p=a.toLowerCase(),s=q.hasOwnProperty(p)?q[p]:null,u,p=[];runtime.assert(null!==s,"Image type is not supported: "+a);s="Pictures/"+b.generateImageName()+s;u=new ops.OpSetBlob;u.init({memberid:d,filename:s,mimetype:a,content:c});p.push(u);e.getStyleElement("Graphics","graphic",[w])||(a=new ops.OpAddStyle,a.init({memberid:d,styleName:"Graphics",styleFamily:"graphic",isAutomaticStyle:!1,setProperties:{"style:graphic-properties":{"text:anchor-type":"paragraph",
|
||
|
"svg:x":"0cm","svg:y":"0cm","style:wrap":"dynamic","style:number-wrapped-paragraphs":"no-limit","style:wrap-contour":"false","style:vertical-pos":"top","style:vertical-rel":"paragraph","style:horizontal-pos":"center","style:horizontal-rel":"paragraph"}}}),p.push(a));a=b.generateStyleName();c=new ops.OpAddStyle;c.init({memberid:d,styleName:a,styleFamily:"graphic",isAutomaticStyle:!0,setProperties:{"style:parent-style-name":"Graphics","style:graphic-properties":{"style:vertical-pos":"top","style:vertical-rel":"baseline",
|
||
|
"style:horizontal-pos":"center","style:horizontal-rel":"paragraph","fo:background-color":"transparent","style:background-transparency":"100%","style:shadow":"none","style:mirror":"none","fo:clip":"rect(0cm, 0cm, 0cm, 0cm)","draw:luminance":"0%","draw:contrast":"0%","draw:red":"0%","draw:green":"0%","draw:blue":"0%","draw:gamma":"100%","draw:color-inversion":"false","draw:image-opacity":"100%","draw:color-mode":"standard"}}});p.push(c);u=new ops.OpInsertImage;u.init({memberid:d,position:m.getCursorPosition(d),
|
||
|
filename:s,frameWidth:h,frameHeight:l,frameStyleName:a,frameName:b.generateFrameName()});p.push(u);f.enqueue(p)}};this.destroy=function(a){m.unsubscribe(ops.Document.signalCursorMoved,p);l.unsubscribe(gui.CommonConstraints.EDIT.REVIEW_MODE,h);a()};m.subscribe(ops.Document.signalCursorMoved,p);l.subscribe(gui.CommonConstraints.EDIT.REVIEW_MODE,h);h()};gui.ImageController.enabledChanged="enabled/changed";gui.ImageSelector=function(f){function l(){var a=f.getSizer(),h=b.createElement("div");h.id="imageSelector";h.style.borderWidth="1px";a.appendChild(h);d.forEach(function(a){var d=b.createElement("div");d.className=a;h.appendChild(d)});return h}var a=odf.Namespaces.svgns,d="topLeft topRight bottomRight bottomLeft topMiddle rightMiddle bottomMiddle leftMiddle".split(" "),b=f.getElement().ownerDocument,h=!1;this.select=function(d){var q,n,m=b.getElementById("imageSelector");m||(m=l());h=!0;q=m.parentNode;
|
||
|
n=d.getBoundingClientRect();var g=q.getBoundingClientRect(),e=f.getZoomLevel();q=(n.left-g.left)/e-1;n=(n.top-g.top)/e-1;m.style.display="block";m.style.left=q+"px";m.style.top=n+"px";m.style.width=d.getAttributeNS(a,"width");m.style.height=d.getAttributeNS(a,"height")};this.clearSelection=function(){var a;h&&(a=b.getElementById("imageSelector"))&&(a.style.display="none");h=!1};this.isSelectorElement=function(a){var d=b.getElementById("imageSelector");return d?a===d||a.parentNode===d:!1}};(function(){function f(f){function a(a){p=a.which&&String.fromCharCode(a.which)===h;h=void 0;return!1===p}function d(){p=!1}function b(a){h=a.data;p=!1}var h,p=!1;this.destroy=function(h){f.unsubscribe("textInput",d);f.unsubscribe("compositionend",b);f.removeFilter("keypress",a);h()};f.subscribe("textInput",d);f.subscribe("compositionend",b);f.addFilter("keypress",a)}gui.InputMethodEditor=function(l,a){function d(a){c&&(a?c.getNode().setAttributeNS(e,"composing","true"):(c.getNode().removeAttributeNS(e,
|
||
|
"composing"),x.textContent=""))}function b(){y&&(y=!1,d(!1),s.emit(gui.InputMethodEditor.signalCompositionEnd,{data:v}),v="")}function h(){B||(B=!0,b(),c&&c.getSelectedRange().collapsed?r.value="":r.value=u.writeToString(c.getSelectedRange().cloneContents()),r.setSelectionRange(0,r.value.length),B=!1)}function p(){a.hasFocus()&&t.trigger()}function q(){w=void 0;t.cancel();d(!0);y||s.emit(gui.InputMethodEditor.signalCompositionStart,{data:""})}function n(a){a=w=a.data;y=!0;v+=a;t.trigger()}function m(a){a.data!==
|
||
|
w&&(a=a.data,y=!0,v+=a,t.trigger());w=void 0}function g(){x.textContent=r.value}var e="urn:webodf:names:cursor",c=null,r=a.getEventTrap(),k=r.ownerDocument,x,t,y=!1,v="",s=new core.EventNotifier([gui.InputMethodEditor.signalCompositionStart,gui.InputMethodEditor.signalCompositionEnd]),w,u,A=[],E,B=!1;this.subscribe=s.subscribe;this.unsubscribe=s.unsubscribe;this.registerCursor=function(b){b.getMemberId()===l&&(c=b,c.getNode().appendChild(x),b.subscribe(ops.OdtCursor.signalCursorUpdated,p),a.subscribe("input",
|
||
|
g),a.subscribe("compositionupdate",g))};this.removeCursor=function(b){c&&b===l&&(c.getNode().removeChild(x),c.unsubscribe(ops.OdtCursor.signalCursorUpdated,p),a.unsubscribe("input",g),a.unsubscribe("compositionupdate",g),c=null)};this.destroy=function(c){a.unsubscribe("compositionstart",q);a.unsubscribe("compositionend",n);a.unsubscribe("textInput",m);a.unsubscribe("keypress",b);a.unsubscribe("focus",h);core.Async.destroyAll(E,c)};(function(){u=new odf.TextSerializer;u.filter=new odf.OdfNodeFilter;
|
||
|
a.subscribe("compositionstart",q);a.subscribe("compositionend",n);a.subscribe("textInput",m);a.subscribe("keypress",b);a.subscribe("focus",h);A.push(new f(a));E=A.map(function(a){return a.destroy});x=k.createElement("span");x.setAttribute("id","composer");t=core.Task.createTimeoutTask(h,1);E.push(t.destroy)})()};gui.InputMethodEditor.signalCompositionStart="input/compositionstart";gui.InputMethodEditor.signalCompositionEnd="input/compositionend"})();gui.MetadataController=function(f,l){function a(a){h.emit(gui.MetadataController.signalMetadataChanged,a)}function d(a){var b=-1===p.indexOf(a);b||runtime.log("Setting "+a+" is restricted.");return b}var b=f.getOdtDocument(),h=new core.EventNotifier([gui.MetadataController.signalMetadataChanged]),p=["dc:creator","dc:date","meta:editing-cycles","meta:editing-duration","meta:document-statistic"];this.setMetadata=function(a,b){var h={},g="",e;a&&Object.keys(a).filter(d).forEach(function(b){h[b]=a[b]});
|
||
|
b&&(g=b.filter(d).join(","));if(0<g.length||0<Object.keys(h).length)e=new ops.OpUpdateMetadata,e.init({memberid:l,setProperties:h,removedProperties:0<g.length?{attributes:g}:null}),f.enqueue([e])};this.getMetadata=function(a){var d;runtime.assert("string"===typeof a,"Property must be a string");d=a.split(":");runtime.assert(2===d.length,"Property must be a namespace-prefixed string");a=odf.Namespaces.lookupNamespaceURI(d[0]);runtime.assert(Boolean(a),"Prefix must be for an ODF namespace.");return b.getOdfCanvas().odfContainer().getMetadata(a,
|
||
|
d[1])};this.subscribe=function(a,b){h.subscribe(a,b)};this.unsubscribe=function(a,b){h.unsubscribe(a,b)};this.destroy=function(d){b.unsubscribe(ops.OdtDocument.signalMetadataUpdated,a);d()};b.subscribe(ops.OdtDocument.signalMetadataUpdated,a)};gui.MetadataController.signalMetadataChanged="metadata/changed";gui.PasteController=function(f,l,a,d){function b(){q=!0===l.getState(gui.CommonConstraints.EDIT.REVIEW_MODE)?a.isLocalCursorWithinOwnAnnotation():!0}function h(a){a.getMemberId()===d&&b()}var p=f.getOdtDocument(),q=!1,n=odf.Namespaces.textns,m=core.StepDirection.NEXT,g=odf.OdfUtils;this.isEnabled=function(){return q};this.paste=function(a){if(q){var b=p.getCursorPosition(d),h=p.getCursor(d).getNode(),h=g.getParagraphElement(h),k=h.getAttributeNS(n,"style-name")||"",l=b,t=[],y=p.convertDomPointToCursorStep(h,
|
||
|
0,m);a.replace(/\r/g,"").split("\n").forEach(function(a){var b=new ops.OpInsertText,c=new ops.OpSplitParagraph;b.init({memberid:d,position:l,text:a,moveCursor:!0});t.push(b);l+=a.length;c.init({memberid:d,position:l,paragraphStyleName:k,sourceParagraphPosition:y,moveCursor:!0});t.push(c);y=l+=1});t.pop();f.enqueue(t)}};this.destroy=function(a){p.unsubscribe(ops.Document.signalCursorMoved,h);l.unsubscribe(gui.CommonConstraints.EDIT.REVIEW_MODE,b);a()};p.subscribe(ops.Document.signalCursorMoved,h);
|
||
|
l.subscribe(gui.CommonConstraints.EDIT.REVIEW_MODE,b);b()};gui.ClosestXOffsetScanner=function(f){function l(a){return null!==a&&void 0!==b?Math.abs(a-f)>b:!1}function a(a){null!==a&&!1===l(a)&&(b=Math.abs(a-f))}var d=this,b,h=gui.StepInfo.VisualDirection.LEFT_TO_RIGHT;this.token=void 0;this.process=function(b,f,n){var m,g;b.visualDirection===h?(m=f&&f.right,g=n&&n.left):(m=f&&f.left,g=n&&n.right);if(l(m)||l(g))return!0;if(f||n)a(m),a(g),d.token=b.token;return!1}};gui.LineBoundaryScanner=function(){var f=this,l=null;this.token=void 0;this.process=function(a,d,b){var h;if(h=b)if(l){var p=l;h=Math.min(p.bottom-p.top,b.bottom-b.top);var q=Math.max(p.top,b.top),p=Math.min(p.bottom,b.bottom)-q;h=0.4>=(0<h?p/h:0)}else h=!1;!d||b&&!h||(f.token=a.token);if(h)return!0;l=(a=l)&&d?{left:Math.min(a.left,d.left),right:Math.max(a.right,d.right),top:Math.min(a.top,d.top),bottom:Math.min(a.bottom,d.bottom)}:a||d;return!1}};gui.ParagraphBoundaryScanner=function(){var f=this,l=!1,a,d=odf.OdfUtils;this.token=void 0;this.process=function(b){var h=d.getParagraphElement(b.container());l||(a=h,l=!0);if(a!==h)return!0;f.token=b.token;return!1}};odf.WordBoundaryFilter=function(f,l){function a(a,b,c){for(var e=null,d=f.getRootNode(),g;a!==d&&null!==a&&null===e;)g=0>b?a.previousSibling:a.nextSibling,c(g)===NodeFilter.FILTER_ACCEPT&&(e=g),a=a.parentNode;return e}function d(a,c){var e;return null===a?r.NO_NEIGHBOUR:p.isCharacterElement(a)?r.SPACE_CHAR:a.nodeType===b||p.isTextSpan(a)||p.isHyperlink(a)?(e=a.textContent.charAt(c()),n.test(e)?r.SPACE_CHAR:q.test(e)?r.PUNCTUATION_CHAR:r.WORD_CHAR):r.OTHER}var b=Node.TEXT_NODE,h=Node.ELEMENT_NODE,
|
||
|
p=odf.OdfUtils,q=/[!-#%-*,-\/:-;?-@\[-\]_{}\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]/,
|
||
|
n=/\s/,m=core.PositionFilter.FilterResult.FILTER_ACCEPT,g=core.PositionFilter.FilterResult.FILTER_REJECT,e=odf.WordBoundaryFilter.IncludeWhitespace.TRAILING,c=odf.WordBoundaryFilter.IncludeWhitespace.LEADING,r={NO_NEIGHBOUR:0,SPACE_CHAR:1,PUNCTUATION_CHAR:2,WORD_CHAR:3,OTHER:4};this.acceptPosition=function(b){var f=b.container(),p=b.leftNode(),n=b.rightNode(),q=b.unfilteredDomOffset,s=function(){return b.unfilteredDomOffset()-1};f.nodeType===h&&(null===n&&(n=a(f,1,b.getNodeFilter())),null===p&&(p=
|
||
|
a(f,-1,b.getNodeFilter())));f!==n&&(q=function(){return 0});f!==p&&null!==p&&(s=function(){return p.textContent.length-1});f=d(p,s);n=d(n,q);return f===r.WORD_CHAR&&n===r.WORD_CHAR||f===r.PUNCTUATION_CHAR&&n===r.PUNCTUATION_CHAR||l===e&&f!==r.NO_NEIGHBOUR&&n===r.SPACE_CHAR||l===c&&f===r.SPACE_CHAR&&n!==r.NO_NEIGHBOUR?g:m}};odf.WordBoundaryFilter.IncludeWhitespace={None:0,TRAILING:1,LEADING:2};gui.SelectionController=function(f,l){function a(a){var b=a.spec();if(a.isEdit||b.memberid===l)E=void 0,B.cancel()}function d(){var a=t.getCursor(l).getNode();return t.createStepIterator(a,0,[s,u],t.getRootElement(a))}function b(a,b,c){c=new odf.WordBoundaryFilter(t,c);var e=t.getRootElement(a)||t.getRootNode(),d=t.createRootFilter(e);return t.createStepIterator(a,b,[s,d,c],e)}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 p(a,b,c){var e=new ops.OpMoveCursor;e.init({memberid:l,position:a,length:b||0,selectionType:c});return e}function q(a,b,c){var e;e=t.getCursor(l);e=h(e.getSelectedRange(),e.hasForwardSelection());e.focusNode=a;e.focusOffset=b;c||(e.anchorNode=e.focusNode,e.anchorOffset=e.focusOffset);a=t.convertDomToCursorRange(e);f.enqueue([p(a.position,a.length)])}function n(a){var c;c=b(a.startContainer,
|
||
|
a.startOffset,F);c.roundToPreviousStep()&&a.setStart(c.container(),c.offset());c=b(a.endContainer,a.endOffset,J);c.roundToNextStep()&&a.setEnd(c.container(),c.offset())}function m(a){var b=v.getParagraphElements(a),c=b[0],b=b[b.length-1];c&&a.setStart(c,0);b&&(v.isParagraph(a.endContainer)&&0===a.endOffset?a.setEndBefore(b):a.setEnd(b,b.childNodes.length))}function g(a,b,c,e){var d,f;e?(d=c.startContainer,f=c.startOffset):(d=c.endContainer,f=c.endOffset);y.containsNode(a,d)||(f=0>y.comparePoints(a,
|
||
|
0,d,f)?0:a.childNodes.length,d=a);a=t.createStepIterator(d,f,b,v.getParagraphElement(d)||a);a.roundToClosestStep()||runtime.assert(!1,"No step found in requested range");e?c.setStart(a.container(),a.offset()):c.setEnd(a.container(),a.offset())}function e(a,b){var c=d();c.advanceStep(a)&&q(c.container(),c.offset(),b)}function c(a,b){var c,e=E,f=[new gui.LineBoundaryScanner,new gui.ParagraphBoundaryScanner];void 0===e&&A&&(e=A());isNaN(e)||(c=d(),w.moveToFilteredStep(c,a,f)&&c.advanceStep(a)&&(f=[new gui.ClosestXOffsetScanner(e),
|
||
|
new gui.LineBoundaryScanner,new gui.ParagraphBoundaryScanner],w.moveToFilteredStep(c,a,f)&&(q(c.container(),c.offset(),b),E=e,B.restart())))}function r(a,b){var c=d(),e=[new gui.LineBoundaryScanner,new gui.ParagraphBoundaryScanner];w.moveToFilteredStep(c,a,e)&&q(c.container(),c.offset(),b)}function k(a,c){var e=t.getCursor(l),e=h(e.getSelectedRange(),e.hasForwardSelection()),e=b(e.focusNode,e.focusOffset,F);e.advanceStep(a)&&q(e.container(),e.offset(),c)}function x(a,b,c){var e=!1,d=t.getCursor(l),
|
||
|
d=h(d.getSelectedRange(),d.hasForwardSelection()),e=t.getRootElement(d.focusNode);runtime.assert(Boolean(e),"SelectionController: Cursor outside root");d=t.createStepIterator(d.focusNode,d.focusOffset,[s,u],e);d.roundToClosestStep();d.advanceStep(a)&&(c=c(d.container()))&&(a===H?(d.setPosition(c,0),e=d.roundToNextStep()):(d.setPosition(c,c.childNodes.length),e=d.roundToPreviousStep()),e&&q(d.container(),d.offset(),b))}var t=f.getOdtDocument(),y=core.DomUtils,v=odf.OdfUtils,s=t.getPositionFilter(),
|
||
|
w=new gui.GuiStepUtils,u=t.createRootFilter(l),A=null,E,B,F=odf.WordBoundaryFilter.IncludeWhitespace.TRAILING,J=odf.WordBoundaryFilter.IncludeWhitespace.LEADING,H=core.StepDirection.PREVIOUS,Q=core.StepDirection.NEXT;this.selectionToRange=function(a){var b=0<=y.comparePoints(a.anchorNode,a.anchorOffset,a.focusNode,a.focusOffset),c=a.focusNode.ownerDocument.createRange();b?(c.setStart(a.anchorNode,a.anchorOffset),c.setEnd(a.focusNode,a.focusOffset)):(c.setStart(a.focusNode,a.focusOffset),c.setEnd(a.anchorNode,
|
||
|
a.anchorOffset));return{range:c,hasForwardSelection:b}};this.rangeToSelection=h;this.selectImage=function(a){var b=t.getRootElement(a),c=t.createRootFilter(b),b=t.createStepIterator(a,0,[c,t.getPositionFilter()],b),e;b.roundToPreviousStep()||runtime.assert(!1,"No walkable position before frame");c=b.container();e=b.offset();b.setPosition(a,a.childNodes.length);b.roundToNextStep()||runtime.assert(!1,"No walkable position after frame");a=t.convertDomToCursorRange({anchorNode:c,anchorOffset:e,focusNode:b.container(),
|
||
|
focusOffset:b.offset()});a=p(a.position,a.length,ops.OdtCursor.RegionSelection);f.enqueue([a])};this.expandToWordBoundaries=n;this.expandToParagraphBoundaries=m;this.selectRange=function(a,b,c){var e=t.getOdfCanvas().getElement(),d,k=[s];d=y.containsNode(e,a.startContainer);e=y.containsNode(e,a.endContainer);if(d||e)if(d&&e&&(2===c?n(a):3<=c&&m(a)),(c=b?t.getRootElement(a.startContainer):t.getRootElement(a.endContainer))||(c=t.getRootNode()),k.push(t.createRootFilter(c)),g(c,k,a,!0),g(c,k,a,!1),a=
|
||
|
h(a,b),b=t.convertDomToCursorRange(a),a=t.getCursorSelection(l),b.position!==a.position||b.length!==a.length)a=p(b.position,b.length,ops.OdtCursor.RangeSelection),f.enqueue([a])};this.moveCursorToLeft=function(){e(H,!1);return!0};this.moveCursorToRight=function(){e(Q,!1);return!0};this.extendSelectionToLeft=function(){e(H,!0);return!0};this.extendSelectionToRight=function(){e(Q,!0);return!0};this.setCaretXPositionLocator=function(a){A=a};this.moveCursorUp=function(){c(H,!1);return!0};this.moveCursorDown=
|
||
|
function(){c(Q,!1);return!0};this.extendSelectionUp=function(){c(H,!0);return!0};this.extendSelectionDown=function(){c(Q,!0);return!0};this.moveCursorBeforeWord=function(){k(H,!1);return!0};this.moveCursorPastWord=function(){k(Q,!1);return!0};this.extendSelectionBeforeWord=function(){k(H,!0);return!0};this.extendSelectionPastWord=function(){k(Q,!0);return!0};this.moveCursorToLineStart=function(){r(H,!1);return!0};this.moveCursorToLineEnd=function(){r(Q,!1);return!0};this.extendSelectionToLineStart=
|
||
|
function(){r(H,!0);return!0};this.extendSelectionToLineEnd=function(){r(Q,!0);return!0};this.extendSelectionToParagraphStart=function(){x(H,!0,v.getParagraphElement);return!0};this.extendSelectionToParagraphEnd=function(){x(Q,!0,v.getParagraphElement);return!0};this.moveCursorToParagraphStart=function(){x(H,!1,v.getParagraphElement);return!0};this.moveCursorToParagraphEnd=function(){x(Q,!1,v.getParagraphElement);return!0};this.moveCursorToDocumentStart=function(){x(H,!1,t.getRootElement);return!0};
|
||
|
this.moveCursorToDocumentEnd=function(){x(Q,!1,t.getRootElement);return!0};this.extendSelectionToDocumentStart=function(){x(H,!0,t.getRootElement);return!0};this.extendSelectionToDocumentEnd=function(){x(Q,!0,t.getRootElement);return!0};this.extendSelectionToEntireDocument=function(){var a=t.getCursor(l),a=t.getRootElement(a.getNode()),b,c,e;runtime.assert(Boolean(a),"SelectionController: Cursor outside root");e=t.createStepIterator(a,0,[s,u],a);e.roundToClosestStep();b=e.container();c=e.offset();
|
||
|
e.setPosition(a,a.childNodes.length);e.roundToClosestStep();a=t.convertDomToCursorRange({anchorNode:b,anchorOffset:c,focusNode:e.container(),focusOffset:e.offset()});f.enqueue([p(a.position,a.length)]);return!0};this.destroy=function(b){t.unsubscribe(ops.OdtDocument.signalOperationStart,a);core.Async.destroyAll([B.destroy],b)};(function(){B=core.Task.createTimeoutTask(function(){E=void 0},2E3);t.subscribe(ops.OdtDocument.signalOperationStart,a)})()};gui.TextController=function(f,l,a,d,b,h){function p(){x=!0===l.getState(gui.CommonConstraints.EDIT.REVIEW_MODE)?a.isLocalCursorWithinOwnAnnotation():!0}function q(a){a.getMemberId()===d&&p()}function n(a,b,e){var d=[c.getPositionFilter()];e&&d.push(c.createRootFilter(a.startContainer));e=c.createStepIterator(a.startContainer,a.startOffset,d,b);e.roundToClosestStep()||runtime.assert(!1,"No walkable step found in paragraph element at range start");b=c.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=c.convertDomPointToCursorStep(e.container(),e.offset()));return{position:b,length:a-b}}function m(a){var b,c,e,f=r.getParagraphElements(a),g=a.cloneRange(),h=[];b=f[0];1<f.length&&(r.hasNoODFContent(b)&&(b=f[f.length-1]),c=b.getAttributeNS(odf.Namespaces.textns,"style-name")||"");f.forEach(function(b,f){var l,m;g.setStart(b,0);g.collapse(!0);
|
||
|
l=n(g,b,!1).position;0<f&&(m=new ops.OpMergeParagraph,m.init({memberid:d,paragraphStyleName:c,destinationStartPosition:e,sourceStartPosition:l,moveCursor:1===f}),h.unshift(m));e=l;g.selectNodeContents(b);if(l=k.rangeIntersection(g,a))l=n(l,b,!0),0<l.length&&(m=new ops.OpRemoveText,m.init({memberid:d,position:l.position,length:l.length}),h.unshift(m))});return h}function g(a){0>a.length&&(a.position+=a.length,a.length=-a.length);return a}function e(a){if(!x)return!1;var b,e=c.getCursor(d).getSelectedRange().cloneRange(),
|
||
|
k=g(c.getCursorSelection(d)),h;if(0===k.length){k=void 0;b=c.getCursor(d).getNode();h=c.getRootElement(b);var l=[c.getPositionFilter(),c.createRootFilter(h)];h=c.createStepIterator(b,0,l,h);h.roundToClosestStep()&&(a?h.nextStep():h.previousStep())&&(k=g(c.convertDomToCursorRange({anchorNode:b,anchorOffset:0,focusNode:h.container(),focusOffset:h.offset()})),a?(e.setStart(b,0),e.setEnd(h.container(),h.offset())):(e.setStart(h.container(),h.offset()),e.setEnd(b,0)))}k&&f.enqueue(m(e));return void 0!==
|
||
|
k}var c=f.getOdtDocument(),r=odf.OdfUtils,k=core.DomUtils,x=!1,t=odf.Namespaces.textns,y=core.StepDirection.NEXT;this.isEnabled=function(){return x};this.enqueueParagraphSplittingOps=function(){if(!x)return!1;var a=c.getCursor(d),b=a.getSelectedRange(),e=g(c.getCursorSelection(d)),k=[],a=r.getParagraphElement(a.getNode()),l=a.getAttributeNS(t,"style-name")||"";0<e.length&&(k=k.concat(m(b)));b=new ops.OpSplitParagraph;b.init({memberid:d,position:e.position,paragraphStyleName:l,sourceParagraphPosition:c.convertDomPointToCursorStep(a,
|
||
|
0,y),moveCursor:!0});k.push(b);h&&(e=h(e.position+1),k=k.concat(e));f.enqueue(k);return!0};this.removeTextByBackspaceKey=function(){return e(!1)};this.removeTextByDeleteKey=function(){return e(!0)};this.removeCurrentSelection=function(){if(!x)return!1;var a=c.getCursor(d).getSelectedRange();f.enqueue(m(a));return!0};this.insertText=function(a){if(x){var e=c.getCursor(d).getSelectedRange(),k=g(c.getCursorSelection(d)),h=[],l=!1;0<k.length&&(h=h.concat(m(e)),l=!0);e=new ops.OpInsertText;e.init({memberid:d,
|
||
|
position:k.position,text:a,moveCursor:!0});h.push(e);b&&(a=b(k.position,a.length,l))&&h.push(a);f.enqueue(h)}};this.destroy=function(a){c.unsubscribe(ops.Document.signalCursorMoved,q);l.unsubscribe(gui.CommonConstraints.EDIT.REVIEW_MODE,p);a()};c.subscribe(ops.Document.signalCursorMoved,q);l.subscribe(gui.CommonConstraints.EDIT.REVIEW_MODE,p);p()};gui.UndoManager=function(){};gui.UndoManager.prototype.subscribe=function(f,l){};gui.UndoManager.prototype.unsubscribe=function(f,l){};gui.UndoManager.prototype.setDocument=function(f){};gui.UndoManager.prototype.setInitialState=function(){};gui.UndoManager.prototype.initialize=function(){};gui.UndoManager.prototype.purgeInitialState=function(){};gui.UndoManager.prototype.setPlaybackFunction=function(f){};gui.UndoManager.prototype.hasUndoStates=function(){};
|
||
|
gui.UndoManager.prototype.hasRedoStates=function(){};gui.UndoManager.prototype.moveForward=function(f){};gui.UndoManager.prototype.moveBackward=function(f){};gui.UndoManager.prototype.onOperationExecuted=function(f){};gui.UndoManager.prototype.isDocumentModified=function(){};gui.UndoManager.prototype.setDocumentModified=function(f){};gui.UndoManager.signalUndoStackChanged="undoStackChanged";gui.UndoManager.signalUndoStateCreated="undoStateCreated";gui.UndoManager.signalUndoStateModified="undoStateModified";
|
||
|
gui.UndoManager.signalDocumentModifiedChanged="documentModifiedChanged";gui.SessionControllerOptions=function(){this.annotationsEnabled=this.directParagraphStylingEnabled=this.directTextStylingEnabled=!1};
|
||
|
(function(){var f=core.PositionFilter.FilterResult.FILTER_ACCEPT;gui.SessionController=function(l,a,d,b){function h(a){return a.target||a.srcElement||null}function p(a,b){var c=I.getDOMDocument(),e=null;c.caretRangeFromPoint?(c=c.caretRangeFromPoint(a,b),e={container:c.startContainer,offset:c.startOffset}):c.caretPositionFromPoint&&(c=c.caretPositionFromPoint(a,b))&&c.offsetNode&&(e={container:c.offsetNode,offset:c.offset});return e}function q(b){var c=I.getCursor(a).getSelectedRange();c.collapsed?
|
||
|
b.preventDefault():Z.setDataFromRange(b,c)?ha.removeCurrentSelection():runtime.log("Cut operation failed")}function n(){return!1!==I.getCursor(a).getSelectedRange().collapsed}function m(b){var c=I.getCursor(a).getSelectedRange();c.collapsed?b.preventDefault():Z.setDataFromRange(b,c)||runtime.log("Copy operation failed")}function g(a){var b;R.clipboardData&&R.clipboardData.getData?b=R.clipboardData.getData("Text"):a.clipboardData&&a.clipboardData.getData&&(b=a.clipboardData.getData("text/plain"));
|
||
|
b&&(ha.removeCurrentSelection(),pa.paste(b));a.preventDefault?a.preventDefault():a.returnValue=!1}function e(){return!1}function c(a){if(S)S.onOperationExecuted(a)}function r(a){I.emit(ops.OdtDocument.signalUndoStackChanged,a)}function k(){var a;return S?(a=L.hasFocus(),S.moveBackward(1),a&&L.focus(),!0):!1}function x(){var a;return S?(a=L.hasFocus(),S.moveForward(1),a&&L.focus(),!0):!1}function t(b){var c=I.getCursor(a).getSelectedRange(),e=h(b).getAttribute("end");c&&e&&(b=p(b.clientX,b.clientY))&&
|
||
|
(ia.setUnfilteredPosition(b.container,b.offset),O.acceptPosition(ia)===f&&(c=c.cloneRange(),"left"===e?c.setStart(ia.container(),ia.unfilteredDomOffset()):c.setEnd(ia.container(),ia.unfilteredDomOffset()),d.setSelectedRange(c,"right"===e),I.emit(ops.Document.signalCursorMoved,d)))}function y(){X.selectRange(d.getSelectedRange(),d.hasForwardSelection(),1)}function v(){var a=R.getSelection(),b=0<a.rangeCount&&X.selectionToRange(a);ca&&b&&(W=!0,la.clearSelection(),ia.setUnfilteredPosition(a.focusNode,
|
||
|
a.focusOffset),O.acceptPosition(ia)===f&&(2===na?X.expandToWordBoundaries(b.range):3<=na&&X.expandToParagraphBoundaries(b.range),d.setSelectedRange(b.range,b.hasForwardSelection),I.emit(ops.Document.signalCursorMoved,d)))}function s(b){var c=h(b),e=I.getCursor(a);if(ca=null!==c&&T.containsNode(I.getOdfCanvas().getElement(),c))W=!1,c=I.getRootElement(c)||I.getRootNode(),O=I.createRootFilter(c),na=0===b.button?b.detail:0,e&&b.shiftKey?R.getSelection().collapse(e.getAnchorNode(),0):(b=R.getSelection(),
|
||
|
c=e.getSelectedRange(),b.extend?e.hasForwardSelection()?(b.collapse(c.startContainer,c.startOffset),b.extend(c.endContainer,c.endOffset)):(b.collapse(c.endContainer,c.endOffset),b.extend(c.startContainer,c.startOffset)):(b.removeAllRanges(),b.addRange(c.cloneRange()))),1<na&&v()}function w(a){var b=I.getRootElement(a),c=I.createRootFilter(b),b=I.createStepIterator(a,0,[c,I.getPositionFilter()],b);b.setPosition(a,a.childNodes.length);return b.roundToNextStep()?{container:b.container(),offset:b.offset()}:
|
||
|
null}function u(a){var b;b=(b=R.getSelection())?{anchorNode:b.anchorNode,anchorOffset:b.anchorOffset,focusNode:b.focusNode,focusOffset:b.focusOffset}:null;var c=R.getSelection().isCollapsed,e,d;b.anchorNode||b.focusNode||!(e=p(a.clientX,a.clientY))||(b.anchorNode=e.container,b.anchorOffset=e.offset,b.focusNode=b.anchorNode,b.focusOffset=b.anchorOffset);if(D.isImage(b.focusNode)&&0===b.focusOffset&&D.isCharacterFrame(b.focusNode.parentNode)){if(d=b.focusNode.parentNode,e=d.getBoundingClientRect(),
|
||
|
a.clientX>e.left&&(e=w(d)))b.focusNode=e.container,b.focusOffset=e.offset,c&&(b.anchorNode=b.focusNode,b.anchorOffset=b.focusOffset)}else D.isImage(b.focusNode.firstChild)&&1===b.focusOffset&&D.isCharacterFrame(b.focusNode)&&(e=w(b.focusNode))&&(b.anchorNode=b.focusNode=e.container,b.anchorOffset=b.focusOffset=e.offset);b.anchorNode&&b.focusNode&&(b=X.selectionToRange(b),X.selectRange(b.range,b.hasForwardSelection,0===a.button?a.detail:0));L.focus()}function A(a){var b;if(b=p(a.clientX,a.clientY))a=
|
||
|
b.container,b=b.offset,a={anchorNode:a,anchorOffset:b,focusNode:a,focusOffset:b},a=X.selectionToRange(a),X.selectRange(a.range,a.hasForwardSelection,2),L.focus()}function E(a){var b=h(a),c,e,f;ja.processRequests();ca&&(D.isImage(b)&&D.isCharacterFrame(b.parentNode)&&R.getSelection().isCollapsed?(X.selectImage(b.parentNode),L.focus()):la.isSelectorElement(b)?L.focus():W?(b=d.getSelectedRange(),e=b.collapsed,D.isImage(b.endContainer)&&0===b.endOffset&&D.isCharacterFrame(b.endContainer.parentNode)&&
|
||
|
(f=b.endContainer.parentNode,f=w(f))&&(b.setEnd(f.container,f.offset),e&&b.collapse(!1)),X.selectRange(b,d.hasForwardSelection(),0===a.button?a.detail:0),L.focus()):ta?u(a):(c=T.cloneEvent(a),aa=runtime.setTimeout(function(){u(c)},0)),na=0,W=ca=!1)}function B(b){var c=I.getCursor(a).getSelectedRange();c.collapsed||P.exportRangeToDataTransfer(b.dataTransfer,c)}function F(){ca&&L.focus();na=0;W=ca=!1}function J(a){E(a)}function H(a){var b=h(a),c=null;"annotationRemoveButton"===b.className?(runtime.assert(ea,
|
||
|
"Remove buttons are displayed on annotations while annotation editing is disabled in the controller."),c=b.parentNode.getElementsByTagNameNS(odf.Namespaces.officens,"annotation").item(0),ga.removeAnnotation(c),L.focus()):"webodf-draggable"!==b.getAttribute("class")&&E(a)}function Q(a){(a=a.data)&&(-1===a.indexOf("\n")?ha.insertText(a):pa.paste(a))}function N(a){return function(){a();return!0}}function z(b){return function(c){return I.getCursor(a).getSelectionType()===ops.OdtCursor.RangeSelection?
|
||
|
b(c):!0}}function Y(a){L.unsubscribe("keydown",C.handleEvent);L.unsubscribe("keypress",V.handleEvent);L.unsubscribe("keyup",$.handleEvent);L.unsubscribe("copy",m);L.unsubscribe("mousedown",s);L.unsubscribe("mousemove",ja.trigger);L.unsubscribe("mouseup",H);L.unsubscribe("contextmenu",J);L.unsubscribe("dragstart",B);L.unsubscribe("dragend",F);L.unsubscribe("click",oa.handleClick);L.unsubscribe("longpress",A);L.unsubscribe("drag",t);L.unsubscribe("dragstop",y);I.unsubscribe(ops.OdtDocument.signalOperationEnd,
|
||
|
fa.trigger);I.unsubscribe(ops.Document.signalCursorAdded,ka.registerCursor);I.unsubscribe(ops.Document.signalCursorRemoved,ka.removeCursor);I.unsubscribe(ops.OdtDocument.signalOperationEnd,c);a()}var R=runtime.getWindow(),I=l.getOdtDocument(),G=new gui.SessionConstraints,ba=new gui.SessionContext(l,a),T=core.DomUtils,D=odf.OdfUtils,P=new gui.MimeDataExporter,Z=new gui.Clipboard(P),C=new gui.KeyboardHandler,V=new gui.KeyboardHandler,$=new gui.KeyboardHandler,ca=!1,U=new odf.ObjectNameGenerator(I.getOdfCanvas().odfContainer(),
|
||
|
a),W=!1,O=null,aa,S=null,L=new gui.EventManager(I),ea=b.annotationsEnabled,ga=new gui.AnnotationController(l,G,a),da=new gui.DirectFormattingController(l,G,ba,a,U,b.directTextStylingEnabled,b.directParagraphStylingEnabled),ha=new gui.TextController(l,G,ba,a,da.createCursorStyleOp,da.createParagraphStyleOps),ma=new gui.ImageController(l,G,ba,a,U),la=new gui.ImageSelector(I.getOdfCanvas()),ia=I.createPositionIterator(I.getRootNode()),ja,fa,pa=new gui.PasteController(l,G,ba,a),ka=new gui.InputMethodEditor(a,
|
||
|
L),na=0,oa=new gui.HyperlinkClickHandler(I.getOdfCanvas().getElement,C,$),qa=new gui.HyperlinkController(l,G,ba,a),X=new gui.SelectionController(l,a),ua=new gui.MetadataController(l,a),K=gui.KeyboardHandler.Modifier,M=gui.KeyboardHandler.KeyCode,ra=-1!==R.navigator.appVersion.toLowerCase().indexOf("mac"),ta=-1!==["iPad","iPod","iPhone"].indexOf(R.navigator.platform),sa;runtime.assert(null!==R,"Expected to be run in an environment which has a global window, like a browser.");this.undo=k;this.redo=
|
||
|
x;this.insertLocalCursor=function(){runtime.assert(void 0===l.getOdtDocument().getCursor(a),"Inserting local cursor a second time.");var b=new ops.OpAddCursor;b.init({memberid:a});l.enqueue([b]);L.focus()};this.removeLocalCursor=function(){runtime.assert(void 0!==l.getOdtDocument().getCursor(a),"Removing local cursor without inserting before.");var b=new ops.OpRemoveCursor;b.init({memberid:a});l.enqueue([b])};this.startEditing=function(){ka.subscribe(gui.InputMethodEditor.signalCompositionStart,ha.removeCurrentSelection);
|
||
|
ka.subscribe(gui.InputMethodEditor.signalCompositionEnd,Q);L.subscribe("beforecut",n);L.subscribe("cut",q);L.subscribe("beforepaste",e);L.subscribe("paste",g);S&&S.initialize();L.setEditing(!0);oa.setModifier(ra?K.Meta:K.Ctrl);C.bind(M.Backspace,K.None,N(ha.removeTextByBackspaceKey),!0);C.bind(M.Delete,K.None,ha.removeTextByDeleteKey);C.bind(M.Tab,K.None,z(function(){ha.insertText("\t");return!0}));ra?(C.bind(M.Clear,K.None,ha.removeCurrentSelection),C.bind(M.B,K.Meta,z(da.toggleBold)),C.bind(M.I,
|
||
|
K.Meta,z(da.toggleItalic)),C.bind(M.U,K.Meta,z(da.toggleUnderline)),C.bind(M.L,K.MetaShift,z(da.alignParagraphLeft)),C.bind(M.E,K.MetaShift,z(da.alignParagraphCenter)),C.bind(M.R,K.MetaShift,z(da.alignParagraphRight)),C.bind(M.J,K.MetaShift,z(da.alignParagraphJustified)),ea&&C.bind(M.C,K.MetaShift,ga.addAnnotation),C.bind(M.Z,K.Meta,k),C.bind(M.Z,K.MetaShift,x)):(C.bind(M.B,K.Ctrl,z(da.toggleBold)),C.bind(M.I,K.Ctrl,z(da.toggleItalic)),C.bind(M.U,K.Ctrl,z(da.toggleUnderline)),C.bind(M.L,K.CtrlShift,
|
||
|
z(da.alignParagraphLeft)),C.bind(M.E,K.CtrlShift,z(da.alignParagraphCenter)),C.bind(M.R,K.CtrlShift,z(da.alignParagraphRight)),C.bind(M.J,K.CtrlShift,z(da.alignParagraphJustified)),ea&&C.bind(M.C,K.CtrlAlt,ga.addAnnotation),C.bind(M.Z,K.Ctrl,k),C.bind(M.Z,K.CtrlShift,x));V.setDefault(z(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:(ha.insertText(b),!0)}));
|
||
|
V.bind(M.Enter,K.None,z(ha.enqueueParagraphSplittingOps))};this.endEditing=function(){ka.unsubscribe(gui.InputMethodEditor.signalCompositionStart,ha.removeCurrentSelection);ka.unsubscribe(gui.InputMethodEditor.signalCompositionEnd,Q);L.unsubscribe("cut",q);L.unsubscribe("beforecut",n);L.unsubscribe("paste",g);L.unsubscribe("beforepaste",e);L.setEditing(!1);oa.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);ra?(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),ea&&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),ea&&C.unbind(M.C,K.CtrlAlt),C.unbind(M.Z,K.Ctrl),C.unbind(M.Z,K.CtrlShift));V.setDefault(null);
|
||
|
V.unbind(M.Enter,K.None)};this.getInputMemberId=function(){return a};this.getSession=function(){return l};this.getSessionConstraints=function(){return G};this.setUndoManager=function(a){S&&S.unsubscribe(gui.UndoManager.signalUndoStackChanged,r);if(S=a)S.setDocument(I),S.setPlaybackFunction(l.enqueue),S.subscribe(gui.UndoManager.signalUndoStackChanged,r)};this.getUndoManager=function(){return S};this.getMetadataController=function(){return ua};this.getAnnotationController=function(){return ga};this.getDirectFormattingController=
|
||
|
function(){return da};this.getHyperlinkClickHandler=function(){return oa};this.getHyperlinkController=function(){return qa};this.getImageController=function(){return ma};this.getSelectionController=function(){return X};this.getTextController=function(){return ha};this.getEventManager=function(){return L};this.getKeyboardHandlers=function(){return{keydown:C,keypress:V}};this.destroy=function(a){var b=[ja.destroy,fa.destroy,da.destroy,ka.destroy,L.destroy,oa.destroy,qa.destroy,ua.destroy,X.destroy,
|
||
|
ha.destroy,Y];sa&&b.unshift(sa.destroy);runtime.clearTimeout(aa);core.Async.destroyAll(b,a)};ja=core.Task.createRedrawTask(v);fa=core.Task.createRedrawTask(function(){var b=I.getCursor(a);if(b&&b.getSelectionType()===ops.OdtCursor.RegionSelection&&(b=D.getImageElements(b.getSelectedRange())[0])){la.select(b.parentNode);return}la.clearSelection()});C.bind(M.Left,K.None,z(X.moveCursorToLeft));C.bind(M.Right,K.None,z(X.moveCursorToRight));C.bind(M.Up,K.None,z(X.moveCursorUp));C.bind(M.Down,K.None,z(X.moveCursorDown));
|
||
|
C.bind(M.Left,K.Shift,z(X.extendSelectionToLeft));C.bind(M.Right,K.Shift,z(X.extendSelectionToRight));C.bind(M.Up,K.Shift,z(X.extendSelectionUp));C.bind(M.Down,K.Shift,z(X.extendSelectionDown));C.bind(M.Home,K.None,z(X.moveCursorToLineStart));C.bind(M.End,K.None,z(X.moveCursorToLineEnd));C.bind(M.Home,K.Ctrl,z(X.moveCursorToDocumentStart));C.bind(M.End,K.Ctrl,z(X.moveCursorToDocumentEnd));C.bind(M.Home,K.Shift,z(X.extendSelectionToLineStart));C.bind(M.End,K.Shift,z(X.extendSelectionToLineEnd));C.bind(M.Up,
|
||
|
K.CtrlShift,z(X.extendSelectionToParagraphStart));C.bind(M.Down,K.CtrlShift,z(X.extendSelectionToParagraphEnd));C.bind(M.Home,K.CtrlShift,z(X.extendSelectionToDocumentStart));C.bind(M.End,K.CtrlShift,z(X.extendSelectionToDocumentEnd));ra?(C.bind(M.Left,K.Alt,z(X.moveCursorBeforeWord)),C.bind(M.Right,K.Alt,z(X.moveCursorPastWord)),C.bind(M.Left,K.Meta,z(X.moveCursorToLineStart)),C.bind(M.Right,K.Meta,z(X.moveCursorToLineEnd)),C.bind(M.Home,K.Meta,z(X.moveCursorToDocumentStart)),C.bind(M.End,K.Meta,
|
||
|
z(X.moveCursorToDocumentEnd)),C.bind(M.Left,K.AltShift,z(X.extendSelectionBeforeWord)),C.bind(M.Right,K.AltShift,z(X.extendSelectionPastWord)),C.bind(M.Left,K.MetaShift,z(X.extendSelectionToLineStart)),C.bind(M.Right,K.MetaShift,z(X.extendSelectionToLineEnd)),C.bind(M.Up,K.AltShift,z(X.extendSelectionToParagraphStart)),C.bind(M.Down,K.AltShift,z(X.extendSelectionToParagraphEnd)),C.bind(M.Up,K.MetaShift,z(X.extendSelectionToDocumentStart)),C.bind(M.Down,K.MetaShift,z(X.extendSelectionToDocumentEnd)),
|
||
|
C.bind(M.A,K.Meta,z(X.extendSelectionToEntireDocument))):(C.bind(M.Left,K.Ctrl,z(X.moveCursorBeforeWord)),C.bind(M.Right,K.Ctrl,z(X.moveCursorPastWord)),C.bind(M.Left,K.CtrlShift,z(X.extendSelectionBeforeWord)),C.bind(M.Right,K.CtrlShift,z(X.extendSelectionPastWord)),C.bind(M.A,K.Ctrl,z(X.extendSelectionToEntireDocument)));ta&&(sa=new gui.IOSSafariSupport(L));L.subscribe("keydown",C.handleEvent);L.subscribe("keypress",V.handleEvent);L.subscribe("keyup",$.handleEvent);L.subscribe("copy",m);L.subscribe("mousedown",
|
||
|
s);L.subscribe("mousemove",ja.trigger);L.subscribe("mouseup",H);L.subscribe("contextmenu",J);L.subscribe("dragstart",B);L.subscribe("dragend",F);L.subscribe("click",oa.handleClick);L.subscribe("longpress",A);L.subscribe("drag",t);L.subscribe("dragstop",y);I.subscribe(ops.OdtDocument.signalOperationEnd,fa.trigger);I.subscribe(ops.Document.signalCursorAdded,ka.registerCursor);I.subscribe(ops.Document.signalCursorRemoved,ka.removeCursor);I.subscribe(ops.OdtDocument.signalOperationEnd,c)}})();gui.CaretManager=function(f,l){function a(a){return h.hasOwnProperty(a)?h[a]:null}function d(){return Object.keys(h).map(function(a){return h[a]})}function b(a){var b=h[a];b&&(delete h[a],a===f.getInputMemberId()?(q.unsubscribe(ops.OdtDocument.signalProcessingBatchEnd,b.ensureVisible),q.unsubscribe(ops.Document.signalCursorMoved,b.refreshCursorBlinking),n.unsubscribe("compositionupdate",b.handleUpdate),n.unsubscribe("compositionend",b.handleUpdate),n.unsubscribe("focus",b.setFocus),n.unsubscribe("blur",
|
||
|
b.removeFocus),p.removeEventListener("focus",b.show,!1),p.removeEventListener("blur",b.hide,!1)):q.unsubscribe(ops.OdtDocument.signalProcessingBatchEnd,b.handleUpdate),b.destroy(function(){}))}var h={},p=runtime.getWindow(),q=f.getSession().getOdtDocument(),n=f.getEventManager();this.registerCursor=function(a,b,e){var c=a.getMemberId();a=new gui.Caret(a,l,b,e);h[c]=a;c===f.getInputMemberId()?(runtime.log("Starting to track input on new cursor of "+c),q.subscribe(ops.OdtDocument.signalProcessingBatchEnd,
|
||
|
a.ensureVisible),q.subscribe(ops.Document.signalCursorMoved,a.refreshCursorBlinking),n.subscribe("compositionupdate",a.handleUpdate),n.subscribe("compositionend",a.handleUpdate),n.subscribe("focus",a.setFocus),n.subscribe("blur",a.removeFocus),p.addEventListener("focus",a.show,!1),p.addEventListener("blur",a.hide,!1),a.setOverlayElement(n.getEventTrap())):q.subscribe(ops.OdtDocument.signalProcessingBatchEnd,a.handleUpdate);return a};this.getCaret=a;this.getCarets=d;this.destroy=function(a){var g=
|
||
|
d().map(function(a){return a.destroy});f.getSelectionController().setCaretXPositionLocator(null);q.unsubscribe(ops.Document.signalCursorRemoved,b);h={};core.Async.destroyAll(g,a)};f.getSelectionController().setCaretXPositionLocator(function(){var b=a(f.getInputMemberId()),d;b&&(d=b.getBoundingClientRect());return d?d.right:void 0});q.subscribe(ops.Document.signalCursorRemoved,b)};gui.EditInfoHandle=function(f){var l=[],a,d=f.ownerDocument,b=d.documentElement.namespaceURI;this.setEdits=function(f){l=f;var p,q,n,m;core.DomUtils.removeAllChildNodes(a);for(f=0;f<l.length;f+=1)p=d.createElementNS(b,"div"),p.className="editInfo",q=d.createElementNS(b,"span"),q.className="editInfoColor",q.setAttributeNS("urn:webodf:names:editinfo","editinfo:memberid",l[f].memberid),n=d.createElementNS(b,"span"),n.className="editInfoAuthor",n.setAttributeNS("urn:webodf:names:editinfo","editinfo:memberid",
|
||
|
l[f].memberid),m=d.createElementNS(b,"span"),m.className="editInfoTime",m.setAttributeNS("urn:webodf:names:editinfo","editinfo:memberid",l[f].memberid),m.appendChild(d.createTextNode(l[f].time.toString())),p.appendChild(q),p.appendChild(n),p.appendChild(m),a.appendChild(p)};this.show=function(){a.style.display="block"};this.hide=function(){a.style.display="none"};this.destroy=function(b){f.removeChild(a);b()};a=d.createElementNS(b,"div");a.setAttribute("class","editInfoHandle");a.style.display="none";
|
||
|
f.appendChild(a)};ops.EditInfo=function(f,l){function a(){var a=[],d;for(d in b)b.hasOwnProperty(d)&&a.push({memberid:d,time:b[d].time});a.sort(function(a,b){return a.time-b.time});return a}var d,b={};this.getNode=function(){return d};this.getOdtDocument=function(){return l};this.getEdits=function(){return b};this.getSortedEdits=function(){return a()};this.addEdit=function(a,d){b[a]={time:d}};this.clearEdits=function(){b={}};this.destroy=function(a){f.parentNode&&f.removeChild(d);a()};d=l.getDOMDocument().createElementNS("urn:webodf:names:editinfo",
|
||
|
"editinfo");f.insertBefore(d,f.firstChild)};gui.EditInfoMarker=function(f,l){function a(a,b){return runtime.setTimeout(function(){p.style.opacity=a},b)}var d=this,b,h,p,q,n,m;this.addEdit=function(b,e){var c=Date.now()-e;f.addEdit(b,e);h.setEdits(f.getSortedEdits());p.setAttributeNS("urn:webodf:names:editinfo","editinfo:memberid",b);runtime.clearTimeout(n);runtime.clearTimeout(m);1E4>c?(q=a(1,0),n=a(0.5,1E4-c),m=a(0.2,2E4-c)):1E4<=c&&2E4>c?(q=a(0.5,0),m=a(0.2,2E4-c)):q=a(0.2,0)};this.getEdits=function(){return f.getEdits()};this.clearEdits=
|
||
|
function(){f.clearEdits();h.setEdits([]);p.hasAttributeNS("urn:webodf:names:editinfo","editinfo:memberid")&&p.removeAttributeNS("urn:webodf:names:editinfo","editinfo:memberid")};this.getEditInfo=function(){return f};this.show=function(){p.style.display="block"};this.hide=function(){d.hideHandle();p.style.display="none"};this.showHandle=function(){h.show()};this.hideHandle=function(){h.hide()};this.destroy=function(a){runtime.clearTimeout(q);runtime.clearTimeout(n);runtime.clearTimeout(m);b.removeChild(p);
|
||
|
h.destroy(function(b){b?a(b):f.destroy(a)})};(function(){var a=f.getOdtDocument().getDOMDocument();p=a.createElementNS(a.documentElement.namespaceURI,"div");p.setAttribute("class","editInfoMarker");p.onmouseover=function(){d.showHandle()};p.onmouseout=function(){d.hideHandle()};b=f.getNode();b.appendChild(p);h=new gui.EditInfoHandle(b);l||d.hide()})()};gui.HyperlinkTooltipView=function(f,l){var a=core.DomUtils,d=odf.OdfUtils,b=runtime.getWindow(),h,p,q;runtime.assert(null!==b,"Expected to be run in an environment which has a global window, like a browser.");this.showTooltip=function(n){var m=n.target||n.srcElement,g=f.getSizer(),e=f.getZoomLevel(),c;a:{for(;m;){if(d.isHyperlink(m))break a;if(d.isParagraph(m)||d.isInlineRoot(m))break;m=m.parentNode}m=null}if(m){a.containsNode(g,q)||g.appendChild(q);c=p;var r;switch(l()){case gui.KeyboardHandler.Modifier.Ctrl:r=
|
||
|
runtime.tr("Ctrl-click to follow link");break;case gui.KeyboardHandler.Modifier.Meta:r=runtime.tr("\u2318-click to follow link");break;default:r=""}c.textContent=r;h.textContent=d.getHyperlinkTarget(m);q.style.display="block";c=b.innerWidth-q.offsetWidth-15;m=n.clientX>c?c:n.clientX+15;c=b.innerHeight-q.offsetHeight-10;n=n.clientY>c?c:n.clientY+10;g=g.getBoundingClientRect();m=(m-g.left)/e;n=(n-g.top)/e;q.style.left=m+"px";q.style.top=n+"px"}};this.hideTooltip=function(){q.style.display="none"};this.destroy=
|
||
|
function(a){q.parentNode&&q.parentNode.removeChild(q);a()};(function(){var a=f.getElement().ownerDocument;h=a.createElement("span");p=a.createElement("span");h.className="webodf-hyperlinkTooltipLink";p.className="webodf-hyperlinkTooltipText";q=a.createElement("div");q.className="webodf-hyperlinkTooltip";q.appendChild(h);q.appendChild(p);f.getElement().appendChild(q)})()};gui.OdfFieldView=function(f){function l(){var a=odf.OdfSchema.getFields().map(function(a){return a.replace(":","|")}),d=a.join(",\n")+"\n{ background-color: #D0D0D0; }\n",a=a.map(function(a){return a+":empty::after"}).join(",\n")+"\n{ content:' '; white-space: pre; }\n";return d+"\n"+a}var a,d=f.getElement().ownerDocument;this.showFieldHighlight=function(){a.appendChild(d.createTextNode(l()))};this.hideFieldHighlight=function(){for(var b=a.sheet,d=b.cssRules;d.length;)b.deleteRule(d.length-1)};this.destroy=
|
||
|
function(b){a.parentNode&&a.parentNode.removeChild(a);b()};a=function(){var a=d.getElementsByTagName("head").item(0),f=d.createElement("style"),l="";f.type="text/css";f.media="screen, print, handheld, projection";odf.Namespaces.forEachPrefix(function(a,b){l+="@namespace "+a+" url("+b+");\n"});f.appendChild(d.createTextNode(l));a.appendChild(f);return f}()};gui.ShadowCursor=function(f){var l=f.getDOMDocument().createRange(),a=!0;this.removeFromDocument=function(){};this.getMemberId=function(){return gui.ShadowCursor.ShadowCursorMemberId};this.getSelectedRange=function(){return l};this.setSelectedRange=function(d,b){l=d;a=!1!==b};this.hasForwardSelection=function(){return a};this.getDocument=function(){return f};this.getSelectionType=function(){return ops.OdtCursor.RangeSelection};l.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 l(){return Object.keys(a).map(function(d){return a[d]})}var a={};this.getSelectionView=function(d){return a.hasOwnProperty(d)?a[d]:null};this.getSelectionViews=l;this.removeSelectionView=function(d){a.hasOwnProperty(d)&&(a[d].destroy(function(){}),delete a[d])};this.hideSelectionView=function(d){a.hasOwnProperty(d)&&a[d].hide()};this.showSelectionView=function(d){a.hasOwnProperty(d)&&a[d].show()};this.rerenderSelectionViews=function(){Object.keys(a).forEach(function(d){a[d].rerender()})};
|
||
|
this.registerCursor=function(d,b){var h=d.getMemberId(),l=new f(d);b?l.show():l.hide();return a[h]=l};this.destroy=function(a){function b(l,q){q?a(q):l<f.length?f[l].destroy(function(a){b(l+1,a)}):a()}var f=l();b(0,void 0)}};gui.SessionViewOptions=function(){this.caretBlinksOnRangeSelect=this.caretAvatarsInitiallyVisible=this.editInfoMarkersInitiallyVisible=!0};
|
||
|
(function(){gui.SessionView=function(f,l,a,d,b,h){function p(a){a.memberId===l&&E.getViewport().scrollIntoView(a.annotation.getBoundingClientRect())}function q(){var a=document.getElementsByTagName("head").item(0),b=document.createElement("style");b.type="text/css";b.media="screen, print, handheld, projection";a.appendChild(b);return b}function n(a,b,c){function e(b,c,d){c=b+'[editinfo|memberid="'+a+'"]'+d+c;a:{var f=v.firstChild;for(b=b+'[editinfo|memberid="'+a+'"]'+d+"{";f;){if(f.nodeType===Node.TEXT_NODE&&
|
||
|
0===f.data.indexOf(b)){b=f;break a}f=f.nextSibling}b=null}b?b.data=c:v.appendChild(document.createTextNode(c))}e("div.editInfoMarker","{ background-color: "+c+"; }","");e("span.editInfoColor","{ background-color: "+c+"; }","");e("span.editInfoAuthor",'{ content: "'+b+'"; }',":before");e("dc|creator","{ background-color: "+c+"; }","");e(".webodf-selectionOverlay","{ fill: "+c+"; stroke: "+c+";}","");a===l&&(e(".webodf-touchEnabled .webodf-selectionOverlay","{ display: block; }"," > .webodf-draggable"),
|
||
|
a=gui.ShadowCursor.ShadowCursorMemberId,e(".webodf-selectionOverlay","{ fill: "+c+"; stroke: "+c+";}",""),e(".webodf-touchEnabled .webodf-selectionOverlay","{ display: block; }"," > .webodf-draggable"))}function m(a){var b,c;for(c in u)u.hasOwnProperty(c)&&(b=u[c],a?b.show():b.hide())}function g(a){b.getCarets().forEach(function(b){a?b.showHandle():b.hideHandle()})}function e(a){var b=a.getMemberId();a=a.getProperties();n(b,a.fullName,a.color)}function c(c){var e=c.getMemberId(),d=a.getOdtDocument().getMember(e).getProperties();
|
||
|
b.registerCursor(c,J,H);h.registerCursor(c,!0);if(c=b.getCaret(e))c.setAvatarImageUrl(d.imageUrl),c.setColor(d.color);runtime.log("+++ View here +++ eagerly created an Caret for '"+e+"'! +++")}function r(a){a=a.getMemberId();var c=h.getSelectionView(l),e=h.getSelectionView(gui.ShadowCursor.ShadowCursorMemberId),d=b.getCaret(l);a===l?(e.hide(),c&&c.show(),d&&d.show()):a===gui.ShadowCursor.ShadowCursorMemberId&&(e.show(),c&&c.hide(),d&&d.hide())}function k(a){h.removeSelectionView(a)}function x(b){var c=
|
||
|
b.paragraphElement,e=b.memberId;b=b.timeStamp;var d,f="",k=c.getElementsByTagNameNS(w,"editinfo").item(0);k?(f=k.getAttributeNS(w,"id"),d=u[f]):(f=Math.random().toString(),d=new ops.EditInfo(c,a.getOdtDocument()),d=new gui.EditInfoMarker(d,F),k=c.getElementsByTagNameNS(w,"editinfo").item(0),k.setAttributeNS(w,"id",f),u[f]=d);d.addEdit(e,new Date(b));B.trigger()}function t(){var b;s.hasChildNodes()&&core.DomUtils.removeAllChildNodes(s);!0===d.getState(gui.CommonConstraints.EDIT.ANNOTATIONS.ONLY_DELETE_OWN)&&
|
||
|
(b=a.getOdtDocument().getMember(l))&&(b=b.getProperties().fullName,s.appendChild(document.createTextNode(".annotationWrapper:not([creator = '"+b+"']) .annotationRemoveButton { display: none; }")))}function y(a){var b=Object.keys(u).map(function(a){return u[a]});A.unsubscribe(ops.Document.signalMemberAdded,e);A.unsubscribe(ops.Document.signalMemberUpdated,e);A.unsubscribe(ops.Document.signalCursorAdded,c);A.unsubscribe(ops.Document.signalCursorRemoved,k);A.unsubscribe(ops.OdtDocument.signalParagraphChanged,
|
||
|
x);A.unsubscribe(ops.Document.signalCursorMoved,r);A.unsubscribe(ops.OdtDocument.signalParagraphChanged,h.rerenderSelectionViews);A.unsubscribe(ops.OdtDocument.signalTableAdded,h.rerenderSelectionViews);A.unsubscribe(ops.OdtDocument.signalParagraphStyleModified,h.rerenderSelectionViews);d.unsubscribe(gui.CommonConstraints.EDIT.ANNOTATIONS.ONLY_DELETE_OWN,t);A.unsubscribe(ops.Document.signalMemberAdded,t);A.unsubscribe(ops.Document.signalMemberUpdated,t);v.parentNode.removeChild(v);s.parentNode.removeChild(s);
|
||
|
(function Y(c,e){e?a(e):c<b.length?b[c].destroy(function(a){Y(c+1,a)}):a()})(0,void 0)}var v,s,w="urn:webodf:names:editinfo",u={},A,E,B,F=void 0!==f.editInfoMarkersInitiallyVisible?Boolean(f.editInfoMarkersInitiallyVisible):!0,J=void 0!==f.caretAvatarsInitiallyVisible?Boolean(f.caretAvatarsInitiallyVisible):!0,H=void 0!==f.caretBlinksOnRangeSelect?Boolean(f.caretBlinksOnRangeSelect):!0;this.showEditInfoMarkers=function(){F||(F=!0,m(F))};this.hideEditInfoMarkers=function(){F&&(F=!1,m(F))};this.showCaretAvatars=
|
||
|
function(){J||(J=!0,g(J))};this.hideCaretAvatars=function(){J&&(J=!1,g(J))};this.getSession=function(){return a};this.getCaret=function(a){return b.getCaret(a)};this.destroy=function(a){var b=[B.destroy,y];A.unsubscribe(ops.OdtDocument.signalAnnotationAdded,p);core.Async.destroyAll(b,a)};A=a.getOdtDocument();E=A.getOdfCanvas();A.subscribe(ops.OdtDocument.signalAnnotationAdded,p);A.subscribe(ops.Document.signalMemberAdded,e);A.subscribe(ops.Document.signalMemberUpdated,e);A.subscribe(ops.Document.signalCursorAdded,
|
||
|
c);A.subscribe(ops.Document.signalCursorRemoved,k);A.subscribe(ops.OdtDocument.signalParagraphChanged,x);A.subscribe(ops.Document.signalCursorMoved,r);A.subscribe(ops.OdtDocument.signalParagraphChanged,h.rerenderSelectionViews);A.subscribe(ops.OdtDocument.signalTableAdded,h.rerenderSelectionViews);A.subscribe(ops.OdtDocument.signalParagraphStyleModified,h.rerenderSelectionViews);d.subscribe(gui.CommonConstraints.EDIT.ANNOTATIONS.ONLY_DELETE_OWN,t);A.subscribe(ops.Document.signalMemberAdded,t);A.subscribe(ops.Document.signalMemberUpdated,
|
||
|
t);v=q();v.appendChild(document.createTextNode("@namespace editinfo url(urn:webodf:names:editinfo);"));v.appendChild(document.createTextNode("@namespace dc url(http://purl.org/dc/elements/1.1/);"));s=q();t();B=core.Task.createRedrawTask(function(){var a=E.getAnnotationViewManager();a&&(a.rehighlightAnnotations(),A.fixCursorPositions())})}})();gui.SvgSelectionView=function(f){function l(){var a=c.getRootNode();r!==a&&(r=a,k=c.getCanvas().getSizer(),k.appendChild(t),t.setAttribute("class","webodf-selectionOverlay"),v.setAttribute("class","webodf-draggable"),s.setAttribute("class","webodf-draggable"),v.setAttribute("end","left"),s.setAttribute("end","right"),v.setAttribute("r",8),s.setAttribute("r",8),t.appendChild(y),t.appendChild(v),t.appendChild(s))}function a(a){a=a.getBoundingClientRect();return Boolean(a&&0!==a.height)}function d(b){var c=
|
||
|
w.getTextElements(b,!0,!1),e=b.cloneRange(),d=b.cloneRange();b=b.cloneRange();if(!c.length)return null;var f;a:{f=0;var k=c[f],g=e.startContainer===k?e.startOffset:0,h=g;e.setStart(k,g);for(e.setEnd(k,h);!a(e);){if(k.nodeType===Node.ELEMENT_NODE&&h<k.childNodes.length)h=k.childNodes.length;else if(k.nodeType===Node.TEXT_NODE&&h<k.length)h+=1;else if(c[f])k=c[f],f+=1,g=h=0;else{f=!1;break a}e.setStart(k,g);e.setEnd(k,h)}f=!0}if(!f)return null;a:{f=c.length-1;k=c[f];h=g=d.endContainer===k?d.endOffset:
|
||
|
k.nodeType===Node.TEXT_NODE?k.length:k.childNodes.length;d.setStart(k,g);for(d.setEnd(k,h);!a(d);){if(k.nodeType===Node.ELEMENT_NODE&&0<g)g=0;else if(k.nodeType===Node.TEXT_NODE&&0<g)g-=1;else if(c[f])k=c[f],f-=1,g=h=k.length||k.childNodes.length;else{c=!1;break a}d.setStart(k,g);d.setEnd(k,h)}c=!0}if(!c)return null;b.setStart(e.startContainer,e.startOffset);b.setEnd(d.endContainer,d.endOffset);return{firstRange:e,lastRange:d,fillerRange:b}}function b(a,b){var c={};c.top=Math.min(a.top,b.top);c.left=
|
||
|
Math.min(a.left,b.left);c.right=Math.max(a.right,b.right);c.bottom=Math.max(a.bottom,b.bottom);c.width=c.right-c.left;c.height=c.bottom-c.top;return c}function h(a,c){c&&0<c.width&&0<c.height&&(a=a?b(a,c):c);return a}function p(a){function b(a){B.setUnfilteredPosition(a,0);return t.acceptNode(a)===F&&s.acceptPosition(B)===F?F:J}function e(a){var c=null;b(a)===F&&(c=u.getBoundingClientRect(a));return c}var d=a.commonAncestorContainer,f=a.startContainer,k=a.endContainer,g=a.startOffset,l=a.endOffset,
|
||
|
m,n,p=null,r,q=x.createRange(),s,t=new odf.OdfNodeFilter,v;if(f===d||k===d)return q=a.cloneRange(),p=q.getBoundingClientRect(),q.detach(),p;for(a=f;a.parentNode!==d;)a=a.parentNode;for(n=k;n.parentNode!==d;)n=n.parentNode;s=c.createRootFilter(f);for(d=a.nextSibling;d&&d!==n;)r=e(d),p=h(p,r),d=d.nextSibling;if(w.isParagraph(a))p=h(p,u.getBoundingClientRect(a));else if(a.nodeType===Node.TEXT_NODE)d=a,q.setStart(d,g),q.setEnd(d,d===n?l:d.length),r=q.getBoundingClientRect(),p=h(p,r);else for(v=x.createTreeWalker(a,
|
||
|
NodeFilter.SHOW_TEXT,b,!1),d=v.currentNode=f;d&&d!==k;)q.setStart(d,g),q.setEnd(d,d.length),r=q.getBoundingClientRect(),p=h(p,r),m=d,g=0,d=v.nextNode();m||(m=f);if(w.isParagraph(n))p=h(p,u.getBoundingClientRect(n));else if(n.nodeType===Node.TEXT_NODE)d=n,q.setStart(d,d===a?g:0),q.setEnd(d,l),r=q.getBoundingClientRect(),p=h(p,r);else for(v=x.createTreeWalker(n,NodeFilter.SHOW_TEXT,b,!1),d=v.currentNode=k;d&&d!==m;)if(q.setStart(d,0),q.setEnd(d,l),r=q.getBoundingClientRect(),p=h(p,r),d=v.previousNode())l=
|
||
|
d.length;return p}function q(a,b){var c=a.getBoundingClientRect(),e={width:0};e.top=c.top;e.bottom=c.bottom;e.height=c.height;e.left=e.right=b?c.right:c.left;return e}function n(){var a=f.getSelectedRange(),c;if(c=E&&f.getSelectionType()===ops.OdtCursor.RangeSelection&&!a.collapsed){l();var e=u.getBoundingClientRect(k),g=A.getZoomLevel(),a=d(a),h,m,n,r,x,w;if(a){c=a.firstRange;h=a.lastRange;m=a.fillerRange;n=u.translateRect(q(c,!1),e,g);x=u.translateRect(q(h,!0),e,g);r=(r=p(m))?u.translateRect(r,
|
||
|
e,g):b(n,x);w=r.left;r=n.left+Math.max(0,r.width-(n.left-r.left));e=Math.min(n.top,x.top);g=x.top+x.height;w=[{x:n.left,y:e+n.height},{x:n.left,y:e},{x:r,y:e},{x:r,y:g-x.height},{x:x.right,y:g-x.height},{x:x.right,y:g},{x:w,y:g},{x:w,y:e+n.height},{x:n.left,y:e+n.height}];r="";var B;for(B=0;B<w.length;B+=1)r+=w[B].x+","+w[B].y+" ";y.setAttribute("points",r);v.setAttribute("cx",n.left);v.setAttribute("cy",e+n.height/2);s.setAttribute("cx",x.right);s.setAttribute("cy",g-x.height/2);c.detach();h.detach();
|
||
|
m.detach()}c=Boolean(a)}t.style.display=c?"block":"none"}function m(a){E&&a===f&&H.trigger()}function g(a){a=8/a;v.setAttribute("r",a);s.setAttribute("r",a)}function e(a){k.removeChild(t);k.classList.remove("webodf-virtualSelections");f.getDocument().unsubscribe(ops.Document.signalCursorMoved,m);A.unsubscribe(gui.ZoomHelper.signalZoomChanged,g);a()}var c=f.getDocument(),r,k,x=c.getDOMDocument(),t=x.createElementNS("http://www.w3.org/2000/svg","svg"),y=x.createElementNS("http://www.w3.org/2000/svg",
|
||
|
"polygon"),v=x.createElementNS("http://www.w3.org/2000/svg","circle"),s=x.createElementNS("http://www.w3.org/2000/svg","circle"),w=odf.OdfUtils,u=core.DomUtils,A=c.getCanvas().getZoomHelper(),E=!0,B=f.getDocument().createPositionIterator(c.getRootNode()),F=NodeFilter.FILTER_ACCEPT,J=NodeFilter.FILTER_REJECT,H;this.rerender=function(){E&&H.trigger()};this.show=function(){E=!0;H.trigger()};this.hide=function(){E=!1;H.trigger()};this.destroy=function(a){core.Async.destroyAll([H.destroy,e],a)};(function(){var a=
|
||
|
f.getMemberId();H=core.Task.createRedrawTask(n);l();t.setAttributeNS("urn:webodf:names:editinfo","editinfo:memberid",a);k.classList.add("webodf-virtualSelections");f.getDocument().subscribe(ops.Document.signalCursorMoved,m);A.subscribe(gui.ZoomHelper.signalZoomChanged,g);g(A.getZoomLevel())})()};gui.UndoStateRules=function(){function f(a,d){var f=a.length;this.previous=function(){for(f-=1;0<=f;f-=1)if(d(a[f]))return a[f];return null}}function l(a){a=a.spec();var d;a.hasOwnProperty("position")&&(d=a.position);return d}function a(a){return a.isEdit}function d(a,d,f){if(!f)return f=l(a)-l(d),0===f||1===Math.abs(f);a=l(a);d=l(d);f=l(f);return a-d===d-f}this.isEditOperation=a;this.isPartOfOperationSet=function(b,h){var l=void 0!==b.group,q;if(!b.isEdit||0===h.length)return!0;q=h[h.length-1];if(l&&
|
||
|
b.group===q.group)return!0;a:switch(b.spec().optype){case "RemoveText":case "InsertText":q=!0;break a;default:q=!1}if(q&&h.some(a)){if(l){var n;l=b.spec().optype;q=new f(h,a);var m=q.previous(),g=null,e,c;runtime.assert(Boolean(m),"No edit operations found in state");c=m.group;runtime.assert(void 0!==c,"Operation has no group");for(e=1;m&&m.group===c;){if(l===m.spec().optype){n=m;break}m=q.previous()}if(n){for(m=q.previous();m;){if(m.group!==c){if(2===e)break;c=m.group;e+=1}if(l===m.spec().optype){g=
|
||
|
m;break}m=q.previous()}n=d(b,n,g)}else n=!1;return n}n=b.spec().optype;l=new f(h,a);q=l.previous();runtime.assert(Boolean(q),"No edit operations found in state");n=n===q.spec().optype?d(b,q,l.previous()):!1;return n}return!1}};(function(){function f(a,b){this.mainId=void 0!==a?a:-1;this.subId=void 0!==b?b:-1}function l(d,b,h){function l(a,b){return a+(d.isEditOperation(b)?1:0)}var q,n,m;this.addOperation=function(a){d.isEditOperation(a)&&(m+=1);n.push(a)};this.isNextStateId=function(a){return a.mainId===q&&a.subId===m};this.getNextStateId=function(){return new f(q,m)};this.getOperations=function(){return n};q=a+=1;n=b||[];m=b&&h?b.reduce(l,0):0}var a=0;gui.TrivialUndoManager=function(a){function b(){return!0!==u.isNextStateId(w)}
|
||
|
function h(a){a=a.getOperations();0<a.length&&(J=!0,v(a),J=!1)}function p(){B.emit(gui.UndoManager.signalUndoStackChanged,{undoAvailable:r.hasUndoStates(),redoAvailable:r.hasRedoStates()})}function q(a){var c=b();a!==c&&B.emit(gui.UndoManager.signalDocumentModifiedChanged,c)}function n(){u!==y&&u!==A[A.length-1]&&A.push(u)}function m(a){var b=a.previousSibling||a.nextSibling;a.parentNode.removeChild(a);x.normalizeTextNodes(b)}function g(a){return Object.keys(a).map(function(b){return a[b]})}function e(a){function b(a){var k=
|
||
|
a.spec();if(d[k.memberid])switch(k.optype){case "AddCursor":c[k.memberid]||(c[k.memberid]=a,delete d[k.memberid],f-=1);break;case "MoveCursor":e[k.memberid]||(e[k.memberid]=a)}}var c={},e={},d={},f,k;k=a.pop();s.getMemberIds().forEach(function(a){d[a]=!0});for(f=Object.keys(d).length;k&&0<f;)k=k.getOperations(),k.reverse(),k.forEach(b),k=a.pop();return new l(F,g(c).concat(g(e)))}function c(){var a=b(),c=t=s.cloneDocumentElement();x.getElementsByTagNameNS(c,k,"cursor").forEach(m);x.getElementsByTagNameNS(c,
|
||
|
k,"anchor").forEach(m);n();u=y=e([y].concat(A));A.length=0;E.length=0;a||(w=u.getNextStateId());p();q(a)}var r=this,k="urn:webodf:names:cursor",x=core.DomUtils,t,y,v,s,w,u,A=[],E=[],B=new core.EventNotifier([gui.UndoManager.signalUndoStackChanged,gui.UndoManager.signalUndoStateCreated,gui.UndoManager.signalUndoStateModified,gui.UndoManager.signalDocumentModifiedChanged,gui.TrivialUndoManager.signalDocumentRootReplaced]),F=a||new gui.UndoStateRules,J=!1;this.subscribe=function(a,b){B.subscribe(a,b)};
|
||
|
this.unsubscribe=function(a,b){B.unsubscribe(a,b)};this.isDocumentModified=b;this.setDocumentModified=function(a){b()!==a&&(w=a?new f:u.getNextStateId(),B.emit(gui.UndoManager.signalDocumentModifiedChanged,a))};this.hasUndoStates=function(){return 0<A.length};this.hasRedoStates=function(){return 0<E.length};this.setDocument=function(a){s=a};this.purgeInitialState=function(){var a=b();A.length=0;E.length=0;u=y=new l(F);w=u.getNextStateId();t=null;p();q(a)};this.setInitialState=c;this.initialize=function(){t||
|
||
|
c()};this.setPlaybackFunction=function(a){v=a};this.onOperationExecuted=function(a){if(!J){var c=b();F.isEditOperation(a)&&(u===y||0<E.length)||!F.isPartOfOperationSet(a,u.getOperations())?(E.length=0,n(),u=new l(F,[a],!0),A.push(u),B.emit(gui.UndoManager.signalUndoStateCreated,{operations:u.getOperations()}),p()):(u.addOperation(a),B.emit(gui.UndoManager.signalUndoStateModified,{operations:u.getOperations()}));q(c)}};this.moveForward=function(a){for(var c=0,e=b(),d;a&&E.length;)d=E.pop(),A.push(d),
|
||
|
h(d),a-=1,c+=1;c&&(u=A[A.length-1],p(),q(e));return c};this.moveBackward=function(a){for(var c=0,e=b();a&&A.length;)E.push(A.pop()),a-=1,c+=1;c&&(s.getMemberIds().forEach(function(a){s.removeCursor(a)}),s.setDocumentElement(t.cloneNode(!0)),B.emit(gui.TrivialUndoManager.signalDocumentRootReplaced,{}),h(y),A.forEach(h),u=A[A.length-1]||y,p(),q(e));return c};u=y=new l(F);w=u.getNextStateId()};gui.TrivialUndoManager.signalDocumentRootReplaced="documentRootReplaced"})();odf.GraphicProperties=function(f,l,a){var d=this,b=odf.Namespaces.stylens,h=odf.Namespaces.svgns;this.verticalPos=function(){return d.data.value("verticalPos")};this.verticalRel=function(){return d.data.value("verticalRel")};this.horizontalPos=function(){return d.data.value("horizontalPos")};this.horizontalRel=function(){return d.data.value("horizontalRel")};this.strokeWidth=function(){return d.data.value("strokeWidth")};d.data=new odf.LazyStyleProperties(void 0===a?void 0:a.data,{verticalPos:function(){var a=
|
||
|
f.getAttributeNS(b,"vertical-pos");return""===a?void 0:a},verticalRel:function(){var a=f.getAttributeNS(b,"vertical-rel");return""===a?void 0:a},horizontalPos:function(){var a=f.getAttributeNS(b,"horizontal-pos");return""===a?void 0:a},horizontalRel:function(){var a=f.getAttributeNS(b,"horizontal-rel");return""===a?void 0:a},strokeWidth:function(){var a=f.getAttributeNS(h,"stroke-width");return l.parseLength(a)}})};
|
||
|
odf.ComputedGraphicProperties=function(){var f;this.setGraphicProperties=function(l){f=l};this.verticalPos=function(){return f&&f.verticalPos()||"from-top"};this.verticalRel=function(){return f&&f.verticalRel()||"page"};this.horizontalPos=function(){return f&&f.horizontalPos()||"from-left"};this.horizontalRel=function(){return f&&f.horizontalRel()||"page"}};odf.PageLayoutProperties=function(f,l,a){var d=this,b=odf.Namespaces.fons;this.pageHeight=function(){return d.data.value("pageHeight")||1123};this.pageWidth=function(){return d.data.value("pageWidth")||794};d.data=new odf.LazyStyleProperties(void 0===a?void 0:a.data,{pageHeight:function(){var a;f&&(a=f.getAttributeNS(b,"page-height"),a=l.parseLength(a));return a},pageWidth:function(){var a;f&&(a=f.getAttributeNS(b,"page-width"),a=l.parseLength(a));return a}})};
|
||
|
odf.PageLayout=function(f,l,a){var d=null;f&&(d=l.getPropertiesElement("page-layout-properties",f));this.pageLayout=new odf.PageLayoutProperties(d,l,a&&a.pageLayout)};odf.PageLayoutCache=function(){};odf.PageLayoutCache.prototype.getPageLayout=function(f){};odf.PageLayoutCache.prototype.getDefaultPageLayout=function(){};odf.ParagraphProperties=function(f,l,a){var d=this,b=odf.Namespaces.fons;this.marginTop=function(){return d.data.value("marginTop")};d.data=new odf.LazyStyleProperties(void 0===a?void 0:a.data,{marginTop:function(){var d=f.getAttributeNS(b,"margin-top");return l.parsePositiveLengthOrPercent(d,"marginTop",a&&a.data)}})};
|
||
|
odf.ComputedParagraphProperties=function(){var f={},l=[];this.setStyleChain=function(a){l=a;f={}};this.marginTop=function(){var a,d;if(f.hasOwnProperty("marginTop"))a=f.marginTop;else{for(d=0;void 0===a&&d<l.length;d+=1)a=l[d].marginTop();f.marginTop=a}return a||0}};odf.TextProperties=function(f,l,a){var d=this,b=odf.Namespaces.fons;this.fontSize=function(){return d.data.value("fontSize")};d.data=new odf.LazyStyleProperties(void 0===a?void 0:a.data,{fontSize:function(){var d=f.getAttributeNS(b,"font-size");return l.parsePositiveLengthOrPercent(d,"fontSize",a&&a.data)}})};
|
||
|
odf.ComputedTextProperties=function(){var f={},l=[];this.setStyleChain=function(a){l=a;f={}};this.fontSize=function(){var a,d;if(f.hasOwnProperty("fontSize"))a=f.fontSize;else{for(d=0;void 0===a&&d<l.length;d+=1)a=l[d].fontSize();f.fontSize=a}return a||12}};odf.MasterPage=function(f,l){var a;f?(a=f.getAttributeNS(odf.Namespaces.stylens,"page-layout-name"),this.pageLayout=l.getPageLayout(a)):this.pageLayout=l.getDefaultPageLayout()};odf.MasterPageCache=function(){};odf.MasterPageCache.prototype.getMasterPage=function(f){};
|
||
|
odf.StylePileEntry=function(f,l,a,d){this.masterPage=function(){var b=f.getAttributeNS(odf.Namespaces.stylens,"master-page-name"),d=null;b&&(d=a.getMasterPage(b));return d};(function(a){var h=f.getAttributeNS(odf.Namespaces.stylens,"family"),p=null;if("graphic"===h||"chart"===h)a.graphic=void 0===d?void 0:d.graphic,p=l.getPropertiesElement("graphic-properties",f,p),null!==p&&(a.graphic=new odf.GraphicProperties(p,l,a.graphic));if("paragraph"===h||"table-cell"===h||"graphic"===h||"presentation"===
|
||
|
h||"chart"===h)a.paragraph=void 0===d?void 0:d.paragraph,p=l.getPropertiesElement("paragraph-properties",f,p),null!==p&&(a.paragraph=new odf.ParagraphProperties(p,l,a.paragraph));if("text"===h||"paragraph"===h||"table-cell"===h||"graphic"===h||"presentation"===h||"chart"===h)a.text=void 0===d?void 0:d.text,p=l.getPropertiesElement("text-properties",f,p),null!==p&&(a.text=new odf.TextProperties(p,l,a.text))})(this)};
|
||
|
odf.StylePile=function(f,l){function a(a,b){var c,h;a.hasAttributeNS(d,"parent-style-name")&&(h=a.getAttributeNS(d,"parent-style-name"),-1===b.indexOf(h)&&(c=m(h,b)));return new odf.StylePileEntry(a,f,l,c)}var d=odf.Namespaces.stylens,b={},h={},p,q={},n={},m;m=function(d,e){var c=q[d],f;!c&&(f=b[d])&&(e.push(d),c=a(f,e),q[d]=c);return c};this.getStyle=function(d){var e=n[d]||q[d],c,f=[];e||(c=h[d],c||(c=b[d])&&f.push(d),c&&(e=a(c,f)));return e};this.addCommonStyle=function(a){var e;a.hasAttributeNS(d,
|
||
|
"name")&&(e=a.getAttributeNS(d,"name"),b.hasOwnProperty(e)||(b[e]=a))};this.addAutomaticStyle=function(a){var b;a.hasAttributeNS(d,"name")&&(b=a.getAttributeNS(d,"name"),h.hasOwnProperty(b)||(h[b]=a))};this.setDefaultStyle=function(b){void 0===p&&(p=a(b,[]))};this.getDefaultStyle=function(){return p}};odf.ComputedGraphicStyle=function(){this.text=new odf.ComputedTextProperties;this.paragraph=new odf.ComputedParagraphProperties;this.graphic=new odf.ComputedGraphicProperties};
|
||
|
odf.ComputedParagraphStyle=function(){this.text=new odf.ComputedTextProperties;this.paragraph=new odf.ComputedParagraphProperties};odf.ComputedTextStyle=function(){this.text=new odf.ComputedTextProperties};
|
||
|
odf.StyleCache=function(f){function l(a,b,c,e){b=c.getAttributeNS(b,"class-names");var d;if(b)for(b=b.split(" "),d=0;d<b.length;d+=1)if(c=b[d])e.push(a),e.push(c)}function a(a,b){var c=t.getStyleName("paragraph",a);void 0!==c&&(b.push("paragraph"),b.push(c));a.namespaceURI!==k||"h"!==a.localName&&"p"!==a.localName||l("paragraph",k,a,b);return b}function d(a,b,c){var e=[],d,f,k,g;for(d=0;d<a.length;d+=2)k=a[d],g=a[d+1],k=q[k],g=k.getStyle(g),void 0!==g&&(g=g[b],void 0!==g&&g!==f&&(e.push(g),f=g));
|
||
|
k=q[c];if(g=k.getDefaultStyle())g=g[b],void 0!==g&&g!==f&&e.push(g);return e}function b(c,e){var d=t.getStyleName("text",c),g=c.parentNode;void 0!==d&&(e.push("text"),e.push(d));"span"===c.localName&&c.namespaceURI===k&&l("text",k,c,e);if(!g||g===f)return e;g.namespaceURI!==k||"p"!==g.localName&&"h"!==g.localName?b(g,e):a(g,e);return e}function h(a){a=a.getAttributeNS(x,"family");return q[a]}var p=this,q,n,m,g,e,c,r,k=odf.Namespaces.textns,x=odf.Namespaces.stylens,t=new odf.StyleInfo,y=new odf.StyleParseUtils,
|
||
|
v,s,w,u,A,E;this.getComputedGraphicStyle=function(a){var b=[];a=t.getStyleName("graphic",a);void 0!==a&&(b.push("graphic"),b.push(a));a=b.join("/");var c=g[a];runtime.assert(0===b.length%2,"Invalid style chain.");void 0===c&&(c=new odf.ComputedGraphicStyle,c.graphic.setGraphicProperties(d(b,"graphic","graphic")[0]),c.text.setStyleChain(d(b,"text","graphic")),c.paragraph.setStyleChain(d(b,"paragraph","graphic")),g[a]=c);return c};this.getComputedParagraphStyle=function(b){b=a(b,[]);var c=b.join("/"),
|
||
|
e=m[c];runtime.assert(0===b.length%2,"Invalid style chain.");void 0===e&&(e=new odf.ComputedParagraphStyle,e.text.setStyleChain(d(b,"text","paragraph")),e.paragraph.setStyleChain(d(b,"paragraph","paragraph")),m[c]=e);return e};this.getComputedTextStyle=function(a){a=b(a,[]);var c=a.join("/"),e=n[c];runtime.assert(0===a.length%2,"Invalid style chain.");void 0===e&&(e=new odf.ComputedTextStyle,e.text.setStyleChain(d(a,"text","text")),n[c]=e);return e};this.getPageLayout=function(a){var b=E[a];b||((b=
|
||
|
A[a])?(b=new odf.PageLayout(b,y,u),E[a]=b):b=u);return b};this.getDefaultPageLayout=function(){return u};this.getMasterPage=function(a){var b=s[a];void 0===b&&((b=v[a])?(b=new odf.MasterPage(b,p),s[a]=b):b=null);return b};this.getDefaultMasterPage=function(){return w};this.update=function(){var a,b,d=null,k=null;n={};m={};g={};v={};s={};E={};A={};e=new odf.StylePile(y,p);c=new odf.StylePile(y,p);r=new odf.StylePile(y,p);q={text:e,paragraph:c,graphic:r};for(a=f.styles.firstElementChild;a;)a.namespaceURI===
|
||
|
x&&((b=h(a))?"style"===a.localName?b.addCommonStyle(a):"default-style"===a.localName&&b.setDefaultStyle(a):"default-page-layout"===a.localName&&(d=a)),a=a.nextElementSibling;u=new odf.PageLayout(d,y);for(a=f.automaticStyles.firstElementChild;a;)a.namespaceURI===x&&((b=h(a))&&"style"===a.localName?b.addAutomaticStyle(a):"page-layout"===a.localName&&(A[a.getAttributeNS(x,"name")]=a)),a=a.nextElementSibling;for(a=f.masterStyles.firstElementChild;a;)a.namespaceURI===x&&"master-page"===a.localName&&(k=
|
||
|
k||a,b=a,d=b.getAttributeNS(x,"name"),0<d.length&&!v.hasOwnProperty(d)&&(v[d]=b)),a=a.nextElementSibling;w=new odf.MasterPage(k,p)}};ops.OperationTransformMatrix=function(){function f(a){a.position+=a.length;a.length*=-1}function l(a){var b=0>a.length;b&&f(a);return b}function a(a,b){function d(g){a[g]===b&&f.push(g)}var f=[];a&&["style:parent-style-name","style:next-style-name"].forEach(d);return f}function d(a,b){function d(f){a[f]===b&&delete a[f]}a&&["style:parent-style-name","style:next-style-name"].forEach(d)}function b(a){var c={};Object.keys(a).forEach(function(d){c[d]="object"===typeof a[d]?b(a[d]):a[d]});return c}function h(a,
|
||
|
b,d,f){var g,h=!1,l=!1,m,n=[];f&&f.attributes&&(n=f.attributes.split(","));a&&(d||0<n.length)&&Object.keys(a).forEach(function(b){var c=a[b],f;"object"!==typeof c&&(d&&(f=d[b]),void 0!==f?(delete a[b],l=!0,f===c&&(delete d[b],h=!0)):-1!==n.indexOf(b)&&(delete a[b],l=!0))});if(b&&b.attributes&&(d||0<n.length)){m=b.attributes.split(",");for(f=0;f<m.length;f+=1)if(g=m[f],d&&void 0!==d[g]||n&&-1!==n.indexOf(g))m.splice(f,1),f-=1,l=!0;0<m.length?b.attributes=m.join(","):delete b.attributes}return{majorChanged:h,
|
||
|
minorChanged:l}}function p(a){for(var b in a)if(a.hasOwnProperty(b))return!0;return!1}function q(a){for(var b in a)if(a.hasOwnProperty(b)&&("attributes"!==b||0<a.attributes.length))return!0;return!1}function n(a,b,d,f,g){var l=a?a[g]:null,m=b?b[g]:null,n=d?d[g]:null,s=f?f[g]:null,w;w=h(l,m,n,s);l&&!p(l)&&delete a[g];m&&!q(m)&&delete b[g];n&&!p(n)&&delete d[g];s&&!q(s)&&delete f[g];return w}function m(a,b){return{opSpecsA:[a],opSpecsB:[b]}}var g;g={AddCursor:{AddCursor:m,AddMember:m,AddStyle:m,ApplyDirectStyling:m,
|
||
|
InsertText:m,MergeParagraph:m,MoveCursor:m,RemoveCursor:m,RemoveMember:m,RemoveStyle:m,RemoveText:m,SetParagraphStyle:m,SplitParagraph:m,UpdateMember:m,UpdateMetadata:m,UpdateParagraphStyle:m},AddMember:{AddStyle:m,ApplyDirectStyling:m,InsertText:m,MergeParagraph:m,MoveCursor:m,RemoveCursor:m,RemoveStyle:m,RemoveText:m,SetParagraphStyle:m,SplitParagraph:m,UpdateMetadata:m,UpdateParagraphStyle:m},AddStyle:{AddStyle:m,ApplyDirectStyling:m,InsertText:m,MergeParagraph:m,MoveCursor:m,RemoveCursor:m,RemoveMember:m,
|
||
|
RemoveStyle:function(b,c){var f,k=[b],g=[c];b.styleFamily===c.styleFamily&&(f=a(b.setProperties,c.styleName),0<f.length&&(f={optype:"UpdateParagraphStyle",memberid:c.memberid,timestamp:c.timestamp,styleName:b.styleName,removedProperties:{attributes:f.join(",")}},g.unshift(f)),d(b.setProperties,c.styleName));return{opSpecsA:k,opSpecsB:g}},RemoveText:m,SetParagraphStyle:m,SplitParagraph:m,UpdateMember:m,UpdateMetadata:m,UpdateParagraphStyle:m},ApplyDirectStyling:{ApplyDirectStyling:function(a,c,d){var f,
|
||
|
g,h,l,m,q,w,u;l=[a];h=[c];if(!(a.position+a.length<=c.position||a.position>=c.position+c.length)){f=d?a:c;g=d?c:a;if(a.position!==c.position||a.length!==c.length)q=b(f),w=b(g);c=n(g.setProperties,null,f.setProperties,null,"style:text-properties");if(c.majorChanged||c.minorChanged)h=[],a=[],l=f.position+f.length,m=g.position+g.length,g.position<f.position?c.minorChanged&&(u=b(w),u.length=f.position-g.position,a.push(u),g.position=f.position,g.length=m-g.position):f.position<g.position&&c.majorChanged&&
|
||
|
(u=b(q),u.length=g.position-f.position,h.push(u),f.position=g.position,f.length=l-f.position),m>l?c.minorChanged&&(q=w,q.position=l,q.length=m-l,a.push(q),g.length=l-g.position):l>m&&c.majorChanged&&(q.position=m,q.length=l-m,h.push(q),f.length=m-f.position),f.setProperties&&p(f.setProperties)&&h.push(f),g.setProperties&&p(g.setProperties)&&a.push(g),d?(l=h,h=a):l=a}return{opSpecsA:l,opSpecsB:h}},InsertText:function(a,b){b.position<=a.position?a.position+=b.text.length:b.position<=a.position+a.length&&
|
||
|
(a.length+=b.text.length);return{opSpecsA:[a],opSpecsB:[b]}},MergeParagraph:function(a,b){var d=a.position,f=a.position+a.length;d>=b.sourceStartPosition&&(d-=1);f>=b.sourceStartPosition&&(f-=1);a.position=d;a.length=f-d;return{opSpecsA:[a],opSpecsB:[b]}},MoveCursor:m,RemoveCursor:m,RemoveMember:m,RemoveStyle:m,RemoveText:function(a,b){var d=a.position+a.length,f=b.position+b.length,g=[a],h=[b];f<=a.position?a.position-=b.length:b.position<d&&(a.position<b.position?a.length=f<d?a.length-b.length:
|
||
|
b.position-a.position:(a.position=b.position,f<d?a.length=d-f:g=[]));return{opSpecsA:g,opSpecsB:h}},SetParagraphStyle:m,SplitParagraph:function(a,b){b.position<a.position?a.position+=1:b.position<a.position+a.length&&(a.length+=1);return{opSpecsA:[a],opSpecsB:[b]}},UpdateMember:m,UpdateMetadata:m,UpdateParagraphStyle:m},InsertText:{InsertText:function(a,b,d){a.position<b.position?b.position+=a.text.length:a.position>b.position?a.position+=b.text.length:d?b.position+=a.text.length:a.position+=b.text.length;
|
||
|
return{opSpecsA:[a],opSpecsB:[b]}},MergeParagraph:function(a,b){a.position>=b.sourceStartPosition?a.position-=1:(a.position<b.sourceStartPosition&&(b.sourceStartPosition+=a.text.length),a.position<b.destinationStartPosition&&(b.destinationStartPosition+=a.text.length));return{opSpecsA:[a],opSpecsB:[b]}},MoveCursor:function(a,b){var d=l(b);a.position<b.position?b.position+=a.text.length:a.position<b.position+b.length&&(b.length+=a.text.length);d&&f(b);return{opSpecsA:[a],opSpecsB:[b]}},RemoveCursor:m,
|
||
|
RemoveMember:m,RemoveStyle:m,RemoveText:function(a,b){var d;d=b.position+b.length;var f=[a],g=[b];d<=a.position?a.position-=b.length:a.position<=b.position?b.position+=a.text.length:(b.length=a.position-b.position,d={optype:"RemoveText",memberid:b.memberid,timestamp:b.timestamp,position:a.position+a.text.length,length:d-a.position},g.unshift(d),a.position=b.position);return{opSpecsA:f,opSpecsB:g}},SetParagraphStyle:function(a,b){b.position>a.position&&(b.position+=a.text.length);return{opSpecsA:[a],
|
||
|
opSpecsB:[b]}},SplitParagraph:function(a,b){a.position<b.sourceParagraphPosition&&(b.sourceParagraphPosition+=a.text.length);a.position<=b.position?b.position+=a.text.length:a.position+=1;return{opSpecsA:[a],opSpecsB:[b]}},UpdateMember:m,UpdateMetadata:m,UpdateParagraphStyle:m},MergeParagraph:{MergeParagraph:function(a,b,d){var f=[a],g=[b],h;a.destinationStartPosition===b.destinationStartPosition?(f=[],g=[],a.moveCursor&&(h={optype:"MoveCursor",memberid:a.memberid,timestamp:a.timestamp,position:a.sourceStartPosition-
|
||
|
1},f.push(h)),b.moveCursor&&(h={optype:"MoveCursor",memberid:b.memberid,timestamp:b.timestamp,position:b.sourceStartPosition-1},g.push(h)),a=d?a:b,a={optype:"SetParagraphStyle",memberid:a.memberid,timestamp:a.timestamp,position:a.destinationStartPosition,styleName:a.paragraphStyleName},d?f.push(a):g.push(a)):b.sourceStartPosition===a.destinationStartPosition?(a.destinationStartPosition=b.destinationStartPosition,a.sourceStartPosition-=1,a.paragraphStyleName=b.paragraphStyleName):a.sourceStartPosition===
|
||
|
b.destinationStartPosition?(b.destinationStartPosition=a.destinationStartPosition,b.sourceStartPosition-=1,b.paragraphStyleName=a.paragraphStyleName):a.destinationStartPosition<b.destinationStartPosition?(b.destinationStartPosition-=1,b.sourceStartPosition-=1):(a.destinationStartPosition-=1,a.sourceStartPosition-=1);return{opSpecsA:f,opSpecsB:g}},MoveCursor:function(a,b){var d=b.position,f=b.position+b.length,g=Math.min(d,f),d=Math.max(d,f);g>=a.sourceStartPosition&&(g-=1);d>=a.sourceStartPosition&&
|
||
|
(d-=1);0<=b.length?(b.position=g,b.length=d-g):(b.position=d,b.length=g-d);return{opSpecsA:[a],opSpecsB:[b]}},RemoveCursor:m,RemoveMember:m,RemoveStyle:m,RemoveText:function(a,b){b.position>=a.sourceStartPosition?b.position-=1:(b.position<a.destinationStartPosition&&(a.destinationStartPosition-=b.length),b.position<a.sourceStartPosition&&(a.sourceStartPosition-=b.length));return{opSpecsA:[a],opSpecsB:[b]}},SetParagraphStyle:function(a,b){var d=[a],f=[b];if(b.position>a.sourceStartPosition)b.position-=
|
||
|
1;else if(b.position===a.destinationStartPosition||b.position===a.sourceStartPosition)b.position=a.destinationStartPosition,a.paragraphStyleName=b.styleName;return{opSpecsA:d,opSpecsB:f}},SplitParagraph:function(a,b){var d,f=[a],g=[b];b.position<a.destinationStartPosition?(a.destinationStartPosition+=1,a.sourceStartPosition+=1):b.position>=a.destinationStartPosition&&b.position<a.sourceStartPosition?(b.paragraphStyleName=a.paragraphStyleName,d={optype:"SetParagraphStyle",memberid:a.memberid,timestamp:a.timestamp,
|
||
|
position:a.destinationStartPosition,styleName:a.paragraphStyleName},f.push(d),b.position===a.sourceStartPosition-1&&a.moveCursor&&(d={optype:"MoveCursor",memberid:a.memberid,timestamp:a.timestamp,position:b.position,length:0},f.push(d)),a.destinationStartPosition=b.position+1,a.sourceStartPosition+=1):b.position>=a.sourceStartPosition&&(b.position-=1,b.sourceParagraphPosition-=1);return{opSpecsA:f,opSpecsB:g}},UpdateMember:m,UpdateMetadata:m,UpdateParagraphStyle:m},MoveCursor:{MoveCursor:m,RemoveCursor:function(a,
|
||
|
b){return{opSpecsA:a.memberid===b.memberid?[]:[a],opSpecsB:[b]}},RemoveMember:m,RemoveStyle:m,RemoveText:function(a,b){var d=l(a),g=a.position+a.length,h=b.position+b.length;h<=a.position?a.position-=b.length:b.position<g&&(a.position<b.position?a.length=h<g?a.length-b.length:b.position-a.position:(a.position=b.position,a.length=h<g?g-h:0));d&&f(a);return{opSpecsA:[a],opSpecsB:[b]}},SetParagraphStyle:m,SplitParagraph:function(a,b){var d=l(a);b.position<a.position?a.position+=1:b.position<a.position+
|
||
|
a.length&&(a.length+=1);d&&f(a);return{opSpecsA:[a],opSpecsB:[b]}},UpdateMember:m,UpdateMetadata:m,UpdateParagraphStyle:m},RemoveCursor:{RemoveCursor:function(a,b){var d=a.memberid===b.memberid;return{opSpecsA:d?[]:[a],opSpecsB:d?[]:[b]}},RemoveMember:m,RemoveStyle:m,RemoveText:m,SetParagraphStyle:m,SplitParagraph:m,UpdateMember:m,UpdateMetadata:m,UpdateParagraphStyle:m},RemoveMember:{RemoveStyle:m,RemoveText:m,SetParagraphStyle:m,SplitParagraph:m,UpdateMetadata:m,UpdateParagraphStyle:m},RemoveStyle:{RemoveStyle:function(a,
|
||
|
b){var d=a.styleName===b.styleName&&a.styleFamily===b.styleFamily;return{opSpecsA:d?[]:[a],opSpecsB:d?[]:[b]}},RemoveText:m,SetParagraphStyle:function(a,b){var d,f=[a],g=[b];"paragraph"===a.styleFamily&&a.styleName===b.styleName&&(d={optype:"SetParagraphStyle",memberid:a.memberid,timestamp:a.timestamp,position:b.position,styleName:""},f.unshift(d),b.styleName="");return{opSpecsA:f,opSpecsB:g}},SplitParagraph:m,UpdateMember:m,UpdateMetadata:m,UpdateParagraphStyle:function(b,c){var f,g=[b],h=[c];"paragraph"===
|
||
|
b.styleFamily&&(f=a(c.setProperties,b.styleName),0<f.length&&(f={optype:"UpdateParagraphStyle",memberid:b.memberid,timestamp:b.timestamp,styleName:c.styleName,removedProperties:{attributes:f.join(",")}},g.unshift(f)),b.styleName===c.styleName?h=[]:d(c.setProperties,b.styleName));return{opSpecsA:g,opSpecsB:h}}},RemoveText:{RemoveText:function(a,b){var d=a.position+a.length,f=b.position+b.length,g=[a],h=[b];f<=a.position?a.position-=b.length:d<=b.position?b.position-=a.length:b.position<d&&(a.position<
|
||
|
b.position?(a.length=f<d?a.length-b.length:b.position-a.position,d<f?(b.position=a.position,b.length=f-d):h=[]):(d<f?b.length-=a.length:b.position<a.position?b.length=a.position-b.position:h=[],f<d?(a.position=b.position,a.length=d-f):g=[]));return{opSpecsA:g,opSpecsB:h}},SetParagraphStyle:function(a,b){a.position<b.position&&(b.position-=a.length);return{opSpecsA:[a],opSpecsB:[b]}},SplitParagraph:function(a,b){var d=a.position+a.length,f=[a],g=[b];b.position<=a.position?a.position+=1:b.position<
|
||
|
d&&(a.length=b.position-a.position,d={optype:"RemoveText",memberid:a.memberid,timestamp:a.timestamp,position:b.position+1,length:d-b.position},f.unshift(d));a.position+a.length<=b.position?b.position-=a.length:a.position<b.position&&(b.position=a.position);a.position+a.length<b.sourceParagraphPosition&&(b.sourceParagraphPosition-=a.length);return{opSpecsA:f,opSpecsB:g}},UpdateMember:m,UpdateMetadata:m,UpdateParagraphStyle:m},SetParagraphStyle:{SetParagraphStyle:function(a,b,d){a.position===b.position&&
|
||
|
(d?b.styleName=a.styleName:a.styleName=b.styleName);return{opSpecsA:[a],opSpecsB:[b]}},SplitParagraph:function(a,c){var d=[a],f=[c],g;a.position>c.position?a.position+=1:a.position===c.sourceParagraphPosition&&(c.paragraphStyleName=a.styleName,g=b(a),g.position=c.position+1,d.push(g));return{opSpecsA:d,opSpecsB:f}},UpdateMember:m,UpdateMetadata:m,UpdateParagraphStyle:m},SplitParagraph:{SplitParagraph:function(a,b,d){var f,g;a.position<b.position?f=!0:b.position<a.position?g=!0:a.position===b.position&&
|
||
|
(d?f=!0:g=!0);f?(b.position+=1,b.sourceParagraphPosition=a.position<b.sourceParagraphPosition?b.sourceParagraphPosition+1:a.position+1):g&&(a.position+=1,a.sourceParagraphPosition=b.position<b.sourceParagraphPosition?a.sourceParagraphPosition+1:b.position+1);return{opSpecsA:[a],opSpecsB:[b]}},UpdateMember:m,UpdateMetadata:m,UpdateParagraphStyle:m},UpdateMember:{UpdateMetadata:m,UpdateParagraphStyle:m},UpdateMetadata:{UpdateMetadata:function(a,b,d){var f,g=[a],l=[b];f=d?a:b;a=d?b:a;h(a.setProperties||
|
||
|
null,a.removedProperties||null,f.setProperties||null,f.removedProperties||null);f.setProperties&&p(f.setProperties)||f.removedProperties&&q(f.removedProperties)||(d?g=[]:l=[]);a.setProperties&&p(a.setProperties)||a.removedProperties&&q(a.removedProperties)||(d?l=[]:g=[]);return{opSpecsA:g,opSpecsB:l}},UpdateParagraphStyle:m},UpdateParagraphStyle:{UpdateParagraphStyle:function(a,b,d){var f,g=[a],l=[b];a.styleName===b.styleName&&(f=d?a:b,a=d?b:a,n(a.setProperties,a.removedProperties,f.setProperties,
|
||
|
f.removedProperties,"style:paragraph-properties"),n(a.setProperties,a.removedProperties,f.setProperties,f.removedProperties,"style:text-properties"),h(a.setProperties||null,a.removedProperties||null,f.setProperties||null,f.removedProperties||null),f.setProperties&&p(f.setProperties)||f.removedProperties&&q(f.removedProperties)||(d?g=[]:l=[]),a.setProperties&&p(a.setProperties)||a.removedProperties&&q(a.removedProperties)||(d?l=[]:g=[]));return{opSpecsA:g,opSpecsB:l}}}};this.passUnchanged=m;this.extendTransformations=
|
||
|
function(a){Object.keys(a).forEach(function(b){var d=a[b],f,h=g.hasOwnProperty(b);runtime.log((h?"Extending":"Adding")+" map for optypeA: "+b);h||(g[b]={});f=g[b];Object.keys(d).forEach(function(a){var e=f.hasOwnProperty(a);runtime.assert(b<=a,"Wrong order:"+b+", "+a);runtime.log(" "+(e?"Overwriting":"Adding")+" entry for optypeB: "+a);f[a]=d[a]})})};this.transformOpspecVsOpspec=function(a,b){var d=a.optype<=b.optype,f;runtime.log("Crosstransforming:");runtime.log(runtime.toJson(a));runtime.log(runtime.toJson(b));
|
||
|
d||(f=a,a=b,b=f);(f=(f=g[a.optype])&&f[b.optype])?(f=f(a,b,!d),d||null===f||(f={opSpecsA:f.opSpecsB,opSpecsB:f.opSpecsA})):f=null;runtime.log("result:");f?(runtime.log(runtime.toJson(f.opSpecsA)),runtime.log(runtime.toJson(f.opSpecsB))):runtime.log("null");return f}};ops.OperationTransformer=function(){function f(a,d){for(var b,h,p=[],q=[];0<a.length&&d;){b=a.shift();b=l.transformOpspecVsOpspec(b,d);if(!b)return null;p=p.concat(b.opSpecsA);if(0===b.opSpecsB.length){p=p.concat(a);d=null;break}for(;1<b.opSpecsB.length;){h=f(a,b.opSpecsB.shift());if(!h)return null;q=q.concat(h.opSpecsB);a=h.opSpecsA}d=b.opSpecsB.pop()}d&&q.push(d);return{opSpecsA:p,opSpecsB:q}}var l=new ops.OperationTransformMatrix;this.getOperationTransformMatrix=function(){return l};this.transform=
|
||
|
function(a,d){for(var b,h=[];0<d.length;){b=f(a,d.shift());if(!b)return null;a=b.opSpecsA;h=h.concat(b.opSpecsB)}return{opSpecsA:a,opSpecsB:h}}};var webodf_css='@namespace draw url(urn:oasis:names:tc:opendocument:xmlns:drawing:1.0);@namespace fo url(urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0);@namespace office url(urn:oasis:names:tc:opendocument:xmlns:office:1.0);@namespace presentation url(urn:oasis:names:tc:opendocument:xmlns:presentation:1.0);@namespace style url(urn:oasis:names:tc:opendocument:xmlns:style:1.0);@namespace svg url(urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0);@namespace table url(urn:oasis:names:tc:opendocument:xmlns:table:1.0);@namespace text url(urn:oasis:names:tc:opendocument:xmlns:text:1.0);@namespace webodfhelper url(urn:webodf:names:helper);@namespace cursor url(urn:webodf:names:cursor);@namespace editinfo url(urn:webodf:names:editinfo);@namespace annotation url(urn:webodf:names:annotation);@namespace dc url(http://purl.org/dc/elements/1.1/);@namespace svgns url(http://www.w3.org/2000/svg);office|document > *, office|document-content > * {display: none;}office|body, office|document {display: inline-block;position: relative;}text|p, text|h {display: block;padding: 0;margin: 0;line-height: normal;position: relative;}text|p::after, text|h::after {content: "\\200B";white-space: pre;}*[webodfhelper|containsparagraphanchor] {position: relative;}text|s {white-space: pre;}text|tab {display: inline;white-space: pre;}text|tracked-changes {display: none;}office|binary-data {display: none;}office|text {display: block;text-align: left;overflow: visible;word-wrap: break-word;}office|text::selection {background: transparent;}.webodf-virtualSelections *::selection {background: transparent;}.webodf-virtualSelections *::-moz-selection {background: transparent;}office|text * draw|text-box {display: block;border: 1px solid #d3d3d3;}office|text draw|frame {z-index: 1;}office|spreadsheet {display: block;border-collapse: collapse;empty-cells: show;font-family: sans-serif;font-size: 10pt;text-align: left;page-break-inside: avoid;overflow: hidden;}office|presentation {display: inline-block;text-align: left;}#shadowContent {display: inline-block;text-align: left;}draw|page {display: block;position: relative;overflow: hidden;}presentation|notes, presentation|footer-decl, presentation|date-time-decl {display: none;}@media print {draw|page {border: 1pt solid black;page-break-inside: avoid;}presentation|notes {}}office|spreadsheet text|p {border: 0px;padding: 1px;margin: 0px;}office|spreadsheet table|table {margin: 3px;}office|spreadsheet table|table:after {}office|spreadsheet table|table-row {counter-increment: row;}office|spreadsheet table|table-row:before {width: 3em;background: #cccccc;border: 1px solid black;text-align: center;content: counter(row);display: table-cell;}office|spreadsheet table|table-cell {border: 1px solid #cccccc;}table|table {display: table;}draw|frame table|table {width: 100%;height: 100%;background: white;}table|table-header-rows {display: table-header-group;}table|table-row {display: table-row;}table|table-column {display: table-column;}table|table-cell {width: 0.889in;display: table-cell;word-break: break-all;}draw|frame {display: block;}draw|image {display: block;width: 100%;height: 100%;top: 0px;left: 0px;background-repeat: no-repeat;background-size: 100% 100%;-moz-background-size: 100% 100%;}draw|frame > draw|image:nth-of-type(n+2) {display: none;}text|list:before {display: none;content:"";}text|list {display: block;}text|list-item {display: block;}text|number {display:none;}text|a {color: blue;text-decoration: underline;cursor: pointer;}.webodf-inactiveLinks text|a {cursor: text;}text|note-citation {vertical-align: super;font-size: smaller;}text|note-body {display: none;}text|note:hover text|note-citation {background: #dddddd;}text|note:hover text|note-body {display: block;left:1em;max-width: 80%;position: absolute;background: #ffffaa;}text|bibliography-source {display: none;}svg|title, svg|desc {display: none;}video {width: 100%;height: 100%}cursor|anchor {display
|