From ed10170ef754f4b346232e3e41a523fc054b4e20 Mon Sep 17 00:00:00 2001 From: Jos van den Oever Date: Thu, 23 Aug 2012 14:50:17 +0200 Subject: [PATCH 01/33] Add abstraction for XML parsing. --- webodf/lib/runtime.js | 40 ++++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/webodf/lib/runtime.js b/webodf/lib/runtime.js index 6fdcca7d..f9c6286d 100644 --- a/webodf/lib/runtime.js +++ b/webodf/lib/runtime.js @@ -31,10 +31,10 @@ * @source: http://gitorious.org/odfkit/webodf/ */ /*jslint nomen: true, evil: true, bitwise: true */ -/*global window: true, XMLHttpRequest: true, require: true, console: true, - process: true, __dirname: true, setTimeout: true, Packages: true, print: true, - readFile: true, quit: true, Buffer: true, ArrayBuffer: true, Uint8Array: true, - navigator: true, VBArray: true */ +/*global window, XMLHttpRequest, require, console, DOMParser, + process, __dirname, setTimeout, Packages, print, + readFile, quit, Buffer, ArrayBuffer, Uint8Array, + navigator, VBArray */ /** * Three implementations of a runtime for browser, node.js and rhino. */ @@ -159,6 +159,11 @@ Runtime.prototype.type = function () {"use strict"; }; * @return {?DOMImplementation} */ Runtime.prototype.getDOMImplementation = function () {"use strict"; }; +/** + * @param {!string} xml + * @return {?Document} + */ +Runtime.prototype.parseXML = function (xml) {"use strict"; }; /** * @return {?Window} */ @@ -624,6 +629,10 @@ function BrowserRuntime(logoutput) { this.getDOMImplementation = function () { return window.document.implementation; }; + this.parseXML = function (xml) { + var parser = new DOMParser(); + return parser.parseFromString(xml, "text/xml"); + }; this.exit = function (exitCode) { log("Calling exit with code " + String(exitCode) + ", but exit() is not implemented."); @@ -641,7 +650,9 @@ function NodeJSRuntime() { "use strict"; var self = this, fs = require('fs'), - currentDirectory = ""; + currentDirectory = "", + parser, + domImplementation; /** * @constructor @@ -708,14 +719,11 @@ function NodeJSRuntime() { } this.readFile = readFile; function loadXML(path, callback) { - var DOMParser = require('xmldom').DOMParser, - parser = new DOMParser(); readFile(path, "utf-8", function (err, data) { if (err) { return callback(err); } - var dom = parser.parseFromString(data, "text/xml"); - callback(null, dom); + callback(null, self.parseXML(data)); }); } this.loadXML = loadXML; @@ -789,12 +797,21 @@ function NodeJSRuntime() { return "NodeJSRuntime"; }; this.getDOMImplementation = function () { - return null; + return domImplementation; + }; + this.parseXML = function (xml) { + return parser.parseFromString(xml, "text/xml"); }; this.exit = process.exit; this.getWindow = function () { return null; }; + function init() { + var DOMParser = require('xmldom').DOMParser; + parser = new DOMParser(); + domImplementation = self.parseXML("").implementation; + } + init(); } /** @@ -977,6 +994,9 @@ function RhinoRuntime() { this.getDOMImplementation = function () { return builder.getDOMImplementation(); }; + this.parseXML = function (xml) { + return builder.parse(xml); + }; this.exit = quit; this.getWindow = function () { return null; From 73b46156a21648048f8e7e3b17dee6f54e7c8cad Mon Sep 17 00:00:00 2001 From: Jos van den Oever Date: Tue, 11 Sep 2012 10:50:56 +0200 Subject: [PATCH 02/33] Update JSLint and Node.JS. --- CMakeLists.txt | 4 +- webodf/lib/core/JSLint.js | 139 ++++++++++++++++++++++++-------------- 2 files changed, 89 insertions(+), 54 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cb6c8a0d..d86e4f00 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,8 +65,8 @@ set(JSDOCDIR ${CMAKE_BINARY_DIR}/JsDoc-prefix/src/JsDoc/jsdoc-toolkit) # Node.JS ExternalProject_Add( NodeJS - URL "http://nodejs.org/dist/v0.8.7/node-v0.8.7.tar.gz" - URL_MD5 44427fff86cbf865f9bb459b6024e9b7 + URL "http://nodejs.org/dist/v0.8.8/node-v0.8.8.tar.gz" + URL_MD5 f4dae84e96a94b768404c14633bccd49 CONFIGURE_COMMAND "./configure" BUILD_IN_SOURCE 1 INSTALL_COMMAND "" diff --git a/webodf/lib/core/JSLint.js b/webodf/lib/core/JSLint.js index 7e45244c..f4eb5e3c 100644 --- a/webodf/lib/core/JSLint.js +++ b/webodf/lib/core/JSLint.js @@ -1,5 +1,5 @@ // jslint.js -// 2012-07-13 +// 2012-08-23 // Copyright (c) 2002 Douglas Crockford (www.JSLint.com) @@ -143,10 +143,10 @@ // You can request a properties report, which produces a list of the program's // properties in the form of a /*properties*/ declaration. -// var myPropertyReport = properties_report(JSLINT.property); +// var myPropertyReport = JSLINT.properties_report(JSLINT.property); // You can obtain the parse tree that JSLint constructed while parsing. The -// latest tree is kept in JSLINT.tree. A nice stringication can be produced +// latest tree is kept in JSLINT.tree. A nice stringification can be produced // with // JSON.stringify(JSLINT.tree, [ @@ -299,14 +299,14 @@ unclosed_comment, unclosed_regexp, undef, undefined, unescaped_a, unexpected_a, unexpected_char_a_b, unexpected_comment, unexpected_else, unexpected_label_a, unexpected_property_a, unexpected_space_a_b, - 'unicode-bidi', unnecessary_initialize, unnecessary_use, unparam, - unreachable_a_b, unrecognized_style_attribute_a, unrecognized_tag_a, unsafe, - unused, url, urls, use_array, use_braces, use_charAt, use_object, use_or, - use_param, used_before_a, var, var_a_not, vars, 'vertical-align', video, - visibility, was, weird_assignment, weird_condition, weird_new, - weird_program, weird_relation, weird_ternary, white, 'white-space', width, - windows, 'word-spacing', 'word-wrap', wrap, wrap_immediate, wrap_regexp, - write_is_wrong, writeable, 'z-index' + unexpected_typeof_a, 'unicode-bidi', unnecessary_initialize, + unnecessary_use, unparam, unreachable_a_b, unrecognized_style_attribute_a, + unrecognized_tag_a, unsafe, unused, url, urls, use_array, use_braces, + use_charAt, use_object, use_or, use_param, used_before_a, var, var_a_not, + vars, 'vertical-align', video, visibility, was, weird_assignment, + weird_condition, weird_new, weird_program, weird_relation, weird_ternary, + white, 'white-space', width, windows, 'word-spacing', 'word-wrap', wrap, + wrap_immediate, wrap_regexp, write_is_wrong, writeable, 'z-index' */ // The global directive is used to declare global variables that can @@ -511,7 +511,7 @@ var JSLINT = (function () { expected_selector_a: "Expected a CSS selector, and instead saw {a}.", expected_small_a: "Expected a small positive integer and instead saw '{a}'", expected_space_a_b: "Expected exactly one space between '{a}' and '{b}'.", - expected_string_a: "Expected a string and instead saw {a}.", + expected_string_a: "Expected a string and instead saw '{a}'.", expected_style_attribute: "Excepted a style attribute, and instead saw '{a}'.", expected_style_pattern: "Expected a style pattern, and instead saw '{a}'.", expected_tagname_a: "Expected a tagName, and instead saw {a}.", @@ -591,6 +591,8 @@ var JSLINT = (function () { unexpected_label_a: "Unexpected label '{a}'.", unexpected_property_a: "Unexpected /*property*/ '{a}'.", unexpected_space_a_b: "Unexpected space between '{a}' and '{b}'.", + unexpected_typeof_a: "Unexpected 'typeof'. " + + "Use '===' to compare directly with {a}.", unnecessary_initialize: "It is not necessary to initialize '{a}' " + "to 'undefined'.", unnecessary_use: "Unnecessary 'use strict'.", @@ -2544,7 +2546,7 @@ klass: do { x.thru = 1; x.line = 0; x.edge = 'edge'; - s.string = s; + x.string = s; return postscript(x); } @@ -2589,13 +2591,26 @@ klass: do { } this.first = expression(150); this.arity = 'prefix'; - if (this.id === '++' || this.id === '--') { + switch (this.id) { + case '++': + case '--': if (!option.plusplus) { warn('unexpected_a', this); } else if ((!this.first.identifier || this.first.reserved) && this.first.id !== '.' && this.first.id !== '[') { warn('bad_operand', this); } + break; + case '+': + case '-': + switch (this.first.id) { + case '[': + case '{': + case '!': + warn('unexpected_a', this.first); + break; + } + break; } return this; }; @@ -2693,7 +2708,10 @@ klass: do { warn(message || bundle.weird_condition, node); break; case '(': - if (node.first.id === '.' && numbery[node.first.second.string] === true) { + if (node.first.id === 'new' || + (node.first.string === 'Boolean') || + (node.first.id === '.' && + numbery[node.first.second.string] === true)) { warn(message || bundle.weird_condition, node); } break; @@ -2738,6 +2756,15 @@ klass: do { ((left.id === '(string)' || left.id === '(number)') && (right.id === '(string)' || right.id === '(number)'))) { warn('weird_relation', that); + } else if (left.id === 'typeof') { + if (right.id !== '(string)') { + warn("expected_string_a", right, right.id === '(number)' + ? right.number + : right.string); + } else if (right.string === 'undefined' || + right.string === 'null') { + warn("unexpected_typeof_a", left, right.string); + } } that.first = left; that.second = check_relation(right); @@ -2904,7 +2931,7 @@ klass: do { // If this is an expression statement, determine if it is acceptable. // We do not like -// new Blah(); +// new Blah; // statments. If it is to be used at all, new should only be used to make // objects, not side effects. The expression statements we do like do // assignment or invocation or delete. @@ -2917,7 +2944,7 @@ klass: do { the_statement.id !== 'delete' && the_statement.id !== '++' && the_statement.id !== '--') { - warn('assignment_function_expression', token); + warn('assignment_function_expression', the_statement); } semicolon(); } @@ -3527,7 +3554,7 @@ klass: do { }); infix('(', 160, function (left, that) { - var p; + var e, p; if (indent && indent.mode === 'expression') { no_space(prev_token, token); } else { @@ -3564,7 +3591,11 @@ klass: do { no_space(); for (;;) { edge(); - p.push(expression(10)); + e = expression(10); + if (left.string === 'Boolean' && (e.id === '!' || e.id === '~')) { + warn('weird_condition', e); + } + p.push(e); if (next_token.id !== ',') { break; } @@ -6250,6 +6281,9 @@ klass: do { itself.error_report = function (data) { var evidence, i, output = [], snippets, warning; if (data.errors) { + if (data.json) { + output.push('JSON: bad.
'); + } for (i = 0; i < data.errors.length; i += 1) { warning = data.errors[i]; if (warning) { @@ -6295,20 +6329,17 @@ klass: do { } output.push(''); } - if (data.json) { - output.push('

JSON: bad.

'); - } return output.join(''); }; itself.report = function (data) { - var dl, err, i, j, names, output = [], the_function; + var dl, i, j, names, output = [], the_function; function detail(h, value) { var comma_needed, singularity; if (Array.isArray(value)) { - output.push('
' + h + '
'); + output.push("
" + h + "
"); value.sort().forEach(function (item) { if (item !== singularity) { singularity = item; @@ -6316,54 +6347,58 @@ klass: do { comma_needed = true; } }); - output.push('
'); + output.push(""); } else if (value) { - output.push('
' + h + '
', value, '
'); + output.push("
" + h + "
", value, "
"); } } output.push('
'); if (data.urls) { - detail("url", data.urls); + detail('url', data.urls); dl = true; } if (data.globals) { detail('global', data.globals); dl = true; } else if (xmode === 'style') { - output.push('

CSS.

'); - } else if (data.json && !err) { - output.push('

JSON: good.

