From 08ae7fcb349f65bfff93e41fae6136e52e66e683 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Tue, 17 Nov 2015 20:02:05 +0100 Subject: [PATCH 1/5] [ADD] viewerjs 0.5.8 --- .../static/lib/ViewerJS/compatibility.js | 29 +- .../static/lib/ViewerJS/index.html | 62 +- attachment_preview/static/lib/ViewerJS/pdf.js | 391 +++-- .../static/lib/ViewerJS/pdf.worker.js | 447 +++-- .../static/lib/ViewerJS/pdfjsversion.js | 2 +- .../static/lib/ViewerJS/text_layer_builder.js | 90 +- .../static/lib/ViewerJS/ui_utils.js | 99 +- .../static/lib/ViewerJS/webodf.js | 1468 ++++++++++------- 8 files changed, 1691 insertions(+), 897 deletions(-) diff --git a/attachment_preview/static/lib/ViewerJS/compatibility.js b/attachment_preview/static/lib/ViewerJS/compatibility.js index 967e312a..06f54bff 100644 --- a/attachment_preview/static/lib/ViewerJS/compatibility.js +++ b/attachment_preview/static/lib/ViewerJS/compatibility.js @@ -447,20 +447,10 @@ if (typeof PDFJS === 'undefined') { // Checks if navigator.language is supported (function checkNavigatorLanguage() { - if ('language' in navigator && - /^[a-z]+(-[A-Z]+)?$/.test(navigator.language)) { + if ('language' in navigator) { return; } - function formatLocale(locale) { - var split = locale.split(/[-_]/); - split[0] = split[0].toLowerCase(); - if (split.length > 1) { - split[1] = split[1].toUpperCase(); - } - return split.join('-'); - } - var language = navigator.language || navigator.userLanguage || 'en-US'; - PDFJS.locale = formatLocale(language); + PDFJS.locale = navigator.userLanguage || 'en-US'; })(); (function checkRangeRequests() { @@ -479,7 +469,10 @@ if (typeof PDFJS === 'undefined') { var regex = /Android\s[0-2][^\d]/; var isOldAndroid = regex.test(navigator.userAgent); - if (isSafari || isOldAndroid) { + // Range requests are broken in Chrome 39 and 40, https://crbug.com/442318 + var isChromeWithRangeBug = /Chrome\/(39|40)\./.test(navigator.userAgent); + + if (isSafari || isOldAndroid || isChromeWithRangeBug) { PDFJS.disableRange = true; PDFJS.disableStream = true; } @@ -572,3 +565,13 @@ if (typeof PDFJS === 'undefined') { PDFJS.maxCanvasPixels = 5242880; } })(); + +// Disable fullscreen support for certain problematic configurations. +// Support: IE11+ (when embedded). +(function checkFullscreenSupport() { + var isEmbeddedIE = (navigator.userAgent.indexOf('Trident') >= 0 && + window.parent !== window); + if (isEmbeddedIE) { + PDFJS.disableFullscreen = true; + } +})(); diff --git a/attachment_preview/static/lib/ViewerJS/index.html b/attachment_preview/static/lib/ViewerJS/index.html index c7496ceb..2eb1fd47 100644 --- a/attachment_preview/static/lib/ViewerJS/index.html +++ b/attachment_preview/static/lib/ViewerJS/index.html @@ -39,43 +39,41 @@ along with ViewerJS. If not, see . - - diff --git a/attachment_preview/static/lib/ViewerJS/pdf.js b/attachment_preview/static/lib/ViewerJS/pdf.js index 41509814..463d7d0f 100644 --- a/attachment_preview/static/lib/ViewerJS/pdf.js +++ b/attachment_preview/static/lib/ViewerJS/pdf.js @@ -22,8 +22,8 @@ if (typeof PDFJS === 'undefined') { (typeof window !== 'undefined' ? window : this).PDFJS = {}; } -PDFJS.version = '1.0.1040'; -PDFJS.build = '997096f'; +PDFJS.version = '1.1.114'; +PDFJS.build = '3fd44fd'; (function pdfjsWrapper() { // Use strict in our context only - users might not want it @@ -239,17 +239,10 @@ function warn(msg) { // Fatal errors that should trigger the fallback UI and halt execution by // throwing an exception. function error(msg) { - // If multiple arguments were passed, pass them all to the log function. - if (arguments.length > 1) { - var logArguments = ['Error:']; - logArguments.push.apply(logArguments, arguments); - console.log.apply(console, logArguments); - // Join the arguments into a single string for the lines below. - msg = [].join.call(arguments, ' '); - } else { + if (PDFJS.verbosity >= PDFJS.VERBOSITY_LEVELS.errors) { console.log('Error: ' + msg); + console.log(backtrace()); } - console.log(backtrace()); UnsupportedManager.notify(UNSUPPORTED_FEATURES.unknown); throw new Error(msg); } @@ -341,6 +334,7 @@ function isValidUrl(url, allowRelative) { case 'https': case 'ftp': case 'mailto': + case 'tel': return true; default: return false; @@ -355,6 +349,7 @@ function shadow(obj, prop, value) { writable: false }); return value; } +PDFJS.shadow = shadow; var PasswordResponses = PDFJS.PasswordResponses = { NEED_PASSWORD: 1, @@ -470,6 +465,8 @@ var XRefParseException = (function XRefParseExceptionClosure() { function bytesToString(bytes) { + assert(bytes !== null && typeof bytes === 'object' && + bytes.length !== undefined, 'Invalid argument for bytesToString'); var length = bytes.length; var MAX_ARGUMENT_COUNT = 8192; if (length < MAX_ARGUMENT_COUNT) { @@ -485,6 +482,7 @@ function bytesToString(bytes) { } function stringToBytes(str) { + assert(typeof str === 'string', 'Invalid argument for stringToBytes'); var length = str.length; var bytes = new Uint8Array(length); for (var i = 0; i < length; ++i) { @@ -1002,10 +1000,6 @@ function isString(v) { return typeof v === 'string'; } -function isNull(v) { - return v === null; -} - function isName(v) { return v instanceof Name; } @@ -1639,7 +1633,7 @@ PDFJS.cMapUrl = (PDFJS.cMapUrl === undefined ? null : PDFJS.cMapUrl); */ PDFJS.cMapPacked = PDFJS.cMapPacked === undefined ? false : PDFJS.cMapPacked; -/* +/** * By default fonts are converted to OpenType fonts and loaded via font face * rules. If disabled, the font will be rendered using a built in font renderer * that constructs the glyphs with primitive path commands. @@ -1694,6 +1688,9 @@ PDFJS.disableStream = (PDFJS.disableStream === undefined ? * Disable pre-fetching of PDF file data. When range requests are enabled PDF.js * will automatically keep fetching more data even if it isn't needed to display * the current page. This default behavior can be disabled. + * + * NOTE: It is also necessary to disable streaming, see above, + * in order for disabling of pre-fetching to work correctly. * @var {boolean} */ PDFJS.disableAutoFetch = (PDFJS.disableAutoFetch === undefined ? @@ -1726,6 +1723,14 @@ PDFJS.disableCreateObjectURL = (PDFJS.disableCreateObjectURL === undefined ? PDFJS.disableWebGL = (PDFJS.disableWebGL === undefined ? true : PDFJS.disableWebGL); +/** + * Disables fullscreen support, and by extension Presentation Mode, + * in browsers which support the fullscreen API. + * @var {boolean} + */ +PDFJS.disableFullscreen = (PDFJS.disableFullscreen === undefined ? + false : PDFJS.disableFullscreen); + /** * Enables CSS only zooming. * @var {boolean} @@ -1745,19 +1750,30 @@ PDFJS.verbosity = (PDFJS.verbosity === undefined ? PDFJS.VERBOSITY_LEVELS.warnings : PDFJS.verbosity); /** - * The maximum supported canvas size in total pixels e.g. width * height. + * The maximum supported canvas size in total pixels e.g. width * height. * The default value is 4096 * 4096. Use -1 for no limit. * @var {number} */ PDFJS.maxCanvasPixels = (PDFJS.maxCanvasPixels === undefined ? 16777216 : PDFJS.maxCanvasPixels); +/** + * Opens external links in a new window if enabled. The default behavior opens + * external links in the PDF.js window. + * @var {boolean} + */ +PDFJS.openExternalLinksInNewWindow = ( + PDFJS.openExternalLinksInNewWindow === undefined ? + false : PDFJS.openExternalLinksInNewWindow); + /** * Document initialization / loading parameters object. * * @typedef {Object} DocumentInitParameters * @property {string} url - The URL of the PDF. - * @property {TypedArray} data - A typed array with PDF data. + * @property {TypedArray|Array|string} data - Binary PDF data. Use typed arrays + * (Uint8Array) to improve the memory usage. If PDF data is BASE64-encoded, + * use atob() to convert it to a binary string first. * @property {Object} httpHeaders - Basic authentication headers. * @property {boolean} withCredentials - Indicates whether or not cross-site * Access-Control requests should be made using credentials such as cookies @@ -1766,6 +1782,9 @@ PDFJS.maxCanvasPixels = (PDFJS.maxCanvasPixels === undefined ? * @property {TypedArray} initialData - A typed array with the first portion or * all of the pdf data. Used by the extension since some data is already * loaded before the switch to range requests. + * @property {number} length - The PDF file length. It's used for progress + * reports and range requests operations. + * @property {PDFDataRangeTransport} range */ /** @@ -1782,68 +1801,226 @@ PDFJS.maxCanvasPixels = (PDFJS.maxCanvasPixels === undefined ? * is used, which means it must follow the same origin rules that any XHR does * e.g. No cross domain requests without CORS. * - * @param {string|TypedArray|DocumentInitParameters} source Can be a url to - * where a PDF is located, a typed array (Uint8Array) already populated with - * data or parameter object. + * @param {string|TypedArray|DocumentInitParameters|PDFDataRangeTransport} src + * Can be a url to where a PDF is located, a typed array (Uint8Array) + * already populated with data or parameter object. * - * @param {Object} pdfDataRangeTransport is optional. It is used if you want - * to manually serve range requests for data in the PDF. See viewer.js for - * an example of pdfDataRangeTransport's interface. + * @param {PDFDataRangeTransport} pdfDataRangeTransport (deprecated) It is used + * if you want to manually serve range requests for data in the PDF. * - * @param {function} passwordCallback is optional. It is used to request a + * @param {function} passwordCallback (deprecated) It is used to request a * password if wrong or no password was provided. The callback receives two * parameters: function that needs to be called with new password and reason * (see {PasswordResponses}). * - * @param {function} progressCallback is optional. It is used to be able to + * @param {function} progressCallback (deprecated) It is used to be able to * monitor the loading progress of the PDF file (necessary to implement e.g. * a loading bar). The callback receives an {Object} with the properties: * {number} loaded and {number} total. * - * @return {Promise} A promise that is resolved with {@link PDFDocumentProxy} - * object. + * @return {PDFDocumentLoadingTask} */ -PDFJS.getDocument = function getDocument(source, +PDFJS.getDocument = function getDocument(src, pdfDataRangeTransport, passwordCallback, progressCallback) { - var workerInitializedCapability, workerReadyCapability, transport; + var task = new PDFDocumentLoadingTask(); - if (typeof source === 'string') { - source = { url: source }; - } else if (isArrayBuffer(source)) { - source = { data: source }; - } else if (typeof source !== 'object') { - error('Invalid parameter in getDocument, need either Uint8Array, ' + - 'string or a parameter object'); + // Support of the obsolete arguments (for compatibility with API v1.0) + if (pdfDataRangeTransport) { + if (!(pdfDataRangeTransport instanceof PDFDataRangeTransport)) { + // Not a PDFDataRangeTransport instance, trying to add missing properties. + pdfDataRangeTransport = Object.create(pdfDataRangeTransport); + pdfDataRangeTransport.length = src.length; + pdfDataRangeTransport.initialData = src.initialData; + } + src = Object.create(src); + src.range = pdfDataRangeTransport; + } + task.onPassword = passwordCallback || null; + task.onProgress = progressCallback || null; + + var workerInitializedCapability, transport; + var source; + if (typeof src === 'string') { + source = { url: src }; + } else if (isArrayBuffer(src)) { + source = { data: src }; + } else if (src instanceof PDFDataRangeTransport) { + source = { range: src }; + } else { + if (typeof src !== 'object') { + error('Invalid parameter in getDocument, need either Uint8Array, ' + + 'string or a parameter object'); + } + if (!src.url && !src.data && !src.range) { + error('Invalid parameter object: need either .data, .range or .url'); + } + + source = src; } - if (!source.url && !source.data) { - error('Invalid parameter array, need either .data or .url'); - } - - // copy/use all keys as is except 'url' -- full path is required var params = {}; for (var key in source) { if (key === 'url' && typeof window !== 'undefined') { + // The full path is required in the 'url' field. params[key] = combineUrl(window.location.href, source[key]); continue; + } else if (key === 'range') { + continue; + } else if (key === 'data' && !(source[key] instanceof Uint8Array)) { + // Converting string or array-like data to Uint8Array. + var pdfBytes = source[key]; + if (typeof pdfBytes === 'string') { + params[key] = stringToBytes(pdfBytes); + } else if (typeof pdfBytes === 'object' && pdfBytes !== null && + !isNaN(pdfBytes.length)) { + params[key] = new Uint8Array(pdfBytes); + } else { + error('Invalid PDF binary data: either typed array, string or ' + + 'array-like object is expected in the data property.'); + } + continue; } params[key] = source[key]; } workerInitializedCapability = createPromiseCapability(); - workerReadyCapability = createPromiseCapability(); - transport = new WorkerTransport(workerInitializedCapability, - workerReadyCapability, pdfDataRangeTransport, - progressCallback); + transport = new WorkerTransport(workerInitializedCapability, source.range); workerInitializedCapability.promise.then(function transportInitialized() { - transport.passwordCallback = passwordCallback; - transport.fetchDocument(params); + transport.fetchDocument(task, params); }); - return workerReadyCapability.promise; + + return task; }; +/** + * PDF document loading operation. + * @class + */ +var PDFDocumentLoadingTask = (function PDFDocumentLoadingTaskClosure() { + /** @constructs PDFDocumentLoadingTask */ + function PDFDocumentLoadingTask() { + this._capability = createPromiseCapability(); + + /** + * Callback to request a password if wrong or no password was provided. + * The callback receives two parameters: function that needs to be called + * with new password and reason (see {PasswordResponses}). + */ + this.onPassword = null; + + /** + * Callback to be able to monitor the loading progress of the PDF file + * (necessary to implement e.g. a loading bar). The callback receives + * an {Object} with the properties: {number} loaded and {number} total. + */ + this.onProgress = null; + } + + PDFDocumentLoadingTask.prototype = + /** @lends PDFDocumentLoadingTask.prototype */ { + /** + * @return {Promise} + */ + get promise() { + return this._capability.promise; + }, + + // TODO add cancel or abort method + + /** + * Registers callbacks to indicate the document loading completion. + * + * @param {function} onFulfilled The callback for the loading completion. + * @param {function} onRejected The callback for the loading failure. + * @return {Promise} A promise that is resolved after the onFulfilled or + * onRejected callback. + */ + then: function PDFDocumentLoadingTask_then(onFulfilled, onRejected) { + return this.promise.then.apply(this.promise, arguments); + } + }; + + return PDFDocumentLoadingTask; +})(); + +/** + * Abstract class to support range requests file loading. + * @class + */ +var PDFDataRangeTransport = (function pdfDataRangeTransportClosure() { + /** + * @constructs PDFDataRangeTransport + * @param {number} length + * @param {Uint8Array} initialData + */ + function PDFDataRangeTransport(length, initialData) { + this.length = length; + this.initialData = initialData; + + this._rangeListeners = []; + this._progressListeners = []; + this._progressiveReadListeners = []; + this._readyCapability = createPromiseCapability(); + } + PDFDataRangeTransport.prototype = + /** @lends PDFDataRangeTransport.prototype */ { + addRangeListener: + function PDFDataRangeTransport_addRangeListener(listener) { + this._rangeListeners.push(listener); + }, + + addProgressListener: + function PDFDataRangeTransport_addProgressListener(listener) { + this._progressListeners.push(listener); + }, + + addProgressiveReadListener: + function PDFDataRangeTransport_addProgressiveReadListener(listener) { + this._progressiveReadListeners.push(listener); + }, + + onDataRange: function PDFDataRangeTransport_onDataRange(begin, chunk) { + var listeners = this._rangeListeners; + for (var i = 0, n = listeners.length; i < n; ++i) { + listeners[i](begin, chunk); + } + }, + + onDataProgress: function PDFDataRangeTransport_onDataProgress(loaded) { + this._readyCapability.promise.then(function () { + var listeners = this._progressListeners; + for (var i = 0, n = listeners.length; i < n; ++i) { + listeners[i](loaded); + } + }.bind(this)); + }, + + onDataProgressiveRead: + function PDFDataRangeTransport_onDataProgress(chunk) { + this._readyCapability.promise.then(function () { + var listeners = this._progressiveReadListeners; + for (var i = 0, n = listeners.length; i < n; ++i) { + listeners[i](chunk); + } + }.bind(this)); + }, + + transportReady: function PDFDataRangeTransport_transportReady() { + this._readyCapability.resolve(); + }, + + requestDataRange: + function PDFDataRangeTransport_requestDataRange(begin, end) { + throw new Error('Abstract method PDFDataRangeTransport.requestDataRange'); + } + }; + return PDFDataRangeTransport; +})(); + +PDFJS.PDFDataRangeTransport = PDFDataRangeTransport; + /** * Proxy to a PDFDocument in the worker thread. Also, contains commonly used * properties that can be read synchronously. @@ -1959,7 +2136,7 @@ var PDFDocumentProxy = (function PDFDocumentProxyClosure() { return this.transport.downloadInfoCapability.promise; }, /** - * @returns {Promise} A promise this is resolved with current stats about + * @return {Promise} A promise this is resolved with current stats about * document structures (see {@link PDFDocumentStats}). */ getStats: function PDFDocumentProxy_getStats() { @@ -2023,12 +2200,12 @@ var PDFDocumentProxy = (function PDFDocumentProxyClosure() { * (default value is 'display'). * @property {Object} imageLayer - (optional) An object that has beginLayout, * endLayout and appendImage functions. - * @property {function} continueCallback - (optional) A function that will be + * @property {function} continueCallback - (deprecated) A function that will be * called each time the rendering is paused. To continue * rendering call the function that is the first argument * to the callback. */ - + /** * PDF page operator list. * @@ -2156,7 +2333,12 @@ var PDFPageProxy = (function PDFPageProxyClosure() { intentState.renderTasks = []; } intentState.renderTasks.push(internalRenderTask); - var renderTask = new RenderTask(internalRenderTask); + var renderTask = internalRenderTask.task; + + // Obsolete parameter support + if (params.continueCallback) { + renderTask.onContinue = params.continueCallback; + } var self = this; intentState.displayReadyCapability.promise.then( @@ -2321,19 +2503,16 @@ var PDFPageProxy = (function PDFPageProxyClosure() { * @ignore */ var WorkerTransport = (function WorkerTransportClosure() { - function WorkerTransport(workerInitializedCapability, workerReadyCapability, - pdfDataRangeTransport, progressCallback) { + function WorkerTransport(workerInitializedCapability, pdfDataRangeTransport) { this.pdfDataRangeTransport = pdfDataRangeTransport; - this.workerInitializedCapability = workerInitializedCapability; - this.workerReadyCapability = workerReadyCapability; - this.progressCallback = progressCallback; this.commonObjs = new PDFObjects(); + this.loadingTask = null; + this.pageCache = []; this.pagePromises = []; this.downloadInfoCapability = createPromiseCapability(); - this.passwordCallback = null; // If worker support isn't disabled explicit and the browser has worker // support, create a new web worker and test if it/the browser fullfills @@ -2482,48 +2661,50 @@ var WorkerTransport = (function WorkerTransportClosure() { this.numPages = data.pdfInfo.numPages; var pdfDocument = new PDFDocumentProxy(pdfInfo, this); this.pdfDocument = pdfDocument; - this.workerReadyCapability.resolve(pdfDocument); + this.loadingTask._capability.resolve(pdfDocument); }, this); messageHandler.on('NeedPassword', function transportNeedPassword(exception) { - if (this.passwordCallback) { - return this.passwordCallback(updatePassword, - PasswordResponses.NEED_PASSWORD); + var loadingTask = this.loadingTask; + if (loadingTask.onPassword) { + return loadingTask.onPassword(updatePassword, + PasswordResponses.NEED_PASSWORD); } - this.workerReadyCapability.reject( + loadingTask._capability.reject( new PasswordException(exception.message, exception.code)); }, this); messageHandler.on('IncorrectPassword', function transportIncorrectPassword(exception) { - if (this.passwordCallback) { - return this.passwordCallback(updatePassword, - PasswordResponses.INCORRECT_PASSWORD); + var loadingTask = this.loadingTask; + if (loadingTask.onPassword) { + return loadingTask.onPassword(updatePassword, + PasswordResponses.INCORRECT_PASSWORD); } - this.workerReadyCapability.reject( + loadingTask._capability.reject( new PasswordException(exception.message, exception.code)); }, this); messageHandler.on('InvalidPDF', function transportInvalidPDF(exception) { - this.workerReadyCapability.reject( + this.loadingTask._capability.reject( new InvalidPDFException(exception.message)); }, this); messageHandler.on('MissingPDF', function transportMissingPDF(exception) { - this.workerReadyCapability.reject( + this.loadingTask._capability.reject( new MissingPDFException(exception.message)); }, this); messageHandler.on('UnexpectedResponse', function transportUnexpectedResponse(exception) { - this.workerReadyCapability.reject( + this.loadingTask._capability.reject( new UnexpectedResponseException(exception.message, exception.status)); }, this); messageHandler.on('UnknownError', function transportUnknownError(exception) { - this.workerReadyCapability.reject( + this.loadingTask._capability.reject( new UnknownErrorException(exception.message, exception.details)); }, this); @@ -2618,8 +2799,9 @@ var WorkerTransport = (function WorkerTransportClosure() { }, this); messageHandler.on('DocProgress', function transportDocProgress(data) { - if (this.progressCallback) { - this.progressCallback({ + var loadingTask = this.loadingTask; + if (loadingTask.onProgress) { + loadingTask.onProgress({ loaded: data.loaded, total: data.total }); @@ -2679,10 +2861,16 @@ var WorkerTransport = (function WorkerTransportClosure() { }); }, - fetchDocument: function WorkerTransport_fetchDocument(source) { + fetchDocument: function WorkerTransport_fetchDocument(loadingTask, source) { + this.loadingTask = loadingTask; + source.disableAutoFetch = PDFJS.disableAutoFetch; source.disableStream = PDFJS.disableStream; source.chunkedViewerLoading = !!this.pdfDataRangeTransport; + if (this.pdfDataRangeTransport) { + source.length = this.pdfDataRangeTransport.length; + source.initialData = this.pdfDataRangeTransport.initialData; + } this.messageHandler.send('GetDocRequest', { source: source, disableRange: PDFJS.disableRange, @@ -2893,26 +3081,37 @@ var PDFObjects = (function PDFObjectsClosure() { */ var RenderTask = (function RenderTaskClosure() { function RenderTask(internalRenderTask) { - this.internalRenderTask = internalRenderTask; + this._internalRenderTask = internalRenderTask; + /** - * Promise for rendering task completion. - * @type {Promise} + * Callback for incremental rendering -- a function that will be called + * each time the rendering is paused. To continue rendering call the + * function that is the first argument to the callback. + * @type {function} */ - this.promise = this.internalRenderTask.capability.promise; + this.onContinue = null; } RenderTask.prototype = /** @lends RenderTask.prototype */ { + /** + * Promise for rendering task completion. + * @return {Promise} + */ + get promise() { + return this._internalRenderTask.capability.promise; + }, + /** * Cancels the rendering task. If the task is currently rendering it will * not be cancelled until graphics pauses with a timeout. The promise that * this object extends will resolved when cancelled. */ cancel: function RenderTask_cancel() { - this.internalRenderTask.cancel(); + this._internalRenderTask.cancel(); }, /** - * Registers callback to indicate the rendering task completion. + * Registers callbacks to indicate the rendering task completion. * * @param {function} onFulfilled The callback for the rendering completion. * @param {function} onRejected The callback for the rendering failure. @@ -2920,7 +3119,7 @@ var RenderTask = (function RenderTaskClosure() { * onRejected callback. */ then: function RenderTask_then(onFulfilled, onRejected) { - return this.promise.then(onFulfilled, onRejected); + return this.promise.then.apply(this.promise, arguments); } }; @@ -2947,6 +3146,7 @@ var InternalRenderTask = (function InternalRenderTaskClosure() { this.graphicsReady = false; this.cancelled = false; this.capability = createPromiseCapability(); + this.task = new RenderTask(this); // caching this-bound methods this._continueBound = this._continue.bind(this); this._scheduleNextBound = this._scheduleNext.bind(this); @@ -3009,8 +3209,8 @@ var InternalRenderTask = (function InternalRenderTaskClosure() { if (this.cancelled) { return; } - if (this.params.continueCallback) { - this.params.continueCallback(this._scheduleNextBound); + if (this.task.onContinue) { + this.task.onContinue.call(this.task, this._scheduleNextBound); } else { this._scheduleNext(); } @@ -3149,11 +3349,8 @@ function createScratchCanvas(width, height) { } function addContextCurrentTransform(ctx) { - // If the context doesn't expose a `mozCurrentTransform`, add a JS based on. + // If the context doesn't expose a `mozCurrentTransform`, add a JS based one. if (!ctx.mozCurrentTransform) { - // Store the original context - ctx._scaleX = ctx._scaleX || 1.0; - ctx._scaleY = ctx._scaleY || 1.0; ctx._originalSave = ctx.save; ctx._originalRestore = ctx.restore; ctx._originalRotate = ctx.rotate; @@ -3162,7 +3359,7 @@ function addContextCurrentTransform(ctx) { ctx._originalTransform = ctx.transform; ctx._originalSetTransform = ctx.setTransform; - ctx._transformMatrix = [ctx._scaleX, 0, 0, ctx._scaleY, 0, 0]; + ctx._transformMatrix = ctx._transformMatrix || [1, 0, 0, 1, 0, 0]; ctx._transformStack = []; Object.defineProperty(ctx, 'mozCurrentTransform', { @@ -3538,6 +3735,8 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { this.smaskCounter = 0; this.tempSMask = null; if (canvasCtx) { + // NOTE: if mozCurrentTransform is polyfilled, then the current state of + // the transformation must already be set in canvasCtx._transformMatrix. addContextCurrentTransform(canvasCtx); } this.cachedGetSinglePixelWidth = null; @@ -5254,7 +5453,6 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { })(); - var WebGLUtils = (function WebGLUtilsClosure() { function loadShader(gl, code, shaderType) { var shader = gl.createShader(shaderType); @@ -6165,7 +6363,8 @@ var FontLoader = { nativeFontFaces: [], - isFontLoadingAPISupported: !isWorker && !!document.fonts, + isFontLoadingAPISupported: (!isWorker && typeof document !== 'undefined' && + !!document.fonts), addNativeFontFace: function fontLoader_addNativeFontFace(nativeFontFace) { this.nativeFontFaces.push(nativeFontFace); @@ -6634,6 +6833,9 @@ var AnnotationUtils = (function AnnotationUtilsClosure() { var link = document.createElement('a'); link.href = link.title = item.url || ''; + if (item.url && PDFJS.openExternalLinksInNewWindow) { + link.target = '_blank'; + } container.appendChild(link); @@ -6893,7 +7095,7 @@ var SVGExtraState = (function SVGExtraStateClosure() { this.lineJoin = ''; this.lineCap = ''; this.miterLimit = 0; - + this.dashArray = []; this.dashPhase = 0; @@ -7120,7 +7322,7 @@ var SVGGraphics = (function SVGGraphicsClosure() { } return opListToTree(opList); }, - + executeOpTree: function SVGGraphics_executeOpTree(opTree) { var opTreeLen = opTree.length; for(var x = 0; x < opTreeLen; x++) { @@ -7159,6 +7361,9 @@ var SVGGraphics = (function SVGGraphicsClosure() { case OPS.setWordSpacing: this.setWordSpacing(args[0]); break; + case OPS.setHScale: + this.setHScale(args[0]); + break; case OPS.setTextMatrix: this.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]); diff --git a/attachment_preview/static/lib/ViewerJS/pdf.worker.js b/attachment_preview/static/lib/ViewerJS/pdf.worker.js index 9f1b4097..c17192e4 100644 --- a/attachment_preview/static/lib/ViewerJS/pdf.worker.js +++ b/attachment_preview/static/lib/ViewerJS/pdf.worker.js @@ -22,8 +22,8 @@ if (typeof PDFJS === 'undefined') { (typeof window !== 'undefined' ? window : this).PDFJS = {}; } -PDFJS.version = '1.0.1040'; -PDFJS.build = '997096f'; +PDFJS.version = '1.1.114'; +PDFJS.build = '3fd44fd'; (function pdfjsWrapper() { // Use strict in our context only - users might not want it @@ -239,17 +239,10 @@ function warn(msg) { // Fatal errors that should trigger the fallback UI and halt execution by // throwing an exception. function error(msg) { - // If multiple arguments were passed, pass them all to the log function. - if (arguments.length > 1) { - var logArguments = ['Error:']; - logArguments.push.apply(logArguments, arguments); - console.log.apply(console, logArguments); - // Join the arguments into a single string for the lines below. - msg = [].join.call(arguments, ' '); - } else { + if (PDFJS.verbosity >= PDFJS.VERBOSITY_LEVELS.errors) { console.log('Error: ' + msg); + console.log(backtrace()); } - console.log(backtrace()); UnsupportedManager.notify(UNSUPPORTED_FEATURES.unknown); throw new Error(msg); } @@ -341,6 +334,7 @@ function isValidUrl(url, allowRelative) { case 'https': case 'ftp': case 'mailto': + case 'tel': return true; default: return false; @@ -355,6 +349,7 @@ function shadow(obj, prop, value) { writable: false }); return value; } +PDFJS.shadow = shadow; var PasswordResponses = PDFJS.PasswordResponses = { NEED_PASSWORD: 1, @@ -470,6 +465,8 @@ var XRefParseException = (function XRefParseExceptionClosure() { function bytesToString(bytes) { + assert(bytes !== null && typeof bytes === 'object' && + bytes.length !== undefined, 'Invalid argument for bytesToString'); var length = bytes.length; var MAX_ARGUMENT_COUNT = 8192; if (length < MAX_ARGUMENT_COUNT) { @@ -485,6 +482,7 @@ function bytesToString(bytes) { } function stringToBytes(str) { + assert(typeof str === 'string', 'Invalid argument for stringToBytes'); var length = str.length; var bytes = new Uint8Array(length); for (var i = 0; i < length; ++i) { @@ -1002,10 +1000,6 @@ function isString(v) { return typeof v === 'string'; } -function isNull(v) { - return v === null; -} - function isName(v) { return v instanceof Name; } @@ -1874,7 +1868,6 @@ var NetworkManager = (function NetworkManagerClosure() { })(); - var ChunkedStream = (function ChunkedStreamClosure() { function ChunkedStream(length, chunkSize, manager) { this.bytes = new Uint8Array(length); @@ -2026,6 +2019,9 @@ var ChunkedStream = (function ChunkedStreamClosure() { getUint16: function ChunkedStream_getUint16() { var b0 = this.getByte(); var b1 = this.getByte(); + if (b0 === -1 || b1 === -1) { + return -1; + } return (b0 << 8) + b1; }, @@ -2415,7 +2411,6 @@ var ChunkedStreamManager = (function ChunkedStreamManagerClosure() { })(); - // The maximum number of bytes fetched per range request var RANGE_CHUNK_SIZE = 65536; @@ -2621,7 +2616,6 @@ var NetworkPdfManager = (function NetworkPdfManagerClosure() { })(); - var Page = (function PageClosure() { var LETTER_SIZE_MEDIABOX = [0, 0, 612, 792]; @@ -3131,7 +3125,6 @@ var PDFDocument = (function PDFDocumentClosure() { })(); - var Name = (function NameClosure() { function Name(name) { this.name = name; @@ -3301,6 +3294,10 @@ var Dict = (function DictClosure() { return all; }, + getKeys: function Dict_getKeys() { + return Object.keys(this.map); + }, + set: function Dict_set(key, value) { this.map[key] = value; }, @@ -3664,7 +3661,7 @@ var Catalog = (function CatalogClosure() { var isPrintAction = (isName(objType) && objType.name === 'Action' && isName(actionType) && actionType.name === 'Named' && isName(action) && action.name === 'Print'); - + if (isPrintAction) { javaScript.push('print(true);'); } @@ -3706,6 +3703,7 @@ var Catalog = (function CatalogClosure() { var nodesToVisit = [this.catDict.getRaw('Pages')]; var currentPageIndex = 0; var xref = this.xref; + var checkAllKids = false; function next() { while (nodesToVisit.length) { @@ -3713,7 +3711,7 @@ var Catalog = (function CatalogClosure() { if (isRef(currentNode)) { xref.fetchAsync(currentNode).then(function (obj) { - if ((isDict(obj, 'Page') || (isDict(obj) && !obj.has('Kids')))) { + if (isDict(obj, 'Page') || (isDict(obj) && !obj.has('Kids'))) { if (pageIndex === currentPageIndex) { capability.resolve([obj, currentNode]); } else { @@ -3728,12 +3726,17 @@ var Catalog = (function CatalogClosure() { return; } - // must be a child page dictionary + // Must be a child page dictionary. assert( isDict(currentNode), 'page dictionary kid reference points to wrong type of object' ); var count = currentNode.get('Count'); + // If the current node doesn't have any children, avoid getting stuck + // in an empty node further down in the tree (see issue5644.pdf). + if (count === 0) { + checkAllKids = true; + } // Skip nodes where the page can't be. if (currentPageIndex + count <= pageIndex) { currentPageIndex += count; @@ -3742,7 +3745,7 @@ var Catalog = (function CatalogClosure() { var kids = currentNode.get('Kids'); assert(isArray(kids), 'page dictionary kids object is not an array'); - if (count === kids.length) { + if (!checkAllKids && count === kids.length) { // Nodes that don't have the page have been skipped and this is the // bottom of the tree which means the page requested must be a // descendant of this pages node. Ideally we would just resolve the @@ -4520,7 +4523,7 @@ var NameTree = (function NameTreeClosure() { warn('Search depth limit for named destionations has been reached.'); return null; } - + var kids = kidsOrNames.get('Kids'); if (!isArray(kids)) { return null; @@ -4575,10 +4578,10 @@ var NameTree = (function NameTreeClosure() { })(); /** - * "A PDF file can refer to the contents of another file by using a File + * "A PDF file can refer to the contents of another file by using a File * Specification (PDF 1.1)", see the spec (7.11) for more details. * NOTE: Only embedded files are supported (as part of the attachments support) - * TODO: support the 'URL' file system (with caching if !/V), portable + * TODO: support the 'URL' file system (with caching if !/V), portable * collections attributes and related files (/RF) */ var FileSpec = (function FileSpecClosure() { @@ -4908,7 +4911,6 @@ var ExpertSubsetCharset = [ ]; - var DEFAULT_ICON_SIZE = 22; // px var SUPPORTED_TYPES = ['Link', 'Text', 'Widget']; @@ -5374,7 +5376,7 @@ var LinkAnnotation = (function LinkAnnotationClosure() { data.annotationType = AnnotationType.LINK; var action = dict.get('A'); - if (action) { + if (action && isDict(action)) { var linkType = action.get('S').name; if (linkType === 'URI') { var url = action.get('URI'); @@ -6802,10 +6804,10 @@ var ColorSpace = (function ColorSpaceClosure() { case 'CMYK': return 'DeviceCmykCS'; case 'CalGray': - params = cs[1].getAll(); + params = xref.fetchIfRef(cs[1]).getAll(); return ['CalGrayCS', params]; case 'CalRGB': - params = cs[1].getAll(); + params = xref.fetchIfRef(cs[1]).getAll(); return ['CalRGBCS', params]; case 'ICCBased': var stream = xref.fetchIfRef(cs[1]); @@ -9721,7 +9723,7 @@ var CipherTransformFactory = (function CipherTransformFactoryClosure() { this.cf = dict.get('CF'); this.stmf = dict.get('StmF') || identityName; this.strf = dict.get('StrF') || identityName; - this.eff = dict.get('EFF') || this.strf; + this.eff = dict.get('EFF') || this.stmf; } } @@ -9796,6 +9798,7 @@ var CipherTransformFactory = (function CipherTransformFactoryClosure() { return CipherTransformFactory; })(); + var PatternType = { FUNCTION_BASED: 1, AXIAL: 2, @@ -11446,7 +11449,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { styles: Object.create(null) }; var bidiTexts = textContent.items; - var SPACE_FACTOR = 0.35; + var SPACE_FACTOR = 0.3; var MULTI_SPACE_FACTOR = 1.5; var self = this; @@ -11885,11 +11888,18 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { var cmap, cmapObj = toUnicode; if (isName(cmapObj)) { cmap = CMapFactory.create(cmapObj, - { url: PDFJS.cMapUrl, packed: PDFJS.cMapPacked }, null).getMap(); - return new ToUnicodeMap(cmap); + { url: PDFJS.cMapUrl, packed: PDFJS.cMapPacked }, null); + if (cmap instanceof IdentityCMap) { + return new IdentityToUnicodeMap(0, 0xFFFF); + } + return new ToUnicodeMap(cmap.getMap()); } else if (isStream(cmapObj)) { cmap = CMapFactory.create(cmapObj, - { url: PDFJS.cMapUrl, packed: PDFJS.cMapPacked }, null).getMap(); + { url: PDFJS.cMapUrl, packed: PDFJS.cMapPacked }, null); + if (cmap instanceof IdentityCMap) { + return new IdentityToUnicodeMap(0, 0xFFFF); + } + cmap = cmap.getMap(); // Convert UTF-16BE // NOTE: cmap can be a sparse array, so use forEach instead of for(;;) // to iterate over all keys. @@ -12117,6 +12127,21 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { hash.update(encoding.name); } else if (isRef(encoding)) { hash.update(encoding.num + '_' + encoding.gen); + } else if (isDict(encoding)) { + var keys = encoding.getKeys(); + for (var i = 0, ii = keys.length; i < ii; i++) { + var entry = encoding.getRaw(keys[i]); + if (isName(entry)) { + hash.update(entry.name); + } else if (isRef(entry)) { + hash.update(entry.num + '_' + entry.gen); + } else if (isArray(entry)) { // 'Differences' entry. + // Ideally we should check the contents of the array, but to avoid + // parsing it here and then again in |extractDataStructures|, + // we only use the array length for now (fixes bug1157493.pdf). + hash.update(entry.length.toString()); + } + } } var toUnicode = dict.get('ToUnicode') || baseDict.get('ToUnicode'); @@ -13384,6 +13409,7 @@ var CMap = (function CMapClosure() { // - bf chars are variable-length byte sequences, stored as strings, with // one byte per character. this._map = []; + this.name = ''; this.vertical = false; this.useCMap = null; this.builtInCMap = builtInCMap; @@ -13483,13 +13509,28 @@ var CMap = (function CMapClosure() { } out.charcode = 0; out.length = 1; + }, + + get isIdentityCMap() { + if (!(this.name === 'Identity-H' || this.name === 'Identity-V')) { + return false; + } + if (this._map.length !== 0x10000) { + return false; + } + for (var i = 0; i < 0x10000; i++) { + if (this._map[i] !== i) { + return false; + } + } + return true; } }; return CMap; })(); // A special case of CMap, where the _map array implicitly has a length of -// 65535 and each element is equal to its index. +// 65536 and each element is equal to its index. var IdentityCMap = (function IdentityCMapClosure() { function IdentityCMap(vertical, n) { CMap.call(this); @@ -13544,7 +13585,11 @@ var IdentityCMap = (function IdentityCMapClosure() { return map; }, - readCharCode: CMap.prototype.readCharCode + readCharCode: CMap.prototype.readCharCode, + + get isIdentityCMap() { + error('should not access .isIdentityCMap'); + } }; return IdentityCMap; @@ -14009,6 +14054,13 @@ var CMapFactory = (function CMapFactoryClosure() { } } + function parseCMapName(cMap, lexer) { + var obj = lexer.getObj(); + if (isName(obj) && isString(obj.name)) { + cMap.name = obj.name; + } + } + function parseCMap(cMap, lexer, builtInCMapParams, useCMap) { var previous; var embededUseCMap; @@ -14019,6 +14071,8 @@ var CMapFactory = (function CMapFactoryClosure() { } else if (isName(obj)) { if (obj.name === 'WMode') { parseWMode(cMap, lexer); + } else if (obj.name === 'CMapName') { + parseCMapName(cMap, lexer); } previous = obj; } else if (isCmd(obj)) { @@ -14128,6 +14182,9 @@ var CMapFactory = (function CMapFactoryClosure() { } catch (e) { warn('Invalid CMap data. ' + e); } + if (cMap.isIdentityCMap) { + return createBuiltInCMap(cMap.name, builtInCMapParams); + } return cMap; } error('Encoding required.'); @@ -14637,7 +14694,7 @@ var SpecialPUASymbols = { '63731': 0x23A9, // braceleftbt (0xF8F3) '63740': 0x23AB, // bracerighttp (0xF8FC) '63741': 0x23AC, // bracerightmid (0xF8FD) - '63742': 0x23AD, // bracerightmid (0xF8FE) + '63742': 0x23AD, // bracerightbt (0xF8FE) '63726': 0x23A1, // bracketlefttp (0xF8EE) '63727': 0x23A2, // bracketleftex (0xF8EF) '63728': 0x23A3, // bracketleftbt (0xF8F0) @@ -16317,6 +16374,10 @@ var ToUnicodeMap = (function ToUnicodeMapClosure() { } }, + has: function(i) { + return this._map[i] !== undefined; + }, + get: function(i) { return this._map[i]; }, @@ -16337,7 +16398,7 @@ var IdentityToUnicodeMap = (function IdentityToUnicodeMapClosure() { IdentityToUnicodeMap.prototype = { get length() { - error('should not access .length'); + return (this.lastChar + 1) - this.firstChar; }, forEach: function (callback) { @@ -16346,6 +16407,10 @@ var IdentityToUnicodeMap = (function IdentityToUnicodeMapClosure() { } }, + has: function (i) { + return this.firstChar <= i && i <= this.lastChar; + }, + get: function (i) { if (this.firstChar <= i && i <= this.lastChar) { return String.fromCharCode(i); @@ -16577,7 +16642,7 @@ var Font = (function FontClosure() { // to be used with the canvas.font. var fontName = name.replace(/[,_]/g, '-'); var isStandardFont = !!stdFontMap[fontName] || - (nonStdFontMap[fontName] && !!stdFontMap[nonStdFontMap[fontName]]); + !!(nonStdFontMap[fontName] && stdFontMap[nonStdFontMap[fontName]]); fontName = stdFontMap[fontName] || nonStdFontMap[fontName] || fontName; this.bold = (fontName.search(/bold/gi) !== -1); @@ -16678,11 +16743,13 @@ var Font = (function FontClosure() { if (subtype === 'CIDFontType0C' && type !== 'CIDFontType0') { type = 'CIDFontType0'; } - // XXX: Temporarily change the type for open type so we trigger a warning. - // This should be removed when we add support for open type. if (subtype === 'OpenType') { type = 'OpenType'; } + // Some CIDFontType0C fonts by mistake claim CIDFontType0. + if (type === 'CIDFontType0') { + subtype = isType1File(file) ? 'CIDFontType0' : 'CIDFontType0C'; + } var data; switch (type) { @@ -16763,6 +16830,52 @@ var Font = (function FontClosure() { return readUint32(header, 0) === 0x00010000; } + function isType1File(file) { + var header = file.peekBytes(2); + // All Type1 font programs must begin with the comment '%!' (0x25 + 0x21). + if (header[0] === 0x25 && header[1] === 0x21) { + return true; + } + // ... obviously some fonts violate that part of the specification, + // please refer to the comment in |Type1Font| below. + if (header[0] === 0x80 && header[1] === 0x01) { // pfb file header. + return true; + } + return false; + } + + /** + * Helper function for |adjustMapping|. + * @return {boolean} + */ + function isProblematicUnicodeLocation(code) { + if (code <= 0x1F) { // Control chars + return true; + } + if (code >= 0x80 && code <= 0x9F) { // Control chars + return true; + } + if ((code >= 0x2000 && code <= 0x200F) || // General punctuation chars + (code >= 0x2028 && code <= 0x202F) || + (code >= 0x2060 && code <= 0x206F)) { + return true; + } + if (code >= 0xFFF0 && code <= 0xFFFF) { // Specials Unicode block + return true; + } + switch (code) { + case 0x7F: // Control char + case 0xA0: // Non breaking space + case 0xAD: // Soft hyphen + case 0x0E33: // Thai character SARA AM + case 0x2011: // Non breaking hyphen + case 0x205F: // Medium mathematical space + case 0x25CC: // Dotted circle (combining mark) + return true; + } + return false; + } + /** * Rebuilds the char code to glyph ID map by trying to replace the char codes * with their unicode value. It also moves char codes that are in known @@ -16778,7 +16891,6 @@ var Font = (function FontClosure() { var isSymbolic = !!(properties.flags & FontFlags.Symbolic); var isIdentityUnicode = properties.toUnicode instanceof IdentityToUnicodeMap; - var isCidFontType2 = (properties.type === 'CIDFontType2'); var newMap = Object.create(null); var toFontChar = []; var usedFontCharCodes = []; @@ -16789,17 +16901,11 @@ var Font = (function FontClosure() { var fontCharCode = originalCharCode; // First try to map the value to a unicode position if a non identity map // was created. - if (!isIdentityUnicode) { - if (toUnicode.get(originalCharCode) !== undefined) { - var unicode = toUnicode.get(fontCharCode); - // TODO: Try to map ligatures to the correct spot. - if (unicode.length === 1) { - fontCharCode = unicode.charCodeAt(0); - } - } else if (isCidFontType2) { - // For CIDFontType2, move characters not present in toUnicode - // to the private use area (fixes bug 1028735 and issue 4881). - fontCharCode = nextAvailableFontCharCode; + if (!isIdentityUnicode && toUnicode.has(originalCharCode)) { + var unicode = toUnicode.get(fontCharCode); + // TODO: Try to map ligatures to the correct spot. + if (unicode.length === 1) { + fontCharCode = unicode.charCodeAt(0); } } // Try to move control characters, special characters and already mapped @@ -16809,13 +16915,7 @@ var Font = (function FontClosure() { // characters probably aren't in the correct position (fixes an issue // with firefox and thuluthfont). if ((usedFontCharCodes[fontCharCode] !== undefined || - fontCharCode <= 0x1f || // Control chars - fontCharCode === 0x7F || // Control char - fontCharCode === 0xAD || // Soft hyphen - fontCharCode === 0xA0 || // Non breaking space - (fontCharCode >= 0x80 && fontCharCode <= 0x9F) || // Control chars - // Prevent drawing characters in the specials unicode block. - (fontCharCode >= 0xFFF0 && fontCharCode <= 0xFFFF) || + isProblematicUnicodeLocation(fontCharCode) || (isSymbolic && isIdentityUnicode)) && nextAvailableFontCharCode <= PRIVATE_USE_OFFSET_END) { // Room left. // Loop to try and find a free spot in the private use area. @@ -17289,13 +17389,20 @@ var Font = (function FontClosure() { var offset = font.getInt32() >>> 0; var useTable = false; - if (platformId === 1 && encodingId === 0) { + if (platformId === 0 && encodingId === 0) { useTable = true; // Continue the loop since there still may be a higher priority // table. - } else if (!isSymbolicFont && platformId === 3 && encodingId === 1) { + } else if (platformId === 1 && encodingId === 0) { useTable = true; - canBreak = true; + // Continue the loop since there still may be a higher priority + // table. + } else if (platformId === 3 && encodingId === 1 && + (!isSymbolicFont || !potentialTable)) { + useTable = true; + if (!isSymbolicFont) { + canBreak = true; + } } else if (isSymbolicFont && platformId === 3 && encodingId === 0) { useTable = true; canBreak = true; @@ -17640,6 +17747,7 @@ var Font = (function FontClosure() { var newGlyfData = new Uint8Array(oldGlyfDataLength); var startOffset = itemDecode(locaData, 0); var writeOffset = 0; + var missingGlyphData = {}; itemEncode(locaData, 0, writeOffset); var i, j; for (i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) { @@ -17657,6 +17765,10 @@ var Font = (function FontClosure() { continue; } + if (startOffset === endOffset) { + missingGlyphData[i] = true; + } + var newLength = sanitizeGlyph(oldGlyfData, startOffset, endOffset, newGlyfData, writeOffset, hintsValid); writeOffset += newLength; @@ -17673,7 +17785,7 @@ var Font = (function FontClosure() { itemEncode(locaData, j, simpleGlyph.length); } glyf.data = simpleGlyph; - return; + return missingGlyphData; } if (dupFirstEntry) { @@ -17690,6 +17802,7 @@ var Font = (function FontClosure() { } else { glyf.data = newGlyfData.subarray(0, writeOffset); } + return missingGlyphData; } function readPostScriptTable(post, properties, maxpNumGlyphs) { @@ -18080,7 +18193,8 @@ var Font = (function FontClosure() { var isTrueType = !tables['CFF ']; if (!isTrueType) { // OpenType font - if (!tables.head || !tables.hhea || !tables.maxp || !tables.post) { + if (header.version === 'OTTO' || + !tables.head || !tables.hhea || !tables.maxp || !tables.post) { // no major tables: throwing everything at CFFFont cffFile = new Stream(tables['CFF '].data); cff = new CFFFont(cffFile, properties); @@ -18149,11 +18263,13 @@ var Font = (function FontClosure() { sanitizeHead(tables.head, numGlyphs, isTrueType ? tables.loca.length : 0); + var missingGlyphs = {}; if (isTrueType) { var isGlyphLocationsLong = int16(tables.head.data[50], tables.head.data[51]); - sanitizeGlyphLocations(tables.loca, tables.glyf, numGlyphs, - isGlyphLocationsLong, hintsValid, dupFirstEntry); + missingGlyphs = sanitizeGlyphLocations(tables.loca, tables.glyf, + numGlyphs, isGlyphLocationsLong, + hintsValid, dupFirstEntry); } if (!tables.hhea) { @@ -18175,19 +18291,33 @@ var Font = (function FontClosure() { } } - var charCodeToGlyphId = [], charCode; + var charCodeToGlyphId = [], charCode, toUnicode = properties.toUnicode; + + function hasGlyph(glyphId, charCode) { + if (!missingGlyphs[glyphId]) { + return true; + } + if (charCode >= 0 && toUnicode.has(charCode)) { + return true; + } + return false; + } + if (properties.type === 'CIDFontType2') { var cidToGidMap = properties.cidToGidMap || []; - var cidToGidMapLength = cidToGidMap.length; + var isCidToGidMapEmpty = cidToGidMap.length === 0; + properties.cMap.forEach(function(charCode, cid) { assert(cid <= 0xffff, 'Max size of CID is 65,535'); var glyphId = -1; - if (cidToGidMapLength === 0) { + if (isCidToGidMapEmpty) { glyphId = charCode; } else if (cidToGidMap[cid] !== undefined) { glyphId = cidToGidMap[cid]; } - if (glyphId >= 0 && glyphId < numGlyphs) { + + if (glyphId >= 0 && glyphId < numGlyphs && + hasGlyph(glyphId, charCode)) { charCodeToGlyphId[charCode] = glyphId; } }); @@ -18247,7 +18377,8 @@ var Font = (function FontClosure() { var found = false; for (i = 0; i < cmapMappingsLength; ++i) { - if (cmapMappings[i].charCode === unicodeOrCharCode) { + if (cmapMappings[i].charCode === unicodeOrCharCode && + hasGlyph(cmapMappings[i].glyphId, unicodeOrCharCode)) { charCodeToGlyphId[charCode] = cmapMappings[i].glyphId; found = true; break; @@ -18257,11 +18388,17 @@ var Font = (function FontClosure() { // Try to map using the post table. There are currently no known // pdfs that this fixes. var glyphId = properties.glyphNames.indexOf(glyphName); - if (glyphId > 0) { + if (glyphId > 0 && hasGlyph(glyphId, -1)) { charCodeToGlyphId[charCode] = glyphId; } } } + } else if (cmapPlatformId === 0 && cmapEncodingId === 0) { + // Default Unicode semantics, use the charcodes as is. + for (i = 0; i < cmapMappingsLength; ++i) { + charCodeToGlyphId[cmapMappings[i].charCode] = + cmapMappings[i].glyphId; + } } else { // For (3, 0) cmap tables: // The charcode key being stored in charCodeToGlyphId is the lower @@ -22026,7 +22163,6 @@ var FontRendererFactory = (function FontRendererFactoryClosure() { })(); - var GlyphsUnicode = { A: 0x0041, AE: 0x00C6, @@ -30033,7 +30169,6 @@ var Metrics = { }; - var EOF = {}; function isEOF(v) { @@ -30176,6 +30311,102 @@ var Parser = (function ParserClosure() { } return ((stream.pos - 4) - startPos); }, + /** + * Find the EOI (end-of-image) marker 0xFFD9 of the stream. + * @returns {number} The inline stream length. + */ + findDCTDecodeInlineStreamEnd: + function Parser_findDCTDecodeInlineStreamEnd(stream) { + var startPos = stream.pos, foundEOI = false, b, markerLength, length; + while ((b = stream.getByte()) !== -1) { + if (b !== 0xFF) { // Not a valid marker. + continue; + } + switch (stream.getByte()) { + case 0x00: // Byte stuffing. + // 0xFF00 appears to be a very common byte sequence in JPEG images. + break; + + case 0xFF: // Fill byte. + // Avoid skipping a valid marker, resetting the stream position. + stream.skip(-1); + break; + + case 0xD9: // EOI + foundEOI = true; + break; + + case 0xC0: // SOF0 + case 0xC1: // SOF1 + case 0xC2: // SOF2 + case 0xC3: // SOF3 + + case 0xC5: // SOF5 + case 0xC6: // SOF6 + case 0xC7: // SOF7 + + case 0xC9: // SOF9 + case 0xCA: // SOF10 + case 0xCB: // SOF11 + + case 0xCD: // SOF13 + case 0xCE: // SOF14 + case 0xCF: // SOF15 + + case 0xC4: // DHT + case 0xCC: // DAC + + case 0xDA: // SOS + case 0xDB: // DQT + case 0xDC: // DNL + case 0xDD: // DRI + case 0xDE: // DHP + case 0xDF: // EXP + + case 0xE0: // APP0 + case 0xE1: // APP1 + case 0xE2: // APP2 + case 0xE3: // APP3 + case 0xE4: // APP4 + case 0xE5: // APP5 + case 0xE6: // APP6 + case 0xE7: // APP7 + case 0xE8: // APP8 + case 0xE9: // APP9 + case 0xEA: // APP10 + case 0xEB: // APP11 + case 0xEC: // APP12 + case 0xED: // APP13 + case 0xEE: // APP14 + case 0xEF: // APP15 + + case 0xFE: // COM + // The marker should be followed by the length of the segment. + markerLength = stream.getUint16(); + if (markerLength > 2) { + // |markerLength| contains the byte length of the marker segment, + // including its own length (2 bytes) and excluding the marker. + stream.skip(markerLength - 2); // Jump to the next marker. + } else { + // The marker length is invalid, resetting the stream position. + stream.skip(-2); + } + break; + } + if (foundEOI) { + break; + } + } + length = stream.pos - startPos; + if (b === -1) { + warn('Inline DCTDecode image stream: ' + + 'EOI marker not found, searching for /EI/ instead.'); + stream.skip(-length); // Reset the stream position. + return this.findDefaultInlineStreamEnd(stream); + } + this.inlineStreamSkipEI(stream); + return length; + }, /** * Find the EOD (end-of-data) marker '~>' (i.e. TILDE + GT) of the stream. * @returns {number} The inline stream length. @@ -30267,7 +30498,9 @@ var Parser = (function ParserClosure() { // Parse image stream. var startPos = stream.pos, length, i, ii; - if (filterName === 'ASCII85Decide' || filterName === 'A85') { + if (filterName === 'DCTDecode' || filterName === 'DCT') { + length = this.findDCTDecodeInlineStreamEnd(stream); + } else if (filterName === 'ASCII85Decide' || filterName === 'A85') { length = this.findASCII85DecodeInlineStreamEnd(stream); } else if (filterName === 'ASCIIHexDecode' || filterName === 'AHx') { length = this.findASCIIHexDecodeInlineStreamEnd(stream); @@ -31194,6 +31427,9 @@ var Stream = (function StreamClosure() { getUint16: function Stream_getUint16() { var b0 = this.getByte(); var b1 = this.getByte(); + if (b0 === -1 || b1 === -1) { + return -1; + } return (b0 << 8) + b1; }, getInt32: function Stream_getInt32() { @@ -31321,6 +31557,9 @@ var DecodeStream = (function DecodeStreamClosure() { getUint16: function DecodeStream_getUint16() { var b0 = this.getByte(); var b1 = this.getByte(); + if (b0 === -1 || b1 === -1) { + return -1; + } return (b0 << 8) + b1; }, getInt32: function DecodeStream_getInt32() { @@ -31433,25 +31672,25 @@ var StreamsSequenceStream = (function StreamsSequenceStreamClosure() { })(); var FlateStream = (function FlateStreamClosure() { - var codeLenCodeMap = new Uint32Array([ + var codeLenCodeMap = new Int32Array([ 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 ]); - var lengthDecode = new Uint32Array([ + var lengthDecode = new Int32Array([ 0x00003, 0x00004, 0x00005, 0x00006, 0x00007, 0x00008, 0x00009, 0x0000a, 0x1000b, 0x1000d, 0x1000f, 0x10011, 0x20013, 0x20017, 0x2001b, 0x2001f, 0x30023, 0x3002b, 0x30033, 0x3003b, 0x40043, 0x40053, 0x40063, 0x40073, 0x50083, 0x500a3, 0x500c3, 0x500e3, 0x00102, 0x00102, 0x00102 ]); - var distDecode = new Uint32Array([ + var distDecode = new Int32Array([ 0x00001, 0x00002, 0x00003, 0x00004, 0x10005, 0x10007, 0x20009, 0x2000d, 0x30011, 0x30019, 0x40021, 0x40031, 0x50041, 0x50061, 0x60081, 0x600c1, 0x70101, 0x70181, 0x80201, 0x80301, 0x90401, 0x90601, 0xa0801, 0xa0c01, 0xb1001, 0xb1801, 0xc2001, 0xc3001, 0xd4001, 0xd6001 ]); - var fixedLitCodeTab = [new Uint32Array([ + var fixedLitCodeTab = [new Int32Array([ 0x70100, 0x80050, 0x80010, 0x80118, 0x70110, 0x80070, 0x80030, 0x900c0, 0x70108, 0x80060, 0x80020, 0x900a0, 0x80000, 0x80080, 0x80040, 0x900e0, 0x70104, 0x80058, 0x80018, 0x90090, 0x70114, 0x80078, 0x80038, 0x900d0, @@ -31518,7 +31757,7 @@ var FlateStream = (function FlateStreamClosure() { 0x7010f, 0x8006f, 0x8002f, 0x900bf, 0x8000f, 0x8008f, 0x8004f, 0x900ff ]), 9]; - var fixedDistCodeTab = [new Uint32Array([ + var fixedDistCodeTab = [new Int32Array([ 0x50000, 0x50010, 0x50008, 0x50018, 0x50004, 0x50014, 0x5000c, 0x5001c, 0x50002, 0x50012, 0x5000a, 0x5001a, 0x50006, 0x50016, 0x5000e, 0x00000, 0x50001, 0x50011, 0x50009, 0x50019, 0x50005, 0x50015, 0x5000d, 0x5001d, @@ -31615,7 +31854,7 @@ var FlateStream = (function FlateStreamClosure() { // build the table var size = 1 << maxLen; - var codes = new Uint32Array(size); + var codes = new Int32Array(size); for (var len = 1, code = 0, skip = 2; len <= maxLen; ++len, code <<= 1, skip <<= 1) { @@ -33185,6 +33424,10 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() { var gotEOL = false; + if (this.byteAlign) { + this.inputBits &= ~7; + } + if (!this.eoblock && this.row === this.rows - 1) { this.eof = true; } else { @@ -33208,10 +33451,6 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() { } } - if (this.byteAlign && !gotEOL) { - this.inputBits &= ~7; - } - if (!this.eof && this.encoding > 0) { this.nextLine2D = !this.lookBits(1); this.eatBits(1); @@ -34087,9 +34326,9 @@ if (typeof window === 'undefined') { /* This class implements the QM Coder decoding as defined in * JPEG 2000 Part I Final Committee Draft Version 1.0 - * Annex C.3 Arithmetic decoding procedure + * Annex C.3 Arithmetic decoding procedure * available at http://www.jpeg.org/public/fcd15444-1.pdf - * + * * The arithmetic decoder is used in conjunction with context models to decode * JPEG2000 and JBIG2 streams. */ @@ -34891,9 +35130,9 @@ var JpegImage = (function jpegImage() { if (fileMarker === 0xFFEE) { if (appData[0] === 0x41 && appData[1] === 0x64 && appData[2] === 0x6F && appData[3] === 0x62 && - appData[4] === 0x65 && appData[5] === 0) { // 'Adobe\x00' + appData[4] === 0x65) { // 'Adobe' adobe = { - version: appData[6], + version: (appData[5] << 8) | appData[6], flags0: (appData[7] << 8) | appData[8], flags1: (appData[9] << 8) | appData[10], transformCode: appData[11] @@ -35014,6 +35253,13 @@ var JpegImage = (function jpegImage() { successiveApproximation >> 4, successiveApproximation & 15); offset += processed; break; + + case 0xFFFF: // Fill bytes + if (data[offset] !== 0xFF) { // Avoid skipping a valid marker. + offset--; + } + break; + default: if (data[offset - 3] === 0xFF && data[offset - 2] >= 0xC0 && data[offset - 2] <= 0xFE) { @@ -35420,11 +35666,6 @@ var JpxImage = (function JpxImageClosure() { context.QCC = []; context.COC = []; break; - case 0xFF55: // Tile-part lengths, main header (TLM) - var Ltlm = readUint16(data, position); // Marker segment length - // Skip tile length markers - position += Ltlm; - break; case 0xFF5C: // Quantization default (QCD) length = readUint16(data, position); var qcd = {}; @@ -35614,6 +35855,9 @@ var JpxImage = (function JpxImageClosure() { length = tile.dataEnd - position; parseTilePackets(context, data, position, length); break; + case 0xFF55: // Tile-part lengths, main header (TLM) + case 0xFF57: // Packet length, main header (PLM) + case 0xFF58: // Packet length, tile-part header (PLT) case 0xFF64: // Comment (COM) length = readUint16(data, position); // skipping content @@ -35954,7 +36198,7 @@ var JpxImage = (function JpxImageClosure() { r = 0; c = 0; p = 0; - + this.nextPacket = function JpxImage_nextPacket() { // Section B.12.1.3 Resolution-position-component-layer for (; r <= maxDecompositionLevelsCount; r++) { @@ -36038,7 +36282,7 @@ var JpxImage = (function JpxImageClosure() { var componentsCount = siz.Csiz; var precinctsSizes = getPrecinctSizesInImageScale(tile); var l = 0, r = 0, c = 0, px = 0, py = 0; - + this.nextPacket = function JpxImage_nextPacket() { // Section B.12.1.5 Component-position-resolution-layer for (; c < componentsCount; ++c) { @@ -37450,7 +37694,6 @@ var JpxImage = (function JpxImageClosure() { })(); - var Jbig2Image = (function Jbig2ImageClosure() { // Utility data structures function ContextCache() {} @@ -37611,10 +37854,9 @@ var Jbig2Image = (function Jbig2ImageClosure() { // At each pixel: Clear contextLabel pixels that are shifted // out of the context, then add new ones. - // If j + n is out of range at the right image border, then - // the undefined value of bitmap[i - 2][j + n] is shifted to 0 contextLabel = ((contextLabel & OLD_PIXEL_MASK) << 1) | - (row2[j + 3] << 11) | (row1[j + 4] << 4) | pixel; + (j + 3 < width ? row2[j + 3] << 11 : 0) | + (j + 4 < width ? row1[j + 4] << 4 : 0) | pixel; } } @@ -38928,7 +39170,6 @@ var bidi = PDFJS.bidi = (function bidiClosure() { return bidi; })(); - /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ diff --git a/attachment_preview/static/lib/ViewerJS/pdfjsversion.js b/attachment_preview/static/lib/ViewerJS/pdfjsversion.js index aabaa0d2..7aefe448 100644 --- a/attachment_preview/static/lib/ViewerJS/pdfjsversion.js +++ b/attachment_preview/static/lib/ViewerJS/pdfjsversion.js @@ -1 +1 @@ -var /**@const{!string}*/pdfjs_version = "v1.0.1040"; +var /**@const{!string}*/pdfjs_version = "v1.1.114"; diff --git a/attachment_preview/static/lib/ViewerJS/text_layer_builder.js b/attachment_preview/static/lib/ViewerJS/text_layer_builder.js index 5fac1c49..7483c023 100644 --- a/attachment_preview/static/lib/ViewerJS/text_layer_builder.js +++ b/attachment_preview/static/lib/ViewerJS/text_layer_builder.js @@ -13,14 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/* globals CustomStyle, scrollIntoView, PDFJS */ +/* globals CustomStyle, PDFJS */ 'use strict'; -var FIND_SCROLL_OFFSET_TOP = -50; -var FIND_SCROLL_OFFSET_LEFT = -400; var MAX_TEXT_DIVS_TO_RENDER = 100000; -var RENDER_DELAY = 200; // ms var NonWhitespaceRegexp = /\S/; @@ -33,9 +30,6 @@ function isAllWhitespace(str) { * @property {HTMLDivElement} textLayerDiv - The text layer container. * @property {number} pageIndex - The page index. * @property {PageViewport} viewport - The viewport of the text layer. - * @property {ILastScrollSource} lastScrollSource - The object that records when - * last time scroll happened. - * @property {boolean} isViewerInPresentationMode * @property {PDFFindController} findController */ @@ -49,18 +43,27 @@ function isAllWhitespace(str) { var TextLayerBuilder = (function TextLayerBuilderClosure() { function TextLayerBuilder(options) { this.textLayerDiv = options.textLayerDiv; - this.layoutDone = false; + this.renderingDone = false; this.divContentDone = false; this.pageIdx = options.pageIndex; + this.pageNumber = this.pageIdx + 1; this.matches = []; - this.lastScrollSource = options.lastScrollSource || null; this.viewport = options.viewport; - this.isViewerInPresentationMode = options.isViewerInPresentationMode; this.textDivs = []; this.findController = options.findController || null; } TextLayerBuilder.prototype = { + _finishRendering: function TextLayerBuilder_finishRendering() { + this.renderingDone = true; + + var event = document.createEvent('CustomEvent'); + event.initCustomEvent('textlayerrendered', true, true, { + pageNumber: this.pageNumber + }); + this.textLayerDiv.dispatchEvent(event); + }, + renderLayer: function TextLayerBuilder_renderLayer() { var textLayerFrag = document.createDocumentFragment(); var textDivs = this.textDivs; @@ -71,6 +74,7 @@ var TextLayerBuilder = (function TextLayerBuilderClosure() { // No point in rendering many divs as it would make the browser // unusable even after the divs are rendered. if (textDivsLength > MAX_TEXT_DIVS_TO_RENDER) { + this._finishRendering(); return; } @@ -114,27 +118,33 @@ var TextLayerBuilder = (function TextLayerBuilderClosure() { } this.textLayerDiv.appendChild(textLayerFrag); - this.renderingDone = true; + this._finishRendering(); this.updateMatches(); }, - setupRenderLayoutTimer: - function TextLayerBuilder_setupRenderLayoutTimer() { - // Schedule renderLayout() if the user has been scrolling, - // otherwise run it right away. - var self = this; - var lastScroll = (this.lastScrollSource === null ? - 0 : this.lastScrollSource.lastScroll); + /** + * Renders the text layer. + * @param {number} timeout (optional) if specified, the rendering waits + * for specified amount of ms. + */ + render: function TextLayerBuilder_render(timeout) { + if (!this.divContentDone || this.renderingDone) { + return; + } - if (Date.now() - lastScroll > RENDER_DELAY) { // Render right away + if (this.renderTimer) { + clearTimeout(this.renderTimer); + this.renderTimer = null; + } + + if (!timeout) { // Render right away this.renderLayer(); } else { // Schedule - if (this.renderTimer) { - clearTimeout(this.renderTimer); - } + var self = this; this.renderTimer = setTimeout(function() { - self.setupRenderLayoutTimer(); - }, RENDER_DELAY); + self.renderLayer(); + self.renderTimer = null; + }, timeout); } }, @@ -204,7 +214,6 @@ var TextLayerBuilder = (function TextLayerBuilderClosure() { this.appendText(textItems[i], textContent.styles); } this.divContentDone = true; - this.setupRenderLayoutTimer(); }, convertMatches: function TextLayerBuilder_convertMatches(matches) { @@ -266,8 +275,9 @@ var TextLayerBuilder = (function TextLayerBuilderClosure() { var bidiTexts = this.textContent.items; var textDivs = this.textDivs; var prevEnd = null; + var pageIdx = this.pageIdx; var isSelectedPage = (this.findController === null ? - false : (this.pageIdx === this.findController.selected.pageIdx)); + false : (pageIdx === this.findController.selected.pageIdx)); var selectedMatchIdx = (this.findController === null ? -1 : this.findController.selected.matchIdx); var highlightAll = (this.findController === null ? @@ -313,10 +323,9 @@ var TextLayerBuilder = (function TextLayerBuilderClosure() { var isSelected = (isSelectedPage && i === selectedMatchIdx); var highlightSuffix = (isSelected ? ' selected' : ''); - if (isSelected && !this.isViewerInPresentationMode) { - scrollIntoView(textDivs[begin.divIdx], - { top: FIND_SCROLL_OFFSET_TOP, - left: FIND_SCROLL_OFFSET_LEFT }); + if (this.findController) { + this.findController.updateMatchPosition(pageIdx, i, textDivs, + begin.divIdx, end.divIdx); } // Match inside new div. @@ -387,3 +396,24 @@ var TextLayerBuilder = (function TextLayerBuilderClosure() { }; return TextLayerBuilder; })(); + +/** + * @constructor + * @implements IPDFTextLayerFactory + */ +function DefaultTextLayerFactory() {} +DefaultTextLayerFactory.prototype = { + /** + * @param {HTMLDivElement} textLayerDiv + * @param {number} pageIndex + * @param {PageViewport} viewport + * @returns {TextLayerBuilder} + */ + createTextLayerBuilder: function (textLayerDiv, pageIndex, viewport) { + return new TextLayerBuilder({ + textLayerDiv: textLayerDiv, + pageIndex: pageIndex, + viewport: viewport + }); + } +}; diff --git a/attachment_preview/static/lib/ViewerJS/ui_utils.js b/attachment_preview/static/lib/ViewerJS/ui_utils.js index b4f2d736..7e798e34 100644 --- a/attachment_preview/static/lib/ViewerJS/ui_utils.js +++ b/attachment_preview/static/lib/ViewerJS/ui_utils.js @@ -22,7 +22,6 @@ var UNKNOWN_SCALE = 0; var MAX_AUTO_SCALE = 1.25; var SCROLLBAR_PADDING = 40; var VERTICAL_PADDING = 5; -var DEFAULT_CACHE_SIZE = 10; // optimised CSS custom property getter/setter var CustomStyle = (function CustomStyleClosure() { @@ -161,13 +160,10 @@ function watchScroll(viewAreaElement, callback) { var currentY = viewAreaElement.scrollTop; var lastY = state.lastY; - if (currentY > lastY) { - state.down = true; - } else if (currentY < lastY) { - state.down = false; + if (currentY !== lastY) { + state.down = currentY > lastY; } state.lastY = currentY; - // else do nothing and use previous value callback(state); }); }; @@ -183,6 +179,38 @@ function watchScroll(viewAreaElement, callback) { return state; } +/** + * Use binary search to find the index of the first item in a given array which + * passes a given condition. The items are expected to be sorted in the sense + * that if the condition is true for one item in the array, then it is also true + * for all following items. + * + * @returns {Number} Index of the first array element to pass the test, + * or |items.length| if no such element exists. + */ +function binarySearchFirstItem(items, condition) { + var minIndex = 0; + var maxIndex = items.length - 1; + + if (items.length === 0 || !condition(items[maxIndex])) { + return items.length; + } + if (condition(items[minIndex])) { + return minIndex; + } + + while (minIndex < maxIndex) { + var currentIndex = (minIndex + maxIndex) >> 1; + var currentItem = items[currentIndex]; + if (condition(currentItem)) { + maxIndex = currentIndex; + } else { + minIndex = currentIndex + 1; + } + } + return minIndex; /* === maxIndex */ +} + /** * Generic helper to find out what elements are visible within a scroll pane. */ @@ -190,30 +218,45 @@ function getVisibleElements(scrollEl, views, sortByVisibility) { var top = scrollEl.scrollTop, bottom = top + scrollEl.clientHeight; var left = scrollEl.scrollLeft, right = left + scrollEl.clientWidth; - var visible = [], view; + function isElementBottomBelowViewTop(view) { + var element = view.div; + var elementBottom = + element.offsetTop + element.clientTop + element.clientHeight; + return elementBottom > top; + } + + var visible = [], view, element; var currentHeight, viewHeight, hiddenHeight, percentHeight; var currentWidth, viewWidth; - for (var i = 0, ii = views.length; i < ii; ++i) { + var firstVisibleElementInd = (views.length === 0) ? 0 : + binarySearchFirstItem(views, isElementBottomBelowViewTop); + + for (var i = firstVisibleElementInd, ii = views.length; i < ii; i++) { view = views[i]; - currentHeight = view.el.offsetTop + view.el.clientTop; - viewHeight = view.el.clientHeight; - if ((currentHeight + viewHeight) < top) { - continue; - } + element = view.div; + currentHeight = element.offsetTop + element.clientTop; + viewHeight = element.clientHeight; + if (currentHeight > bottom) { break; } - currentWidth = view.el.offsetLeft + view.el.clientLeft; - viewWidth = view.el.clientWidth; - if ((currentWidth + viewWidth) < left || currentWidth > right) { + + currentWidth = element.offsetLeft + element.clientLeft; + viewWidth = element.clientWidth; + if (currentWidth + viewWidth < left || currentWidth > right) { continue; } hiddenHeight = Math.max(0, top - currentHeight) + Math.max(0, currentHeight + viewHeight - bottom); percentHeight = ((viewHeight - hiddenHeight) * 100 / viewHeight) | 0; - visible.push({ id: view.id, x: currentWidth, y: currentHeight, - view: view, percent: percentHeight }); + visible.push({ + id: view.id, + x: currentWidth, + y: currentHeight, + view: view, + percent: percentHeight + }); } var first = visible[0]; @@ -349,23 +392,3 @@ var ProgressBar = (function ProgressBarClosure() { return ProgressBar; })(); - -var Cache = function cacheCache(size) { - var data = []; - this.push = function cachePush(view) { - var i = data.indexOf(view); - if (i >= 0) { - data.splice(i, 1); - } - data.push(view); - if (data.length > size) { - data.shift().destroy(); - } - }; - this.resize = function (newSize) { - size = newSize; - while (data.length > size) { - data.shift().destroy(); - } - }; -}; diff --git a/attachment_preview/static/lib/ViewerJS/webodf.js b/attachment_preview/static/lib/ViewerJS/webodf.js index 6a07cea1..dbb0d33d 100644 --- a/attachment_preview/static/lib/ViewerJS/webodf.js +++ b/attachment_preview/static/lib/ViewerJS/webodf.js @@ -40,603 +40,897 @@ @source: http://www.webodf.org/ @source: https://github.com/kogmbh/WebODF/ */ -var webodf_version="0.5.7";function Runtime(){}Runtime.prototype.getVariable=function(f){};Runtime.prototype.toJson=function(f){};Runtime.prototype.fromJson=function(f){};Runtime.prototype.byteArrayFromString=function(f,l){};Runtime.prototype.byteArrayToString=function(f,l){};Runtime.prototype.read=function(f,l,a,c){};Runtime.prototype.readFile=function(f,l,a){};Runtime.prototype.readFileSync=function(f,l){};Runtime.prototype.loadXML=function(f,l){};Runtime.prototype.writeFile=function(f,l,a){}; -Runtime.prototype.deleteFile=function(f,l){};Runtime.prototype.log=function(f,l){};Runtime.prototype.setTimeout=function(f,l){};Runtime.prototype.clearTimeout=function(f){};Runtime.prototype.libraryPaths=function(){};Runtime.prototype.currentDirectory=function(){};Runtime.prototype.setCurrentDirectory=function(f){};Runtime.prototype.type=function(){};Runtime.prototype.getDOMImplementation=function(){};Runtime.prototype.parseXML=function(f){};Runtime.prototype.exit=function(f){}; -Runtime.prototype.getWindow=function(){};Runtime.prototype.requestAnimationFrame=function(f){};Runtime.prototype.cancelAnimationFrame=function(f){};Runtime.prototype.assert=function(f,l){};var IS_COMPILED_CODE=!0; -Runtime.byteArrayToString=function(f,l){function a(a){var c="",b,n=a.length;for(b=0;bh?g.push(h):(b+=1,d=a[b],194<=h&&224>h?g.push((h&31)<<6|d&63):(b+=1,e=a[b],224<=h&&240>h?g.push((h&15)<<12|(d&63)<<6|e&63):(b+=1,s=a[b],240<=h&&245>h&&(h=(h&7)<<18|(d&63)<<12|(e&63)<<6|s&63,h-=65536,g.push((h>>10)+55296,(h&1023)+56320))))),1E3<=g.length&& -(c+=String.fromCharCode.apply(null,g),g.length=0);return c+String.fromCharCode.apply(null,g)}var b;"utf8"===l?b=c(f):("binary"!==l&&this.log("Unsupported encoding: "+l),b=a(f));return b};Runtime.getVariable=function(f){try{return eval(f)}catch(l){}};Runtime.toJson=function(f){return JSON.stringify(f)};Runtime.fromJson=function(f){return JSON.parse(f)};Runtime.getFunctionName=function(f){return void 0===f.name?(f=/function\s+(\w+)/.exec(f))&&f[1]:f.name}; -Runtime.assert=function(f,l){if(!f)throw this.log("alert","ASSERTION FAILED:\n"+l),Error(l);}; -function BrowserRuntime(){function f(a){var g=a.length,h,d,e=0;for(h=0;hd&&(e+=1,h+=1);return e}function l(a,g,h){var d=a.length,e,s;g=new Uint8Array(new ArrayBuffer(g));h?(g[0]=239,g[1]=187,g[2]=191,s=3):s=0;for(h=0;he?(g[s]=e,s+=1):2048>e?(g[s]=192|e>>>6,g[s+1]=128|e&63,s+=2):55040>=e||57344<=e?(g[s]=224|e>>>12&15,g[s+1]=128|e>>>6&63,g[s+2]=128|e&63,s+=3):(h+=1,e=(e-55296<<10|a.charCodeAt(h)-56320)+65536, -g[s]=240|e>>>18&7,g[s+1]=128|e>>>12&63,g[s+2]=128|e>>>6&63,g[s+3]=128|e&63,s+=4);return g}function a(a){var g=a.length,h=new Uint8Array(new ArrayBuffer(g)),d;for(d=0;dd.status||0===d.status?h(null):h("Status "+String(d.status)+": "+d.responseText||d.statusText):h("File "+c+" is empty."))};e=a.buffer&&!d.sendAsBinary?a.buffer:p.byteArrayToString(a,"binary");try{d.sendAsBinary?d.sendAsBinary(e):d.send(e)}catch(s){p.log("HUH? "+ -s+" "+a),h(s.message)}};this.deleteFile=function(c,a){var h=new XMLHttpRequest;h.open("DELETE",c,!0);h.onreadystatechange=function(){4===h.readyState&&(200>h.status&&300<=h.status?a(h.responseText):a(null))};h.send(null)};this.loadXML=function(c,a){var h=new XMLHttpRequest;h.open("GET",c,!0);h.overrideMimeType&&h.overrideMimeType("text/xml");h.onreadystatechange=function(){4===h.readyState&&(0!==h.status||h.responseText?200===h.status||0===h.status?a(null,h.responseXML):a(h.responseText,null):a("File "+ -c+" is empty.",null))};try{h.send(null)}catch(d){a(d.message,null)}};this.log=c;this.enableAlerts=!0;this.assert=Runtime.assert;this.setTimeout=function(a,c){return setTimeout(function(){a()},c)};this.clearTimeout=function(a){clearTimeout(a)};this.libraryPaths=function(){return["lib"]};this.setCurrentDirectory=function(){};this.currentDirectory=function(){return""};this.type=function(){return"BrowserRuntime"};this.getDOMImplementation=function(){return window.document.implementation};this.parseXML= -function(a){return(new DOMParser).parseFromString(a,"text/xml")};this.exit=function(a){c("Calling exit with code "+String(a)+", but exit() is not implemented.")};this.getWindow=function(){return window};this.requestAnimationFrame=function(a){var c=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame,h=0;if(c)c.bind(window),h=c(a);else return setTimeout(a,15);return h};this.cancelAnimationFrame=function(a){var c=window.cancelAnimationFrame|| -window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.msCancelAnimationFrame;c?(c.bind(window),c(a)):clearTimeout(a)}} -function NodeJSRuntime(){function f(a){var c=a.length,h,d=new Uint8Array(new ArrayBuffer(c));for(h=0;h").implementation} -function RhinoRuntime(){var f=this,l={},a=l.javax.xml.parsers.DocumentBuilderFactory.newInstance(),c,b,k="";a.setValidating(!1);a.setNamespaceAware(!0);a.setExpandEntityReferences(!1);a.setSchema(null);b=l.org.xml.sax.EntityResolver({resolveEntity:function(a,c){var b=new l.java.io.FileReader(c);return new l.org.xml.sax.InputSource(b)}});c=a.newDocumentBuilder();c.setEntityResolver(b);this.byteArrayFromString=function(a,c){var b,g=a.length,h=new Uint8Array(new ArrayBuffer(g));for(b=0;bl?e.push(l):(r+=1,a=b[r],194<=l&&224>l?e.push((l&31)<<6|a&63):(r+=1,d=b[r],224<=l&&240>l?e.push((l&15)<<12|(a&63)<<6|d&63):(r+=1,m=b[r],240<=l&&245>l&&(l=(l&7)<<18|(a&63)<<12|(d&63)<<6|m&63,l-=65536,e.push((l>>10)+55296,(l&1023)+56320))))),1E3<=e.length&& +(c+=String.fromCharCode.apply(null,e),e.length=0);return c+String.fromCharCode.apply(null,e)}var f;"utf8"===k?f=b(g):("binary"!==k&&this.log("Unsupported encoding: "+k),f=c(g));return f};Runtime.getVariable=function(g){try{return eval(g)}catch(k){}};Runtime.toJson=function(g){return JSON.stringify(g)};Runtime.fromJson=function(g){return JSON.parse(g)};Runtime.getFunctionName=function(g){return void 0===g.name?(g=/function\s+(\w+)/.exec(g))&&g[1]:g.name}; +Runtime.assert=function(g,k){if(!g)throw this.log("alert","ASSERTION FAILED:\n"+k),Error(k);}; +function BrowserRuntime(){function g(b){var e=b.length,l,a,d=0;for(l=0;la&&(d+=1,l+=1);return d}function k(b,e,l){var a=b.length,d,m;e=new Uint8Array(new ArrayBuffer(e));l?(e[0]=239,e[1]=187,e[2]=191,m=3):m=0;for(l=0;ld?(e[m]=d,m+=1):2048>d?(e[m]=192|d>>>6,e[m+1]=128|d&63,m+=2):55040>=d||57344<=d?(e[m]=224|d>>>12&15,e[m+1]=128|d>>>6&63,e[m+2]=128|d&63,m+=3):(l+=1,d=(d-55296<<10|b.charCodeAt(l)-56320)+65536, +e[m]=240|d>>>18&7,e[m+1]=128|d>>>12&63,e[m+2]=128|d>>>6&63,e[m+3]=128|d&63,m+=4);return e}function c(b){var e=b.length,l=new Uint8Array(new ArrayBuffer(e)),a;for(a=0;aa.status||0===a.status?l(null):l("Status "+String(a.status)+": "+a.responseText||a.statusText):l("File "+b+" is empty."))};d=e.buffer&&!a.sendAsBinary?e.buffer:r.byteArrayToString(e,"binary");try{a.sendAsBinary?a.sendAsBinary(d):a.send(d)}catch(m){r.log("HUH? "+ +m+" "+e),l(m.message)}};this.deleteFile=function(b,e){var l=new XMLHttpRequest;l.open("DELETE",b,!0);l.onreadystatechange=function(){4===l.readyState&&(200>l.status&&300<=l.status?e(l.responseText):e(null))};l.send(null)};this.loadXML=function(b,e){var l=new XMLHttpRequest;l.open("GET",b,!0);l.overrideMimeType&&l.overrideMimeType("text/xml");l.onreadystatechange=function(){4===l.readyState&&(0!==l.status||l.responseText?200===l.status||0===l.status?e(null,l.responseXML):e(l.responseText,null):e("File "+ +b+" is empty.",null))};try{l.send(null)}catch(a){e(a.message,null)}};this.log=b;this.enableAlerts=!0;this.assert=Runtime.assert;this.setTimeout=function(b,e){return setTimeout(function(){b()},e)};this.clearTimeout=function(b){clearTimeout(b)};this.libraryPaths=function(){return["lib"]};this.setCurrentDirectory=function(){};this.currentDirectory=function(){return""};this.type=function(){return"BrowserRuntime"};this.getDOMImplementation=function(){return window.document.implementation};this.parseXML= +function(b){return(new DOMParser).parseFromString(b,"text/xml")};this.exit=function(c){b("Calling exit with code "+String(c)+", but exit() is not implemented.")};this.getWindow=function(){return window};this.requestAnimationFrame=function(b){var e=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame,l=0;if(e)e.bind(window),l=e(b);else return setTimeout(b,15);return l};this.cancelAnimationFrame=function(b){var e=window.cancelAnimationFrame|| +window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.msCancelAnimationFrame;e?(e.bind(window),e(b)):clearTimeout(b)}} +function NodeJSRuntime(){function g(b){var e=b.length,l,a=new Uint8Array(new ArrayBuffer(e));for(l=0;l").implementation} +function RhinoRuntime(){var g=this,k={},c=k.javax.xml.parsers.DocumentBuilderFactory.newInstance(),b,f,n="";c.setValidating(!1);c.setNamespaceAware(!0);c.setExpandEntityReferences(!1);c.setSchema(null);f=k.org.xml.sax.EntityResolver({resolveEntity:function(b,c){var f=new k.java.io.FileReader(c);return new k.org.xml.sax.InputSource(f)}});b=c.newDocumentBuilder();b.setEntityResolver(f);this.byteArrayFromString=function(b,c){var f,e=b.length,l=new Uint8Array(new ArrayBuffer(e));for(f=0;f>>18],m+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[e>>>12&63],m+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[e>>>6&63],m+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[e& -63];a===s+1?(e=d[a]<<4,m+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[e>>>6],m+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[e&63],m+="=="):a===s&&(e=d[a]<<10|d[a+1]<<2,m+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[e>>>12],m+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[e>>>6&63],m+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[e&63],m+="=");return m}function a(e){e=e.replace(/[^A-Za-z0-9+\/]+/g, -"");var d=e.length,a=new Uint8Array(new ArrayBuffer(3*d)),s=e.length%4,c=0,b,H;for(b=0;b>16,a[c+1]=H>>8&255,a[c+2]=H&255,c+=3;d=3*d-[0,0,2,1][s];return a.subarray(0,d)}function c(e){var d,m,a=e.length,s=0,c=new Uint8Array(new ArrayBuffer(3*a));for(d=0;dm?c[s++]=m:(2048>m?c[s++]=192|m>>>6:(c[s++]=224|m>>>12&15,c[s++]=128|m>>>6&63),c[s++]=128|m&63);return c.subarray(0, -s)}function b(e){var d,m,a,s,c=e.length,H=new Uint8Array(new ArrayBuffer(c)),b=0;for(d=0;dm?H[b++]=m:(d+=1,a=e[d],224>m?H[b++]=(m&31)<<6|a&63:(d+=1,s=e[d],H[b++]=(m&15)<<12|(a&63)<<6|s&63));return H.subarray(0,b)}function k(d){return l(f(d))}function q(d){return String.fromCharCode.apply(String,a(d))}function p(d){return b(f(d))}function n(d){d=b(d);for(var e="",m=0;me?H+=String.fromCharCode(e):(c+=1,a=d.charCodeAt(c)&255,224>e?H+=String.fromCharCode((e&31)<<6|a&63):(c+=1,s=d.charCodeAt(c)&255,H+=String.fromCharCode((e&15)<<12|(a&63)<<6|s&63)));return H}function h(d,e){function m(){var c=s+1E5;c>d.length&&(c=d.length);a+=g(d,s,c);s=c;c=s===d.length;e(a,c)&&!c&&runtime.setTimeout(m,0)}var a="",s=0;1E5>d.length?e(g(d,0,d.length),!0):("string"!==typeof d&&(d=d.slice()),m())}function d(d){return c(f(d))}function e(d){return String.fromCharCode.apply(String, -c(d))}function s(d){return String.fromCharCode.apply(String,c(f(d)))}var m=function(d){var e={},m,a;m=0;for(a=d.length;mb-c&&(b=Math.max(2*b,c+a),a=new Uint8Array(new ArrayBuffer(b)),a.set(k),k=a)}var a=this,c=0,b=1024,k=new Uint8Array(new ArrayBuffer(b));this.appendByteArrayWriter=function(c){a.appendByteArray(c.getByteArray())};this.appendByteArray=function(a){var b=a.length;l(b);k.set(a,c);c+=b};this.appendArray=function(a){var b=a.length;l(b);k.set(a,c);c+=b};this.appendUInt16LE=function(c){a.appendArray([c&255,c>>8&255])};this.appendUInt32LE=function(c){a.appendArray([c& -255,c>>8&255,c>>16&255,c>>24&255])};this.appendString=function(c){a.appendByteArray(runtime.byteArrayFromString(c,f))};this.getLength=function(){return c};this.getByteArray=function(){var a=new Uint8Array(new ArrayBuffer(c));a.set(k.subarray(0,c));return a}};core.CSSUnits=function(){var f=this,l={"in":1,cm:2.54,mm:25.4,pt:72,pc:12,px:96};this.convert=function(a,c,b){return a*l[b]/l[c]};this.convertMeasure=function(a,c){var b,k;a&&c&&(b=parseFloat(a),k=a.replace(b.toString(),""),b=f.convert(b,k,c));return b};this.getUnits=function(a){return a.substr(a.length-2,a.length)}};(function(){function f(){var c,b,k,f,p,l,g,h,d;void 0===a&&(b=(c=runtime.getWindow())&&c.document,l=b.documentElement,g=b.body,a={rangeBCRIgnoresElementBCR:!1,unscaledRangeClientRects:!1,elementBCRIgnoresBodyScroll:!1},b&&(f=b.createElement("div"),f.style.position="absolute",f.style.left="-99999px",f.style.transform="scale(2)",f.style["-webkit-transform"]="scale(2)",p=b.createElement("div"),f.appendChild(p),g.appendChild(f),c=b.createRange(),c.selectNode(p),a.rangeBCRIgnoresElementBCR=0===c.getClientRects().length, -p.appendChild(b.createTextNode("Rect transform test")),b=p.getBoundingClientRect(),k=c.getBoundingClientRect(),a.unscaledRangeClientRects=2=d.compareBoundaryPoints(Range.START_TO_START,e)&&0<=d.compareBoundaryPoints(Range.END_TO_END,e)}function k(d,e){return 0>=d.compareBoundaryPoints(Range.END_TO_START,e)&&0<=d.compareBoundaryPoints(Range.START_TO_END,e)}function q(d,e){var a=null;d.nodeType===Node.TEXT_NODE&&(0===d.length?(d.parentNode.removeChild(d),e.nodeType===Node.TEXT_NODE&&(a=e)):(e.nodeType===Node.TEXT_NODE&&(d.appendData(e.data),e.parentNode.removeChild(e)),a=d));return a} -function p(d){for(var e=d.parentNode;d.firstChild;)e.insertBefore(d.firstChild,d);e.removeChild(d);return e}function n(d,e){var a=d.parentNode,c=d.firstChild,b=e(d),h;if(b===NodeFilter.FILTER_SKIP)return a;for(;c;)h=c.nextSibling,n(c,e),c=h;a&&b===NodeFilter.FILTER_REJECT&&p(d);return a}function g(d,e){return d===e||Boolean(d.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_CONTAINED_BY)}function h(d,e){return f().unscaledRangeClientRects?d:d/e}function d(e,m,a){Object.keys(m).forEach(function(c){var b= -c.split(":"),h=b[1],g=a(b[0]),b=m[c],k=typeof b;"object"===k?Object.keys(b).length&&(c=g?e.getElementsByTagNameNS(g,h)[0]||e.ownerDocument.createElementNS(g,c):e.getElementsByTagName(h)[0]||e.ownerDocument.createElement(c),e.appendChild(c),d(c,b,a)):g&&(runtime.assert("number"===k||"string"===k,"attempting to map unsupported type '"+k+"' (key: "+c+")"),e.setAttributeNS(g,c,String(b)))})}var e=null;this.splitBoundaries=function(d){var e,b=[],h,g,k;if(d.startContainer.nodeType===Node.TEXT_NODE||d.endContainer.nodeType=== -Node.TEXT_NODE){h=d.endContainer;g=d.endContainer.nodeType!==Node.TEXT_NODE?d.endOffset===d.endContainer.childNodes.length:!1;k=d.endOffset;e=d.endContainer;if(kf))throw runtime.log("alert","watchdog timeout"),"timeout!";if(0l))throw runtime.log("alert","watchdog loop overflow"),"loop overflow";}};core.NodeFilterChain=function(f){var l=NodeFilter.FILTER_REJECT,a=NodeFilter.FILTER_ACCEPT;this.acceptNode=function(c){var b;for(b=0;b "+e.length),runtime.assert(0<=a,"Error in setPosition: "+a+" < 0"),a===e.length&&(h.nextSibling()?d=0:h.parentNode()?d=1:runtime.assert(!1,"Error in setUnfilteredPosition: position not valid."))):ac.windowBits&&(c.windowBits=-c.windowBits,0===c.windowBits&&(c.windowBits=-15));!(0<=c.windowBits&&16>c.windowBits)||a&&a.windowBits||(c.windowBits+=32);15c.windowBits&&0===(c.windowBits&15)&&(c.windowBits|=15);this.err=0;this.msg="";this.ended=!1;this.chunks= -[];this.strm=new d;this.strm.avail_out=0;a=f.inflateInit2(this.strm,c.windowBits);if(a!==g.Z_OK)throw Error(h[a]);this.header=new e;f.inflateGetHeader(this.strm,this.header)};s.prototype.push=function(d,e){var a=this.strm,c=this.options.chunkSize,b,h,s,k,A;if(this.ended)return!1;h=e===~~e?e:!0===e?g.Z_FINISH:g.Z_NO_FLUSH;a.input="string"===typeof d?n.binstring2buf(d):d;a.next_in=0;a.avail_in=a.input.length;do{0===a.avail_out&&(a.output=new p.Buf8(c),a.next_out=0,a.avail_out=c);b=f.inflate(a,g.Z_NO_FLUSH); -if(b!==g.Z_STREAM_END&&b!==g.Z_OK)return this.onEnd(b),this.ended=!0,!1;if(a.next_out&&(0===a.avail_out||b===g.Z_STREAM_END||0===a.avail_in&&h===g.Z_FINISH))if("string"===this.options.to)s=n.utf8border(a.output,a.next_out),k=a.next_out-s,A=n.buf2string(a.output,s),a.next_out=k,a.avail_out=c-k,k&&p.arraySet(a.output,a.output,s,k,0),this.onData(A);else this.onData(p.shrinkBuf(a.output,a.next_out))}while((0a&&(d.subarray&&n||!d.subarray&&p))return String.fromCharCode.apply(null,f.shrinkBuf(d,a));for(var c="",b=0;ba;a++)d[a]=252<=a?6:248<= -a?5:240<=a?4:224<=a?3:192<=a?2:1;d[254]=d[254]=1;b.string2buf=function(d){var a,c,b,h,k,g=d.length,p=0;for(h=0;hc?1:2048>c?2:65536>c?3:4;a=new f.Buf8(p);for(h=k=0;kc?a[k++]=c:(2048>c?a[k++]=192|c>>>6:(65536>c?a[k++]=224|c>>>12:(a[k++]= -240|c>>>18,a[k++]=128|c>>>12&63),a[k++]=128|c>>>6&63),a[k++]=128|c&63);return a};b.buf2binstring=function(d){return k(d,d.length)};b.binstring2buf=function(d){for(var a=new f.Buf8(d.length),c=0,b=a.length;cg)q[h++]=g;else if(f=d[g],4g?q[h++]=g:(g-=65536,q[h++]= -55296|g>>10&1023,q[h++]=56320|g&1023)}return k(q,h)};b.utf8border=function(a,c){var b;c=c||a.length;c>a.length&&(c=a.length);for(b=c-1;0<=b&&128===(a[b]&192);)b--;return 0>b||0===b?c:b+d[a[b]]>c?b:c}},{"./common":2}],4:[function(a,c,b){c.exports=function(a,c,b,f){var g=a&65535|0;a=a>>>16&65535|0;for(var h=0;0!==b;){h=2E3b;b++){a=b;for(var k=0;8>k;k++)a=a&1?3988292384^a>>>1:a>>>1;c[b]=a}return c}();c.exports=function(a,c,b,g){b=g+b;for(a^= --1;g>>8^k[(a^c[g])&255];return a^-1}},{}],7:[function(a,c,b){c.exports=function(){this.os=this.xflags=this.time=this.text=0;this.extra=null;this.extra_len=0;this.comment=this.name="";this.hcrc=0;this.done=!1}},{}],8:[function(a,c,b){c.exports=function(a,c){var b,f,g,h,d,e,s,m,x,t,y,v,r,w,u,A,F,B,E,H,I,Q,N,z;b=a.state;f=a.next_in;N=a.input;g=f+(a.avail_in-5);h=a.next_out;z=a.output;d=h-(c-a.avail_out);e=h+(a.avail_out-257);s=b.dmax;m=b.wsize;x=b.whave;t=b.wnext;y=b.window;v=b.hold;r=b.bits; -w=b.lencode;u=b.distcode;A=(1<r&&(v+=N[f++]<>>24;v>>>=E;r-=E;E=B>>>16&255;if(0===E)z[h++]=B&65535;else if(E&16){H=B&65535;if(E&=15)r>>=E,r-=E;15>r&&(v+=N[f++]<>>24;v>>>=E;r-=E;E=B>>>16&255;if(E&16){B&=65535;E&=15;rs){a.msg="invalid distance too far back"; -b.mode=30;break a}v>>>=E;r-=E;E=h-d;if(B>E){E=B-E;if(E>x&&b.sane){a.msg="invalid distance too far back";b.mode=30;break a}I=0;Q=y;if(0===t){if(I+=m-E,E>3;f-=H;r-=H<<3;a.next_in=f;a.next_out=h;a.avail_in=f>>24&255)+(d>>>8&65280)+((d&65280)<<8)+((d&255)<<24)}function f(){this.mode=0;this.last=!1;this.wrap=0;this.havedict=!1;this.total=this.check=this.dmax=this.flags=0;this.head=null;this.wnext=this.whave=this.wsize=this.wbits=0;this.window=null;this.extra=this.offset=this.length=this.bits=this.hold=0;this.distcode=this.lencode=null;this.have=this.ndist=this.nlen=this.ncode=this.distbits=this.lenbits=0;this.next=null;this.lens=new d.Buf16(320);this.work= -new d.Buf16(288);this.distdyn=this.lendyn=null;this.was=this.back=this.sane=0}function p(a){var e;if(!a||!a.state)return y;e=a.state;a.total_in=a.total_out=e.total=0;a.msg="";e.wrap&&(a.adler=e.wrap&1);e.mode=v;e.last=0;e.havedict=0;e.dmax=32768;e.head=null;e.hold=0;e.bits=0;e.lencode=e.lendyn=new d.Buf32(r);e.distcode=e.distdyn=new d.Buf32(w);e.sane=1;e.back=-1;return t}function n(d){var a;if(!d||!d.state)return y;a=d.state;a.wsize=0;a.whave=0;a.wnext=0;return p(d)}function g(d,a){var e,c;if(!d|| -!d.state)return y;c=d.state;0>a?(e=0,a=-a):(e=(a>>4)+1,48>a&&(a&=15));if(a&&(8>a||15r;){if(0===p)break a;p--;n+=h[g++]<>>8&255;b.check=s(b.check,W,2,0);r=n=0;b.mode=2;break}b.flags=0;b.head&&(b.head.done=!1);if(!(b.wrap&1)||(((n&255)<<8)+(n>>8))%31){a.msg="incorrect header check";b.mode=30;break}if(8!==(n&15)){a.msg="unknown compression method";b.mode=30;break}n>>>=4;r-=4;O=(n&15)+8;if(0===b.wbits)b.wbits=O;else if(O>b.wbits){a.msg="invalid window size";b.mode=30;break}b.dmax=1<r;){if(0===p)break a;p--;n+=h[g++]<>8&1);b.flags&512&&(W[0]=n&255,W[1]=n>>>8&255,b.check=s(b.check,W,2,0));r=n=0;b.mode=3;case 3:for(;32>r;){if(0===p)break a;p--;n+=h[g++]<>>8&255,W[2]=n>>>16&255,W[3]=n>>>24&255,b.check=s(b.check,W,4,0));r=n=0;b.mode=4;case 4:for(;16>r;){if(0===p)break a;p--;n+=h[g++]<>8);b.flags&512&&(W[0]=n&255,W[1]=n>>>8&255,b.check=s(b.check,W,2,0));r=n=0;b.mode=5;case 5:if(b.flags&1024){for(;16>r;){if(0===p)break a;p--;n+=h[g++]<>>8&255,b.check=s(b.check,W,2,0));r=n=0}else b.head&&(b.head.extra=null);b.mode=6;case 6:if(b.flags&1024&&(D=b.length,D>p&&(D=p),D&&(b.head&&(O=b.head.extra_len-b.length,b.head.extra||(b.head.extra=Array(b.head.extra_len)),d.arraySet(b.head.extra, -h,g,D,O)),b.flags&512&&(b.check=s(b.check,h,D,g)),p-=D,g+=D,b.length-=D),b.length))break a;b.length=0;b.mode=7;case 7:if(b.flags&2048){if(0===p)break a;D=0;do O=h[g+D++],b.head&&O&&65536>b.length&&(b.head.name+=String.fromCharCode(O));while(O&&Db.length&&(b.head.comment+=String.fromCharCode(O));while(O&&D< -p);b.flags&512&&(b.check=s(b.check,h,D,g));p-=D;g+=D;if(O)break a}else b.head&&(b.head.comment=null);b.mode=9;case 9:if(b.flags&512){for(;16>r;){if(0===p)break a;p--;n+=h[g++]<>9&1,b.head.done=!0);a.adler=b.check=0;b.mode=12;break;case 10:for(;32>r;){if(0===p)break a;p--;n+=h[g++]<>>=r&7;r-=r&7;b.mode=27;break}for(;3>r;){if(0===p)break a;p--;n+=h[g++]<>>=1;r-=1;switch(n&3){case 0:b.mode=14;break;case 1:D=b;if(u){O=void 0;A=new d.Buf32(512);F=new d.Buf32(32);for(O=0;144>O;)D.lens[O++]=8;for(;256>O;)D.lens[O++]=9;for(;280>O;)D.lens[O++]=7;for(;288>O;)D.lens[O++]=8;x(1,D.lens,0,288,A,0,D.work,{bits:9});for(O=0;32>O;)D.lens[O++]=5;x(2,D.lens, -0,32,F,0,D.work,{bits:5});u=!1}D.lencode=A;D.lenbits=9;D.distcode=F;D.distbits=5;b.mode=20;if(6===c){n>>>=2;r-=2;break a}break;case 2:b.mode=17;break;case 3:a.msg="invalid block type",b.mode=30}n>>>=2;r-=2;break;case 14:n>>>=r&7;for(r-=r&7;32>r;){if(0===p)break a;p--;n+=h[g++]<>>16^65535)){a.msg="invalid stored block lengths";b.mode=30;break}b.length=n&65535;r=n=0;b.mode=15;if(6===c)break a;case 15:b.mode=16;case 16:if(D=b.length){D>p&&(D=p);D>q&&(D=q);if(0===D)break a;d.arraySet(f, -h,g,D,z);p-=D;g+=D;q-=D;z+=D;b.length-=D;break}b.mode=12;break;case 17:for(;14>r;){if(0===p)break a;p--;n+=h[g++]<>>=5;r-=5;b.ndist=(n&31)+1;n>>>=5;r-=5;b.ncode=(n&15)+4;n>>>=4;r-=4;if(286r;){if(0===p)break a;p--;n+=h[g++]<>>=3;r-=3}for(;19>b.have;)b.lens[P[b.have++]]=0;b.lencode=b.lendyn;b.lenbits=7; -D={bits:b.lenbits};U=x(0,b.lens,0,19,b.lencode,0,b.work,D);b.lenbits=D.bits;if(U){a.msg="invalid code lengths set";b.mode=30;break}b.have=0;b.mode=19;case 19:for(;b.have>>24;V=D>>>16&255;$=D&65535;if(C<=r)break;if(0===p)break a;p--;n+=h[g++]<$)n>>>=C,r-=C,b.lens[b.have++]=$;else{if(16===$){for(D=C+2;r>>=C;r-=C;if(0===b.have){a.msg="invalid bit length repeat";b.mode=30;break}O= -b.lens[b.have-1];D=3+(n&3);n>>>=2;r-=2}else if(17===$){for(D=C+3;r>>=C;r-=C;O=0;D=3+(n&7);n>>>=3;r-=3}else{for(D=C+7;r>>=C;r-=C;O=0;D=11+(n&127);n>>>=7;r-=7}if(b.have+D>b.nlen+b.ndist){a.msg="invalid bit length repeat";b.mode=30;break}for(;D--;)b.lens[b.have++]=O}}if(30===b.mode)break;if(0===b.lens[256]){a.msg="invalid code -- missing end-of-block";b.mode=30;break}b.lenbits=9;D={bits:b.lenbits};U=x(1,b.lens, -0,b.nlen,b.lencode,0,b.work,D);b.lenbits=D.bits;if(U){a.msg="invalid literal/lengths set";b.mode=30;break}b.distbits=6;b.distcode=b.distdyn;D={bits:b.distbits};U=x(2,b.lens,b.nlen,b.ndist,b.distcode,0,b.work,D);b.distbits=D.bits;if(U){a.msg="invalid distances set";b.mode=30;break}b.mode=20;if(6===c)break a;case 20:b.mode=21;case 21:if(6<=p&&258<=q){a.next_out=z;a.avail_out=q;a.next_in=g;a.avail_in=p;b.hold=n;b.bits=r;m(a,T);z=a.next_out;f=a.output;q=a.avail_out;g=a.next_in;h=a.input;p=a.avail_in; -n=b.hold;r=b.bits;12===b.mode&&(b.back=-1);break}for(b.back=0;;){D=b.lencode[n&(1<>>24;V=D>>>16&255;$=D&65535;if(C<=r)break;if(0===p)break a;p--;n+=h[g++]<>O)];C=D>>>24;V=D>>>16&255;$=D&65535;if(O+C<=r)break;if(0===p)break a;p--;n+=h[g++]<>>=O;r-=O;b.back+=O}n>>>=C;r-=C;b.back+=C;b.length=$;if(0===V){b.mode=26;break}if(V&32){b.back=-1;b.mode=12;break}if(V&64){a.msg="invalid literal/length code"; -b.mode=30;break}b.extra=V&15;b.mode=22;case 22:if(b.extra){for(D=b.extra;r>>=b.extra;r-=b.extra;b.back+=b.extra}b.was=b.length;b.mode=23;case 23:for(;;){D=b.distcode[n&(1<>>24;V=D>>>16&255;$=D&65535;if(C<=r)break;if(0===p)break a;p--;n+=h[g++]<>O)];C=D>>>24;V=D>>>16&255;$=D&65535;if(O+C<=r)break;if(0===p)break a;p--;n+=h[g++]<>>=O;r-=O;b.back+=O}n>>>=C;r-=C;b.back+=C;if(V&64){a.msg="invalid distance code";b.mode=30;break}b.offset=$;b.extra=V&15;b.mode=24;case 24:if(b.extra){for(D=b.extra;r>>=b.extra;r-=b.extra;b.back+=b.extra}if(b.offset>b.dmax){a.msg="invalid distance too far back";b.mode=30;break}b.mode=25;case 25:if(0===q)break a;D=T-q;if(b.offset>D){D=b.offset-D;if(D>b.whave&&b.sane){a.msg="invalid distance too far back";b.mode=30;break}D> -b.wnext?(D-=b.wnext,O=b.wsize-D):O=b.wnext-D;D>b.length&&(D=b.length);Z=b.window}else Z=f,O=z-b.offset,D=b.length;D>q&&(D=q);q-=D;b.length-=D;do f[z++]=Z[O++];while(--D);0===b.length&&(b.mode=21);break;case 26:if(0===q)break a;f[z++]=b.length;q--;b.mode=21;break;case 27:if(b.wrap){for(;32>r;){if(0===p)break a;p--;n|=h[g++]<r;){if(0===p)break a;p--;n+=h[g++]<b.mode&&(27>b.mode||4!==c))h=a.output,g=a.next_out,z=T-a.avail_out,q=a.state,null===q.window&&(q.wsize=1<=q.wsize?(d.arraySet(q.window,h,g-q.wsize,q.wsize,0),q.wnext=0,q.whave=q.wsize):(p=q.wsize-q.wnext,p>z&&(p=z),d.arraySet(q.window,h,g-z,p,q.wnext),(z-=p)?(d.arraySet(q.window,h,g-z,z,0),q.wnext=z,q.whave=q.wsize):(q.wnext+=p,q.wnext===q.wsize&&(q.wnext=0),q.whave=r;r++)G[r]=0;for(w=0;wA&&(F=A);if(0===A)return m[x++]=20971520,m[x++]=20971520,y.bits=1,0;for(u=1;u=r;r++)if(H<<=1,H-=G[r],0>H)return-1;if(0r;r++)B[r+1]=B[r]+G[r];for(w=0;wJ?(O=ba[T+t[w]],Z=Y[R+t[w]]):(O=96,Z=0);H=1<>E)+N]=D<<24|O<<16|Z|0;while(0!==N);for(H=1<>=1;0!==H?(Q&=H-1,Q+=H):Q=0;w++;if(0===--G[r]){if(r===A)break;r=d[b+t[w]]}if(r>F&&(Q&c)!==z){0===E&&(E=F);v+=u;B=r-E;for(H=1<=H)break;B++;H<<=1}I+=1<>>8^h;return b^-1}function b(a){return new Date((a>>25&127)+1980,(a>>21&15)-1,a>>16&31,a>>11&15, -a>>5&63,(a&31)<<1)}function k(a){var d=a.getFullYear();return 1980>d?0:d-1980<<25|a.getMonth()+1<<21|a.getDate()<<16|a.getHours()<<11|a.getMinutes()<<5|a.getSeconds()>>1}function q(d,e){var c,h,m,g,s,f,k,p=this;this.load=function(b){if(null!==p.data)b(null,p.data);else{var e=s+34+h+m+256;e+k>t&&(e=t-k);a(k,e,function(a,e){if(a||null===e)b(a,e);else a:{var c=e,h=new core.ByteArray(c),m=h.readUInt32LE(),k;if(67324752!==m)b("File entry signature is wrong."+m.toString()+" "+c.length.toString(),null); -else{h.pos+=22;m=h.readUInt16LE();k=h.readUInt16LE();h.pos+=m+k;if(g){c=c.subarray(h.pos,h.pos+s);if(s!==c.length){b("The amount of compressed bytes read was "+c.length.toString()+" instead of "+s.toString()+" for "+p.filename+" in "+d+".",null);break a}c=v(c,f)}else c=c.subarray(h.pos,h.pos+f);f!==c.length?b("The amount of bytes read was "+c.length.toString()+" instead of "+f.toString()+" for "+p.filename+" in "+d+".",null):(p.data=c,b(null,c))}}})}};this.set=function(a,d,b,e){p.filename=a;p.data= -d;p.compressed=b;p.date=e};this.error=null;e&&(c=e.readUInt32LE(),33639248!==c?this.error="Central directory entry has wrong signature at position "+(e.pos-4).toString()+' for file "'+d+'": '+e.data.length.toString():(e.pos+=6,g=e.readUInt16LE(),this.date=b(e.readUInt32LE()),e.readUInt32LE(),s=e.readUInt32LE(),f=e.readUInt32LE(),h=e.readUInt16LE(),m=e.readUInt16LE(),c=e.readUInt16LE(),e.pos+=8,k=e.readUInt32LE(),this.filename=runtime.byteArrayToString(e.data.subarray(e.pos,e.pos+h),"utf8"),this.data= -null,e.pos+=h+m+c))}function p(d,b){if(22!==d.length)b("Central directory length should be 22.",r);else{var e=new core.ByteArray(d),c;c=e.readUInt32LE();101010256!==c?b("Central directory signature is wrong: "+c.toString(),r):(c=e.readUInt16LE(),0!==c?b("Zip files with non-zero disk numbers are not supported.",r):(c=e.readUInt16LE(),0!==c?b("Zip files with non-zero disk numbers are not supported.",r):(c=e.readUInt16LE(),y=e.readUInt16LE(),c!==y?b("Number of entries is inconsistent.",r):(c=e.readUInt32LE(), -e=e.readUInt16LE(),e=t-22-c,a(e,t-e,function(a,d){if(a||null===d)b(a,r);else a:{var e=new core.ByteArray(d),c,h;m=[];for(c=0;c>>18],m+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[d>>>12&63],m+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[d>>>6&63],m+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[d& +63];h===b+1?(d=a[h]<<4,m+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[d>>>6],m+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[d&63],m+="=="):h===b&&(d=a[h]<<10|a[h+1]<<2,m+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[d>>>12],m+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[d>>>6&63],m+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[d&63],m+="=");return m}function c(a){a=a.replace(/[^A-Za-z0-9+\/]+/g, +"");var d=a.length,m=new Uint8Array(new ArrayBuffer(3*d)),b=a.length%4,c=0,l,e;for(l=0;l>16,m[c+1]=e>>8&255,m[c+2]=e&255,c+=3;d=3*d-[0,0,2,1][b];return m.subarray(0,d)}function b(a){var d,m,h=a.length,b=0,c=new Uint8Array(new ArrayBuffer(3*h));for(d=0;dm?c[b++]=m:(2048>m?c[b++]=192|m>>>6:(c[b++]=224|m>>>12&15,c[b++]=128|m>>>6&63),c[b++]=128|m&63);return c.subarray(0, +b)}function f(a){var d,m,h,b,c=a.length,l=new Uint8Array(new ArrayBuffer(c)),e=0;for(d=0;dm?l[e++]=m:(d+=1,h=a[d],224>m?l[e++]=(m&31)<<6|h&63:(d+=1,b=a[d],l[e++]=(m&15)<<12|(h&63)<<6|b&63));return l.subarray(0,e)}function n(a){return k(g(a))}function p(a){return String.fromCharCode.apply(String,c(a))}function r(a){return f(g(a))}function q(a){a=f(a);for(var d="",m=0;md?l+=String.fromCharCode(d):(c+=1,h=a.charCodeAt(c)&255,224>d?l+=String.fromCharCode((d&31)<<6|h&63):(c+=1,b=a.charCodeAt(c)&255,l+=String.fromCharCode((d&15)<<12|(h&63)<<6|b&63)));return l}function l(a,d){function m(){var c=b+1E5;c>a.length&&(c=a.length);h+=e(a,b,c);b=c;c=b===a.length;d(h,c)&&!c&&runtime.setTimeout(m,0)}var h="",b=0;1E5>a.length?d(e(a,0,a.length),!0):("string"!==typeof a&&(a=a.slice()),m())}function a(a){return b(g(a))}function d(a){return String.fromCharCode.apply(String, +b(a))}function m(a){return String.fromCharCode.apply(String,b(g(a)))}var h=function(a){var d={},m,h;m=0;for(h=a.length;m=a.compareBoundaryPoints(Range.START_TO_START,d)&&0<=a.compareBoundaryPoints(Range.END_TO_END,d)}function n(a,d){return 0>=a.compareBoundaryPoints(Range.END_TO_START,d)&&0<=a.compareBoundaryPoints(Range.START_TO_END,d)}function p(a,d){var b=null;a.nodeType===Node.TEXT_NODE&&(0===a.length?(a.parentNode.removeChild(a),d.nodeType===Node.TEXT_NODE&&(b=d)):(d.nodeType===Node.TEXT_NODE&&(a.appendData(d.data),d.parentNode.removeChild(d)),b=a));return b} +function r(a){for(var d=a.parentNode;a.firstChild;)d.insertBefore(a.firstChild,a);d.removeChild(a);return d}function q(a,d){var b=a.parentNode,c=a.firstChild,l=d(a),e;if(l===NodeFilter.FILTER_SKIP)return b;for(;c;)e=c.nextSibling,q(c,d),c=e;b&&l===NodeFilter.FILTER_REJECT&&r(a);return b}function e(a,d){return a===d||Boolean(a.compareDocumentPosition(d)&Node.DOCUMENT_POSITION_CONTAINED_BY)}function l(a,d){return g().unscaledRangeClientRects?a:a/d}function a(d,h,b){Object.keys(h).forEach(function(c){var l= +c.split(":"),e=l[1],f=b(l[0]),l=h[c],n=typeof l;"object"===n?Object.keys(l).length&&(c=f?d.getElementsByTagNameNS(f,e)[0]||d.ownerDocument.createElementNS(f,c):d.getElementsByTagName(e)[0]||d.ownerDocument.createElement(c),d.appendChild(c),a(c,l,b)):f&&(runtime.assert("number"===n||"string"===n,"attempting to map unsupported type '"+n+"' (key: "+c+")"),d.setAttributeNS(f,c,String(l)))})}var d=null;this.splitBoundaries=function(a){var d,c=[],l,e,f;if(a.startContainer.nodeType===Node.TEXT_NODE||a.endContainer.nodeType=== +Node.TEXT_NODE){l=a.endContainer;e=a.endContainer.nodeType!==Node.TEXT_NODE?a.endOffset===a.endContainer.childNodes.length:!1;f=a.endOffset;d=a.endContainer;if(fg))throw runtime.log("alert","watchdog timeout"),"timeout!";if(0k))throw runtime.log("alert","watchdog loop overflow"),"loop overflow";}};core.NodeFilterChain=function(g){var k=NodeFilter.FILTER_REJECT,c=NodeFilter.FILTER_ACCEPT;this.acceptNode=function(b){var f;for(f=0;f "+d.length),runtime.assert(0<=b,"Error in setPosition: "+b+" < 0"),b===d.length&&(l.nextSibling()?a=0:l.parentNode()?a=1:runtime.assert(!1,"Error in setUnfilteredPosition: position not valid."))):ba.value||"%"===a.unit)?null:a}function E(a){return(a=F(a))&&"%"!==a.unit?null:a}function H(a){switch(a.namespaceURI){case odf.Namespaces.drawns:case odf.Namespaces.svgns:case odf.Namespaces.dr3dns:return!1;case odf.Namespaces.textns:switch(a.localName){case "note-body":case "ruby-text":return!1}break;case odf.Namespaces.officens:switch(a.localName){case "annotation":case "binary-data":case "event-listeners":return!1}break;default:switch(a.localName){case "cursor":case "editinfo":return!1}}return!0} -function I(a,d){for(;0=d.value||"%"===d.unit)?null:d;return d||E(a)};this.parseFoLineHeight= -function(a){return B(a)||E(a)};this.isTextContentContainingNode=H;this.getTextNodes=function(a,d){var b;b=G.getNodesInRange(a,function(a){var d=NodeFilter.FILTER_REJECT;a.nodeType===Node.TEXT_NODE?Boolean(k(a)&&(!p(a.textContent)||A(a,0)))&&(d=NodeFilter.FILTER_ACCEPT):H(a)&&(d=NodeFilter.FILTER_SKIP);return d},NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT);d||I(a,b);return b};this.getTextElements=Q;this.getParagraphElements=function(a){var d;d=G.getNodesInRange(a,function(a){var d=NodeFilter.FILTER_REJECT; -if(b(a))d=NodeFilter.FILTER_ACCEPT;else if(H(a)||n(a))d=NodeFilter.FILTER_SKIP;return d},NodeFilter.SHOW_ELEMENT);N(a.startContainer,d,b);return d};this.getImageElements=function(a){var d;d=G.getNodesInRange(a,function(a){var d=NodeFilter.FILTER_SKIP;f(a)&&(d=NodeFilter.FILTER_ACCEPT);return d},NodeFilter.SHOW_ELEMENT);N(a.startContainer,d,f);return d};this.getHyperlinkElements=function(a){var d=[],e=a.cloneRange();a.collapsed&&a.endContainer.nodeType===Node.ELEMENT_NODE&&(a=z(a.endContainer,a.endOffset), -a.nodeType===Node.TEXT_NODE&&e.setEnd(a,1));Q(e,!0,!1).forEach(function(a){for(a=a.parentNode;!b(a);){if(c(a)&&-1===d.indexOf(a)){d.push(a);break}a=a.parentNode}});e.detach();return d};this.getNormalizedFontFamilyName=function(a){/^(["'])(?:.|[\n\r])*?\1$/.test(a)||(a=a.replace(/^[ \t\r\n\f]*((?:.|[\n\r])*?)[ \t\r\n\f]*$/,"$1"),/[ \t\r\n\f]/.test(a)&&(a="'"+a.replace(/[ \t\r\n\f]+/g," ")+"'"));return a}};odf.OdfUtils=new odf.OdfUtilsImpl;gui.OdfTextBodyNodeFilter=function(){var f=odf.OdfUtils,l=Node.TEXT_NODE,a=NodeFilter.FILTER_REJECT,c=NodeFilter.FILTER_ACCEPT,b=odf.Namespaces.textns;this.acceptNode=function(k){if(k.nodeType===l){if(!f.isGroupingElement(k.parentNode))return a}else if(k.namespaceURI===b&&"tracked-changes"===k.localName)return a;return c}};xmldom.LSSerializerFilter=function(){};xmldom.LSSerializerFilter.prototype.acceptNode=function(f){};odf.OdfNodeFilter=function(){this.acceptNode=function(f){return"http://www.w3.org/1999/xhtml"===f.namespaceURI?NodeFilter.FILTER_SKIP:f.namespaceURI&&f.namespaceURI.match(/^urn:webodf:/)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}};xmldom.XPathIterator=function(){};xmldom.XPathIterator.prototype.next=function(){};xmldom.XPathIterator.prototype.reset=function(){}; -function createXPathSingleton(){function f(a,d,b){return-1!==a&&(a=g&&b.push(l(a.substring(d,c)))):"["===a[c]&&(0>=g&&(d=c+1),g+=1),c+=1;return c};n=function(a,d,e){var g,m,f,k;for(g=0;ga.value||"%"===a.unit)?null:a}function L(a){return(a=I(a))&&"%"!==a.unit?null:a}function E(a){switch(a.namespaceURI){case odf.Namespaces.drawns:case odf.Namespaces.svgns:case odf.Namespaces.dr3dns:return!1;case odf.Namespaces.textns:switch(a.localName){case "note-body":case "ruby-text":return!1}break;case odf.Namespaces.officens:switch(a.localName){case "annotation":case "binary-data":case "event-listeners":return!1}break;default:switch(a.localName){case "cursor":case "editinfo":return!1}}return!0} +function N(a){return Boolean(n(a)&&(!r(a.textContent)||A(a,0)))}function O(a,d){for(;0=d.value||"%"===d.unit)?null:d;return d||L(a)};this.parseFoLineHeight= +function(a){return K(a)||L(a)};this.isTextContentContainingNode=E;this.getTextNodes=function(a,d){var b;b=aa.getNodesInRange(a,function(a){var d=NodeFilter.FILTER_REJECT;a.nodeType===Node.TEXT_NODE?N(a)&&(d=NodeFilter.FILTER_ACCEPT):E(a)&&(d=NodeFilter.FILTER_SKIP);return d},NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT);d||O(a,b);return b};this.getTextElements=D;this.getParagraphElements=function(a){var d;d=aa.getNodesInRange(a,function(a){var d=NodeFilter.FILTER_REJECT;if(f(a))d=NodeFilter.FILTER_ACCEPT; +else if(E(a)||q(a))d=NodeFilter.FILTER_SKIP;return d},NodeFilter.SHOW_ELEMENT);V(a.startContainer,d,f);return d};this.getImageElements=function(a){var d;d=aa.getNodesInRange(a,function(a){var d=NodeFilter.FILTER_SKIP;g(a)&&(d=NodeFilter.FILTER_ACCEPT);return d},NodeFilter.SHOW_ELEMENT);V(a.startContainer,d,g);return d};this.getHyperlinkElements=function(a){var d=[],c=a.cloneRange();a.collapsed&&a.endContainer.nodeType===Node.ELEMENT_NODE&&(a=W(a.endContainer,a.endOffset),a.nodeType===Node.TEXT_NODE&& +c.setEnd(a,1));D(c,!0,!1).forEach(function(a){for(a=a.parentNode;!f(a);){if(b(a)&&-1===d.indexOf(a)){d.push(a);break}a=a.parentNode}});c.detach();return d};this.getNormalizedFontFamilyName=function(a){/^(["'])(?:.|[\n\r])*?\1$/.test(a)||(a=a.replace(/^[ \t\r\n\f]*((?:.|[\n\r])*?)[ \t\r\n\f]*$/,"$1"),/[ \t\r\n\f]/.test(a)&&(a="'"+a.replace(/[ \t\r\n\f]+/g," ")+"'"));return a}};odf.OdfUtils=new odf.OdfUtilsImpl; +gui.OdfTextBodyNodeFilter=function(){var g=odf.OdfUtils,k=Node.TEXT_NODE,c=NodeFilter.FILTER_REJECT,b=NodeFilter.FILTER_ACCEPT,f=odf.Namespaces.textns;this.acceptNode=function(n){if(n.nodeType===k){if(!g.isGroupingElement(n.parentNode))return c}else if(n.namespaceURI===f&&"tracked-changes"===n.localName)return c;return b}};xmldom.LSSerializerFilter=function(){};xmldom.LSSerializerFilter.prototype.acceptNode=function(g){}; +odf.OdfNodeFilter=function(){this.acceptNode=function(g){return"http://www.w3.org/1999/xhtml"===g.namespaceURI?NodeFilter.FILTER_SKIP:g.namespaceURI&&g.namespaceURI.match(/^urn:webodf:/)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}};xmldom.XPathIterator=function(){};xmldom.XPathIterator.prototype.next=function(){};xmldom.XPathIterator.prototype.reset=function(){}; +function createXPathSingleton(){function g(b,a,d){return-1!==b&&(b=e&&d.push(k(b.substring(a,c)))):"["===b[c]&&(0>=e&&(a=c+1),e+=1),c+=1;return c};q=function(c,a,d){var m,h,e,n;for(m=0;m/g,">").replace(/'/g,"'").replace(/"/g,""")}function a(b,f){var q="",p=c.filter?c.filter.acceptNode(f):NodeFilter.FILTER_ACCEPT,n;if(p===NodeFilter.FILTER_ACCEPT&&f.nodeType===Node.ELEMENT_NODE){b.push();n=b.getQName(f);var g,h=f.attributes,d,e,s,m="",x;g="<"+n;d=h.length;for(e=0;e")}if(p===NodeFilter.FILTER_ACCEPT||p===NodeFilter.FILTER_SKIP){for(p=f.firstChild;p;)q+=a(b,p),p=p.nextSibling;f.nodeValue&&(q+=l(f.nodeValue))}n&&(q+="",b.pop());return q}var c=this;this.filter=null;this.writeToString=function(b,c){if(!b)return"";var q=new f(c);return a(q,b)}};(function(){function f(a){var b,e=p.length;for(b=0;be)break;m=m.nextSibling}a.insertBefore(b,m)}}}var b=new odf.StyleInfo,k=core.DomUtils,q=odf.Namespaces.stylens,p="meta settings scripts font-face-decls styles automatic-styles master-styles body".split(" "), -n=Date.now()+"_webodf_",g=new core.Base64;odf.ODFElement=function(){};odf.ODFDocumentElement=function(){};odf.ODFDocumentElement.prototype=new odf.ODFElement;odf.ODFDocumentElement.prototype.constructor=odf.ODFDocumentElement;odf.ODFDocumentElement.prototype.fontFaceDecls=null;odf.ODFDocumentElement.prototype.manifest=null;odf.ODFDocumentElement.prototype.settings=null;odf.ODFDocumentElement.namespaceURI="urn:oasis:names:tc:opendocument:xmlns:office:1.0";odf.ODFDocumentElement.localName="document"; -odf.AnnotationElement=function(){};odf.OdfPart=function(a,b,e,c){var m=this;this.size=0;this.type=null;this.name=a;this.container=e;this.url=null;this.mimetype=b;this.onstatereadychange=this.document=null;this.EMPTY=0;this.LOADING=1;this.DONE=2;this.state=this.EMPTY;this.data="";this.load=function(){null!==c&&(this.mimetype=b,c.loadAsDataURL(a,b,function(a,b){a&&runtime.log(a);m.url=b;if(m.onchange)m.onchange(m);if(m.onstatereadychange)m.onstatereadychange(m)}))}};odf.OdfPart.prototype.load=function(){}; -odf.OdfPart.prototype.getUrl=function(){return this.data?"data:;base64,"+g.toBase64(this.data):null};odf.OdfContainer=function d(e,f){function m(a){for(var b=a.firstChild,d;b;)d=b.nextSibling,b.nodeType===Node.ELEMENT_NODE?m(b):b.nodeType===Node.PROCESSING_INSTRUCTION_NODE&&a.removeChild(b),b=d}function p(a){var b={},d,e,c=a.ownerDocument.createNodeIterator(a,NodeFilter.SHOW_ELEMENT,null,!1);for(a=c.nextNode();a;)"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===a.namespaceURI&&("annotation"=== -a.localName?(d=a.getAttributeNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0","name"))&&(b.hasOwnProperty(d)?runtime.log("Warning: annotation name used more than once with : '"+d+"'"):b[d]=a):"annotation-end"===a.localName&&((d=a.getAttributeNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0","name"))?b.hasOwnProperty(d)?(e=b[d],e.annotationEndElement?runtime.log("Warning: annotation name used more than once with : '"+d+"'"):e.annotationEndElement= -a):runtime.log("Warning: annotation end without an annotation start, name: '"+d+"'"):runtime.log("Warning: annotation end without a name found"))),a=c.nextNode()}function t(a,b){for(var d=a&&a.firstChild;d;)d.nodeType===Node.ELEMENT_NODE&&d.setAttributeNS("urn:webodf:names:scope","scope",b),d=d.nextSibling}function y(a,b){for(var d=U.rootElement.meta,d=d&&d.firstChild;d&&(d.namespaceURI!==a||d.localName!==b);)d=d.nextSibling;for(d=d&&d.firstChild;d&&d.nodeType!==Node.TEXT_NODE;)d=d.nextSibling;return d? -d.data:null}function v(a){var b={},d;for(a=a.firstChild;a;)a.nodeType===Node.ELEMENT_NODE&&a.namespaceURI===q&&"font-face"===a.localName&&(d=a.getAttributeNS(q,"name"),b[d]=a),a=a.nextSibling;return b}function r(a,b){var d=null,e,c,m;if(a)for(d=a.cloneNode(!0),e=d.firstElementChild;e;)c=e.nextElementSibling,(m=e.getAttributeNS("urn:webodf:names:scope","scope"))&&m!==b&&d.removeChild(e),e=c;return d}function w(a,d){var e,c,m,g=null,f={};if(a)for(d.forEach(function(a){b.collectUsedFontFaces(f,a)}), -g=a.cloneNode(!0),e=g.firstElementChild;e;)c=e.nextElementSibling,m=e.getAttributeNS(q,"name"),f[m]||g.removeChild(e),e=c;return g}function u(a){var b=U.rootElement.ownerDocument,d;if(a){m(a.documentElement);try{d=b.importNode(a.documentElement,!0)}catch(e){}}return d}function A(a){U.state=a;if(U.onchange)U.onchange(U);if(U.onstatereadychange)U.onstatereadychange(U)}function F(a){aa=null;U.rootElement=a;a.fontFaceDecls=k.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","font-face-decls"); -a.styles=k.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","styles");a.automaticStyles=k.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","automatic-styles");a.masterStyles=k.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","master-styles");a.body=k.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","body");a.meta=k.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","meta");a.settings=k.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0", -"settings");a.scripts=k.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","scripts");p(a)}function B(a){var e=u(a),m=U.rootElement,g;e&&"document-styles"===e.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===e.namespaceURI?(m.fontFaceDecls=k.getDirectChild(e,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","font-face-decls"),c(m,m.fontFaceDecls),g=k.getDirectChild(e,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","styles"),m.styles=g||a.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0", -"styles"),c(m,m.styles),g=k.getDirectChild(e,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","automatic-styles"),m.automaticStyles=g||a.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0","automatic-styles"),t(m.automaticStyles,"document-styles"),c(m,m.automaticStyles),e=k.getDirectChild(e,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","master-styles"),m.masterStyles=e||a.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0","master-styles"),c(m,m.masterStyles), -b.prefixStyleNames(m.automaticStyles,n,m.masterStyles)):A(d.INVALID)}function E(a){a=u(a);var e,m,g,f;if(a&&"document-content"===a.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===a.namespaceURI){e=U.rootElement;g=k.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","font-face-decls");if(e.fontFaceDecls&&g){f=e.fontFaceDecls;var p,s,n,l,z={};m=v(f);l=v(g);for(g=g.firstElementChild;g;){p=g.nextElementSibling;if(g.namespaceURI===q&&"font-face"===g.localName)if(s=g.getAttributeNS(q, -"name"),m.hasOwnProperty(s)){if(!g.isEqualNode(m[s])){n=s;for(var r=m,Q=l,x=0,Y=void 0,Y=n=n.replace(/\d+$/,"");r.hasOwnProperty(Y)||Q.hasOwnProperty(Y);)x+=1,Y=n+x;n=Y;g.setAttributeNS(q,"style:name",n);f.appendChild(g);m[n]=g;delete l[s];z[s]=n}}else f.appendChild(g),m[s]=g,delete l[s];g=p}f=z}else g&&(e.fontFaceDecls=g,c(e,g));m=k.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","automatic-styles");t(m,"document-content");f&&b.changeFontFaceNames(m,f);if(e.automaticStyles&&m)for(f= -m.firstChild;f;)e.automaticStyles.appendChild(f),f=m.firstChild;else m&&(e.automaticStyles=m,c(e,m));a=k.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","body");if(null===a)throw" tag is mising.";e.body=a;c(e,e.body)}else A(d.INVALID)}function H(a){a=u(a);var b;a&&"document-meta"===a.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===a.namespaceURI&&(b=U.rootElement,b.meta=k.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","meta"), -c(b,b.meta))}function I(a){a=u(a);var b;a&&"document-settings"===a.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===a.namespaceURI&&(b=U.rootElement,b.settings=k.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","settings"),c(b,b.settings))}function Q(a){a=u(a);var b;if(a&&"manifest"===a.localName&&"urn:oasis:names:tc:opendocument:xmlns:manifest:1.0"===a.namespaceURI)for(b=U.rootElement,b.manifest=a,a=b.manifest.firstElementChild;a;)"file-entry"===a.localName&&"urn:oasis:names:tc:opendocument:xmlns:manifest:1.0"=== -a.namespaceURI&&(P[a.getAttributeNS("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0","full-path")]=a.getAttributeNS("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0","media-type")),a=a.nextElementSibling}function N(a,b,d){a=k.getElementsByTagName(a,b);var e;for(e=0;e'}function G(){var a=new xmldom.LSSerializer,b=J("document-meta");a.filter=new odf.OdfNodeFilter;b+=a.writeToString(U.rootElement.meta,odf.Namespaces.namespaceMap);return b+""}function ba(a,b){var d=document.createElementNS("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0","manifest:file-entry");d.setAttributeNS("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0","manifest:full-path",a);d.setAttributeNS("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0", -"manifest:media-type",b);return d}function T(){var a=runtime.parseXML(''),b=a.documentElement,d=new xmldom.LSSerializer,e;for(e in P)P.hasOwnProperty(e)&&b.appendChild(ba(e,P[e]));d.filter=new odf.OdfNodeFilter;return'\n'+d.writeToString(a,odf.Namespaces.namespaceMap)}function D(){var a,d,e,c=odf.Namespaces.namespaceMap, -m=new xmldom.LSSerializer,g=J("document-styles");d=r(U.rootElement.automaticStyles,"document-styles");e=U.rootElement.masterStyles.cloneNode(!0);a=w(U.rootElement.fontFaceDecls,[e,U.rootElement.styles,d]);b.removePrefixFromStyleNames(d,n,e);m.filter=new l(e,d);g+=m.writeToString(a,c);g+=m.writeToString(U.rootElement.styles,c);g+=m.writeToString(d,c);g+=m.writeToString(e,c);return g+""}function O(){var b,d,e=odf.Namespaces.namespaceMap,c=new xmldom.LSSerializer,m=J("document-content"); -d=r(U.rootElement.automaticStyles,"document-content");b=w(U.rootElement.fontFaceDecls,[d]);c.filter=new a(U.rootElement.body,d);m+=c.writeToString(b,e);m+=c.writeToString(d,e);m+=c.writeToString(U.rootElement.body,e);return m+""}function Z(a,b){runtime.loadXML(a,function(a,e){if(a)b(a);else if(e){z(e);Y(e.documentElement);var c=u(e);c&&"document"===c.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===c.namespaceURI?(F(c),A(d.DONE)):A(d.INVALID)}else b("No DOM was loaded.")})} -function C(a,b){var d;d=U.rootElement;var e=d.meta;e||(d.meta=e=document.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0","meta"),c(d,e));d=e;a&&k.mapKeyValObjOntoNode(d,a,odf.Namespaces.lookupNamespaceURI);b&&k.removeKeyElementsFromNode(d,b,odf.Namespaces.lookupNamespaceURI)}function V(a,b){function e(a,b){var d;b||(b=a);d=document.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0",b);f[a]=d;f.appendChild(d)}var c=new core.Zip("",null),m="application/vnd.oasis.opendocument."+ -a+(!0===b?"-template":""),g=runtime.byteArrayFromString(m,"utf8"),f=U.rootElement,k=document.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0",a);c.save("mimetype",g,!1,new Date);e("meta");e("settings");e("scripts");e("fontFaceDecls","font-face-decls");e("styles");e("automaticStyles","automatic-styles");e("masterStyles","master-styles");e("body");f.body.appendChild(k);P["/"]=m;P["settings.xml"]="text/xml";P["meta.xml"]="text/xml";P["styles.xml"]="text/xml";P["content.xml"]="text/xml"; -A(d.DONE);return c}function $(){var a,b=new Date,d="";U.rootElement.settings&&U.rootElement.settings.firstElementChild&&(a=new xmldom.LSSerializer,d=J("document-settings"),a.filter=new odf.OdfNodeFilter,d+=a.writeToString(U.rootElement.settings,odf.Namespaces.namespaceMap),d+="");(a=d)?(a=runtime.byteArrayFromString(a,"utf8"),W.save("settings.xml",a,!0,b)):W.remove("settings.xml");d=runtime.getWindow();a="WebODF/"+webodf.Version;d&&(a=a+" "+d.navigator.userAgent);C({"meta:generator":a}, -null);a=runtime.byteArrayFromString(G(),"utf8");W.save("meta.xml",a,!0,b);a=runtime.byteArrayFromString(D(),"utf8");W.save("styles.xml",a,!0,b);a=runtime.byteArrayFromString(O(),"utf8");W.save("content.xml",a,!0,b);a=runtime.byteArrayFromString(T(),"utf8");W.save("META-INF/manifest.xml",a,!0,b)}function ca(a,b){$();W.writeAs(a,function(a){b(a)})}var U=this,W,P={},aa,S="";this.onstatereadychange=f;this.state=this.onchange=null;this.getMetadata=y;this.setRootElement=F;this.getContentElement=function(){var a; -aa||(a=U.rootElement.body,aa=k.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","text")||k.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","presentation")||k.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","spreadsheet"));if(!aa)throw"Could not find content element in .";return aa};this.getDocumentType=function(){var a=U.getContentElement();return a&&a.localName};this.isTemplate=function(){return"-template"===P["/"].substr(-9)}; -this.setIsTemplate=function(a){var b=P["/"],d="-template"===b.substr(-9);a!==d&&(b=a?b+"-template":b.substr(0,b.length-9),P["/"]=b,a=runtime.byteArrayFromString(b,"utf8"),W.save("mimetype",a,!1,new Date))};this.getPart=function(a){return new odf.OdfPart(a,P[a],U,W)};this.getPartData=function(a,b){W.load(a,b)};this.setMetadata=C;this.incrementEditingCycles=function(){var a=y(odf.Namespaces.metans,"editing-cycles"),a=a?parseInt(a,10):0;isNaN(a)&&(a=0);C({"meta:editing-cycles":a+1},null);return a+1}; -this.createByteArray=function(a,b){$();W.createByteArray(a,b)};this.saveAs=ca;this.save=function(a){ca(S,a)};this.getUrl=function(){return S};this.setBlob=function(a,b,d){d=g.convertBase64ToByteArray(d);W.save(a,d,!1,new Date);P.hasOwnProperty(a)&&runtime.log(a+" has been overwritten.");P[a]=b};this.removeBlob=function(a){var b=W.remove(a);runtime.assert(b,"file is not found: "+a);delete P[a]};this.state=d.LOADING;this.rootElement=function(a){var b=document.createElementNS(a.namespaceURI,a.localName), -d;a=new a.Type;for(d in a)a.hasOwnProperty(d)&&(b[d]=a[d]);return b}({Type:odf.ODFDocumentElement,namespaceURI:odf.ODFDocumentElement.namespaceURI,localName:odf.ODFDocumentElement.localName});e===odf.OdfContainer.DocumentType.TEXT?W=V("text"):e===odf.OdfContainer.DocumentType.TEXT_TEMPLATE?W=V("text",!0):e===odf.OdfContainer.DocumentType.PRESENTATION?W=V("presentation"):e===odf.OdfContainer.DocumentType.PRESENTATION_TEMPLATE?W=V("presentation",!0):e===odf.OdfContainer.DocumentType.SPREADSHEET?W=V("spreadsheet"): -e===odf.OdfContainer.DocumentType.SPREADSHEET_TEMPLATE?W=V("spreadsheet",!0):(S=e,W=new core.Zip(S,function(a,b){W=b;a?Z(S,function(b){a&&(W.error=a+"\n"+b,A(d.INVALID))}):R([{path:"styles.xml",handler:B},{path:"content.xml",handler:E},{path:"meta.xml",handler:H},{path:"settings.xml",handler:I},{path:"META-INF/manifest.xml",handler:Q}])}))};odf.OdfContainer.EMPTY=0;odf.OdfContainer.LOADING=1;odf.OdfContainer.DONE=2;odf.OdfContainer.INVALID=3;odf.OdfContainer.SAVING=4;odf.OdfContainer.MODIFIED=5;odf.OdfContainer.getContainer= -function(a){return new odf.OdfContainer(a,null)}})();odf.OdfContainer.DocumentType={TEXT:1,TEXT_TEMPLATE:2,PRESENTATION:3,PRESENTATION_TEMPLATE:4,SPREADSHEET:5,SPREADSHEET_TEMPLATE:6};gui.AnnotatableCanvas=function(){};gui.AnnotatableCanvas.prototype.refreshSize=function(){};gui.AnnotatableCanvas.prototype.getZoomLevel=function(){};gui.AnnotatableCanvas.prototype.getSizer=function(){}; -gui.AnnotationViewManager=function(f,l,a,c){function b(a){var b=a.annotationEndElement,e=h.createRange(),c=a.getAttributeNS(odf.Namespaces.officens,"name");b&&(e.setStart(a,a.childNodes.length),e.setEnd(b,0),a=d.getTextNodes(e,!1),a.forEach(function(a){var b;a:{for(b=a.parentNode;b.namespaceURI!==odf.Namespaces.officens||"body"!==b.localName;){if(b.namespaceURI===s&&"webodf-annotationHighlight"===b.className&&b.getAttribute("annotation")===c){b=!0;break a}b=b.parentNode}b=!1}b||(b=h.createElement("span"), -b.className="webodf-annotationHighlight",b.setAttribute("annotation",c),a.parentNode.replaceChild(b,a),b.appendChild(a))}));e.detach()}function k(b){var d=f.getSizer();b?(a.style.display="inline-block",d.style.paddingRight=e.getComputedStyle(a).width):(a.style.display="none",d.style.paddingRight=0);f.refreshSize()}function q(){g.sort(function(a,b){return 0!==(a.compareDocumentPosition(b)&Node.DOCUMENT_POSITION_FOLLOWING)?-1:1})}function p(){var b;for(b=0;b=(k.getBoundingClientRect().top-s.bottom)/d?e.style.top=Math.abs(k.getBoundingClientRect().top-s.bottom)/d+20+"px":e.style.top="0px"):e.style.top="0px";h.style.left= -c.getBoundingClientRect().width/d+"px";var c=h.style,k=h.getBoundingClientRect().left/d,p=h.getBoundingClientRect().top/d,s=e.getBoundingClientRect().left/d,n=e.getBoundingClientRect().top/d,q=0,l=0,q=s-k,q=q*q,l=n-p,l=l*l,k=Math.sqrt(q+l);c.width=k+"px";p=Math.asin((e.getBoundingClientRect().top-h.getBoundingClientRect().top)/(d*parseFloat(h.style.width)));h.style.transform="rotate("+p+"rad)";h.style.MozTransform="rotate("+p+"rad)";h.style.WebkitTransform="rotate("+p+"rad)";h.style.msTransform="rotate("+ -p+"rad)"}}function n(a){var b=g.indexOf(a),d=a.parentNode.parentNode;"div"===d.localName&&(d.parentNode.insertBefore(a,d),d.parentNode.removeChild(d));a=a.getAttributeNS(odf.Namespaces.officens,"name");a=h.querySelectorAll('span.webodf-annotationHighlight[annotation="'+a+'"]');for(var e,d=0;dq||l.bottom>q)f.scrollTop=l.bottom-l.top<=q-b?f.scrollTop+(l.bottom-q):f.scrollTop+(l.top-b);l.leftk&&(f.scrollLeft=l.right-l.left<=k-c?f.scrollLeft+(l.right-k):f.scrollLeft-(c-l.left))}}};(function(){function f(a,k,q,p,n){var g,h=0,d;for(d in a)if(a.hasOwnProperty(d)){if(h===q){g=d;break}h+=1}g?k.getPartData(a[g].href,function(d,h){if(d)runtime.log(d);else if(h){var m="@font-face { font-family: "+(a[g].family||g)+"; src: url(data:application/x-font-ttf;charset=binary;base64,"+c.convertUTF8ArrayToBase64(h)+') format("truetype"); }';try{p.insertRule(m,p.cssRules.length)}catch(l){runtime.log("Problem inserting rule in CSS: "+runtime.toJson(l)+"\nRule: "+m)}}else runtime.log("missing font data for "+ -a[g].href);f(a,k,q+1,p,n)}):n&&n()}var l=xmldom.XPath,a=odf.OdfUtils,c=new core.Base64;odf.FontLoader=function(){this.loadFonts=function(b,c){for(var q=b.rootElement.fontFaceDecls;c.cssRules.length;)c.deleteRule(c.cssRules.length-1);if(q){var p={},n,g,h,d;if(q)for(q=l.getODFElementsWithXPath(q,"style:font-face[svg:font-face-src]",odf.Namespaces.lookupNamespaceURI),n=0;n text|list-item:first-child > :not(text|list):first-child:before',w+="{",w+="counter-increment: "+r+" 0;",w+="}",f(a,w));for(;p.counterIdStack.length>=q;)p.counterIdStack.pop();p.counterIdStack.push(r);u=p.contentRules[q.toString()]||"";for(w=1;w<=q;w+=1)u=u.replace(w+"webodf-listLevel",p.counterIdStack[w-1]);w='text|list[webodfhelper|counter-id="'+l+'"] > text|list-item > :not(text|list):first-child:before'; -w+="{";w+=u;w+="counter-increment: "+r+";";w+="}";f(a,w)}for(c=c.firstElementChild;c;)b(e,c,h,p),c=c.nextElementSibling}else p.continuedCounterIdStack=[]}var c=0,d="",e={};this.createCounterRules=function(a,d,f){var k=d.getAttributeNS(q,"id"),p=[];f&&(f=f.getAttributeNS("urn:webodf:names:helper","counter-id"),p=e[f].slice(0));a=new l(a,p);k?k="Y"+k:(c+=1,k="X"+c);b(k,d,0,a);e[k+"-level1-1"]=a.counterIdStack};this.initialiseCreatedCounters=function(){var b;b="office|document{"+("counter-reset: "+d+ -";");b+="}";f(a,b)}}var c=odf.Namespaces.fons,b=odf.Namespaces.stylens,k=odf.Namespaces.textns,q=odf.Namespaces.xmlns,p={1:"decimal",a:"lower-latin",A:"upper-latin",i:"lower-roman",I:"upper-roman"};odf.ListStyleToCss=function(){function n(a){var b=s.parseLength(a);return b?e.convert(b.value,b.unit,"px"):(runtime.log("Could not parse value '"+a+"'."),0)}function g(a){return a.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}function h(a,b){var d;a&&(d=a.getAttributeNS(k,"style-name"));return d===b}function d(d, -e,c){e=e.getElementsByTagNameNS(k,"list");d=new a(d);var f,n,s,l,u,A,F={},B;for(B=0;B text|list-item > text|list",x-=1;x=t&&t.getAttributeNS(c,"text-align")||"left";switch(x){case "end":x="right";break;case "start":x="left"}"label-alignment"===I?(N=Q&&Q.getAttributeNS(c,"margin-left")||"0px",R=Q&&Q.getAttributeNS(c,"text-indent")||"0px",J=Q&&Q.getAttributeNS(k,"label-followed-by"),Q=n(N)):(N=t&&t.getAttributeNS(k,"space-before")||"0px",z=t&&t.getAttributeNS(k,"min-label-width")||"0px", -Y=t&&t.getAttributeNS(k,"min-label-distance")||"0px",Q=n(N)+n(z));t=q+" > text|list-item";t+="{";t+="margin-left: "+Q+"px;";t+="}";f(h,t);t=q+" > text|list-item > text|list";t+="{";t+="margin-left: "+-Q+"px;";t+="}";f(h,t);t=q+" > text|list-item > :not(text|list):first-child:before";t+="{";t+="text-align: "+x+";";t+="display: inline-block;";"label-alignment"===I?(t+="margin-left: "+R+";","listtab"===J&&(t+="padding-right: 0.2cm;")):(t+="min-width: "+z+";",t+="margin-left: "+(0===parseFloat(z)?"": -"-")+z+";",t+="padding-right: "+Y+";");t+="}";f(h,t)}e=e.nextElementSibling}});d(a,h,g)}}})();odf.LazyStyleProperties=function(f,l){var a={};this.value=function(c){var b;a.hasOwnProperty(c)?b=a[c]:(b=l[c](),void 0===b&&f&&(b=f.value(c)),a[c]=b);return b};this.reset=function(c){f=c;a={}}}; -odf.StyleParseUtils=function(){function f(a){var c,b;a=(a=/(-?[0-9]*[0-9][0-9]*(\.[0-9]*)?|0+\.[0-9]*[1-9][0-9]*|\.[0-9]*[1-9][0-9]*)((cm)|(mm)|(in)|(pt)|(pc)|(px))/.exec(a))?{value:parseFloat(a[1]),unit:a[3]}:null;b=a&&a.unit;"px"===b?c=a.value:"cm"===b?c=96*(a.value/2.54):"mm"===b?c=96*(a.value/25.4):"in"===b?c=96*a.value:"pt"===b?c=a.value/0.75:"pc"===b&&(c=16*a.value);return c}var l=odf.Namespaces.stylens;this.parseLength=f;this.parsePositiveLengthOrPercent=function(a,c,b){var k;a&&(k=parseFloat(a.substr(0, -a.indexOf("%"))),isNaN(k)&&(k=void 0));var q;void 0!==k?(b&&(q=b.value(c)),k=void 0===q?void 0:k*(q/100)):k=f(a);return k};this.getPropertiesElement=function(a,c,b){for(c=b?b.nextElementSibling:c.firstElementChild;null!==c&&(c.localName!==a||c.namespaceURI!==l);)c=c.nextElementSibling;return c};this.parseAttributeList=function(a){a&&(a=a.replace(/^\s*(.*?)\s*$/g,"$1"));return a&&0k.value&&(g="0.75pt"+m);m=g}else if(z.hasOwnProperty(c[1])){var g= -a,f=c[0],k=c[1],p=R.parseLength(m),n=void 0,s=void 0,q=void 0,r=void 0,q=void 0;if(p&&"%"===p.unit){n=p.value/100;s=l(g.parentNode);for(r="0";s;){if(q=x.getDirectChild(s,h,"paragraph-properties"))if(q=R.parseLength(q.getAttributeNS(f,k))){if("%"!==q.unit){r=q.value*n+q.unit;break}n*=q.value/100}s=l(s)}m=r}}c[2]&&(d+=c[2]+":"+m+";")}return d}function c(a,b,d,e){return b+b+d+d+e+e}function b(a,d){var e=[a],c=d.derivedStyles;Object.keys(c).forEach(function(a){a=b(a,c[a]);e=e.concat(a)});return e}function k(a, -d,e,c){function g(b,d){var e=[],c;b.forEach(function(a){h.forEach(function(b){e.push('draw|page[webodfhelper|page-style-name="'+b+'"] draw|frame[presentation|class="'+a+'"]')})});0/g,">").replace(/'/g,"'").replace(/"/g,""")}function c(f,n){var g="",r=b.filter?b.filter.acceptNode(n):NodeFilter.FILTER_ACCEPT,q;if(r===NodeFilter.FILTER_ACCEPT&&n.nodeType===Node.ELEMENT_NODE){f.push();q=f.getQName(n);var e,l=n.attributes,a,d,m,h="",y;e="<"+q;a=l.length;for(d=0;d")}if(r===NodeFilter.FILTER_ACCEPT||r===NodeFilter.FILTER_SKIP){for(r=n.firstChild;r;)g+=c(f,r),r=r.nextSibling;n.nodeValue&&(g+=k(n.nodeValue))}q&&(g+="",f.pop());return g}var b=this;this.filter=null;this.writeToString=function(b,n){if(!b)return"";var k=new g(n);return c(k,b)}}; +(function(){function g(b){var a,d=r.length;for(a=0;ad)break;h=h.nextSibling}b.insertBefore(a,h)}}}var f=new odf.StyleInfo,n=core.DomUtils,p=odf.Namespaces.stylens,r="meta settings scripts font-face-decls styles automatic-styles master-styles body".split(" "), +q=Date.now()+"_webodf_",e=new core.Base64;odf.ODFElement=function(){};odf.ODFDocumentElement=function(){};odf.ODFDocumentElement.prototype=new odf.ODFElement;odf.ODFDocumentElement.prototype.constructor=odf.ODFDocumentElement;odf.ODFDocumentElement.prototype.fontFaceDecls=null;odf.ODFDocumentElement.prototype.manifest=null;odf.ODFDocumentElement.prototype.settings=null;odf.ODFDocumentElement.namespaceURI="urn:oasis:names:tc:opendocument:xmlns:office:1.0";odf.ODFDocumentElement.localName="document"; +odf.AnnotationElement=function(){};odf.OdfPart=function(b,a,d,c){var h=this;this.size=0;this.type=null;this.name=b;this.container=d;this.url=null;this.mimetype=a;this.onstatereadychange=this.document=null;this.EMPTY=0;this.LOADING=1;this.DONE=2;this.state=this.EMPTY;this.data="";this.load=function(){null!==c&&(this.mimetype=a,c.loadAsDataURL(b,a,function(a,d){a&&runtime.log(a);h.url=d;if(h.onchange)h.onchange(h);if(h.onstatereadychange)h.onstatereadychange(h)}))}};odf.OdfPart.prototype.load=function(){}; +odf.OdfPart.prototype.getUrl=function(){return this.data?"data:;base64,"+e.toBase64(this.data):null};odf.OdfContainer=function a(d,m){function h(a){for(var d=a.firstChild,b;d;)b=d.nextSibling,d.nodeType===Node.ELEMENT_NODE?h(d):d.nodeType===Node.PROCESSING_INSTRUCTION_NODE&&a.removeChild(d),d=b}function g(a){var d={},b,c,h=a.ownerDocument.createNodeIterator(a,NodeFilter.SHOW_ELEMENT,null,!1);for(a=h.nextNode();a;)"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===a.namespaceURI&&("annotation"=== +a.localName?(b=a.getAttributeNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0","name"))&&(d.hasOwnProperty(b)?runtime.log("Warning: annotation name used more than once with : '"+b+"'"):d[b]=a):"annotation-end"===a.localName&&((b=a.getAttributeNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0","name"))?d.hasOwnProperty(b)?(c=d[b],c.annotationEndElement?runtime.log("Warning: annotation name used more than once with : '"+b+"'"):c.annotationEndElement= +a):runtime.log("Warning: annotation end without an annotation start, name: '"+b+"'"):runtime.log("Warning: annotation end without a name found"))),a=h.nextNode()}function r(a,d){for(var b=a&&a.firstChild;b;)b.nodeType===Node.ELEMENT_NODE&&b.setAttributeNS("urn:webodf:names:scope","scope",d),b=b.nextSibling}function z(a,d){for(var b=B.rootElement.meta,b=b&&b.firstChild;b&&(b.namespaceURI!==a||b.localName!==d);)b=b.nextSibling;for(b=b&&b.firstChild;b&&b.nodeType!==Node.TEXT_NODE;)b=b.nextSibling;return b? +b.data:null}function w(a){var d={},b;for(a=a.firstChild;a;)a.nodeType===Node.ELEMENT_NODE&&a.namespaceURI===p&&"font-face"===a.localName&&(b=a.getAttributeNS(p,"name"),d[b]=a),a=a.nextSibling;return d}function v(a,d){var b=null,c,h,e;if(a)for(b=a.cloneNode(!0),c=b.firstElementChild;c;)h=c.nextElementSibling,(e=c.getAttributeNS("urn:webodf:names:scope","scope"))&&e!==d&&b.removeChild(c),c=h;return b}function u(a,d){var b,c,h,e=null,m={};if(a)for(d.forEach(function(a){f.collectUsedFontFaces(m,a)}), +e=a.cloneNode(!0),b=e.firstElementChild;b;)c=b.nextElementSibling,h=b.getAttributeNS(p,"name"),m[h]||e.removeChild(b),b=c;return e}function t(a){var d=B.rootElement.ownerDocument,b;if(a){h(a.documentElement);try{b=d.importNode(a.documentElement,!0)}catch(c){}}return b}function A(a){B.state=a;if(B.onchange)B.onchange(B);if(B.onstatereadychange)B.onstatereadychange(B)}function I(a){Q=null;B.rootElement=a;a.fontFaceDecls=n.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","font-face-decls"); +a.styles=n.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","styles");a.automaticStyles=n.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","automatic-styles");a.masterStyles=n.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","master-styles");a.body=n.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","body");a.meta=n.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","meta");a.settings=n.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0", +"settings");a.scripts=n.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","scripts");g(a)}function K(d){var c=t(d),h=B.rootElement,e;c&&"document-styles"===c.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===c.namespaceURI?(h.fontFaceDecls=n.getDirectChild(c,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","font-face-decls"),b(h,h.fontFaceDecls),e=n.getDirectChild(c,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","styles"),h.styles=e||d.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0", +"styles"),b(h,h.styles),e=n.getDirectChild(c,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","automatic-styles"),h.automaticStyles=e||d.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0","automatic-styles"),r(h.automaticStyles,"document-styles"),b(h,h.automaticStyles),c=n.getDirectChild(c,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","master-styles"),h.masterStyles=c||d.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0","master-styles"),b(h,h.masterStyles), +f.prefixStyleNames(h.automaticStyles,q,h.masterStyles)):A(a.INVALID)}function L(d){d=t(d);var c,h,e,m;if(d&&"document-content"===d.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===d.namespaceURI){c=B.rootElement;e=n.getDirectChild(d,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","font-face-decls");if(c.fontFaceDecls&&e){m=c.fontFaceDecls;var g,k,O,q,D={};h=w(m);q=w(e);for(e=e.firstElementChild;e;){g=e.nextElementSibling;if(e.namespaceURI===p&&"font-face"===e.localName)if(k=e.getAttributeNS(p, +"name"),h.hasOwnProperty(k)){if(!e.isEqualNode(h[k])){O=k;for(var y=h,E=q,u=0,W=void 0,W=O=O.replace(/\d+$/,"");y.hasOwnProperty(W)||E.hasOwnProperty(W);)u+=1,W=O+u;O=W;e.setAttributeNS(p,"style:name",O);m.appendChild(e);h[O]=e;delete q[k];D[k]=O}}else m.appendChild(e),h[k]=e,delete q[k];e=g}m=D}else e&&(c.fontFaceDecls=e,b(c,e));h=n.getDirectChild(d,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","automatic-styles");r(h,"document-content");m&&f.changeFontFaceNames(h,m);if(c.automaticStyles&&h)for(m= +h.firstChild;m;)c.automaticStyles.appendChild(m),m=h.firstChild;else h&&(c.automaticStyles=h,b(c,h));d=n.getDirectChild(d,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","body");if(null===d)throw" tag is mising.";c.body=d;b(c,c.body)}else A(a.INVALID)}function E(a){a=t(a);var d;a&&"document-meta"===a.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===a.namespaceURI&&(d=B.rootElement,d.meta=n.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","meta"), +b(d,d.meta))}function N(a){a=t(a);var d;a&&"document-settings"===a.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===a.namespaceURI&&(d=B.rootElement,d.settings=n.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","settings"),b(d,d.settings))}function O(a){a=t(a);var d;if(a&&"manifest"===a.localName&&"urn:oasis:names:tc:opendocument:xmlns:manifest:1.0"===a.namespaceURI)for(d=B.rootElement,d.manifest=a,a=d.manifest.firstElementChild;a;)"file-entry"===a.localName&&"urn:oasis:names:tc:opendocument:xmlns:manifest:1.0"=== +a.namespaceURI&&(M[a.getAttributeNS("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0","full-path")]=a.getAttributeNS("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0","media-type")),a=a.nextElementSibling}function D(a,d,b){a=n.getElementsByTagName(a,d);var c;for(c=0;c'}function P(){var a=new xmldom.LSSerializer,d=R("document-meta");a.filter=new odf.OdfNodeFilter;d+=a.writeToString(B.rootElement.meta,odf.Namespaces.namespaceMap);return d+""}function aa(a,d){var b=document.createElementNS("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0","manifest:file-entry");b.setAttributeNS("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0","manifest:full-path",a);b.setAttributeNS("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0", +"manifest:media-type",d);return b}function S(){var a=runtime.parseXML(''),d=a.documentElement,b=new xmldom.LSSerializer,c;for(c in M)M.hasOwnProperty(c)&&d.appendChild(aa(c,M[c]));b.filter=new odf.OdfNodeFilter;return'\n'+b.writeToString(a,odf.Namespaces.namespaceMap)}function fa(){var a,d,b,c=odf.Namespaces.namespaceMap, +h=new xmldom.LSSerializer,e=R("document-styles");d=v(B.rootElement.automaticStyles,"document-styles");b=B.rootElement.masterStyles.cloneNode(!0);a=u(B.rootElement.fontFaceDecls,[b,B.rootElement.styles,d]);f.removePrefixFromStyleNames(d,q,b);h.filter=new k(b,d);e+=h.writeToString(a,c);e+=h.writeToString(B.rootElement.styles,c);e+=h.writeToString(d,c);e+=h.writeToString(b,c);return e+""}function ha(){var a,d,b=odf.Namespaces.namespaceMap,h=new xmldom.LSSerializer,e=R("document-content"); +d=v(B.rootElement.automaticStyles,"document-content");a=u(B.rootElement.fontFaceDecls,[d]);h.filter=new c(B.rootElement.body,d);e+=h.writeToString(a,b);e+=h.writeToString(d,b);e+=h.writeToString(B.rootElement.body,b);return e+""}function C(d,b){runtime.loadXML(d,function(d,c){if(d)b(d);else if(c){V(c);W(c.documentElement);var h=t(c);h&&"document"===h.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===h.namespaceURI?(I(h),A(a.DONE)):A(a.INVALID)}else b("No DOM was loaded.")})} +function Z(a,d){var c;c=B.rootElement;var h=c.meta;h||(c.meta=h=document.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0","meta"),b(c,h));c=h;a&&n.mapKeyValObjOntoNode(c,a,odf.Namespaces.lookupNamespaceURI);d&&n.removeKeyElementsFromNode(c,d,odf.Namespaces.lookupNamespaceURI)}function ba(d,b){function c(a,d){var b;d||(d=a);b=document.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0",d);f[a]=b;f.appendChild(b)}var h=new core.Zip("",null),e="application/vnd.oasis.opendocument."+ +d+(!0===b?"-template":""),m=runtime.byteArrayFromString(e,"utf8"),f=B.rootElement,g=document.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0",d);h.save("mimetype",m,!1,new Date);c("meta");c("settings");c("scripts");c("fontFaceDecls","font-face-decls");c("styles");c("automaticStyles","automatic-styles");c("masterStyles","master-styles");c("body");f.body.appendChild(g);M["/"]=e;M["settings.xml"]="text/xml";M["meta.xml"]="text/xml";M["styles.xml"]="text/xml";M["content.xml"]="text/xml"; +A(a.DONE);return h}function U(){var a,d=new Date,b="";B.rootElement.settings&&B.rootElement.settings.firstElementChild&&(a=new xmldom.LSSerializer,b=R("document-settings"),a.filter=new odf.OdfNodeFilter,b+=a.writeToString(B.rootElement.settings,odf.Namespaces.namespaceMap),b+="");(a=b)?(a=runtime.byteArrayFromString(a,"utf8"),Y.save("settings.xml",a,!0,d)):Y.remove("settings.xml");b=runtime.getWindow();a="WebODF/"+webodf.Version;b&&(a=a+" "+b.navigator.userAgent);Z({"meta:generator":a}, +null);a=runtime.byteArrayFromString(P(),"utf8");Y.save("meta.xml",a,!0,d);a=runtime.byteArrayFromString(fa(),"utf8");Y.save("styles.xml",a,!0,d);a=runtime.byteArrayFromString(ha(),"utf8");Y.save("content.xml",a,!0,d);a=runtime.byteArrayFromString(S(),"utf8");Y.save("META-INF/manifest.xml",a,!0,d)}function ga(a,d){U();Y.writeAs(a,function(a){d(a)})}var B=this,Y,M={},Q,F="";this.onstatereadychange=m;this.state=this.onchange=null;this.getMetadata=z;this.setRootElement=I;this.getContentElement=function(){var a; +Q||(a=B.rootElement.body,Q=n.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","text")||n.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","presentation")||n.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","spreadsheet"));if(!Q)throw"Could not find content element in .";return Q};this.getDocumentType=function(){var a=B.getContentElement();return a&&a.localName};this.isTemplate=function(){return"-template"===M["/"].substr(-9)}; +this.setIsTemplate=function(a){var d=M["/"],b="-template"===d.substr(-9);a!==b&&(d=a?d+"-template":d.substr(0,d.length-9),M["/"]=d,a=runtime.byteArrayFromString(d,"utf8"),Y.save("mimetype",a,!1,new Date))};this.getPart=function(a){return new odf.OdfPart(a,M[a],B,Y)};this.getPartData=function(a,d){Y.load(a,d)};this.setMetadata=Z;this.incrementEditingCycles=function(){var a=z(odf.Namespaces.metans,"editing-cycles"),a=a?parseInt(a,10):0;isNaN(a)&&(a=0);Z({"meta:editing-cycles":a+1},null);return a+1}; +this.createByteArray=function(a,d){U();Y.createByteArray(a,d)};this.saveAs=ga;this.save=function(a){ga(F,a)};this.getUrl=function(){return F};this.setBlob=function(a,d,b){b=e.convertBase64ToByteArray(b);Y.save(a,b,!1,new Date);M.hasOwnProperty(a)&&runtime.log(a+" has been overwritten.");M[a]=d};this.removeBlob=function(a){var d=Y.remove(a);runtime.assert(d,"file is not found: "+a);delete M[a]};this.state=a.LOADING;this.rootElement=function(a){var d=document.createElementNS(a.namespaceURI,a.localName), +b;a=new a.Type;for(b in a)a.hasOwnProperty(b)&&(d[b]=a[b]);return d}({Type:odf.ODFDocumentElement,namespaceURI:odf.ODFDocumentElement.namespaceURI,localName:odf.ODFDocumentElement.localName});d===odf.OdfContainer.DocumentType.TEXT?Y=ba("text"):d===odf.OdfContainer.DocumentType.TEXT_TEMPLATE?Y=ba("text",!0):d===odf.OdfContainer.DocumentType.PRESENTATION?Y=ba("presentation"):d===odf.OdfContainer.DocumentType.PRESENTATION_TEMPLATE?Y=ba("presentation",!0):d===odf.OdfContainer.DocumentType.SPREADSHEET? +Y=ba("spreadsheet"):d===odf.OdfContainer.DocumentType.SPREADSHEET_TEMPLATE?Y=ba("spreadsheet",!0):(F=d,Y=new core.Zip(F,function(d,b){Y=b;d?C(F,function(b){d&&(Y.error=d+"\n"+b,A(a.INVALID))}):J([{path:"styles.xml",handler:K},{path:"content.xml",handler:L},{path:"meta.xml",handler:E},{path:"settings.xml",handler:N},{path:"META-INF/manifest.xml",handler:O}])}))};odf.OdfContainer.EMPTY=0;odf.OdfContainer.LOADING=1;odf.OdfContainer.DONE=2;odf.OdfContainer.INVALID=3;odf.OdfContainer.SAVING=4;odf.OdfContainer.MODIFIED= +5;odf.OdfContainer.getContainer=function(a){return new odf.OdfContainer(a,null)}})();odf.OdfContainer.DocumentType={TEXT:1,TEXT_TEMPLATE:2,PRESENTATION:3,PRESENTATION_TEMPLATE:4,SPREADSHEET:5,SPREADSHEET_TEMPLATE:6};gui.AnnotatableCanvas=function(){};gui.AnnotatableCanvas.prototype.refreshSize=function(){};gui.AnnotatableCanvas.prototype.getZoomLevel=function(){};gui.AnnotatableCanvas.prototype.getSizer=function(){}; +gui.AnnotationViewManager=function(g,k,c,b){function f(d){var b=d.annotationEndElement,c=l.createRange(),e=d.getAttributeNS(odf.Namespaces.officens,"name");b&&(c.setStart(d,d.childNodes.length),c.setEnd(b,0),d=a.getTextNodes(c,!1),d.forEach(function(a){var d;a:{for(d=a.parentNode;d.namespaceURI!==odf.Namespaces.officens||"body"!==d.localName;){if("http://www.w3.org/1999/xhtml"===d.namespaceURI&&"webodf-annotationHighlight"===d.className&&d.getAttribute("annotation")===e){d=!0;break a}d=d.parentNode}d= +!1}d||(d=l.createElement("span"),d.className="webodf-annotationHighlight",d.setAttribute("annotation",e),a.parentNode.replaceChild(d,a),d.appendChild(a))}));c.detach()}function n(a){var b=g.getSizer();a?(c.style.display="inline-block",b.style.paddingRight=d.getComputedStyle(c).width):(c.style.display="none",b.style.paddingRight=0);g.refreshSize()}function p(){e.sort(function(a,d){return 0!==(a.compareDocumentPosition(d)&Node.DOCUMENT_POSITION_FOLLOWING)?-1:1})}function r(){var a;for(a=0;a=(n.getBoundingClientRect().top-r.bottom)/d?b.style.top=Math.abs(n.getBoundingClientRect().top-r.bottom)/d+20+"px":b.style.top="0px"): +b.style.top="0px";l.style.left=f.getBoundingClientRect().width/d+"px";var f=l.style,n=l.getBoundingClientRect().left/d,k=l.getBoundingClientRect().top/d,r=b.getBoundingClientRect().left/d,p=b.getBoundingClientRect().top/d,q=0,I=0,q=r-n,q=q*q,I=p-k,I=I*I,n=Math.sqrt(q+I);f.width=n+"px";k=Math.asin((b.getBoundingClientRect().top-l.getBoundingClientRect().top)/(d*parseFloat(l.style.width)));l.style.transform="rotate("+k+"rad)";l.style.MozTransform="rotate("+k+"rad)";l.style.WebkitTransform="rotate("+ +k+"rad)";l.style.msTransform="rotate("+k+"rad)"}}function q(a){var d=e.indexOf(a),b=a.parentNode.parentNode;"div"===b.localName&&(b.parentNode.insertBefore(a,b),b.parentNode.removeChild(b));a=a.getAttributeNS(odf.Namespaces.officens,"name");a=l.querySelectorAll('span.webodf-annotationHighlight[annotation="'+a+'"]');for(var c,b=0;bp||k.bottom>p)g.scrollTop=k.bottom-k.top<=p-f?g.scrollTop+(k.bottom-p):g.scrollTop+(k.top-f);k.leftn&&(g.scrollLeft=k.right-k.left<=n-b?g.scrollLeft+(k.right-n):g.scrollLeft-(b-k.left))}}}; +(function(){function g(c,n,k,r,q){var e,l=0,a;for(a in c)if(c.hasOwnProperty(a)){if(l===k){e=a;break}l+=1}e?n.getPartData(c[e].href,function(a,m){if(a)runtime.log(a);else if(m){var h="@font-face { font-family: "+(c[e].family||e)+"; src: url(data:application/x-font-ttf;charset=binary;base64,"+b.convertUTF8ArrayToBase64(m)+') format("truetype"); }';try{r.insertRule(h,r.cssRules.length)}catch(l){runtime.log("Problem inserting rule in CSS: "+runtime.toJson(l)+"\nRule: "+h)}}else runtime.log("missing font data for "+ +c[e].href);g(c,n,k+1,r,q)}):q&&q()}var k=xmldom.XPath,c=odf.OdfUtils,b=new core.Base64;odf.FontLoader=function(){this.loadFonts=function(b,n){for(var p=b.rootElement.fontFaceDecls;n.cssRules.length;)n.deleteRule(n.cssRules.length-1);if(p){var r={},q,e,l,a;if(p)for(p=k.getODFElementsWithXPath(p,"style:font-face[svg:font-face-src]",odf.Namespaces.lookupNamespaceURI),q=0;q text|list-item:first-child > :not(text|list):first-child:before',u+="{",u+="counter-increment: "+p+" 0;",u+="}",g(b,u));for(;l.counterIdStack.length>=k;)l.counterIdStack.pop();l.counterIdStack.push(p);t=l.contentRules[k.toString()]||"";for(u=1;u<=k;u+=1)t=t.replace(u+"webodf-listLevel",l.counterIdStack[u-1]);u='text|list[webodfhelper|counter-id="'+r+'"] > text|list-item > :not(text|list):first-child:before'; +u+="{";u+=t;u+="counter-increment: "+p+";";u+="}";g(b,u)}for(h=h.firstElementChild;h;)c(d,h,f,l),h=h.nextElementSibling}else l.continuedCounterIdStack=[]}var f=0,a="",d={};this.createCounterRules=function(a,b,n){var g=b.getAttributeNS(p,"id"),r=[];n&&(n=n.getAttributeNS("urn:webodf:names:helper","counter-id"),r=d[n].slice(0));a=new k(a,r);g?g="Y"+g:(f+=1,g="X"+f);c(g,b,0,a);d[g+"-level1-1"]=a.counterIdStack};this.initialiseCreatedCounters=function(){var d;d="office|document{"+("counter-reset: "+a+ +";");d+="}";g(b,d)}}var b=odf.Namespaces.fons,f=odf.Namespaces.stylens,n=odf.Namespaces.textns,p=odf.Namespaces.xmlns,r={1:"decimal",a:"lower-latin",A:"upper-latin",i:"lower-roman",I:"upper-roman"};odf.ListStyleToCss=function(){function k(a){var b=m.parseLength(a);return b?d.convert(b.value,b.unit,"px"):(runtime.log("Could not parse value '"+a+"'."),0)}function e(a){return a.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}function l(a,d){var b;a&&(b=a.getAttributeNS(n,"style-name"));return b===d}function a(a, +d,b){d=d.getElementsByTagNameNS(n,"list");a=new c(a);var m,g,k,q,t,A,I={},K;for(K=0;K text|list-item > text|list",--x;x=E&&E.getAttributeNS(b,"text-align")||"left";switch(x){case "end":x="right";break;case "start":x="left"}"label-alignment"===N?(D=O&&O.getAttributeNS(b,"margin-left")||"0px",J=O&&O.getAttributeNS(b,"text-indent")||"0px",R=O&&O.getAttributeNS(n,"label-followed-by"),O=k(D)):(D=E&&E.getAttributeNS(n,"space-before")||"0px",V=E&&E.getAttributeNS(n,"min-label-width")||"0px", +W=E&&E.getAttributeNS(n,"min-label-distance")||"0px",O=k(D)+k(V));E=p+" > text|list-item";E+="{";E+="margin-left: "+O+"px;";E+="}";g(e,E);E=p+" > text|list-item > text|list";E+="{";E+="margin-left: "+-O+"px;";E+="}";g(e,E);E=p+" > text|list-item > :not(text|list):first-child:before";E+="{";E+="text-align: "+x+";";E+="display: inline-block;";"label-alignment"===N?(E+="margin-left: "+J+";","listtab"===R&&(E+="padding-right: 0.2cm;")):(E+="min-width: "+V+";",E+="margin-left: "+(0===parseFloat(V)?"": +"-")+V+";",E+="padding-right: "+W+";");E+="}";g(e,E)}c=c.nextElementSibling}});a(d,e,m)}}})();odf.LazyStyleProperties=function(g,k){var c={};this.value=function(b){var f;c.hasOwnProperty(b)?f=c[b]:(f=k[b](),void 0===f&&g&&(f=g.value(b)),c[b]=f);return f};this.reset=function(b){g=b;c={}}}; +odf.StyleParseUtils=function(){function g(c){var b,f;c=(c=/(-?[0-9]*[0-9][0-9]*(\.[0-9]*)?|0+\.[0-9]*[1-9][0-9]*|\.[0-9]*[1-9][0-9]*)((cm)|(mm)|(in)|(pt)|(pc)|(px))/.exec(c))?{value:parseFloat(c[1]),unit:c[3]}:null;f=c&&c.unit;"px"===f?b=c.value:"cm"===f?b=c.value/2.54*96:"mm"===f?b=c.value/25.4*96:"in"===f?b=96*c.value:"pt"===f?b=c.value/.75:"pc"===f&&(b=16*c.value);return b}var k=odf.Namespaces.stylens;this.parseLength=g;this.parsePositiveLengthOrPercent=function(c,b,f){var n;c&&(n=parseFloat(c.substr(0, +c.indexOf("%"))),isNaN(n)&&(n=void 0));var k;void 0!==n?(f&&(k=f.value(b)),n=void 0===k?void 0:k/100*n):n=g(c);return n};this.getPropertiesElement=function(c,b,f){for(b=f?f.nextElementSibling:b.firstElementChild;null!==b&&(b.localName!==c||b.namespaceURI!==k);)b=b.nextElementSibling;return b};this.parseAttributeList=function(c){c&&(c=c.replace(/^\s*(.*?)\s*$/g,"$1"));return c&&0n.value&&(m="0.75pt"+h);h=m}else if(V.hasOwnProperty(e[1])){var m= +a,f=e[0],n=e[1],g=J.parseLength(h),r=void 0,p=void 0,q=void 0,O=void 0,q=void 0;if(g&&"%"===g.unit){r=g.value/100;p=k(m.parentNode);for(O="0";p;){if(q=y.getDirectChild(p,l,"paragraph-properties"))if(q=J.parseLength(q.getAttributeNS(f,n))){if("%"!==q.unit){O=q.value*r+q.unit;break}r*=q.value/100}p=k(p)}h=O}}e[2]&&(b+=e[2]+":"+h+";")}return b}function b(a,d,b,c){return d+d+b+b+c+c}function f(a,d){var b=[a],c=d.derivedStyles;Object.keys(c).forEach(function(a){a=f(a,c[a]);b=b.concat(a)});return b}function n(a, +d,b,c){function e(d,b){var c=[],h;d.forEach(function(a){m.forEach(function(d){c.push('draw|page[webodfhelper|page-style-name="'+d+'"] draw|frame[presentation|class="'+a+'"]')})});0v&&(b=v);for(d=Math.floor(b/a)*a;!e&&0<=d;)e=m[d],d-=a;for(e=e||y;e.nextBookmark&&e.nextBookmark.steps<= -b;)c.check(),e=e.nextBookmark;runtime.assert(-1===b||e.steps<=b,"Bookmark @"+q(e)+" at step "+e.steps+" exceeds requested step of "+b);return e}function d(a){a.previousBookmark&&(a.previousBookmark.nextBookmark=a.nextBookmark);a.nextBookmark&&(a.nextBookmark.previousBookmark=a.previousBookmark)}function e(a){for(var b,d=null;!d&&a&&a!==l;)(b=n(a))&&(d=x[b])&&d.node!==a&&(runtime.log("Cloned node detected. Creating new bookmark"),d=null,a.removeAttributeNS(s,"nodeId")),a=a.parentNode;return d}var s= -"urn:webodf:names:steps",m={},x={},t=core.DomUtils,y,v,r=Node.DOCUMENT_POSITION_FOLLOWING,w=Node.DOCUMENT_POSITION_PRECEDING,u;this.updateBookmark=function(e,c){var f,k=Math.ceil(e/a)*a,p,s,q;if(void 0!==v&&vp.steps)m[k]=s;u()};this.setToClosestStep=function(a,b){var d;u();d=h(a);d.setIteratorPosition(b); -return d.steps};this.setToClosestDomPoint=function(a,b,d){var c,g;u();if(a===l&&0===b)c=y;else if(a===l&&b===l.childNodes.length)for(g in c=y,m)m.hasOwnProperty(g)&&(a=m[g],a.steps>c.steps&&(c=a));else if(c=e(a.childNodes.item(b)||a),!c)for(d.setUnfilteredPosition(a,b);!c&&d.previousNode();)c=e(d.getCurrentNode());c=c||y;void 0!==v&&c.steps>v&&(c=h(v));c.setIteratorPosition(d);return c.steps};this.damageCacheAfterStep=function(a){0>a&&(a=-1);void 0===v?v=a:ad)throw new RangeError("Requested steps is negative ("+d+")");for(c=q.setToClosestStep(d,l);cn.comparePoints(f,0,d,c),d=f,c=c?0:f.childNodes.length);l.setUnfilteredPosition(d,c);k(l,m)||l.setUnfilteredPosition(d,c);m=l.container();c=l.unfilteredDomOffset();d=q.setToClosestDomPoint(m,c,l);if(0>n.comparePoints(l.container(),l.unfilteredDomOffset(),m,c))return 0=g.textNode.length?null:g.textNode.splitText(g.offset));for(e=g.textNode;e!==d;){e=e.parentNode;s=e.cloneNode(!1);m&&s.appendChild(m);if(x)for(;x&&x.nextSibling;)s.appendChild(x.nextSibling);else for(;e.firstChild;)s.appendChild(e.firstChild);e.parentNode.insertBefore(s,e.nextSibling);x=e;m=s}q.isListItem(m)&&(m=m.childNodes.item(0));k?m.setAttributeNS(p,"text:style-name",k):m.removeAttributeNS(p,"style-name");0===g.textNode.length&& -g.textNode.parentNode.removeChild(g.textNode);a.emit(ops.OdtDocument.signalStepsInserted,{position:c});t&&b&&(a.moveCursor(f,c+1,0),a.emit(ops.Document.signalCursorMoved,t));a.fixCursorPositions();a.getOdfCanvas().refreshSize();a.emit(ops.OdtDocument.signalParagraphChanged,{paragraphElement:h,memberId:f,timeStamp:l});a.emit(ops.OdtDocument.signalParagraphChanged,{paragraphElement:m,memberId:f,timeStamp:l});a.getOdfCanvas().rerenderAnnotations();return!0};this.spec=function(){return{optype:"SplitParagraph", -memberid:f,timestamp:l,position:c,sourceParagraphPosition:a,paragraphStyleName:k,moveCursor:b}}};ops.OpUpdateMember=function(){function f(a){var b="//dc:creator[@editinfo:memberid='"+l+"']";a=xmldom.XPath.getODFElementsWithXPath(a.getRootNode(),b,function(a){return"editinfo"===a?"urn:webodf:names:editinfo":odf.Namespaces.lookupNamespaceURI(a)});for(b=0;b=g.width&&(g=null),f.detach();else if(l.isCharacterElement(b.container)||l.isCharacterFrame(b.container))g=c.getBoundingClientRect(b.container); -return g}var l=odf.OdfUtils,a=new odf.StepUtils,c=core.DomUtils,b=core.StepDirection.NEXT,k=gui.StepInfo.VisualDirection.LEFT_TO_RIGHT,q=gui.StepInfo.VisualDirection.RIGHT_TO_LEFT;this.getContentRect=f;this.moveToFilteredStep=function(a,c,g){function h(a,b){b.process(v,m,x)&&(a=!0,!t&&b.token&&(t=b.token));return a}var d=c===b,e,l,m,x,t,y=a.snapshot();e=!1;var v;do e=f(a),v={token:a.snapshot(),container:a.container,offset:a.offset,direction:c,visualDirection:c===b?k:q},l=a.nextStep()?f(a):null,a.restore(v.token), -d?(m=e,x=l):(m=l,x=e),e=g.reduce(h,!1);while(!e&&a.advanceStep(c));e||g.forEach(function(a){!t&&a.token&&(t=a.token)});a.restore(t||y);return Boolean(t)}};gui.Caret=function(f,l,a,c){function b(){h.style.opacity="0"===h.style.opacity?"1":"0";w.trigger()}function k(){m.selectNodeContents(s);return m.getBoundingClientRect()}function q(){Object.keys(B).forEach(function(a){E[a]=B[a]})}function p(){if(!1===B.isShown||f.getSelectionType()!==ops.OdtCursor.RangeSelection||!c&&!f.getSelectedRange().collapsed)B.visibility="hidden",h.style.visibility="hidden",w.cancel();else if(B.visibility="visible",h.style.visibility="visible",!1===B.isFocused)h.style.opacity= -"1",w.cancel();else{if(u||E.visibility!==B.visibility)h.style.opacity="1",w.cancel();w.trigger()}if(F||A){var a;a=f.getNode();var b,m,p=t.getBoundingClientRect(x.getSizer()),n=!1,s=0;a.removeAttributeNS("urn:webodf:names:cursor","caret-sizer-active");if(0a.height&&(a={top:a.top-(8-a.height)/2,height:8,right:a.right});g.style.height=a.height+"px";g.style.top=a.top+"px";g.style.left=a.right- -a.width+"px";g.style.width=a.width?a.width+"px":"";e&&(a=runtime.getWindow().getComputedStyle(f.getNode(),null),a.font?e.style.font=a.font:(e.style.fontStyle=a.fontStyle,e.style.fontVariant=a.fontVariant,e.style.fontWeight=a.fontWeight,e.style.fontSize=a.fontSize,e.style.lineHeight=a.lineHeight,e.style.fontFamily=a.fontFamily))}B.isShown&&A&&l.scrollIntoView(h.getBoundingClientRect());E.isFocused!==B.isFocused&&d.markAsFocussed(B.isFocused);q();F=A=u=!1}function n(a){g.parentNode.removeChild(g);s.parentNode.removeChild(s); -a()}var g,h,d,e,s,m,x=f.getDocument().getCanvas(),t=core.DomUtils,y=new gui.GuiStepUtils,v,r,w,u=!1,A=!1,F=!1,B={isFocused:!1,isShown:!0,visibility:"hidden"},E={isFocused:!B.isFocused,isShown:!B.isShown,visibility:"hidden"};this.handleUpdate=function(){F=!0;r.trigger()};this.refreshCursorBlinking=function(){u=!0;r.trigger()};this.setFocus=function(){B.isFocused=!0;r.trigger()};this.removeFocus=function(){B.isFocused=!1;r.trigger()};this.show=function(){B.isShown=!0;r.trigger()};this.hide=function(){B.isShown= -!1;r.trigger()};this.setAvatarImageUrl=function(a){d.setImageUrl(a)};this.setColor=function(a){h.style.borderColor=a;d.setColor(a)};this.getCursor=function(){return f};this.getFocusElement=function(){return h};this.toggleHandleVisibility=function(){d.isVisible()?d.hide():d.show()};this.showHandle=function(){d.show()};this.hideHandle=function(){d.hide()};this.setOverlayElement=function(a){e=a;g.appendChild(a);F=!0;r.trigger()};this.ensureVisible=function(){A=!0;r.trigger()};this.getBoundingClientRect= -function(){return t.getBoundingClientRect(g)};this.destroy=function(a){core.Async.destroyAll([r.destroy,w.destroy,d.destroy,n],a)};(function(){var e=f.getDocument(),c=[e.createRootFilter(f.getMemberId()),e.getPositionFilter()],k=e.getDOMDocument();m=k.createRange();s=k.createElement("span");s.className="webodf-caretSizer";s.textContent="|";f.getNode().appendChild(s);g=k.createElement("div");g.setAttributeNS("urn:webodf:names:editinfo","editinfo:memberid",f.getMemberId());g.className="webodf-caretOverlay"; -h=k.createElement("div");h.className="caret";g.appendChild(h);d=new gui.Avatar(g,a);x.getSizer().appendChild(g);v=e.createStepIterator(f.getNode(),0,c,e.getRootNode());r=core.Task.createRedrawTask(p);w=core.Task.createTimeoutTask(b,500);r.triggerImmediate()})()};odf.TextSerializer=function(){function f(c){var b="",k=l.filter?l.filter.acceptNode(c):NodeFilter.FILTER_ACCEPT,q=c.nodeType,p;if((k===NodeFilter.FILTER_ACCEPT||k===NodeFilter.FILTER_SKIP)&&a.isTextContentContainingNode(c))for(p=c.firstChild;p;)b+=f(p),p=p.nextSibling;k===NodeFilter.FILTER_ACCEPT&&(q===Node.ELEMENT_NODE&&a.isParagraph(c)?b+="\n":q===Node.TEXT_NODE&&c.textContent&&(b+=c.textContent));return b}var l=this,a=odf.OdfUtils;this.filter=null;this.writeToString=function(a){if(!a)return""; -a=f(a);"\n"===a[a.length-1]&&(a=a.substr(0,a.length-1));return a}};gui.MimeDataExporter=function(){var f;this.exportRangeToDataTransfer=function(l,a){var c;c=a.startContainer.ownerDocument.createElement("span");c.appendChild(a.cloneContents());c=f.writeToString(c);try{l.setData("text/plain",c)}catch(b){l.setData("Text",c)}};f=new odf.TextSerializer;f.filter=new odf.OdfNodeFilter};gui.Clipboard=function(f){this.setDataFromRange=function(l,a){var c,b=l.clipboardData;c=runtime.getWindow();!b&&c&&(b=c.clipboardData);b?(c=!0,f.exportRangeToDataTransfer(b,a),l.preventDefault()):c=!1;return c}};gui.SessionContext=function(f,l){var a=f.getOdtDocument(),c=odf.OdfUtils;this.isLocalCursorWithinOwnAnnotation=function(){var b=a.getCursor(l),f;if(!b)return!1;f=b&&b.getNode();b=a.getMember(l).getProperties().fullName;return(f=c.getParentAnnotation(f,a.getRootNode()))&&c.getAnnotationCreator(f)===b?!0:!1}};gui.StyleSummary=function(f){function l(a,c){var p=a+"|"+c,l;b.hasOwnProperty(p)||(l=[],f.forEach(function(b){b=(b=b.styleProperties[a])&&b[c];-1===l.indexOf(b)&&l.push(b)}),b[p]=l);return b[p]}function a(a,b,c){return function(){var f=l(a,b);return c.length>=f.length&&f.every(function(a){return-1!==c.indexOf(a)})}}function c(a,b){var c=l(a,b);return 1===c.length?c[0]:void 0}var b={};this.getPropertyValues=l;this.getCommonValue=c;this.isBold=a("style:text-properties","fo:font-weight",["bold"]);this.isItalic= -a("style:text-properties","fo:font-style",["italic"]);this.hasUnderline=a("style:text-properties","style:text-underline-style",["solid"]);this.hasStrikeThrough=a("style:text-properties","style:text-line-through-style",["solid"]);this.fontSize=function(){var a=c("style:text-properties","fo:font-size");return a&&parseFloat(a)};this.fontName=function(){return c("style:text-properties","style:font-name")};this.isAlignedLeft=a("style:paragraph-properties","fo:text-align",["left","start"]);this.isAlignedCenter= -a("style:paragraph-properties","fo:text-align",["center"]);this.isAlignedRight=a("style:paragraph-properties","fo:text-align",["right","end"]);this.isAlignedJustified=a("style:paragraph-properties","fo:text-align",["justify"]);this.text={isBold:this.isBold,isItalic:this.isItalic,hasUnderline:this.hasUnderline,hasStrikeThrough:this.hasStrikeThrough,fontSize:this.fontSize,fontName:this.fontName};this.paragraph={isAlignedLeft:this.isAlignedLeft,isAlignedCenter:this.isAlignedCenter,isAlignedRight:this.isAlignedRight, -isAlignedJustified:this.isAlignedJustified}};gui.DirectFormattingController=function(f,l,a,c,b,k,q){function p(){return V.value().styleSummary}function n(){return V.value().enabledFeatures}function g(a){var b;a.collapsed?(b=a.startContainer,b.hasChildNodes()&&a.startOffseta.clientWidth||a.scrollHeight>a.clientHeight)&&b.push(new h(a)),a=a.parentNode;b.push(new g(r));return b}function v(){var a; -m()||(a=y(B),t(),B.focus(),a.forEach(function(a){a.restore()}))}var r=runtime.getWindow(),w={beforecut:!0,beforepaste:!0,longpress:!0,drag:!0,dragstop:!0},u={mousedown:!0,mouseup:!0,focus:!0},A={},F={},B,E=f.getCanvas().getElement(),H=this,I={};this.addFilter=function(a,b){d(a,!0).filters.push(b)};this.removeFilter=function(a,b){var e=d(a,!0),c=e.filters.indexOf(b);-1!==c&&e.filters.splice(c,1)};this.subscribe=e;this.unsubscribe=s;this.hasFocus=m;this.focus=v;this.getEventTrap=function(){return B}; -this.setEditing=function(a){var b=m();b&&B.blur();a?B.removeAttribute("readOnly"):B.setAttribute("readOnly","true");b&&v()};this.destroy=function(a){s("touchstart",n);Object.keys(I).forEach(function(a){c(parseInt(a,10))});I.length=0;Object.keys(A).forEach(function(a){A[a].destroy()});A={};s("mousedown",x);s("mouseup",t);s("contextmenu",t);Object.keys(F).forEach(function(a){F[a].destroy()});F={};B.parentNode.removeChild(B);a()};(function(){var b=f.getOdfCanvas().getSizer(),d=b.ownerDocument;runtime.assert(Boolean(r), -"EventManager requires a window object to operate correctly");B=d.createElement("textarea");B.id="eventTrap";B.setAttribute("tabindex","-1");B.setAttribute("readOnly","true");B.setAttribute("rows","1");b.appendChild(B);e("mousedown",x);e("mouseup",t);e("contextmenu",t);A.longpress=new a("longpress",["touchstart","touchmove","touchend"],k);A.drag=new a("drag",["touchstart","touchmove","touchend"],q);A.dragstop=new a("dragstop",["drag","touchend"],p);e("touchstart",n)})()};gui.IOSSafariSupport=function(f){function l(){a.innerHeight!==a.outerHeight&&(c.style.display="none",runtime.requestAnimationFrame(function(){c.style.display="block"}))}var a=runtime.getWindow(),c=f.getEventTrap();this.destroy=function(a){f.unsubscribe("focus",l);c.removeAttribute("autocapitalize");c.style.WebkitTransform="";a()};f.subscribe("focus",l);c.setAttribute("autocapitalize","off");c.style.WebkitTransform="translateX(-10000px)"};gui.HyperlinkController=function(f,l,a,c){function b(){var b=!0;!0===l.getState(gui.CommonConstraints.EDIT.REVIEW_MODE)&&(b=a.isLocalCursorWithinOwnAnnotation());b!==g&&(g=b,n.emit(gui.HyperlinkController.enabledChanged,g))}function k(a){a.getMemberId()===c&&b()}var q=odf.OdfUtils,p=f.getOdtDocument(),n=new core.EventNotifier([gui.HyperlinkController.enabledChanged]),g=!1;this.isEnabled=function(){return g};this.subscribe=function(a,b){n.subscribe(a,b)};this.unsubscribe=function(a,b){n.unsubscribe(a, -b)};this.addHyperlink=function(a,b){if(g){var e=p.getCursorSelection(c),k=new ops.OpApplyHyperlink,m=[];if(0===e.length||b)b=b||a,k=new ops.OpInsertText,k.init({memberid:c,position:e.position,text:b}),e.length=b.length,m.push(k);k=new ops.OpApplyHyperlink;k.init({memberid:c,position:e.position,length:e.length,hyperlink:a});m.push(k);f.enqueue(m)}};this.removeHyperlinks=function(){if(g){var a=p.createPositionIterator(p.getRootNode()),b=p.getCursor(c).getSelectedRange(),e=q.getHyperlinkElements(b), -k=b.collapsed&&1===e.length,m=p.getDOMDocument().createRange(),l=[],n,y;0!==e.length&&(e.forEach(function(a){m.selectNodeContents(a);n=p.convertDomToCursorRange({anchorNode:m.startContainer,anchorOffset:m.startOffset,focusNode:m.endContainer,focusOffset:m.endOffset});y=new ops.OpRemoveHyperlink;y.init({memberid:c,position:n.position,length:n.length});l.push(y)}),k||(k=e[0],-1===b.comparePoint(k,0)&&(m.setStart(k,0),m.setEnd(b.startContainer,b.startOffset),n=p.convertDomToCursorRange({anchorNode:m.startContainer, -anchorOffset:m.startOffset,focusNode:m.endContainer,focusOffset:m.endOffset}),0k.width&&(q=k.width/l.width);l.height>k.height&&(r=k.height/l.height);k=Math.min(q,r);l={width:l.width*k,height:l.height* -k}}k=l.width+"px";l=l.height+"px";var w=g.getOdfCanvas().odfContainer().rootElement.styles,q=a.toLowerCase(),r=p.hasOwnProperty(q)?p[q]:null,u,q=[];runtime.assert(null!==r,"Image type is not supported: "+a);r="Pictures/"+b.generateImageName()+r;u=new ops.OpSetBlob;u.init({memberid:c,filename:r,mimetype:a,content:e});q.push(u);d.getStyleElement("Graphics","graphic",[w])||(a=new ops.OpAddStyle,a.init({memberid:c,styleName:"Graphics",styleFamily:"graphic",isAutomaticStyle:!1,setProperties:{"style:graphic-properties":{"text:anchor-type":"paragraph", -"svg:x":"0cm","svg:y":"0cm","style:wrap":"dynamic","style:number-wrapped-paragraphs":"no-limit","style:wrap-contour":"false","style:vertical-pos":"top","style:vertical-rel":"paragraph","style:horizontal-pos":"center","style:horizontal-rel":"paragraph"}}}),q.push(a));a=b.generateStyleName();e=new ops.OpAddStyle;e.init({memberid:c,styleName:a,styleFamily:"graphic",isAutomaticStyle:!0,setProperties:{"style:parent-style-name":"Graphics","style:graphic-properties":{"style:vertical-pos":"top","style:vertical-rel":"baseline", -"style:horizontal-pos":"center","style:horizontal-rel":"paragraph","fo:background-color":"transparent","style:background-transparency":"100%","style:shadow":"none","style:mirror":"none","fo:clip":"rect(0cm, 0cm, 0cm, 0cm)","draw:luminance":"0%","draw:contrast":"0%","draw:red":"0%","draw:green":"0%","draw:blue":"0%","draw:gamma":"100%","draw:color-inversion":"false","draw:image-opacity":"100%","draw:color-mode":"standard"}}});q.push(e);u=new ops.OpInsertImage;u.init({memberid:c,position:g.getCursorPosition(c), -filename:r,frameWidth:k,frameHeight:l,frameStyleName:a,frameName:b.generateFrameName()});q.push(u);f.enqueue(q)}};this.destroy=function(a){g.unsubscribe(ops.Document.signalCursorMoved,q);l.unsubscribe(gui.CommonConstraints.EDIT.REVIEW_MODE,k);a()};g.subscribe(ops.Document.signalCursorMoved,q);l.subscribe(gui.CommonConstraints.EDIT.REVIEW_MODE,k);k()};gui.ImageController.enabledChanged="enabled/changed";gui.ImageSelector=function(f){function l(){var a=f.getSizer(),k=b.createElement("div");k.id="imageSelector";k.style.borderWidth="1px";a.appendChild(k);c.forEach(function(a){var c=b.createElement("div");c.className=a;k.appendChild(c)});return k}var a=odf.Namespaces.svgns,c="topLeft topRight bottomRight bottomLeft topMiddle rightMiddle bottomMiddle leftMiddle".split(" "),b=f.getElement().ownerDocument,k=!1;this.select=function(c){var p,n,g=b.getElementById("imageSelector");g||(g=l());k=!0;p=g.parentNode; -n=c.getBoundingClientRect();var h=p.getBoundingClientRect(),d=f.getZoomLevel();p=(n.left-h.left)/d-1;n=(n.top-h.top)/d-1;g.style.display="block";g.style.left=p+"px";g.style.top=n+"px";g.style.width=c.getAttributeNS(a,"width");g.style.height=c.getAttributeNS(a,"height")};this.clearSelection=function(){var a;k&&(a=b.getElementById("imageSelector"))&&(a.style.display="none");k=!1};this.isSelectorElement=function(a){var c=b.getElementById("imageSelector");return c?a===c||a.parentNode===c:!1}};(function(){function f(f){function a(a){q=a.which&&String.fromCharCode(a.which)===k;k=void 0;return!1===q}function c(){q=!1}function b(a){k=a.data;q=!1}var k,q=!1;this.destroy=function(k){f.unsubscribe("textInput",c);f.unsubscribe("compositionend",b);f.removeFilter("keypress",a);k()};f.subscribe("textInput",c);f.subscribe("compositionend",b);f.addFilter("keypress",a)}gui.InputMethodEditor=function(l,a){function c(a){e&&(a?e.getNode().setAttributeNS(d,"composing","true"):(e.getNode().removeAttributeNS(d, -"composing"),x.textContent=""))}function b(){y&&(y=!1,c(!1),r.emit(gui.InputMethodEditor.signalCompositionEnd,{data:v}),v="")}function k(){B||(B=!0,b(),e&&e.getSelectedRange().collapsed?s.value="":s.value=u.writeToString(e.getSelectedRange().cloneContents()),s.setSelectionRange(0,s.value.length),B=!1)}function q(){a.hasFocus()&&t.trigger()}function p(){w=void 0;t.cancel();c(!0);y||r.emit(gui.InputMethodEditor.signalCompositionStart,{data:""})}function n(a){a=w=a.data;y=!0;v+=a;t.trigger()}function g(a){a.data!== -w&&(a=a.data,y=!0,v+=a,t.trigger());w=void 0}function h(){x.textContent=s.value}var d="urn:webodf:names:cursor",e=null,s=a.getEventTrap(),m=s.ownerDocument,x,t,y=!1,v="",r=new core.EventNotifier([gui.InputMethodEditor.signalCompositionStart,gui.InputMethodEditor.signalCompositionEnd]),w,u,A=[],F,B=!1;this.subscribe=r.subscribe;this.unsubscribe=r.unsubscribe;this.registerCursor=function(b){b.getMemberId()===l&&(e=b,e.getNode().appendChild(x),b.subscribe(ops.OdtCursor.signalCursorUpdated,q),a.subscribe("input", -h),a.subscribe("compositionupdate",h))};this.removeCursor=function(b){e&&b===l&&(e.getNode().removeChild(x),e.unsubscribe(ops.OdtCursor.signalCursorUpdated,q),a.unsubscribe("input",h),a.unsubscribe("compositionupdate",h),e=null)};this.destroy=function(d){a.unsubscribe("compositionstart",p);a.unsubscribe("compositionend",n);a.unsubscribe("textInput",g);a.unsubscribe("keypress",b);a.unsubscribe("focus",k);core.Async.destroyAll(F,d)};(function(){u=new odf.TextSerializer;u.filter=new odf.OdfNodeFilter; -a.subscribe("compositionstart",p);a.subscribe("compositionend",n);a.subscribe("textInput",g);a.subscribe("keypress",b);a.subscribe("focus",k);A.push(new f(a));F=A.map(function(a){return a.destroy});x=m.createElement("span");x.setAttribute("id","composer");t=core.Task.createTimeoutTask(k,1);F.push(t.destroy)})()};gui.InputMethodEditor.signalCompositionStart="input/compositionstart";gui.InputMethodEditor.signalCompositionEnd="input/compositionend"})();gui.MetadataController=function(f,l){function a(a){k.emit(gui.MetadataController.signalMetadataChanged,a)}function c(a){var b=-1===q.indexOf(a);b||runtime.log("Setting "+a+" is restricted.");return b}var b=f.getOdtDocument(),k=new core.EventNotifier([gui.MetadataController.signalMetadataChanged]),q=["dc:creator","dc:date","meta:editing-cycles","meta:editing-duration","meta:document-statistic"];this.setMetadata=function(a,b){var g={},h="",d;a&&Object.keys(a).filter(c).forEach(function(b){g[b]=a[b]}); -b&&(h=b.filter(c).join(","));if(0b:!1}function a(a){null!==a&&!1===l(a)&&(b=Math.abs(a-f))}var c=this,b,k=gui.StepInfo.VisualDirection.LEFT_TO_RIGHT;this.token=void 0;this.process=function(b,f,n){var g,h;b.visualDirection===k?(g=f&&f.right,h=n&&n.left):(g=f&&f.left,h=n&&n.right);if(l(g)||l(h))return!0;if(f||n)a(g),a(h),c.token=b.token;return!1}};gui.LineBoundaryScanner=function(){var f=this,l=null;this.token=void 0;this.process=function(a,c,b){var k;if(k=b)if(l){var q=l;k=Math.min(q.bottom-q.top,b.bottom-b.top);var p=Math.max(q.top,b.top),q=Math.min(q.bottom,b.bottom)-p;k=0.4>=(0b?a.previousSibling:a.nextSibling,d(g)===NodeFilter.FILTER_ACCEPT&&(e=g),a=a.parentNode;return e}function c(a,d){var e;return null===a?s.NO_NEIGHBOUR:q.isCharacterElement(a)?s.SPACE_CHAR:a.nodeType===b||q.isTextSpan(a)||q.isHyperlink(a)?(e=a.textContent.charAt(d()),n.test(e)?s.SPACE_CHAR:p.test(e)?s.PUNCTUATION_CHAR:s.WORD_CHAR):s.OTHER}var b=Node.TEXT_NODE,k=Node.ELEMENT_NODE, -q=odf.OdfUtils,p=/[!-#%-*,-\/:-;?-@\[-\]_{}\u00a1\u00ab\u00b7\u00bb\u00bf;\u00b7\u055a-\u055f\u0589-\u058a\u05be\u05c0\u05c3\u05c6\u05f3-\u05f4\u0609-\u060a\u060c-\u060d\u061b\u061e-\u061f\u066a-\u066d\u06d4\u0700-\u070d\u07f7-\u07f9\u0964-\u0965\u0970\u0df4\u0e4f\u0e5a-\u0e5b\u0f04-\u0f12\u0f3a-\u0f3d\u0f85\u0fd0-\u0fd4\u104a-\u104f\u10fb\u1361-\u1368\u166d-\u166e\u169b-\u169c\u16eb-\u16ed\u1735-\u1736\u17d4-\u17d6\u17d8-\u17da\u1800-\u180a\u1944-\u1945\u19de-\u19df\u1a1e-\u1a1f\u1b5a-\u1b60\u1c3b-\u1c3f\u1c7e-\u1c7f\u2000-\u206e\u207d-\u207e\u208d-\u208e\u3008-\u3009\u2768-\u2775\u27c5-\u27c6\u27e6-\u27ef\u2983-\u2998\u29d8-\u29db\u29fc-\u29fd\u2cf9-\u2cfc\u2cfe-\u2cff\u2e00-\u2e7e\u3000-\u303f\u30a0\u30fb\ua60d-\ua60f\ua673\ua67e\ua874-\ua877\ua8ce-\ua8cf\ua92e-\ua92f\ua95f\uaa5c-\uaa5f\ufd3e-\ufd3f\ufe10-\ufe19\ufe30-\ufe52\ufe54-\ufe61\ufe63\ufe68\ufe6a-\ufe6b\uff01-\uff03\uff05-\uff0a\uff0c-\uff0f\uff1a-\uff1b\uff1f-\uff20\uff3b-\uff3d\uff3f\uff5b\uff5d\uff5f-\uff65]|\ud800[\udd00-\udd01\udf9f\udfd0]|\ud802[\udd1f\udd3f\ude50-\ude58]|\ud809[\udc00-\udc7e]/, -n=/\s/,g=core.PositionFilter.FilterResult.FILTER_ACCEPT,h=core.PositionFilter.FilterResult.FILTER_REJECT,d=odf.WordBoundaryFilter.IncludeWhitespace.TRAILING,e=odf.WordBoundaryFilter.IncludeWhitespace.LEADING,s={NO_NEIGHBOUR:0,SPACE_CHAR:1,PUNCTUATION_CHAR:2,WORD_CHAR:3,OTHER:4};this.acceptPosition=function(b){var f=b.container(),p=b.leftNode(),n=b.rightNode(),q=b.unfilteredDomOffset,r=function(){return b.unfilteredDomOffset()-1};f.nodeType===k&&(null===n&&(n=a(f,1,b.getNodeFilter())),null===p&&(p= -a(f,-1,b.getNodeFilter())));f!==n&&(q=function(){return 0});f!==p&&null!==p&&(r=function(){return p.textContent.length-1});f=c(p,r);n=c(n,q);return f===s.WORD_CHAR&&n===s.WORD_CHAR||f===s.PUNCTUATION_CHAR&&n===s.PUNCTUATION_CHAR||l===d&&f!==s.NO_NEIGHBOUR&&n===s.SPACE_CHAR||l===e&&f===s.SPACE_CHAR&&n!==s.NO_NEIGHBOUR?h:g}};odf.WordBoundaryFilter.IncludeWhitespace={None:0,TRAILING:1,LEADING:2};gui.SelectionController=function(f,l){function a(a){var b=a.spec();if(a.isEdit||b.memberid===l)F=void 0,B.cancel()}function c(){var a=t.getCursor(l).getNode();return t.createStepIterator(a,0,[r,u],t.getRootElement(a))}function b(a,b,d){d=new odf.WordBoundaryFilter(t,d);var e=t.getRootElement(a)||t.getRootNode(),c=t.createRootFilter(e);return t.createStepIterator(a,b,[r,c,d],e)}function k(a,b){return b?{anchorNode:a.startContainer,anchorOffset:a.startOffset,focusNode:a.endContainer,focusOffset:a.endOffset}: -{anchorNode:a.endContainer,anchorOffset:a.endOffset,focusNode:a.startContainer,focusOffset:a.startOffset}}function q(a,b,d){var e=new ops.OpMoveCursor;e.init({memberid:l,position:a,length:b||0,selectionType:d});return e}function p(a,b,d){var e;e=t.getCursor(l);e=k(e.getSelectedRange(),e.hasForwardSelection());e.focusNode=a;e.focusOffset=b;d||(e.anchorNode=e.focusNode,e.anchorOffset=e.focusOffset);a=t.convertDomToCursorRange(e);f.enqueue([q(a.position,a.length)])}function n(a){var d;d=b(a.startContainer, -a.startOffset,E);d.roundToPreviousStep()&&a.setStart(d.container(),d.offset());d=b(a.endContainer,a.endOffset,H);d.roundToNextStep()&&a.setEnd(d.container(),d.offset())}function g(a){var b=v.getParagraphElements(a),d=b[0],b=b[b.length-1];d&&a.setStart(d,0);b&&(v.isParagraph(a.endContainer)&&0===a.endOffset?a.setEndBefore(b):a.setEnd(b,b.childNodes.length))}function h(a,b,d,e){var c,f;e?(c=d.startContainer,f=d.startOffset):(c=d.endContainer,f=d.endOffset);y.containsNode(a,c)||(f=0>y.comparePoints(a, -0,c,f)?0:a.childNodes.length,c=a);a=t.createStepIterator(c,f,b,v.getParagraphElement(c)||a);a.roundToClosestStep()||runtime.assert(!1,"No step found in requested range");e?d.setStart(a.container(),a.offset()):d.setEnd(a.container(),a.offset())}function d(a,b){var d=c();d.advanceStep(a)&&p(d.container(),d.offset(),b)}function e(a,b){var d,e=F,f=[new gui.LineBoundaryScanner,new gui.ParagraphBoundaryScanner];void 0===e&&A&&(e=A());isNaN(e)||(d=c(),w.moveToFilteredStep(d,a,f)&&d.advanceStep(a)&&(f=[new gui.ClosestXOffsetScanner(e), -new gui.LineBoundaryScanner,new gui.ParagraphBoundaryScanner],w.moveToFilteredStep(d,a,f)&&(p(d.container(),d.offset(),b),F=e,B.restart())))}function s(a,b){var d=c(),e=[new gui.LineBoundaryScanner,new gui.ParagraphBoundaryScanner];w.moveToFilteredStep(d,a,e)&&p(d.container(),d.offset(),b)}function m(a,d){var e=t.getCursor(l),e=k(e.getSelectedRange(),e.hasForwardSelection()),e=b(e.focusNode,e.focusOffset,E);e.advanceStep(a)&&p(e.container(),e.offset(),d)}function x(a,b,d){var e=!1,c=t.getCursor(l), -c=k(c.getSelectedRange(),c.hasForwardSelection()),e=t.getRootElement(c.focusNode);runtime.assert(Boolean(e),"SelectionController: Cursor outside root");c=t.createStepIterator(c.focusNode,c.focusOffset,[r,u],e);c.roundToClosestStep();c.advanceStep(a)&&(d=d(c.container()))&&(a===I?(c.setPosition(d,0),e=c.roundToNextStep()):(c.setPosition(d,d.childNodes.length),e=c.roundToPreviousStep()),e&&p(c.container(),c.offset(),b))}var t=f.getOdtDocument(),y=core.DomUtils,v=odf.OdfUtils,r=t.getPositionFilter(), -w=new gui.GuiStepUtils,u=t.createRootFilter(l),A=null,F,B,E=odf.WordBoundaryFilter.IncludeWhitespace.TRAILING,H=odf.WordBoundaryFilter.IncludeWhitespace.LEADING,I=core.StepDirection.PREVIOUS,Q=core.StepDirection.NEXT;this.selectionToRange=function(a){var b=0<=y.comparePoints(a.anchorNode,a.anchorOffset,a.focusNode,a.focusOffset),d=a.focusNode.ownerDocument.createRange();b?(d.setStart(a.anchorNode,a.anchorOffset),d.setEnd(a.focusNode,a.focusOffset)):(d.setStart(a.focusNode,a.focusOffset),d.setEnd(a.anchorNode, -a.anchorOffset));return{range:d,hasForwardSelection:b}};this.rangeToSelection=k;this.selectImage=function(a){var b=t.getRootElement(a),d=t.createRootFilter(b),b=t.createStepIterator(a,0,[d,t.getPositionFilter()],b),e;b.roundToPreviousStep()||runtime.assert(!1,"No walkable position before frame");d=b.container();e=b.offset();b.setPosition(a,a.childNodes.length);b.roundToNextStep()||runtime.assert(!1,"No walkable position after frame");a=t.convertDomToCursorRange({anchorNode:d,anchorOffset:e,focusNode:b.container(), -focusOffset:b.offset()});a=q(a.position,a.length,ops.OdtCursor.RegionSelection);f.enqueue([a])};this.expandToWordBoundaries=n;this.expandToParagraphBoundaries=g;this.selectRange=function(a,b,d){var e=t.getOdfCanvas().getElement(),c,m=[r];c=y.containsNode(e,a.startContainer);e=y.containsNode(e,a.endContainer);if(c||e)if(c&&e&&(2===d?n(a):3<=d&&g(a)),(d=b?t.getRootElement(a.startContainer):t.getRootElement(a.endContainer))||(d=t.getRootNode()),m.push(t.createRootFilter(d)),h(d,m,a,!0),h(d,m,a,!1),a= -k(a,b),b=t.convertDomToCursorRange(a),a=t.getCursorSelection(l),b.position!==a.position||b.length!==a.length)a=q(b.position,b.length,ops.OdtCursor.RangeSelection),f.enqueue([a])};this.moveCursorToLeft=function(){d(I,!1);return!0};this.moveCursorToRight=function(){d(Q,!1);return!0};this.extendSelectionToLeft=function(){d(I,!0);return!0};this.extendSelectionToRight=function(){d(Q,!0);return!0};this.setCaretXPositionLocator=function(a){A=a};this.moveCursorUp=function(){e(I,!1);return!0};this.moveCursorDown= -function(){e(Q,!1);return!0};this.extendSelectionUp=function(){e(I,!0);return!0};this.extendSelectionDown=function(){e(Q,!0);return!0};this.moveCursorBeforeWord=function(){m(I,!1);return!0};this.moveCursorPastWord=function(){m(Q,!1);return!0};this.extendSelectionBeforeWord=function(){m(I,!0);return!0};this.extendSelectionPastWord=function(){m(Q,!0);return!0};this.moveCursorToLineStart=function(){s(I,!1);return!0};this.moveCursorToLineEnd=function(){s(Q,!1);return!0};this.extendSelectionToLineStart= -function(){s(I,!0);return!0};this.extendSelectionToLineEnd=function(){s(Q,!0);return!0};this.extendSelectionToParagraphStart=function(){x(I,!0,v.getParagraphElement);return!0};this.extendSelectionToParagraphEnd=function(){x(Q,!0,v.getParagraphElement);return!0};this.moveCursorToParagraphStart=function(){x(I,!1,v.getParagraphElement);return!0};this.moveCursorToParagraphEnd=function(){x(Q,!1,v.getParagraphElement);return!0};this.moveCursorToDocumentStart=function(){x(I,!1,t.getRootElement);return!0}; -this.moveCursorToDocumentEnd=function(){x(Q,!1,t.getRootElement);return!0};this.extendSelectionToDocumentStart=function(){x(I,!0,t.getRootElement);return!0};this.extendSelectionToDocumentEnd=function(){x(Q,!0,t.getRootElement);return!0};this.extendSelectionToEntireDocument=function(){var a=t.getCursor(l),a=t.getRootElement(a.getNode()),b,d,e;runtime.assert(Boolean(a),"SelectionController: Cursor outside root");e=t.createStepIterator(a,0,[r,u],a);e.roundToClosestStep();b=e.container();d=e.offset(); -e.setPosition(a,a.childNodes.length);e.roundToClosestStep();a=t.convertDomToCursorRange({anchorNode:b,anchorOffset:d,focusNode:e.container(),focusOffset:e.offset()});f.enqueue([q(a.position,a.length)]);return!0};this.destroy=function(b){t.unsubscribe(ops.OdtDocument.signalOperationStart,a);core.Async.destroyAll([B.destroy],b)};(function(){B=core.Task.createTimeoutTask(function(){F=void 0},2E3);t.subscribe(ops.OdtDocument.signalOperationStart,a)})()};gui.TextController=function(f,l,a,c,b,k){function q(){x=!0===l.getState(gui.CommonConstraints.EDIT.REVIEW_MODE)?a.isLocalCursorWithinOwnAnnotation():!0}function p(a){a.getMemberId()===c&&q()}function n(a,b,d){var c=[e.getPositionFilter()];d&&c.push(e.createRootFilter(a.startContainer));d=e.createStepIterator(a.startContainer,a.startOffset,c,b);d.roundToClosestStep()||runtime.assert(!1,"No walkable step found in paragraph element at range start");b=e.convertDomPointToCursorStep(d.container(),d.offset()); -a.collapsed?a=b:(d.setPosition(a.endContainer,a.endOffset),d.roundToClosestStep()||runtime.assert(!1,"No walkable step found in paragraph element at range end"),a=e.convertDomPointToCursorStep(d.container(),d.offset()));return{position:b,length:a-b}}function g(a){var b,d,e,f=s.getParagraphElements(a),g=a.cloneRange(),h=[];b=f[0];1a.length&&(a.position+=a.length,a.length=-a.length);return a}function d(a){if(!x)return!1;var b,d=e.getCursor(c).getSelectedRange().cloneRange(), -m=h(e.getCursorSelection(c)),k;if(0===m.length){m=void 0;b=e.getCursor(c).getNode();k=e.getRootElement(b);var l=[e.getPositionFilter(),e.createRootFilter(k)];k=e.createStepIterator(b,0,l,k);k.roundToClosestStep()&&(a?k.nextStep():k.previousStep())&&(m=h(e.convertDomToCursorRange({anchorNode:b,anchorOffset:0,focusNode:k.container(),focusOffset:k.offset()})),a?(d.setStart(b,0),d.setEnd(k.container(),k.offset())):(d.setStart(k.container(),k.offset()),d.setEnd(b,0)))}m&&f.enqueue(g(d));return void 0!== -m}var e=f.getOdtDocument(),s=odf.OdfUtils,m=core.DomUtils,x=!1,t=odf.Namespaces.textns,y=core.StepDirection.NEXT;this.isEnabled=function(){return x};this.enqueueParagraphSplittingOps=function(){if(!x)return!1;var a=e.getCursor(c),b=a.getSelectedRange(),d=h(e.getCursorSelection(c)),m=[],a=s.getParagraphElement(a.getNode()),l=a.getAttributeNS(t,"style-name")||"";0e.left&&(e=w(c)))b.focusNode=e.container,b.focusOffset=e.offset,d&&(b.anchorNode=b.focusNode,b.anchorOffset=b.focusOffset)}else D.isImage(b.focusNode.firstChild)&&1===b.focusOffset&&D.isCharacterFrame(b.focusNode)&&(e=w(b.focusNode))&&(b.anchorNode=b.focusNode=e.container,b.anchorOffset=b.focusOffset=e.offset);b.anchorNode&&b.focusNode&&(b=X.selectionToRange(b),X.selectRange(b.range,b.hasForwardSelection,0===a.button?a.detail:0));L.focus()}function A(a){var b;if(b=q(a.clientX,a.clientY))a= -b.container,b=b.offset,a={anchorNode:a,anchorOffset:b,focusNode:a,focusOffset:b},a=X.selectionToRange(a),X.selectRange(a.range,a.hasForwardSelection,2),L.focus()}function F(a){var b=k(a),d,e,f;ja.processRequests();ca&&(D.isImage(b)&&D.isCharacterFrame(b.parentNode)&&R.getSelection().isCollapsed?(X.selectImage(b.parentNode),L.focus()):la.isSelectorElement(b)?L.focus():W?(b=c.getSelectedRange(),e=b.collapsed,D.isImage(b.endContainer)&&0===b.endOffset&&D.isCharacterFrame(b.endContainer.parentNode)&& -(f=b.endContainer.parentNode,f=w(f))&&(b.setEnd(f.container,f.offset),e&&b.collapse(!1)),X.selectRange(b,c.hasForwardSelection(),0===a.button?a.detail:0),L.focus()):ta?u(a):(d=T.cloneEvent(a),aa=runtime.setTimeout(function(){u(d)},0)),na=0,W=ca=!1)}function B(b){var d=J.getCursor(a).getSelectedRange();d.collapsed||O.exportRangeToDataTransfer(b.dataTransfer,d)}function E(){ca&&L.focus();na=0;W=ca=!1}function H(a){F(a)}function I(a){var b=k(a),d=null;"annotationRemoveButton"===b.className?(runtime.assert(ea, -"Remove buttons are displayed on annotations while annotation editing is disabled in the controller."),d=b.parentNode.getElementsByTagNameNS(odf.Namespaces.officens,"annotation").item(0),ga.removeAnnotation(d),L.focus()):"webodf-draggable"!==b.getAttribute("class")&&F(a)}function Q(a){(a=a.data)&&(-1===a.indexOf("\n")?ha.insertText(a):pa.paste(a))}function N(a){return function(){a();return!0}}function z(b){return function(d){return J.getCursor(a).getSelectionType()===ops.OdtCursor.RangeSelection? -b(d):!0}}function Y(a){L.unsubscribe("keydown",C.handleEvent);L.unsubscribe("keypress",V.handleEvent);L.unsubscribe("keyup",$.handleEvent);L.unsubscribe("copy",g);L.unsubscribe("mousedown",r);L.unsubscribe("mousemove",ja.trigger);L.unsubscribe("mouseup",I);L.unsubscribe("contextmenu",H);L.unsubscribe("dragstart",B);L.unsubscribe("dragend",E);L.unsubscribe("click",oa.handleClick);L.unsubscribe("longpress",A);L.unsubscribe("drag",t);L.unsubscribe("dragstop",y);J.unsubscribe(ops.OdtDocument.signalOperationEnd, -fa.trigger);J.unsubscribe(ops.Document.signalCursorAdded,ka.registerCursor);J.unsubscribe(ops.Document.signalCursorRemoved,ka.removeCursor);J.unsubscribe(ops.OdtDocument.signalOperationEnd,e);a()}var R=runtime.getWindow(),J=l.getOdtDocument(),G=new gui.SessionConstraints,ba=new gui.SessionContext(l,a),T=core.DomUtils,D=odf.OdfUtils,O=new gui.MimeDataExporter,Z=new gui.Clipboard(O),C=new gui.KeyboardHandler,V=new gui.KeyboardHandler,$=new gui.KeyboardHandler,ca=!1,U=new odf.ObjectNameGenerator(J.getOdfCanvas().odfContainer(), -a),W=!1,P=null,aa,S=null,L=new gui.EventManager(J),ea=b.annotationsEnabled,ga=new gui.AnnotationController(l,G,a),da=new gui.DirectFormattingController(l,G,ba,a,U,b.directTextStylingEnabled,b.directParagraphStylingEnabled),ha=new gui.TextController(l,G,ba,a,da.createCursorStyleOp,da.createParagraphStyleOps),ma=new gui.ImageController(l,G,ba,a,U),la=new gui.ImageSelector(J.getOdfCanvas()),ia=J.createPositionIterator(J.getRootNode()),ja,fa,pa=new gui.PasteController(l,G,ba,a),ka=new gui.InputMethodEditor(a, -L),na=0,oa=new gui.HyperlinkClickHandler(J.getOdfCanvas().getElement,C,$),qa=new gui.HyperlinkController(l,G,ba,a),X=new gui.SelectionController(l,a),ua=new gui.MetadataController(l,a),K=gui.KeyboardHandler.Modifier,M=gui.KeyboardHandler.KeyCode,ra=-1!==R.navigator.appVersion.toLowerCase().indexOf("mac"),ta=-1!==["iPad","iPod","iPhone"].indexOf(R.navigator.platform),sa;runtime.assert(null!==R,"Expected to be run in an environment which has a global window, like a browser.");this.undo=m;this.redo= -x;this.insertLocalCursor=function(){runtime.assert(void 0===l.getOdtDocument().getCursor(a),"Inserting local cursor a second time.");var b=new ops.OpAddCursor;b.init({memberid:a});l.enqueue([b]);L.focus()};this.removeLocalCursor=function(){runtime.assert(void 0!==l.getOdtDocument().getCursor(a),"Removing local cursor without inserting before.");var b=new ops.OpRemoveCursor;b.init({memberid:a});l.enqueue([b])};this.startEditing=function(){ka.subscribe(gui.InputMethodEditor.signalCompositionStart,ha.removeCurrentSelection); -ka.subscribe(gui.InputMethodEditor.signalCompositionEnd,Q);L.subscribe("beforecut",n);L.subscribe("cut",p);L.subscribe("beforepaste",d);L.subscribe("paste",h);S&&S.initialize();L.setEditing(!0);oa.setModifier(ra?K.Meta:K.Ctrl);C.bind(M.Backspace,K.None,N(ha.removeTextByBackspaceKey),!0);C.bind(M.Delete,K.None,ha.removeTextByDeleteKey);C.bind(M.Tab,K.None,z(function(){ha.insertText("\t");return!0}));ra?(C.bind(M.Clear,K.None,ha.removeCurrentSelection),C.bind(M.B,K.Meta,z(da.toggleBold)),C.bind(M.I, -K.Meta,z(da.toggleItalic)),C.bind(M.U,K.Meta,z(da.toggleUnderline)),C.bind(M.L,K.MetaShift,z(da.alignParagraphLeft)),C.bind(M.E,K.MetaShift,z(da.alignParagraphCenter)),C.bind(M.R,K.MetaShift,z(da.alignParagraphRight)),C.bind(M.J,K.MetaShift,z(da.alignParagraphJustified)),ea&&C.bind(M.C,K.MetaShift,ga.addAnnotation),C.bind(M.Z,K.Meta,m),C.bind(M.Z,K.MetaShift,x)):(C.bind(M.B,K.Ctrl,z(da.toggleBold)),C.bind(M.I,K.Ctrl,z(da.toggleItalic)),C.bind(M.U,K.Ctrl,z(da.toggleUnderline)),C.bind(M.L,K.CtrlShift, -z(da.alignParagraphLeft)),C.bind(M.E,K.CtrlShift,z(da.alignParagraphCenter)),C.bind(M.R,K.CtrlShift,z(da.alignParagraphRight)),C.bind(M.J,K.CtrlShift,z(da.alignParagraphJustified)),ea&&C.bind(M.C,K.CtrlAlt,ga.addAnnotation),C.bind(M.Z,K.Ctrl,m),C.bind(M.Z,K.CtrlShift,x));V.setDefault(z(function(a){var b;b=null===a.which||void 0===a.which?String.fromCharCode(a.keyCode):0!==a.which&&0!==a.charCode?String.fromCharCode(a.which):null;return!b||a.altKey||a.ctrlKey||a.metaKey?!1:(ha.insertText(b),!0)})); -V.bind(M.Enter,K.None,z(ha.enqueueParagraphSplittingOps))};this.endEditing=function(){ka.unsubscribe(gui.InputMethodEditor.signalCompositionStart,ha.removeCurrentSelection);ka.unsubscribe(gui.InputMethodEditor.signalCompositionEnd,Q);L.unsubscribe("cut",p);L.unsubscribe("beforecut",n);L.unsubscribe("paste",h);L.unsubscribe("beforepaste",d);L.setEditing(!1);oa.setModifier(K.None);C.bind(M.Backspace,K.None,function(){return!0},!0);C.unbind(M.Delete,K.None);C.unbind(M.Tab,K.None);ra?(C.unbind(M.Clear, -K.None),C.unbind(M.B,K.Meta),C.unbind(M.I,K.Meta),C.unbind(M.U,K.Meta),C.unbind(M.L,K.MetaShift),C.unbind(M.E,K.MetaShift),C.unbind(M.R,K.MetaShift),C.unbind(M.J,K.MetaShift),ea&&C.unbind(M.C,K.MetaShift),C.unbind(M.Z,K.Meta),C.unbind(M.Z,K.MetaShift)):(C.unbind(M.B,K.Ctrl),C.unbind(M.I,K.Ctrl),C.unbind(M.U,K.Ctrl),C.unbind(M.L,K.CtrlShift),C.unbind(M.E,K.CtrlShift),C.unbind(M.R,K.CtrlShift),C.unbind(M.J,K.CtrlShift),ea&&C.unbind(M.C,K.CtrlAlt),C.unbind(M.Z,K.Ctrl),C.unbind(M.Z,K.CtrlShift));V.setDefault(null); -V.unbind(M.Enter,K.None)};this.getInputMemberId=function(){return a};this.getSession=function(){return l};this.getSessionConstraints=function(){return G};this.setUndoManager=function(a){S&&S.unsubscribe(gui.UndoManager.signalUndoStackChanged,s);if(S=a)S.setDocument(J),S.setPlaybackFunction(l.enqueue),S.subscribe(gui.UndoManager.signalUndoStackChanged,s)};this.getUndoManager=function(){return S};this.getMetadataController=function(){return ua};this.getAnnotationController=function(){return ga};this.getDirectFormattingController= -function(){return da};this.getHyperlinkClickHandler=function(){return oa};this.getHyperlinkController=function(){return qa};this.getImageController=function(){return ma};this.getSelectionController=function(){return X};this.getTextController=function(){return ha};this.getEventManager=function(){return L};this.getKeyboardHandlers=function(){return{keydown:C,keypress:V}};this.destroy=function(a){var b=[ja.destroy,fa.destroy,da.destroy,ka.destroy,L.destroy,oa.destroy,qa.destroy,ua.destroy,X.destroy, -ha.destroy,Y];sa&&b.unshift(sa.destroy);runtime.clearTimeout(aa);core.Async.destroyAll(b,a)};ja=core.Task.createRedrawTask(v);fa=core.Task.createRedrawTask(function(){var b=J.getCursor(a);if(b&&b.getSelectionType()===ops.OdtCursor.RegionSelection&&(b=D.getImageElements(b.getSelectedRange())[0])){la.select(b.parentNode);return}la.clearSelection()});C.bind(M.Left,K.None,z(X.moveCursorToLeft));C.bind(M.Right,K.None,z(X.moveCursorToRight));C.bind(M.Up,K.None,z(X.moveCursorUp));C.bind(M.Down,K.None,z(X.moveCursorDown)); -C.bind(M.Left,K.Shift,z(X.extendSelectionToLeft));C.bind(M.Right,K.Shift,z(X.extendSelectionToRight));C.bind(M.Up,K.Shift,z(X.extendSelectionUp));C.bind(M.Down,K.Shift,z(X.extendSelectionDown));C.bind(M.Home,K.None,z(X.moveCursorToLineStart));C.bind(M.End,K.None,z(X.moveCursorToLineEnd));C.bind(M.Home,K.Ctrl,z(X.moveCursorToDocumentStart));C.bind(M.End,K.Ctrl,z(X.moveCursorToDocumentEnd));C.bind(M.Home,K.Shift,z(X.extendSelectionToLineStart));C.bind(M.End,K.Shift,z(X.extendSelectionToLineEnd));C.bind(M.Up, -K.CtrlShift,z(X.extendSelectionToParagraphStart));C.bind(M.Down,K.CtrlShift,z(X.extendSelectionToParagraphEnd));C.bind(M.Home,K.CtrlShift,z(X.extendSelectionToDocumentStart));C.bind(M.End,K.CtrlShift,z(X.extendSelectionToDocumentEnd));ra?(C.bind(M.Left,K.Alt,z(X.moveCursorBeforeWord)),C.bind(M.Right,K.Alt,z(X.moveCursorPastWord)),C.bind(M.Left,K.Meta,z(X.moveCursorToLineStart)),C.bind(M.Right,K.Meta,z(X.moveCursorToLineEnd)),C.bind(M.Home,K.Meta,z(X.moveCursorToDocumentStart)),C.bind(M.End,K.Meta, -z(X.moveCursorToDocumentEnd)),C.bind(M.Left,K.AltShift,z(X.extendSelectionBeforeWord)),C.bind(M.Right,K.AltShift,z(X.extendSelectionPastWord)),C.bind(M.Left,K.MetaShift,z(X.extendSelectionToLineStart)),C.bind(M.Right,K.MetaShift,z(X.extendSelectionToLineEnd)),C.bind(M.Up,K.AltShift,z(X.extendSelectionToParagraphStart)),C.bind(M.Down,K.AltShift,z(X.extendSelectionToParagraphEnd)),C.bind(M.Up,K.MetaShift,z(X.extendSelectionToDocumentStart)),C.bind(M.Down,K.MetaShift,z(X.extendSelectionToDocumentEnd)), -C.bind(M.A,K.Meta,z(X.extendSelectionToEntireDocument))):(C.bind(M.Left,K.Ctrl,z(X.moveCursorBeforeWord)),C.bind(M.Right,K.Ctrl,z(X.moveCursorPastWord)),C.bind(M.Left,K.CtrlShift,z(X.extendSelectionBeforeWord)),C.bind(M.Right,K.CtrlShift,z(X.extendSelectionPastWord)),C.bind(M.A,K.Ctrl,z(X.extendSelectionToEntireDocument)));ta&&(sa=new gui.IOSSafariSupport(L));L.subscribe("keydown",C.handleEvent);L.subscribe("keypress",V.handleEvent);L.subscribe("keyup",$.handleEvent);L.subscribe("copy",g);L.subscribe("mousedown", -r);L.subscribe("mousemove",ja.trigger);L.subscribe("mouseup",I);L.subscribe("contextmenu",H);L.subscribe("dragstart",B);L.subscribe("dragend",E);L.subscribe("click",oa.handleClick);L.subscribe("longpress",A);L.subscribe("drag",t);L.subscribe("dragstop",y);J.subscribe(ops.OdtDocument.signalOperationEnd,fa.trigger);J.subscribe(ops.Document.signalCursorAdded,ka.registerCursor);J.subscribe(ops.Document.signalCursorRemoved,ka.removeCursor);J.subscribe(ops.OdtDocument.signalOperationEnd,e)}})();gui.CaretManager=function(f,l){function a(a){return k.hasOwnProperty(a)?k[a]:null}function c(){return Object.keys(k).map(function(a){return k[a]})}function b(a){var b=k[a];b&&(delete k[a],a===f.getInputMemberId()?(p.unsubscribe(ops.OdtDocument.signalProcessingBatchEnd,b.ensureVisible),p.unsubscribe(ops.Document.signalCursorMoved,b.refreshCursorBlinking),n.unsubscribe("compositionupdate",b.handleUpdate),n.unsubscribe("compositionend",b.handleUpdate),n.unsubscribe("focus",b.setFocus),n.unsubscribe("blur", -b.removeFocus),q.removeEventListener("focus",b.show,!1),q.removeEventListener("blur",b.hide,!1)):p.unsubscribe(ops.OdtDocument.signalProcessingBatchEnd,b.handleUpdate),b.destroy(function(){}))}var k={},q=runtime.getWindow(),p=f.getSession().getOdtDocument(),n=f.getEventManager();this.registerCursor=function(a,b,d){var e=a.getMemberId();a=new gui.Caret(a,l,b,d);k[e]=a;e===f.getInputMemberId()?(runtime.log("Starting to track input on new cursor of "+e),p.subscribe(ops.OdtDocument.signalProcessingBatchEnd, -a.ensureVisible),p.subscribe(ops.Document.signalCursorMoved,a.refreshCursorBlinking),n.subscribe("compositionupdate",a.handleUpdate),n.subscribe("compositionend",a.handleUpdate),n.subscribe("focus",a.setFocus),n.subscribe("blur",a.removeFocus),q.addEventListener("focus",a.show,!1),q.addEventListener("blur",a.hide,!1),a.setOverlayElement(n.getEventTrap())):p.subscribe(ops.OdtDocument.signalProcessingBatchEnd,a.handleUpdate);return a};this.getCaret=a;this.getCarets=c;this.destroy=function(a){var h= -c().map(function(a){return a.destroy});f.getSelectionController().setCaretXPositionLocator(null);p.unsubscribe(ops.Document.signalCursorRemoved,b);k={};core.Async.destroyAll(h,a)};f.getSelectionController().setCaretXPositionLocator(function(){var b=a(f.getInputMemberId()),c;b&&(c=b.getBoundingClientRect());return c?c.right:void 0});p.subscribe(ops.Document.signalCursorRemoved,b)};gui.EditInfoHandle=function(f){var l=[],a,c=f.ownerDocument,b=c.documentElement.namespaceURI;this.setEdits=function(f){l=f;var q,p,n,g;core.DomUtils.removeAllChildNodes(a);for(f=0;fe?(p=a(1,0),n=a(0.5,1E4-e),g=a(0.2,2E4-e)):1E4<=e&&2E4>e?(p=a(0.5,0),g=a(0.2,2E4-e)):p=a(0.2,0)};this.getEdits=function(){return f.getEdits()};this.clearEdits= -function(){f.clearEdits();k.setEdits([]);q.hasAttributeNS("urn:webodf:names:editinfo","editinfo:memberid")&&q.removeAttributeNS("urn:webodf:names:editinfo","editinfo:memberid")};this.getEditInfo=function(){return f};this.show=function(){q.style.display="block"};this.hide=function(){c.hideHandle();q.style.display="none"};this.showHandle=function(){k.show()};this.hideHandle=function(){k.hide()};this.destroy=function(a){runtime.clearTimeout(p);runtime.clearTimeout(n);runtime.clearTimeout(g);b.removeChild(q); -k.destroy(function(b){b?a(b):f.destroy(a)})};(function(){var a=f.getOdtDocument().getDOMDocument();q=a.createElementNS(a.documentElement.namespaceURI,"div");q.setAttribute("class","editInfoMarker");q.onmouseover=function(){c.showHandle()};q.onmouseout=function(){c.hideHandle()};b=f.getNode();b.appendChild(q);k=new gui.EditInfoHandle(b);l||c.hide()})()};gui.HyperlinkTooltipView=function(f,l){var a=core.DomUtils,c=odf.OdfUtils,b=runtime.getWindow(),k,q,p;runtime.assert(null!==b,"Expected to be run in an environment which has a global window, like a browser.");this.showTooltip=function(n){var g=n.target||n.srcElement,h=f.getSizer(),d=f.getZoomLevel(),e;a:{for(;g;){if(c.isHyperlink(g))break a;if(c.isParagraph(g)||c.isInlineRoot(g))break;g=g.parentNode}g=null}if(g){a.containsNode(h,p)||h.appendChild(p);e=q;var s;switch(l()){case gui.KeyboardHandler.Modifier.Ctrl:s= -runtime.tr("Ctrl-click to follow link");break;case gui.KeyboardHandler.Modifier.Meta:s=runtime.tr("\u2318-click to follow link");break;default:s=""}e.textContent=s;k.textContent=c.getHyperlinkTarget(g);p.style.display="block";e=b.innerWidth-p.offsetWidth-15;g=n.clientX>e?e:n.clientX+15;e=b.innerHeight-p.offsetHeight-10;n=n.clientY>e?e:n.clientY+10;h=h.getBoundingClientRect();g=(g-h.left)/d;n=(n-h.top)/d;p.style.left=g+"px";p.style.top=n+"px"}};this.hideTooltip=function(){p.style.display="none"};this.destroy= -function(a){p.parentNode&&p.parentNode.removeChild(p);a()};(function(){var a=f.getElement().ownerDocument;k=a.createElement("span");q=a.createElement("span");k.className="webodf-hyperlinkTooltipLink";q.className="webodf-hyperlinkTooltipText";p=a.createElement("div");p.className="webodf-hyperlinkTooltip";p.appendChild(k);p.appendChild(q);f.getElement().appendChild(p)})()};gui.OdfFieldView=function(f){function l(){var a=odf.OdfSchema.getFields().map(function(a){return a.replace(":","|")}),c=a.join(",\n")+"\n{ background-color: #D0D0D0; }\n",a=a.map(function(a){return a+":empty::after"}).join(",\n")+"\n{ content:' '; white-space: pre; }\n";return c+"\n"+a}var a,c=f.getElement().ownerDocument;this.showFieldHighlight=function(){a.appendChild(c.createTextNode(l()))};this.hideFieldHighlight=function(){for(var b=a.sheet,c=b.cssRules;c.length;)b.deleteRule(c.length-1)};this.destroy= -function(b){a.parentNode&&a.parentNode.removeChild(a);b()};a=function(){var a=c.getElementsByTagName("head").item(0),f=c.createElement("style"),l="";f.type="text/css";f.media="screen, print, handheld, projection";odf.Namespaces.forEachPrefix(function(a,b){l+="@namespace "+a+" url("+b+");\n"});f.appendChild(c.createTextNode(l));a.appendChild(f);return f}()};gui.ShadowCursor=function(f){var l=f.getDOMDocument().createRange(),a=!0;this.removeFromDocument=function(){};this.getMemberId=function(){return gui.ShadowCursor.ShadowCursorMemberId};this.getSelectedRange=function(){return l};this.setSelectedRange=function(c,b){l=c;a=!1!==b};this.hasForwardSelection=function(){return a};this.getDocument=function(){return f};this.getSelectionType=function(){return ops.OdtCursor.RangeSelection};l.setStart(f.getRootNode(),0)};gui.ShadowCursor.ShadowCursorMemberId="";gui.SelectionView=function(f){};gui.SelectionView.prototype.rerender=function(){};gui.SelectionView.prototype.show=function(){};gui.SelectionView.prototype.hide=function(){};gui.SelectionView.prototype.destroy=function(f){};gui.SelectionViewManager=function(f){function l(){return Object.keys(a).map(function(c){return a[c]})}var a={};this.getSelectionView=function(c){return a.hasOwnProperty(c)?a[c]:null};this.getSelectionViews=l;this.removeSelectionView=function(c){a.hasOwnProperty(c)&&(a[c].destroy(function(){}),delete a[c])};this.hideSelectionView=function(c){a.hasOwnProperty(c)&&a[c].hide()};this.showSelectionView=function(c){a.hasOwnProperty(c)&&a[c].show()};this.rerenderSelectionViews=function(){Object.keys(a).forEach(function(c){a[c].rerender()})}; -this.registerCursor=function(c,b){var k=c.getMemberId(),l=new f(c);b?l.show():l.hide();return a[k]=l};this.destroy=function(a){function b(l,p){p?a(p):l .webodf-draggable"), -a=gui.ShadowCursor.ShadowCursorMemberId,e(".webodf-selectionOverlay","{ fill: "+d+"; stroke: "+d+";}",""),e(".webodf-touchEnabled .webodf-selectionOverlay","{ display: block; }"," > .webodf-draggable"))}function g(a){var b,d;for(d in u)u.hasOwnProperty(d)&&(b=u[d],a?b.show():b.hide())}function h(a){b.getCarets().forEach(function(b){a?b.showHandle():b.hideHandle()})}function d(a){var b=a.getMemberId();a=a.getProperties();n(b,a.fullName,a.color)}function e(d){var e=d.getMemberId(),c=a.getOdtDocument().getMember(e).getProperties(); -b.registerCursor(d,H,I);k.registerCursor(d,!0);if(d=b.getCaret(e))d.setAvatarImageUrl(c.imageUrl),d.setColor(c.color);runtime.log("+++ View here +++ eagerly created an Caret for '"+e+"'! +++")}function s(a){a=a.getMemberId();var d=k.getSelectionView(l),e=k.getSelectionView(gui.ShadowCursor.ShadowCursorMemberId),c=b.getCaret(l);a===l?(e.hide(),d&&d.show(),c&&c.show()):a===gui.ShadowCursor.ShadowCursorMemberId&&(e.show(),d&&d.hide(),c&&c.hide())}function m(a){k.removeSelectionView(a)}function x(b){var d= -b.paragraphElement,e=b.memberId;b=b.timeStamp;var c,f="",g=d.getElementsByTagNameNS(w,"editinfo").item(0);g?(f=g.getAttributeNS(w,"id"),c=u[f]):(f=Math.random().toString(),c=new ops.EditInfo(d,a.getOdtDocument()),c=new gui.EditInfoMarker(c,E),g=d.getElementsByTagNameNS(w,"editinfo").item(0),g.setAttributeNS(w,"id",f),u[f]=c);c.addEdit(e,new Date(b));B.trigger()}function t(){var b;r.hasChildNodes()&&core.DomUtils.removeAllChildNodes(r);!0===c.getState(gui.CommonConstraints.EDIT.ANNOTATIONS.ONLY_DELETE_OWN)&& -(b=a.getOdtDocument().getMember(l))&&(b=b.getProperties().fullName,r.appendChild(document.createTextNode(".annotationWrapper:not([creator = '"+b+"']) .annotationRemoveButton { display: none; }")))}function y(a){var b=Object.keys(u).map(function(a){return u[a]});A.unsubscribe(ops.Document.signalMemberAdded,d);A.unsubscribe(ops.Document.signalMemberUpdated,d);A.unsubscribe(ops.Document.signalCursorAdded,e);A.unsubscribe(ops.Document.signalCursorRemoved,m);A.unsubscribe(ops.OdtDocument.signalParagraphChanged, -x);A.unsubscribe(ops.Document.signalCursorMoved,s);A.unsubscribe(ops.OdtDocument.signalParagraphChanged,k.rerenderSelectionViews);A.unsubscribe(ops.OdtDocument.signalTableAdded,k.rerenderSelectionViews);A.unsubscribe(ops.OdtDocument.signalParagraphStyleModified,k.rerenderSelectionViews);c.unsubscribe(gui.CommonConstraints.EDIT.ANNOTATIONS.ONLY_DELETE_OWN,t);A.unsubscribe(ops.Document.signalMemberAdded,t);A.unsubscribe(ops.Document.signalMemberUpdated,t);v.parentNode.removeChild(v);r.parentNode.removeChild(r); -(function Y(d,e){e?a(e):d +z&&(a=z);for(d=Math.floor(a/c)*c;!b&&0<=d;)b=m[d],d-=c;for(b=b||x;b.nextBookmark&&b.nextBookmark.steps<=a;)e.check(),b=b.nextBookmark;runtime.assert(-1===a||b.steps<=a,"Bookmark @"+p(b)+" at step "+b.steps+" exceeds requested step of "+a);return b}function a(a){a.previousBookmark&&(a.previousBookmark.nextBookmark=a.nextBookmark);a.nextBookmark&&(a.nextBookmark.previousBookmark=a.previousBookmark)}function d(a){for(var d,b=null;!b&&a&&a!==k;)(d=q(a))&&(b=h[d])&&b.node!==a&&(runtime.log("Cloned node detected. Creating new bookmark"), +b=null,a.removeAttributeNS("urn:webodf:names:steps","nodeId")),a=a.parentNode;return b}var m={},h={},y=core.DomUtils,x,z,w=Node.DOCUMENT_POSITION_FOLLOWING,v=Node.DOCUMENT_POSITION_PRECEDING;this.updateBookmark=function(d,b){var g,n=Math.ceil(d/c)*c,p,v,E;if(void 0!==z&&zp.steps)m[n]=v;r()};this.setToClosestStep=function(a,d){var b;r();b=l(a);b.setIteratorPosition(d); +return b.steps};this.setToClosestDomPoint=function(a,b,c){var e,h;r();if(a===k&&0===b)e=x;else if(a===k&&b===k.childNodes.length)for(h in e=x,m)m.hasOwnProperty(h)&&(a=m[h],a.steps>e.steps&&(e=a));else if(e=d(a.childNodes.item(b)||a),!e)for(c.setUnfilteredPosition(a,b);!e&&c.previousNode();)e=d(c.getCurrentNode());e=e||x;void 0!==z&&e.steps>z&&(e=l(z));e.setIteratorPosition(c);return e.steps};this.damageCacheAfterStep=function(a){0>a&&(a=-1);void 0===z?z=a:aa)throw new RangeError("Requested steps is negative ("+a+")");for(b=p.setToClosestStep(a,k);bq.comparePoints(g,0,a,b),a=g,b=b?0:g.childNodes.length);k.setUnfilteredPosition(a,b);n(k,h)||k.setUnfilteredPosition(a,b);h=k.container();b=k.unfilteredDomOffset();a=p.setToClosestDomPoint(h,b,k);if(0>q.comparePoints(k.container(),k.unfilteredDomOffset(),h,b))return 0=e.textNode.length?null:e.textNode.splitText(e.offset));for(d=e.textNode;d!==a;){d=d.parentNode;m=d.cloneNode(!1);h&&m.appendChild(h);if(y)for(;y&&y.nextSibling;)m.appendChild(y.nextSibling);else for(;d.firstChild;)m.appendChild(d.firstChild);d.parentNode.insertBefore(m,d.nextSibling);y=d;h=m}p.isListItem(h)&&(h=h.childNodes.item(0));n?h.setAttributeNS(r,"text:style-name",n):h.removeAttributeNS(r,"style-name");0===e.textNode.length&& +e.textNode.parentNode.removeChild(e.textNode);c.emit(ops.OdtDocument.signalStepsInserted,{position:b});x&&f&&(c.moveCursor(g,b+1,0),c.emit(ops.Document.signalCursorMoved,x));c.fixCursorPositions();c.getOdfCanvas().refreshSize();c.emit(ops.OdtDocument.signalParagraphChanged,{paragraphElement:l,memberId:g,timeStamp:k});c.emit(ops.OdtDocument.signalParagraphChanged,{paragraphElement:h,memberId:g,timeStamp:k});c.getOdfCanvas().rerenderAnnotations();return!0};this.spec=function(){return{optype:"SplitParagraph", +memberid:g,timestamp:k,position:b,sourceParagraphPosition:c,paragraphStyleName:n,moveCursor:f}}}; +ops.OpUpdateMember=function(){function g(c){var f="//dc:creator[@editinfo:memberid='"+k+"']";c=xmldom.XPath.getODFElementsWithXPath(c.getRootNode(),f,function(b){return"editinfo"===b?"urn:webodf:names:editinfo":odf.Namespaces.lookupNamespaceURI(b)});for(f=0;f=e.width&&(e=null),g.detach();else if(k.isCharacterElement(f.container)||k.isCharacterFrame(f.container))e=b.getBoundingClientRect(f.container); +return e}var k=odf.OdfUtils,c=new odf.StepUtils,b=core.DomUtils,f=core.StepDirection.NEXT,n=gui.StepInfo.VisualDirection.LEFT_TO_RIGHT,p=gui.StepInfo.VisualDirection.RIGHT_TO_LEFT;this.getContentRect=g;this.moveToFilteredStep=function(b,c,e){function l(a,b){b.process(w,h,k)&&(a=!0,!x&&b.token&&(x=b.token));return a}var a=c===f,d,m,h,k,x,z=b.snapshot();d=!1;var w;do d=g(b),w={token:b.snapshot(),container:b.container,offset:b.offset,direction:c,visualDirection:c===f?n:p},m=b.nextStep()?g(b):null,b.restore(w.token), +a?(h=d,k=m):(h=m,k=d),d=e.reduce(l,!1);while(!d&&b.advanceStep(c));d||e.forEach(function(a){!x&&a.token&&(x=a.token)});b.restore(x||z);return Boolean(x)}}; +gui.Caret=function(g,k,c,b){function f(){a.style.opacity="0"===a.style.opacity?"1":"0";t.trigger()}function n(){y.selectNodeContents(h);return y.getBoundingClientRect()}function p(a){return E[a]!==L[a]}function r(){Object.keys(L).forEach(function(a){E[a]=L[a]})}function q(){if(!1===L.isShown||g.getSelectionType()!==ops.OdtCursor.RangeSelection||!b&&!g.getSelectedRange().collapsed)L.visibility="hidden",a.style.visibility="hidden",t.cancel();else if(L.visibility="visible",a.style.visibility="visible", +!1===L.isFocused)a.style.opacity="1",t.cancel();else{if(A||p("visibility"))a.style.opacity="1",t.cancel();t.trigger()}if(K||I){var c;c=g.getNode();var e,h,f=z.getBoundingClientRect(x.getSizer()),q=!1,y=0;c.removeAttributeNS("urn:webodf:names:cursor","caret-sizer-active");if(0c.height&&(c={top:c.top-(8-c.height)/2,height:8,right:c.right});l.style.height=c.height+"px";l.style.top=c.top+"px"; +l.style.left=c.right-c.width+"px";l.style.width=c.width?c.width+"px":"";m&&(c=runtime.getWindow().getComputedStyle(g.getNode(),null),c.font?m.style.font=c.font:(m.style.fontStyle=c.fontStyle,m.style.fontVariant=c.fontVariant,m.style.fontWeight=c.fontWeight,m.style.fontSize=c.fontSize,m.style.lineHeight=c.lineHeight,m.style.fontFamily=c.fontFamily))}L.isShown&&I&&k.scrollIntoView(a.getBoundingClientRect());p("isFocused")&&d.markAsFocussed(L.isFocused);r();K=I=A=!1}function e(a){l.parentNode.removeChild(l); +h.parentNode.removeChild(h);a()}var l,a,d,m,h,y,x=g.getDocument().getCanvas(),z=core.DomUtils,w=new gui.GuiStepUtils,v,u,t,A=!1,I=!1,K=!1,L={isFocused:!1,isShown:!0,visibility:"hidden"},E={isFocused:!L.isFocused,isShown:!L.isShown,visibility:"hidden"};this.handleUpdate=function(){K=!0;u.trigger()};this.refreshCursorBlinking=function(){A=!0;u.trigger()};this.setFocus=function(){L.isFocused=!0;u.trigger()};this.removeFocus=function(){L.isFocused=!1;u.trigger()};this.show=function(){L.isShown=!0;u.trigger()}; +this.hide=function(){L.isShown=!1;u.trigger()};this.setAvatarImageUrl=function(a){d.setImageUrl(a)};this.setColor=function(b){a.style.borderColor=b;d.setColor(b)};this.getCursor=function(){return g};this.getFocusElement=function(){return a};this.toggleHandleVisibility=function(){d.isVisible()?d.hide():d.show()};this.showHandle=function(){d.show()};this.hideHandle=function(){d.hide()};this.setOverlayElement=function(a){m=a;l.appendChild(a);K=!0;u.trigger()};this.ensureVisible=function(){I=!0;u.trigger()}; +this.getBoundingClientRect=function(){return z.getBoundingClientRect(l)};this.destroy=function(a){core.Async.destroyAll([u.destroy,t.destroy,d.destroy,e],a)};(function(){var b=g.getDocument(),e=[b.createRootFilter(g.getMemberId()),b.getPositionFilter()],m=b.getDOMDocument();y=m.createRange();h=m.createElement("span");h.className="webodf-caretSizer";h.textContent="|";g.getNode().appendChild(h);l=m.createElement("div");l.setAttributeNS("urn:webodf:names:editinfo","editinfo:memberid",g.getMemberId()); +l.className="webodf-caretOverlay";a=m.createElement("div");a.className="caret";l.appendChild(a);d=new gui.Avatar(l,c);x.getSizer().appendChild(l);v=b.createStepIterator(g.getNode(),0,e,b.getRootNode());u=core.Task.createRedrawTask(q);t=core.Task.createTimeoutTask(f,500);u.triggerImmediate()})()}; +odf.TextSerializer=function(){function g(b){var f="",n=k.filter?k.filter.acceptNode(b):NodeFilter.FILTER_ACCEPT,p=b.nodeType,r;if((n===NodeFilter.FILTER_ACCEPT||n===NodeFilter.FILTER_SKIP)&&c.isTextContentContainingNode(b))for(r=b.firstChild;r;)f+=g(r),r=r.nextSibling;n===NodeFilter.FILTER_ACCEPT&&(p===Node.ELEMENT_NODE&&c.isParagraph(b)?f+="\n":p===Node.TEXT_NODE&&b.textContent&&(f+=b.textContent));return f}var k=this,c=odf.OdfUtils;this.filter=null;this.writeToString=function(b){if(!b)return""; +b=g(b);"\n"===b[b.length-1]&&(b=b.substr(0,b.length-1));return b}};gui.MimeDataExporter=function(){var g;this.exportRangeToDataTransfer=function(k,c){var b;b=c.startContainer.ownerDocument.createElement("span");b.appendChild(c.cloneContents());b=g.writeToString(b);try{k.setData("text/plain",b)}catch(f){k.setData("Text",b)}};g=new odf.TextSerializer;g.filter=new odf.OdfNodeFilter}; +gui.Clipboard=function(g){this.setDataFromRange=function(k,c){var b,f=k.clipboardData;b=runtime.getWindow();!f&&b&&(f=b.clipboardData);f?(b=!0,g.exportRangeToDataTransfer(f,c),k.preventDefault()):b=!1;return b}}; +gui.SessionContext=function(g,k){var c=g.getOdtDocument(),b=odf.OdfUtils;this.isLocalCursorWithinOwnAnnotation=function(){var f=c.getCursor(k),g;if(!f)return!1;g=f&&f.getNode();f=c.getMember(k).getProperties().fullName;return(g=b.getParentAnnotation(g,c.getRootNode()))&&b.getAnnotationCreator(g)===f?!0:!1}}; +gui.StyleSummary=function(g){function k(b,c){var k=b+"|"+c,q;f.hasOwnProperty(k)||(q=[],g.forEach(function(e){e=(e=e.styleProperties[b])&&e[c];-1===q.indexOf(e)&&q.push(e)}),f[k]=q);return f[k]}function c(b,c,f){return function(){var g=k(b,c);return f.length>=g.length&&g.every(function(b){return-1!==f.indexOf(b)})}}function b(b,c){var f=k(b,c);return 1===f.length?f[0]:void 0}var f={};this.getPropertyValues=k;this.getCommonValue=b;this.isBold=c("style:text-properties","fo:font-weight",["bold"]);this.isItalic= +c("style:text-properties","fo:font-style",["italic"]);this.hasUnderline=c("style:text-properties","style:text-underline-style",["solid"]);this.hasStrikeThrough=c("style:text-properties","style:text-line-through-style",["solid"]);this.fontSize=function(){var c=b("style:text-properties","fo:font-size");return c&&parseFloat(c)};this.fontName=function(){return b("style:text-properties","style:font-name")};this.isAlignedLeft=c("style:paragraph-properties","fo:text-align",["left","start"]);this.isAlignedCenter= +c("style:paragraph-properties","fo:text-align",["center"]);this.isAlignedRight=c("style:paragraph-properties","fo:text-align",["right","end"]);this.isAlignedJustified=c("style:paragraph-properties","fo:text-align",["justify"]);this.text={isBold:this.isBold,isItalic:this.isItalic,hasUnderline:this.hasUnderline,hasStrikeThrough:this.hasStrikeThrough,fontSize:this.fontSize,fontName:this.fontName};this.paragraph={isAlignedLeft:this.isAlignedLeft,isAlignedCenter:this.isAlignedCenter,isAlignedRight:this.isAlignedRight, +isAlignedJustified:this.isAlignedJustified}}; +gui.DirectFormattingController=function(g,k,c,b,f,n,p){function r(){return U.value().styleSummary}function q(){return U.value().enabledFeatures}function e(a){var b;a.collapsed?(b=a.startContainer,b.hasChildNodes()&&a.startOffseta.clientWidth||a.scrollHeight>a.clientHeight)&&b.push(new l(a)),a=a.parentNode;b.push(new e(v));return b}function w(){var a; +h()||(a=z(K),x(),K.focus(),a.forEach(function(a){a.restore()}))}var v=runtime.getWindow(),u={beforecut:!0,beforepaste:!0,longpress:!0,drag:!0,dragstop:!0},t={mousedown:!0,mouseup:!0,focus:!0},A={},I={},K,L=g.getCanvas().getElement(),E=this,N={};this.addFilter=function(b,d){a(b,!0).filters.push(d)};this.removeFilter=function(b,d){var c=a(b,!0),e=c.filters.indexOf(d);-1!==e&&c.filters.splice(e,1)};this.subscribe=d;this.unsubscribe=m;this.hasFocus=h;this.focus=w;this.getEventTrap=function(){return K}; +this.setEditing=function(a){var b=h();b&&K.blur();a?K.removeAttribute("readOnly"):K.setAttribute("readOnly","true");b&&w()};this.destroy=function(a){m("touchstart",q);Object.keys(N).forEach(function(a){b(parseInt(a,10))});N.length=0;Object.keys(A).forEach(function(a){A[a].destroy()});A={};m("mousedown",y);m("mouseup",x);m("contextmenu",x);Object.keys(I).forEach(function(a){I[a].destroy()});I={};K.parentNode.removeChild(K);a()};(function(){var a=g.getOdfCanvas().getSizer(),b=a.ownerDocument;runtime.assert(Boolean(v), +"EventManager requires a window object to operate correctly");K=b.createElement("textarea");K.id="eventTrap";K.setAttribute("tabindex","-1");K.setAttribute("readOnly","true");K.setAttribute("rows","1");a.appendChild(K);d("mousedown",y);d("mouseup",x);d("contextmenu",x);A.longpress=new c("longpress",["touchstart","touchmove","touchend"],n);A.drag=new c("drag",["touchstart","touchmove","touchend"],p);A.dragstop=new c("dragstop",["drag","touchend"],r);d("touchstart",q)})()}; +gui.IOSSafariSupport=function(g){function k(){c.innerHeight!==c.outerHeight&&(b.style.display="none",runtime.requestAnimationFrame(function(){b.style.display="block"}))}var c=runtime.getWindow(),b=g.getEventTrap();this.destroy=function(c){g.unsubscribe("focus",k);b.removeAttribute("autocapitalize");b.style.WebkitTransform="";c()};g.subscribe("focus",k);b.setAttribute("autocapitalize","off");b.style.WebkitTransform="translateX(-10000px)"}; +gui.HyperlinkController=function(g,k,c,b){function f(){var b=!0;!0===k.getState(gui.CommonConstraints.EDIT.REVIEW_MODE)&&(b=c.isLocalCursorWithinOwnAnnotation());b!==e&&(e=b,q.emit(gui.HyperlinkController.enabledChanged,e))}function n(c){c.getMemberId()===b&&f()}var p=odf.OdfUtils,r=g.getOdtDocument(),q=new core.EventNotifier([gui.HyperlinkController.enabledChanged]),e=!1;this.isEnabled=function(){return e};this.subscribe=function(b,a){q.subscribe(b,a)};this.unsubscribe=function(b,a){q.unsubscribe(b, +a)};this.addHyperlink=function(c,a){if(e){var d=r.getCursorSelection(b),f=new ops.OpApplyHyperlink,h=[];if(0===d.length||a)a=a||c,f=new ops.OpInsertText,f.init({memberid:b,position:d.position,text:a}),d.length=a.length,h.push(f);f=new ops.OpApplyHyperlink;f.init({memberid:b,position:d.position,length:d.length,hyperlink:c});h.push(f);g.enqueue(h)}};this.removeHyperlinks=function(){if(e){var c=r.createPositionIterator(r.getRootNode()),a=r.getCursor(b).getSelectedRange(),d=p.getHyperlinkElements(a), +f=a.collapsed&&1===d.length,h=r.getDOMDocument().createRange(),k=[],n,q;0!==d.length&&(d.forEach(function(a){h.selectNodeContents(a);n=r.convertDomToCursorRange({anchorNode:h.startContainer,anchorOffset:h.startOffset,focusNode:h.endContainer,focusOffset:h.endOffset});q=new ops.OpRemoveHyperlink;q.init({memberid:b,position:n.position,length:n.length});k.push(q)}),f||(f=d[0],-1===a.comparePoint(f,0)&&(h.setStart(f,0),h.setEnd(a.startContainer,a.startOffset),n=r.convertDomToCursorRange({anchorNode:h.startContainer, +anchorOffset:h.startOffset,focusNode:h.endContainer,focusOffset:h.endOffset}),0k.width&&(v=k.width/n.width);n.height>k.height&&(u=k.height/n.height);k=Math.min(v,u);n= +{width:n.width*k,height:n.height*k}}k=p.convert(n.width,"px","cm")+"cm";p=p.convert(n.height,"px","cm")+"cm";u=e.getOdfCanvas().odfContainer().rootElement.styles;n=d.toLowerCase();var v=r.hasOwnProperty(n)?r[n]:null,t;n=[];runtime.assert(null!==v,"Image type is not supported: "+d);v="Pictures/"+f.generateImageName()+v;t=new ops.OpSetBlob;t.init({memberid:b,filename:v,mimetype:d,content:c});n.push(t);a.getStyleElement("Graphics","graphic",[u])||(d=new ops.OpAddStyle,d.init({memberid:b,styleName:"Graphics", +styleFamily:"graphic",isAutomaticStyle:!1,setProperties:{"style:graphic-properties":{"text:anchor-type":"paragraph","svg:x":"0cm","svg:y":"0cm","style:wrap":"dynamic","style:number-wrapped-paragraphs":"no-limit","style:wrap-contour":"false","style:vertical-pos":"top","style:vertical-rel":"paragraph","style:horizontal-pos":"center","style:horizontal-rel":"paragraph"}}}),n.push(d));d=f.generateStyleName();c=new ops.OpAddStyle;c.init({memberid:b,styleName:d,styleFamily:"graphic",isAutomaticStyle:!0, +setProperties:{"style:parent-style-name":"Graphics","style:graphic-properties":{"style:vertical-pos":"top","style:vertical-rel":"baseline","style:horizontal-pos":"center","style:horizontal-rel":"paragraph","fo:background-color":"transparent","style:background-transparency":"100%","style:shadow":"none","style:mirror":"none","fo:clip":"rect(0cm, 0cm, 0cm, 0cm)","draw:luminance":"0%","draw:contrast":"0%","draw:red":"0%","draw:green":"0%","draw:blue":"0%","draw:gamma":"100%","draw:color-inversion":"false", +"draw:image-opacity":"100%","draw:color-mode":"standard"}}});n.push(c);t=new ops.OpInsertImage;t.init({memberid:b,position:e.getCursorPosition(b),filename:v,frameWidth:k,frameHeight:p,frameStyleName:d,frameName:f.generateFrameName()});n.push(t);g.enqueue(n)}};this.destroy=function(a){e.unsubscribe(ops.Document.signalCursorMoved,p);k.unsubscribe(gui.CommonConstraints.EDIT.REVIEW_MODE,n);a()};e.subscribe(ops.Document.signalCursorMoved,p);k.subscribe(gui.CommonConstraints.EDIT.REVIEW_MODE,n);n()}; +gui.ImageController.enabledChanged="enabled/changed"; +gui.ImageSelector=function(g){function k(){var c=g.getSizer(),k=f.createElement("div");k.id="imageSelector";k.style.borderWidth="1px";c.appendChild(k);b.forEach(function(b){var c=f.createElement("div");c.className=b;k.appendChild(c)});return k}var c=odf.Namespaces.svgns,b="topLeft topRight bottomRight bottomLeft topMiddle rightMiddle bottomMiddle leftMiddle".split(" "),f=g.getElement().ownerDocument,n=!1;this.select=function(b){var r,q,e=f.getElementById("imageSelector");e||(e=k());n=!0;r=e.parentNode; +q=b.getBoundingClientRect();var l=r.getBoundingClientRect(),a=g.getZoomLevel();r=(q.left-l.left)/a-1;q=(q.top-l.top)/a-1;e.style.display="block";e.style.left=r+"px";e.style.top=q+"px";e.style.width=b.getAttributeNS(c,"width");e.style.height=b.getAttributeNS(c,"height")};this.clearSelection=function(){var b;n&&(b=f.getElementById("imageSelector"))&&(b.style.display="none");n=!1};this.isSelectorElement=function(b){var c=f.getElementById("imageSelector");return c?b===c||b.parentNode===c:!1}}; +(function(){function g(g){function c(b){p=b.which&&String.fromCharCode(b.which)===n;n=void 0;return!1===p}function b(){p=!1}function f(b){n=b.data;p=!1}var n,p=!1;this.destroy=function(n){g.unsubscribe("textInput",b);g.unsubscribe("compositionend",f);g.removeFilter("keypress",c);n()};g.subscribe("textInput",b);g.subscribe("compositionend",f);g.addFilter("keypress",c)}gui.InputMethodEditor=function(k,c){function b(b){a&&(b?a.getNode().setAttributeNS("urn:webodf:names:cursor","composing","true"):(a.getNode().removeAttributeNS("urn:webodf:names:cursor", +"composing"),h.textContent=""))}function f(){x&&(x=!1,b(!1),w.emit(gui.InputMethodEditor.signalCompositionEnd,{data:z}),z="")}function n(){I||(I=!0,f(),a&&a.getSelectedRange().collapsed?d.value="":d.value=u.writeToString(a.getSelectedRange().cloneContents()),d.setSelectionRange(0,d.value.length),I=!1)}function p(){c.hasFocus()&&y.trigger()}function r(){v=void 0;y.cancel();b(!0);x||w.emit(gui.InputMethodEditor.signalCompositionStart,{data:""})}function q(a){a=v=a.data;x=!0;z+=a;y.trigger()}function e(a){a.data!== +v&&(a=a.data,x=!0,z+=a,y.trigger());v=void 0}function l(){h.textContent=d.value}var a=null,d=c.getEventTrap(),m=d.ownerDocument,h,y,x=!1,z="",w=new core.EventNotifier([gui.InputMethodEditor.signalCompositionStart,gui.InputMethodEditor.signalCompositionEnd]),v,u,t=[],A,I=!1;this.subscribe=w.subscribe;this.unsubscribe=w.unsubscribe;this.registerCursor=function(b){b.getMemberId()===k&&(a=b,a.getNode().appendChild(h),b.subscribe(ops.OdtCursor.signalCursorUpdated,p),c.subscribe("input",l),c.subscribe("compositionupdate", +l))};this.removeCursor=function(b){a&&b===k&&(a.getNode().removeChild(h),a.unsubscribe(ops.OdtCursor.signalCursorUpdated,p),c.unsubscribe("input",l),c.unsubscribe("compositionupdate",l),a=null)};this.destroy=function(a){c.unsubscribe("compositionstart",r);c.unsubscribe("compositionend",q);c.unsubscribe("textInput",e);c.unsubscribe("keypress",f);c.unsubscribe("focus",n);core.Async.destroyAll(A,a)};(function(){u=new odf.TextSerializer;u.filter=new odf.OdfNodeFilter;c.subscribe("compositionstart",r); +c.subscribe("compositionend",q);c.subscribe("textInput",e);c.subscribe("keypress",f);c.subscribe("focus",n);t.push(new g(c));A=t.map(function(a){return a.destroy});h=m.createElement("span");h.setAttribute("id","composer");y=core.Task.createTimeoutTask(n,1);A.push(y.destroy)})()};gui.InputMethodEditor.signalCompositionStart="input/compositionstart";gui.InputMethodEditor.signalCompositionEnd="input/compositionend"})(); +gui.MetadataController=function(g,k){function c(b){n.emit(gui.MetadataController.signalMetadataChanged,b)}function b(b){var c=-1===p.indexOf(b);c||runtime.log("Setting "+b+" is restricted.");return c}var f=g.getOdtDocument(),n=new core.EventNotifier([gui.MetadataController.signalMetadataChanged]),p=["dc:creator","dc:date","meta:editing-cycles","meta:editing-duration","meta:document-statistic"];this.setMetadata=function(c,f){var e={},l="",a;c&&Object.keys(c).filter(b).forEach(function(a){e[a]=c[a]}); +f&&(l=f.filter(b).join(","));if(0f:!1}function c(b){null!==b&&!1===k(b)&&(f=Math.abs(b-g))}var b=this,f,n=gui.StepInfo.VisualDirection.LEFT_TO_RIGHT;this.token=void 0;this.process=function(f,g,q){var e,l;f.visualDirection===n?(e=g&&g.right,l=q&&q.left):(e=g&&g.left,l=q&&q.right);if(k(e)||k(l))return!0;if(g||q)c(e),c(l),b.token=f.token;return!1}}; +gui.LineBoundaryScanner=function(){var g=this,k=null;this.token=void 0;this.process=function(c,b,f){var n;if(n=f)if(k){var p=k;n=Math.min(p.bottom-p.top,f.bottom-f.top);var r=Math.max(p.top,f.top),p=Math.min(p.bottom,f.bottom)-r;n=.4>=(0b?a.previousSibling:a.nextSibling,d(f)===NodeFilter.FILTER_ACCEPT&&(c=f),a=a.parentNode;return c}function b(a,b){var d;return null===a?m.NO_NEIGHBOUR:p.isCharacterElement(a)?m.SPACE_CHAR:a.nodeType===f||p.isTextSpan(a)||p.isHyperlink(a)?(d=a.textContent.charAt(b()),q.test(d)?m.SPACE_CHAR:r.test(d)?m.PUNCTUATION_CHAR:m.WORD_CHAR):m.OTHER}var f=Node.TEXT_NODE,n=Node.ELEMENT_NODE, +p=odf.OdfUtils,r=/[!-#%-*,-\/:-;?-@\[-\]_{}\u00a1\u00ab\u00b7\u00bb\u00bf;\u00b7\u055a-\u055f\u0589-\u058a\u05be\u05c0\u05c3\u05c6\u05f3-\u05f4\u0609-\u060a\u060c-\u060d\u061b\u061e-\u061f\u066a-\u066d\u06d4\u0700-\u070d\u07f7-\u07f9\u0964-\u0965\u0970\u0df4\u0e4f\u0e5a-\u0e5b\u0f04-\u0f12\u0f3a-\u0f3d\u0f85\u0fd0-\u0fd4\u104a-\u104f\u10fb\u1361-\u1368\u166d-\u166e\u169b-\u169c\u16eb-\u16ed\u1735-\u1736\u17d4-\u17d6\u17d8-\u17da\u1800-\u180a\u1944-\u1945\u19de-\u19df\u1a1e-\u1a1f\u1b5a-\u1b60\u1c3b-\u1c3f\u1c7e-\u1c7f\u2000-\u206e\u207d-\u207e\u208d-\u208e\u3008-\u3009\u2768-\u2775\u27c5-\u27c6\u27e6-\u27ef\u2983-\u2998\u29d8-\u29db\u29fc-\u29fd\u2cf9-\u2cfc\u2cfe-\u2cff\u2e00-\u2e7e\u3000-\u303f\u30a0\u30fb\ua60d-\ua60f\ua673\ua67e\ua874-\ua877\ua8ce-\ua8cf\ua92e-\ua92f\ua95f\uaa5c-\uaa5f\ufd3e-\ufd3f\ufe10-\ufe19\ufe30-\ufe52\ufe54-\ufe61\ufe63\ufe68\ufe6a-\ufe6b\uff01-\uff03\uff05-\uff0a\uff0c-\uff0f\uff1a-\uff1b\uff1f-\uff20\uff3b-\uff3d\uff3f\uff5b\uff5d\uff5f-\uff65]|\ud800[\udd00-\udd01\udf9f\udfd0]|\ud802[\udd1f\udd3f\ude50-\ude58]|\ud809[\udc00-\udc7e]/, +q=/\s/,e=core.PositionFilter.FilterResult.FILTER_ACCEPT,l=core.PositionFilter.FilterResult.FILTER_REJECT,a=odf.WordBoundaryFilter.IncludeWhitespace.TRAILING,d=odf.WordBoundaryFilter.IncludeWhitespace.LEADING,m={NO_NEIGHBOUR:0,SPACE_CHAR:1,PUNCTUATION_CHAR:2,WORD_CHAR:3,OTHER:4};this.acceptPosition=function(f){var g=f.container(),p=f.leftNode(),q=f.rightNode(),r=f.unfilteredDomOffset,v=function(){return f.unfilteredDomOffset()-1};g.nodeType===n&&(null===q&&(q=c(g,1,f.getNodeFilter())),null===p&&(p= +c(g,-1,f.getNodeFilter())));g!==q&&(r=function(){return 0});g!==p&&null!==p&&(v=function(){return p.textContent.length-1});g=b(p,v);q=b(q,r);return g===m.WORD_CHAR&&q===m.WORD_CHAR||g===m.PUNCTUATION_CHAR&&q===m.PUNCTUATION_CHAR||k===a&&g!==m.NO_NEIGHBOUR&&q===m.SPACE_CHAR||k===d&&g===m.SPACE_CHAR&&q!==m.NO_NEIGHBOUR?l:e}};odf.WordBoundaryFilter.IncludeWhitespace={None:0,TRAILING:1,LEADING:2}; +gui.SelectionController=function(g,k){function c(a){var b=a.spec();if(a.isEdit||b.memberid===k)I=void 0,K.cancel()}function b(){var a=x.getCursor(k).getNode();return x.createStepIterator(a,0,[v,t],x.getRootElement(a))}function f(a,b,d){d=new odf.WordBoundaryFilter(x,d);var c=x.getRootElement(a)||x.getRootNode(),e=x.createRootFilter(c);return x.createStepIterator(a,b,[v,e,d],c)}function n(a,b){return b?{anchorNode:a.startContainer,anchorOffset:a.startOffset,focusNode:a.endContainer,focusOffset:a.endOffset}: +{anchorNode:a.endContainer,anchorOffset:a.endOffset,focusNode:a.startContainer,focusOffset:a.startOffset}}function p(a,b,d){var c=new ops.OpMoveCursor;c.init({memberid:k,position:a,length:b||0,selectionType:d});return c}function r(a,b,d){var c;c=x.getCursor(k);c=n(c.getSelectedRange(),c.hasForwardSelection());c.focusNode=a;c.focusOffset=b;d||(c.anchorNode=c.focusNode,c.anchorOffset=c.focusOffset);a=x.convertDomToCursorRange(c);g.enqueue([p(a.position,a.length)])}function q(a){var b;b=f(a.startContainer, +a.startOffset,L);b.roundToPreviousStep()&&a.setStart(b.container(),b.offset());b=f(a.endContainer,a.endOffset,E);b.roundToNextStep()&&a.setEnd(b.container(),b.offset())}function e(a){var b=w.getParagraphElements(a),d=b[0],b=b[b.length-1];d&&a.setStart(d,0);b&&(w.isParagraph(a.endContainer)&&0===a.endOffset?a.setEndBefore(b):a.setEnd(b,b.childNodes.length))}function l(a,b,d,c){var e,f;c?(e=d.startContainer,f=d.startOffset):(e=d.endContainer,f=d.endOffset);z.containsNode(a,e)||(f=0>z.comparePoints(a, +0,e,f)?0:a.childNodes.length,e=a);a=x.createStepIterator(e,f,b,w.getParagraphElement(e)||a);a.roundToClosestStep()||runtime.assert(!1,"No step found in requested range");c?d.setStart(a.container(),a.offset()):d.setEnd(a.container(),a.offset())}function a(a,d){var c=b();c.advanceStep(a)&&r(c.container(),c.offset(),d)}function d(a,d){var c,e=I,f=[new gui.LineBoundaryScanner,new gui.ParagraphBoundaryScanner];void 0===e&&A&&(e=A());isNaN(e)||(c=b(),u.moveToFilteredStep(c,a,f)&&c.advanceStep(a)&&(f=[new gui.ClosestXOffsetScanner(e), +new gui.LineBoundaryScanner,new gui.ParagraphBoundaryScanner],u.moveToFilteredStep(c,a,f)&&(r(c.container(),c.offset(),d),I=e,K.restart())))}function m(a,d){var c=b(),e=[new gui.LineBoundaryScanner,new gui.ParagraphBoundaryScanner];u.moveToFilteredStep(c,a,e)&&r(c.container(),c.offset(),d)}function h(a,b){var d=x.getCursor(k),d=n(d.getSelectedRange(),d.hasForwardSelection()),d=f(d.focusNode,d.focusOffset,L);d.advanceStep(a)&&r(d.container(),d.offset(),b)}function y(a,b,d){var c=!1,e=x.getCursor(k), +e=n(e.getSelectedRange(),e.hasForwardSelection()),c=x.getRootElement(e.focusNode);runtime.assert(Boolean(c),"SelectionController: Cursor outside root");e=x.createStepIterator(e.focusNode,e.focusOffset,[v,t],c);e.roundToClosestStep();e.advanceStep(a)&&(d=d(e.container()))&&(a===N?(e.setPosition(d,0),c=e.roundToNextStep()):(e.setPosition(d,d.childNodes.length),c=e.roundToPreviousStep()),c&&r(e.container(),e.offset(),b))}var x=g.getOdtDocument(),z=core.DomUtils,w=odf.OdfUtils,v=x.getPositionFilter(), +u=new gui.GuiStepUtils,t=x.createRootFilter(k),A=null,I,K,L=odf.WordBoundaryFilter.IncludeWhitespace.TRAILING,E=odf.WordBoundaryFilter.IncludeWhitespace.LEADING,N=core.StepDirection.PREVIOUS,O=core.StepDirection.NEXT;this.selectionToRange=function(a){var b=0<=z.comparePoints(a.anchorNode,a.anchorOffset,a.focusNode,a.focusOffset),d=a.focusNode.ownerDocument.createRange();b?(d.setStart(a.anchorNode,a.anchorOffset),d.setEnd(a.focusNode,a.focusOffset)):(d.setStart(a.focusNode,a.focusOffset),d.setEnd(a.anchorNode, +a.anchorOffset));return{range:d,hasForwardSelection:b}};this.rangeToSelection=n;this.selectImage=function(a){var b=x.getRootElement(a),d=x.createRootFilter(b),b=x.createStepIterator(a,0,[d,x.getPositionFilter()],b),c;b.roundToPreviousStep()||runtime.assert(!1,"No walkable position before frame");d=b.container();c=b.offset();b.setPosition(a,a.childNodes.length);b.roundToNextStep()||runtime.assert(!1,"No walkable position after frame");a=x.convertDomToCursorRange({anchorNode:d,anchorOffset:c,focusNode:b.container(), +focusOffset:b.offset()});a=p(a.position,a.length,ops.OdtCursor.RegionSelection);g.enqueue([a])};this.expandToWordBoundaries=q;this.expandToParagraphBoundaries=e;this.selectRange=function(a,b,d){var c=x.getOdfCanvas().getElement(),f,h=[v];f=z.containsNode(c,a.startContainer);c=z.containsNode(c,a.endContainer);if(f||c)if(f&&c&&(2===d?q(a):3<=d&&e(a)),(d=b?x.getRootElement(a.startContainer):x.getRootElement(a.endContainer))||(d=x.getRootNode()),h.push(x.createRootFilter(d)),l(d,h,a,!0),l(d,h,a,!1),a= +n(a,b),b=x.convertDomToCursorRange(a),a=x.getCursorSelection(k),b.position!==a.position||b.length!==a.length)a=p(b.position,b.length,ops.OdtCursor.RangeSelection),g.enqueue([a])};this.moveCursorToLeft=function(){a(N,!1);return!0};this.moveCursorToRight=function(){a(O,!1);return!0};this.extendSelectionToLeft=function(){a(N,!0);return!0};this.extendSelectionToRight=function(){a(O,!0);return!0};this.setCaretXPositionLocator=function(a){A=a};this.moveCursorUp=function(){d(N,!1);return!0};this.moveCursorDown= +function(){d(O,!1);return!0};this.extendSelectionUp=function(){d(N,!0);return!0};this.extendSelectionDown=function(){d(O,!0);return!0};this.moveCursorBeforeWord=function(){h(N,!1);return!0};this.moveCursorPastWord=function(){h(O,!1);return!0};this.extendSelectionBeforeWord=function(){h(N,!0);return!0};this.extendSelectionPastWord=function(){h(O,!0);return!0};this.moveCursorToLineStart=function(){m(N,!1);return!0};this.moveCursorToLineEnd=function(){m(O,!1);return!0};this.extendSelectionToLineStart= +function(){m(N,!0);return!0};this.extendSelectionToLineEnd=function(){m(O,!0);return!0};this.extendSelectionToParagraphStart=function(){y(N,!0,w.getParagraphElement);return!0};this.extendSelectionToParagraphEnd=function(){y(O,!0,w.getParagraphElement);return!0};this.moveCursorToParagraphStart=function(){y(N,!1,w.getParagraphElement);return!0};this.moveCursorToParagraphEnd=function(){y(O,!1,w.getParagraphElement);return!0};this.moveCursorToDocumentStart=function(){y(N,!1,x.getRootElement);return!0}; +this.moveCursorToDocumentEnd=function(){y(O,!1,x.getRootElement);return!0};this.extendSelectionToDocumentStart=function(){y(N,!0,x.getRootElement);return!0};this.extendSelectionToDocumentEnd=function(){y(O,!0,x.getRootElement);return!0};this.extendSelectionToEntireDocument=function(){var a=x.getCursor(k),a=x.getRootElement(a.getNode()),b,d,c;runtime.assert(Boolean(a),"SelectionController: Cursor outside root");c=x.createStepIterator(a,0,[v,t],a);c.roundToClosestStep();b=c.container();d=c.offset(); +c.setPosition(a,a.childNodes.length);c.roundToClosestStep();a=x.convertDomToCursorRange({anchorNode:b,anchorOffset:d,focusNode:c.container(),focusOffset:c.offset()});g.enqueue([p(a.position,a.length)]);return!0};this.destroy=function(a){x.unsubscribe(ops.OdtDocument.signalOperationStart,c);core.Async.destroyAll([K.destroy],a)};(function(){K=core.Task.createTimeoutTask(function(){I=void 0},2E3);x.subscribe(ops.OdtDocument.signalOperationStart,c)})()}; +gui.TextController=function(g,k,c,b,f,n){function p(){y=!0===k.getState(gui.CommonConstraints.EDIT.REVIEW_MODE)?c.isLocalCursorWithinOwnAnnotation():!0}function r(a){a.getMemberId()===b&&p()}function q(a,b,c){var e=[d.getPositionFilter()];c&&e.push(d.createRootFilter(a.startContainer));c=d.createStepIterator(a.startContainer,a.startOffset,e,b);c.roundToClosestStep()||runtime.assert(!1,"No walkable step found in paragraph element at range start");b=d.convertDomPointToCursorStep(c.container(),c.offset()); +a.collapsed?a=b:(c.setPosition(a.endContainer,a.endOffset),c.roundToClosestStep()||runtime.assert(!1,"No walkable step found in paragraph element at range end"),a=d.convertDomPointToCursorStep(c.container(),c.offset()));return{position:b,length:a-b}}function e(a){var d,c,e,f=m.getParagraphElements(a),g=a.cloneRange(),l=[];d=f[0];1a.length&&(a.position+=a.length,a.length=-a.length);return a}function a(a){if(!y)return!1;var c,f=d.getCursor(b).getSelectedRange().cloneRange(), +h=l(d.getCursorSelection(b)),m;if(0===h.length){h=void 0;c=d.getCursor(b).getNode();m=d.getRootElement(c);var k=[d.getPositionFilter(),d.createRootFilter(m)];m=d.createStepIterator(c,0,k,m);m.roundToClosestStep()&&(a?m.nextStep():m.previousStep())&&(h=l(d.convertDomToCursorRange({anchorNode:c,anchorOffset:0,focusNode:m.container(),focusOffset:m.offset()})),a?(f.setStart(c,0),f.setEnd(m.container(),m.offset())):(f.setStart(m.container(),m.offset()),f.setEnd(c,0)))}h&&g.enqueue(e(f));return void 0!== +h}var d=g.getOdtDocument(),m=odf.OdfUtils,h=core.DomUtils,y=!1,x=odf.Namespaces.textns,z=core.StepDirection.NEXT;this.isEnabled=function(){return y};this.enqueueParagraphSplittingOps=function(){if(!y)return!1;var a=d.getCursor(b),c=a.getSelectedRange(),f=l(d.getCursorSelection(b)),h=[],a=m.getParagraphElement(a.getNode()),k=a.getAttributeNS(x,"style-name")||"";0c.left&&(c=v(e)))b.focusNode=c.container,b.focusOffset=c.offset, +d&&(b.anchorNode=b.focusNode,b.anchorOffset=b.focusOffset)}else S.isImage(b.focusNode.firstChild)&&1===b.focusOffset&&S.isCharacterFrame(b.focusNode)&&(c=v(b.focusNode))&&(b.anchorNode=b.focusNode=c.container,b.anchorOffset=b.focusOffset=c.offset);b.anchorNode&&b.focusNode&&(b=T.selectionToRange(b),T.selectRange(b.range,b.hasForwardSelection,0===a.button?a.detail:0));F.focus()}function t(a){var b;if(b=n(a.clientX,a.clientY))a=b.container,b=b.offset,a={anchorNode:a,anchorOffset:b,focusNode:a,focusOffset:b}, +a=T.selectionToRange(a),T.selectRange(a.range,a.hasForwardSelection,2),F.focus()}function A(a){var d=a.target||a.srcElement||null,c,e,f;ma.processRequests();U&&(S.isImage(d)&&S.isCharacterFrame(d.parentNode)&&W.getSelection().isCollapsed?(T.selectImage(d.parentNode),F.focus()):la.isSelectorElement(d)?F.focus():B?(d=b.getSelectedRange(),e=d.collapsed,S.isImage(d.endContainer)&&0===d.endOffset&&S.isCharacterFrame(d.endContainer.parentNode)&&(f=d.endContainer.parentNode,f=v(f))&&(d.setEnd(f.container, +f.offset),e&&d.collapse(!1)),T.selectRange(d,b.hasForwardSelection(),0===a.button?a.detail:0),F.focus()):ua?u(a):(c=aa.cloneEvent(a),M=runtime.setTimeout(function(){u(c)},0)),oa=0,B=U=!1)}function I(a){var b=J.getCursor(c).getSelectedRange();b.collapsed||fa.exportRangeToDataTransfer(a.dataTransfer,b)}function K(){U&&F.focus();oa=0;B=U=!1}function L(a){A(a)}function E(a){var b=a.target||a.srcElement||null,d=null;"annotationRemoveButton"===b.className?(runtime.assert(ja,"Remove buttons are displayed on annotations while annotation editing is disabled in the controller."), +d=b.parentNode.getElementsByTagNameNS(odf.Namespaces.officens,"annotation").item(0),ca.removeAnnotation(d),F.focus()):"webodf-draggable"!==b.getAttribute("class")&&A(a)}function N(a){(a=a.data)&&(-1===a.indexOf("\n")?da.insertText(a):ea.paste(a))}function O(a){return function(){a();return!0}}function D(a){return function(b){return J.getCursor(c).getSelectionType()===ops.OdtCursor.RangeSelection?a(b):!0}}function V(b){F.unsubscribe("keydown",C.handleEvent);F.unsubscribe("keypress",Z.handleEvent);F.unsubscribe("keyup", +ba.handleEvent);F.unsubscribe("copy",q);F.unsubscribe("mousedown",w);F.unsubscribe("mousemove",ma.trigger);F.unsubscribe("mouseup",E);F.unsubscribe("contextmenu",L);F.unsubscribe("dragstart",I);F.unsubscribe("dragend",K);F.unsubscribe("click",pa.handleClick);F.unsubscribe("longpress",t);F.unsubscribe("drag",y);F.unsubscribe("dragstop",x);J.unsubscribe(ops.OdtDocument.signalOperationEnd,na.trigger);J.unsubscribe(ops.Document.signalCursorAdded,ka.registerCursor);J.unsubscribe(ops.Document.signalCursorRemoved, +ka.removeCursor);J.unsubscribe(ops.OdtDocument.signalOperationEnd,a);b()}var W=runtime.getWindow(),J=k.getOdtDocument(),R=new gui.SessionConstraints,P=new gui.SessionContext(k,c),aa=core.DomUtils,S=odf.OdfUtils,fa=new gui.MimeDataExporter,ha=new gui.Clipboard(fa),C=new gui.KeyboardHandler,Z=new gui.KeyboardHandler,ba=new gui.KeyboardHandler,U=!1,ga=new odf.ObjectNameGenerator(J.getOdfCanvas().odfContainer(),c),B=!1,Y=null,M,Q=null,F=new gui.EventManager(J),ja=f.annotationsEnabled,ca=new gui.AnnotationController(k, +R,c),X=new gui.DirectFormattingController(k,R,P,c,ga,f.directTextStylingEnabled,f.directParagraphStylingEnabled),da=new gui.TextController(k,R,P,c,X.createCursorStyleOp,X.createParagraphStyleOps),qa=new gui.ImageController(k,R,P,c,ga),la=new gui.ImageSelector(J.getOdfCanvas()),ia=J.createPositionIterator(J.getRootNode()),ma,na,ea=new gui.PasteController(k,R,P,c),ka=new gui.InputMethodEditor(c,F),oa=0,pa=new gui.HyperlinkClickHandler(J.getOdfCanvas().getElement,C,ba),ta=new gui.HyperlinkController(k, +R,P,c),T=new gui.SelectionController(k,c),va=new gui.MetadataController(k,c),G=gui.KeyboardHandler.Modifier,H=gui.KeyboardHandler.KeyCode,ra=-1!==W.navigator.appVersion.toLowerCase().indexOf("mac"),ua=-1!==["iPad","iPod","iPhone"].indexOf(W.navigator.platform),sa;runtime.assert(null!==W,"Expected to be run in an environment which has a global window, like a browser.");this.undo=m;this.redo=h;this.insertLocalCursor=function(){runtime.assert(void 0===k.getOdtDocument().getCursor(c),"Inserting local cursor a second time."); +var a=new ops.OpAddCursor;a.init({memberid:c});k.enqueue([a]);F.focus()};this.removeLocalCursor=function(){runtime.assert(void 0!==k.getOdtDocument().getCursor(c),"Removing local cursor without inserting before.");var a=new ops.OpRemoveCursor;a.init({memberid:c});k.enqueue([a])};this.startEditing=function(){ka.subscribe(gui.InputMethodEditor.signalCompositionStart,da.removeCurrentSelection);ka.subscribe(gui.InputMethodEditor.signalCompositionEnd,N);F.subscribe("beforecut",r);F.subscribe("cut",p); +F.subscribe("beforepaste",l);F.subscribe("paste",e);Q&&Q.initialize();F.setEditing(!0);pa.setModifier(ra?G.Meta:G.Ctrl);C.bind(H.Backspace,G.None,O(da.removeTextByBackspaceKey),!0);C.bind(H.Delete,G.None,da.removeTextByDeleteKey);C.bind(H.Tab,G.None,D(function(){da.insertText("\t");return!0}));ra?(C.bind(H.Clear,G.None,da.removeCurrentSelection),C.bind(H.B,G.Meta,D(X.toggleBold)),C.bind(H.I,G.Meta,D(X.toggleItalic)),C.bind(H.U,G.Meta,D(X.toggleUnderline)),C.bind(H.L,G.MetaShift,D(X.alignParagraphLeft)), +C.bind(H.E,G.MetaShift,D(X.alignParagraphCenter)),C.bind(H.R,G.MetaShift,D(X.alignParagraphRight)),C.bind(H.J,G.MetaShift,D(X.alignParagraphJustified)),ja&&C.bind(H.C,G.MetaShift,ca.addAnnotation),C.bind(H.Z,G.Meta,m),C.bind(H.Z,G.MetaShift,h)):(C.bind(H.B,G.Ctrl,D(X.toggleBold)),C.bind(H.I,G.Ctrl,D(X.toggleItalic)),C.bind(H.U,G.Ctrl,D(X.toggleUnderline)),C.bind(H.L,G.CtrlShift,D(X.alignParagraphLeft)),C.bind(H.E,G.CtrlShift,D(X.alignParagraphCenter)),C.bind(H.R,G.CtrlShift,D(X.alignParagraphRight)), +C.bind(H.J,G.CtrlShift,D(X.alignParagraphJustified)),ja&&C.bind(H.C,G.CtrlAlt,ca.addAnnotation),C.bind(H.Z,G.Ctrl,m),C.bind(H.Z,G.CtrlShift,h));Z.setDefault(D(function(a){var b;b=null===a.which||void 0===a.which?String.fromCharCode(a.keyCode):0!==a.which&&0!==a.charCode?String.fromCharCode(a.which):null;return!b||a.altKey||a.ctrlKey||a.metaKey?!1:(da.insertText(b),!0)}));Z.bind(H.Enter,G.None,D(da.enqueueParagraphSplittingOps))};this.endEditing=function(){ka.unsubscribe(gui.InputMethodEditor.signalCompositionStart, +da.removeCurrentSelection);ka.unsubscribe(gui.InputMethodEditor.signalCompositionEnd,N);F.unsubscribe("cut",p);F.unsubscribe("beforecut",r);F.unsubscribe("paste",e);F.unsubscribe("beforepaste",l);F.setEditing(!1);pa.setModifier(G.None);C.bind(H.Backspace,G.None,function(){return!0},!0);C.unbind(H.Delete,G.None);C.unbind(H.Tab,G.None);ra?(C.unbind(H.Clear,G.None),C.unbind(H.B,G.Meta),C.unbind(H.I,G.Meta),C.unbind(H.U,G.Meta),C.unbind(H.L,G.MetaShift),C.unbind(H.E,G.MetaShift),C.unbind(H.R,G.MetaShift), +C.unbind(H.J,G.MetaShift),ja&&C.unbind(H.C,G.MetaShift),C.unbind(H.Z,G.Meta),C.unbind(H.Z,G.MetaShift)):(C.unbind(H.B,G.Ctrl),C.unbind(H.I,G.Ctrl),C.unbind(H.U,G.Ctrl),C.unbind(H.L,G.CtrlShift),C.unbind(H.E,G.CtrlShift),C.unbind(H.R,G.CtrlShift),C.unbind(H.J,G.CtrlShift),ja&&C.unbind(H.C,G.CtrlAlt),C.unbind(H.Z,G.Ctrl),C.unbind(H.Z,G.CtrlShift));Z.setDefault(null);Z.unbind(H.Enter,G.None)};this.getInputMemberId=function(){return c};this.getSession=function(){return k};this.getSessionConstraints=function(){return R}; +this.setUndoManager=function(a){Q&&Q.unsubscribe(gui.UndoManager.signalUndoStackChanged,d);if(Q=a)Q.setDocument(J),Q.setPlaybackFunction(k.enqueue),Q.subscribe(gui.UndoManager.signalUndoStackChanged,d)};this.getUndoManager=function(){return Q};this.getMetadataController=function(){return va};this.getAnnotationController=function(){return ca};this.getDirectFormattingController=function(){return X};this.getHyperlinkClickHandler=function(){return pa};this.getHyperlinkController=function(){return ta}; +this.getImageController=function(){return qa};this.getSelectionController=function(){return T};this.getTextController=function(){return da};this.getEventManager=function(){return F};this.getKeyboardHandlers=function(){return{keydown:C,keypress:Z}};this.destroy=function(a){var b=[ma.destroy,na.destroy,X.destroy,ka.destroy,F.destroy,pa.destroy,ta.destroy,va.destroy,T.destroy,da.destroy,V];sa&&b.unshift(sa.destroy);runtime.clearTimeout(M);core.Async.destroyAll(b,a)};ma=core.Task.createRedrawTask(z); +na=core.Task.createRedrawTask(function(){var a=J.getCursor(c);if(a&&a.getSelectionType()===ops.OdtCursor.RegionSelection&&(a=S.getImageElements(a.getSelectedRange())[0])){la.select(a.parentNode);return}la.clearSelection()});C.bind(H.Left,G.None,D(T.moveCursorToLeft));C.bind(H.Right,G.None,D(T.moveCursorToRight));C.bind(H.Up,G.None,D(T.moveCursorUp));C.bind(H.Down,G.None,D(T.moveCursorDown));C.bind(H.Left,G.Shift,D(T.extendSelectionToLeft));C.bind(H.Right,G.Shift,D(T.extendSelectionToRight));C.bind(H.Up, +G.Shift,D(T.extendSelectionUp));C.bind(H.Down,G.Shift,D(T.extendSelectionDown));C.bind(H.Home,G.None,D(T.moveCursorToLineStart));C.bind(H.End,G.None,D(T.moveCursorToLineEnd));C.bind(H.Home,G.Ctrl,D(T.moveCursorToDocumentStart));C.bind(H.End,G.Ctrl,D(T.moveCursorToDocumentEnd));C.bind(H.Home,G.Shift,D(T.extendSelectionToLineStart));C.bind(H.End,G.Shift,D(T.extendSelectionToLineEnd));C.bind(H.Up,G.CtrlShift,D(T.extendSelectionToParagraphStart));C.bind(H.Down,G.CtrlShift,D(T.extendSelectionToParagraphEnd)); +C.bind(H.Home,G.CtrlShift,D(T.extendSelectionToDocumentStart));C.bind(H.End,G.CtrlShift,D(T.extendSelectionToDocumentEnd));ra?(C.bind(H.Left,G.Alt,D(T.moveCursorBeforeWord)),C.bind(H.Right,G.Alt,D(T.moveCursorPastWord)),C.bind(H.Left,G.Meta,D(T.moveCursorToLineStart)),C.bind(H.Right,G.Meta,D(T.moveCursorToLineEnd)),C.bind(H.Home,G.Meta,D(T.moveCursorToDocumentStart)),C.bind(H.End,G.Meta,D(T.moveCursorToDocumentEnd)),C.bind(H.Left,G.AltShift,D(T.extendSelectionBeforeWord)),C.bind(H.Right,G.AltShift, +D(T.extendSelectionPastWord)),C.bind(H.Left,G.MetaShift,D(T.extendSelectionToLineStart)),C.bind(H.Right,G.MetaShift,D(T.extendSelectionToLineEnd)),C.bind(H.Up,G.AltShift,D(T.extendSelectionToParagraphStart)),C.bind(H.Down,G.AltShift,D(T.extendSelectionToParagraphEnd)),C.bind(H.Up,G.MetaShift,D(T.extendSelectionToDocumentStart)),C.bind(H.Down,G.MetaShift,D(T.extendSelectionToDocumentEnd)),C.bind(H.A,G.Meta,D(T.extendSelectionToEntireDocument))):(C.bind(H.Left,G.Ctrl,D(T.moveCursorBeforeWord)),C.bind(H.Right, +G.Ctrl,D(T.moveCursorPastWord)),C.bind(H.Left,G.CtrlShift,D(T.extendSelectionBeforeWord)),C.bind(H.Right,G.CtrlShift,D(T.extendSelectionPastWord)),C.bind(H.A,G.Ctrl,D(T.extendSelectionToEntireDocument)));ua&&(sa=new gui.IOSSafariSupport(F));F.subscribe("keydown",C.handleEvent);F.subscribe("keypress",Z.handleEvent);F.subscribe("keyup",ba.handleEvent);F.subscribe("copy",q);F.subscribe("mousedown",w);F.subscribe("mousemove",ma.trigger);F.subscribe("mouseup",E);F.subscribe("contextmenu",L);F.subscribe("dragstart", +I);F.subscribe("dragend",K);F.subscribe("click",pa.handleClick);F.subscribe("longpress",t);F.subscribe("drag",y);F.subscribe("dragstop",x);J.subscribe(ops.OdtDocument.signalOperationEnd,na.trigger);J.subscribe(ops.Document.signalCursorAdded,ka.registerCursor);J.subscribe(ops.Document.signalCursorRemoved,ka.removeCursor);J.subscribe(ops.OdtDocument.signalOperationEnd,a)}})(); +gui.CaretManager=function(g,k){function c(b){return n.hasOwnProperty(b)?n[b]:null}function b(){return Object.keys(n).map(function(b){return n[b]})}function f(b){var c=n[b];c&&(delete n[b],b===g.getInputMemberId()?(r.unsubscribe(ops.OdtDocument.signalProcessingBatchEnd,c.ensureVisible),r.unsubscribe(ops.Document.signalCursorMoved,c.refreshCursorBlinking),q.unsubscribe("compositionupdate",c.handleUpdate),q.unsubscribe("compositionend",c.handleUpdate),q.unsubscribe("focus",c.setFocus),q.unsubscribe("blur", +c.removeFocus),p.removeEventListener("focus",c.show,!1),p.removeEventListener("blur",c.hide,!1)):r.unsubscribe(ops.OdtDocument.signalProcessingBatchEnd,c.handleUpdate),c.destroy(function(){}))}var n={},p=runtime.getWindow(),r=g.getSession().getOdtDocument(),q=g.getEventManager();this.registerCursor=function(b,c,a){var d=b.getMemberId();b=new gui.Caret(b,k,c,a);n[d]=b;d===g.getInputMemberId()?(runtime.log("Starting to track input on new cursor of "+d),r.subscribe(ops.OdtDocument.signalProcessingBatchEnd, +b.ensureVisible),r.subscribe(ops.Document.signalCursorMoved,b.refreshCursorBlinking),q.subscribe("compositionupdate",b.handleUpdate),q.subscribe("compositionend",b.handleUpdate),q.subscribe("focus",b.setFocus),q.subscribe("blur",b.removeFocus),p.addEventListener("focus",b.show,!1),p.addEventListener("blur",b.hide,!1),b.setOverlayElement(q.getEventTrap())):r.subscribe(ops.OdtDocument.signalProcessingBatchEnd,b.handleUpdate);return b};this.getCaret=c;this.getCarets=b;this.destroy=function(c){var l= +b().map(function(a){return a.destroy});g.getSelectionController().setCaretXPositionLocator(null);r.unsubscribe(ops.Document.signalCursorRemoved,f);n={};core.Async.destroyAll(l,c)};g.getSelectionController().setCaretXPositionLocator(function(){var b=c(g.getInputMemberId()),f;b&&(f=b.getBoundingClientRect());return f?f.right:void 0});r.subscribe(ops.Document.signalCursorRemoved,f)}; +gui.EditInfoHandle=function(g){var k=[],c,b=g.ownerDocument,f=b.documentElement.namespaceURI;this.setEdits=function(g){k=g;var p,r,q,e;core.DomUtils.removeAllChildNodes(c);for(g=0;gd?(r=c(1,0),q=c(.5,1E4-d),e=c(.2,2E4-d)):1E4<=d&&2E4>d?(r=c(.5,0),e=c(.2,2E4-d)):r=c(.2,0)};this.getEdits=function(){return g.getEdits()};this.clearEdits=function(){g.clearEdits(); +n.setEdits([]);p.hasAttributeNS("urn:webodf:names:editinfo","editinfo:memberid")&&p.removeAttributeNS("urn:webodf:names:editinfo","editinfo:memberid")};this.getEditInfo=function(){return g};this.show=function(){p.style.display="block"};this.hide=function(){b.hideHandle();p.style.display="none"};this.showHandle=function(){n.show()};this.hideHandle=function(){n.hide()};this.destroy=function(b){runtime.clearTimeout(r);runtime.clearTimeout(q);runtime.clearTimeout(e);f.removeChild(p);n.destroy(function(a){a? +b(a):g.destroy(b)})};(function(){var c=g.getOdtDocument().getDOMDocument();p=c.createElementNS(c.documentElement.namespaceURI,"div");p.setAttribute("class","editInfoMarker");p.onmouseover=function(){b.showHandle()};p.onmouseout=function(){b.hideHandle()};f=g.getNode();f.appendChild(p);n=new gui.EditInfoHandle(f);k||b.hide()})()}; +gui.HyperlinkTooltipView=function(g,k){var c=core.DomUtils,b=odf.OdfUtils,f=runtime.getWindow(),n,p,r;runtime.assert(null!==f,"Expected to be run in an environment which has a global window, like a browser.");this.showTooltip=function(q){var e=q.target||q.srcElement,l=g.getSizer(),a=g.getZoomLevel(),d;a:{for(;e;){if(b.isHyperlink(e))break a;if(b.isParagraph(e)||b.isInlineRoot(e))break;e=e.parentNode}e=null}if(e){c.containsNode(l,r)||l.appendChild(r);d=p;var m;switch(k()){case gui.KeyboardHandler.Modifier.Ctrl:m= +runtime.tr("Ctrl-click to follow link");break;case gui.KeyboardHandler.Modifier.Meta:m=runtime.tr("\u2318-click to follow link");break;default:m=""}d.textContent=m;n.textContent=b.getHyperlinkTarget(e);r.style.display="block";d=f.innerWidth-r.offsetWidth-15;e=q.clientX>d?d:q.clientX+15;d=f.innerHeight-r.offsetHeight-10;q=q.clientY>d?d:q.clientY+10;l=l.getBoundingClientRect();e=(e-l.left)/a;q=(q-l.top)/a;r.style.left=e+"px";r.style.top=q+"px"}};this.hideTooltip=function(){r.style.display="none"};this.destroy= +function(b){r.parentNode&&r.parentNode.removeChild(r);b()};(function(){var b=g.getElement().ownerDocument;n=b.createElement("span");p=b.createElement("span");n.className="webodf-hyperlinkTooltipLink";p.className="webodf-hyperlinkTooltipText";r=b.createElement("div");r.className="webodf-hyperlinkTooltip";r.appendChild(n);r.appendChild(p);g.getElement().appendChild(r)})()}; +gui.OdfFieldView=function(g){function k(){var b=odf.OdfSchema.getFields().map(function(b){return b.replace(":","|")}),c=b.join(",\n")+"\n{ background-color: #D0D0D0; }\n",b=b.map(function(b){return b+":empty::after"}).join(",\n")+"\n{ content:' '; white-space: pre; }\n";return c+"\n"+b}var c,b=g.getElement().ownerDocument;this.showFieldHighlight=function(){c.appendChild(b.createTextNode(k()))};this.hideFieldHighlight=function(){for(var b=c.sheet,g=b.cssRules;g.length;)b.deleteRule(g.length-1)};this.destroy= +function(b){c.parentNode&&c.parentNode.removeChild(c);b()};c=function(){var c=b.getElementsByTagName("head").item(0),g=b.createElement("style"),k="";g.type="text/css";g.media="screen, print, handheld, projection";odf.Namespaces.forEachPrefix(function(b,c){k+="@namespace "+b+" url("+c+");\n"});g.appendChild(b.createTextNode(k));c.appendChild(g);return g}()}; +gui.ShadowCursor=function(g){var k=g.getDOMDocument().createRange(),c=!0;this.removeFromDocument=function(){};this.getMemberId=function(){return gui.ShadowCursor.ShadowCursorMemberId};this.getSelectedRange=function(){return k};this.setSelectedRange=function(b,f){k=b;c=!1!==f};this.hasForwardSelection=function(){return c};this.getDocument=function(){return g};this.getSelectionType=function(){return ops.OdtCursor.RangeSelection};k.setStart(g.getRootNode(),0)};gui.ShadowCursor.ShadowCursorMemberId=""; +gui.SelectionView=function(g){};gui.SelectionView.prototype.rerender=function(){};gui.SelectionView.prototype.show=function(){};gui.SelectionView.prototype.hide=function(){};gui.SelectionView.prototype.destroy=function(g){}; +gui.SelectionViewManager=function(g){function k(){return Object.keys(c).map(function(b){return c[b]})}var c={};this.getSelectionView=function(b){return c.hasOwnProperty(b)?c[b]:null};this.getSelectionViews=k;this.removeSelectionView=function(b){c.hasOwnProperty(b)&&(c[b].destroy(function(){}),delete c[b])};this.hideSelectionView=function(b){c.hasOwnProperty(b)&&c[b].hide()};this.showSelectionView=function(b){c.hasOwnProperty(b)&&c[b].show()};this.rerenderSelectionViews=function(){Object.keys(c).forEach(function(b){c[b].rerender()})}; +this.registerCursor=function(b,f){var k=b.getMemberId(),p=new g(b);f?p.show():p.hide();return c[k]=p};this.destroy=function(b){function c(k,r){r?b(r):k .webodf-draggable"),a=gui.ShadowCursor.ShadowCursorMemberId,e(".webodf-selectionOverlay","{ fill: "+d+"; stroke: "+d+";}",""),e(".webodf-touchEnabled .webodf-selectionOverlay","{ display: block; }"," > .webodf-draggable"))}function l(a){var b,d;for(d in t)t.hasOwnProperty(d)&&(b=t[d],a?b.show():b.hide())}function a(a){n.getCarets().forEach(function(b){a?b.showHandle():b.hideHandle()})}function d(a){var b=a.getMemberId();a=a.getProperties();e(b,a.fullName,a.color)}function m(a){var d= +a.getMemberId(),c=b.getOdtDocument().getMember(d).getProperties();n.registerCursor(a,E,N);p.registerCursor(a,!0);if(a=n.getCaret(d))a.setAvatarImageUrl(c.imageUrl),a.setColor(c.color);runtime.log("+++ View here +++ eagerly created an Caret for '"+d+"'! +++")}function h(a){a=a.getMemberId();var b=p.getSelectionView(c),d=p.getSelectionView(gui.ShadowCursor.ShadowCursorMemberId),e=n.getCaret(c);a===c?(d.hide(),b&&b.show(),e&&e.show()):a===gui.ShadowCursor.ShadowCursorMemberId&&(d.show(),b&&b.hide(), +e&&e.hide())}function y(a){p.removeSelectionView(a)}function x(a){var d=a.paragraphElement,c=a.memberId;a=a.timeStamp;var e,f="",h=d.getElementsByTagNameNS("urn:webodf:names:editinfo","editinfo").item(0);h?(f=h.getAttributeNS("urn:webodf:names:editinfo","id"),e=t[f]):(f=Math.random().toString(),e=new ops.EditInfo(d,b.getOdtDocument()),e=new gui.EditInfoMarker(e,L),h=d.getElementsByTagNameNS("urn:webodf:names:editinfo","editinfo").item(0),h.setAttributeNS("urn:webodf:names:editinfo","id",f),t[f]=e); +e.addEdit(c,new Date(a));K.trigger()}function z(){var a;u.hasChildNodes()&&core.DomUtils.removeAllChildNodes(u);!0===f.getState(gui.CommonConstraints.EDIT.ANNOTATIONS.ONLY_DELETE_OWN)&&(a=b.getOdtDocument().getMember(c))&&(a=a.getProperties().fullName,u.appendChild(document.createTextNode(".annotationWrapper:not([creator = '"+a+"']) .annotationRemoveButton { display: none; }")))}function w(a){var b=Object.keys(t).map(function(a){return t[a]});A.unsubscribe(ops.Document.signalMemberAdded,d);A.unsubscribe(ops.Document.signalMemberUpdated, +d);A.unsubscribe(ops.Document.signalCursorAdded,m);A.unsubscribe(ops.Document.signalCursorRemoved,y);A.unsubscribe(ops.OdtDocument.signalParagraphChanged,x);A.unsubscribe(ops.Document.signalCursorMoved,h);A.unsubscribe(ops.OdtDocument.signalParagraphChanged,p.rerenderSelectionViews);A.unsubscribe(ops.OdtDocument.signalTableAdded,p.rerenderSelectionViews);A.unsubscribe(ops.OdtDocument.signalParagraphStyleModified,p.rerenderSelectionViews);f.unsubscribe(gui.CommonConstraints.EDIT.ANNOTATIONS.ONLY_DELETE_OWN, +z);A.unsubscribe(ops.Document.signalMemberAdded,z);A.unsubscribe(ops.Document.signalMemberUpdated,z);v.parentNode.removeChild(v);u.parentNode.removeChild(u);(function W(d,c){c?a(c):da.length;b&&f(a);return b}function a(a,b){function c(g){a[g]===b&&f.push(g)}var f=[];a&&["style:parent-style-name","style:next-style-name"].forEach(c);return f}function c(a,b){function c(f){a[f]===b&&delete a[f]}a&&["style:parent-style-name","style:next-style-name"].forEach(c)}function b(a){var e={};Object.keys(a).forEach(function(c){e[c]="object"===typeof a[c]?b(a[c]):a[c]});return e}function k(a, -b,c,f){var g,h=!1,k=!1,l,n=[];f&&f.attributes&&(n=f.attributes.split(","));a&&(c||0=e.position+e.length)){f=c?a:e;g=c?e:a;if(a.position!==e.position||a.length!==e.length)p=b(f),w=b(g);e=n(g.setProperties,null,f.setProperties,null,"style:text-properties");if(e.majorChanged||e.minorChanged)h=[],a=[],k=f.position+f.length,l=g.position+g.length,g.positionk?e.minorChanged&&(p=w,p.position=k,p.length=l-k,a.push(p),g.length=k-g.position):k>l&&e.majorChanged&&(p.position=l,p.length=k-l,h.push(p),f.length=l-f.position),f.setProperties&&q(f.setProperties)&&h.push(f),g.setProperties&&q(g.setProperties)&&a.push(g),c?(k=h,h=a):k=a}return{opSpecsA:k,opSpecsB:h}},InsertText:function(a,b){b.position<=a.position?a.position+=b.text.length:b.position<=a.position+a.length&& -(a.length+=b.text.length);return{opSpecsA:[a],opSpecsB:[b]}},MergeParagraph:function(a,b){var c=a.position,f=a.position+a.length;c>=b.sourceStartPosition&&(c-=1);f>=b.sourceStartPosition&&(f-=1);a.position=c;a.length=f-c;return{opSpecsA:[a],opSpecsB:[b]}},MoveCursor:g,RemoveCursor:g,RemoveMember:g,RemoveStyle:g,RemoveText:function(a,b){var c=a.position+a.length,f=b.position+b.length,g=[a],h=[b];f<=a.position?a.position-=b.length:b.positionb.position?a.position+=b.text.length:c?b.position+=a.text.length:a.position+=b.text.length; -return{opSpecsA:[a],opSpecsB:[b]}},MergeParagraph:function(a,b){a.position>=b.sourceStartPosition?a.position-=1:(a.positiona.position&&(b.position+=a.text.length);return{opSpecsA:[a], -opSpecsB:[b]}},SplitParagraph:function(a,b){a.position=a.sourceStartPosition&&(g-=1);c>=a.sourceStartPosition&& -(c-=1);0<=b.length?(b.position=g,b.length=c-g):(b.position=c,b.length=g-c);return{opSpecsA:[a],opSpecsB:[b]}},RemoveCursor:g,RemoveMember:g,RemoveStyle:g,RemoveText:function(a,b){b.position>=a.sourceStartPosition?b.position-=1:(b.positiona.sourceStartPosition)b.position-= -1;else if(b.position===a.destinationStartPosition||b.position===a.sourceStartPosition)b.position=a.destinationStartPosition,a.paragraphStyleName=b.styleName;return{opSpecsA:c,opSpecsB:f}},SplitParagraph:function(a,b){var c,f=[a],g=[b];b.position=a.destinationStartPosition&&b.position=a.sourceStartPosition&&(b.position-=1,b.sourceParagraphPosition-=1);return{opSpecsA:f,opSpecsB:g}},UpdateMember:g,UpdateMetadata:g,UpdateParagraphStyle:g},MoveCursor:{MoveCursor:g,RemoveCursor:function(a, -b){return{opSpecsA:a.memberid===b.memberid?[]:[a],opSpecsB:[b]}},RemoveMember:g,RemoveStyle:g,RemoveText:function(a,b){var c=l(a),g=a.position+a.length,h=b.position+b.length;h<=a.position?a.position-=b.length:b.positionc.position?a.position+=1:a.position===c.sourceParagraphPosition&&(c.paragraphStyleName=a.styleName,h=b(a),h.position=c.position+1,f.push(h));return{opSpecsA:f,opSpecsB:g}},UpdateMember:g,UpdateMetadata:g,UpdateParagraphStyle:g},SplitParagraph:{SplitParagraph:function(a,b,c){var f,g;a.positiona.length;b&&g(a);return b}function c(a,b){function c(f){a[f]===b&&e.push(f)}var e=[];a&&["style:parent-style-name","style:next-style-name"].forEach(c);return e}function b(a,b){function c(e){a[e]===b&&delete a[e]}a&&["style:parent-style-name","style:next-style-name"].forEach(c)}function f(a){var b={};Object.keys(a).forEach(function(c){b[c]="object"===typeof a[c]?f(a[c]):a[c]});return b}function n(a, +b,c,e){var f,g=!1,k=!1,l,n=[];e&&e.attributes&&(n=e.attributes.split(","));a&&(c||0=a.length?0:a.length-f.length)):void 0!==a.length&&(f=a.position+a.length,e<=f?a.length-=b.length:c=b.position+b.length)){e=c?a:b;g=c?b:a;if(a.position!==b.position||a.length!==b.length)r=f(e),u=f(g);b=q(g.setProperties,null,e.setProperties, +null,"style:text-properties");if(b.majorChanged||b.minorChanged)k=[],a=[],l=e.position+e.length,n=g.position+g.length,g.positionl?b.minorChanged&&(r=u,r.position=l,r.length=n-l,a.push(r),g.length=l-g.position):l>n&&b.majorChanged&&(r.position=n, +r.length=l-n,k.push(r),e.length=n-e.position),e.setProperties&&p(e.setProperties)&&k.push(e),g.setProperties&&p(g.setProperties)&&a.push(g),c?(l=k,k=a):l=a}return{opSpecsA:l,opSpecsB:k}},InsertText:function(a,b){b.position<=a.position?a.position+=b.text.length:b.position<=a.position+a.length&&(a.length+=b.text.length);return{opSpecsA:[a],opSpecsB:[b]}},MergeParagraph:function(a,b){var c=a.position,e=a.position+a.length;c>=b.sourceStartPosition&&--c;e>=b.sourceStartPosition&&--e;a.position=c;a.length= +e-c;return{opSpecsA:[a],opSpecsB:[b]}},MoveCursor:e,RemoveAnnotation:function(a,b){var c=a.position,e=a.position+a.length,f=b.position+b.length,g=[a],k=[b];b.position<=c&&e<=f?g=[]:(fb.position?a.position+=b.text.length:c?b.position+=a.text.length:a.position+= +b.text.length;return{opSpecsA:[a],opSpecsB:[b]}},MergeParagraph:function(a,b){a.position>=b.sourceStartPosition?--a.position:(a.positiona.position&&(b.position+=a.text.length);return{opSpecsA:[a],opSpecsB:[b]}},SplitParagraph:function(a,b){a.position=a.sourceStartPosition&&--f;c>=a.sourceStartPosition&&--c;0<=b.length?(b.position=f,b.length=c-f):(b.position=c,b.length=f-c);return{opSpecsA:[a],opSpecsB:[b]}},RemoveAnnotation:function(a,b){var c=b.position+b.length,e=[a],f=[b];b.position<=a.destinationStartPosition&&a.sourceStartPosition<=c?(e=[],--b.length):a.sourceStartPosition=a.sourceStartPosition?--b.position:(b.positiona.sourceStartPosition)--b.position;else if(b.position===a.destinationStartPosition||b.position===a.sourceStartPosition)b.position=a.destinationStartPosition,a.paragraphStyleName=b.styleName;return{opSpecsA:c,opSpecsB:e}},SplitParagraph:function(a,b){var c,e=[a],f=[b];b.position=a.destinationStartPosition&&b.position=a.sourceStartPosition&&(--b.position,--b.sourceParagraphPosition);return{opSpecsA:e,opSpecsB:f}},UpdateMember:e,UpdateMetadata:e, +UpdateParagraphStyle:e},MoveCursor:{MoveCursor:e,RemoveAnnotation:function(a,b){var c=k(a),e=a.position+a.length,f=b.position+b.length;b.position<=a.position&&e<=f?(a.position=b.position-1,a.length=0):(fb.position?a.position+= +1:a.position===b.sourceParagraphPosition&&(b.paragraphStyleName=a.styleName,g=f(a),g.position=b.position+1,c.push(g));return{opSpecsA:c,opSpecsB:e}},UpdateMember:e,UpdateMetadata:e,UpdateParagraphStyle:e},SplitParagraph:{SplitParagraph:function(a,b,c){var e,f;a.position + +(c) 2009-2014 Stuart Knightley +Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/master/LICENSE.markdown. + +JSZip uses the library pako released under the MIT license : +https://github.com/nodeca/pako/blob/master/LICENSE + @licend +*/ +!function(e){var globalScope=typeof window!=="undefined"?window:typeof global!=="undefined"?global:{},externs=globalScope.externs||(globalScope.externs={});externs.JSZip=e()}(function(){var define,module,exports;return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'");}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f, +f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o>2;enc2=(chr1&3)<<4|chr2>>4;enc3=(chr2&15)<<2|chr3>> +6;enc4=chr3&63;if(isNaN(chr2))enc3=enc4=64;else if(isNaN(chr3))enc4=64;output=output+_keyStr.charAt(enc1)+_keyStr.charAt(enc2)+_keyStr.charAt(enc3)+_keyStr.charAt(enc4)}return output};exports.decode=function(input,utf8){var output="";var chr1,chr2,chr3;var enc1,enc2,enc3,enc4;var i=0;input=input.replace(/[^A-Za-z0-9\+\/\=]/g,"");while(i>4;chr2=(enc2&15)<<4|enc3>>2;chr3=(enc3&3)<<6|enc4;output=output+String.fromCharCode(chr1);if(enc3!=64)output=output+String.fromCharCode(chr2);if(enc4!=64)output=output+String.fromCharCode(chr3)}return output}},{}],2:[function(_dereq_,module,exports){function CompressedObject(){this.compressedSize=0;this.uncompressedSize=0;this.crc32=0;this.compressionMethod=null;this.compressedContent=null}CompressedObject.prototype={getContent:function(){return null},getCompressedContent:function(){return null}}; +module.exports=CompressedObject},{}],3:[function(_dereq_,module,exports){exports.STORE={magic:"\x00\x00",compress:function(content){return content},uncompress:function(content){return content},compressInputType:null,uncompressInputType:null};exports.DEFLATE=_dereq_("./flate")},{"./flate":8}],4:[function(_dereq_,module,exports){var utils=_dereq_("./utils");var table=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021, +3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527, +1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856, +1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626, +1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692, +2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918E3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614, +3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];module.exports=function crc32(input,crc){if(typeof input==="undefined"||!input.length)return 0;var isArray=utils.getTypeOf(input)!=="string";if(typeof crc=="undefined")crc=0;var x=0;var y=0;var b=0;crc=crc^-1;for(var i=0,iTop=input.length;i>>8^x}return crc^-1}},{"./utils":21}],5:[function(_dereq_,module,exports){var utils=_dereq_("./utils"); +function DataReader(data){this.data=null;this.length=0;this.index=0}DataReader.prototype={checkOffset:function(offset){this.checkIndex(this.index+offset)},checkIndex:function(newIndex){if(this.length=this.index;i--)result=(result<<8)+this.byteAt(i);this.index+=size;return result},readString:function(size){return utils.transformTo("string",this.readData(size))},readData:function(size){},lastIndexOfSignature:function(sig){},readDate:function(){var dostime=this.readInt(4);return new Date((dostime>>25&127)+1980,(dostime>>21&15)-1,dostime>>16&31,dostime>>11&31,dostime>>5&63,(dostime&31)<<1)}};module.exports=DataReader},{"./utils":21}],6:[function(_dereq_, +module,exports){exports.base64=false;exports.binary=false;exports.dir=false;exports.createFolders=false;exports.date=null;exports.compression=null;exports.comment=null},{}],7:[function(_dereq_,module,exports){var utils=_dereq_("./utils");exports.string2binary=function(str){return utils.string2binary(str)};exports.string2Uint8Array=function(str){return utils.transformTo("uint8array",str)};exports.uint8Array2String=function(array){return utils.transformTo("string",array)};exports.string2Blob=function(str){var buffer= +utils.transformTo("arraybuffer",str);return utils.arrayBuffer2Blob(buffer)};exports.arrayBuffer2Blob=function(buffer){return utils.arrayBuffer2Blob(buffer)};exports.transformTo=function(outputType,input){return utils.transformTo(outputType,input)};exports.getTypeOf=function(input){return utils.getTypeOf(input)};exports.checkSupport=function(type){return utils.checkSupport(type)};exports.MAX_VALUE_16BITS=utils.MAX_VALUE_16BITS;exports.MAX_VALUE_32BITS=utils.MAX_VALUE_32BITS;exports.pretty=function(str){return utils.pretty(str)}; +exports.findCompression=function(compressionMethod){return utils.findCompression(compressionMethod)};exports.isRegExp=function(object){return utils.isRegExp(object)}},{"./utils":21}],8:[function(_dereq_,module,exports){var USE_TYPEDARRAY=typeof Uint8Array!=="undefined"&&typeof Uint16Array!=="undefined"&&typeof Uint32Array!=="undefined";var pako=_dereq_("pako");exports.uncompressInputType=USE_TYPEDARRAY?"uint8array":"array";exports.compressInputType=USE_TYPEDARRAY?"uint8array":"array";exports.magic= +"\b\x00";exports.compress=function(input){return pako.deflateRaw(input)};exports.uncompress=function(input){return pako.inflateRaw(input)}},{"pako":24}],9:[function(_dereq_,module,exports){var base64=_dereq_("./base64");function JSZip(data,options){if(!(this instanceof JSZip))return new JSZip(data,options);this.files={};this.comment=null;this.root="";if(data)this.load(data,options);this.clone=function(){var newObj=new JSZip;for(var i in this)if(typeof this[i]!=="function")newObj[i]=this[i];return newObj}} +JSZip.prototype=_dereq_("./object");JSZip.prototype.load=_dereq_("./load");JSZip.support=_dereq_("./support");JSZip.defaults=_dereq_("./defaults");JSZip.utils=_dereq_("./deprecatedPublicUtils");JSZip.base64={encode:function(input){return base64.encode(input)},decode:function(input){return base64.decode(input)}};JSZip.compressions=_dereq_("./compressions");module.exports=JSZip},{"./base64":1,"./compressions":3,"./defaults":6,"./deprecatedPublicUtils":7,"./load":10,"./object":13,"./support":17}],10:[function(_dereq_, +module,exports){var base64=_dereq_("./base64");var ZipEntries=_dereq_("./zipEntries");module.exports=function(data,options){var files,zipEntries,i,input;options=options||{};if(options.base64)data=base64.decode(data);zipEntries=new ZipEntries(data,options);files=zipEntries.files;for(i=0;i>>8}return hex};var extend=function(){var result={},i,attr;for(i=0;i0?path.substring(0,lastSlash):""};var folderAdd=function(name,createFolders){if(name.slice(-1)!="/")name+="/";createFolders=typeof createFolders!=="undefined"?createFolders:false;if(!this.files[name])fileAdd.call(this,name,null,{dir:true,createFolders:createFolders});return this.files[name]};var generateCompressedObjectFrom=function(file,compression){var result=new CompressedObject,content;if(file._data instanceof +CompressedObject){result.uncompressedSize=file._data.uncompressedSize;result.crc32=file._data.crc32;if(result.uncompressedSize===0||file.dir){compression=compressions["STORE"];result.compressedContent="";result.crc32=0}else if(file._data.compressionMethod===compression.magic)result.compressedContent=file._data.getCompressedContent();else{content=file._data.getContent();result.compressedContent=compression.compress(utils.transformTo(compression.compressInputType,content))}}else{content=getBinaryData(file); +if(!content||content.length===0||file.dir){compression=compressions["STORE"];content=""}result.uncompressedSize=content.length;result.crc32=crc32(content);result.compressedContent=compression.compress(utils.transformTo(compression.compressInputType,content))}result.compressedSize=result.compressedContent.length;result.compressionMethod=compression.magic;return result};var generateZipParts=function(name,file,compressedObject,offset){var data=compressedObject.compressedContent,utfEncodedFileName=utils.transformTo("string", +utf8.utf8encode(file.name)),comment=file.comment||"",utfEncodedComment=utils.transformTo("string",utf8.utf8encode(comment)),useUTF8ForFileName=utfEncodedFileName.length!==file.name.length,useUTF8ForComment=utfEncodedComment.length!==comment.length,o=file.options,dosTime,dosDate,extraFields="",unicodePathExtraField="",unicodeCommentExtraField="",dir,date;if(file._initialMetadata.dir!==file.dir)dir=file.dir;else dir=o.dir;if(file._initialMetadata.date!==file.date)date=file.date;else date=o.date;dosTime= +date.getHours();dosTime=dosTime<<6;dosTime=dosTime|date.getMinutes();dosTime=dosTime<<5;dosTime=dosTime|date.getSeconds()/2;dosDate=date.getFullYear()-1980;dosDate=dosDate<<4;dosDate=dosDate|date.getMonth()+1;dosDate=dosDate<<5;dosDate=dosDate|date.getDate();if(useUTF8ForFileName){unicodePathExtraField=decToHex(1,1)+decToHex(crc32(utfEncodedFileName),4)+utfEncodedFileName;extraFields+="up"+decToHex(unicodePathExtraField.length,2)+unicodePathExtraField}if(useUTF8ForComment){unicodeCommentExtraField= +decToHex(1,1)+decToHex(this.crc32(utfEncodedComment),4)+utfEncodedComment;extraFields+="uc"+decToHex(unicodeCommentExtraField.length,2)+unicodeCommentExtraField}var header="";header+="\n\x00";header+=useUTF8ForFileName||useUTF8ForComment?"\x00\b":"\x00\x00";header+=compressedObject.compressionMethod;header+=decToHex(dosTime,2);header+=decToHex(dosDate,2);header+=decToHex(compressedObject.crc32,4);header+=decToHex(compressedObject.compressedSize,4);header+=decToHex(compressedObject.uncompressedSize, +4);header+=decToHex(utfEncodedFileName.length,2);header+=decToHex(extraFields.length,2);var fileRecord=signature.LOCAL_FILE_HEADER+header+utfEncodedFileName+extraFields;var dirRecord=signature.CENTRAL_FILE_HEADER+"\u0014\x00"+header+decToHex(utfEncodedComment.length,2)+"\x00\x00"+"\x00\x00"+(dir===true?"\u0010\x00\x00\x00":"\x00\x00\x00\x00")+decToHex(offset,4)+utfEncodedFileName+extraFields+utfEncodedComment;return{fileRecord:fileRecord,dirRecord:dirRecord,compressedObject:compressedObject}};var out= +{load:function(stream,options){throw new Error("Load method is not defined. Is the file jszip-load.js included ?");},filter:function(search){var result=[],filename,relativePath,file,fileClone;for(filename in this.files){if(!this.files.hasOwnProperty(filename))continue;file=this.files[filename];fileClone=new ZipObject(file.name,file._data,extend(file.options));relativePath=filename.slice(this.root.length,filename.length);if(filename.slice(0,this.root.length)===this.root&&search(relativePath,fileClone))result.push(fileClone)}return result}, +file:function(name,data,o){if(arguments.length===1)if(utils.isRegExp(name)){var regexp=name;return this.filter(function(relativePath,file){return!file.dir&®exp.test(relativePath)})}else return this.filter(function(relativePath,file){return!file.dir&&relativePath===name})[0]||null;else{name=this.root+name;fileAdd.call(this,name,data,o)}return this},folder:function(arg){if(!arg)return this;if(utils.isRegExp(arg))return this.filter(function(relativePath,file){return file.dir&&arg.test(relativePath)}); +var name=this.root+arg;var newFolder=folderAdd.call(this,name);var ret=this.clone();ret.root=newFolder.name;return ret},remove:function(name){name=this.root+name;var file=this.files[name];if(!file){if(name.slice(-1)!="/")name+="/";file=this.files[name]}if(file&&!file.dir)delete this.files[name];else{var kids=this.filter(function(relativePath,file){return file.name.slice(0,name.length)===name});for(var i=0;i=0;--i)if(this.data[i]===sig0&&this.data[i+1]===sig1&&this.data[i+2]===sig2&&this.data[i+3]===sig3)return i;return-1};Uint8ArrayReader.prototype.readData=function(size){this.checkOffset(size);if(size===0)return new Uint8Array(0);var result=this.data.subarray(this.index, +this.index+size);this.index+=size;return result};module.exports=Uint8ArrayReader},{"./dataReader":5}],19:[function(_dereq_,module,exports){var utils=_dereq_("./utils");var Uint8ArrayWriter=function(length){this.data=new Uint8Array(length);this.index=0};Uint8ArrayWriter.prototype={append:function(input){if(input.length!==0){input=utils.transformTo("uint8array",input);this.data.set(input,this.index);this.index+=input.length}},finalize:function(){return this.data}};module.exports=Uint8ArrayWriter},{"./utils":21}], +20:[function(_dereq_,module,exports){var utils=_dereq_("./utils");var support=_dereq_("./support");var nodeBuffer=_dereq_("./nodeBuffer");var _utf8len=new Array(256);for(var i=0;i<256;i++)_utf8len[i]=i>=252?6:i>=248?5:i>=240?4:i>=224?3:i>=192?2:1;_utf8len[254]=_utf8len[254]=1;var string2buf=function(str){var buf,c,c2,m_pos,i,str_len=str.length,buf_len=0;for(m_pos=0;m_pos>>6;buf[i++]=128|c&63}else if(c<65536){buf[i++]=224|c>>>12;buf[i++]=128|c>>>6&63;buf[i++]=128|c&63}else{buf[i++]= +240|c>>>18;buf[i++]=128|c>>>12&63;buf[i++]=128|c>>>6&63;buf[i++]=128|c&63}}return buf};var utf8border=function(buf,max){var pos;max=max||buf.length;if(max>buf.length)max=buf.length;pos=max-1;while(pos>=0&&(buf[pos]&192)===128)pos--;if(pos<0)return max;if(pos===0)return max;return pos+_utf8len[buf[pos]]>max?pos:max};var buf2string=function(buf){var str,i,out,c,c_len;var len=buf.length;var utf16buf=new Array(len*2);for(out=0,i=0;i4){utf16buf[out++]=65533;i+=c_len-1;continue}c&=c_len===2?31:c_len===3?15:7;while(c_len>1&&i1){utf16buf[out++]=65533;continue}if(c<65536)utf16buf[out++]=c;else{c-=65536;utf16buf[out++]=55296|c>>10&1023;utf16buf[out++]=56320|c&1023}}if(utf16buf.length!==out)if(utf16buf.subarray)utf16buf=utf16buf.subarray(0,out);else utf16buf.length=out;return utils.applyFromCharCode(utf16buf)};exports.utf8encode=function utf8encode(str){if(support.nodebuffer)return nodeBuffer(str, +"utf-8");return string2buf(str)};exports.utf8decode=function utf8decode(buf){if(support.nodebuffer)return utils.transformTo("nodebuffer",buf).toString("utf-8");buf=utils.transformTo(support.uint8array?"uint8array":"array",buf);var result=[],k=0,len=buf.length,chunk=65536;while(k1)try{if(type==="array"||type==="nodebuffer")result.push(String.fromCharCode.apply(null,array.slice(k,Math.min(k+chunk,len))));else result.push(String.fromCharCode.apply(null, +array.subarray(k,Math.min(k+chunk,len))));k+=chunk}catch(e){chunk=Math.floor(chunk/2)}return result.join("")}exports.applyFromCharCode=arrayLikeToString;function arrayLikeToArrayLike(arrayFrom,arrayTo){for(var i=0;i1)throw new Error("Multi-volumes zip are not supported");},readLocalFiles:function(){var i,file;for(i=0;i0)opt.windowBits=-opt.windowBits;else if(opt.gzip&&opt.windowBits>0&&opt.windowBits<16)opt.windowBits+=16;this.err=0;this.msg="";this.ended=false;this.chunks=[];this.strm=new zstream;this.strm.avail_out=0;var status=zlib_deflate.deflateInit2(this.strm,opt.level,opt.method,opt.windowBits,opt.memLevel,opt.strategy);if(status!==Z_OK)throw new Error(msg[status]); +if(opt.header)zlib_deflate.deflateSetHeader(this.strm,opt.header)};Deflate.prototype.push=function(data,mode){var strm=this.strm;var chunkSize=this.options.chunkSize;var status,_mode;if(this.ended)return false;_mode=mode===~~mode?mode:mode===true?Z_FINISH:Z_NO_FLUSH;if(typeof data==="string")strm.input=strings.string2buf(data);else strm.input=data;strm.next_in=0;strm.avail_in=strm.input.length;do{if(strm.avail_out===0){strm.output=new utils.Buf8(chunkSize);strm.next_out=0;strm.avail_out=chunkSize}status= +zlib_deflate.deflate(strm,_mode);if(status!==Z_STREAM_END&&status!==Z_OK){this.onEnd(status);this.ended=true;return false}if(strm.avail_out===0||strm.avail_in===0&&_mode===Z_FINISH)if(this.options.to==="string")this.onData(strings.buf2binstring(utils.shrinkBuf(strm.output,strm.next_out)));else this.onData(utils.shrinkBuf(strm.output,strm.next_out))}while((strm.avail_in>0||strm.avail_out===0)&&status!==Z_STREAM_END);if(_mode===Z_FINISH){status=zlib_deflate.deflateEnd(this.strm);this.onEnd(status); +this.ended=true;return status===Z_OK}return true};Deflate.prototype.onData=function(chunk){this.chunks.push(chunk)};Deflate.prototype.onEnd=function(status){if(status===Z_OK)if(this.options.to==="string")this.result=this.chunks.join("");else this.result=utils.flattenChunks(this.chunks);this.chunks=[];this.err=status;this.msg=this.strm.msg};function deflate(input,options){var deflator=new Deflate(options);deflator.push(input,true);if(deflator.err)throw deflator.msg;return deflator.result}function deflateRaw(input, +options){options=options||{};options.raw=true;return deflate(input,options)}function gzip(input,options){options=options||{};options.gzip=true;return deflate(input,options)}exports.Deflate=Deflate;exports.deflate=deflate;exports.deflateRaw=deflateRaw;exports.gzip=gzip},{"./utils/common":27,"./utils/strings":28,"./zlib/deflate.js":32,"./zlib/messages":37,"./zlib/zstream":39}],26:[function(_dereq_,module,exports){var zlib_inflate=_dereq_("./zlib/inflate.js");var utils=_dereq_("./utils/common");var strings= +_dereq_("./utils/strings");var c=_dereq_("./zlib/constants");var msg=_dereq_("./zlib/messages");var zstream=_dereq_("./zlib/zstream");var gzheader=_dereq_("./zlib/gzheader");var Inflate=function(options){this.options=utils.assign({chunkSize:16384,windowBits:0,to:""},options||{});var opt=this.options;if(opt.raw&&opt.windowBits>=0&&opt.windowBits<16){opt.windowBits=-opt.windowBits;if(opt.windowBits===0)opt.windowBits=-15}if(opt.windowBits>=0&&opt.windowBits<16&&!(options&&options.windowBits))opt.windowBits+= +32;if(opt.windowBits>15&&opt.windowBits<48)if((opt.windowBits&15)===0)opt.windowBits|=15;this.err=0;this.msg="";this.ended=false;this.chunks=[];this.strm=new zstream;this.strm.avail_out=0;var status=zlib_inflate.inflateInit2(this.strm,opt.windowBits);if(status!==c.Z_OK)throw new Error(msg[status]);this.header=new gzheader;zlib_inflate.inflateGetHeader(this.strm,this.header)};Inflate.prototype.push=function(data,mode){var strm=this.strm;var chunkSize=this.options.chunkSize;var status,_mode;var next_out_utf8, +tail,utf8str;if(this.ended)return false;_mode=mode===~~mode?mode:mode===true?c.Z_FINISH:c.Z_NO_FLUSH;if(typeof data==="string")strm.input=strings.binstring2buf(data);else strm.input=data;strm.next_in=0;strm.avail_in=strm.input.length;do{if(strm.avail_out===0){strm.output=new utils.Buf8(chunkSize);strm.next_out=0;strm.avail_out=chunkSize}status=zlib_inflate.inflate(strm,c.Z_NO_FLUSH);if(status!==c.Z_STREAM_END&&status!==c.Z_OK){this.onEnd(status);this.ended=true;return false}if(strm.next_out)if(strm.avail_out=== +0||status===c.Z_STREAM_END||strm.avail_in===0&&_mode===c.Z_FINISH)if(this.options.to==="string"){next_out_utf8=strings.utf8border(strm.output,strm.next_out);tail=strm.next_out-next_out_utf8;utf8str=strings.buf2string(strm.output,next_out_utf8);strm.next_out=tail;strm.avail_out=chunkSize-tail;if(tail)utils.arraySet(strm.output,strm.output,next_out_utf8,tail,0);this.onData(utf8str)}else this.onData(utils.shrinkBuf(strm.output,strm.next_out))}while(strm.avail_in>0&&status!==c.Z_STREAM_END);if(status=== +c.Z_STREAM_END)_mode=c.Z_FINISH;if(_mode===c.Z_FINISH){status=zlib_inflate.inflateEnd(this.strm);this.onEnd(status);this.ended=true;return status===c.Z_OK}return true};Inflate.prototype.onData=function(chunk){this.chunks.push(chunk)};Inflate.prototype.onEnd=function(status){if(status===c.Z_OK)if(this.options.to==="string")this.result=this.chunks.join("");else this.result=utils.flattenChunks(this.chunks);this.chunks=[];this.err=status;this.msg=this.strm.msg};function inflate(input,options){var inflator= +new Inflate(options);inflator.push(input,true);if(inflator.err)throw inflator.msg;return inflator.result}function inflateRaw(input,options){options=options||{};options.raw=true;return inflate(input,options)}exports.Inflate=Inflate;exports.inflate=inflate;exports.inflateRaw=inflateRaw;exports.ungzip=inflate},{"./utils/common":27,"./utils/strings":28,"./zlib/constants":30,"./zlib/gzheader":33,"./zlib/inflate.js":35,"./zlib/messages":37,"./zlib/zstream":39}],27:[function(_dereq_,module,exports){var TYPED_OK= +typeof Uint8Array!=="undefined"&&typeof Uint16Array!=="undefined"&&typeof Int32Array!=="undefined";exports.assign=function(obj){var sources=Array.prototype.slice.call(arguments,1);while(sources.length){var source=sources.shift();if(!source)continue;if(typeof source!=="object")throw new TypeError(source+"must be non-object");for(var p in source)if(source.hasOwnProperty(p))obj[p]=source[p]}return obj};exports.shrinkBuf=function(buf,size){if(buf.length===size)return buf;if(buf.subarray)return buf.subarray(0, +size);buf.length=size;return buf};var fnTyped={arraySet:function(dest,src,src_offs,len,dest_offs){if(src.subarray&&dest.subarray){dest.set(src.subarray(src_offs,src_offs+len),dest_offs);return}for(var i=0;i=252?6:i>=248?5:i>=240?4:i>=224?3:i>=192?2:1;_utf8len[254]=_utf8len[254]=1;exports.string2buf=function(str){var buf,c,c2,m_pos,i,str_len=str.length,buf_len=0;for(m_pos=0;m_pos>>6;buf[i++]=128|c&63}else if(c<65536){buf[i++]=224|c>>>12;buf[i++]= +128|c>>>6&63;buf[i++]=128|c&63}else{buf[i++]=240|c>>>18;buf[i++]=128|c>>>12&63;buf[i++]=128|c>>>6&63;buf[i++]=128|c&63}}return buf};function buf2binstring(buf,len){if(len<65537)if(buf.subarray&&STR_APPLY_UIA_OK||!buf.subarray&&STR_APPLY_OK)return String.fromCharCode.apply(null,utils.shrinkBuf(buf,len));var result="";for(var i=0;i4){utf16buf[out++]=65533;i+=c_len-1;continue}c&=c_len===2?31:c_len===3?15:7;while(c_len>1&&i1){utf16buf[out++]=65533;continue}if(c<65536)utf16buf[out++]= +c;else{c-=65536;utf16buf[out++]=55296|c>>10&1023;utf16buf[out++]=56320|c&1023}}return buf2binstring(utf16buf,out)};exports.utf8border=function(buf,max){var pos;max=max||buf.length;if(max>buf.length)max=buf.length;pos=max-1;while(pos>=0&&(buf[pos]&192)===128)pos--;if(pos<0)return max;if(pos===0)return max;return pos+_utf8len[buf[pos]]>max?pos:max}},{"./common":27}],29:[function(_dereq_,module,exports){function adler32(adler,buf,len,pos){var s1=adler&65535|0,s2=adler>>>16&65535|0,n=0;while(len!==0){n= +len>2E3?2E3:len;len-=n;do{s1=s1+buf[pos++]|0;s2=s2+s1|0}while(--n);s1%=65521;s2%=65521}return s1|s2<<16|0}module.exports=adler32},{}],30:[function(_dereq_,module,exports){module.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4, +Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],31:[function(_dereq_,module,exports){function makeTable(){var c,table=[];for(var n=0;n<256;n++){c=n;for(var k=0;k<8;k++)c=c&1?3988292384^c>>>1:c>>>1;table[n]=c}return table}var crcTable=makeTable();function crc32(crc,buf,len,pos){var t=crcTable,end=pos+len;crc=crc^-1;for(var i=pos;i>>8^t[(crc^buf[i])&255];return crc^-1}module.exports=crc32},{}],32:[function(_dereq_,module,exports){var utils=_dereq_("../utils/common"); +var trees=_dereq_("./trees");var adler32=_dereq_("./adler32");var crc32=_dereq_("./crc32");var msg=_dereq_("./messages");var Z_NO_FLUSH=0;var Z_PARTIAL_FLUSH=1;var Z_FULL_FLUSH=3;var Z_FINISH=4;var Z_BLOCK=5;var Z_OK=0;var Z_STREAM_END=1;var Z_STREAM_ERROR=-2;var Z_DATA_ERROR=-3;var Z_BUF_ERROR=-5;var Z_DEFAULT_COMPRESSION=-1;var Z_FILTERED=1;var Z_HUFFMAN_ONLY=2;var Z_RLE=3;var Z_FIXED=4;var Z_DEFAULT_STRATEGY=0;var Z_UNKNOWN=2;var Z_DEFLATED=8;var MAX_MEM_LEVEL=9;var MAX_WBITS=15;var DEF_MEM_LEVEL= +8;var LENGTH_CODES=29;var LITERALS=256;var L_CODES=LITERALS+1+LENGTH_CODES;var D_CODES=30;var BL_CODES=19;var HEAP_SIZE=2*L_CODES+1;var MAX_BITS=15;var MIN_MATCH=3;var MAX_MATCH=258;var MIN_LOOKAHEAD=MAX_MATCH+MIN_MATCH+1;var PRESET_DICT=32;var INIT_STATE=42;var EXTRA_STATE=69;var NAME_STATE=73;var COMMENT_STATE=91;var HCRC_STATE=103;var BUSY_STATE=113;var FINISH_STATE=666;var BS_NEED_MORE=1;var BS_BLOCK_DONE=2;var BS_FINISH_STARTED=3;var BS_FINISH_DONE=4;var OS_CODE=3;function err(strm,errorCode){strm.msg= +msg[errorCode];return errorCode}function rank(f){return(f<<1)-(f>4?9:0)}function zero(buf){var len=buf.length;while(--len>=0)buf[len]=0}function flush_pending(strm){var s=strm.state;var len=s.pending;if(len>strm.avail_out)len=strm.avail_out;if(len===0)return;utils.arraySet(strm.output,s.pending_buf,s.pending_out,len,strm.next_out);strm.next_out+=len;s.pending_out+=len;strm.total_out+=len;strm.avail_out-=len;s.pending-=len;if(s.pending===0)s.pending_out=0}function flush_block_only(s,last){trees._tr_flush_block(s, +s.block_start>=0?s.block_start:-1,s.strstart-s.block_start,last);s.block_start=s.strstart;flush_pending(s.strm)}function put_byte(s,b){s.pending_buf[s.pending++]=b}function putShortMSB(s,b){s.pending_buf[s.pending++]=b>>>8&255;s.pending_buf[s.pending++]=b&255}function read_buf(strm,buf,start,size){var len=strm.avail_in;if(len>size)len=size;if(len===0)return 0;strm.avail_in-=len;utils.arraySet(buf,strm.input,strm.next_in,len,start);if(strm.state.wrap===1)strm.adler=adler32(strm.adler,buf,len,start); +else if(strm.state.wrap===2)strm.adler=crc32(strm.adler,buf,len,start);strm.next_in+=len;strm.total_in+=len;return len}function longest_match(s,cur_match){var chain_length=s.max_chain_length;var scan=s.strstart;var match;var len;var best_len=s.prev_length;var nice_match=s.nice_match;var limit=s.strstart>s.w_size-MIN_LOOKAHEAD?s.strstart-(s.w_size-MIN_LOOKAHEAD):0;var _win=s.window;var wmask=s.w_mask;var prev=s.prev;var strend=s.strstart+MAX_MATCH;var scan_end1=_win[scan+best_len-1];var scan_end=_win[scan+ +best_len];if(s.prev_length>=s.good_match)chain_length>>=2;if(nice_match>s.lookahead)nice_match=s.lookahead;do{match=cur_match;if(_win[match+best_len]!==scan_end||_win[match+best_len-1]!==scan_end1||_win[match]!==_win[scan]||_win[++match]!==_win[scan+1])continue;scan+=2;match++;do;while(_win[++scan]===_win[++match]&&_win[++scan]===_win[++match]&&_win[++scan]===_win[++match]&&_win[++scan]===_win[++match]&&_win[++scan]===_win[++match]&&_win[++scan]===_win[++match]&&_win[++scan]===_win[++match]&&_win[++scan]=== +_win[++match]&&scanbest_len){s.match_start=cur_match;best_len=len;if(len>=nice_match)break;scan_end1=_win[scan+best_len-1];scan_end=_win[scan+best_len]}}while((cur_match=prev[cur_match&wmask])>limit&&--chain_length!==0);if(best_len<=s.lookahead)return best_len;return s.lookahead}function fill_window(s){var _w_size=s.w_size;var p,n,m,more,str;do{more=s.window_size-s.lookahead-s.strstart;if(s.strstart>=_w_size+(_w_size-MIN_LOOKAHEAD)){utils.arraySet(s.window, +s.window,_w_size,_w_size,0);s.match_start-=_w_size;s.strstart-=_w_size;s.block_start-=_w_size;n=s.hash_size;p=n;do{m=s.head[--p];s.head[p]=m>=_w_size?m-_w_size:0}while(--n);n=_w_size;p=n;do{m=s.prev[--p];s.prev[p]=m>=_w_size?m-_w_size:0}while(--n);more+=_w_size}if(s.strm.avail_in===0)break;n=read_buf(s.strm,s.window,s.strstart+s.lookahead,more);s.lookahead+=n;if(s.lookahead+s.insert>=MIN_MATCH){str=s.strstart-s.insert;s.ins_h=s.window[str];s.ins_h=(s.ins_h<s.pending_buf_size-5)max_block_size=s.pending_buf_size-5;for(;;){if(s.lookahead<=1){fill_window(s);if(s.lookahead===0&&flush===Z_NO_FLUSH)return BS_NEED_MORE;if(s.lookahead=== +0)break}s.strstart+=s.lookahead;s.lookahead=0;var max_start=s.block_start+max_block_size;if(s.strstart===0||s.strstart>=max_start){s.lookahead=s.strstart-max_start;s.strstart=max_start;flush_block_only(s,false);if(s.strm.avail_out===0)return BS_NEED_MORE}if(s.strstart-s.block_start>=s.w_size-MIN_LOOKAHEAD){flush_block_only(s,false);if(s.strm.avail_out===0)return BS_NEED_MORE}}s.insert=0;if(flush===Z_FINISH){flush_block_only(s,true);if(s.strm.avail_out===0)return BS_FINISH_STARTED;return BS_FINISH_DONE}if(s.strstart> +s.block_start){flush_block_only(s,false);if(s.strm.avail_out===0)return BS_NEED_MORE}return BS_NEED_MORE}function deflate_fast(s,flush){var hash_head;var bflush;for(;;){if(s.lookahead=MIN_MATCH){s.ins_h=(s.ins_h<=MIN_MATCH){bflush=trees._tr_tally(s,s.strstart-s.match_start,s.match_length-MIN_MATCH);s.lookahead-=s.match_length;if(s.match_length<=s.max_lazy_match&&s.lookahead>=MIN_MATCH){s.match_length--;do{s.strstart++;s.ins_h=(s.ins_h<=MIN_MATCH){s.ins_h=(s.ins_h<4096))s.match_length=MIN_MATCH-1}if(s.prev_length>=MIN_MATCH&&s.match_length<=s.prev_length){max_insert=s.strstart+s.lookahead-MIN_MATCH;bflush=trees._tr_tally(s,s.strstart-1-s.prev_match,s.prev_length- +MIN_MATCH);s.lookahead-=s.prev_length-1;s.prev_length-=2;do if(++s.strstart<=max_insert){s.ins_h=(s.ins_h<=MIN_MATCH&&s.strstart>0){scan=s.strstart-1;prev=_win[scan];if(prev===_win[++scan]&&prev===_win[++scan]&&prev===_win[++scan]){strend=s.strstart+MAX_MATCH;do;while(prev===_win[++scan]&&prev===_win[++scan]&&prev===_win[++scan]&&prev===_win[++scan]&& +prev===_win[++scan]&&prev===_win[++scan]&&prev===_win[++scan]&&prev===_win[++scan]&&scans.lookahead)s.match_length=s.lookahead}}if(s.match_length>=MIN_MATCH){bflush=trees._tr_tally(s,1,s.match_length-MIN_MATCH);s.lookahead-=s.match_length;s.strstart+=s.match_length;s.match_length=0}else{bflush=trees._tr_tally(s,0,s.window[s.strstart]);s.lookahead--;s.strstart++}if(bflush){flush_block_only(s,false);if(s.strm.avail_out===0)return BS_NEED_MORE}}s.insert= +0;if(flush===Z_FINISH){flush_block_only(s,true);if(s.strm.avail_out===0)return BS_FINISH_STARTED;return BS_FINISH_DONE}if(s.last_lit){flush_block_only(s,false);if(s.strm.avail_out===0)return BS_NEED_MORE}return BS_BLOCK_DONE}function deflate_huff(s,flush){var bflush;for(;;){if(s.lookahead===0){fill_window(s);if(s.lookahead===0){if(flush===Z_NO_FLUSH)return BS_NEED_MORE;break}}s.match_length=0;bflush=trees._tr_tally(s,0,s.window[s.strstart]);s.lookahead--;s.strstart++;if(bflush){flush_block_only(s, +false);if(s.strm.avail_out===0)return BS_NEED_MORE}}s.insert=0;if(flush===Z_FINISH){flush_block_only(s,true);if(s.strm.avail_out===0)return BS_FINISH_STARTED;return BS_FINISH_DONE}if(s.last_lit){flush_block_only(s,false);if(s.strm.avail_out===0)return BS_NEED_MORE}return BS_BLOCK_DONE}var Config=function(good_length,max_lazy,nice_length,max_chain,func){this.good_length=good_length;this.max_lazy=max_lazy;this.nice_length=nice_length;this.max_chain=max_chain;this.func=func};var configuration_table; +configuration_table=[new Config(0,0,0,0,deflate_stored),new Config(4,4,8,4,deflate_fast),new Config(4,5,16,8,deflate_fast),new Config(4,6,32,32,deflate_fast),new Config(4,4,16,16,deflate_slow),new Config(8,16,32,32,deflate_slow),new Config(8,16,128,128,deflate_slow),new Config(8,32,128,256,deflate_slow),new Config(32,128,258,1024,deflate_slow),new Config(32,258,258,4096,deflate_slow)];function lm_init(s){s.window_size=2*s.w_size;zero(s.head);s.max_lazy_match=configuration_table[s.level].max_lazy; +s.good_match=configuration_table[s.level].good_length;s.nice_match=configuration_table[s.level].nice_length;s.max_chain_length=configuration_table[s.level].max_chain;s.strstart=0;s.block_start=0;s.lookahead=0;s.insert=0;s.match_length=s.prev_length=MIN_MATCH-1;s.match_available=0;s.ins_h=0}function DeflateState(){this.strm=null;this.status=0;this.pending_buf=null;this.pending_buf_size=0;this.pending_out=0;this.pending=0;this.wrap=0;this.gzhead=null;this.gzindex=0;this.method=Z_DEFLATED;this.last_flush= +-1;this.w_size=0;this.w_bits=0;this.w_mask=0;this.window=null;this.window_size=0;this.prev=null;this.head=null;this.ins_h=0;this.hash_size=0;this.hash_bits=0;this.hash_mask=0;this.hash_shift=0;this.block_start=0;this.match_length=0;this.prev_match=0;this.match_available=0;this.strstart=0;this.match_start=0;this.lookahead=0;this.prev_length=0;this.max_chain_length=0;this.max_lazy_match=0;this.level=0;this.strategy=0;this.good_match=0;this.nice_match=0;this.dyn_ltree=new utils.Buf16(HEAP_SIZE*2);this.dyn_dtree= +new utils.Buf16((2*D_CODES+1)*2);this.bl_tree=new utils.Buf16((2*BL_CODES+1)*2);zero(this.dyn_ltree);zero(this.dyn_dtree);zero(this.bl_tree);this.l_desc=null;this.d_desc=null;this.bl_desc=null;this.bl_count=new utils.Buf16(MAX_BITS+1);this.heap=new utils.Buf16(2*L_CODES+1);zero(this.heap);this.heap_len=0;this.heap_max=0;this.depth=new utils.Buf16(2*L_CODES+1);zero(this.depth);this.l_buf=0;this.lit_bufsize=0;this.last_lit=0;this.d_buf=0;this.opt_len=0;this.static_len=0;this.matches=0;this.insert=0; +this.bi_buf=0;this.bi_valid=0}function deflateResetKeep(strm){var s;if(!strm||!strm.state)return err(strm,Z_STREAM_ERROR);strm.total_in=strm.total_out=0;strm.data_type=Z_UNKNOWN;s=strm.state;s.pending=0;s.pending_out=0;if(s.wrap<0)s.wrap=-s.wrap;s.status=s.wrap?INIT_STATE:BUSY_STATE;strm.adler=s.wrap===2?0:1;s.last_flush=Z_NO_FLUSH;trees._tr_init(s);return Z_OK}function deflateReset(strm){var ret=deflateResetKeep(strm);if(ret===Z_OK)lm_init(strm.state);return ret}function deflateSetHeader(strm,head){if(!strm|| +!strm.state)return Z_STREAM_ERROR;if(strm.state.wrap!==2)return Z_STREAM_ERROR;strm.state.gzhead=head;return Z_OK}function deflateInit2(strm,level,method,windowBits,memLevel,strategy){if(!strm)return Z_STREAM_ERROR;var wrap=1;if(level===Z_DEFAULT_COMPRESSION)level=6;if(windowBits<0){wrap=0;windowBits=-windowBits}else if(windowBits>15){wrap=2;windowBits-=16}if(memLevel<1||memLevel>MAX_MEM_LEVEL||method!==Z_DEFLATED||windowBits<8||windowBits>15||level<0||level>9||strategy<0||strategy>Z_FIXED)return err(strm, +Z_STREAM_ERROR);if(windowBits===8)windowBits=9;var s=new DeflateState;strm.state=s;s.strm=strm;s.wrap=wrap;s.gzhead=null;s.w_bits=windowBits;s.w_size=1<>1;s.l_buf=(1+2)*s.lit_bufsize;s.level=level;s.strategy=strategy;s.method=method;return deflateReset(strm)}function deflateInit(strm,level){return deflateInit2(strm,level,Z_DEFLATED,MAX_WBITS,DEF_MEM_LEVEL,Z_DEFAULT_STRATEGY)}function deflate(strm,flush){var old_flush,s;var beg,val;if(!strm||!strm.state||flush>Z_BLOCK||flush<0)return strm?err(strm,Z_STREAM_ERROR):Z_STREAM_ERROR;s=strm.state;if(!strm.output||!strm.input&&strm.avail_in!==0||s.status===FINISH_STATE&&flush!==Z_FINISH)return err(strm, +strm.avail_out===0?Z_BUF_ERROR:Z_STREAM_ERROR);s.strm=strm;old_flush=s.last_flush;s.last_flush=flush;if(s.status===INIT_STATE)if(s.wrap===2){strm.adler=0;put_byte(s,31);put_byte(s,139);put_byte(s,8);if(!s.gzhead){put_byte(s,0);put_byte(s,0);put_byte(s,0);put_byte(s,0);put_byte(s,0);put_byte(s,s.level===9?2:s.strategy>=Z_HUFFMAN_ONLY||s.level<2?4:0);put_byte(s,OS_CODE);s.status=BUSY_STATE}else{put_byte(s,(s.gzhead.text?1:0)+(s.gzhead.hcrc?2:0)+(!s.gzhead.extra?0:4)+(!s.gzhead.name?0:8)+(!s.gzhead.comment? +0:16));put_byte(s,s.gzhead.time&255);put_byte(s,s.gzhead.time>>8&255);put_byte(s,s.gzhead.time>>16&255);put_byte(s,s.gzhead.time>>24&255);put_byte(s,s.level===9?2:s.strategy>=Z_HUFFMAN_ONLY||s.level<2?4:0);put_byte(s,s.gzhead.os&255);if(s.gzhead.extra&&s.gzhead.extra.length){put_byte(s,s.gzhead.extra.length&255);put_byte(s,s.gzhead.extra.length>>8&255)}if(s.gzhead.hcrc)strm.adler=crc32(strm.adler,s.pending_buf,s.pending,0);s.gzindex=0;s.status=EXTRA_STATE}}else{var header=Z_DEFLATED+(s.w_bits-8<< +4)<<8;var level_flags=-1;if(s.strategy>=Z_HUFFMAN_ONLY||s.level<2)level_flags=0;else if(s.level<6)level_flags=1;else if(s.level===6)level_flags=2;else level_flags=3;header|=level_flags<<6;if(s.strstart!==0)header|=PRESET_DICT;header+=31-header%31;s.status=BUSY_STATE;putShortMSB(s,header);if(s.strstart!==0){putShortMSB(s,strm.adler>>>16);putShortMSB(s,strm.adler&65535)}strm.adler=1}if(s.status===EXTRA_STATE)if(s.gzhead.extra){beg=s.pending;while(s.gzindex<(s.gzhead.extra.length&65535)){if(s.pending=== +s.pending_buf_size){if(s.gzhead.hcrc&&s.pending>beg)strm.adler=crc32(strm.adler,s.pending_buf,s.pending-beg,beg);flush_pending(strm);beg=s.pending;if(s.pending===s.pending_buf_size)break}put_byte(s,s.gzhead.extra[s.gzindex]&255);s.gzindex++}if(s.gzhead.hcrc&&s.pending>beg)strm.adler=crc32(strm.adler,s.pending_buf,s.pending-beg,beg);if(s.gzindex===s.gzhead.extra.length){s.gzindex=0;s.status=NAME_STATE}}else s.status=NAME_STATE;if(s.status===NAME_STATE)if(s.gzhead.name){beg=s.pending;do{if(s.pending=== +s.pending_buf_size){if(s.gzhead.hcrc&&s.pending>beg)strm.adler=crc32(strm.adler,s.pending_buf,s.pending-beg,beg);flush_pending(strm);beg=s.pending;if(s.pending===s.pending_buf_size){val=1;break}}if(s.gzindexbeg)strm.adler=crc32(strm.adler,s.pending_buf,s.pending-beg,beg);if(val===0){s.gzindex=0;s.status=COMMENT_STATE}}else s.status=COMMENT_STATE;if(s.status===COMMENT_STATE)if(s.gzhead.comment){beg= +s.pending;do{if(s.pending===s.pending_buf_size){if(s.gzhead.hcrc&&s.pending>beg)strm.adler=crc32(strm.adler,s.pending_buf,s.pending-beg,beg);flush_pending(strm);beg=s.pending;if(s.pending===s.pending_buf_size){val=1;break}}if(s.gzindexbeg)strm.adler=crc32(strm.adler,s.pending_buf,s.pending-beg,beg);if(val===0)s.status=HCRC_STATE}else s.status=HCRC_STATE;if(s.status=== +HCRC_STATE)if(s.gzhead.hcrc){if(s.pending+2>s.pending_buf_size)flush_pending(strm);if(s.pending+2<=s.pending_buf_size){put_byte(s,strm.adler&255);put_byte(s,strm.adler>>8&255);strm.adler=0;s.status=BUSY_STATE}}else s.status=BUSY_STATE;if(s.pending!==0){flush_pending(strm);if(strm.avail_out===0){s.last_flush=-1;return Z_OK}}else if(strm.avail_in===0&&rank(flush)<=rank(old_flush)&&flush!==Z_FINISH)return err(strm,Z_BUF_ERROR);if(s.status===FINISH_STATE&&strm.avail_in!==0)return err(strm,Z_BUF_ERROR); +if(strm.avail_in!==0||s.lookahead!==0||flush!==Z_NO_FLUSH&&s.status!==FINISH_STATE){var bstate=s.strategy===Z_HUFFMAN_ONLY?deflate_huff(s,flush):s.strategy===Z_RLE?deflate_rle(s,flush):configuration_table[s.level].func(s,flush);if(bstate===BS_FINISH_STARTED||bstate===BS_FINISH_DONE)s.status=FINISH_STATE;if(bstate===BS_NEED_MORE||bstate===BS_FINISH_STARTED){if(strm.avail_out===0)s.last_flush=-1;return Z_OK}if(bstate===BS_BLOCK_DONE){if(flush===Z_PARTIAL_FLUSH)trees._tr_align(s);else if(flush!==Z_BLOCK){trees._tr_stored_block(s, +0,0,false);if(flush===Z_FULL_FLUSH){zero(s.head);if(s.lookahead===0){s.strstart=0;s.block_start=0;s.insert=0}}}flush_pending(strm);if(strm.avail_out===0){s.last_flush=-1;return Z_OK}}}if(flush!==Z_FINISH)return Z_OK;if(s.wrap<=0)return Z_STREAM_END;if(s.wrap===2){put_byte(s,strm.adler&255);put_byte(s,strm.adler>>8&255);put_byte(s,strm.adler>>16&255);put_byte(s,strm.adler>>24&255);put_byte(s,strm.total_in&255);put_byte(s,strm.total_in>>8&255);put_byte(s,strm.total_in>>16&255);put_byte(s,strm.total_in>> +24&255)}else{putShortMSB(s,strm.adler>>>16);putShortMSB(s,strm.adler&65535)}flush_pending(strm);if(s.wrap>0)s.wrap=-s.wrap;return s.pending!==0?Z_OK:Z_STREAM_END}function deflateEnd(strm){var status;if(!strm||!strm.state)return Z_STREAM_ERROR;status=strm.state.status;if(status!==INIT_STATE&&status!==EXTRA_STATE&&status!==NAME_STATE&&status!==COMMENT_STATE&&status!==HCRC_STATE&&status!==BUSY_STATE&&status!==FINISH_STATE)return err(strm,Z_STREAM_ERROR);strm.state=null;return status===BUSY_STATE?err(strm, +Z_DATA_ERROR):Z_OK}exports.deflateInit=deflateInit;exports.deflateInit2=deflateInit2;exports.deflateReset=deflateReset;exports.deflateResetKeep=deflateResetKeep;exports.deflateSetHeader=deflateSetHeader;exports.deflate=deflate;exports.deflateEnd=deflateEnd;exports.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":27,"./adler32":29,"./crc32":31,"./messages":37,"./trees":38}],33:[function(_dereq_,module,exports){function GZheader(){this.text=0;this.time=0;this.xflags=0;this.os=0; +this.extra=null;this.extra_len=0;this.name="";this.comment="";this.hcrc=0;this.done=false}module.exports=GZheader},{}],34:[function(_dereq_,module,exports){var BAD=30;var TYPE=12;module.exports=function inflate_fast(strm,start){var state;var _in;var last;var _out;var beg;var end;var dmax;var wsize;var whave;var wnext;var window;var hold;var bits;var lcode;var dcode;var lmask;var dmask;var here;var op;var len;var dist;var from;var from_source;var input,output;state=strm.state;_in=strm.next_in;input= +strm.input;last=_in+(strm.avail_in-5);_out=strm.next_out;output=strm.output;beg=_out-(start-strm.avail_out);end=_out+(strm.avail_out-257);dmax=state.dmax;wsize=state.wsize;whave=state.whave;wnext=state.wnext;window=state.window;hold=state.hold;bits=state.bits;lcode=state.lencode;dcode=state.distcode;lmask=(1<>>24;hold>>>=op; +bits-=op;op=here>>>16&255;if(op===0)output[_out++]=here&65535;else if(op&16){len=here&65535;op&=15;if(op){if(bits>>=op;bits-=op}if(bits<15){hold+=input[_in++]<>>24;hold>>>=op;bits-=op;op=here>>>16&255;if(op&16){dist=here&65535;op&=15;if(bitsdmax){strm.msg="invalid distance too far back";state.mode=BAD;break top}hold>>>=op;bits-=op;op=_out-beg;if(dist>op){op=dist-op;if(op>whave)if(state.sane){strm.msg="invalid distance too far back";state.mode=BAD;break top}from=0;from_source=window;if(wnext===0){from+=wsize-op;if(op2){output[_out++]=from_source[from++];output[_out++]=from_source[from++];output[_out++]=from_source[from++];len-=3}if(len){output[_out++]=from_source[from++];if(len>1)output[_out++]=from_source[from++]}}else{from=_out-dist;do{output[_out++]=output[from++];output[_out++]= +output[from++];output[_out++]=output[from++];len-=3}while(len>2);if(len){output[_out++]=output[from++];if(len>1)output[_out++]=output[from++]}}}else if((op&64)===0){here=dcode[(here&65535)+(hold&(1<>3;_in-=len;bits-=len<<3;hold&=(1<>>24&255)+(q>>>8&65280)+((q&65280)<<8)+((q&255)<<24)}function InflateState(){this.mode=0;this.last=false;this.wrap=0;this.havedict=false;this.flags=0;this.dmax=0;this.check=0;this.total=0;this.head=null;this.wbits=0;this.wsize=0;this.whave=0;this.wnext=0;this.window=null;this.hold=0;this.bits=0;this.length=0;this.offset= +0;this.extra=0;this.lencode=null;this.distcode=null;this.lenbits=0;this.distbits=0;this.ncode=0;this.nlen=0;this.ndist=0;this.have=0;this.next=null;this.lens=new utils.Buf16(320);this.work=new utils.Buf16(288);this.lendyn=null;this.distdyn=null;this.sane=0;this.back=0;this.was=0}function inflateResetKeep(strm){var state;if(!strm||!strm.state)return Z_STREAM_ERROR;state=strm.state;strm.total_in=strm.total_out=state.total=0;strm.msg="";if(state.wrap)strm.adler=state.wrap&1;state.mode=HEAD;state.last= +0;state.havedict=0;state.dmax=32768;state.head=null;state.hold=0;state.bits=0;state.lencode=state.lendyn=new utils.Buf32(ENOUGH_LENS);state.distcode=state.distdyn=new utils.Buf32(ENOUGH_DISTS);state.sane=1;state.back=-1;return Z_OK}function inflateReset(strm){var state;if(!strm||!strm.state)return Z_STREAM_ERROR;state=strm.state;state.wsize=0;state.whave=0;state.wnext=0;return inflateResetKeep(strm)}function inflateReset2(strm,windowBits){var wrap;var state;if(!strm||!strm.state)return Z_STREAM_ERROR; +state=strm.state;if(windowBits<0){wrap=0;windowBits=-windowBits}else{wrap=(windowBits>>4)+1;if(windowBits<48)windowBits&=15}if(windowBits&&(windowBits<8||windowBits>15))return Z_STREAM_ERROR;if(state.window!==null&&state.wbits!==windowBits)state.window=null;state.wrap=wrap;state.wbits=windowBits;return inflateReset(strm)}function inflateInit2(strm,windowBits){var ret;var state;if(!strm)return Z_STREAM_ERROR;state=new InflateState;strm.state=state;state.window=null;ret=inflateReset2(strm,windowBits); +if(ret!==Z_OK)strm.state=null;return ret}function inflateInit(strm){return inflateInit2(strm,DEF_WBITS)}var virgin=true;var lenfix,distfix;function fixedtables(state){if(virgin){var sym;lenfix=new utils.Buf32(512);distfix=new utils.Buf32(32);sym=0;while(sym<144)state.lens[sym++]=8;while(sym<256)state.lens[sym++]=9;while(sym<280)state.lens[sym++]=7;while(sym<288)state.lens[sym++]=8;inflate_table(LENS,state.lens,0,288,lenfix,0,state.work,{bits:9});sym=0;while(sym<32)state.lens[sym++]=5;inflate_table(DISTS, +state.lens,0,32,distfix,0,state.work,{bits:5});virgin=false}state.lencode=lenfix;state.lenbits=9;state.distcode=distfix;state.distbits=5}function updatewindow(strm,src,end,copy){var dist;var state=strm.state;if(state.window===null){state.wsize=1<=state.wsize){utils.arraySet(state.window,src,end-state.wsize,state.wsize,0);state.wnext=0;state.whave=state.wsize}else{dist=state.wsize-state.wnext;if(dist>copy)dist= +copy;utils.arraySet(state.window,src,end-copy,dist,state.wnext);copy-=dist;if(copy){utils.arraySet(state.window,src,end-copy,copy,0);state.wnext=copy;state.whave=state.wsize}else{state.wnext+=dist;if(state.wnext===state.wsize)state.wnext=0;if(state.whave>>8&255;state.check=crc32(state.check,hbuf,2,0);hold=0;bits=0;state.mode=FLAGS;break}state.flags=0;if(state.head)state.head.done=false;if(!(state.wrap&1)||(((hold&255)<<8)+(hold>>8))%31){strm.msg="incorrect header check";state.mode=BAD;break}if((hold&15)!==Z_DEFLATED){strm.msg="unknown compression method";state.mode= +BAD;break}hold>>>=4;bits-=4;len=(hold&15)+8;if(state.wbits===0)state.wbits=len;else if(len>state.wbits){strm.msg="invalid window size";state.mode=BAD;break}state.dmax=1<>8&1;if(state.flags&512){hbuf[0]=hold&255;hbuf[1]=hold>>>8&255;state.check=crc32(state.check,hbuf,2,0)}hold=0;bits=0;state.mode=TIME;case TIME:while(bits<32){if(have===0)break inf_leave;have--;hold+=input[next++]<>>8&255;hbuf[2]=hold>>>16&255;hbuf[3]=hold>>>24&255;state.check=crc32(state.check,hbuf,4,0)}hold=0;bits=0;state.mode=OS;case OS:while(bits< +16){if(have===0)break inf_leave;have--;hold+=input[next++]<>8}if(state.flags&512){hbuf[0]=hold&255;hbuf[1]=hold>>>8&255;state.check=crc32(state.check,hbuf,2,0)}hold=0;bits=0;state.mode=EXLEN;case EXLEN:if(state.flags&1024){while(bits<16){if(have===0)break inf_leave;have--;hold+=input[next++]<>>8&255;state.check= +crc32(state.check,hbuf,2,0)}hold=0;bits=0}else if(state.head)state.head.extra=null;state.mode=EXTRA;case EXTRA:if(state.flags&1024){copy=state.length;if(copy>have)copy=have;if(copy){if(state.head){len=state.head.extra_len-state.length;if(!state.head.extra)state.head.extra=new Array(state.head.extra_len);utils.arraySet(state.head.extra,input,next,copy,len)}if(state.flags&512)state.check=crc32(state.check,input,copy,next);have-=copy;next+=copy;state.length-=copy}if(state.length)break inf_leave}state.length= +0;state.mode=NAME;case NAME:if(state.flags&2048){if(have===0)break inf_leave;copy=0;do{len=input[next+copy++];if(state.head&&len&&state.length<65536)state.head.name+=String.fromCharCode(len)}while(len&©>9&1;state.head.done=true}strm.adler=state.check=0;state.mode=TYPE;break;case DICTID:while(bits<32){if(have===0)break inf_leave;have--;hold+=input[next++]<>>=bits&7;bits-=bits&7;state.mode=CHECK;break}while(bits<3){if(have===0)break inf_leave;have--;hold+=input[next++]<>>=1;bits-=1;switch(hold&3){case 0:state.mode=STORED;break;case 1:fixedtables(state);state.mode=LEN_;if(flush===Z_TREES){hold>>>=2;bits-=2;break inf_leave}break;case 2:state.mode=TABLE;break;case 3:strm.msg="invalid block type";state.mode=BAD}hold>>>=2;bits-=2;break;case STORED:hold>>>=bits&7;bits-=bits&7;while(bits< +32){if(have===0)break inf_leave;have--;hold+=input[next++]<>>16^65535)){strm.msg="invalid stored block lengths";state.mode=BAD;break}state.length=hold&65535;hold=0;bits=0;state.mode=COPY_;if(flush===Z_TREES)break inf_leave;case COPY_:state.mode=COPY;case COPY:copy=state.length;if(copy){if(copy>have)copy=have;if(copy>left)copy=left;if(copy===0)break inf_leave;utils.arraySet(output,input,next,copy,put);have-=copy;next+=copy;left-=copy;put+=copy;state.length-=copy; +break}state.mode=TYPE;break;case TABLE:while(bits<14){if(have===0)break inf_leave;have--;hold+=input[next++]<>>=5;bits-=5;state.ndist=(hold&31)+1;hold>>>=5;bits-=5;state.ncode=(hold&15)+4;hold>>>=4;bits-=4;if(state.nlen>286||state.ndist>30){strm.msg="too many length or distance symbols";state.mode=BAD;break}state.have=0;state.mode=LENLENS;case LENLENS:while(state.have>>=3;bits-=3}while(state.have<19)state.lens[order[state.have++]]=0;state.lencode=state.lendyn;state.lenbits=7;opts={bits:state.lenbits};ret=inflate_table(CODES,state.lens,0,19,state.lencode,0,state.work,opts);state.lenbits=opts.bits;if(ret){strm.msg="invalid code lengths set";state.mode=BAD;break}state.have=0;state.mode=CODELENS;case CODELENS:while(state.have>>24;here_op=here>>>16&255;here_val=here&65535;if(here_bits<=bits)break;if(have===0)break inf_leave;have--;hold+=input[next++]<>>=here_bits;bits-=here_bits;state.lens[state.have++]=here_val}else{if(here_val===16){n=here_bits+2;while(bits>>=here_bits;bits-=here_bits;if(state.have===0){strm.msg="invalid bit length repeat";state.mode=BAD;break}len=state.lens[state.have-1];copy=3+(hold& +3);hold>>>=2;bits-=2}else if(here_val===17){n=here_bits+3;while(bits>>=here_bits;bits-=here_bits;len=0;copy=3+(hold&7);hold>>>=3;bits-=3}else{n=here_bits+7;while(bits>>=here_bits;bits-=here_bits;len=0;copy=11+(hold&127);hold>>>=7;bits-=7}if(state.have+copy>state.nlen+state.ndist){strm.msg="invalid bit length repeat";state.mode=BAD;break}while(copy--)state.lens[state.have++]= +len}}if(state.mode===BAD)break;if(state.lens[256]===0){strm.msg="invalid code -- missing end-of-block";state.mode=BAD;break}state.lenbits=9;opts={bits:state.lenbits};ret=inflate_table(LENS,state.lens,0,state.nlen,state.lencode,0,state.work,opts);state.lenbits=opts.bits;if(ret){strm.msg="invalid literal/lengths set";state.mode=BAD;break}state.distbits=6;state.distcode=state.distdyn;opts={bits:state.distbits};ret=inflate_table(DISTS,state.lens,state.nlen,state.ndist,state.distcode,0,state.work,opts); +state.distbits=opts.bits;if(ret){strm.msg="invalid distances set";state.mode=BAD;break}state.mode=LEN_;if(flush===Z_TREES)break inf_leave;case LEN_:state.mode=LEN;case LEN:if(have>=6&&left>=258){strm.next_out=put;strm.avail_out=left;strm.next_in=next;strm.avail_in=have;state.hold=hold;state.bits=bits;inflate_fast(strm,_out);put=strm.next_out;output=strm.output;left=strm.avail_out;next=strm.next_in;input=strm.input;have=strm.avail_in;hold=state.hold;bits=state.bits;if(state.mode===TYPE)state.back= +-1;break}state.back=0;for(;;){here=state.lencode[hold&(1<>>24;here_op=here>>>16&255;here_val=here&65535;if(here_bits<=bits)break;if(have===0)break inf_leave;have--;hold+=input[next++]<>last_bits)];here_bits=here>>>24;here_op=here>>>16&255;here_val=here&65535;if(last_bits+here_bits<=bits)break;if(have=== +0)break inf_leave;have--;hold+=input[next++]<>>=last_bits;bits-=last_bits;state.back+=last_bits}hold>>>=here_bits;bits-=here_bits;state.back+=here_bits;state.length=here_val;if(here_op===0){state.mode=LIT;break}if(here_op&32){state.back=-1;state.mode=TYPE;break}if(here_op&64){strm.msg="invalid literal/length code";state.mode=BAD;break}state.extra=here_op&15;state.mode=LENEXT;case LENEXT:if(state.extra){n=state.extra;while(bits>>=state.extra;bits-=state.extra;state.back+=state.extra}state.was=state.length;state.mode=DIST;case DIST:for(;;){here=state.distcode[hold&(1<>>24;here_op=here>>>16&255;here_val=here&65535;if(here_bits<=bits)break;if(have===0)break inf_leave;have--;hold+=input[next++]<>last_bits)];here_bits=here>>>24;here_op=here>>>16&255;here_val=here&65535;if(last_bits+here_bits<=bits)break;if(have===0)break inf_leave;have--;hold+=input[next++]<>>=last_bits;bits-=last_bits;state.back+=last_bits}hold>>>=here_bits;bits-=here_bits;state.back+=here_bits;if(here_op&64){strm.msg="invalid distance code";state.mode=BAD;break}state.offset=here_val;state.extra=here_op&15;state.mode=DISTEXT;case DISTEXT:if(state.extra){n=state.extra;while(bits>>=state.extra;bits-=state.extra;state.back+=state.extra}if(state.offset>state.dmax){strm.msg="invalid distance too far back";state.mode=BAD;break}state.mode=MATCH;case MATCH:if(left===0)break inf_leave;copy=_out-left;if(state.offset>copy){copy=state.offset-copy;if(copy>state.whave)if(state.sane){strm.msg="invalid distance too far back";state.mode=BAD;break}if(copy>state.wnext){copy-=state.wnext; +from=state.wsize-copy}else from=state.wnext-copy;if(copy>state.length)copy=state.length;from_source=state.window}else{from_source=output;from=put-state.offset;copy=state.length}if(copy>left)copy=left;left-=copy;state.length-=copy;do output[put++]=from_source[from++];while(--copy);if(state.length===0)state.mode=LEN;break;case LIT:if(left===0)break inf_leave;output[put++]=state.length;left--;state.mode=LEN;break;case CHECK:if(state.wrap){while(bits<32){if(have===0)break inf_leave;have--;hold|=input[next++]<< +bits;bits+=8}_out-=left;strm.total_out+=_out;state.total+=_out;if(_out)strm.adler=state.check=state.flags?crc32(state.check,output,_out,put-_out):adler32(state.check,output,_out,put-_out);_out=left;if((state.flags?hold:ZSWAP32(hold))!==state.check){strm.msg="incorrect data check";state.mode=BAD;break}hold=0;bits=0}state.mode=LENGTH;case LENGTH:if(state.wrap&&state.flags){while(bits<32){if(have===0)break inf_leave;have--;hold+=input[next++]<=1;max--)if(count[max]!==0)break;if(root>max)root=max;if(max===0){table[table_index++]=1<<24|64<<16|0;table[table_index++]= +1<<24|64<<16|0;opts.bits=1;return 0}for(min=1;min0&&(type===CODES||max!==1))return-1;offs[1]=0;for(len=1;lenENOUGH_LENS||type===DISTS&&used>ENOUGH_DISTS)return 1;var i=0;for(;;){i++;here_bits=len-drop;if(work[sym]end){here_op=extra[extra_index+work[sym]];here_val=base[base_index+work[sym]]}else{here_op=32+64;here_val=0}incr=1<>drop)+fill]= +here_bits<<24|here_op<<16|here_val|0}while(fill!==0);incr=1<>=1;if(incr!==0){huff&=incr-1;huff+=incr}else huff=0;sym++;if(--count[len]===0){if(len===max)break;len=lens[lens_index+work[sym]]}if(len>root&&(huff&mask)!==low){if(drop===0)drop=root;next+=min;curr=len-drop;left=1<ENOUGH_LENS||type===DISTS&&used>ENOUGH_DISTS)return 1;low=huff&mask;table[low]=root<< +24|curr<<16|next-table_index|0}}if(huff!==0)table[next+huff]=len-drop<<24|64<<16|0;opts.bits=root;return 0}},{"../utils/common":27}],37:[function(_dereq_,module,exports){module.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],38:[function(_dereq_,module,exports){var utils=_dereq_("../utils/common");var Z_FIXED=4;var Z_BINARY=0;var Z_TEXT=1;var Z_UNKNOWN=2;function zero(buf){var len= +buf.length;while(--len>=0)buf[len]=0}var STORED_BLOCK=0;var STATIC_TREES=1;var DYN_TREES=2;var MIN_MATCH=3;var MAX_MATCH=258;var LENGTH_CODES=29;var LITERALS=256;var L_CODES=LITERALS+1+LENGTH_CODES;var D_CODES=30;var BL_CODES=19;var HEAP_SIZE=2*L_CODES+1;var MAX_BITS=15;var Buf_size=16;var MAX_BL_BITS=7;var END_BLOCK=256;var REP_3_6=16;var REPZ_3_10=17;var REPZ_11_138=18;var extra_lbits=[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];var extra_dbits=[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];var extra_blbits=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7];var bl_order=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];var DIST_CODE_LEN=512;var static_ltree=new Array((L_CODES+2)*2);zero(static_ltree);var static_dtree=new Array(D_CODES*2);zero(static_dtree);var _dist_code=new Array(DIST_CODE_LEN);zero(_dist_code);var _length_code=new Array(MAX_MATCH-MIN_MATCH+1);zero(_length_code);var base_length=new Array(LENGTH_CODES);zero(base_length);var base_dist=new Array(D_CODES); +zero(base_dist);var StaticTreeDesc=function(static_tree,extra_bits,extra_base,elems,max_length){this.static_tree=static_tree;this.extra_bits=extra_bits;this.extra_base=extra_base;this.elems=elems;this.max_length=max_length;this.has_stree=static_tree&&static_tree.length};var static_l_desc;var static_d_desc;var static_bl_desc;var TreeDesc=function(dyn_tree,stat_desc){this.dyn_tree=dyn_tree;this.max_code=0;this.stat_desc=stat_desc};function d_code(dist){return dist<256?_dist_code[dist]:_dist_code[256+ +(dist>>>7)]}function put_short(s,w){s.pending_buf[s.pending++]=w&255;s.pending_buf[s.pending++]=w>>>8&255}function send_bits(s,value,length){if(s.bi_valid>Buf_size-length){s.bi_buf|=value<>Buf_size-s.bi_valid;s.bi_valid+=length-Buf_size}else{s.bi_buf|=value<>>=1;res<<=1}while(--len>0); +return res>>>1}function bi_flush(s){if(s.bi_valid===16){put_short(s,s.bi_buf);s.bi_buf=0;s.bi_valid=0}else if(s.bi_valid>=8){s.pending_buf[s.pending++]=s.bi_buf&255;s.bi_buf>>=8;s.bi_valid-=8}}function gen_bitlen(s,desc){var tree=desc.dyn_tree;var max_code=desc.max_code;var stree=desc.stat_desc.static_tree;var has_stree=desc.stat_desc.has_stree;var extra=desc.stat_desc.extra_bits;var base=desc.stat_desc.extra_base;var max_length=desc.stat_desc.max_length;var h;var n,m;var bits;var xbits;var f;var overflow= +0;for(bits=0;bits<=MAX_BITS;bits++)s.bl_count[bits]=0;tree[s.heap[s.heap_max]*2+1]=0;for(h=s.heap_max+1;hmax_length){bits=max_length;overflow++}tree[n*2+1]=bits;if(n>max_code)continue;s.bl_count[bits]++;xbits=0;if(n>=base)xbits=extra[n-base];f=tree[n*2];s.opt_len+=f*(bits+xbits);if(has_stree)s.static_len+=f*(stree[n*2+1]+xbits)}if(overflow===0)return;do{bits=max_length-1;while(s.bl_count[bits]===0)bits--;s.bl_count[bits]--;s.bl_count[bits+ +1]+=2;s.bl_count[max_length]--;overflow-=2}while(overflow>0);for(bits=max_length;bits!==0;bits--){n=s.bl_count[bits];while(n!==0){m=s.heap[--h];if(m>max_code)continue;if(tree[m*2+1]!==bits){s.opt_len+=(bits-tree[m*2+1])*tree[m*2];tree[m*2+1]=bits}n--}}}function gen_codes(tree,max_code,bl_count){var next_code=new Array(MAX_BITS+1);var code=0;var bits;var n;for(bits=1;bits<=MAX_BITS;bits++)next_code[bits]=code=code+bl_count[bits-1]<<1;for(n=0;n<=max_code;n++){var len=tree[n*2+1];if(len===0)continue; +tree[n*2]=bi_reverse(next_code[len]++,len)}}function tr_static_init(){var n;var bits;var length;var code;var dist;var bl_count=new Array(MAX_BITS+1);length=0;for(code=0;code>=7;for(;code8)put_short(s,s.bi_buf);else if(s.bi_valid>0)s.pending_buf[s.pending++]= +s.bi_buf;s.bi_buf=0;s.bi_valid=0}function copy_block(s,buf,len,header){bi_windup(s);if(header){put_short(s,len);put_short(s,~len)}utils.arraySet(s.pending_buf,s.window,buf,len,s.pending);s.pending+=len}function smaller(tree,n,m,depth){var _n2=n*2;var _m2=m*2;return tree[_n2]>1;n>=1;n--)pqdownheap(s,tree,n);node=elems;do{n=s.heap[1];s.heap[1]=s.heap[s.heap_len--];pqdownheap(s,tree,1);m=s.heap[1];s.heap[--s.heap_max]=n;s.heap[--s.heap_max]=m;tree[node*2]=tree[n*2]+tree[m*2];s.depth[node]=(s.depth[n]>=s.depth[m]?s.depth[n]:s.depth[m])+1;tree[n*2+1]=tree[m*2+1]=node;s.heap[1]=node++;pqdownheap(s,tree,1)}while(s.heap_len>=2);s.heap[--s.heap_max]=s.heap[1];gen_bitlen(s, +desc);gen_codes(tree,max_code,s.bl_count)}function scan_tree(s,tree,max_code){var n;var prevlen=-1;var curlen;var nextlen=tree[0*2+1];var count=0;var max_count=7;var min_count=4;if(nextlen===0){max_count=138;min_count=3}tree[(max_code+1)*2+1]=65535;for(n=0;n<=max_code;n++){curlen=nextlen;nextlen=tree[(n+1)*2+1];if(++count=3;max_blindex--)if(s.bl_tree[bl_order[max_blindex]*2+1]!==0)break;s.opt_len+=3*(max_blindex+1)+5+5+4;return max_blindex}function send_all_trees(s,lcodes,dcodes,blcodes){var rank;send_bits(s,lcodes-257,5);send_bits(s,dcodes-1,5);send_bits(s,blcodes-4,4);for(rank=0;rank>>=1)if(black_mask&1&&s.dyn_ltree[n*2]!==0)return Z_BINARY;if(s.dyn_ltree[9*2]!==0||s.dyn_ltree[10*2]!==0||s.dyn_ltree[13*2]!==0)return Z_TEXT;for(n=32;n0){if(s.strm.data_type===Z_UNKNOWN)s.strm.data_type= +detect_data_type(s);build_tree(s,s.l_desc);build_tree(s,s.d_desc);max_blindex=build_bl_tree(s);opt_lenb=s.opt_len+3+7>>>3;static_lenb=s.static_len+3+7>>>3;if(static_lenb<=opt_lenb)opt_lenb=static_lenb}else opt_lenb=static_lenb=stored_len+5;if(stored_len+4<=opt_lenb&&buf!==-1)_tr_stored_block(s,buf,stored_len,last);else if(s.strategy===Z_FIXED||static_lenb===opt_lenb){send_bits(s,(STATIC_TREES<<1)+(last?1:0),3);compress_block(s,static_ltree,static_dtree)}else{send_bits(s,(DYN_TREES<<1)+(last?1:0), +3);send_all_trees(s,s.l_desc.max_code+1,s.d_desc.max_code+1,max_blindex+1);compress_block(s,s.dyn_ltree,s.dyn_dtree)}init_block(s);if(last)bi_windup(s)}function _tr_tally(s,dist,lc){s.pending_buf[s.d_buf+s.last_lit*2]=dist>>>8&255;s.pending_buf[s.d_buf+s.last_lit*2+1]=dist&255;s.pending_buf[s.l_buf+s.last_lit]=lc&255;s.last_lit++;if(dist===0)s.dyn_ltree[lc*2]++;else{s.matches++;dist--;s.dyn_ltree[(_length_code[lc]+LITERALS+1)*2]++;s.dyn_dtree[d_code(dist)*2]++}return s.last_lit===s.lit_bufsize-1} +exports._tr_init=_tr_init;exports._tr_stored_block=_tr_stored_block;exports._tr_flush_block=_tr_flush_block;exports._tr_tally=_tr_tally;exports._tr_align=_tr_align},{"../utils/common":27}],39:[function(_dereq_,module,exports){function ZStream(){this.input=null;this.next_in=0;this.avail_in=0;this.total_in=0;this.output=null;this.next_out=0;this.avail_out=0;this.total_out=0;this.msg="";this.state=null;this.data_type=2;this.adler=0}module.exports=ZStream},{}]},{},[9])(9)}); From e414291af6e75d1969f5f41e354da08e92254807 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Tue, 17 Nov 2015 20:06:59 +0100 Subject: [PATCH 2/5] [ADD] readd our tweaks --- attachment_preview/static/lib/ViewerJS/index.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/attachment_preview/static/lib/ViewerJS/index.html b/attachment_preview/static/lib/ViewerJS/index.html index 2eb1fd47..c79df466 100644 --- a/attachment_preview/static/lib/ViewerJS/index.html +++ b/attachment_preview/static/lib/ViewerJS/index.html @@ -74,6 +74,8 @@ c;a?(e.title||(e.title=a.replace(/^.*[\\\/]/,"")),e.documentUrl=a,b(a,function(b //]]> + + From 5b02ff9aa82aefa13feac393770437a8aab3a757 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Tue, 17 Nov 2015 21:08:20 +0100 Subject: [PATCH 3/5] [FIX] pass file extension where newer viewerjs versions expect it fixes #67 --- attachment_preview/static/src/js/attachment_preview.js | 5 +++-- attachment_preview/static/src/js/viewerjs_tweaks.js | 4 ++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/attachment_preview/static/src/js/attachment_preview.js b/attachment_preview/static/src/js/attachment_preview.js index d75e9922..f47426d3 100644 --- a/attachment_preview/static/src/js/attachment_preview.js +++ b/attachment_preview/static/src/js/attachment_preview.js @@ -27,10 +27,11 @@ openerp.attachment_preview = function(instance) attachment_title) { var url = (window.location.origin || '') + - '/attachment_preview/static/lib/ViewerJS/index.html#' + + '/attachment_preview/static/lib/ViewerJS/index.html' + + '&type=' + encodeURIComponent(attachment_extension) + + '#' + attachment_url.replace(window.location.origin, '') + '&title=' + encodeURIComponent(attachment_title) + - '&ext=.' + encodeURIComponent(attachment_extension); window.open(url); }; openerp.attachment_preview.can_preview = function(extension) diff --git a/attachment_preview/static/src/js/viewerjs_tweaks.js b/attachment_preview/static/src/js/viewerjs_tweaks.js index 197aba59..2eb1968f 100644 --- a/attachment_preview/static/src/js/viewerjs_tweaks.js +++ b/attachment_preview/static/src/js/viewerjs_tweaks.js @@ -24,6 +24,10 @@ var original_Viewer = Viewer; Viewer = function(plugin, parameters) { + if(!plugin) + { + alert('Unsupported file type'); + } var matches = (/&title=([^&]+)&/).exec(window.location.hash); if(matches && matches.length > 1) { From e92e6e79c0a2d0b46811a93b25e64e055026aa1e Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Wed, 18 Nov 2015 08:44:46 +0100 Subject: [PATCH 4/5] [IMP] simplify code --- attachment_preview/static/src/js/attachment_preview.js | 6 +++--- attachment_preview/static/src/js/viewerjs_tweaks.js | 5 ----- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/attachment_preview/static/src/js/attachment_preview.js b/attachment_preview/static/src/js/attachment_preview.js index f47426d3..2f3d7b46 100644 --- a/attachment_preview/static/src/js/attachment_preview.js +++ b/attachment_preview/static/src/js/attachment_preview.js @@ -28,10 +28,10 @@ openerp.attachment_preview = function(instance) { var url = (window.location.origin || '') + '/attachment_preview/static/lib/ViewerJS/index.html' + - '&type=' + encodeURIComponent(attachment_extension) + - '#' + - attachment_url.replace(window.location.origin, '') + + '?type=' + encodeURIComponent(attachment_extension) + '&title=' + encodeURIComponent(attachment_title) + + '#' + + attachment_url.replace(window.location.origin, '') window.open(url); }; openerp.attachment_preview.can_preview = function(extension) diff --git a/attachment_preview/static/src/js/viewerjs_tweaks.js b/attachment_preview/static/src/js/viewerjs_tweaks.js index 2eb1968f..0adb7d14 100644 --- a/attachment_preview/static/src/js/viewerjs_tweaks.js +++ b/attachment_preview/static/src/js/viewerjs_tweaks.js @@ -28,10 +28,5 @@ Viewer = function(plugin, parameters) { alert('Unsupported file type'); } - var matches = (/&title=([^&]+)&/).exec(window.location.hash); - if(matches && matches.length > 1) - { - parameters.title = decodeURIComponent(matches[1]); - } return original_Viewer(plugin, parameters); } From 56d48d2ab9b02b8ab3f415ebb7e2546d4994be79 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Wed, 18 Nov 2015 08:49:33 +0100 Subject: [PATCH 5/5] [IMP] use current OCA template for README --- attachment_preview/README.rst | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/attachment_preview/README.rst b/attachment_preview/README.rst index 4f6feebe..6dcebbd4 100644 --- a/attachment_preview/README.rst +++ b/attachment_preview/README.rst @@ -19,6 +19,22 @@ Usage The module adds a little print preview icon right of download links for attachments or binary fields. +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/118/8.0 + +For further information, please visit: + +* https://www.odoo.com/forum/help-1 + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed feedback +`here `_. + Credits =======