From 89ad7ecd4ea63dc338e6cdfd59b255c4ce225df1 Mon Sep 17 00:00:00 2001 From: Tobias Hintze Date: Sat, 27 Oct 2012 23:08:13 +0200 Subject: [PATCH] include programs/viewer in the build and create zip * creates a viewer-$ver.zip * compiles viewer.js * removes the compiled webodf.js from programs/viewer/ in source --- LICENSE | 1 + programs/CMakeLists.txt | 1 + programs/viewer/CMakeLists.txt | 78 ++++ .../viewer/index-amalgamation-template.html | 70 ++++ programs/viewer/index.html | 8 +- programs/viewer/viewer.css | 2 +- programs/viewer/viewer.js | 1 + programs/viewer/webodf.js | 357 ------------------ webodf/tools/replaceByFileContents.js | 95 +++++ webodf/tools/zipper.js | 84 +++++ 10 files changed, 335 insertions(+), 362 deletions(-) create mode 100644 programs/viewer/CMakeLists.txt create mode 100644 programs/viewer/index-amalgamation-template.html delete mode 100644 programs/viewer/webodf.js create mode 100644 webodf/tools/replaceByFileContents.js create mode 100644 webodf/tools/zipper.js diff --git a/LICENSE b/LICENSE index 2547a454..4d067c63 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,5 @@ /** + * @license * Copyright (C) 2012 KO GmbH * * @licstart diff --git a/programs/CMakeLists.txt b/programs/CMakeLists.txt index d71a22df..bfcf54b9 100644 --- a/programs/CMakeLists.txt +++ b/programs/CMakeLists.txt @@ -34,3 +34,4 @@ add_subdirectory(firefoxextension) add_subdirectory(touchui) add_subdirectory(playbook) add_subdirectory(editor) +add_subdirectory(viewer) diff --git a/programs/viewer/CMakeLists.txt b/programs/viewer/CMakeLists.txt new file mode 100644 index 00000000..669fe84a --- /dev/null +++ b/programs/viewer/CMakeLists.txt @@ -0,0 +1,78 @@ +# files for the viewer +set(VIEWER_IMAGES + images/texture.png + images/toolbarButton-download.png + images/toolbarButton-fullscreen.png + images/toolbarButton-menuArrows.png + images/toolbarButton-pageDown.png + images/toolbarButton-pageUp.png + images/toolbarButton-zoomIn.png + images/toolbarButton-zoomOut.png +) + +set (RUNTIME ${CMAKE_CURRENT_SOURCE_DIR}/../../webodf/lib/runtime.js) +set (TOOLS ${CMAKE_CURRENT_SOURCE_DIR}/../../webodf/tools) + +# amalgamation: +# (write js code into into viewer.html) +set (VIEWER_MERGED_HTML viewer-amalgamation.html) +add_custom_command( + OUTPUT ${VIEWER_MERGED_HTML} + COMMAND ${NODE} ARGS ${RUNTIME} ${TOOLS}/replaceByFileContents.js + ${CMAKE_CURRENT_SOURCE_DIR}/index-amalgamation-template.html + ${VIEWER_MERGED_HTML} + @VIEWER_JS@ ${CMAKE_CURRENT_SOURCE_DIR}/viewer.js + @WEBODF_JS@ ${CMAKE_BINARY_DIR}/webodf/webodf.js + DEPENDS NodeJS ${TOOLS}/replaceByFileContents.js + ${CMAKE_BINARY_DIR}/webodf/webodf.js + ${CMAKE_CURRENT_SOURCE_DIR}/index-amalgamation-template.html +) + +# create zip file +set (VIEWER_ZIP ${CMAKE_BINARY_DIR}/viewer-${WEBODF_VERSION}.zip) +add_custom_command( + OUTPUT ${VIEWER_ZIP} + + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/images images + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/viewer.css viewer.css + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/webodf/webodf.js webodf.js + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/viewer-minimized.js viewer.js + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/index.html index.html + + # zip using javascript code running in node.js + COMMAND ${NODE} ARGS ${RUNTIME} ${TOOLS}/zipper.js + ${VIEWER_ZIP} + ${VIEWER_IMAGES} + index.html + # let's not put the amalgamation in zip until it at + # least includes css as well... + # ${VIEWER_MERGED_HTML} + webodf.js + viewer.js + viewer.css + + DEPENDS NodeJS + ${TOOLS}/replaceByFileContents.js ${VIEWER_IMAGES} + ${CMAKE_BINARY_DIR}/webodf/webodf.js + ${VIEWER_MERGED_HTML} + ${CMAKE_CURRENT_SOURCE_DIR}/index.html + ${CMAKE_CURRENT_SOURCE_DIR}/viewer.css + ${CMAKE_CURRENT_SOURCE_DIR}/viewer.js + ${CMAKE_CURRENT_BINARY_DIR}/viewer-minimized.js +) +add_custom_target(viewerzip ALL DEPENDS ${VIEWER_MERGED_HTML} ${VIEWER_ZIP}) + +# minimize js code +add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/viewer-minimized.js + COMMAND ${Java_JAVA_EXECUTABLE} + ARGS -jar ${CLOSURE_JAR} + ${SHARED_CLOSURE_ARGS} + --js ${CMAKE_CURRENT_SOURCE_DIR}/viewer.js + --compilation_level SIMPLE_OPTIMIZATIONS + --js_output_file ${CMAKE_CURRENT_BINARY_DIR}/viewer-minimized.js + DEPENDS ClosureCompiler ${CMAKE_CURRENT_SOURCE_DIR}/viewer.js + ) +add_custom_target(viewer-minimized.js) + + diff --git a/programs/viewer/index-amalgamation-template.html b/programs/viewer/index-amalgamation-template.html new file mode 100644 index 00000000..b4eec7d8 --- /dev/null +++ b/programs/viewer/index-amalgamation-template.html @@ -0,0 +1,70 @@ + + + + + + + + +
+
+
+
+
+
+
+ + + + +
+
+
+
+ +
+ +
+ + + +
+
+
+
+
+
+ + +
+
+
+
+
+
+
+ + diff --git a/programs/viewer/index.html b/programs/viewer/index.html index c55b3015..54247e2f 100644 --- a/programs/viewer/index.html +++ b/programs/viewer/index.html @@ -1,8 +1,8 @@ - - - + + + @@ -59,4 +59,4 @@ - \ No newline at end of file + diff --git a/programs/viewer/viewer.css b/programs/viewer/viewer.css index 0fe318bf..38af6ecd 100644 --- a/programs/viewer/viewer.css +++ b/programs/viewer/viewer.css @@ -541,4 +541,4 @@ html[dir='rtl'] .dropdownToolbarButton { #sliderContainer { visibility: hidden; -} \ No newline at end of file +} diff --git a/programs/viewer/viewer.js b/programs/viewer/viewer.js index f53c4d53..828264dd 100644 --- a/programs/viewer/viewer.js +++ b/programs/viewer/viewer.js @@ -1,4 +1,5 @@ /** + * @license * Copyright (C) 2012 KO GmbH * * @licstart diff --git a/programs/viewer/webodf.js b/programs/viewer/webodf.js deleted file mode 100644 index 9170a0d8..00000000 --- a/programs/viewer/webodf.js +++ /dev/null @@ -1,357 +0,0 @@ -/** - * Copyright (C) 2012 KO GmbH - - * @licstart - * The JavaScript code in this page is free software: you can redistribute it - * and/or modify it under the terms of the GNU Affero General Public License - * (GNU AGPL) as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. The code is distributed - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU AGPL for more details. - * - * As additional permission under GNU AGPL version 3 section 7, you - * may distribute non-source (e.g., minimized or compacted) forms of - * that code without the copy of the GNU GPL normally required by - * section 4, provided you include this license notice and a URL - * through which recipients can access the Corresponding Source. - * - * As a special exception to the AGPL, any HTML file which merely makes function - * calls to this code, and for that purpose includes it by reference shall be - * deemed a separate work for copyright law purposes. In addition, the copyright - * holders of this code give you permission to combine this code with free - * software libraries that are released under the GNU LGPL. You may copy and - * distribute such a system following the terms of the GNU AGPL for this code - * and the LGPL for the libraries. If you modify this code, you may extend this - * exception to your version of the code, but you are not obligated to do so. - * If you do not wish to do so, delete this exception statement from your - * version. - * - * This license applies to this entire compilation. - * @licend - * @source: http://www.webodf.org/ - * @source: http://gitorious.org/webodf/webodf/ - */ -var core={},gui={},xmldom={},odf={}; -// Input 1 -function Runtime(){}Runtime.ByteArray=function(){};Runtime.ByteArray.prototype.slice=function(){};Runtime.prototype.byteArrayFromArray=function(){};Runtime.prototype.byteArrayFromString=function(){};Runtime.prototype.byteArrayToString=function(){};Runtime.prototype.concatByteArrays=function(){};Runtime.prototype.read=function(){};Runtime.prototype.readFile=function(){};Runtime.prototype.readFileSync=function(){};Runtime.prototype.loadXML=function(){};Runtime.prototype.writeFile=function(){}; -Runtime.prototype.isFile=function(){};Runtime.prototype.getFileSize=function(){};Runtime.prototype.deleteFile=function(){};Runtime.prototype.log=function(){};Runtime.prototype.setTimeout=function(){};Runtime.prototype.libraryPaths=function(){};Runtime.prototype.type=function(){};Runtime.prototype.getDOMImplementation=function(){};Runtime.prototype.parseXML=function(){};Runtime.prototype.getWindow=function(){};var IS_COMPILED_CODE=!0; -Runtime.byteArrayToString=function(j,n){var k;if("utf8"===n){k="";var i,c=j.length,b,a,d;for(i=0;ib?k+=String.fromCharCode(b):(i+=1,a=j[i],224>b?k+=String.fromCharCode((b&31)<<6|a&63):(i+=1,d=j[i],k+=String.fromCharCode((b&15)<<12|(a&63)<<6|d&63)))}else{"binary"!==n&&this.log("Unsupported encoding: "+n);k="";c=j.length;for(i=0;if?(c[m]=f,m+=1):2048>f?(c[m]=192|f>>>6,c[m+1]=128|f&63,m+=2):(c[m]=224|f>>>12&15,c[m+1]=128|f>>>6&63,c[m+2]=128|f&63,m+=3)}else{"binary"!==a&&k.log("unknown encoding: "+a);d=b.length;c=new k.ByteArray(d);for(e=0;ec.status||0===c.status?d(null):d("Status "+String(c.status)+": "+c.responseText||c.statusText))};a=a.buffer&&!c.sendAsBinary?a.buffer:k.byteArrayToString(a,"binary");try{c.sendAsBinary?c.sendAsBinary(a):c.send(a)}catch(e){k.log("HUH? "+e+" "+a),d(e.message)}};this.deleteFile=function(b,a){delete i[b];var d=new XMLHttpRequest;d.open("DELETE",b,!0);d.onreadystatechange=function(){4=== -d.readyState&&(200>d.status&&300<=d.status?a(d.responseText):a(null))};d.send(null)};this.loadXML=function(b,a){var d=new XMLHttpRequest;d.open("GET",b,!0);d.overrideMimeType&&d.overrideMimeType("text/xml");d.onreadystatechange=function(){4===d.readyState&&(0===d.status&&!d.responseText?a("File "+b+" is empty."):200===d.status||0===d.status?a(null,d.responseXML):a(d.responseText))};try{d.send(null)}catch(c){a(c.message)}};this.isFile=function(b,a){k.getFileSize(b,function(d){a(-1!==d)})};this.getFileSize= -function(b,a){var d=new XMLHttpRequest;d.open("HEAD",b,!0);d.onreadystatechange=function(){if(4===d.readyState){var b=d.getResponseHeader("Content-Length");b?a(parseInt(b,10)):a(-1)}};d.send(null)};this.log=n;this.setTimeout=function(b,a){setTimeout(function(){b()},a)};this.libraryPaths=function(){return["lib"]};this.setCurrentDirectory=function(){};this.type=function(){return"BrowserRuntime"};this.getDOMImplementation=function(){return window.document.implementation};this.parseXML=function(b){return(new DOMParser).parseFromString(b, -"text/xml")};this.exit=function(b){n("Calling exit with code "+String(b)+", but exit() is not implemented.")};this.getWindow=function(){return window}} -function NodeJSRuntime(){function j(a,d,b){i&&(a=i+"/"+a);"binary"!==d?k.readFile(a,d,b):k.readFile(a,null,b)}var n=this,k=require("fs"),i="",c,b;this.ByteArray=function(a){return new Buffer(a)};this.byteArrayFromArray=function(a){var d=new Buffer(a.length),b,e=a.length;for(b=0;b").implementation} -function RhinoRuntime(){var j=this,n=Packages.javax.xml.parsers.DocumentBuilderFactory.newInstance(),k,i,c="";n.setValidating(!1);n.setNamespaceAware(!0);n.setExpandEntityReferences(!1);n.setSchema(null);i=Packages.org.xml.sax.EntityResolver({resolveEntity:function(b,a){var c=new Packages.java.io.FileReader(a);return new Packages.org.xml.sax.InputSource(c)}});k=n.newDocumentBuilder();k.setEntityResolver(i);this.ByteArray=function(b){return[b]};this.byteArrayFromArray=function(b){return b};this.byteArrayFromString= -function(b){var a=[],c,l=b.length;for(c=0;c>>18],c+=o[b>>>12&63],c+=o[b>>>6&63],c+=o[b&63];e===d+1?(b=a[e]<<4,c+=o[b>>>6],c+=o[b&63],c+="=="):e===d&&(b=a[e]<<10|a[e+1]<<2,c+=o[b>>>12],c+=o[b>>>6&63],c+=o[b&63],c+="=");return c}function k(a){var a=a.replace(/[^A-Za-z0-9+\/]+/g,""),b=[],c=a.length%4,e,d=a.length,g;for(e=0;e>16,g>>8&255,g&255);b.length-=[0,0,2,1][c];return b}function i(a){var b=[],c,e=a.length,d;for(c=0;cd?b.push(d):2048>d?b.push(192|d>>>6,128|d&63):b.push(224|d>>>12&15,128|d>>>6&63,128|d&63);return b}function c(a){var b=[],c,e=a.length,d,g,h;for(c=0;cd?b.push(d):(c+=1,g=a[c],224>d?b.push((d&31)<<6|g&63):(c+=1,h=a[c],b.push((d&15)<<12|(g&63)<<6|h&63)));return b}function b(a){return n(j(a))} -function a(a){return String.fromCharCode.apply(String,k(a))}function d(a){return c(j(a))}function l(a){for(var a=c(a),b="",e=0;eb?e+=String.fromCharCode(b):(h+=1,d=a.charCodeAt(h)&255,224>b?e+=String.fromCharCode((b&31)<<6|d&63):(h+=1,g=a.charCodeAt(h)&255,e+=String.fromCharCode((b&15)<<12|(d&63)<<6|g&63)));return e}function f(a,b){function c(){var h= -g+d;h>a.length&&(h=a.length);q+=e(a,g,h);g=h;h=g===a.length;b(q,h)&&!h&&runtime.setTimeout(c,0)}var d=1E5,q="",g=0;a.lengthz;z+=1)p.push(65+z);for(z=0;26>z;z+=1)p.push(97+z);for(z=0;10>z;z+=1)p.push(48+ -z);p.push(43);p.push(47);var C,p=o;z={};var w,v;w=0;for(v=p.length;w draw|image:nth-of-type(n+2) {\n display: none;\n}\ntext|list:before {\n display: none;\n content:\"\";\n}\ntext|list {\n counter-reset: list;\n}\ntext|list-item {\n display: block;\n}\ntext|number {\n display:none;\n}\n\ntext|a {\n color: blue;\n text-decoration: underline;\n cursor: pointer;\n}\ntext|note-citation {\n vertical-align: super;\n font-size: smaller;\n}\ntext|note-body {\n display: none;\n}\ntext|note:hover text|note-citation {\n background: #dddddd;\n}\ntext|note:hover text|note-body {\n display: block;\n left:1em;\n max-width: 80%;\n position: absolute;\n background: #ffffaa;\n}\nsvg|title, svg|desc {\n display: none;\n}\nvideo {\n width:100%;\n height:100%\n}\n"; -// Input 4 -core.RawDeflate=function(){function j(){this.dl=this.fc=0}function n(){this.extra_bits=this.static_tree=this.dyn_tree=null;this.max_code=this.max_length=this.elems=this.extra_base=0}function k(a,b,c,e){this.good_length=a;this.max_lazy=b;this.nice_length=c;this.max_chain=e}function i(){this.next=null;this.len=0;this.ptr=[];this.ptr.length=c;this.off=0}var c=8192,b,a,d,l,e=null,f,m,g,h,o,p,z,C,w,v,A,B,D,x,u,J,r,s,t,q,F,O,R,y,G,I,M,P,H,K,E,W,Q,N,X,ba,U,ca,$,ia,ea,fa,S,ja,aa,V,L,Y,da,ka,qa,ra=[0,0,0, -0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],ga=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],Ha=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],va=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],la;la=[new k(0,0,0,0),new k(4,4,8,4),new k(4,5,16,8),new k(4,6,32,32),new k(4,4,16,16),new k(8,16,32,32),new k(8,16,128,128),new k(8,32,128,256),new k(32,128,258,1024),new k(32,258,258,4096)];var ma=function(q){e[m+f++]=q;if(m+f===c){var g;if(0!==f){null!==b?(q=b,b=b.next):q=new i; -q.next=null;q.len=q.off=0;null===a?a=d=q:d=d.next=q;q.len=f-m;for(g=0;g>>8):(ma(a&255),ma(a>>>8))},oa=function(){A=(A<<5^h[r+3-1]&255)&8191;B=z[32768+A];z[r&32767]=B;z[32768+A]=r},T=function(a,b){w>16-b?(C|=a<>16-w,w+=b-16):(C|=a<a;a++)h[a]=h[a+32768];s-=32768;r-=32768;v-=32768;for(a=0;8192>a;a++)b=z[32768+a],z[32768+a]=32768<=b?b-32768:0;for(a=0;32768>a;a++)b=z[a],z[a]=32768<=b?b-32768:0;c+=32768}t||(a=xa(h,r+q,c),0>=a?t=!0:q+=a)},ya=function(a){var b=F,c=r,e,d=J,q=32506=y&&(b>>=2);do if(e=a,!(h[e+d]!==m||h[e+d-1]!==t||h[e]!==h[c]||h[++e]!==h[c+1])){c+=2;e++;do++c; -while(h[c]===h[++e]&&h[++c]===h[++e]&&h[++c]===h[++e]&&h[++c]===h[++e]&&h[++c]===h[++e]&&h[++c]===h[++e]&&h[++c]===h[++e]&&h[++c]===h[++e]&&cd){s=a;d=e;if(258<=e)break;t=h[c+d-1];m=h[c+d]}}while((a=z[a&32767])>q&&0!==--b);return d},ha=function(a,b){p[S++]=b;0===a?G[b].fc++:(a--,G[ca[b]+256+1].fc++,I[(256>a?$[a]:$[256+(a>>7)])&255].fc++,o[ja++]=a,V|=L);L<<=1;0===(S&7)&&(fa[aa++]=V,V=0,L=1);if(2d;d++)c+=I[d].fc*(5+ga[d]);c>>= -3;if(ja>=1,c<<=1;while(0<--b);return c>>1},Aa=function(a,b){var c=[];c.length=16;var e=0,d;for(d=1;15>=d;d++)e=e+Q[d-1]<<1,c[d]=e;for(e=0;e<=b;e++)d=a[e].dl,0!==d&&(a[e].fc=za(c[d]++,d))},ua=function(a){var b=a.dyn_tree,c=a.static_tree,e=a.elems,d,q=-1,g=e;X=0;ba=573; -for(d=0;dX;)d=N[++X]=2>q?++q:0,b[d].fc=1,U[d]=0,Y--,null!==c&&(da-=c[d].dl);a.max_code=q;for(d=X>>1;1<=d;d--)ta(b,d);do d=N[1],N[1]=N[X--],ta(b,1),c=N[1],N[--ba]=d,N[--ba]=c,b[g].fc=b[d].fc+b[c].fc,U[g]=U[d]>U[c]+1?U[d]:U[c]+1,b[d].dl=b[c].dl=g,N[1]=g++,ta(b,1);while(2<=X);N[--ba]=N[1];g=a.dyn_tree;d=a.extra_bits;var e=a.extra_base,c=a.max_code,h=a.max_length,t=a.static_tree,m,f,s,o,l=0;for(f=0;15>=f;f++)Q[f]=0;g[N[ba]].dl=0;for(a=ba+1;573>a;a++)if(m= -N[a],f=g[g[m].dl].dl+1,f>h&&(f=h,l++),g[m].dl=f,!(m>c))Q[f]++,s=0,m>=e&&(s=d[m-e]),o=g[m].fc,Y+=o*(f+s),null!==t&&(da+=o*(t[m].dl+s));if(0!==l){do{for(f=h-1;0===Q[f];)f--;Q[f]--;Q[f+1]+=2;Q[h]--;l-=2}while(0c||(g[d].dl!==f&&(Y+=(f-g[d].dl)*g[d].fc,g[d].fc=f),m--)}Aa(b,q)},Ba=function(a,b){var c,e=-1,d,g=a[0].dl,q=0,h=7,f=4;0===g&&(h=138,f=3);a[b+1].dl=65535;for(c=0;c<=b;c++)if(d=g,g=a[c+1].dl,!(++q=q?H[17].fc++:H[18].fc++,q=0,e=d,0===g)?(h=138,f=3):d===g?(h=6,f=3):(h=7,f=4)},Ca=function(){8c?$[c]:$[256+(c>>7)])&255,Z(h,b),f=ga[h],0!==f)c-=ea[h],T(c,f);q>>=1}while(e=q?(Z(17,H),T(q-3,3)):(Z(18,H),T(q-11,7));q=0;e=d;0===g?(h=138,f=3):d===g?(h=6,f=3):(h=7,f=4)}},Fa=function(){var a;for(a=0;286>a;a++)G[a].fc=0;for(a=0;30>a;a++)I[a].fc=0;for(a=0;19>a;a++)H[a].fc=0;G[256].fc=1;V=S=ja=aa=Y=da=0;L=1},pa=function(a){var c,b,e,d;d=r-v;fa[aa]=V;ua(K);ua(E);Ba(G,K.max_code);Ba(I,E.max_code);ua(W);for(e=18;3<=e&&0===H[va[e]].dl;e--);Y+=3*(e+1)+14;c=Y+3+7>> -3;b=da+3+7>>3;b<=c&&(c=b);if(d+4<=c&&0<=v){T(0+a,3);Ca();na(d);na(~d);for(e=0;ea.len&&(h=a.len);for(t=0;tf- -m&&(h=f-m);for(t=0;tp;p++){ia[p]=o;for(d=0;d<1<p;p++){ea[p]=o;for(d=0;d<1<>=7;30>p;p++){ea[p]=o<<7;for(d=0;d<1<=d;d++)Q[d]=0;for(d=0;143>=d;)M[d++].dl=8,Q[8]++;for(;255>=d;)M[d++].dl=9,Q[9]++;for(;279>=d;)M[d++].dl=7,Q[7]++;for(;287>=d;)M[d++].dl=8,Q[8]++;Aa(M,287);for(d=0;30>d;d++)P[d].dl=5,P[d].fc=za(d,5);Fa()}for(d=0;8192>d;d++)z[32768+d]=0;O=la[R].max_lazy;y=la[R].good_length;F=la[R].max_chain;v=r=0;q=xa(h,0,65536);if(0>=q)t=!0,q=0;else{for(t=!1;262>q&& -!t;)sa();for(d=A=0;2>d;d++)A=(A<<5^h[d]&255)&8191}a=null;m=f=0;3>=R?(J=2,u=0):(u=2,x=0);g=!1}l=!0;if(0===q)return g=!0,0}if((d=Ga(c,b,e))===e)return e;if(g)return d;if(3>=R)for(;0!==q&&null===a;){oa();0!==B&&32506>=r-B&&(u=ya(B),u>q&&(u=q));if(3<=u)if(p=ha(r-s,u-3),q-=u,u<=O){u--;do r++,oa();while(0!==--u);r++}else r+=u,u=0,A=h[r]&255,A=(A<<5^h[r+1]&255)&8191;else p=ha(0,h[r]&255),q--,r++;p&&(pa(0),v=r);for(;262>q&&!t;)sa()}else for(;0!==q&&null===a;){oa();J=u;D=s;u=2;0!==B&&(J=r-B)&&(u= -ya(B),u>q&&(u=q),3===u&&4096q&&!t;)sa()}0===q&&(0!==x&&ha(0,h[r-1]&255),pa(1),g=!0);return d+Ga(c,d+b,e-d)};this.deflate=function(g,q){var f,m;ka=g;qa=0;"undefined"===String(typeof q)&&(q=6);(f=q)?1>f?f=1:9f;f++)G[f]=new j;I=[];I.length=61;for(f=0;61>f;f++)I[f]=new j;M=[];M.length=288;for(f=0;288>f;f++)M[f]=new j;P=[];P.length=30;for(f=0;30>f;f++)P[f]=new j;H=[];H.length=39;for(f=0;39>f;f++)H[f]=new j;K=new n;E=new n;W=new n;Q=[];Q.length=16;N=[];N.length=573;U=[];U.length=573;ca=[];ca.length=256;$=[];$.length=512;ia=[];ia.length=29;ea=[];ea.length=30;fa=[];fa.length=1024}for(var s=Array(1024),F=[];0<(f=Ia(s,0,s.length));){var i=[];i.length=f;for(m=0;m< -f;m++)i[m]=String.fromCharCode(s[m]);F[F.length]=i.join("")}ka=null;return F.join("")}}; -// Input 5 -core.ByteArray=function(j){this.pos=0;this.data=j;this.readUInt32LE=function(){var j=this.data,k=this.pos+=4;return j[--k]<<24|j[--k]<<16|j[--k]<<8|j[--k]};this.readUInt16LE=function(){var j=this.data,k=this.pos+=2;return j[--k]<<8|j[--k]}}; -// Input 6 -core.ByteArrayWriter=function(j){var n=this,k=new runtime.ByteArray(0);this.appendByteArrayWriter=function(i){k=runtime.concatByteArrays(k,i.getByteArray())};this.appendByteArray=function(i){k=runtime.concatByteArrays(k,i)};this.appendArray=function(i){k=runtime.concatByteArrays(k,runtime.byteArrayFromArray(i))};this.appendUInt16LE=function(i){n.appendArray([i&255,i>>8&255])};this.appendUInt32LE=function(i){n.appendArray([i&255,i>>8&255,i>>16&255,i>>24&255])};this.appendString=function(i){k=runtime.concatByteArrays(k, -runtime.byteArrayFromString(i,j))};this.getLength=function(){return k.length};this.getByteArray=function(){return k}}; -// Input 7 -core.RawInflate=function(){var j,n,k=null,i,c,b,a,d,l,e,f,m,g,h,o,p,z,C=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535],w=[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],v=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,99,99],A=[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],B=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],D=[16,17,18, -0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],x=function(){this.list=this.next=null},u=function(){this.n=this.b=this.e=0;this.t=null},J=function(a,c,b,d,e,g){this.BMAX=16;this.N_MAX=288;this.status=0;this.root=null;this.m=0;var q=Array(this.BMAX+1),h,f,m,t,o,s,p,l=Array(this.BMAX+1),F,i,j,w=new u,k=Array(this.BMAX);t=Array(this.N_MAX);var z,C=Array(this.BMAX+1),n,r,O;O=this.root=null;for(o=0;oo&&(g=o);for(n=1<(n-=q[s])){this.status=2;this.m=g;return}if(0>(n-=q[o]))this.status=2,this.m=g;else{q[o]+=n;C[1]=s=0;F=q;i=1;for(j=2;0<--o;)C[j++]=s+=F[i++];F=a;o=i=0;do if(0!=(s=F[i++]))t[C[s]++]=o;while(++oz+l[1+t];){z+=l[1+t];t++;r=(r=m-z)>g?g:r;if((f=1<<(s=p-z))>a+1){f-=a+1;for(j=p;++sh&&z>z-l[t],k[t-1][s].e=w.e,k[t-1][s].b=w.b,k[t-1][s].n=w.n,k[t-1][s].t=w.t)}w.b=p-z;i>=c?w.e=99:F[i]F[i]?16:15,w.n=F[i++]): -(w.e=e[F[i]-b],w.n=d[F[i++]-b]);f=1<>z;s>=1)o^=s;for(o^=s;(o&(1<>=c;a-=c},q=function(a,c,b){var q,p,l;if(0==b)return 0;for(l=0;;){r(h);p=m.list[s(h)];for(q=p.e;16 -e;e++)j[D[e]]=0;h=7;e=new J(j,19,19,null,null,h);if(0!=e.status)return-1;m=e.root;h=e.m;p=F+i;for(d=f=0;de)j[d++]=f=e;else if(16==e){r(2);e=3+s(2);t(2);if(d+e>p)return-1;for(;0p)return-1;for(;0E;E++)K[E]=8;for(;256>E;E++)K[E]=9;for(;280>E;E++)K[E]=7;for(;288>E;E++)K[E]=8;c=7;E=new J(K,288,257,w,v,c);if(0!=E.status){alert("HufBuild error: "+E.status);D=-1;break b}k=E.root;c=E.m;for(E=0;30>E;E++)K[E]=5;F=5;E=new J(K,30,0,A,B,F);if(1e&&l.setStart(f,l.startOffset-1);l.endContainer===c?l.setEnd(f,e):l.endContainer===f&&l.endOffset>e&&l.setEnd(f,l.endOffset-1)}if(d){for(b=0;b1/l?"-0":String(l),j(b+" should be "+c+". Was "+a+".")):j(b+" should be "+c+" (of type "+typeof c+"). Was "+l+" (of type "+typeof l+").")}var i=0;this.shouldBeNull=function(c,b){k(c,b,"null")};this.shouldBeNonNull=function(c,b){var a,d;try{d=eval(b)}catch(l){a=l}a?j(b+" should be non-null. Threw exception "+a):null!==d?runtime.log("pass",b+ -" is non-null."):j(b+" should be non-null. Was "+d)};this.shouldBe=k;this.countFailedTests=function(){return i}}; -core.UnitTester=function(){var j=0,n={};this.runTests=function(k,i){function c(a){if(0===a.length)n[b]=e,j+=d.countFailedTests(),i();else{m=a[0];var g=Runtime.getFunctionName(m);runtime.log("Running "+g);h=d.countFailedTests();l.setUp();m(function(){l.tearDown();e[g]=h===d.countFailedTests();c(a.slice(1))})}}var b=Runtime.getFunctionName(k),a,d=new core.UnitTestRunner,l=new k(d),e={},f,m,g,h;if(b.hasOwnProperty(n))runtime.log("Test "+b+" has already run.");else{runtime.log("Running "+b+": "+l.description()); -g=l.tests();for(f=0;f>>8^g;return b^-1}function i(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 c(a, -c){var b,d,e,g,f,o,p,l=this;this.load=function(c){if(void 0!==l.data)c(null,l.data);else{var b=f+34+d+e+256;b+p>m&&(b=m-p);runtime.read(a,p,b,function(b,d){if(b||null===d)c(b,d);else a:{var e=d,s=new core.ByteArray(e),m=s.readUInt32LE(),p;if(67324752!==m)c("File entry signature is wrong."+m.toString()+" "+e.length.toString(),null);else{s.pos+=22;m=s.readUInt16LE();p=s.readUInt16LE();s.pos+=m+p;if(g){e=e.slice(s.pos,s.pos+f);if(f!==e.length){c("The amount of compressed bytes read was "+e.length.toString()+ -" instead of "+f.toString()+" for "+l.filename+" in "+a+".",null);break a}e=h(e,o)}else e=e.slice(s.pos,s.pos+o);o!==e.length?c("The amount of bytes read was "+e.length.toString()+" instead of "+o.toString()+" for "+l.filename+" in "+a+".",null):(l.data=e,c(null,e))}}})}};this.set=function(a,c,b,d){l.filename=a;l.data=c;l.compressed=b;l.date=d};this.error=null;c&&(b=c.readUInt32LE(),33639248!==b?this.error="Central directory entry has wrong signature at position "+(c.pos-4).toString()+' for file "'+ -a+'": '+c.data.length.toString():(c.pos+=6,g=c.readUInt16LE(),b=c.readUInt32LE(),this.date=new Date((b>>25&127)+1980,(b>>21&15)-1,b>>16&31,b>>11&15,b>>5&63,(b&31)<<1),c.readUInt32LE(),f=c.readUInt32LE(),o=c.readUInt32LE(),d=c.readUInt16LE(),e=c.readUInt16LE(),b=c.readUInt16LE(),c.pos+=8,p=c.readUInt32LE(),this.filename=runtime.byteArrayToString(c.data.slice(c.pos,c.pos+d),"utf8"),c.pos+=d+e+b))}function b(a,c){var b=null,d,e;for(e=0;em?n("File '"+j+"' cannot be read.", -o):runtime.read(j,m-22,22,function(a,b){if(a||null===n||null===b)n(a,o);else if(22!==b.length)n("Central directory length should be 22.",o);else{var e=new core.ByteArray(b),d;d=e.readUInt32LE();101010256!==d?n("Central directory signature is wrong: "+d.toString(),o):(d=e.readUInt16LE(),0!==d?n("Zip files with non-zero disk numbers are not supported.",o):(d=e.readUInt16LE(),0!==d?n("Zip files with non-zero disk numbers are not supported.",o):(d=e.readUInt16LE(),g=e.readUInt16LE(),d!==g?n("Number of entries is inconsistent.", -o):(d=e.readUInt32LE(),e=e.readUInt16LE(),e=m-22-d,runtime.read(j,e,m-e,function(a,b){if(a||null===b)n(a,o);else a:{var e=new core.ByteArray(b),d,h;f=[];for(d=0;d"}c+=d}if(1===a||3===a){for(d=i.firstChild;d;)c+=j(b,d),d=d.nextSibling;i.nodeValue&&(c+=i.nodeValue)}1===a&&(b="",1===i.nodeType&&(b+=""),c+=b);return c}var n=this;this.filter=null;this.writeToString=function(k,i){if(!k)return"";var c;if(i){c=i;var b={},a;for(a in c)c.hasOwnProperty(a)&&(b[c[a]]=a);c=b}else c={};return j(c, -k)}}; -// Input 15 -xmldom.RelaxNGParser=function(){function j(a,c){this.message=function(){c&&(a+=1===c.nodeType?" Element ":" Node ",a+=c.nodeName,c.nodeValue&&(a+=" with value '"+c.nodeValue+"'"),a+=".");return a}}function n(a){if(2>=a.e.length)return a;var c={name:a.name,e:a.e.slice(0,2)};return n({name:a.name,e:[c].concat(a.e.slice(2))})}function k(a){var a=a.split(":",2),c="",b;1===a.length?a=["",a[0]]:c=a[0];for(b in d)d[b]===c&&(a[0]=b);return a}function i(a,c){for(var b=0,d,h,o=a.name;a.e&&b=e.length)return c;0===h&&(h=0);for(var g=e.item(h);g.namespaceURI===d;){h+=1;if(h>=e.length)return c;g=e.item(h)}return g=b(a,c.attDeriv(a,e.item(h)),e,h+1)} -function a(b,c,d){d.e[0].a?(b.push(d.e[0].text),c.push(d.e[0].a.ns)):a(b,c,d.e[0]);d.e[1].a?(b.push(d.e[1].text),c.push(d.e[1].a.ns)):a(b,c,d.e[1])}var d="http://www.w3.org/2000/xmlns/",l,e,f,m,g,h,o,p,z,C,w={type:"notAllowed",nullable:!1,hash:"notAllowed",textDeriv:function(){return w},startTagOpenDeriv:function(){return w},attDeriv:function(){return w},startTagCloseDeriv:function(){return w},endTagDeriv:function(){return w}},v={type:"empty",nullable:!0,hash:"empty",textDeriv:function(){return w}, -startTagOpenDeriv:function(){return w},attDeriv:function(){return w},startTagCloseDeriv:function(){return v},endTagDeriv:function(){return w}},A={type:"text",nullable:!0,hash:"text",textDeriv:function(){return A},startTagOpenDeriv:function(){return w},attDeriv:function(){return w},startTagCloseDeriv:function(){return A},endTagDeriv:function(){return w}},B,D,x;l=i("choice",function(a,b){if(a===w)return b;if(b===w||a===b)return a},function(a,b){var d={},e;c(d,{p1:a,p2:b});b=a=void 0;for(e in d)d.hasOwnProperty(e)&& -(void 0===a?a=d[e]:b=void 0===b?d[e]:l(b,d[e]));var h=a,g=b;return{type:"choice",p1:h,p2:g,nullable:h.nullable||g.nullable,textDeriv:function(a,b){return l(h.textDeriv(a,b),g.textDeriv(a,b))},startTagOpenDeriv:k(function(a){return l(h.startTagOpenDeriv(a),g.startTagOpenDeriv(a))}),attDeriv:function(a,b){return l(h.attDeriv(a,b),g.attDeriv(a,b))},startTagCloseDeriv:j(function(){return l(h.startTagCloseDeriv(),g.startTagCloseDeriv())}),endTagDeriv:j(function(){return l(h.endTagDeriv(),g.endTagDeriv())})}}); -var u=function(a,b){if(a===w||b===w)return w;if(a===v)return b;if(b===v)return a},J={},r=0;e=function(a,b){var c=u&&u(a,b),d,h;if(void 0!==c)return c;c=a.hash||a.toString();d=b.hash||b.toString();c=f&&c.push(n(a.substring(b,d)))):"["===a[d]&&(0>=f&&(b=d+1),f+=1),d+=1;return d};k.prototype.next=function(){};k.prototype.reset=function(){};f=function(a,e,f){var j,i,m,k;for(j= -0;j text|list-item > text|list",e-=1;i=b+" > text|list-item > *:not(text|list):first-child:before{"+d+";counter-increment:list;"+("margin-left:"+h+";")+("width:"+c+";")+"display:inline-block}";try{a.insertRule(b+" > text|list-item > *:not(text|list):first-child{margin-left:"+f+";}",a.cssRules.length), -a.insertRule(i,a.cssRules.length)}catch(l){throw l;}}function e(c,h,i,j){if("list"===h)for(var o=j.firstChild,k,p;o;){if(o.namespaceURI===g)if(k=o,"list-level-style-number"===o.localName){p=k;var n=p.getAttributeNS(m,"num-format"),y=p.getAttributeNS(m,"num-suffix"),G="",G={1:"decimal",a:"lower-latin",A:"upper-latin",i:"lower-roman",I:"upper-roman"},I="",I=p.getAttributeNS(m,"num-prefix")||"",I=G.hasOwnProperty(n)?I+(" counter(list, "+G[n]+")"):n?I+("'"+n+"';"):I+" ''";y&&(I+=" '"+y+"'");p=G="content: "+ -I+";";l(c,i,k,p)}else"list-level-style-image"===o.localName?(p="content: none;",l(c,i,k,p)):"list-level-style-bullet"===o.localName&&(p="content: '"+k.getAttributeNS(g,"bullet-char")+"';",l(c,i,k,p));o=o.nextSibling}else{i=b(h,i,j).join(",");k="";if(o=a(j,m,"text-properties")){p=""+d(o,z);n=o.getAttributeNS(m,"text-underline-style");"solid"===n&&(p+="text-decoration: underline;");if(n=o.getAttributeNS(m,"font-name"))(n=u[n])&&(p+="font-family: "+n+";");k+=p}if(o=a(j,m,"paragraph-properties")){p=o; -o=""+d(p,w);p=p.getElementsByTagNameNS(m,"background-image");if(0c)break;e=e.nextSibling}a.insertBefore(b,e)}}}function c(a){this.OdfContainer=a}function b(a,b,c){var d=this;this.size=0;this.type=null;this.name=a;this.container=b;this.onchange=this.onreadystatechange=this.document=this.mimetype=this.url=null;this.EMPTY=0;this.LOADING=1;this.DONE=2;this.state=this.EMPTY;this.load=function(){if(null!==c){var b=h[a];this.mimetype=b;c.loadAsDataURL(a,b,function(a,b){d.url=b;if(d.onchange)d.onchange(d);if(d.onstatereadychange)d.onstatereadychange(d)})}}; -this.abort=function(){}}function a(){this.length=0;this.item=function(){}}var d=new odf.StyleInfo,l=new odf.Style2CSS,e="urn:oasis:names:tc:opendocument:xmlns:office:1.0",f="meta settings scripts font-face-decls styles automatic-styles master-styles body".split(" "),m=new core.Base64,g=new odf.FontLoader,h={};c.prototype=new function(){};c.prototype.constructor=c;c.namespaceURI=e;c.localName="document";b.prototype.load=function(){};b.prototype.getUrl=function(){return this.data?"data:;base64,"+m.toBase64(this.data): -null};odf.OdfContainer=function p(d,f){function m(a){for(var b=a.firstChild,c;b;)c=b.nextSibling,1===b.nodeType?m(b):7===b.nodeType&&a.removeChild(b),b=c}function n(a){var b=s.rootElement.ownerDocument,c;if(a){m(a.documentElement);try{c=b.importNode(a.documentElement,!0)}catch(d){}}return c}function A(a){s.state=a;if(s.onchange)s.onchange(s);if(s.onstatereadychange)s.onstatereadychange(s)}function B(a,b){var c="",d;for(d in b)b.hasOwnProperty(d)&&(c+=" xmlns:"+d+'="'+b[d]+'"');return''}function D(){var a=l.namespaces,b=new xmldom.LSSerializer,c=B("document-meta",a);b.filter=new k(s.rootElement);c+=b.writeToString(s.rootElement.meta,a);return c+""}function x(){var a=l.namespaces,b=new xmldom.LSSerializer,c=B("document-settings",a);b.filter=new k(s.rootElement);c+=b.writeToString(s.rootElement.settings,a);return c+""}function u(){var a=l.namespaces,b=new xmldom.LSSerializer,c=B("document-styles",a); -b.filter=new k(s.rootElement,s.rootElement.masterStyles);c+=b.writeToString(s.rootElement.fontFaceDecls,a);c+=b.writeToString(s.rootElement.styles,a);c+=b.writeToString(s.rootElement.automaticStyles,a);c+=b.writeToString(s.rootElement.masterStyles,a);return c+""}function J(){var a=l.namespaces,b=new xmldom.LSSerializer,c=B("document-content",a);b.filter=new k(s.rootElement,s.rootElement.body);c+=b.writeToString(s.rootElement.automaticStyles,a);c+=b.writeToString(s.rootElement.body, -a);return c+""}function r(a,b){var c;c=runtime.byteArrayFromString(x(),"utf8");t.save("settings.xml",c,!0,new Date);c=runtime.byteArrayFromString(D(),"utf8");t.save("meta.xml",c,!0,new Date);c=runtime.byteArrayFromString(u(),"utf8");t.save("styles.xml",c,!0,new Date);c=runtime.byteArrayFromString(J(),"utf8");t.save("content.xml",c,!0,new Date);t.writeAs(a,function(a){b(a)})}var s=this,t=null;this.onstatereadychange=f;this.parts=this.rootElement=this.state=this.onchange=null; -this.getPart=function(a){return new b(a,s,t)};this.saveAs=r;this.save=function(a){r(d,a)};this.state=p.LOADING;var q=document.createElementNS(c.namespaceURI,c.localName),F,O=new c;for(F in O)O.hasOwnProperty(F)&&(q[F]=O[F]);this.rootElement=q;this.parts=new a(this);t=new core.Zip(d,function(a,b){t=b;a?runtime.loadXML(d,function(b,c){if(b)a&&(t.error=a+"\n"+b,A(p.INVALID));else{var d=n(c);!d||"document"!==d.localName||d.namespaceURI!==e?A(p.INVALID):(s.rootElement=d,d.fontFaceDecls=j(d,e,"font-face-decls"), -d.styles=j(d,e,"styles"),d.automaticStyles=j(d,e,"automatic-styles"),d.masterStyles=j(d,e,"master-styles"),d.body=j(d,e,"body"),d.meta=j(d,e,"meta"),A(p.DONE))}}):t.loadAsDOM("styles.xml",function(a,b){var c=n(b),d=s.rootElement;!c||"document-styles"!==c.localName||c.namespaceURI!==e?A(p.INVALID):(d.fontFaceDecls=j(c,e,"font-face-decls"),i(d,d.fontFaceDecls),d.styles=j(c,e,"styles"),i(d,d.styles),d.automaticStyles=j(c,e,"automatic-styles"),i(d,d.automaticStyles),d.masterStyles=j(c,e,"master-styles"), -i(d,d.masterStyles),g.loadFonts(d.fontFaceDecls,t,null));s.state!==p.INVALID&&t.loadAsDOM("content.xml",function(a,b){var c=n(b),d,f,g;if(!c||c.localName!=="document-content"||c.namespaceURI!==e)A(p.INVALID);else{d=s.rootElement;f=j(c,e,"font-face-decls");if(d.fontFaceDecls&&f)for(g=f.firstChild;g;){d.fontFaceDecls.appendChild(g);g=f.firstChild}else if(f){d.fontFaceDecls=f;i(d,f)}f=j(c,e,"automatic-styles");if(d.automaticStyles&&f)for(g=f.firstChild;g;){d.automaticStyles.appendChild(g);g=f.firstChild}else if(f){d.automaticStyles= -f;i(d,f)}d.body=j(c,e,"body");i(d,d.body)}s.state!==p.INVALID&&t.loadAsDOM("meta.xml",function(a,c){var b=n(c),d;if(b&&!(b.localName!=="document-meta"||b.namespaceURI!==e)){d=s.rootElement;d.meta=j(b,e,"meta");i(d,d.meta)}s.state!==p.INVALID&&t.loadAsDOM("settings.xml",function(a,b){if(b){var c=n(b),d;if(c&&!(c.localName!=="document-settings"||c.namespaceURI!==e)){d=s.rootElement;d.settings=j(c,e,"settings");i(d,d.settings)}}t.loadAsDOM("META-INF/manifest.xml",function(a,c){if(c){var b=n(c),d;if(b&& -!(b.localName!=="manifest"||b.namespaceURI!=="urn:oasis:names:tc:opendocument:xmlns:manifest:1.0")){d=s.rootElement;d.manifest=b;for(b=d.manifest.firstChild;b;){b.nodeType===1&&(b.localName==="file-entry"&&b.namespaceURI==="urn:oasis:names:tc:opendocument:xmlns:manifest:1.0")&&(h[b.getAttributeNS("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0","full-path")]=b.getAttributeNS("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0","media-type"));b=b.nextSibling}}}s.state!==p.INVALID&&A(p.DONE)})})})})})})}; -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)};return odf.OdfContainer}(); -// Input 25 -odf.Formatting=function(){function j(j){function i(b,a){for(var c=b&&b.firstChild;c&&a;)c=c.nextSibling,a-=1;return c}var c=i(j.startContainer,j.startOffset);i(j.endContainer,j.endOffset);this.next=function(){return null===c?c:null}}var n=new odf.StyleInfo;this.setOdfContainer=function(){};this.isCompletelyBold=function(){return!1};this.getAlignment=function(j){this.getParagraphStyles(j)};this.getParagraphStyles=function(k){var i,c,b,a=[];for(i=0;i text|list-item > *:first-child:before {";if(y=x.getAttributeNS(h,"style-name"))x=t[y],L=x.firstChild,x=void 0,"list-level-style-number"===L.localName?(x=L.getAttributeNS(f,"num-format"),y=L.getAttributeNS(f,"num-suffix"),G="",G={1:"decimal",a:"lower-latin",A:"upper-latin",i:"lower-roman",I:"upper-roman"},I=void 0,I=L.getAttributeNS(f,"num-prefix")||"",I=G.hasOwnProperty(x)?I+(" counter(list, "+ -G[x]+")"):x?I+("'"+x+"';"):I+" ''",y&&(I+=" '"+y+"'"),x=G="content: "+I+";"):"list-level-style-image"===L.localName?x="content: none;":"list-level-style-bullet"===L.localName&&(x="content: '"+L.getAttributeNS(h,"bullet-char")+"';"),L=x;if(H){for(x=q[H];x;)H=x,x=q[H];r+="counter-increment:"+H+";";L?(L=L.replace("list",H),r+=L):r+="content:counter("+H+");"}else H="",L?(L=L.replace("list",v),r+=L):r+="content: counter("+v+");",r+="counter-increment:"+v+";",k.insertRule("text|list#"+v+" {counter-reset:"+ -v+"}",k.cssRules.length);r+="}";q[v]=H;r&&k.insertRule(r,k.cssRules.length)}e();if(w.hasOwnProperty("statereadychange")){k=w.statereadychange;for(L=0;L0?c.getRangeAt(0):null,e=d&&d.startContainer,f=d&&d.startOffset,g=d&&d.endContainer,i=d&&d.endOffset,j,k;b&&!((b.localName==="p"||b.localName==="h")&&b.namespaceURI===h);)b=b.parentNode;if(R&&b&&b.parentNode!==v){j=b.ownerDocument;k=j.documentElement.namespaceURI;if(v)v.parentNode&&u();else{v=j.createElementNS(k,"p");v.style.margin="0px";v.style.padding="0px";v.style.border="0px";v.setAttribute("contenteditable", -true)}b.parentNode.replaceChild(v,b);v.appendChild(b);v.focus();if(d){c.removeAllRanges();d=b.ownerDocument.createRange();d.setStart(e,f);d.setEnd(g,i);c.addRange(d)}if(a.preventDefault){a.preventDefault();a.stopPropagation()}else{a.returnValue=false;a.cancelBubble=true}}})};return odf.OdfCanvas}(); -// Input 27 -runtime.loadClass("odf.OdfCanvas"); -odf.CommandLineTools=function(){this.roundTrip=function(j,n,k){new odf.OdfContainer(j,function(i){if(i.state===odf.OdfContainer.INVALID)return k("Document "+j+" is invalid.");i.state===odf.OdfContainer.DONE?i.saveAs(n,function(c){k(c)}):k("Document was not completely loaded.")})};this.render=function(j,n,k){for(n=n.getElementsByTagName("body")[0];n.firstChild;)n.removeChild(n.firstChild);n=new odf.OdfCanvas(n);n.addListener("statereadychange",function(i){k(i)});n.load(j)}}; -// Input 28 -runtime.loadClass("xmldom.XPath");runtime.loadClass("odf.Style2CSS"); -gui.PresenterUI=function(){var j=new odf.Style2CSS,n=new xmldom.XPath,k=j.namespaceResolver;return function(i){var c=this;c.setInitialSlideMode=function(){c.startSlideMode("single")};c.keyDownHandler=function(b){if(!b.target.isContentEditable&&"input"!==b.target.nodeName)switch(b.keyCode){case 84:c.toggleToolbar();break;case 37:case 8:c.prevSlide();break;case 39:case 32:c.nextSlide();break;case 36:c.firstSlide();break;case 35:c.lastSlide()}};c.root=function(){return c.odf_canvas.odfContainer().rootElement}; -c.firstSlide=function(){c.slideChange(function(){return 0})};c.lastSlide=function(){c.slideChange(function(b,a){return a-1})};c.nextSlide=function(){c.slideChange(function(b,a){return b+1b?-1:b-1})};c.slideChange=function(b){var a=c.getPages(c.odf_canvas.odfContainer().rootElement),d=-1,i=0;a.forEach(function(a){a=a[1];a.hasAttribute("slide_current")&&(d=i,a.removeAttribute("slide_current"));i+=1});b=b(d,a.length);-1===b&&(b=d); -a[b][1].setAttribute("slide_current","1");document.getElementById("pagelist").selectedIndex=b;"cont"===c.slide_mode&&window.scrollBy(0,a[b][1].getBoundingClientRect().top-30)};c.selectSlide=function(b){c.slideChange(function(a,c){return b>=c||0>b?-1:b})};c.scrollIntoContView=function(b){var a=c.getPages(c.odf_canvas.odfContainer().rootElement);0!==a.length&&window.scrollBy(0,a[b][1].getBoundingClientRect().top-30)};c.getPages=function(b){var b=b.getElementsByTagNameNS(k("draw"),"page"),a=[],c;for(c= -0;cc}}var c=n.node().ownerDocument,b=new core.Cursor(j,c);this.movePointForward=function(a){k(a,n.stepForward)};this.movePointBackward=function(a){k(a,n.stepBackward)};this.moveLineForward=function(a){j.modify?j.modify(a?"extend":"move", -"forward","line"):k(a,i)};this.moveLineBackward=function(a){j.modify?j.modify(a?"extend":"move","backward","line"):k(a,function(){})};return this}; -// Input 31 -runtime.loadClass("core.PointWalker");runtime.loadClass("core.Cursor"); -gui.XMLEdit=function(j,n){function k(a,b,c){a.addEventListener?a.addEventListener(b,c,!1):a.attachEvent?a.attachEvent("on"+b,c):a["on"+b]=c}function i(a){a.preventDefault?a.preventDefault():a.returnValue=!1}function c(){var a=j.ownerDocument.defaultView.getSelection();a&&(!(0>=a.rangeCount)&&g)&&(a=a.getRangeAt(0),g.setPoint(a.startContainer,a.startOffset))}function b(){var a=j.ownerDocument.defaultView.getSelection(),b,c;a.removeAllRanges();g&&g.node()&&(b=g.node(),c=b.ownerDocument.createRange(), -c.setStart(b,g.position()),c.collapse(!0),a.addRange(c))}function a(b){for(var c=b.firstChild;c&&c!==b;)1===c.nodeType&&a(c),c=c.nextSibling||c.parentNode;var d,e,f,c=b.attributes;d="";for(f=c.length-1;0<=f;f-=1)e=c.item(f),d=d+" "+e.nodeName+'="'+e.nodeValue+'"';b.setAttribute("customns_name",b.nodeName);b.setAttribute("customns_atts",d);c=b.firstChild;for(e=/^\s*$/;c&&c!==b;)d=c,c=c.nextSibling||c.parentNode,3===d.nodeType&&e.test(d.nodeValue)&&d.parentNode.removeChild(d)}function d(a,b){for(var c= -a.firstChild,e,f,g;c&&c!==a;){if(1===c.nodeType){d(c,b);e=c.attributes;for(g=e.length-1;0<=g;g-=1)f=e.item(g),"http://www.w3.org/2000/xmlns/"===f.namespaceURI&&!b[f.nodeValue]&&(b[f.nodeValue]=f.localName)}c=c.nextSibling||c.parentNode}}function l(){var a=j.ownerDocument.createElement("style"),b;b={};d(j,b);var c={},f,g,i=0;for(f in b)if(b.hasOwnProperty(f)&&f){g=b[f];if(!g||c.hasOwnProperty(g)||"xmlns"===g){do g="ns"+i,i+=1;while(c.hasOwnProperty(g));b[f]=g}c[g]=!0}a.type="text/css";b="@namespace customns url(customns);\n"+ -e;a.appendChild(j.ownerDocument.createTextNode(b));n=n.parentNode.replaceChild(a,n)}var e,f,m,g=null;j.id||(j.id="xml"+String(Math.random()).substring(2));f="#"+j.id+" ";e=f+"*,"+f+":visited, "+f+":link {display:block; margin: 0px; margin-left: 10px; font-size: medium; color: black; background: white; font-variant: normal; font-weight: normal; font-style: normal; font-family: sans-serif; text-decoration: none; white-space: pre-wrap; height: auto; width: auto}\n"+f+":before {color: blue; content: '<' attr(customns_name) attr(customns_atts) '>';}\n"+ -f+":after {color: blue; content: '';}\n"+f+"{overflow: auto;}\n";f=j;k(f,"click",function(a){j.ownerDocument.defaultView.getSelection().getRangeAt(0);i(a)});k(f,"keydown",function(a){var d=a.charCode||a.keyCode;if((g=null)&&d===39){c();g.stepForward();b()}else if(g&&d===37){c();g.stepBackward();b()}else if(d>=16&&d<=20||d>=33&&d<=40)return;i(a)});k(f,"keypress",function(){});k(f,"drop",i);k(f,"dragend",i);k(f,"beforepaste",i);k(f,"paste",i);this.updateCSS=l;this.setXML=function(b){b= -b.documentElement||b;m=b=j.ownerDocument.importNode(b,true);for(a(b);j.lastChild;)j.removeChild(j.lastChild);j.appendChild(b);l();g=new core.PointWalker(b)};this.getXML=function(){return m}}; -// Input 32 -(function(){return"core/Async.js core/Base64.js core/ByteArray.js core/ByteArrayWriter.js core/Cursor.js core/JSLint.js core/PointWalker.js core/RawDeflate.js core/RawInflate.js core/UnitTester.js core/Zip.js gui/Caret.js gui/PresenterUI.js gui/SelectionMover.js gui/XMLEdit.js odf/CommandLineTools.js odf/FontLoader.js odf/Formatting.js odf/OdfCanvas.js odf/OdfContainer.js odf/Style2CSS.js odf/StyleInfo.js xmldom/LSSerializer.js xmldom/LSSerializerFilter.js xmldom/OperationalTransformDOM.js xmldom/OperationalTransformInterface.js xmldom/RelaxNG.js xmldom/RelaxNG2.js xmldom/RelaxNGParser.js xmldom/XPath.js".split(" ")})(); diff --git a/webodf/tools/replaceByFileContents.js b/webodf/tools/replaceByFileContents.js new file mode 100644 index 00000000..ff0ac0c2 --- /dev/null +++ b/webodf/tools/replaceByFileContents.js @@ -0,0 +1,95 @@ +/** + * Copyright (C) 2012 KO GmbH + * + * @licstart + * The JavaScript code in this page is free software: you can redistribute it + * and/or modify it under the terms of the GNU Affero General Public License + * (GNU AGPL) as published by the Free Software Foundation, either version 3 of + * the License, or (at your option) any later version. The code is distributed + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU AGPL for more details. + * + * As additional permission under GNU AGPL version 3 section 7, you + * may distribute non-source (e.g., minimized or compacted) forms of + * that code without the copy of the GNU GPL normally required by + * section 4, provided you include this license notice and a URL + * through which recipients can access the Corresponding Source. + * + * As a special exception to the AGPL, any HTML file which merely makes function + * calls to this code, and for that purpose includes it by reference shall be + * deemed a separate work for copyright law purposes. In addition, the copyright + * holders of this code give you permission to combine this code with free + * software libraries that are released under the GNU LGPL. You may copy and + * distribute such a system following the terms of the GNU AGPL for this code + * and the LGPL for the libraries. If you modify this code, you may extend this + * exception to your version of the code, but you are not obligated to do so. + * If you do not wish to do so, delete this exception statement from your + * version. + * + * This license applies to this entire compilation. + * @licend + * @source: http://www.webodf.org/ + * @source: http://gitorious.org/webodf/webodf/ + */ +/*global runtime: true, core: true*/ + +/** + * tool used in build process. + * + * this tool reads argv[1] and writes it to argv[2] + * after replacing every occurance of argv[2n+1] with + * the contents of the file argv[2n+2] + * (for n>0) + * + */ + +var i, input_file, output_file, keywords=[]; +i = 1; +input_file = arguments[i]; i+=1; +output_file = arguments[i]; i+=1; + +for (; i+1 + * + * @licstart + * The JavaScript code in this page is free software: you can redistribute it + * and/or modify it under the terms of the GNU Affero General Public License + * (GNU AGPL) as published by the Free Software Foundation, either version 3 of + * the License, or (at your option) any later version. The code is distributed + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU AGPL for more details. + * + * As additional permission under GNU AGPL version 3 section 7, you + * may distribute non-source (e.g., minimized or compacted) forms of + * that code without the copy of the GNU GPL normally required by + * section 4, provided you include this license notice and a URL + * through which recipients can access the Corresponding Source. + * + * As a special exception to the AGPL, any HTML file which merely makes function + * calls to this code, and for that purpose includes it by reference shall be + * deemed a separate work for copyright law purposes. In addition, the copyright + * holders of this code give you permission to combine this code with free + * software libraries that are released under the GNU LGPL. You may copy and + * distribute such a system following the terms of the GNU AGPL for this code + * and the LGPL for the libraries. If you modify this code, you may extend this + * exception to your version of the code, but you are not obligated to do so. + * If you do not wish to do so, delete this exception statement from your + * version. + * + * This license applies to this entire compilation. + * @licend + * @source: http://www.webodf.org/ + * @source: http://gitorious.org/webodf/webodf/ + */ + +/** + * tool used in build process. + * + * this tool creates a zip archive argv[1] + * of all entries argv[n]. + * (n>1) + * + */ + + +/*global runtime: true, core: true*/ +runtime.loadClass("core.Zip"); + +function addFiles(zip, pos, files, callback) { + "use strict"; + if (pos >= files.length) { + zip.write(function (err) { + return callback(err); + }); + return; + } + var entry = {}; + entry.path = files[pos]; + entry.date = new Date(); + runtime.readFile(entry.path, "binary", function (err, data) { + if (err) { + return callback(err); + } + runtime.log("["+zip.filename+"] << \""+entry.path+"\""); + zip.save(entry.path, data, false, entry.date); + addFiles(zip, pos + 1, files, callback); + }); +} + +var args = arguments, + filename = args[1], + zipmembers = [], + i, + zip = new core.Zip(filename, null); + zip.filename = filename; +for (i = 2; i < arguments.length; i += 1) { + zipmembers.push(arguments[i]); +} + +addFiles(zip, 0, zipmembers, function (err) { + "use strict"; + if (err) { + runtime.log(err); + } +});