'); + output.push("
CSS.
"); + } else if (data.json) { + if (!data.errors) { + output.push("
JSON: good.
"); + } } else { - output.push('
No new global variables introduced.
'); + output.push("
No new global variables introduced.
"); } if (dl) { - output.push('
'); + output.push(""); } else { output[0] = ''; } - for (i = 0; i < data.functions.length; i += 1) { - the_function = data.functions[i]; - names = []; - if (the_function.params) { - for (j = 0; j < the_function.params.length; j += 1) { - names[j] = the_function.params[j].string; + if (data.functions) { + for (i = 0; i < data.functions.length; i += 1) { + the_function = data.functions[i]; + names = []; + if (the_function.params) { + for (j = 0; j < the_function.params.length; j += 1) { + names[j] = the_function.params[j].string; + } } + output.push('
line ' + + String(the_function.line) + '
' + + the_function.name.entityify() + + '(' + names.join(', ') + ')'); + detail('undefined', the_function['undefined']); + detail('unused', the_function.unused); + detail('closure', the_function.closure); + detail('variable', the_function['var']); + detail('exception', the_function.exception); + detail('outer', the_function.outer); + detail('global', the_function.global); + detail('label', the_function.label); + output.push('
'); } - output.push('
line ' + - String(the_function.line) + '
' + - the_function.name.entityify() + - '(' + names.join(', ') + ')'); - detail('undefined', the_function['undefined']); - detail('unused', the_function.unused); - detail('closure', the_function.closure); - detail('variable', the_function['var']); - detail('exception', the_function.exception); - detail('outer', the_function.outer); - detail('global', the_function.global); - detail('label', the_function.label); - output.push('
'); } return output.join(''); }; @@ -6404,7 +6439,7 @@ klass: do { itself.jslint = itself; - itself.edition = '2012-07-13'; + itself.edition = '2012-08-23'; return itself; }()); From 3f82e131c51a82ca4351a20e4229ae1d5ede75c1 Mon Sep 17 00:00:00 2001 From: Aditya Bhatt Date: Fri, 17 Aug 2012 17:44:37 +0530 Subject: [PATCH 03/33] Tell CMake that webodf.css.js is in tools/ --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d86e4f00..bfda402e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -94,7 +94,7 @@ if (NOT ANT) endif(NOT ANT) set(LIBJSFILES lib/packages.js lib/runtime.js lib/core/Base64.js - webodf.css.js + tools/webodf.css.js lib/core/RawDeflate.js lib/core/ByteArray.js lib/core/ByteArrayWriter.js lib/core/RawInflate.js From bbaa8e6e99d3a9bd8e7ed30dbed4e19b9e3ae619 Mon Sep 17 00:00:00 2001 From: Jos van den Oever Date: Mon, 27 Aug 2012 12:06:29 +0200 Subject: [PATCH 04/33] Fix generation of webodf.css.js. --- CMakeLists.txt | 2 +- webodf/CMakeLists.txt | 14 ++++++++++---- webodf/lib/runtime.js | 2 +- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bfda402e..28c9e90d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -94,7 +94,7 @@ if (NOT ANT) endif(NOT ANT) set(LIBJSFILES lib/packages.js lib/runtime.js lib/core/Base64.js - tools/webodf.css.js + ${CMAKE_CURRENT_BINARY_DIR}/webodf/webodf.css.js lib/core/RawDeflate.js lib/core/ByteArray.js lib/core/ByteArrayWriter.js lib/core/RawInflate.js diff --git a/webodf/CMakeLists.txt b/webodf/CMakeLists.txt index 9a183a00..1d9f990c 100644 --- a/webodf/CMakeLists.txt +++ b/webodf/CMakeLists.txt @@ -26,9 +26,10 @@ add_custom_target(jslintcheck ALL ) add_custom_command( - OUTPUT webodf.css.js + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/webodf.css.js COMMAND ${NODE} - ARGS lib/runtime.js tools/css2js.js webodf.css webodf.css.js + ARGS lib/runtime.js tools/css2js.js webodf.css + ${CMAKE_CURRENT_BINARY_DIR}/webodf.css.js DEPENDS NodeJS lib/runtime.js tools/css2js.js webodf.css WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) @@ -42,8 +43,13 @@ if (Java_JAVA_EXECUTABLE) set(SHARED_CLOSURE_ARGS --warning_level VERBOSE --jscomp_error accessControls --jscomp_error ambiguousFunctionDecl --jscomp_error checkRegExp --jscomp_error checkTypes --jscomp_error checkVars --jscomp_error constantProperty --jscomp_error deprecated --jscomp_error externsValidation --jscomp_error fileoverviewTags --jscomp_error globalThis --jscomp_error invalidCasts --jscomp_error missingProperties --jscomp_error strictModuleDepCheck --jscomp_error typeInvalidation --jscomp_error undefinedVars --jscomp_error unknownDefines --jscomp_error uselessCode --jscomp_error visibility --jscomp_off nonStandardJsDocs --summary_detail_level 3) foreach(JSFILE ${LIBJSFILES}) - set(LIB_CLOSURE_ARGS ${LIB_CLOSURE_ARGS} - --js ${CMAKE_CURRENT_SOURCE_DIR}/${JSFILE}) + if (IS_ABSOLUTE ${JSFILE}) + set(LIB_CLOSURE_ARGS ${LIB_CLOSURE_ARGS} + --js ${JSFILE}) + else (IS_ABSOLUTE ${JSFILE}) + set(LIB_CLOSURE_ARGS ${LIB_CLOSURE_ARGS} + --js ${CMAKE_CURRENT_SOURCE_DIR}/${JSFILE}) + endif (IS_ABSOLUTE ${JSFILE}) endforeach(JSFILE ${LIBJSFILES}) foreach(JSFILE ${TESTJSFILES}) diff --git a/webodf/lib/runtime.js b/webodf/lib/runtime.js index f9c6286d..62d22672 100644 --- a/webodf/lib/runtime.js +++ b/webodf/lib/runtime.js @@ -728,7 +728,7 @@ function NodeJSRuntime() { } this.loadXML = loadXML; this.writeFile = function (path, data, callback) { - if (currentDirectory) { + if (currentDirectory && !path[0] === '/') { path = currentDirectory + "/" + path; } fs.writeFile(path, data, "binary", function (err) { From 130e76746dc6197dba829bc397895e5d05ade859 Mon Sep 17 00:00:00 2001 From: Jos van den Oever Date: Mon, 27 Aug 2012 12:11:06 +0200 Subject: [PATCH 05/33] Fix path check. --- webodf/lib/runtime.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webodf/lib/runtime.js b/webodf/lib/runtime.js index 62d22672..7888cca7 100644 --- a/webodf/lib/runtime.js +++ b/webodf/lib/runtime.js @@ -728,7 +728,7 @@ function NodeJSRuntime() { } this.loadXML = loadXML; this.writeFile = function (path, data, callback) { - if (currentDirectory && !path[0] === '/') { + if (currentDirectory && path[0] !== '/') { path = currentDirectory + "/" + path; } fs.writeFile(path, data, "binary", function (err) { From fd65da33d730f6d514fe0d62df26a4e714ef6603 Mon Sep 17 00:00:00 2001 From: Jos van den Oever Date: Mon, 27 Aug 2012 12:17:21 +0200 Subject: [PATCH 06/33] Fix path check. --- programs/CMakeLists.txt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/programs/CMakeLists.txt b/programs/CMakeLists.txt index dc02189b..d71a22df 100644 --- a/programs/CMakeLists.txt +++ b/programs/CMakeLists.txt @@ -2,13 +2,18 @@ macro(COPY_FILES _varname _srcdir _tgtdir) foreach(_file ${ARGN}) GET_FILENAME_COMPONENT(_subdir ${_file} PATH) FILE(MAKE_DIRECTORY ${_tgtdir}/${_subdir}) + if (IS_ABSOLUTE ${_file}) + SET(_srcfile ${_file}) + else (IS_ABSOLUTE ${_file}) + SET(_srcfile ${_srcdir}/${_file}) + endif (IS_ABSOLUTE ${_file}) add_custom_command( OUTPUT ${_tgtdir}/${_file} COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different - ${_srcdir}/${_file} + ${_srcfile} ${_tgtdir}/${_file} DEPENDS - ${_srcdir}/${_file} + ${_srcfile} ) set(${_varname} ${${_varname}} ${_tgtdir}/${_file}) endforeach(_file) From d2c21788b59acfd1b4ea45b59e2bfea424362042 Mon Sep 17 00:00:00 2001 From: Tobias Hintze Date: Mon, 17 Sep 2012 16:52:26 +0200 Subject: [PATCH 07/33] workaround recent JSLint pain (typeof foo !== "undefined") --- webodf/lib/core/RawDeflate.js | 2 +- webodf/lib/core/UnitTester.js | 2 +- webodf/lib/odf/OdfCanvas.js | 2 +- webodf/lib/runtime.js | 10 +++++----- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/webodf/lib/core/RawDeflate.js b/webodf/lib/core/RawDeflate.js index 5fdd2b02..068dc7d6 100644 --- a/webodf/lib/core/RawDeflate.js +++ b/webodf/lib/core/RawDeflate.js @@ -1810,7 +1810,7 @@ core.RawDeflate = function () { zip_deflate_data = str; zip_deflate_pos = 0; - if (typeof level === "undefined") { + if (String(typeof level) === "undefined") { level = zip_DEFAULT_LEVEL; } zip_deflate_start(level); diff --git a/webodf/lib/core/UnitTester.js b/webodf/lib/core/UnitTester.js index 4dbe1fa2..0a8531ad 100644 --- a/webodf/lib/core/UnitTester.js +++ b/webodf/lib/core/UnitTester.js @@ -134,7 +134,7 @@ core.UnitTestRunner = function UnitTestRunner() { exception); } else if (isResultCorrect(av, bv)) { testPassed(a + " is " + b); - } else if (typeof av === typeof bv) { + } else if (String(typeof av) === String(typeof bv)) { testFailed(a + " should be " + bv + ". Was " + stringify(av) + "."); } else { testFailed(a + " should be " + bv + " (of type " + typeof bv + diff --git a/webodf/lib/odf/OdfCanvas.js b/webodf/lib/odf/OdfCanvas.js index 55e7fce1..57a17c8a 100644 --- a/webodf/lib/odf/OdfCanvas.js +++ b/webodf/lib/odf/OdfCanvas.js @@ -804,7 +804,7 @@ odf.OdfCanvas = (function () { function addWebODFStyleSheet(document) { var head = document.getElementsByTagName('head')[0], style; - if (typeof (webodf_css) !== 'undefined') { + if (String(typeof webodf_css) !== "undefined") { style = document.createElementNS(head.namespaceURI, 'style'); style.setAttribute('media', 'screen, print, handheld, projection'); style.appendChild(document.createTextNode(webodf_css)); diff --git a/webodf/lib/runtime.js b/webodf/lib/runtime.js index 7888cca7..962881df 100644 --- a/webodf/lib/runtime.js +++ b/webodf/lib/runtime.js @@ -388,7 +388,7 @@ function BrowserRuntime(logoutput) { } else if (xhr.status === 200 || xhr.status === 0) { // report file if (encoding === "binary") { - if (typeof VBArray !== "undefined") { // IE9 + if (String(typeof VBArray) !== "undefined") { // IE9 data = new VBArray(xhr.responseBody).toArray(); } else { data = self.byteArrayFromString(xhr.responseText, @@ -435,7 +435,7 @@ function BrowserRuntime(logoutput) { callback("File " + path + " is empty."); } else if (xhr.status === 200 || xhr.status === 0) { // report file - if (typeof VBArray !== "undefined") { + if (String(typeof VBArray) !== "undefined") { data = new VBArray(xhr.responseBody).toArray(); } else { data = self.byteArrayFromString(xhr.responseText, "binary"); @@ -1010,9 +1010,9 @@ function RhinoRuntime() { var runtime = (function () { "use strict"; var result; - if (typeof window !== "undefined") { + if (String(typeof window) !== "undefined") { result = new BrowserRuntime(window.document.getElementById("logoutput")); - } else if (typeof require !== "undefined") { + } else if (String(typeof require) !== "undefined") { result = new NodeJSRuntime(); } else { result = new RhinoRuntime(); @@ -1163,5 +1163,5 @@ var runtime = (function () { } else { run(args.slice(1)); } -}(typeof arguments !== "undefined" && arguments)); +}(String(typeof arguments) !== "undefined" && arguments)); From 8966cfc3e5e98a6242867841dd8d325b0b525396 Mon Sep 17 00:00:00 2001 From: Aditya Bhatt Date: Mon, 17 Sep 2012 19:09:47 +0530 Subject: [PATCH 08/33] add vendor prefixes --- webodf/lib/odf/OdfCanvas.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/webodf/lib/odf/OdfCanvas.js b/webodf/lib/odf/OdfCanvas.js index 57a17c8a..3bac8176 100644 --- a/webodf/lib/odf/OdfCanvas.js +++ b/webodf/lib/odf/OdfCanvas.js @@ -864,8 +864,14 @@ odf.OdfCanvas = (function () { if (!odfdoc) { return; } + element.style.zoom = zoomLevel; element.style.WebkitTransform = 'scale(' + zoomLevel + ')'; element.style.WebkitTransformOrigin = 'left top'; + element.style.MozTransform = 'scale(' + zoomLevel + ')'; + element.style.MozTransformOrigin = 'left top'; + element.style.OTransform = 'scale(' + zoomLevel + ')'; + element.style.OTransformOrigin = 'left top'; + element.style.width = Math.round(zoomLevel * odfdoc.offsetWidth) + "px"; element.style.height = Math.round(zoomLevel * odfdoc.offsetHeight) From 9fdab7069cfe9d979c5f1210d57e4f1947706020 Mon Sep 17 00:00:00 2001 From: Aditya Bhatt Date: Wed, 19 Sep 2012 16:00:38 +0530 Subject: [PATCH 09/33] Viewer app. Added basic toolbar and canvas. --- programs/viewer/index.html | 16 ++ programs/viewer/viewer.css | 42 +++++ programs/viewer/viewer.js | 15 ++ programs/viewer/webodf.js | 356 +++++++++++++++++++++++++++++++++++++ 4 files changed, 429 insertions(+) create mode 100644 programs/viewer/index.html create mode 100644 programs/viewer/viewer.css create mode 100644 programs/viewer/viewer.js create mode 100644 programs/viewer/webodf.js diff --git a/programs/viewer/index.html b/programs/viewer/index.html new file mode 100644 index 00000000..948fa32b --- /dev/null +++ b/programs/viewer/index.html @@ -0,0 +1,16 @@ + + + + + + + + +
+ +
+
+
+
+ + diff --git a/programs/viewer/viewer.css b/programs/viewer/viewer.css new file mode 100644 index 00000000..ceccc262 --- /dev/null +++ b/programs/viewer/viewer.css @@ -0,0 +1,42 @@ +* { + padding: 0; + margin: 0; +} + +#toolbar { + position: relative; + top: 0px; + left: 0px; + height: 32px; + width: 100%; + + background-image: linear-gradient(rgba(82, 82, 82, .99), rgba(69, 69, 69, .95)); + background-image: -webkit-linear-gradient(rgba(82, 82, 82, .99), rgba(69, 69, 69, .95)); + background-image: -moz-linear-gradient(rgba(82, 82, 82, .99), rgba(69, 69, 69, .95)); + background-image: -ms-linear-gradient(rgba(82, 82, 82, .99), rgba(69, 69, 69, .95)); + background-image: -o-linear-gradient(rgba(82, 82, 82, .99), rgba(69, 69, 69, .95)); + + box-shadow: inset 1px 0 0 rgba(255, 255, 255, .08), inset 0 1px 1px rgba(0, 0, 0, .15), inset 0 -1px 0 rgba(255, 255, 255, .05), 0 1px 0 rgba(0, 0, 0, .15), 0 1px 1px rgba(0, 0, 0, .1); +} + +#canvasContainer { + overflow: auto; + padding-top: 30px; + position: absolute; + top: 32px; + right: 0; + bottom: 0; + left: 0; + + text-align: center; + + background-color: #888; +} + +#canvas { + box-shadow: 0px 0px 7px rgba(0, 0, 0, 0.75); + -webkit-box-shadow: 0px 0px 7px rgba(0, 0, 0, 0.75); + -moz-box-shadow: 0px 0px 7px rgba(0, 0, 0, 0.75); + -ms-box-shadow: 0px 0px 7px rgba(0, 0, 0, 0.75); + -o-box-shadow: 0px 0px 7px rgba(0, 0, 0, 0.75); +} diff --git a/programs/viewer/viewer.js b/programs/viewer/viewer.js new file mode 100644 index 00000000..a27d9cc5 --- /dev/null +++ b/programs/viewer/viewer.js @@ -0,0 +1,15 @@ +window.onload = function() { + // If the URL has a fragment (#...), try to load the file it represents + var location = String(document.location), + pos = location.indexOf('#'); + location = location.substr(pos + 1); + if(pos === -1 || location.length == 0) { + console.log('Could not parse file path argument.'); + return; + } + + var odfElement = document.getElementById('canvas'), + odfCanvas = new odf.OdfCanvas(odfElement); + + odfCanvas.load(location); +}; diff --git a/programs/viewer/webodf.js b/programs/viewer/webodf.js new file mode 100644 index 00000000..d16849da --- /dev/null +++ b/programs/viewer/webodf.js @@ -0,0 +1,356 @@ +// Input 0 +/* + + @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/odfkit/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(i,n){var k;if("utf8"===n){k="";var h,b=i.length,c,a,d;for(h=0;hc?k+=String.fromCharCode(c):(h+=1,a=i[h],224>c?k+=String.fromCharCode((c&31)<<6|a&63):(h+=1,d=i[h],k+=String.fromCharCode((c&15)<<12|(a&63)<<6|d&63)))}else{"binary"!==n&&this.log("Unsupported encoding: "+n);k="";b=i.length;for(h=0;hf?(b[m]=f,m+=1):2048>f?(b[m]=192|f>>>6,b[m+1]=128|f&63,m+=2):(b[m]=224|f>>>12&15,b[m+1]=128|f>>>6&63,b[m+2]=128|f&63,m+=3)}else{"binary"!==a&&k.log("unknown encoding: "+a);d=c.length;b=new k.ByteArray(d);for(e=0;eb.status||0===b.status?d(null):d("Status "+String(b.status)+": "+b.responseText||b.statusText))};a=a.buffer&&!b.sendAsBinary?a.buffer:k.byteArrayToString(a,"binary");try{b.sendAsBinary?b.sendAsBinary(a):b.send(a)}catch(e){k.log("HUH? "+e+" "+a),d(e.message)}};this.deleteFile=function(c,a){delete h[c];var d=new XMLHttpRequest;d.open("DELETE",c,!0);d.onreadystatechange=function(){4=== +d.readyState&&(200>d.status&&300<=d.status?a(d.responseText):a(null))};d.send(null)};this.loadXML=function(c,a){var d=new XMLHttpRequest;d.open("GET",c,!0);d.overrideMimeType&&d.overrideMimeType("text/xml");d.onreadystatechange=function(){4===d.readyState&&(0===d.status&&!d.responseText?a("File "+c+" is empty."):200===d.status||0===d.status?a(null,d.responseXML):a(d.responseText))};try{d.send(null)}catch(b){a(b.message)}};this.isFile=function(c,a){k.getFileSize(c,function(d){a(-1!==d)})};this.getFileSize= +function(c,a){var d=new XMLHttpRequest;d.open("HEAD",c,!0);d.onreadystatechange=function(){if(4===d.readyState){var c=d.getResponseHeader("Content-Length");c?a(parseInt(c,10)):a(-1)}};d.send(null)};this.log=n;this.setTimeout=function(c,a){setTimeout(function(){c()},a)};this.libraryPaths=function(){return["lib"]};this.setCurrentDirectory=function(){};this.type=function(){return"BrowserRuntime"};this.getDOMImplementation=function(){return window.document.implementation};this.parseXML=function(c){return(new DOMParser).parseFromString(c, +"text/xml")};this.exit=function(c){n("Calling exit with code "+String(c)+", but exit() is not implemented.")};this.getWindow=function(){return window}} +function NodeJSRuntime(){function i(a,d,c){h&&(a=h+"/"+a);"binary"!==d?k.readFile(a,d,c):k.readFile(a,null,c)}var n=this,k=require("fs"),h="",b,c;this.ByteArray=function(a){return new Buffer(a)};this.byteArrayFromArray=function(a){var d=new Buffer(a.length),c,e=a.length;for(c=0;c").implementation} +function RhinoRuntime(){var i=this,n=Packages.javax.xml.parsers.DocumentBuilderFactory.newInstance(),k,h,b="";n.setValidating(!1);n.setNamespaceAware(!0);n.setExpandEntityReferences(!1);n.setSchema(null);h=Packages.org.xml.sax.EntityResolver({resolveEntity:function(c,a){var b=new Packages.java.io.FileReader(a);return new Packages.org.xml.sax.InputSource(b)}});k=n.newDocumentBuilder();k.setEntityResolver(h);this.ByteArray=function(c){return[c]};this.byteArrayFromArray=function(c){return c};this.byteArrayFromString= +function(c){var a=[],b,j=c.length;for(b=0;b>>18],b+=o[c>>>12&63],b+=o[c>>>6&63],b+=o[c&63];e===d+1?(c=a[e]<<4,b+=o[c>>>6],b+=o[c&63],b+="=="):e===d&&(c=a[e]<<10|a[e+1]<<2,b+=o[c>>>12],b+=o[c>>>6&63],b+=o[c&63],b+="=");return b}function k(a){var a=a.replace(/[^A-Za-z0-9+\/]+/g,""),c=[],b=a.length%4,e,d=a.length,l;for(e=0;e>16,l>>8&255,l&255);c.length-=[0,0,2,1][b];return c}function h(a){var c=[],b,e=a.length,d;for(b=0;bd?c.push(d):2048>d?c.push(192|d>>>6,128|d&63):c.push(224|d>>>12&15,128|d>>>6&63,128|d&63);return c}function b(a){var c=[],b,e=a.length,d,l,g;for(b=0;bd?c.push(d):(b+=1,l=a[b],224>d?c.push((d&31)<<6|l&63):(b+=1,g=a[b],c.push((d&15)<<12|(l&63)<<6|g&63)));return c}function c(a){return n(i(a))} +function a(a){return String.fromCharCode.apply(String,k(a))}function d(a){return b(i(a))}function j(a){for(var a=b(a),c="",e=0;ec?e+=String.fromCharCode(c):(g+=1,d=a.charCodeAt(g)&255,224>c?e+=String.fromCharCode((c&31)<<6|d&63):(g+=1,l=a.charCodeAt(g)&255,e+=String.fromCharCode((c&15)<<12|(d&63)<<6|l&63)));return e}function f(a,c){function b(){var g= +l+d;g>a.length&&(g=a.length);q+=e(a,l,g);l=g;g=l===a.length;c(q,g)&&!g&&runtime.setTimeout(b,0)}var d=1E5,q="",l=0;a.lengthy;y+=1)p.push(65+y);for(y=0;26>y;y+=1)p.push(97+y);for(y=0;10>y;y+=1)p.push(48+ +y);p.push(43);p.push(47);var B,p=o;y={};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 i(){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,c,b,e){this.good_length=a;this.max_lazy=c;this.nice_length=b;this.max_chain=e}function h(){this.next=null;this.len=0;this.ptr=[];this.ptr.length=b;this.off=0}var b=8192,c,a,d,j,e=null,f,m,l,g,o,p,y,B,w,v,A,z,C,x,u,I,r,s,t,q,G,T,R,E,D,M,N,P,H,K,F,W,Q,O,X,ba,U,ca,J,ia,ea,fa,Y,ja,aa,V,L,Z,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(l){e[m+f++]=l;if(m+f===b){var g;if(0!==f){null!==c?(l=c,c=c.next):l=new h; +l.next=null;l.len=l.off=0;null===a?a=d=l:d=d.next=l;l.len=f-m;for(g=0;g>>8):(ma(a&255),ma(a>>>8))},oa=function(){A=(A<<5^g[r+3-1]&255)&8191;z=y[32768+A];y[r&32767]=z;y[32768+A]=r},S=function(a,c){w>16-c?(B|=a<>16-w,w+=c-16):(B|=a<a;a++)g[a]=g[a+32768];s-=32768;r-=32768;v-=32768;for(a=0;8192>a;a++)c=y[32768+a],y[32768+a]=32768<=c?c-32768:0;for(a=0;32768>a;a++)c=y[a],y[a]=32768<=c?c-32768:0;b+=32768}t||(a=xa(g,r+q,b),0>=a?t=!0:q+=a)},ya=function(a){var c=G,b=r,e,d=I,l=32506=E&&(c>>=2);do if(e=a,!(g[e+d]!==m||g[e+d-1]!==t||g[e]!==g[b]||g[++e]!==g[b+1])){b+=2;e++;do++b; +while(g[b]===g[++e]&&g[++b]===g[++e]&&g[++b]===g[++e]&&g[++b]===g[++e]&&g[++b]===g[++e]&&g[++b]===g[++e]&&g[++b]===g[++e]&&g[++b]===g[++e]&&bd){s=a;d=e;if(258<=e)break;t=g[b+d-1];m=g[b+d]}}while((a=y[a&32767])>l&&0!==--c);return d},ha=function(a,c){p[Y++]=c;0===a?D[c].fc++:(a--,D[ca[c]+256+1].fc++,M[(256>a?J[a]:J[256+(a>>7)])&255].fc++,o[ja++]=a,V|=L);L<<=1;0===(Y&7)&&(fa[aa++]=V,V=0,L=1);if(2d;d++)b+=M[d].fc*(5+ga[d]);b>>= +3;if(ja>=1,b<<=1;while(0<--c);return b>>1},Aa=function(a,c){var b=[];b.length=16;var e=0,d;for(d=1;15>=d;d++)e=e+Q[d-1]<<1,b[d]=e;for(e=0;e<=c;e++)d=a[e].dl,0!==d&&(a[e].fc=za(b[d]++,d))},ua=function(a){var c=a.dyn_tree,b=a.static_tree,e=a.elems,d,l=-1,g=e;X=0;ba=573; +for(d=0;dX;)d=O[++X]=2>l?++l:0,c[d].fc=1,U[d]=0,Z--,null!==b&&(da-=b[d].dl);a.max_code=l;for(d=X>>1;1<=d;d--)ta(c,d);do d=O[1],O[1]=O[X--],ta(c,1),b=O[1],O[--ba]=d,O[--ba]=b,c[g].fc=c[d].fc+c[b].fc,U[g]=U[d]>U[b]+1?U[d]:U[b]+1,c[d].dl=c[b].dl=g,O[1]=g++,ta(c,1);while(2<=X);O[--ba]=O[1];g=a.dyn_tree;d=a.extra_bits;var e=a.extra_base,b=a.max_code,q=a.max_length,t=a.static_tree,m,f,s,o,j=0;for(f=0;15>=f;f++)Q[f]=0;g[O[ba]].dl=0;for(a=ba+1;573>a;a++)if(m= +O[a],f=g[g[m].dl].dl+1,f>q&&(f=q,j++),g[m].dl=f,!(m>b))Q[f]++,s=0,m>=e&&(s=d[m-e]),o=g[m].fc,Z+=o*(f+s),null!==t&&(da+=o*(t[m].dl+s));if(0!==j){do{for(f=q-1;0===Q[f];)f--;Q[f]--;Q[f+1]+=2;Q[q]--;j-=2}while(0b||(g[d].dl!==f&&(Z+=(f-g[d].dl)*g[d].fc,g[d].fc=f),m--)}Aa(c,l)},Ba=function(a,c){var b,e=-1,d,l=a[0].dl,g=0,q=7,f=4;0===l&&(q=138,f=3);a[c+1].dl=65535;for(b=0;b<=c;b++)if(d=l,l=a[b+1].dl,!(++g=g?H[17].fc++:H[18].fc++,g=0,e=d,0===l)?(q=138,f=3):d===l?(q=6,f=3):(q=7,f=4)},Ca=function(){8b?J[b]:J[256+(b>>7)])&255,$(q,c),f=ga[q],0!==f)b-=ea[q],S(b,f);g>>=1}while(e=l?($(17,H),S(l-3,3)):($(18,H),S(l-11,7));l=0;e=d;0===g?(q=138,f=3):d===g?(q=6,f=3):(q=7,f=4)}},Fa=function(){var a;for(a=0;286>a;a++)D[a].fc=0;for(a=0;30>a;a++)M[a].fc=0;for(a=0;19>a;a++)H[a].fc=0;D[256].fc=1;V=Y=ja=aa=Z=da=0;L=1},pa=function(a){var b,c,e,d;d=r-v;fa[aa]=V;ua(K);ua(F);Ba(D,K.max_code);Ba(M,F.max_code);ua(W);for(e=18;3<=e&&0===H[va[e]].dl;e--);Z+=3*(e+1)+14;b=Z+3+7>> +3;c=da+3+7>>3;c<=b&&(b=c);if(d+4<=b&&0<=v){S(0+a,3);Ca();na(d);na(~d);for(e=0;ea.len&&(q=a.len);for(t=0;tf- +m&&(q=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;)N[d++].dl=8,Q[8]++;for(;255>=d;)N[d++].dl=9,Q[9]++;for(;279>=d;)N[d++].dl=7,Q[7]++;for(;287>=d;)N[d++].dl=8,Q[8]++;Aa(N,287);for(d=0;30>d;d++)P[d].dl=5,P[d].fc=za(d,5);Fa()}for(d=0;8192>d;d++)y[32768+d]=0;T=la[R].max_lazy;E=la[R].good_length;G=la[R].max_chain;v=r=0;q=xa(g,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^g[d]&255)&8191}a=null;m=f=0;3>=R?(I=2,u=0):(u=2,x=0);l=!1}j=!0;if(0===q)return l=!0,0}if((d=Ga(b,c,e))===e)return e;if(l)return d;if(3>=R)for(;0!==q&&null===a;){oa();0!==z&&32506>=r-z&&(u=ya(z),u>q&&(u=q));if(3<=u)if(p=ha(r-s,u-3),q-=u,u<=T){u--;do r++,oa();while(0!==--u);r++}else r+=u,u=0,A=g[r]&255,A=(A<<5^g[r+1]&255)&8191;else p=ha(0,g[r]&255),q--,r++;p&&(pa(0),v=r);for(;262>q&&!t;)sa()}else for(;0!==q&&null===a;){oa();I=u;C=s;u=2;0!==z&&(I=r-z)&&(u= +ya(z),u>q&&(u=q),3===u&&4096q&&!t;)sa()}0===q&&(0!==x&&ha(0,g[r-1]&255),pa(1),l=!0);return d+Ga(b,d+c,e-d)};this.deflate=function(q,l){var f,m;ka=q;qa=0;"undefined"===String(typeof l)&&(l=6);(f=l)?1>f?f=1:9f;f++)D[f]=new i;M=[];M.length=61;for(f=0;61>f;f++)M[f]=new i;N=[];N.length=288;for(f=0;288>f;f++)N[f]=new i;P=[];P.length=30;for(f=0;30>f;f++)P[f]=new i;H=[];H.length=39;for(f=0;39>f;f++)H[f]=new i;K=new n;F=new n;W=new n;Q=[];Q.length=16;O=[];O.length=573;U=[];U.length=573;ca=[];ca.length=256;J=[];J.length=512;ia=[];ia.length=29;ea=[];ea.length=30;fa=[];fa.length=1024}for(var s=Array(1024),G=[];0<(f=Ia(s,0,s.length));){var h=[];h.length=f;for(m=0;m< +f;m++)h[m]=String.fromCharCode(s[m]);G[G.length]=h.join("")}ka=null;return G.join("")}}; +// Input 5 +core.ByteArray=function(i){this.pos=0;this.data=i;this.readUInt32LE=function(){var i=this.data,k=this.pos+=4;return i[--k]<<24|i[--k]<<16|i[--k]<<8|i[--k]};this.readUInt16LE=function(){var i=this.data,k=this.pos+=2;return i[--k]<<8|i[--k]}}; +// Input 6 +core.ByteArrayWriter=function(i){var n=this,k=new runtime.ByteArray(0);this.appendByteArrayWriter=function(h){k=runtime.concatByteArrays(k,h.getByteArray())};this.appendByteArray=function(h){k=runtime.concatByteArrays(k,h)};this.appendArray=function(h){k=runtime.concatByteArrays(k,runtime.byteArrayFromArray(h))};this.appendUInt16LE=function(h){n.appendArray([h&255,h>>8&255])};this.appendUInt32LE=function(h){n.appendArray([h&255,h>>8&255,h>>16&255,h>>24&255])};this.appendString=function(h){k=runtime.concatByteArrays(k, +runtime.byteArrayFromString(h,i))};this.getLength=function(){return k.length};this.getByteArray=function(){return k}}; +// Input 7 +core.RawInflate=function(){var i,n,k=null,h,b,c,a,d,j,e,f,m,l,g,o,p,y,B=[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],z=[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],C=[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},I=function(a,b,c,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),l,f,m,t,o,s,p,j=Array(this.BMAX+1),G,h,i,w=new u,k=Array(this.BMAX);t=Array(this.N_MAX);var y,B=Array(this.BMAX+1),n,r,z;z=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;B[1]=s=0;G=q;h=1;for(i=2;0<--o;)B[i++]=s+=G[h++];G=a;o=h=0;do if(0!=(s=G[h++]))t[B[s]++]=o;while(++oy+j[1+t];){y+=j[1+t];t++;r=(r=m-y)>g?g:r;if((f=1<<(s=p-y))>a+1){f-=a+1;for(i=p;++sl&&y>y-j[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-y;h>=b?w.e=99:G[h]G[h]?16:15,w.n=G[h++]): +(w.e=e[G[h]-c],w.n=d[G[h++]-c]);f=1<>y;s>=1)o^=s;for(o^=s;(o&(1<>=b;a-=b},q=function(a,b,c){var q,p,j;if(0==c)return 0;for(j=0;;){r(g);p=m.list[s(g)];for(q=p.e;16 +e;e++)i[C[e]]=0;g=7;e=new I(i,19,19,null,null,g);if(0!=e.status)return-1;m=e.root;g=e.m;p=G+h;for(d=f=0;de)i[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(;0F;F++)K[F]=8;for(;256>F;F++)K[F]=9;for(;280>F;F++)K[F]=7;for(;288>F;F++)K[F]=8;b=7;F=new I(K,288,257,w,v,b);if(0!=F.status){alert("HufBuild error: "+F.status);C=-1;break b}k=F.root;b=F.m;for(F=0;30>F;F++)K[F]=5;G=5;F=new I(K,30,0,A,z,G);if(1e&&j.setStart(f,j.startOffset-1);j.endContainer===b?j.setEnd(f,e):j.endContainer===f&&j.endOffset>e&&j.setEnd(f,j.endOffset-1)}if(d){for(c=0;c1/j?"-0":String(j),i(c+" should be "+b+". Was "+a+".")):i(c+" should be "+b+" (of type "+typeof b+"). Was "+j+" (of type "+typeof j+").")}var h=0;this.shouldBeNull=function(b,c){k(b,c,"null")};this.shouldBeNonNull=function(b,c){var a,d;try{d=eval(c)}catch(j){a=j}a?i(c+" should be non-null. Threw exception "+a):null!==d?runtime.log("pass",c+ +" is non-null."):i(c+" should be non-null. Was "+d)};this.shouldBe=k;this.countFailedTests=function(){return h}}; +core.UnitTester=function(){var i=0,n={};this.runTests=function(k,h){function b(a){if(0===a.length)n[c]=e,i+=d.countFailedTests(),h();else{m=a[0];var f=Runtime.getFunctionName(m);runtime.log("Running "+f);g=d.countFailedTests();j.setUp();m(function(){j.tearDown();e[f]=g===d.countFailedTests();b(a.slice(1))})}}var c=Runtime.getFunctionName(k),a,d=new core.UnitTestRunner,j=new k(d),e={},f,m,l,g;if(c.hasOwnProperty(n))runtime.log("Test "+c+" has already run.");else{runtime.log("Running "+c+": "+j.description()); +l=j.tests();for(f=0;f>>8^f;return c^-1}function h(a){var b=a.getFullYear();return 1980>b?0:b-1980<<25|a.getMonth()+1<<21|a.getDate()<<16|a.getHours()<<11|a.getMinutes()<<5|a.getSeconds()>>1}function b(a, +b){var c,d,e,f,l,o,p,j=this;this.load=function(b){if(void 0!==j.data)b(null,j.data);else{var c=l+34+d+e+256;c+p>m&&(c=m-p);runtime.read(a,p,c,function(c,d){if(c||null===d)b(c,d);else a:{var e=d,s=new core.ByteArray(e),m=s.readUInt32LE(),p;if(67324752!==m)b("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(f){e=e.slice(s.pos,s.pos+l);if(l!==e.length){b("The amount of compressed bytes read was "+e.length.toString()+ +" instead of "+l.toString()+" for "+j.filename+" in "+a+".",null);break a}e=g(e,o)}else e=e.slice(s.pos,s.pos+o);o!==e.length?b("The amount of bytes read was "+e.length.toString()+" instead of "+o.toString()+" for "+j.filename+" in "+a+".",null):(j.data=e,b(null,e))}}})}};this.set=function(a,b,c,d){j.filename=a;j.data=b;j.compressed=c;j.date=d};this.error=null;b&&(c=b.readUInt32LE(),33639248!==c?this.error="Central directory entry has wrong signature at position "+(b.pos-4).toString()+' for file "'+ +a+'": '+b.data.length.toString():(b.pos+=6,f=b.readUInt16LE(),c=b.readUInt32LE(),this.date=new Date((c>>25&127)+1980,(c>>21&15)-1,c>>16&31,c>>11&15,c>>5&63,(c&31)<<1),b.readUInt32LE(),l=b.readUInt32LE(),o=b.readUInt32LE(),d=b.readUInt16LE(),e=b.readUInt16LE(),c=b.readUInt16LE(),b.pos+=8,p=b.readUInt32LE(),this.filename=runtime.byteArrayToString(b.data.slice(b.pos,b.pos+d),"utf8"),b.pos+=d+e+c))}function c(a,b){var c=null,d,e;for(e=0;em?n("File '"+i+"' cannot be read.", +o):runtime.read(i,m-22,22,function(a,c){if(a||null===n||null===c)n(a,o);else if(22!==c.length)n("Central directory length should be 22.",o);else{var e=new core.ByteArray(c),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(),l=e.readUInt16LE(),d!==l?n("Number of entries is inconsistent.", +o):(d=e.readUInt32LE(),e=e.readUInt16LE(),e=m-22-d,runtime.read(i,e,m-e,function(a,c){if(a||null===c)n(a,o);else a:{var e=new core.ByteArray(c),d,g;f=[];for(d=0;d"}b+=d}if(1===a||3===a){for(d=h.firstChild;d;)b+=i(c,d),d=d.nextSibling;h.nodeValue&&(b+=h.nodeValue)}1===a&&(c="",1===h.nodeType&&(c+=""),b+=c);return b}var n=this;this.filter=null;this.writeToString=function(k,h){if(!k)return"";var b;if(h){b=h;var c={},a;for(a in b)b.hasOwnProperty(a)&&(c[b[a]]=a);b=c}else b={};return i(b, +k)}}; +// Input 15 +xmldom.RelaxNGParser=function(){function i(a,b){this.message=function(){b&&(a+=1===b.nodeType?" Element ":" Node ",a+=b.nodeName,b.nodeValue&&(a+=" with value '"+b.nodeValue+"'"),a+=".");return a}}function n(a){if(2>=a.e.length)return a;var b={name:a.name,e:a.e.slice(0,2)};return n({name:a.name,e:[b].concat(a.e.slice(2))})}function k(a){var a=a.split(":",2),b="",c;1===a.length?a=["",a[0]]:b=a[0];for(c in d)d[c]===b&&(a[0]=c);return a}function h(a,b){for(var c=0,d,g,o=a.name;a.e&&c=e.length)return b;0===g&&(g=0);for(var f=e.item(g);f.namespaceURI===d;){g+=1;if(g>=e.length)return b;f=e.item(g)}return f=c(a,b.attDeriv(a,e.item(g)),e,g+1)} +function a(c,b,d){d.e[0].a?(c.push(d.e[0].text),b.push(d.e[0].a.ns)):a(c,b,d.e[0]);d.e[1].a?(c.push(d.e[1].text),b.push(d.e[1].a.ns)):a(c,b,d.e[1])}var d="http://www.w3.org/2000/xmlns/",j,e,f,m,l,g,o,p,y,B,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}},z,C,x;j=h("choice",function(a,c){if(a===w)return c;if(c===w||a===c)return a},function(a,c){var d={},e;b(d,{p1:a,p2:c});c=a=void 0;for(e in d)d.hasOwnProperty(e)&& +(void 0===a?a=d[e]:c=void 0===c?d[e]:j(c,d[e]));var g=a,f=c;return{type:"choice",p1:g,p2:f,nullable:g.nullable||f.nullable,textDeriv:function(a,c){return j(g.textDeriv(a,c),f.textDeriv(a,c))},startTagOpenDeriv:k(function(a){return j(g.startTagOpenDeriv(a),f.startTagOpenDeriv(a))}),attDeriv:function(a,c){return j(g.attDeriv(a,c),f.attDeriv(a,c))},startTagCloseDeriv:i(function(){return j(g.startTagCloseDeriv(),f.startTagCloseDeriv())}),endTagDeriv:i(function(){return j(g.endTagDeriv(),f.endTagDeriv())})}}); +var u=function(a,c){if(a===w||c===w)return w;if(a===v)return c;if(c===v)return a},I={},r=0;e=function(a,c){var b=u&&u(a,c),d,g;if(void 0!==b)return b;b=a.hash||a.toString();d=c.hash||c.toString();b=f&&b.push(n(a.substring(c,d)))):"["===a[d]&&(0>=f&&(c=d+1),f+=1),d+=1;return d};k.prototype.next=function(){};k.prototype.reset=function(){};f=function(a,e,f){var i,h,m,k;for(i= +0;i text|list-item > text|list",e-=1;h=c+" > text|list-item > *:not(text|list):first-child:before{"+d+";counter-increment:list;"+("margin-left:"+g+";")+("width:"+b+";")+"display:inline-block}";try{a.insertRule(c+" > text|list-item > *:not(text|list):first-child{margin-left:"+f+";}",a.cssRules.length), +a.insertRule(h,a.cssRules.length)}catch(j){throw j;}}function e(b,g,h,i){if("list"===g)for(var o=i.firstChild,k,p;o;){if(o.namespaceURI===l)if(k=o,"list-level-style-number"===o.localName){p=k;var n=p.getAttributeNS(m,"num-format"),E=p.getAttributeNS(m,"num-suffix"),D="",D={1:"decimal",a:"lower-latin",A:"upper-latin",i:"lower-roman",I:"upper-roman"},M="",M=p.getAttributeNS(m,"num-prefix")||"",M=D.hasOwnProperty(n)?M+(" counter(list, "+D[n]+")"):n?M+("'"+n+"';"):M+" ''";E&&(M+=" '"+E+"'");p=D="content: "+ +M+";";j(b,h,k,p)}else"list-level-style-image"===o.localName?(p="content: none;",j(b,h,k,p)):"list-level-style-bullet"===o.localName&&(p="content: '"+k.getAttributeNS(l,"bullet-char")+"';",j(b,h,k,p));o=o.nextSibling}else{h=c(g,h,i).join(",");k="";if(o=a(i,m,"text-properties")){p=""+d(o,y);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(i,m,"paragraph-properties")){p=o; +o=""+d(p,w);p=p.getElementsByTagNameNS(m,"background-image");if(0b)break;e=e.nextSibling}a.insertBefore(c,e)}}}function b(a){this.OdfContainer=a}function c(a,c,b){var d=this;this.size=0;this.type=null;this.name=a;this.container=c;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!==b){var c=g[a];this.mimetype=c;b.loadAsDataURL(a,c,function(a,c){d.url=c;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,j=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,l=new odf.FontLoader,g={};b.prototype=new function(){};b.prototype.constructor=b;b.namespaceURI=e;b.localName="document";c.prototype.load=function(){};c.prototype.getUrl=function(){return this.data?"data:;base64,"+m.toBase64(this.data): +null};odf.OdfContainer=function p(d,f){function m(a){for(var c=a.firstChild,b;c;)b=c.nextSibling,1===c.nodeType?m(c):7===c.nodeType&&a.removeChild(c),c=b}function n(a){var c=s.rootElement.ownerDocument,b;if(a){m(a.documentElement);try{b=c.importNode(a.documentElement,!0)}catch(d){}}return b}function A(a){s.state=a;if(s.onchange)s.onchange(s);if(s.onstatereadychange)s.onstatereadychange(s)}function z(a,c){var b="",d;for(d in c)c.hasOwnProperty(d)&&(b+=" xmlns:"+d+'="'+c[d]+'"');return''}function C(){var a=j.namespaces,c=new xmldom.LSSerializer,b=z("document-meta",a);c.filter=new k(s.rootElement);b+=c.writeToString(s.rootElement.meta,a);return b+""}function x(){var a=j.namespaces,c=new xmldom.LSSerializer,b=z("document-settings",a);c.filter=new k(s.rootElement);b+=c.writeToString(s.rootElement.settings,a);return b+""}function u(){var a=j.namespaces,c=new xmldom.LSSerializer,b=z("document-styles",a); +c.filter=new k(s.rootElement,s.rootElement.masterStyles);b+=c.writeToString(s.rootElement.fontFaceDecls,a);b+=c.writeToString(s.rootElement.styles,a);b+=c.writeToString(s.rootElement.automaticStyles,a);b+=c.writeToString(s.rootElement.masterStyles,a);return b+""}function I(){var a=j.namespaces,c=new xmldom.LSSerializer,b=z("document-content",a);c.filter=new k(s.rootElement,s.rootElement.body);b+=c.writeToString(s.rootElement.automaticStyles,a);b+=c.writeToString(s.rootElement.body, +a);return b+""}function r(a,c){var b;b=runtime.byteArrayFromString(x(),"utf8");t.save("settings.xml",b,!0,new Date);b=runtime.byteArrayFromString(C(),"utf8");t.save("meta.xml",b,!0,new Date);b=runtime.byteArrayFromString(u(),"utf8");t.save("styles.xml",b,!0,new Date);b=runtime.byteArrayFromString(I(),"utf8");t.save("content.xml",b,!0,new Date);t.writeAs(a,function(a){c(a)})}var s=this,t=null;this.onstatereadychange=f;this.parts=this.rootElement=this.state=this.onchange=null; +this.getPart=function(a){return new c(a,s,t)};this.saveAs=r;this.save=function(a){r(d,a)};this.state=p.LOADING;var q=document.createElementNS(b.namespaceURI,b.localName),G,T=new b;for(G in T)T.hasOwnProperty(G)&&(q[G]=T[G]);this.rootElement=q;this.parts=new a(this);t=new core.Zip(d,function(a,c){t=c;a?runtime.loadXML(d,function(c,b){if(c)a&&(t.error=a+"\n"+c,A(p.INVALID));else{var d=n(b);!d||"document"!==d.localName||d.namespaceURI!==e?A(p.INVALID):(s.rootElement=d,d.fontFaceDecls=i(d,e,"font-face-decls"), +d.styles=i(d,e,"styles"),d.automaticStyles=i(d,e,"automatic-styles"),d.masterStyles=i(d,e,"master-styles"),d.body=i(d,e,"body"),d.meta=i(d,e,"meta"),A(p.DONE))}}):t.loadAsDOM("styles.xml",function(a,c){var b=n(c),d=s.rootElement;!b||"document-styles"!==b.localName||b.namespaceURI!==e?A(p.INVALID):(d.fontFaceDecls=i(b,e,"font-face-decls"),h(d,d.fontFaceDecls),d.styles=i(b,e,"styles"),h(d,d.styles),d.automaticStyles=i(b,e,"automatic-styles"),h(d,d.automaticStyles),d.masterStyles=i(b,e,"master-styles"), +h(d,d.masterStyles),l.loadFonts(d.fontFaceDecls,t,null));s.state!==p.INVALID&&t.loadAsDOM("content.xml",function(a,c){var b=n(c),d,f,j;if(!b||b.localName!=="document-content"||b.namespaceURI!==e)A(p.INVALID);else{d=s.rootElement;f=i(b,e,"font-face-decls");if(d.fontFaceDecls&&f)for(j=f.firstChild;j;){d.fontFaceDecls.appendChild(j);j=f.firstChild}else if(f){d.fontFaceDecls=f;h(d,f)}f=i(b,e,"automatic-styles");if(d.automaticStyles&&f)for(j=f.firstChild;j;){d.automaticStyles.appendChild(j);j=f.firstChild}else if(f){d.automaticStyles= +f;h(d,f)}d.body=i(b,e,"body");h(d,d.body)}s.state!==p.INVALID&&t.loadAsDOM("meta.xml",function(a,b){var c=n(b),d;if(c&&!(c.localName!=="document-meta"||c.namespaceURI!==e)){d=s.rootElement;d.meta=i(c,e,"meta");h(d,d.meta)}s.state!==p.INVALID&&t.loadAsDOM("settings.xml",function(a,c){if(c){var b=n(c),d;if(b&&!(b.localName!=="document-settings"||b.namespaceURI!==e)){d=s.rootElement;d.settings=i(b,e,"settings");h(d,d.settings)}}t.loadAsDOM("META-INF/manifest.xml",function(a,b){if(b){var c=n(b),d;if(c&& +!(c.localName!=="manifest"||c.namespaceURI!=="urn:oasis:names:tc:opendocument:xmlns:manifest:1.0")){d=s.rootElement;d.manifest=c;for(c=d.manifest.firstChild;c;){c.nodeType===1&&(c.localName==="file-entry"&&c.namespaceURI==="urn:oasis:names:tc:opendocument:xmlns:manifest:1.0")&&(g[c.getAttributeNS("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0","full-path")]=c.getAttributeNS("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0","media-type"));c=c.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 i(i){function h(c,a){for(var b=c&&c.firstChild;b&&a;)b=b.nextSibling,a-=1;return b}var b=h(i.startContainer,i.startOffset);h(i.endContainer,i.endOffset);this.next=function(){return null===b?b:null}}var n=new odf.StyleInfo;this.setOdfContainer=function(){};this.isCompletelyBold=function(){return!1};this.getAlignment=function(i){this.getParagraphStyles(i)};this.getParagraphStyles=function(k){var h,b,c,a=[];for(h=0;h text|list-item > *:first-child:before {";if(J=x.getAttributeNS(g,"style-name"))x=t[J],L=x.firstChild,x=void 0,"list-level-style-number"===L.localName?(x=L.getAttributeNS(f,"num-format"),J=L.getAttributeNS(f,"num-suffix"),E="",E={1:"decimal", +a:"lower-latin",A:"upper-latin",i:"lower-roman",I:"upper-roman"},D=void 0,D=L.getAttributeNS(f,"num-prefix")||"",D=E.hasOwnProperty(x)?D+(" counter(list, "+E[x]+")"):x?D+("'"+x+"';"):D+" ''",J&&(D+=" '"+J+"'"),x=E="content: "+D+";"):"list-level-style-image"===L.localName?x="content: none;":"list-level-style-bullet"===L.localName&&(x="content: '"+L.getAttributeNS(g,"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,h=d&&d.endContainer,j=d&&d.endOffset,i,k;b&&!((b.localName==="p"||b.localName==="h")&&b.namespaceURI===g);)b=b.parentNode;if(R&&b&&b.parentNode!==v){i=b.ownerDocument;k=i.documentElement.namespaceURI;if(v)v.parentNode&&u();else{v=i.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(h,j);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(i,n,k){new odf.OdfContainer(i,function(h){if(h.state===odf.OdfContainer.INVALID)return k("Document "+i+" is invalid.");h.state===odf.OdfContainer.DONE?h.saveAs(n,function(b){k(b)}):k("Document was not completely loaded.")})};this.render=function(i,n,k){for(n=n.getElementsByTagName("body")[0];n.firstChild;)n.removeChild(n.firstChild);n=new odf.OdfCanvas(n);n.addListener("statereadychange",function(h){k(h)});n.load(i)}}; +// Input 28 +runtime.loadClass("xmldom.XPath");runtime.loadClass("odf.Style2CSS"); +gui.PresenterUI=function(){var i=new odf.Style2CSS,n=new xmldom.XPath,k=i.namespaceResolver;return function(h){var b=this;b.setInitialSlideMode=function(){b.startSlideMode("single")};b.keyDownHandler=function(c){if(!c.target.isContentEditable&&"input"!==c.target.nodeName)switch(c.keyCode){case 84:b.toggleToolbar();break;case 37:case 8:b.prevSlide();break;case 39:case 32:b.nextSlide();break;case 36:b.firstSlide();break;case 35:b.lastSlide()}};b.root=function(){return b.odf_canvas.odfContainer().rootElement}; +b.firstSlide=function(){b.slideChange(function(){return 0})};b.lastSlide=function(){b.slideChange(function(b,a){return a-1})};b.nextSlide=function(){b.slideChange(function(b,a){return b+1b?-1:b-1})};b.slideChange=function(c){var a=b.getPages(b.odf_canvas.odfContainer().rootElement),d=-1,h=0;a.forEach(function(a){a=a[1];a.hasAttribute("slide_current")&&(d=h,a.removeAttribute("slide_current"));h+=1});c=c(d,a.length);-1===c&&(c=d); +a[c][1].setAttribute("slide_current","1");document.getElementById("pagelist").selectedIndex=c;"cont"===b.slide_mode&&window.scrollBy(0,a[c][1].getBoundingClientRect().top-30)};b.selectSlide=function(c){b.slideChange(function(a,b){return c>=b||0>c?-1:c})};b.scrollIntoContView=function(c){var a=b.getPages(b.odf_canvas.odfContainer().rootElement);0!==a.length&&window.scrollBy(0,a[c][1].getBoundingClientRect().top-30)};b.getPages=function(b){var b=b.getElementsByTagNameNS(k("draw"),"page"),a=[],d;for(d= +0;db}}var b=n.node().ownerDocument,c=new core.Cursor(i,b);this.movePointForward=function(a){k(a,n.stepForward)};this.movePointBackward=function(a){k(a,n.stepBackward)};this.moveLineForward=function(a){i.modify?i.modify(a?"extend":"move", +"forward","line"):k(a,h)};this.moveLineBackward=function(a){i.modify?i.modify(a?"extend":"move","backward","line"):k(a,function(){})};return this}; +// Input 31 +runtime.loadClass("core.PointWalker");runtime.loadClass("core.Cursor"); +gui.XMLEdit=function(i,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 h(a){a.preventDefault?a.preventDefault():a.returnValue=!1}function b(){var a=i.ownerDocument.defaultView.getSelection();a&&(!(0>=a.rangeCount)&&l)&&(a=a.getRangeAt(0),l.setPoint(a.startContainer,a.startOffset))}function c(){var a=i.ownerDocument.defaultView.getSelection(),b,c;a.removeAllRanges();l&&l.node()&&(b=l.node(),c=b.ownerDocument.createRange(), +c.setStart(b,l.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,h;c&&c!==a;){if(1===c.nodeType){d(c,b);e=c.attributes;for(h=e.length-1;0<=h;h-=1)f=e.item(h),"http://www.w3.org/2000/xmlns/"===f.namespaceURI&&!b[f.nodeValue]&&(b[f.nodeValue]=f.localName)}c=c.nextSibling||c.parentNode}}function j(){var a=i.ownerDocument.createElement("style"),b;b={};d(i,b);var c={},f,h,j=0;for(f in b)if(b.hasOwnProperty(f)&&f){h=b[f];if(!h||c.hasOwnProperty(h)||"xmlns"===h){do h="ns"+j,j+=1;while(c.hasOwnProperty(h));b[f]=h}c[h]=!0}a.type="text/css";b="@namespace customns url(customns);\n"+ +e;a.appendChild(i.ownerDocument.createTextNode(b));n=n.parentNode.replaceChild(a,n)}var e,f,m,l=null;i.id||(i.id="xml"+String(Math.random()).substring(2));f="#"+i.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=i;k(f,"click",function(a){i.ownerDocument.defaultView.getSelection().getRangeAt(0);h(a)});k(f,"keydown",function(a){var d=a.charCode||a.keyCode;if((l=null)&&d===39){b();l.stepForward();c()}else if(l&&d===37){b();l.stepBackward();c()}else if(d>=16&&d<=20||d>=33&&d<=40)return;h(a)});k(f,"keypress",function(){});k(f,"drop",h);k(f,"dragend",h);k(f,"beforepaste",h);k(f,"paste",h);this.updateCSS=j;this.setXML=function(b){b= +b.documentElement||b;m=b=i.ownerDocument.importNode(b,true);for(a(b);i.lastChild;)i.removeChild(i.lastChild);i.appendChild(b);j();l=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(" ")})(); From 819e2dbbfeba321d53a08aa5d0e21da7ad390c24 Mon Sep 17 00:00:00 2001 From: Aditya Bhatt Date: Wed, 19 Sep 2012 17:00:27 +0530 Subject: [PATCH 10/33] toolbar button for fullscreen, with image --- programs/viewer/images/texture.png | Bin 0 -> 2459 bytes .../images/toolbarButton-fullscreen.png | Bin 0 -> 491 bytes programs/viewer/index.html | 11 +- programs/viewer/viewer.css | 104 ++++++++++++++++-- 4 files changed, 104 insertions(+), 11 deletions(-) create mode 100644 programs/viewer/images/texture.png create mode 100644 programs/viewer/images/toolbarButton-fullscreen.png diff --git a/programs/viewer/images/texture.png b/programs/viewer/images/texture.png new file mode 100644 index 0000000000000000000000000000000000000000..df00864932368d75024b46b3a1993d0f51f1d59a GIT binary patch literal 2459 zcmbW3`9Bkm1IBk?jJ4dh>4T3l63OHmV{DF+TaMhv&!VjURh z&cVUK(b3V_*_lKlxw*M{czBS>WN&Y8UteE;fB(S1z@VTY3WX995)u{`79JiR85tQJ z9Zjdxhb*hIj~45O*;?8ijr>0q>&B1)0QmLI33z)aQ+n>z=qYVvQjafR<_+22DLm^z z?Rpt&-~C$L@DuN$4S_X=_4Z{T!|K4t*=HZ*uQz|d0dJ0^i!mSWoX&}PVk&>!)Ngsk z@O^Gq%_2N8)OWXi+j=N+c`G@W@oCrOQ-U|6+RAv}f>5(h*!N!COj?>yXac+9`93|l zsz`DR1cMBb{lM%z(p{0>pzf5Rm8{m?J+;3PyjafJgAoa4HmAIGYYmP?$TgAG;3J(a z(|df+fW+3h1+fApjo2IF?(_SCK}#PoqbfVX|0Ifj04G<*?}WB9{NMe@>y@rHU-#$=}#Ze+Q3g;AmbWO%MY#r>L2&wnTN zFBL#_E0k@0z15>v6k-d-o~PP$lnLi2cYDdjuZm@bk^Hb`kbeq@ug|ffCC9o&ZC@~~ zlLT9%LJN;^FG5N_wV*zXs3 z+}`MRRYb&Cp@&RztXAYka6V+Rg)doG<$anSAok&~)2whKzDb+(k*90He?d`8h%I9G zdtU!_$5b0Fs;Wq7zFMO(A0-woM7(wL9ixR-z|7(~&n9yekUkepeqRe{5aRl}gPRAeJ;t*R37F`i-`DOFs_lKo zemLKN`|2{?QXi~59(!wLb{KaG?>Ce%RO;G-a?frZjYGBDKd4~9+_rxdUTwFznOrHi z)DrzIGV#&k=J1k>5Dao-xphI9(H&V5_4+G|@e7Le@EAf|<7ugV{IkG^7dhz&5HX0I zN-FvCg;30NKk?z)*4a|kST^-i&o*bWx^o;C<@MWBExhw{6jfcYeMRmQknmT@GbBnAPSoW^kfzd`*__ zTwLJ2uC#{A7`66*?D)avsgSjr+Rcd-*HmKS7K{rr_L8hhhJJ>3Q~!C;OZ7Z^M+f$o zXrBvWoyiUVg%)^GVxHEaEG>7;EUJ$N5OrSSCV9%>sL0P%+Wf2ON=AV$RrYruHj~TI zGaI^ey$ie|&BkvubMD@?n=B_(Y)Y-glbb7C}qX!NliUD4-jvf1esbJH= z-HtIv2!mL67ZS;ihlgGBr>|z#J)|>8;+YR-D{={oLUH>aCmJcgf2H$ut#rS9jB2H2 z6IdjA`0;Rc6fBdl0#m%{9}y?rQTBnp?}SraO5`CiMM*%fG^QNY|MPe;OPO&)T`+o%t~)!d8BuQ zfi*gnP|3*zCgY=YckL*F`Wkv^a`yso(%@8Udd7*MAD)+55hpp}7gOi4d7^$^=u6)R zl6ufd=^Y!Y9aXi(-s947R{UJXS@w3&i7Sc6fr@G8_`mQDMZ^eFetgt=xd6ybXb{DN zQ3H!R5`W3`LU2!Nv~EUx)4J^zwa3tQ>XWdQp!_=a?W26*-1J~uJXNP}4`x-A60yal z;e!2pmMnHpClq(3aMjY%R3>_294ugexOaLOioXwMMR*PZ;>9?0ai~cvb1(C;?ED<+ z70ZCF$kdPcRFO%lhJvmmlwJ-y8|lMBp5g0>nD^-BfQ}4aI4T0eJE&4-NEuyoeHK?{ z{Q6I~O22iR!sy8JbG&rk9>%OT@77S1u~d{CMVg^HSIO5bp(md(Fn z%_^JD&L{xN4!yl{vwKmz-lokG&CEEN`t$z$t%3A92x#N57L}{LarIj`tgce$UJT`{ zY{1*lk*xqmZpql96?GoxGMI_tn3!v)jom72;QuKpbJr>esRoy_!0KTqEj^3r`nrUs zRe6{n|6B~1o0MDp!{iW~f7OnSb3z3h7S)$A4t$>`mkxx(<)ap+m;*dOaO~q@iGf&J z#$j;(IuLezH4nWwh~efLyEfAtzLWpt8UH&c)h^F(lR%;!>%QDCp5j!I(dl?S`|Yn2 zb)lPcF?o#u&f$cXGPj9RS&Hux_fX|g=)}1~6b!dVSzVMqt8P0iEsi<&DqGnilNwLd z8qR`JGgfP1kLtm3yVMi>kWM`au1|pG*kmD>FhF>{-c{%tCWSEnm{Tc|IHiFpFm*pq z*v+bB7e5L`f0xv5KL9~M4e{b6ozC)en^BGE`dmnChEQG30CVS>!>LTp>2*m2KmDTY z*z9li(3g@gF}%RZ_U4IdfBh>}Aj|q+p|v7qRrOIIAS{uOd5r4(_nnmYIsl7UC#D8H zK2?ftu2M2Iu9P#%Zzhb(eU90#3*KMIa^(BY&N*-%!W9Fr7rwA^*@;Wn(*k8bhgcuo O5r8?-l2B*lk?>!&x?|k{ literal 0 HcmV?d00001 diff --git a/programs/viewer/images/toolbarButton-fullscreen.png b/programs/viewer/images/toolbarButton-fullscreen.png new file mode 100644 index 0000000000000000000000000000000000000000..fa730955054b440a9e32ce282a3361cf13f198fa GIT binary patch literal 491 zcmVgp@kF&{Rb5bN zGzijG&{UKVshtpNClNu)%Ekhbw2`1J>Z6HtgGN0xKEhh;{0EDsrSU_qGw%`SWF~jc zxpQak3{VFTy2*App+P}o)NW`Vy70=Y$@eYTjRgDq)}ID15R?~1J&mx+C#(qTX;VcI z7?3B$uiL;R>R}-rT@%F{Q^f$#FZUOjQcfPeZ$<}E18p$$rORXa`Z6Q;=m%OKw=v~i zDrMy^zYYg%xi!g`vmMKrqSFdWO=yItW9DoVJ*XuE>5afFEf*aJP=P8AjY%zNU{t}` z&6S2q!}*1UI~}}%g2r}h|1FKpX|M(R^hMUF<}P<`VJOHX(}C-46~4}~;<03|R$zne zd{Hvx6aP5;bXPIK`>N>asx-f>p5`o;?TlKMQ-6LJb45R#;%UHjic=P>Ck@ z+{d0AQcWVHUUFA4oxlhWu<(*~7(R)cs(MMk>=;Zw$5hvZ{W->}h6+FUwIhgP8WFVd hn-r{!B2=PuoIg4=n|)8MY<2(u002ovPDHLkV1hfJ)Vlxx literal 0 HcmV?d00001 diff --git a/programs/viewer/index.html b/programs/viewer/index.html index 948fa32b..b8cd6af3 100644 --- a/programs/viewer/index.html +++ b/programs/viewer/index.html @@ -1,4 +1,4 @@ - + @@ -6,8 +6,13 @@ -
- +
+
+
+ +
+
diff --git a/programs/viewer/viewer.css b/programs/viewer/viewer.css index ceccc262..770c3688 100644 --- a/programs/viewer/viewer.css +++ b/programs/viewer/viewer.css @@ -3,20 +3,108 @@ margin: 0; } -#toolbar { - position: relative; +#toolbarContainer { + position: absolute; + z-index: 2; top: 0px; left: 0px; height: 32px; width: 100%; - background-image: linear-gradient(rgba(82, 82, 82, .99), rgba(69, 69, 69, .95)); - background-image: -webkit-linear-gradient(rgba(82, 82, 82, .99), rgba(69, 69, 69, .95)); - background-image: -moz-linear-gradient(rgba(82, 82, 82, .99), rgba(69, 69, 69, .95)); - background-image: -ms-linear-gradient(rgba(82, 82, 82, .99), rgba(69, 69, 69, .95)); - background-image: -o-linear-gradient(rgba(82, 82, 82, .99), rgba(69, 69, 69, .95)); + -webkit-box-shadow: 0px 1px 3px rgba(50, 50, 50, 0.75); + -moz-box-shadow: 0px 1px 3px rgba(50, 50, 50, 0.75); + box-shadow: 0px 1px 3px rgba(50, 50, 50, 0.75); - box-shadow: inset 1px 0 0 rgba(255, 255, 255, .08), inset 0 1px 1px rgba(0, 0, 0, .15), inset 0 -1px 0 rgba(255, 255, 255, .05), 0 1px 0 rgba(0, 0, 0, .15), 0 1px 1px rgba(0, 0, 0, .1); + background-image: url(images/texture.png), linear-gradient(rgba(82, 82, 82, .99), rgba(69, 69, 69, .95)); + background-image: url(images/texture.png), -webkit-linear-gradient(rgba(82, 82, 82, .99), rgba(69, 69, 69, .95)); + background-image: url(images/texture.png), -moz-linear-gradient(rgba(82, 82, 82, .99), rgba(69, 69, 69, .95)); + background-image: url(images/texture.png), -ms-linear-gradient(rgba(82, 82, 82, .99), rgba(69, 69, 69, .95)); + background-image: url(images/texture.png), -o-linear-gradient(rgba(82, 82, 82, .99), rgba(69, 69, 69, .95)); +} + +#toolbar { + position: relative; +} + +html[dir='ltr'] #toolbarLeft { + margin-left: -1px; +} +html[dir='rtl'] #toolbarRight { + margin-left: -1px; +} +html[dir='ltr'] #toolbarLeft, +html[dir='rtl'] #toolbarRight { + position: absolute; + top: 0; + left: 0; +} +html[dir='ltr'] #toolbarRight, +html[dir='rtl'] #toolbarLeft { + position: absolute; + top: 0; + right: 0; +} +html[dir='ltr'] #toolbarLeft > *, +html[dir='ltr'] #toolbarMiddle > *, +html[dir='ltr'] #toolbarRight > * { + float: left; +} +html[dir='rtl'] #toolbarLeft > *, +html[dir='rtl'] #toolbarMiddle > *, +html[dir='rtl'] #toolbarRight > * { + float: right; +} + + +.toolbarButton { + border: 0 none; + background-color: rgba(0, 0, 0, 0); + width: 32px; + height: 25px; + border-radius: 2px; +} + +html[dir='ltr'] .toolbarButton, +html[dir='ltr'] .dropdownToolbarButton { + margin: 3px 2px 4px 0; +} +html[dir='rtl'] .toolbarButton, +html[dir='rtl'] .dropdownToolbarButton { + margin: 3px 0 4px 2px; +} + +.toolbarButton:hover, +.toolbarButton:focus { + background-color: hsla(0,0%,0%,.12); + background-image: linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,100%,0)); + background-image: -webkit-linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,100%,0)); + background-image: -moz-linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,100%,0)); + background-image: -ms-linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,100%,0)); + background-image: -o-linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,100%,0)); + background-clip: padding-box; + border: 1px solid hsla(0,0%,0%,.35); + border-color: hsla(0,0%,0%,.32) hsla(0,0%,0%,.38) hsla(0,0%,0%,.42); + box-shadow: 0 1px 0 hsla(0,0%,100%,.05) inset, + 0 0 1px hsla(0,0%,100%,.15) inset, + 0 1px 0 hsla(0,0%,100%,.05); +} + +.toolbarButton:hover:active { + background-color: hsla(0,0%,0%,.2); + background-image: linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,100%,0)); + background-image: -webkit-linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,100%,0)); + background-image: -moz-linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,100%,0)); + background-image: -ms-linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,100%,0)); + background-image: -o-linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,100%,0)); + border-color: hsla(0,0%,0%,.35) hsla(0,0%,0%,.4) hsla(0,0%,0%,.45); + box-shadow: 0 1px 1px hsla(0,0%,0%,.1) inset, + 0 0 1px hsla(0,0%,0%,.2) inset, + 0 1px 0 hsla(0,0%,100%,.05); +} + +.toolbarButton.fullscreen::before { + display: inline-block; + content: url(images/toolbarButton-fullscreen.png); } #canvasContainer { From 2d229c2a7c315e626e67f065233e196097edbca8 Mon Sep 17 00:00:00 2001 From: Aditya Bhatt Date: Wed, 19 Sep 2012 17:34:05 +0530 Subject: [PATCH 11/33] download button, working --- .../viewer/images/toolbarButton-download.png | Bin 0 -> 512 bytes programs/viewer/index.html | 4 +- programs/viewer/viewer.css | 5 ++ programs/viewer/viewer.js | 51 +++++++++++++----- 4 files changed, 45 insertions(+), 15 deletions(-) create mode 100644 programs/viewer/images/toolbarButton-download.png diff --git a/programs/viewer/images/toolbarButton-download.png b/programs/viewer/images/toolbarButton-download.png new file mode 100644 index 0000000000000000000000000000000000000000..8676d8e2c2c0bac77cfce486f6f18639a8caa987 GIT binary patch literal 512 zcmV+b0{{JqP)z}Is24wg34Vg0&(Nh)A4KqyCy|cYNsu~v@z2dmB9tj1uH`lp^J3U`8~E{N z-p=3On^hdg5sIR03L*9Y+kk-hD<6Ofzy>Vo6d1ck4*P?_;4T~v8^TAR$Zf0DN+pxY zdoYJGiL9nW@D^3_!$~5MNL4D8YtWAX>pTG(3u?~~8-RJKR61@po0nw&j-Zf}uM`Re z1IBnHvj;%lW(tv*fb&ZHFIX|iIJtqC9%tO0lVf5?1zr z%n1($UyPgb4t7C5rMH$zKiPV#uKO2UXNZ0M7GMAtm#g$qt>3!<0000
- + +
diff --git a/programs/viewer/viewer.css b/programs/viewer/viewer.css index 770c3688..32ae56d0 100644 --- a/programs/viewer/viewer.css +++ b/programs/viewer/viewer.css @@ -107,6 +107,11 @@ html[dir='rtl'] .dropdownToolbarButton { content: url(images/toolbarButton-fullscreen.png); } +.toolbarButton.download::before { + display: inline-block; + content: url(images/toolbarButton-download.png); +} + #canvasContainer { overflow: auto; padding-top: 30px; diff --git a/programs/viewer/viewer.js b/programs/viewer/viewer.js index a27d9cc5..8f15c3ab 100644 --- a/programs/viewer/viewer.js +++ b/programs/viewer/viewer.js @@ -1,15 +1,40 @@ -window.onload = function() { - // If the URL has a fragment (#...), try to load the file it represents - var location = String(document.location), - pos = location.indexOf('#'); - location = location.substr(pos + 1); - if(pos === -1 || location.length == 0) { - console.log('Could not parse file path argument.'); - return; - } - - var odfElement = document.getElementById('canvas'), - odfCanvas = new odf.OdfCanvas(odfElement); +var Viewer = { + url: null, + filename: null, + odfCanvas: null, - odfCanvas.load(location); + initialize: function() { + // If the URL has a fragment (#...), try to load the file it represents + var location = String(document.location), + pos = location.indexOf('#'); + location= location.substr(pos + 1); + if(pos === -1 || location.length == 0) { + console.log('Could not parse file path argument.'); + return; + } + + this.url = location; + this.filename = this.url.replace(/^.*[\\\/]/, ''); + + var odfElement = document.getElementById('canvas'); + this.odfCanvas = new odf.OdfCanvas(odfElement); + this.odfCanvas.load(location); + window.title = this.filename; + }, + + download: function() { + var url = this.url.split('#')[0]; + url += '#webodf-viewer.action=download'; + window.open(url, '_parent'); + } }; + +window.onload = function() { + Viewer.initialize(); + + document.getElementById('download').addEventListener('click', function() { + Viewer.download(); + }); +}; + + From 193ea3813286bd456e4581f5b3ed4bee4f6c1f07 Mon Sep 17 00:00:00 2001 From: Aditya Bhatt Date: Wed, 19 Sep 2012 18:22:21 +0530 Subject: [PATCH 12/33] Fullscreen mode, particularly useful when the viewer is embedded as an iframe, and you want to see the full thing. Uses the new HTML5 Fullscreen API --- programs/viewer/index.html | 18 ++++++++++-------- programs/viewer/viewer.js | 37 ++++++++++++++++++++++++++++++++++--- 2 files changed, 44 insertions(+), 11 deletions(-) diff --git a/programs/viewer/index.html b/programs/viewer/index.html index 492a944a..355abf06 100644 --- a/programs/viewer/index.html +++ b/programs/viewer/index.html @@ -6,16 +6,18 @@ -
-
-
- - +
+
+
+
+ + +
-
-
-
+
+
+
diff --git a/programs/viewer/viewer.js b/programs/viewer/viewer.js index 8f15c3ab..6b77f735 100644 --- a/programs/viewer/viewer.js +++ b/programs/viewer/viewer.js @@ -1,7 +1,14 @@ +function isFullScreen() { + // Note that the browser fullscreen (triggered by short keys) might + // be considered different from content fullscreen when expecting a boolean + return document.mozFullScreen || document.webkitIsFullScreen; +} + var Viewer = { url: null, filename: null, odfCanvas: null, + element: null, initialize: function() { // If the URL has a fragment (#...), try to load the file it represents @@ -13,6 +20,7 @@ var Viewer = { return; } + this.element = document.getElementById('viewer'); this.url = location; this.filename = this.url.replace(/^.*[\\\/]/, ''); @@ -26,15 +34,38 @@ var Viewer = { var url = this.url.split('#')[0]; url += '#webodf-viewer.action=download'; window.open(url, '_parent'); + }, + + toggleFullScreen: function() { + var elem = this.element; + if(!isFullScreen()) { + if (elem.requestFullScreen) { +   elem.requestFullScreen(); + } else if (elem.mozRequestFullScreen) { +   elem.mozRequestFullScreen(); + } else if (elem.webkitRequestFullScreen) { +   elem.webkitRequestFullScreen(); + } + } + else { + if (document.cancelFullScreen) { + document.cancelFullScreen(); + } else if (document.mozCancelFullScreen) { + document.mozCancelFullScreen(); + } else if (document.webkitCancelFullScreen) { + document.webkitCancelFullScreen(); + } + } } }; window.onload = function() { Viewer.initialize(); - + + document.getElementById('fullscreen').addEventListener('click', function() { + Viewer.toggleFullScreen(); + }); document.getElementById('download').addEventListener('click', function() { Viewer.download(); }); }; - - From bf7b0c18998e6e55e9a0a32f583fe2b537ba5324 Mon Sep 17 00:00:00 2001 From: Aditya Bhatt Date: Wed, 19 Sep 2012 18:59:37 +0530 Subject: [PATCH 13/33] check for Fullscreen API support, if it does not exist, delete the button --- programs/viewer/viewer.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/programs/viewer/viewer.js b/programs/viewer/viewer.js index 6b77f735..d43034e9 100644 --- a/programs/viewer/viewer.js +++ b/programs/viewer/viewer.js @@ -28,6 +28,9 @@ var Viewer = { this.odfCanvas = new odf.OdfCanvas(odfElement); this.odfCanvas.load(location); window.title = this.filename; + + if(! (document.cancelFullScreen || document.mozCancelFullScreen || document.webkitCancelFullScreen) ) + document.getElementById('fullscreen').parentNode.removeChild(document.getElementById('fullscreen')); }, download: function() { From 6794d954176cfae682cd15df3f3370b4a0ab2f18 Mon Sep 17 00:00:00 2001 From: Aditya Bhatt Date: Wed, 19 Sep 2012 19:01:54 +0530 Subject: [PATCH 14/33] set visibility as hidden instead of deleting button, avoid breaking event handling --- programs/viewer/viewer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/programs/viewer/viewer.js b/programs/viewer/viewer.js index d43034e9..872e3876 100644 --- a/programs/viewer/viewer.js +++ b/programs/viewer/viewer.js @@ -30,7 +30,7 @@ var Viewer = { window.title = this.filename; if(! (document.cancelFullScreen || document.mozCancelFullScreen || document.webkitCancelFullScreen) ) - document.getElementById('fullscreen').parentNode.removeChild(document.getElementById('fullscreen')); + document.getElementById('fullscreen').style.visibility = 'hidden'; }, download: function() { From 834b86832ed2e182e40c71dad6c18efe5a731d8b Mon Sep 17 00:00:00 2001 From: Aditya Bhatt Date: Wed, 19 Sep 2012 21:15:56 +0530 Subject: [PATCH 15/33] add toolbar controls for zooming --- .../images/toolbarButton-menuArrows.png | Bin 0 -> 237 bytes .../viewer/images/toolbarButton-zoomIn.png | Bin 0 -> 228 bytes .../viewer/images/toolbarButton-zoomOut.png | Bin 0 -> 143 bytes programs/viewer/index.html | 22 ++ programs/viewer/viewer.css | 316 +++++++++++++++++- 5 files changed, 329 insertions(+), 9 deletions(-) create mode 100644 programs/viewer/images/toolbarButton-menuArrows.png create mode 100644 programs/viewer/images/toolbarButton-zoomIn.png create mode 100644 programs/viewer/images/toolbarButton-zoomOut.png diff --git a/programs/viewer/images/toolbarButton-menuArrows.png b/programs/viewer/images/toolbarButton-menuArrows.png new file mode 100644 index 0000000000000000000000000000000000000000..31b06b5af9e548b15e274677b8ecaac1c1d06e77 GIT binary patch literal 237 zcmeAS@N?(olHy`uVBq!ia0vp^>_9BQ!2%=;I@VSLDajJoh?3y^w370~qErUQl>DSr z1<%~X^wgl##FWaylc_d9Mg5*Gjv*Y;$q5RA21W%&988AFF7neS9({Y$O^hc-fzNvT zy{kX}UyqMIu=e3{csed~)S6b>9XaCpJd2PXwsj@)uEyTHN9Cd}ro z5XP`c@(2I(zwen392I~4ZeZ0+OPe6@{r)uVcjpxtQviSpk+Ka&^`vn5+K)IU-oAe*-xp*r
+
+
+
+ +
+ +
+ + + +
+
diff --git a/programs/viewer/viewer.css b/programs/viewer/viewer.css index 32ae56d0..f5a5c7f1 100644 --- a/programs/viewer/viewer.css +++ b/programs/viewer/viewer.css @@ -6,14 +6,15 @@ #toolbarContainer { position: absolute; z-index: 2; - top: 0px; + bottom: 0px; left: 0px; height: 32px; width: 100%; - - -webkit-box-shadow: 0px 1px 3px rgba(50, 50, 50, 0.75); - -moz-box-shadow: 0px 1px 3px rgba(50, 50, 50, 0.75); - box-shadow: 0px 1px 3px rgba(50, 50, 50, 0.75); + overflow: hidden; + + -webkit-box-shadow: 0px -1px 3px rgba(50, 50, 50, 0.75); + -moz-box-shadow: 0px -1px 3px rgba(50, 50, 50, 0.75); + box-shadow: 0px -1px 3px rgba(50, 50, 50, 0.75); background-image: url(images/texture.png), linear-gradient(rgba(82, 82, 82, .99), rgba(69, 69, 69, .95)); background-image: url(images/texture.png), -webkit-linear-gradient(rgba(82, 82, 82, .99), rgba(69, 69, 69, .95)); @@ -55,6 +56,48 @@ html[dir='rtl'] #toolbarRight > * { float: right; } +/* outer/inner center provides horizontal center */ +html[dir='ltr'] .outerCenter { + float: right; + position: relative; + right: 50%; +} +html[dir='rtl'] .outerCenter { + float: left; + position: relative; + left: 50%; +} +html[dir='ltr'] .innerCenter { + float: right; + position: relative; + right: -50%; +} +html[dir='rtl'] .innerCenter { + float: left; + position: relative; + left: -50%; +} + +html[dir='ltr'] .splitToolbarButton { + margin: 3px 2px 4px 0; + display: inline-block; +} +html[dir='rtl'] .splitToolbarButton { + margin: 3px 0 4px 2px; + display: inline-block; +} +html[dir='ltr'] .splitToolbarButton > .toolbarButton { + border-radius: 0; + float: left; +} +html[dir='rtl'] .splitToolbarButton > .toolbarButton { + border-radius: 0; + float: right; +} + +.splitToolbarButton.toggled .toolbarButton { + margin: 0; +} .toolbarButton { border: 0 none; @@ -74,7 +117,8 @@ html[dir='rtl'] .dropdownToolbarButton { } .toolbarButton:hover, -.toolbarButton:focus { +.toolbarButton:focus, +.dropdownToolbarButton { background-color: hsla(0,0%,0%,.12); background-image: linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,100%,0)); background-image: -webkit-linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,100%,0)); @@ -89,7 +133,8 @@ html[dir='rtl'] .dropdownToolbarButton { 0 1px 0 hsla(0,0%,100%,.05); } -.toolbarButton:hover:active { +.toolbarButton:hover:active, +.dropdownToolbarButton:hover:active { background-color: hsla(0,0%,0%,.2); background-image: linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,100%,0)); background-image: -webkit-linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,100%,0)); @@ -102,6 +147,247 @@ html[dir='rtl'] .dropdownToolbarButton { 0 1px 0 hsla(0,0%,100%,.05); } +.splitToolbarButton:hover > .toolbarButton, +.splitToolbarButton:focus > .toolbarButton, +.splitToolbarButton.toggled > .toolbarButton, +.toolbarButton.textButton { + background-color: hsla(0,0%,0%,.12); + background-image: -webkit-linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,100%,0)); + background-image: -moz-linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,100%,0)); + background-image: -ms-linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,100%,0)); + background-image: -o-linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,100%,0)); + background-image: linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,100%,0)); + background-clip: padding-box; + border: 1px solid hsla(0,0%,0%,.35); + border-color: hsla(0,0%,0%,.32) hsla(0,0%,0%,.38) hsla(0,0%,0%,.42); + box-shadow: 0 1px 0 hsla(0,0%,100%,.05) inset, + 0 0 1px hsla(0,0%,100%,.15) inset, + 0 1px 0 hsla(0,0%,100%,.05); + -webkit-transition-property: background-color, border-color, box-shadow; + -webkit-transition-duration: 150ms; + -webkit-transition-timing-function: ease; + -moz-transition-property: background-color, border-color, box-shadow; + -moz-transition-duration: 150ms; + -moz-transition-timing-function: ease; + -ms-transition-property: background-color, border-color, box-shadow; + -ms-transition-duration: 150ms; + -ms-transition-timing-function: ease; + -o-transition-property: background-color, border-color, box-shadow; + -o-transition-duration: 150ms; + -o-transition-timing-function: ease; + transition-property: background-color, border-color, box-shadow; + transition-duration: 150ms; + transition-timing-function: ease; + +} +.splitToolbarButton > .toolbarButton:hover, +.splitToolbarButton > .toolbarButton:focus, +.dropdownToolbarButton:hover, +.toolbarButton.textButton:hover, +.toolbarButton.textButton:focus { + background-color: hsla(0,0%,0%,.2); + box-shadow: 0 1px 0 hsla(0,0%,100%,.05) inset, + 0 0 1px hsla(0,0%,100%,.15) inset, + 0 0 1px hsla(0,0%,0%,.05); + z-index: 199; +} + + +.splitToolbarButton:hover > .toolbarButton, +.splitToolbarButton:focus > .toolbarButton, +.splitToolbarButton.toggled > .toolbarButton, +.toolbarButton.textButton { + background-color: hsla(0,0%,0%,.12); + background-image: -webkit-linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,100%,0)); + background-image: -moz-linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,100%,0)); + background-image: -ms-linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,100%,0)); + background-image: -o-linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,100%,0)); + background-image: linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,100%,0)); + background-clip: padding-box; + border: 1px solid hsla(0,0%,0%,.35); + border-color: hsla(0,0%,0%,.32) hsla(0,0%,0%,.38) hsla(0,0%,0%,.42); + box-shadow: 0 1px 0 hsla(0,0%,100%,.05) inset, + 0 0 1px hsla(0,0%,100%,.15) inset, + 0 1px 0 hsla(0,0%,100%,.05); + -webkit-transition-property: background-color, border-color, box-shadow; + -webkit-transition-duration: 150ms; + -webkit-transition-timing-function: ease; + -moz-transition-property: background-color, border-color, box-shadow; + -moz-transition-duration: 150ms; + -moz-transition-timing-function: ease; + -ms-transition-property: background-color, border-color, box-shadow; + -ms-transition-duration: 150ms; + -ms-transition-timing-function: ease; + -o-transition-property: background-color, border-color, box-shadow; + -o-transition-duration: 150ms; + -o-transition-timing-function: ease; + transition-property: background-color, border-color, box-shadow; + transition-duration: 150ms; + transition-timing-function: ease; + +} +.splitToolbarButton > .toolbarButton:hover, +.splitToolbarButton > .toolbarButton:focus, +.dropdownToolbarButton:hover, +.toolbarButton.textButton:hover, +.toolbarButton.textButton:focus { + background-color: hsla(0,0%,0%,.2); + box-shadow: 0 1px 0 hsla(0,0%,100%,.05) inset, + 0 0 1px hsla(0,0%,100%,.15) inset, + 0 0 1px hsla(0,0%,0%,.05); + z-index: 199; +} + +.dropdownToolbarButton { + border: 1px solid #333 !important; +} + +.toolbarButton, +.dropdownToolbarButton { + min-width: 16px; + padding: 2px 6px 2px; + border: 1px solid transparent; + border-radius: 2px; + color: hsl(0,0%,95%); + font-size: 12px; + line-height: 14px; + -webkit-user-select:none; + -moz-user-select:none; + -ms-user-select:none; + /* Opera does not support user-select, use <... unselectable="on"> instead */ + cursor: default; + -webkit-transition-property: background-color, border-color, box-shadow; + -webkit-transition-duration: 150ms; + -webkit-transition-timing-function: ease; + -moz-transition-property: background-color, border-color, box-shadow; + -moz-transition-duration: 150ms; + -moz-transition-timing-function: ease; + -ms-transition-property: background-color, border-color, box-shadow; + -ms-transition-duration: 150ms; + -ms-transition-timing-function: ease; + -o-transition-property: background-color, border-color, box-shadow; + -o-transition-duration: 150ms; + -o-transition-timing-function: ease; + transition-property: background-color, border-color, box-shadow; + transition-duration: 150ms; + transition-timing-function: ease; +} + +html[dir='ltr'] .toolbarButton, +html[dir='ltr'] .dropdownToolbarButton { + margin: 3px 2px 4px 0; +} +html[dir='rtl'] .toolbarButton, +html[dir='rtl'] .dropdownToolbarButton { + margin: 3px 0 4px 2px; +} + +.splitToolbarButton:hover > .splitToolbarButtonSeparator, +.splitToolbarButton.toggled > .splitToolbarButtonSeparator { + padding: 12px 0; + margin: 0; + box-shadow: 0 0 0 1px hsla(0,0%,100%,.03); + -webkit-transition-property: padding; + -webkit-transition-duration: 10ms; + -webkit-transition-timing-function: ease; + -moz-transition-property: padding; + -moz-transition-duration: 10ms; + -moz-transition-timing-function: ease; + -ms-transition-property: padding; + -ms-transition-duration: 10ms; + -ms-transition-timing-function: ease; + -o-transition-property: padding; + -o-transition-duration: 10ms; + -o-transition-timing-function: ease; + transition-property: padding; + transition-duration: 10ms; + transition-timing-function: ease; +} + +.toolbarButton.toggled:hover:active, +.splitToolbarButton > .toolbarButton:hover:active { + background-color: hsla(0,0%,0%,.4); + border-color: hsla(0,0%,0%,.4) hsla(0,0%,0%,.5) hsla(0,0%,0%,.55); + box-shadow: 0 1px 1px hsla(0,0%,0%,.2) inset, + 0 0 1px hsla(0,0%,0%,.3) inset, + 0 1px 0 hsla(0,0%,100%,.05); +} + +html[dir='ltr'] .splitToolbarButton > .toolbarButton:first-child, +html[dir='rtl'] .splitToolbarButton > .toolbarButton:last-child { + position: relative; + margin: 0; + margin-right: -1px; + border-top-left-radius: 2px; + border-bottom-left-radius: 2px; + border-right-color: transparent; +} +html[dir='ltr'] .splitToolbarButton > .toolbarButton:last-child, +html[dir='rtl'] .splitToolbarButton > .toolbarButton:first-child { + position: relative; + margin: 0; + margin-left: -1px; + border-top-right-radius: 2px; + border-bottom-right-radius: 2px; + border-left-color: transparent; +} +.splitToolbarButtonSeparator { + padding: 8px 0; + width: 1px; + background-color: hsla(0,0%,00%,.5); + z-index: 99; + box-shadow: 0 0 0 1px hsla(0,0%,100%,.08); + display: inline-block; + margin: 5px 0; +} +html[dir='ltr'] .splitToolbarButtonSeparator { + float:left; +} +html[dir='rtl'] .splitToolbarButtonSeparator { + float:right; +} + +.dropdownToolbarButton { + min-width: 120px; + max-width: 120px; + padding: 4px 2px 4px; + overflow: hidden; + background: url(images/toolbarButton-menuArrows.png) no-repeat; +} + +.dropdownToolbarButton > select { + -webkit-appearance: none; + -moz-appearance: none; /* in the future this might matter, see bugzilla bug #649849 */ + min-width: 140px; + font-size: 12px; + color: hsl(0,0%,95%); + margin:0; + padding:0; + border:none; + background: rgba(0,0,0,0); /* Opera does not support 'transparent' + diff --git a/programs/viewer/viewer.js b/programs/viewer/viewer.js index 3577d2d3..d44ba61d 100644 --- a/programs/viewer/viewer.js +++ b/programs/viewer/viewer.js @@ -4,11 +4,35 @@ function isFullScreen() { return document.mozFullScreen || document.webkitIsFullScreen; } +function selectScaleOption(value) { + var options = document.getElementById('scaleSelect').options; + var predefinedValueFound = false; + for (var i = 0; i < options.length; i++) { + var option = options[i]; + if (option.value != value) { + option.selected = false; + continue; + } + option.selected = true; + predefinedValueFound = true; + } + return predefinedValueFound; +} + + +var kCssUnits = 96.0 / 72.0; +var kScrollbarPadding = 40; +var kMinScale = 0.25; +var kMaxScale = 4.0; +var kDefaultScaleDelta = 1.1; +var kDefaultScale = 'auto'; + var Viewer = { url: null, filename: null, odfCanvas: null, element: null, + initialized: false, initialize: function() { // If the URL has a fragment (#...), try to load the file it represents @@ -31,6 +55,8 @@ var Viewer = { if(! (document.cancelFullScreen || document.mozCancelFullScreen || document.webkitCancelFullScreen) ) document.getElementById('fullscreen').style.visibility = 'hidden'; + + this.initialized = true; }, download: function() { @@ -65,16 +91,66 @@ var Viewer = { return this.odfCanvas.getZoomLevel(); }, + setScale: function (val, resetAutoSettings, noScroll) { + if (val == this.zoomLevel() ) + return; + + this.odfCanvas.setZoomLevel(val); + /*var event = document.createEvent('UIEvents'); + event.initUIEvent('scalechange', false, false, window, 0); + event.scale = val; + event.resetAutoSettings = resetAutoSettings; + window.dispatchEvent(event);*/ + }, + + parseScale: function (value, resetAutoSettings, noScroll) { + if ('custom' == value) + return; + + var scale = parseFloat(value); + if (scale) { + this.setScale(scale, true, noScroll); + return; + } + + var container = this.element.parentNode; + + var pageWidthScale = (container.clientWidth - kScrollbarPadding) / + this.element.clientWidth * this.zoomLevel() / kCssUnits; + /*console.log('value ' + value); + console.log('zoomlevel ' + this.zoomLevel()); + console.log('clientWidth ' + this.element.clientWidth); + console.log('pageWidthScale ' + pageWidthScale);*/ + switch (value) { + case 'page-actual': + scale = 1; + break; + case 'page-width': + scale = pageWidthScale; + this.odfCanvas.fitToWidth(document.body.clientWidth - kScrollbarPadding); + break; + case 'auto': + scale = Math.min(1.0, pageWidthScale); + break; + } + //console.log('scale ' + scale); + //this.setScale(scale, resetAutoSettings, noScroll); + + selectScaleOption(value); + }, + zoomOut: function() { // 10 % decrement - var newLevel = this.zoomLevel() * 0.9; - this.odfCanvas.setZoomLevel(newLevel); + var newScale = (this.zoomLevel() / kDefaultScaleDelta).toFixed(2); + newScale = Math.max(kMinScale, newScale); + this.parseScale(newScale, true); }, zoomIn: function() { // 10 % increment - var newLevel = this.zoomLevel() * 1.1; - this.odfCanvas.setZoomLevel(newLevel); + var newScale = (this.zoomLevel() * kDefaultScaleDelta).toFixed(2); + newScale = Math.min(kMaxScale, newScale); + this.parseScale(newScale, true); } }; @@ -93,4 +169,11 @@ window.onload = function() { document.getElementById('zoomIn').addEventListener('click', function() { Viewer.zoomIn(); }); + window.addEventListener('resize', function webViewerResize(evt) { + if (Viewer.initialized && + (document.getElementById('pageWidthOption').selected || + document.getElementById('pageAutoOption').selected)) + Viewer.parseScale(document.getElementById('scaleSelect').value); + }); + }; diff --git a/programs/viewer/webodf.js b/programs/viewer/webodf.js index 89e93c9e..c12549dd 100644 --- a/programs/viewer/webodf.js +++ b/programs/viewer/webodf.js @@ -64,29 +64,29 @@ arguments); core.Base64=function(){function i(a){var c=[],b,e=a.length;for(b=0;b>>18],b+=o[c>>>12&63],b+=o[c>>>6&63],b+=o[c&63];e===d+1?(c=a[e]<<4,b+=o[c>>>6],b+=o[c&63],b+="=="):e===d&&(c=a[e]<<10|a[e+1]<<2,b+=o[c>>>12],b+=o[c>>>6&63],b+=o[c&63],b+="=");return b}function k(a){var a=a.replace(/[^A-Za-z0-9+\/]+/g,""),c=[],b=a.length%4,e,d=a.length,l;for(e=0;e>16,l>>8&255,l&255);c.length-=[0,0,2,1][b];return c}function h(a){var c=[],b,e=a.length,d;for(b=0;bd?c.push(d):2048>d?c.push(192|d>>>6,128|d&63):c.push(224|d>>>12&15,128|d>>>6&63,128|d&63);return c}function b(a){var c=[],b,e=a.length,d,l,g;for(b=0;bd?c.push(d):(b+=1,l=a[b],224>d?c.push((d&31)<<6|l&63):(b+=1,g=a[b],c.push((d&15)<<12|(l&63)<<6|g&63)));return c}function c(a){return n(i(a))} function a(a){return String.fromCharCode.apply(String,k(a))}function d(a){return b(i(a))}function j(a){for(var a=b(a),c="",e=0;ec?e+=String.fromCharCode(c):(g+=1,d=a.charCodeAt(g)&255,224>c?e+=String.fromCharCode((c&31)<<6|d&63):(g+=1,l=a.charCodeAt(g)&255,e+=String.fromCharCode((c&15)<<12|(d&63)<<6|l&63)));return e}function f(a,c){function b(){var g= -l+d;g>a.length&&(g=a.length);q+=e(a,l,g);l=g;g=l===a.length;c(q,g)&&!g&&runtime.setTimeout(b,0)}var d=1E5,q="",l=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;wa.length&&(g=a.length);q+=e(a,l,g);l=g;g=l===a.length;c(q,g)&&!g&&runtime.setTimeout(b,0)}var d=1E5,q="",l=0;a.lengthy;y+=1)p.push(65+y);for(y=0;26>y;y+=1)p.push(97+y);for(y=0;10>y;y+=1)p.push(48+ +y);p.push(43);p.push(47);var C,p=o;y={};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 i(){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,c,b,e){this.good_length=a;this.max_lazy=c;this.nice_length=b;this.max_chain=e}function h(){this.next=null;this.len=0;this.ptr=[];this.ptr.length=b;this.off=0}var b=8192,c,a,d,j,e=null,f,m,l,g,o,p,z,C,w,v,A,B,D,x,u,I,r,s,t,q,F,O,R,y,G,J,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, +core.RawDeflate=function(){function i(){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,c,b,e){this.good_length=a;this.max_lazy=c;this.nice_length=b;this.max_chain=e}function h(){this.next=null;this.len=0;this.ptr=[];this.ptr.length=b;this.off=0}var b=8192,c,a,d,j,e=null,f,m,l,g,o,p,y,C,w,v,A,B,D,x,u,J,r,s,t,q,F,O,R,z,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(l){e[m+f++]=l;if(m+f===b){var g;if(0!==f){null!==c?(l=c,c=c.next):l=new h; -l.next=null;l.len=l.off=0;null===a?a=d=l:d=d.next=l;l.len=f-m;for(g=0;g>>8):(ma(a&255),ma(a>>>8))},oa=function(){A=(A<<5^g[r+3-1]&255)&8191;B=z[32768+A];z[r&32767]=B;z[32768+A]=r},T=function(a,c){w>16-c?(C|=a<>16-w,w+=c-16):(C|=a<a;a++)g[a]=g[a+32768];s-=32768;r-=32768;v-=32768;for(a=0;8192>a;a++)c=z[32768+a],z[32768+a]=32768<=c?c-32768:0;for(a=0;32768>a;a++)c=z[a],z[a]=32768<=c?c-32768:0;b+=32768}t||(a=xa(g,r+q,b),0>=a?t=!0:q+=a)},ya=function(a){var c=F,b=r,e,d=I,l=32506=y&&(c>>=2);do if(e=a,!(g[e+d]!==m||g[e+d-1]!==t||g[e]!==g[b]||g[++e]!==g[b+1])){b+=2;e++;do++b; -while(g[b]===g[++e]&&g[++b]===g[++e]&&g[++b]===g[++e]&&g[++b]===g[++e]&&g[++b]===g[++e]&&g[++b]===g[++e]&&g[++b]===g[++e]&&g[++b]===g[++e]&&bd){s=a;d=e;if(258<=e)break;t=g[b+d-1];m=g[b+d]}}while((a=z[a&32767])>l&&0!==--c);return d},ha=function(a,c){p[S++]=c;0===a?G[c].fc++:(a--,G[ca[c]+256+1].fc++,J[(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++)b+=J[d].fc*(5+ga[d]);b>>= +l.next=null;l.len=l.off=0;null===a?a=d=l:d=d.next=l;l.len=f-m;for(g=0;g>>8):(ma(a&255),ma(a>>>8))},oa=function(){A=(A<<5^g[r+3-1]&255)&8191;B=y[32768+A];y[r&32767]=B;y[32768+A]=r},T=function(a,c){w>16-c?(C|=a<>16-w,w+=c-16):(C|=a<a;a++)g[a]=g[a+32768];s-=32768;r-=32768;v-=32768;for(a=0;8192>a;a++)c=y[32768+a],y[32768+a]=32768<=c?c-32768:0;for(a=0;32768>a;a++)c=y[a],y[a]=32768<=c?c-32768:0;b+=32768}t||(a=xa(g,r+q,b),0>=a?t=!0:q+=a)},ya=function(a){var c=F,b=r,e,d=J,l=32506=z&&(c>>=2);do if(e=a,!(g[e+d]!==m||g[e+d-1]!==t||g[e]!==g[b]||g[++e]!==g[b+1])){b+=2;e++;do++b; +while(g[b]===g[++e]&&g[++b]===g[++e]&&g[++b]===g[++e]&&g[++b]===g[++e]&&g[++b]===g[++e]&&g[++b]===g[++e]&&g[++b]===g[++e]&&g[++b]===g[++e]&&bd){s=a;d=e;if(258<=e)break;t=g[b+d-1];m=g[b+d]}}while((a=y[a&32767])>l&&0!==--c);return d},ha=function(a,c){p[S++]=c;0===a?G[c].fc++:(a--,G[ca[c]+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++)b+=I[d].fc*(5+ga[d]);b>>= 3;if(ja>=1,b<<=1;while(0<--c);return b>>1},Aa=function(a,c){var b=[];b.length=16;var e=0,d;for(d=1;15>=d;d++)e=e+Q[d-1]<<1,b[d]=e;for(e=0;e<=c;e++)d=a[e].dl,0!==d&&(a[e].fc=za(b[d]++,d))},ua=function(a){var c=a.dyn_tree,b=a.static_tree,e=a.elems,d,l=-1,g=e;X=0;ba=573; for(d=0;dX;)d=N[++X]=2>l?++l:0,c[d].fc=1,U[d]=0,Y--,null!==b&&(da-=b[d].dl);a.max_code=l;for(d=X>>1;1<=d;d--)ta(c,d);do d=N[1],N[1]=N[X--],ta(c,1),b=N[1],N[--ba]=d,N[--ba]=b,c[g].fc=c[d].fc+c[b].fc,U[g]=U[d]>U[b]+1?U[d]:U[b]+1,c[d].dl=c[b].dl=g,N[1]=g++,ta(c,1);while(2<=X);N[--ba]=N[1];g=a.dyn_tree;d=a.extra_bits;var e=a.extra_base,b=a.max_code,q=a.max_length,t=a.static_tree,m,f,s,o,j=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>q&&(f=q,j++),g[m].dl=f,!(m>b))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!==j){do{for(f=q-1;0===Q[f];)f--;Q[f]--;Q[f+1]+=2;Q[q]--;j-=2}while(0b||(g[d].dl!==f&&(Y+=(f-g[d].dl)*g[d].fc,g[d].fc=f),m--)}Aa(c,l)},Ba=function(a,c){var b,e=-1,d,l=a[0].dl,g=0,q=7,f=4;0===l&&(q=138,f=3);a[c+1].dl=65535;for(b=0;b<=c;b++)if(d=l,l=a[b+1].dl,!(++g=g?H[17].fc++:H[18].fc++,g=0,e=d,0===l)?(q=138,f=3):d===l?(q=6,f=3):(q=7,f=4)},Ca=function(){8b?$[b]:$[256+(b>>7)])&255,Z(q,c),f=ga[q],0!==f)b-=ea[q],T(b,f);g>>=1}while(e=l?(Z(17,H),T(l-3,3)):(Z(18,H),T(l-11,7));l=0;e=d;0===g?(q=138,f=3):d===g?(q=6,f=3):(q=7,f=4)}},Fa=function(){var a;for(a=0;286>a;a++)G[a].fc=0;for(a=0;30>a;a++)J[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 b,c,e,d;d=r-v;fa[aa]=V;ua(K);ua(E);Ba(G,K.max_code);Ba(J,E.max_code);ua(W);for(e=18;3<=e&&0===H[va[e]].dl;e--);Y+=3*(e+1)+14;b=Y+3+7>> -3;c=da+3+7>>3;c<=b&&(b=c);if(d+4<=b&&0<=v){T(0+a,3);Ca();na(d);na(~d);for(e=0;ea.len&&(q=a.len);for(t=0;tf- -m&&(q=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(g,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^g[d]&255)&8191}a=null;m=f=0;3>=R?(I=2,u=0):(u=2,x=0);l=!1}j=!0;if(0===q)return l=!0,0}if((d=Ga(b,c,e))===e)return e;if(l)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=g[r]&255,A=(A<<5^g[r+1]&255)&8191;else p=ha(0,g[r]&255),q--,r++;p&&(pa(0),v=r);for(;262>q&&!t;)sa()}else for(;0!==q&&null===a;){oa();I=u;D=s;u=2;0!==B&&(I=r-B)&&(u= -ya(B),u>q&&(u=q),3===u&&4096q&&!t;)sa()}0===q&&(0!==x&&ha(0,g[r-1]&255),pa(1),l=!0);return d+Ga(b,d+c,e-d)};this.deflate=function(q,l){var f,m;ka=q;qa=0;"undefined"===String(typeof l)&&(l=6);(f=l)?1>f?f=1:9f;f++)G[f]=new i;J=[];J.length=61;for(f=0;61>f;f++)J[f]=new i;M=[];M.length=288;for(f=0;288>f;f++)M[f]=new i;P=[];P.length=30;for(f=0;30>f;f++)P[f]=new i;H=[];H.length=39;for(f=0;39>f;f++)H[f]=new i;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 h=[];h.length=f;for(m=0;m< +g,g=a[b+1].dl,!(++l=l?(Z(17,H),T(l-3,3)):(Z(18,H),T(l-11,7));l=0;e=d;0===g?(q=138,f=3):d===g?(q=6,f=3):(q=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 b,c,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;b=Y+3+7>> +3;c=da+3+7>>3;c<=b&&(b=c);if(d+4<=b&&0<=v){T(0+a,3);Ca();na(d);na(~d);for(e=0;ea.len&&(q=a.len);for(t=0;tf- +m&&(q=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++)y[32768+d]=0;O=la[R].max_lazy;z=la[R].good_length;F=la[R].max_chain;v=r=0;q=xa(g,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^g[d]&255)&8191}a=null;m=f=0;3>=R?(J=2,u=0):(u=2,x=0);l=!1}j=!0;if(0===q)return l=!0,0}if((d=Ga(b,c,e))===e)return e;if(l)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=g[r]&255,A=(A<<5^g[r+1]&255)&8191;else p=ha(0,g[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,g[r-1]&255),pa(1),l=!0);return d+Ga(b,d+c,e-d)};this.deflate=function(q,l){var f,m;ka=q;qa=0;"undefined"===String(typeof l)&&(l=6);(f=l)?1>f?f=1:9f;f++)G[f]=new i;I=[];I.length=61;for(f=0;61>f;f++)I[f]=new i;M=[];M.length=288;for(f=0;288>f;f++)M[f]=new i;P=[];P.length=30;for(f=0;30>f;f++)P[f]=new i;H=[];H.length=39;for(f=0;39>f;f++)H[f]=new i;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 h=[];h.length=f;for(m=0;m< f;m++)h[m]=String.fromCharCode(s[m]);F[F.length]=h.join("")}ka=null;return F.join("")}}; // Input 5 core.ByteArray=function(i){this.pos=0;this.data=i;this.readUInt32LE=function(){var i=this.data,k=this.pos+=4;return i[--k]<<24|i[--k]<<16|i[--k]<<8|i[--k]};this.readUInt16LE=function(){var i=this.data,k=this.pos+=2;return i[--k]<<8|i[--k]}}; @@ -94,16 +94,16 @@ core.ByteArray=function(i){this.pos=0;this.data=i;this.readUInt32LE=function(){v core.ByteArrayWriter=function(i){var n=this,k=new runtime.ByteArray(0);this.appendByteArrayWriter=function(h){k=runtime.concatByteArrays(k,h.getByteArray())};this.appendByteArray=function(h){k=runtime.concatByteArrays(k,h)};this.appendArray=function(h){k=runtime.concatByteArrays(k,runtime.byteArrayFromArray(h))};this.appendUInt16LE=function(h){n.appendArray([h&255,h>>8&255])};this.appendUInt32LE=function(h){n.appendArray([h&255,h>>8&255,h>>16&255,h>>24&255])};this.appendString=function(h){k=runtime.concatByteArrays(k, runtime.byteArrayFromString(h,i))};this.getLength=function(){return k.length};this.getByteArray=function(){return k}}; // Input 7 -core.RawInflate=function(){var i,n,k=null,h,b,c,a,d,j,e,f,m,l,g,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},I=function(a,b,c,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),l,f,m,t,o,s,p,j=Array(this.BMAX+1),F,h,i,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;h=1;for(i=2;0<--o;)C[i++]=s+=F[h++];F=a;o=h=0;do if(0!=(s=F[h++]))t[C[s]++]=o;while(++oz+j[1+t];){z+=j[1+t];t++;r=(r=m-z)>g?g:r;if((f=1<<(s=p-z))>a+1){f-=a+1;for(i=p;++sl&&z>z-j[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;h>=b?w.e=99:F[h]F[h]?16:15,w.n=F[h++]): -(w.e=e[F[h]-c],w.n=d[F[h++]-c]);f=1<>z;s>=1)o^=s;for(o^=s;(o&(1<>=b;a-=b},q=function(a,b,c){var q,p,j;if(0==c)return 0;for(j=0;;){r(g);p=m.list[s(g)];for(q=p.e;16y+j[1+t];){y+=j[1+t];t++;r=(r=m-y)>g?g:r;if((f=1<<(s=p-y))>a+1){f-=a+1;for(i=p;++sl&&y>y-j[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-y;h>=b?w.e=99:F[h]F[h]?16:15,w.n=F[h++]): +(w.e=e[F[h]-c],w.n=d[F[h++]-c]);f=1<>y;s>=1)o^=s;for(o^=s;(o&(1<>=b;a-=b},q=function(a,b,c){var q,p,j;if(0==c)return 0;for(j=0;;){r(g);p=m.list[s(g)];for(q=p.e;16 -e;e++)i[D[e]]=0;g=7;e=new I(i,19,19,null,null,g);if(0!=e.status)return-1;m=e.root;g=e.m;p=F+h;for(d=f=0;de)i[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;b=7;E=new I(K,288,257,w,v,b);if(0!=E.status){alert("HufBuild error: "+E.status);D=-1;break b}k=E.root;b=E.m;for(E=0;30>E;E++)K[E]=5;F=5;E=new I(K,30,0,A,B,F);if(1e)i[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;b=7;E=new J(K,288,257,w,v,b);if(0!=E.status){alert("HufBuild error: "+E.status);D=-1;break b}k=E.root;b=E.m;for(E=0;30>E;E++)K[E]=5;F=5;E=new J(K,30,0,A,B,F);if(1e&&j.setStart(f,j.startOffset-1);j.endContainer===b?j.setEnd(f,e):j.endContainer===f&&j.endOffset>e&&j.setEnd(f,j.endOffset-1)}if(d){for(c=0;c=e.length)return b;0===g&&(g=0);for(var f=e.item(g);f.namespaceURI===d;){g+=1;if(g>=e.length)return b;f=e.item(g)}return f=c(a,b.attDeriv(a,e.item(g)),e,g+1)} -function a(c,b,d){d.e[0].a?(c.push(d.e[0].text),b.push(d.e[0].a.ns)):a(c,b,d.e[0]);d.e[1].a?(c.push(d.e[1].text),b.push(d.e[1].a.ns)):a(c,b,d.e[1])}var d="http://www.w3.org/2000/xmlns/",j,e,f,m,l,g,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}, +function a(c,b,d){d.e[0].a?(c.push(d.e[0].text),b.push(d.e[0].a.ns)):a(c,b,d.e[0]);d.e[1].a?(c.push(d.e[1].text),b.push(d.e[1].a.ns)):a(c,b,d.e[1])}var d="http://www.w3.org/2000/xmlns/",j,e,f,m,l,g,o,p,y,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;j=h("choice",function(a,c){if(a===w)return c;if(c===w||a===c)return a},function(a,c){var d={},e;b(d,{p1:a,p2:c});c=a=void 0;for(e in d)d.hasOwnProperty(e)&& (void 0===a?a=d[e]:c=void 0===c?d[e]:j(c,d[e]));var g=a,f=c;return{type:"choice",p1:g,p2:f,nullable:g.nullable||f.nullable,textDeriv:function(a,c){return j(g.textDeriv(a,c),f.textDeriv(a,c))},startTagOpenDeriv:k(function(a){return j(g.startTagOpenDeriv(a),f.startTagOpenDeriv(a))}),attDeriv:function(a,c){return j(g.attDeriv(a,c),f.attDeriv(a,c))},startTagCloseDeriv:i(function(){return j(g.startTagCloseDeriv(),f.startTagCloseDeriv())}),endTagDeriv:i(function(){return j(g.endTagDeriv(),f.endTagDeriv())})}}); -var u=function(a,c){if(a===w||c===w)return w;if(a===v)return c;if(c===v)return a},I={},r=0;e=function(a,c){var b=u&&u(a,c),d,g;if(void 0!==b)return b;b=a.hash||a.toString();d=c.hash||c.toString();b=f&&b.push(n(a.substring(c,d)))):"["===a[d]&&(0>=f&&(c=d+1),f+=1),d+=1;return d};k.prototype.next=function(){};k.prototype.reset=function(){};f=function(a,e,f){var i,h,m,k;for(i= 0;i text|list-item > text|list",e-=1;h=c+" > text|list-item > *:not(text|list):first-child:before{"+d+";counter-increment:list;"+("margin-left:"+g+";")+("width:"+b+";")+"display:inline-block}";try{a.insertRule(c+" > text|list-item > *:not(text|list):first-child{margin-left:"+f+";}",a.cssRules.length), -a.insertRule(h,a.cssRules.length)}catch(j){throw j;}}function e(b,g,h,i){if("list"===g)for(var o=i.firstChild,k,p;o;){if(o.namespaceURI===l)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"},J="",J=p.getAttributeNS(m,"num-prefix")||"",J=G.hasOwnProperty(n)?J+(" counter(list, "+G[n]+")"):n?J+("'"+n+"';"):J+" ''";y&&(J+=" '"+y+"'");p=G="content: "+ -J+";";j(b,h,k,p)}else"list-level-style-image"===o.localName?(p="content: none;",j(b,h,k,p)):"list-level-style-bullet"===o.localName&&(p="content: '"+k.getAttributeNS(l,"bullet-char")+"';",j(b,h,k,p));o=o.nextSibling}else{h=c(g,h,i).join(",");k="";if(o=a(i,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(i,m,"paragraph-properties")){p=o; +a.insertRule(h,a.cssRules.length)}catch(j){throw j;}}function e(b,g,h,i){if("list"===g)for(var o=i.firstChild,k,p;o;){if(o.namespaceURI===l)if(k=o,"list-level-style-number"===o.localName){p=k;var n=p.getAttributeNS(m,"num-format"),z=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+" ''";z&&(I+=" '"+z+"'");p=G="content: "+ +I+";";j(b,h,k,p)}else"list-level-style-image"===o.localName?(p="content: none;",j(b,h,k,p)):"list-level-style-bullet"===o.localName&&(p="content: '"+k.getAttributeNS(l,"bullet-char")+"';",j(b,h,k,p));o=o.nextSibling}else{h=c(g,h,i).join(",");k="";if(o=a(i,m,"text-properties")){p=""+d(o,y);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(i,m,"paragraph-properties")){p=o; o=""+d(p,w);p=p.getElementsByTagNameNS(m,"background-image");if(0b)break;e=e.nextSibling this.abort=function(){}}function a(){this.length=0;this.item=function(){}}var d=new odf.StyleInfo,j=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,l=new odf.FontLoader,g={};b.prototype=new function(){};b.prototype.constructor=b;b.namespaceURI=e;b.localName="document";c.prototype.load=function(){};c.prototype.getUrl=function(){return this.data?"data:;base64,"+m.toBase64(this.data): null};odf.OdfContainer=function p(d,f){function m(a){for(var c=a.firstChild,b;c;)b=c.nextSibling,1===c.nodeType?m(c):7===c.nodeType&&a.removeChild(c),c=b}function n(a){var c=s.rootElement.ownerDocument,b;if(a){m(a.documentElement);try{b=c.importNode(a.documentElement,!0)}catch(d){}}return b}function A(a){s.state=a;if(s.onchange)s.onchange(s);if(s.onstatereadychange)s.onstatereadychange(s)}function B(a,c){var b="",d;for(d in c)c.hasOwnProperty(d)&&(b+=" xmlns:"+d+'="'+c[d]+'"');return''}function D(){var a=j.namespaces,c=new xmldom.LSSerializer,b=B("document-meta",a);c.filter=new k(s.rootElement);b+=c.writeToString(s.rootElement.meta,a);return b+""}function x(){var a=j.namespaces,c=new xmldom.LSSerializer,b=B("document-settings",a);c.filter=new k(s.rootElement);b+=c.writeToString(s.rootElement.settings,a);return b+""}function u(){var a=j.namespaces,c=new xmldom.LSSerializer,b=B("document-styles",a); -c.filter=new k(s.rootElement,s.rootElement.masterStyles);b+=c.writeToString(s.rootElement.fontFaceDecls,a);b+=c.writeToString(s.rootElement.styles,a);b+=c.writeToString(s.rootElement.automaticStyles,a);b+=c.writeToString(s.rootElement.masterStyles,a);return b+""}function I(){var a=j.namespaces,c=new xmldom.LSSerializer,b=B("document-content",a);c.filter=new k(s.rootElement,s.rootElement.body);b+=c.writeToString(s.rootElement.automaticStyles,a);b+=c.writeToString(s.rootElement.body, -a);return b+""}function r(a,c){var b;b=runtime.byteArrayFromString(x(),"utf8");t.save("settings.xml",b,!0,new Date);b=runtime.byteArrayFromString(D(),"utf8");t.save("meta.xml",b,!0,new Date);b=runtime.byteArrayFromString(u(),"utf8");t.save("styles.xml",b,!0,new Date);b=runtime.byteArrayFromString(I(),"utf8");t.save("content.xml",b,!0,new Date);t.writeAs(a,function(a){c(a)})}var s=this,t=null;this.onstatereadychange=f;this.parts=this.rootElement=this.state=this.onchange=null; +c.filter=new k(s.rootElement,s.rootElement.masterStyles);b+=c.writeToString(s.rootElement.fontFaceDecls,a);b+=c.writeToString(s.rootElement.styles,a);b+=c.writeToString(s.rootElement.automaticStyles,a);b+=c.writeToString(s.rootElement.masterStyles,a);return b+""}function J(){var a=j.namespaces,c=new xmldom.LSSerializer,b=B("document-content",a);c.filter=new k(s.rootElement,s.rootElement.body);b+=c.writeToString(s.rootElement.automaticStyles,a);b+=c.writeToString(s.rootElement.body, +a);return b+""}function r(a,c){var b;b=runtime.byteArrayFromString(x(),"utf8");t.save("settings.xml",b,!0,new Date);b=runtime.byteArrayFromString(D(),"utf8");t.save("meta.xml",b,!0,new Date);b=runtime.byteArrayFromString(u(),"utf8");t.save("styles.xml",b,!0,new Date);b=runtime.byteArrayFromString(J(),"utf8");t.save("content.xml",b,!0,new Date);t.writeAs(a,function(a){c(a)})}var s=this,t=null;this.onstatereadychange=f;this.parts=this.rootElement=this.state=this.onchange=null; this.getPart=function(a){return new c(a,s,t)};this.saveAs=r;this.save=function(a){r(d,a)};this.state=p.LOADING;var q=document.createElementNS(b.namespaceURI,b.localName),F,O=new b;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,c){t=c;a?runtime.loadXML(d,function(c,b){if(c)a&&(t.error=a+"\n"+c,A(p.INVALID));else{var d=n(b);!d||"document"!==d.localName||d.namespaceURI!==e?A(p.INVALID):(s.rootElement=d,d.fontFaceDecls=i(d,e,"font-face-decls"), d.styles=i(d,e,"styles"),d.automaticStyles=i(d,e,"automatic-styles"),d.masterStyles=i(d,e,"master-styles"),d.body=i(d,e,"body"),d.meta=i(d,e,"meta"),A(p.DONE))}}):t.loadAsDOM("styles.xml",function(a,c){var b=n(c),d=s.rootElement;!b||"document-styles"!==b.localName||b.namespaceURI!==e?A(p.INVALID):(d.fontFaceDecls=i(b,e,"font-face-decls"),h(d,d.fontFaceDecls),d.styles=i(b,e,"styles"),h(d,d.styles),d.automaticStyles=i(b,e,"automatic-styles"),h(d,d.automaticStyles),d.masterStyles=i(b,e,"master-styles"), h(d,d.masterStyles),l.loadFonts(d.fontFaceDecls,t,null));s.state!==p.INVALID&&t.loadAsDOM("content.xml",function(a,c){var b=n(c),d,f,j;if(!b||b.localName!=="document-content"||b.namespaceURI!==e)A(p.INVALID);else{d=s.rootElement;f=i(b,e,"font-face-decls");if(d.fontFaceDecls&&f)for(j=f.firstChild;j;){d.fontFaceDecls.appendChild(j);j=f.firstChild}else if(f){d.fontFaceDecls=f;h(d,f)}f=i(b,e,"automatic-styles");if(d.automaticStyles&&f)for(j=f.firstChild;j;){d.automaticStyles.appendChild(j);j=f.firstChild}else if(f){d.automaticStyles= @@ -308,24 +308,23 @@ runtime.loadClass("odf.OdfContainer");runtime.loadClass("odf.Formatting");runtim odf.OdfCanvas=function(){function i(a){function c(){for(;0 text|list-item > *:first-child:before {";if(y=x.getAttributeNS(g,"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"},J=void 0,J=L.getAttributeNS(f,"num-prefix")||"",J=G.hasOwnProperty(x)?J+(" counter(list, "+G[x]+")"):x?J+("'"+ -x+"';"):J+" ''",y&&(J+=" '"+y+"'"),x=G="content: "+J+";"):"list-level-style-image"===L.localName?x="content: none;":"list-level-style-bullet"===L.localName&&(x="content: '"+L.getAttributeNS(g,"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,h=d&&d.endContainer,j=d&&d.endOffset,i,k;b&&!((b.localName==="p"||b.localName=== -"h")&&b.namespaceURI===g);)b=b.parentNode;if(R&&b&&b.parentNode!==v){i=b.ownerDocument;k=i.documentElement.namespaceURI;if(v)v.parentNode&&u();else{v=i.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(h,j);c.addRange(d)}if(a.preventDefault){a.preventDefault();a.stopPropagation()}else{a.returnValue= -false;a.cancelBubble=true}}})};return odf.OdfCanvas}(); +b.getElementsByTagName("head")[0],d=b.createElementNS(c.namespaceURI,"style"),e="",f;d.setAttribute("type","text/css");d.setAttribute("media","screen, print, handheld, projection");for(f in a)a.hasOwnProperty(f)&&f&&(e+="@namespace "+f+" url("+a[f]+");\n");d.appendChild(b.createTextNode(e));c.appendChild(d);return d}var c=new odf.Style2CSS,a=c.namespaces,d=a.draw,j=a.fo,e=a.office,f=a.style,m=a.svg,l=a.table,g=a.text,o=a.xlink,p=a.xml,y=runtime.getWindow(),C=new xmldom.XPath,w={},v,A=new function(){function a(d){c= +!0;runtime.setTimeout(function(){try{d()}catch(e){runtime.log(e)}c=!1;0 text|list-item > *:first-child:before {";if(z=x.getAttributeNS(g,"style-name"))x=t[z],L=x.firstChild,x=void 0,"list-level-style-number"===L.localName?(x=L.getAttributeNS(f,"num-format"),z=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+" ''",z&&(I+=" '"+z+"'"),x=G="content: "+I+";"):"list-level-style-image"=== +L.localName?x="content: none;":"list-level-style-bullet"===L.localName&&(x="content: '"+L.getAttributeNS(g,"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,h=d&&d.endContainer,j=d&&d.endOffset,i,k;b&&!((b.localName==="p"||b.localName==="h")&&b.namespaceURI===g);)b=b.parentNode;if(R&&b&&b.parentNode!==v){i=b.ownerDocument;k=i.documentElement.namespaceURI; +if(v)v.parentNode&&u();else{v=i.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(h,j);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(i,n,k){new odf.OdfContainer(i,function(h){if(h.state===odf.OdfContainer.INVALID)return k("Document "+i+" is invalid.");h.state===odf.OdfContainer.DONE?h.saveAs(n,function(b){k(b)}):k("Document was not completely loaded.")})};this.render=function(i,n,k){for(n=n.getElementsByTagName("body")[0];n.firstChild;)n.removeChild(n.firstChild);n=new odf.OdfCanvas(n);n.addListener("statereadychange",function(h){k(h)});n.load(i)}}; From 8e47bb853616f03d44b2bf5aaba7c7ac33c812fb Mon Sep 17 00:00:00 2001 From: Aditya Bhatt Date: Fri, 21 Sep 2012 00:39:53 +0530 Subject: [PATCH 24/33] added an OdfCanvas.fitSmart method, for automatic zoom depending on the page size --- webodf/lib/odf/OdfCanvas.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/webodf/lib/odf/OdfCanvas.js b/webodf/lib/odf/OdfCanvas.js index 8029eaaa..6cd552a3 100644 --- a/webodf/lib/odf/OdfCanvas.js +++ b/webodf/lib/odf/OdfCanvas.js @@ -1129,6 +1129,17 @@ odf.OdfCanvas = (function () { fixContainerSize(); }; + /** + * @param {!number} width + * @return {undefined} + */ + this.fitSmart = function (width) { + var realWidth = element.offsetWidth / zoomLevel; + var newScale = width / realWidth; + zoomLevel = Math.min(1.0, newScale); + + fixContainerSize(); + }; /** * @param {!number} height * @return {undefined} From feafce137e78cce9e490fe26405f7b2fcf73b771 Mon Sep 17 00:00:00 2001 From: Aditya Bhatt Date: Fri, 21 Sep 2012 00:40:31 +0530 Subject: [PATCH 25/33] page view styles menu works --- programs/viewer/index.html | 2 +- programs/viewer/viewer.css | 4 --- programs/viewer/viewer.js | 67 ++++++++++++++++++++++--------------- programs/viewer/webodf.js | 68 +++++++++++++++++++------------------- 4 files changed, 76 insertions(+), 65 deletions(-) diff --git a/programs/viewer/index.html b/programs/viewer/index.html index bdc137af..9cb6df36 100644 --- a/programs/viewer/index.html +++ b/programs/viewer/index.html @@ -18,7 +18,7 @@
+
+
+
@@ -43,4 +49,4 @@
- + \ No newline at end of file diff --git a/programs/viewer/viewer.css b/programs/viewer/viewer.css index 8a660941..40fa0ac0 100644 --- a/programs/viewer/viewer.css +++ b/programs/viewer/viewer.css @@ -3,6 +3,35 @@ margin: 0; } +#titlebar { + position: absolute; + z-index: 2; + top: 0px; + left: 0px; + height: 32px; + width: 100%; + overflow: hidden; + + -webkit-box-shadow: 0px 1px 3px rgba(50, 50, 50, 0.75); + -moz-box-shadow: 0px 1px 3px rgba(50, 50, 50, 0.75); + box-shadow: 0px 1px 3px rgba(50, 50, 50, 0.75); + + background-image: url(images/texture.png), linear-gradient(rgba(69, 69, 69, .95), rgba(82, 82, 82, .99)); + background-image: url(images/texture.png), -webkit-linear-gradient(rgba(69, 69, 69, .95), rgba(82, 82, 82, .99)); + background-image: url(images/texture.png), -moz-linear-gradient(rgba(69, 69, 69, .95), rgba(82, 82, 82, .99)); + background-image: url(images/texture.png), -ms-linear-gradient(rgba(69, 69, 69, .95), rgba(82, 82, 82, .99)); + background-image: url(images/texture.png), -o-linear-gradient(rgba(69, 69, 69, .95), rgba(82, 82, 82, .99)); +} + +#documentName { + margin-left: 10px; + margin-top: 8px; + color: #F2F2F2; + font-size: 14px; + line-height: 14px; + font-family: sans-serif; +} + #toolbarContainer { position: absolute; z-index: 2; @@ -407,10 +436,10 @@ html[dir='rtl'] .dropdownToolbarButton { #canvasContainer { overflow: auto; - padding-top: 30px; - padding-bottom: 30px; + padding-top: 6px; + padding-bottom: 6px; position: absolute; - top: 0px; + top: 32px; right: 0; bottom: 32px; left: 0; diff --git a/programs/viewer/viewer.js b/programs/viewer/viewer.js index 1325e04b..3beedf7f 100644 --- a/programs/viewer/viewer.js +++ b/programs/viewer/viewer.js @@ -54,6 +54,7 @@ var Viewer = { root: null, documentType: null, pages: [], + currentPage: null, initialize: function() { // If the URL has a fragment (#...), try to load the file it represents @@ -74,6 +75,8 @@ var Viewer = { this.odfCanvas.load(location); document.title = this.filename; + document.getElementById('documentName').innerHTML = document.title; + if(! (document.cancelFullScreen || document.mozCancelFullScreen || document.webkitCancelFullScreen) ) document.getElementById('fullscreen').style.visibility = 'hidden'; @@ -84,9 +87,12 @@ var Viewer = { self.documentType = getDocumentType(self.root); if(self.documentType == 'presentation') { + // no padding for presentations self.odfElement.parentNode.style.padding = 0; + // get a list of pages self.pages = self.getPages(); - self.odfCanvas.showFirstPage(); + // start with the first page + self.showPage(1); } self.parseScale(kDefaultScale); @@ -205,6 +211,22 @@ var Viewer = { pages.push(tuple); } return pages; + }, + + showPage: function(n) { + if(n <= 0 || n > this.pages.length) + return; + + this.odfCanvas.showPage(n); + this.currentPage = n; + }, + + showNextPage: function() { + this.showPage(this.currentPage + 1); + }, + + showPreviousPage: function() { + this.showPage(this.currentPage - 1); } }; @@ -227,8 +249,7 @@ window.onload = function() { Viewer.zoomIn(); }); - document.getElementById('scaleSelect').addEventListener('change', - function() { + document.getElementById('scaleSelect').addEventListener('change', function() { Viewer.parseScale(this.value); }); @@ -249,4 +270,20 @@ window.onload = function() { document.getElementById('pageAutoOption').selected)) Viewer.parseScale(document.getElementById('scaleSelect').value); }); + + window.addEventListener('keydown', function(evt) { + var code = evt.keyCode; + if (evt.charCode && code == 0) + code = evt.charCode; + switch(code) { + case 38: // up + case 37: // left + Viewer.showPreviousPage(); + break; + case 40: // down + case 39: // right + Viewer.showNextPage(); + break; + } + }); }; diff --git a/programs/viewer/webodf.js b/programs/viewer/webodf.js index 63420bfa..974d6cc3 100644 --- a/programs/viewer/webodf.js +++ b/programs/viewer/webodf.js @@ -72,20 +72,20 @@ this.convertUTF16StringToBase64=A;this.convertBase64ToUTF16String=B;this.fromBas var webodf_css="@namespace draw url(urn:oasis:names:tc:opendocument:xmlns:drawing:1.0);\n@namespace fo url(urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0);\n@namespace office url(urn:oasis:names:tc:opendocument:xmlns:office:1.0);\n@namespace presentation url(urn:oasis:names:tc:opendocument:xmlns:presentation:1.0);\n@namespace style url(urn:oasis:names:tc:opendocument:xmlns:style:1.0);\n@namespace svg url(urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0);\n@namespace table url(urn:oasis:names:tc:opendocument:xmlns:table:1.0);\n@namespace text url(urn:oasis:names:tc:opendocument:xmlns:text:1.0);\n@namespace runtimens url(urn:webodf); /* namespace for runtime only */\n\noffice|document > *, office|document-content > * {\n display: none;\n}\noffice|body, office|document {\n display: inline-block;\n position: relative;\n}\n\ntext|p, text|h {\n display: block;\n padding: 3px 3px 3px 3px;\n margin: 5px 5px 5px 5px;\n}\ntext|h {\n font-weight: bold;\n}\n*[runtimens|containsparagraphanchor] {\n position: relative;\n}\ntext|s:before { /* this needs to be the number of spaces given by text:c */\n content: ' ';\n}\ntext|tab:before {\n display: inline;\n content: ' ';\n}\ntext|line-break {\n content: \" \";\n display: block;\n}\ntext|tracked-changes {\n /*Consumers that do not support change tracking, should ignore changes.*/\n display: none;\n}\noffice|binary-data {\n display: none;\n}\noffice|text {\n display: block;\n width: 216mm; /* default to A4 width */\n min-height: 279mm;\n padding-left: 32mm;\n padding-right: 32mm;\n padding-top: 25mm;\n padding-bottom: 13mm;\n margin: 2px;\n text-align: left;\n overflow: hidden;\n}\noffice|spreadsheet {\n display: block;\n border-collapse: collapse;\n empty-cells: show;\n font-family: sans-serif;\n font-size: 10pt;\n text-align: left;\n page-break-inside: avoid;\n overflow: hidden;\n}\noffice|presentation {\n display: inline-block;\n text-align: left;\n}\ndraw|page {\n display: block;\n height: 21cm;\n width: 28cm;\n margin: 3px;\n position: relative;\n overflow: hidden;\n}\npresentation|notes {\n display: none;\n}\n@media print {\n draw|page {\n border: 1pt solid black;\n page-break-inside: avoid;\n }\n presentation|notes {\n /*TODO*/\n }\n}\noffice|spreadsheet text|p {\n border: 0px;\n padding: 1px;\n margin: 0px;\n}\noffice|spreadsheet table|table {\n margin: 3px;\n}\noffice|spreadsheet table|table:after {\n /* show sheet name the end of the sheet */\n /*content: attr(table|name);*/ /* gives parsing error in opera */\n}\noffice|spreadsheet table|table-row {\n counter-increment: row;\n}\noffice|spreadsheet table|table-row:before {\n width: 3em;\n background: #cccccc;\n border: 1px solid black;\n text-align: center;\n content: counter(row);\n display: table-cell;\n}\noffice|spreadsheet table|table-cell {\n border: 1px solid #cccccc;\n}\ntable|table {\n display: table;\n}\ndraw|frame table|table {\n width: 100%;\n height: 100%;\n background: white;\n}\ntable|table-header-rows {\n display: table-header-group;\n}\ntable|table-row {\n display: table-row;\n}\ntable|table-column {\n display: table-column;\n}\ntable|table-cell {\n width: 0.889in;\n display: table-cell;\n}\ndraw|frame {\n display: block;\n}\ndraw|image {\n display: block;\n width: 100%;\n height: 100%;\n top: 0px;\n left: 0px;\n background-repeat: no-repeat;\n background-size: 100% 100%;\n -moz-background-size: 100% 100%;\n}\n/* only show the first image in frame */\ndraw|frame > 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(g){e[m+f++]=g;if(m+f===c){var q;if(0!==f){null!==b?(g=b,b=b.next):g=new i; -g.next=null;g.len=g.off=0;null===a?a=d=g:d=d.next=g;g.len=f-m;for(q=0;q>>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,g=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])>g&&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,g=-1,q=e;X=0;ba=573; -for(d=0;dX;)d=N[++X]=2>g?++g:0,b[d].fc=1,U[d]=0,Y--,null!==c&&(da-=c[d].dl);a.max_code=g;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[q].fc=b[d].fc+b[c].fc,U[q]=U[d]>U[c]+1?U[d]:U[c]+1,b[d].dl=b[c].dl=q,N[1]=q++,ta(b,1);while(2<=X);N[--ba]=N[1];q=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;q[N[ba]].dl=0;for(a=ba+1;573>a;a++)if(m= -N[a],f=q[q[m].dl].dl+1,f>h&&(f=h,l++),q[m].dl=f,!(m>c))Q[f]++,s=0,m>=e&&(s=d[m-e]),o=q[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||(q[d].dl!==f&&(Y+=(f-q[d].dl)*q[d].fc,q[d].fc=f),m--)}Aa(b,g)},Ba=function(a,b){var c,e=-1,d,q=a[0].dl,g=0,h=7,f=4;0===q&&(h=138,f=3);a[b+1].dl=65535;for(c=0;c<=b;c++)if(d=q,q=a[c+1].dl,!(++g=g?H[17].fc++:H[18].fc++,g=0,e=d,0===q)?(h=138,f=3):d===q?(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);g>>=1}while(e=g?(Z(17,H),T(g-3,3)):(Z(18,H),T(g-11,7));g=0;e=d;0===q?(h=138,f=3):d===q?(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<>>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(q,g){var f,m;ka=q;qa=0;"undefined"===String(typeof g)&&(g=6);(f=g)?1>f?f=1:9q&&(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 @@ -95,9 +95,9 @@ core.ByteArrayWriter=function(j){var n=this,k=new runtime.ByteArray(0);this.appe 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,q){this.BMAX=16;this.N_MAX=288;this.status=0;this.root=null;this.m=0;var g=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&&(q=o);for(n=1<(n-=g[s])){this.status=2;this.m=q;return}if(0>(n-=g[o]))this.status=2,this.m=q;else{g[o]+=n;C[1]=s=0;F=g;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)>q?q: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++]): +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(;00?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}(); +y;y=b/(a.offsetWidth/y);c/d0?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)}}; From 5a9e57929c08a6fb184bc4cf2754679ff7414ad4 Mon Sep 17 00:00:00 2001 From: Aditya Bhatt Date: Sat, 22 Sep 2012 07:14:03 +0530 Subject: [PATCH 33/33] page navigation controls --- .../viewer/images/toolbarButton-pageDown.png | Bin 0 -> 353 bytes .../viewer/images/toolbarButton-pageUp.png | Bin 0 -> 344 bytes programs/viewer/index.html | 10 +++ programs/viewer/viewer.css | 84 ++++++++++++++++++ programs/viewer/viewer.js | 28 +++++- 5 files changed, 120 insertions(+), 2 deletions(-) create mode 100644 programs/viewer/images/toolbarButton-pageDown.png create mode 100644 programs/viewer/images/toolbarButton-pageUp.png diff --git a/programs/viewer/images/toolbarButton-pageDown.png b/programs/viewer/images/toolbarButton-pageDown.png new file mode 100644 index 0000000000000000000000000000000000000000..762ac43e08cf71f688136dd9c391e1eeac8336b6 GIT binary patch literal 353 zcmV-n0iOPeP)N)i16KOjF~A%cy9L}N?{*aRypMbKt#Y{Wu@^dWzc zB43gw@m?5VSf4XKI1uvgxkJb(Jp(WVYhVPnHDj;=mcX2{j2A`GW>r;L-}l82ZQFh| zO*2i?^oZrQ5>KD9SC-`y?f{*0oaG|B7xlwaLz8mj}qKT!aP_teqVs_y##kUGoqtiwOACzF#-<;cM@iX z4qc!Yz$DM}D=cpR1G99rt30p*4zet}M&QNP=Y&2{#AlocLCwd zgzqHz&yp|CdBw$>ph$U z)hTRj6#q=2*TFhKHzx|6MzWGs8Z{*folGT{Oft!nX+2TscPHu_w7sJZOjQKt!iL$+`E7GKObZu1M&0Q qn}h0!&|(*d3p}p4q{kr^2K)fvg`AtvZ>v!N0000
+
+ + + + +
diff --git a/programs/viewer/viewer.css b/programs/viewer/viewer.css index 40fa0ac0..0fe318bf 100644 --- a/programs/viewer/viewer.css +++ b/programs/viewer/viewer.css @@ -3,6 +3,18 @@ margin: 0; } +body { + font-family: sans-serif; +} + +.titlebar > span, +.toolbarLabel, +input, +button, +select { + font: message-box; +} + #titlebar { position: absolute; z-index: 2; @@ -346,6 +358,7 @@ html[dir='ltr'] .splitToolbarButton > .toolbarButton:first-child, html[dir='rtl'] .splitToolbarButton > .toolbarButton:last-child { position: relative; margin: 0; + margin-left: 4px; margin-right: -1px; border-top-left-radius: 2px; border-bottom-left-radius: 2px; @@ -433,6 +446,73 @@ html[dir='rtl'] .dropdownToolbarButton { content: url(images/toolbarButton-zoomIn.png); } +.toolbarButton.pageUp::before { + display: inline-block; + content: url(images/toolbarButton-pageUp.png); +} + +.toolbarButton.pageDown::before { + display: inline-block; + content: url(images/toolbarButton-pageDown.png); +} + +.toolbarField.pageNumber { + min-width: 16px; + text-align: right; + width: 40px; +} + +.toolbarField { + padding: 3px 6px; + margin: 4px 0 4px 0; + border: 1px solid transparent; + border-radius: 2px; + background-color: hsla(0,0%,100%,.09); + background-image: -moz-linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,100%,0)); + background-clip: padding-box; + border: 1px solid hsla(0,0%,0%,.35); + border-color: hsla(0,0%,0%,.32) hsla(0,0%,0%,.38) hsla(0,0%,0%,.42); + box-shadow: 0 1px 0 hsla(0,0%,0%,.05) inset, + 0 1px 0 hsla(0,0%,100%,.05); + color: hsl(0,0%,95%); + font-size: 12px; + line-height: 14px; + outline-style: none; + -moz-transition-property: background-color, border-color, box-shadow; + -moz-transition-duration: 150ms; + -moz-transition-timing-function: ease; +} + +.toolbarField.pageNumber::-webkit-inner-spin-button, +.toolbarField.pageNumber::-webkit-outer-spin-button { + -webkit-appearance: none; + margin: 0; +} + +.toolbarField:hover { + background-color: hsla(0,0%,100%,.11); + border-color: hsla(0,0%,0%,.4) hsla(0,0%,0%,.43) hsla(0,0%,0%,.45); +} + +.toolbarField:focus { + background-color: hsla(0,0%,100%,.15); + border-color: hsla(204,100%,65%,.8) hsla(204,100%,65%,.85) hsla(204,100%,65%,.9); +} + +.toolbarLabel { + min-width: 16px; + padding: 3px 6px 3px 2px; + margin: 4px 2px 4px 0; + border: 1px solid transparent; + border-radius: 2px; + color: hsl(0,0%,85%); + font-size: 12px; + line-height: 14px; + text-align: left; + -webkit-user-select:none; + -moz-user-select:none; + cursor: default; +} #canvasContainer { overflow: auto; @@ -458,3 +538,7 @@ html[dir='rtl'] .dropdownToolbarButton { -ms-box-shadow: 0px 0px 7px rgba(0, 0, 0, 0.75); -o-box-shadow: 0px 0px 7px rgba(0, 0, 0, 0.75); } + +#sliderContainer { + visibility: hidden; +} \ No newline at end of file diff --git a/programs/viewer/viewer.js b/programs/viewer/viewer.js index 3beedf7f..7f639807 100644 --- a/programs/viewer/viewer.js +++ b/programs/viewer/viewer.js @@ -87,14 +87,23 @@ var Viewer = { self.documentType = getDocumentType(self.root); if(self.documentType == 'presentation') { + // temporary hack: remove zoom buttons to make way for the navigation controls + document.getElementById('toolbarMiddle').style.visibility = 'hidden'; + // no padding for presentations self.odfElement.parentNode.style.padding = 0; // get a list of pages self.pages = self.getPages(); + document.getElementById('numPages').innerHTML = 'of ' + self.pages.length; + // start with the first page self.showPage(1); } + else { + document.getElementById('toolbarLeft').style.visibility = 'hidden'; + } + // WTF, but I need to call it thrice to render presentations properly. Need to investigate. self.parseScale(kDefaultScale); self.parseScale(kDefaultScale); self.parseScale(kDefaultScale); @@ -214,11 +223,14 @@ var Viewer = { }, showPage: function(n) { - if(n <= 0 || n > this.pages.length) - return; + if (n <= 0) + n = 1; + else if (n > this.pages.length) + n = this.pages.length; this.odfCanvas.showPage(n); this.currentPage = n; + document.getElementById('pageNumber').value = this.currentPage; }, showNextPage: function() { @@ -249,6 +261,18 @@ window.onload = function() { Viewer.zoomIn(); }); + document.getElementById('previous').addEventListener('click', function() { + Viewer.showPreviousPage(); + }); + + document.getElementById('next').addEventListener('click', function() { + Viewer.showNextPage(); + }); + + document.getElementById('pageNumber').addEventListener('change', function() { + Viewer.showPage(this.value); + }) + document.getElementById('scaleSelect').addEventListener('change', function() { Viewer.parseScale(this.value); });