(function() { var FormatDialog, HyperLinkDialog, OpenPage; OpenPage = class OpenPage extends this.OS.GUI.BaseApplication { constructor(args) { super("OpenPage", args); } main() { var me; // load session class //if not OpenPage.EditorSession // require ["webodf/editor/EditorSession"], (ES) -> // OpenPage.EditorSession = ES me = this; this.eventSubscriptions = new core.EventSubscriptions(); this.initToolbox(); this.userid = `${this.systemsetting.user.username}@${this.pid}`; //file = "home://welcome.odt" //file = "#{@_api.handler.get}/home://welcome.odt" //@canvas.load file //odfContainer = new odf.OdfContainer file, (c) -> // me.canvas.setOdfContainer c, false this.currentStyle = ""; if (this.args && this.args.length > 0) { this.open(this.args[0]); } else { this.newdoc(); } this.resource = { fonts: [], formats: [] }; this.bindKey("ALT-N", function() { return me.actionFile(`${me.name}-New`); }); this.bindKey("ALT-O", function() { return me.actionFile(`${me.name}-Open`); }); this.bindKey("CTRL-S", function() { return me.actionFile(`${me.name}-Save`); }); return this.bindKey("ALT-W", function() { return me.actionFile(`${me.name}-Saveas`); }); } menu() { var me, menu; me = this; menu = [ { text: "__(File)", child: [ { text: "__(New)", dataid: `${this.name}-New`, shortcut: "A-N" }, { text: "__(Open)", dataid: `${this.name}-Open`, shortcut: "A-O" }, { text: "__(Save)", dataid: `${this.name}-Save`, shortcut: "C-S" }, { text: "__(Save as)", dataid: `${this.name}-Saveas`, shortcut: "A-W" } ], onmenuselect: function(e) { return me.actionFile(e.item.data.dataid); } } ]; return menu; } actionFile(e) { var me, saveas; me = this; saveas = function() { return me.openDialog("FileDiaLog", function(d, n, p) { me.currfile.setPath(`${d}/${n}`); return me.save(); }, __("Save as"), { file: me.currfile }); }; switch (e) { case `${this.name}-Open`: return this.openDialog("FileDiaLog", function(d, f, p) { return me.open(p); }, __("Open file"), { mimes: me.meta().mimes }); case `${this.name}-Save`: if (this.currfile.basename) { //@currfile.cache = @editor.value() return this.save(); } return saveas(); case `${this.name}-Saveas`: return saveas(); case `${this.name}-New`: return this.newdoc(); } } newdoc() { var blank; blank = `${(this.meta().path)}/blank.odt`; return this.open(blank, true); } open(p, b) { var me; me = this; return this.pathAsDataURL(p).then(function(r) { var OdfContainer; if (me.editorSession) { me.closeDocument(); } me.initCanvas(); return OdfContainer = new odf.OdfContainer(r.data, function(c) { me.canvas.setOdfContainer(c, false); if (b) { return me.currfile = "Untitled".asFileHandler(); } if (me.currfile) { me.currfile.setPath(p); } else { me.currfile = p.asFileHandler(); } me.scheme.set("apptitle", me.currfile.basename); return me.notify(__("File {0} opened", p)); }); }).catch(function(e) { return me.error(__("Problem read file {0}", e)); }); } save() { var container, me; me = this; if (!this.editorSession) { return; } container = this.canvas.odfContainer(); if (!container) { return this.error(__("No document container found")); } return container.createByteArray(function(ba) { // create blob me.currfile.cache = new Blob([ba], { type: "application/vnd.oasis.opendocument.text" }); return me.currfile.write("application/vnd.oasis.opendocument.text", function(r) { if (r.error) { return me.error(__("Cannot save file: {0}", r.error)); } me.notify(__("File {0} saved", me.currfile.basename)); me.scheme.set("apptitle", me.currfile.basename); me.currfile.dirty = false; return me.editorFocus(); }); }, function(err) { return this.error(__("Cannot create byte array from container: {0}", err || "")); }); } initToolbox() { var el, fn, me, name, ref; me = this; this.basictool = { undo: this.find("btundo"), redo: this.find("btredo"), bold: this.find("btbold"), italic: this.find("btitalic"), underline: this.find("btunderline"), strike: this.find("btstrike"), note: this.find("btnote"), link: this.find("btlink"), unlink: this.find("btunlink"), image: this.find("btimage"), ac: this.find("btac"), al: this.find("btal"), ar: this.find("btar"), aj: this.find("btaj"), indent: this.find("btindent"), outdent: this.find("btoutdent"), fonts: this.find("font-list"), fontsize: this.find("font-size"), styles: this.find("format-list"), zoom: this.find("slzoom"), format: this.find("btformat") }; fn = function(name, el) { var act; if (name === "fonts" || name === "styles") { act = "onlistselect"; } else if (name === "fontsize" || name === "zoom") { act = "onchange"; } else { act = "onbtclick"; } return el.set(act, function(e) { if (!me.directFormattingCtl) { return; } if (!me[name]) { return; } me[name](e); return me.editorFocus(); }); }; ref = this.basictool; for (name in ref) { el = ref[name]; fn(name, el); } (this.find("btzoomfix")).set("onbtclick", function(e) { return me.zoom(100); }); return this.basictool.zoom.set("onchanging", function(e) { var zlb; zlb = me.find("lbzoom"); return zlb.set("text", Math.floor(e) + "%"); }); } initCanvas() { var el, me; el = this.find("odfcanvas"); me = this; el.setAttribute("translate", "no"); el.classList.add("notranslate"); this.canvas = new odf.OdfCanvas(el); this.documentChanged = function(e) { if (me.currfile.dirty) { return; } me.currfile.dirty = true; return me.scheme.set("apptitle", me.currfile.basename + "*"); }; //console.log e this.metaChanged = function(e) { if (me.currfile.dirty) { return; } me.currfile.dirty = true; return me.scheme.set("apptitle", me.currfile.basename + "*"); }; //console.log e this.textStylingChanged = function(e) { return me.updateToolbar(e); }; this.paragrahStyleChanged = function(e) { var i, item, items, j, len, v; if (e.type !== "style") { return; } items = me.basictool.styles.get("items"); for (i = j = 0, len = items.length; j < len; i = ++j) { v = items[i]; if (v.name === e.styleName) { item = i; } } me.currentStyle = e.styleName; return me.basictool.styles.set("selected", item); }; this.styleAdded = function(e) { var dtext, item, items, j, len, stylens, v; if (e.family !== 'paragraph') { return; } items = me.basictool.styles.get("items"); for (j = 0, len = items.length; j < len; j++) { v = items[j]; if (v.name === e.name) { item = v; } } if (item) { return; } stylens = "urn:oasis:names:tc:opendocument:xmlns:style:1.0"; el = me.editorSession.getParagraphStyleElement(e.name); dtext = el.getAttributeNS(stylens, 'display-name'); return me.basictool.styles.push({ text: dtext, name: e.name }, true); }; //me.resource.formats.push {text: dtext, name:e.name} this.updateSlider = function(v) { var value, zlb; value = Math.floor(v * 100); me.basictool.zoom.set("value", value); zlb = me.find("lbzoom"); return zlb.set("text", value + "%"); }; //me.canvas.enableAnnotations true, true return this.canvas.addListener("statereadychange", function() { var op, viewOptions; me.session = new ops.Session(me.canvas); viewOptions = { editInfoMarkersInitiallyVisible: false, caretAvatarsInitiallyVisible: false, caretBlinksOnRangeSelect: true }; me.editorSession = new OpenPage.EditorSession(me.session, me.userid, { viewOptions: viewOptions, directTextStylingEnabled: true, directParagraphStylingEnabled: true, paragraphStyleSelectingEnabled: true, paragraphStyleEditingEnabled: true, imageEditingEnabled: true, hyperlinkEditingEnabled: true, annotationsEnabled: true, zoomingEnabled: true, reviewModeEnabled: false }); me.initFontList(me.editorSession.getDeclaredFonts()); me.initStyles(me.editorSession.getAvailableParagraphStyles()); //fix annotation problem on canvas //console.log $("office:body").css "background-color", "red" // basic format me.directFormattingCtl = me.editorSession.sessionController.getDirectFormattingController(); me.directFormattingCtl.subscribe(gui.DirectFormattingController.textStylingChanged, me.textStylingChanged); me.directFormattingCtl.subscribe(gui.DirectFormattingController.paragraphStylingChanged, me.textStylingChanged); me.editorSession.subscribe(OpenPage.EditorSession.signalParagraphChanged, me.paragrahStyleChanged); // hyper link controller me.hyperlinkController = me.editorSession.sessionController.getHyperlinkController(); me.eventSubscriptions.addFrameSubscription(me.editorSession, OpenPage.EditorSession.signalCursorMoved, function() { return me.updateHyperlinkButtons(); }); me.eventSubscriptions.addFrameSubscription(me.editorSession, OpenPage.EditorSession.signalParagraphChanged, function() { return me.updateHyperlinkButtons(); }); me.eventSubscriptions.addFrameSubscription(me.editorSession, OpenPage.EditorSession.signalParagraphStyleModified, function() { return me.updateHyperlinkButtons(); }); //annotation controller me.annotationController = me.editorSession.sessionController.getAnnotationController(); //image controller me.imageController = me.editorSession.sessionController.getImageController(); //imageController.subscribe(gui.ImageController.enabledChanged, enableButtons) //text controller me.textController = me.editorSession.sessionController.getTextController(); // zoom controller me.zoomHelper = me.editorSession.getOdfCanvas().getZoomHelper(); me.zoomHelper.subscribe(gui.ZoomHelper.signalZoomChanged, me.updateSlider); me.updateSlider(me.zoomHelper.getZoomLevel()); // format controller me.editorSession.subscribe(OpenPage.EditorSession.signalCommonStyleCreated, me.styleAdded); me.editorSession.sessionController.setUndoManager(new gui.TrivialUndoManager()); me.editorSession.sessionController.getUndoManager().subscribe(gui.UndoManager.signalDocumentModifiedChanged, me.documentChanged); me.editorSession.sessionController.getMetadataController().subscribe(gui.MetadataController.signalMetadataChanged, me.metaChanged); op = new ops.OpAddMember(); op.init({ memberid: me.userid, setProperties: { "fullName": me.userid, "color": "blue" } }); me.session.enqueue([op]); me.editorSession.sessionController.insertLocalCursor(); return me.editorSession.sessionController.startEditing(); }); } //console.log me.editorSession.getDeclaredFonts() initFontList(list) { var j, l, len, len1, v; for (j = 0, len = list.length; j < len; j++) { v = list[j]; v.text = v.name; } for (l = 0, len1 = list.length; l < len1; l++) { v = list[l]; this.resource.fonts.push({ text: v.text, name: v.family }); } return this.basictool.fonts.set("items", list); } initStyles(list) { var j, l, len, len1, v; list.unshift({ name: "", displayName: 'Default style' }); for (j = 0, len = list.length; j < len; j++) { v = list[j]; v.text = v.displayName; } for (l = 0, len1 = list.length; l < len1; l++) { v = list[l]; this.resource.formats.push({ text: v.text, name: v.name }); } return this.basictool.styles.set("items", list); } updateToolbar(changes) { if (changes.hasOwnProperty('isBold')) { // basic style this.basictool.bold.set("selected", changes.isBold); } if (changes.hasOwnProperty('isItalic')) { this.basictool.italic.set("selected", changes.isItalic); } if (changes.hasOwnProperty('hasUnderline')) { this.basictool.underline.set("selected", changes.hasUnderline); } if (changes.hasOwnProperty('hasStrikeThrough')) { this.basictool.strike.set("selected", changes.hasStrikeThrough); } if (changes.hasOwnProperty("fontSize")) { this.basictool.fontsize.set("value", changes.fontSize); } if (changes.hasOwnProperty("fontName")) { this.selectFont(changes.fontName); } if (changes.hasOwnProperty("isAlignedLeft")) { //pharagraph style this.basictool.al.set("selected", changes.isAlignedLeft); } if (changes.hasOwnProperty("isAlignedRight")) { this.basictool.ar.set("selected", changes.isAlignedRight); } if (changes.hasOwnProperty("isAlignedCenter")) { this.basictool.ac.set("selected", changes.isAlignedCenter); } if (changes.hasOwnProperty("isAlignedJustified")) { return this.basictool.aj.set("selected", changes.isAlignedJustified); } } updateHyperlinkButtons(e) { var selectedLinks; selectedLinks = this.editorSession.getSelectedHyperlinks(); return this.basictool.unlink.set("enable", selectedLinks.length > 0); } selectFont(name) { var i, item, items, j, len, v; items = this.basictool.fonts.get("items"); for (i = j = 0, len = items.length; j < len; i = ++j) { v = items[i]; if (v.name === name) { item = i; } } return this.basictool.fonts.set("selected", item); } editorFocus() { return this.editorSession.sessionController.getEventManager().focus(); } bold(e) { //console.log @, e return this.directFormattingCtl.setBold(!this.basictool.bold.get("selected")); } italic(e) { return this.directFormattingCtl.setItalic(!this.basictool.italic.get("selected")); } underline(e) { return this.directFormattingCtl.setHasUnderline(!this.basictool.underline.get("selected")); } strike(e) { return this.directFormattingCtl.setHasStrikethrough(!this.basictool.strike.get("selected")); } fonts(e) { return this.directFormattingCtl.setFontName(e.data.name); } fontsize(e) { return this.directFormattingCtl.setFontSize(e); } al(e) { return this.directFormattingCtl.alignParagraphLeft(); } ar(e) { return this.directFormattingCtl.alignParagraphRight(); } ac(e) { return this.directFormattingCtl.alignParagraphCenter(); } note(e) { return this.annotationController.addAnnotation(); } aj(e) { return this.directFormattingCtl.alignParagraphJustified(); } indent(e) { return this.directFormattingCtl.indent(); } outdent(e) { return this.directFormattingCtl.outdent(); } link(e) { var data, linkTarget, linksInSelection, me, selection, textSerializer; // get the link first me = this; textSerializer = new odf.TextSerializer(); selection = this.editorSession.getSelectedRange(); linksInSelection = this.editorSession.getSelectedHyperlinks(); linkTarget = linksInSelection[0] ? odf.OdfUtils.getHyperlinkTarget(linksInSelection[0]) : "http://"; data = { link: linkTarget, text: "", readonly: true, action: "new" }; if (selection && selection.collapsed && linksInSelection.length === 1) { // selection is collapsed within a single link // text in this case is read only data.text = textSerializer.writeToString(linksInSelection[0]); data.action = "edit"; } else if (selection && !selection.collapsed) { // user select part of link or a block of text // user convert a selection to a link data.text = textSerializer.writeToString(selection.cloneContents()); } else { data.readonly = false; } return this.openDialog(new HyperLinkDialog(), function(d) { var selectedLinkRange, selectionController; selectionController = me.editorSession.sessionController.getSelectionController(); if (d.readonly) { // edit the existing link if (d.action === "edit") { selectedLinkRange = selection.cloneRange(); selectedLinkRange.selectNode(linksInSelection[0]); selectionController.selectRange(selectedLinkRange, true); } me.hyperlinkController.removeHyperlinks(); return me.hyperlinkController.addHyperlink(d.link); } else { me.hyperlinkController.addHyperlink(d.link, d.text); linksInSelection = me.editorSession.getSelectedHyperlinks(); selectedLinkRange = selection.cloneRange(); selectedLinkRange.selectNode(linksInSelection[0]); return selectionController.selectRange(selectedLinkRange, true); } }, "__(Insert/edit link)", data); } unlink(e) { return this.hyperlinkController.removeHyperlinks(); } undo(e) { return this.editorSession.undo(); } redo(e) { return this.editorSession.redo(); } pathAsDataURL(p) { return new Promise(function(resolve, error) { var fp; fp = p.asFileHandler(); return fp.read(function(data) { var blob, reader; blob = new Blob([data], { type: fp.info.mime }); reader = new FileReader(); reader.onloadend = function() { if (reader.readyState !== 2) { return error(p); } return resolve({ data: reader.result, fp: fp }); }; return reader.readAsDataURL(blob); }, "binary"); }); } /* if not isText else fp.read (data) -> * convert to base64 b64 = btoa data dataurl = "data:#{fp.info.mime};base64," + b64 resolve { reader: {result: dataurl}, fp:fp } */ image(e) { var me; me = this; return this.openDialog("FileDiaLog", function(d, n, p) { return me.pathAsDataURL(p).then(function(r) { var hiddenImage; hiddenImage = new Image(); hiddenImage.style.position = "absolute"; hiddenImage.style.left = "-99999px"; document.body.appendChild(hiddenImage); hiddenImage.onload = function() { var content; content = r.data.substring(r.data.indexOf(",") + 1); //insert image me.textController.removeCurrentSelection(); me.imageController.insertImage(r.fp.info.mime, content, hiddenImage.width, hiddenImage.height); return document.body.removeChild(hiddenImage); }; return hiddenImage.src = r.data; }).catch(function() { return me.error(__("Couldnt load image {0}", p)); }); }, __("Select image file"), { mimes: ["image/.*"] }); } styles(e) { if (e.data.name === this.currentStyle) { return; } return this.editorSession.setCurrentParagraphStyle(e.data.name); } zoom(e) { //console.log "zooming", e if (!this.zoomHelper) { return; } return this.zoomHelper.setZoomLevel(e / 100.0); } format(e) { return this.openDialog(new FormatDialog(), function(d) {}, __("Add/Modify paragraph format"), this.resource); } closeDocument(f) { var me, op; // finish editing if (!(this.editorSession && this.session)) { return; } me = this; this.eventSubscriptions.unsubscribeAll(); this.editorSession.sessionController.endEditing(); this.editorSession.sessionController.removeLocalCursor(); // remove user op = new ops.OpRemoveMember(); op.init({ memberid: this.userid }); this.session.enqueue([op]); // close the session return this.session.close(function(e) { if (e) { return me.error(__("Cannot close session {0}", e)); } me.editorSession.sessionController.getMetadataController().unsubscribe(gui.MetadataController.signalMetadataChanged, me.metaChanged); me.editorSession.sessionController.getUndoManager().unsubscribe(gui.UndoManager.signalDocumentModifiedChanged, me.documentChanged); me.directFormattingCtl.unsubscribe(gui.DirectFormattingController.textStylingChanged, me.textStylingChanged); me.directFormattingCtl.unsubscribe(gui.DirectFormattingController.paragraphStylingChanged, me.textStylingChanged); me.editorSession.unsubscribe(OpenPage.EditorSession.signalParagraphChanged, me.paragrahStyleChanged); me.zoomHelper.unsubscribe(gui.ZoomHelper.signalZoomChanged, me.updateSlider); me.editorSession.unsubscribe(OpenPage.EditorSession.signalCommonStyleCreated, me.styleAdded); // destry editorSession return me.editorSession.destroy(function(e) { if (e) { return me.error(__("Cannot destroy editor session {0}", e)); } me.editorSession = void 0; // destroy session return me.session.destroy(function(e) { if (e) { return me.error(__("Cannot destroy document session {0}", e)); } core.Async.destroyAll([me.canvas.destroy], function(e) { if (e) { return me.error(__("Cannot destroy canvas {0}", e)); } me.notify("Document closed"); if (f) { return f(); } }); me.session = void 0; me.annotationController = void 0; me.directFormattingCtl = void 0; me.textController = void 0; me.imageController = void 0; me.ZoomHelper = void 0; me.metaChanged = void 0; me.documentChanged = void 0; me.textStylingChanged = void 0; me.paragrahStyleChanged = void 0; me.updateSlider = void 0; me.styleAdded = void 0; me.basictool.fonts.set("selected", -1); return me.basictool.styles.set("selected", -1); }); }); }); } cleanup(e) { var me; me = this; if (this.editorSession) { e.preventDefault(); return me.closeDocument(function() { return me.quit(); }); } } }; this.OS.register("OpenPage", OpenPage); HyperLinkDialog = class HyperLinkDialog extends this.OS.GUI.BasicDialog { constructor() { super("HyperLinkDialog", { tags: [ { tag: "afx-label", att: 'text="__(Text)" data-height="23" class="header"' }, { tag: "input", att: 'data-height="30"' }, { tag: "afx-label", att: 'text="__(Link)" data-height="23" class="header"' }, { tag: "input", att: 'data-height="30"' }, { tag: "div", att: ' data-height="5"' } ], width: 350, height: 150, resizable: false, buttons: [ { label: "Ok", onclick: function(d) { var data; data = { text: (d.find("content1")).value, link: (d.find("content3")).value, readonly: d.data.readonly, action: d.data.action }; if (d.handler) { d.handler(data); } return d.quit(); } }, { label: "__(Cancel)", onclick: function(d) { return d.quit(); } } ], filldata: function(d) { if (!d.data) { return; } (d.find("content1")).value = d.data.text; (d.find("content3")).value = d.data.link; return $(d.find("content1")).prop('disabled', d.data.readonly); } }); } }; FormatDialog = class FormatDialog extends this.OS.GUI.BaseDialog { constructor() { super("FormatDialog"); } init() { return this._gui.htmlToScheme(FormatDialog.scheme, this, this.host); } main() { this.ui = { aligment: { left: this.find("swleft"), right: this.find("swright"), center: this.find("swcenter"), justify: this.find("swjustify") }, spacing: { left: this.find("spnleft"), right: this.find("spnright"), top: this.find("spntop"), bottom: this.find("spnbottom"), lineheight: this.find("spnlheight") }, padding: { left: this.find("pspnleft"), right: this.find("pspnright"), top: this.find("pspntop"), bottom: this.find("pspnbottom") }, style: { bold: this.find("swbold"), italic: this.find("switalic"), underline: this.find("swunderline"), color: this.find("txtcolor"), bgcolor: this.find("bgcolor") }, font: { family: this.find("lstfont"), size: this.find("spnfsize") }, formats: this.find("lstformats") }; this.initStyleObject(); this.preview = ($(this.find("preview")).find("p"))[0]; $(this.preview).css("padding", "0").css("margin", "0"); return this.initUIEvent(); } //@previewStyle() initStyleObject() { // init the format object return this.currentStyle = { aligment: this._api.switcher("left", "right", "center", "justify"), spacing: { left: 0, top: 0, right: 0, bottom: 0, lineheight: 0 }, padding: { left: 0, top: 0, right: 0, bottom: 0 }, style: { bold: false, italic: false, underline: false, color: void 0, bgcolor: void 0 }, font: { family: void 0, size: 12 } }; } initUIEvent() { var k, me, ref, ref1, ref2, ref3, set, v; me = this; set = function(e, o, k, f) { return me.ui[o][k].set(e, function(r) { var v; v = r; if (f) { v = f(r); } me.currentStyle[o][k] = v; return me.previewStyle(); }); }; ref = this.ui.aligment; for (k in ref) { v = ref[k]; set("onchange", "aligment", k, (function(e) { return e.data; })); } ref1 = this.ui.spacing; for (k in ref1) { v = ref1[k]; set("onchange", "spacing", k); } ref2 = this.ui.padding; for (k in ref2) { v = ref2[k]; set("onchange", "padding", k); } ref3 = this.ui.style; for (k in ref3) { v = ref3[k]; if (k !== "color" && k !== "bgcolor") { set("onchange", "style", k, (function(e) { return e.data; })); } } set("onchange", "font", "size"); $(this.ui.style.color).click(function(e) { return me.openDialog("ColorPickerDialog", function(d) { me.currentStyle.style.color = d; return me.previewStyle(); }); }); $(this.ui.style.bgcolor).click(function(e) { return me.openDialog("ColorPickerDialog", function(d) { me.currentStyle.style.bgcolor = d; return me.previewStyle(); }); }); if (this.data && this.data.fonts) { //font this.ui.font.family.set("items", this.data.fonts); } set("onlistselect", "font", "family", (function(e) { return e.data; })); //format list this.ui.formats.set("selected", -1); if (this.data && this.data.formats) { this.ui.formats.set("items", this.data.formats); } this.ui.formats.set("onlistselect", function(e) { return me.fromODFStyleFormat(e.data); }); this.ui.formats.set("selected", 0); (this.find("btok")).set("onbtclick", function(e) { return me.saveCurrentStyle(); }); (this.find("btx")).set("onbtclick", function(e) { return me.quit(); }); return (this.find("bt-clone")).set("onbtclick", function(e) { return me.clone(); }); } clone() { var me, selected; me = this; selected = this.ui.formats.get("selected"); if (!selected) { return; } return this.openDialog("PromptDialog", function(d) { var newstyle; if (!(d && d.trim() !== "")) { return me.notify(__("Abort: no style name is specified")); } newstyle = me.parent.editorSession.cloneParagraphStyle(selected.name, d); me.ui.formats.push({ text: d, name: newstyle }); me.ui.formats.set("selected", (me.ui.formats.get('count')) - 1); return me.notify(__("New style: {0} added", newstyle)); }, __("Clone style: {0}", selected.text), { label: __("New style name:") }); } saveCurrentStyle() { var odfs, selected; selected = this.ui.formats.get("selected"); if (!selected) { return; } odfs = { "style:paragraph-properties": { "fo:margin-top": this.currentStyle.spacing.top + "mm", "fo:margin-left": this.currentStyle.spacing.left + "mm", "fo:margin-bottom": this.currentStyle.spacing.bottom + "mm", "fo:margin-right": this.currentStyle.spacing.right + "mm", "fo:padding-top": this.currentStyle.padding.top + "mm", "fo:padding-left": this.currentStyle.padding.left + "mm", "fo:padding-bottom": this.currentStyle.padding.bottom + "mm", "fo:padding-right": this.currentStyle.padding.right + "mm", "fo:line-height": this.currentStyle.spacing.lineheight > 0 ? this.currentStyle.spacing.lineheight + "mm" : "normal", "fo:text-align": this.currentStyle.aligment.selected || "left" }, "style:text-properties": { "fo:font-weight": this.currentStyle.style.bold ? "bold" : "normal", "fo:font-style": this.currentStyle.style.italic ? "italic" : "normal", "style:text-underline-style": this.currentStyle.style.underline ? "solid" : "none", "fo:font-size": this.currentStyle.font.size + "pt", "fo:font-name": this.currentStyle.font.family.text, "fo:color": this.currentStyle.style.color ? this.currentStyle.style.color.hex : "#000000", "fo:background-color": this.currentStyle.style.bgcolor ? this.currentStyle.style.bgcolor.hex : "transparent" } }; this.parent.editorSession.updateParagraphStyle(selected.name, odfs); return this.notify(__("Paragraph format [{0}] is saved", selected.text)); } fromODFStyleFormat(odfs) { var cssUnits, findFont, me, style; me = this; this.initStyleObject(); cssUnits = new core.CSSUnits(); findFont = function(name) { var item, items, j, len, v; items = me.ui.font.family.get("items"); for (j = 0, len = items.length; j < len; j++) { v = items[j]; if (v.text === name) { item = v; } } if (!item) { return void 0; } return item; }; // spacing style = this.parent.editorSession.getParagraphStyleAttributes(odfs.name)['style:paragraph-properties']; if (style) { this.currentStyle.spacing.top = cssUnits.convertMeasure(style['fo:margin-top'], 'mm') || 0; this.currentStyle.spacing.left = cssUnits.convertMeasure(style['fo:margin-left'], 'mm') || 0; this.currentStyle.spacing.right = cssUnits.convertMeasure(style['fo:margin-right'], 'mm') || 0; this.currentStyle.spacing.bottom = cssUnits.convertMeasure(style['fo:margin-bottom'], 'mm') || 0; this.currentStyle.padding.top = cssUnits.convertMeasure(style['fo:padding-top'], 'mm') || 0; this.currentStyle.padding.left = cssUnits.convertMeasure(style['fo:padding-left'], 'mm') || 0; this.currentStyle.padding.right = cssUnits.convertMeasure(style['fo:padding-right'], 'mm') || 0; this.currentStyle.padding.bottom = cssUnits.convertMeasure(style['fo:padding-bottom'], 'mm') || 0; this.currentStyle.spacing.lineheight = cssUnits.convertMeasure(style['fo:line-height'], 'mm') || 4.2; // 1em = 4,2175176mm if (style['fo:text-align']) { this.currentStyle.aligment[style['fo:text-align']] = true; } } style = this.parent.editorSession.getParagraphStyleAttributes(odfs.name)['style:text-properties']; if (style) { this.currentStyle.style.bold = style['fo:font-weight'] === 'bold'; this.currentStyle.style.italic = style['fo:font-style'] === 'italic'; if (style['style:text-underline-style'] && style['style:text-underline-style'] !== 'none') { this.currentStyle.style.underline = true; } this.currentStyle.font.size = parseFloat(style['fo:font-size']); this.currentStyle.font.family = findFont(style['style:font-name']); if (style['fo:color']) { this.currentStyle.style.color = { hex: style['fo:color'] }; } if (style['fo:background-color']) { this.currentStyle.style.bgcolor = { hex: style['fo:background-color'] }; } } return this.previewStyle(); } previewStyle() { var el, i, item, items, j, len, v; //console.log "previewing" // reset ui this.ui.aligment.left.set("swon", this.currentStyle.aligment.left); this.ui.aligment.right.set("swon", this.currentStyle.aligment.right); this.ui.aligment.center.set("swon", this.currentStyle.aligment.center); this.ui.aligment.justify.set("swon", this.currentStyle.aligment.justify); this.ui.spacing.left.set("value", this.currentStyle.spacing.left); this.ui.spacing.right.set("value", this.currentStyle.spacing.right); this.ui.spacing.top.set("value", this.currentStyle.spacing.top); this.ui.spacing.bottom.set("value", this.currentStyle.spacing.bottom); this.ui.spacing.lineheight.set("value", this.currentStyle.spacing.lineheight); this.ui.padding.left.set("value", this.currentStyle.padding.left); this.ui.padding.right.set("value", this.currentStyle.padding.right); this.ui.padding.top.set("value", this.currentStyle.padding.top); this.ui.padding.bottom.set("value", this.currentStyle.padding.bottom); this.ui.style.bold.set("swon", this.currentStyle.style.bold); this.ui.style.italic.set("swon", this.currentStyle.style.italic); this.ui.style.underline.set("swon", this.currentStyle.style.underline); this.ui.font.size.set("value", this.currentStyle.font.size); //console.log @currentStyle if (this.currentStyle.font.family) { items = this.ui.font.family.get("items"); for (i = j = 0, len = items.length; j < len; i = ++j) { v = items[i]; if (v.text === this.currentStyle.font.family.text) { item = i; } } if (item >= 0) { this.ui.font.family.set("selected", item); } } $(this.ui.style.color).css("background-color", this.currentStyle.style.color ? this.currentStyle.style.color.hex : "#000000"); $(this.ui.style.bgcolor).css("background-color", this.currentStyle.style.bgcolor ? this.currentStyle.style.bgcolor.hex : "white"); // set the preview css el = $(this.preview); el.css("text-align", this.currentStyle.aligment.selected ? this.currentStyle.aligment.selected : "left"); el.css("margin-left", this.currentStyle.spacing.left + "mm"); el.css("margin-right", this.currentStyle.spacing.right + "mm"); el.css("margin-top", this.currentStyle.spacing.top + "mm"); el.css("margin-bottom", this.currentStyle.spacing.bottom + "mm"); el.css("padding-left", this.currentStyle.padding.left + "mm"); el.css("padding-right", this.currentStyle.padding.right + "mm"); el.css("padding-top", this.currentStyle.padding.top + "mm"); el.css("padding-bottom", this.currentStyle.padding.bottom + "mm"); el.css("font-weight", "normal").css("font-style", "normal").css("text-decoration", "none").css("line-height", "normal"); if (this.currentStyle.style.bold) { el.css("font-weight", "bold"); } if (this.currentStyle.style.italic) { el.css("font-style", "italic"); } if (this.currentStyle.style.underline) { el.css("text-decoration", "underline"); } el.css("color", this.currentStyle.style.color ? this.currentStyle.style.color.hex : "#000000"); el.css("background-color", this.currentStyle.style.bgcolor ? this.currentStyle.style.bgcolor.hex : "transparent"); el.css("font-size", this.currentStyle.font.size + "pt"); if (this.currentStyle.font.family) { el.css("font-family", this.currentStyle.font.family.name); } if (this.currentStyle.spacing.lineheight > 0) { return el.css("line-height", this.currentStyle.spacing.lineheight + "mm"); } } }; FormatDialog.scheme = "\n \n
\n \n
\n \n
\n \n
\n
\n \n \n
\n \n \n \n \n \n \n \n \n
\n
\n
\n \n
\n \n
\n \n \n
\n \n \n
\n \n \n
\n \n \n
\n
\n
\n \n
\n \n
\n \n \n
\n \n \n
\n \n \n
\n \n \n
\n
\n \n
\n \n
\n \n
\n \n \n \n \n \n \n \n
\n
\n \n
\n
\n
\n
\n \n
\n \n
\n \n
\n \n \n
\n \n \n
\n
\n
\n \n
\n \n
\n
\n

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce laoreet diam vestibulum massa malesuada quis dignissim libero blandit. Duis sit amet volutpat nisl.

\n
\n
\n
\n \n
\n \n
\n \n
\n \n
\n
\n
\n
"; }).call(this); /* This is a generated file. DO NOT EDIT. Copyright (C) 2010-2015 KO GmbH @licstart The code in this file is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License (GNU AGPL) as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. The code in this file is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with WebODF. If not, see . As additional permission under GNU AGPL version 3 section 7, you may distribute UNMODIFIED VERSIONS OF THIS file without the copy of the GNU AGPL normally required by section 4, provided you include this license notice and a URL through which recipients can access the Corresponding Source. As a special exception to the AGPL, any HTML file which merely makes function calls to this code, and for that purpose includes it in unmodified form by reference or in-line shall be deemed a separate work for copyright law purposes. In addition, the copyright holders of this code give you permission to combine this code with free software libraries that are released under the GNU LGPL. You may copy and distribute such a system following the terms of the GNU AGPL for this code and the LGPL for the libraries. If you modify this code, you may extend this exception to your version of the code, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. This license applies to this entire compilation. @licend @source: http://www.webodf.org/ @source: https://github.com/kogmbh/WebODF/ */ var webodf_version="0.5.9";function Runtime(){}Runtime.prototype.getVariable=function(g){};Runtime.prototype.toJson=function(g){};Runtime.prototype.fromJson=function(g){};Runtime.prototype.byteArrayFromString=function(g,k){};Runtime.prototype.byteArrayToString=function(g,k){};Runtime.prototype.read=function(g,k,d,b){};Runtime.prototype.readFile=function(g,k,d){};Runtime.prototype.readFileSync=function(g,k){};Runtime.prototype.loadXML=function(g,k){};Runtime.prototype.writeFile=function(g,k,d){}; Runtime.prototype.deleteFile=function(g,k){};Runtime.prototype.log=function(g,k){};Runtime.prototype.setTimeout=function(g,k){};Runtime.prototype.clearTimeout=function(g){};Runtime.prototype.libraryPaths=function(){};Runtime.prototype.currentDirectory=function(){};Runtime.prototype.setCurrentDirectory=function(g){};Runtime.prototype.type=function(){};Runtime.prototype.getDOMImplementation=function(){};Runtime.prototype.parseXML=function(g){};Runtime.prototype.exit=function(g){}; Runtime.prototype.getWindow=function(){};Runtime.prototype.requestAnimationFrame=function(g){};Runtime.prototype.cancelAnimationFrame=function(g){};Runtime.prototype.assert=function(g,k){};var IS_COMPILED_CODE=!0; Runtime.byteArrayToString=function(g,k){function d(b){var d="",r,q=b.length;for(r=0;rl?e.push(l):(r+=1,a=b[r],194<=l&&224>l?e.push((l&31)<<6|a&63):(r+=1,c=b[r],224<=l&&240>l?e.push((l&15)<<12|(a&63)<<6|c&63):(r+=1,m=b[r],240<=l&&245>l&&(l=(l&7)<<18|(a&63)<<12|(c&63)<<6|m&63,l-=65536,e.push((l>>10)+55296,(l&1023)+56320))))),1E3<=e.length&& (d+=String.fromCharCode.apply(null,e),e.length=0);return d+String.fromCharCode.apply(null,e)}var f;"utf8"===k?f=b(g):("binary"!==k&&this.log("Unsupported encoding: "+k),f=d(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,c=0;for(l=0;la&&(c+=1,l+=1);return c}function k(b,e,l){var a=b.length,c,m;e=new Uint8Array(new ArrayBuffer(e));l?(e[0]=239,e[1]=187,e[2]=191,m=3):m=0;for(l=0;lc?(e[m]=c,m+=1):2048>c?(e[m]=192|c>>>6,e[m+1]=128|c&63,m+=2):55040>=c||57344<=c?(e[m]=224|c>>>12&15,e[m+1]=128|c>>>6&63,e[m+2]=128|c&63,m+=3):(l+=1,c=(c-55296<<10|b.charCodeAt(l)-56320)+65536, e[m]=240|c>>>18&7,e[m+1]=128|c>>>12&63,e[m+2]=128|c>>>6&63,e[m+3]=128|c&63,m+=4);return e}function d(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."))};c=e.buffer&&!a.sendAsBinary?e.buffer:r.byteArrayToString(e,"binary");try{a.sendAsBinary?a.sendAsBinary(c):a.send(c)}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(d){b("Calling exit with code "+String(d)+", 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={},d=k.javax.xml.parsers.DocumentBuilderFactory.newInstance(),b,f,n="";d.setValidating(!1);d.setNamespaceAware(!0);d.setExpandEntityReferences(!1);d.setSchema(null);f=k.org.xml.sax.EntityResolver({resolveEntity:function(b,d){var f=new k.java.io.FileReader(d);return new k.org.xml.sax.InputSource(f)}});b=d.newDocumentBuilder();b.setEntityResolver(f);this.byteArrayFromString=function(b,d){var f,e=b.length,l=new Uint8Array(new ArrayBuffer(e));for(f=0;f>>18],m+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[c>>>12&63],m+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[c>>>6&63],m+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[c& 63];h===b+1?(c=a[h]<<4,m+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[c>>>6],m+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[c&63],m+="=="):h===b&&(c=a[h]<<10|a[h+1]<<2,m+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[c>>>12],m+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[c>>>6&63],m+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[c&63],m+="=");return m}function d(a){a=a.replace(/[^A-Za-z0-9+\/]+/g, "");var c=a.length,m=new Uint8Array(new ArrayBuffer(3*c)),b=a.length%4,d=0,l,e;for(l=0;l>16,m[d+1]=e>>8&255,m[d+2]=e&255,d+=3;c=3*c-[0,0,2,1][b];return m.subarray(0,c)}function b(a){var c,m,h=a.length,b=0,d=new Uint8Array(new ArrayBuffer(3*h));for(c=0;cm?d[b++]=m:(2048>m?d[b++]=192|m>>>6:(d[b++]=224|m>>>12&15,d[b++]=128|m>>>6&63),d[b++]=128|m&63);return d.subarray(0, b)}function f(a){var c,m,h,b,d=a.length,l=new Uint8Array(new ArrayBuffer(d)),e=0;for(c=0;cm?l[e++]=m:(c+=1,h=a[c],224>m?l[e++]=(m&31)<<6|h&63:(c+=1,b=a[c],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,d(a))}function r(a){return f(g(a))}function q(a){a=f(a);for(var c="",m=0;mc?l+=String.fromCharCode(c):(d+=1,h=a.charCodeAt(d)&255,224>c?l+=String.fromCharCode((c&31)<<6|h&63):(d+=1,b=a.charCodeAt(d)&255,l+=String.fromCharCode((c&15)<<12|(h&63)<<6|b&63)));return l}function l(a,c){function m(){var d=b+1E5;d>a.length&&(d=a.length);h+=e(a,b,d);b=d;d=b===a.length;c(h,d)&&!d&&runtime.setTimeout(m,0)}var h="",b=0;1E5>a.length?c(e(a,0,a.length),!0):("string"!==typeof a&&(a=a.slice()),m())}function a(a){return b(g(a))}function c(a){return String.fromCharCode.apply(String, b(a))}function m(a){return String.fromCharCode.apply(String,b(g(a)))}var h=function(a){var c={},m,h;m=0;for(h=a.length;m=a.compareBoundaryPoints(Range.START_TO_START,c)&&0<=a.compareBoundaryPoints(Range.END_TO_END,c)}function n(a,c){return 0>=a.compareBoundaryPoints(Range.END_TO_START,c)&&0<=a.compareBoundaryPoints(Range.START_TO_END,c)}function p(a,c){var b=null;a.nodeType===Node.TEXT_NODE&&(0===a.length?(a.parentNode.removeChild(a),c.nodeType===Node.TEXT_NODE&&(b=c)):(c.nodeType===Node.TEXT_NODE&&(a.appendData(c.data),c.parentNode.removeChild(c)),b=a));return b} function r(a){for(var c=a.parentNode;a.firstChild;)c.insertBefore(a.firstChild,a);c.removeChild(a);return c}function q(a,c){var b=a.parentNode,d=a.firstChild,l=c(a),e;if(l===NodeFilter.FILTER_SKIP)return b;for(;d;)e=d.nextSibling,q(d,c),d=e;b&&l===NodeFilter.FILTER_REJECT&&r(a);return b}function e(a,c){return a===c||Boolean(a.compareDocumentPosition(c)&Node.DOCUMENT_POSITION_CONTAINED_BY)}function l(a,c){return g().unscaledRangeClientRects?a:a/c}function a(c,h,b){Object.keys(h).forEach(function(d){var l= d.split(":"),e=l[1],f=b(l[0]),l=h[d],n=typeof l;"object"===n?Object.keys(l).length&&(d=f?c.getElementsByTagNameNS(f,e)[0]||c.ownerDocument.createElementNS(f,d):c.getElementsByTagName(e)[0]||c.ownerDocument.createElement(d),c.appendChild(d),a(d,l,b)):f&&(runtime.assert("number"===n||"string"===n,"attempting to map unsupported type '"+n+"' (key: "+d+")"),c.setAttributeNS(f,d,String(l)))})}var c=null;this.splitBoundaries=function(a){var c,d=[],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;c=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,d=NodeFilter.FILTER_ACCEPT;this.acceptNode=function(b){var f;for(f=0;f "+c.length),runtime.assert(0<=b,"Error in setPosition: "+b+" < 0"),b===c.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 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,c){for(;0=c.value||"%"===c.unit)?null:c;return c||L(a)};this.parseFoLineHeight= function(a){return K(a)||L(a)};this.isTextContentContainingNode=E;this.getTextNodes=function(a,c){var b;b=aa.getNodesInRange(a,function(a){var c=NodeFilter.FILTER_REJECT;a.nodeType===Node.TEXT_NODE?N(a)&&(c=NodeFilter.FILTER_ACCEPT):E(a)&&(c=NodeFilter.FILTER_SKIP);return c},NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT);c||O(a,b);return b};this.getTextElements=D;this.getParagraphElements=function(a){var c;c=aa.getNodesInRange(a,function(a){var c=NodeFilter.FILTER_REJECT;if(f(a))c=NodeFilter.FILTER_ACCEPT; else if(E(a)||q(a))c=NodeFilter.FILTER_SKIP;return c},NodeFilter.SHOW_ELEMENT);V(a.startContainer,c,f);return c};this.getImageElements=function(a){var c;c=aa.getNodesInRange(a,function(a){var c=NodeFilter.FILTER_SKIP;g(a)&&(c=NodeFilter.FILTER_ACCEPT);return c},NodeFilter.SHOW_ELEMENT);V(a.startContainer,c,g);return c};this.getHyperlinkElements=function(a){var c=[],d=a.cloneRange();a.collapsed&&a.endContainer.nodeType===Node.ELEMENT_NODE&&(a=W(a.endContainer,a.endOffset),a.nodeType===Node.TEXT_NODE&& d.setEnd(a,1));D(d,!0,!1).forEach(function(a){for(a=a.parentNode;!f(a);){if(b(a)&&-1===c.indexOf(a)){c.push(a);break}a=a.parentNode}});d.detach();return c};this.getNormalizedFontFamilyName=function(a){/^(["'])(?:.|[\n\r])*?\1$/.test(a)||(a=a.replace(/^[ \t\r\n\f]*((?:.|[\n\r])*?)[ \t\r\n\f]*$/,"$1"),/[ \t\r\n\f]/.test(a)&&(a="'"+a.replace(/[ \t\r\n\f]+/g," ")+"'"));return a}};odf.OdfUtils=new odf.OdfUtilsImpl; gui.OdfTextBodyNodeFilter=function(){var g=odf.OdfUtils,k=Node.TEXT_NODE,d=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 d}else if(n.namespaceURI===f&&"tracked-changes"===n.localName)return d;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,c){return-1!==b&&(b=e&&c.push(k(b.substring(a,d)))):"["===b[d]&&(0>=e&&(a=d+1),e+=1),d+=1;return d};q=function(d,a,c){var m,h,e,n;for(m=0;m/g,">").replace(/'/g,"'").replace(/"/g,""")}function d(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,c,m,h="",y;e="<"+q;a=l.length;for(c=0;c")}if(r===NodeFilter.FILTER_ACCEPT||r===NodeFilter.FILTER_SKIP){for(r=n.firstChild;r;)g+=d(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 d(k,b)}}; (function(){function g(b){var a,c=r.length;for(a=0;ac)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,c,d){var h=this;this.size=0;this.type=null;this.name=b;this.container=c;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!==d&&(this.mimetype=a,d.loadAsDataURL(b,a,function(a,c){a&&runtime.log(a);h.url=c;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(c,m){function h(a){for(var c=a.firstChild,b;c;)b=c.nextSibling,c.nodeType===Node.ELEMENT_NODE?h(c):c.nodeType===Node.PROCESSING_INSTRUCTION_NODE&&a.removeChild(c),c=b}function g(a){var c={},b,d,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"))&&(c.hasOwnProperty(b)?runtime.log("Warning: annotation name used more than once with : '"+b+"'"):c[b]=a):"annotation-end"===a.localName&&((b=a.getAttributeNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0","name"))?c.hasOwnProperty(b)?(d=c[b],d.annotationEndElement?runtime.log("Warning: annotation name used more than once with : '"+b+"'"):d.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,c){for(var b=a&&a.firstChild;b;)b.nodeType===Node.ELEMENT_NODE&&b.setAttributeNS("urn:webodf:names:scope","scope",c),b=b.nextSibling}function z(a,c){for(var b=B.rootElement.meta,b=b&&b.firstChild;b&&(b.namespaceURI!==a||b.localName!==c);)b=b.nextSibling;for(b=b&&b.firstChild;b&&b.nodeType!==Node.TEXT_NODE;)b=b.nextSibling;return b? b.data:null}function w(a){var c={},b;for(a=a.firstChild;a;)a.nodeType===Node.ELEMENT_NODE&&a.namespaceURI===p&&"font-face"===a.localName&&(b=a.getAttributeNS(p,"name"),c[b]=a),a=a.nextSibling;return c}function v(a,c){var b=null,d,h,e;if(a)for(b=a.cloneNode(!0),d=b.firstElementChild;d;)h=d.nextElementSibling,(e=d.getAttributeNS("urn:webodf:names:scope","scope"))&&e!==c&&b.removeChild(d),d=h;return b}function u(a,c){var b,d,h,e=null,m={};if(a)for(c.forEach(function(a){f.collectUsedFontFaces(m,a)}), e=a.cloneNode(!0),b=e.firstElementChild;b;)d=b.nextElementSibling,h=b.getAttributeNS(p,"name"),m[h]||e.removeChild(b),b=d;return e}function t(a){var c=B.rootElement.ownerDocument,b;if(a){h(a.documentElement);try{b=c.importNode(a.documentElement,!0)}catch(d){}}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(c){var d=t(c),h=B.rootElement,e;d&&"document-styles"===d.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===d.namespaceURI?(h.fontFaceDecls=n.getDirectChild(d,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","font-face-decls"),b(h,h.fontFaceDecls),e=n.getDirectChild(d,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","styles"),h.styles=e||c.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0", "styles"),b(h,h.styles),e=n.getDirectChild(d,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","automatic-styles"),h.automaticStyles=e||c.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0","automatic-styles"),r(h.automaticStyles,"document-styles"),b(h,h.automaticStyles),d=n.getDirectChild(d,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","master-styles"),h.masterStyles=d||c.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(c){c=t(c);var d,h,e,m;if(c&&"document-content"===c.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===c.namespaceURI){d=B.rootElement;e=n.getDirectChild(c,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","font-face-decls");if(d.fontFaceDecls&&e){m=d.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&&(d.fontFaceDecls=e,b(d,e));h=n.getDirectChild(c,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","automatic-styles");r(h,"document-content");m&&f.changeFontFaceNames(h,m);if(d.automaticStyles&&h)for(m= h.firstChild;m;)d.automaticStyles.appendChild(m),m=h.firstChild;else h&&(d.automaticStyles=h,b(d,h));c=n.getDirectChild(c,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","body");if(null===c)throw" tag is mising.";d.body=c;b(d,d.body)}else A(a.INVALID)}function E(a){a=t(a);var c;a&&"document-meta"===a.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===a.namespaceURI&&(c=B.rootElement,c.meta=n.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","meta"), b(c,c.meta))}function N(a){a=t(a);var c;a&&"document-settings"===a.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===a.namespaceURI&&(c=B.rootElement,c.settings=n.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","settings"),b(c,c.settings))}function O(a){a=t(a);var c;if(a&&"manifest"===a.localName&&"urn:oasis:names:tc:opendocument:xmlns:manifest:1.0"===a.namespaceURI)for(c=B.rootElement,c.manifest=a,a=c.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,c,b){a=n.getElementsByTagName(a,c);var d;for(d=0;d'}function P(){var a=new xmldom.LSSerializer,c=R("document-meta");a.filter=new odf.OdfNodeFilter;c+=a.writeToString(B.rootElement.meta,odf.Namespaces.namespaceMap);return c+""}function aa(a,c){var b=document.createElementNS("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0","manifest:file-entry");b.setAttributeNS("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0","manifest:full-path",a);b.setAttributeNS("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0", "manifest:media-type",c);return b}function S(){var a=runtime.parseXML(''),c=a.documentElement,b=new xmldom.LSSerializer,d;for(d in M)M.hasOwnProperty(d)&&c.appendChild(aa(d,M[d]));b.filter=new odf.OdfNodeFilter;return'\n'+b.writeToString(a,odf.Namespaces.namespaceMap)}function fa(){var a,c,b,d=odf.Namespaces.namespaceMap, h=new xmldom.LSSerializer,e=R("document-styles");c=v(B.rootElement.automaticStyles,"document-styles");b=B.rootElement.masterStyles.cloneNode(!0);a=u(B.rootElement.fontFaceDecls,[b,B.rootElement.styles,c]);f.removePrefixFromStyleNames(c,q,b);h.filter=new k(b,c);e+=h.writeToString(a,d);e+=h.writeToString(B.rootElement.styles,d);e+=h.writeToString(c,d);e+=h.writeToString(b,d);return e+""}function ha(){var a,c,b=odf.Namespaces.namespaceMap,h=new xmldom.LSSerializer,e=R("document-content"); c=v(B.rootElement.automaticStyles,"document-content");a=u(B.rootElement.fontFaceDecls,[c]);h.filter=new d(B.rootElement.body,c);e+=h.writeToString(a,b);e+=h.writeToString(c,b);e+=h.writeToString(B.rootElement.body,b);return e+""}function C(c,b){runtime.loadXML(c,function(c,d){if(c)b(c);else if(d){V(d);W(d.documentElement);var h=t(d);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,c){var d;d=B.rootElement;var h=d.meta;h||(d.meta=h=document.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0","meta"),b(d,h));d=h;a&&n.mapKeyValObjOntoNode(d,a,odf.Namespaces.lookupNamespaceURI);c&&n.removeKeyElementsFromNode(d,c,odf.Namespaces.lookupNamespaceURI)}function ba(c,b){function d(a,c){var b;c||(c=a);b=document.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0",c);f[a]=b;f.appendChild(b)}var h=new core.Zip("",null),e="application/vnd.oasis.opendocument."+ c+(!0===b?"-template":""),m=runtime.byteArrayFromString(e,"utf8"),f=B.rootElement,g=document.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0",c);h.save("mimetype",m,!1,new Date);d("meta");d("settings");d("scripts");d("fontFaceDecls","font-face-decls");d("styles");d("automaticStyles","automatic-styles");d("masterStyles","master-styles");d("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,c=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,c)):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,c);a=runtime.byteArrayFromString(fa(),"utf8");Y.save("styles.xml",a,!0,c);a=runtime.byteArrayFromString(ha(),"utf8");Y.save("content.xml",a,!0,c);a=runtime.byteArrayFromString(S(),"utf8");Y.save("META-INF/manifest.xml",a,!0,c)}function ga(a,c){U();Y.writeAs(a,function(a){c(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 c=M["/"],b="-template"===c.substr(-9);a!==b&&(c=a?c+"-template":c.substr(0,c.length-9),M["/"]=c,a=runtime.byteArrayFromString(c,"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,c){Y.load(a,c)};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,c){U();Y.createByteArray(a,c)};this.saveAs=ga;this.save=function(a){ga(F,a)};this.getUrl=function(){return F};this.setBlob=function(a,c,b){b=e.convertBase64ToByteArray(b);Y.save(a,b,!1,new Date);M.hasOwnProperty(a)&&runtime.log(a+" has been overwritten.");M[a]=c};this.removeBlob=function(a){var c=Y.remove(a);runtime.assert(c,"file is not found: "+a);delete M[a]};this.state=a.LOADING;this.rootElement=function(a){var c=document.createElementNS(a.namespaceURI,a.localName), b;a=new a.Type;for(b in a)a.hasOwnProperty(b)&&(c[b]=a[b]);return c}({Type:odf.ODFDocumentElement,namespaceURI:odf.ODFDocumentElement.namespaceURI,localName:odf.ODFDocumentElement.localName});c===odf.OdfContainer.DocumentType.TEXT?Y=ba("text"):c===odf.OdfContainer.DocumentType.TEXT_TEMPLATE?Y=ba("text",!0):c===odf.OdfContainer.DocumentType.PRESENTATION?Y=ba("presentation"):c===odf.OdfContainer.DocumentType.PRESENTATION_TEMPLATE?Y=ba("presentation",!0):c===odf.OdfContainer.DocumentType.SPREADSHEET? Y=ba("spreadsheet"):c===odf.OdfContainer.DocumentType.SPREADSHEET_TEMPLATE?Y=ba("spreadsheet",!0):(F=c,Y=new core.Zip(F,function(c,b){Y=b;c?C(F,function(b){c&&(Y.error=c+"\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,d,b){function f(c){var b=c.annotationEndElement,d=l.createRange(),e=c.getAttributeNS(odf.Namespaces.officens,"name");b&&(d.setStart(c,c.childNodes.length),d.setEnd(b,0),c=a.getTextNodes(d,!1),c.forEach(function(a){var c;a:{for(c=a.parentNode;c.namespaceURI!==odf.Namespaces.officens||"body"!==c.localName;){if("http://www.w3.org/1999/xhtml"===c.namespaceURI&&"webodf-annotationHighlight"===c.className&&c.getAttribute("annotation")===e){c=!0;break a}c=c.parentNode}c= !1}c||(c=l.createElement("span"),c.className="webodf-annotationHighlight",c.setAttribute("annotation",e),a.parentNode.replaceChild(c,a),c.appendChild(a))}));d.detach()}function n(a){var b=g.getSizer();a?(d.style.display="inline-block",b.style.paddingRight=c.getComputedStyle(d).width):(d.style.display="none",b.style.paddingRight=0);g.refreshSize()}function p(){e.sort(function(a,c){return 0!==(a.compareDocumentPosition(c)&Node.DOCUMENT_POSITION_FOLLOWING)?-1:1})}function r(){var a;for(a=0;a=(n.getBoundingClientRect().top-r.bottom)/c?b.style.top=Math.abs(n.getBoundingClientRect().top-r.bottom)/c+20+"px":b.style.top="0px"): b.style.top="0px";l.style.left=f.getBoundingClientRect().width/c+"px";var f=l.style,n=l.getBoundingClientRect().left/c,k=l.getBoundingClientRect().top/c,r=b.getBoundingClientRect().left/c,p=b.getBoundingClientRect().top/c,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)/(c*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 c=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 d,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(d,n,k,r,q){var e,l=0,a;for(a in d)if(d.hasOwnProperty(a)){if(l===k){e=a;break}l+=1}e?n.getPartData(d[e].href,function(a,m){if(a)runtime.log(a);else if(m){var h="@font-face { font-family: "+(d[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 "+ d[e].href);g(d,n,k+1,r,q)}):q&&q()}var k=xmldom.XPath,d=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;)d(c,h,f,l),h=h.nextElementSibling}else l.continuedCounterIdStack=[]}var f=0,a="",c={};this.createCounterRules=function(a,b,n){var g=b.getAttributeNS(p,"id"),r=[];n&&(n=n.getAttributeNS("urn:webodf:names:helper","counter-id"),r=c[n].slice(0));a=new k(a,r);g?g="Y"+g:(f+=1,g="X"+f);d(g,b,0,a);c[g+"-level1-1"]=a.counterIdStack};this.initialiseCreatedCounters=function(){var c;c="office|document{"+("counter-reset: "+a+ ";");c+="}";g(b,c)}}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?c.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,c){var b;a&&(b=a.getAttributeNS(n,"style-name"));return b===c}function a(a, c,b){c=c.getElementsByTagNameNS(n,"list");a=new d(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)}d=d.nextElementSibling}});a(c,e,m)}}})();odf.LazyStyleProperties=function(g,k){var d={};this.value=function(b){var f;d.hasOwnProperty(b)?f=d[b]:(f=k[b](),void 0===f&&g&&(f=g.value(b)),d[b]=f);return f};this.reset=function(b){g=b;d={}}}; odf.StyleParseUtils=function(){function g(d){var b,f;d=(d=/(-?[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(d))?{value:parseFloat(d[1]),unit:d[3]}:null;f=d&&d.unit;"px"===f?b=d.value:"cm"===f?b=d.value/2.54*96:"mm"===f?b=d.value/25.4*96:"in"===f?b=96*d.value:"pt"===f?b=d.value/.75:"pc"===f&&(b=16*d.value);return b}var k=odf.Namespaces.stylens;this.parseLength=g;this.parsePositiveLengthOrPercent=function(d,b,f){var n;d&&(n=parseFloat(d.substr(0, d.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(d);return n};this.getPropertiesElement=function(d,b,f){for(b=f?f.nextElementSibling:b.firstElementChild;null!==b&&(b.localName!==d||b.namespaceURI!==k);)b=b.nextElementSibling;return b};this.parseAttributeList=function(d){d&&(d=d.replace(/^\s*(.*?)\s*$/g,"$1"));return d&&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,c,b,d){return c+c+b+b+d+d}function f(a,c){var b=[a],d=c.derivedStyles;Object.keys(d).forEach(function(a){a=f(a,d[a]);b=b.concat(a)});return b}function n(a, c,b,d){function e(c,b){var d=[],h;c.forEach(function(a){m.forEach(function(c){d.push('draw|page[webodfhelper|page-style-name="'+c+'"] draw|frame[presentation|class="'+a+'"]')})});0 z&&(a=z);for(c=Math.floor(a/d)*d;!b&&0<=c;)b=m[c],c-=d;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 c(a){for(var c,b=null;!b&&a&&a!==k;)(c=q(a))&&(b=h[c])&&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(c,b){var g,n=Math.ceil(c/d)*d,p,v,E;if(void 0!==z&&zp.steps)m[n]=v;r()};this.setToClosestStep=function(a,c){var b;r();b=l(a);b.setIteratorPosition(c); return b.steps};this.setToClosestDomPoint=function(a,b,d){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=c(a.childNodes.item(b)||a),!e)for(d.setUnfilteredPosition(a,b);!e&&d.previousNode();)e=c(d.getCurrentNode());e=e||x;void 0!==z&&e.steps>z&&(e=l(z));e.setIteratorPosition(d);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(c=e.textNode;c!==a;){c=c.parentNode;m=c.cloneNode(!1);h&&m.appendChild(h);if(y)for(;y&&y.nextSibling;)m.appendChild(y.nextSibling);else for(;c.firstChild;)m.appendChild(c.firstChild);c.parentNode.insertBefore(m,c.nextSibling);y=c;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);d.emit(ops.OdtDocument.signalStepsInserted,{position:b});x&&f&&(d.moveCursor(g,b+1,0),d.emit(ops.Document.signalCursorMoved,x));d.fixCursorPositions();d.getOdfCanvas().refreshSize();d.emit(ops.OdtDocument.signalParagraphChanged,{paragraphElement:l,memberId:g,timeStamp:k});d.emit(ops.OdtDocument.signalParagraphChanged,{paragraphElement:h,memberId:g,timeStamp:k});d.getOdfCanvas().rerenderAnnotations();return!0};this.spec=function(){return{optype:"SplitParagraph", memberid:g,timestamp:k,position:b,sourceParagraphPosition:d,paragraphStyleName:n,moveCursor:f}}}; ops.OpUpdateMember=function(){function g(d){var f="//dc:creator[@editinfo:memberid='"+k+"']";d=xmldom.XPath.getODFElementsWithXPath(d.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,d=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,d,e){function l(a,b){b.process(w,h,k)&&(a=!0,!x&&b.token&&(x=b.token));return a}var a=d===f,c,m,h,k,x,z=b.snapshot();c=!1;var w;do c=g(b),w={token:b.snapshot(),container:b.container,offset:b.offset,direction:d,visualDirection:d===f?n:p},m=b.nextStep()?g(b):null,b.restore(w.token), a?(h=c,k=m):(h=m,k=c),c=e.reduce(l,!1);while(!c&&b.advanceStep(d));c||e.forEach(function(a){!x&&a.token&&(x=a.token)});b.restore(x||z);return Boolean(x)}}; gui.Caret=function(g,k,d,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 d;d=g.getNode();var e,h,f=z.getBoundingClientRect(x.getSizer()),q=!1,y=0;d.removeAttributeNS("urn:webodf:names:cursor","caret-sizer-active");if(0d.height&&(d={top:d.top-(8-d.height)/2,height:8,right:d.right});l.style.height=d.height+"px";l.style.top=d.top+"px"; l.style.left=d.right-d.width+"px";l.style.width=d.width?d.width+"px":"";m&&(d=runtime.getWindow().getComputedStyle(g.getNode(),null),d.font?m.style.font=d.font:(m.style.fontStyle=d.fontStyle,m.style.fontVariant=d.fontVariant,m.style.fontWeight=d.fontWeight,m.style.fontSize=d.fontSize,m.style.lineHeight=d.lineHeight,m.style.fontFamily=d.fontFamily))}L.isShown&&I&&k.scrollIntoView(a.getBoundingClientRect());p("isFocused")&&c.markAsFocussed(L.isFocused);r();K=I=A=!1}function e(a){l.parentNode.removeChild(l); h.parentNode.removeChild(h);a()}var l,a,c,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){c.setImageUrl(a)};this.setColor=function(b){a.style.borderColor=b;c.setColor(b)};this.getCursor=function(){return g};this.getFocusElement=function(){return a};this.toggleHandleVisibility=function(){c.isVisible()?c.hide():c.show()};this.showHandle=function(){c.show()};this.hideHandle=function(){c.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,c.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);c=new gui.Avatar(l,d);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)&&d.isTextContentContainingNode(b))for(r=b.firstChild;r;)f+=g(r),r=r.nextSibling;n===NodeFilter.FILTER_ACCEPT&&(p===Node.ELEMENT_NODE&&d.isParagraph(b)?f+="\n":p===Node.TEXT_NODE&&b.textContent&&(f+=b.textContent));return f}var k=this,d=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,d){var b;b=d.startContainer.ownerDocument.createElement("span");b.appendChild(d.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,d){var b,f=k.clipboardData;b=runtime.getWindow();!f&&b&&(f=b.clipboardData);f?(b=!0,g.exportRangeToDataTransfer(f,d),k.preventDefault()):b=!1;return b}}; gui.SessionContext=function(g,k){var d=g.getOdtDocument(),b=odf.OdfUtils;this.isLocalCursorWithinOwnAnnotation=function(){var f=d.getCursor(k),g;if(!f)return!1;g=f&&f.getNode();f=d.getMember(k).getProperties().fullName;return(g=b.getParentAnnotation(g,d.getRootNode()))&&b.getAnnotationCreator(g)===f?!0:!1}}; gui.StyleSummary=function(g){function k(b,d){var k=b+"|"+d,q;f.hasOwnProperty(k)||(q=[],g.forEach(function(e){e=(e=e.styleProperties[b])&&e[d];-1===q.indexOf(e)&&q.push(e)}),f[k]=q);return f[k]}function d(b,d,f){return function(){var g=k(b,d);return f.length>=g.length&&g.every(function(b){return-1!==f.indexOf(b)})}}function b(b,d){var f=k(b,d);return 1===f.length?f[0]:void 0}var f={};this.getPropertyValues=k;this.getCommonValue=b;this.isBold=d("style:text-properties","fo:font-weight",["bold"]);this.isItalic= d("style:text-properties","fo:font-style",["italic"]);this.hasUnderline=d("style:text-properties","style:text-underline-style",["solid"]);this.hasStrikeThrough=d("style:text-properties","style:text-line-through-style",["solid"]);this.fontSize=function(){var d=b("style:text-properties","fo:font-size");return d&&parseFloat(d)};this.fontName=function(){return b("style:text-properties","style:font-name")};this.isAlignedLeft=d("style:paragraph-properties","fo:text-align",["left","start"]);this.isAlignedCenter= d("style:paragraph-properties","fo:text-align",["center"]);this.isAlignedRight=d("style:paragraph-properties","fo:text-align",["right","end"]);this.isAlignedJustified=d("style:paragraph-properties","fo:text-align",["justify"]);this.text={isBold:this.isBold,isItalic:this.isItalic,hasUnderline:this.hasUnderline,hasStrikeThrough:this.hasStrikeThrough,fontSize:this.fontSize,fontName:this.fontName};this.paragraph={isAlignedLeft:this.isAlignedLeft,isAlignedCenter:this.isAlignedCenter,isAlignedRight:this.isAlignedRight, isAlignedJustified:this.isAlignedJustified}}; gui.DirectFormattingController=function(g,k,d,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)&&c.push(new l(a)),a=a.parentNode;c.push(new e(v));return c}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(c,b){a(c,!0).filters.push(b)};this.removeFilter=function(c,b){var d=a(c,!0),e=d.filters.indexOf(b);-1!==e&&d.filters.splice(e,1)};this.subscribe=c;this.unsubscribe=m;this.hasFocus=h;this.focus=w;this.getEventTrap=function(){return K}; this.setEditing=function(a){var c=h();c&&K.blur();a?K.removeAttribute("readOnly"):K.setAttribute("readOnly","true");c&&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);c("mousedown",y);c("mouseup",x);c("contextmenu",x);A.longpress=new d("longpress",["touchstart","touchmove","touchend"],n);A.drag=new d("drag",["touchstart","touchmove","touchend"],p);A.dragstop=new d("dragstop",["drag","touchend"],r);c("touchstart",q)})()}; gui.IOSSafariSupport=function(g){function k(){d.innerHeight!==d.outerHeight&&(b.style.display="none",runtime.requestAnimationFrame(function(){b.style.display="block"}))}var d=runtime.getWindow(),b=g.getEventTrap();this.destroy=function(d){g.unsubscribe("focus",k);b.removeAttribute("autocapitalize");b.style.WebkitTransform="";d()};g.subscribe("focus",k);b.setAttribute("autocapitalize","off");b.style.WebkitTransform="translateX(-10000px)"}; gui.HyperlinkController=function(g,k,d,b){function f(){var b=!0;!0===k.getState(gui.CommonConstraints.EDIT.REVIEW_MODE)&&(b=d.isLocalCursorWithinOwnAnnotation());b!==e&&(e=b,q.emit(gui.HyperlinkController.enabledChanged,e))}function n(d){d.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(d,a){if(e){var c=r.getCursorSelection(b),f=new ops.OpApplyHyperlink,h=[];if(0===c.length||a)a=a||d,f=new ops.OpInsertText,f.init({memberid:b,position:c.position,text:a}),c.length=a.length,h.push(f);f=new ops.OpApplyHyperlink;f.init({memberid:b,position:c.position,length:c.length,hyperlink:d});h.push(f);g.enqueue(h)}};this.removeHyperlinks=function(){if(e){var d=r.createPositionIterator(r.getRootNode()),a=r.getCursor(b).getSelectedRange(),c=p.getHyperlinkElements(a), f=a.collapsed&&1===c.length,h=r.getDOMDocument().createRange(),k=[],n,q;0!==c.length&&(c.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=c[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=c.toLowerCase();var v=r.hasOwnProperty(n)?r[n]:null,t;n=[];runtime.assert(null!==v,"Image type is not supported: "+c);v="Pictures/"+f.generateImageName()+v;t=new ops.OpSetBlob;t.init({memberid:b,filename:v,mimetype:c,content:d});n.push(t);a.getStyleElement("Graphics","graphic",[u])||(c=new ops.OpAddStyle,c.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(c));c=f.generateStyleName();d=new ops.OpAddStyle;d.init({memberid:b,styleName:c,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(d);t=new ops.OpInsertImage;t.init({memberid:b,position:e.getCursorPosition(b),filename:v,frameWidth:k,frameHeight:p,frameStyleName:c,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 d=g.getSizer(),k=f.createElement("div");k.id="imageSelector";k.style.borderWidth="1px";d.appendChild(k);b.forEach(function(b){var d=f.createElement("div");d.className=b;k.appendChild(d)});return k}var d=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(d,"width");e.style.height=b.getAttributeNS(d,"height")};this.clearSelection=function(){var b;n&&(b=f.getElementById("imageSelector"))&&(b.style.display="none");n=!1};this.isSelectorElement=function(b){var d=f.getElementById("imageSelector");return d?b===d||b.parentNode===d:!1}}; (function(){function g(g){function d(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",d);n()};g.subscribe("textInput",b);g.subscribe("compositionend",f);g.addFilter("keypress",d)}gui.InputMethodEditor=function(k,d){function b(c){a&&(c?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?c.value="":c.value=u.writeToString(a.getSelectedRange().cloneContents()),c.setSelectionRange(0,c.value.length),I=!1)}function p(){d.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=c.value}var a=null,c=d.getEventTrap(),m=c.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(c){c.getMemberId()===k&&(a=c,a.getNode().appendChild(h),c.subscribe(ops.OdtCursor.signalCursorUpdated,p),d.subscribe("input",l),d.subscribe("compositionupdate", l))};this.removeCursor=function(c){a&&c===k&&(a.getNode().removeChild(h),a.unsubscribe(ops.OdtCursor.signalCursorUpdated,p),d.unsubscribe("input",l),d.unsubscribe("compositionupdate",l),a=null)};this.destroy=function(a){d.unsubscribe("compositionstart",r);d.unsubscribe("compositionend",q);d.unsubscribe("textInput",e);d.unsubscribe("keypress",f);d.unsubscribe("focus",n);core.Async.destroyAll(A,a)};(function(){u=new odf.TextSerializer;u.filter=new odf.OdfNodeFilter;d.subscribe("compositionstart",r); d.subscribe("compositionend",q);d.subscribe("textInput",e);d.subscribe("keypress",f);d.subscribe("focus",n);t.push(new g(d));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 d(b){n.emit(gui.MetadataController.signalMetadataChanged,b)}function b(b){var d=-1===p.indexOf(b);d||runtime.log("Setting "+b+" is restricted.");return d}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(d,f){var e={},l="",a;d&&Object.keys(d).filter(b).forEach(function(a){e[a]=d[a]}); f&&(l=f.filter(b).join(","));if(0f:!1}function d(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)d(e),d(l),b.token=f.token;return!1}}; gui.LineBoundaryScanner=function(){var g=this,k=null;this.token=void 0;this.process=function(d,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,c(f)===NodeFilter.FILTER_ACCEPT&&(d=f),a=a.parentNode;return d}function b(a,b){var c;return null===a?m.NO_NEIGHBOUR:p.isCharacterElement(a)?m.SPACE_CHAR:a.nodeType===f||p.isTextSpan(a)||p.isHyperlink(a)?(c=a.textContent.charAt(b()),q.test(c)?m.SPACE_CHAR:r.test(c)?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,c=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(),r=f.rightNode(),q=f.unfilteredDomOffset,v=function(){return f.unfilteredDomOffset()-1};g.nodeType===n&&(null===r&&(r=d(g,1,f.getNodeFilter())),null===p&&(p= d(g,-1,f.getNodeFilter())));g!==r&&(q=function(){return 0});g!==p&&null!==p&&(v=function(){return p.textContent.length-1});g=b(p,v);r=b(r,q);return g===m.WORD_CHAR&&r===m.WORD_CHAR||g===m.PUNCTUATION_CHAR&&r===m.PUNCTUATION_CHAR||k===a&&g!==m.NO_NEIGHBOUR&&r===m.SPACE_CHAR||k===c&&g===m.SPACE_CHAR&&r!==m.NO_NEIGHBOUR?l:e}};odf.WordBoundaryFilter.IncludeWhitespace={None:0,TRAILING:1,LEADING:2}; gui.SelectionController=function(g,k){function d(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,c){c=new odf.WordBoundaryFilter(x,c);var d=x.getRootElement(a)||x.getRootNode(),e=x.createRootFilter(d);return x.createStepIterator(a,b,[v,e,c],d)}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,c){var d=new ops.OpMoveCursor;d.init({memberid:k,position:a,length:b||0,selectionType:c});return d}function r(a,b,c){var d;d=x.getCursor(k);d=n(d.getSelectedRange(),d.hasForwardSelection());d.focusNode=a;d.focusOffset=b;c||(d.anchorNode=d.focusNode,d.anchorOffset=d.focusOffset);a=x.convertDomToCursorRange(d);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),c=b[0],b=b[b.length-1];c&&a.setStart(c,0);b&&(w.isParagraph(a.endContainer)&&0===a.endOffset?a.setEndBefore(b):a.setEnd(b,b.childNodes.length))}function l(a,b,c,d){var e,f;d?(e=c.startContainer,f=c.startOffset):(e=c.endContainer,f=c.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");d?c.setStart(a.container(),a.offset()):c.setEnd(a.container(),a.offset())}function a(a,c){var d=b();d.advanceStep(a)&&r(d.container(),d.offset(),c)}function c(a,c){var d,e=I,f=[new gui.LineBoundaryScanner,new gui.ParagraphBoundaryScanner];void 0===e&&A&&(e=A());isNaN(e)||(d=b(),u.moveToFilteredStep(d,a,f)&&d.advanceStep(a)&&(f=[new gui.ClosestXOffsetScanner(e), new gui.LineBoundaryScanner,new gui.ParagraphBoundaryScanner],u.moveToFilteredStep(d,a,f)&&(r(d.container(),d.offset(),c),I=e,K.restart())))}function m(a,c){var d=b(),e=[new gui.LineBoundaryScanner,new gui.ParagraphBoundaryScanner];u.moveToFilteredStep(d,a,e)&&r(d.container(),d.offset(),c)}function h(a,b){var c=x.getCursor(k),c=n(c.getSelectedRange(),c.hasForwardSelection()),c=f(c.focusNode,c.focusOffset,L);c.advanceStep(a)&&r(c.container(),c.offset(),b)}function y(a,b,c){var d=!1,e=x.getCursor(k), e=n(e.getSelectedRange(),e.hasForwardSelection()),d=x.getRootElement(e.focusNode);runtime.assert(Boolean(d),"SelectionController: Cursor outside root");e=x.createStepIterator(e.focusNode,e.focusOffset,[v,t],d);e.roundToClosestStep();e.advanceStep(a)&&(c=c(e.container()))&&(a===N?(e.setPosition(c,0),d=e.roundToNextStep()):(e.setPosition(c,c.childNodes.length),d=e.roundToPreviousStep()),d&&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),c=a.focusNode.ownerDocument.createRange();b?(c.setStart(a.anchorNode,a.anchorOffset),c.setEnd(a.focusNode,a.focusOffset)):(c.setStart(a.focusNode,a.focusOffset),c.setEnd(a.anchorNode, a.anchorOffset));return{range:c,hasForwardSelection:b}};this.rangeToSelection=n;this.selectImage=function(a){var c=x.getRootElement(a),b=x.createRootFilter(c),c=x.createStepIterator(a,0,[b,x.getPositionFilter()],c),d;c.roundToPreviousStep()||runtime.assert(!1,"No walkable position before frame");b=c.container();d=c.offset();c.setPosition(a,a.childNodes.length);c.roundToNextStep()||runtime.assert(!1,"No walkable position after frame");a=x.convertDomToCursorRange({anchorNode:b,anchorOffset:d,focusNode:c.container(), focusOffset:c.offset()});a=p(a.position,a.length,ops.OdtCursor.RegionSelection);g.enqueue([a])};this.expandToWordBoundaries=q;this.expandToParagraphBoundaries=e;this.selectRange=function(a,c,b){var d=x.getOdfCanvas().getElement(),f,h=[v];f=z.containsNode(d,a.startContainer);d=z.containsNode(d,a.endContainer);if(f||d)if(f&&d&&(2===b?q(a):3<=b&&e(a)),(b=c?x.getRootElement(a.startContainer):x.getRootElement(a.endContainer))||(b=x.getRootNode()),h.push(x.createRootFilter(b)),l(b,h,a,!0),l(b,h,a,!1),a= n(a,c),c=x.convertDomToCursorRange(a),a=x.getCursorSelection(k),c.position!==a.position||c.length!==a.length)a=p(c.position,c.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(){c(N,!1);return!0};this.moveCursorDown= function(){c(O,!1);return!0};this.extendSelectionUp=function(){c(N,!0);return!0};this.extendSelectionDown=function(){c(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()),c,b,d;runtime.assert(Boolean(a),"SelectionController: Cursor outside root");d=x.createStepIterator(a,0,[v,t],a);d.roundToClosestStep();c=d.container();b=d.offset(); d.setPosition(a,a.childNodes.length);d.roundToClosestStep();a=x.convertDomToCursorRange({anchorNode:c,anchorOffset:b,focusNode:d.container(),focusOffset:d.offset()});g.enqueue([p(a.position,a.length)]);return!0};this.destroy=function(a){x.unsubscribe(ops.OdtDocument.signalOperationStart,d);core.Async.destroyAll([K.destroy],a)};(function(){K=core.Task.createTimeoutTask(function(){I=void 0},2E3);x.subscribe(ops.OdtDocument.signalOperationStart,d)})()}; gui.TextController=function(g,k,d,b,f,n){function p(){y=!0===k.getState(gui.CommonConstraints.EDIT.REVIEW_MODE)?d.isLocalCursorWithinOwnAnnotation():!0}function r(a){a.getMemberId()===b&&p()}function q(a,b,d){var e=[c.getPositionFilter()];d&&e.push(c.createRootFilter(a.startContainer));d=c.createStepIterator(a.startContainer,a.startOffset,e,b);d.roundToClosestStep()||runtime.assert(!1,"No walkable step found in paragraph element at range start");b=c.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=c.convertDomPointToCursorStep(d.container(),d.offset()));return{position:b,length:a-b}}function e(a){var c,d,e,f=m.getParagraphElements(a),g=a.cloneRange(),l=[];c=f[0];1a.length&&(a.position+=a.length,a.length=-a.length);return a}function a(a){if(!y)return!1;var d,f=c.getCursor(b).getSelectedRange().cloneRange(), h=l(c.getCursorSelection(b)),m;if(0===h.length){h=void 0;d=c.getCursor(b).getNode();m=c.getRootElement(d);var k=[c.getPositionFilter(),c.createRootFilter(m)];m=c.createStepIterator(d,0,k,m);m.roundToClosestStep()&&(a?m.nextStep():m.previousStep())&&(h=l(c.convertDomToCursorRange({anchorNode:d,anchorOffset:0,focusNode:m.container(),focusOffset:m.offset()})),a?(f.setStart(d,0),f.setEnd(m.container(),m.offset())):(f.setStart(m.container(),m.offset()),f.setEnd(d,0)))}h&&g.enqueue(e(f));return void 0!== h}var c=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=c.getCursor(b),d=a.getSelectedRange(),f=l(c.getCursorSelection(b)),h=[],a=m.getParagraphElement(a.getNode()),k=a.getAttributeNS(x,"style-name")||"";0d.left&&(d=v(e)))c.focusNode=d.container,c.focusOffset=d.offset, b&&(c.anchorNode=c.focusNode,c.anchorOffset=c.focusOffset)}else S.isImage(c.focusNode.firstChild)&&1===c.focusOffset&&S.isCharacterFrame(c.focusNode)&&(d=v(c.focusNode))&&(c.anchorNode=c.focusNode=d.container,c.anchorOffset=c.focusOffset=d.offset);c.anchorNode&&c.focusNode&&(c=T.selectionToRange(c),T.selectRange(c.range,c.hasForwardSelection,0===a.button?a.detail:0));F.focus()}function t(a){var c;if(c=n(a.clientX,a.clientY))a=c.container,c=c.offset,a={anchorNode:a,anchorOffset:c,focusNode:a,focusOffset:c}, a=T.selectionToRange(a),T.selectRange(a.range,a.hasForwardSelection,2),F.focus()}function A(a){var c=a.target||a.srcElement||null,d,e,f;ma.processRequests();U&&(S.isImage(c)&&S.isCharacterFrame(c.parentNode)&&W.getSelection().isCollapsed?(T.selectImage(c.parentNode),F.focus()):la.isSelectorElement(c)?F.focus():B?(c=b.getSelectedRange(),e=c.collapsed,S.isImage(c.endContainer)&&0===c.endOffset&&S.isCharacterFrame(c.endContainer.parentNode)&&(f=c.endContainer.parentNode,f=v(f))&&(c.setEnd(f.container, f.offset),e&&c.collapse(!1)),T.selectRange(c,b.hasForwardSelection(),0===a.button?a.detail:0),F.focus()):ua?u(a):(d=aa.cloneEvent(a),M=runtime.setTimeout(function(){u(d)},0)),oa=0,B=U=!1)}function I(a){var c=J.getCursor(d).getSelectedRange();c.collapsed||fa.exportRangeToDataTransfer(a.dataTransfer,c)}function K(){U&&F.focus();oa=0;B=U=!1}function L(a){A(a)}function E(a){var c=a.target||a.srcElement||null,b=null;"annotationRemoveButton"===c.className?(runtime.assert(ja,"Remove buttons are displayed on annotations while annotation editing is disabled in the controller."), b=c.parentNode.getElementsByTagNameNS(odf.Namespaces.officens,"annotation").item(0),ca.removeAnnotation(b),F.focus()):"webodf-draggable"!==c.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(c){return J.getCursor(d).getSelectionType()===ops.OdtCursor.RangeSelection?a(c):!0}}function V(c){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);c()}var W=runtime.getWindow(),J=k.getOdtDocument(),R=new gui.SessionConstraints,P=new gui.SessionContext(k,d),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(),d),B=!1,Y=null,M,Q=null,F=new gui.EventManager(J),ja=f.annotationsEnabled,ca=new gui.AnnotationController(k, R,d),X=new gui.DirectFormattingController(k,R,P,d,ga,f.directTextStylingEnabled,f.directParagraphStylingEnabled),da=new gui.TextController(k,R,P,d,X.createCursorStyleOp,X.createParagraphStyleOps),qa=new gui.ImageController(k,R,P,d,ga),la=new gui.ImageSelector(J.getOdfCanvas()),ia=J.createPositionIterator(J.getRootNode()),ma,na,ea=new gui.PasteController(k,R,P,d),ka=new gui.InputMethodEditor(d,F),oa=0,pa=new gui.HyperlinkClickHandler(J.getOdfCanvas().getElement,C,ba),ta=new gui.HyperlinkController(k, R,P,d),T=new gui.SelectionController(k,d),va=new gui.MetadataController(k,d),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(d),"Inserting local cursor a second time."); var a=new ops.OpAddCursor;a.init({memberid:d});k.enqueue([a]);F.focus()};this.removeLocalCursor=function(){runtime.assert(void 0!==k.getOdtDocument().getCursor(d),"Removing local cursor without inserting before.");var a=new ops.OpRemoveCursor;a.init({memberid:d});k.enqueue([a])};this.startEditing=function(){ka.subscribe(gui.InputMethodEditor.signalCompositionStart,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 c;c=null===a.which||void 0===a.which?String.fromCharCode(a.keyCode):0!==a.which&&0!==a.charCode?String.fromCharCode(a.which):null;return!c||a.altKey||a.ctrlKey||a.metaKey?!1:(da.insertText(c),!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 d};this.getSession=function(){return k};this.getSessionConstraints=function(){return R}; this.setUndoManager=function(a){Q&&Q.unsubscribe(gui.UndoManager.signalUndoStackChanged,c);if(Q=a)Q.setDocument(J),Q.setPlaybackFunction(k.enqueue),Q.subscribe(gui.UndoManager.signalUndoStackChanged,c)};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 c=[ma.destroy,na.destroy,X.destroy,ka.destroy,F.destroy,pa.destroy,ta.destroy,va.destroy,T.destroy,da.destroy,V];sa&&c.unshift(sa.destroy);runtime.clearTimeout(M);core.Async.destroyAll(c,a)};ma=core.Task.createRedrawTask(z); na=core.Task.createRedrawTask(function(){var a=J.getCursor(d);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 d(b){return n.hasOwnProperty(b)?n[b]:null}function b(){return Object.keys(n).map(function(b){return n[b]})}function f(b){var d=n[b];d&&(delete n[b],b===g.getInputMemberId()?(r.unsubscribe(ops.OdtDocument.signalProcessingBatchEnd,d.ensureVisible),r.unsubscribe(ops.Document.signalCursorMoved,d.refreshCursorBlinking),q.unsubscribe("compositionupdate",d.handleUpdate),q.unsubscribe("compositionend",d.handleUpdate),q.unsubscribe("focus",d.setFocus),q.unsubscribe("blur", d.removeFocus),p.removeEventListener("focus",d.show,!1),p.removeEventListener("blur",d.hide,!1)):r.unsubscribe(ops.OdtDocument.signalProcessingBatchEnd,d.handleUpdate),d.destroy(function(){}))}var n={},p=runtime.getWindow(),r=g.getSession().getOdtDocument(),q=g.getEventManager();this.registerCursor=function(b,d,a){var c=b.getMemberId();b=new gui.Caret(b,k,d,a);n[c]=b;c===g.getInputMemberId()?(runtime.log("Starting to track input on new cursor of "+c),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=d;this.getCarets=b;this.destroy=function(d){var l= b().map(function(a){return a.destroy});g.getSelectionController().setCaretXPositionLocator(null);r.unsubscribe(ops.Document.signalCursorRemoved,f);n={};core.Async.destroyAll(l,d)};g.getSelectionController().setCaretXPositionLocator(function(){var b=d(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=[],d,b=g.ownerDocument,f=b.documentElement.namespaceURI;this.setEdits=function(g){k=g;var p,r,q,e;core.DomUtils.removeAllChildNodes(d);for(g=0;gc?(r=d(1,0),q=d(.5,1E4-c),e=d(.2,2E4-c)):1E4<=c&&2E4>c?(r=d(.5,0),e=d(.2,2E4-c)):r=d(.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 d=g.getOdtDocument().getDOMDocument();p=d.createElementNS(d.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 d=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(),c;a:{for(;e;){if(b.isHyperlink(e))break a;if(b.isParagraph(e)||b.isInlineRoot(e))break;e=e.parentNode}e=null}if(e){d.containsNode(l,r)||l.appendChild(r);c=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=""}c.textContent=m;n.textContent=b.getHyperlinkTarget(e);r.style.display="block";c=f.innerWidth-r.offsetWidth-15;e=q.clientX>c?c:q.clientX+15;c=f.innerHeight-r.offsetHeight-10;q=q.clientY>c?c: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(":","|")}),d=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 d+"\n"+b}var d,b=g.getElement().ownerDocument;this.showFieldHighlight=function(){d.appendChild(b.createTextNode(k()))};this.hideFieldHighlight=function(){for(var b=d.sheet,g=b.cssRules;g.length;)b.deleteRule(g.length-1)};this.destroy= function(b){d.parentNode&&d.parentNode.removeChild(d);b()};d=function(){var d=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,d){k+="@namespace "+b+" url("+d+");\n"});g.appendChild(b.createTextNode(k));d.appendChild(g);return g}()}; gui.ShadowCursor=function(g){var k=g.getDOMDocument().createRange(),d=!0;this.removeFromDocument=function(){};this.getMemberId=function(){return gui.ShadowCursor.ShadowCursorMemberId};this.getSelectedRange=function(){return k};this.setSelectedRange=function(b,f){k=b;d=!1!==f};this.hasForwardSelection=function(){return d};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(d).map(function(b){return d[b]})}var d={};this.getSelectionView=function(b){return d.hasOwnProperty(b)?d[b]:null};this.getSelectionViews=k;this.removeSelectionView=function(b){d.hasOwnProperty(b)&&(d[b].destroy(function(){}),delete d[b])};this.hideSelectionView=function(b){d.hasOwnProperty(b)&&d[b].hide()};this.showSelectionView=function(b){d.hasOwnProperty(b)&&d[b].show()};this.rerenderSelectionViews=function(){Object.keys(d).forEach(function(b){d[b].rerender()})}; this.registerCursor=function(b,f){var k=b.getMemberId(),p=new g(b);f?p.show():p.hide();return d[k]=p};this.destroy=function(b){function d(k,r){r?b(r):k .webodf-draggable"),a=gui.ShadowCursor.ShadowCursorMemberId,e(".webodf-selectionOverlay","{ fill: "+b+"; stroke: "+b+";}",""),e(".webodf-touchEnabled .webodf-selectionOverlay","{ display: block; }"," > .webodf-draggable"))}function l(a){var c,b;for(b in t)t.hasOwnProperty(b)&&(c=t[b],a?c.show():c.hide())}function a(a){n.getCarets().forEach(function(c){a?c.showHandle():c.hideHandle()})}function c(a){var c=a.getMemberId();a=a.getProperties();e(c,a.fullName,a.color)}function m(a){var c= a.getMemberId(),d=b.getOdtDocument().getMember(c).getProperties();n.registerCursor(a,E,N);p.registerCursor(a,!0);if(a=n.getCaret(c))a.setAvatarImageUrl(d.imageUrl),a.setColor(d.color);runtime.log("+++ View here +++ eagerly created an Caret for '"+c+"'! +++")}function h(a){a=a.getMemberId();var c=p.getSelectionView(d),b=p.getSelectionView(gui.ShadowCursor.ShadowCursorMemberId),e=n.getCaret(d);a===d?(b.hide(),c&&c.show(),e&&e.show()):a===gui.ShadowCursor.ShadowCursorMemberId&&(b.show(),c&&c.hide(), e&&e.hide())}function y(a){p.removeSelectionView(a)}function x(a){var c=a.paragraphElement,d=a.memberId;a=a.timeStamp;var e,f="",h=c.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(c,b.getOdtDocument()),e=new gui.EditInfoMarker(e,L),h=c.getElementsByTagNameNS("urn:webodf:names:editinfo","editinfo").item(0),h.setAttributeNS("urn:webodf:names:editinfo","id",f),t[f]=e); e.addEdit(d,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(d))&&(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,c);A.unsubscribe(ops.Document.signalMemberUpdated, c);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(c,d){d?a(d):ca.length;c&&g(a);return c}function d(a,c){function b(e){a[e]===c&&d.push(e)}var d=[];a&&["style:parent-style-name","style:next-style-name"].forEach(b);return d}function b(a,c){function b(d){a[d]===c&&delete a[d]}a&&["style:parent-style-name","style:next-style-name"].forEach(b)}function f(a){var c={};Object.keys(a).forEach(function(b){c[b]="object"===typeof a[b]?f(a[b]):a[b]});return c}function n(a, c,b,d){var e,f=!1,g=!1,k,l=[];d&&d.attributes&&(l=d.attributes.split(","));a&&(b||0=a.length?0:a.length-e.length)):void 0!==a.length&&(e=a.position+a.length,d<=e?a.length-=c.length:b=c.position+c.length)){d=b?a:c;e=b?c:a;if(a.position!==c.position||a.length!==c.length)n=f(d),r=f(e);c=q(e.setProperties,null,d.setProperties, null,"style:text-properties");if(c.majorChanged||c.minorChanged)g=[],a=[],k=d.position+d.length,l=e.position+e.length,e.positionk?c.minorChanged&&(n=r,n.position=k,n.length=l-k,a.push(n),e.length=k-e.position):k>l&&c.majorChanged&&(n.position=l, n.length=k-l,g.push(n),d.length=l-d.position),d.setProperties&&p(d.setProperties)&&g.push(d),e.setProperties&&p(e.setProperties)&&a.push(e),b?(k=g,g=a):k=a}return{opSpecsA:k,opSpecsB:g}},InsertText:function(a,c){c.position<=a.position?a.position+=c.text.length:c.position<=a.position+a.length&&(a.length+=c.text.length);return{opSpecsA:[a],opSpecsB:[c]}},MergeParagraph:function(a,c){var b=a.position,d=a.position+a.length;b>=c.sourceStartPosition&&--b;d>=c.sourceStartPosition&&--d;a.position=b;a.length= d-b;return{opSpecsA:[a],opSpecsB:[c]}},MoveCursor:e,RemoveAnnotation:function(a,b){var d=a.position,e=a.position+a.length,f=b.position+b.length,g=[a],k=[b];b.position<=d&&e<=f?g=[]:(fb.position?a.position+=b.text.length:d?b.position+=a.text.length:a.position+= b.text.length;return{opSpecsA:[a],opSpecsB:[b]}},MergeParagraph:function(a,b){a.position>=b.sourceStartPosition?--a.position:(a.positiona.position&&(b.position+=a.text.length);return{opSpecsA:[a],opSpecsB:[b]}},SplitParagraph:function(a,b){a.position=a.sourceStartPosition&&--f;d>=a.sourceStartPosition&&--d;0<=b.length?(b.position=f,b.length=d-f):(b.position=d,b.length=f-d);return{opSpecsA:[a],opSpecsB:[b]}},RemoveAnnotation:function(a,b){var d=b.position+b.length,e=[a],f=[b];b.position<=a.destinationStartPosition&&a.sourceStartPosition<=d?(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:d,opSpecsB:e}},SplitParagraph:function(a,b){var d,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 d=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,d.push(g));return{opSpecsA:d,opSpecsB:e}},UpdateMember:e,UpdateMetadata:e,UpdateParagraphStyle:e},SplitParagraph:{SplitParagraph:function(a,b,d){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)}); /** * Copyright (C) 2013 KO GmbH * * @licstart * This file is part of WebODF. * * WebODF is free software: you can redistribute it and/or modify it * under the terms of the GNU Affero General Public License (GNU AGPL) * as published by the Free Software Foundation, either version 3 of * the License, or (at your option) any later version. * * WebODF is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with WebODF. If not, see . * @licend * * @source: http://www.webodf.org/ * @source: https://github.com/kogmbh/WebODF/ */ /*global runtime, define, document, core, odf, gui, ops*/ /*define("webodf/editor/EditorSession", [ "dojo/text!resources/fonts/fonts.css" ],*/ this.OS.APP.OpenPage.EditorSession = (function (fontsCSS) { // fontsCSS is retrieved as a string, using dojo's text retrieval AMD plugin "use strict"; runtime.loadClass("core.Async"); runtime.loadClass("core.DomUtils"); runtime.loadClass("odf.OdfUtils"); runtime.loadClass("ops.OdtDocument"); runtime.loadClass("ops.OdtStepsTranslator"); runtime.loadClass("ops.Session"); runtime.loadClass("odf.Namespaces"); runtime.loadClass("odf.OdfCanvas"); runtime.loadClass("odf.OdfUtils"); runtime.loadClass("gui.CaretManager"); runtime.loadClass("gui.Caret"); runtime.loadClass("gui.OdfFieldView"); runtime.loadClass("gui.SessionController"); runtime.loadClass("gui.SessionView"); runtime.loadClass("gui.HyperlinkTooltipView"); runtime.loadClass("gui.TrivialUndoManager"); runtime.loadClass("gui.SvgSelectionView"); runtime.loadClass("gui.SelectionViewManager"); runtime.loadClass("core.EventNotifier"); runtime.loadClass("gui.ShadowCursor"); runtime.loadClass("gui.CommonConstraints"); /** * Instantiate a new editor session attached to an existing operation session * @constructor * @implements {core.EventSource} * @param {!ops.Session} session * @param {!string} localMemberId * @param {{viewOptions:gui.SessionViewOptions,directParagraphStylingEnabled:boolean,annotationsEnabled:boolean}} config */ var EditorSession = function EditorSession(session, localMemberId, config) { var self = this, currentParagraphNode = null, currentCommonStyleName = null, currentStyleName = null, caretManager, selectionViewManager, hyperlinkTooltipView, odtDocument = session.getOdtDocument(), textns = odf.Namespaces.textns, fontStyles = document.createElement('style'), formatting = odtDocument.getFormatting(), domUtils = core.DomUtils, odfUtils = odf.OdfUtils, odfFieldView, eventNotifier = new core.EventNotifier([ EditorSession.signalMemberAdded, EditorSession.signalMemberUpdated, EditorSession.signalMemberRemoved, EditorSession.signalCursorAdded, EditorSession.signalCursorMoved, EditorSession.signalCursorRemoved, EditorSession.signalParagraphChanged, EditorSession.signalCommonStyleCreated, EditorSession.signalCommonStyleDeleted, EditorSession.signalParagraphStyleModified, EditorSession.signalUndoStackChanged]), shadowCursor = new gui.ShadowCursor(odtDocument), sessionConstraints, /**@const*/ NEXT = core.StepDirection.NEXT; /** * @return {Array.} */ function getAvailableFonts() { var availableFonts, regex, matches; availableFonts = {}; /*jslint regexp: true*/ regex = /font-family *: *(?:\'([^']*)\'|\"([^"]*)\")/gm; /*jslint regexp: false*/ matches = regex.exec(fontsCSS); while (matches) { availableFonts[matches[1] || matches[2]] = 1; matches = regex.exec(fontsCSS); } availableFonts = Object.keys(availableFonts); return availableFonts; } function checkParagraphStyleName() { var newStyleName, newCommonStyleName; newStyleName = currentParagraphNode.getAttributeNS(textns, 'style-name'); if (newStyleName !== currentStyleName) { currentStyleName = newStyleName; // check if common style is still the same newCommonStyleName = formatting.getFirstCommonParentStyleNameOrSelf(newStyleName); if (!newCommonStyleName) { // Default style, empty-string name currentCommonStyleName = newStyleName = currentStyleName = ""; self.emit(EditorSession.signalParagraphChanged, { type: 'style', node: currentParagraphNode, styleName: currentCommonStyleName }); return; } // a common style if (newCommonStyleName !== currentCommonStyleName) { currentCommonStyleName = newCommonStyleName; self.emit(EditorSession.signalParagraphChanged, { type: 'style', node: currentParagraphNode, styleName: currentCommonStyleName }); } } } /** * Creates a NCName from the passed string * @param {!string} name * @return {!string} */ function createNCName(name) { var letter, result = "", i; // encode for (i = 0; i < name.length; i += 1) { letter = name[i]; // simple approach, can be improved to not skip other allowed chars if (letter.match(/[a-zA-Z0-9.-_]/) !== null) { result += letter; } else { result += "_" + letter.charCodeAt(0).toString(16) + "_"; } } // ensure leading char is from proper range if (result.match(/^[a-zA-Z_]/) === null) { result = "_" + result; } return result; } function uniqueParagraphStyleNCName(name) { var result, i = 0, ncMemberId = createNCName(localMemberId), ncName = createNCName(name); // create default paragraph style // localMemberId is used to avoid id conflicts with ids created by other members result = ncName + "_" + ncMemberId; // then loop until result is really unique while (formatting.hasParagraphStyle(result)) { result = ncName + "_" + i + "_" + ncMemberId; i += 1; } return result; } function trackCursor(cursor) { var node; node = odfUtils.getParagraphElement(cursor.getNode()); if (!node) { return; } currentParagraphNode = node; checkParagraphStyleName(); } function trackCurrentParagraph(info) { var cursor = odtDocument.getCursor(localMemberId), range = cursor && cursor.getSelectedRange(), paragraphRange = odtDocument.getDOMDocument().createRange(); paragraphRange.selectNode(info.paragraphElement); if ((range && domUtils.rangesIntersect(range, paragraphRange)) || info.paragraphElement === currentParagraphNode) { self.emit(EditorSession.signalParagraphChanged, info); checkParagraphStyleName(); } paragraphRange.detach(); } function onMemberAdded(member) { self.emit(EditorSession.signalMemberAdded, member.getMemberId()); } function onMemberUpdated(member) { self.emit(EditorSession.signalMemberUpdated, member.getMemberId()); } function onMemberRemoved(memberId) { self.emit(EditorSession.signalMemberRemoved, memberId); } function onCursorAdded(cursor) { self.emit(EditorSession.signalCursorAdded, cursor.getMemberId()); trackCursor(cursor); } function onCursorRemoved(memberId) { self.emit(EditorSession.signalCursorRemoved, memberId); } function onCursorMoved(cursor) { // Emit 'cursorMoved' only when *I* am moving the cursor, not the other users if (cursor.getMemberId() === localMemberId) { self.emit(EditorSession.signalCursorMoved, cursor); trackCursor(cursor); } } function onStyleCreated(newStyleName) { self.emit(EditorSession.signalCommonStyleCreated, newStyleName); } function onStyleDeleted(styleName) { self.emit(EditorSession.signalCommonStyleDeleted, styleName); } function onParagraphStyleModified(styleName) { self.emit(EditorSession.signalParagraphStyleModified, styleName); } /** * Call all subscribers for the given event with the specified argument * @param {!string} eventid * @param {Object} args */ this.emit = function (eventid, args) { eventNotifier.emit(eventid, args); }; /** * Subscribe to a given event with a callback * @param {!string} eventid * @param {!Function} cb */ this.subscribe = function (eventid, cb) { eventNotifier.subscribe(eventid, cb); }; /** * @param {!string} eventid * @param {!Function} cb * @return {undefined} */ this.unsubscribe = function (eventid, cb) { eventNotifier.unsubscribe(eventid, cb); }; this.getCursorPosition = function () { return odtDocument.getCursorPosition(localMemberId); }; this.getCursorSelection = function () { return odtDocument.getCursorSelection(localMemberId); }; this.getOdfCanvas = function () { return odtDocument.getOdfCanvas(); }; this.getCurrentParagraph = function () { return currentParagraphNode; }; this.getAvailableParagraphStyles = function () { return formatting.getAvailableParagraphStyles(); }; this.getCurrentParagraphStyle = function () { return currentCommonStyleName; }; /** * Applies the paragraph style with the given * style name to all the paragraphs within * the cursor selection. * @param {!string} styleName * @return {undefined} */ this.setCurrentParagraphStyle = function (styleName) { var range = odtDocument.getCursor(localMemberId).getSelectedRange(), paragraphs = odfUtils.getParagraphElements(range), opQueue = []; paragraphs.forEach(function (paragraph) { var paragraphStartPoint = odtDocument.convertDomPointToCursorStep(paragraph, 0, NEXT), paragraphStyleName = paragraph.getAttributeNS(odf.Namespaces.textns, "style-name"), opSetParagraphStyle; if (paragraphStyleName !== styleName) { opSetParagraphStyle = new ops.OpSetParagraphStyle(); opSetParagraphStyle.init({ memberid: localMemberId, styleName: styleName, position: paragraphStartPoint }); opQueue.push(opSetParagraphStyle); } }); if (opQueue.length > 0) { session.enqueue(opQueue); } }; this.insertTable = function (initialRows, initialColumns, tableStyleName, tableColumnStyleName, tableCellStyleMatrix) { var op = new ops.OpInsertTable(); op.init({ memberid: localMemberId, position: self.getCursorPosition(), initialRows: initialRows, initialColumns: initialColumns, tableStyleName: tableStyleName, tableColumnStyleName: tableColumnStyleName, tableCellStyleMatrix: tableCellStyleMatrix }); session.enqueue([op]); }; /** * Takes a style name and returns the corresponding paragraph style * element. If the style name is an empty string, the default style * is returned. * @param {!string} styleName * @return {?Element} */ function getParagraphStyleElement(styleName) { return (styleName === "") ? formatting.getDefaultStyleElement('paragraph') : formatting.getStyleElement(styleName, 'paragraph'); } this.getParagraphStyleElement = getParagraphStyleElement; /** * Returns if the style is used anywhere in the document * @param {!Element} styleElement * @return {boolean} */ this.isStyleUsed = function (styleElement) { return formatting.isStyleUsed(styleElement); }; /** * Returns the attributes of a given paragraph style name * (with inheritance). If the name is an empty string, * the attributes of the default style are returned. * @param {!string} styleName * @return {?odf.Formatting.StyleData} */ this.getParagraphStyleAttributes = function (styleName) { var styleNode = getParagraphStyleElement(styleName), includeSystemDefault = styleName === ""; if (styleNode) { return formatting.getInheritedStyleAttributes(styleNode, includeSystemDefault); } return null; }; /** * Creates and enqueues a paragraph-style cloning operation. * Returns the created id for the new style. * @param {!string} styleName id of the style to update * @param {!{paragraphProperties,textProperties}} setProperties properties which are set * @param {!{paragraphPropertyNames,textPropertyNames}=} removedProperties properties which are removed * @return {undefined} */ this.updateParagraphStyle = function (styleName, setProperties, removedProperties) { var op; op = new ops.OpUpdateParagraphStyle(); op.init({ memberid: localMemberId, styleName: styleName, setProperties: setProperties, removedProperties: (!removedProperties) ? {} : removedProperties }); session.enqueue([op]); }; /** * Creates and enqueues a paragraph-style cloning operation. * Returns the created id for the new style. * @param {!string} styleName id of the style to clone * @param {!string} newStyleDisplayName display name of the new style * @return {!string} */ this.cloneParagraphStyle = function (styleName, newStyleDisplayName) { var newStyleName = uniqueParagraphStyleNCName(newStyleDisplayName), styleNode = getParagraphStyleElement(styleName), op, setProperties, attributes, i; setProperties = formatting.getStyleAttributes(styleNode); // copy any attributes directly on the style attributes = styleNode.attributes; for (i = 0; i < attributes.length; i += 1) { // skip... // * style:display-name -> not copied, set to new string below // * style:name -> not copied, set from op by styleName property // * style:family -> "paragraph" always, set by op if (!/^(style:display-name|style:name|style:family)/.test(attributes[i].name)) { setProperties[attributes[i].name] = attributes[i].value; } } setProperties['style:display-name'] = newStyleDisplayName; op = new ops.OpAddStyle(); op.init({ memberid: localMemberId, styleName: newStyleName, styleFamily: 'paragraph', setProperties: setProperties }); session.enqueue([op]); return newStyleName; }; this.deleteStyle = function (styleName) { var op; op = new ops.OpRemoveStyle(); op.init({ memberid: localMemberId, styleName: styleName, styleFamily: 'paragraph' }); session.enqueue([op]); }; /** * Returns an array of the declared fonts in the ODF document, * with 'duplicates' like Arial1, Arial2, etc removed. The alphabetically * first font name for any given family is kept. * The elements of the array are objects containing the font's name and * the family. * @return {Array.} */ this.getDeclaredFonts = function () { var fontMap = formatting.getFontMap(), usedFamilies = [], array = [], sortedNames, key, value, i; // Sort all the keys in the font map alphabetically sortedNames = Object.keys(fontMap); sortedNames.sort(); for (i = 0; i < sortedNames.length; i += 1) { key = sortedNames[i]; value = fontMap[key]; // Use the font declaration only if the family is not already used. // Therefore we are able to discard the alphabetic successors of the first // font name. if (usedFamilies.indexOf(value) === -1) { array.push({ name: key, family: value }); if (value) { usedFamilies.push(value); } } } return array; }; this.getSelectedHyperlinks = function () { var cursor = odtDocument.getCursor(localMemberId); // no own cursor yet/currently added? if (!cursor) { return []; } return odfUtils.getHyperlinkElements(cursor.getSelectedRange()); }; this.getSelectedRange = function () { var cursor = odtDocument.getCursor(localMemberId); return cursor && cursor.getSelectedRange(); }; function undoStackModified(e) { self.emit(EditorSession.signalUndoStackChanged, e); } this.undo = function () { self.sessionController.undo(); }; this.redo = function () { self.sessionController.redo(); }; /** * @param {!string} memberId * @return {?ops.Member} */ this.getMember = function (memberId) { return odtDocument.getMember(memberId); }; /** * @param {!function(!Object=)} callback passing an error object in case of error * @return {undefined} */ function destroy(callback) { var head = document.getElementsByTagName('head')[0], eventManager = self.sessionController.getEventManager(); head.removeChild(fontStyles); odtDocument.unsubscribe(ops.Document.signalMemberAdded, onMemberAdded); odtDocument.unsubscribe(ops.Document.signalMemberUpdated, onMemberUpdated); odtDocument.unsubscribe(ops.Document.signalMemberRemoved, onMemberRemoved); odtDocument.unsubscribe(ops.Document.signalCursorAdded, onCursorAdded); odtDocument.unsubscribe(ops.Document.signalCursorRemoved, onCursorRemoved); odtDocument.unsubscribe(ops.Document.signalCursorMoved, onCursorMoved); odtDocument.unsubscribe(ops.OdtDocument.signalCommonStyleCreated, onStyleCreated); odtDocument.unsubscribe(ops.OdtDocument.signalCommonStyleDeleted, onStyleDeleted); odtDocument.unsubscribe(ops.OdtDocument.signalParagraphStyleModified, onParagraphStyleModified); odtDocument.unsubscribe(ops.OdtDocument.signalParagraphChanged, trackCurrentParagraph); odtDocument.unsubscribe(ops.OdtDocument.signalUndoStackChanged, undoStackModified); eventManager.unsubscribe("mousemove", hyperlinkTooltipView.showTooltip); eventManager.unsubscribe("mouseout", hyperlinkTooltipView.hideTooltip); delete self.sessionView; delete self.sessionController; callback(); } /** * @param {!function(!Error=)} callback passing an error object in case of error * @return {undefined} */ this.destroy = function(callback) { var cleanup = [ self.sessionView.destroy, caretManager.destroy, selectionViewManager.destroy, self.sessionController.destroy, hyperlinkTooltipView.destroy, odfFieldView.destroy, destroy ]; core.Async.destroyAll(cleanup, callback); }; function init() { var head = document.getElementsByTagName('head')[0], odfCanvas = session.getOdtDocument().getOdfCanvas(), eventManager; // TODO: fonts.css should be rather done by odfCanvas, or? fontStyles.type = 'text/css'; fontStyles.media = 'screen, print, handheld, projection'; fontStyles.appendChild(document.createTextNode(fontsCSS)); head.appendChild(fontStyles); odfFieldView = new gui.OdfFieldView(odfCanvas); odfFieldView.showFieldHighlight(); self.sessionController = new gui.SessionController(session, localMemberId, shadowCursor, { annotationsEnabled: config.annotationsEnabled, directTextStylingEnabled: config.directTextStylingEnabled, directParagraphStylingEnabled: config.directParagraphStylingEnabled }); sessionConstraints = self.sessionController.getSessionConstraints(); eventManager = self.sessionController.getEventManager(); hyperlinkTooltipView = new gui.HyperlinkTooltipView(odfCanvas, self.sessionController.getHyperlinkClickHandler().getModifier); eventManager.subscribe("mousemove", hyperlinkTooltipView.showTooltip); eventManager.subscribe("mouseout", hyperlinkTooltipView.hideTooltip); caretManager = new gui.CaretManager(self.sessionController, odfCanvas.getViewport()); selectionViewManager = new gui.SelectionViewManager(gui.SvgSelectionView); self.sessionView = new gui.SessionView(config.viewOptions, localMemberId, session, sessionConstraints, caretManager, selectionViewManager); self.availableFonts = getAvailableFonts(); selectionViewManager.registerCursor(shadowCursor, true); // Session Constraints can be applied once the controllers are instantiated. if (config.reviewModeEnabled) { // Disallow deleting other authors' annotations. sessionConstraints.setState(gui.CommonConstraints.EDIT.ANNOTATIONS.ONLY_DELETE_OWN, true); sessionConstraints.setState(gui.CommonConstraints.EDIT.REVIEW_MODE, true); } // Custom signals, that make sense in the Editor context. We do not want to expose webodf's ops signals to random bits of the editor UI. odtDocument.subscribe(ops.Document.signalMemberAdded, onMemberAdded); odtDocument.subscribe(ops.Document.signalMemberUpdated, onMemberUpdated); odtDocument.subscribe(ops.Document.signalMemberRemoved, onMemberRemoved); odtDocument.subscribe(ops.Document.signalCursorAdded, onCursorAdded); odtDocument.subscribe(ops.Document.signalCursorRemoved, onCursorRemoved); odtDocument.subscribe(ops.Document.signalCursorMoved, onCursorMoved); odtDocument.subscribe(ops.OdtDocument.signalCommonStyleCreated, onStyleCreated); odtDocument.subscribe(ops.OdtDocument.signalCommonStyleDeleted, onStyleDeleted); odtDocument.subscribe(ops.OdtDocument.signalParagraphStyleModified, onParagraphStyleModified); odtDocument.subscribe(ops.OdtDocument.signalParagraphChanged, trackCurrentParagraph); odtDocument.subscribe(ops.OdtDocument.signalUndoStackChanged, undoStackModified); } init(); }; /**@const*/EditorSession.signalMemberAdded = "memberAdded"; /**@const*/EditorSession.signalMemberUpdated = "memberUpdated"; /**@const*/EditorSession.signalMemberRemoved = "memberRemoved"; /**@const*/EditorSession.signalCursorAdded = "cursorAdded"; /**@const*/EditorSession.signalCursorRemoved = "cursorRemoved"; /**@const*/EditorSession.signalCursorMoved = "cursorMoved"; /**@const*/EditorSession.signalParagraphChanged = "paragraphChanged"; /**@const*/EditorSession.signalCommonStyleCreated = "styleCreated"; /**@const*/EditorSession.signalCommonStyleDeleted = "styleDeleted"; /**@const*/EditorSession.signalParagraphStyleModified = "paragraphStyleModified"; /**@const*/EditorSession.signalUndoStackChanged = "signalUndoStackChanged"; return EditorSession; })("");