diff --git a/js/editor/Editor.js b/js/editor/Editor.js index c950b7b5..d8a8514d 100644 --- a/js/editor/Editor.js +++ b/js/editor/Editor.js @@ -384,7 +384,8 @@ define("webodf/editor/Editor", [ // create session around loaded document session = new ops.Session(odfCanvas); editorSession = new EditorSession(session, pendingMemberId, { - viewOptions: viewOptions + viewOptions: viewOptions, + directStylingEnabled: directStylingEnabled }); if (undoRedoEnabled) { editorSession.sessionController.setUndoManager(new gui.TrivialUndoManager()); diff --git a/js/editor/EditorSession.js b/js/editor/EditorSession.js index ea271fd3..e9a11b77 100644 --- a/js/editor/EditorSession.js +++ b/js/editor/EditorSession.js @@ -54,14 +54,13 @@ define("webodf/editor/EditorSession", [ runtime.loadClass("gui.SessionController"); runtime.loadClass("gui.SessionView"); runtime.loadClass("gui.TrivialUndoManager"); - runtime.loadClass("gui.StyleHelper"); runtime.loadClass("core.EventNotifier"); /** * Instantiate a new editor session attached to an existing operation session * @param {!ops.Session} session * @param {!string} localMemberId - * @param {{viewOptions:gui.SessionViewOptions}} config + * @param {{viewOptions:gui.SessionViewOptions,directStylingEnabled:boolean}} config * @constructor */ var EditorSession = function EditorSession(session, localMemberId, config) { @@ -74,33 +73,23 @@ define("webodf/editor/EditorSession", [ textns = odf.Namespaces.textns, fontStyles = document.createElement('style'), formatting = odtDocument.getFormatting(), - styleHelper = new gui.StyleHelper(formatting), domUtils = new core.DomUtils(), eventNotifier = new core.EventNotifier([ EditorSession.signalMemberAdded, EditorSession.signalMemberRemoved, EditorSession.signalCursorMoved, EditorSession.signalParagraphChanged, - EditorSession.signalStyleCreated, - EditorSession.signalStyleDeleted, + EditorSession.signalCommonParagraphStyleCreated, + EditorSession.signalCommonParagraphStyleDeleted, EditorSession.signalParagraphStyleModified, EditorSession.signalUndoStackChanged]); - this.sessionController = new gui.SessionController(session, localMemberId); + this.sessionController = new gui.SessionController(session, localMemberId, {directStylingEnabled: config.directStylingEnabled}); caretManager = new gui.CaretManager(self.sessionController); this.sessionView = new gui.SessionView(config.viewOptions, session, caretManager); this.availableFonts = []; - function isTrueForSelection(predicate) { - var cursor = odtDocument.getCursor(localMemberId); - // no own cursor yet/currently added? - if (!cursor) { - return false; - } - return predicate(cursor.getSelectedRange()); - } - /* * @return {Array.{!string}} */ @@ -233,11 +222,11 @@ define("webodf/editor/EditorSession", [ } function onStyleCreated(newStyleName) { - self.emit(EditorSession.signalStyleCreated, newStyleName); + self.emit(EditorSession.signalCommonParagraphStyleCreated, newStyleName); } function onStyleDeleted(styleName) { - self.emit(EditorSession.signalStyleDeleted, styleName); + self.emit(EditorSession.signalCommonParagraphStyleDeleted, styleName); } function onParagraphStyleModified(styleName) { @@ -299,32 +288,10 @@ define("webodf/editor/EditorSession", [ return formatting.getAvailableParagraphStyles(); }; - this.isBold = isTrueForSelection.bind(self, styleHelper.isBold); - this.isItalic = isTrueForSelection.bind(self, styleHelper.isItalic); - this.hasUnderline = isTrueForSelection.bind(self, styleHelper.hasUnderline); - this.hasStrikeThrough = isTrueForSelection.bind(self, styleHelper.hasStrikeThrough); - - this.isAlignedLeft = isTrueForSelection.bind(self, styleHelper.isAlignedLeft); - this.isAlignedCenter = isTrueForSelection.bind(self, styleHelper.isAlignedCenter); - this.isAlignedRight = isTrueForSelection.bind(self, styleHelper.isAlignedRight); - this.isAlignedJustified = isTrueForSelection.bind(self, styleHelper.isAlignedJustified); - this.getCurrentParagraphStyle = function () { return currentNamedStyleName; }; - this.formatSelection = function (value) { - var op = new ops.OpApplyDirectStyling(), - selection = self.getCursorSelection(); - op.init({ - memberid: localMemberId, - position: selection.position, - length: selection.length, - setProperties: value - }); - session.enqueue(op); - }; - /** * Adds an annotation to the document based on the current selection * @return {undefined} @@ -555,8 +522,8 @@ define("webodf/editor/EditorSession", [ odtDocument.unsubscribe(ops.OdtDocument.signalCursorAdded, onCursorAdded); odtDocument.unsubscribe(ops.OdtDocument.signalCursorRemoved, onCursorRemoved); odtDocument.unsubscribe(ops.OdtDocument.signalCursorMoved, onCursorMoved); - odtDocument.unsubscribe(ops.OdtDocument.signalStyleCreated, onStyleCreated); - odtDocument.unsubscribe(ops.OdtDocument.signalStyleDeleted, onStyleDeleted); + odtDocument.unsubscribe(ops.OdtDocument.signalCommonParagraphStyleCreated, onStyleCreated); + odtDocument.unsubscribe(ops.OdtDocument.signalCommonParagraphStyleDeleted, onStyleDeleted); odtDocument.unsubscribe(ops.OdtDocument.signalParagraphStyleModified, onParagraphStyleModified); odtDocument.unsubscribe(ops.OdtDocument.signalParagraphChanged, trackCurrentParagraph); odtDocument.unsubscribe(ops.OdtDocument.signalUndoStackChanged, undoStackModified); @@ -597,8 +564,8 @@ define("webodf/editor/EditorSession", [ odtDocument.subscribe(ops.OdtDocument.signalCursorAdded, onCursorAdded); odtDocument.subscribe(ops.OdtDocument.signalCursorRemoved, onCursorRemoved); odtDocument.subscribe(ops.OdtDocument.signalCursorMoved, onCursorMoved); - odtDocument.subscribe(ops.OdtDocument.signalStyleCreated, onStyleCreated); - odtDocument.subscribe(ops.OdtDocument.signalStyleDeleted, onStyleDeleted); + odtDocument.subscribe(ops.OdtDocument.signalCommonParagraphStyleCreated, onStyleCreated); + odtDocument.subscribe(ops.OdtDocument.signalCommonParagraphStyleDeleted, onStyleDeleted); odtDocument.subscribe(ops.OdtDocument.signalParagraphStyleModified, onParagraphStyleModified); odtDocument.subscribe(ops.OdtDocument.signalParagraphChanged, trackCurrentParagraph); odtDocument.subscribe(ops.OdtDocument.signalUndoStackChanged, undoStackModified); @@ -611,8 +578,8 @@ define("webodf/editor/EditorSession", [ /**@const*/EditorSession.signalMemberRemoved = "memberRemoved"; /**@const*/EditorSession.signalCursorMoved = "cursorMoved"; /**@const*/EditorSession.signalParagraphChanged = "paragraphChanged"; - /**@const*/EditorSession.signalStyleCreated = "styleCreated"; - /**@const*/EditorSession.signalStyleDeleted = "styleDeleted"; + /**@const*/EditorSession.signalCommonParagraphStyleCreated = "styleCreated"; + /**@const*/EditorSession.signalCommonParagraphStyleDeleted = "styleDeleted"; /**@const*/EditorSession.signalParagraphStyleModified = "paragraphStyleModified"; /**@const*/EditorSession.signalUndoStackChanged = "signalUndoStackChanged"; diff --git a/js/editor/Tools.js b/js/editor/Tools.js index 3ee59426..88c32cb5 100644 --- a/js/editor/Tools.js +++ b/js/editor/Tools.js @@ -97,6 +97,21 @@ define("webodf/editor/Tools", [ sessionSubscribers.push(undoRedoMenu); } + // Add annotation + if (args.annotationsEnabled) { + annotateButton = new Button({ + label: translator('annotate'), + showLabel: false, + iconClass: 'dijitIconBookmark', + onClick: function () { + if (editorSession) { + editorSession.addAnnotation(); + } + } + }); + annotateButton.placeAt(toolbar); + } + // Simple Style Selector [B, I, U, S] if (args.directStylingEnabled) { simpleStyles = new SimpleStyles(function (widget) { @@ -189,21 +204,6 @@ define("webodf/editor/Tools", [ }); formatMenuButton.placeAt(toolbar); - // Add annotation - if (args.annotationsEnabled) { - annotateButton = new Button({ - label: translator('annotate'), - showLabel: false, - iconClass: 'dijitIconBookmark', - onClick: function () { - if (editorSession) { - editorSession.addAnnotation(); - } - } - }); - annotateButton.placeAt(toolbar); - } - if (close) { closeButton = new Button({ label: translator('close'), diff --git a/js/editor/server/pullbox/SessionList.js b/js/editor/server/pullbox/SessionList.js index c0b6b349..e0d57acc 100644 --- a/js/editor/server/pullbox/SessionList.js +++ b/js/editor/server/pullbox/SessionList.js @@ -48,6 +48,8 @@ define("webodf/editor/server/pullbox/SessionList", [], function () { var i, isNew = ! cachedSessionData.hasOwnProperty(sessionData.id); + // extend data with download url + sessionData.fileUrl = "/session/" + sessionData.id + "/last/" + sessionData.filename; // cache cachedSessionData[sessionData.id] = sessionData; runtime.log("get session data for:"+sessionData.title+", is new:"+isNew); diff --git a/js/editor/widgets/fontPicker.js b/js/editor/widgets/fontPicker.js index 9e99cdb6..513c2626 100644 --- a/js/editor/widgets/fontPicker.js +++ b/js/editor/widgets/fontPicker.js @@ -32,108 +32,102 @@ * @source: http://gitorious.org/webodf/webodf/ */ /*global define,require,document */ -define("webodf/editor/widgets/fontPicker", [], function () { - "use strict"; - /** - * @constructor - */ - var FontPicker = function (callback) { - var self = this, - editorSession, - select, - editorFonts = [], - documentFonts = [], - selectionList = []; +define("webodf/editor/widgets/fontPicker", [ + "dijit/form/Select"], - this.widget = function () { - return select; - }; - - this.value = function () { - return select.get('value'); - }; - - this.setValue = function (value) { - select.set('value', value); - }; + function (Select) { + "use strict"; /** - * Returns the font family for a given font name. If unavailable, - * return the name itself (e.g. editor fonts won't have a name-family separation - * @param {!string} name - * @return {!string} + * @constructor */ - this.getFamily = function (name) { - var i; - for (i = 0; i < documentFonts.length; i += 1) { - if ((documentFonts[i].name === name) && documentFonts[i].family) { - return documentFonts[i].family; + var FontPicker = function (callback) { + var self = this, + editorSession, + select, + editorFonts = [], + documentFonts = [], + selectionList = []; + + select = new Select({ + name: 'FontPicker', + maxHeight: 200, + style: { + width: '150px' } - } - return name; - }; - // events - this.onAdd = null; - this.onRemove = null; + }); - function populateFonts() { - var i, name, family; - editorFonts = editorSession ? editorSession.availableFonts : []; - documentFonts = editorSession ? editorSession.getDeclaredFonts() : []; + this.widget = function () { + return select; + }; - // First populate the fonts used in the document - for (i = 0; i < documentFonts.length; i += 1) { - name = documentFonts[i].name; - family = documentFonts[i].family || name; - selectionList.push({ - label: '' + name + '', - value: name - }); - } - if (editorFonts.length) { - // Then add a separator - selectionList.push({ - type: 'separator' - }); - } - // Lastly populate the fonts provided by the editor - for (i = 0; i < editorFonts.length; i += 1) { - selectionList.push({ - label: '' + editorFonts[i] + '', - value: editorFonts[i] - }); - } + this.value = function () { + return select.get('value'); + }; - select.removeOption(select.getOptions()); - select.addOption(selectionList); - } + this.setValue = function (value) { + select.set('value', value); + }; - this.setEditorSession = function(session) { - editorSession = session; - populateFonts(); - }; + /** + * Returns the font family for a given font name. If unavailable, + * return the name itself (e.g. editor fonts won't have a name-family separation + * @param {!string} name + * @return {!string} + */ + this.getFamily = function (name) { + var i; + for (i = 0; i < documentFonts.length; i += 1) { + if ((documentFonts[i].name === name) && documentFonts[i].family) { + return documentFonts[i].family; + } + } + return name; + }; + // events + this.onAdd = null; + this.onRemove = null; + function populateFonts() { + var i, name, family; + editorFonts = editorSession ? editorSession.availableFonts : []; + documentFonts = editorSession ? editorSession.getDeclaredFonts() : []; - function init(cb) { - require(["dijit/form/Select"], function (Select) { - select = new Select({ - name: 'FontPicker', - maxHeight: 200, - style: { - width: '100px' - } - }); + // First populate the fonts used in the document + for (i = 0; i < documentFonts.length; i += 1) { + name = documentFonts[i].name; + family = documentFonts[i].family || name; + selectionList.push({ + label: '' + name + '', + value: name + }); + } + if (editorFonts.length) { + // Then add a separator + selectionList.push({ + type: 'separator' + }); + } + // Lastly populate the fonts provided by the editor + for (i = 0; i < editorFonts.length; i += 1) { + selectionList.push({ + label: '' + editorFonts[i] + '', + value: editorFonts[i] + }); + } - populateFonts(); + select.removeOption(select.getOptions()); + select.addOption(selectionList); + } - return cb(); - }); - } + this.setEditorSession = function(session) { + editorSession = session; + populateFonts(); + }; - init(function () { - return callback(self); - }); - }; + populateFonts(); + callback(self); + }; - return FontPicker; + return FontPicker; }); diff --git a/js/editor/widgets/paragraphAlignment.js b/js/editor/widgets/paragraphAlignment.js index 0dd9b5a4..efa4e049 100644 --- a/js/editor/widgets/paragraphAlignment.js +++ b/js/editor/widgets/paragraphAlignment.js @@ -36,16 +36,15 @@ /*global define,require,document */ define("webodf/editor/widgets/paragraphAlignment", [ - "webodf/editor/EditorSession", "dijit/form/ToggleButton", "dijit/form/Button"], - function (EditorSession, ToggleButton, Button) { + function (ToggleButton, Button) { "use strict"; var ParagraphAlignment = function (callback) { var widget = {}, - editorSession, + directParagraphStyler, justifyLeft, justifyCenter, justifyRight, @@ -55,75 +54,68 @@ define("webodf/editor/widgets/paragraphAlignment", [ justifyLeft = new ToggleButton({ label: document.translator('justifyLeft'), + disabled: true, showLabel: false, checked: false, iconClass: "dijitEditorIcon dijitEditorIconJustifyLeft", onChange: function () { - editorSession.sessionController.alignParagraphLeft(); + directParagraphStyler.alignParagraphLeft(); } }); justifyCenter = new ToggleButton({ label: document.translator('justifyCenter'), + disabled: true, showLabel: false, checked: false, iconClass: "dijitEditorIcon dijitEditorIconJustifyCenter", onChange: function () { - editorSession.sessionController.alignParagraphCenter(); + directParagraphStyler.alignParagraphCenter(); } }); justifyRight = new ToggleButton({ label: document.translator('justifyRight'), + disabled: true, showLabel: false, checked: false, iconClass: "dijitEditorIcon dijitEditorIconJustifyRight", onChange: function () { - editorSession.sessionController.alignParagraphRight(); + directParagraphStyler.alignParagraphRight(); } }); justifyFull = new ToggleButton({ label: document.translator('justifyFull'), + disabled: true, showLabel: false, checked: false, iconClass: "dijitEditorIcon dijitEditorIconJustifyFull", onChange: function () { - editorSession.sessionController.alignParagraphJustified(); + directParagraphStyler.alignParagraphJustified(); } }); outdent = new Button({ label: document.translator('outdent'), + disabled: true, showLabel: false, - disabled: false, iconClass: "dijitEditorIcon dijitEditorIconOutdent", onClick: function () { - editorSession.sessionController.outdent(); + directParagraphStyler.outdent(); } }); indent = new Button({ label: document.translator('indent'), + disabled: true, showLabel: false, - disabled: false, iconClass: "dijitEditorIcon dijitEditorIconIndent", onClick: function () { - editorSession.sessionController.indent(); + directParagraphStyler.indent(); } }); - function checkStyleButtons() { - // The 3rd parameter is false to avoid firing onChange when setting the value - // programmatically. - justifyLeft.set('checked', editorSession.isAlignedLeft(), false); - justifyCenter.set('checked', editorSession.isAlignedCenter(), false); - justifyRight.set('checked', editorSession.isAlignedRight(), false); - justifyFull.set('checked', editorSession.isAlignedJustified(), false); - } - - - widget.children = [justifyLeft, justifyCenter, justifyRight, @@ -145,19 +137,40 @@ define("webodf/editor/widgets/paragraphAlignment", [ return widget; }; + function updateStyleButtons(changes) { + var buttons = { + isAlignedLeft: justifyLeft, + isAlignedCenter: justifyCenter, + isAlignedRight: justifyRight, + isAlignedJustified: justifyFull + }; + + Object.keys(changes).forEach(function (key) { + var button = buttons[key]; + if (button) { + // The 3rd parameter to set(...) is false to avoid firing onChange when setting the value programmatically. + button.set('checked', changes[key], false); + } + }); + } + this.setEditorSession = function(session) { - if (editorSession) { - editorSession.unsubscribe(EditorSession.signalCursorMoved, checkStyleButtons); - editorSession.unsubscribe(EditorSession.signalParagraphChanged, checkStyleButtons); - editorSession.unsubscribe(EditorSession.signalParagraphStyleModified, checkStyleButtons); + if (directParagraphStyler) { + directParagraphStyler.unsubscribe(gui.DirectParagraphStyler.paragraphStylingChanged, updateStyleButtons); } - editorSession = session; - if (editorSession) { - editorSession.subscribe(EditorSession.signalCursorMoved, checkStyleButtons); - editorSession.subscribe(EditorSession.signalParagraphChanged, checkStyleButtons); - editorSession.subscribe(EditorSession.signalParagraphStyleModified, checkStyleButtons); - checkStyleButtons(); + directParagraphStyler = session && session.sessionController.getDirectParagraphStyler(); + if (directParagraphStyler) { + directParagraphStyler.subscribe(gui.DirectParagraphStyler.paragraphStylingChanged, updateStyleButtons); } + widget.children.forEach(function (element) { + element.setAttribute('disabled', !directParagraphStyler); + }); + updateStyleButtons({ + isAlignedLeft: directParagraphStyler ? directParagraphStyler.isAlignedLeft() : false, + isAlignedCenter: directParagraphStyler ? directParagraphStyler.isAlignedCenter() : false, + isAlignedRight: directParagraphStyler ? directParagraphStyler.isAlignedRight() : false, + isAlignedJustified: directParagraphStyler ? directParagraphStyler.isAlignedJustified() : false + }); }; callback(widget); diff --git a/js/editor/widgets/paragraphStyles.js b/js/editor/widgets/paragraphStyles.js index 6d8bf205..cc4f4cd2 100644 --- a/js/editor/widgets/paragraphStyles.js +++ b/js/editor/widgets/paragraphStyles.js @@ -129,13 +129,13 @@ define("webodf/editor/widgets/paragraphStyles", this.setEditorSession = function(session) { if (editorSession) { - editorSession.unsubscribe(EditorSession.signalStyleCreated, addStyle); - editorSession.unsubscribe(EditorSession.signalStyleDeleted, removeStyle); + editorSession.unsubscribe(EditorSession.signalCommonParagraphStyleCreated, addStyle); + editorSession.unsubscribe(EditorSession.signalCommonParagraphStyleDeleted, removeStyle); } editorSession = session; if (editorSession) { - editorSession.subscribe(EditorSession.signalStyleCreated, addStyle); - editorSession.subscribe(EditorSession.signalStyleDeleted, removeStyle); + editorSession.subscribe(EditorSession.signalCommonParagraphStyleCreated, addStyle); + editorSession.subscribe(EditorSession.signalCommonParagraphStyleDeleted, removeStyle); populateStyles(); } }; diff --git a/js/editor/widgets/simpleStyles.js b/js/editor/widgets/simpleStyles.js index 6524bc7d..ecb31d30 100644 --- a/js/editor/widgets/simpleStyles.js +++ b/js/editor/widgets/simpleStyles.js @@ -35,143 +35,150 @@ /*global define,require,document */ -define("webodf/editor/widgets/simpleStyles", - ["webodf/editor/EditorSession"], - - function (EditorSession) { - "use strict"; - - return function SimpleStyles(callback) { - var editorSession, - boldButton, - italicButton, - underlineButton, - strikethroughButton; - - function makeWidget(callback) { - require(["dijit/form/ToggleButton"], function (ToggleButton) { - var i, - widget = {}; - - boldButton = new ToggleButton({ - label: document.translator('bold'), - showLabel: false, - checked: editorSession ? editorSession.isBold(): false, - iconClass: "dijitEditorIcon dijitEditorIconBold", - onChange: function (checked) { - var value = checked ? 'bold' : 'normal'; - if (editorSession) { - editorSession.formatSelection({ - 'style:text-properties': { - 'fo:font-weight' : value - } - }); - } - } - }); +define("webodf/editor/widgets/simpleStyles", [ + "webodf/editor/widgets/fontPicker", + "dijit/form/ToggleButton", + "dijit/form/NumberSpinner"], - italicButton = new ToggleButton({ - label: document.translator('italic'), - showLabel: false, - checked: editorSession ? editorSession.isItalic(): false, - iconClass: "dijitEditorIcon dijitEditorIconItalic", - onChange: function (checked) { - var value = checked ? 'italic' : 'normal'; - if (editorSession) { - editorSession.formatSelection({ - 'style:text-properties': { - 'fo:font-style' : value - } - }); - } - } - }); - underlineButton = new ToggleButton({ - label: document.translator('underline'), - showLabel: false, - checked: editorSession ? editorSession.hasUnderline(): false, - iconClass: "dijitEditorIcon dijitEditorIconUnderline", - onChange: function (checked) { - var value = checked ? 'solid' : 'none'; - if (editorSession) { - editorSession.formatSelection({ - 'style:text-properties': { - 'style:text-underline-style' : value - } - }); - } - } - }); - strikethroughButton = new ToggleButton({ - label: document.translator('strikethrough'), - showLabel: false, - checked: editorSession ? editorSession.hasStrikeThrough(): false, - iconClass: "dijitEditorIcon dijitEditorIconStrikethrough", - onChange: function (checked) { - var value = checked ? 'solid' : 'none'; - if (editorSession) { - editorSession.formatSelection({ - 'style:text-properties': { - 'style:text-line-through-style' : value - } - }); - } - } - }); + function (FontPicker, ToggleButton, NumberSpinner) { + "use strict"; - widget.children = [boldButton, italicButton, underlineButton, strikethroughButton]; - widget.startup = function () { - widget.children.forEach(function (element) { - element.startup(); - }); - }; + var SimpleStyles = function(callback) { + var widget = {}, + directTextStyler, + boldButton, + italicButton, + underlineButton, + strikethroughButton, + fontSizeSpinner, + fontPicker, + fontPickerWidget; - widget.placeAt = function (container) { - widget.children.forEach(function (element) { - element.placeAt(container); - }); - return widget; - }; + boldButton = new ToggleButton({ + label: document.translator('bold'), + disabled: true, + showLabel: false, + checked: false, + iconClass: "dijitEditorIcon dijitEditorIconBold", + onChange: function (checked) { + directTextStyler.setBold(checked); + } + }); - return callback(widget); + italicButton = new ToggleButton({ + label: document.translator('italic'), + disabled: true, + showLabel: false, + checked: false, + iconClass: "dijitEditorIcon dijitEditorIconItalic", + onChange: function (checked) { + directTextStyler.setItalic(checked); + } }); - } - function checkStyleButtons() { - // The 3rd parameter is false to avoid firing onChange when setting the value - // programmatically. - if (boldButton) { - boldButton.set('checked', editorSession.isBold(), false); - } - if (italicButton) { - italicButton.set('checked', editorSession.isItalic(), false); - } - if (underlineButton) { - underlineButton.set('checked', editorSession.hasUnderline(), false); - } - if (strikethroughButton) { - strikethroughButton.set('checked', editorSession.hasStrikeThrough(), false); - } - } + underlineButton = new ToggleButton({ + label: document.translator('underline'), + disabled: true, + showLabel: false, + checked: false, + iconClass: "dijitEditorIcon dijitEditorIconUnderline", + onChange: function (checked) { + directTextStyler.setHasUnderline(checked); + } + }); - this.setEditorSession = function(session) { - if (editorSession) { - editorSession.unsubscribe(EditorSession.signalCursorMoved, checkStyleButtons); - editorSession.unsubscribe(EditorSession.signalParagraphChanged, checkStyleButtons); - editorSession.unsubscribe(EditorSession.signalParagraphStyleModified, checkStyleButtons); - } - editorSession = session; - if (editorSession) { - editorSession.subscribe(EditorSession.signalCursorMoved, checkStyleButtons); - editorSession.subscribe(EditorSession.signalParagraphChanged, checkStyleButtons); - editorSession.subscribe(EditorSession.signalParagraphStyleModified, checkStyleButtons); - checkStyleButtons(); + strikethroughButton = new ToggleButton({ + label: document.translator('strikethrough'), + disabled: true, + showLabel: false, + checked: false, + iconClass: "dijitEditorIcon dijitEditorIconStrikethrough", + onChange: function (checked) { + directTextStyler.setHasStrikethrough(checked); + } + }); + + fontSizeSpinner = new NumberSpinner({ + label: document.translator('size'), + disabled: true, + showLabel: false, + value: 12, + smallDelta: 1, + constraints: {min:6, max:96}, + intermediateChanges: true, + onChange: function(value) { + directTextStyler.setFontSize(value); + } + }); + + fontPicker = new FontPicker(function () {}); + fontPickerWidget = fontPicker.widget(); + fontPickerWidget.setAttribute('disabled', true); + fontPickerWidget.onChange = function(value) { + directTextStyler.setFontName(value); + }; + + widget.children = [boldButton, italicButton, underlineButton, strikethroughButton, fontPickerWidget, fontSizeSpinner]; + widget.startup = function () { + widget.children.forEach(function (element) { + element.startup(); + }); + }; + + widget.placeAt = function (container) { + widget.children.forEach(function (element) { + element.placeAt(container); + }); + return widget; + }; + + function updateStyleButtons(changes) { + // The 3rd parameter to set(...) is false to avoid firing onChange when setting the value programmatically. + var updateCalls = { + isBold: function(value) { boldButton.set('checked', value, false); }, + isItalic: function(value) { italicButton.set('checked', value, false); }, + hasUnderline: function(value) { underlineButton.set('checked', value, false); }, + hasStrikeThrough: function(value) { strikethroughButton.set('checked', value, false); }, + fontSize: function(value) { + fontSizeSpinner.set('intermediateChanges', false); // Necessary due to https://bugs.dojotoolkit.org/ticket/11588 + fontSizeSpinner.set('value', value, false); + fontSizeSpinner.set('intermediateChanges', true); + }, + fontName: function(value) { fontPickerWidget.set('value', value, false); } + }; + + Object.keys(changes).forEach(function (key) { + var updateCall = updateCalls[key]; + if (updateCall) { + updateCall(changes[key]); + } + }); } + + this.setEditorSession = function(session) { + if (directTextStyler) { + directTextStyler.unsubscribe(gui.DirectTextStyler.textStylingChanged, updateStyleButtons); + } + directTextStyler = session && session.sessionController.getDirectTextStyler(); + fontPicker.setEditorSession(session); + if (directTextStyler) { + directTextStyler.subscribe(gui.DirectTextStyler.textStylingChanged, updateStyleButtons); + } + widget.children.forEach(function (element) { + element.setAttribute('disabled', !directTextStyler); + }); + updateStyleButtons({ + isBold: directTextStyler ? directTextStyler.isBold() : false, + isItalic: directTextStyler ? directTextStyler.isItalic() : false, + hasUnderline: directTextStyler ? directTextStyler.hasUnderline() : false, + hasStrikeThrough: directTextStyler ? directTextStyler.hasStrikeThrough() : false, + fontSize: directTextStyler ? directTextStyler.fontSize() : undefined, + fontName: directTextStyler ? directTextStyler.fontName() : undefined + }); + }; + + callback(widget); }; - // init - makeWidget(function (widget) { - return callback(widget); - }); - }; + return SimpleStyles; }); diff --git a/js/webodf-debug.js b/js/webodf-debug.js index eeac81b0..41258d4a 100644 --- a/js/webodf-debug.js +++ b/js/webodf-debug.js @@ -3083,9 +3083,8 @@ core.DomUtils = function DomUtils() { node1.parentNode.removeChild(node1) }else { if(node2.nodeType === Node.TEXT_NODE) { - node2.insertData(0, node1.data); - node1.parentNode.removeChild(node1); - return node2 + node1.appendData(node2.data); + node2.parentNode.removeChild(node2) } } } @@ -8305,7 +8304,9 @@ odf.Formatting = function Formatting() { node.appendChild(element); mapObjOntoNode(element, value) }else { - node.setAttributeNS(ns, key, value) + if(ns) { + node.setAttributeNS(ns, key, value) + } } }) } @@ -9679,18 +9680,8 @@ runtime.loadClass("odf.Namespaces"); runtime.loadClass("odf.OdfUtils"); gui.StyleHelper = function StyleHelper(formatting) { var domUtils = new core.DomUtils, odfUtils = new odf.OdfUtils, textns = odf.Namespaces.textns; - this.getAppliedStyles = function(range) { - var textNodes = odfUtils.getTextNodes(range, true); - return formatting.getAppliedStyles(textNodes) - }; - this.applyStyle = function(memberId, range, info) { - var nextTextNodes = domUtils.splitBoundaries(range), textNodes = odfUtils.getTextNodes(range, false), limits; - limits = {startContainer:range.startContainer, startOffset:range.startOffset, endContainer:range.endContainer, endOffset:range.endOffset}; - formatting.applyStyle(memberId, textNodes, limits, info); - nextTextNodes.forEach(domUtils.normalizeTextNodes) - }; - function hasTextPropertyValue(range, propertyName, propertyValue) { - var hasOtherValue = true, nodes, styles, properties, container, i; + function getAppliedStyles(range) { + var container, nodes; if(range.collapsed) { container = range.startContainer; if(container.hasChildNodes() && range.startOffset < container.childNodes.length) { @@ -9700,7 +9691,18 @@ gui.StyleHelper = function StyleHelper(formatting) { }else { nodes = odfUtils.getTextNodes(range, true) } - styles = formatting.getAppliedStyles(nodes); + return formatting.getAppliedStyles(nodes) + } + this.getAppliedStyles = getAppliedStyles; + this.applyStyle = function(memberId, range, info) { + var nextTextNodes = domUtils.splitBoundaries(range), textNodes = odfUtils.getTextNodes(range, false), limits; + limits = {startContainer:range.startContainer, startOffset:range.startOffset, endContainer:range.endContainer, endOffset:range.endOffset}; + formatting.applyStyle(memberId, textNodes, limits, info); + nextTextNodes.forEach(domUtils.normalizeTextNodes) + }; + function hasTextPropertyValue(range, propertyName, propertyValue) { + var hasOtherValue = true, styles, properties, i; + styles = getAppliedStyles(range); for(i = 0;i < styles.length;i += 1) { properties = styles[i]["style:text-properties"]; hasOtherValue = !properties || properties[propertyName] !== propertyValue; @@ -11051,7 +11053,9 @@ ops.OpAddParagraphStyle = function OpAddParagraphStyle() { odfContainer.rootElement.styles.appendChild(styleNode) } odtDocument.getOdfCanvas().refreshCSS(); - odtDocument.emit(ops.OdtDocument.signalStyleCreated, styleName); + if(!isAutomaticStyle) { + odtDocument.emit(ops.OdtDocument.signalCommonParagraphStyleCreated, styleName) + } return true }; this.spec = function() { @@ -11146,7 +11150,7 @@ ops.OpRemoveParagraphStyle = function OpRemoveParagraphStyle() { } styleNode.parentNode.removeChild(styleNode); odtDocument.getOdfCanvas().refreshCSS(); - odtDocument.emit(ops.OdtDocument.signalStyleDeleted, styleName); + odtDocument.emit(ops.OdtDocument.signalCommonParagraphStyleDeleted, styleName); return true }; this.spec = function() { @@ -12205,48 +12209,6 @@ gui.Caret = function Caret(cursor, avatarInitiallyVisible, blinkOnRangeSelect) { } init() }; -runtime.loadClass("core.EventNotifier"); -gui.ClickHandler = function ClickHandler() { - var clickTimer, clickCount = 0, clickPosition = null, eventNotifier = new core.EventNotifier([gui.ClickHandler.signalSingleClick, gui.ClickHandler.signalDoubleClick, gui.ClickHandler.signalTripleClick]); - function resetClick() { - clickCount = 0; - clickPosition = null - } - this.subscribe = function(eventid, cb) { - eventNotifier.subscribe(eventid, cb) - }; - this.handleMouseUp = function(e) { - var window = runtime.getWindow(); - if(clickPosition && clickPosition.x === e.screenX && clickPosition.y === e.screenY) { - clickCount += 1; - if(clickCount === 1) { - eventNotifier.emit(gui.ClickHandler.signalSingleClick, e) - }else { - if(clickCount === 2) { - eventNotifier.emit(gui.ClickHandler.signalDoubleClick, undefined) - }else { - if(clickCount === 3) { - window.clearTimeout(clickTimer); - eventNotifier.emit(gui.ClickHandler.signalTripleClick, undefined); - resetClick() - } - } - } - }else { - eventNotifier.emit(gui.ClickHandler.signalSingleClick, e); - clickCount = 1; - clickPosition = {x:e.screenX, y:e.screenY}; - window.clearTimeout(clickTimer); - clickTimer = window.setTimeout(resetClick, 400) - } - } -}; -gui.ClickHandler.signalSingleClick = "click"; -gui.ClickHandler.signalDoubleClick = "doubleClick"; -gui.ClickHandler.signalTripleClick = "tripleClick"; -(function() { - return gui.ClickHandler -})(); /* Copyright (C) 2012-2013 KO GmbH @@ -12411,6 +12373,381 @@ gui.Clipboard = function Clipboard() { } init() }; +/* + + Copyright (C) 2013 KO GmbH + + @licstart + The JavaScript code in this page is free software: you can redistribute it + and/or modify it under the terms of the GNU Affero General Public License + (GNU AGPL) as published by the Free Software Foundation, either version 3 of + the License, or (at your option) any later version. The code is distributed + WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU AGPL for more details. + + As additional permission under GNU AGPL version 3 section 7, you + may distribute non-source (e.g., minimized or compacted) forms of + that code without the copy of the GNU GPL normally required by + section 4, provided you include this license notice and a URL + through which recipients can access the Corresponding Source. + + As a special exception to the AGPL, any HTML file which merely makes function + calls to this code, and for that purpose includes it by reference shall be + deemed a separate work for copyright law purposes. In addition, the copyright + holders of this code give you permission to combine this code with free + software libraries that are released under the GNU LGPL. You may copy and + distribute such a system following the terms of the GNU AGPL for this code + and the LGPL for the libraries. If you modify this code, you may extend this + exception to your version of the code, but you are not obligated to do so. + If you do not wish to do so, delete this exception statement from your + version. + + This license applies to this entire compilation. + @licend + @source: http://www.webodf.org/ + @source: http://gitorious.org/webodf/webodf/ +*/ +runtime.loadClass("core.EventNotifier"); +runtime.loadClass("ops.OpApplyDirectStyling"); +runtime.loadClass("gui.StyleHelper"); +gui.DirectTextStyler = function DirectTextStyler(session, inputMemberId) { + var self = this, odtDocument = session.getOdtDocument(), styleHelper = new gui.StyleHelper(odtDocument.getFormatting()), eventNotifier = new core.EventNotifier([gui.DirectTextStyler.textStylingChanged]), isBoldValue = false, isItalicValue = false, hasUnderlineValue = false, hasStrikeThroughValue = false, fontSizeValue, fontNameValue; + function get(obj, keys) { + var i = 0, key = keys[i]; + while(key && obj) { + obj = obj[key]; + i += 1; + key = keys[i] + } + return keys.length === i ? obj : undefined + } + function getCommonValue(objArray, keys) { + var value = get(objArray[0], keys); + return objArray.every(function(obj) { + return value === get(obj, keys) + }) ? value : undefined + } + function updatedCachedValues() { + var cursor = odtDocument.getCursor(inputMemberId), range = cursor && cursor.getSelectedRange(), currentSelectionStyles = range && styleHelper.getAppliedStyles(range), fontSize, diffMap; + function noteChange(oldValue, newValue, id) { + if(oldValue !== newValue) { + if(diffMap === undefined) { + diffMap = {} + } + diffMap[id] = newValue + } + return newValue + } + isBoldValue = noteChange(isBoldValue, range ? styleHelper.isBold(range) : false, "isBold"); + isItalicValue = noteChange(isItalicValue, range ? styleHelper.isItalic(range) : false, "isItalic"); + hasUnderlineValue = noteChange(hasUnderlineValue, range ? styleHelper.hasUnderline(range) : false, "hasUnderline"); + hasStrikeThroughValue = noteChange(hasStrikeThroughValue, range ? styleHelper.hasStrikeThrough(range) : false, "hasStrikeThrough"); + fontSize = currentSelectionStyles && getCommonValue(currentSelectionStyles, ["style:text-properties", "fo:font-size"]); + fontSizeValue = noteChange(fontSizeValue, fontSize && parseFloat(fontSize), "fontSize"); + fontNameValue = noteChange(fontNameValue, currentSelectionStyles && getCommonValue(currentSelectionStyles, ["style:text-properties", "style:font-name"]), "fontName"); + if(diffMap) { + eventNotifier.emit(gui.DirectTextStyler.textStylingChanged, diffMap) + } + } + function onCursorAdded(cursor) { + if(cursor.getMemberId() === inputMemberId) { + updatedCachedValues() + } + } + function onCursorRemoved(memberId) { + if(memberId === inputMemberId) { + updatedCachedValues() + } + } + function onCursorMoved(cursor) { + if(cursor.getMemberId() === inputMemberId) { + updatedCachedValues() + } + } + function onParagraphStyleModified() { + updatedCachedValues() + } + function onParagraphChanged(args) { + var cursor = odtDocument.getCursor(inputMemberId); + if(cursor && odtDocument.getParagraphElement(cursor.getNode()) === args.paragraphElement) { + updatedCachedValues() + } + } + function toggle(predicate, toggleMethod) { + var cursor = odtDocument.getCursor(inputMemberId); + if(!cursor) { + return false + } + toggleMethod(!predicate(cursor.getSelectedRange())); + return true + } + function formatTextSelection(propertyName, propertyValue) { + var selection = odtDocument.getCursorSelection(inputMemberId), op = new ops.OpApplyDirectStyling, properties = {}; + properties[propertyName] = propertyValue; + op.init({memberid:inputMemberId, position:selection.position, length:selection.length, setProperties:{"style:text-properties":properties}}); + session.enqueue(op) + } + function setBold(checked) { + var value = checked ? "bold" : "normal"; + formatTextSelection("fo:font-weight", value) + } + this.setBold = setBold; + function setItalic(checked) { + var value = checked ? "italic" : "normal"; + formatTextSelection("fo:font-style", value) + } + this.setItalic = setItalic; + function setHasUnderline(checked) { + var value = checked ? "solid" : "none"; + formatTextSelection("style:text-underline-style", value) + } + this.setHasUnderline = setHasUnderline; + function setHasStrikethrough(checked) { + var value = checked ? "solid" : "none"; + formatTextSelection("style:text-line-through-style", value) + } + this.setHasStrikethrough = setHasStrikethrough; + function setFontSize(value) { + formatTextSelection("fo:font-size", value + "pt") + } + this.setFontSize = setFontSize; + function setFontName(value) { + formatTextSelection("style:font-name", value) + } + this.setFontName = setFontName; + this.toggleBold = toggle.bind(self, styleHelper.isBold, setBold); + this.toggleItalic = toggle.bind(self, styleHelper.isItalic, setItalic); + this.toggleUnderline = toggle.bind(self, styleHelper.hasUnderline, setHasUnderline); + this.toggleStrikethrough = toggle.bind(self, styleHelper.hasStrikeThrough, setHasStrikethrough); + this.isBold = function() { + return isBoldValue + }; + this.isItalic = function() { + return isItalicValue + }; + this.hasUnderline = function() { + return hasUnderlineValue + }; + this.hasStrikeThrough = function() { + return hasStrikeThroughValue + }; + this.fontSize = function() { + return fontSizeValue + }; + this.fontName = function() { + return fontNameValue + }; + this.subscribe = function(eventid, cb) { + eventNotifier.subscribe(eventid, cb) + }; + this.unsubscribe = function(eventid, cb) { + eventNotifier.unsubscribe(eventid, cb) + }; + this.destroy = function(callback) { + odtDocument.unsubscribe(ops.OdtDocument.signalCursorAdded, onCursorAdded); + odtDocument.unsubscribe(ops.OdtDocument.signalCursorRemoved, onCursorRemoved); + odtDocument.unsubscribe(ops.OdtDocument.signalCursorMoved, onCursorMoved); + odtDocument.unsubscribe(ops.OdtDocument.signalParagraphStyleModified, onParagraphStyleModified); + odtDocument.unsubscribe(ops.OdtDocument.signalParagraphChanged, onParagraphChanged); + callback() + }; + function init() { + odtDocument.subscribe(ops.OdtDocument.signalCursorAdded, onCursorAdded); + odtDocument.subscribe(ops.OdtDocument.signalCursorRemoved, onCursorRemoved); + odtDocument.subscribe(ops.OdtDocument.signalCursorMoved, onCursorMoved); + odtDocument.subscribe(ops.OdtDocument.signalParagraphStyleModified, onParagraphStyleModified); + odtDocument.subscribe(ops.OdtDocument.signalParagraphChanged, onParagraphChanged); + updatedCachedValues() + } + init() +}; +gui.DirectTextStyler.textStylingChanged = "textStyling/changed"; +(function() { + return gui.DirectTextStyler +})(); +/* + + Copyright (C) 2013 KO GmbH + + @licstart + The JavaScript code in this page is free software: you can redistribute it + and/or modify it under the terms of the GNU Affero General Public License + (GNU AGPL) as published by the Free Software Foundation, either version 3 of + the License, or (at your option) any later version. The code is distributed + WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU AGPL for more details. + + As additional permission under GNU AGPL version 3 section 7, you + may distribute non-source (e.g., minimized or compacted) forms of + that code without the copy of the GNU GPL normally required by + section 4, provided you include this license notice and a URL + through which recipients can access the Corresponding Source. + + As a special exception to the AGPL, any HTML file which merely makes function + calls to this code, and for that purpose includes it by reference shall be + deemed a separate work for copyright law purposes. In addition, the copyright + holders of this code give you permission to combine this code with free + software libraries that are released under the GNU LGPL. You may copy and + distribute such a system following the terms of the GNU AGPL for this code + and the LGPL for the libraries. If you modify this code, you may extend this + exception to your version of the code, but you are not obligated to do so. + If you do not wish to do so, delete this exception statement from your + version. + + This license applies to this entire compilation. + @licend + @source: http://www.webodf.org/ + @source: http://gitorious.org/webodf/webodf/ +*/ +runtime.loadClass("core.EventNotifier"); +runtime.loadClass("core.Utils"); +runtime.loadClass("odf.OdfUtils"); +runtime.loadClass("ops.OpAddParagraphStyle"); +runtime.loadClass("ops.OpSetParagraphStyle"); +runtime.loadClass("gui.StyleHelper"); +gui.DirectParagraphStyler = function DirectParagraphStyler(session, inputMemberId, styleNameGenerator) { + var odtDocument = session.getOdtDocument(), utils = new core.Utils, odfUtils = new odf.OdfUtils, styleHelper = new gui.StyleHelper(odtDocument.getFormatting()), eventNotifier = new core.EventNotifier([gui.DirectParagraphStyler.paragraphStylingChanged]), isAlignedLeftValue, isAlignedCenterValue, isAlignedRightValue, isAlignedJustifiedValue; + function updatedCachedValues() { + var cursor = odtDocument.getCursor(inputMemberId), range = cursor && cursor.getSelectedRange(), diffMap; + function noteChange(oldValue, newValue, id) { + if(oldValue !== newValue) { + if(diffMap === undefined) { + diffMap = {} + } + diffMap[id] = newValue + } + return newValue + } + isAlignedLeftValue = noteChange(isAlignedLeftValue, range ? styleHelper.isAlignedLeft(range) : false, "isAlignedLeft"); + isAlignedCenterValue = noteChange(isAlignedCenterValue, range ? styleHelper.isAlignedCenter(range) : false, "isAlignedCenter"); + isAlignedRightValue = noteChange(isAlignedRightValue, range ? styleHelper.isAlignedRight(range) : false, "isAlignedRight"); + isAlignedJustifiedValue = noteChange(isAlignedJustifiedValue, range ? styleHelper.isAlignedJustified(range) : false, "isAlignedJustified"); + if(diffMap) { + eventNotifier.emit(gui.DirectParagraphStyler.paragraphStylingChanged, diffMap) + } + } + function onCursorAdded(cursor) { + if(cursor.getMemberId() === inputMemberId) { + updatedCachedValues() + } + } + function onCursorRemoved(memberId) { + if(memberId === inputMemberId) { + updatedCachedValues() + } + } + function onCursorMoved(cursor) { + if(cursor.getMemberId() === inputMemberId) { + updatedCachedValues() + } + } + function onParagraphStyleModified() { + updatedCachedValues() + } + function onParagraphChanged(args) { + var cursor = odtDocument.getCursor(inputMemberId); + if(cursor && odtDocument.getParagraphElement(cursor.getNode()) === args.paragraphElement) { + updatedCachedValues() + } + } + this.isAlignedLeft = function() { + return isAlignedLeftValue + }; + this.isAlignedCenter = function() { + return isAlignedCenterValue + }; + this.isAlignedRight = function() { + return isAlignedRightValue + }; + this.isAlignedJustified = function() { + return isAlignedJustifiedValue + }; + function applyParagraphDirectStyling(applyDirectStyling) { + var range = odtDocument.getCursor(inputMemberId).getSelectedRange(), position = odtDocument.getCursorPosition(inputMemberId), paragraphs = odfUtils.getParagraphElements(range), formatting = odtDocument.getFormatting(); + paragraphs.forEach(function(paragraph) { + var paragraphStartPoint = position + odtDocument.getDistanceFromCursor(inputMemberId, paragraph, 0), paragraphStyleName = paragraph.getAttributeNS(odf.Namespaces.textns, "style-name"), newParagraphStyleName = styleNameGenerator.generateName(), opAddParagraphStyle, opSetParagraphStyle, paragraphProperties; + paragraphStartPoint += 1; + if(paragraphStyleName) { + paragraphProperties = formatting.createDerivedStyleObject(paragraphStyleName, "paragraph", {}) + } + paragraphProperties = applyDirectStyling(paragraphProperties || {}); + opAddParagraphStyle = new ops.OpAddParagraphStyle; + opAddParagraphStyle.init({memberid:inputMemberId, styleName:newParagraphStyleName, isAutomaticStyle:true, setProperties:paragraphProperties}); + opSetParagraphStyle = new ops.OpSetParagraphStyle; + opSetParagraphStyle.init({memberid:inputMemberId, styleName:newParagraphStyleName, position:paragraphStartPoint}); + session.enqueue(opAddParagraphStyle); + session.enqueue(opSetParagraphStyle) + }) + } + function applySimpleParagraphDirectStyling(styleOverrides) { + applyParagraphDirectStyling(function(paragraphStyle) { + return utils.mergeObjects(paragraphStyle, styleOverrides) + }) + } + function alignParagraph(alignment) { + applySimpleParagraphDirectStyling({"style:paragraph-properties":{"fo:text-align":alignment}}) + } + this.alignParagraphLeft = function() { + alignParagraph("left"); + return true + }; + this.alignParagraphCenter = function() { + alignParagraph("center"); + return true + }; + this.alignParagraphRight = function() { + alignParagraph("right"); + return true + }; + this.alignParagraphJustified = function() { + alignParagraph("justify"); + return true + }; + function modifyParagraphIndent(direction, paragraphStyle) { + var tabStopDistance = odtDocument.getFormatting().getDefaultTabStopDistance(), paragraphProperties = paragraphStyle["style:paragraph-properties"], indentValue = paragraphProperties && paragraphProperties["fo:margin-left"], indent = indentValue && odfUtils.parseLength(indentValue), newIndent; + if(indent && indent.unit === tabStopDistance.unit) { + newIndent = indent.value + direction * tabStopDistance.value + indent.unit + }else { + newIndent = direction * tabStopDistance.value + tabStopDistance.unit + } + return utils.mergeObjects(paragraphStyle, {"style:paragraph-properties":{"fo:margin-left":newIndent}}) + } + this.indent = function() { + applyParagraphDirectStyling(modifyParagraphIndent.bind(null, 1)); + return true + }; + this.outdent = function() { + applyParagraphDirectStyling(modifyParagraphIndent.bind(null, -1)); + return true + }; + this.subscribe = function(eventid, cb) { + eventNotifier.subscribe(eventid, cb) + }; + this.unsubscribe = function(eventid, cb) { + eventNotifier.unsubscribe(eventid, cb) + }; + this.destroy = function(callback) { + odtDocument.unsubscribe(ops.OdtDocument.signalCursorAdded, onCursorAdded); + odtDocument.unsubscribe(ops.OdtDocument.signalCursorRemoved, onCursorRemoved); + odtDocument.unsubscribe(ops.OdtDocument.signalCursorMoved, onCursorMoved); + odtDocument.unsubscribe(ops.OdtDocument.signalParagraphStyleModified, onParagraphStyleModified); + odtDocument.unsubscribe(ops.OdtDocument.signalParagraphChanged, onParagraphChanged); + callback() + }; + function init() { + odtDocument.subscribe(ops.OdtDocument.signalCursorAdded, onCursorAdded); + odtDocument.subscribe(ops.OdtDocument.signalCursorRemoved, onCursorRemoved); + odtDocument.subscribe(ops.OdtDocument.signalCursorMoved, onCursorMoved); + odtDocument.subscribe(ops.OdtDocument.signalParagraphStyleModified, onParagraphStyleModified); + odtDocument.subscribe(ops.OdtDocument.signalParagraphChanged, onParagraphChanged); + updatedCachedValues() + } + init() +}; +gui.DirectParagraphStyler.paragraphStylingChanged = "paragraphStyling/changed"; +(function() { + return gui.DirectParagraphStyler +})(); runtime.loadClass("core.DomUtils"); runtime.loadClass("core.Utils"); runtime.loadClass("odf.OdfUtils"); @@ -12422,14 +12759,14 @@ runtime.loadClass("ops.OpRemoveText"); runtime.loadClass("ops.OpSplitParagraph"); runtime.loadClass("ops.OpSetParagraphStyle"); runtime.loadClass("ops.OpRemoveAnnotation"); -runtime.loadClass("gui.ClickHandler"); runtime.loadClass("gui.Clipboard"); runtime.loadClass("gui.KeyboardHandler"); -runtime.loadClass("gui.StyleHelper"); +runtime.loadClass("gui.DirectTextStyler"); +runtime.loadClass("gui.DirectParagraphStyler"); gui.SessionController = function() { - gui.SessionController = function SessionController(session, inputMemberId) { - var window = (runtime.getWindow()), odtDocument = session.getOdtDocument(), domUtils = new core.DomUtils, odfUtils = new odf.OdfUtils, clipboard = new gui.Clipboard, clickHandler = new gui.ClickHandler, keyDownHandler = new gui.KeyboardHandler, keyPressHandler = new gui.KeyboardHandler, styleHelper = new gui.StyleHelper(odtDocument.getFormatting()), keyboardMovementsFilter = new core.PositionFilterChain, baseFilter = odtDocument.getPositionFilter(), clickStartedWithinContainer = false, undoManager = - null, utils = new core.Utils, styleNameGenerator = new odf.StyleNameGenerator("auto" + utils.hashString(inputMemberId) + "_", odtDocument.getFormatting()); + gui.SessionController = function SessionController(session, inputMemberId, args) { + var window = (runtime.getWindow()), odtDocument = session.getOdtDocument(), utils = new core.Utils, domUtils = new core.DomUtils, odfUtils = new odf.OdfUtils, clipboard = new gui.Clipboard, keyDownHandler = new gui.KeyboardHandler, keyPressHandler = new gui.KeyboardHandler, keyboardMovementsFilter = new core.PositionFilterChain, baseFilter = odtDocument.getPositionFilter(), clickStartedWithinContainer = false, styleNameGenerator = new odf.StyleNameGenerator("auto" + utils.hashString(inputMemberId) + + "_", odtDocument.getFormatting()), undoManager = null, directTextStyler = args && args.directStylingEnabled ? new gui.DirectTextStyler(session, inputMemberId) : null, directParagraphStyler = args && args.directStylingEnabled ? new gui.DirectParagraphStyler(session, inputMemberId, styleNameGenerator) : null; runtime.assert(window !== null, "Expected to be run in an environment which has a global window, like a browser."); keyboardMovementsFilter.addFilter("BaseFilter", baseFilter); keyboardMovementsFilter.addFilter("RootFilter", odtDocument.createRootFilter(inputMemberId)); @@ -12591,9 +12928,6 @@ gui.SessionController = function() { session.enqueue(op) } function selectRange(e) { - if(!clickStartedWithinContainer) { - return - } runtime.setTimeout(function() { var selection = getSelection(e), oldPosition, stepsToAnchor, stepsToFocus, op; if(selection === null) { @@ -12974,76 +13308,29 @@ gui.SessionController = function() { } return false } - function formatTextSelection(propertyName, propertyValue) { - var selection = odtDocument.getCursorSelection(inputMemberId), op = new ops.OpApplyDirectStyling, properties = {}; - properties[propertyName] = propertyValue; - op.init({memberid:inputMemberId, position:selection.position, length:selection.length, setProperties:{"style:text-properties":properties}}); - session.enqueue(op) - } - function toggleBold() { - var range = odtDocument.getCursor(inputMemberId).getSelectedRange(), value = styleHelper.isBold(range) ? "normal" : "bold"; - formatTextSelection("fo:font-weight", value); - return true - } - function toggleItalic() { - var range = odtDocument.getCursor(inputMemberId).getSelectedRange(), value = styleHelper.isItalic(range) ? "normal" : "italic"; - formatTextSelection("fo:font-style", value); - return true - } - function toggleUnderline() { - var range = odtDocument.getCursor(inputMemberId).getSelectedRange(), value = styleHelper.hasUnderline(range) ? "none" : "solid"; - formatTextSelection("style:text-underline-style", value); - return true - } function filterMouseClicks(e) { clickStartedWithinContainer = e.target && domUtils.containsNode(odtDocument.getOdfCanvas().getElement(), e.target) } - function applyParagraphDirectStyling(applyDirectStyling) { - var range = odtDocument.getCursor(inputMemberId).getSelectedRange(), position = odtDocument.getCursorPosition(inputMemberId), paragraphs = odfUtils.getParagraphElements(range), formatting = odtDocument.getFormatting(); - paragraphs.forEach(function(paragraph) { - var paragraphStartPoint = position + odtDocument.getDistanceFromCursor(inputMemberId, paragraph, 0), paragraphStyleName = paragraph.getAttributeNS(odf.Namespaces.textns, "style-name"), newParagraphStyleName = styleNameGenerator.generateName(), opAddParagraphStyle, opSetParagraphStyle, paragraphProperties; - paragraphStartPoint += 1; - if(paragraphStyleName) { - paragraphProperties = formatting.createDerivedStyleObject(paragraphStyleName, "paragraph", {}) - } - paragraphProperties = applyDirectStyling(paragraphProperties || {}); - opAddParagraphStyle = new ops.OpAddParagraphStyle; - opAddParagraphStyle.init({memberid:inputMemberId, styleName:newParagraphStyleName, isAutomaticStyle:true, setProperties:paragraphProperties}); - session.enqueue(opAddParagraphStyle); - opSetParagraphStyle = new ops.OpSetParagraphStyle; - opSetParagraphStyle.init({memberid:inputMemberId, styleName:newParagraphStyleName, position:paragraphStartPoint}); - session.enqueue(opSetParagraphStyle) - }) - } - function applySimpleParagraphDirectStyling(styleOverrides) { - applyParagraphDirectStyling(function(paragraphStyle) { - return utils.mergeObjects(paragraphStyle, styleOverrides) - }) - } - function alignParagraphLeft() { - applySimpleParagraphDirectStyling({"style:paragraph-properties":{"fo:text-align":"left"}}); - return true - } - function alignParagraphCenter() { - applySimpleParagraphDirectStyling({"style:paragraph-properties":{"fo:text-align":"center"}}); - return true - } - function alignParagraphRight() { - applySimpleParagraphDirectStyling({"style:paragraph-properties":{"fo:text-align":"right"}}); - return true - } - function alignParagraphJustified() { - applySimpleParagraphDirectStyling({"style:paragraph-properties":{"fo:text-align":"justify"}}); - return true - } - function modifyParagraphIndent(direction, paragraphStyle) { - var tabStopDistance = odtDocument.getFormatting().getDefaultTabStopDistance(), paragraphProperties = paragraphStyle["style:paragraph-properties"], indentValue = paragraphProperties && paragraphProperties["fo:margin-left"], indent = indentValue && odfUtils.parseLength(indentValue), newIndent; - if(indent && indent.unit === tabStopDistance.unit) { - newIndent = indent.value + direction * tabStopDistance.value + indent.unit + function handleMouseUp(event) { + var target = event.target, clickCount = event.detail, annotationNode = null; + if(target.className === "annotationRemoveButton") { + annotationNode = domUtils.getElementsByTagNameNS(target.parentNode, odf.Namespaces.officens, "annotation")[0]; + removeAnnotation(annotationNode) }else { - newIndent = direction * tabStopDistance.value + tabStopDistance.unit + if(clickStartedWithinContainer) { + if(clickCount === 1) { + selectRange(event) + }else { + if(clickCount === 2) { + selectWord() + }else { + if(clickCount === 3) { + selectParagraph() + } + } + } + } } - return utils.mergeObjects(paragraphStyle, {"style:paragraph-properties":{"fo:margin-left":newIndent}}) } this.startEditing = function() { var canvasElement, op; @@ -13057,7 +13344,7 @@ gui.SessionController = function() { listenEvent(canvasElement, "beforepaste", handleBeforePaste, true); listenEvent(canvasElement, "paste", handlePaste); listenEvent(window, "mousedown", filterMouseClicks); - listenEvent(window, "mouseup", clickHandler.handleMouseUp); + listenEvent(window, "mouseup", handleMouseUp); listenEvent(canvasElement, "contextmenu", handleContextMenu); odtDocument.subscribe(ops.OdtDocument.signalOperationExecuted, maintainCursorSelection); odtDocument.subscribe(ops.OdtDocument.signalOperationExecuted, updateUndoStack); @@ -13082,7 +13369,7 @@ gui.SessionController = function() { removeEvent(canvasElement, "paste", handlePaste); removeEvent(canvasElement, "beforepaste", handleBeforePaste); removeEvent(window, "mousedown", filterMouseClicks); - removeEvent(window, "mouseup", clickHandler.handleMouseUp); + removeEvent(window, "mouseup", handleMouseUp); removeEvent(canvasElement, "contextmenu", handleContextMenu); op = new ops.OpRemoveCursor; op.init({memberid:inputMemberId}); @@ -13091,18 +13378,6 @@ gui.SessionController = function() { undoManager.resetInitialState() } }; - this.alignParagraphLeft = alignParagraphLeft; - this.alignParagraphCenter = alignParagraphCenter; - this.alignParagraphRight = alignParagraphRight; - this.alignParagraphJustified = alignParagraphJustified; - this.indent = function() { - applyParagraphDirectStyling(modifyParagraphIndent.bind(null, 1)); - return true - }; - this.outdent = function() { - applyParagraphDirectStyling(modifyParagraphIndent.bind(null, -1)); - return true - }; this.getInputMemberId = function() { return inputMemberId }; @@ -13125,8 +13400,25 @@ gui.SessionController = function() { this.getUndoManager = function() { return undoManager }; + this.getDirectTextStyler = function() { + return directTextStyler + }; + this.getDirectParagraphStyler = function() { + return directParagraphStyler + }; this.destroy = function(callback) { - callback() + var destroyDirectTextStyler = directTextStyler ? directTextStyler.destroy : function(cb) { + cb() + }, destroyDirectParagraphStyler = directParagraphStyler ? directParagraphStyler.destroy : function(cb) { + cb() + }; + destroyDirectTextStyler(function(err) { + if(err) { + callback(err) + }else { + destroyDirectParagraphStyler(callback) + } + }) }; function init() { var isMacOS = window.navigator.appVersion.toLowerCase().indexOf("mac") !== -1, modifier = gui.KeyboardHandler.Modifier, keyCode = gui.KeyboardHandler.KeyCode; @@ -13167,24 +13459,32 @@ gui.SessionController = function() { keyDownHandler.bind(keyCode.Up, modifier.MetaShift, extendSelectionToDocumentStart); keyDownHandler.bind(keyCode.Down, modifier.MetaShift, extendSelectionToDocumentEnd); keyDownHandler.bind(keyCode.A, modifier.Meta, extendSelectionToEntireDocument); - keyDownHandler.bind(keyCode.B, modifier.Meta, toggleBold); - keyDownHandler.bind(keyCode.I, modifier.Meta, toggleItalic); - keyDownHandler.bind(keyCode.U, modifier.Meta, toggleUnderline); - keyDownHandler.bind(keyCode.L, modifier.MetaShift, alignParagraphLeft); - keyDownHandler.bind(keyCode.E, modifier.MetaShift, alignParagraphCenter); - keyDownHandler.bind(keyCode.R, modifier.MetaShift, alignParagraphRight); - keyDownHandler.bind(keyCode.J, modifier.MetaShift, alignParagraphJustified); + if(directTextStyler) { + keyDownHandler.bind(keyCode.B, modifier.Meta, directTextStyler.toggleBold); + keyDownHandler.bind(keyCode.I, modifier.Meta, directTextStyler.toggleItalic); + keyDownHandler.bind(keyCode.U, modifier.Meta, directTextStyler.toggleUnderline) + } + if(directParagraphStyler) { + keyDownHandler.bind(keyCode.L, modifier.MetaShift, directParagraphStyler.alignParagraphLeft); + keyDownHandler.bind(keyCode.E, modifier.MetaShift, directParagraphStyler.alignParagraphCenter); + keyDownHandler.bind(keyCode.R, modifier.MetaShift, directParagraphStyler.alignParagraphRight); + keyDownHandler.bind(keyCode.J, modifier.MetaShift, directParagraphStyler.alignParagraphJustified) + } keyDownHandler.bind(keyCode.Z, modifier.Meta, undo); keyDownHandler.bind(keyCode.Z, modifier.MetaShift, redo) }else { keyDownHandler.bind(keyCode.A, modifier.Ctrl, extendSelectionToEntireDocument); - keyDownHandler.bind(keyCode.B, modifier.Ctrl, toggleBold); - keyDownHandler.bind(keyCode.I, modifier.Ctrl, toggleItalic); - keyDownHandler.bind(keyCode.U, modifier.Ctrl, toggleUnderline); - keyDownHandler.bind(keyCode.L, modifier.CtrlShift, alignParagraphLeft); - keyDownHandler.bind(keyCode.E, modifier.CtrlShift, alignParagraphCenter); - keyDownHandler.bind(keyCode.R, modifier.CtrlShift, alignParagraphRight); - keyDownHandler.bind(keyCode.J, modifier.CtrlShift, alignParagraphJustified); + if(directTextStyler) { + keyDownHandler.bind(keyCode.B, modifier.Ctrl, directTextStyler.toggleBold); + keyDownHandler.bind(keyCode.I, modifier.Ctrl, directTextStyler.toggleItalic); + keyDownHandler.bind(keyCode.U, modifier.Ctrl, directTextStyler.toggleUnderline) + } + if(directParagraphStyler) { + keyDownHandler.bind(keyCode.L, modifier.CtrlShift, directParagraphStyler.alignParagraphLeft); + keyDownHandler.bind(keyCode.E, modifier.CtrlShift, directParagraphStyler.alignParagraphCenter); + keyDownHandler.bind(keyCode.R, modifier.CtrlShift, directParagraphStyler.alignParagraphRight); + keyDownHandler.bind(keyCode.J, modifier.CtrlShift, directParagraphStyler.alignParagraphJustified) + } keyDownHandler.bind(keyCode.Z, modifier.Ctrl, undo); keyDownHandler.bind(keyCode.Z, modifier.CtrlShift, redo) } @@ -13196,18 +13496,7 @@ gui.SessionController = function() { } return false }); - keyPressHandler.bind(keyCode.Enter, modifier.None, enqueueParagraphSplittingOps); - clickHandler.subscribe(gui.ClickHandler.signalSingleClick, function(event) { - var target = event.target, annotationNode = null; - if(target.className === "annotationRemoveButton") { - annotationNode = domUtils.getElementsByTagNameNS(target.parentNode, odf.Namespaces.officens, "annotation")[0]; - removeAnnotation(annotationNode) - }else { - selectRange(event) - } - }); - clickHandler.subscribe(gui.ClickHandler.signalDoubleClick, selectWord); - clickHandler.subscribe(gui.ClickHandler.signalTripleClick, selectParagraph) + keyPressHandler.bind(keyCode.Enter, modifier.None, enqueueParagraphSplittingOps) } init() }; @@ -14682,8 +14971,8 @@ runtime.loadClass("gui.SelectionMover"); runtime.loadClass("gui.StyleHelper"); runtime.loadClass("core.PositionFilterChain"); ops.OdtDocument = function OdtDocument(odfCanvas) { - var self = this, textns = "urn:oasis:names:tc:opendocument:xmlns:text:1.0", odfUtils, cursors = {}, eventNotifier = new core.EventNotifier([ops.OdtDocument.signalCursorAdded, ops.OdtDocument.signalCursorRemoved, ops.OdtDocument.signalCursorMoved, ops.OdtDocument.signalParagraphChanged, ops.OdtDocument.signalParagraphStyleModified, ops.OdtDocument.signalStyleCreated, ops.OdtDocument.signalStyleDeleted, ops.OdtDocument.signalTableAdded, ops.OdtDocument.signalOperationExecuted, ops.OdtDocument.signalUndoStackChanged]), - FILTER_ACCEPT = core.PositionFilter.FilterResult.FILTER_ACCEPT, FILTER_REJECT = core.PositionFilter.FilterResult.FILTER_REJECT, filter; + var self = this, textns = "urn:oasis:names:tc:opendocument:xmlns:text:1.0", odfUtils, cursors = {}, eventNotifier = new core.EventNotifier([ops.OdtDocument.signalCursorAdded, ops.OdtDocument.signalCursorRemoved, ops.OdtDocument.signalCursorMoved, ops.OdtDocument.signalParagraphChanged, ops.OdtDocument.signalParagraphStyleModified, ops.OdtDocument.signalCommonParagraphStyleCreated, ops.OdtDocument.signalCommonParagraphStyleDeleted, ops.OdtDocument.signalTableAdded, ops.OdtDocument.signalOperationExecuted, + ops.OdtDocument.signalUndoStackChanged]), FILTER_ACCEPT = core.PositionFilter.FilterResult.FILTER_ACCEPT, FILTER_REJECT = core.PositionFilter.FilterResult.FILTER_REJECT, filter; function getRootNode() { var element = odfCanvas.odfContainer().getContentElement(), localName = element && element.localName; runtime.assert(localName === "text", "Unsupported content element type '" + localName + "'for OdtDocument"); @@ -15075,8 +15364,8 @@ ops.OdtDocument.signalCursorRemoved = "cursor/removed"; ops.OdtDocument.signalCursorMoved = "cursor/moved"; ops.OdtDocument.signalParagraphChanged = "paragraph/changed"; ops.OdtDocument.signalTableAdded = "table/added"; -ops.OdtDocument.signalStyleCreated = "style/created"; -ops.OdtDocument.signalStyleDeleted = "style/deleted"; +ops.OdtDocument.signalCommonParagraphStyleCreated = "style/created"; +ops.OdtDocument.signalCommonParagraphStyleDeleted = "style/deleted"; ops.OdtDocument.signalParagraphStyleModified = "paragraphstyle/modified"; ops.OdtDocument.signalOperationExecuted = "operation/executed"; ops.OdtDocument.signalUndoStackChanged = "undo/changed"; diff --git a/js/webodf.js b/js/webodf.js index 1ed7b394..ab535607 100644 --- a/js/webodf.js +++ b/js/webodf.js @@ -36,79 +36,79 @@ */ var core={},gui={},xmldom={},odf={},ops={}; // Input 1 -function Runtime(){}Runtime.ByteArray=function(m){};Runtime.prototype.getVariable=function(m){};Runtime.prototype.toJson=function(m){};Runtime.prototype.fromJson=function(m){};Runtime.ByteArray.prototype.slice=function(m,l){};Runtime.ByteArray.prototype.length=0;Runtime.prototype.byteArrayFromArray=function(m){};Runtime.prototype.byteArrayFromString=function(m,l){};Runtime.prototype.byteArrayToString=function(m,l){};Runtime.prototype.concatByteArrays=function(m,l){}; -Runtime.prototype.read=function(m,l,e,c){};Runtime.prototype.readFile=function(m,l,e){};Runtime.prototype.readFileSync=function(m,l){};Runtime.prototype.loadXML=function(m,l){};Runtime.prototype.writeFile=function(m,l,e){};Runtime.prototype.isFile=function(m,l){};Runtime.prototype.getFileSize=function(m,l){};Runtime.prototype.deleteFile=function(m,l){};Runtime.prototype.log=function(m,l){};Runtime.prototype.setTimeout=function(m,l){};Runtime.prototype.clearTimeout=function(m){}; -Runtime.prototype.libraryPaths=function(){};Runtime.prototype.type=function(){};Runtime.prototype.getDOMImplementation=function(){};Runtime.prototype.parseXML=function(m){};Runtime.prototype.getWindow=function(){};Runtime.prototype.assert=function(m,l,e){};var IS_COMPILED_CODE=!0; -Runtime.byteArrayToString=function(m,l){function e(b){var a="",n,f=b.length;for(n=0;nd?a+=String.fromCharCode(d):(n+=1,c=b[n],194<=d&&224>d?a+=String.fromCharCode((d&31)<<6|c&63):(n+=1,k=b[n],224<=d&&240>d?a+=String.fromCharCode((d&15)<<12|(c&63)<<6|k&63):(n+=1,q=b[n],240<=d&&245>d&&(d=(d&7)<<18|(c&63)<<12|(k&63)<<6|q&63,d-=65536,a+=String.fromCharCode((d>>10)+55296,(d&1023)+56320))))); -return a}var b;"utf8"===l?b=c(m):("binary"!==l&&this.log("Unsupported encoding: "+l),b=e(m));return b};Runtime.getVariable=function(m){try{return eval(m)}catch(l){}};Runtime.toJson=function(m){return JSON.stringify(m)};Runtime.fromJson=function(m){return JSON.parse(m)};Runtime.getFunctionName=function(m){return void 0===m.name?(m=/function\s+(\w+)/.exec(m))&&m[1]:m.name}; -function BrowserRuntime(m){function l(a,n){var f,d,b;void 0!==n?b=a:n=a;m?(d=m.ownerDocument,b&&(f=d.createElement("span"),f.className=b,f.appendChild(d.createTextNode(b)),m.appendChild(f),m.appendChild(d.createTextNode(" "))),f=d.createElement("span"),0k?(d[e]=k,e+=1):2048>k?(d[e]=192|k>>>6,d[e+1]=128|k&63,e+=2):(d[e]=224|k>>>12&15,d[e+1]=128|k>>>6&63,d[e+2]=128|k&63,e+=3)}else for("binary"!== -n&&c.log("unknown encoding: "+n),f=a.length,d=new c.ByteArray(f),b=0;bd.status||0===d.status?f(null):f("Status "+String(d.status)+": "+d.responseText|| -d.statusText):f("File "+a+" is empty."))};n=n.buffer&&!d.sendAsBinary?n.buffer:c.byteArrayToString(n,"binary");try{d.sendAsBinary?d.sendAsBinary(n):d.send(n)}catch(e){c.log("HUH? "+e+" "+n),f(e.message)}};this.deleteFile=function(a,n){delete b[a];var f=new XMLHttpRequest;f.open("DELETE",a,!0);f.onreadystatechange=function(){4===f.readyState&&(200>f.status&&300<=f.status?n(f.responseText):n(null))};f.send(null)};this.loadXML=function(a,n){var f=new XMLHttpRequest;f.open("GET",a,!0);f.overrideMimeType&& -f.overrideMimeType("text/xml");f.onreadystatechange=function(){4===f.readyState&&(0!==f.status||f.responseText?200===f.status||0===f.status?n(null,f.responseXML):n(f.responseText):n("File "+a+" is empty."))};try{f.send(null)}catch(d){n(d.message)}};this.isFile=function(a,n){c.getFileSize(a,function(a){n(-1!==a)})};this.getFileSize=function(a,n){var f=new XMLHttpRequest;f.open("HEAD",a,!0);f.onreadystatechange=function(){if(4===f.readyState){var d=f.getResponseHeader("Content-Length");d?n(parseInt(d, -10)):e(a,"binary",function(d,a){d?n(-1):n(a.length)})}};f.send(null)};this.log=l;this.assert=function(a,n,f){if(!a)throw l("alert","ASSERTION FAILED:\n"+n),f&&f(),n;};this.setTimeout=function(a,n){return setTimeout(function(){a()},n)};this.clearTimeout=function(a){clearTimeout(a)};this.libraryPaths=function(){return["lib"]};this.setCurrentDirectory=function(){};this.type=function(){return"BrowserRuntime"};this.getDOMImplementation=function(){return window.document.implementation};this.parseXML=function(a){return(new DOMParser).parseFromString(a, -"text/xml")};this.exit=function(a){l("Calling exit with code "+String(a)+", but exit() is not implemented.")};this.getWindow=function(){return window}} -function NodeJSRuntime(){function m(a,f,d){a=c.resolve(b,a);"binary"!==f?e.readFile(a,f,d):e.readFile(a,null,d)}var l=this,e=require("fs"),c=require("path"),b="",h,a;this.ByteArray=function(a){return new Buffer(a)};this.byteArrayFromArray=function(a){var f=new Buffer(a.length),d,b=a.length;for(d=0;dd?a+=String.fromCharCode(d):(e+=1,c=b[e],194<=d&&224>d?a+=String.fromCharCode((d&31)<<6|c&63):(e+=1,k=b[e],224<=d&&240>d?a+=String.fromCharCode((d&15)<<12|(c&63)<<6|k&63):(e+=1,p=b[e],240<=d&&245>d&&(d=(d&7)<<18|(c&63)<<12|(k&63)<<6|p&63,d-=65536,a+=String.fromCharCode((d>>10)+55296,(d&1023)+56320))))); +return a}var b;"utf8"===m?b=c(l):("binary"!==m&&this.log("Unsupported encoding: "+m),b=g(l));return b};Runtime.getVariable=function(l){try{return eval(l)}catch(m){}};Runtime.toJson=function(l){return JSON.stringify(l)};Runtime.fromJson=function(l){return JSON.parse(l)};Runtime.getFunctionName=function(l){return void 0===l.name?(l=/function\s+(\w+)/.exec(l))&&l[1]:l.name}; +function BrowserRuntime(l){function m(a,e){var f,d,b;void 0!==e?b=a:e=a;l?(d=l.ownerDocument,b&&(f=d.createElement("span"),f.className=b,f.appendChild(d.createTextNode(b)),l.appendChild(f),l.appendChild(d.createTextNode(" "))),f=d.createElement("span"),0k?(d[p]=k,p+=1):2048>k?(d[p]=192|k>>>6,d[p+1]=128|k&63,p+=2):(d[p]=224|k>>>12&15,d[p+1]=128|k>>>6&63,d[p+2]=128|k&63,p+=3)}else for("binary"!== +e&&c.log("unknown encoding: "+e),f=a.length,d=new c.ByteArray(f),b=0;bd.status||0===d.status?f(null):f("Status "+String(d.status)+": "+d.responseText|| +d.statusText):f("File "+a+" is empty."))};e=e.buffer&&!d.sendAsBinary?e.buffer:c.byteArrayToString(e,"binary");try{d.sendAsBinary?d.sendAsBinary(e):d.send(e)}catch(g){c.log("HUH? "+g+" "+e),f(g.message)}};this.deleteFile=function(a,e){delete b[a];var f=new XMLHttpRequest;f.open("DELETE",a,!0);f.onreadystatechange=function(){4===f.readyState&&(200>f.status&&300<=f.status?e(f.responseText):e(null))};f.send(null)};this.loadXML=function(a,e){var f=new XMLHttpRequest;f.open("GET",a,!0);f.overrideMimeType&& +f.overrideMimeType("text/xml");f.onreadystatechange=function(){4===f.readyState&&(0!==f.status||f.responseText?200===f.status||0===f.status?e(null,f.responseXML):e(f.responseText):e("File "+a+" is empty."))};try{f.send(null)}catch(d){e(d.message)}};this.isFile=function(a,e){c.getFileSize(a,function(a){e(-1!==a)})};this.getFileSize=function(a,e){var f=new XMLHttpRequest;f.open("HEAD",a,!0);f.onreadystatechange=function(){if(4===f.readyState){var d=f.getResponseHeader("Content-Length");d?e(parseInt(d, +10)):g(a,"binary",function(d,k){d?e(-1):e(k.length)})}};f.send(null)};this.log=m;this.assert=function(a,e,f){if(!a)throw m("alert","ASSERTION FAILED:\n"+e),f&&f(),e;};this.setTimeout=function(a,e){return setTimeout(function(){a()},e)};this.clearTimeout=function(a){clearTimeout(a)};this.libraryPaths=function(){return["lib"]};this.setCurrentDirectory=function(){};this.type=function(){return"BrowserRuntime"};this.getDOMImplementation=function(){return window.document.implementation};this.parseXML=function(a){return(new DOMParser).parseFromString(a, +"text/xml")};this.exit=function(a){m("Calling exit with code "+String(a)+", but exit() is not implemented.")};this.getWindow=function(){return window}} +function NodeJSRuntime(){function l(e,a,d){e=c.resolve(b,e);"binary"!==a?g.readFile(e,a,d):g.readFile(e,null,d)}var m=this,g=require("fs"),c=require("path"),b="",n,a;this.ByteArray=function(e){return new Buffer(e)};this.byteArrayFromArray=function(e){var a=new Buffer(e.length),d,b=e.length;for(d=0;d").implementation} -function RhinoRuntime(){function m(a,b){var f;void 0!==b?f=a:b=a;"alert"===f&&print("\n!!!!! ALERT !!!!!");print(b);"alert"===f&&print("!!!!! ALERT !!!!!")}var l=this,e=Packages.javax.xml.parsers.DocumentBuilderFactory.newInstance(),c,b,h="";e.setValidating(!1);e.setNamespaceAware(!0);e.setExpandEntityReferences(!1);e.setSchema(null);b=Packages.org.xml.sax.EntityResolver({resolveEntity:function(a,b){var f=new Packages.java.io.FileReader(b);return new Packages.org.xml.sax.InputSource(f)}});c=e.newDocumentBuilder(); -c.setEntityResolver(b);this.ByteArray=function(a){return[a]};this.byteArrayFromArray=function(a){return a};this.byteArrayFromString=function(a,b){var f=[],d,e=a.length;for(d=0;d").implementation} +function RhinoRuntime(){function l(a,b){var f;void 0!==b?f=a:b=a;"alert"===f&&print("\n!!!!! ALERT !!!!!");print(b);"alert"===f&&print("!!!!! ALERT !!!!!")}var m=this,g=Packages.javax.xml.parsers.DocumentBuilderFactory.newInstance(),c,b,n="";g.setValidating(!1);g.setNamespaceAware(!0);g.setExpandEntityReferences(!1);g.setSchema(null);b=Packages.org.xml.sax.EntityResolver({resolveEntity:function(a,b){var f=new Packages.java.io.FileReader(b);return new Packages.org.xml.sax.InputSource(f)}});c=g.newDocumentBuilder(); +c.setEntityResolver(b);this.ByteArray=function(a){return[a]};this.byteArrayFromArray=function(a){return a};this.byteArrayFromString=function(a,b){var f=[],d,c=a.length;for(d=0;d>>18],b+=p[d>>>12&63],b+=p[d>>>6&63],b+=p[d&63];k===g+1?(d=a[k]<<4,b+=p[d>>>6],b+=p[d&63],b+="=="):k===g&&(d=a[k]<<10|a[k+1]<<2,b+=p[d>>>12],b+=p[d>>>6&63],b+=p[d&63],b+="=");return b}function e(a){a=a.replace(/[^A-Za-z0-9+\/]+/g,"");var d=[],b=a.length%4,k,g=a.length,e;for(k=0;k>16,e>>8&255,e&255);d.length-=[0,0,2,1][b];return d}function c(a){var d=[],b,k=a.length,g;for(b=0;bg?d.push(g):2048>g?d.push(192|g>>>6,128|g&63):d.push(224|g>>>12&15,128|g>>>6&63,128|g&63);return d}function b(a){var d=[],b,k=a.length,g,e,f;for(b=0;bg?d.push(g):(b+=1,e=a[b],224>g?d.push((g&31)<<6|e&63):(b+=1,f=a[b],d.push((g&15)<<12|(e&63)<<6|f&63)));return d}function h(a){return l(m(a))} -function a(a){return String.fromCharCode.apply(String,e(a))}function n(a){return b(m(a))}function f(a){a=b(a);for(var d="",k=0;kd?k+=String.fromCharCode(d):(f+=1,g=a.charCodeAt(f)&255,224>d?k+=String.fromCharCode((d&31)<<6|g&63):(f+=1,e=a.charCodeAt(f)&255,k+=String.fromCharCode((d&15)<<12|(g&63)<<6|e&63)));return k}function s(a,b){function k(){var c= -e+g;c>a.length&&(c=a.length);f+=d(a,e,c);e=c;c=e===a.length;b(f,c)&&!c&&runtime.setTimeout(k,0)}var g=1E5,f="",e=0;a.length>>18],b+=q[d>>>12&63],b+=q[d>>>6&63],b+=q[d&63];k===h+1?(d=a[k]<<4,b+=q[d>>>6],b+=q[d&63],b+="=="):k===h&&(d=a[k]<<10|a[k+1]<<2,b+=q[d>>>12],b+=q[d>>>6&63],b+=q[d&63],b+="=");return b}function g(a){a=a.replace(/[^A-Za-z0-9+\/]+/g,"");var d=[],b=a.length%4,k,h=a.length,e;for(k=0;k>16,e>>8&255,e&255);d.length-=[0,0,2,1][b];return d}function c(a){var d=[],b,k=a.length,h;for(b=0;bh?d.push(h):2048>h?d.push(192|h>>>6,128|h&63):d.push(224|h>>>12&15,128|h>>>6&63,128|h&63);return d}function b(a){var d=[],b,k=a.length,h,e,f;for(b=0;bh?d.push(h):(b+=1,e=a[b],224>h?d.push((h&31)<<6|e&63):(b+=1,f=a[b],d.push((h&15)<<12|(e&63)<<6|f&63)));return d}function n(a){return m(l(a))} +function a(a){return String.fromCharCode.apply(String,g(a))}function e(a){return b(l(a))}function f(a){a=b(a);for(var d="",k=0;kd?k+=String.fromCharCode(d):(f+=1,h=a.charCodeAt(f)&255,224>d?k+=String.fromCharCode((d&31)<<6|h&63):(f+=1,e=a.charCodeAt(f)&255,k+=String.fromCharCode((d&15)<<12|(h&63)<<6|e&63)));return k}function t(a,b){function k(){var c= +f+h;c>a.length&&(c=a.length);e+=d(a,f,c);f=c;c=f===a.length;b(e,c)&&!c&&runtime.setTimeout(k,0)}var h=1E5,e="",f=0;a.length>>8):(z(a&255),z(a>>>8))},ua=function(){v=(v<<5^g[B+3-1]&255)&8191;t=w[32768+v];w[B&32767]=t;w[32768+v]=B},ea=function(a,d){A>16-d?(u|=a<>16-A,A+=d-16):(u|=a<a;a++)g[a]=g[a+32768];R-=32768;B-=32768;x-=32768;for(a=0;8192>a;a++)d=w[32768+a],w[32768+a]=32768<=d?d-32768:0;for(a=0;32768>a;a++)d=w[a],w[a]=32768<=d?d-32768:0;b+=32768}G||(a=xa(g,B+L,b),0>=a?G=!0:L+=a)},ra=function(a){var d=X,b=B,k,f=P,e=32506=sa&&(d>>=2);do if(k=a,g[k+f]===n&&g[k+f-1]===t&&g[k]===g[b]&&g[++k]===g[b+1]){b+=2;k++;do++b;while(g[b]=== -g[++k]&&g[++b]===g[++k]&&g[++b]===g[++k]&&g[++b]===g[++k]&&g[++b]===g[++k]&&g[++b]===g[++k]&&g[++b]===g[++k]&&g[++b]===g[++k]&&bf){R=a;f=k;if(258<=k)break;t=g[b+f-1];n=g[b+f]}a=w[a&32767]}while(a>e&&0!==--d);return f},na=function(a,d){r[T++]=d;0===a?Y[d].fc++:(a--,Y[$[d]+256+1].fc++,ba[(256>a?fa[a]:fa[256+(a>>7)])&255].fc++,p[ia++]=a,U|=ma);ma<<=1;0===(T&7)&&(ha[la++]=U,U=0,ma=1);if(2g;g++)b+=ba[g].fc*(5+pa[g]);b>>=3;if(ia< -parseInt(T/2,10)&&b>=1,b<<=1;while(0<--d);return b>>1},Aa=function(a,d){var b=[];b.length=16;var k=0,g;for(g=1;15>=g;g++)k=k+K[g-1]<<1,b[g]=k;for(k=0;k<=d;k++)g=a[k].dl,0!==g&&(a[k].fc=aa(b[g]++,g))},Da=function(a){var d=a.dyn_tree,b=a.static_tree,k=a.elems,g,f=-1,e=k;Z=0;da=573;for(g=0;g< -k;g++)0!==d[g].fc?(Q[++Z]=f=g,O[g]=0):d[g].dl=0;for(;2>Z;)g=Q[++Z]=2>f?++f:0,d[g].fc=1,O[g]=0,W--,null!==b&&(ja-=b[g].dl);a.max_code=f;for(g=Z>>1;1<=g;g--)za(d,g);do g=Q[1],Q[1]=Q[Z--],za(d,1),b=Q[1],Q[--da]=g,Q[--da]=b,d[e].fc=d[g].fc+d[b].fc,O[e]=O[g]>O[b]+1?O[g]:O[b]+1,d[g].dl=d[b].dl=e,Q[1]=e++,za(d,1);while(2<=Z);Q[--da]=Q[1];e=a.dyn_tree;g=a.extra_bits;var k=a.extra_base,b=a.max_code,c=a.max_length,t=a.static_tree,n,p,h,q,r=0;for(p=0;15>=p;p++)K[p]=0;e[Q[da]].dl=0;for(a=da+1;573>a;a++)n=Q[a], -p=e[e[n].dl].dl+1,p>c&&(p=c,r++),e[n].dl=p,n>b||(K[p]++,h=0,n>=k&&(h=g[n-k]),q=e[n].fc,W+=q*(p+h),null!==t&&(ja+=q*(t[n].dl+h)));if(0!==r){do{for(p=c-1;0===K[p];)p--;K[p]--;K[p+1]+=2;K[c]--;r-=2}while(0b||(e[g].dl!==p&&(W+=(p-e[g].dl)*e[g].fc,e[g].fc=p),n--)}Aa(d,f)},Fa=function(a,d){var b,k=-1,g,f=a[0].dl,e=0,c=7,p=4;0===f&&(c=138,p=3);a[d+1].dl=65535;for(b=0;b<=d;b++)g=f,f=a[b+1].dl,++e=e?S[17].fc++:S[18].fc++,e=0,k=g,0===f?(c=138,p=3):g===f?(c=6,p=3):(c=7,p=4))},Ga=function(){8b?fa[b]:fa[256+(b>>7)])&255,ga(c,d),t=pa[c],0!==t&&(b-=ka[c],ea(b,t))),e>>=1;while(k=e?(ga(17,S),ea(e-3,3)):(ga(18,S),ea(e-11,7));e=0;k=g;0===f?(c=138,p=3):g===f?(c=6,p=3):(c=7,p=4)}},Ja=function(){var a;for(a=0;286>a;a++)Y[a].fc=0;for(a=0;30>a;a++)ba[a].fc=0;for(a=0;19>a;a++)S[a].fc=0;Y[256].fc=1;U=T=ia=la=W=ja=0;ma=1},Ea=function(a){var d,b,k,f;f=B-x;ha[la]=U;Da(J);Da(C);Fa(Y,J.max_code);Fa(ba,C.max_code);Da(I);for(k=18;3<=k&&0===S[Ca[k]].dl;k--);W+=3*(k+1)+14;d=W+3+ -7>>3;b=ja+3+7>>3;b<=d&&(d=b);if(f+4<=d&&0<=x)for(ea(0+a,3),Ga(),qa(f),qa(~f),k=0;ka.len&&(c=a.len);for(p=0;ps-k&&(c=s-k);for(p=0;pn;n++)for(F[n]=p,c=0;c<1<n;n++)for(ka[n]=p,c=0;c<1<>=7;30>n;n++)for(ka[n]=p<<7,c=0;c<1<=c;c++)K[c]=0;for(c=0;143>=c;)M[c++].dl=8,K[8]++;for(;255>=c;)M[c++].dl=9,K[9]++;for(;279>=c;)M[c++].dl=7,K[7]++;for(;287>=c;)M[c++].dl=8,K[8]++;Aa(M,287);for(c=0;30>c;c++)V[c].dl=5,V[c].fc=aa(c,5);Ja()}for(c=0;8192>c;c++)w[32768+c]=0;oa=ca[N].max_lazy;sa=ca[N].good_length;X=ca[N].max_chain;x=B=0;L=xa(g,0,65536);if(0>=L)G=!0,L=0;else{for(G=!1;262>L&& -!G;)ya();for(c=v=0;2>c;c++)v=(v<<5^g[c]&255)&8191}a=null;k=s=0;3>=N?(P=2,y=0):(y=2,H=0);q=!1}f=!0;if(0===L)return q=!0,0}c=Ka(d,b,e);if(c===e)return e;if(q)return c;if(3>=N)for(;0!==L&&null===a;){ua();0!==t&&32506>=B-t&&(y=ra(t),y>L&&(y=L));if(3<=y)if(n=na(B-R,y-3),L-=y,y<=oa){y--;do B++,ua();while(0!==--y);B++}else B+=y,y=0,v=g[B]&255,v=(v<<5^g[B+1]&255)&8191;else n=na(0,g[B]&255),L--,B++;n&&(Ea(0),x=B);for(;262>L&&!G;)ya()}else for(;0!==L&&null===a;){ua();P=y;E=R;y=2;0!==t&&(P=B-t)&& -(y=ra(t),y>L&&(y=L),3===y&&4096L&&!G;)ya()}0===L&&(0!==H&&na(0,g[B-1]&255),Ea(1),q=!0);return c+Ka(d,c+b,e-c)};this.deflate=function(k,e){var c,t;ta=k;va=0;"undefined"===String(typeof e)&&(e=6);(c=e)?1>c?c=1:9c;c++)Y[c]=new m;ba=[];ba.length=61;for(c=0;61>c;c++)ba[c]=new m;M=[];M.length=288;for(c=0;288>c;c++)M[c]=new m;V=[];V.length=30;for(c=0;30>c;c++)V[c]=new m;S=[];S.length=39;for(c=0;39>c;c++)S[c]=new m;J=new l;C=new l;I=new l;K=[];K.length=16;Q=[];Q.length=573;O=[];O.length=573;$=[];$.length=256;fa=[];fa.length=512;F=[];F.length=29;ka=[];ka.length=30;ha=[];ha.length=1024}var q=Array(1024),u=[],s=[];for(c=La(q,0,q.length);0>>8):(ia(a&255),ia(a>>>8))},V=function(){v=(v<<5^h[B+3-1]&255)&8191;r=w[32768+v];w[B&32767]=r;w[32768+v]=B},Y=function(a,d){A>16-d?(u|=a<>16-A,A+=d-16):(u|=a<a;a++)h[a]=h[a+32768];M-=32768;B-=32768;y-=32768;for(a=0;8192>a;a++)d=w[32768+a],w[32768+a]=32768<=d?d-32768:0;for(a=0;32768>a;a++)d=w[a],w[a]=32768<=d?d-32768:0;b+=32768}F||(a=Ba(h,B+K,b),0>=a?F=!0:K+=a)},Ca=function(a){var d=ea,b=B,k,e=L,f=32506=qa&&(d>>=2);do if(k=a,h[k+e]===q&&h[k+e-1]===r&&h[k]===h[b]&&h[++k]===h[b+1]){b+=2;k++;do++b;while(h[b]=== +h[++k]&&h[++b]===h[++k]&&h[++b]===h[++k]&&h[++b]===h[++k]&&h[++b]===h[++k]&&h[++b]===h[++k]&&h[++b]===h[++k]&&h[++b]===h[++k]&&be){M=a;e=k;if(258<=k)break;r=h[b+e-1];q=h[b+e]}a=w[a&32767]}while(a>f&&0!==--d);return e},va=function(a,d){s[U++]=d;0===a?Z[d].fc++:(a--,Z[ca[d]+256+1].fc++,$[(256>a?ja[a]:ja[256+(a>>7)])&255].fc++,q[na++]=a,x|=la);la<<=1;0===(U&7)&&(ka[X++]=x,x=0,la=1);if(2h;h++)b+=$[h].fc*(5+ha[h]);b>>=3;if(na< +parseInt(U/2,10)&&b>=1,b<<=1;while(0<--d);return b>>1},Ea=function(a,d){var b=[];b.length=16;var k=0,h;for(h=1;15>=h;h++)k=k+J[h-1]<<1,b[h]=k;for(k=0;k<=d;k++)h=a[k].dl,0!==h&&(a[k].fc=Da(b[h]++,h))},za=function(a){var d=a.dyn_tree,b=a.static_tree,k=a.elems,h,e=-1,f=k;ba=0;fa=573;for(h= +0;hba;)h=R[++ba]=2>e?++e:0,d[h].fc=1,P[h]=0,T--,null!==b&&(oa-=b[h].dl);a.max_code=e;for(h=ba>>1;1<=h;h--)ya(d,h);do h=R[1],R[1]=R[ba--],ya(d,1),b=R[1],R[--fa]=h,R[--fa]=b,d[f].fc=d[h].fc+d[b].fc,P[f]=P[h]>P[b]+1?P[h]:P[b]+1,d[h].dl=d[b].dl=f,R[1]=f++,ya(d,1);while(2<=ba);R[--fa]=R[1];f=a.dyn_tree;h=a.extra_bits;var k=a.extra_base,b=a.max_code,c=a.max_length,r=a.static_tree,q,g,p,n,s=0;for(g=0;15>=g;g++)J[g]=0;f[R[fa]].dl=0;for(a=fa+1;573>a;a++)q= +R[a],g=f[f[q].dl].dl+1,g>c&&(g=c,s++),f[q].dl=g,q>b||(J[g]++,p=0,q>=k&&(p=h[q-k]),n=f[q].fc,T+=n*(g+p),null!==r&&(oa+=n*(r[q].dl+p)));if(0!==s){do{for(g=c-1;0===J[g];)g--;J[g]--;J[g+1]+=2;J[c]--;s-=2}while(0b||(f[h].dl!==g&&(T+=(g-f[h].dl)*f[h].fc,f[h].fc=g),q--)}Ea(d,e)},Fa=function(a,d){var b,k=-1,h,e=a[0].dl,f=0,c=7,r=4;0===e&&(c=138,r=3);a[d+1].dl=65535;for(b=0;b<=d;b++)h=e,e=a[b+1].dl,++f=f?S[17].fc++:S[18].fc++,f=0,k=h,0===e?(c=138,r=3):h===e?(c=6,r=3):(c=7,r=4))},Ga=function(){8b?ja[b]:ja[256+(b>>7)])&255,ga(c,d),r=ha[c],0!==r&&(b-=ma[c],Y(b,r))),f>>=1;while(k=f?(ga(17,S),Y(f-3,3)):(ga(18,S),Y(f-11,7));f=0;k=h;0===e?(c=138,r=3):h===e?(c=6,r=3):(c=7,r=4)}},Ja=function(){var a;for(a=0;286>a;a++)Z[a].fc=0;for(a=0;30>a;a++)$[a].fc=0;for(a=0;19>a;a++)S[a].fc=0;Z[256].fc=1;x=U=na=X=T=oa=0;la=1},wa=function(a){var d,b,k,e;e=B-y;ka[X]=x;za(O);za(H);Fa(Z,O.max_code);Fa($,H.max_code);za(I);for(k=18;3<=k&&0===S[ua[k]].dl;k--);T+=3*(k+1)+14;d=T+3+7>>3;b= +oa+3+7>>3;b<=d&&(d=b);if(e+4<=d&&0<=y)for(Y(0+a,3),Ga(),da(e),da(~e),k=0;ka.len&&(c=a.len);for(r=0;rt-k&&(c= +t-k);for(r=0;rq;q++)for(E[q]=g,c=0;c<1<q;q++)for(ma[q]=g,c=0;c<1<>=7;30>q;q++)for(ma[q]=g<<7,c=0;c<1<=c;c++)J[c]=0;for(c=0;143>=c;)Q[c++].dl=8,J[8]++;for(;255>=c;)Q[c++].dl=9,J[9]++;for(;279>=c;)Q[c++].dl=7,J[7]++;for(;287>=c;)Q[c++].dl=8,J[8]++;Ea(Q,287);for(c=0;30>c;c++)W[c].dl=5,W[c].fc=Da(c,5);Ja()}for(c=0;8192>c;c++)w[32768+c]=0;pa=aa[N].max_lazy;qa=aa[N].good_length;ea=aa[N].max_chain;y=B=0;K=Ba(h,0,65536);if(0>=K)F=!0,K=0;else{for(F=!1;262> +K&&!F;)xa();for(c=v=0;2>c;c++)v=(v<<5^h[c]&255)&8191}a=null;k=t=0;3>=N?(L=2,C=0):(C=2,G=0);p=!1}f=!0;if(0===K)return p=!0,0}c=Ka(b,d,e);if(c===e)return e;if(p)return c;if(3>=N)for(;0!==K&&null===a;){V();0!==r&&32506>=B-r&&(C=Ca(r),C>K&&(C=K));if(3<=C)if(q=va(B-M,C-3),K-=C,C<=pa){C--;do B++,V();while(0!==--C);B++}else B+=C,C=0,v=h[B]&255,v=(v<<5^h[B+1]&255)&8191;else q=va(0,h[B]&255),K--,B++;q&&(wa(0),y=B);for(;262>K&&!F;)xa()}else for(;0!==K&&null===a;){V();L=C;z=M;C=2;0!==r&&(L=B-r)&& +(C=Ca(r),C>K&&(C=K),3===C&&4096K&&!F;)xa()}0===K&&(0!==G&&va(0,h[B-1]&255),wa(1),p=!0);return c+Ka(b,c+d,e-c)};this.deflate=function(k,c){var r,g;ta=k;D=0;"undefined"===String(typeof c)&&(c=6);(r=c)?1>r?r=1:9r;r++)Z[r]=new l;$=[];$.length=61;for(r=0;61>r;r++)$[r]=new l;Q=[];Q.length=288;for(r=0;288>r;r++)Q[r]=new l;W=[];W.length=30;for(r=0;30>r;r++)W[r]=new l;S=[];S.length=39;for(r=0;39>r;r++)S[r]=new l;O=new m;H=new m;I=new m;J=[];J.length=16;R=[];R.length=573;P=[];P.length=573;ca=[];ca.length=256;ja=[];ja.length=512;E=[];E.length=29;ma=[];ma.length=30;ka=[];ka.length=1024}var p=Array(1024),u=[],t=[];for(r=La(p,0,p.length);0>8&255])};this.appendUInt32LE=function(c){l.appendArray([c&255,c>>8&255,c>>16&255,c>>24&255])};this.appendString=function(c){e=runtime.concatByteArrays(e, -runtime.byteArrayFromString(c,m))};this.getLength=function(){return e.length};this.getByteArray=function(){return e}}; +core.ByteArrayWriter=function(l){var m=this,g=new runtime.ByteArray(0);this.appendByteArrayWriter=function(c){g=runtime.concatByteArrays(g,c.getByteArray())};this.appendByteArray=function(c){g=runtime.concatByteArrays(g,c)};this.appendArray=function(c){g=runtime.concatByteArrays(g,runtime.byteArrayFromArray(c))};this.appendUInt16LE=function(c){m.appendArray([c&255,c>>8&255])};this.appendUInt32LE=function(c){m.appendArray([c&255,c>>8&255,c>>16&255,c>>24&255])};this.appendString=function(c){g=runtime.concatByteArrays(g, +runtime.byteArrayFromString(c,l))};this.getLength=function(){return g.length};this.getByteArray=function(){return g}}; // Input 6 -core.RawInflate=function(){var m,l,e=null,c,b,h,a,n,f,d,s,k,q,g,p,r,w,u=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535],A=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],x=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,99,99],v=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],t=[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],E=[16,17,18, -0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],H=function(){this.list=this.next=null},y=function(){this.n=this.b=this.e=0;this.t=null},P=function(a,d,b,k,g,c){this.BMAX=16;this.N_MAX=288;this.status=0;this.root=null;this.m=0;var e=Array(this.BMAX+1),f,p,n,t,h,q,r,m=Array(this.BMAX+1),l,w,u,s=new y,v=Array(this.BMAX);t=Array(this.N_MAX);var x,A=Array(this.BMAX+1),E,X,B;B=this.root=null;for(h=0;hh&&(c=h);for(E=1<(E-=e[q])){this.status=2;this.m=c;return}if(0>(E-=e[h]))this.status=2,this.m=c;else{e[h]+=E;A[1]=q=0;l=e;w=1;for(u=2;0<--h;)A[u++]=q+=l[w++];l=a;h=w=0;do 0!=(q=l[w++])&&(t[A[q]++]=h);while(++hx+m[1+t];){x+=m[1+t];t++;X=(X=n-x)>c?c:X;if((p=1<<(q=r-x))>a+1)for(p-=a+1,u=r;++qf&&x>x-m[t],v[t-1][q].e=s.e,v[t-1][q].b=s.b,v[t-1][q].n=s.n,v[t-1][q].t=s.t)}s.b=r-x;w>=d?s.e=99:l[w]l[w]?16:15,s.n=l[w++]): -(s.e=g[l[w]-b],s.n=k[l[w++]-b]);p=1<>x;q>=1)h^=q;for(h^=q;(h&(1<>=d;a-=d},L=function(a,b,c){var e,f,t;if(0==c)return 0;for(t=0;;){B(g);f=k.list[R(g)];for(e=f.e;16 -c;c++)l[E[c]]=0;g=7;c=new P(l,19,19,null,null,g);if(0!=c.status)return-1;k=c.root;g=c.m;n=r+m;for(e=f=0;ec)l[e++]=f=c;else if(16==c){B(2);c=3+R(2);G(2);if(e+c>n)return-1;for(;0n)return-1;for(;0C;C++)J[C]=8;for(;256>C;C++)J[C]=9;for(;280>C;C++)J[C]=7;for(;288>C;C++)J[C]=8;b=7;C=new P(J,288,257,A,x,b);if(0!=C.status){alert("HufBuild error: "+C.status);M=-1;break b}e=C.root;b=C.m;for(C=0;30>C;C++)J[C]=5;X=5;C=new P(J,30,0,v,t,X);if(1p&&(c=p);for(z=1<(z-=e[n])){this.status=2;this.m=c;return}if(0>(z-=e[p]))this.status=2,this.m=c;else{e[p]+=z;A[1]=n=0;l=e;w=1;for(u=2;0<--p;)A[u++]=n+=l[w++];l=a;p=w=0;do 0!=(n=l[w++])&&(g[A[n]++]=p);while(++py+m[1+g];){y+=m[1+g];g++;B=(B=q-y)>c?c:B;if((r=1<<(n=s-y))>a+1)for(r-=a+1,u=s;++nf&&y>y-m[g],v[g-1][n].e=t.e,v[g-1][n].b=t.b,v[g-1][n].n=t.n,v[g-1][n].t=t.t)}t.b=s-y;w>=b?t.e=99:l[w]l[w]?16:15,t.n=l[w++]): +(t.e=h[l[w]-d],t.n=k[l[w++]-d]);r=1<>y;n>=1)p^=n;for(p^=n;(p&(1<>=b;a-=b},K=function(a,b,c){var f,r,g;if(0==c)return 0;for(g=0;;){B(h);r=k.list[M(h)];for(f=r.e;16 +c;c++)m[z[c]]=0;h=7;c=new L(m,19,19,null,null,h);if(0!=c.status)return-1;k=c.root;h=c.m;g=s+l;for(f=e=0;fc)m[f++]=e=c;else if(16==c){B(2);c=3+M(2);F(2);if(f+c>g)return-1;for(;0g)return-1;for(;0H;H++)O[H]=8;for(;256>H;H++)O[H]=9;for(;280>H;H++)O[H]=7;for(;288>H;H++)O[H]=8;b=7;H=new L(O,288,257,A,y,b);if(0!=H.status){alert("HufBuild error: "+H.status);Q=-1;break b}g=H.root;b=H.m;for(H=0;30>H;H++)O[H]=5;ea=5;H=new L(O,30,0,v,r,ea);if(1m))throw runtime.log("alert","watchdog timeout"),"timeout!";if(0l))throw runtime.log("alert","watchdog loop overflow"),"loop overflow";}}; +core.LoopWatchDog=function(l,m){var g=Date.now(),c=0;this.check=function(){var b;if(l&&(b=Date.now(),b-g>l))throw runtime.log("alert","watchdog timeout"),"timeout!";if(0m))throw runtime.log("alert","watchdog loop overflow"),"loop overflow";}}; // Input 8 -core.Utils=function(){function m(l,e){Array.isArray(e)?l=(l||[]).concat(e.map(function(c){return m({},c)})):"object"===typeof e?(l=l||{},Object.keys(e).forEach(function(c){l[c]=m(l[c],e[c])})):l=e;return l}this.hashString=function(m){var e=0,c,b;c=0;for(b=m.length;c=e.compareBoundaryPoints(e.START_TO_START,c)&&0<=e.compareBoundaryPoints(e.END_TO_END,c)};this.rangesIntersect=function(e,c){return 0>=e.compareBoundaryPoints(e.END_TO_START,c)&&0<=e.compareBoundaryPoints(e.START_TO_END,c)};this.getNodesInRange=function(e,c){var b=[],h,a=e.startContainer.ownerDocument.createTreeWalker(e.commonAncestorContainer,NodeFilter.SHOW_ALL,c,!1);for(h=a.currentNode=e.startContainer;h;){if(c(h)=== -NodeFilter.FILTER_ACCEPT)b.push(h);else if(c(h)===NodeFilter.FILTER_REJECT)break;h=h.parentNode}b.reverse();for(h=a.nextNode();h;)b.push(h),h=a.nextNode();return b};this.normalizeTextNodes=function(e){e&&e.nextSibling&&(e=m(e,e.nextSibling));e&&e.previousSibling&&m(e.previousSibling,e)};this.rangeContainsNode=function(e,c){var b=c.ownerDocument.createRange(),h=c.nodeType===Node.TEXT_NODE?c.length:c.childNodes.length;b.setStart(e.startContainer,e.startOffset);b.setEnd(e.endContainer,e.endOffset);h= -0===b.comparePoint(c,0)&&0===b.comparePoint(c,h);b.detach();return h};this.mergeIntoParent=function(e){for(var c=e.parentNode;e.firstChild;)c.insertBefore(e.firstChild,e);c.removeChild(e);return c};this.getElementsByTagNameNS=function(e,c,b){return Array.prototype.slice.call(e.getElementsByTagNameNS(c,b))};this.rangeIntersectsNode=function(e,c){var b=c.nodeType===Node.TEXT_NODE?c.length:c.childNodes.length;return 0>=e.comparePoint(c,0)&&0<=e.comparePoint(c,b)};this.containsNode=function(e,c){return e=== -c||e.contains(c)};(function(e){var c=runtime.getWindow();null!==c&&(c=c.navigator.appVersion.toLowerCase(),c=-1===c.indexOf("chrome")&&(-1!==c.indexOf("applewebkit")||-1!==c.indexOf("safari")))&&(e.containsNode=l)})(this)}; +core.DomUtils=function(){function l(g,c){g.nodeType===Node.TEXT_NODE&&(0===g.length?g.parentNode.removeChild(g):c.nodeType===Node.TEXT_NODE&&(g.appendData(c.data),c.parentNode.removeChild(c)));return g}function m(g,c){return g===c||Boolean(g.compareDocumentPosition(c)&Node.DOCUMENT_POSITION_CONTAINED_BY)}this.splitBoundaries=function(g){var c=[],b;if(g.startContainer.nodeType===Node.TEXT_NODE||g.endContainer.nodeType===Node.TEXT_NODE){b=g.endContainer;var n=g.endOffset;if(n=g.compareBoundaryPoints(g.START_TO_START,c)&&0<=g.compareBoundaryPoints(g.END_TO_END,c)};this.rangesIntersect=function(g,c){return 0>=g.compareBoundaryPoints(g.END_TO_START,c)&&0<=g.compareBoundaryPoints(g.START_TO_END,c)};this.getNodesInRange=function(g,c){var b=[],n,a=g.startContainer.ownerDocument.createTreeWalker(g.commonAncestorContainer,NodeFilter.SHOW_ALL,c,!1);for(n=a.currentNode=g.startContainer;n;){if(c(n)=== +NodeFilter.FILTER_ACCEPT)b.push(n);else if(c(n)===NodeFilter.FILTER_REJECT)break;n=n.parentNode}b.reverse();for(n=a.nextNode();n;)b.push(n),n=a.nextNode();return b};this.normalizeTextNodes=function(g){g&&g.nextSibling&&(g=l(g,g.nextSibling));g&&g.previousSibling&&l(g.previousSibling,g)};this.rangeContainsNode=function(g,c){var b=c.ownerDocument.createRange(),n=c.nodeType===Node.TEXT_NODE?c.length:c.childNodes.length;b.setStart(g.startContainer,g.startOffset);b.setEnd(g.endContainer,g.endOffset);n= +0===b.comparePoint(c,0)&&0===b.comparePoint(c,n);b.detach();return n};this.mergeIntoParent=function(g){for(var c=g.parentNode;g.firstChild;)c.insertBefore(g.firstChild,g);c.removeChild(g);return c};this.getElementsByTagNameNS=function(g,c,b){return Array.prototype.slice.call(g.getElementsByTagNameNS(c,b))};this.rangeIntersectsNode=function(g,c){var b=c.nodeType===Node.TEXT_NODE?c.length:c.childNodes.length;return 0>=g.comparePoint(c,0)&&0<=g.comparePoint(c,b)};this.containsNode=function(g,c){return g=== +c||g.contains(c)};(function(g){var c=runtime.getWindow();null!==c&&(c=c.navigator.appVersion.toLowerCase(),c=-1===c.indexOf("chrome")&&(-1!==c.indexOf("applewebkit")||-1!==c.indexOf("safari")))&&(g.containsNode=m)})(this)}; // Input 10 runtime.loadClass("core.DomUtils"); -core.Cursor=function(m,l){function e(a){a.parentNode&&(n.push(a.previousSibling),n.push(a.nextSibling),a.parentNode.removeChild(a))}function c(a,d,b){if(d.nodeType===Node.TEXT_NODE){runtime.assert(Boolean(d),"putCursorIntoTextNode: invalid container");var c=d.parentNode;runtime.assert(Boolean(c),"putCursorIntoTextNode: container without parent");runtime.assert(0<=b&&b<=d.length,"putCursorIntoTextNode: offset is out of bounds");0===b?c.insertBefore(a,d):(b!==d.length&&d.splitText(b),c.insertBefore(a, -d.nextSibling))}else if(d.nodeType===Node.ELEMENT_NODE){runtime.assert(Boolean(d),"putCursorIntoContainer: invalid container");for(c=d.firstChild;null!==c&&01/e?"-0":String(e),m(d+" should be "+a+". Was "+c+".")):m(d+" should be "+a+" (of type "+typeof a+"). Was "+e+" (of type "+typeof e+").")}var a=0,n;n=function(a,d){var c=Object.keys(a),k=Object.keys(d);c.sort();k.sort();return l(c,k)&&Object.keys(a).every(function(k){var c= -a[k],e=d[k];return b(c,e)?!0:(m(c+" should be "+e+" for key "+k),!1)})};this.areNodesEqual=c;this.shouldBeNull=function(a,b){h(a,b,"null")};this.shouldBeNonNull=function(a,b){var c,k;try{k=eval(b)}catch(e){c=e}c?m(b+" should be non-null. Threw exception "+c):null!==k?runtime.log("pass",b+" is non-null."):m(b+" should be non-null. Was "+k)};this.shouldBe=h;this.countFailedTests=function(){return a}}; -core.UnitTester=function(){function m(c,b){return""+c+""}var l=0,e={};this.runTests=function(c,b,h){function a(k){if(0===k.length)e[n]=s,l+=f.countFailedTests(),b();else{q=k[0];var c=Runtime.getFunctionName(q);runtime.log("Running "+c);p=f.countFailedTests();d.setUp();q(function(){d.tearDown();s[c]=p===f.countFailedTests();a(k.slice(1))})}}var n=Runtime.getFunctionName(c),f=new core.UnitTestRunner,d=new c(f),s={},k,q,g,p,r="BrowserRuntime"=== -runtime.type();if(e.hasOwnProperty(n))runtime.log("Test "+n+" has already run.");else{r?runtime.log("Running "+m(n,'runSuite("'+n+'");')+": "+d.description()+""):runtime.log("Running "+n+": "+d.description);g=d.tests();for(k=0;kRunning "+m(c,'runTest("'+n+'","'+c+'")')+""):runtime.log("Running "+c),p=f.countFailedTests(),d.setUp(),q(),d.tearDown(),s[c]=p===f.countFailedTests()); -a(d.asyncTests())}};this.countFailedTests=function(){return l};this.results=function(){return e}}; +core.UnitTest.provideTestAreaDiv=function(){var l=runtime.getWindow().document,m=l.getElementById("testarea");runtime.assert(!m,'Unclean test environment, found a div with id "testarea".');m=l.createElement("div");m.setAttribute("id","testarea");l.body.appendChild(m);return m}; +core.UnitTest.cleanupTestAreaDiv=function(){var l=runtime.getWindow().document,m=l.getElementById("testarea");runtime.assert(!!m&&m.parentNode===l.body,'Test environment broken, found no div with id "testarea" below body.');l.body.removeChild(m)}; +core.UnitTestRunner=function(){function l(b){a+=1;runtime.log("fail",b)}function m(a,b){var c;try{if(a.length!==b.length)return l("array of length "+a.length+" should be "+b.length+" long"),!1;for(c=0;c1/e?"-0":String(e),l(d+" should be "+a+". Was "+c+".")):l(d+" should be "+a+" (of type "+typeof a+"). Was "+e+" (of type "+typeof e+").")}var a=0,e;e=function(a,d){var c=Object.keys(a),k=Object.keys(d);c.sort();k.sort();return m(c,k)&&Object.keys(a).every(function(k){var h= +a[k],c=d[k];return b(h,c)?!0:(l(h+" should be "+c+" for key "+k),!1)})};this.areNodesEqual=c;this.shouldBeNull=function(a,b){n(a,b,"null")};this.shouldBeNonNull=function(a,b){var c,k;try{k=eval(b)}catch(e){c=e}c?l(b+" should be non-null. Threw exception "+c):null!==k?runtime.log("pass",b+" is non-null."):l(b+" should be non-null. Was "+k)};this.shouldBe=n;this.countFailedTests=function(){return a}}; +core.UnitTester=function(){function l(c,b){return""+c+""}var m=0,g={};this.runTests=function(c,b,n){function a(k){if(0===k.length)g[e]=t,m+=f.countFailedTests(),b();else{p=k[0];var c=Runtime.getFunctionName(p);runtime.log("Running "+c);q=f.countFailedTests();d.setUp();p(function(){d.tearDown();t[c]=q===f.countFailedTests();a(k.slice(1))})}}var e=Runtime.getFunctionName(c),f=new core.UnitTestRunner,d=new c(f),t={},k,p,h,q,s="BrowserRuntime"=== +runtime.type();if(g.hasOwnProperty(e))runtime.log("Test "+e+" has already run.");else{s?runtime.log("Running "+l(e,'runSuite("'+e+'");')+": "+d.description()+""):runtime.log("Running "+e+": "+d.description);h=d.tests();for(k=0;kRunning "+l(c,'runTest("'+e+'","'+c+'")')+""):runtime.log("Running "+c),q=f.countFailedTests(),d.setUp(),p(),d.tearDown(),t[c]=q===f.countFailedTests()); +a(d.asyncTests())}};this.countFailedTests=function(){return m};this.results=function(){return g}}; // Input 13 -core.PositionIterator=function(m,l,e,c){function b(){this.acceptNode=function(a){return a.nodeType===Node.TEXT_NODE&&0===a.length?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}}function h(a){this.acceptNode=function(b){return b.nodeType===Node.TEXT_NODE&&0===b.length?NodeFilter.FILTER_REJECT:a.acceptNode(b)}}function a(){var a=f.currentNode.nodeType;d=a===Node.TEXT_NODE?f.currentNode.length-1:a===Node.ELEMENT_NODE?1:0}var n=this,f,d,s;this.nextPosition=function(){if(f.currentNode===m)return!1; -if(0===d&&f.currentNode.nodeType===Node.ELEMENT_NODE)null===f.firstChild()&&(d=1);else if(f.currentNode.nodeType===Node.TEXT_NODE&&d+1 "+a.length),runtime.assert(0<=b,"Error in setPosition: "+b+" < 0"), -b===a.length&&(d=void 0,f.nextSibling()?d=0:f.parentNode()&&(d=1),runtime.assert(void 0!==d,"Error in setPosition: position not valid.")),!0;c=s(a);b>>8^g;return d^-1}function c(a){return new Date((a>>25&127)+1980,(a>>21&15)-1,a>>16&31,a>>11&15,a>>5&63,(a&31)<<1)}function b(a){var b=a.getFullYear();return 1980>b?0:b-1980<< -25|a.getMonth()+1<<21|a.getDate()<<16|a.getHours()<<11|a.getMinutes()<<5|a.getSeconds()>>1}function h(a,b){var d,e,g,k,f,n,h,r=this;this.load=function(b){if(void 0!==r.data)b(null,r.data);else{var d=f+34+e+g+256;d+h>p&&(d=p-h);runtime.read(a,h,d,function(d,c){if(d||null===c)b(d,c);else a:{var e=c,g=new core.ByteArray(e),p=g.readUInt32LE(),t;if(67324752!==p)b("File entry signature is wrong."+p.toString()+" "+e.length.toString(),null);else{g.pos+=22;p=g.readUInt16LE();t=g.readUInt16LE();g.pos+=p+t; -if(k){e=e.slice(g.pos,g.pos+f);if(f!==e.length){b("The amount of compressed bytes read was "+e.length.toString()+" instead of "+f.toString()+" for "+r.filename+" in "+a+".",null);break a}e=w(e,n)}else e=e.slice(g.pos,g.pos+n);n!==e.length?b("The amount of bytes read was "+e.length.toString()+" instead of "+n.toString()+" for "+r.filename+" in "+a+".",null):(r.data=e,b(null,e))}}})}};this.set=function(a,b,d,c){r.filename=a;r.data=b;r.compressed=d;r.date=c};this.error=null;b&&(d=b.readUInt32LE(),33639248!== -d?this.error="Central directory entry has wrong signature at position "+(b.pos-4).toString()+' for file "'+a+'": '+b.data.length.toString():(b.pos+=6,k=b.readUInt16LE(),this.date=c(b.readUInt32LE()),b.readUInt32LE(),f=b.readUInt32LE(),n=b.readUInt32LE(),e=b.readUInt16LE(),g=b.readUInt16LE(),d=b.readUInt16LE(),b.pos+=8,h=b.readUInt32LE(),this.filename=runtime.byteArrayToString(b.data.slice(b.pos,b.pos+e),"utf8"),b.pos+=e+g+d))}function a(a,b){if(22!==a.length)b("Central directory length should be 22.", -u);else{var d=new core.ByteArray(a),c;c=d.readUInt32LE();101010256!==c?b("Central directory signature is wrong: "+c.toString(),u):(c=d.readUInt16LE(),0!==c?b("Zip files with non-zero disk numbers are not supported.",u):(c=d.readUInt16LE(),0!==c?b("Zip files with non-zero disk numbers are not supported.",u):(c=d.readUInt16LE(),r=d.readUInt16LE(),c!==r?b("Number of entries is inconsistent.",u):(c=d.readUInt32LE(),d=d.readUInt16LE(),d=p-22-c,runtime.read(m,d,p-d,function(a,d){if(a||null===d)b(a,u);else a:{var c= -new core.ByteArray(d),e,k;g=[];for(e=0;ep?l("File '"+m+"' cannot be read.",u):runtime.read(m,p-22,22,function(b,d){b||null===l||null===d?l(b,u):a(d,l)})})}; +2932959818,3654703836,1088359270,936918E3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117],d,c,h=a.length,k=0,k=0;d=-1;for(c=0;c>>8^k;return d^-1}function c(a){return new Date((a>>25&127)+1980,(a>>21&15)-1,a>>16&31,a>>11&15,a>>5&63,(a&31)<<1)}function b(a){var b=a.getFullYear();return 1980>b?0:b-1980<< +25|a.getMonth()+1<<21|a.getDate()<<16|a.getHours()<<11|a.getMinutes()<<5|a.getSeconds()>>1}function n(a,b){var d,h,k,e,f,g,n,p=this;this.load=function(b){if(void 0!==p.data)b(null,p.data);else{var d=f+34+h+k+256;d+n>q&&(d=q-n);runtime.read(a,n,d,function(d,c){if(d||null===c)b(d,c);else a:{var h=c,k=new core.ByteArray(h),r=k.readUInt32LE(),q;if(67324752!==r)b("File entry signature is wrong."+r.toString()+" "+h.length.toString(),null);else{k.pos+=22;r=k.readUInt16LE();q=k.readUInt16LE();k.pos+=r+q; +if(e){h=h.slice(k.pos,k.pos+f);if(f!==h.length){b("The amount of compressed bytes read was "+h.length.toString()+" instead of "+f.toString()+" for "+p.filename+" in "+a+".",null);break a}h=w(h,g)}else h=h.slice(k.pos,k.pos+g);g!==h.length?b("The amount of bytes read was "+h.length.toString()+" instead of "+g.toString()+" for "+p.filename+" in "+a+".",null):(p.data=h,b(null,h))}}})}};this.set=function(a,b,d,c){p.filename=a;p.data=b;p.compressed=d;p.date=c};this.error=null;b&&(d=b.readUInt32LE(),33639248!== +d?this.error="Central directory entry has wrong signature at position "+(b.pos-4).toString()+' for file "'+a+'": '+b.data.length.toString():(b.pos+=6,e=b.readUInt16LE(),this.date=c(b.readUInt32LE()),b.readUInt32LE(),f=b.readUInt32LE(),g=b.readUInt32LE(),h=b.readUInt16LE(),k=b.readUInt16LE(),d=b.readUInt16LE(),b.pos+=8,n=b.readUInt32LE(),this.filename=runtime.byteArrayToString(b.data.slice(b.pos,b.pos+h),"utf8"),b.pos+=h+k+d))}function a(a,b){if(22!==a.length)b("Central directory length should be 22.", +u);else{var d=new core.ByteArray(a),c;c=d.readUInt32LE();101010256!==c?b("Central directory signature is wrong: "+c.toString(),u):(c=d.readUInt16LE(),0!==c?b("Zip files with non-zero disk numbers are not supported.",u):(c=d.readUInt16LE(),0!==c?b("Zip files with non-zero disk numbers are not supported.",u):(c=d.readUInt16LE(),s=d.readUInt16LE(),c!==s?b("Number of entries is inconsistent.",u):(c=d.readUInt32LE(),d=d.readUInt16LE(),d=q-22-c,runtime.read(l,d,q-d,function(a,d){if(a||null===d)b(a,u);else a:{var c= +new core.ByteArray(d),k,e;h=[];for(k=0;kq?m("File '"+l+"' cannot be read.",u):runtime.read(l,q-22,22,function(b,d){b||null===m||null===d?m(b,u):a(d,m)})})}; // Input 18 -core.CSSUnits=function(){var m={"in":1,cm:2.54,mm:25.4,pt:72,pc:12};this.convert=function(l,e,c){return l*m[c]/m[e]};this.convertMeasure=function(m,e){var c,b;m&&e?(c=parseFloat(m),b=m.replace(c.toString(),""),c=this.convert(c,b,e)):c="";return c.toString()};this.getUnits=function(m){return m.substr(m.length-2,m.length)}}; +core.CSSUnits=function(){var l={"in":1,cm:2.54,mm:25.4,pt:72,pc:12};this.convert=function(m,g,c){return m*l[c]/l[g]};this.convertMeasure=function(m,g){var c,b;m&&g?(c=parseFloat(m),b=m.replace(c.toString(),""),c=this.convert(c,b,g)):c="";return c.toString()};this.getUnits=function(m){return m.substr(m.length-2,m.length)}}; // Input 19 xmldom.LSSerializerFilter=function(){}; // Input 20 -"function"!==typeof Object.create&&(Object.create=function(m){var l=function(){};l.prototype=m;return new l}); -xmldom.LSSerializer=function(){function m(b){var c=b||{},a=function(a){var b={},d;for(d in a)a.hasOwnProperty(d)&&(b[a[d]]=d);return b}(b),e=[c],f=[a],d=0;this.push=function(){d+=1;c=e[d]=Object.create(c);a=f[d]=Object.create(a)};this.pop=function(){e[d]=void 0;f[d]=void 0;d-=1;c=e[d];a=f[d]};this.getLocalNamespaceDefinitions=function(){return a};this.getQName=function(b){var d=b.namespaceURI,e=0,g;if(!d)return b.localName;if(g=a[d])return g+":"+b.localName;do{g||!b.prefix?(g="ns"+e,e+=1):g=b.prefix; -if(c[g]===d)break;if(!c[g]){c[g]=d;a[d]=g;break}g=null}while(null===g);return g+":"+b.localName}}function l(b){return b.replace(/&/g,"&").replace(//g,">").replace(/'/g,"'").replace(/"/g,""")}function e(b,h){var a="",n=c.filter?c.filter.acceptNode(h):NodeFilter.FILTER_ACCEPT,f;if(n===NodeFilter.FILTER_ACCEPT&&h.nodeType===Node.ELEMENT_NODE){b.push();f=b.getQName(h);var d,m=h.attributes,k,q,g,p="",r;d="<"+f;k=m.length;for(q=0;q")}if(n===NodeFilter.FILTER_ACCEPT||n===NodeFilter.FILTER_SKIP){for(n=h.firstChild;n;)a+=e(b,n),n=n.nextSibling;h.nodeValue&&(a+=l(h.nodeValue))}f&&(a+="",b.pop());return a}var c=this;this.filter=null;this.writeToString=function(b,c){if(!b)return"";var a=new m(c);return e(a,b)}}; +"function"!==typeof Object.create&&(Object.create=function(l){var m=function(){};m.prototype=l;return new m}); +xmldom.LSSerializer=function(){function l(b){var c=b||{},a=function(a){var b={},d;for(d in a)a.hasOwnProperty(d)&&(b[a[d]]=d);return b}(b),e=[c],f=[a],d=0;this.push=function(){d+=1;c=e[d]=Object.create(c);a=f[d]=Object.create(a)};this.pop=function(){e[d]=void 0;f[d]=void 0;d-=1;c=e[d];a=f[d]};this.getLocalNamespaceDefinitions=function(){return a};this.getQName=function(b){var d=b.namespaceURI,e=0,h;if(!d)return b.localName;if(h=a[d])return h+":"+b.localName;do{h||!b.prefix?(h="ns"+e,e+=1):h=b.prefix; +if(c[h]===d)break;if(!c[h]){c[h]=d;a[d]=h;break}h=null}while(null===h);return h+":"+b.localName}}function m(b){return b.replace(/&/g,"&").replace(//g,">").replace(/'/g,"'").replace(/"/g,""")}function g(b,n){var a="",e=c.filter?c.filter.acceptNode(n):NodeFilter.FILTER_ACCEPT,f;if(e===NodeFilter.FILTER_ACCEPT&&n.nodeType===Node.ELEMENT_NODE){b.push();f=b.getQName(n);var d,l=n.attributes,k,p,h,q="",s;d="<"+f;k=l.length;for(p=0;p")}if(e===NodeFilter.FILTER_ACCEPT||e===NodeFilter.FILTER_SKIP){for(e=n.firstChild;e;)a+=g(b,e),e=e.nextSibling;n.nodeValue&&(a+=m(n.nodeValue))}f&&(a+="",b.pop());return a}var c=this;this.filter=null;this.writeToString=function(b,c){if(!b)return"";var a=new l(c);return g(a,b)}}; // Input 21 -xmldom.RelaxNGParser=function(){function m(a,b){this.message=function(){b&&(a+=1===b.nodeType?" Element ":" Node ",a+=b.nodeName,b.nodeValue&&(a+=" with value '"+b.nodeValue+"'"),a+=".");return a}}function l(a){if(2>=a.e.length)return a;var b={name:a.name,e:a.e.slice(0,2)};return l({name:a.name,e:[b].concat(a.e.slice(2))})}function e(a){a=a.split(":",2);var b="",c;1===a.length?a=["",a[0]]:b=a[0];for(c in n)n[c]===b&&(a[0]=c);return a}function c(a,b){for(var k=0,f,g,p=a.name;a.e&&k=a.e.length)return a;var b={name:a.name,e:a.e.slice(0,2)};return m({name:a.name,e:[b].concat(a.e.slice(2))})}function g(a){a=a.split(":",2);var b="",c;1===a.length?a=["",a[0]]:b=a[0];for(c in e)e[c]===b&&(a[0]=c);return a}function c(a,b){for(var k=0,e,h,f=a.name;a.e&&k=c.length)return b;0===e&&(e=0);for(var g=c.item(e);g.namespaceURI===d;){e+=1;if(e>=c.length)return b;g=c.item(e)}return g=n(a,b.attDeriv(a,c.item(e)),c,e+1)}function f(a,b,c){c.e[0].a?(a.push(c.e[0].text),b.push(c.e[0].a.ns)):f(a,b,c.e[0]);c.e[1].a?(a.push(c.e[1].text),b.push(c.e[1].a.ns)): -f(a,b,c.e[1])}var d="http://www.w3.org/2000/xmlns/",s,k,q,g,p,r,w,u,A,x,v={type:"notAllowed",nullable:!1,hash:"notAllowed",textDeriv:function(){return v},startTagOpenDeriv:function(){return v},attDeriv:function(){return v},startTagCloseDeriv:function(){return v},endTagDeriv:function(){return v}},t={type:"empty",nullable:!0,hash:"empty",textDeriv:function(){return v},startTagOpenDeriv:function(){return v},attDeriv:function(){return v},startTagCloseDeriv:function(){return t},endTagDeriv:function(){return v}}, -E={type:"text",nullable:!0,hash:"text",textDeriv:function(){return E},startTagOpenDeriv:function(){return v},attDeriv:function(){return v},startTagCloseDeriv:function(){return E},endTagDeriv:function(){return v}},H,y,P;s=c("choice",function(a,b){if(a===v)return b;if(b===v||a===b)return a},function(a,c){var d={},g;b(d,{p1:a,p2:c});c=a=void 0;for(g in d)d.hasOwnProperty(g)&&(void 0===a?a=d[g]:c=void 0===c?d[g]:s(c,d[g]));return function(a,b){return{type:"choice",p1:a,p2:b,nullable:a.nullable||b.nullable, -textDeriv:function(c,d){return s(a.textDeriv(c,d),b.textDeriv(c,d))},startTagOpenDeriv:e(function(c){return s(a.startTagOpenDeriv(c),b.startTagOpenDeriv(c))}),attDeriv:function(c,d){return s(a.attDeriv(c,d),b.attDeriv(c,d))},startTagCloseDeriv:m(function(){return s(a.startTagCloseDeriv(),b.startTagCloseDeriv())}),endTagDeriv:m(function(){return s(a.endTagDeriv(),b.endTagDeriv())})}}(a,c)});k=function(a,b,c){return function(){var d={},e=0;return function(g,f){var k=b&&b(g,f),p,n;if(void 0!==k)return k; -k=g.hash||g.toString();p=f.hash||f.toString();k=c.length)return b;0===h&&(h=0);for(var k=c.item(h);k.namespaceURI===d;){h+=1;if(h>=c.length)return b;k=c.item(h)}return k=e(a,b.attDeriv(a,c.item(h)),c,h+1)}function f(a,b,c){c.e[0].a?(a.push(c.e[0].text),b.push(c.e[0].a.ns)):f(a,b,c.e[0]);c.e[1].a?(a.push(c.e[1].text),b.push(c.e[1].a.ns)): +f(a,b,c.e[1])}var d="http://www.w3.org/2000/xmlns/",t,k,p,h,q,s,w,u,A,y,v={type:"notAllowed",nullable:!1,hash:"notAllowed",textDeriv:function(){return v},startTagOpenDeriv:function(){return v},attDeriv:function(){return v},startTagCloseDeriv:function(){return v},endTagDeriv:function(){return v}},r={type:"empty",nullable:!0,hash:"empty",textDeriv:function(){return v},startTagOpenDeriv:function(){return v},attDeriv:function(){return v},startTagCloseDeriv:function(){return r},endTagDeriv:function(){return v}}, +z={type:"text",nullable:!0,hash:"text",textDeriv:function(){return z},startTagOpenDeriv:function(){return v},attDeriv:function(){return v},startTagCloseDeriv:function(){return z},endTagDeriv:function(){return v}},G,C,L;t=c("choice",function(a,b){if(a===v)return b;if(b===v||a===b)return a},function(a,c){var d={},h;b(d,{p1:a,p2:c});c=a=void 0;for(h in d)d.hasOwnProperty(h)&&(void 0===a?a=d[h]:c=void 0===c?d[h]:t(c,d[h]));return function(a,b){return{type:"choice",p1:a,p2:b,nullable:a.nullable||b.nullable, +textDeriv:function(c,d){return t(a.textDeriv(c,d),b.textDeriv(c,d))},startTagOpenDeriv:g(function(c){return t(a.startTagOpenDeriv(c),b.startTagOpenDeriv(c))}),attDeriv:function(c,d){return t(a.attDeriv(c,d),b.attDeriv(c,d))},startTagCloseDeriv:l(function(){return t(a.startTagCloseDeriv(),b.startTagCloseDeriv())}),endTagDeriv:l(function(){return t(a.endTagDeriv(),b.endTagDeriv())})}}(a,c)});k=function(a,b,c){return function(){var d={},h=0;return function(e,k){var f=b&&b(e,k),g,r;if(void 0!==f)return f; +f=e.hash||e.toString();g=k.hash||k.toString();fNode.ELEMENT_NODE;){if(d!==Node.COMMENT_NODE&&(d!==Node.TEXT_NODE||!/^\s+$/.test(b.currentNode.nodeValue)))return[new m("Not allowed node of type "+ -d+".")];d=(c=b.nextSibling())?c.nodeType:0}if(!c)return[new m("Missing element "+a.names)];if(a.names&&-1===a.names.indexOf(h[c.namespaceURI]+":"+c.localName))return[new m("Found "+c.nodeName+" instead of "+a.names+".",c)];if(b.firstChild()){for(e=l(a.e[1],b,c);b.nextSibling();)if(d=b.currentNode.nodeType,!(b.currentNode&&b.currentNode.nodeType===Node.TEXT_NODE&&/^\s+$/.test(b.currentNode.nodeValue)||d===Node.COMMENT_NODE))return[new m("Spurious content.",b.currentNode)];if(b.parentNode()!==c)return[new m("Implementation error.")]}else e= -l(a.e[1],b,c);b.nextSibling();return e}var c,b,h;b=function(a,c,f,d){var h=a.name,k=null;if("text"===h)a:{for(var q=(a=c.currentNode)?a.nodeType:0;a!==f&&3!==q;){if(1===q){k=[new m("Element not allowed here.",a)];break a}q=(a=c.nextSibling())?a.nodeType:0}c.nextSibling();k=null}else if("data"===h)k=null;else if("value"===h)d!==a.text&&(k=[new m("Wrong value, should be '"+a.text+"', not '"+d+"'",f)]);else if("list"===h)k=null;else if("attribute"===h)a:{if(2!==a.e.length)throw"Attribute with wrong # of elements: "+ -a.e.length;h=a.localnames.length;for(k=0;kNode.ELEMENT_NODE;){if(d!==Node.COMMENT_NODE&&(d!==Node.TEXT_NODE||!/^\s+$/.test(b.currentNode.nodeValue)))return[new l("Not allowed node of type "+ +d+".")];d=(c=b.nextSibling())?c.nodeType:0}if(!c)return[new l("Missing element "+a.names)];if(a.names&&-1===a.names.indexOf(n[c.namespaceURI]+":"+c.localName))return[new l("Found "+c.nodeName+" instead of "+a.names+".",c)];if(b.firstChild()){for(g=m(a.e[1],b,c);b.nextSibling();)if(d=b.currentNode.nodeType,!(b.currentNode&&b.currentNode.nodeType===Node.TEXT_NODE&&/^\s+$/.test(b.currentNode.nodeValue)||d===Node.COMMENT_NODE))return[new l("Spurious content.",b.currentNode)];if(b.parentNode()!==c)return[new l("Implementation error.")]}else g= +m(a.e[1],b,c);b.nextSibling();return g}var c,b,n;b=function(a,c,f,d){var n=a.name,k=null;if("text"===n)a:{for(var p=(a=c.currentNode)?a.nodeType:0;a!==f&&3!==p;){if(1===p){k=[new l("Element not allowed here.",a)];break a}p=(a=c.nextSibling())?a.nodeType:0}c.nextSibling();k=null}else if("data"===n)k=null;else if("value"===n)d!==a.text&&(k=[new l("Wrong value, should be '"+a.text+"', not '"+d+"'",f)]);else if("list"===n)k=null;else if("attribute"===n)a:{if(2!==a.e.length)throw"Attribute with wrong # of elements: "+ +a.e.length;n=a.localnames.length;for(k=0;k=f&&c.push(l(a.substring(b,d)))):"["===a[d]&&(0>=f&&(b=d+1),f+=1),d+=1;return d};xmldom.XPathIterator.prototype.next=function(){};xmldom.XPathIterator.prototype.reset=function(){};d=function(d,e,g){var f,h,m,l;for(f=0;f=f&&c.push(m(a.substring(b,d)))):"["===a[d]&&(0>=f&&(b=d+1),f+=1),d+=1;return d};xmldom.XPathIterator.prototype.next=function(){};xmldom.XPathIterator.prototype.reset=function(){};d=function(d,f,h){var g,n,m,l;for(g=0;g=(l.getBoundingClientRect().top-x.bottom)/u?c.style.top=Math.abs(l.getBoundingClientRect().top-x.bottom)/u+20+"px":c.style.top="0px");h.style.left=d.getBoundingClientRect().width/u+"px";var d=h.style,l=h.getBoundingClientRect().left/u,A=h.getBoundingClientRect().top/u,x=c.getBoundingClientRect().left/u,v=c.getBoundingClientRect().top/u,t=0,E= -0,t=x-l,t=t*t,E=v-A,E=E*E,l=Math.sqrt(t+E);d.width=l+"px";u=Math.asin((c.getBoundingClientRect().top-h.getBoundingClientRect().top)/(u*parseFloat(h.style.width)));h.style.transform="rotate("+u+"rad)";h.style.MozTransform="rotate("+u+"rad)";h.style.WebkitTransform="rotate("+u+"rad)";h.style.msTransform="rotate("+u+"rad)";b&&(u=s.getComputedStyle(b,":before").content)&&"none"!==u&&(u=u.substring(1,u.length-1),b.firstChild?b.firstChild.nodeValue=u:b.appendChild(f.createTextNode(u)))}}var n=[],f=l.ownerDocument, -d=new odf.OdfUtils,s=runtime.getWindow();runtime.assert(Boolean(s),"Expected to be run in an environment which has a global window, like a browser.");this.rerenderAnnotations=a;this.addAnnotation=function(d){b(!0);n.push({node:d.node,end:d.end});h();var e=f.createElement("div"),g=f.createElement("div"),p=f.createElement("div"),m=f.createElement("div"),l=f.createElement("div"),u=d.node;e.className="annotationWrapper";u.parentNode.insertBefore(e,u);g.className="annotationNote";g.appendChild(u);l.className= -"annotationRemoveButton";g.appendChild(l);p.className="annotationConnector horizontal";m.className="annotationConnector angular";e.appendChild(g);e.appendChild(p);e.appendChild(m);d.end&&c(d);a()};this.forgetAnnotations=function(){for(;n.length;){var a=n[0],c=n.indexOf(a),d=a.node,e=d.parentNode.parentNode;"div"===e.localName&&(e.parentNode.insertBefore(d,e),e.parentNode.removeChild(e));a=a.node.getAttributeNS(odf.Namespaces.officens,"name");a=f.querySelectorAll('span.annotationHighlight[annotation="'+ -a+'"]');e=d=void 0;for(d=0;d=(m.getBoundingClientRect().top-y.bottom)/u?c.style.top=Math.abs(m.getBoundingClientRect().top-y.bottom)/u+20+"px":c.style.top="0px");n.style.left=d.getBoundingClientRect().width/u+"px";var d=n.style,m=n.getBoundingClientRect().left/u,A=n.getBoundingClientRect().top/u,y=c.getBoundingClientRect().left/u,v=c.getBoundingClientRect().top/u,r=0,z= +0,r=y-m,r=r*r,z=v-A,z=z*z,m=Math.sqrt(r+z);d.width=m+"px";u=Math.asin((c.getBoundingClientRect().top-n.getBoundingClientRect().top)/(u*parseFloat(n.style.width)));n.style.transform="rotate("+u+"rad)";n.style.MozTransform="rotate("+u+"rad)";n.style.WebkitTransform="rotate("+u+"rad)";n.style.msTransform="rotate("+u+"rad)";b&&(u=t.getComputedStyle(b,":before").content)&&"none"!==u&&(u=u.substring(1,u.length-1),b.firstChild?b.firstChild.nodeValue=u:b.appendChild(f.createTextNode(u)))}}var e=[],f=m.ownerDocument, +d=new odf.OdfUtils,t=runtime.getWindow();runtime.assert(Boolean(t),"Expected to be run in an environment which has a global window, like a browser.");this.rerenderAnnotations=a;this.addAnnotation=function(d){b(!0);e.push({node:d.node,end:d.end});n();var g=f.createElement("div"),h=f.createElement("div"),q=f.createElement("div"),m=f.createElement("div"),l=f.createElement("div"),u=d.node;g.className="annotationWrapper";u.parentNode.insertBefore(g,u);h.className="annotationNote";h.appendChild(u);l.className= +"annotationRemoveButton";h.appendChild(l);q.className="annotationConnector horizontal";m.className="annotationConnector angular";g.appendChild(h);g.appendChild(q);g.appendChild(m);d.end&&c(d);a()};this.forgetAnnotations=function(){for(;e.length;){var a=e[0],c=e.indexOf(a),d=a.node,g=d.parentNode.parentNode;"div"===g.localName&&(g.parentNode.insertBefore(d,g),g.parentNode.removeChild(g));a=a.node.getAttributeNS(odf.Namespaces.officens,"name");a=f.querySelectorAll('span.annotationHighlight[annotation="'+ +a+'"]');g=d=void 0;for(d=0;da.value||"%"===a.unit)?null:a}function r(a){return(a=g(a))&&"%"!==a.unit?null:a}function w(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 "editinfo":return!1}}return!0} -var u="urn:oasis:names:tc:opendocument:xmlns:text:1.0",A="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0",x=/^\s*$/,v=new core.DomUtils;this.isParagraph=m;this.getParagraphElement=l;this.isWithinTrackedChanges=function(a,b){for(;a&&a!==b;){if(a.namespaceURI===u&&"tracked-changes"===a.localName)return!0;a=a.parentNode}return!1};this.isListItem=function(a){return"list-item"===(a&&a.localName)&&a.namespaceURI===u};this.isODFWhitespace=e;this.isGroupingElement=c;this.isCharacterElement=b;this.firstChild= -h;this.lastChild=a;this.previousNode=n;this.nextNode=f;this.scanLeftForNonWhitespace=d;this.lookLeftForCharacter=function(a){var c;c=0;a.nodeType===Node.TEXT_NODE&&0=b.value||"%"===b.unit)?null:b;return b||r(a)};this.parseFoLineHeight=function(a){return p(a)|| -r(a)};this.getImpactedParagraphs=function(a){var b=a.commonAncestorContainer,c=[];for(b.nodeType===Node.ELEMENT_NODE&&(c=v.getElementsByTagNameNS(b,u,"p").concat(v.getElementsByTagNameNS(b,u,"h")));b&&!m(b);)b=b.parentNode;b&&c.push(b);return c.filter(function(b){return v.rangeIntersectsNode(a,b)})};this.getTextNodes=function(a,b){var c=a.startContainer.ownerDocument.createRange(),d;d=v.getNodesInRange(a,function(d){c.selectNodeContents(d);if(d.nodeType===Node.TEXT_NODE){if(b&&v.rangesIntersect(a, -c)||v.containsRange(a,c))return Boolean(l(d)&&(!e(d.textContent)||q(d,0)))?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT}else if(v.rangesIntersect(a,c)&&w(d))return NodeFilter.FILTER_SKIP;return NodeFilter.FILTER_REJECT});c.detach();return d};this.getTextElements=function(a,d){var f=a.startContainer.ownerDocument.createRange(),g;g=v.getNodesInRange(a,function(g){var h=g.nodeType;f.selectNodeContents(g);if(h===Node.TEXT_NODE){if(v.containsRange(a,f)&&(d||Boolean(l(g)&&(!e(g.textContent)||q(g,0)))))return NodeFilter.FILTER_ACCEPT}else if(b(g)){if(v.containsRange(a, -f))return NodeFilter.FILTER_ACCEPT}else if(w(g)||c(g))return NodeFilter.FILTER_SKIP;return NodeFilter.FILTER_REJECT});f.detach();return g};this.getParagraphElements=function(a){var b=a.startContainer.ownerDocument.createRange(),d;d=v.getNodesInRange(a,function(d){b.selectNodeContents(d);if(m(d)){if(v.rangesIntersect(a,b))return NodeFilter.FILTER_ACCEPT}else if(w(d)||c(d))return NodeFilter.FILTER_SKIP;return NodeFilter.FILTER_REJECT});b.detach();return d}}; +odf.OdfUtils=function(){function l(a){var b=a&&a.localName;return("p"===b||"h"===b)&&a.namespaceURI===u}function m(a){for(;a&&!l(a);)a=a.parentNode;return a}function g(a){return/^[ \t\r\n]+$/.test(a)}function c(a){var b=a&&a.localName;return/^(span|p|h|a|meta)$/.test(b)&&a.namespaceURI===u||"span"===b&&"annotationHighlight"===a.className?!0:!1}function b(a){var b=a&&a.localName,c,d=!1;b&&(c=a.namespaceURI,c===u?d="s"===b||"tab"===b||"line-break"===b:c===A&&(d="frame"===b&&"as-char"===a.getAttributeNS(u, +"anchor-type")));return d}function n(a){for(;null!==a.firstChild&&c(a);)a=a.firstChild;return a}function a(a){for(;null!==a.lastChild&&c(a);)a=a.lastChild;return a}function e(b){for(;!l(b)&&null===b.previousSibling;)b=b.parentNode;return l(b)?null:a(b.previousSibling)}function f(a){for(;!l(a)&&null===a.nextSibling;)a=a.parentNode;return l(a)?null:n(a.nextSibling)}function d(a){for(var c=!1;a;)if(a.nodeType===Node.TEXT_NODE)if(0===a.length)a=e(a);else return!g(a.data.substr(a.length-1,1));else b(a)? +(c=!0,a=null):a=e(a);return c}function t(a){var c=!1;for(a=a&&n(a);a;){if(a.nodeType===Node.TEXT_NODE&&0a.value||"%"===a.unit)?null:a}function s(a){return(a=h(a))&&"%"!==a.unit?null:a}function w(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 "editinfo":return!1}}return!0} +var u="urn:oasis:names:tc:opendocument:xmlns:text:1.0",A="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0",y=/^\s*$/,v=new core.DomUtils;this.isParagraph=l;this.getParagraphElement=m;this.isWithinTrackedChanges=function(a,b){for(;a&&a!==b;){if(a.namespaceURI===u&&"tracked-changes"===a.localName)return!0;a=a.parentNode}return!1};this.isListItem=function(a){return"list-item"===(a&&a.localName)&&a.namespaceURI===u};this.isODFWhitespace=g;this.isGroupingElement=c;this.isCharacterElement=b;this.firstChild= +n;this.lastChild=a;this.previousNode=e;this.nextNode=f;this.scanLeftForNonWhitespace=d;this.lookLeftForCharacter=function(a){var c;c=0;a.nodeType===Node.TEXT_NODE&&0=b.value||"%"===b.unit)?null:b;return b||s(a)};this.parseFoLineHeight=function(a){return q(a)|| +s(a)};this.getImpactedParagraphs=function(a){var b=a.commonAncestorContainer,c=[];for(b.nodeType===Node.ELEMENT_NODE&&(c=v.getElementsByTagNameNS(b,u,"p").concat(v.getElementsByTagNameNS(b,u,"h")));b&&!l(b);)b=b.parentNode;b&&c.push(b);return c.filter(function(b){return v.rangeIntersectsNode(a,b)})};this.getTextNodes=function(a,b){var c=a.startContainer.ownerDocument.createRange(),d;d=v.getNodesInRange(a,function(d){c.selectNodeContents(d);if(d.nodeType===Node.TEXT_NODE){if(b&&v.rangesIntersect(a, +c)||v.containsRange(a,c))return Boolean(m(d)&&(!g(d.textContent)||p(d,0)))?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT}else if(v.rangesIntersect(a,c)&&w(d))return NodeFilter.FILTER_SKIP;return NodeFilter.FILTER_REJECT});c.detach();return d};this.getTextElements=function(a,d){var e=a.startContainer.ownerDocument.createRange(),h;h=v.getNodesInRange(a,function(h){var f=h.nodeType;e.selectNodeContents(h);if(f===Node.TEXT_NODE){if(v.containsRange(a,e)&&(d||Boolean(m(h)&&(!g(h.textContent)||p(h,0)))))return NodeFilter.FILTER_ACCEPT}else if(b(h)){if(v.containsRange(a, +e))return NodeFilter.FILTER_ACCEPT}else if(w(h)||c(h))return NodeFilter.FILTER_SKIP;return NodeFilter.FILTER_REJECT});e.detach();return h};this.getParagraphElements=function(a){var b=a.startContainer.ownerDocument.createRange(),d;d=v.getNodesInRange(a,function(d){b.selectNodeContents(d);if(l(d)){if(v.rangesIntersect(a,b))return NodeFilter.FILTER_ACCEPT}else if(w(d)||c(d))return NodeFilter.FILTER_SKIP;return NodeFilter.FILTER_REJECT});b.detach();return d}}; // Input 30 /* @@ -565,7 +565,7 @@ f))return NodeFilter.FILTER_ACCEPT}else if(w(g)||c(g))return NodeFilter.FILTER_S @source: http://gitorious.org/webodf/webodf/ */ runtime.loadClass("odf.OdfUtils"); -odf.TextSerializer=function(){function m(c){var b="",h=l.filter?l.filter.acceptNode(c):NodeFilter.FILTER_ACCEPT,a=c.nodeType,n;if(h===NodeFilter.FILTER_ACCEPT||h===NodeFilter.FILTER_SKIP)for(n=c.firstChild;n;)b+=m(n),n=n.nextSibling;h===NodeFilter.FILTER_ACCEPT&&(a===Node.ELEMENT_NODE&&e.isParagraph(c)?b+="\n":a===Node.TEXT_NODE&&c.textContent&&(b+=c.textContent));return b}var l=this,e=new odf.OdfUtils;this.filter=null;this.writeToString=function(c){return c?m(c):""}}; +odf.TextSerializer=function(){function l(c){var b="",n=m.filter?m.filter.acceptNode(c):NodeFilter.FILTER_ACCEPT,a=c.nodeType,e;if(n===NodeFilter.FILTER_ACCEPT||n===NodeFilter.FILTER_SKIP)for(e=c.firstChild;e;)b+=l(e),e=e.nextSibling;n===NodeFilter.FILTER_ACCEPT&&(a===Node.ELEMENT_NODE&&g.isParagraph(c)?b+="\n":a===Node.TEXT_NODE&&c.textContent&&(b+=c.textContent));return b}var m=this,g=new odf.OdfUtils;this.filter=null;this.writeToString=function(c){return c?l(c):""}}; // Input 31 /* @@ -602,10 +602,10 @@ odf.TextSerializer=function(){function m(c){var b="",h=l.filter?l.filter.acceptN @source: http://gitorious.org/webodf/webodf/ */ runtime.loadClass("core.DomUtils");runtime.loadClass("core.LoopWatchDog");runtime.loadClass("odf.Namespaces"); -odf.TextStyleApplicator=function(m,l,e){function c(a){function b(a,c){return"object"===typeof a&&"object"===typeof c?Object.keys(a).every(function(d){return b(a[d],c[d])}):a===c}this.isStyleApplied=function(c){c=l.getAppliedStylesForElement(c);return b(a,c)}}function b(b){var c={};this.applyStyleToContainer=function(h){var q;q=h.getAttributeNS(a,"style-name");var g=h.ownerDocument;q=q||"";if(!c.hasOwnProperty(q)){var p=q,r;r=q?l.createDerivedStyleObject(q,"text",b):b;g=g.createElementNS(n,"style:style"); -l.updateStyle(g,r);g.setAttributeNS(n,"style:name",m.generateName());g.setAttributeNS(n,"style:family","text");g.setAttributeNS(f,"scope","document-content");e.appendChild(g);c[p]=g}q=c[q].getAttributeNS(n,"name");h.setAttributeNS(a,"text:style-name",q)}}var h=new core.DomUtils,a=odf.Namespaces.textns,n=odf.Namespaces.stylens,f="urn:webodf:names:scope";this.applyStyle=function(d,e,f){var n={},g,m,l,w;runtime.assert(f&&f["style:text-properties"],"applyStyle without any text properties");n["style:text-properties"]= -f["style:text-properties"];l=new b(n);w=new c(n);d.forEach(function(b){g=w.isStyleApplied(b);if(!1===g){var c=b.ownerDocument,d=b.parentNode,f,k=b,n=new core.LoopWatchDog(1E3);"span"===d.localName&&d.namespaceURI===a?(b.previousSibling&&!h.rangeContainsNode(e,b.previousSibling)?(c=d.cloneNode(!1),d.parentNode.insertBefore(c,d.nextSibling)):c=d,f=!0):(c=c.createElementNS(a,"text:span"),d.insertBefore(c,b),f=!1);for(;k&&(k===b||h.rangeContainsNode(e,k));)n.check(),d=k.nextSibling,k.parentNode!==c&& -c.appendChild(k),k=d;if(k&&f)for(b=c.cloneNode(!1),c.parentNode.insertBefore(b,c.nextSibling);k;)n.check(),d=k.nextSibling,b.appendChild(k),k=d;m=c;l.applyStyleToContainer(m)}})}}; +odf.TextStyleApplicator=function(l,m,g){function c(a){function b(a,c){return"object"===typeof a&&"object"===typeof c?Object.keys(a).every(function(d){return b(a[d],c[d])}):a===c}this.isStyleApplied=function(c){c=m.getAppliedStylesForElement(c);return b(a,c)}}function b(b){var c={};this.applyStyleToContainer=function(k){var n;n=k.getAttributeNS(a,"style-name");var h=k.ownerDocument;n=n||"";if(!c.hasOwnProperty(n)){var q=n,s;s=n?m.createDerivedStyleObject(n,"text",b):b;h=h.createElementNS(e,"style:style"); +m.updateStyle(h,s);h.setAttributeNS(e,"style:name",l.generateName());h.setAttributeNS(e,"style:family","text");h.setAttributeNS(f,"scope","document-content");g.appendChild(h);c[q]=h}n=c[n].getAttributeNS(e,"name");k.setAttributeNS(a,"text:style-name",n)}}var n=new core.DomUtils,a=odf.Namespaces.textns,e=odf.Namespaces.stylens,f="urn:webodf:names:scope";this.applyStyle=function(d,e,f){var g={},h,m,l,w;runtime.assert(f&&f["style:text-properties"],"applyStyle without any text properties");g["style:text-properties"]= +f["style:text-properties"];l=new b(g);w=new c(g);d.forEach(function(b){h=w.isStyleApplied(b);if(!1===h){var c=b.ownerDocument,d=b.parentNode,f,k=b,g=new core.LoopWatchDog(1E3);"span"===d.localName&&d.namespaceURI===a?(b.previousSibling&&!n.rangeContainsNode(e,b.previousSibling)?(c=d.cloneNode(!1),d.parentNode.insertBefore(c,d.nextSibling)):c=d,f=!0):(c=c.createElementNS(a,"text:span"),d.insertBefore(c,b),f=!1);for(;k&&(k===b||n.rangeContainsNode(e,k));)g.check(),d=k.nextSibling,k.parentNode!==c&& +c.appendChild(k),k=d;if(k&&f)for(b=c.cloneNode(!1),c.parentNode.insertBefore(b,c.nextSibling);k;)g.check(),d=k.nextSibling,b.appendChild(k),k=d;m=c;l.applyStyleToContainer(m)}})}}; // Input 32 /* @@ -642,48 +642,48 @@ c.appendChild(k),k=d;if(k&&f)for(b=c.cloneNode(!1),c.parentNode.insertBefore(b,c @source: http://gitorious.org/webodf/webodf/ */ runtime.loadClass("odf.Namespaces");runtime.loadClass("odf.OdfUtils");runtime.loadClass("xmldom.XPath");runtime.loadClass("core.CSSUnits"); -odf.Style2CSS=function(){function m(a){var b={},c,d;if(!a)return b;for(a=a.firstChild;a;){if(d=a.namespaceURI!==p||"style"!==a.localName&&"default-style"!==a.localName?a.namespaceURI===u&&"list-style"===a.localName?"list":a.namespaceURI!==p||"page-layout"!==a.localName&&"default-page-layout"!==a.localName?void 0:"page":a.getAttributeNS(p,"family"))(c=a.getAttributeNS&&a.getAttributeNS(p,"name"))||(c=""),d=b[d]=b[d]||{},d[c]=a;a=a.nextSibling}return b}function l(a,b){if(!b||!a)return null;if(a[b])return a[b]; -var c,d;for(c in a)if(a.hasOwnProperty(c)&&(d=l(a[c].derivedStyles,b)))return d;return null}function e(a,b,c){var d=b[a],f,g;d&&(f=d.getAttributeNS(p,"parent-style-name"),g=null,f&&(g=l(c,f),!g&&b[f]&&(e(f,b,c),g=b[f],b[f]=null)),g?(g.derivedStyles||(g.derivedStyles={}),g.derivedStyles[a]=d):c[a]=d)}function c(a,b){for(var c in a)a.hasOwnProperty(c)&&(e(c,a,b),a[c]=null)}function b(a,b){var c=v[a],d;if(null===c)return null;d=b?"["+c+'|style-name="'+b+'"]':"["+c+"|style-name]";"presentation"===c&& -(c="draw",d=b?'[presentation|style-name="'+b+'"]':"[presentation|style-name]");return c+"|"+t[a].join(d+","+c+"|")+d}function h(a,c,d){var e=[],f,g;e.push(b(a,c));for(f in d.derivedStyles)if(d.derivedStyles.hasOwnProperty(f))for(g in c=h(a,f,d.derivedStyles[f]),c)c.hasOwnProperty(g)&&e.push(c[g]);return e}function a(a,b,c){if(!a)return null;for(a=a.firstChild;a;){if(a.namespaceURI===b&&a.localName===c)return b=a;a=a.nextSibling}return null}function n(a,b){var c="",d,e;for(d in b)if(b.hasOwnProperty(d)&& -(d=b[d],e=a.getAttributeNS(d[0],d[1]))){e=e.trim();if(N.hasOwnProperty(d[1])){var f=e.indexOf(" "),g=void 0,h=void 0;-1!==f?(g=e.substring(0,f),h=e.substring(f)):(g=e,h="");(g=Y.parseLength(g))&&("pt"===g.unit&&0.75>g.value)&&(e="0.75pt"+h)}d[2]&&(c+=d[2]+":"+e+";")}return c}function f(b){return(b=a(b,p,"text-properties"))?Y.parseFoFontSize(b.getAttributeNS(g,"font-size")):null}function d(a){a=a.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i,function(a,b,c,d){return b+b+c+c+d+d});return(a=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(a))? -{r:parseInt(a[1],16),g:parseInt(a[2],16),b:parseInt(a[3],16)}:null}function s(a,b,c,d){b='text|list[text|style-name="'+b+'"]';var e=c.getAttributeNS(u,"level"),f;c=Y.getFirstNonWhitespaceChild(c);c=Y.getFirstNonWhitespaceChild(c);var g;c&&(f=c.attributes,g=f["fo:text-indent"]?f["fo:text-indent"].value:void 0,f=f["fo:margin-left"]?f["fo:margin-left"].value:void 0);g||(g="-0.6cm");c="-"===g.charAt(0)?g.substring(1):"-"+g;for(e=e&&parseInt(e,10);1 text|list-item > text|list",e-=1;e=b+" > text|list-item > *:not(text|list):first-child"; -void 0!==f&&(f=e+"{margin-left:"+f+";}",a.insertRule(f,a.cssRules.length));d=b+" > text|list-item > *:not(text|list):first-child:before{"+d+";";d+="counter-increment:list;";d+="margin-left:"+g+";";d+="width:"+c+";";d+="display:inline-block}";try{a.insertRule(d,a.cssRules.length)}catch(h){throw h;}}function k(b,c,e,m){if("list"===c)for(var l=m.firstChild,r,t;l;){if(l.namespaceURI===u)if(r=l,"list-level-style-number"===l.localName){var v=r;t=v.getAttributeNS(p,"num-format");var N=v.getAttributeNS(p, -"num-suffix"),F={1:"decimal",a:"lower-latin",A:"upper-latin",i:"lower-roman",I:"upper-roman"},v=v.getAttributeNS(p,"num-prefix")||"",v=F.hasOwnProperty(t)?v+(" counter(list, "+F[t]+")"):t?v+("'"+t+"';"):v+" ''";N&&(v+=" '"+N+"'");t="content: "+v+";";s(b,e,r,t)}else"list-level-style-image"===l.localName?(t="content: none;",s(b,e,r,t)):"list-level-style-bullet"===l.localName&&(t="content: '"+r.getAttributeNS(u,"bullet-char")+"';",s(b,e,r,t));l=l.nextSibling}else if("page"===c)if(N=r=e="",l=m.getElementsByTagNameNS(p, -"page-layout-properties")[0],r=l.parentNode.parentNode.parentNode.masterStyles,N="",e+=n(l,X),t=l.getElementsByTagNameNS(p,"background-image"),0f.value)&&(e="0.75pt"+k)}d[2]&&(c+=d[2]+":"+e+";")}return c}function f(b){return(b=a(b,q,"text-properties"))?Z.parseFoFontSize(b.getAttributeNS(h,"font-size")):null}function d(a){a=a.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i,function(a,b,c,d){return b+b+c+c+d+d});return(a=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(a))? +{r:parseInt(a[1],16),g:parseInt(a[2],16),b:parseInt(a[3],16)}:null}function t(a,b,c,d){b='text|list[text|style-name="'+b+'"]';var e=c.getAttributeNS(u,"level"),h;c=Z.getFirstNonWhitespaceChild(c);c=Z.getFirstNonWhitespaceChild(c);var f;c&&(h=c.attributes,f=h["fo:text-indent"]?h["fo:text-indent"].value:void 0,h=h["fo:margin-left"]?h["fo:margin-left"].value:void 0);f||(f="-0.6cm");c="-"===f.charAt(0)?f.substring(1):"-"+f;for(e=e&&parseInt(e,10);1 text|list-item > text|list",e-=1;e=b+" > text|list-item > *:not(text|list):first-child"; +void 0!==h&&(h=e+"{margin-left:"+h+";}",a.insertRule(h,a.cssRules.length));d=b+" > text|list-item > *:not(text|list):first-child:before{"+d+";";d+="counter-increment:list;";d+="margin-left:"+f+";";d+="width:"+c+";";d+="display:inline-block}";try{a.insertRule(d,a.cssRules.length)}catch(k){throw k;}}function k(b,c,g,m){if("list"===c)for(var l=m.firstChild,r,s;l;){if(l.namespaceURI===u)if(r=l,"list-level-style-number"===l.localName){var v=r;s=v.getAttributeNS(q,"num-format");var N=v.getAttributeNS(q, +"num-suffix"),E={1:"decimal",a:"lower-latin",A:"upper-latin",i:"lower-roman",I:"upper-roman"},v=v.getAttributeNS(q,"num-prefix")||"",v=E.hasOwnProperty(s)?v+(" counter(list, "+E[s]+")"):s?v+("'"+s+"';"):v+" ''";N&&(v+=" '"+N+"'");s="content: "+v+";";t(b,g,r,s)}else"list-level-style-image"===l.localName?(s="content: none;",t(b,g,r,s)):"list-level-style-bullet"===l.localName&&(s="content: '"+r.getAttributeNS(u,"bullet-char")+"';",t(b,g,r,s));l=l.nextSibling}else if("page"===c)if(N=r=g="",l=m.getElementsByTagNameNS(q, +"page-layout-properties")[0],r=l.parentNode.parentNode.parentNode.masterStyles,N="",g+=e(l,ea),s=l.getElementsByTagNameNS(q,"background-image"),0c)break;e=e.nextSibling}a.insertBefore(b,e)}}}function h(a){this.OdfContainer=a}function a(a, -b,c,d){var e=this;this.size=0;this.type=null;this.name=a;this.container=c;this.onchange=this.onreadystatechange=this.document=this.mimetype=this.url=null;this.EMPTY=0;this.LOADING=1;this.DONE=2;this.state=this.EMPTY;this.load=function(){null!==d&&(this.mimetype=b,d.loadAsDataURL(a,b,function(a,b){a&&runtime.log(a);e.url=b;if(e.onchange)e.onchange(e);if(e.onstatereadychange)e.onstatereadychange(e)}))}}var n=new odf.StyleInfo,f="urn:oasis:names:tc:opendocument:xmlns:office:1.0",d="urn:oasis:names:tc:opendocument:xmlns:manifest:1.0", -s="urn:webodf:names:scope",k="meta settings scripts font-face-decls styles automatic-styles master-styles body".split(" "),q=(new Date).getTime()+"_webodf_",g=new core.Base64;h.prototype=new function(){};h.prototype.constructor=h;h.namespaceURI=f;h.localName="document";a.prototype.load=function(){};a.prototype.getUrl=function(){return this.data?"data:;base64,"+g.toBase64(this.data):null};odf.OdfContainer=function r(g,k){function l(a){for(var b=a.firstChild,c;b;)c=b.nextSibling,b.nodeType===Node.ELEMENT_NODE? -l(b):b.nodeType===Node.PROCESSING_INSTRUCTION_NODE&&a.removeChild(b),b=c}function x(a,b){for(var c=a&&a.firstChild;c;)c.nodeType===Node.ELEMENT_NODE&&c.setAttributeNS(s,"scope",b),c=c.nextSibling}function v(a,b){var c=null,d,e,f;if(a)for(c=a.cloneNode(!0),d=c.firstChild;d;)e=d.nextSibling,d.nodeType===Node.ELEMENT_NODE&&(f=d.getAttributeNS(s,"scope"))&&f!==b&&c.removeChild(d),d=e;return c}function t(a){var b=I.rootElement.ownerDocument,c;if(a){l(a.documentElement);try{c=b.importNode(a.documentElement, -!0)}catch(d){}}return c}function E(a){I.state=a;if(I.onchange)I.onchange(I);if(I.onstatereadychange)I.onstatereadychange(I)}function H(a){Z=null;I.rootElement=a;a.fontFaceDecls=m(a,f,"font-face-decls");a.styles=m(a,f,"styles");a.automaticStyles=m(a,f,"automatic-styles");a.masterStyles=m(a,f,"master-styles");a.body=m(a,f,"body");a.meta=m(a,f,"meta")}function y(a){a=t(a);var c=I.rootElement;a&&"document-styles"===a.localName&&a.namespaceURI===f?(c.fontFaceDecls=m(a,f,"font-face-decls"),b(c,c.fontFaceDecls), -c.styles=m(a,f,"styles"),b(c,c.styles),c.automaticStyles=m(a,f,"automatic-styles"),x(c.automaticStyles,"document-styles"),b(c,c.automaticStyles),c.masterStyles=m(a,f,"master-styles"),b(c,c.masterStyles),n.prefixStyleNames(c.automaticStyles,q,c.masterStyles)):E(r.INVALID)}function P(a){a=t(a);var c,d,e;if(a&&"document-content"===a.localName&&a.namespaceURI===f){c=I.rootElement;d=m(a,f,"font-face-decls");if(c.fontFaceDecls&&d)for(e=d.firstChild;e;)c.fontFaceDecls.appendChild(e),e=d.firstChild;else d&& -(c.fontFaceDecls=d,b(c,d));d=m(a,f,"automatic-styles");x(d,"document-content");if(c.automaticStyles&&d)for(e=d.firstChild;e;)c.automaticStyles.appendChild(e),e=d.firstChild;else d&&(c.automaticStyles=d,b(c,d));c.body=m(a,f,"body");b(c,c.body)}else E(r.INVALID)}function B(a){a=t(a);var c;a&&("document-meta"===a.localName&&a.namespaceURI===f)&&(c=I.rootElement,c.meta=m(a,f,"meta"),b(c,c.meta))}function R(a){a=t(a);var c;a&&("document-settings"===a.localName&&a.namespaceURI===f)&&(c=I.rootElement,c.settings= -m(a,f,"settings"),b(c,c.settings))}function G(a){a=t(a);var b;if(a&&"manifest"===a.localName&&a.namespaceURI===d)for(b=I.rootElement,b.manifest=a,a=b.manifest.firstChild;a;)a.nodeType===Node.ELEMENT_NODE&&("file-entry"===a.localName&&a.namespaceURI===d)&&(Q[a.getAttributeNS(d,"full-path")]=a.getAttributeNS(d,"media-type")),a=a.nextSibling}function L(a){var b=a.shift(),c,d;b?(c=b[0],d=b[1],K.loadAsDOM(c,function(b,c){d(c);b||I.state===r.INVALID||L(a)})):E(r.DONE)}function X(a){var b="";odf.Namespaces.forEachPrefix(function(a, -c){b+=" xmlns:"+a+'="'+c+'"'});return''}function oa(){var a=new xmldom.LSSerializer,b=X("document-meta");a.filter=new odf.OdfNodeFilter;b+=a.writeToString(I.rootElement.meta,odf.Namespaces.namespaceMap);return b+""}function N(a,b){var c=document.createElementNS(d,"manifest:file-entry");c.setAttributeNS(d,"manifest:full-path",a);c.setAttributeNS(d,"manifest:media-type",b);return c}function sa(){var a= -runtime.parseXML(''),b=m(a,d,"manifest"),c=new xmldom.LSSerializer,e;for(e in Q)Q.hasOwnProperty(e)&&b.appendChild(N(e,Q[e]));c.filter=new odf.OdfNodeFilter;return'\n'+c.writeToString(a,odf.Namespaces.namespaceMap)}function Y(){var a=new xmldom.LSSerializer,b=X("document-settings");a.filter=new odf.OdfNodeFilter;b+=a.writeToString(I.rootElement.settings,odf.Namespaces.namespaceMap); -return b+""}function ba(){var a=odf.Namespaces.namespaceMap,b=new xmldom.LSSerializer,c=v(I.rootElement.automaticStyles,"document-styles"),d=I.rootElement.masterStyles&&I.rootElement.masterStyles.cloneNode(!0),f=X("document-styles");n.removePrefixFromStyleNames(c,q,d);b.filter=new e(d,c);f+=b.writeToString(I.rootElement.fontFaceDecls,a);f+=b.writeToString(I.rootElement.styles,a);f+=b.writeToString(c,a);f+=b.writeToString(d,a);return f+""}function M(){var a= -odf.Namespaces.namespaceMap,b=new xmldom.LSSerializer,d=v(I.rootElement.automaticStyles,"document-content"),e=X("document-content");b.filter=new c(I.rootElement.body,d);e+=b.writeToString(d,a);e+=b.writeToString(I.rootElement.body,a);return e+""}function V(a,b){runtime.loadXML(a,function(a,c){if(a)b(a);else{var d=t(c);d&&"document"===d.localName&&d.namespaceURI===f?(H(d),E(r.DONE)):E(r.INVALID)}})}function S(){function a(b,c){var e;c||(c=b);e=document.createElementNS(f,c); -d[b]=e;d.appendChild(e)}var b=new core.Zip("",null),c=runtime.byteArrayFromString("application/vnd.oasis.opendocument.text","utf8"),d=I.rootElement,e=document.createElementNS(f,"text");b.save("mimetype",c,!1,new Date);a("meta");a("settings");a("scripts");a("fontFaceDecls","font-face-decls");a("styles");a("automaticStyles","automatic-styles");a("masterStyles","master-styles");a("body");d.body.appendChild(e);E(r.DONE);return b}function J(){var a,b=new Date;a=runtime.byteArrayFromString(Y(),"utf8"); -K.save("settings.xml",a,!0,b);a=runtime.byteArrayFromString(oa(),"utf8");K.save("meta.xml",a,!0,b);a=runtime.byteArrayFromString(ba(),"utf8");K.save("styles.xml",a,!0,b);a=runtime.byteArrayFromString(M(),"utf8");K.save("content.xml",a,!0,b);a=runtime.byteArrayFromString(sa(),"utf8");K.save("META-INF/manifest.xml",a,!0,b)}function C(a,b){J();K.writeAs(a,function(a){b(a)})}var I=this,K,Q={},Z;this.onstatereadychange=k;this.rootElement=this.state=this.onchange=null;this.setRootElement=H;this.getContentElement= -function(){var a;Z||(a=I.rootElement.body,Z=a.getElementsByTagNameNS(f,"text")[0]||a.getElementsByTagNameNS(f,"presentation")[0]||a.getElementsByTagNameNS(f,"spreadsheet")[0]);return Z};this.getDocumentType=function(){var a=I.getContentElement();return a&&a.localName};this.getPart=function(b){return new a(b,Q[b],I,K)};this.getPartData=function(a,b){K.load(a,b)};this.createByteArray=function(a,b){J();K.createByteArray(a,b)};this.saveAs=C;this.save=function(a){C(g,a)};this.getUrl=function(){return g}; -this.state=r.LOADING;this.rootElement=function(a){var b=document.createElementNS(a.namespaceURI,a.localName),c;a=new a;for(c in a)a.hasOwnProperty(c)&&(b[c]=a[c]);return b}(h);K=g?new core.Zip(g,function(a,b){K=b;a?V(g,function(b){a&&(K.error=a+"\n"+b,E(r.INVALID))}):L([["styles.xml",y],["content.xml",P],["meta.xml",B],["settings.xml",R],["META-INF/manifest.xml",G]])}):S()};odf.OdfContainer.EMPTY=0;odf.OdfContainer.LOADING=1;odf.OdfContainer.DONE=2;odf.OdfContainer.INVALID=3;odf.OdfContainer.SAVING= +odf.OdfContainer=function(){function l(a,b,c){for(a=a?a.firstChild:null;a;){if(a.localName===c&&a.namespaceURI===b)return a;a=a.nextSibling}return null}function m(a){var b,c=k.length;for(b=0;bc)break;e=e.nextSibling}a.insertBefore(b,e)}}}function n(a){this.OdfContainer=a}function a(a, +b,c,d){var e=this;this.size=0;this.type=null;this.name=a;this.container=c;this.onchange=this.onreadystatechange=this.document=this.mimetype=this.url=null;this.EMPTY=0;this.LOADING=1;this.DONE=2;this.state=this.EMPTY;this.load=function(){null!==d&&(this.mimetype=b,d.loadAsDataURL(a,b,function(a,b){a&&runtime.log(a);e.url=b;if(e.onchange)e.onchange(e);if(e.onstatereadychange)e.onstatereadychange(e)}))}}var e=new odf.StyleInfo,f="urn:oasis:names:tc:opendocument:xmlns:office:1.0",d="urn:oasis:names:tc:opendocument:xmlns:manifest:1.0", +t="urn:webodf:names:scope",k="meta settings scripts font-face-decls styles automatic-styles master-styles body".split(" "),p=(new Date).getTime()+"_webodf_",h=new core.Base64;n.prototype=new function(){};n.prototype.constructor=n;n.namespaceURI=f;n.localName="document";a.prototype.load=function(){};a.prototype.getUrl=function(){return this.data?"data:;base64,"+h.toBase64(this.data):null};odf.OdfContainer=function s(h,k){function m(a){for(var b=a.firstChild,c;b;)c=b.nextSibling,b.nodeType===Node.ELEMENT_NODE? +m(b):b.nodeType===Node.PROCESSING_INSTRUCTION_NODE&&a.removeChild(b),b=c}function y(a,b){for(var c=a&&a.firstChild;c;)c.nodeType===Node.ELEMENT_NODE&&c.setAttributeNS(t,"scope",b),c=c.nextSibling}function v(a,b){var c=null,d,e,h;if(a)for(c=a.cloneNode(!0),d=c.firstChild;d;)e=d.nextSibling,d.nodeType===Node.ELEMENT_NODE&&(h=d.getAttributeNS(t,"scope"))&&h!==b&&c.removeChild(d),d=e;return c}function r(a){var b=I.rootElement.ownerDocument,c;if(a){m(a.documentElement);try{c=b.importNode(a.documentElement, +!0)}catch(d){}}return c}function z(a){I.state=a;if(I.onchange)I.onchange(I);if(I.onstatereadychange)I.onstatereadychange(I)}function G(a){ba=null;I.rootElement=a;a.fontFaceDecls=l(a,f,"font-face-decls");a.styles=l(a,f,"styles");a.automaticStyles=l(a,f,"automatic-styles");a.masterStyles=l(a,f,"master-styles");a.body=l(a,f,"body");a.meta=l(a,f,"meta")}function C(a){a=r(a);var c=I.rootElement;a&&"document-styles"===a.localName&&a.namespaceURI===f?(c.fontFaceDecls=l(a,f,"font-face-decls"),b(c,c.fontFaceDecls), +c.styles=l(a,f,"styles"),b(c,c.styles),c.automaticStyles=l(a,f,"automatic-styles"),y(c.automaticStyles,"document-styles"),b(c,c.automaticStyles),c.masterStyles=l(a,f,"master-styles"),b(c,c.masterStyles),e.prefixStyleNames(c.automaticStyles,p,c.masterStyles)):z(s.INVALID)}function L(a){a=r(a);var c,d,e;if(a&&"document-content"===a.localName&&a.namespaceURI===f){c=I.rootElement;d=l(a,f,"font-face-decls");if(c.fontFaceDecls&&d)for(e=d.firstChild;e;)c.fontFaceDecls.appendChild(e),e=d.firstChild;else d&& +(c.fontFaceDecls=d,b(c,d));d=l(a,f,"automatic-styles");y(d,"document-content");if(c.automaticStyles&&d)for(e=d.firstChild;e;)c.automaticStyles.appendChild(e),e=d.firstChild;else d&&(c.automaticStyles=d,b(c,d));c.body=l(a,f,"body");b(c,c.body)}else z(s.INVALID)}function B(a){a=r(a);var c;a&&("document-meta"===a.localName&&a.namespaceURI===f)&&(c=I.rootElement,c.meta=l(a,f,"meta"),b(c,c.meta))}function M(a){a=r(a);var c;a&&("document-settings"===a.localName&&a.namespaceURI===f)&&(c=I.rootElement,c.settings= +l(a,f,"settings"),b(c,c.settings))}function F(a){a=r(a);var b;if(a&&"manifest"===a.localName&&a.namespaceURI===d)for(b=I.rootElement,b.manifest=a,a=b.manifest.firstChild;a;)a.nodeType===Node.ELEMENT_NODE&&("file-entry"===a.localName&&a.namespaceURI===d)&&(R[a.getAttributeNS(d,"full-path")]=a.getAttributeNS(d,"media-type")),a=a.nextSibling}function K(a){var b=a.shift(),c,d;b?(c=b[0],d=b[1],J.loadAsDOM(c,function(b,c){d(c);b||I.state===s.INVALID||K(a)})):z(s.DONE)}function ea(a){var b="";odf.Namespaces.forEachPrefix(function(a, +c){b+=" xmlns:"+a+'="'+c+'"'});return''}function pa(){var a=new xmldom.LSSerializer,b=ea("document-meta");a.filter=new odf.OdfNodeFilter;b+=a.writeToString(I.rootElement.meta,odf.Namespaces.namespaceMap);return b+""}function N(a,b){var c=document.createElementNS(d,"manifest:file-entry");c.setAttributeNS(d,"manifest:full-path",a);c.setAttributeNS(d,"manifest:media-type",b);return c}function qa(){var a= +runtime.parseXML(''),b=l(a,d,"manifest"),c=new xmldom.LSSerializer,e;for(e in R)R.hasOwnProperty(e)&&b.appendChild(N(e,R[e]));c.filter=new odf.OdfNodeFilter;return'\n'+c.writeToString(a,odf.Namespaces.namespaceMap)}function Z(){var a=new xmldom.LSSerializer,b=ea("document-settings");a.filter=new odf.OdfNodeFilter;b+=a.writeToString(I.rootElement.settings,odf.Namespaces.namespaceMap); +return b+""}function $(){var a=odf.Namespaces.namespaceMap,b=new xmldom.LSSerializer,c=v(I.rootElement.automaticStyles,"document-styles"),d=I.rootElement.masterStyles&&I.rootElement.masterStyles.cloneNode(!0),h=ea("document-styles");e.removePrefixFromStyleNames(c,p,d);b.filter=new g(d,c);h+=b.writeToString(I.rootElement.fontFaceDecls,a);h+=b.writeToString(I.rootElement.styles,a);h+=b.writeToString(c,a);h+=b.writeToString(d,a);return h+""}function Q(){var a= +odf.Namespaces.namespaceMap,b=new xmldom.LSSerializer,d=v(I.rootElement.automaticStyles,"document-content"),e=ea("document-content");b.filter=new c(I.rootElement.body,d);e+=b.writeToString(d,a);e+=b.writeToString(I.rootElement.body,a);return e+""}function W(a,b){runtime.loadXML(a,function(a,c){if(a)b(a);else{var d=r(c);d&&"document"===d.localName&&d.namespaceURI===f?(G(d),z(s.DONE)):z(s.INVALID)}})}function S(){function a(b,c){var e;c||(c=b);e=document.createElementNS(f, +c);d[b]=e;d.appendChild(e)}var b=new core.Zip("",null),c=runtime.byteArrayFromString("application/vnd.oasis.opendocument.text","utf8"),d=I.rootElement,e=document.createElementNS(f,"text");b.save("mimetype",c,!1,new Date);a("meta");a("settings");a("scripts");a("fontFaceDecls","font-face-decls");a("styles");a("automaticStyles","automatic-styles");a("masterStyles","master-styles");a("body");d.body.appendChild(e);z(s.DONE);return b}function O(){var a,b=new Date;a=runtime.byteArrayFromString(Z(),"utf8"); +J.save("settings.xml",a,!0,b);a=runtime.byteArrayFromString(pa(),"utf8");J.save("meta.xml",a,!0,b);a=runtime.byteArrayFromString($(),"utf8");J.save("styles.xml",a,!0,b);a=runtime.byteArrayFromString(Q(),"utf8");J.save("content.xml",a,!0,b);a=runtime.byteArrayFromString(qa(),"utf8");J.save("META-INF/manifest.xml",a,!0,b)}function H(a,b){O();J.writeAs(a,function(a){b(a)})}var I=this,J,R={},ba;this.onstatereadychange=k;this.rootElement=this.state=this.onchange=null;this.setRootElement=G;this.getContentElement= +function(){var a;ba||(a=I.rootElement.body,ba=a.getElementsByTagNameNS(f,"text")[0]||a.getElementsByTagNameNS(f,"presentation")[0]||a.getElementsByTagNameNS(f,"spreadsheet")[0]);return ba};this.getDocumentType=function(){var a=I.getContentElement();return a&&a.localName};this.getPart=function(b){return new a(b,R[b],I,J)};this.getPartData=function(a,b){J.load(a,b)};this.createByteArray=function(a,b){O();J.createByteArray(a,b)};this.saveAs=H;this.save=function(a){H(h,a)};this.getUrl=function(){return h}; +this.state=s.LOADING;this.rootElement=function(a){var b=document.createElementNS(a.namespaceURI,a.localName),c;a=new a;for(c in a)a.hasOwnProperty(c)&&(b[c]=a[c]);return b}(n);J=h?new core.Zip(h,function(a,b){J=b;a?W(h,function(b){a&&(J.error=a+"\n"+b,z(s.INVALID))}):K([["styles.xml",C],["content.xml",L],["meta.xml",B],["settings.xml",M],["META-INF/manifest.xml",F]])}):S()};odf.OdfContainer.EMPTY=0;odf.OdfContainer.LOADING=1;odf.OdfContainer.DONE=2;odf.OdfContainer.INVALID=3;odf.OdfContainer.SAVING= 4;odf.OdfContainer.MODIFIED=5;odf.OdfContainer.getContainer=function(a){return new odf.OdfContainer(a,null)};return odf.OdfContainer}(); // Input 34 /* @@ -721,9 +721,9 @@ this.state=r.LOADING;this.rootElement=function(a){var b=document.createElementNS @source: http://gitorious.org/webodf/webodf/ */ runtime.loadClass("core.Base64");runtime.loadClass("xmldom.XPath");runtime.loadClass("odf.OdfContainer"); -odf.FontLoader=function(){function m(c,b,h,a,n){var f,d=0,l;for(l in c)if(c.hasOwnProperty(l)){if(d===h){f=l;break}d+=1}f?b.getPartData(c[f].href,function(d,l){if(d)runtime.log(d);else{var g="@font-face { font-family: '"+(c[f].family||f)+"'; src: url(data:application/x-font-ttf;charset=binary;base64,"+e.convertUTF8ArrayToBase64(l)+') format("truetype"); }';try{a.insertRule(g,a.cssRules.length)}catch(p){runtime.log("Problem inserting rule in CSS: "+runtime.toJson(p)+"\nRule: "+g)}}m(c,b,h+1,a,n)}): -n&&n()}var l=new xmldom.XPath,e=new core.Base64;odf.FontLoader=function(){this.loadFonts=function(c,b){for(var e=c.rootElement.fontFaceDecls;b.cssRules.length;)b.deleteRule(b.cssRules.length-1);if(e){var a={},n,f,d,s;if(e)for(e=l.getODFElementsWithXPath(e,"style:font-face[svg:font-face-src]",odf.Namespaces.resolvePrefix),n=0;n text|list-item > *:first-child:before {";if(F=y.getAttributeNS(t,"style-name")){y= -p[F];C=R.getFirstNonWhitespaceChild(y);y=void 0;if(C)if("list-level-style-number"===C.localName){y=C.getAttributeNS(A,"num-format");F=C.getAttributeNS(A,"num-suffix");var M="",M={1:"decimal",a:"lower-latin",A:"upper-latin",i:"lower-roman",I:"upper-roman"},J=void 0,J=C.getAttributeNS(A,"num-prefix")||"",J=M.hasOwnProperty(y)?J+(" counter(list, "+M[y]+")"):y?J+("'"+y+"';"):J+" ''";F&&(J+=" '"+F+"'");y=M="content: "+J+";"}else"list-level-style-image"===C.localName?y="content: none;":"list-level-style-bullet"=== -C.localName&&(y="content: '"+C.getAttributeNS(t,"bullet-char")+"';");C=y}if(G){for(y=m[G];y;)G=y,y=m[G];D+="counter-increment:"+G+";";C?(C=C.replace("list",G),D+=C):D+="content:counter("+G+");"}else G="",C?(C=C.replace("list",u),D+=C):D+="content: counter("+u+");",D+="counter-increment:"+u+";",g.insertRule("text|list#"+u+" {counter-reset:"+u+"}",g.cssRules.length);D+="}";m[u]=G;D&&g.insertRule(D,g.cssRules.length)}O.insertBefore(L,O.firstChild);x();E(f);if(!b&&(f=[K],ma.hasOwnProperty("statereadychange")))for(g= -ma.statereadychange,C=0;C text|list-item > *:first-child:before {";if(ga=V.getAttributeNS(r, +"style-name")){V=q[ga];x=M.getFirstNonWhitespaceChild(V);V=void 0;if(x)if("list-level-style-number"===x.localName){V=x.getAttributeNS(A,"num-format");ga=x.getAttributeNS(A,"num-suffix");var D="",D={1:"decimal",a:"lower-latin",A:"upper-latin",i:"lower-roman",I:"upper-roman"},F=void 0,F=x.getAttributeNS(A,"num-prefix")||"",F=D.hasOwnProperty(V)?F+(" counter(list, "+D[V]+")"):V?F+("'"+V+"';"):F+" ''";ga&&(F+=" '"+ga+"'");V=D="content: "+F+";"}else"list-level-style-image"===x.localName?V="content: none;": +"list-level-style-bullet"===x.localName&&(V="content: '"+x.getAttributeNS(r,"bullet-char")+"';");x=V}if(Y){for(V=l[Y];V;)Y=V,V=l[Y];z+="counter-increment:"+Y+";";x?(x=x.replace("list",Y),z+=x):z+="content:counter("+Y+");"}else Y="",x?(x=x.replace("list",u),z+=x):z+="content: counter("+u+");",z+="counter-increment:"+u+";",g.insertRule("text|list#"+u+" {counter-reset:"+u+"}",g.cssRules.length);z+="}";l[u]=Y;z&&g.insertRule(z,g.cssRules.length)}P.insertBefore(K,P.firstChild);y();C(f);if(!b&&(f=[J],la.hasOwnProperty("statereadychange")))for(g= +la.statereadychange,x=0;xd?-n.countBackwardSteps(-d, -f):0;a.move(d);b&&(f=0b?-n.countBackwardSteps(-b,f):0,a.move(f,!0));e.emit(ops.OdtDocument.signalCursorMoved,a);return!0};this.spec=function(){return{optype:"MoveCursor",memberid:l,timestamp:e,position:c,length:b}}}; +ops.OpMoveCursor=function(){var l=this,m,g,c,b;this.init=function(n){m=n.memberid;g=n.timestamp;c=parseInt(n.position,10);b=void 0!==n.length?parseInt(n.length,10):0};this.merge=function(n){return"MoveCursor"===n.optype&&n.memberid===m?(c=n.position,b=n.length,g=n.timestamp,!0):!1};this.transform=function(g,a){var e=g.spec(),f=c+b,d,t=[l];switch(e.optype){case "RemoveText":d=e.position+e.length;d<=c?c-=e.length:e.positiond?-e.countBackwardSteps(-d, +f):0;a.move(d);b&&(f=0b?-e.countBackwardSteps(-b,f):0,a.move(f,!0));g.emit(ops.OdtDocument.signalCursorMoved,a);return!0};this.spec=function(){return{optype:"MoveCursor",memberid:m,timestamp:g,position:c,length:b}}}; // Input 46 /* @@ -1170,11 +1170,11 @@ f):0;a.move(d);b&&(f=0b?-n.countBackwardSteps(-b,f @source: http://www.webodf.org/ @source: http://gitorious.org/webodf/webodf/ */ -ops.OpInsertTable=function(){function m(a,c){var d;if(1===s.length)d=s[0];else if(3===s.length)switch(a){case 0:d=s[0];break;case b-1:d=s[2];break;default:d=s[1]}else d=s[a];if(1===d.length)return d[0];if(3===d.length)switch(c){case 0:return d[0];case h-1:return d[2];default:return d[1]}return d[c]}var l=this,e,c,b,h,a,n,f,d,s;this.init=function(k){e=k.memberid;c=k.timestamp;a=parseInt(k.position,10);b=parseInt(k.initialRows,10);h=parseInt(k.initialColumns,10);n=k.tableName;f=k.tableStyleName;d=k.tableColumnStyleName; -s=k.tableCellStyleMatrix};this.transform=function(b,c){var d=b.spec(),e=[l];switch(d.optype){case "InsertTable":e=null;break;case "AddAnnotation":d.position=a.textNode.length?null:a.textNode.splitText(a.offset));for(a=a.textNode;a!==f;)if(a=a.parentNode,d=a.cloneNode(!1),k){for(m&&d.appendChild(m);k.nextSibling;)d.appendChild(k.nextSibling); -a.parentNode.insertBefore(d,a.nextSibling);k=a;m=d}else a.parentNode.insertBefore(d,a),k=d,m=a;b.isListItem(m)&&(m=m.childNodes[0]);h.fixCursorPositions(l);h.getOdfCanvas().refreshSize();h.emit(ops.OdtDocument.signalParagraphChanged,{paragraphElement:n,memberId:l,timeStamp:e});h.emit(ops.OdtDocument.signalParagraphChanged,{paragraphElement:m,memberId:l,timeStamp:e});h.getOdfCanvas().rerenderAnnotations();return!0};this.spec=function(){return{optype:"SplitParagraph",memberid:l,timestamp:e,position:c}}}; +ops.OpSplitParagraph=function(){var l=this,m,g,c,b=new odf.OdfUtils;this.init=function(b){m=b.memberid;g=b.timestamp;c=parseInt(b.position,10)};this.transform=function(b,a){var e=b.spec(),f=[l];switch(e.optype){case "SplitParagraph":e.position=a.textNode.length?null:a.textNode.splitText(a.offset));for(a=a.textNode;a!==f;)if(a=a.parentNode,d=a.cloneNode(!1),k){for(l&&d.appendChild(l);k.nextSibling;)d.appendChild(k.nextSibling); +a.parentNode.insertBefore(d,a.nextSibling);k=a;l=d}else a.parentNode.insertBefore(d,a),k=d,l=a;b.isListItem(l)&&(l=l.childNodes[0]);n.fixCursorPositions(m);n.getOdfCanvas().refreshSize();n.emit(ops.OdtDocument.signalParagraphChanged,{paragraphElement:e,memberId:m,timeStamp:g});n.emit(ops.OdtDocument.signalParagraphChanged,{paragraphElement:l,memberId:m,timeStamp:g});n.getOdfCanvas().rerenderAnnotations();return!0};this.spec=function(){return{optype:"SplitParagraph",memberid:m,timestamp:g,position:c}}}; // Input 50 /* @@ -1330,8 +1330,8 @@ a.parentNode.insertBefore(d,a.nextSibling);k=a;m=d}else a.parentNode.insertBefor @source: http://www.webodf.org/ @source: http://gitorious.org/webodf/webodf/ */ -ops.OpSetParagraphStyle=function(){var m=this,l,e,c,b;this.init=function(h){l=h.memberid;e=h.timestamp;c=h.position;b=h.styleName};this.transform=function(c,a){var e=c.spec(),f=[m];switch(e.optype){case "RemoveParagraphStyle":e.styleName===b&&(b="")}return f};this.execute=function(h){var a;if(a=h.getPositionInTextNode(c))if(a=h.getParagraphElement(a.textNode))return""!==b?a.setAttributeNS("urn:oasis:names:tc:opendocument:xmlns:text:1.0","text:style-name",b):a.removeAttributeNS("urn:oasis:names:tc:opendocument:xmlns:text:1.0", -"style-name"),h.getOdfCanvas().refreshSize(),h.emit(ops.OdtDocument.signalParagraphChanged,{paragraphElement:a,timeStamp:e,memberId:l}),h.getOdfCanvas().rerenderAnnotations(),!0;return!1};this.spec=function(){return{optype:"SetParagraphStyle",memberid:l,timestamp:e,position:c,styleName:b}}}; +ops.OpSetParagraphStyle=function(){var l=this,m,g,c,b;this.init=function(n){m=n.memberid;g=n.timestamp;c=n.position;b=n.styleName};this.transform=function(c,a){var e=c.spec(),f=[l];switch(e.optype){case "RemoveParagraphStyle":e.styleName===b&&(b="")}return f};this.execute=function(n){var a;if(a=n.getPositionInTextNode(c))if(a=n.getParagraphElement(a.textNode))return""!==b?a.setAttributeNS("urn:oasis:names:tc:opendocument:xmlns:text:1.0","text:style-name",b):a.removeAttributeNS("urn:oasis:names:tc:opendocument:xmlns:text:1.0", +"style-name"),n.getOdfCanvas().refreshSize(),n.emit(ops.OdtDocument.signalParagraphChanged,{paragraphElement:a,timeStamp:g,memberId:m}),n.getOdfCanvas().rerenderAnnotations(),!0;return!1};this.spec=function(){return{optype:"SetParagraphStyle",memberid:m,timestamp:g,position:c,styleName:b}}}; // Input 51 /* @@ -1368,11 +1368,11 @@ ops.OpSetParagraphStyle=function(){var m=this,l,e,c,b;this.init=function(h){l=h. @source: http://gitorious.org/webodf/webodf/ */ runtime.loadClass("odf.Namespaces"); -ops.OpUpdateParagraphStyle=function(){function m(a,b){var c,d,e=b?b.split(","):[];for(c=0;ck?-g.countBackwardSteps(-k,d):0,s.move(d),l.emit(ops.OdtDocument.signalCursorMoved,s));l.getOdfCanvas().addAnnotation(f);return!0};this.spec=function(){return{optype:"AddAnnotation",memberid:e,timestamp:c,position:b, -length:h,name:a}}}; +ops.OpAddAnnotation=function(){function l(a,b,c){if(c=a.getPositionInTextNode(c,g))a=c.textNode,c.offset!==a.length&&a.splitText(c.offset),a.parentNode.insertBefore(b,a.nextSibling)}var m=this,g,c,b,n,a;this.init=function(e){g=e.memberid;c=parseInt(e.timestamp,10);b=parseInt(e.position,10);n=parseInt(e.length,10)||0;a=e.name};this.transform=function(a,c){var d=a.spec(),g=b+n,k=[m];switch(d.optype){case "AddAnnotation":d.positionk?-h.countBackwardSteps(-k,d):0,m.move(d),e.emit(ops.OdtDocument.signalCursorMoved,m));e.getOdfCanvas().addAnnotation(f);return!0};this.spec=function(){return{optype:"AddAnnotation",memberid:g,timestamp:c,position:b, +length:n,name:a}}}; // Input 55 /* @@ -1524,9 +1524,9 @@ length:h,name:a}}}; @source: http://gitorious.org/webodf/webodf/ */ runtime.loadClass("odf.Namespaces");runtime.loadClass("core.DomUtils"); -ops.OpRemoveAnnotation=function(){var m,l,e,c,b;this.init=function(h){m=h.memberid;l=h.timestamp;e=parseInt(h.position,10);c=parseInt(h.length,10);b=new core.DomUtils};this.transform=function(b,a){return null};this.execute=function(c){for(var a=c.getIteratorAtPosition(e).container(),l,f=null,d=null;a.namespaceURI!==odf.Namespaces.officens||"annotation"!==a.localName;)a=a.parentNode;if(null===a)return!1;f=a;(l=f.getAttributeNS(odf.Namespaces.officens,"name"))&&(d=b.getElementsByTagNameNS(c.getRootNode(), -odf.Namespaces.officens,"annotation-end").filter(function(a){return l===a.getAttributeNS(odf.Namespaces.officens,"name")})[0]||null);c.getOdfCanvas().forgetAnnotations();for(a=b.getElementsByTagNameNS(f,odf.Namespaces.webodfns+":names:cursor","cursor");a.length;)f.parentNode.insertBefore(a.pop(),f);f.parentNode.removeChild(f);d&&d.parentNode.removeChild(d);c.fixCursorPositions();c.getOdfCanvas().refreshAnnotations();return!0};this.spec=function(){return{optype:"RemoveAnnotation",memberid:m,timestamp:l, -position:e,length:c}}}; +ops.OpRemoveAnnotation=function(){var l,m,g,c,b;this.init=function(n){l=n.memberid;m=n.timestamp;g=parseInt(n.position,10);c=parseInt(n.length,10);b=new core.DomUtils};this.transform=function(b,a){return null};this.execute=function(c){for(var a=c.getIteratorAtPosition(g).container(),e,f=null,d=null;a.namespaceURI!==odf.Namespaces.officens||"annotation"!==a.localName;)a=a.parentNode;if(null===a)return!1;f=a;(e=f.getAttributeNS(odf.Namespaces.officens,"name"))&&(d=b.getElementsByTagNameNS(c.getRootNode(), +odf.Namespaces.officens,"annotation-end").filter(function(a){return e===a.getAttributeNS(odf.Namespaces.officens,"name")})[0]||null);c.getOdfCanvas().forgetAnnotations();for(a=b.getElementsByTagNameNS(f,odf.Namespaces.webodfns+":names:cursor","cursor");a.length;)f.parentNode.insertBefore(a.pop(),f);f.parentNode.removeChild(f);d&&d.parentNode.removeChild(d);c.fixCursorPositions();c.getOdfCanvas().refreshAnnotations();return!0};this.spec=function(){return{optype:"RemoveAnnotation",memberid:l,timestamp:m, +position:g,length:c}}}; // Input 56 /* @@ -1564,21 +1564,21 @@ position:e,length:c}}}; */ runtime.loadClass("ops.OpAddCursor");runtime.loadClass("ops.OpApplyDirectStyling");runtime.loadClass("ops.OpRemoveCursor");runtime.loadClass("ops.OpMoveCursor");runtime.loadClass("ops.OpInsertTable");runtime.loadClass("ops.OpInsertText");runtime.loadClass("ops.OpRemoveText");runtime.loadClass("ops.OpSplitParagraph");runtime.loadClass("ops.OpSetParagraphStyle");runtime.loadClass("ops.OpUpdateParagraphStyle");runtime.loadClass("ops.OpAddParagraphStyle");runtime.loadClass("ops.OpRemoveParagraphStyle"); runtime.loadClass("ops.OpAddAnnotation");runtime.loadClass("ops.OpRemoveAnnotation"); -ops.OperationFactory=function(){function m(e){return function(){return new e}}var l;this.register=function(e,c){l[e]=c};this.create=function(e){var c=null,b=l[e.optype];b&&(c=b(e),c.init(e));return c};l={AddCursor:m(ops.OpAddCursor),ApplyDirectStyling:m(ops.OpApplyDirectStyling),InsertTable:m(ops.OpInsertTable),InsertText:m(ops.OpInsertText),RemoveText:m(ops.OpRemoveText),SplitParagraph:m(ops.OpSplitParagraph),SetParagraphStyle:m(ops.OpSetParagraphStyle),UpdateParagraphStyle:m(ops.OpUpdateParagraphStyle), -AddParagraphStyle:m(ops.OpAddParagraphStyle),RemoveParagraphStyle:m(ops.OpRemoveParagraphStyle),MoveCursor:m(ops.OpMoveCursor),RemoveCursor:m(ops.OpRemoveCursor),AddAnnotation:m(ops.OpAddAnnotation),RemoveAnnotation:m(ops.OpRemoveAnnotation)}}; +ops.OperationFactory=function(){function l(g){return function(){return new g}}var m;this.register=function(g,c){m[g]=c};this.create=function(g){var c=null,b=m[g.optype];b&&(c=b(g),c.init(g));return c};m={AddCursor:l(ops.OpAddCursor),ApplyDirectStyling:l(ops.OpApplyDirectStyling),InsertTable:l(ops.OpInsertTable),InsertText:l(ops.OpInsertText),RemoveText:l(ops.OpRemoveText),SplitParagraph:l(ops.OpSplitParagraph),SetParagraphStyle:l(ops.OpSetParagraphStyle),UpdateParagraphStyle:l(ops.OpUpdateParagraphStyle), +AddParagraphStyle:l(ops.OpAddParagraphStyle),RemoveParagraphStyle:l(ops.OpRemoveParagraphStyle),MoveCursor:l(ops.OpMoveCursor),RemoveCursor:l(ops.OpRemoveCursor),AddAnnotation:l(ops.OpAddAnnotation),RemoveAnnotation:l(ops.OpRemoveAnnotation)}}; // Input 57 runtime.loadClass("core.Cursor");runtime.loadClass("core.PositionIterator");runtime.loadClass("core.PositionFilter");runtime.loadClass("core.LoopWatchDog");runtime.loadClass("odf.OdfUtils"); -gui.SelectionMover=function(m,l){function e(){u.setUnfilteredPosition(m.getNode(),0);return u}function c(a,b){var c,d=null;a&&(c=b?a[a.length-1]:a[0]);c&&(d={top:c.top,left:b?c.right:c.left,bottom:c.bottom});return d}function b(a,d,e,f){var g=a.nodeType;e.setStart(a,d);e.collapse(!f);f=c(e.getClientRects(),!0===f);!f&&0a?-1:1;for(a=Math.abs(a);0m?n.previousPosition():n.nextPosition());)if(I.check(),k.acceptPosition(n)===v&&(r+=1,p=n.container(),w=b(p,n.unfilteredDomOffset(),C),w.top!==V)){if(w.top!==J&&J!==V)break;J=w.top;w=Math.abs(S-w.left);if(null===u||wa?(d=k.previousPosition,f=-1):(d=k.nextPosition,f=1);for(g=b(k.container(),k.unfilteredDomOffset(),p);d.call(k);)if(c.acceptPosition(k)===v){if(w.getParagraphElement(k.getCurrentNode())!==m)break;h=b(k.container(),k.unfilteredDomOffset(),p);if(h.bottom!==g.bottom&&(g=h.top>=g.top&&h.bottomg.bottom,!g))break;n+=f;g=h}p.detach();return n}function p(a,b){for(var c=0,d;a.parentNode!==b;)runtime.assert(null!==a.parentNode,"parent is null"), -a=a.parentNode;for(d=b.firstChild;d!==a;)c+=1,d=d.nextSibling;return c}function r(a,b,c){runtime.assert(null!==a,"SelectionMover.countStepsToPosition called with element===null");var d=e(),f=d.container(),g=d.unfilteredDomOffset(),h=0,k=new core.LoopWatchDog(1E3);d.setUnfilteredPosition(a,b);a=d.container();runtime.assert(Boolean(a),"SelectionMover.countStepsToPosition: positionIterator.container() returned null");b=d.unfilteredDomOffset();d.setUnfilteredPosition(f,g);var f=a,g=b,l=d.container(), -m=d.unfilteredDomOffset();if(f===l)f=m-g;else{var n=f.compareDocumentPosition(l);2===n?n=-1:4===n?n=1:10===n?(g=p(f,l),n=gf)for(;d.nextPosition()&&(k.check(),c.acceptPosition(d)===v&&(h+=1),d.container()!==a||d.unfilteredDomOffset()!==b););else if(0a?-1:1;for(a=Math.abs(a);0n?l.previousPosition():l.nextPosition());)if(I.check(),k.acceptPosition(l)===v&&(s+=1,q=l.container(),w=b(q,l.unfilteredDomOffset(),H),w.top!==W)){if(w.top!==O&&O!==W)break;O=w.top;w=Math.abs(S-w.left);if(null===u||wa?(d=k.previousPosition,e=-1):(d=k.nextPosition,e=1);for(h=b(k.container(),k.unfilteredDomOffset(),q);d.call(k);)if(c.acceptPosition(k)===v){if(w.getParagraphElement(k.getCurrentNode())!==n)break;f=b(k.container(),k.unfilteredDomOffset(),q);if(f.bottom!==h.bottom&&(h=f.top>=h.top&&f.bottomh.bottom,!h))break;l+=e;h=f}q.detach();return l}function q(a,b){for(var c=0,d;a.parentNode!==b;)runtime.assert(null!==a.parentNode,"parent is null"), +a=a.parentNode;for(d=b.firstChild;d!==a;)c+=1,d=d.nextSibling;return c}function s(a,b,c){runtime.assert(null!==a,"SelectionMover.countStepsToPosition called with element===null");var d=g(),e=d.container(),h=d.unfilteredDomOffset(),f=0,k=new core.LoopWatchDog(1E3);d.setUnfilteredPosition(a,b);a=d.container();runtime.assert(Boolean(a),"SelectionMover.countStepsToPosition: positionIterator.container() returned null");b=d.unfilteredDomOffset();d.setUnfilteredPosition(e,h);var e=a,h=b,n=d.container(), +l=d.unfilteredDomOffset();if(e===n)e=l-h;else{var m=e.compareDocumentPosition(n);2===m?m=-1:4===m?m=1:10===m?(h=q(e,n),m=he)for(;d.nextPosition()&&(k.check(),c.acceptPosition(d)===v&&(f+=1),d.container()!==a||d.unfilteredDomOffset()!==b););else if(0=b&&(l=-c.movePointBackward(-b,a));e.handleUpdate();return l};this.handleUpdate=function(){};this.getStepCounter=function(){return c.getStepCounter()};this.getMemberId=function(){return m};this.getNode=function(){return b.getNode()};this.getAnchorNode=function(){return b.getAnchorNode()};this.getSelectedRange=function(){return b.getSelectedRange()}; -this.getOdtDocument=function(){return l};b=new core.Cursor(l.getDOM(),m);c=new gui.SelectionMover(b,l.getRootNode())}; +ops.OdtCursor=function(l,m){var g=this,c,b;this.removeFromOdtDocument=function(){b.remove()};this.move=function(b,a){var e=0;0=b&&(e=-c.movePointBackward(-b,a));g.handleUpdate();return e};this.handleUpdate=function(){};this.getStepCounter=function(){return c.getStepCounter()};this.getMemberId=function(){return l};this.getNode=function(){return b.getNode()};this.getAnchorNode=function(){return b.getAnchorNode()};this.getSelectedRange=function(){return b.getSelectedRange()}; +this.getOdtDocument=function(){return m};b=new core.Cursor(m.getDOM(),l);c=new gui.SelectionMover(b,m.getRootNode())}; // Input 60 /* @@ -1656,21 +1656,17 @@ this.getOdtDocument=function(){return l};b=new core.Cursor(l.getDOM(),m);c=new g @source: http://www.webodf.org/ @source: http://gitorious.org/webodf/webodf/ */ -ops.EditInfo=function(m,l){function e(){var c=[],a;for(a in b)b.hasOwnProperty(a)&&c.push({memberid:a,time:b[a].time});c.sort(function(a,b){return a.time-b.time});return c}var c,b={};this.getNode=function(){return c};this.getOdtDocument=function(){return l};this.getEdits=function(){return b};this.getSortedEdits=function(){return e()};this.addEdit=function(c,a){b[c]={time:a}};this.clearEdits=function(){b={}};this.destroy=function(b){m.removeChild(c);b()};c=l.getDOM().createElementNS("urn:webodf:names:editinfo", -"editinfo");m.insertBefore(c,m.firstChild)}; +ops.EditInfo=function(l,m){function g(){var c=[],a;for(a in b)b.hasOwnProperty(a)&&c.push({memberid:a,time:b[a].time});c.sort(function(a,b){return a.time-b.time});return c}var c,b={};this.getNode=function(){return c};this.getOdtDocument=function(){return m};this.getEdits=function(){return b};this.getSortedEdits=function(){return g()};this.addEdit=function(c,a){b[c]={time:a}};this.clearEdits=function(){b={}};this.destroy=function(b){l.removeChild(c);b()};c=m.getDOM().createElementNS("urn:webodf:names:editinfo", +"editinfo");l.insertBefore(c,l.firstChild)}; // Input 61 -gui.Avatar=function(m,l){var e=this,c,b,h;this.setColor=function(a){b.style.borderColor=a};this.setImageUrl=function(a){e.isVisible()?b.src=a:h=a};this.isVisible=function(){return"block"===c.style.display};this.show=function(){h&&(b.src=h,h=void 0);c.style.display="block"};this.hide=function(){c.style.display="none"};this.markAsFocussed=function(a){c.className=a?"active":""};this.destroy=function(a){m.removeChild(c);a()};(function(){var a=m.ownerDocument,e=a.documentElement.namespaceURI;c=a.createElementNS(e, -"div");b=a.createElementNS(e,"img");b.width=64;b.height=64;c.appendChild(b);c.style.width="64px";c.style.height="70px";c.style.position="absolute";c.style.top="-80px";c.style.left="-34px";c.style.display=l?"block":"none";m.appendChild(c)})()}; +gui.Avatar=function(l,m){var g=this,c,b,n;this.setColor=function(a){b.style.borderColor=a};this.setImageUrl=function(a){g.isVisible()?b.src=a:n=a};this.isVisible=function(){return"block"===c.style.display};this.show=function(){n&&(b.src=n,n=void 0);c.style.display="block"};this.hide=function(){c.style.display="none"};this.markAsFocussed=function(a){c.className=a?"active":""};this.destroy=function(a){l.removeChild(c);a()};(function(){var a=l.ownerDocument,e=a.documentElement.namespaceURI;c=a.createElementNS(e, +"div");b=a.createElementNS(e,"img");b.width=64;b.height=64;c.appendChild(b);c.style.width="64px";c.style.height="70px";c.style.position="absolute";c.style.top="-80px";c.style.left="-34px";c.style.display=m?"block":"none";l.appendChild(c)})()}; // Input 62 runtime.loadClass("gui.Avatar");runtime.loadClass("ops.OdtCursor"); -gui.Caret=function(m,l,e){function c(e){n&&a.parentNode&&(!f||e)&&(e&&void 0!==d&&runtime.clearTimeout(d),f=!0,b.style.opacity=e||"0"===b.style.opacity?"1":"0",d=runtime.setTimeout(function(){f=!1;c(!1)},500))}var b,h,a,n=!1,f=!1,d;this.refreshCursorBlinking=function(){e||m.getSelectedRange().collapsed?(n=!0,c(!0)):(n=!1,b.style.opacity="0")};this.setFocus=function(){n=!0;h.markAsFocussed(!0);c(!0)};this.removeFocus=function(){n=!1;h.markAsFocussed(!1);b.style.opacity="0"};this.setAvatarImageUrl= -function(a){h.setImageUrl(a)};this.setColor=function(a){b.style.borderColor=a;h.setColor(a)};this.getCursor=function(){return m};this.getFocusElement=function(){return b};this.toggleHandleVisibility=function(){h.isVisible()?h.hide():h.show()};this.showHandle=function(){h.show()};this.hideHandle=function(){h.hide()};this.ensureVisible=function(){var a,c,d,e,f=m.getOdtDocument().getOdfCanvas().getElement().parentNode,h;d=f.offsetWidth-f.clientWidth+5;e=f.offsetHeight-f.clientHeight+5;h=b.getBoundingClientRect(); -a=h.left-d;c=h.top-e;d=h.right+d;e=h.bottom+e;h=f.getBoundingClientRect();ch.bottom&&(f.scrollTop+=e-h.bottom);ah.right&&(f.scrollLeft+=d-h.right)};this.destroy=function(c){h.destroy(function(d){d?c(d):(a.removeChild(b),c())})};(function(){var c=m.getOdtDocument().getDOM();b=c.createElementNS(c.documentElement.namespaceURI,"span");a=m.getNode();a.appendChild(b);h=new gui.Avatar(a,l)})()}; +gui.Caret=function(l,m,g){function c(g){e&&a.parentNode&&(!f||g)&&(g&&void 0!==d&&runtime.clearTimeout(d),f=!0,b.style.opacity=g||"0"===b.style.opacity?"1":"0",d=runtime.setTimeout(function(){f=!1;c(!1)},500))}var b,n,a,e=!1,f=!1,d;this.refreshCursorBlinking=function(){g||l.getSelectedRange().collapsed?(e=!0,c(!0)):(e=!1,b.style.opacity="0")};this.setFocus=function(){e=!0;n.markAsFocussed(!0);c(!0)};this.removeFocus=function(){e=!1;n.markAsFocussed(!1);b.style.opacity="0"};this.setAvatarImageUrl= +function(a){n.setImageUrl(a)};this.setColor=function(a){b.style.borderColor=a;n.setColor(a)};this.getCursor=function(){return l};this.getFocusElement=function(){return b};this.toggleHandleVisibility=function(){n.isVisible()?n.hide():n.show()};this.showHandle=function(){n.show()};this.hideHandle=function(){n.hide()};this.ensureVisible=function(){var a,c,d,e,f=l.getOdtDocument().getOdfCanvas().getElement().parentNode,g;d=f.offsetWidth-f.clientWidth+5;e=f.offsetHeight-f.clientHeight+5;g=b.getBoundingClientRect(); +a=g.left-d;c=g.top-e;d=g.right+d;e=g.bottom+e;g=f.getBoundingClientRect();cg.bottom&&(f.scrollTop+=e-g.bottom);ag.right&&(f.scrollLeft+=d-g.right)};this.destroy=function(c){n.destroy(function(d){d?c(d):(a.removeChild(b),c())})};(function(){var c=l.getOdtDocument().getDOM();b=c.createElementNS(c.documentElement.namespaceURI,"span");a=l.getNode();a.appendChild(b);n=new gui.Avatar(a,m)})()}; // Input 63 -runtime.loadClass("core.EventNotifier"); -gui.ClickHandler=function(){function m(){e=0;c=null}var l,e=0,c=null,b=new core.EventNotifier([gui.ClickHandler.signalSingleClick,gui.ClickHandler.signalDoubleClick,gui.ClickHandler.signalTripleClick]);this.subscribe=function(c,a){b.subscribe(c,a)};this.handleMouseUp=function(h){var a=runtime.getWindow();c&&c.x===h.screenX&&c.y===h.screenY?(e+=1,1===e?b.emit(gui.ClickHandler.signalSingleClick,h):2===e?b.emit(gui.ClickHandler.signalDoubleClick,void 0):3===e&&(a.clearTimeout(l),b.emit(gui.ClickHandler.signalTripleClick, -void 0),m())):(b.emit(gui.ClickHandler.signalSingleClick,h),e=1,c={x:h.screenX,y:h.screenY},a.clearTimeout(l),l=a.setTimeout(m,400))}};gui.ClickHandler.signalSingleClick="click";gui.ClickHandler.signalDoubleClick="doubleClick";gui.ClickHandler.signalTripleClick="tripleClick";(function(){return gui.ClickHandler})(); -// Input 64 /* Copyright (C) 2012-2013 KO GmbH @@ -1705,9 +1701,9 @@ void 0),m())):(b.emit(gui.ClickHandler.signalSingleClick,h),e=1,c={x:h.screenX,y @source: http://www.webodf.org/ @source: http://gitorious.org/webodf/webodf/ */ -gui.KeyboardHandler=function(){function m(b,c){c||(c=l.None);return b+":"+c}var l=gui.KeyboardHandler.Modifier,e=null,c={};this.setDefault=function(b){e=b};this.bind=function(b,e,a){b=m(b,e);runtime.assert(!1===c.hasOwnProperty(b),"tried to overwrite the callback handler of key combo: "+b);c[b]=a};this.unbind=function(b,e){var a=m(b,e);delete c[a]};this.reset=function(){e=null;c={}};this.handleEvent=function(b){var h=b.keyCode,a=l.None;b.metaKey&&(a|=l.Meta);b.ctrlKey&&(a|=l.Ctrl);b.altKey&&(a|=l.Alt); -b.shiftKey&&(a|=l.Shift);h=m(h,a);h=c[h];a=!1;h?a=h():null!==e&&(a=e(b));a&&(b.preventDefault?b.preventDefault():b.returnValue=!1)}};gui.KeyboardHandler.Modifier={None:0,Meta:1,Ctrl:2,Alt:4,Shift:8,MetaShift:9,CtrlShift:10,AltShift:12};gui.KeyboardHandler.KeyCode={Backspace:8,Tab:9,Clear:12,Enter:13,End:35,Home:36,Left:37,Up:38,Right:39,Down:40,Delete:46,A:65,B:66,C:67,D:68,E:69,F:70,G:71,H:72,I:73,J:74,K:75,L:76,M:77,N:78,O:79,P:80,Q:81,R:82,S:83,T:84,U:85,V:86,W:87,X:88,Y:89,Z:90};(function(){return gui.KeyboardHandler})(); -// Input 65 +gui.KeyboardHandler=function(){function l(b,c){c||(c=m.None);return b+":"+c}var m=gui.KeyboardHandler.Modifier,g=null,c={};this.setDefault=function(b){g=b};this.bind=function(b,g,a){b=l(b,g);runtime.assert(!1===c.hasOwnProperty(b),"tried to overwrite the callback handler of key combo: "+b);c[b]=a};this.unbind=function(b,g){var a=l(b,g);delete c[a]};this.reset=function(){g=null;c={}};this.handleEvent=function(b){var n=b.keyCode,a=m.None;b.metaKey&&(a|=m.Meta);b.ctrlKey&&(a|=m.Ctrl);b.altKey&&(a|=m.Alt); +b.shiftKey&&(a|=m.Shift);n=l(n,a);n=c[n];a=!1;n?a=n():null!==g&&(a=g(b));a&&(b.preventDefault?b.preventDefault():b.returnValue=!1)}};gui.KeyboardHandler.Modifier={None:0,Meta:1,Ctrl:2,Alt:4,Shift:8,MetaShift:9,CtrlShift:10,AltShift:12};gui.KeyboardHandler.KeyCode={Backspace:8,Tab:9,Clear:12,Enter:13,End:35,Home:36,Left:37,Up:38,Right:39,Down:40,Delete:46,A:65,B:66,C:67,D:68,E:69,F:70,G:71,H:72,I:73,J:74,K:75,L:76,M:77,N:78,O:79,P:80,Q:81,R:82,S:83,T:84,U:85,V:86,W:87,X:88,Y:89,Z:90};(function(){return gui.KeyboardHandler})(); +// Input 64 /* Copyright (C) 2013 KO GmbH @@ -1743,45 +1739,54 @@ b.shiftKey&&(a|=l.Shift);h=m(h,a);h=c[h];a=!1;h?a=h():null!==e&&(a=e(b));a&&(b.p @source: http://gitorious.org/webodf/webodf/ */ runtime.loadClass("odf.Namespaces");runtime.loadClass("xmldom.LSSerializer");runtime.loadClass("odf.OdfNodeFilter");runtime.loadClass("odf.TextSerializer"); -gui.Clipboard=function(){var m,l,e;this.setDataFromRange=function(c,b){var e=!0,a,n=c.clipboardData;a=runtime.getWindow();var f=b.startContainer.ownerDocument;!n&&a&&(n=a.clipboardData);n?(f=f.createElement("span"),f.appendChild(b.cloneContents()),a=n.setData("text/plain",l.writeToString(f)),e=e&&a,a=n.setData("text/html",m.writeToString(f,odf.Namespaces.namespaceMap)),e=e&&a,c.preventDefault()):e=!1;return e};m=new xmldom.LSSerializer;l=new odf.TextSerializer;e=new odf.OdfNodeFilter;m.filter=e;l.filter= -e}; +gui.Clipboard=function(){var l,m,g;this.setDataFromRange=function(c,b){var g=!0,a,e=c.clipboardData;a=runtime.getWindow();var f=b.startContainer.ownerDocument;!e&&a&&(e=a.clipboardData);e?(f=f.createElement("span"),f.appendChild(b.cloneContents()),a=e.setData("text/plain",m.writeToString(f)),g=g&&a,a=e.setData("text/html",l.writeToString(f,odf.Namespaces.namespaceMap)),g=g&&a,c.preventDefault()):g=!1;return g};l=new xmldom.LSSerializer;m=new odf.TextSerializer;g=new odf.OdfNodeFilter;l.filter=g;m.filter= +g}; +// Input 65 +/* + + Copyright (C) 2013 KO GmbH + + @licstart + The JavaScript code in this page is free software: you can redistribute it + and/or modify it under the terms of the GNU Affero General Public License + (GNU AGPL) as published by the Free Software Foundation, either version 3 of + the License, or (at your option) any later version. The code is distributed + WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU AGPL for more details. + + As additional permission under GNU AGPL version 3 section 7, you + may distribute non-source (e.g., minimized or compacted) forms of + that code without the copy of the GNU GPL normally required by + section 4, provided you include this license notice and a URL + through which recipients can access the Corresponding Source. + + As a special exception to the AGPL, any HTML file which merely makes function + calls to this code, and for that purpose includes it by reference shall be + deemed a separate work for copyright law purposes. In addition, the copyright + holders of this code give you permission to combine this code with free + software libraries that are released under the GNU LGPL. You may copy and + distribute such a system following the terms of the GNU AGPL for this code + and the LGPL for the libraries. If you modify this code, you may extend this + exception to your version of the code, but you are not obligated to do so. + If you do not wish to do so, delete this exception statement from your + version. + + This license applies to this entire compilation. + @licend + @source: http://www.webodf.org/ + @source: http://gitorious.org/webodf/webodf/ +*/ +runtime.loadClass("core.EventNotifier");runtime.loadClass("ops.OpApplyDirectStyling");runtime.loadClass("gui.StyleHelper"); +gui.DirectTextStyler=function(l,m){function g(a,b){for(var c=0,d=b[c];d&&a;)a=a[d],c+=1,d=b[c];return b.length===c?a:void 0}function c(a,b){var c=g(a[0],b);return a.every(function(a){return c===g(a,b)})?c:void 0}function b(){function a(b,c,d){b!==c&&(void 0===e&&(e={}),e[d]=c);return c}var b=w.getCursor(m),d=b&&b.getSelectedRange(),b=d&&u.getAppliedStyles(d),e;y=a(y,d?u.isBold(d):!1,"isBold");v=a(v,d?u.isItalic(d):!1,"isItalic");r=a(r,d?u.hasUnderline(d):!1,"hasUnderline");z=a(z,d?u.hasStrikeThrough(d): +!1,"hasStrikeThrough");d=b&&c(b,["style:text-properties","fo:font-size"]);G=a(G,d&&parseFloat(d),"fontSize");C=a(C,b&&c(b,["style:text-properties","style:font-name"]),"fontName");e&&A.emit(gui.DirectTextStyler.textStylingChanged,e)}function n(a){a.getMemberId()===m&&b()}function a(a){a===m&&b()}function e(a){a.getMemberId()===m&&b()}function f(){b()}function d(a){var c=w.getCursor(m);c&&w.getParagraphElement(c.getNode())===a.paragraphElement&&b()}function t(a,b){var c=w.getCursor(m);if(!c)return!1; +b(!a(c.getSelectedRange()));return!0}function k(a,b){var c=w.getCursorSelection(m),d=new ops.OpApplyDirectStyling,e={};e[a]=b;d.init({memberid:m,position:c.position,length:c.length,setProperties:{"style:text-properties":e}});l.enqueue(d)}function p(a){k("fo:font-weight",a?"bold":"normal")}function h(a){k("fo:font-style",a?"italic":"normal")}function q(a){k("style:text-underline-style",a?"solid":"none")}function s(a){k("style:text-line-through-style",a?"solid":"none")}var w=l.getOdtDocument(),u=new gui.StyleHelper(w.getFormatting()), +A=new core.EventNotifier([gui.DirectTextStyler.textStylingChanged]),y=!1,v=!1,r=!1,z=!1,G,C;this.setBold=p;this.setItalic=h;this.setHasUnderline=q;this.setHasStrikethrough=s;this.setFontSize=function(a){k("fo:font-size",a+"pt")};this.setFontName=function(a){k("style:font-name",a)};this.toggleBold=t.bind(this,u.isBold,p);this.toggleItalic=t.bind(this,u.isItalic,h);this.toggleUnderline=t.bind(this,u.hasUnderline,q);this.toggleStrikethrough=t.bind(this,u.hasStrikeThrough,s);this.isBold=function(){return y}; +this.isItalic=function(){return v};this.hasUnderline=function(){return r};this.hasStrikeThrough=function(){return z};this.fontSize=function(){return G};this.fontName=function(){return C};this.subscribe=function(a,b){A.subscribe(a,b)};this.unsubscribe=function(a,b){A.unsubscribe(a,b)};this.destroy=function(b){w.unsubscribe(ops.OdtDocument.signalCursorAdded,n);w.unsubscribe(ops.OdtDocument.signalCursorRemoved,a);w.unsubscribe(ops.OdtDocument.signalCursorMoved,e);w.unsubscribe(ops.OdtDocument.signalParagraphStyleModified, +f);w.unsubscribe(ops.OdtDocument.signalParagraphChanged,d);b()};w.subscribe(ops.OdtDocument.signalCursorAdded,n);w.subscribe(ops.OdtDocument.signalCursorRemoved,a);w.subscribe(ops.OdtDocument.signalCursorMoved,e);w.subscribe(ops.OdtDocument.signalParagraphStyleModified,f);w.subscribe(ops.OdtDocument.signalParagraphChanged,d);b()};gui.DirectTextStyler.textStylingChanged="textStyling/changed";(function(){return gui.DirectTextStyler})(); // Input 66 -runtime.loadClass("core.DomUtils");runtime.loadClass("core.Utils");runtime.loadClass("odf.OdfUtils");runtime.loadClass("ops.OpAddCursor");runtime.loadClass("ops.OpRemoveCursor");runtime.loadClass("ops.OpMoveCursor");runtime.loadClass("ops.OpInsertText");runtime.loadClass("ops.OpRemoveText");runtime.loadClass("ops.OpSplitParagraph");runtime.loadClass("ops.OpSetParagraphStyle");runtime.loadClass("ops.OpRemoveAnnotation");runtime.loadClass("gui.ClickHandler");runtime.loadClass("gui.Clipboard");runtime.loadClass("gui.KeyboardHandler"); -runtime.loadClass("gui.StyleHelper"); -gui.SessionController=function(){gui.SessionController=function(m,l){function e(a,b,c,d){var e="on"+b,f=!1;a.attachEvent&&(f=a.attachEvent(e,c));!f&&a.addEventListener&&(a.addEventListener(b,c,!1),f=!0);f&&!d||!a.hasOwnProperty(e)||(a[e]=c)}function c(a,b,c){var d="on"+b;a.detachEvent&&a.detachEvent(d,c);a.removeEventListener&&a.removeEventListener(b,c,!1);a[d]===c&&(a[d]=null)}function b(a){a.preventDefault?a.preventDefault():a.returnValue=!1}function h(a,b){var c=new ops.OpMoveCursor;c.init({memberid:l, -position:a,length:b||0});return c}function a(a,b){var c=gui.SelectionMover.createPositionIterator(z.getRootNode()),d=z.getOdfCanvas().getElement(),e;e=a;if(!e)return null;for(;e!==d&&!("urn:webodf:names:cursor"===e.namespaceURI&&"cursor"===e.localName||"urn:webodf:names:editinfo"===e.namespaceURI&&"editinfo"===e.localName);)if(e=e.parentNode,!e)return null;e!==d&&a!==e&&(a=e.parentNode,b=Array.prototype.indexOf.call(a.childNodes,e));c.setUnfilteredPosition(a,b);return z.getDistanceFromCursor(l,c.container(), -c.unfilteredDomOffset())}function n(a){var b=z.getOdfCanvas().getElement(),c=z.getRootNode(),d=0;b.compareDocumentPosition(a)&Node.DOCUMENT_POSITION_PRECEDING||(a=gui.SelectionMover.createPositionIterator(c),a.moveToEnd(),c=a.container(),d=a.unfilteredDomOffset());return{node:c,offset:d}}function f(b){za&&runtime.setTimeout(function(){var c;a:{var d=z.getOdfCanvas().getElement(),e=ca.getSelection(),f,g,k,p;if(null===e.anchorNode&&null===e.focusNode){c=b.clientX;f=b.clientY;g=z.getDOM();g.caretRangeFromPoint? -(c=g.caretRangeFromPoint(c,f),f={container:c.startContainer,offset:c.startOffset}):g.caretPositionFromPoint?(c=g.caretPositionFromPoint(c,f),f={container:c.offsetNode,offset:c.offset}):f=null;if(!f){c=null;break a}c=f.container;f=f.offset;g=c;e=f}else c=e.anchorNode,f=e.anchorOffset,g=e.focusNode,e=e.focusOffset;runtime.assert(null!==c&&null!==g,"anchorNode is null or focusNode is null");k=qa.containsNode(d,c);p=qa.containsNode(d,g);k||p?(k||(k=n(c),c=k.node,f=k.offset),p||(k=n(g),g=k.node,e=k.offset), -d.focus(),c={anchorNode:c,anchorOffset:f,focusNode:g,focusOffset:e}):c=null}null!==c&&(d=a(c.anchorNode,c.anchorOffset),f=c.focusNode===c.anchorNode&&c.focusOffset===c.anchorOffset?d:a(c.focusNode,c.focusOffset),null!==f&&0!==f||null!==d&&0!==d)&&(c=z.getCursorPosition(l),d=h(c+d,f-d),m.enqueue(d))},0)}function d(a){f(a)}function s(){var a=z.getOdfCanvas().getElement(),b=/[A-Za-z0-9]/,c=0,d=0,e,f;if(qa.containsNode(a,ca.getSelection().focusNode)){a=gui.SelectionMover.createPositionIterator(z.getRootNode()); -e=z.getCursor(l).getNode();for(a.setUnfilteredPosition(e,0);a.previousPosition();)if(f=a.getCurrentNode(),f.nodeType===Node.TEXT_NODE){f=f.data[a.unfilteredDomOffset()];if(!b.test(f))break;c-=1}else if(f.namespaceURI!==odf.Namespaces.textns||"span"!==f.localName)break;a.setUnfilteredPosition(e,0);do if(f=a.getCurrentNode(),f.nodeType===Node.TEXT_NODE){f=f.data[a.unfilteredDomOffset()];if(!b.test(f))break;d+=1}else if(f.namespaceURI!==odf.Namespaces.textns||"span"!==f.localName)break;while(a.nextPosition()); -if(0!==c||0!==d)b=z.getCursorPosition(l),c=h(b+c,Math.abs(c)+Math.abs(d)),m.enqueue(c)}}function k(){var a=z.getOdfCanvas().getElement(),b,c;qa.containsNode(a,ca.getSelection().focusNode)&&(c=z.getParagraphElement(z.getCursor(l).getNode()),a=z.getDistanceFromCursor(l,c,0),b=gui.SelectionMover.createPositionIterator(z.getRootNode()),b.moveToEndOfNode(c),c=z.getDistanceFromCursor(l,c,b.unfilteredDomOffset()),0!==a||0!==c)&&(b=z.getCursorPosition(l),a=h(b+a,Math.abs(a)+Math.abs(c)),m.enqueue(a))}function q(a){var b= -z.getCursorSelection(l),c=z.getCursor(l).getStepCounter();0!==a&&(a=0a.length&&(a.position+=a.length,a.length=-a.length); -return a}function V(a){var b=new ops.OpRemoveText;b.init({memberid:l,position:a.position,length:a.length});return b}function S(){var a=M(z.getCursorSelection(l)),b=null;0===a.length?0 + Copyright (C) 2013 KO GmbH @licstart The JavaScript code in this page is free software: you can redistribute it @@ -1813,7 +1818,43 @@ ga.subscribe(gui.ClickHandler.signalDoubleClick,s);ga.subscribe(gui.ClickHandler @source: http://www.webodf.org/ @source: http://gitorious.org/webodf/webodf/ */ -ops.MemberModel=function(){};ops.MemberModel.prototype.getMemberDetailsAndUpdates=function(m,l){};ops.MemberModel.prototype.unsubscribeMemberDetailsUpdates=function(m,l){};ops.MemberModel.prototype.close=function(m){}; +runtime.loadClass("core.EventNotifier");runtime.loadClass("core.Utils");runtime.loadClass("odf.OdfUtils");runtime.loadClass("ops.OpAddParagraphStyle");runtime.loadClass("ops.OpSetParagraphStyle");runtime.loadClass("gui.StyleHelper"); +gui.DirectParagraphStyler=function(l,m,g){function c(){function a(b,d,e){b!==d&&(void 0===c&&(c={}),c[e]=d);return d}var b=h.getCursor(m),b=b&&b.getSelectedRange(),c;A=a(A,b?w.isAlignedLeft(b):!1,"isAlignedLeft");y=a(y,b?w.isAlignedCenter(b):!1,"isAlignedCenter");v=a(v,b?w.isAlignedRight(b):!1,"isAlignedRight");r=a(r,b?w.isAlignedJustified(b):!1,"isAlignedJustified");c&&u.emit(gui.DirectParagraphStyler.paragraphStylingChanged,c)}function b(a){a.getMemberId()===m&&c()}function n(a){a===m&&c()}function a(a){a.getMemberId()=== +m&&c()}function e(){c()}function f(a){var b=h.getCursor(m);b&&h.getParagraphElement(b.getNode())===a.paragraphElement&&c()}function d(a){var b=h.getCursor(m).getSelectedRange(),c=h.getCursorPosition(m),b=s.getParagraphElements(b),d=h.getFormatting();b.forEach(function(b){var e=c+h.getDistanceFromCursor(m,b,0),f=b.getAttributeNS(odf.Namespaces.textns,"style-name");b=g.generateName();var k,e=e+1;f&&(k=d.createDerivedStyleObject(f,"paragraph",{}));k=a(k||{});f=new ops.OpAddParagraphStyle;f.init({memberid:m, +styleName:b,isAutomaticStyle:!0,setProperties:k});k=new ops.OpSetParagraphStyle;k.init({memberid:m,styleName:b,position:e});l.enqueue(f);l.enqueue(k)})}function t(a){d(function(b){return q.mergeObjects(b,a)})}function k(a){t({"style:paragraph-properties":{"fo:text-align":a}})}function p(a,b){var c=h.getFormatting().getDefaultTabStopDistance(),d=b["style:paragraph-properties"],d=(d=d&&d["fo:margin-left"])&&s.parseLength(d);return q.mergeObjects(b,{"style:paragraph-properties":{"fo:margin-left":d&& +d.unit===c.unit?d.value+a*c.value+d.unit:a*c.value+c.unit}})}var h=l.getOdtDocument(),q=new core.Utils,s=new odf.OdfUtils,w=new gui.StyleHelper(h.getFormatting()),u=new core.EventNotifier([gui.DirectParagraphStyler.paragraphStylingChanged]),A,y,v,r;this.isAlignedLeft=function(){return A};this.isAlignedCenter=function(){return y};this.isAlignedRight=function(){return v};this.isAlignedJustified=function(){return r};this.alignParagraphLeft=function(){k("left");return!0};this.alignParagraphCenter=function(){k("center"); +return!0};this.alignParagraphRight=function(){k("right");return!0};this.alignParagraphJustified=function(){k("justify");return!0};this.indent=function(){d(p.bind(null,1));return!0};this.outdent=function(){d(p.bind(null,-1));return!0};this.subscribe=function(a,b){u.subscribe(a,b)};this.unsubscribe=function(a,b){u.unsubscribe(a,b)};this.destroy=function(c){h.unsubscribe(ops.OdtDocument.signalCursorAdded,b);h.unsubscribe(ops.OdtDocument.signalCursorRemoved,n);h.unsubscribe(ops.OdtDocument.signalCursorMoved, +a);h.unsubscribe(ops.OdtDocument.signalParagraphStyleModified,e);h.unsubscribe(ops.OdtDocument.signalParagraphChanged,f);c()};h.subscribe(ops.OdtDocument.signalCursorAdded,b);h.subscribe(ops.OdtDocument.signalCursorRemoved,n);h.subscribe(ops.OdtDocument.signalCursorMoved,a);h.subscribe(ops.OdtDocument.signalParagraphStyleModified,e);h.subscribe(ops.OdtDocument.signalParagraphChanged,f);c()};gui.DirectParagraphStyler.paragraphStylingChanged="paragraphStyling/changed";(function(){return gui.DirectParagraphStyler})(); +// Input 67 +runtime.loadClass("core.DomUtils");runtime.loadClass("core.Utils");runtime.loadClass("odf.OdfUtils");runtime.loadClass("ops.OpAddCursor");runtime.loadClass("ops.OpRemoveCursor");runtime.loadClass("ops.OpMoveCursor");runtime.loadClass("ops.OpInsertText");runtime.loadClass("ops.OpRemoveText");runtime.loadClass("ops.OpSplitParagraph");runtime.loadClass("ops.OpSetParagraphStyle");runtime.loadClass("ops.OpRemoveAnnotation");runtime.loadClass("gui.Clipboard");runtime.loadClass("gui.KeyboardHandler");runtime.loadClass("gui.DirectTextStyler"); +runtime.loadClass("gui.DirectParagraphStyler"); +gui.SessionController=function(){gui.SessionController=function(l,m,g){function c(a,b,c,d){var e="on"+b,h=!1;a.attachEvent&&(h=a.attachEvent(e,c));!h&&a.addEventListener&&(a.addEventListener(b,c,!1),h=!0);h&&!d||!a.hasOwnProperty(e)||(a[e]=c)}function b(a,b,c){var d="on"+b;a.detachEvent&&a.detachEvent(d,c);a.removeEventListener&&a.removeEventListener(b,c,!1);a[d]===c&&(a[d]=null)}function n(a){a.preventDefault?a.preventDefault():a.returnValue=!1}function a(a,b){var c=new ops.OpMoveCursor;c.init({memberid:m, +position:a,length:b||0});return c}function e(a,b){var c=gui.SelectionMover.createPositionIterator(x.getRootNode()),d=x.getOdfCanvas().getElement(),e;e=a;if(!e)return null;for(;e!==d&&!("urn:webodf:names:cursor"===e.namespaceURI&&"cursor"===e.localName||"urn:webodf:names:editinfo"===e.namespaceURI&&"editinfo"===e.localName);)if(e=e.parentNode,!e)return null;e!==d&&a!==e&&(a=e.parentNode,b=Array.prototype.indexOf.call(a.childNodes,e));c.setUnfilteredPosition(a,b);return x.getDistanceFromCursor(m,c.container(), +c.unfilteredDomOffset())}function f(a){var b=x.getOdfCanvas().getElement(),c=x.getRootNode(),d=0;b.compareDocumentPosition(a)&Node.DOCUMENT_POSITION_PRECEDING||(a=gui.SelectionMover.createPositionIterator(c),a.moveToEnd(),c=a.container(),d=a.unfilteredDomOffset());return{node:c,offset:d}}function d(b){runtime.setTimeout(function(){var c;a:{var d=x.getOdfCanvas().getElement(),h=X.getSelection(),g,k,n,q;if(null===h.anchorNode&&null===h.focusNode){c=b.clientX;g=b.clientY;k=x.getDOM();k.caretRangeFromPoint? +(c=k.caretRangeFromPoint(c,g),g={container:c.startContainer,offset:c.startOffset}):k.caretPositionFromPoint?(c=k.caretPositionFromPoint(c,g),g={container:c.offsetNode,offset:c.offset}):g=null;if(!g){c=null;break a}c=g.container;g=g.offset;k=c;h=g}else c=h.anchorNode,g=h.anchorOffset,k=h.focusNode,h=h.focusOffset;runtime.assert(null!==c&&null!==k,"anchorNode is null or focusNode is null");n=T.containsNode(d,c);q=T.containsNode(d,k);n||q?(n||(n=f(c),c=n.node,g=n.offset),q||(n=f(k),k=n.node,h=n.offset), +d.focus(),c={anchorNode:c,anchorOffset:g,focusNode:k,focusOffset:h}):c=null}null!==c&&(d=e(c.anchorNode,c.anchorOffset),g=c.focusNode===c.anchorNode&&c.focusOffset===c.anchorOffset?d:e(c.focusNode,c.focusOffset),null!==g&&0!==g||null!==d&&0!==d)&&(c=x.getCursorPosition(m),d=a(c+d,g-d),l.enqueue(d))},0)}function t(a){d(a)}function k(b){var c=x.getCursorSelection(m),d=x.getCursor(m).getStepCounter();0!==b&&(b=0a.length&&(a.position+=a.length,a.length=-a.length);return a}function Q(a){var b=new ops.OpRemoveText;b.init({memberid:m,position:a.position,length:a.length});return b}function W(){var a=$(x.getCursorSelection(m)), +b=null;0===a.length?0 + Copyright (C) 2012-2013 KO GmbH @licstart The JavaScript code in this page is free software: you can redistribute it @@ -1885,11 +1926,11 @@ ops.TrivialMemberModel=function(){this.getMemberDetailsAndUpdates=function(m,l){ @source: http://www.webodf.org/ @source: http://gitorious.org/webodf/webodf/ */ -ops.OperationRouter=function(){};ops.OperationRouter.prototype.setOperationFactory=function(m){};ops.OperationRouter.prototype.setPlaybackFunction=function(m){};ops.OperationRouter.prototype.push=function(m){};ops.OperationRouter.prototype.close=function(m){};ops.OperationRouter.prototype.getHasLocalUnsyncedOpsAndUpdates=function(m){};ops.OperationRouter.prototype.unsubscribeHasLocalUnsyncedOpsUpdates=function(m){}; +ops.TrivialMemberModel=function(){this.getMemberDetailsAndUpdates=function(l,m){m(l,{memberid:l,fullname:"Unknown",color:"black",imageurl:"avatar-joe.png"})};this.unsubscribeMemberDetailsUpdates=function(l,m){};this.close=function(l){l()}}; // Input 70 /* - Copyright (C) 2012 KO GmbH + Copyright (C) 2013 KO GmbH @licstart The JavaScript code in this page is free software: you can redistribute it @@ -1921,11 +1962,47 @@ ops.OperationRouter=function(){};ops.OperationRouter.prototype.setOperationFacto @source: http://www.webodf.org/ @source: http://gitorious.org/webodf/webodf/ */ -ops.TrivialOperationRouter=function(){var m,l;this.setOperationFactory=function(e){m=e};this.setPlaybackFunction=function(e){l=e};this.push=function(e){e=e.spec();e.timestamp=(new Date).getTime();e=m.create(e);l(e)};this.close=function(e){e()};this.getHasLocalUnsyncedOpsAndUpdates=function(e){e(!0)};this.unsubscribeHasLocalUnsyncedOpsUpdates=function(e){}}; +ops.OperationRouter=function(){};ops.OperationRouter.prototype.setOperationFactory=function(l){};ops.OperationRouter.prototype.setPlaybackFunction=function(l){};ops.OperationRouter.prototype.push=function(l){};ops.OperationRouter.prototype.close=function(l){};ops.OperationRouter.prototype.getHasLocalUnsyncedOpsAndUpdates=function(l){};ops.OperationRouter.prototype.unsubscribeHasLocalUnsyncedOpsUpdates=function(l){}; // Input 71 -gui.EditInfoHandle=function(m){var l=[],e,c=m.ownerDocument,b=c.documentElement.namespaceURI;this.setEdits=function(h){l=h;var a,m,f,d;e.innerHTML="";for(h=0;h + + @licstart + The JavaScript code in this page is free software: you can redistribute it + and/or modify it under the terms of the GNU Affero General Public License + (GNU AGPL) as published by the Free Software Foundation, either version 3 of + the License, or (at your option) any later version. The code is distributed + WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU AGPL for more details. + + As additional permission under GNU AGPL version 3 section 7, you + may distribute non-source (e.g., minimized or compacted) forms of + that code without the copy of the GNU GPL normally required by + section 4, provided you include this license notice and a URL + through which recipients can access the Corresponding Source. + + As a special exception to the AGPL, any HTML file which merely makes function + calls to this code, and for that purpose includes it by reference shall be + deemed a separate work for copyright law purposes. In addition, the copyright + holders of this code give you permission to combine this code with free + software libraries that are released under the GNU LGPL. You may copy and + distribute such a system following the terms of the GNU AGPL for this code + and the LGPL for the libraries. If you modify this code, you may extend this + exception to your version of the code, but you are not obligated to do so. + If you do not wish to do so, delete this exception statement from your + version. + + This license applies to this entire compilation. + @licend + @source: http://www.webodf.org/ + @source: http://gitorious.org/webodf/webodf/ +*/ +ops.TrivialOperationRouter=function(){var l,m;this.setOperationFactory=function(g){l=g};this.setPlaybackFunction=function(g){m=g};this.push=function(g){g=g.spec();g.timestamp=(new Date).getTime();g=l.create(g);m(g)};this.close=function(g){g()};this.getHasLocalUnsyncedOpsAndUpdates=function(g){g(!0)};this.unsubscribeHasLocalUnsyncedOpsUpdates=function(g){}}; // Input 72 +gui.EditInfoHandle=function(l){var m=[],g,c=l.ownerDocument,b=c.documentElement.namespaceURI;this.setEdits=function(n){m=n;var a,e,f,d;g.innerHTML="";for(n=0;n @@ -1961,10 +2038,10 @@ d=c.createElementNS(b,"span"),d.className="editInfoTime",d.setAttributeNS("urn:w @source: http://gitorious.org/webodf/webodf/ */ runtime.loadClass("ops.EditInfo");runtime.loadClass("gui.EditInfoHandle"); -gui.EditInfoMarker=function(m,l){function e(b,c){return runtime.getWindow().setTimeout(function(){a.style.opacity=b},c)}var c=this,b,h,a,n,f;this.addEdit=function(b,c){var k=Date.now()-c;m.addEdit(b,c);h.setEdits(m.getSortedEdits());a.setAttributeNS("urn:webodf:names:editinfo","editinfo:memberid",b);if(n){var l=n;runtime.getWindow().clearTimeout(l)}f&&(l=f,runtime.getWindow().clearTimeout(l));1E4>k?(e(1,0),n=e(0.5,1E4-k),f=e(0.2,2E4-k)):1E4<=k&&2E4>k?(e(0.5,0),f=e(0.2,2E4-k)):e(0.2,0)};this.getEdits= -function(){return m.getEdits()};this.clearEdits=function(){m.clearEdits();h.setEdits([]);a.hasAttributeNS("urn:webodf:names:editinfo","editinfo:memberid")&&a.removeAttributeNS("urn:webodf:names:editinfo","editinfo:memberid")};this.getEditInfo=function(){return m};this.show=function(){a.style.display="block"};this.hide=function(){c.hideHandle();a.style.display="none"};this.showHandle=function(){h.show()};this.hideHandle=function(){h.hide()};this.destroy=function(c){b.removeChild(a);h.destroy(function(a){a? -c(a):m.destroy(c)})};(function(){var d=m.getOdtDocument().getDOM();a=d.createElementNS(d.documentElement.namespaceURI,"div");a.setAttribute("class","editInfoMarker");a.onmouseover=function(){c.showHandle()};a.onmouseout=function(){c.hideHandle()};b=m.getNode();b.appendChild(a);h=new gui.EditInfoHandle(b);l||c.hide()})()}; -// Input 73 +gui.EditInfoMarker=function(l,m){function g(b,c){return runtime.getWindow().setTimeout(function(){a.style.opacity=b},c)}var c=this,b,n,a,e,f;this.addEdit=function(b,c){var k=Date.now()-c;l.addEdit(b,c);n.setEdits(l.getSortedEdits());a.setAttributeNS("urn:webodf:names:editinfo","editinfo:memberid",b);if(e){var m=e;runtime.getWindow().clearTimeout(m)}f&&(m=f,runtime.getWindow().clearTimeout(m));1E4>k?(g(1,0),e=g(0.5,1E4-k),f=g(0.2,2E4-k)):1E4<=k&&2E4>k?(g(0.5,0),f=g(0.2,2E4-k)):g(0.2,0)};this.getEdits= +function(){return l.getEdits()};this.clearEdits=function(){l.clearEdits();n.setEdits([]);a.hasAttributeNS("urn:webodf:names:editinfo","editinfo:memberid")&&a.removeAttributeNS("urn:webodf:names:editinfo","editinfo:memberid")};this.getEditInfo=function(){return l};this.show=function(){a.style.display="block"};this.hide=function(){c.hideHandle();a.style.display="none"};this.showHandle=function(){n.show()};this.hideHandle=function(){n.hide()};this.destroy=function(c){b.removeChild(a);n.destroy(function(a){a? +c(a):l.destroy(c)})};(function(){var d=l.getOdtDocument().getDOM();a=d.createElementNS(d.documentElement.namespaceURI,"div");a.setAttribute("class","editInfoMarker");a.onmouseover=function(){c.showHandle()};a.onmouseout=function(){c.hideHandle()};b=l.getNode();b.appendChild(a);n=new gui.EditInfoHandle(b);m||c.hide()})()}; +// Input 74 /* Copyright (C) 2012-2013 KO GmbH @@ -2000,14 +2077,14 @@ c(a):m.destroy(c)})};(function(){var d=m.getOdtDocument().getDOM();a=d.createEle @source: http://gitorious.org/webodf/webodf/ */ runtime.loadClass("gui.Caret");runtime.loadClass("ops.TrivialMemberModel");runtime.loadClass("ops.EditInfo");runtime.loadClass("gui.EditInfoMarker");gui.SessionViewOptions=function(){this.caretBlinksOnRangeSelect=this.caretAvatarsInitiallyVisible=this.editInfoMarkersInitiallyVisible=!0}; -gui.SessionView=function(){return function(m,l,e){function c(a,b,c){function d(b,c,e){c=b+'[editinfo|memberid^="'+a+'"]'+e+c;a:{var f=s.firstChild;for(b=b+'[editinfo|memberid^="'+a+'"]'+e;f;){if(f.nodeType===Node.TEXT_NODE&&0===f.data.indexOf(b)){b=f;break a}f=f.nextSibling}b=null}b?b.data=c:s.appendChild(document.createTextNode(c))}d("div.editInfoMarker","{ background-color: "+c+"; }","");d("span.editInfoColor","{ background-color: "+c+"; }","");d("span.editInfoAuthor",'{ content: "'+b+'"; }',":before"); -d("dc|creator",'{ content: "'+b+'"; display: none;}',":before");d("dc|creator","{ background-color: "+c+"; }","")}function b(a){var b,c;for(c in q)q.hasOwnProperty(c)&&(b=q[c],a?b.show():b.hide())}function h(a){e.getCarets().forEach(function(b){a?b.showHandle():b.hideHandle()})}function a(a,b){var d=e.getCaret(a);b?(d&&(d.setAvatarImageUrl(b.imageurl),d.setColor(b.color)),c(a,b.fullname,b.color)):runtime.log('MemberModel sent undefined data for member "'+a+'".')}function n(b){var c=b.getMemberId(), -d=l.getMemberModel();e.registerCursor(b,p,r);a(c,null);d.getMemberDetailsAndUpdates(c,a);runtime.log("+++ View here +++ eagerly created an Caret for '"+c+"'! +++")}function f(b){var c=!1,d;for(d in q)if(q.hasOwnProperty(d)&&q[d].getEditInfo().getEdits().hasOwnProperty(b)){c=!0;break}c||l.getMemberModel().unsubscribeMemberDetailsUpdates(b,a)}function d(a){var b=a.paragraphElement,c=a.memberId;a=a.timeStamp;var d,e="",f=b.getElementsByTagNameNS(k,"editinfo")[0];f?(e=f.getAttributeNS(k,"id"),d=q[e]): -(e=Math.random().toString(),d=new ops.EditInfo(b,l.getOdtDocument()),d=new gui.EditInfoMarker(d,g),f=b.getElementsByTagNameNS(k,"editinfo")[0],f.setAttributeNS(k,"id",e),q[e]=d);d.addEdit(c,new Date(a))}var s,k="urn:webodf:names:editinfo",q={},g=void 0!==m.editInfoMarkersInitiallyVisible?Boolean(m.editInfoMarkersInitiallyVisible):!0,p=void 0!==m.caretAvatarsInitiallyVisible?Boolean(m.caretAvatarsInitiallyVisible):!0,r=void 0!==m.caretBlinksOnRangeSelect?Boolean(m.caretBlinksOnRangeSelect):!0;this.showEditInfoMarkers= -function(){g||(g=!0,b(g))};this.hideEditInfoMarkers=function(){g&&(g=!1,b(g))};this.showCaretAvatars=function(){p||(p=!0,h(p))};this.hideCaretAvatars=function(){p&&(p=!1,h(p))};this.getSession=function(){return l};this.getCaret=function(a){return e.getCaret(a)};this.destroy=function(b){var c=l.getOdtDocument(),g=l.getMemberModel(),h=Object.keys(q).map(function(a){return q[a]});c.subscribe(ops.OdtDocument.signalCursorAdded,n);c.subscribe(ops.OdtDocument.signalCursorRemoved,f);c.subscribe(ops.OdtDocument.signalParagraphChanged, -d);e.getCarets().forEach(function(b){g.unsubscribeMemberDetailsUpdates(b.getCursor().getMemberId(),a)});s.parentNode.removeChild(s);(function t(a,c){c?b(c):a @@ -2043,27 +2120,27 @@ s.type="text/css";s.media="screen, print, handheld, projection";s.appendChild(do @source: http://gitorious.org/webodf/webodf/ */ runtime.loadClass("gui.Caret"); -gui.CaretManager=function(m){function l(a){return d.hasOwnProperty(a)?d[a]:null}function e(){return Object.keys(d).map(function(a){return d[a]})}function c(){return m.getSession().getOdtDocument().getOdfCanvas().getElement()}function b(a){a===m.getInputMemberId()&&c().removeAttribute("tabindex");delete d[a]}function h(a){a=a.getMemberId();a===m.getInputMemberId()&&(a=l(a))&&a.refreshCursorBlinking()}function a(a){a.memberId===m.getInputMemberId()&&(a=l(a.memberId))&&a.ensureVisible()}function n(){var a= -l(m.getInputMemberId());a&&a.setFocus()}function f(){var a=l(m.getInputMemberId());a&&a.removeFocus()}var d={};this.registerCursor=function(a,b,e){var f=a.getMemberId(),h=c();b=new gui.Caret(a,b,e);d[f]=b;f===m.getInputMemberId()&&(runtime.log("Starting to track input on new cursor of "+f),a.handleUpdate=b.ensureVisible,h.setAttribute("tabindex",0),h.focus());return b};this.getCaret=l;this.getCarets=e;this.destroy=function(d){var f=m.getSession().getOdtDocument(),l=c(),g=e();f.unsubscribe(ops.OdtDocument.signalParagraphChanged, -a);f.unsubscribe(ops.OdtDocument.signalCursorMoved,h);f.unsubscribe(ops.OdtDocument.signalCursorRemoved,b);l.onfocus=null;l.onblur=null;(function r(a,b){b?d(b):ab?-1:b-1})};c.slideChange=function(b){var e=c.getPages(c.odf_canvas.odfContainer().rootElement),a=-1,m=0;e.forEach(function(b){b=b[1];b.hasAttribute("slide_current")&&(a=m,b.removeAttribute("slide_current"));m+=1});b=b(a,e.length);-1===b&&(b=a);e[b][1].setAttribute("slide_current", -"1");document.getElementById("pagelist").selectedIndex=b;"cont"===c.slide_mode&&l.scrollBy(0,e[b][1].getBoundingClientRect().top-30)};c.selectSlide=function(b){c.slideChange(function(c,a){return b>=a||0>b?-1:b})};c.scrollIntoContView=function(b){var e=c.getPages(c.odf_canvas.odfContainer().rootElement);0!==e.length&&l.scrollBy(0,e[b][1].getBoundingClientRect().top-30)};c.getPages=function(b){b=b.getElementsByTagNameNS(odf.Namespaces.drawns,"page");var c=[],a;for(a=0;a=a.rangeCount||!p)||(a=a.getRangeAt(0),p.setPoint(a.startContainer,a.startOffset))}function h(){var a=m.ownerDocument.defaultView.getSelection(),b,c;a.removeAllRanges();p&&p.node()&&(b=p.node(),c=b.ownerDocument.createRange(), -c.setStart(b,p.position()),c.collapse(!0),a.addRange(c))}function a(a){var d=a.charCode||a.keyCode;if(p=null,p&&37===d)b(),p.stepBackward(),h();else if(16<=d&&20>=d||33<=d&&40>=d)return;c(a)}function n(a){c(a)}function f(a){for(var b=a.firstChild;b&&b!==a;)b.nodeType===Node.ELEMENT_NODE&&f(b),b=b.nextSibling||b.parentNode;var c,d,e,b=a.attributes;c="";for(e=b.length-1;0<=e;e-=1)d=b.item(e),c=c+" "+d.nodeName+'="'+d.nodeValue+'"';a.setAttribute("customns_name",a.nodeName);a.setAttribute("customns_atts", -c);b=a.firstChild;for(d=/^\s*$/;b&&b!==a;)c=b,b=b.nextSibling||b.parentNode,c.nodeType===Node.TEXT_NODE&&d.test(c.nodeValue)&&c.parentNode.removeChild(c)}function d(a,b){for(var c=a.firstChild,e,f,g;c&&c!==a;){if(c.nodeType===Node.ELEMENT_NODE)for(d(c,b),e=c.attributes,g=e.length-1;0<=g;g-=1)f=e.item(g),"http://www.w3.org/2000/xmlns/"!==f.namespaceURI||b[f.nodeValue]||(b[f.nodeValue]=f.localName);c=c.nextSibling||c.parentNode}}function s(){var a=m.ownerDocument.createElement("style"),b;b={};d(m,b); -var c={},e,f,g=0;for(e in b)if(b.hasOwnProperty(e)&&e){f=b[e];if(!f||c.hasOwnProperty(f)||"xmlns"===f){do f="ns"+g,g+=1;while(c.hasOwnProperty(f));b[e]=f}c[f]=!0}a.type="text/css";b="@namespace customns url(customns);\n"+k;a.appendChild(m.ownerDocument.createTextNode(b));l=l.parentNode.replaceChild(a,l)}var k,q,g,p=null;m.id||(m.id="xml"+String(Math.random()).substring(2));q="#"+m.id+" ";k=q+"*,"+q+":visited, "+q+":link {display:block; margin: 0px; margin-left: 10px; font-size: medium; color: black; background: white; font-variant: normal; font-weight: normal; font-style: normal; font-family: sans-serif; text-decoration: none; white-space: pre-wrap; height: auto; width: auto}\n"+ -q+":before {color: blue; content: '<' attr(customns_name) attr(customns_atts) '>';}\n"+q+":after {color: blue; content: '';}\n"+q+"{overflow: auto;}\n";(function(b){e(b,"click",n);e(b,"keydown",a);e(b,"drop",c);e(b,"dragend",c);e(b,"beforepaste",c);e(b,"paste",c)})(m);this.updateCSS=s;this.setXML=function(a){a=a.documentElement||a;g=a=m.ownerDocument.importNode(a,!0);for(f(a);m.lastChild;)m.removeChild(m.lastChild);m.appendChild(a);s();p=new core.PositionIterator(a)};this.getXML= -function(){return g}}; +runtime.loadClass("xmldom.XPath");runtime.loadClass("odf.Namespaces"); +gui.PresenterUI=function(){var l=new xmldom.XPath,m=runtime.getWindow();return function(g){var c=this;c.setInitialSlideMode=function(){c.startSlideMode("single")};c.keyDownHandler=function(b){if(!b.target.isContentEditable&&"input"!==b.target.nodeName)switch(b.keyCode){case 84:c.toggleToolbar();break;case 37:case 8:c.prevSlide();break;case 39:case 32:c.nextSlide();break;case 36:c.firstSlide();break;case 35:c.lastSlide()}};c.root=function(){return c.odf_canvas.odfContainer().rootElement};c.firstSlide= +function(){c.slideChange(function(b,c){return 0})};c.lastSlide=function(){c.slideChange(function(b,c){return c-1})};c.nextSlide=function(){c.slideChange(function(b,c){return b+1b?-1:b-1})};c.slideChange=function(b){var g=c.getPages(c.odf_canvas.odfContainer().rootElement),a=-1,e=0;g.forEach(function(b){b=b[1];b.hasAttribute("slide_current")&&(a=e,b.removeAttribute("slide_current"));e+=1});b=b(a,g.length);-1===b&&(b=a);g[b][1].setAttribute("slide_current", +"1");document.getElementById("pagelist").selectedIndex=b;"cont"===c.slide_mode&&m.scrollBy(0,g[b][1].getBoundingClientRect().top-30)};c.selectSlide=function(b){c.slideChange(function(c,a){return b>=a||0>b?-1:b})};c.scrollIntoContView=function(b){var g=c.getPages(c.odf_canvas.odfContainer().rootElement);0!==g.length&&m.scrollBy(0,g[b][1].getBoundingClientRect().top-30)};c.getPages=function(b){b=b.getElementsByTagNameNS(odf.Namespaces.drawns,"page");var c=[],a;for(a=0;a=a.rangeCount||!q)||(a=a.getRangeAt(0),q.setPoint(a.startContainer,a.startOffset))}function n(){var a=l.ownerDocument.defaultView.getSelection(),b,c;a.removeAllRanges();q&&q.node()&&(b=q.node(),c=b.ownerDocument.createRange(), +c.setStart(b,q.position()),c.collapse(!0),a.addRange(c))}function a(a){var d=a.charCode||a.keyCode;if(q=null,q&&37===d)b(),q.stepBackward(),n();else if(16<=d&&20>=d||33<=d&&40>=d)return;c(a)}function e(a){c(a)}function f(a){for(var b=a.firstChild;b&&b!==a;)b.nodeType===Node.ELEMENT_NODE&&f(b),b=b.nextSibling||b.parentNode;var c,d,e,b=a.attributes;c="";for(e=b.length-1;0<=e;e-=1)d=b.item(e),c=c+" "+d.nodeName+'="'+d.nodeValue+'"';a.setAttribute("customns_name",a.nodeName);a.setAttribute("customns_atts", +c);b=a.firstChild;for(d=/^\s*$/;b&&b!==a;)c=b,b=b.nextSibling||b.parentNode,c.nodeType===Node.TEXT_NODE&&d.test(c.nodeValue)&&c.parentNode.removeChild(c)}function d(a,b){for(var c=a.firstChild,e,h,f;c&&c!==a;){if(c.nodeType===Node.ELEMENT_NODE)for(d(c,b),e=c.attributes,f=e.length-1;0<=f;f-=1)h=e.item(f),"http://www.w3.org/2000/xmlns/"!==h.namespaceURI||b[h.nodeValue]||(b[h.nodeValue]=h.localName);c=c.nextSibling||c.parentNode}}function t(){var a=l.ownerDocument.createElement("style"),b;b={};d(l,b); +var c={},e,h,f=0;for(e in b)if(b.hasOwnProperty(e)&&e){h=b[e];if(!h||c.hasOwnProperty(h)||"xmlns"===h){do h="ns"+f,f+=1;while(c.hasOwnProperty(h));b[e]=h}c[h]=!0}a.type="text/css";b="@namespace customns url(customns);\n"+k;a.appendChild(l.ownerDocument.createTextNode(b));m=m.parentNode.replaceChild(a,m)}var k,p,h,q=null;l.id||(l.id="xml"+String(Math.random()).substring(2));p="#"+l.id+" ";k=p+"*,"+p+":visited, "+p+":link {display:block; margin: 0px; margin-left: 10px; font-size: medium; color: black; background: white; font-variant: normal; font-weight: normal; font-style: normal; font-family: sans-serif; text-decoration: none; white-space: pre-wrap; height: auto; width: auto}\n"+ +p+":before {color: blue; content: '<' attr(customns_name) attr(customns_atts) '>';}\n"+p+":after {color: blue; content: '';}\n"+p+"{overflow: auto;}\n";(function(b){g(b,"click",e);g(b,"keydown",a);g(b,"drop",c);g(b,"dragend",c);g(b,"beforepaste",c);g(b,"paste",c)})(l);this.updateCSS=t;this.setXML=function(a){a=a.documentElement||a;h=a=l.ownerDocument.importNode(a,!0);for(f(a);l.lastChild;)l.removeChild(l.lastChild);l.appendChild(a);t();q=new core.PositionIterator(a)};this.getXML= +function(){return h}}; +// Input 78 /* Copyright (C) 2013 KO GmbH @@ -2098,9 +2175,9 @@ function(){return g}}; @source: http://www.webodf.org/ @source: http://gitorious.org/webodf/webodf/ */ -gui.UndoManager=function(){};gui.UndoManager.prototype.subscribe=function(m,l){};gui.UndoManager.prototype.unsubscribe=function(m,l){};gui.UndoManager.prototype.setOdtDocument=function(m){};gui.UndoManager.prototype.saveInitialState=function(){};gui.UndoManager.prototype.resetInitialState=function(){};gui.UndoManager.prototype.setPlaybackFunction=function(m){};gui.UndoManager.prototype.hasUndoStates=function(){};gui.UndoManager.prototype.hasRedoStates=function(){}; -gui.UndoManager.prototype.moveForward=function(m){};gui.UndoManager.prototype.moveBackward=function(m){};gui.UndoManager.prototype.onOperationExecuted=function(m){};gui.UndoManager.signalUndoStackChanged="undoStackChanged";gui.UndoManager.signalUndoStateCreated="undoStateCreated";gui.UndoManager.signalUndoStateModified="undoStateModified";(function(){return gui.UndoManager})(); -// Input 78 +gui.UndoManager=function(){};gui.UndoManager.prototype.subscribe=function(l,m){};gui.UndoManager.prototype.unsubscribe=function(l,m){};gui.UndoManager.prototype.setOdtDocument=function(l){};gui.UndoManager.prototype.saveInitialState=function(){};gui.UndoManager.prototype.resetInitialState=function(){};gui.UndoManager.prototype.setPlaybackFunction=function(l){};gui.UndoManager.prototype.hasUndoStates=function(){};gui.UndoManager.prototype.hasRedoStates=function(){}; +gui.UndoManager.prototype.moveForward=function(l){};gui.UndoManager.prototype.moveBackward=function(l){};gui.UndoManager.prototype.onOperationExecuted=function(l){};gui.UndoManager.signalUndoStackChanged="undoStackChanged";gui.UndoManager.signalUndoStateCreated="undoStateCreated";gui.UndoManager.signalUndoStateModified="undoStateModified";(function(){return gui.UndoManager})(); +// Input 79 /* Copyright (C) 2013 KO GmbH @@ -2135,9 +2212,9 @@ gui.UndoManager.prototype.moveForward=function(m){};gui.UndoManager.prototype.mo @source: http://www.webodf.org/ @source: http://gitorious.org/webodf/webodf/ */ -gui.UndoStateRules=function(){function m(e){return e.spec().optype}function l(e){switch(m(e)){case "MoveCursor":case "AddCursor":case "RemoveCursor":return!1;default:return!0}}this.getOpType=m;this.isEditOperation=l;this.isPartOfOperationSet=function(e,c){if(l(e)){if(0===c.length)return!0;var b;if(b=l(c[c.length-1]))a:{b=c.filter(l);var h=m(e),a;b:switch(h){case "RemoveText":case "InsertText":a=!0;break b;default:a=!1}if(a&&h===m(b[0])){if(1===b.length){b=!0;break a}h=b[b.length-2].spec().position; -b=b[b.length-1].spec().position;a=e.spec().position;if(b===a-(b-h)){b=!0;break a}}b=!1}return b}return!0}}; -// Input 79 +gui.UndoStateRules=function(){function l(g){return g.spec().optype}function m(g){switch(l(g)){case "MoveCursor":case "AddCursor":case "RemoveCursor":return!1;default:return!0}}this.getOpType=l;this.isEditOperation=m;this.isPartOfOperationSet=function(g,c){if(m(g)){if(0===c.length)return!0;var b;if(b=m(c[c.length-1]))a:{b=c.filter(m);var n=l(g),a;b:switch(n){case "RemoveText":case "InsertText":a=!0;break b;default:a=!1}if(a&&n===l(b[0])){if(1===b.length){b=!0;break a}n=b[b.length-2].spec().position; +b=b[b.length-1].spec().position;a=g.spec().position;if(b===a-(b-n)){b=!0;break a}}b=!1}return b}return!0}}; +// Input 80 /* Copyright (C) 2013 KO GmbH @@ -2173,13 +2250,13 @@ b=b[b.length-1].spec().position;a=e.spec().position;if(b===a-(b-h)){b=!0;break a @source: http://gitorious.org/webodf/webodf/ */ runtime.loadClass("core.DomUtils");runtime.loadClass("gui.UndoManager");runtime.loadClass("gui.UndoStateRules"); -gui.TrivialUndoManager=function(m){function l(){r.emit(gui.UndoManager.signalUndoStackChanged,{undoAvailable:a.hasUndoStates(),redoAvailable:a.hasRedoStates()})}function e(){q!==d&&q!==g[g.length-1]&&g.push(q)}function c(a){var b=a.previousSibling||a.nextSibling;a.parentNode.removeChild(a);n.normalizeTextNodes(b)}function b(a){return Object.keys(a).map(function(b){return a[b]})}function h(a){function c(a){var b=a.spec();if(f[b.memberid])switch(b.optype){case "AddCursor":d[b.memberid]||(d[b.memberid]= -a,delete f[b.memberid],g-=1);break;case "MoveCursor":e[b.memberid]||(e[b.memberid]=a)}}var d={},e={},f={},g,h=a.pop();k.getCursors().forEach(function(a){f[a.getMemberId()]=!0});for(g=Object.keys(f).length;h&&0 @@ -2215,22 +2292,23 @@ b.refreshCSS(),q=g[g.length-1]||d,l());return e}};gui.TrivialUndoManager.signalD @source: http://gitorious.org/webodf/webodf/ */ runtime.loadClass("core.EventNotifier");runtime.loadClass("odf.OdfUtils");runtime.loadClass("gui.SelectionMover");runtime.loadClass("gui.StyleHelper");runtime.loadClass("core.PositionFilterChain"); -ops.OdtDocument=function(m){function l(){var a=m.odfContainer().getContentElement(),b=a&&a.localName;runtime.assert("text"===b,"Unsupported content element type '"+b+"'for OdtDocument");return a}function e(a){function b(a){for(;!(a.namespaceURI===odf.Namespaces.officens&&"text"===a.localName||a.namespaceURI===odf.Namespaces.officens&&"annotation"===a.localName);)a=a.parentNode;return a}this.acceptPosition=function(c){c=c.container();var d=f[a].getNode();return b(c)===b(d)?s:k}}function c(a){var b= -gui.SelectionMover.createPositionIterator(l());for(a+=1;0=e;e+=1){b=a.container();d=a.unfilteredDomOffset();if(b.nodeType===Node.TEXT_NODE&&" "===b.data[d]&&n.isSignificantWhitespace(b, -d)){runtime.assert(" "===b.data[d],"upgradeWhitespaceToElement: textNode.data[offset] should be a literal space");var f=b.ownerDocument.createElementNS("urn:oasis:names:tc:opendocument:xmlns:text:1.0","text:s");f.appendChild(b.ownerDocument.createTextNode(" "));b.deleteData(d,1);0= 0");1===q.acceptPosition(d)?(h=d.container(),h.nodeType===Node.TEXT_NODE&&(e=h,k=0)):b+=1;for(;0=f;f+=1){b=a.container();d=a.unfilteredDomOffset();if(b.nodeType===Node.TEXT_NODE&&" "===b.data[d]&& +e.isSignificantWhitespace(b,d)){runtime.assert(" "===b.data[d],"upgradeWhitespaceToElement: textNode.data[offset] should be a literal space");var g=b.ownerDocument.createElementNS("urn:oasis:names:tc:opendocument:xmlns:text:1.0","text:s");g.appendChild(b.ownerDocument.createTextNode(" "));b.deleteData(d,1);0= 0");1===p.acceptPosition(d)?(g=d.container(),g.nodeType===Node.TEXT_NODE&&(e=g,k=0)):b+=1;for(;0 @@ -2266,7 +2344,7 @@ ops.OdtDocument.signalCursorRemoved="cursor/removed";ops.OdtDocument.signalCurso @source: http://gitorious.org/webodf/webodf/ */ runtime.loadClass("ops.TrivialMemberModel");runtime.loadClass("ops.TrivialOperationRouter");runtime.loadClass("ops.OperationFactory");runtime.loadClass("ops.OdtDocument"); -ops.Session=function(m){var l=new ops.OperationFactory,e=new ops.OdtDocument(m),c=new ops.TrivialMemberModel,b=null;this.setMemberModel=function(b){c=b};this.setOperationFactory=function(c){l=c;b&&b.setOperationFactory(l)};this.setOperationRouter=function(c){b=c;c.setPlaybackFunction(function(a){a.execute(e);e.emit(ops.OdtDocument.signalOperationExecuted,a)});c.setOperationFactory(l)};this.getMemberModel=function(){return c};this.getOperationFactory=function(){return l};this.getOdtDocument=function(){return e}; -this.enqueue=function(c){b.push(c)};this.close=function(h){b.close(function(a){a?h(a):c.close(function(a){a?h(a):e.close(h)})})};this.destroy=function(b){e.destroy(b)};this.setOperationRouter(new ops.TrivialOperationRouter)}; -// Input 82 +ops.Session=function(l){var m=new ops.OperationFactory,g=new ops.OdtDocument(l),c=new ops.TrivialMemberModel,b=null;this.setMemberModel=function(b){c=b};this.setOperationFactory=function(c){m=c;b&&b.setOperationFactory(m)};this.setOperationRouter=function(c){b=c;c.setPlaybackFunction(function(a){a.execute(g);g.emit(ops.OdtDocument.signalOperationExecuted,a)});c.setOperationFactory(m)};this.getMemberModel=function(){return c};this.getOperationFactory=function(){return m};this.getOdtDocument=function(){return g}; +this.enqueue=function(c){b.push(c)};this.close=function(l){b.close(function(a){a?l(a):c.close(function(a){a?l(a):g.close(l)})})};this.destroy=function(b){g.destroy(b)};this.setOperationRouter(new ops.TrivialOperationRouter)}; +// Input 83 var webodf_css="@namespace draw url(urn:oasis:names:tc:opendocument:xmlns:drawing:1.0);\n@namespace fo url(urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0);\n@namespace office url(urn:oasis:names:tc:opendocument:xmlns:office:1.0);\n@namespace presentation url(urn:oasis:names:tc:opendocument:xmlns:presentation:1.0);\n@namespace style url(urn:oasis:names:tc:opendocument:xmlns:style:1.0);\n@namespace svg url(urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0);\n@namespace table url(urn:oasis:names:tc:opendocument:xmlns:table:1.0);\n@namespace text url(urn:oasis:names:tc:opendocument:xmlns:text:1.0);\n@namespace runtimens url(urn:webodf); /* namespace for runtime only */\n@namespace cursor url(urn:webodf:names:cursor);\n@namespace editinfo url(urn:webodf:names:editinfo);\n@namespace annotation url(urn:webodf:names:annotation);\n@namespace dc url(http://purl.org/dc/elements/1.1/);\n\noffice|document > *, office|document-content > * {\n display: none;\n}\noffice|body, office|document {\n display: inline-block;\n position: relative;\n}\n\ntext|p, text|h {\n display: block;\n padding: 0;\n margin: 0;\n line-height: normal;\n position: relative;\n min-height: 1.3em; /* prevent empty paragraphs and headings from collapsing if they are empty */\n}\n*[runtimens|containsparagraphanchor] {\n position: relative;\n}\ntext|s {\n white-space: pre;\n}\ntext|tab {\n display: inline;\n white-space: pre;\n}\ntext|line-break {\n content: \" \";\n display: block;\n}\ntext|tracked-changes {\n /*Consumers that do not support change tracking, should ignore changes.*/\n display: none;\n}\noffice|binary-data {\n display: none;\n}\noffice|text {\n display: block;\n text-align: left;\n overflow: visible;\n word-wrap: break-word;\n}\n\noffice|text::selection {\n /** Let's not draw selection highlight that overflows into the office|text\n * node when selecting content across several paragraphs\n */\n background: transparent;\n}\noffice|text * draw|text-box {\n /** only for text documents */\n display: block;\n border: 1px solid #d3d3d3;\n}\noffice|spreadsheet {\n display: block;\n border-collapse: collapse;\n empty-cells: show;\n font-family: sans-serif;\n font-size: 10pt;\n text-align: left;\n page-break-inside: avoid;\n overflow: hidden;\n}\noffice|presentation {\n display: inline-block;\n text-align: left;\n}\n#shadowContent {\n display: inline-block;\n text-align: left;\n}\ndraw|page {\n display: block;\n position: relative;\n overflow: hidden;\n}\npresentation|notes, presentation|footer-decl, presentation|date-time-decl {\n display: none;\n}\n@media print {\n draw|page {\n border: 1pt solid black;\n page-break-inside: avoid;\n }\n presentation|notes {\n /*TODO*/\n }\n}\noffice|spreadsheet text|p {\n border: 0px;\n padding: 1px;\n margin: 0px;\n}\noffice|spreadsheet table|table {\n margin: 3px;\n}\noffice|spreadsheet table|table:after {\n /* show sheet name the end of the sheet */\n /*content: attr(table|name);*/ /* gives parsing error in opera */\n}\noffice|spreadsheet table|table-row {\n counter-increment: row;\n}\noffice|spreadsheet table|table-row:before {\n width: 3em;\n background: #cccccc;\n border: 1px solid black;\n text-align: center;\n content: counter(row);\n display: table-cell;\n}\noffice|spreadsheet table|table-cell {\n border: 1px solid #cccccc;\n}\ntable|table {\n display: table;\n}\ndraw|frame table|table {\n width: 100%;\n height: 100%;\n background: white;\n}\ntable|table-header-rows {\n display: table-header-group;\n}\ntable|table-row {\n display: table-row;\n}\ntable|table-column {\n display: table-column;\n}\ntable|table-cell {\n width: 0.889in;\n display: table-cell;\n word-break: break-all; /* prevent long words from extending out the table cell */\n}\ndraw|frame {\n display: block;\n}\ndraw|image {\n display: block;\n width: 100%;\n height: 100%;\n top: 0px;\n left: 0px;\n background-repeat: no-repeat;\n background-size: 100% 100%;\n -moz-background-size: 100% 100%;\n}\n/* only show the first image in frame */\ndraw|frame > draw|image:nth-of-type(n+2) {\n display: none;\n}\ntext|list:before {\n display: none;\n content:\"\";\n}\ntext|list {\n counter-reset: list;\n}\ntext|list-item {\n display: block;\n}\ntext|number {\n display:none;\n}\n\ntext|a {\n color: blue;\n text-decoration: underline;\n cursor: pointer;\n}\ntext|note-citation {\n vertical-align: super;\n font-size: smaller;\n}\ntext|note-body {\n display: none;\n}\ntext|note:hover text|note-citation {\n background: #dddddd;\n}\ntext|note:hover text|note-body {\n display: block;\n left:1em;\n max-width: 80%;\n position: absolute;\n background: #ffffaa;\n}\nsvg|title, svg|desc {\n display: none;\n}\nvideo {\n width: 100%;\n height: 100%\n}\n\n/* below set up the cursor */\ncursor|cursor {\n display: inline;\n width: 0px;\n height: 1em;\n /* making the position relative enables the avatar to use\n the cursor as reference for its absolute position */\n position: relative;\n z-index: 1;\n}\ncursor|cursor > span {\n display: inline;\n position: absolute;\n top: 5%; /* push down the caret; 0px can do the job, 5% looks better, 10% is a bit over */\n height: 1em;\n border-left: 2px solid black;\n outline: none;\n}\n\ncursor|cursor > div {\n padding: 3px;\n box-shadow: 0px 0px 5px rgba(50, 50, 50, 0.75);\n border: none !important;\n border-radius: 5px;\n opacity: 0.3;\n}\n\ncursor|cursor > div > img {\n border-radius: 5px;\n}\n\ncursor|cursor > div.active {\n opacity: 0.8;\n}\n\ncursor|cursor > div:after {\n content: ' ';\n position: absolute;\n width: 0px;\n height: 0px;\n border-style: solid;\n border-width: 8.7px 5px 0 5px;\n border-color: black transparent transparent transparent;\n\n top: 100%;\n left: 43%;\n}\n\n\n.editInfoMarker {\n position: absolute;\n width: 10px;\n height: 100%;\n left: -20px;\n opacity: 0.8;\n top: 0;\n border-radius: 5px;\n background-color: transparent;\n box-shadow: 0px 0px 5px rgba(50, 50, 50, 0.75);\n}\n.editInfoMarker:hover {\n box-shadow: 0px 0px 8px rgba(0, 0, 0, 1);\n}\n\n.editInfoHandle {\n position: absolute;\n background-color: black;\n padding: 5px;\n border-radius: 5px;\n opacity: 0.8;\n box-shadow: 0px 0px 5px rgba(50, 50, 50, 0.75);\n bottom: 100%;\n margin-bottom: 10px;\n z-index: 3;\n left: -25px;\n}\n.editInfoHandle:after {\n content: ' ';\n position: absolute;\n width: 0px;\n height: 0px;\n border-style: solid;\n border-width: 8.7px 5px 0 5px;\n border-color: black transparent transparent transparent;\n\n top: 100%;\n left: 5px;\n}\n.editInfo {\n font-family: sans-serif;\n font-weight: normal;\n font-style: normal;\n text-decoration: none;\n color: white;\n width: 100%;\n height: 12pt;\n}\n.editInfoColor {\n float: left;\n width: 10pt;\n height: 10pt;\n border: 1px solid white;\n}\n.editInfoAuthor {\n float: left;\n margin-left: 5pt;\n font-size: 10pt;\n text-align: left;\n height: 12pt;\n line-height: 12pt;\n}\n.editInfoTime {\n float: right;\n margin-left: 30pt;\n font-size: 8pt;\n font-style: italic;\n color: yellow;\n height: 12pt;\n line-height: 12pt;\n}\n\n.annotationWrapper {\n display: inline;\n position: relative;\n}\n\n.annotationRemoveButton:before {\n content: '\u00d7';\n color: white;\n padding: 5px;\n line-height: 1em;\n}\n\n.annotationRemoveButton {\n width: 20px;\n height: 20px;\n border-radius: 10px;\n background-color: black;\n box-shadow: 0px 0px 5px rgba(50, 50, 50, 0.75);\n position: absolute;\n top: -10px;\n left: -10px;\n z-index: 3;\n text-align: center;\n font-family: sans-serif;\n font-style: normal;\n font-weight: normal;\n text-decoration: none;\n font-size: 15px;\n}\n.annotationRemoveButton:hover {\n cursor: pointer;\n box-shadow: 0px 0px 5px rgba(0, 0, 0, 1);\n}\n\n.annotationNote {\n width: 4cm;\n position: absolute;\n display: inline;\n z-index: 10;\n}\n.annotationNote > office|annotation {\n display: block;\n text-align: left;\n}\n\n.annotationConnector {\n position: absolute;\n display: inline;\n z-index: 2;\n border-top: 1px dashed brown;\n}\n.annotationConnector.angular {\n -moz-transform-origin: left top;\n -webkit-transform-origin: left top;\n -ms-transform-origin: left top;\n transform-origin: left top;\n}\n.annotationConnector.horizontal {\n left: 0;\n}\n.annotationConnector.horizontal:before {\n content: '';\n display: inline;\n position: absolute;\n width: 0px;\n height: 0px;\n border-style: solid;\n border-width: 8.7px 5px 0 5px;\n border-color: brown transparent transparent transparent;\n top: -1px;\n left: -5px;\n}\n\noffice|annotation {\n width: 100%;\n height: 100%;\n display: none;\n background: rgb(198, 238, 184);\n background: -moz-linear-gradient(90deg, rgb(198, 238, 184) 30%, rgb(180, 196, 159) 100%);\n background: -webkit-linear-gradient(90deg, rgb(198, 238, 184) 30%, rgb(180, 196, 159) 100%);\n background: -o-linear-gradient(90deg, rgb(198, 238, 184) 30%, rgb(180, 196, 159) 100%);\n background: -ms-linear-gradient(90deg, rgb(198, 238, 184) 30%, rgb(180, 196, 159) 100%);\n background: linear-gradient(180deg, rgb(198, 238, 184) 30%, rgb(180, 196, 159) 100%);\n box-shadow: 0 3px 4px -3px #ccc;\n}\n\noffice|annotation > dc|creator {\n display: block;\n font-size: 10pt;\n font-weight: normal;\n font-style: normal;\n font-family: sans-serif;\n color: white;\n background-color: brown;\n padding: 4px;\n}\noffice|annotation > dc|date {\n display: block;\n font-size: 10pt;\n font-weight: normal;\n font-style: normal;\n font-family: sans-serif;\n border: 4px solid transparent;\n}\noffice|annotation > text|list {\n display: block;\n padding: 5px;\n}\n\n/* This is very temporary CSS. This must go once\n * we start bundling webodf-default ODF styles for annotations.\n */\noffice|annotation text|p {\n font-size: 10pt;\n color: black;\n font-weight: normal;\n font-style: normal;\n text-decoration: none;\n font-family: sans-serif;\n}\n\ndc|*::selection {\n background: transparent;\n}\ndc|*::-moz-selection {\n background: transparent;\n}\n\n#annotationsPane {\n background-color: #EAEAEA;\n width: 4cm;\n height: 100%;\n display: none;\n position: absolute;\n outline: 1px solid #ccc;\n}\n\n.annotationHighlight {\n background-color: yellow;\n position: relative;\n}\n";