diff --git a/js/3rdparty/webodf/editor/Editor.js b/js/3rdparty/webodf/editor/Editor.js index b2fc8115..3ffb0ba6 100644 --- a/js/3rdparty/webodf/editor/Editor.js +++ b/js/3rdparty/webodf/editor/Editor.js @@ -127,6 +127,36 @@ define("webodf/editor/Editor", [ initDocLoading(docUrl, memberId, editorReadyCallback); }; + /** + * Closes a single-user document, and does cleanup. + * @param {!function(!Object=)} callback, passing an error object in case of error + * @return undefined; + */ + this.closeDocument = function (callback) { + runtime.assert(session, "session should exist here."); + session.close(function (err) { + if (err) { + callback(err); + } else { + editorSession.destroy(function (err) { + if (err) { + callback(err); + } else { + editorSession = undefined; + session.destroy(function (err) { + if (err) { + callback(err); + } else { + session = undefined; + callback(); + } + }); + } + }); + } + }); + }; + /** * @param {!string} filename * @param {?function()} callback @@ -188,34 +218,26 @@ define("webodf/editor/Editor", [ * @param {!function(!Object=)} callback, passing an error object in case of error * @return {undefined} */ - this.close = function (callback) { + this.closeSession = function (callback) { runtime.assert(session, "session should exist here."); // TODO: there is a better pattern for this instead of unrolling - editorSession.close(function(err) { + session.close(function(err) { if (err) { callback(err); } else { - session.close(function(err) { + // now also destroy session, will not be reused for new document + memberListView.setEditorSession(undefined); + editorSession.destroy(function(err) { if (err) { callback(err); } else { - // now also destroy session, will not be reused for new document - if (memberListView) { - memberListView.setEditorSession(undefined); - } - editorSession.destroy(function(err) { + editorSession = undefined; + session.destroy(function(err) { if (err) { callback(err); } else { - editorSession = undefined; - session.destroy(function(err) { - if (err) { - callback(err); - } else { - session = undefined; - callback(); - } - }); + session = undefined; + callback(); } }); } @@ -294,7 +316,7 @@ define("webodf/editor/Editor", [ canvasElement = document.getElementById("canvas"), memberListElement = document.getElementById('memberList'), collabEditing = Boolean(server), - directStylingEnabled = (! collabEditing) || args.unstableFeaturesEnabled, + directParagraphStylingEnabled = (! collabEditing) || args.unstableFeaturesEnabled, imageInsertingEnabled = (! collabEditing) || args.unstableFeaturesEnabled, // annotations not yet properly supported for OT annotationsEnabled = (! collabEditing) || args.unstableFeaturesEnabled, @@ -360,7 +382,7 @@ define("webodf/editor/Editor", [ loadOdtFile: loadOdtFile, saveOdtFile: saveOdtFile, close: close, - directStylingEnabled: directStylingEnabled, + directParagraphStylingEnabled: directParagraphStylingEnabled, imageInsertingEnabled: imageInsertingEnabled, annotationsEnabled: annotationsEnabled, undoRedoEnabled: undoRedoEnabled @@ -380,7 +402,7 @@ define("webodf/editor/Editor", [ session = new ops.Session(odfCanvas); editorSession = new EditorSession(session, pendingMemberId, { viewOptions: viewOptions, - directStylingEnabled: directStylingEnabled, + directParagraphStylingEnabled: directParagraphStylingEnabled, imageInsertingEnabled: imageInsertingEnabled }); if (undoRedoEnabled) { diff --git a/js/3rdparty/webodf/editor/EditorSession.js b/js/3rdparty/webodf/editor/EditorSession.js index 746d8a7b..575eb89d 100644 --- a/js/3rdparty/webodf/editor/EditorSession.js +++ b/js/3rdparty/webodf/editor/EditorSession.js @@ -65,7 +65,7 @@ define("webodf/editor/EditorSession", [ * Instantiate a new editor session attached to an existing operation session * @param {!ops.Session} session * @param {!string} localMemberId - * @param {{viewOptions:gui.SessionViewOptions,directStylingEnabled:boolean}} config + * @param {{viewOptions:gui.SessionViewOptions,directParagraphStylingEnabled:boolean}} config * @constructor */ var EditorSession = function EditorSession(session, localMemberId, config) { @@ -512,28 +512,6 @@ define("webodf/editor/EditorSession", [ self.sessionController.getTextManipulator().removeCurrentSelection(); self.sessionController.getImageManager().insertImage(mimetype, content, width, height); }; - /** - * @param {!function(!Object=)} callback, passing an error object in case of error - * @return {undefined} - */ - this.close = function (callback) { - callback(); - /* - self.sessionView.close(function(err) { - if (err) { - callback(err); - } else { - caretManager.close(function(err) { - if (err) { - callback(err); - } else { - self.sessionController.close(callback); - } - }); - } - }); - */ - }; /** * @param {!function(!Object=)} callback, passing an error object in case of error @@ -592,7 +570,7 @@ define("webodf/editor/EditorSession", [ head.appendChild(fontStyles); self.sessionController = new gui.SessionController(session, localMemberId, shadowCursor, { - directStylingEnabled: config.directStylingEnabled + directParagraphStylingEnabled: config.directParagraphStylingEnabled }); caretManager = new gui.CaretManager(self.sessionController); selectionViewManager = new gui.SelectionViewManager(); diff --git a/js/3rdparty/webodf/editor/Tools.js b/js/3rdparty/webodf/editor/Tools.js index f4a6ccb0..8ab50b2b 100644 --- a/js/3rdparty/webodf/editor/Tools.js +++ b/js/3rdparty/webodf/editor/Tools.js @@ -141,17 +141,15 @@ define("webodf/editor/Tools", [ } // Simple Style Selector [B, I, U, S] - if (args.directStylingEnabled) { - simpleStyles = new SimpleStyles(function (widget) { - widget.placeAt(toolbar); - widget.startup(); - }); - sessionSubscribers.push(simpleStyles); - simpleStyles.onToolDone = onToolDone; - } + simpleStyles = new SimpleStyles(function (widget) { + widget.placeAt(toolbar); + widget.startup(); + }); + sessionSubscribers.push(simpleStyles); + simpleStyles.onToolDone = onToolDone; // Paragraph direct alignment buttons - if (args.directStylingEnabled) { + if (args.directParagraphStylingEnabled) { paragraphAlignment = new ParagraphAlignment(function (widget) { widget.placeAt(toolbar); widget.startup(); diff --git a/js/3rdparty/webodf/webodf-debug.js b/js/3rdparty/webodf/webodf-debug.js index 6c1479de..3e014e51 100644 --- a/js/3rdparty/webodf/webodf-debug.js +++ b/js/3rdparty/webodf/webodf-debug.js @@ -3320,15 +3320,6 @@ core.Cursor = function Cursor(document, memberId) { } } } - function putIntoContainer(node, container, offset) { - runtime.assert(Boolean(container), "putCursorIntoContainer: invalid container"); - var n = container.firstChild; - while(n !== null && offset > 0) { - n = n.nextSibling; - offset -= 1 - } - container.insertBefore(node, n) - } function removeNode(node) { if(node.parentNode) { recentlyModifiedNodes.push(node.previousSibling); @@ -3337,14 +3328,11 @@ core.Cursor = function Cursor(document, memberId) { } } function putNode(node, container, offset) { - var text, element; if(container.nodeType === Node.TEXT_NODE) { - text = (container); - putIntoTextNode(node, text, offset) + putIntoTextNode(node, (container), offset) }else { if(container.nodeType === Node.ELEMENT_NODE) { - element = (container); - putIntoContainer(node, element, offset) + container.insertBefore(node, container.childNodes[offset]) } } recentlyModifiedNodes.push(node.previousSibling); @@ -3546,7 +3534,7 @@ core.UnitTestRunner = function UnitTestRunner() { var aatts = a.attributes, n = aatts.length, i, att, v; for(i = 0;i < n;i += 1) { att = aatts.item(i); - if(att.prefix !== "xmlns") { + if(att.prefix !== "xmlns" && att.namespaceURI !== "urn:webodf:names:steps") { v = b.getAttributeNS(att.namespaceURI, att.localName); if(!b.hasAttributeNS(att.namespaceURI, att.localName)) { testFailed("Attribute " + att.localName + " with value " + att.value + " was not present"); @@ -3562,23 +3550,32 @@ core.UnitTestRunner = function UnitTestRunner() { } function areNodesEqual(a, b) { if(a.nodeType !== b.nodeType) { - testFailed(a.nodeType + " should be " + b.nodeType); + testFailed("Nodetype '" + a.nodeType + "' should be '" + b.nodeType + "'"); return false } if(a.nodeType === Node.TEXT_NODE) { - return a.data === b.data - } - runtime.assert(a.nodeType === Node.ELEMENT_NODE, "Only textnodes and elements supported."); - if(a.namespaceURI !== b.namespaceURI || a.localName !== b.localName) { - testFailed(a.namespaceURI + " should be " + b.namespaceURI); + if(a.data === b.data) { + return true + } + testFailed("Textnode data '" + a.data + "' should be '" + b.data + "'"); return false } - if(!areAttributesEqual(a, b, false)) { + runtime.assert(a.nodeType === Node.ELEMENT_NODE, "Only textnodes and elements supported."); + if(a.namespaceURI !== b.namespaceURI) { + testFailed("namespace '" + a.namespaceURI + "' should be '" + b.namespaceURI + "'"); + return false + } + if(a.localName !== b.localName) { + testFailed("localName '" + a.localName + "' should be '" + b.localName + "'"); + return false + } + if(!areAttributesEqual((a), (b), false)) { return false } var an = a.firstChild, bn = b.firstChild; while(an) { if(!bn) { + testFailed("Nodetype '" + an.nodeType + "' is unexpected here."); return false } if(!areNodesEqual(an, bn)) { @@ -3588,6 +3585,7 @@ core.UnitTestRunner = function UnitTestRunner() { bn = bn.nextSibling } if(bn) { + testFailed("Nodetype '" + bn.nodeType + "' is missing here."); return false } return true @@ -3603,11 +3601,11 @@ core.UnitTestRunner = function UnitTestRunner() { return typeof actual === "number" && isNaN(actual) } if(Object.prototype.toString.call(expected) === Object.prototype.toString.call([])) { - return areArraysEqual(actual, expected) + return areArraysEqual((actual), (expected)) } if(typeof expected === "object" && typeof actual === "object") { if(expected.constructor === Element || expected.constructor === Node) { - return areNodesEqual(expected, actual) + return areNodesEqual((expected), (actual)) } return areObjectsEqual(expected, actual) } @@ -3797,18 +3795,22 @@ core.PositionIterator = function PositionIterator(root, whatToShow, filter, expa currentPos = type === Node.ELEMENT_NODE ? 1 : 0 } } + function previousNode() { + if(walker.previousSibling() === null) { + if(!walker.parentNode() || walker.currentNode === root) { + walker.firstChild(); + return false + } + currentPos = 0 + }else { + setAtEnd() + } + return true + } this.previousPosition = function() { var moved = true; if(currentPos === 0) { - if(walker.previousSibling() === null) { - if(!walker.parentNode() || walker.currentNode === root) { - walker.firstChild(); - return false - } - currentPos = 0 - }else { - setAtEnd() - } + moved = previousNode() }else { if(walker.currentNode.nodeType === Node.TEXT_NODE) { currentPos -= 1 @@ -3826,6 +3828,7 @@ core.PositionIterator = function PositionIterator(root, whatToShow, filter, expa } return moved }; + this.previousNode = previousNode; this.container = function() { var n = walker.currentNode, t = n.nodeType; if(currentPos === 0 && t !== Node.TEXT_NODE) { @@ -7122,10 +7125,15 @@ odf.TextSerializer = function TextSerializer() { } this.filter = null; this.writeToString = function(node) { + var plainText; if(!node) { return"" } - return serializeNode(node) + plainText = serializeNode(node); + if(plainText[plainText.length - 1] === "\n") { + plainText = plainText.substr(0, plainText.length - 1) + } + return plainText } }; /* @@ -7213,7 +7221,7 @@ odf.TextStyleApplicator = function TextStyleApplicator(objectNameGenerator, form return node.localName === "span" && node.namespaceURI === textns } function moveToNewSpan(startNode, limits) { - var document = startNode.ownerDocument, originalContainer = (startNode.parentNode), styledContainer, trailingContainer, moveTrailing, node, nextNode, loopGuard = new core.LoopWatchDog(1E3), styledNodes = []; + var document = startNode.ownerDocument, originalContainer = (startNode.parentNode), styledContainer, trailingContainer, moveTrailing, node, nextNode, loopGuard = new core.LoopWatchDog(1E4), styledNodes = []; if(!isTextSpan(originalContainer)) { styledContainer = document.createElementNS(textns, "text:span"); originalContainer.insertBefore(styledContainer, startNode); @@ -10585,17 +10593,12 @@ ops.OpMoveCursor = function OpMoveCursor() { selectionType = data.selectionType || ops.OdtCursor.RangeSelection }; this.execute = function(odtDocument) { - var cursor = odtDocument.getCursor(memberid), oldPosition = odtDocument.getCursorPosition(memberid), positionFilter = odtDocument.getPositionFilter(), number = position - oldPosition, stepsToSelectionStart, stepsToSelectionEnd, stepCounter; + var cursor = odtDocument.getCursor(memberid), selectedRange; if(!cursor) { return false } - stepCounter = cursor.getStepCounter(); - stepsToSelectionStart = stepCounter.countSteps(number, positionFilter); - cursor.move(stepsToSelectionStart); - if(length) { - stepsToSelectionEnd = stepCounter.countSteps(length, positionFilter); - cursor.move(stepsToSelectionEnd, true) - } + selectedRange = odtDocument.convertCursorToDomRange(position, length); + cursor.setSelectedRange(selectedRange, length >= 0); cursor.setSelectionType(selectionType); odtDocument.emit(ops.OdtDocument.signalCursorMoved, cursor); return true @@ -10774,7 +10777,7 @@ ops.OpInsertImage = function OpInsertImage() { return frameNode } this.execute = function(odtDocument) { - var odfCanvas = odtDocument.getOdfCanvas(), domPosition = odtDocument.getPositionInTextNode(position, memberid), textNode, refNode, paragraphElement, frameElement; + var odfCanvas = odtDocument.getOdfCanvas(), domPosition = odtDocument.getTextNodeAtStep(position, memberid), textNode, refNode, paragraphElement, frameElement; if(!domPosition) { return false } @@ -10783,6 +10786,7 @@ ops.OpInsertImage = function OpInsertImage() { refNode = domPosition.offset !== textNode.length ? textNode.splitText(domPosition.offset) : textNode.nextSibling; frameElement = createFrameElement(odtDocument.getDOM()); textNode.parentNode.insertBefore(frameElement, refNode); + odtDocument.emit(ops.OdtDocument.signalStepsInserted, {position:position, length:1}); if(textNode.length === 0) { textNode.parentNode.removeChild(textNode) } @@ -10912,11 +10916,12 @@ ops.OpInsertTable = function OpInsertTable() { return tableNode } this.execute = function(odtDocument) { - var domPosition = odtDocument.getPositionInTextNode(position), rootNode = odtDocument.getRootNode(), previousSibling, tableNode; + var domPosition = odtDocument.getTextNodeAtStep(position), rootNode = odtDocument.getRootNode(), previousSibling, tableNode; if(domPosition) { tableNode = createTableNode(odtDocument.getDOM()); previousSibling = odtDocument.getParagraphElement(domPosition.textNode); rootNode.insertBefore(tableNode, previousSibling.nextSibling); + odtDocument.emit(ops.OdtDocument.signalStepsInserted, {position:position, length:initialColumns * initialRows + 1}); odtDocument.getOdfCanvas().refreshSize(); odtDocument.emit(ops.OdtDocument.signalTableAdded, {tableElement:tableNode, memberId:memberid, timeStamp:timestamp}); odtDocument.getOdfCanvas().rerenderAnnotations(); @@ -10987,7 +10992,7 @@ ops.OpInsertText = function OpInsertText() { parentElement.insertBefore(ownerDocument.createTextNode(toInsertText), nextNode) } odtDocument.upgradeWhitespacesAtPosition(position); - domPosition = odtDocument.getPositionInTextNode(position, memberid); + domPosition = odtDocument.getTextNodeAtStep(position, memberid); if(domPosition) { previousNode = domPosition.textNode; nextNode = previousNode.nextSibling; @@ -11025,6 +11030,7 @@ ops.OpInsertText = function OpInsertText() { if(previousNode.length === 0) { previousNode.parentNode.removeChild(previousNode) } + odtDocument.emit(ops.OdtDocument.signalStepsInserted, {position:position, length:text.length}); if(position > 0) { if(position > 1) { odtDocument.downgradeWhitespacesAtPosition(position - 2) @@ -11086,7 +11092,7 @@ runtime.loadClass("odf.Namespaces"); runtime.loadClass("odf.OdfUtils"); runtime.loadClass("core.DomUtils"); ops.OpRemoveText = function OpRemoveText() { - var memberid, timestamp, position, length, odfUtils, domUtils, editinfons = "urn:webodf:names:editinfo", FILTER_ACCEPT = core.PositionFilter.FilterResult.FILTER_ACCEPT, odfNodeNamespaceMap = {}; + var memberid, timestamp, position, length, odfUtils, domUtils, editinfons = "urn:webodf:names:editinfo", odfNodeNamespaceMap = {}; this.init = function(data) { runtime.assert(data.length >= 0, "OpRemoveText only supports positive lengths"); memberid = data.memberid; @@ -11177,28 +11183,12 @@ ops.OpRemoveText = function OpRemoveText() { collapseRules.mergeChildrenIntoParent(source); return destination } - function stepsToRange(odtDocument) { - var iterator, filter = odtDocument.getPositionFilter(), startContainer, startOffset, endContainer, endOffset, remainingLength = length, range = odtDocument.getDOM().createRange(); - iterator = odtDocument.getIteratorAtPosition(position); - startContainer = iterator.container(); - startOffset = iterator.unfilteredDomOffset(); - while(remainingLength && iterator.nextPosition()) { - endContainer = iterator.container(); - endOffset = iterator.unfilteredDomOffset(); - if(filter.acceptPosition(iterator) === FILTER_ACCEPT) { - remainingLength -= 1 - } - } - range.setStart(startContainer, startOffset); - range.setEnd(endContainer, endOffset); - domUtils.splitBoundaries(range); - return range - } this.execute = function(odtDocument) { var paragraphElement, destinationParagraph, range, textNodes, paragraphs, cursor = odtDocument.getCursor(memberid), collapseRules = new CollapsingRules(odtDocument.getRootNode()); odtDocument.upgradeWhitespacesAtPosition(position); odtDocument.upgradeWhitespacesAtPosition(position + length); - range = stepsToRange(odtDocument); + range = odtDocument.convertCursorToDomRange(position, length); + domUtils.splitBoundaries(range); paragraphElement = odtDocument.getParagraphElement(range.startContainer); textNodes = odfUtils.getTextElements(range, false, true); paragraphs = odfUtils.getParagraphElements(range); @@ -11209,6 +11199,7 @@ ops.OpRemoveText = function OpRemoveText() { destinationParagraph = paragraphs.reduce(function(destination, paragraph) { return mergeParagraphs(destination, paragraph, collapseRules) }); + odtDocument.emit(ops.OdtDocument.signalStepsRemoved, {position:position, length:length}); odtDocument.downgradeWhitespacesAtPosition(position); odtDocument.fixCursorPositions(); odtDocument.getOdfCanvas().refreshSize(); @@ -11272,7 +11263,7 @@ ops.OpSplitParagraph = function OpSplitParagraph() { this.execute = function(odtDocument) { var domPosition, paragraphNode, targetNode, node, splitNode, splitChildNode, keptChildNode; odtDocument.upgradeWhitespacesAtPosition(position); - domPosition = odtDocument.getPositionInTextNode(position, memberid); + domPosition = odtDocument.getTextNodeAtStep(position, memberid); if(!domPosition) { return false } @@ -11300,21 +11291,21 @@ ops.OpSplitParagraph = function OpSplitParagraph() { while(node !== targetNode) { node = node.parentNode; splitNode = node.cloneNode(false); - if(!keptChildNode) { - node.parentNode.insertBefore(splitNode, node); - keptChildNode = splitNode; - splitChildNode = node - }else { - if(splitChildNode) { - splitNode.appendChild(splitChildNode) - } - while(keptChildNode.nextSibling) { + if(splitChildNode) { + splitNode.appendChild(splitChildNode) + } + if(keptChildNode) { + while(keptChildNode && keptChildNode.nextSibling) { splitNode.appendChild(keptChildNode.nextSibling) } - node.parentNode.insertBefore(splitNode, node.nextSibling); - keptChildNode = node; - splitChildNode = splitNode + }else { + while(node.firstChild) { + splitNode.appendChild(node.firstChild) + } } + node.parentNode.insertBefore(splitNode, node.nextSibling); + keptChildNode = node; + splitChildNode = splitNode } if(odfUtils.isListItem(splitChildNode)) { splitChildNode = splitChildNode.childNodes[0] @@ -11322,6 +11313,7 @@ ops.OpSplitParagraph = function OpSplitParagraph() { if(domPosition.textNode.length === 0) { domPosition.textNode.parentNode.removeChild(domPosition.textNode) } + odtDocument.emit(ops.OdtDocument.signalStepsInserted, {position:position, length:1}); odtDocument.fixCursorPositions(); odtDocument.getOdfCanvas().refreshSize(); odtDocument.emit(ops.OdtDocument.signalParagraphChanged, {paragraphElement:paragraphNode, memberId:memberid, timeStamp:timestamp}); @@ -11695,7 +11687,7 @@ ops.OpAddAnnotation = function OpAddAnnotation() { return annotationEnd } function insertNodeAtPosition(odtDocument, node, insertPosition) { - var previousNode, parentNode, domPosition = odtDocument.getPositionInTextNode(insertPosition, memberid); + var previousNode, parentNode, domPosition = odtDocument.getTextNodeAtStep(insertPosition, memberid); if(domPosition) { previousNode = domPosition.textNode; parentNode = previousNode.parentNode; @@ -11722,6 +11714,7 @@ ops.OpAddAnnotation = function OpAddAnnotation() { insertNodeAtPosition(odtDocument, annotation.end, position + length) } insertNodeAtPosition(odtDocument, annotation.node, position); + odtDocument.emit(ops.OdtDocument.signalStepsInserted, {position:position, length:length}); if(cursor) { stepsToParagraph = cursor.getStepCounter().countSteps(lengthToMove, positionFilter); cursor.move(stepsToParagraph); @@ -11785,7 +11778,7 @@ ops.OpRemoveAnnotation = function OpRemoveAnnotation() { domUtils = new core.DomUtils }; this.execute = function(odtDocument) { - var iterator = odtDocument.getIteratorAtPosition(position), container = iterator.container(), annotationName, annotationNode = null, annotationEnd = null, cursors; + var iterator = odtDocument.getIteratorAtPosition(position), container = iterator.container(), annotationName, annotationNode, annotationEnd, cursors; while(!(container.namespaceURI === odf.Namespaces.officens && container.localName === "annotation")) { container = container.parentNode } @@ -11808,6 +11801,7 @@ ops.OpRemoveAnnotation = function OpRemoveAnnotation() { if(annotationEnd) { annotationEnd.parentNode.removeChild(annotationEnd) } + odtDocument.emit(ops.OdtDocument.signalStepsRemoved, {position:position > 0 ? position - 1 : position, length:length}); odtDocument.fixCursorPositions(); odtDocument.getOdfCanvas().refreshAnnotations(); return true @@ -12039,7 +12033,7 @@ gui.SelectionMover = function SelectionMover(cursor, rootNode) { return false } function countSteps(iterator, steps, filter) { - var watch = new core.LoopWatchDog(1E3), positions = 0, positionsCount = 0, increment = steps >= 0 ? 1 : -1, delegate = (steps >= 0 ? iterator.nextPosition : iterator.previousPosition); + var watch = new core.LoopWatchDog(1E4), positions = 0, positionsCount = 0, increment = steps >= 0 ? 1 : -1, delegate = (steps >= 0 ? iterator.nextPosition : iterator.previousPosition); while(steps !== 0 && delegate()) { watch.check(); positionsCount += increment; @@ -12052,7 +12046,7 @@ gui.SelectionMover = function SelectionMover(cursor, rootNode) { return positions } function convertForwardStepsBetweenFilters(stepsFilter1, filter1, filter2) { - var iterator = getIteratorAtCursor(), watch = new core.LoopWatchDog(1E3), pendingStepsFilter2 = 0, stepsFilter2 = 0; + var iterator = getIteratorAtCursor(), watch = new core.LoopWatchDog(1E4), pendingStepsFilter2 = 0, stepsFilter2 = 0; while(stepsFilter1 > 0 && iterator.nextPosition()) { watch.check(); if(filter2.acceptPosition(iterator) === FILTER_ACCEPT) { @@ -12067,7 +12061,7 @@ gui.SelectionMover = function SelectionMover(cursor, rootNode) { return stepsFilter2 } function convertBackwardStepsBetweenFilters(stepsFilter1, filter1, filter2) { - var iterator = getIteratorAtCursor(), watch = new core.LoopWatchDog(1E3), pendingStepsFilter2 = 0, stepsFilter2 = 0; + var iterator = getIteratorAtCursor(), watch = new core.LoopWatchDog(1E4), pendingStepsFilter2 = 0, stepsFilter2 = 0; while(stepsFilter1 > 0 && iterator.previousPosition()) { watch.check(); if(filter2.acceptPosition(iterator) === FILTER_ACCEPT) { @@ -12098,7 +12092,7 @@ gui.SelectionMover = function SelectionMover(cursor, rootNode) { return count } function countLineSteps(filter, direction, iterator) { - var c = iterator.container(), steps = 0, bestContainer = null, bestOffset, bestXDiff = 10, xDiff, bestCount = 0, top, left, lastTop, rect, range = (rootNode.ownerDocument.createRange()), watch = new core.LoopWatchDog(1E3); + var c = iterator.container(), steps = 0, bestContainer = null, bestOffset, bestXDiff = 10, xDiff, bestCount = 0, top, left, lastTop, rect, range = (rootNode.ownerDocument.createRange()), watch = new core.LoopWatchDog(1E4); rect = getVisibleRect(c, iterator.unfilteredDomOffset(), range); top = rect.top; if(cachedXOffset === undefined) { @@ -12181,7 +12175,7 @@ gui.SelectionMover = function SelectionMover(cursor, rootNode) { } function countStepsToPosition(targetNode, targetOffset, filter) { runtime.assert(targetNode !== null, "SelectionMover.countStepsToPosition called with element===null"); - var iterator = getIteratorAtCursor(), c = iterator.container(), o = iterator.unfilteredDomOffset(), steps = 0, watch = new core.LoopWatchDog(1E3), comparison; + var iterator = getIteratorAtCursor(), c = iterator.container(), o = iterator.unfilteredDomOffset(), steps = 0, watch = new core.LoopWatchDog(1E4), comparison; iterator.setUnfilteredPosition(targetNode, targetOffset); while(filter.acceptPosition(iterator) !== FILTER_ACCEPT && iterator.previousPosition()) { watch.check() @@ -12248,6 +12242,443 @@ gui.SelectionMover.createPositionIterator = function(rootNode) { (function() { return gui.SelectionMover })(); +/* + + Copyright (C) 2012-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. + + You should have received a copy of the GNU Affero General Public License + along with this code. If not, see . + + 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: https://github.com/kogmbh/WebODF/ +*/ +runtime.loadClass("core.DomUtils"); +runtime.loadClass("core.PositionFilter"); +runtime.loadClass("odf.OdfUtils"); +(function() { + var nextNodeId = 0; + function StepsCache(rootNode, filter, bucketSize) { + var coordinatens = "urn:webodf:names:steps", stepToDomPoint = {}, nodeToBookmark = {}, odfUtils = new odf.OdfUtils, domUtils = new core.DomUtils, basePoint, FILTER_ACCEPT = core.PositionFilter.FilterResult.FILTER_ACCEPT; + function ParagraphBookmark(steps, paragraphNode) { + this.steps = steps; + this.node = paragraphNode; + function positionInContainer(node) { + var position = 0; + while(node && node.previousSibling) { + position += 1; + node = node.previousSibling + } + return position + } + this.setIteratorPosition = function(iterator) { + iterator.setUnfilteredPosition(paragraphNode.parentNode, positionInContainer(paragraphNode)); + do { + if(filter.acceptPosition(iterator) === FILTER_ACCEPT) { + break + } + }while(iterator.nextPosition()) + } + } + function RootBookmark(steps, rootNode) { + this.steps = steps; + this.node = rootNode; + this.setIteratorPosition = function(iterator) { + iterator.setUnfilteredPosition(rootNode, 0); + do { + if(filter.acceptPosition(iterator) === FILTER_ACCEPT) { + break + } + }while(iterator.nextPosition()) + } + } + function getBucket(steps) { + return Math.floor(steps / bucketSize) * bucketSize + } + function getDestinationBucket(steps) { + return Math.ceil(steps / bucketSize) * bucketSize + } + function clearNodeId(node) { + node.removeAttributeNS(coordinatens, "nodeId") + } + function getNodeId(node) { + return node.nodeType === Node.ELEMENT_NODE && node.getAttributeNS(coordinatens, "nodeId") + } + function setNodeId(node) { + var nodeId = nextNodeId; + node.setAttributeNS(coordinatens, "nodeId", nodeId.toString()); + nextNodeId += 1; + return nodeId + } + function isValidBookmarkForNode(node, bookmark) { + return bookmark.node === node + } + function getNodeBookmark(node, steps) { + var nodeId = getNodeId(node) || setNodeId(node), existingBookmark; + existingBookmark = nodeToBookmark[nodeId]; + if(!existingBookmark) { + existingBookmark = nodeToBookmark[nodeId] = new ParagraphBookmark(steps, node) + }else { + if(!isValidBookmarkForNode(node, existingBookmark)) { + runtime.log("Cloned node detected. Creating new bookmark"); + nodeId = setNodeId(node); + existingBookmark = nodeToBookmark[nodeId] = new ParagraphBookmark(steps, node) + }else { + existingBookmark.steps = steps + } + } + return existingBookmark + } + function isFirstPositionInParagraph(node, offset) { + return offset === 0 && odfUtils.isParagraph(node) + } + this.updateCache = function(steps, node, offset, isWalkable) { + var stablePoint, cacheBucket, existingCachePoint, bookmark; + if(isFirstPositionInParagraph(node, offset)) { + stablePoint = true; + if(!isWalkable) { + steps += 1 + } + }else { + if(node.hasChildNodes() && node.childNodes[offset]) { + node = node.childNodes[offset]; + offset = 0; + stablePoint = isFirstPositionInParagraph(node, offset); + if(stablePoint) { + steps += 1 + } + } + } + if(stablePoint) { + bookmark = getNodeBookmark(node, steps); + cacheBucket = getDestinationBucket(bookmark.steps); + existingCachePoint = stepToDomPoint[cacheBucket]; + if(!existingCachePoint || bookmark.steps > existingCachePoint.steps) { + stepToDomPoint[cacheBucket] = bookmark + } + } + }; + this.setToClosestStep = function(steps, iterator) { + var cacheBucket = getBucket(steps), cachePoint; + while(!cachePoint && cacheBucket !== 0) { + cachePoint = stepToDomPoint[cacheBucket]; + cacheBucket -= bucketSize + } + cachePoint = cachePoint || basePoint; + cachePoint.setIteratorPosition(iterator); + return cachePoint.steps + }; + function findBookmarkedAncestor(node, offset) { + var nodeId, bookmark = null; + node = node.childNodes[offset] || node; + while(!bookmark && (node && node !== rootNode)) { + nodeId = getNodeId(node); + if(nodeId) { + bookmark = nodeToBookmark[nodeId]; + if(bookmark && !isValidBookmarkForNode(node, bookmark)) { + runtime.log("Cloned node detected. Creating new bookmark"); + bookmark = null; + clearNodeId(node) + } + } + node = node.parentNode + } + return bookmark + } + this.setToClosestDomPoint = function(node, offset, iterator) { + var bookmark; + if(node === rootNode && offset === 0) { + bookmark = basePoint + }else { + if(node === rootNode && offset === rootNode.childNodes.length) { + bookmark = Object.keys(stepToDomPoint).map(function(cacheBucket) { + return stepToDomPoint[cacheBucket] + }).reduce(function(largestBookmark, bookmark) { + return bookmark.steps > largestBookmark.steps ? bookmark : largestBookmark + }, basePoint) + }else { + bookmark = findBookmarkedAncestor(node, offset); + if(!bookmark) { + iterator.setUnfilteredPosition(node, offset); + while(!bookmark && iterator.previousNode()) { + bookmark = findBookmarkedAncestor(iterator.container(), iterator.unfilteredDomOffset()) + } + } + } + } + bookmark = bookmark || basePoint; + bookmark.setIteratorPosition(iterator); + return bookmark.steps + }; + this.updateCacheAtPoint = function(inflectionStep, doUpdate) { + var affectedBookmarks, updatedBuckets = {}; + affectedBookmarks = Object.keys(nodeToBookmark).map(function(nodeId) { + return nodeToBookmark[nodeId] + }).filter(function(bookmark) { + return bookmark.steps > inflectionStep + }); + affectedBookmarks.forEach(function(bookmark) { + var originalCacheBucket = getDestinationBucket(bookmark.steps), newCacheBucket, existingBookmark; + if(domUtils.containsNode(rootNode, bookmark.node)) { + doUpdate(bookmark); + newCacheBucket = getDestinationBucket(bookmark.steps); + existingBookmark = updatedBuckets[newCacheBucket]; + if(!existingBookmark || bookmark.steps > existingBookmark.steps) { + updatedBuckets[newCacheBucket] = bookmark + } + }else { + delete nodeToBookmark[getNodeId(bookmark.node)] + } + if(stepToDomPoint[originalCacheBucket] === bookmark) { + delete stepToDomPoint[originalCacheBucket] + } + }); + Object.keys(updatedBuckets).forEach(function(cacheBucket) { + stepToDomPoint[cacheBucket] = updatedBuckets[cacheBucket] + }) + }; + function init() { + basePoint = new RootBookmark(0, rootNode) + } + init() + } + ops.StepsTranslator = function StepsTranslator(getRootNode, newIterator, filter, bucketSize) { + var rootNode = getRootNode(), stepsCache = new StepsCache(rootNode, filter, bucketSize), domUtils = new core.DomUtils, iterator = newIterator(getRootNode()), FILTER_ACCEPT = core.PositionFilter.FilterResult.FILTER_ACCEPT; + function verifyRootNode() { + var currentRootNode = getRootNode(); + if(currentRootNode !== rootNode) { + runtime.log("Undo detected. Resetting steps cache"); + rootNode = currentRootNode; + stepsCache = new StepsCache(rootNode, filter, bucketSize); + iterator = newIterator(rootNode) + } + } + this.convertStepsToDomPoint = function(steps) { + var stepsFromRoot, isWalkable; + if(steps < 0) { + runtime.log("warn", "Requested steps were negative (" + steps + ")"); + steps = 0 + } + verifyRootNode(); + stepsFromRoot = stepsCache.setToClosestStep(steps, iterator); + while(stepsFromRoot < steps && iterator.nextPosition()) { + isWalkable = filter.acceptPosition(iterator) === FILTER_ACCEPT; + if(isWalkable) { + stepsFromRoot += 1 + } + stepsCache.updateCache(stepsFromRoot, iterator.container(), iterator.unfilteredDomOffset(), isWalkable) + } + if(stepsFromRoot !== steps) { + runtime.log("warn", "Requested " + steps + " steps but only " + stepsFromRoot + " are available") + } + return{node:iterator.container(), offset:iterator.unfilteredDomOffset()} + }; + this.convertDomPointToSteps = function(node, offset, roundUp) { + var stepsFromRoot, beforeRoot, destinationNode, destinationOffset, rounding = 0, isWalkable; + verifyRootNode(); + if(!domUtils.containsNode(rootNode, node)) { + beforeRoot = domUtils.comparePoints(rootNode, 0, node, offset) < 0; + node = rootNode; + offset = beforeRoot ? 0 : rootNode.childNodes.length + } + iterator.setUnfilteredPosition(node, offset); + destinationNode = iterator.container(); + destinationOffset = iterator.unfilteredDomOffset(); + if(roundUp && filter.acceptPosition(iterator) !== FILTER_ACCEPT) { + rounding = 1 + } + stepsFromRoot = stepsCache.setToClosestDomPoint(node, offset, iterator); + if(domUtils.comparePoints(iterator.container(), iterator.unfilteredDomOffset(), destinationNode, destinationOffset) < 0) { + return stepsFromRoot > 0 && !roundUp ? stepsFromRoot - 1 : stepsFromRoot + } + while(!(iterator.container() === destinationNode && iterator.unfilteredDomOffset() === destinationOffset) && iterator.nextPosition()) { + isWalkable = filter.acceptPosition(iterator) === FILTER_ACCEPT; + if(isWalkable) { + stepsFromRoot += 1 + } + stepsCache.updateCache(stepsFromRoot, iterator.container(), iterator.unfilteredDomOffset(), isWalkable) + } + return stepsFromRoot + rounding + }; + this.prime = function() { + var stepsFromRoot, isWalkable; + verifyRootNode(); + stepsFromRoot = stepsCache.setToClosestStep(0, iterator); + while(iterator.nextPosition()) { + isWalkable = filter.acceptPosition(iterator) === FILTER_ACCEPT; + if(isWalkable) { + stepsFromRoot += 1 + } + stepsCache.updateCache(stepsFromRoot, iterator.container(), iterator.unfilteredDomOffset(), isWalkable) + } + }; + this.handleStepsInserted = function(eventArgs) { + verifyRootNode(); + stepsCache.updateCacheAtPoint(eventArgs.position, function(bucket) { + bucket.steps += eventArgs.length + }) + }; + this.handleStepsRemoved = function(eventArgs) { + verifyRootNode(); + stepsCache.updateCacheAtPoint(eventArgs.position, function(bucket) { + bucket.steps -= eventArgs.length; + if(bucket.steps < 0) { + bucket.steps = 0 + } + }) + } + }; + return ops.StepsTranslator +})(); +/* + + Copyright (C) 2012-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. + + You should have received a copy of the GNU Affero General Public License + along with this code. If not, see . + + 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: https://github.com/kogmbh/WebODF/ +*/ +runtime.loadClass("core.PositionFilter"); +runtime.loadClass("odf.OdfUtils"); +ops.TextPositionFilter = function TextPositionFilter(getRootNode) { + var odfUtils = new odf.OdfUtils, FILTER_ACCEPT = core.PositionFilter.FilterResult.FILTER_ACCEPT, FILTER_REJECT = core.PositionFilter.FilterResult.FILTER_REJECT; + function checkLeftRight(container, leftNode, rightNode) { + var r, firstPos, rightOfChar; + if(leftNode) { + r = odfUtils.lookLeftForCharacter(leftNode); + if(r === 1) { + return FILTER_ACCEPT + } + if(r === 2 && (odfUtils.scanRightForAnyCharacter(rightNode) || odfUtils.scanRightForAnyCharacter(odfUtils.nextNode(container)))) { + return FILTER_ACCEPT + } + } + firstPos = leftNode === null && odfUtils.isParagraph(container); + rightOfChar = odfUtils.lookRightForCharacter(rightNode); + if(firstPos) { + if(rightOfChar) { + return FILTER_ACCEPT + } + return odfUtils.scanRightForAnyCharacter(rightNode) ? FILTER_REJECT : FILTER_ACCEPT + } + if(!rightOfChar) { + return FILTER_REJECT + } + leftNode = leftNode || odfUtils.previousNode(container); + return odfUtils.scanLeftForAnyCharacter(leftNode) ? FILTER_REJECT : FILTER_ACCEPT + } + this.acceptPosition = function(iterator) { + var container = iterator.container(), nodeType = container.nodeType, offset, text, leftChar, rightChar, leftNode, rightNode, r; + if(nodeType !== Node.ELEMENT_NODE && nodeType !== Node.TEXT_NODE) { + return FILTER_REJECT + } + if(nodeType === Node.TEXT_NODE) { + if(!odfUtils.isGroupingElement(container.parentNode) || odfUtils.isWithinTrackedChanges(container.parentNode, getRootNode())) { + return FILTER_REJECT + } + offset = iterator.unfilteredDomOffset(); + text = container.data; + runtime.assert(offset !== text.length, "Unexpected offset."); + if(offset > 0) { + leftChar = text.substr(offset - 1, 1); + if(!odfUtils.isODFWhitespace(leftChar)) { + return FILTER_ACCEPT + } + if(offset > 1) { + leftChar = text.substr(offset - 2, 1); + if(!odfUtils.isODFWhitespace(leftChar)) { + r = FILTER_ACCEPT + }else { + if(!odfUtils.isODFWhitespace(text.substr(0, offset))) { + return FILTER_REJECT + } + } + }else { + leftNode = odfUtils.previousNode(container); + if(odfUtils.scanLeftForNonWhitespace(leftNode)) { + r = FILTER_ACCEPT + } + } + if(r === FILTER_ACCEPT) { + return odfUtils.isTrailingWhitespace(container, offset) ? FILTER_REJECT : FILTER_ACCEPT + } + rightChar = text.substr(offset, 1); + if(odfUtils.isODFWhitespace(rightChar)) { + return FILTER_REJECT + } + return odfUtils.scanLeftForAnyCharacter(odfUtils.previousNode(container)) ? FILTER_REJECT : FILTER_ACCEPT + } + leftNode = iterator.leftNode(); + rightNode = container; + container = (container.parentNode); + r = checkLeftRight(container, leftNode, rightNode) + }else { + if(!odfUtils.isGroupingElement(container) || odfUtils.isWithinTrackedChanges(container, getRootNode())) { + r = FILTER_REJECT + }else { + leftNode = iterator.leftNode(); + rightNode = iterator.rightNode(); + r = checkLeftRight(container, leftNode, rightNode) + } + } + return r + } +}; /* Copyright (C) 2013 KO GmbH @@ -12273,8 +12704,16 @@ gui.SelectionMover.createPositionIterator = function(rootNode) { @source: https://github.com/kogmbh/WebODF/ */ ops.OperationTransformMatrix = function OperationTransformMatrix() { - function passUnchanged(opSpecA, opSpecB) { - return{opSpecsA:[opSpecA], opSpecsB:[opSpecB]} + function invertMoveCursorSpecRange(moveCursorSpec) { + moveCursorSpec.position = moveCursorSpec.position + moveCursorSpec.length; + moveCursorSpec.length *= -1 + } + function invertMoveCursorSpecRangeOnNegativeLength(moveCursorSpec) { + var isBackwards = moveCursorSpec.length < 0; + if(isBackwards) { + invertMoveCursorSpecRange(moveCursorSpec) + } + return isBackwards } function getStyleReferencingAttributes(setProperties, styleName) { var attributes = []; @@ -12296,6 +12735,95 @@ ops.OperationTransformMatrix = function OperationTransformMatrix() { }) } } + function cloneOpspec(opspec) { + var result = {}; + Object.keys(opspec).forEach(function(key) { + if(typeof opspec[key] === "object") { + result[key] = cloneOpspec(opspec[key]) + }else { + result[key] = opspec[key] + } + }); + return result + } + function dropShadowedAttributes(minorSetProperties, minorRemovedProperties, majorSetProperties, majorRemovedProperties) { + var value, i, name, majorChanged = false, minorChanged = false, shadowingPropertyValue, removedPropertyNames, majorRemovedPropertyNames = majorRemovedProperties && majorRemovedProperties.attributes ? majorRemovedProperties.attributes.split(",") : []; + if(minorSetProperties && (majorSetProperties || majorRemovedPropertyNames.length > 0)) { + Object.keys(minorSetProperties).forEach(function(key) { + value = minorSetProperties[key]; + if(typeof value !== "object") { + shadowingPropertyValue = majorSetProperties && majorSetProperties[key]; + if(shadowingPropertyValue !== undefined) { + delete minorSetProperties[key]; + minorChanged = true; + if(shadowingPropertyValue === value) { + delete majorSetProperties[key]; + majorChanged = true + } + }else { + if(majorRemovedPropertyNames && majorRemovedPropertyNames.indexOf(key) !== -1) { + delete minorSetProperties[key]; + minorChanged = true + } + } + } + }) + } + if(minorRemovedProperties && (minorRemovedProperties.attributes && (majorSetProperties || majorRemovedPropertyNames.length > 0))) { + removedPropertyNames = minorRemovedProperties.attributes.split(","); + for(i = 0;i < removedPropertyNames.length;i += 1) { + name = removedPropertyNames[i]; + if(majorSetProperties && majorSetProperties[name] !== undefined || majorRemovedPropertyNames && majorRemovedPropertyNames.indexOf(name) !== -1) { + removedPropertyNames.splice(i, 1); + i -= 1; + minorChanged = true + } + } + if(removedPropertyNames.length > 0) { + minorRemovedProperties.attributes = removedPropertyNames.join(",") + }else { + delete minorRemovedProperties.attributes + } + } + return{majorChanged:majorChanged, minorChanged:minorChanged} + } + function hasProperties(properties) { + var key; + for(key in properties) { + if(properties.hasOwnProperty(key)) { + return true + } + } + return false + } + function hasRemovedProperties(properties) { + var key; + for(key in properties) { + if(properties.hasOwnProperty(key)) { + if(key !== "attributes" || properties.attributes.length > 0) { + return true + } + } + } + return false + } + function dropShadowedProperties(minorOpspec, majorOpspec, propertiesName) { + var minorSP = minorOpspec.setProperties ? minorOpspec.setProperties[propertiesName] : null, minorRP = minorOpspec.removedProperties ? minorOpspec.removedProperties[propertiesName] : null, majorSP = majorOpspec.setProperties ? majorOpspec.setProperties[propertiesName] : null, majorRP = majorOpspec.removedProperties ? majorOpspec.removedProperties[propertiesName] : null, result; + result = dropShadowedAttributes(minorSP, minorRP, majorSP, majorRP); + if(minorSP && !hasProperties(minorSP)) { + delete minorOpspec.setProperties[propertiesName] + } + if(minorRP && !hasRemovedProperties(minorRP)) { + delete minorOpspec.removedProperties[propertiesName] + } + if(majorSP && !hasProperties(majorSP)) { + delete majorOpspec.setProperties[propertiesName] + } + if(majorRP && !hasRemovedProperties(majorRP)) { + delete majorOpspec.removedProperties[propertiesName] + } + return result + } function transformAddStyleRemoveStyle(addStyleSpec, removeStyleSpec) { var setAttributes, helperOpspec, addStyleSpecResult = [addStyleSpec], removeStyleSpecResult = [removeStyleSpec]; if(addStyleSpec.styleFamily === removeStyleSpec.styleFamily) { @@ -12308,6 +12836,120 @@ ops.OperationTransformMatrix = function OperationTransformMatrix() { } return{opSpecsA:addStyleSpecResult, opSpecsB:removeStyleSpecResult} } + function transformApplyDirectStylingApplyDirectStyling(applyDirectStylingSpecA, applyDirectStylingSpecB, hasAPriority) { + var majorSpec, minorSpec, majorSpecResult, minorSpecResult, majorSpecEnd, minorSpecEnd, dropResult, originalMajorSpec, originalMinorSpec, helperOpspecBefore, helperOpspecAfter, applyDirectStylingSpecAResult = [applyDirectStylingSpecA], applyDirectStylingSpecBResult = [applyDirectStylingSpecB]; + if(!(applyDirectStylingSpecA.position + applyDirectStylingSpecA.length <= applyDirectStylingSpecB.position || applyDirectStylingSpecA.position >= applyDirectStylingSpecB.position + applyDirectStylingSpecB.length)) { + majorSpec = hasAPriority ? applyDirectStylingSpecA : applyDirectStylingSpecB; + minorSpec = hasAPriority ? applyDirectStylingSpecB : applyDirectStylingSpecA; + if(applyDirectStylingSpecA.position !== applyDirectStylingSpecB.position || applyDirectStylingSpecA.length !== applyDirectStylingSpecB.length) { + originalMajorSpec = cloneOpspec(majorSpec); + originalMinorSpec = cloneOpspec(minorSpec) + } + dropResult = dropShadowedProperties(minorSpec, majorSpec, "style:text-properties"); + if(dropResult.majorChanged || dropResult.minorChanged) { + majorSpecResult = []; + minorSpecResult = []; + majorSpecEnd = majorSpec.position + majorSpec.length; + minorSpecEnd = minorSpec.position + minorSpec.length; + if(minorSpec.position < majorSpec.position) { + if(dropResult.minorChanged) { + helperOpspecBefore = cloneOpspec((originalMinorSpec)); + helperOpspecBefore.length = majorSpec.position - minorSpec.position; + minorSpecResult.push(helperOpspecBefore); + minorSpec.position = majorSpec.position; + minorSpec.length = minorSpecEnd - minorSpec.position + } + }else { + if(majorSpec.position < minorSpec.position) { + if(dropResult.majorChanged) { + helperOpspecBefore = cloneOpspec((originalMajorSpec)); + helperOpspecBefore.length = minorSpec.position - majorSpec.position; + majorSpecResult.push(helperOpspecBefore); + majorSpec.position = minorSpec.position; + majorSpec.length = majorSpecEnd - majorSpec.position + } + } + } + if(minorSpecEnd > majorSpecEnd) { + if(dropResult.minorChanged) { + helperOpspecAfter = originalMinorSpec; + helperOpspecAfter.position = majorSpecEnd; + helperOpspecAfter.length = minorSpecEnd - majorSpecEnd; + minorSpecResult.push(helperOpspecAfter); + minorSpec.length = majorSpecEnd - minorSpec.position + } + }else { + if(majorSpecEnd > minorSpecEnd) { + if(dropResult.majorChanged) { + helperOpspecAfter = originalMajorSpec; + helperOpspecAfter.position = minorSpecEnd; + helperOpspecAfter.length = majorSpecEnd - minorSpecEnd; + majorSpecResult.push(helperOpspecAfter); + majorSpec.length = minorSpecEnd - majorSpec.position + } + } + } + if(majorSpec.setProperties && hasProperties(majorSpec.setProperties)) { + majorSpecResult.push(majorSpec) + } + if(minorSpec.setProperties && hasProperties(minorSpec.setProperties)) { + minorSpecResult.push(minorSpec) + } + if(hasAPriority) { + applyDirectStylingSpecAResult = majorSpecResult; + applyDirectStylingSpecBResult = minorSpecResult + }else { + applyDirectStylingSpecAResult = minorSpecResult; + applyDirectStylingSpecBResult = majorSpecResult + } + } + } + return{opSpecsA:applyDirectStylingSpecAResult, opSpecsB:applyDirectStylingSpecBResult} + } + function transformApplyDirectStylingInsertText(applyDirectStylingSpec, insertTextSpec) { + if(insertTextSpec.position <= applyDirectStylingSpec.position) { + applyDirectStylingSpec.position += insertTextSpec.text.length + }else { + if(insertTextSpec.position <= applyDirectStylingSpec.position + applyDirectStylingSpec.length) { + applyDirectStylingSpec.length += insertTextSpec.text.length + } + } + return{opSpecsA:[applyDirectStylingSpec], opSpecsB:[insertTextSpec]} + } + function transformApplyDirectStylingRemoveText(applyDirectStylingSpec, removeTextSpec) { + var applyDirectStylingSpecEnd = applyDirectStylingSpec.position + applyDirectStylingSpec.length, removeTextSpecEnd = removeTextSpec.position + removeTextSpec.length, applyDirectStylingSpecResult = [applyDirectStylingSpec], removeTextSpecResult = [removeTextSpec]; + if(removeTextSpecEnd <= applyDirectStylingSpec.position) { + applyDirectStylingSpec.position -= removeTextSpec.length + }else { + if(removeTextSpec.position < applyDirectStylingSpecEnd) { + if(applyDirectStylingSpec.position < removeTextSpec.position) { + if(removeTextSpecEnd < applyDirectStylingSpecEnd) { + applyDirectStylingSpec.length -= removeTextSpec.length + }else { + applyDirectStylingSpec.length = removeTextSpec.position - applyDirectStylingSpec.position + } + }else { + applyDirectStylingSpec.position = removeTextSpec.position; + if(removeTextSpecEnd < applyDirectStylingSpecEnd) { + applyDirectStylingSpec.length = applyDirectStylingSpecEnd - removeTextSpecEnd + }else { + applyDirectStylingSpecResult = [] + } + } + } + } + return{opSpecsA:applyDirectStylingSpecResult, opSpecsB:removeTextSpecResult} + } + function transformApplyDirectStylingSplitParagraph(applyDirectStylingSpec, splitParagraphSpec) { + if(splitParagraphSpec.position < applyDirectStylingSpec.position) { + applyDirectStylingSpec.position += 1 + }else { + if(splitParagraphSpec.position < applyDirectStylingSpec.position + applyDirectStylingSpec.length) { + applyDirectStylingSpec.length += 1 + } + } + return{opSpecsA:[applyDirectStylingSpec], opSpecsB:[splitParagraphSpec]} + } function transformInsertTextInsertText(insertTextSpecA, insertTextSpecB, hasAPriority) { if(insertTextSpecA.position < insertTextSpecB.position) { insertTextSpecB.position += insertTextSpecA.text.length @@ -12326,13 +12968,17 @@ ops.OperationTransformMatrix = function OperationTransformMatrix() { return{opSpecsA:[insertTextSpecA], opSpecsB:[insertTextSpecB]} } function transformInsertTextMoveCursor(insertTextSpec, moveCursorSpec) { + var isMoveCursorSpecRangeInverted = invertMoveCursorSpecRangeOnNegativeLength(moveCursorSpec); if(insertTextSpec.position < moveCursorSpec.position) { moveCursorSpec.position += insertTextSpec.text.length }else { - if(insertTextSpec.position <= moveCursorSpec.position + moveCursorSpec.length) { + if(insertTextSpec.position < moveCursorSpec.position + moveCursorSpec.length) { moveCursorSpec.length += insertTextSpec.text.length } } + if(isMoveCursorSpecRangeInverted) { + invertMoveCursorSpecRange(moveCursorSpec) + } return{opSpecsA:[insertTextSpec], opSpecsB:[moveCursorSpec]} } function transformInsertTextRemoveText(insertTextSpec, removeTextSpec) { @@ -12368,64 +13014,6 @@ ops.OperationTransformMatrix = function OperationTransformMatrix() { } return{opSpecsA:[insertTextSpec], opSpecsB:[splitParagraphSpec]} } - function dropShadowedAttributes(properties, removedProperties, shadowingProperties, shadowingRemovedProperties) { - var value, i, name, removedPropertyNames, shadowingRemovedPropertyNames = shadowingRemovedProperties && shadowingRemovedProperties.attributes ? shadowingRemovedProperties.attributes.split(",") : []; - if(properties && (shadowingProperties || shadowingRemovedPropertyNames.length > 0)) { - Object.keys(properties).forEach(function(key) { - value = properties[key]; - if(shadowingProperties && shadowingProperties[key] !== undefined || shadowingRemovedPropertyNames && shadowingRemovedPropertyNames.indexOf(key) !== -1) { - if(typeof value !== "object") { - delete properties[key] - } - } - }) - } - if(removedProperties && (removedProperties.attributes && (shadowingProperties || shadowingRemovedPropertyNames.length > 0))) { - removedPropertyNames = removedProperties.attributes.split(","); - for(i = 0;i < removedPropertyNames.length;i += 1) { - name = removedPropertyNames[i]; - if(shadowingProperties && shadowingProperties[name] !== undefined || shadowingRemovedPropertyNames && shadowingRemovedPropertyNames.indexOf(name) !== -1) { - removedPropertyNames.splice(i, 1); - i -= 1 - } - } - if(removedPropertyNames.length > 0) { - removedProperties.attributes = removedPropertyNames.join(",") - }else { - delete removedProperties.attributes - } - } - } - function hasProperties(properties) { - var key; - for(key in properties) { - if(properties.hasOwnProperty(key)) { - return true - } - } - return false - } - function hasRemovedProperties(properties) { - var key; - for(key in properties) { - if(properties.hasOwnProperty(key)) { - if(key !== "attributes" || properties.attributes.length > 0) { - return true - } - } - } - return false - } - function dropShadowedProperties(targetOpspec, shadowingOpspec, propertiesName) { - var sp = targetOpspec.setProperties ? targetOpspec.setProperties[propertiesName] : null, rp = targetOpspec.removedProperties ? targetOpspec.removedProperties[propertiesName] : null; - dropShadowedAttributes(sp, rp, shadowingOpspec.setProperties ? shadowingOpspec.setProperties[propertiesName] : null, shadowingOpspec.removedProperties ? shadowingOpspec.removedProperties[propertiesName] : null); - if(sp && !hasProperties(sp)) { - delete targetOpspec.setProperties[propertiesName] - } - if(rp && !hasRemovedProperties(rp)) { - delete targetOpspec.removedProperties[propertiesName] - } - } function transformUpdateParagraphStyleUpdateParagraphStyle(updateParagraphStyleSpecA, updateParagraphStyleSpecB, hasAPriority) { var majorSpec, minorSpec, updateParagraphStyleSpecAResult = [updateParagraphStyleSpecA], updateParagraphStyleSpecBResult = [updateParagraphStyleSpecB]; if(updateParagraphStyleSpecA.styleName === updateParagraphStyleSpecB.styleName) { @@ -12434,6 +13022,13 @@ ops.OperationTransformMatrix = function OperationTransformMatrix() { dropShadowedProperties(minorSpec, majorSpec, "style:paragraph-properties"); dropShadowedProperties(minorSpec, majorSpec, "style:text-properties"); dropShadowedAttributes(minorSpec.setProperties || null, minorSpec.removedProperties || null, majorSpec.setProperties || null, majorSpec.removedProperties || null); + if(!(majorSpec.setProperties && hasProperties(majorSpec.setProperties)) && !(majorSpec.removedProperties && hasRemovedProperties(majorSpec.removedProperties))) { + if(hasAPriority) { + updateParagraphStyleSpecAResult = [] + }else { + updateParagraphStyleSpecBResult = [] + } + } if(!(minorSpec.setProperties && hasProperties(minorSpec.setProperties)) && !(minorSpec.removedProperties && hasRemovedProperties(minorSpec.removedProperties))) { if(hasAPriority) { updateParagraphStyleSpecBResult = [] @@ -12468,7 +13063,7 @@ ops.OperationTransformMatrix = function OperationTransformMatrix() { return{opSpecsA:isSameCursorRemoved ? [] : [moveCursorSpec], opSpecsB:[removeCursorSpec]} } function transformMoveCursorRemoveText(moveCursorSpec, removeTextSpec) { - var moveCursorSpecEnd = moveCursorSpec.position + moveCursorSpec.length, removeTextSpecEnd = removeTextSpec.position + removeTextSpec.length; + var isMoveCursorSpecRangeInverted = invertMoveCursorSpecRangeOnNegativeLength(moveCursorSpec), moveCursorSpecEnd = moveCursorSpec.position + moveCursorSpec.length, removeTextSpecEnd = removeTextSpec.position + removeTextSpec.length; if(removeTextSpecEnd <= moveCursorSpec.position) { moveCursorSpec.position -= removeTextSpec.length }else { @@ -12489,16 +13084,23 @@ ops.OperationTransformMatrix = function OperationTransformMatrix() { } } } + if(isMoveCursorSpecRangeInverted) { + invertMoveCursorSpecRange(moveCursorSpec) + } return{opSpecsA:[moveCursorSpec], opSpecsB:[removeTextSpec]} } function transformMoveCursorSplitParagraph(moveCursorSpec, splitParagraphSpec) { + var isMoveCursorSpecRangeInverted = invertMoveCursorSpecRangeOnNegativeLength(moveCursorSpec); if(splitParagraphSpec.position < moveCursorSpec.position) { moveCursorSpec.position += 1 }else { - if(splitParagraphSpec.position <= moveCursorSpec.position + moveCursorSpec.length) { + if(splitParagraphSpec.position < moveCursorSpec.position + moveCursorSpec.length) { moveCursorSpec.length += 1 } } + if(isMoveCursorSpecRangeInverted) { + invertMoveCursorSpecRange(moveCursorSpec) + } return{opSpecsA:[moveCursorSpec], opSpecsB:[splitParagraphSpec]} } function transformRemoveCursorRemoveCursor(removeCursorSpecA, removeCursorSpecB) { @@ -12597,10 +13199,14 @@ ops.OperationTransformMatrix = function OperationTransformMatrix() { } return{opSpecsA:removeTextSpecResult, opSpecsB:splitParagraphSpecResult} } - var transformations = {"AddCursor":{"AddCursor":passUnchanged, "AddStyle":passUnchanged, "InsertText":passUnchanged, "MoveCursor":passUnchanged, "RemoveCursor":passUnchanged, "RemoveStyle":passUnchanged, "RemoveText":passUnchanged, "SetParagraphStyle":passUnchanged, "SplitParagraph":passUnchanged, "UpdateParagraphStyle":passUnchanged}, "AddStyle":{"AddStyle":passUnchanged, "InsertText":passUnchanged, "MoveCursor":passUnchanged, "RemoveCursor":passUnchanged, "RemoveStyle":transformAddStyleRemoveStyle, - "RemoveText":passUnchanged, "SetParagraphStyle":passUnchanged, "SplitParagraph":passUnchanged, "UpdateParagraphStyle":passUnchanged}, "InsertText":{"InsertText":transformInsertTextInsertText, "MoveCursor":transformInsertTextMoveCursor, "RemoveCursor":passUnchanged, "RemoveStyle":passUnchanged, "RemoveText":transformInsertTextRemoveText, "SplitParagraph":transformInsertTextSplitParagraph, "UpdateParagraphStyle":passUnchanged}, "MoveCursor":{"MoveCursor":passUnchanged, "RemoveCursor":transformMoveCursorRemoveCursor, - "RemoveStyle":passUnchanged, "RemoveText":transformMoveCursorRemoveText, "SetParagraphStyle":passUnchanged, "SplitParagraph":transformMoveCursorSplitParagraph, "UpdateParagraphStyle":passUnchanged}, "RemoveCursor":{"RemoveCursor":transformRemoveCursorRemoveCursor, "RemoveStyle":passUnchanged, "RemoveText":passUnchanged, "SetParagraphStyle":passUnchanged, "SplitParagraph":passUnchanged, "UpdateParagraphStyle":passUnchanged}, "RemoveStyle":{"RemoveStyle":transformRemoveStyleRemoveStyle, "RemoveText":passUnchanged, - "SetParagraphStyle":transformRemoveStyleSetParagraphStyle, "SplitParagraph":passUnchanged, "UpdateParagraphStyle":transformRemoveStyleUpdateParagraphStyle}, "RemoveText":{"RemoveText":transformRemoveTextRemoveText, "SplitParagraph":transformRemoveTextSplitParagraph, "UpdateParagraphStyle":passUnchanged}, "SetParagraphStyle":{"UpdateParagraphStyle":passUnchanged}, "SplitParagraph":{"SplitParagraph":transformSplitParagraphSplitParagraph, "UpdateParagraphStyle":passUnchanged}, "UpdateParagraphStyle":{"UpdateParagraphStyle":transformUpdateParagraphStyleUpdateParagraphStyle}}; + function passUnchanged(opSpecA, opSpecB) { + return{opSpecsA:[opSpecA], opSpecsB:[opSpecB]} + } + var transformations = {"AddCursor":{"AddCursor":passUnchanged, "AddStyle":passUnchanged, "ApplyDirectStyling":passUnchanged, "InsertText":passUnchanged, "MoveCursor":passUnchanged, "RemoveCursor":passUnchanged, "RemoveStyle":passUnchanged, "RemoveText":passUnchanged, "SetParagraphStyle":passUnchanged, "SplitParagraph":passUnchanged, "UpdateParagraphStyle":passUnchanged}, "AddStyle":{"AddStyle":passUnchanged, "ApplyDirectStyling":passUnchanged, "InsertText":passUnchanged, "MoveCursor":passUnchanged, + "RemoveCursor":passUnchanged, "RemoveStyle":transformAddStyleRemoveStyle, "RemoveText":passUnchanged, "SetParagraphStyle":passUnchanged, "SplitParagraph":passUnchanged, "UpdateParagraphStyle":passUnchanged}, "ApplyDirectStyling":{"ApplyDirectStyling":transformApplyDirectStylingApplyDirectStyling, "InsertText":transformApplyDirectStylingInsertText, "MoveCursor":passUnchanged, "RemoveCursor":passUnchanged, "RemoveStyle":passUnchanged, "RemoveText":transformApplyDirectStylingRemoveText, "SetParagraphStyle":passUnchanged, + "SplitParagraph":transformApplyDirectStylingSplitParagraph, "UpdateParagraphStyle":passUnchanged}, "InsertText":{"InsertText":transformInsertTextInsertText, "MoveCursor":transformInsertTextMoveCursor, "RemoveCursor":passUnchanged, "RemoveStyle":passUnchanged, "RemoveText":transformInsertTextRemoveText, "SplitParagraph":transformInsertTextSplitParagraph, "UpdateParagraphStyle":passUnchanged}, "MoveCursor":{"MoveCursor":passUnchanged, "RemoveCursor":transformMoveCursorRemoveCursor, "RemoveStyle":passUnchanged, + "RemoveText":transformMoveCursorRemoveText, "SetParagraphStyle":passUnchanged, "SplitParagraph":transformMoveCursorSplitParagraph, "UpdateParagraphStyle":passUnchanged}, "RemoveCursor":{"RemoveCursor":transformRemoveCursorRemoveCursor, "RemoveStyle":passUnchanged, "RemoveText":passUnchanged, "SetParagraphStyle":passUnchanged, "SplitParagraph":passUnchanged, "UpdateParagraphStyle":passUnchanged}, "RemoveStyle":{"RemoveStyle":transformRemoveStyleRemoveStyle, "RemoveText":passUnchanged, "SetParagraphStyle":transformRemoveStyleSetParagraphStyle, + "SplitParagraph":passUnchanged, "UpdateParagraphStyle":transformRemoveStyleUpdateParagraphStyle}, "RemoveText":{"RemoveText":transformRemoveTextRemoveText, "SplitParagraph":transformRemoveTextSplitParagraph, "UpdateParagraphStyle":passUnchanged}, "SetParagraphStyle":{"UpdateParagraphStyle":passUnchanged}, "SplitParagraph":{"SplitParagraph":transformSplitParagraphSplitParagraph, "UpdateParagraphStyle":passUnchanged}, "UpdateParagraphStyle":{"UpdateParagraphStyle":transformUpdateParagraphStyleUpdateParagraphStyle}}; this.passUnchanged = passUnchanged; this.extendTransformations = function(moreTransformations) { Object.keys(moreTransformations).forEach(function(optypeA) { @@ -12770,7 +13376,8 @@ ops.OdtCursor = function OdtCursor(memberId, odtDocument) { return cursor.getSelectedRange() }; this.setSelectedRange = function(range, isForwardSelection) { - cursor.setSelectedRange(range, isForwardSelection) + cursor.setSelectedRange(range, isForwardSelection); + self.handleUpdate() }; this.hasForwardSelection = function() { return cursor.hasForwardSelection() @@ -13190,6 +13797,61 @@ gui.Caret = function Caret(cursor, avatarInitiallyVisible, blinkOnRangeSelect) { @source: http://www.webodf.org/ @source: https://github.com/kogmbh/WebODF/ */ +gui.PlainTextPasteboard = function PlainTextPasteboard(odtDocument, inputMemberId) { + function createOp(op, data) { + op.init(data); + return op + } + this.createPasteOps = function(data) { + var originalCursorPosition = odtDocument.getCursorPosition(inputMemberId), cursorPosition = originalCursorPosition, operations = [], paragraphs; + paragraphs = data.replace(/\r/g, "").split("\n"); + paragraphs.forEach(function(text) { + operations.push(createOp(new ops.OpSplitParagraph, {memberid:inputMemberId, position:cursorPosition})); + cursorPosition += 1; + operations.push(createOp(new ops.OpInsertText, {memberid:inputMemberId, position:cursorPosition, text:text})); + cursorPosition += text.length + }); + operations.push(createOp(new ops.OpRemoveText, {memberid:inputMemberId, position:originalCursorPosition, length:1})); + return operations + } +}; +/* + + 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. + + You should have received a copy of the GNU Affero General Public License + along with this code. If not, see . + + 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: https://github.com/kogmbh/WebODF/ +*/ runtime.loadClass("odf.Namespaces"); runtime.loadClass("xmldom.LSSerializer"); runtime.loadClass("odf.OdfNodeFilter"); @@ -13900,8 +14562,9 @@ gui.ImageSelector = function ImageSelector(odfCanvas) { @source: http://www.webodf.org/ @source: https://github.com/kogmbh/WebODF/ */ +runtime.loadClass("core.PositionFilter"); gui.TextManipulator = function TextManipulator(session, inputMemberId, directStyleOp) { - var odtDocument = session.getOdtDocument(); + var odtDocument = session.getOdtDocument(), FILTER_ACCEPT = core.PositionFilter.FilterResult.FILTER_ACCEPT; function createOpRemoveSelection(selection) { var op = new ops.OpRemoveText; op.init({memberid:inputMemberId, position:selection.position, length:selection.length}); @@ -13926,10 +14589,22 @@ gui.TextManipulator = function TextManipulator(session, inputMemberId, directSty session.enqueue(operations); return true }; + function hasPositionInDirection(cursorNode, forward) { + var rootConstrainedFilter = new core.PositionFilterChain, iterator = gui.SelectionMover.createPositionIterator(odtDocument.getRootElement(cursorNode)), nextPosition = (forward ? iterator.nextPosition : iterator.previousPosition); + rootConstrainedFilter.addFilter("BaseFilter", odtDocument.getPositionFilter()); + rootConstrainedFilter.addFilter("RootFilter", odtDocument.createRootFilter(inputMemberId)); + iterator.setUnfilteredPosition(cursorNode, 0); + while(nextPosition()) { + if(rootConstrainedFilter.acceptPosition(iterator) === FILTER_ACCEPT) { + return true + } + } + return false + } this.removeTextByBackspaceKey = function() { - var selection = toForwardSelection(odtDocument.getCursorSelection(inputMemberId)), op = null; + var cursor = odtDocument.getCursor(inputMemberId), selection = toForwardSelection(odtDocument.getCursorSelection(inputMemberId)), op = null; if(selection.length === 0) { - if(selection.position > 0 && odtDocument.getPositionInTextNode(selection.position - 1)) { + if(hasPositionInDirection(cursor.getNode(), false)) { op = new ops.OpRemoveText; op.init({memberid:inputMemberId, position:selection.position - 1, length:1}); session.enqueue([op]) @@ -13941,9 +14616,9 @@ gui.TextManipulator = function TextManipulator(session, inputMemberId, directSty return op !== null }; this.removeTextByDeleteKey = function() { - var selection = toForwardSelection(odtDocument.getCursorSelection(inputMemberId)), op = null; + var cursor = odtDocument.getCursor(inputMemberId), selection = toForwardSelection(odtDocument.getCursorSelection(inputMemberId)), op = null; if(selection.length === 0) { - if(odtDocument.getPositionInTextNode(selection.position + 1)) { + if(hasPositionInDirection(cursor.getNode(), true)) { op = new ops.OpRemoveText; op.init({memberid:inputMemberId, position:selection.position, length:1}); session.enqueue([op]) @@ -14027,7 +14702,7 @@ runtime.loadClass("ops.OpAddAnnotation"); runtime.loadClass("ops.OpRemoveAnnotation"); runtime.loadClass("gui.SelectionMover"); gui.AnnotationManager = function AnnotationManager(session, inputMemberId) { - var odtDocument = session.getOdtDocument(), baseFilter = odtDocument.getPositionFilter(), isAnnotatable = false, eventNotifier = new core.EventNotifier([gui.AnnotationManager.annotatableChanged]), officens = odf.Namespaces.officens, FILTER_ACCEPT = core.PositionFilter.FilterResult.FILTER_ACCEPT; + var odtDocument = session.getOdtDocument(), isAnnotatable = false, eventNotifier = new core.EventNotifier([gui.AnnotationManager.annotatableChanged]), officens = odf.Namespaces.officens; function isWithinAnnotation(node, container) { while(node && node !== container) { if(node.namespaceURI === officens && node.localName === "annotation") { @@ -14059,34 +14734,6 @@ gui.AnnotationManager = function AnnotationManager(session, inputMemberId) { updatedCachedValues() } } - function getWalkableNodeLength(node) { - var length = 0, iterator = gui.SelectionMover.createPositionIterator(odtDocument.getRootNode()), inside = false; - iterator.setUnfilteredPosition(node, 0); - do { - inside = Boolean(node.compareDocumentPosition(iterator.container()) & Node.DOCUMENT_POSITION_CONTAINED_BY); - if(!inside && node !== iterator.container()) { - break - } - if(baseFilter.acceptPosition(iterator) === FILTER_ACCEPT) { - length += 1 - } - }while(iterator.nextPosition()); - return length - } - function getFirstWalkablePositionInNode(node) { - var position = 0, iterator = gui.SelectionMover.createPositionIterator(odtDocument.getRootNode()), watch = new core.LoopWatchDog(1E3), inside = false; - while(iterator.nextPosition()) { - watch.check(); - inside = Boolean(node.compareDocumentPosition(iterator.container()) & Node.DOCUMENT_POSITION_CONTAINED_BY); - if(baseFilter.acceptPosition(iterator) === FILTER_ACCEPT) { - if(inside) { - break - } - position += 1 - } - } - return position - } this.isAnnotatable = function() { return isAnnotatable }; @@ -14101,13 +14748,13 @@ gui.AnnotationManager = function AnnotationManager(session, inputMemberId) { session.enqueue([op]) }; this.removeAnnotation = function(annotationNode) { - var position, length, op, moveCursor; - position = getFirstWalkablePositionInNode(annotationNode); - length = getWalkableNodeLength(annotationNode); + var startStep, endStep, op, moveCursor; + startStep = odtDocument.convertDomPointToCursorStep(annotationNode, 0) + 1; + endStep = odtDocument.convertDomPointToCursorStep(annotationNode, annotationNode.childNodes.length); op = new ops.OpRemoveAnnotation; - op.init({memberid:inputMemberId, position:position, length:length}); + op.init({memberid:inputMemberId, position:startStep, length:endStep - startStep}); moveCursor = new ops.OpMoveCursor; - moveCursor.init({memberid:inputMemberId, position:position - 1, length:0}); + moveCursor.init({memberid:inputMemberId, position:startStep > 0 ? startStep - 1 : startStep, length:0}); session.enqueue([op, moveCursor]) }; this.subscribe = function(eventid, cb) { @@ -14237,12 +14884,13 @@ runtime.loadClass("gui.ImageSelector"); runtime.loadClass("gui.TextManipulator"); runtime.loadClass("gui.AnnotationManager"); runtime.loadClass("gui.EventManager"); +runtime.loadClass("gui.PlainTextPasteboard"); gui.SessionController = function() { var FILTER_ACCEPT = core.PositionFilter.FilterResult.FILTER_ACCEPT; gui.SessionController = function SessionController(session, inputMemberId, shadowCursor, args) { var window = (runtime.getWindow()), odtDocument = session.getOdtDocument(), async = new core.Async, 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, objectNameGenerator = new odf.ObjectNameGenerator(odtDocument.getOdfCanvas().odfContainer(), - inputMemberId), isMouseMoved = false, mouseDownRootFilter = null, undoManager = null, eventManager = new gui.EventManager(odtDocument), annotationManager = new gui.AnnotationManager(session, inputMemberId), directTextStyler = args && args.directStylingEnabled ? new gui.DirectTextStyler(session, inputMemberId) : null, directParagraphStyler = args && args.directStylingEnabled ? new gui.DirectParagraphStyler(session, inputMemberId, objectNameGenerator) : null, createCursorStyleOp = (directTextStyler && - directTextStyler.createCursorStyleOp), textManipulator = new gui.TextManipulator(session, inputMemberId, createCursorStyleOp), imageManager = new gui.ImageManager(session, inputMemberId, objectNameGenerator), imageSelector = new gui.ImageSelector(odtDocument.getOdfCanvas()), shadowCursorIterator = gui.SelectionMover.createPositionIterator(odtDocument.getRootNode()), drawShadowCursorTask; + inputMemberId), isMouseMoved = false, mouseDownRootFilter = null, undoManager = null, eventManager = new gui.EventManager(odtDocument), annotationManager = new gui.AnnotationManager(session, inputMemberId), directTextStyler = new gui.DirectTextStyler(session, inputMemberId), directParagraphStyler = args && args.directParagraphStylingEnabled ? new gui.DirectParagraphStyler(session, inputMemberId, objectNameGenerator) : null, createCursorStyleOp = (directTextStyler.createCursorStyleOp), textManipulator = + new gui.TextManipulator(session, inputMemberId, createCursorStyleOp), imageManager = new gui.ImageManager(session, inputMemberId, objectNameGenerator), imageSelector = new gui.ImageSelector(odtDocument.getOdfCanvas()), shadowCursorIterator = gui.SelectionMover.createPositionIterator(odtDocument.getRootNode()), drawShadowCursorTask, pasteHandler = new gui.PlainTextPasteboard(odtDocument, inputMemberId); 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)); @@ -14276,17 +14924,6 @@ gui.SessionController = function() { } return null } - function findClosestPosition(node) { - var canvasElement = odtDocument.getOdfCanvas().getElement(), newNode = odtDocument.getRootNode(), newOffset = 0, beforeCanvas, iterator; - beforeCanvas = canvasElement.compareDocumentPosition(node) & Node.DOCUMENT_POSITION_PRECEDING; - if(!beforeCanvas) { - iterator = gui.SelectionMover.createPositionIterator(newNode); - iterator.moveToEnd(); - newNode = iterator.container(); - newOffset = iterator.unfilteredDomOffset() - } - return{node:newNode, offset:newOffset} - } function expandToWordBoundaries(selection) { var alphaNumeric = /[A-Za-z0-9]/, iterator = gui.SelectionMover.createPositionIterator(odtDocument.getRootNode()), isForwardSelection = domUtils.comparePoints(selection.anchorNode, selection.anchorOffset, selection.focusNode, selection.focusOffset) > 0, startPoint, endPoint, currentNode, c; if(isForwardSelection) { @@ -14361,7 +14998,7 @@ gui.SessionController = function() { eventManager.focus() } function selectRange(selection, capturedDetails) { - var canvasElement = odtDocument.getOdfCanvas().getElement(), validSelection, clickCount = capturedDetails.detail, caretPos, anchorNodeInsideCanvas, focusNodeInsideCanvas, position, stepsToAnchor, stepsToFocus, oldPosition, op; + var canvasElement = odtDocument.getOdfCanvas().getElement(), validSelection, clickCount = capturedDetails.detail, caretPos, anchorNodeInsideCanvas, focusNodeInsideCanvas, existingSelection, newSelection, op; if(!selection) { return } @@ -14382,36 +15019,24 @@ gui.SessionController = function() { if(!anchorNodeInsideCanvas && !focusNodeInsideCanvas) { return } - if(!anchorNodeInsideCanvas) { - position = findClosestPosition(validSelection.anchorNode); - validSelection.anchorNode = position.node; - validSelection.anchorOffset = position.offset - } - if(!focusNodeInsideCanvas) { - position = findClosestPosition(validSelection.focusNode); - validSelection.focusNode = position.node; - validSelection.focusOffset = position.offset - } - if(clickCount === 2) { - expandToWordBoundaries(validSelection) - }else { - if(clickCount === 3) { - expandToParagraphBoundaries(validSelection) + if(anchorNodeInsideCanvas && focusNodeInsideCanvas) { + if(clickCount === 2) { + expandToWordBoundaries(validSelection) + }else { + if(clickCount >= 3) { + expandToParagraphBoundaries(validSelection) + } } } - stepsToAnchor = odtDocument.getDistanceFromCursor(inputMemberId, validSelection.anchorNode, validSelection.anchorOffset); - if(validSelection.focusNode === validSelection.anchorNode && validSelection.focusOffset === validSelection.anchorOffset) { - stepsToFocus = stepsToAnchor - }else { - stepsToFocus = odtDocument.getDistanceFromCursor(inputMemberId, validSelection.focusNode, validSelection.focusOffset) - } - if(stepsToFocus || stepsToAnchor) { - oldPosition = odtDocument.getCursorPosition(inputMemberId); - op = createOpMoveCursor(oldPosition + stepsToAnchor, stepsToFocus - stepsToAnchor, ops.OdtCursor.RangeSelection); + newSelection = odtDocument.convertDomToCursorRange(validSelection.anchorNode, validSelection.anchorOffset, validSelection.focusNode, validSelection.focusOffset); + existingSelection = odtDocument.getCursorSelection(inputMemberId); + if(newSelection.position !== existingSelection.position || newSelection.length !== existingSelection.length) { + op = createOpMoveCursor(newSelection.position, newSelection.length, ops.OdtCursor.RangeSelection); session.enqueue([op]) } eventManager.focus() } + this.selectRange = selectRange; function extendCursorByAdjustment(lengthAdjust) { var selection = odtDocument.getCursorSelection(inputMemberId), stepCounter = odtDocument.getCursor(inputMemberId).getStepCounter(), newLength; if(lengthAdjust !== 0) { @@ -14432,6 +15057,7 @@ gui.SessionController = function() { moveCursorByAdjustment(-1); return true } + this.moveCursorToLeft = moveCursorToLeft; function moveCursorToRight() { moveCursorByAdjustment(1); return true @@ -14537,6 +15163,7 @@ gui.SessionController = function() { moveCursorByAdjustment(steps) } } + this.moveCursorToDocumentBoundary = moveCursorToDocumentBoundary; function moveCursorToDocumentStart() { moveCursorToDocumentBoundary(-1, false); return true @@ -14554,13 +15181,11 @@ gui.SessionController = function() { return true } function extendSelectionToEntireDocument() { - var iterator = gui.SelectionMover.createPositionIterator(odtDocument.getRootNode()), steps; - steps = -odtDocument.getDistanceFromCursor(inputMemberId, iterator.container(), iterator.unfilteredDomOffset()); - iterator.moveToEnd(); - steps += odtDocument.getDistanceFromCursor(inputMemberId, iterator.container(), iterator.unfilteredDomOffset()); - session.enqueue([createOpMoveCursor(0, steps)]); + var rootNode = odtDocument.getRootNode(), lastWalkableStep = odtDocument.convertDomPointToCursorStep(rootNode, rootNode.childNodes.length); + session.enqueue([createOpMoveCursor(0, lastWalkableStep)]); return true } + this.extendSelectionToEntireDocument = extendSelectionToEntireDocument; function maintainCursorSelection() { var cursor = odtDocument.getCursor(inputMemberId), selection = window.getSelection(), imageElement, range; if(cursor) { @@ -14636,7 +15261,8 @@ gui.SessionController = function() { } } if(plainText) { - textManipulator.insertText(plainText); + textManipulator.removeCurrentSelection(); + session.enqueue(pasteHandler.createPasteOps(plainText)); cancelEvent(e) } } @@ -14827,10 +15453,7 @@ gui.SessionController = function() { return{keydown:keyDownHandler, keypress:keyPressHandler} }; this.destroy = function(callback) { - var destroyCallbacks = [drawShadowCursorTask.destroy]; - if(directTextStyler) { - destroyCallbacks.push(directTextStyler.destroy) - } + var destroyCallbacks = [drawShadowCursorTask.destroy, directTextStyler.destroy]; if(directParagraphStyler) { destroyCallbacks.push(directParagraphStyler.destroy) } @@ -14891,11 +15514,9 @@ gui.SessionController = function() { keyDownHandler.bind(keyCode.Up, modifier.MetaShift, rangeSelectionOnly(extendSelectionToDocumentStart)); keyDownHandler.bind(keyCode.Down, modifier.MetaShift, rangeSelectionOnly(extendSelectionToDocumentEnd)); keyDownHandler.bind(keyCode.A, modifier.Meta, rangeSelectionOnly(extendSelectionToEntireDocument)); - if(directTextStyler) { - keyDownHandler.bind(keyCode.B, modifier.Meta, rangeSelectionOnly(directTextStyler.toggleBold)); - keyDownHandler.bind(keyCode.I, modifier.Meta, rangeSelectionOnly(directTextStyler.toggleItalic)); - keyDownHandler.bind(keyCode.U, modifier.Meta, rangeSelectionOnly(directTextStyler.toggleUnderline)) - } + keyDownHandler.bind(keyCode.B, modifier.Meta, rangeSelectionOnly(directTextStyler.toggleBold)); + keyDownHandler.bind(keyCode.I, modifier.Meta, rangeSelectionOnly(directTextStyler.toggleItalic)); + keyDownHandler.bind(keyCode.U, modifier.Meta, rangeSelectionOnly(directTextStyler.toggleUnderline)); if(directParagraphStyler) { keyDownHandler.bind(keyCode.L, modifier.MetaShift, rangeSelectionOnly(directParagraphStyler.alignParagraphLeft)); keyDownHandler.bind(keyCode.E, modifier.MetaShift, rangeSelectionOnly(directParagraphStyler.alignParagraphCenter)); @@ -14909,11 +15530,9 @@ gui.SessionController = function() { keyDownHandler.bind(keyCode.Z, modifier.MetaShift, redo) }else { keyDownHandler.bind(keyCode.A, modifier.Ctrl, rangeSelectionOnly(extendSelectionToEntireDocument)); - if(directTextStyler) { - keyDownHandler.bind(keyCode.B, modifier.Ctrl, rangeSelectionOnly(directTextStyler.toggleBold)); - keyDownHandler.bind(keyCode.I, modifier.Ctrl, rangeSelectionOnly(directTextStyler.toggleItalic)); - keyDownHandler.bind(keyCode.U, modifier.Ctrl, rangeSelectionOnly(directTextStyler.toggleUnderline)) - } + keyDownHandler.bind(keyCode.B, modifier.Ctrl, rangeSelectionOnly(directTextStyler.toggleBold)); + keyDownHandler.bind(keyCode.I, modifier.Ctrl, rangeSelectionOnly(directTextStyler.toggleItalic)); + keyDownHandler.bind(keyCode.U, modifier.Ctrl, rangeSelectionOnly(directTextStyler.toggleUnderline)); if(directParagraphStyler) { keyDownHandler.bind(keyCode.L, modifier.CtrlShift, rangeSelectionOnly(directParagraphStyler.alignParagraphLeft)); keyDownHandler.bind(keyCode.E, modifier.CtrlShift, rangeSelectionOnly(directParagraphStyler.alignParagraphCenter)); @@ -16534,27 +17153,34 @@ runtime.loadClass("odf.OdfUtils"); runtime.loadClass("odf.Namespaces"); runtime.loadClass("gui.SelectionMover"); runtime.loadClass("core.PositionFilterChain"); +runtime.loadClass("ops.StepsTranslator"); +runtime.loadClass("ops.TextPositionFilter"); ops.OdtDocument = function OdtDocument(odfCanvas) { - var self = this, odfUtils, domUtils, cursors = {}, eventNotifier = new core.EventNotifier([ops.OdtDocument.signalCursorAdded, ops.OdtDocument.signalCursorRemoved, ops.OdtDocument.signalCursorMoved, ops.OdtDocument.signalParagraphChanged, ops.OdtDocument.signalParagraphStyleModified, ops.OdtDocument.signalCommonStyleCreated, ops.OdtDocument.signalCommonStyleDeleted, 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, odfUtils, domUtils, cursors = {}, eventNotifier = new core.EventNotifier([ops.OdtDocument.signalCursorAdded, ops.OdtDocument.signalCursorRemoved, ops.OdtDocument.signalCursorMoved, ops.OdtDocument.signalParagraphChanged, ops.OdtDocument.signalParagraphStyleModified, ops.OdtDocument.signalCommonStyleCreated, ops.OdtDocument.signalCommonStyleDeleted, ops.OdtDocument.signalTableAdded, ops.OdtDocument.signalOperationExecuted, ops.OdtDocument.signalUndoStackChanged, ops.OdtDocument.signalStepsInserted, + ops.OdtDocument.signalStepsRemoved]), FILTER_ACCEPT = core.PositionFilter.FilterResult.FILTER_ACCEPT, FILTER_REJECT = core.PositionFilter.FilterResult.FILTER_REJECT, filter, stepsTranslator; function getRootNode() { var element = odfCanvas.odfContainer().getContentElement(), localName = element && element.localName; - runtime.assert(localName === "text", "Unsupported content element type '" + localName + "'for OdtDocument"); + runtime.assert(localName === "text", "Unsupported content element type '" + localName + "' for OdtDocument"); return element } + function getDOM() { + return(getRootNode().ownerDocument) + } + this.getDOM = getDOM; + function isRoot(node) { + if(node.namespaceURI === odf.Namespaces.officens && node.localName === "text" || node.namespaceURI === odf.Namespaces.officens && node.localName === "annotation") { + return true + } + return false + } + function getRoot(node) { + while(node && !isRoot(node)) { + node = (node.parentNode) + } + return node + } + this.getRootElement = getRoot; function RootFilter(anchor) { - function isRoot(node) { - if(node.namespaceURI === odf.Namespaces.officens && node.localName === "text" || node.namespaceURI === odf.Namespaces.officens && node.localName === "annotation") { - return true - } - return false - } - function getRoot(node) { - while(node && !isRoot(node)) { - node = (node.parentNode) - } - return node - } this.acceptPosition = function(iterator) { var node = iterator.container(), anchorNode; if(typeof anchor === "string") { @@ -16568,167 +17194,62 @@ ops.OdtDocument = function OdtDocument(odfCanvas) { return FILTER_REJECT } } - function TextPositionFilter() { - function checkLeftRight(container, leftNode, rightNode) { - var r, firstPos, rightOfChar; - if(leftNode) { - r = odfUtils.lookLeftForCharacter(leftNode); - if(r === 1) { - return FILTER_ACCEPT - } - if(r === 2 && (odfUtils.scanRightForAnyCharacter(rightNode) || odfUtils.scanRightForAnyCharacter(odfUtils.nextNode(container)))) { - return FILTER_ACCEPT - } - } - firstPos = leftNode === null && odfUtils.isParagraph(container); - rightOfChar = odfUtils.lookRightForCharacter(rightNode); - if(firstPos) { - if(rightOfChar) { - return FILTER_ACCEPT - } - return odfUtils.scanRightForAnyCharacter(rightNode) ? FILTER_REJECT : FILTER_ACCEPT - } - if(!rightOfChar) { - return FILTER_REJECT - } - leftNode = leftNode || odfUtils.previousNode(container); - return odfUtils.scanLeftForAnyCharacter(leftNode) ? FILTER_REJECT : FILTER_ACCEPT - } - this.acceptPosition = function(iterator) { - var container = iterator.container(), nodeType = container.nodeType, offset, text, leftChar, rightChar, leftNode, rightNode, r; - if(nodeType !== Node.ELEMENT_NODE && nodeType !== Node.TEXT_NODE) { - return FILTER_REJECT - } - if(nodeType === Node.TEXT_NODE) { - if(!odfUtils.isGroupingElement(container.parentNode) || odfUtils.isWithinTrackedChanges(container.parentNode, getRootNode())) { - return FILTER_REJECT - } - offset = iterator.unfilteredDomOffset(); - text = container.data; - runtime.assert(offset !== text.length, "Unexpected offset."); - if(offset > 0) { - leftChar = text.substr(offset - 1, 1); - if(!odfUtils.isODFWhitespace(leftChar)) { - return FILTER_ACCEPT - } - if(offset > 1) { - leftChar = text.substr(offset - 2, 1); - if(!odfUtils.isODFWhitespace(leftChar)) { - r = FILTER_ACCEPT - }else { - if(!odfUtils.isODFWhitespace(text.substr(0, offset))) { - return FILTER_REJECT - } - } - }else { - leftNode = odfUtils.previousNode(container); - if(odfUtils.scanLeftForNonWhitespace(leftNode)) { - r = FILTER_ACCEPT - } - } - if(r === FILTER_ACCEPT) { - return odfUtils.isTrailingWhitespace(container, offset) ? FILTER_REJECT : FILTER_ACCEPT - } - rightChar = text.substr(offset, 1); - if(odfUtils.isODFWhitespace(rightChar)) { - return FILTER_REJECT - } - return odfUtils.scanLeftForAnyCharacter(odfUtils.previousNode(container)) ? FILTER_REJECT : FILTER_ACCEPT - } - leftNode = iterator.leftNode(); - rightNode = container; - container = (container.parentNode); - r = checkLeftRight(container, leftNode, rightNode) - }else { - if(!odfUtils.isGroupingElement(container) || odfUtils.isWithinTrackedChanges(container, getRootNode())) { - r = FILTER_REJECT - }else { - leftNode = iterator.leftNode(); - rightNode = iterator.rightNode(); - r = checkLeftRight(container, leftNode, rightNode) - } - } - return r - } - } function getIteratorAtPosition(position) { - var iterator = gui.SelectionMover.createPositionIterator(getRootNode()); - position += 1; - while(position > 0 && iterator.nextPosition()) { - if(filter.acceptPosition(iterator) === FILTER_ACCEPT) { - position -= 1 - } - } + var iterator = gui.SelectionMover.createPositionIterator(getRootNode()), point = stepsTranslator.convertStepsToDomPoint(position); + iterator.setUnfilteredPosition(point.node, point.offset); return iterator } this.getIteratorAtPosition = getIteratorAtPosition; - function getPositionInTextNode(position, memberid) { - var iterator = gui.SelectionMover.createPositionIterator(getRootNode()), lastTextNode = null, node, nodeOffset = 0, cursorNode = null, originalPosition = position; - runtime.assert(position >= 0, "position must be >= 0"); - if(filter.acceptPosition(iterator) === FILTER_ACCEPT) { - node = iterator.container(); - if(node.nodeType === Node.TEXT_NODE) { - lastTextNode = (node); - nodeOffset = 0 + this.convertDomPointToCursorStep = function(node, offset) { + return stepsTranslator.convertDomPointToSteps(node, offset) + }; + this.convertDomToCursorRange = function(anchorNode, anchorOffset, focusNode, focusOffset) { + var point1, point2; + point1 = stepsTranslator.convertDomPointToSteps(anchorNode, anchorOffset); + if(anchorNode === focusNode && anchorOffset === focusOffset) { + point2 = point1 + }else { + point2 = stepsTranslator.convertDomPointToSteps(focusNode, focusOffset) + } + return{position:point1, length:point2 - point1} + }; + this.convertCursorToDomRange = function(position, length) { + var range = getDOM().createRange(), point1, point2; + point1 = stepsTranslator.convertStepsToDomPoint(position); + if(length) { + point2 = stepsTranslator.convertStepsToDomPoint(position + length); + if(length > 0) { + range.setStart(point1.node, point1.offset); + range.setEnd(point2.node, point2.offset) + }else { + range.setStart(point2.node, point2.offset); + range.setEnd(point1.node, point1.offset) } }else { - position += 1 + range.setStart(point1.node, point1.offset) } - while(position > 0 || lastTextNode === null) { - if(!iterator.nextPosition()) { - return null - } - if(filter.acceptPosition(iterator) === FILTER_ACCEPT) { - position -= 1; - node = iterator.container(); - if(node.nodeType === Node.TEXT_NODE) { - if(node !== lastTextNode) { - lastTextNode = (node); - nodeOffset = iterator.unfilteredDomOffset() - }else { - nodeOffset += 1 - } - }else { - if(lastTextNode !== null) { - if(position === 0) { - nodeOffset = lastTextNode.length; - break - } - lastTextNode = null - }else { - if(position === 0) { - lastTextNode = getRootNode().ownerDocument.createTextNode(""); - node.insertBefore(lastTextNode, iterator.rightNode()); - nodeOffset = 0; - break - } - } - } - } + return range + }; + function getTextNodeAtStep(steps, memberid) { + var iterator = getIteratorAtPosition(steps), node = iterator.container(), lastTextNode, nodeOffset = 0, cursorNode = null; + if(node.nodeType === Node.TEXT_NODE) { + lastTextNode = (node); + nodeOffset = iterator.unfilteredDomOffset() + }else { + lastTextNode = getDOM().createTextNode(""); + nodeOffset = 0; + node.insertBefore(lastTextNode, iterator.rightNode()) } - if(lastTextNode === null) { - return null - } - if(memberid && (cursors[memberid] && self.getCursorPosition(memberid) === originalPosition)) { + if(memberid && (cursors[memberid] && self.getCursorPosition(memberid) === steps)) { cursorNode = cursors[memberid].getNode(); - while(nodeOffset === 0 && (cursorNode.nextSibling && cursorNode.nextSibling.localName === "cursor")) { - cursorNode.parentNode.insertBefore(cursorNode, cursorNode.nextSibling.nextSibling) + while(cursorNode.nextSibling && cursorNode.nextSibling.localName === "cursor") { + cursorNode.parentNode.insertBefore(cursorNode.nextSibling, cursorNode) } - if(lastTextNode.length > 0) { - lastTextNode = getRootNode().ownerDocument.createTextNode(""); - nodeOffset = 0; - cursorNode.parentNode.insertBefore(lastTextNode, cursorNode.nextSibling) - } - while(nodeOffset === 0 && (lastTextNode.previousSibling && lastTextNode.previousSibling.localName === "cursor")) { - node = lastTextNode.previousSibling; - if(lastTextNode.length > 0) { - lastTextNode = getRootNode().ownerDocument.createTextNode("") - } - node.parentNode.insertBefore(lastTextNode, node); - if(cursorNode === node) { - break - } + if(lastTextNode.length > 0 && lastTextNode.nextSibling !== cursorNode) { + lastTextNode = getDOM().createTextNode(""); + nodeOffset = 0 } + cursorNode.parentNode.insertBefore(lastTextNode, cursorNode) } while(lastTextNode.previousSibling && lastTextNode.previousSibling.nodeType === Node.TEXT_NODE) { lastTextNode.previousSibling.appendData(lastTextNode.data); @@ -16805,7 +17326,7 @@ ops.OdtDocument = function OdtDocument(odfCanvas) { this.getParagraphStyleElement = getParagraphStyleElement; this.getParagraphElement = getParagraphElement; this.getParagraphStyleAttributes = getParagraphStyleAttributes; - this.getPositionInTextNode = getPositionInTextNode; + this.getTextNodeAtStep = getTextNodeAtStep; this.fixCursorPositions = function() { var rootConstrainedFilter = new core.PositionFilterChain; rootConstrainedFilter.addFilter("BaseFilter", filter); @@ -16841,39 +17362,26 @@ ops.OdtDocument = function OdtDocument(odfCanvas) { rootConstrainedFilter.removeFilter("RootFilter") }) }; - this.getWalkableParagraphLength = function(paragraph) { - var iterator = getIteratorAtPosition(0), length = 0; - iterator.setUnfilteredPosition(paragraph, 0); - do { - if(getParagraphElement(iterator.container()) !== paragraph) { - return length - } - if(filter.acceptPosition(iterator) === FILTER_ACCEPT) { - length += 1 - } - }while(iterator.nextPosition()); - return length - }; this.getDistanceFromCursor = function(memberid, node, offset) { - var counter, cursor = cursors[memberid], steps = 0; + var cursor = cursors[memberid], focusPosition, targetPosition; runtime.assert(node !== null && node !== undefined, "OdtDocument.getDistanceFromCursor called without node"); if(cursor) { - counter = cursor.getStepCounter().countStepsToPosition; - steps = counter(node, offset, filter) + focusPosition = stepsTranslator.convertDomPointToSteps(cursor.getNode(), 0); + targetPosition = stepsTranslator.convertDomPointToSteps(node, offset) } - return steps + return targetPosition - focusPosition }; this.getCursorPosition = function(memberid) { - return-self.getDistanceFromCursor(memberid, getRootNode(), 0) + var cursor = cursors[memberid]; + return cursor ? stepsTranslator.convertDomPointToSteps(cursor.getNode(), 0) : 0 }; this.getCursorSelection = function(memberid) { - var counter, cursor = cursors[memberid], focusPosition = 0, stepsToAnchor = 0; + var cursor = cursors[memberid], focusPosition = 0, anchorPosition = 0; if(cursor) { - counter = cursor.getStepCounter().countStepsToPosition; - focusPosition = -counter(getRootNode(), 0, filter); - stepsToAnchor = counter(cursor.getAnchorNode(), 0, filter) + focusPosition = stepsTranslator.convertDomPointToSteps(cursor.getNode(), 0); + anchorPosition = stepsTranslator.convertDomPointToSteps(cursor.getAnchorNode(), 0) } - return{position:focusPosition + stepsToAnchor, length:-stepsToAnchor} + return{position:anchorPosition, length:focusPosition - anchorPosition} }; this.getPositionFilter = function() { return filter @@ -16882,9 +17390,6 @@ ops.OdtDocument = function OdtDocument(odfCanvas) { return odfCanvas }; this.getRootNode = getRootNode; - this.getDOM = function() { - return(getRootNode().ownerDocument) - }; this.getCursor = function(memberid) { return cursors[memberid] }; @@ -16952,9 +17457,12 @@ ops.OdtDocument = function OdtDocument(odfCanvas) { callback() }; function init() { - filter = new TextPositionFilter; + filter = new ops.TextPositionFilter(getRootNode); odfUtils = new odf.OdfUtils; - domUtils = new core.DomUtils + domUtils = new core.DomUtils; + stepsTranslator = new ops.StepsTranslator(getRootNode, gui.SelectionMover.createPositionIterator, filter, 500); + eventNotifier.subscribe(ops.OdtDocument.signalStepsInserted, stepsTranslator.handleStepsInserted); + eventNotifier.subscribe(ops.OdtDocument.signalStepsRemoved, stepsTranslator.handleStepsRemoved) } init() }; @@ -16968,6 +17476,8 @@ ops.OdtDocument.signalCommonStyleDeleted = "style/deleted"; ops.OdtDocument.signalParagraphStyleModified = "paragraphstyle/modified"; ops.OdtDocument.signalOperationExecuted = "operation/executed"; ops.OdtDocument.signalUndoStackChanged = "undo/changed"; +ops.OdtDocument.signalStepsInserted = "steps/inserted"; +ops.OdtDocument.signalStepsRemoved = "steps/removed"; (function() { return ops.OdtDocument })(); diff --git a/js/3rdparty/webodf/webodf.js b/js/3rdparty/webodf/webodf.js index 14521100..ec4dc8f5 100644 --- a/js/3rdparty/webodf/webodf.js +++ b/js/3rdparty/webodf/webodf.js @@ -39,79 +39,79 @@ */ var core={},gui={},xmldom={},odf={},ops={}; // Input 1 -function Runtime(){}Runtime.ByteArray=function(e){};Runtime.prototype.getVariable=function(e){};Runtime.prototype.toJson=function(e){};Runtime.prototype.fromJson=function(e){};Runtime.ByteArray.prototype.slice=function(e,h){};Runtime.ByteArray.prototype.length=0;Runtime.prototype.byteArrayFromArray=function(e){};Runtime.prototype.byteArrayFromString=function(e,h){};Runtime.prototype.byteArrayToString=function(e,h){};Runtime.prototype.concatByteArrays=function(e,h){}; -Runtime.prototype.read=function(e,h,f,n){};Runtime.prototype.readFile=function(e,h,f){};Runtime.prototype.readFileSync=function(e,h){};Runtime.prototype.loadXML=function(e,h){};Runtime.prototype.writeFile=function(e,h,f){};Runtime.prototype.isFile=function(e,h){};Runtime.prototype.getFileSize=function(e,h){};Runtime.prototype.deleteFile=function(e,h){};Runtime.prototype.log=function(e,h){};Runtime.prototype.setTimeout=function(e,h){};Runtime.prototype.clearTimeout=function(e){}; -Runtime.prototype.libraryPaths=function(){};Runtime.prototype.type=function(){};Runtime.prototype.getDOMImplementation=function(){};Runtime.prototype.parseXML=function(e){};Runtime.prototype.getWindow=function(){};Runtime.prototype.assert=function(e,h,f){};var IS_COMPILED_CODE=!0; -Runtime.byteArrayToString=function(e,h){function f(f){var c="",b,a=f.length;for(b=0;bd?c+=String.fromCharCode(d):(b+=1,k=f[b],194<=d&&224>d?c+=String.fromCharCode((d&31)<<6|k&63):(b+=1,g=f[b],224<=d&&240>d?c+=String.fromCharCode((d&15)<<12|(k&63)<<6|g&63):(b+=1,q=f[b],240<=d&&245>d&&(d=(d&7)<<18|(k&63)<<12|(g&63)<<6|q&63,d-=65536,c+=String.fromCharCode((d>>10)+55296,(d&1023)+56320))))); -return c}var m;"utf8"===h?m=n(e):("binary"!==h&&this.log("Unsupported encoding: "+h),m=f(e));return m};Runtime.getVariable=function(e){try{return eval(e)}catch(h){}};Runtime.toJson=function(e){return JSON.stringify(e)};Runtime.fromJson=function(e){return JSON.parse(e)};Runtime.getFunctionName=function(e){return void 0===e.name?(e=/function\s+(\w+)/.exec(e))&&e[1]:e.name}; -function BrowserRuntime(e){function h(c,b){var a,d,k;void 0!==b?k=c:b=c;e?(d=e.ownerDocument,k&&(a=d.createElement("span"),a.className=k,a.appendChild(d.createTextNode(k)),e.appendChild(a),e.appendChild(d.createTextNode(" "))),a=d.createElement("span"),0g?(d[q]=g,q+=1):2048>g?(d[q]=192|g>>>6,d[q+1]=128|g&63,q+=2):(d[q]=224|g>>>12&15,d[q+1]=128|g>>>6&63,d[q+2]=128|g&63,q+=3)}else for("binary"!== -b&&n.log("unknown encoding: "+b),a=c.length,d=new n.ByteArray(a),k=0;kd.status||0===d.status?a(null):a("Status "+String(d.status)+": "+d.responseText|| -d.statusText):a("File "+c+" is empty."))};b=b.buffer&&!d.sendAsBinary?b.buffer:n.byteArrayToString(b,"binary");try{d.sendAsBinary?d.sendAsBinary(b):d.send(b)}catch(k){n.log("HUH? "+k+" "+b),a(k.message)}};this.deleteFile=function(c,b){delete m[c];var a=new XMLHttpRequest;a.open("DELETE",c,!0);a.onreadystatechange=function(){4===a.readyState&&(200>a.status&&300<=a.status?b(a.responseText):b(null))};a.send(null)};this.loadXML=function(c,b){var a=new XMLHttpRequest;a.open("GET",c,!0);a.overrideMimeType&& -a.overrideMimeType("text/xml");a.onreadystatechange=function(){4===a.readyState&&(0!==a.status||a.responseText?200===a.status||0===a.status?b(null,a.responseXML):b(a.responseText):b("File "+c+" is empty."))};try{a.send(null)}catch(d){b(d.message)}};this.isFile=function(c,b){n.getFileSize(c,function(a){b(-1!==a)})};this.getFileSize=function(c,b){var a=new XMLHttpRequest;a.open("HEAD",c,!0);a.onreadystatechange=function(){if(4===a.readyState){var d=a.getResponseHeader("Content-Length");d?b(parseInt(d, -10)):f(c,"binary",function(a,d){a?b(-1):b(d.length)})}};a.send(null)};this.log=h;this.assert=function(c,b,a){if(!c)throw h("alert","ASSERTION FAILED:\n"+b),a&&a(),b;};this.setTimeout=function(c,b){return setTimeout(function(){c()},b)};this.clearTimeout=function(c){clearTimeout(c)};this.libraryPaths=function(){return["lib"]};this.setCurrentDirectory=function(){};this.type=function(){return"BrowserRuntime"};this.getDOMImplementation=function(){return window.document.implementation};this.parseXML=function(c){return(new DOMParser).parseFromString(c, -"text/xml")};this.exit=function(c){h("Calling exit with code "+String(c)+", but exit() is not implemented.")};this.getWindow=function(){return window}} -function NodeJSRuntime(){function e(b,a,d){b=n.resolve(m,b);"binary"!==a?f.readFile(b,a,d):f.readFile(b,null,d)}var h=this,f=require("fs"),n=require("path"),m="",p,c;this.ByteArray=function(b){return new Buffer(b)};this.byteArrayFromArray=function(b){var a=new Buffer(b.length),d,c=b.length;for(d=0;d").implementation} -function RhinoRuntime(){function e(c,b){var a;void 0!==b?a=c:b=c;"alert"===a&&print("\n!!!!! ALERT !!!!!");print(b);"alert"===a&&print("!!!!! ALERT !!!!!")}var h=this,f=Packages.javax.xml.parsers.DocumentBuilderFactory.newInstance(),n,m,p="";f.setValidating(!1);f.setNamespaceAware(!0);f.setExpandEntityReferences(!1);f.setSchema(null);m=Packages.org.xml.sax.EntityResolver({resolveEntity:function(c,b){var a=new Packages.java.io.FileReader(b);return new Packages.org.xml.sax.InputSource(a)}});n=f.newDocumentBuilder(); -n.setEntityResolver(m);this.ByteArray=function(c){return[c]};this.byteArrayFromArray=function(c){return c};this.byteArrayFromString=function(c,b){var a=[],d,k=c.length;for(d=0;db?a+=String.fromCharCode(b):(d+=1,k=e[d],194<=b&&224>b?a+=String.fromCharCode((b&31)<<6|k&63):(d+=1,c=e[d],224<=b&&240>b?a+=String.fromCharCode((b&15)<<12|(k&63)<<6|c&63):(d+=1,g=e[d],240<=b&&245>b&&(b=(b&7)<<18|(k&63)<<12|(c&63)<<6|g&63,b-=65536,a+=String.fromCharCode((b>>10)+55296,(b&1023)+56320))))); +return a}var l;"utf8"===m?l=p(h):("binary"!==m&&this.log("Unsupported encoding: "+m),l=e(h));return l};Runtime.getVariable=function(h){try{return eval(h)}catch(m){}};Runtime.toJson=function(h){return JSON.stringify(h)};Runtime.fromJson=function(h){return JSON.parse(h)};Runtime.getFunctionName=function(h){return void 0===h.name?(h=/function\s+(\w+)/.exec(h))&&h[1]:h.name}; +function BrowserRuntime(h){function m(a,d){var f,b,k;void 0!==d?k=a:d=a;h?(b=h.ownerDocument,k&&(f=b.createElement("span"),f.className=k,f.appendChild(b.createTextNode(k)),h.appendChild(f),h.appendChild(b.createTextNode(" "))),f=b.createElement("span"),0c?(b[g]=c,g+=1):2048>c?(b[g]=192|c>>>6,b[g+1]=128|c&63,g+=2):(b[g]=224|c>>>12&15,b[g+1]=128|c>>>6&63,b[g+2]=128|c&63,g+=3)}else for("binary"!== +d&&p.log("unknown encoding: "+d),f=a.length,b=new p.ByteArray(f),k=0;kb.status||0===b.status?f(null):f("Status "+String(b.status)+": "+b.responseText|| +b.statusText):f("File "+a+" is empty."))};d=d.buffer&&!b.sendAsBinary?d.buffer:p.byteArrayToString(d,"binary");try{b.sendAsBinary?b.sendAsBinary(d):b.send(d)}catch(k){p.log("HUH? "+k+" "+d),f(k.message)}};this.deleteFile=function(a,d){delete l[a];var f=new XMLHttpRequest;f.open("DELETE",a,!0);f.onreadystatechange=function(){4===f.readyState&&(200>f.status&&300<=f.status?d(f.responseText):d(null))};f.send(null)};this.loadXML=function(a,d){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?d(null,f.responseXML):d(f.responseText):d("File "+a+" is empty."))};try{f.send(null)}catch(b){d(b.message)}};this.isFile=function(a,d){p.getFileSize(a,function(a){d(-1!==a)})};this.getFileSize=function(a,d){var f=new XMLHttpRequest;f.open("HEAD",a,!0);f.onreadystatechange=function(){if(4===f.readyState){var b=f.getResponseHeader("Content-Length");b?d(parseInt(b, +10)):e(a,"binary",function(b,c){b?d(-1):d(c.length)})}};f.send(null)};this.log=m;this.assert=function(a,d,f){if(!a)throw m("alert","ASSERTION FAILED:\n"+d),f&&f(),d;};this.setTimeout=function(a,d){return setTimeout(function(){a()},d)};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 h(d,a,b){d=p.resolve(l,d);"binary"!==a?e.readFile(d,a,b):e.readFile(d,null,b)}var m=this,e=require("fs"),p=require("path"),l="",q,a;this.ByteArray=function(d){return new Buffer(d)};this.byteArrayFromArray=function(d){var a=new Buffer(d.length),b,k=d.length;for(b=0;b").implementation} +function RhinoRuntime(){function h(a,d){var f;void 0!==d?f=a:d=a;"alert"===f&&print("\n!!!!! ALERT !!!!!");print(d);"alert"===f&&print("!!!!! ALERT !!!!!")}var m=this,e=Packages.javax.xml.parsers.DocumentBuilderFactory.newInstance(),p,l,q="";e.setValidating(!1);e.setNamespaceAware(!0);e.setExpandEntityReferences(!1);e.setSchema(null);l=Packages.org.xml.sax.EntityResolver({resolveEntity:function(a,d){var f=new Packages.java.io.FileReader(d);return new Packages.org.xml.sax.InputSource(f)}});p=e.newDocumentBuilder(); +p.setEntityResolver(l);this.ByteArray=function(a){return[a]};this.byteArrayFromArray=function(a){return a};this.byteArrayFromString=function(a,d){var f=[],b,k=a.length;for(b=0;b>>18],b+=r[d>>>12&63],b+=r[d>>>6&63],b+=r[d&63];g===c+1?(d=a[g]<<4,b+=r[d>>>6],b+=r[d&63],b+="=="):g===c&&(d=a[g]<<10|a[g+1]<<2,b+=r[d>>>12],b+=r[d>>>6&63],b+=r[d&63],b+="=");return b}function f(a){a=a.replace(/[^A-Za-z0-9+\/]+/g,"");var d=[],b=a.length%4,g,c=a.length,k;for(g=0;g>16,k>>8&255,k&255);d.length-=[0,0,2,1][b];return d}function n(a){var d=[],b,g=a.length,c;for(b=0;bc?d.push(c):2048>c?d.push(192|c>>>6,128|c&63):d.push(224|c>>>12&15,128|c>>>6&63,128|c&63);return d}function m(a){var d=[],b,g=a.length,c,k,l;for(b=0;bc?d.push(c):(b+=1,k=a[b],224>c?d.push((c&31)<<6|k&63):(b+=1,l=a[b],d.push((c&15)<<12|(k&63)<<6|l&63)));return d}function p(a){return h(e(a))} -function c(a){return String.fromCharCode.apply(String,f(a))}function b(a){return m(e(a))}function a(a){a=m(a);for(var d="",b=0;bd?g+=String.fromCharCode(d):(l+=1,c=a.charCodeAt(l)&255,224>d?g+=String.fromCharCode((d&31)<<6|c&63):(l+=1,k=a.charCodeAt(l)&255,g+=String.fromCharCode((d&15)<<12|(c&63)<<6|k&63)));return g}function k(a,b){function g(){var q= -k+c;q>a.length&&(q=a.length);l+=d(a,k,q);k=q;q=k===a.length;b(l,q)&&!q&&runtime.setTimeout(g,0)}var c=1E5,l="",k=0;a.length>>18],b+=r[g>>>12&63],b+=r[g>>>6&63],b+=r[g&63];a===d+1?(g=c[a]<<4,b+=r[g>>>6],b+=r[g&63],b+="=="):a===d&&(g=c[a]<<10|c[a+1]<<2,b+=r[g>>>12],b+=r[g>>>6&63],b+=r[g&63],b+="=");return b}function e(c){c=c.replace(/[^A-Za-z0-9+\/]+/g,"");var g=[],b=c.length%4,a,d=c.length,n;for(a=0;a>16,n>>8&255,n&255);g.length-=[0,0,2,1][b];return g}function p(c){var g=[],b,a=c.length,d;for(b=0;bd?g.push(d):2048>d?g.push(192|d>>>6,128|d&63):g.push(224|d>>>12&15,128|d>>>6&63,128|d&63);return g}function l(c){var g=[],b,a=c.length,d,n,f;for(b=0;bd?g.push(d):(b+=1,n=c[b],224>d?g.push((d&31)<<6|n&63):(b+=1,f=c[b],g.push((d&15)<<12|(n&63)<<6|f&63)));return g}function q(c){return m(h(c))} +function a(c){return String.fromCharCode.apply(String,e(c))}function d(c){return l(h(c))}function f(c){c=l(c);for(var g="",b=0;bg?a+=String.fromCharCode(g):(f+=1,d=c.charCodeAt(f)&255,224>g?a+=String.fromCharCode((g&31)<<6|d&63):(f+=1,n=c.charCodeAt(f)&255,a+=String.fromCharCode((g&15)<<12|(d&63)<<6|n&63)));return a}function k(c,g){function a(){var k= +f+d;k>c.length&&(k=c.length);n+=b(c,f,k);f=k;k=f===c.length;g(n,k)&&!k&&runtime.setTimeout(a,0)}var d=1E5,n="",f=0;c.length>>8):(xa(a&255),xa(a>>>8))},X=function(){u=(u<<5^l[z+3-1]&255)&8191;s=w[32768+u];w[z&32767]=s;w[32768+u]=z},ga=function(a,d){y>16-d?(v|=a<>16-y,y+=d-16):(v|=a<a;a++)l[a]=l[a+32768];N-=32768;z-=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=qa(l,z+R,b),0>=a?G=!0:R+=a)},va=function(a){var d=Z,b=z,g,c=I,k=32506=ra&&(d>>=2);do if(g=a,l[g+c]===e&&l[g+c-1]===f&&l[g]===l[b]&&l[++g]===l[b+1]){b+= -2;g++;do++b;while(l[b]===l[++g]&&l[++b]===l[++g]&&l[++b]===l[++g]&&l[++b]===l[++g]&&l[++b]===l[++g]&&l[++b]===l[++g]&&l[++b]===l[++g]&&l[++b]===l[++g]&&bc){N=a;c=g;if(258<=g)break;f=l[b+c-1];e=l[b+c]}a=w[a&32767]}while(a>k&&0!==--d);return c},wa=function(a,d){t[D++]=d;0===a?$[d].fc++:(a--,$[V[d]+256+1].fc++,ha[(256>a?Q[a]:Q[256+(a>>7)])&255].fc++,r[fa++]=a,ia|=Y);Y<<=1;0===(D&7)&&(oa[F++]=ia,ia=0,Y=1);if(2c;c++)b+=ha[c].fc* -(5+ma[c]);b>>=3;if(fa>=1,b<<=1;while(0<--d);return b>>1},Ea=function(a,d){var b=[];b.length=16;var g=0,c;for(c=1;15>=c;c++)g=g+S[c-1]<<1,b[c]=g;for(g=0;g<=d;g++)c=a[g].dl,0!==c&&(a[g].fc=Da(b[c]++,c))},Ca=function(a){var d=a.dyn_tree,b=a.static_tree,g=a.elems,c,l= --1,k=g;aa=0;na=573;for(c=0;caa;)c=P[++aa]=2>l?++l:0,d[c].fc=1,da[c]=0,ba--,null!==b&&(la-=b[c].dl);a.max_code=l;for(c=aa>>1;1<=c;c--)ua(d,c);do c=P[1],P[1]=P[aa--],ua(d,1),b=P[1],P[--na]=c,P[--na]=b,d[k].fc=d[c].fc+d[b].fc,da[k]=da[c]>da[b]+1?da[c]:da[b]+1,d[c].dl=d[b].dl=k,P[1]=k++,ua(d,1);while(2<=aa);P[--na]=P[1];k=a.dyn_tree;c=a.extra_bits;var g=a.extra_base,b=a.max_code,q=a.max_length,f=a.static_tree,e,r,A,h,s=0;for(r=0;15>=r;r++)S[r]= -0;k[P[na]].dl=0;for(a=na+1;573>a;a++)e=P[a],r=k[k[e].dl].dl+1,r>q&&(r=q,s++),k[e].dl=r,e>b||(S[r]++,A=0,e>=g&&(A=c[e-g]),h=k[e].fc,ba+=h*(r+A),null!==f&&(la+=h*(f[e].dl+A)));if(0!==s){do{for(r=q-1;0===S[r];)r--;S[r]--;S[r+1]+=2;S[q]--;s-=2}while(0b||(k[c].dl!==r&&(ba+=(r-k[c].dl)*k[c].fc,k[c].fc=r),e--)}Ea(d,l)},Fa=function(a,d){var b,g=-1,c,k=a[0].dl,l=0,q=7,e=4;0===k&&(q=138,e=3);a[d+1].dl=65535;for(b=0;b<=d;b++)c=k,k=a[b+1].dl,++l=l?W[17].fc++:W[18].fc++,l=0,g=c,0===k?(q=138,e=3):c===k?(q=6,e=3):(q=7,e=4))},Ga=function(){8b?Q[b]:Q[256+(b>>7)])&255,K(q,d),e=ma[q],0!==e&&(b-=ea[q],ga(b,e))),l>>=1;while(g=l?(K(17,W),ga(l-3,3)):(K(18,W),ga(l-11,7));l=0;g=c;0===k?(q=138,e=3):c===k?(q=6,e=3):(q=7,e=4)}},Ja=function(){var a;for(a=0;286>a;a++)$[a].fc=0;for(a=0;30>a;a++)ha[a].fc=0;for(a=0;19>a;a++)W[a].fc=0;$[256].fc=1;ia=D=fa=F=ba=la=0;Y=1},Ba=function(a){var d,b,g,c;c=z-x;oa[F]=ia;Ca(E);Ca(H);Fa($,E.max_code);Fa(ha,H.max_code);Ca(M);for(g=18;3<=g&& -0===W[za[g]].dl;g--);ba+=3*(g+1)+14;d=ba+3+7>>3;b=la+3+7>>3;b<=d&&(d=b);if(c+4<=d&&0<=x)for(ga(0+a,3),Ga(),ca(c),ca(~c),g=0;gc.len&&(e=c.len);for(f=0;fk-g&&(e=k-g);for(f=0;fh;h++)for(J[h]=r,f=0;f<1<h;h++)for(ea[h]=r,f=0;f<1<>=7;30>h;h++)for(ea[h]=r<<7,f=0;f<1<=f;f++)S[f]=0;for(f=0;143>=f;)U[f++].dl=8,S[8]++;for(;255>=f;)U[f++].dl=9,S[9]++;for(;279>=f;)U[f++].dl=7,S[7]++;for(;287>=f;)U[f++].dl=8,S[8]++;Ea(U,287);for(f=0;30>f;f++)O[f].dl=5,O[f].fc=Da(f,5);Ja()}for(f=0;8192>f;f++)w[32768+f]=0;ka=ta[T].max_lazy;ra=ta[T].good_length;Z=ta[T].max_chain;x=z=0;R=qa(l, -0,65536);if(0>=R)G=!0,R=0;else{for(G=!1;262>R&&!G;)Aa();for(f=u=0;2>f;f++)u=(u<<5^l[f]&255)&8191}c=null;g=k=0;3>=T?(I=2,A=0):(A=2,B=0);q=!1}a=!0;if(0===R)return q=!0,0}f=Ka(d,b,e);if(f===e)return e;if(q)return f;if(3>=T)for(;0!==R&&null===c;){X();0!==s&&32506>=z-s&&(A=va(s),A>R&&(A=R));if(3<=A)if(h=wa(z-N,A-3),R-=A,A<=ka){A--;do z++,X();while(0!==--A);z++}else z+=A,A=0,u=l[z]&255,u=(u<<5^l[z+1]&255)&8191;else h=wa(0,l[z]&255),R--,z++;h&&(Ba(0),x=z);for(;262>R&&!G;)Aa()}else for(;0!==R&&null===c;){X(); -I=A;C=N;A=2;0!==s&&I=z-s&&(A=va(s),A>R&&(A=R),3===A&&4096R&&!G;)Aa()}0===R&&(0!==B&&wa(0,l[z-1]&255),Ba(1),q=!0);return f+Ka(d,f+b,e-f)};this.deflate=function(g,k){var q,f;L=g;sa=0;"undefined"===String(typeof k)&&(k=6);(q=k)?1>q?q=1:9q;q++)$[q]=new e;ha=[];ha.length=61;for(q=0;61>q;q++)ha[q]=new e;U=[];U.length=288;for(q=0;288>q;q++)U[q]=new e;O=[];O.length=30;for(q=0;30>q;q++)O[q]=new e;W=[];W.length=39;for(q=0;39>q;q++)W[q]=new e;E=new h;H=new h;M=new h;S=[];S.length=16;P=[];P.length=573;da=[];da.length=573;V=[];V.length=256;Q=[];Q.length=512;J=[];J.length=29;ea=[];ea.length=30;oa=[];oa.length=1024}var A=Array(1024),s=[],n=[];for(q=La(A,0, -A.length);0>>8):(ea(g&255),ea(g>>>8))},pa=function(){t=(t<<5^n[z+3-1]&255)&8191;s=y[32768+t];y[z&32767]=s;y[32768+t]=z},aa=function(c,g){w>16-g?(x|=c<>16-w,w+=g-16):(x|=c<c;c++)n[c]=n[c+32768];M-=32768;z-=32768;v-=32768;for(c=0;8192>c;c++)g=y[32768+c],y[32768+c]=32768<=g?g-32768:0;for(c=0;32768>c;c++)g=y[c],y[c]=32768<=g?g-32768:0;b+=32768}H||(c=Aa(n,z+R,b),0>=c?H=!0:R+=c)},xa=function(c){var g=Z,b=z,a,d=I,f=32506=ka&&(g>>=2);do if(a=c,n[a+d]===r&&n[a+d-1]===e&&n[a]===n[b]&&n[++a]===n[b+1]){b+= +2;a++;do++b;while(n[b]===n[++a]&&n[++b]===n[++a]&&n[++b]===n[++a]&&n[++b]===n[++a]&&n[++b]===n[++a]&&n[++b]===n[++a]&&n[++b]===n[++a]&&n[++b]===n[++a]&&bd){M=c;d=a;if(258<=a)break;e=n[b+d-1];r=n[b+d]}c=y[c&32767]}while(c>f&&0!==--g);return d},qa=function(c,g){u[U++]=g;0===c?ba[g].fc++:(c--,ba[T[g]+256+1].fc++,ga[(256>c?P[c]:P[256+(c>>7)])&255].fc++,r[J++]=c,fa|=W);W<<=1;0===(U&7)&&(F[ia++]=fa,fa=0,W=1);if(2d;d++)b+=ga[d].fc* +(5+ma[d]);b>>=3;if(J>=1,b<<=1;while(0<--g);return b>>1},Ea=function(c,g){var b=[];b.length=16;var a=0,d;for(d=1;15>=d;d++)a=a+Q[d-1]<<1,b[d]=a;for(a=0;a<=g;a++)d=c[a].dl,0!==d&&(c[a].fc=Da(b[d]++,d))},Ca=function(c){var g=c.dyn_tree,b=c.static_tree,a=c.elems,d,n=-1, +f=a;ca=0;oa=573;for(d=0;dca;)d=O[++ca]=2>n?++n:0,g[d].fc=1,da[d]=0,ha--,null!==b&&(B-=b[d].dl);c.max_code=n;for(d=ca>>1;1<=d;d--)ya(g,d);do d=O[1],O[1]=O[ca--],ya(g,1),b=O[1],O[--oa]=d,O[--oa]=b,g[f].fc=g[d].fc+g[b].fc,da[f]=da[d]>da[b]+1?da[d]:da[b]+1,g[d].dl=g[b].dl=f,O[1]=f++,ya(g,1);while(2<=ca);O[--oa]=O[1];f=c.dyn_tree;d=c.extra_bits;var a=c.extra_base,b=c.max_code,k=c.max_length,e=c.static_tree,r,s,h,C,l=0;for(s=0;15>=s;s++)Q[s]=0;f[O[oa]].dl= +0;for(c=oa+1;573>c;c++)r=O[c],s=f[f[r].dl].dl+1,s>k&&(s=k,l++),f[r].dl=s,r>b||(Q[s]++,h=0,r>=a&&(h=d[r-a]),C=f[r].fc,ha+=C*(s+h),null!==e&&(B+=C*(e[r].dl+h)));if(0!==l){do{for(s=k-1;0===Q[s];)s--;Q[s]--;Q[s+1]+=2;Q[k]--;l-=2}while(0b||(f[d].dl!==s&&(ha+=(s-f[d].dl)*f[d].fc,f[d].fc=s),r--)}Ea(g,n)},Fa=function(c,g){var b,a=-1,d,n=c[0].dl,f=0,k=7,e=4;0===n&&(k=138,e=3);c[g+1].dl=65535;for(b=0;b<=g;b++)d=n,n=c[b+1].dl,++f=f?V[17].fc++:V[18].fc++,f=0,a=d,0===n?(k=138,e=3):d===n?(k=6,e=3):(k=7,e=4))},Ga=function(){8b?P[b]:P[256+(b>>7)])&255,K(k,g),e=ma[k],0!==e&&(b-=$[k],aa(b,e))),f>>=1;while(a=f?(K(17,V),aa(f-3,3)):(K(18,V),aa(f-11,7));f=0;a=d;0===n?(k=138,e=3):d===n?(k=6,e=3):(k=7,e=4)}},Ja=function(){var c;for(c=0;286>c;c++)ba[c].fc=0;for(c=0;30>c;c++)ga[c].fc=0;for(c=0;19>c;c++)V[c].fc=0;ba[256].fc=1;fa=U=J=ia=ha=B=0;W=1},Ba=function(c){var g,b,a,d;d=z-v;F[ia]=fa;Ca(N);Ca(L);Fa(ba,N.max_code);Fa(ga,L.max_code);Ca(G);for(a=18;3<=a&&0===V[va[a]].dl;a--); +ha+=3*(a+1)+14;g=ha+3+7>>3;b=B+3+7>>3;b<=g&&(g=b);if(d+4<=g&&0<=v)for(aa(0+c,3),Ga(),X(d),X(~d),a=0;aa.len&&(e=a.len);for(r=0;rk-c&&(e=k-c);for(r=0;rl;l++)for(ra[l]= +h,r=0;r<1<l;l++)for($[l]=h,r=0;r<1<>=7;30>l;l++)for($[l]=h<<7,r=0;r<1<=r;r++)Q[r]=0;for(r=0;143>=r;)S[r++].dl=8,Q[8]++;for(;255>=r;)S[r++].dl=9,Q[9]++;for(;279>=r;)S[r++].dl=7,Q[7]++;for(;287>=r;)S[r++].dl=8,Q[8]++;Ea(S,287);for(r=0;30>r;r++)Y[r].dl=5,Y[r].fc=Da(r,5);Ja()}for(r=0;8192>r;r++)y[32768+r]=0;ja=wa[E].max_lazy;ka=wa[E].good_length;Z=wa[E].max_chain;v=z=0;R=Aa(n,0,65536);if(0>=R)H=!0, +R=0;else{for(H=!1;262>R&&!H;)ua();for(r=t=0;2>r;r++)t=(t<<5^n[r]&255)&8191}a=null;c=k=0;3>=E?(I=2,C=0):(C=2,A=0);g=!1}f=!0;if(0===R)return g=!0,0}r=Ka(b,d,e);if(r===e)return e;if(g)return r;if(3>=E)for(;0!==R&&null===a;){pa();0!==s&&32506>=z-s&&(C=xa(s),C>R&&(C=R));if(3<=C)if(l=qa(z-M,C-3),R-=C,C<=ja){C--;do z++,pa();while(0!==--C);z++}else z+=C,C=0,t=n[z]&255,t=(t<<5^n[z+1]&255)&8191;else l=qa(0,n[z]&255),R--,z++;l&&(Ba(0),v=z);for(;262>R&&!H;)ua()}else for(;0!==R&&null===a;){pa();I=C;D=M;C=2;0!== +s&&I=z-s&&(C=xa(s),C>R&&(C=R),3===C&&4096R&&!H;)ua()}0===R&&(0!==A&&qa(0,n[z-1]&255),Ba(1),g=!0);return r+Ka(b,r+d,e-r)};this.deflate=function(c,g){var k,e;sa=c;la=0;"undefined"===String(typeof g)&&(g=6);(k=g)?1>k?k=1:9k;k++)ba[k]=new h;ga=[];ga.length=61;for(k=0;61>k;k++)ga[k]=new h;S=[];S.length=288;for(k=0;288>k;k++)S[k]=new h;Y=[];Y.length=30;for(k=0;30>k;k++)Y[k]=new h;V=[];V.length=39;for(k=0;39>k;k++)V[k]=new h;N=new m;L=new m;G=new m;Q=[];Q.length=16;O=[];O.length=573;da=[];da.length=573;T=[];T.length=256;P=[];P.length=512;ra=[];ra.length=29;$=[];$.length=30;F=[];F.length=1024}var s=Array(1024),C=[],p=[];for(k=La(s,0,s.length);0>8&255])};this.appendUInt32LE=function(f){h.appendArray([f&255,f>>8&255,f>>16&255,f>>24&255])};this.appendString=function(h){f=runtime.concatByteArrays(f, -runtime.byteArrayFromString(h,e))};this.getLength=function(){return f.length};this.getByteArray=function(){return f}}; +core.ByteArrayWriter=function(h){var m=this,e=new runtime.ByteArray(0);this.appendByteArrayWriter=function(h){e=runtime.concatByteArrays(e,h.getByteArray())};this.appendByteArray=function(h){e=runtime.concatByteArrays(e,h)};this.appendArray=function(h){e=runtime.concatByteArrays(e,runtime.byteArrayFromArray(h))};this.appendUInt16LE=function(e){m.appendArray([e&255,e>>8&255])};this.appendUInt32LE=function(e){m.appendArray([e&255,e>>8&255,e>>16&255,e>>24&255])};this.appendString=function(m){e=runtime.concatByteArrays(e, +runtime.byteArrayFromString(m,h))};this.getLength=function(){return e.length};this.getByteArray=function(){return e}}; // Input 6 -core.RawInflate=function(){var e,h,f=null,n,m,p,c,b,a,d,k,g,q,l,r,t,w,v=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535],y=[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],u=[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],s=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],C=[16,17,18, -0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],B=function(){this.list=this.next=null},A=function(){this.n=this.b=this.e=0;this.t=null},I=function(a,d,b,g,c,l){this.BMAX=16;this.N_MAX=288;this.status=0;this.root=null;this.m=0;var k=Array(this.BMAX+1),q,f,e,r,h,s,t,m=Array(this.BMAX+1),p,n,N,w=new A,G=Array(this.BMAX);r=Array(this.N_MAX);var z,u=Array(this.BMAX+1),I,v,R;R=this.root=null;for(h=0;hh&&(l=h);for(I=1<(I-=k[s])){this.status=2;this.m=l;return}if(0>(I-=k[h]))this.status=2,this.m=l;else{k[h]+=I;u[1]=s=0;p=k;n=1;for(N=2;0<--h;)u[N++]=s+=p[n++];p=a;h=n=0;do 0!=(s=p[n++])&&(r[u[s]++]=h);while(++hz+m[1+r];){z+=m[1+r];r++;v=(v=e-z)>l?l:v;if((f=1<<(s=t-z))>a+1)for(f-=a+1,N=t;++sq&&z>z-m[r],G[r-1][s].e=w.e,G[r-1][s].b=w.b,G[r-1][s].n=w.n,G[r-1][s].t=w.t)}w.b=t-z;n>=d?w.e=99:p[n]p[n]?16:15,w.n=p[n++]): -(w.e=c[p[n]-b],w.n=g[p[n++]-b]);f=1<>z;s>=1)h^=s;for(h^=s;(h&(1<>=a;c-=a},R=function(a,c,f){var s,A,t;if(0==f)return 0;for(t=0;;){z(l);A=g.list[N(l)];for(s=A.e;16 -k;k++)m[C[k]]=0;l=7;k=new I(m,19,19,null,null,l);if(0!=k.status)return-1;g=k.root;l=k.m;e=A+t;for(c=f=0;ck)m[c++]=f=k;else if(16==k){z(2);k=3+N(2);G(2);if(c+k>e)return-1;for(;0e)return-1;for(;0H;H++)E[H]=8;for(;256>H;H++)E[H]=9;for(;280>H;H++)E[H]=7;for(;288>H;H++)E[H]=8;m=7;H=new I(E,288,257,y,x,m);if(0!=H.status){alert("HufBuild error: "+H.status);U=-1;break b}f=H.root;m=H.m;for(H=0;30>H;H++)E[H]=5;Z=5;H=new I(E,30,0,u,s,Z);if(1h&&(n=h);for(z=1<(z-=f[l])){this.status=2;this.m=n;return}if(0>(z-=f[h]))this.status=2,this.m=n;else{f[h]+=z;H[1]=l=0;q=f;M=1;for(x=2;0<--h;)H[x++]=l+=q[M++];q=c;h=M=0;do 0!=(l=q[M++])&&(s[H[l]++]=h);while(++hv+p[1+s];){v+=p[1+s];s++;I=(I=r-v)>n?n:I;if((e=1<<(l=m-v))>c+1)for(e-=c+1,x=m;++lk&&v>v-p[s],t[s-1][l].e=u.e,t[s-1][l].b=u.b,t[s-1][l].n=u.n,t[s-1][l].t=u.t)}u.b=m-v;M>=g?u.e=99:q[M]q[M]?16:15,u.n=q[M++]): +(u.e=d[q[M]-b],u.n=a[q[M++]-b]);e=1<>v;l>=1)h^=l;for(h^=l;(h&(1<>=c;a-=c},R=function(a,f,e){var l,s,C;if(0==e)return 0;for(C=0;;){z(n);s=c.list[M(n)];for(l=s.e;16 +k;k++)p[D[k]]=0;n=7;k=new I(p,19,19,null,null,n);if(0!=k.status)return-1;c=k.root;n=k.m;l=C+m;for(f=e=0;fk)p[f++]=e=k;else if(16==k){z(2);k=3+M(2);H(2);if(f+k>l)return-1;for(;0l)return-1;for(;0L;L++)N[L]=8;for(;256>L;L++)N[L]=9;for(;280>L;L++)N[L]=7;for(;288>L;L++)N[L]=8;l=7;L=new I(N,288,257,w,v,l);if(0!=L.status){alert("HufBuild error: "+L.status);S=-1;break b}e=L.root;l=L.m;for(L=0;30>L;L++)N[L]=5;Z=5;L=new I(N,30,0,t,s,Z);if(1e))throw runtime.log("alert","watchdog timeout"),"timeout!";if(0h))throw runtime.log("alert","watchdog loop overflow"),"loop overflow";}}; +core.LoopWatchDog=function(h,m){var e=Date.now(),p=0;this.check=function(){var l;if(h&&(l=Date.now(),l-e>h))throw runtime.log("alert","watchdog timeout"),"timeout!";if(0m))throw runtime.log("alert","watchdog loop overflow"),"loop overflow";}}; // Input 8 -core.Utils=function(){function e(h,f){f&&Array.isArray(f)?h=(h||[]).concat(f.map(function(f){return e({},f)})):f&&"object"===typeof f?(h=h||{},Object.keys(f).forEach(function(n){h[n]=e(h[n],f[n])})):h=f;return h}this.hashString=function(e){var f=0,n,m;n=0;for(m=e.length;n=b.compareBoundaryPoints(b.START_TO_START, -a)&&0<=b.compareBoundaryPoints(b.END_TO_END,a)};this.rangesIntersect=function(b,a){return 0>=b.compareBoundaryPoints(b.END_TO_START,a)&&0<=b.compareBoundaryPoints(b.START_TO_END,a)};this.getNodesInRange=function(b,a){var d=[],c,g,q=b.startContainer.ownerDocument.createTreeWalker(b.commonAncestorContainer,NodeFilter.SHOW_ALL,a,!1);for(c=q.currentNode=b.startContainer;c;){g=a(c);if(g===NodeFilter.FILTER_ACCEPT)d.push(c);else if(g===NodeFilter.FILTER_REJECT)break;c=c.parentNode}d.reverse();for(c=q.nextNode();c;)d.push(c), -c=q.nextNode();return d};this.normalizeTextNodes=function(b){b&&b.nextSibling&&(b=f(b,b.nextSibling));b&&b.previousSibling&&f(b.previousSibling,b)};this.rangeContainsNode=function(b,a){var d=a.ownerDocument.createRange(),c=a.nodeType===Node.TEXT_NODE?a.length:a.childNodes.length;d.setStart(b.startContainer,b.startOffset);d.setEnd(b.endContainer,b.endOffset);c=0===d.comparePoint(a,0)&&0===d.comparePoint(a,c);d.detach();return c};this.mergeIntoParent=h;this.removeUnwantedNodes=m;this.getElementsByTagNameNS= -function(b,a,d){return Array.prototype.slice.call(b.getElementsByTagNameNS(a,d))};this.rangeIntersectsNode=function(b,a){var d=a.nodeType===Node.TEXT_NODE?a.length:a.childNodes.length;return 0>=b.comparePoint(a,0)&&0<=b.comparePoint(a,d)};this.containsNode=function(b,a){return b===a||b.contains(a)};this.comparePoints=function(b,a,d,c){if(b===d)return c-a;var g=b.compareDocumentPosition(d);2===g?g=-1:4===g?g=1:10===g?(a=p(b,d),g=a=a.compareBoundaryPoints(a.START_TO_START, +f)&&0<=a.compareBoundaryPoints(a.END_TO_END,f)};this.rangesIntersect=function(a,f){return 0>=a.compareBoundaryPoints(a.END_TO_START,f)&&0<=a.compareBoundaryPoints(a.START_TO_END,f)};this.getNodesInRange=function(a,f){var b=[],k,c,g=a.startContainer.ownerDocument.createTreeWalker(a.commonAncestorContainer,NodeFilter.SHOW_ALL,f,!1);for(k=g.currentNode=a.startContainer;k;){c=f(k);if(c===NodeFilter.FILTER_ACCEPT)b.push(k);else if(c===NodeFilter.FILTER_REJECT)break;k=k.parentNode}b.reverse();for(k=g.nextNode();k;)b.push(k), +k=g.nextNode();return b};this.normalizeTextNodes=function(a){a&&a.nextSibling&&(a=e(a,a.nextSibling));a&&a.previousSibling&&e(a.previousSibling,a)};this.rangeContainsNode=function(a,f){var b=f.ownerDocument.createRange(),k=f.nodeType===Node.TEXT_NODE?f.length:f.childNodes.length;b.setStart(a.startContainer,a.startOffset);b.setEnd(a.endContainer,a.endOffset);k=0===b.comparePoint(f,0)&&0===b.comparePoint(f,k);b.detach();return k};this.mergeIntoParent=m;this.removeUnwantedNodes=l;this.getElementsByTagNameNS= +function(a,f,b){return Array.prototype.slice.call(a.getElementsByTagNameNS(f,b))};this.rangeIntersectsNode=function(a,f){var b=f.nodeType===Node.TEXT_NODE?f.length:f.childNodes.length;return 0>=a.comparePoint(f,0)&&0<=a.comparePoint(f,b)};this.containsNode=function(a,f){return a===f||a.contains(f)};this.comparePoints=function(a,f,b,k){if(a===b)return k-f;var c=a.compareDocumentPosition(b);2===c?c=-1:4===c?c=1:10===c?(f=q(a,b),c=f";return runtime.parseXML(f)}; -core.UnitTestRunner=function(){function e(a){c+=1;runtime.log("fail",a)}function h(a,d){var b;try{if(a.length!==d.length)return e("array of length "+a.length+" should be "+d.length+" long"),!1;for(b=0;b1/q?"-0":String(q),e(d+" should be "+a+". Was "+b+".")):e(d+" should be "+a+" (of type "+typeof a+"). Was "+q+" (of type "+typeof q+").")}var c=0,b;b=function(a,d){var b=Object.keys(a),c=Object.keys(d);b.sort();c.sort();return h(b,c)&&Object.keys(a).every(function(b){var c= -a[b],g=d[b];return m(c,g)?!0:(e(c+" should be "+g+" for key "+b),!1)})};this.areNodesEqual=n;this.shouldBeNull=function(a,d){p(a,d,"null")};this.shouldBeNonNull=function(a,d){var b,c;try{c=eval(d)}catch(q){b=q}b?e(d+" should be non-null. Threw exception "+b):null!==c?runtime.log("pass",d+" is non-null."):e(d+" should be non-null. Was "+c)};this.shouldBe=p;this.countFailedTests=function(){return c}}; -core.UnitTester=function(){function e(f,e){return""+f+""}var h=0,f={};this.runTests=function(n,m,p){function c(g){if(0===g.length)f[b]=k,h+=a.countFailedTests(),m();else{q=g[0];var l=Runtime.getFunctionName(q);runtime.log("Running "+l);r=a.countFailedTests();d.setUp();q(function(){d.tearDown();k[l]=r===a.countFailedTests();c(g.slice(1))})}}var b=Runtime.getFunctionName(n),a=new core.UnitTestRunner,d=new n(a),k={},g,q,l,r,t="BrowserRuntime"=== -runtime.type();if(f.hasOwnProperty(b))runtime.log("Test "+b+" has already run.");else{t?runtime.log("Running "+e(b,'runSuite("'+b+'");')+": "+d.description()+""):runtime.log("Running "+b+": "+d.description);l=d.tests();for(g=0;gRunning "+e(n,'runTest("'+b+'","'+n+'")')+""):runtime.log("Running "+n),r=a.countFailedTests(),d.setUp(),q(),d.tearDown(),k[n]=r===a.countFailedTests()); -c(d.asyncTests())}};this.countFailedTests=function(){return h};this.results=function(){return f}}; +core.UnitTest.provideTestAreaDiv=function(){var h=runtime.getWindow().document,m=h.getElementById("testarea");runtime.assert(!m,'Unclean test environment, found a div with id "testarea".');m=h.createElement("div");m.setAttribute("id","testarea");h.body.appendChild(m);return m}; +core.UnitTest.cleanupTestAreaDiv=function(){var h=runtime.getWindow().document,m=h.getElementById("testarea");runtime.assert(!!m&&m.parentNode===h.body,'Test environment broken, found no div with id "testarea" below body.');h.body.removeChild(m)};core.UnitTest.createOdtDocument=function(h,m){var e="",e=e+"";return runtime.parseXML(e)}; +core.UnitTestRunner=function(){function h(f){a+=1;runtime.log("fail",f)}function m(a,b){var d;try{if(a.length!==b.length)return h("array of length "+a.length+" should be "+b.length+" long"),!1;for(d=0;d1/g?"-0":String(g),h(b+" should be "+a+". Was "+d+".")):h(b+" should be "+a+" (of type "+typeof a+"). Was "+g+" (of type "+typeof g+").")}var a=0,d;d=function(a,b){var d=Object.keys(a),c=Object.keys(b);d.sort();c.sort();return m(d,c)&&Object.keys(a).every(function(c){var d=a[c],k=b[c];return l(d,k)?!0:(h(d+" should be "+k+" for key "+c),!1)})};this.areNodesEqual=p;this.shouldBeNull=function(a,b){q(a,b,"null")}; +this.shouldBeNonNull=function(a,b){var d,c;try{c=eval(b)}catch(g){d=g}d?h(b+" should be non-null. Threw exception "+d):null!==c?runtime.log("pass",b+" is non-null."):h(b+" should be non-null. Was "+c)};this.shouldBe=q;this.countFailedTests=function(){return a}}; +core.UnitTester=function(){function h(e,h){return""+e+""}var m=0,e={};this.runTests=function(p,l,q){function a(c){if(0===c.length)e[d]=k,m+=f.countFailedTests(),l();else{g=c[0];var n=Runtime.getFunctionName(g);runtime.log("Running "+n);r=f.countFailedTests();b.setUp();g(function(){b.tearDown();k[n]=r===f.countFailedTests();a(c.slice(1))})}}var d=Runtime.getFunctionName(p),f=new core.UnitTestRunner,b=new p(f),k={},c,g,n,r,u="BrowserRuntime"=== +runtime.type();if(e.hasOwnProperty(d))runtime.log("Test "+d+" has already run.");else{u?runtime.log("Running "+h(d,'runSuite("'+d+'");')+": "+b.description()+""):runtime.log("Running "+d+": "+b.description);n=b.tests();for(c=0;cRunning "+h(p,'runTest("'+d+'","'+p+'")')+""):runtime.log("Running "+p),r=f.countFailedTests(),b.setUp(),g(),b.tearDown(),k[p]=r===f.countFailedTests()); +a(b.asyncTests())}};this.countFailedTests=function(){return m};this.results=function(){return e}}; // Input 13 -core.PositionIterator=function(e,h,f,n){function m(){this.acceptNode=function(a){return a.nodeType===Node.TEXT_NODE&&0===a.length?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}}function p(a){this.acceptNode=function(d){return d.nodeType===Node.TEXT_NODE&&0===d.length?NodeFilter.FILTER_REJECT:a.acceptNode(d)}}function c(){var b=a.currentNode.nodeType;d=b===Node.TEXT_NODE?a.currentNode.length-1:b===Node.ELEMENT_NODE?1:0}var b=this,a,d,k;this.nextPosition=function(){if(a.currentNode===e)return!1; -if(0===d&&a.currentNode.nodeType===Node.ELEMENT_NODE)null===a.firstChild()&&(d=1);else if(a.currentNode.nodeType===Node.TEXT_NODE&&d+1 "+c.length),runtime.assert(0<=f,"Error in setPosition: "+f+" < 0"),f===c.length&&(d=void 0,a.nextSibling()?d=0:a.parentNode()&&(d=1),runtime.assert(void 0!==d,"Error in setPosition: position not valid.")),!0;l=k(c);for(h=c.parentNode;h&&h!==e&&l===NodeFilter.FILTER_ACCEPT;)l= -k(h),l!==NodeFilter.FILTER_ACCEPT&&(a.currentNode=h),h=h.parentNode;f "+a.length),runtime.assert(0<=d,"Error in setPosition: "+d+" < 0"),d===a.length&&(k=void 0,b.nextSibling()?k=0:b.parentNode()&&(k=1),runtime.assert(void 0!==k,"Error in setPosition: position not valid.")),!0;e=c(a);for(l=a.parentNode;l&&l!==h&&e===NodeFilter.FILTER_ACCEPT;)e= +c(l),e!==NodeFilter.FILTER_ACCEPT&&(b.currentNode=l),l=l.parentNode;d>>8^l;return b^-1}function n(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 m(a){var d=a.getFullYear();return 1980>d?0:d-1980<< -25|a.getMonth()+1<<21|a.getDate()<<16|a.getHours()<<11|a.getMinutes()<<5|a.getSeconds()>>1}function p(a,d){var b,c,g,l,k,f,e,q=this;this.load=function(d){if(void 0!==q.data)d(null,q.data);else{var b=k+34+c+g+256;b+e>r&&(b=r-e);runtime.read(a,e,b,function(b,c){if(b||null===c)d(b,c);else a:{var g=c,e=new core.ByteArray(g),h=e.readUInt32LE(),r;if(67324752!==h)d("File entry signature is wrong."+h.toString()+" "+g.length.toString(),null);else{e.pos+=22;h=e.readUInt16LE();r=e.readUInt16LE();e.pos+=h+r; -if(l){g=g.slice(e.pos,e.pos+k);if(k!==g.length){d("The amount of compressed bytes read was "+g.length.toString()+" instead of "+k.toString()+" for "+q.filename+" in "+a+".",null);break a}g=w(g,f)}else g=g.slice(e.pos,e.pos+f);f!==g.length?d("The amount of bytes read was "+g.length.toString()+" instead of "+f.toString()+" for "+q.filename+" in "+a+".",null):(q.data=g,d(null,g))}}})}};this.set=function(a,d,b,c){q.filename=a;q.data=d;q.compressed=b;q.date=c};this.error=null;d&&(b=d.readUInt32LE(),33639248!== -b?this.error="Central directory entry has wrong signature at position "+(d.pos-4).toString()+' for file "'+a+'": '+d.data.length.toString():(d.pos+=6,l=d.readUInt16LE(),this.date=n(d.readUInt32LE()),d.readUInt32LE(),k=d.readUInt32LE(),f=d.readUInt32LE(),c=d.readUInt16LE(),g=d.readUInt16LE(),b=d.readUInt16LE(),d.pos+=8,e=d.readUInt32LE(),this.filename=runtime.byteArrayToString(d.data.slice(d.pos,d.pos+c),"utf8"),d.pos+=c+g+b))}function c(a,d){if(22!==a.length)d("Central directory length should be 22.", -v);else{var b=new core.ByteArray(a),c;c=b.readUInt32LE();101010256!==c?d("Central directory signature is wrong: "+c.toString(),v):(c=b.readUInt16LE(),0!==c?d("Zip files with non-zero disk numbers are not supported.",v):(c=b.readUInt16LE(),0!==c?d("Zip files with non-zero disk numbers are not supported.",v):(c=b.readUInt16LE(),t=b.readUInt16LE(),c!==t?d("Number of entries is inconsistent.",v):(c=b.readUInt32LE(),b=b.readUInt16LE(),b=r-22-c,runtime.read(e,b,r-b,function(a,b){if(a||null===b)d(a,v);else a:{var c= -new core.ByteArray(b),g,k;l=[];for(g=0;gr?h("File '"+e+"' cannot be read.",v):runtime.read(e,r-22,22,function(a,d){a||null===h||null===d?h(a,v):c(d,h)})})}; +2932959818,3654703836,1088359270,936918E3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117],b,g,d=c.length,n=0,n=0;b=-1;for(g=0;g>>8^n;return b^-1}function p(c){return new Date((c>>25&127)+1980,(c>>21&15)-1,c>>16&31,c>>11&15,c>>5&63,(c&31)<<1)}function l(c){var a=c.getFullYear();return 1980>a?0:a-1980<< +25|c.getMonth()+1<<21|c.getDate()<<16|c.getHours()<<11|c.getMinutes()<<5|c.getSeconds()>>1}function q(c,a){var b,g,d,n,f,k,e,h=this;this.load=function(a){if(void 0!==h.data)a(null,h.data);else{var b=f+34+g+d+256;b+e>r&&(b=r-e);runtime.read(c,e,b,function(b,g){if(b||null===g)a(b,g);else a:{var d=g,e=new core.ByteArray(d),r=e.readUInt32LE(),l;if(67324752!==r)a("File entry signature is wrong."+r.toString()+" "+d.length.toString(),null);else{e.pos+=22;r=e.readUInt16LE();l=e.readUInt16LE();e.pos+=r+l; +if(n){d=d.slice(e.pos,e.pos+f);if(f!==d.length){a("The amount of compressed bytes read was "+d.length.toString()+" instead of "+f.toString()+" for "+h.filename+" in "+c+".",null);break a}d=y(d,k)}else d=d.slice(e.pos,e.pos+k);k!==d.length?a("The amount of bytes read was "+d.length.toString()+" instead of "+k.toString()+" for "+h.filename+" in "+c+".",null):(h.data=d,a(null,d))}}})}};this.set=function(c,a,b,g){h.filename=c;h.data=a;h.compressed=b;h.date=g};this.error=null;a&&(b=a.readUInt32LE(),33639248!== +b?this.error="Central directory entry has wrong signature at position "+(a.pos-4).toString()+' for file "'+c+'": '+a.data.length.toString():(a.pos+=6,n=a.readUInt16LE(),this.date=p(a.readUInt32LE()),a.readUInt32LE(),f=a.readUInt32LE(),k=a.readUInt32LE(),g=a.readUInt16LE(),d=a.readUInt16LE(),b=a.readUInt16LE(),a.pos+=8,e=a.readUInt32LE(),this.filename=runtime.byteArrayToString(a.data.slice(a.pos,a.pos+g),"utf8"),a.pos+=g+d+b))}function a(c,a){if(22!==c.length)a("Central directory length should be 22.", +x);else{var b=new core.ByteArray(c),g;g=b.readUInt32LE();101010256!==g?a("Central directory signature is wrong: "+g.toString(),x):(g=b.readUInt16LE(),0!==g?a("Zip files with non-zero disk numbers are not supported.",x):(g=b.readUInt16LE(),0!==g?a("Zip files with non-zero disk numbers are not supported.",x):(g=b.readUInt16LE(),u=b.readUInt16LE(),g!==u?a("Number of entries is inconsistent.",x):(g=b.readUInt32LE(),b=b.readUInt16LE(),b=r-22-g,runtime.read(h,b,r-b,function(c,b){if(c||null===b)a(c,x);else a:{var g= +new core.ByteArray(b),d,f;n=[];for(d=0;dr?m("File '"+h+"' cannot be read.",x):runtime.read(h,r-22,22,function(c,b){c||null===m||null===b?m(c,x):a(b,m)})})}; // Input 19 -core.CSSUnits=function(){var e={"in":1,cm:2.54,mm:25.4,pt:72,pc:12};this.convert=function(h,f,n){return h*e[n]/e[f]};this.convertMeasure=function(e,f){var n,m;e&&f?(n=parseFloat(e),m=e.replace(n.toString(),""),n=this.convert(n,m,f)):n="";return n.toString()};this.getUnits=function(e){return e.substr(e.length-2,e.length)}}; +core.CSSUnits=function(){var h={"in":1,cm:2.54,mm:25.4,pt:72,pc:12};this.convert=function(m,e,p){return m*h[p]/h[e]};this.convertMeasure=function(h,e){var p,l;h&&e?(p=parseFloat(h),l=h.replace(p.toString(),""),p=this.convert(p,l,e)):p="";return p.toString()};this.getUnits=function(h){return h.substr(h.length-2,h.length)}}; // Input 20 xmldom.LSSerializerFilter=function(){}; // Input 21 -"function"!==typeof Object.create&&(Object.create=function(e){var h=function(){};h.prototype=e;return new h}); -xmldom.LSSerializer=function(){function e(e){var f=e||{},c=function(a){var d={},b;for(b in a)a.hasOwnProperty(b)&&(d[a[b]]=b);return d}(e),b=[f],a=[c],d=0;this.push=function(){d+=1;f=b[d]=Object.create(f);c=a[d]=Object.create(c)};this.pop=function(){b[d]=void 0;a[d]=void 0;d-=1;f=b[d];c=a[d]};this.getLocalNamespaceDefinitions=function(){return c};this.getQName=function(a){var d=a.namespaceURI,b=0,l;if(!d)return a.localName;if(l=c[d])return l+":"+a.localName;do{l||!a.prefix?(l="ns"+b,b+=1):l=a.prefix; -if(f[l]===d)break;if(!f[l]){f[l]=d;c[d]=l;break}l=null}while(null===l);return l+":"+a.localName}}function h(f){return f.replace(/&/g,"&").replace(//g,">").replace(/'/g,"'").replace(/"/g,""")}function f(e,p){var c="",b=n.filter?n.filter.acceptNode(p):NodeFilter.FILTER_ACCEPT,a;if(b===NodeFilter.FILTER_ACCEPT&&p.nodeType===Node.ELEMENT_NODE){e.push();a=e.getQName(p);var d,k=p.attributes,g,q,l,r="",t;d="<"+a;g=k.length;for(q=0;q")}if(b===NodeFilter.FILTER_ACCEPT||b===NodeFilter.FILTER_SKIP){for(b=p.firstChild;b;)c+=f(e,b),b=b.nextSibling;p.nodeValue&&(c+=h(p.nodeValue))}a&&(c+="",e.pop());return c}var n=this;this.filter=null;this.writeToString=function(h,p){if(!h)return"";var c=new e(p);return f(c,h)}}; +"function"!==typeof Object.create&&(Object.create=function(h){var m=function(){};m.prototype=h;return new m}); +xmldom.LSSerializer=function(){function h(e){var h=e||{},a=function(a){var c={},b;for(b in a)a.hasOwnProperty(b)&&(c[a[b]]=b);return c}(e),d=[h],f=[a],b=0;this.push=function(){b+=1;h=d[b]=Object.create(h);a=f[b]=Object.create(a)};this.pop=function(){d[b]=void 0;f[b]=void 0;b-=1;h=d[b];a=f[b]};this.getLocalNamespaceDefinitions=function(){return a};this.getQName=function(b){var c=b.namespaceURI,g=0,d;if(!c)return b.localName;if(d=a[c])return d+":"+b.localName;do{d||!b.prefix?(d="ns"+g,g+=1):d=b.prefix; +if(h[d]===c)break;if(!h[d]){h[d]=c;a[c]=d;break}d=null}while(null===d);return d+":"+b.localName}}function m(e){return e.replace(/&/g,"&").replace(//g,">").replace(/'/g,"'").replace(/"/g,""")}function e(h,q){var a="",d=p.filter?p.filter.acceptNode(q):NodeFilter.FILTER_ACCEPT,f;if(d===NodeFilter.FILTER_ACCEPT&&q.nodeType===Node.ELEMENT_NODE){h.push();f=h.getQName(q);var b,k=q.attributes,c,g,n,r="",u;b="<"+f;c=k.length;for(g=0;g")}if(d===NodeFilter.FILTER_ACCEPT||d===NodeFilter.FILTER_SKIP){for(d=q.firstChild;d;)a+=e(h,d),d=d.nextSibling;q.nodeValue&&(a+=m(q.nodeValue))}f&&(a+="",h.pop());return a}var p=this;this.filter=null;this.writeToString=function(l,m){if(!l)return"";var a=new h(m);return e(a,l)}}; // Input 22 -xmldom.RelaxNGParser=function(){function e(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 h(a){if(2>=a.e.length)return a;var b={name:a.name,e:a.e.slice(0,2)};return h({name:a.name,e:[b].concat(a.e.slice(2))})}function f(a){a=a.split(":",2);var c="",g;1===a.length?a=["",a[0]]:c=a[0];for(g in b)b[g]===c&&(a[0]=g);return a}function n(a,b){for(var c=0,e,l,h=a.name;a.e&&c=a.e.length)return a;var d={name:a.name,e:a.e.slice(0,2)};return m({name:a.name,e:[d].concat(a.e.slice(2))})}function e(a){a=a.split(":",2);var f="",c;1===a.length?a=["",a[0]]:f=a[0];for(c in d)d[c]===f&&(a[0]=c);return a}function p(a,d){for(var c=0,g,f,h=a.name;a.e&&c=g.length)return c;0===e&&(e=0);for(var l=g.item(e);l.namespaceURI===d;){e+=1;if(e>=g.length)return c;l=g.item(e)}return l=b(a,c.attDeriv(a,g.item(e)),g,e+1)}function a(b,d,c){c.e[0].a?(b.push(c.e[0].text),d.push(c.e[0].a.ns)):a(b,d,c.e[0]);c.e[1].a?(b.push(c.e[1].text),d.push(c.e[1].a.ns)): -a(b,d,c.e[1])}var d="http://www.w3.org/2000/xmlns/",k,g,q,l,r,t,w,v,y,x,u={type:"notAllowed",nullable:!1,hash:"notAllowed",textDeriv:function(){return u},startTagOpenDeriv:function(){return u},attDeriv:function(){return u},startTagCloseDeriv:function(){return u},endTagDeriv:function(){return u}},s={type:"empty",nullable:!0,hash:"empty",textDeriv:function(){return u},startTagOpenDeriv:function(){return u},attDeriv:function(){return u},startTagCloseDeriv:function(){return s},endTagDeriv:function(){return u}}, -C={type:"text",nullable:!0,hash:"text",textDeriv:function(){return C},startTagOpenDeriv:function(){return u},attDeriv:function(){return u},startTagCloseDeriv:function(){return C},endTagDeriv:function(){return u}},B,A,I;k=n("choice",function(a,b){if(a===u)return b;if(b===u||a===b)return a},function(a,b){var d={},c;m(d,{p1:a,p2:b});b=a=void 0;for(c in d)d.hasOwnProperty(c)&&(void 0===a?a=d[c]:b=void 0===b?d[c]:k(b,d[c]));return function(a,b){return{type:"choice",p1:a,p2:b,nullable:a.nullable||b.nullable, -textDeriv:function(d,c){return k(a.textDeriv(d,c),b.textDeriv(d,c))},startTagOpenDeriv:f(function(d){return k(a.startTagOpenDeriv(d),b.startTagOpenDeriv(d))}),attDeriv:function(d,c){return k(a.attDeriv(d,c),b.attDeriv(d,c))},startTagCloseDeriv:e(function(){return k(a.startTagCloseDeriv(),b.startTagCloseDeriv())}),endTagDeriv:e(function(){return k(a.endTagDeriv(),b.endTagDeriv())})}}(a,b)});g=function(a,b,d){return function(){var c={},g=0;return function(e,l){var f=b&&b(e,l),k,h;if(void 0!==f)return f; -f=e.hash||e.toString();k=l.hash||l.toString();f=g.length)return c;0===f&&(f=0);for(var n=g.item(f);n.namespaceURI===b;){f+=1;if(f>=g.length)return c;n=g.item(f)}return n=d(a,c.attDeriv(a,g.item(f)),g,f+1)}function f(a,c,g){g.e[0].a?(a.push(g.e[0].text),c.push(g.e[0].a.ns)):f(a,c,g.e[0]);g.e[1].a?(a.push(g.e[1].text),c.push(g.e[1].a.ns)): +f(a,c,g.e[1])}var b="http://www.w3.org/2000/xmlns/",k,c,g,n,r,u,y,x,w,v,t={type:"notAllowed",nullable:!1,hash:"notAllowed",textDeriv:function(){return t},startTagOpenDeriv:function(){return t},attDeriv:function(){return t},startTagCloseDeriv:function(){return t},endTagDeriv:function(){return t}},s={type:"empty",nullable:!0,hash:"empty",textDeriv:function(){return t},startTagOpenDeriv:function(){return t},attDeriv:function(){return t},startTagCloseDeriv:function(){return s},endTagDeriv:function(){return t}}, +D={type:"text",nullable:!0,hash:"text",textDeriv:function(){return D},startTagOpenDeriv:function(){return t},attDeriv:function(){return t},startTagCloseDeriv:function(){return D},endTagDeriv:function(){return t}},A,C,I;k=p("choice",function(a,c){if(a===t)return c;if(c===t||a===c)return a},function(a,c){var g={},b;l(g,{p1:a,p2:c});c=a=void 0;for(b in g)g.hasOwnProperty(b)&&(void 0===a?a=g[b]:c=void 0===c?g[b]:k(c,g[b]));return function(a,c){return{type:"choice",p1:a,p2:c,nullable:a.nullable||c.nullable, +textDeriv:function(g,b){return k(a.textDeriv(g,b),c.textDeriv(g,b))},startTagOpenDeriv:e(function(g){return k(a.startTagOpenDeriv(g),c.startTagOpenDeriv(g))}),attDeriv:function(g,b){return k(a.attDeriv(g,b),c.attDeriv(g,b))},startTagCloseDeriv:h(function(){return k(a.startTagCloseDeriv(),c.startTagCloseDeriv())}),endTagDeriv:h(function(){return k(a.endTagDeriv(),c.endTagDeriv())})}}(a,c)});c=function(a,c,g){return function(){var b={},d=0;return function(f,n){var e=c&&c(f,n),k,h;if(void 0!==e)return e; +e=f.hash||f.toString();k=n.hash||n.toString();eNode.ELEMENT_NODE;){if(d!==Node.COMMENT_NODE&&(d!==Node.TEXT_NODE||!/^\s+$/.test(b.currentNode.nodeValue)))return[new e("Not allowed node of type "+ -d+".")];d=(a=b.nextSibling())?a.nodeType:0}if(!a)return[new e("Missing element "+c.names)];if(c.names&&-1===c.names.indexOf(p[a.namespaceURI]+":"+a.localName))return[new e("Found "+a.nodeName+" instead of "+c.names+".",a)];if(b.firstChild()){for(f=h(c.e[1],b,a);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 e("Spurious content.",b.currentNode)];if(b.parentNode()!==a)return[new e("Implementation error.")]}else f= -h(c.e[1],b,a);b.nextSibling();return f}var n,m,p;m=function(c,b,a,d){var k=c.name,g=null;if("text"===k)a:{for(var q=(c=b.currentNode)?c.nodeType:0;c!==a&&3!==q;){if(1===q){g=[new e("Element not allowed here.",c)];break a}q=(c=b.nextSibling())?c.nodeType:0}b.nextSibling();g=null}else if("data"===k)g=null;else if("value"===k)d!==c.text&&(g=[new e("Wrong value, should be '"+c.text+"', not '"+d+"'",a)]);else if("list"===k)g=null;else if("attribute"===k)a:{if(2!==c.e.length)throw"Attribute with wrong # of elements: "+ -c.e.length;k=c.localnames.length;for(g=0;gNode.ELEMENT_NODE;){if(b!==Node.COMMENT_NODE&&(b!==Node.TEXT_NODE||!/^\s+$/.test(d.currentNode.nodeValue)))return[new h("Not allowed node of type "+ +b+".")];b=(f=d.nextSibling())?f.nodeType:0}if(!f)return[new h("Missing element "+a.names)];if(a.names&&-1===a.names.indexOf(q[f.namespaceURI]+":"+f.localName))return[new h("Found "+f.nodeName+" instead of "+a.names+".",f)];if(d.firstChild()){for(e=m(a.e[1],d,f);d.nextSibling();)if(b=d.currentNode.nodeType,!(d.currentNode&&d.currentNode.nodeType===Node.TEXT_NODE&&/^\s+$/.test(d.currentNode.nodeValue)||b===Node.COMMENT_NODE))return[new h("Spurious content.",d.currentNode)];if(d.parentNode()!==f)return[new h("Implementation error.")]}else e= +m(a.e[1],d,f);d.nextSibling();return e}var p,l,q;l=function(a,d,f,b){var k=a.name,c=null;if("text"===k)a:{for(var g=(a=d.currentNode)?a.nodeType:0;a!==f&&3!==g;){if(1===g){c=[new h("Element not allowed here.",a)];break a}g=(a=d.nextSibling())?a.nodeType:0}d.nextSibling();c=null}else if("data"===k)c=null;else if("value"===k)b!==a.text&&(c=[new h("Wrong value, should be '"+a.text+"', not '"+b+"'",f)]);else if("list"===k)c=null;else if("attribute"===k)a:{if(2!==a.e.length)throw"Attribute with wrong # of elements: "+ +a.e.length;k=a.localnames.length;for(c=0;c=f&&d.push(h(a.substring(b,c)))):"["===a[c]&&(0>=f&&(b=c+1),f+=1),c+=1;return c};xmldom.XPathIterator.prototype.next=function(){};xmldom.XPathIterator.prototype.reset=function(){};d=function(a,d,e){var f,k,h,p;for(f=0;f=k&&d.push(m(a.substring(b,f)))):"["===a[f]&&(0>=k&&(b=f+1),k+=1),f+=1;return f};xmldom.XPathIterator.prototype.next=function(){};xmldom.XPathIterator.prototype.reset=function(){};b=function(c,b,f){var e,k,h,m;for(e=0;e=(p.getBoundingClientRect().top-x.bottom)/n?l.style.top=Math.abs(p.getBoundingClientRect().top-x.bottom)/n+20+"px":l.style.top="0px");m.style.left=h.getBoundingClientRect().width/n+"px";var h=m.style,p=m.getBoundingClientRect().left/n,y=m.getBoundingClientRect().top/n,x=l.getBoundingClientRect().left/n,u=l.getBoundingClientRect().top/n,s=0,C= -0,s=x-p,s=s*s,C=u-y,C=C*C,p=Math.sqrt(s+C);h.width=p+"px";n=Math.asin((l.getBoundingClientRect().top-m.getBoundingClientRect().top)/(n*parseFloat(m.style.width)));m.style.transform="rotate("+n+"rad)";m.style.MozTransform="rotate("+n+"rad)";m.style.WebkitTransform="rotate("+n+"rad)";m.style.msTransform="rotate("+n+"rad)";c&&(n=k.getComputedStyle(c,":before").content)&&"none"!==n&&(/^["'].*["']$/.test(n)&&(n=n.substring(1,n.length-1)),c.firstChild?c.firstChild.nodeValue=n:c.appendChild(a.createTextNode(n)))}} -var b=[],a=h.ownerDocument,d=new odf.OdfUtils,k=runtime.getWindow();runtime.assert(Boolean(k),"Expected to be run in an environment which has a global window, like a browser.");this.rerenderAnnotations=c;this.addAnnotation=function(d){m(!0);b.push({node:d.node,end:d.end});p();var e=a.createElement("div"),f=a.createElement("div"),k=a.createElement("div"),h=a.createElement("div"),w=a.createElement("div"),v=d.node;e.className="annotationWrapper";v.parentNode.insertBefore(e,v);f.className="annotationNote"; -f.appendChild(v);w.className="annotationRemoveButton";f.appendChild(w);k.className="annotationConnector horizontal";h.className="annotationConnector angular";e.appendChild(f);e.appendChild(k);e.appendChild(h);d.end&&n(d);c()};this.forgetAnnotations=function(){for(;b.length;){var d=b[0],c=b.indexOf(d),e=d.node,f=e.parentNode.parentNode;"div"===f.localName&&(f.parentNode.insertBefore(e,f),f.parentNode.removeChild(f));d=d.node.getAttributeNS(odf.Namespaces.officens,"name");d=a.querySelectorAll('span.annotationHighlight[annotation="'+ -d+'"]');f=e=void 0;for(e=0;e=(p.getBoundingClientRect().top-v.bottom)/q?n.style.top=Math.abs(p.getBoundingClientRect().top-v.bottom)/q+20+"px":n.style.top="0px");m.style.left=l.getBoundingClientRect().width/q+"px";var l=m.style,p=m.getBoundingClientRect().left/q,w=m.getBoundingClientRect().top/q,v=n.getBoundingClientRect().left/q,t=n.getBoundingClientRect().top/q,s=0,D= +0,s=v-p,s=s*s,D=t-w,D=D*D,p=Math.sqrt(s+D);l.width=p+"px";q=Math.asin((n.getBoundingClientRect().top-m.getBoundingClientRect().top)/(q*parseFloat(m.style.width)));m.style.transform="rotate("+q+"rad)";m.style.MozTransform="rotate("+q+"rad)";m.style.WebkitTransform="rotate("+q+"rad)";m.style.msTransform="rotate("+q+"rad)";b&&(q=k.getComputedStyle(b,":before").content)&&"none"!==q&&(/^["'].*["']$/.test(q)&&(q=q.substring(1,q.length-1)),b.firstChild?b.firstChild.nodeValue=q:b.appendChild(f.createTextNode(q)))}} +var d=[],f=m.ownerDocument,b=new odf.OdfUtils,k=runtime.getWindow();runtime.assert(Boolean(k),"Expected to be run in an environment which has a global window, like a browser.");this.rerenderAnnotations=a;this.addAnnotation=function(c){l(!0);d.push({node:c.node,end:c.end});q();var b=f.createElement("div"),e=f.createElement("div"),k=f.createElement("div"),h=f.createElement("div"),m=f.createElement("div"),x=c.node;b.className="annotationWrapper";x.parentNode.insertBefore(b,x);e.className="annotationNote"; +e.appendChild(x);m.className="annotationRemoveButton";e.appendChild(m);k.className="annotationConnector horizontal";h.className="annotationConnector angular";b.appendChild(e);b.appendChild(k);b.appendChild(h);c.end&&p(c);a()};this.forgetAnnotations=function(){for(;d.length;){var a=d[0],b=d.indexOf(a),e=a.node,k=e.parentNode.parentNode;"div"===k.localName&&(k.parentNode.insertBefore(e,k),k.parentNode.removeChild(k));a=a.node.getAttributeNS(odf.Namespaces.officens,"name");a=f.querySelectorAll('span.annotationHighlight[annotation="'+ +a+'"]');k=e=void 0;for(e=0;ea.value||"%"===a.unit)?null:a}function y(a){return(a=w(a))&&"%"!==a.unit?null:a}function x(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=odf.Namespaces.textns,s=odf.Namespaces.drawns,C=/^\s*$/,B=new core.DomUtils;this.isImage=e;this.isCharacterFrame=h;this.isTextSpan=function(a){return"span"===(a&&a.localName)&&a.namespaceURI===u};this.isParagraph=f;this.getParagraphElement=n;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.isLineBreak=function(a){return"line-break"===(a&&a.localName)&&a.namespaceURI===u};this.isODFWhitespace=m;this.isGroupingElement=p;this.isCharacterElement=c;this.isWhitespaceElement=b;this.firstChild=a;this.lastChild=d;this.previousNode=k;this.nextNode=g;this.scanLeftForNonWhitespace=q;this.lookLeftForCharacter=function(a){var b;b=0;a.nodeType=== -Node.TEXT_NODE&&0=b.value||"%"===b.unit)?null:b;return b||y(a)};this.parseFoLineHeight=function(a){return v(a)||y(a)};this.getImpactedParagraphs= -function(a){var b=a.commonAncestorContainer,d=[];for(b.nodeType===Node.ELEMENT_NODE&&(d=B.getElementsByTagNameNS(b,u,"p").concat(B.getElementsByTagNameNS(b,u,"h")));b&&!f(b);)b=b.parentNode;b&&d.push(b);return d.filter(function(b){return B.rangeIntersectsNode(a,b)})};this.getTextNodes=function(a,b){var d=a.startContainer.ownerDocument.createRange(),c;c=B.getNodesInRange(a,function(c){d.selectNodeContents(c);if(c.nodeType===Node.TEXT_NODE){if(b&&B.rangesIntersect(a,d)||B.containsRange(a,d))return Boolean(n(c)&& -(!m(c.textContent)||t(c,0)))?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT}else if(B.rangesIntersect(a,d)&&x(c))return NodeFilter.FILTER_SKIP;return NodeFilter.FILTER_REJECT});d.detach();return c};this.getTextElements=function(a,b,d){var e=a.startContainer.ownerDocument.createRange(),f;f=B.getNodesInRange(a,function(f){e.selectNodeContents(f);if(c(f.parentNode))return NodeFilter.FILTER_REJECT;if(f.nodeType===Node.TEXT_NODE){if(b&&B.rangesIntersect(a,e)||B.containsRange(a,e))if(d||Boolean(n(f)&& -(!m(f.textContent)||t(f,0))))return NodeFilter.FILTER_ACCEPT}else if(c(f)){if(b&&B.rangesIntersect(a,e)||B.containsRange(a,e))return NodeFilter.FILTER_ACCEPT}else if(x(f)||p(f))return NodeFilter.FILTER_SKIP;return NodeFilter.FILTER_REJECT});e.detach();return f};this.getParagraphElements=function(a){var b=a.startContainer.ownerDocument.createRange(),d;d=B.getNodesInRange(a,function(d){b.selectNodeContents(d);if(f(d)){if(B.rangesIntersect(a,b))return NodeFilter.FILTER_ACCEPT}else if(x(d)||p(d))return NodeFilter.FILTER_SKIP; -return NodeFilter.FILTER_REJECT});b.detach();return d};this.getImageElements=function(a){var b=a.startContainer.ownerDocument.createRange(),d;d=B.getNodesInRange(a,function(d){b.selectNodeContents(d);return e(d)&&B.containsRange(a,b)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});b.detach();return d}}; +odf.OdfUtils=function(){function h(a){return"image"===(a&&a.localName)&&a.namespaceURI===s}function m(a){return"frame"===(a&&a.localName)&&a.namespaceURI===s&&"as-char"===a.getAttributeNS(t,"anchor-type")}function e(a){var c=a&&a.localName;return("p"===c||"h"===c)&&a.namespaceURI===t}function p(a){for(;a&&!e(a);)a=a.parentNode;return a}function l(a){return/^[ \t\r\n]+$/.test(a)}function q(a){var c=a&&a.localName;return/^(span|p|h|a|meta)$/.test(c)&&a.namespaceURI===t||"span"===c&&"annotationHighlight"=== +a.className?!0:!1}function a(a){var c=a&&a.localName,b;b=!1;c&&(b=a.namespaceURI,b=b===t?"s"===c||"tab"===c||"line-break"===c:m(a));return b}function d(a){var c=a&&a.localName,b=!1;c&&(a=a.namespaceURI,a===t&&(b="s"===c||"tab"===c));return b}function f(a){for(;null!==a.firstChild&&q(a);)a=a.firstChild;return a}function b(a){for(;null!==a.lastChild&&q(a);)a=a.lastChild;return a}function k(a){for(;!e(a)&&null===a.previousSibling;)a=a.parentNode;return e(a)?null:b(a.previousSibling)}function c(a){for(;!e(a)&& +null===a.nextSibling;)a=a.parentNode;return e(a)?null:f(a.nextSibling)}function g(c){for(var b=!1;c;)if(c.nodeType===Node.TEXT_NODE)if(0===c.length)c=k(c);else return!l(c.data.substr(c.length-1,1));else a(c)?(b=!1===d(c),c=null):c=k(c);return b}function n(b){var g=!1;for(b=b&&f(b);b;){if(b.nodeType===Node.TEXT_NODE&&0a.value||"%"===a.unit)?null:a}function w(a){return(a=y(a))&&"%"!==a.unit?null:a}function v(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 t=odf.Namespaces.textns,s=odf.Namespaces.drawns,D=/^\s*$/,A=new core.DomUtils;this.isImage=h;this.isCharacterFrame=m;this.isTextSpan=function(a){return"span"===(a&&a.localName)&&a.namespaceURI===t};this.isParagraph=e;this.getParagraphElement=p;this.isWithinTrackedChanges=function(a,c){for(;a&&a!==c;){if(a.namespaceURI=== +t&&"tracked-changes"===a.localName)return!0;a=a.parentNode}return!1};this.isListItem=function(a){return"list-item"===(a&&a.localName)&&a.namespaceURI===t};this.isLineBreak=function(a){return"line-break"===(a&&a.localName)&&a.namespaceURI===t};this.isODFWhitespace=l;this.isGroupingElement=q;this.isCharacterElement=a;this.isWhitespaceElement=d;this.firstChild=f;this.lastChild=b;this.previousNode=k;this.nextNode=c;this.scanLeftForNonWhitespace=g;this.lookLeftForCharacter=function(c){var b;b=0;c.nodeType=== +Node.TEXT_NODE&&0=c.value||"%"===c.unit)?null:c;return c||w(a)};this.parseFoLineHeight=function(a){return x(a)||w(a)};this.getImpactedParagraphs= +function(a){var c=a.commonAncestorContainer,b=[];for(c.nodeType===Node.ELEMENT_NODE&&(b=A.getElementsByTagNameNS(c,t,"p").concat(A.getElementsByTagNameNS(c,t,"h")));c&&!e(c);)c=c.parentNode;c&&b.push(c);return b.filter(function(c){return A.rangeIntersectsNode(a,c)})};this.getTextNodes=function(a,c){var b=a.startContainer.ownerDocument.createRange(),g;g=A.getNodesInRange(a,function(g){b.selectNodeContents(g);if(g.nodeType===Node.TEXT_NODE){if(c&&A.rangesIntersect(a,b)||A.containsRange(a,b))return Boolean(p(g)&& +(!l(g.textContent)||u(g,0)))?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT}else if(A.rangesIntersect(a,b)&&v(g))return NodeFilter.FILTER_SKIP;return NodeFilter.FILTER_REJECT});b.detach();return g};this.getTextElements=function(c,b,g){var d=c.startContainer.ownerDocument.createRange(),f;f=A.getNodesInRange(c,function(f){d.selectNodeContents(f);if(a(f.parentNode))return NodeFilter.FILTER_REJECT;if(f.nodeType===Node.TEXT_NODE){if(b&&A.rangesIntersect(c,d)||A.containsRange(c,d))if(g||Boolean(p(f)&& +(!l(f.textContent)||u(f,0))))return NodeFilter.FILTER_ACCEPT}else if(a(f)){if(b&&A.rangesIntersect(c,d)||A.containsRange(c,d))return NodeFilter.FILTER_ACCEPT}else if(v(f)||q(f))return NodeFilter.FILTER_SKIP;return NodeFilter.FILTER_REJECT});d.detach();return f};this.getParagraphElements=function(a){var c=a.startContainer.ownerDocument.createRange(),b;b=A.getNodesInRange(a,function(b){c.selectNodeContents(b);if(e(b)){if(A.rangesIntersect(a,c))return NodeFilter.FILTER_ACCEPT}else if(v(b)||q(b))return NodeFilter.FILTER_SKIP; +return NodeFilter.FILTER_REJECT});c.detach();return b};this.getImageElements=function(a){var c=a.startContainer.ownerDocument.createRange(),b;b=A.getNodesInRange(a,function(b){c.selectNodeContents(b);return h(b)&&A.containsRange(a,c)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});c.detach();return b}}; // Input 31 /* @@ -637,7 +637,8 @@ return NodeFilter.FILTER_REJECT});b.detach();return d};this.getImageElements=fun @source: https://github.com/kogmbh/WebODF/ */ runtime.loadClass("odf.OdfUtils"); -odf.TextSerializer=function(){function e(n){var m="",p=h.filter?h.filter.acceptNode(n):NodeFilter.FILTER_ACCEPT,c=n.nodeType,b;if(p===NodeFilter.FILTER_ACCEPT||p===NodeFilter.FILTER_SKIP)for(b=n.firstChild;b;)m+=e(b),b=b.nextSibling;p===NodeFilter.FILTER_ACCEPT&&(c===Node.ELEMENT_NODE&&f.isParagraph(n)?m+="\n":c===Node.TEXT_NODE&&n.textContent&&(m+=n.textContent));return m}var h=this,f=new odf.OdfUtils;this.filter=null;this.writeToString=function(f){return f?e(f):""}}; +odf.TextSerializer=function(){function h(p){var l="",q=m.filter?m.filter.acceptNode(p):NodeFilter.FILTER_ACCEPT,a=p.nodeType,d;if(q===NodeFilter.FILTER_ACCEPT||q===NodeFilter.FILTER_SKIP)for(d=p.firstChild;d;)l+=h(d),d=d.nextSibling;q===NodeFilter.FILTER_ACCEPT&&(a===Node.ELEMENT_NODE&&e.isParagraph(p)?l+="\n":a===Node.TEXT_NODE&&p.textContent&&(l+=p.textContent));return l}var m=this,e=new odf.OdfUtils;this.filter=null;this.writeToString=function(e){if(!e)return"";e=h(e);"\n"===e[e.length-1]&&(e= +e.substr(0,e.length-1));return e}}; // Input 32 /* @@ -677,10 +678,10 @@ odf.TextSerializer=function(){function e(n){var m="",p=h.filter?h.filter.acceptN @source: https://github.com/kogmbh/WebODF/ */ runtime.loadClass("core.DomUtils");runtime.loadClass("core.LoopWatchDog");runtime.loadClass("odf.Namespaces"); -odf.TextStyleApplicator=function(e,h,f){function n(a){function b(a,d){return"object"===typeof a&&"object"===typeof d?Object.keys(a).every(function(c){return b(a[c],d[c])}):a===d}this.isStyleApplied=function(c){c=h.getAppliedStylesForElement(c);return b(a,c)}}function m(d){var c={};this.applyStyleToContainer=function(g){var q;q=g.getAttributeNS(b,"style-name");var l=g.ownerDocument;q=q||"";if(!c.hasOwnProperty(q)){var m=q,p;p=q?h.createDerivedStyleObject(q,"text",d):d;l=l.createElementNS(a,"style:style"); -h.updateStyle(l,p);l.setAttributeNS(a,"style:name",e.generateStyleName());l.setAttributeNS(a,"style:family","text");l.setAttributeNS("urn:webodf:names:scope","scope","document-content");f.appendChild(l);c[m]=l}q=c[q].getAttributeNS(a,"name");g.setAttributeNS(b,"text:style-name",q)}}function p(a,e){var f=a.ownerDocument,h=a.parentNode,l,m,p=new core.LoopWatchDog(1E3);m=[];"span"!==h.localName||h.namespaceURI!==b?(l=f.createElementNS(b,"text:span"),h.insertBefore(l,a),h=!1):(a.previousSibling&&!c.rangeContainsNode(e, -h.firstChild)?(l=h.cloneNode(!1),h.parentNode.insertBefore(l,h.nextSibling)):l=h,h=!0);m.push(a);for(f=a.nextSibling;f&&c.rangeContainsNode(e,f);)p.check(),m.push(f),f=f.nextSibling;m.forEach(function(a){a.parentNode!==l&&l.appendChild(a)});if(f&&h)for(m=l.cloneNode(!1),l.parentNode.insertBefore(m,l.nextSibling);f;)p.check(),h=f.nextSibling,m.appendChild(f),f=h;return l}var c=new core.DomUtils,b=odf.Namespaces.textns,a=odf.Namespaces.stylens;this.applyStyle=function(a,b,c){var e={},f,h,t,w;runtime.assert(c&& -c["style:text-properties"],"applyStyle without any text properties");e["style:text-properties"]=c["style:text-properties"];t=new m(e);w=new n(e);a.forEach(function(a){f=w.isStyleApplied(a);!1===f&&(h=p(a,b),t.applyStyleToContainer(h))})}}; +odf.TextStyleApplicator=function(h,m,e){function p(a){function d(a,b){return"object"===typeof a&&"object"===typeof b?Object.keys(a).every(function(f){return d(a[f],b[f])}):a===b}this.isStyleApplied=function(c){c=m.getAppliedStylesForElement(c);return d(a,c)}}function l(a){var k={};this.applyStyleToContainer=function(c){var g;g=c.getAttributeNS(d,"style-name");var n=c.ownerDocument;g=g||"";if(!k.hasOwnProperty(g)){var l=g,q;q=g?m.createDerivedStyleObject(g,"text",a):a;n=n.createElementNS(f,"style:style"); +m.updateStyle(n,q);n.setAttributeNS(f,"style:name",h.generateStyleName());n.setAttributeNS(f,"style:family","text");n.setAttributeNS("urn:webodf:names:scope","scope","document-content");e.appendChild(n);k[l]=n}g=k[g].getAttributeNS(f,"name");c.setAttributeNS(d,"text:style-name",g)}}function q(b,f){var c=b.ownerDocument,g=b.parentNode,e,h,l=new core.LoopWatchDog(1E4);h=[];"span"!==g.localName||g.namespaceURI!==d?(e=c.createElementNS(d,"text:span"),g.insertBefore(e,b),g=!1):(b.previousSibling&&!a.rangeContainsNode(f, +g.firstChild)?(e=g.cloneNode(!1),g.parentNode.insertBefore(e,g.nextSibling)):e=g,g=!0);h.push(b);for(c=b.nextSibling;c&&a.rangeContainsNode(f,c);)l.check(),h.push(c),c=c.nextSibling;h.forEach(function(a){a.parentNode!==e&&e.appendChild(a)});if(c&&g)for(h=e.cloneNode(!1),e.parentNode.insertBefore(h,e.nextSibling);c;)l.check(),g=c.nextSibling,h.appendChild(c),c=g;return e}var a=new core.DomUtils,d=odf.Namespaces.textns,f=odf.Namespaces.stylens;this.applyStyle=function(a,d,c){var g={},f,e,h,m;runtime.assert(c&& +c["style:text-properties"],"applyStyle without any text properties");g["style:text-properties"]=c["style:text-properties"];h=new l(g);m=new p(g);a.forEach(function(a){f=m.isStyleApplied(a);!1===f&&(e=q(a,d),h.applyStyleToContainer(e))})}}; // Input 33 /* @@ -720,29 +721,29 @@ c["style:text-properties"],"applyStyle without any text properties");e["style:te @source: https://github.com/kogmbh/WebODF/ */ runtime.loadClass("odf.Namespaces");runtime.loadClass("odf.OdfUtils");runtime.loadClass("xmldom.XPath");runtime.loadClass("core.CSSUnits"); -odf.Style2CSS=function(){function e(a){var b={},d,c;if(!a)return b;for(a=a.firstChild;a;){if(c=a.namespaceURI!==r||"style"!==a.localName&&"default-style"!==a.localName?a.namespaceURI===v&&"list-style"===a.localName?"list":a.namespaceURI!==r||"page-layout"!==a.localName&&"default-page-layout"!==a.localName?void 0:"page":a.getAttributeNS(r,"family"))(d=a.getAttributeNS&&a.getAttributeNS(r,"name"))||(d=""),c=b[c]=b[c]||{},c[d]=a;a=a.nextSibling}return b}function h(a,b){if(!b||!a)return null;if(a[b])return a[b]; -var d,c;for(d in a)if(a.hasOwnProperty(d)&&(c=h(a[d].derivedStyles,b)))return c;return null}function f(a,b,d){var c=b[a],e,g;c&&(e=c.getAttributeNS(r,"parent-style-name"),g=null,e&&(g=h(d,e),!g&&b[e]&&(f(e,b,d),g=b[e],b[e]=null)),g?(g.derivedStyles||(g.derivedStyles={}),g.derivedStyles[a]=c):d[a]=c)}function n(a,b){for(var d in a)a.hasOwnProperty(d)&&(f(d,a,b),a[d]=null)}function m(a,b){var d=u[a],c;if(null===d)return null;c=b?"["+d+'|style-name="'+b+'"]':"";"presentation"===d&&(d="draw",c=b?'[presentation|style-name="'+ -b+'"]':"");return d+"|"+s[a].join(c+","+d+"|")+c}function p(a,b,d){var c=[],e,f;c.push(m(a,b));for(e in d.derivedStyles)if(d.derivedStyles.hasOwnProperty(e))for(f in b=p(a,e,d.derivedStyles[e]),b)b.hasOwnProperty(f)&&c.push(b[f]);return c}function c(a,b,d){if(!a)return null;for(a=a.firstChild;a;){if(a.namespaceURI===b&&a.localName===d)return b=a;a=a.nextSibling}return null}function b(a,b){var d="",c,e;for(c in b)if(b.hasOwnProperty(c)&&(c=b[c],e=a.getAttributeNS(c[0],c[1]))){e=e.trim();if(T.hasOwnProperty(c[1])){var f= -e.indexOf(" "),g=void 0,k=void 0;-1!==f?(g=e.substring(0,f),k=e.substring(f)):(g=e,k="");(g=$.parseLength(g))&&"pt"===g.unit&&0.75>g.value&&(e="0.75pt"+k)}c[2]&&(d+=c[2]+":"+e+";")}return d}function a(a){return(a=c(a,r,"text-properties"))?$.parseFoFontSize(a.getAttributeNS(l,"font-size")):null}function d(a){a=a.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i,function(a,b,d,c){return b+b+d+d+c+c});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 k(a,b,d,c){b='text|list[text|style-name="'+b+'"]';var e=d.getAttributeNS(v,"level"),f;d=$.getFirstNonWhitespaceChild(d);d=$.getFirstNonWhitespaceChild(d);var g;d&&(f=d.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");d="-"===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));c=b+" > text|list-item > *:not(text|list):first-child:before{"+c+";";c+="counter-increment:list;";c+="margin-left:"+g+";";c+="width:"+d+";";c+="display:inline-block}";try{a.insertRule(c,a.cssRules.length)}catch(k){throw k;}}function g(e,f,h,m){if("list"===f)for(var s=m.firstChild,n,t;s;){if(s.namespaceURI===v)if(n=s,"list-level-style-number"===s.localName){var u=n;t=u.getAttributeNS(r,"num-format");var Q=u.getAttributeNS(r,"num-suffix"), -J={1:"decimal",a:"lower-latin",A:"upper-latin",i:"lower-roman",I:"upper-roman"},u=u.getAttributeNS(r,"num-prefix")||"",u=J.hasOwnProperty(t)?u+(" counter(list, "+J[t]+")"):t?u+("'"+t+"';"):u+" ''";Q&&(u+=" '"+Q+"'");t="content: "+u+";";k(e,h,n,t)}else"list-level-style-image"===s.localName?(t="content: none;",k(e,h,n,t)):"list-level-style-bullet"===s.localName&&(t="content: '"+n.getAttributeNS(v,"bullet-char")+"';",k(e,h,n,t));s=s.nextSibling}else if("page"===f)if(Q=n=h="",s=m.getElementsByTagNameNS(r, -"page-layout-properties")[0],n=s.parentNode.parentNode.parentNode.masterStyles,Q="",h+=b(s,Z),t=s.getElementsByTagNameNS(r,"background-image"),0e.value&&(d="0.75pt"+k)}g[2]&&(b+=g[2]+":"+d+";")}return b}function f(c){return(c=a(c,r,"text-properties"))?ba.parseFoFontSize(c.getAttributeNS(n,"font-size")):null}function b(a){a=a.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i,function(a,c,b,g){return c+c+b+b+g+g});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 k(a,c,b,g){c='text|list[text|style-name="'+c+'"]';var d=b.getAttributeNS(x,"level"),f;b=ba.getFirstNonWhitespaceChild(b);b=ba.getFirstNonWhitespaceChild(b);var e;b&&(f=b.attributes,e=f["fo:text-indent"]?f["fo:text-indent"].value:void 0,f=f["fo:margin-left"]?f["fo:margin-left"].value:void 0);e||(e="-0.6cm");b="-"===e.charAt(0)?e.substring(1):"-"+e;for(d=d&&parseInt(d,10);1 text|list-item > text|list",d-=1;d=c+" > text|list-item > *:not(text|list):first-child";void 0!== +f&&(f=d+"{margin-left:"+f+";}",a.insertRule(f,a.cssRules.length));g=c+" > text|list-item > *:not(text|list):first-child:before{"+g+";";g+="counter-increment:list;";g+="margin-left:"+e+";";g+="width:"+b+";";g+="display:inline-block}";try{a.insertRule(g,a.cssRules.length)}catch(k){throw k;}}function c(e,h,l,m){if("list"===h)for(var s=m.firstChild,p,u;s;){if(s.namespaceURI===x)if(p=s,"list-level-style-number"===s.localName){var t=p;u=t.getAttributeNS(r,"num-format");var P=t.getAttributeNS(r,"num-suffix"), +E={1:"decimal",a:"lower-latin",A:"upper-latin",i:"lower-roman",I:"upper-roman"},t=t.getAttributeNS(r,"num-prefix")||"",t=E.hasOwnProperty(u)?t+(" counter(list, "+E[u]+")"):u?t+("'"+u+"';"):t+" ''";P&&(t+=" '"+P+"'");u="content: "+t+";";k(e,l,p,u)}else"list-level-style-image"===s.localName?(u="content: none;",k(e,l,p,u)):"list-level-style-bullet"===s.localName&&(u="content: '"+p.getAttributeNS(x,"bullet-char")+"';",k(e,l,p,u));s=s.nextSibling}else if("page"===h)if(P=p=l="",s=m.getElementsByTagNameNS(r, +"page-layout-properties")[0],p=s.parentNode.parentNode.parentNode.masterStyles,P="",l+=d(s,Z),u=s.getElementsByTagNameNS(r,"background-image"),0d)break;e=e.nextSibling}a.insertBefore(b,e)}}}function p(a){this.OdfContainer= -a}function c(a,b,d,c){var e=this;this.size=0;this.type=null;this.name=a;this.container=d;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!==c&&(this.mimetype=b,c.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 b=new odf.StyleInfo,a=odf.Namespaces.stylens,d="meta settings scripts font-face-decls styles automatic-styles master-styles body".split(" "), -k=(new Date).getTime()+"_webodf_",g=new core.Base64;p.prototype=new function(){};p.prototype.constructor=p;p.namespaceURI="urn:oasis:names:tc:opendocument:xmlns:office:1.0";p.localName="document";c.prototype.load=function(){};c.prototype.getUrl=function(){return this.data?"data:;base64,"+g.toBase64(this.data):null};odf.OdfContainer=function l(d,h){function w(a){for(var b=a.firstChild,d;b;)d=b.nextSibling,b.nodeType===Node.ELEMENT_NODE?w(b):b.nodeType===Node.PROCESSING_INSTRUCTION_NODE&&a.removeChild(b), -b=d}function v(a,b){for(var d=a&&a.firstChild;d;)d.nodeType===Node.ELEMENT_NODE&&d.setAttributeNS("urn:webodf:names:scope","scope",b),d=d.nextSibling}function y(b,d){function c(a,b,d){var e=0,f;for(f=a=a.replace(/\d+$/,"");b.hasOwnProperty(f)||d.hasOwnProperty(f);)e+=1,f=a+e;return f}function e(b){var d={};for(b=b.firstChild;b;)b.nodeType===Node.ELEMENT_NODE&&b.namespaceURI===a&&"font-face"===b.localName&&(k=b.getAttributeNS(a,"name"),d[k]=b),b=b.nextSibling;return d}var f,g,k,h,l,m,n={};l=e(b);m= -e(d);for(f=d.firstChild;f;)g=f.nextSibling,f.nodeType===Node.ELEMENT_NODE&&f.namespaceURI===a&&"font-face"===f.localName&&(k=f.getAttributeNS(a,"name"),l.hasOwnProperty(k)?f.isEqualNode(l[k])||(h=c(k,l,m),f.setAttributeNS(a,"style:name",h),b.appendChild(f),l[h]=f,delete m[k],n[k]=h):(b.appendChild(f),l[k]=f,delete m[k])),f=g;return n}function x(a,b){var d=null,c,e,f;if(a)for(d=a.cloneNode(!0),c=d.firstChild;c;)e=c.nextSibling,c.nodeType===Node.ELEMENT_NODE&&(f=c.getAttributeNS("urn:webodf:names:scope", -"scope"))&&f!==b&&d.removeChild(c),c=e;return d}function u(d,c){var e=null,f,g,k,h={};if(d)for(c.forEach(function(a){b.collectUsedFontFaces(h,a)}),e=d.cloneNode(!0),f=e.firstChild;f;)g=f.nextSibling,f.nodeType===Node.ELEMENT_NODE&&(k=f.getAttributeNS(a,"name"),h[k]||e.removeChild(f)),f=g;return e}function s(a){var b=M.rootElement.ownerDocument,d;if(a){w(a.documentElement);try{d=b.importNode(a.documentElement,!0)}catch(c){}}return d}function C(a){M.state=a;if(M.onchange)M.onchange(M);if(M.onstatereadychange)M.onstatereadychange(M)} -function B(a){aa=null;M.rootElement=a;a.fontFaceDecls=e(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","font-face-decls");a.styles=e(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","styles");a.automaticStyles=e(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","automatic-styles");a.masterStyles=e(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","master-styles");a.body=e(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","body");a.meta=e(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0", -"meta")}function A(a){a=s(a);var d=M.rootElement;a&&"document-styles"===a.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===a.namespaceURI?(d.fontFaceDecls=e(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","font-face-decls"),m(d,d.fontFaceDecls),d.styles=e(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","styles"),m(d,d.styles),d.automaticStyles=e(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","automatic-styles"),v(d.automaticStyles,"document-styles"),m(d,d.automaticStyles), -d.masterStyles=e(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","master-styles"),m(d,d.masterStyles),b.prefixStyleNames(d.automaticStyles,k,d.masterStyles)):C(l.INVALID)}function I(a){a=s(a);var d,c,f;if(a&&"document-content"===a.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===a.namespaceURI){d=M.rootElement;c=e(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","font-face-decls");d.fontFaceDecls&&c?f=y(d.fontFaceDecls,c):c&&(d.fontFaceDecls=c,m(d,c));c=e(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0", -"automatic-styles");v(c,"document-content");f&&b.changeFontFaceNames(c,f);if(d.automaticStyles&&c)for(f=c.firstChild;f;)d.automaticStyles.appendChild(f),f=c.firstChild;else c&&(d.automaticStyles=c,m(d,c));d.body=e(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","body");m(d,d.body)}else C(l.INVALID)}function z(a){a=s(a);var b;a&&"document-meta"===a.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===a.namespaceURI&&(b=M.rootElement,b.meta=e(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0", -"meta"),m(b,b.meta))}function N(a){a=s(a);var b;a&&"document-settings"===a.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===a.namespaceURI&&(b=M.rootElement,b.settings=e(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","settings"),m(b,b.settings))}function G(a){a=s(a);var b;if(a&&"manifest"===a.localName&&"urn:oasis:names:tc:opendocument:xmlns:manifest:1.0"===a.namespaceURI)for(b=M.rootElement,b.manifest=a,a=b.manifest.firstChild;a;)a.nodeType===Node.ELEMENT_NODE&&"file-entry"=== -a.localName&&"urn:oasis:names:tc:opendocument:xmlns:manifest:1.0"===a.namespaceURI&&(P[a.getAttributeNS("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0","full-path")]=a.getAttributeNS("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0","media-type")),a=a.nextSibling}function R(a){var b=a.shift(),d,c;b?(d=b[0],c=b[1],S.loadAsDOM(d,function(b,d){c(d);b||M.state===l.INVALID||R(a)})):C(l.DONE)}function Z(a){var b="";odf.Namespaces.forEachPrefix(function(a,d){b+=" xmlns:"+a+'="'+d+'"'});return''}function ka(){var a=new xmldom.LSSerializer,b=Z("document-meta");a.filter=new odf.OdfNodeFilter;b+=a.writeToString(M.rootElement.meta,odf.Namespaces.namespaceMap);return b+""}function T(a,b){var d=document.createElementNS("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0","manifest:file-entry");d.setAttributeNS("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0","manifest:full-path",a);d.setAttributeNS("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0", -"manifest:media-type",b);return d}function ra(){var a=runtime.parseXML(''),b=e(a,"urn:oasis:names:tc:opendocument:xmlns:manifest:1.0","manifest"),d=new xmldom.LSSerializer,c;for(c in P)P.hasOwnProperty(c)&&b.appendChild(T(c,P[c]));d.filter=new odf.OdfNodeFilter;return'\n'+d.writeToString(a,odf.Namespaces.namespaceMap)} -function $(){var a=new xmldom.LSSerializer,b=Z("document-settings");a.filter=new odf.OdfNodeFilter;b+=a.writeToString(M.rootElement.settings,odf.Namespaces.namespaceMap);return b+""}function ha(){var a=odf.Namespaces.namespaceMap,d=new xmldom.LSSerializer,c,e,g,h=Z("document-styles");e=x(M.rootElement.automaticStyles,"document-styles");g=M.rootElement.masterStyles&&M.rootElement.masterStyles.cloneNode(!0);c=u(M.rootElement.fontFaceDecls,[g,M.rootElement.styles,e]);b.removePrefixFromStyleNames(e, -k,g);d.filter=new f(g,e);h+=d.writeToString(c,a);h+=d.writeToString(M.rootElement.styles,a);h+=d.writeToString(e,a);h+=d.writeToString(g,a);return h+""}function U(){var a=odf.Namespaces.namespaceMap,b=new xmldom.LSSerializer,d,c,e=Z("document-content");c=x(M.rootElement.automaticStyles,"document-content");d=u(M.rootElement.fontFaceDecls,[c]);b.filter=new n(M.rootElement.body,c);e+=b.writeToString(d,a);e+=b.writeToString(c,a);e+=b.writeToString(M.rootElement.body,a);return e+ -""}function O(a,b){runtime.loadXML(a,function(a,d){if(a)b(a);else{var c=s(d);c&&"document"===c.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===c.namespaceURI?(B(c),C(l.DONE)):C(l.INVALID)}})}function W(){function a(b,d){var e;d||(d=b);e=document.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0",d);c[b]=e;c.appendChild(e)}var b=new core.Zip("",null),d=runtime.byteArrayFromString("application/vnd.oasis.opendocument.text","utf8"),c=M.rootElement, -e=document.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0","text");b.save("mimetype",d,!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");c.body.appendChild(e);C(l.DONE);return b}function E(){var a,b=new Date;a=runtime.byteArrayFromString($(),"utf8");S.save("settings.xml",a,!0,b);a=runtime.byteArrayFromString(ka(),"utf8");S.save("meta.xml",a,!0,b); -a=runtime.byteArrayFromString(ha(),"utf8");S.save("styles.xml",a,!0,b);a=runtime.byteArrayFromString(U(),"utf8");S.save("content.xml",a,!0,b);a=runtime.byteArrayFromString(ra(),"utf8");S.save("META-INF/manifest.xml",a,!0,b)}function H(a,b){E();S.writeAs(a,function(a){b(a)})}var M=this,S,P={},aa;this.onstatereadychange=h;this.rootElement=this.state=this.onchange=null;this.setRootElement=B;this.getContentElement=function(){var a;aa||(a=M.rootElement.body,aa=a.getElementsByTagNameNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0", -"text")[0]||a.getElementsByTagNameNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0","presentation")[0]||a.getElementsByTagNameNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0","spreadsheet")[0]);return aa};this.getDocumentType=function(){var a=M.getContentElement();return a&&a.localName};this.getPart=function(a){return new c(a,P[a],M,S)};this.getPartData=function(a,b){S.load(a,b)};this.createByteArray=function(a,b){E();S.createByteArray(a,b)};this.saveAs=H;this.save=function(a){H(d,a)};this.getUrl= -function(){return d};this.setBlob=function(a,b,d){d=g.convertBase64ToByteArray(d);S.save(a,d,!1,new Date);P.hasOwnProperty(a)&&runtime.log(a+" has been overwritten.");P[a]=b};this.removeBlob=function(a){var b=S.remove(a);runtime.assert(b,"file is not found: "+a);delete P[a]};this.state=l.LOADING;this.rootElement=function(a){var b=document.createElementNS(a.namespaceURI,a.localName),d;a=new a;for(d in a)a.hasOwnProperty(d)&&(b[d]=a[d]);return b}(p);S=d?new core.Zip(d,function(a,b){S=b;a?O(d,function(b){a&& -(S.error=a+"\n"+b,C(l.INVALID))}):R([["styles.xml",A],["content.xml",I],["meta.xml",z],["settings.xml",N],["META-INF/manifest.xml",G]])}):W()};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}(); +odf.OdfContainer=function(){function h(a,c,b){for(a=a?a.firstChild:null;a;){if(a.localName===b&&a.namespaceURI===c)return a;a=a.nextSibling}return null}function m(a){var c,d=b.length;for(c=0;cb)break;f=f.nextSibling}a.insertBefore(c,f)}}}function q(a){this.OdfContainer= +a}function a(a,c,b,d){var f=this;this.size=0;this.type=null;this.name=a;this.container=b;this.onchange=this.onreadystatechange=this.document=this.mimetype=this.url=null;this.EMPTY=0;this.LOADING=1;this.DONE=2;this.state=this.EMPTY;this.load=function(){null!==d&&(this.mimetype=c,d.loadAsDataURL(a,c,function(a,c){a&&runtime.log(a);f.url=c;if(f.onchange)f.onchange(f);if(f.onstatereadychange)f.onstatereadychange(f)}))}}var d=new odf.StyleInfo,f=odf.Namespaces.stylens,b="meta settings scripts font-face-decls styles automatic-styles master-styles body".split(" "), +k=(new Date).getTime()+"_webodf_",c=new core.Base64;q.prototype=new function(){};q.prototype.constructor=q;q.namespaceURI="urn:oasis:names:tc:opendocument:xmlns:office:1.0";q.localName="document";a.prototype.load=function(){};a.prototype.getUrl=function(){return this.data?"data:;base64,"+c.toBase64(this.data):null};odf.OdfContainer=function n(b,m){function y(a){for(var c=a.firstChild,b;c;)b=c.nextSibling,c.nodeType===Node.ELEMENT_NODE?y(c):c.nodeType===Node.PROCESSING_INSTRUCTION_NODE&&a.removeChild(c), +c=b}function x(a,c){for(var b=a&&a.firstChild;b;)b.nodeType===Node.ELEMENT_NODE&&b.setAttributeNS("urn:webodf:names:scope","scope",c),b=b.nextSibling}function w(a,c){function b(a,c,d){var f=0,e;for(e=a=a.replace(/\d+$/,"");c.hasOwnProperty(e)||d.hasOwnProperty(e);)f+=1,e=a+f;return e}function d(a){var c={};for(a=a.firstChild;a;)a.nodeType===Node.ELEMENT_NODE&&a.namespaceURI===f&&"font-face"===a.localName&&(h=a.getAttributeNS(f,"name"),c[h]=a),a=a.nextSibling;return c}var e,k,h,l,n,m,s={};n=d(a);m= +d(c);for(e=c.firstChild;e;)k=e.nextSibling,e.nodeType===Node.ELEMENT_NODE&&e.namespaceURI===f&&"font-face"===e.localName&&(h=e.getAttributeNS(f,"name"),n.hasOwnProperty(h)?e.isEqualNode(n[h])||(l=b(h,n,m),e.setAttributeNS(f,"style:name",l),a.appendChild(e),n[l]=e,delete m[h],s[h]=l):(a.appendChild(e),n[h]=e,delete m[h])),e=k;return s}function v(a,c){var b=null,d,f,e;if(a)for(b=a.cloneNode(!0),d=b.firstChild;d;)f=d.nextSibling,d.nodeType===Node.ELEMENT_NODE&&(e=d.getAttributeNS("urn:webodf:names:scope", +"scope"))&&e!==c&&b.removeChild(d),d=f;return b}function t(a,c){var b=null,e,k,h,l={};if(a)for(c.forEach(function(a){d.collectUsedFontFaces(l,a)}),b=a.cloneNode(!0),e=b.firstChild;e;)k=e.nextSibling,e.nodeType===Node.ELEMENT_NODE&&(h=e.getAttributeNS(f,"name"),l[h]||b.removeChild(e)),e=k;return b}function s(a){var c=G.rootElement.ownerDocument,b;if(a){y(a.documentElement);try{b=c.importNode(a.documentElement,!0)}catch(d){}}return b}function D(a){G.state=a;if(G.onchange)G.onchange(G);if(G.onstatereadychange)G.onstatereadychange(G)} +function A(a){ca=null;G.rootElement=a;a.fontFaceDecls=h(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","font-face-decls");a.styles=h(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","styles");a.automaticStyles=h(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","automatic-styles");a.masterStyles=h(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","master-styles");a.body=h(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","body");a.meta=h(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0", +"meta")}function C(a){a=s(a);var c=G.rootElement;a&&"document-styles"===a.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===a.namespaceURI?(c.fontFaceDecls=h(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","font-face-decls"),l(c,c.fontFaceDecls),c.styles=h(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","styles"),l(c,c.styles),c.automaticStyles=h(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","automatic-styles"),x(c.automaticStyles,"document-styles"),l(c,c.automaticStyles), +c.masterStyles=h(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","master-styles"),l(c,c.masterStyles),d.prefixStyleNames(c.automaticStyles,k,c.masterStyles)):D(n.INVALID)}function I(a){a=s(a);var c,b,f;if(a&&"document-content"===a.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===a.namespaceURI){c=G.rootElement;b=h(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","font-face-decls");c.fontFaceDecls&&b?f=w(c.fontFaceDecls,b):b&&(c.fontFaceDecls=b,l(c,b));b=h(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0", +"automatic-styles");x(b,"document-content");f&&d.changeFontFaceNames(b,f);if(c.automaticStyles&&b)for(f=b.firstChild;f;)c.automaticStyles.appendChild(f),f=b.firstChild;else b&&(c.automaticStyles=b,l(c,b));c.body=h(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","body");l(c,c.body)}else D(n.INVALID)}function z(a){a=s(a);var c;a&&"document-meta"===a.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===a.namespaceURI&&(c=G.rootElement,c.meta=h(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0", +"meta"),l(c,c.meta))}function M(a){a=s(a);var c;a&&"document-settings"===a.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===a.namespaceURI&&(c=G.rootElement,c.settings=h(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","settings"),l(c,c.settings))}function H(a){a=s(a);var c;if(a&&"manifest"===a.localName&&"urn:oasis:names:tc:opendocument:xmlns:manifest:1.0"===a.namespaceURI)for(c=G.rootElement,c.manifest=a,a=c.manifest.firstChild;a;)a.nodeType===Node.ELEMENT_NODE&&"file-entry"=== +a.localName&&"urn:oasis:names:tc:opendocument:xmlns:manifest:1.0"===a.namespaceURI&&(O[a.getAttributeNS("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0","full-path")]=a.getAttributeNS("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0","media-type")),a=a.nextSibling}function R(a){var c=a.shift(),b,d;c?(b=c[0],d=c[1],Q.loadAsDOM(b,function(c,b){d(b);c||G.state===n.INVALID||R(a)})):D(n.DONE)}function Z(a){var c="";odf.Namespaces.forEachPrefix(function(a,b){c+=" xmlns:"+a+'="'+b+'"'});return''}function ja(){var a=new xmldom.LSSerializer,c=Z("document-meta");a.filter=new odf.OdfNodeFilter;c+=a.writeToString(G.rootElement.meta,odf.Namespaces.namespaceMap);return c+""}function E(a,c){var b=document.createElementNS("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0","manifest:file-entry");b.setAttributeNS("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0","manifest:full-path",a);b.setAttributeNS("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0", +"manifest:media-type",c);return b}function ka(){var a=runtime.parseXML(''),c=h(a,"urn:oasis:names:tc:opendocument:xmlns:manifest:1.0","manifest"),b=new xmldom.LSSerializer,d;for(d in O)O.hasOwnProperty(d)&&c.appendChild(E(d,O[d]));b.filter=new odf.OdfNodeFilter;return'\n'+b.writeToString(a,odf.Namespaces.namespaceMap)} +function ba(){var a=new xmldom.LSSerializer,c=Z("document-settings");a.filter=new odf.OdfNodeFilter;c+=a.writeToString(G.rootElement.settings,odf.Namespaces.namespaceMap);return c+""}function ga(){var a=odf.Namespaces.namespaceMap,c=new xmldom.LSSerializer,b,f,h,l=Z("document-styles");f=v(G.rootElement.automaticStyles,"document-styles");h=G.rootElement.masterStyles&&G.rootElement.masterStyles.cloneNode(!0);b=t(G.rootElement.fontFaceDecls,[h,G.rootElement.styles,f]);d.removePrefixFromStyleNames(f, +k,h);c.filter=new e(h,f);l+=c.writeToString(b,a);l+=c.writeToString(G.rootElement.styles,a);l+=c.writeToString(f,a);l+=c.writeToString(h,a);return l+""}function S(){var a=odf.Namespaces.namespaceMap,c=new xmldom.LSSerializer,b,d,f=Z("document-content");d=v(G.rootElement.automaticStyles,"document-content");b=t(G.rootElement.fontFaceDecls,[d]);c.filter=new p(G.rootElement.body,d);f+=c.writeToString(b,a);f+=c.writeToString(d,a);f+=c.writeToString(G.rootElement.body,a);return f+ +""}function Y(a,c){runtime.loadXML(a,function(a,b){if(a)c(a);else{var d=s(b);d&&"document"===d.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===d.namespaceURI?(A(d),D(n.DONE)):D(n.INVALID)}})}function V(){function a(c,b){var f;b||(b=c);f=document.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0",b);d[c]=f;d.appendChild(f)}var c=new core.Zip("",null),b=runtime.byteArrayFromString("application/vnd.oasis.opendocument.text","utf8"),d=G.rootElement, +f=document.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0","text");c.save("mimetype",b,!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(f);D(n.DONE);return c}function N(){var a,c=new Date;a=runtime.byteArrayFromString(ba(),"utf8");Q.save("settings.xml",a,!0,c);a=runtime.byteArrayFromString(ja(),"utf8");Q.save("meta.xml",a,!0,c); +a=runtime.byteArrayFromString(ga(),"utf8");Q.save("styles.xml",a,!0,c);a=runtime.byteArrayFromString(S(),"utf8");Q.save("content.xml",a,!0,c);a=runtime.byteArrayFromString(ka(),"utf8");Q.save("META-INF/manifest.xml",a,!0,c)}function L(a,c){N();Q.writeAs(a,function(a){c(a)})}var G=this,Q,O={},ca;this.onstatereadychange=m;this.rootElement=this.state=this.onchange=null;this.setRootElement=A;this.getContentElement=function(){var a;ca||(a=G.rootElement.body,ca=a.getElementsByTagNameNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0", +"text")[0]||a.getElementsByTagNameNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0","presentation")[0]||a.getElementsByTagNameNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0","spreadsheet")[0]);return ca};this.getDocumentType=function(){var a=G.getContentElement();return a&&a.localName};this.getPart=function(c){return new a(c,O[c],G,Q)};this.getPartData=function(a,c){Q.load(a,c)};this.createByteArray=function(a,c){N();Q.createByteArray(a,c)};this.saveAs=L;this.save=function(a){L(b,a)};this.getUrl= +function(){return b};this.setBlob=function(a,b,d){d=c.convertBase64ToByteArray(d);Q.save(a,d,!1,new Date);O.hasOwnProperty(a)&&runtime.log(a+" has been overwritten.");O[a]=b};this.removeBlob=function(a){var c=Q.remove(a);runtime.assert(c,"file is not found: "+a);delete O[a]};this.state=n.LOADING;this.rootElement=function(a){var c=document.createElementNS(a.namespaceURI,a.localName),b;a=new a;for(b in a)a.hasOwnProperty(b)&&(c[b]=a[b]);return c}(q);Q=b?new core.Zip(b,function(a,c){Q=c;a?Y(b,function(c){a&& +(Q.error=a+"\n"+c,D(n.INVALID))}):R([["styles.xml",C],["content.xml",I],["meta.xml",z],["settings.xml",M],["META-INF/manifest.xml",H]])}):V()};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 35 /* @@ -844,9 +845,9 @@ function(){return d};this.setBlob=function(a,b,d){d=g.convertBase64ToByteArray(d @source: https://github.com/kogmbh/WebODF/ */ runtime.loadClass("core.Base64");runtime.loadClass("xmldom.XPath");runtime.loadClass("odf.OdfContainer"); -odf.FontLoader=function(){function e(h,m,p,c,b){var a,d=0,k;for(k in h)if(h.hasOwnProperty(k)){if(d===p){a=k;break}d+=1}a?m.getPartData(h[a].href,function(d,k){if(d)runtime.log(d);else{var l="@font-face { font-family: '"+(h[a].family||a)+"'; src: url(data:application/x-font-ttf;charset=binary;base64,"+f.convertUTF8ArrayToBase64(k)+') format("truetype"); }';try{c.insertRule(l,c.cssRules.length)}catch(r){runtime.log("Problem inserting rule in CSS: "+runtime.toJson(r)+"\nRule: "+l)}}e(h,m,p+1,c,b)}): -b&&b()}var h=new xmldom.XPath,f=new core.Base64;odf.FontLoader=function(){this.loadFonts=function(f,m){for(var p=f.rootElement.fontFaceDecls;m.cssRules.length;)m.deleteRule(m.cssRules.length-1);if(p){var c={},b,a,d,k;if(p)for(p=h.getODFElementsWithXPath(p,"style:font-face[svg:font-face-src]",odf.Namespaces.resolvePrefix),b=0;b text|list-item > *:first-child:before {";if(H=K.getAttributeNS(I, -"style-name"))K=v[H],O=ka.getFirstNonWhitespaceChild(K),K=void 0,O&&("list-level-style-number"===O.localName?(K=O.getAttributeNS(C,"num-format"),H=O.getAttributeNS(C,"num-suffix"),J="",J={1:"decimal",a:"lower-latin",A:"upper-latin",i:"lower-roman",I:"upper-roman"},M=void 0,M=O.getAttributeNS(C,"num-prefix")||"",M=J.hasOwnProperty(K)?M+(" counter(list, "+J[K]+")"):K?M+("'"+K+"';"):M+" ''",H&&(M+=" '"+H+"'"),K=J="content: "+M+";"):"list-level-style-image"===O.localName?K="content: none;":"list-level-style-bullet"=== -O.localName&&(K="content: '"+O.getAttributeNS(I,"bullet-char")+"';")),O=K;if(T){for(K=w[T];K;)T=K,K=w[T];E+="counter-increment:"+T+";";O?(O=O.replace("list",T),E+=O):E+="content:counter("+T+");"}else T="",O?(O=O.replace("list",z),E+=O):E+="content: counter("+z+");",E+="counter-increment:"+z+";",h.insertRule("text|list#"+z+" {counter-reset:"+z+"}",h.cssRules.length);E+="}";w[z]=T;E&&h.insertRule(E,h.cssRules.length)}V.insertBefore(ia,V.firstChild);B();W(g);if(!e&&(g=[P],ba.hasOwnProperty("statereadychange")))for(h= -ba.statereadychange,O=0;O text|list-item > *:first-child:before {";if(F=K.getAttributeNS(I, +"style-name"))K=w[F],G=ja.getFirstNonWhitespaceChild(K),K=void 0,G&&("list-level-style-number"===G.localName?(K=G.getAttributeNS(D,"num-format"),F=G.getAttributeNS(D,"num-suffix"),N="",N={1:"decimal",a:"lower-latin",A:"upper-latin",i:"lower-roman",I:"upper-roman"},L=void 0,L=G.getAttributeNS(D,"num-prefix")||"",L=N.hasOwnProperty(K)?L+(" counter(list, "+N[K]+")"):K?L+("'"+K+"';"):L+" ''",F&&(L+=" '"+F+"'"),K=N="content: "+L+";"):"list-level-style-image"===G.localName?K="content: none;":"list-level-style-bullet"=== +G.localName&&(K="content: '"+G.getAttributeNS(I,"bullet-char")+"';")),G=K;if(E){for(K=x[E];K;)E=K,K=x[E];B+="counter-increment:"+E+";";G?(G=G.replace("list",E),B+=G):B+="content:counter("+E+");"}else E="",G?(G=G.replace("list",z),B+=G):B+="content: counter("+z+");",B+="counter-increment:"+z+";",l.insertRule("text|list#"+z+" {counter-reset:"+z+"}",l.cssRules.length);B+="}";x[z]=E;B&&l.insertRule(B,l.cssRules.length)}T.insertBefore(fa,T.firstChild);A();V(h);if(!c&&(h=[O],ha.hasOwnProperty("statereadychange")))for(l= +ha.statereadychange,G=0;G=p.textNode.length?null:p.textNode.splitText(p.offset));for(a=p.textNode;a!==b;)if(a= -a.parentNode,d=a.cloneNode(!1),g){for(k&&d.appendChild(k);g.nextSibling;)d.appendChild(g.nextSibling);a.parentNode.insertBefore(d,a.nextSibling);g=a;k=d}else a.parentNode.insertBefore(d,a),g=d,k=a;n.isListItem(k)&&(k=k.childNodes[0]);0===p.textNode.length&&p.textNode.parentNode.removeChild(p.textNode);m.fixCursorPositions();m.getOdfCanvas().refreshSize();m.emit(ops.OdtDocument.signalParagraphChanged,{paragraphElement:c,memberId:e,timeStamp:h});m.emit(ops.OdtDocument.signalParagraphChanged,{paragraphElement:k, -memberId:e,timeStamp:h});m.getOdfCanvas().rerenderAnnotations();return!0};this.spec=function(){return{optype:"SplitParagraph",memberid:e,timestamp:h,position:f}}}; +ops.OpSplitParagraph=function(){var h,m,e,p;this.init=function(l){h=l.memberid;m=l.timestamp;e=l.position;p=new odf.OdfUtils};this.execute=function(l){var q,a,d,f,b,k,c;l.upgradeWhitespacesAtPosition(e);q=l.getTextNodeAtStep(e,h);if(!q)return!1;a=l.getParagraphElement(q.textNode);if(!a)return!1;d=p.isListItem(a.parentNode)?a.parentNode:a;0===q.offset?(c=q.textNode.previousSibling,k=null):(c=q.textNode,k=q.offset>=q.textNode.length?null:q.textNode.splitText(q.offset));for(f=q.textNode;f!==d;){f=f.parentNode; +b=f.cloneNode(!1);k&&b.appendChild(k);if(c)for(;c&&c.nextSibling;)b.appendChild(c.nextSibling);else for(;f.firstChild;)b.appendChild(f.firstChild);f.parentNode.insertBefore(b,f.nextSibling);c=f;k=b}p.isListItem(k)&&(k=k.childNodes[0]);0===q.textNode.length&&q.textNode.parentNode.removeChild(q.textNode);l.emit(ops.OdtDocument.signalStepsInserted,{position:e,length:1});l.fixCursorPositions();l.getOdfCanvas().refreshSize();l.emit(ops.OdtDocument.signalParagraphChanged,{paragraphElement:a,memberId:h, +timeStamp:m});l.emit(ops.OdtDocument.signalParagraphChanged,{paragraphElement:k,memberId:h,timeStamp:m});l.getOdfCanvas().rerenderAnnotations();return!0};this.spec=function(){return{optype:"SplitParagraph",memberid:h,timestamp:m,position:e}}}; // Input 54 /* @@ -1620,8 +1620,8 @@ memberId:e,timeStamp:h});m.getOdfCanvas().rerenderAnnotations();return!0};this.s @source: http://www.webodf.org/ @source: https://github.com/kogmbh/WebODF/ */ -ops.OpSetParagraphStyle=function(){var e,h,f,n;this.init=function(m){e=m.memberid;h=m.timestamp;f=m.position;n=m.styleName};this.execute=function(m){var p;p=m.getIteratorAtPosition(f);return(p=m.getParagraphElement(p.container()))?(""!==n?p.setAttributeNS("urn:oasis:names:tc:opendocument:xmlns:text:1.0","text:style-name",n):p.removeAttributeNS("urn:oasis:names:tc:opendocument:xmlns:text:1.0","style-name"),m.getOdfCanvas().refreshSize(),m.emit(ops.OdtDocument.signalParagraphChanged,{paragraphElement:p, -timeStamp:h,memberId:e}),m.getOdfCanvas().rerenderAnnotations(),!0):!1};this.spec=function(){return{optype:"SetParagraphStyle",memberid:e,timestamp:h,position:f,styleName:n}}}; +ops.OpSetParagraphStyle=function(){var h,m,e,p;this.init=function(l){h=l.memberid;m=l.timestamp;e=l.position;p=l.styleName};this.execute=function(l){var q;q=l.getIteratorAtPosition(e);return(q=l.getParagraphElement(q.container()))?(""!==p?q.setAttributeNS("urn:oasis:names:tc:opendocument:xmlns:text:1.0","text:style-name",p):q.removeAttributeNS("urn:oasis:names:tc:opendocument:xmlns:text:1.0","style-name"),l.getOdfCanvas().refreshSize(),l.emit(ops.OdtDocument.signalParagraphChanged,{paragraphElement:q, +timeStamp:m,memberId:h}),l.getOdfCanvas().rerenderAnnotations(),!0):!1};this.spec=function(){return{optype:"SetParagraphStyle",memberid:h,timestamp:m,position:e,styleName:p}}}; // Input 55 /* @@ -1661,9 +1661,9 @@ timeStamp:h,memberId:e}),m.getOdfCanvas().rerenderAnnotations(),!0):!1};this.spe @source: https://github.com/kogmbh/WebODF/ */ runtime.loadClass("odf.Namespaces"); -ops.OpUpdateParagraphStyle=function(){function e(b,a){var d,c,e=a?a.split(","):[];for(d=0;da?-1:1;for(a=Math.abs(a);0l?n.previousPosition():n.nextPosition());)if(M.check(),k.acceptPosition(n)===u&&(t+=1,p=n.container(),v=m(p,n.unfilteredDomOffset(),H),v.top!==O)){if(v.top!==E&&E!==O)break;E=v.top;v=Math.abs(W-v.left);if(null===q||va?(d=k.previousPosition,c=-1):(d=k.nextPosition,c=1);for(e=m(k.container(),k.unfilteredDomOffset(),p);d.call(k);)if(b.acceptPosition(k)===u){if(t.getParagraphElement(k.getCurrentNode())!==l)break;g=m(k.container(),k.unfilteredDomOffset(),p);if(g.bottom!==e.bottom&&(e=g.top>=e.top&&g.bottome.bottom,!e))break;n+= -c;e=g}p.detach();return n}function r(a,b,d){runtime.assert(null!==a,"SelectionMover.countStepsToPosition called with element===null");var c=f(),e=c.container(),g=c.unfilteredDomOffset(),h=0,k=new core.LoopWatchDog(1E3);for(c.setUnfilteredPosition(a,b);d.acceptPosition(c)!==u&&c.previousPosition();)k.check();a=c.container();runtime.assert(Boolean(a),"SelectionMover.countStepsToPosition: positionIterator.container() returned null");b=c.unfilteredDomOffset();for(c.setUnfilteredPosition(e,g);d.acceptPosition(c)!== -u&&c.previousPosition();)k.check();e=w.comparePoints(a,b,c.container(),c.unfilteredDomOffset());if(0>e)for(;c.nextPosition()&&(k.check(),d.acceptPosition(c)===u&&(h+=1),c.container()!==a||c.unfilteredDomOffset()!==b););else if(0a?-1:1;for(a=Math.abs(a);0k?n.previousPosition():n.nextPosition());)if(G.check(),h.acceptPosition(n)===t&&(r+=1,p=n.container(),v=l(p,n.unfilteredDomOffset(),L),v.top!==Y)){if(v.top!==N&&N!==Y)break;N=v.top;v=Math.abs(V-v.left);if(null===q||va?(b=h.previousPosition,d=-1):(b=h.nextPosition,d=1);for(g=l(h.container(),h.unfilteredDomOffset(),p);b.call(h);)if(c.acceptPosition(h)===t){if(u.getParagraphElement(h.getCurrentNode())!==k)break;f=l(h.container(),h.unfilteredDomOffset(),p);if(f.bottom!==g.bottom&&(g=f.top>=g.top&&f.bottomg.bottom,!g))break;n+= +d;g=f}p.detach();return n}function r(a,c,b){runtime.assert(null!==a,"SelectionMover.countStepsToPosition called with element===null");var d=e(),g=d.container(),f=d.unfilteredDomOffset(),h=0,k=new core.LoopWatchDog(1E4);for(d.setUnfilteredPosition(a,c);b.acceptPosition(d)!==t&&d.previousPosition();)k.check();a=d.container();runtime.assert(Boolean(a),"SelectionMover.countStepsToPosition: positionIterator.container() returned null");c=d.unfilteredDomOffset();for(d.setUnfilteredPosition(g,f);b.acceptPosition(d)!== +t&&d.previousPosition();)k.check();g=y.comparePoints(a,c,d.container(),d.unfilteredDomOffset());if(0>g)for(;d.nextPosition()&&(k.check(),b.acceptPosition(d)===t&&(h+=1),d.container()!==a||d.unfilteredDomOffset()!==c););else if(0 + + @licstart + The JavaScript code in this page is free software: you can redistribute it + and/or modify it under the terms of the GNU Affero General Public License + (GNU AGPL) as published by the Free Software Foundation, either version 3 of + the License, or (at your option) any later version. The code is distributed + WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU AGPL for more details. + + You should have received a copy of the GNU Affero General Public License + along with this code. If not, see . + + 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: https://github.com/kogmbh/WebODF/ +*/ +runtime.loadClass("core.DomUtils");runtime.loadClass("core.PositionFilter");runtime.loadClass("odf.OdfUtils"); +(function(){function h(e,h,l){function q(a,c){function b(a){for(var c=0;a&&a.previousSibling;)c+=1,a=a.previousSibling;return c}this.steps=a;this.node=c;this.setIteratorPosition=function(a){a.setUnfilteredPosition(c.parentNode,b(c));do if(h.acceptPosition(a)===u)break;while(a.nextPosition())}}function a(a){return a.nodeType===Node.ELEMENT_NODE&&a.getAttributeNS(b,"nodeId")}function d(a){var c=m;a.setAttributeNS(b,"nodeId",c.toString());m+=1;return c}function f(d,g){var f,h=null;for(d=d.childNodes[g]|| +d;!h&&d&&d!==e;)(f=a(d))&&(h=c[f])&&h.node!==d&&(runtime.log("Cloned node detected. Creating new bookmark"),h=null,d.removeAttributeNS(b,"nodeId")),d=d.parentNode;return h}var b="urn:webodf:names:steps",k={},c={},g=new odf.OdfUtils,n=new core.DomUtils,r,u=core.PositionFilter.FilterResult.FILTER_ACCEPT;this.updateCache=function(b,f,e,h){var n;0===e&&g.isParagraph(f)?(n=!0,h||(b+=1)):f.hasChildNodes()&&f.childNodes[e]&&(f=f.childNodes[e],(n=g.isParagraph(f))&&(b+=1));n&&(e=a(f)||d(f),(h=c[e])?h.node=== +f?h.steps=b:(runtime.log("Cloned node detected. Creating new bookmark"),e=d(f),h=c[e]=new q(b,f)):h=c[e]=new q(b,f),e=h,b=Math.ceil(e.steps/l)*l,f=k[b],!f||e.steps>f.steps)&&(k[b]=e)};this.setToClosestStep=function(a,c){for(var b=Math.floor(a/l)*l,d;!d&&0!==b;)d=k[b],b-=l;d=d||r;d.setIteratorPosition(c);return d.steps};this.setToClosestDomPoint=function(a,c,b){var d;if(a===e&&0===c)d=r;else if(a===e&&c===e.childNodes.length)d=Object.keys(k).map(function(a){return k[a]}).reduce(function(a,c){return c.steps> +a.steps?c:a},r);else if(d=f(a,c),!d)for(b.setUnfilteredPosition(a,c);!d&&b.previousNode();)d=f(b.container(),b.unfilteredDomOffset());d=d||r;d.setIteratorPosition(b);return d.steps};this.updateCacheAtPoint=function(b,d){var g={};Object.keys(c).map(function(a){return c[a]}).filter(function(a){return a.steps>b}).forEach(function(b){var f=Math.ceil(b.steps/l)*l,h,m;if(n.containsNode(e,b.node)){if(d(b),h=Math.ceil(b.steps/l)*l,m=g[h],!m||b.steps>m.steps)g[h]=b}else delete c[a(b.node)];k[f]===b&&delete k[f]}); +Object.keys(g).forEach(function(a){k[a]=g[a]})};r=new function(a,c){this.steps=a;this.node=c;this.setIteratorPosition=function(a){a.setUnfilteredPosition(c,0);do if(h.acceptPosition(a)===u)break;while(a.nextPosition())}}(0,e)}var m=0;ops.StepsTranslator=function(e,m,l,q){function a(){var a=e();a!==d&&(runtime.log("Undo detected. Resetting steps cache"),d=a,f=new h(d,l,q),k=m(d))}var d=e(),f=new h(d,l,q),b=new core.DomUtils,k=m(e()),c=core.PositionFilter.FilterResult.FILTER_ACCEPT;this.convertStepsToDomPoint= +function(b){var d,e;0>b&&(runtime.log("warn","Requested steps were negative ("+b+")"),b=0);a();for(d=f.setToClosestStep(b,k);db.comparePoints(d,0,g,e),g=d,e=m?0: +d.childNodes.length);k.setUnfilteredPosition(g,e);m=k.container();p=k.unfilteredDomOffset();h&&l.acceptPosition(k)!==c&&(q=1);g=f.setToClosestDomPoint(g,e,k);if(0>b.comparePoints(k.container(),k.unfilteredDomOffset(),m,p))return 0a.steps&&(a.steps=0)})}};return ops.StepsTranslator})(); +// Input 63 +/* + + Copyright (C) 2012-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. + + You should have received a copy of the GNU Affero General Public License + along with this code. If not, see . + + 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: https://github.com/kogmbh/WebODF/ +*/ +runtime.loadClass("core.PositionFilter");runtime.loadClass("odf.OdfUtils"); +ops.TextPositionFilter=function(h){function m(h,a,d){var f,b;if(a&&(f=e.lookLeftForCharacter(a),1===f||2===f&&(e.scanRightForAnyCharacter(d)||e.scanRightForAnyCharacter(e.nextNode(h)))))return p;f=null===a&&e.isParagraph(h);b=e.lookRightForCharacter(d);if(f)return b?p:e.scanRightForAnyCharacter(d)?l:p;if(!b)return l;a=a||e.previousNode(h);return e.scanLeftForAnyCharacter(a)?l:p}var e=new odf.OdfUtils,p=core.PositionFilter.FilterResult.FILTER_ACCEPT,l=core.PositionFilter.FilterResult.FILTER_REJECT; +this.acceptPosition=function(q){var a=q.container(),d=a.nodeType,f,b,k;if(d!==Node.ELEMENT_NODE&&d!==Node.TEXT_NODE)return l;if(d===Node.TEXT_NODE){if(!e.isGroupingElement(a.parentNode)||e.isWithinTrackedChanges(a.parentNode,h()))return l;d=q.unfilteredDomOffset();f=a.data;runtime.assert(d!==f.length,"Unexpected offset.");if(0 @@ -1944,21 +2034,26 @@ gui.SelectionMover.createPositionIterator=function(e){var h=new function(){this. @source: http://www.webodf.org/ @source: https://github.com/kogmbh/WebODF/ */ -ops.OperationTransformMatrix=function(){function e(a,b){return{opSpecsA:[a],opSpecsB:[b]}}function h(a,b){var c=[];a&&["style:parent-style-name","style:next-style-name"].forEach(function(e){a[e]===b&&c.push(e)});return c}function f(a,b){a&&["style:parent-style-name","style:next-style-name"].forEach(function(c){a[c]===b&&delete a[c]})}function n(a,b,c,e){var f,h,m,n=e&&e.attributes?e.attributes.split(","):[];a&&(c||0b.position)a.position+=b.text.length;else return c?b.position+= -a.text.length:a.position+=b.text.length,null;return{opSpecsA:[a],opSpecsB:[b]}},MoveCursor:function(a,b){a.positionb.position)a.position+=1;else return c?b.position+=a.text.length:a.position+=1,null;return{opSpecsA:[a],opSpecsB:[b]}},UpdateParagraphStyle:e},MoveCursor:{MoveCursor:e,RemoveCursor:function(a,b){return{opSpecsA:a.memberid===b.memberid?[]:[a],opSpecsB:[b]}}, -RemoveStyle:e,RemoveText:function(a,b){var c=a.position+a.length,e=b.position+b.length;e<=a.position?a.position-=b.length:b.positionb.position)a.position+= -1;else if(a.position===b.position)return c?b.position+=1:a.position+=1,null;return{opSpecsA:[a],opSpecsB:[b]}},UpdateParagraphStyle:e},UpdateParagraphStyle:{UpdateParagraphStyle:function(a,b,e){var f,h=[a],l=[b];a.styleName===b.styleName&&(f=e?a:b,a=e?b:a,c(a,f,"style:paragraph-properties"),c(a,f,"style:text-properties"),n(a.setProperties||null,a.removedProperties||null,f.setProperties||null,f.removedProperties||null),a.setProperties&&m(a.setProperties)||a.removedProperties&&p(a.removedProperties)|| -(e?l=[]:h=[]));return{opSpecsA:h,opSpecsB:l}}}};this.passUnchanged=e;this.extendTransformations=function(a){Object.keys(a).forEach(function(c){var e=a[c],f,h=b.hasOwnProperty(c);runtime.log((h?"Extending":"Adding")+" map for optypeA: "+c);h||(b[c]={});f=b[c];Object.keys(e).forEach(function(a){var b=f.hasOwnProperty(a);runtime.assert(c<=a,"Wrong order:"+c+", "+a);runtime.log(" "+(b?"Overwriting":"Adding")+" entry for optypeB: "+a);f[a]=e[a]})})};this.transformOpspecVsOpspec=function(a,c){var e=a.optype<= -c.optype,f;runtime.log("Crosstransforming:");runtime.log(runtime.toJson(a));runtime.log(runtime.toJson(c));e||(f=a,a=c,c=f);(f=(f=b[a.optype])&&f[c.optype])?(f=f(a,c,!e),e||null===f||(f={opSpecsA:f.opSpecsB,opSpecsB:f.opSpecsA})):f=null;runtime.log("result:");f?(runtime.log(runtime.toJson(f.opSpecsA)),runtime.log(runtime.toJson(f.opSpecsB))):runtime.log("null");return f}}; -// Input 63 +ops.OperationTransformMatrix=function(){function h(a){a.position+=a.length;a.length*=-1}function m(a){var b=0>a.length;b&&h(a);return b}function e(a,b){var d=[];a&&["style:parent-style-name","style:next-style-name"].forEach(function(f){a[f]===b&&d.push(f)});return d}function p(a,b){a&&["style:parent-style-name","style:next-style-name"].forEach(function(d){a[d]===b&&delete a[d]})}function l(a){var b={};Object.keys(a).forEach(function(d){b[d]="object"===typeof a[d]?l(a[d]):a[d]});return b}function q(a, +b,d,f){var e,h,k=!1,l=!1,m,p,q=f&&f.attributes?f.attributes.split(","):[];a&&(d||0=b.position+b.length)){e=d?c:b;h=d?b:c;if(c.position!==b.position|| +c.length!==b.length)q=l(e),t=l(h);b=f(h,e,"style:text-properties");if(b.majorChanged||b.minorChanged)k=[],c=[],m=e.position+e.length,p=h.position+h.length,h.positionm?b.minorChanged&&(q=t,q.position=m,q.length=p-m,c.push(q),h.length=m-h.position): +m>p&&b.majorChanged&&(q.position=p,q.length=m-p,k.push(q),e.length=p-e.position),e.setProperties&&a(e.setProperties)&&k.push(e),h.setProperties&&a(h.setProperties)&&c.push(h),d?(m=k,k=c):m=c}return{opSpecsA:m,opSpecsB:k}},InsertText:function(a,b){b.position<=a.position?a.position+=b.text.length:b.position<=a.position+a.length&&(a.length+=b.text.length);return{opSpecsA:[a],opSpecsB:[b]}},MoveCursor:b,RemoveCursor:b,RemoveStyle:b,RemoveText:function(a,b){var d=a.position+a.length,f=b.position+b.length, +e=[a],h=[b];f<=a.position?a.position-=b.length:b.position +b.position)a.position+=b.text.length;else return d?b.position+=a.text.length:a.position+=b.text.length,null;return{opSpecsA:[a],opSpecsB:[b]}},MoveCursor:function(a,b){var d=m(b);a.positionb.position)a.position+=1;else return d?b.position+=a.text.length:a.position+=1,null;return{opSpecsA:[a],opSpecsB:[b]}},UpdateParagraphStyle:b},MoveCursor:{MoveCursor:b,RemoveCursor:function(a, +b){return{opSpecsA:a.memberid===b.memberid?[]:[a],opSpecsB:[b]}},RemoveStyle:b,RemoveText:function(a,b){var d=m(a),f=a.position+a.length,e=b.position+b.length;e<=a.position?a.position-=b.length:b.positionb.position)a.position+=1;else if(a.position===b.position)return d?b.position+=1:a.position+=1,null;return{opSpecsA:[a],opSpecsB:[b]}},UpdateParagraphStyle:b},UpdateParagraphStyle:{UpdateParagraphStyle:function(b,e,h){var k,l=[b],m=[e];b.styleName===e.styleName&&(k=h?b:e,b=h?e:b,f(b,k,"style:paragraph-properties"),f(b,k,"style:text-properties"),q(b.setProperties||null,b.removedProperties||null, +k.setProperties||null,k.removedProperties||null),k.setProperties&&a(k.setProperties)||k.removedProperties&&d(k.removedProperties)||(h?l=[]:m=[]),b.setProperties&&a(b.setProperties)||b.removedProperties&&d(b.removedProperties)||(h?m=[]:l=[]));return{opSpecsA:l,opSpecsB:m}}}};this.passUnchanged=b;this.extendTransformations=function(a){Object.keys(a).forEach(function(b){var d=a[b],f,e=k.hasOwnProperty(b);runtime.log((e?"Extending":"Adding")+" map for optypeA: "+b);e||(k[b]={});f=k[b];Object.keys(d).forEach(function(a){var c= +f.hasOwnProperty(a);runtime.assert(b<=a,"Wrong order:"+b+", "+a);runtime.log(" "+(c?"Overwriting":"Adding")+" entry for optypeB: "+a);f[a]=d[a]})})};this.transformOpspecVsOpspec=function(a,b){var d=a.optype<=b.optype,f;runtime.log("Crosstransforming:");runtime.log(runtime.toJson(a));runtime.log(runtime.toJson(b));d||(f=a,a=b,b=f);(f=(f=k[a.optype])&&f[b.optype])?(f=f(a,b,!d),d||null===f||(f={opSpecsA:f.opSpecsB,opSpecsB:f.opSpecsA})):f=null;runtime.log("result:");f?(runtime.log(runtime.toJson(f.opSpecsA)), +runtime.log(runtime.toJson(f.opSpecsB))):runtime.log("null");return f}}; +// Input 65 /* Copyright (C) 2013 KO GmbH @@ -1984,14 +2079,14 @@ c.optype,f;runtime.log("Crosstransforming:");runtime.log(runtime.toJson(a));runt @source: https://github.com/kogmbh/WebODF/ */ runtime.loadClass("ops.OperationFactory");runtime.loadClass("ops.OperationTransformMatrix"); -ops.OperationTransformer=function(){function e(e){var h=[];e.forEach(function(c){h.push(f.create(c))});return h}function h(e,f){for(var c,b,a=[],d=[];0=b&&(c=-p.movePointBackward(-b,a));f.handleUpdate();return c};this.handleUpdate=function(){};this.getStepCounter=function(){return p.getStepCounter()};this.getMemberId=function(){return e};this.getNode=function(){return c.getNode()};this.getAnchorNode=function(){return c.getAnchorNode()};this.getSelectedRange=function(){return c.getSelectedRange()}; -this.setSelectedRange=function(b,a){c.setSelectedRange(b,a)};this.hasForwardSelection=function(){return c.hasForwardSelection()};this.getOdtDocument=function(){return h};this.getSelectionType=function(){return m};this.setSelectionType=function(b){n.hasOwnProperty(b)?m=b:runtime.log("Invalid selection type: "+b)};this.resetSelectionType=function(){f.setSelectionType(ops.OdtCursor.RangeSelection)};c=new core.Cursor(h.getDOM(),e);p=new gui.SelectionMover(c,h.getRootNode());n[ops.OdtCursor.RangeSelection]= -!0;n[ops.OdtCursor.RegionSelection]=!0;f.resetSelectionType()};ops.OdtCursor.RangeSelection="Range";ops.OdtCursor.RegionSelection="Region";(function(){return ops.OdtCursor})(); -// Input 65 +ops.OdtCursor=function(h,m){var e=this,p={},l,q,a;this.removeFromOdtDocument=function(){a.remove()};this.move=function(a,f){var b=0;0=a&&(b=-q.movePointBackward(-a,f));e.handleUpdate();return b};this.handleUpdate=function(){};this.getStepCounter=function(){return q.getStepCounter()};this.getMemberId=function(){return h};this.getNode=function(){return a.getNode()};this.getAnchorNode=function(){return a.getAnchorNode()};this.getSelectedRange=function(){return a.getSelectedRange()}; +this.setSelectedRange=function(d,f){a.setSelectedRange(d,f);e.handleUpdate()};this.hasForwardSelection=function(){return a.hasForwardSelection()};this.getOdtDocument=function(){return m};this.getSelectionType=function(){return l};this.setSelectionType=function(a){p.hasOwnProperty(a)?l=a:runtime.log("Invalid selection type: "+a)};this.resetSelectionType=function(){e.setSelectionType(ops.OdtCursor.RangeSelection)};a=new core.Cursor(m.getDOM(),h);q=new gui.SelectionMover(a,m.getRootNode());p[ops.OdtCursor.RangeSelection]= +!0;p[ops.OdtCursor.RegionSelection]=!0;e.resetSelectionType()};ops.OdtCursor.RangeSelection="Range";ops.OdtCursor.RegionSelection="Region";(function(){return ops.OdtCursor})(); +// Input 67 /* Copyright (C) 2012 KO GmbH @@ -2029,110 +2124,22 @@ this.setSelectedRange=function(b,a){c.setSelectedRange(b,a)};this.hasForwardSele @source: http://www.webodf.org/ @source: https://github.com/kogmbh/WebODF/ */ -ops.EditInfo=function(e,h){function f(){var e=[],c;for(c in m)m.hasOwnProperty(c)&&e.push({memberid:c,time:m[c].time});e.sort(function(b,a){return b.time-a.time});return e}var n,m={};this.getNode=function(){return n};this.getOdtDocument=function(){return h};this.getEdits=function(){return m};this.getSortedEdits=function(){return f()};this.addEdit=function(e,c){m[e]={time:c}};this.clearEdits=function(){m={}};this.destroy=function(f){e.parentNode&&e.removeChild(n);f()};n=h.getDOM().createElementNS("urn:webodf:names:editinfo", -"editinfo");e.insertBefore(n,e.firstChild)}; -// Input 66 -runtime.loadClass("gui.SelectionMover");gui.ShadowCursor=function(e){var h=e.getDOM().createRange(),f=!0;this.removeFromOdtDocument=function(){};this.getMemberId=function(){return gui.ShadowCursor.ShadowCursorMemberId};this.getSelectedRange=function(){return h};this.setSelectedRange=function(e,m){h=e;f=!1!==m};this.hasForwardSelection=function(){return f};this.getOdtDocument=function(){return e};this.getSelectionType=function(){return ops.OdtCursor.RangeSelection};h.setStart(e.getRootNode(),0)}; -gui.ShadowCursor.ShadowCursorMemberId="";(function(){return gui.ShadowCursor})(); -// Input 67 -gui.Avatar=function(e,h){var f=this,n,m,p;this.setColor=function(c){m.style.borderColor=c};this.setImageUrl=function(c){f.isVisible()?m.src=c:p=c};this.isVisible=function(){return"block"===n.style.display};this.show=function(){p&&(m.src=p,p=void 0);n.style.display="block"};this.hide=function(){n.style.display="none"};this.markAsFocussed=function(c){n.className=c?"active":""};this.destroy=function(c){e.removeChild(n);c()};(function(){var c=e.ownerDocument,b=c.documentElement.namespaceURI;n=c.createElementNS(b, -"div");m=c.createElementNS(b,"img");m.width=64;m.height=64;n.appendChild(m);n.style.width="64px";n.style.height="70px";n.style.position="absolute";n.style.top="-80px";n.style.left="-34px";n.style.display=h?"block":"none";e.appendChild(n)})()}; +ops.EditInfo=function(h,m){function e(){var e=[],a;for(a in l)l.hasOwnProperty(a)&&e.push({memberid:a,time:l[a].time});e.sort(function(a,f){return a.time-f.time});return e}var p,l={};this.getNode=function(){return p};this.getOdtDocument=function(){return m};this.getEdits=function(){return l};this.getSortedEdits=function(){return e()};this.addEdit=function(e,a){l[e]={time:a}};this.clearEdits=function(){l={}};this.destroy=function(e){h.parentNode&&h.removeChild(p);e()};p=m.getDOM().createElementNS("urn:webodf:names:editinfo", +"editinfo");h.insertBefore(p,h.firstChild)}; // Input 68 -runtime.loadClass("core.DomUtils");runtime.loadClass("gui.Avatar");runtime.loadClass("ops.OdtCursor"); -gui.Caret=function(e,h,f){function n(b){k&&a.parentNode&&(!g||b)&&(b&&void 0!==q&&runtime.clearTimeout(q),g=!0,c.style.opacity=b||"0"===c.style.opacity?"1":"0",q=runtime.setTimeout(function(){g=!1;n(!1)},500))}function m(a,b){var c=a.getBoundingClientRect(),d=0,e=0;c&&b&&(d=Math.max(c.top,b.top),e=Math.min(c.bottom,b.bottom));return e-d}function p(){var a;a=e.getSelectedRange().cloneRange();var b=e.getNode(),f,g=null;b.previousSibling&&(f=b.previousSibling.nodeType===Node.TEXT_NODE?b.previousSibling.textContent.length: -b.previousSibling.childNodes.length,a.setStart(b.previousSibling,0m(b,g))&&(g=f));a=g;b=e.getOdtDocument().getOdfCanvas().getZoomLevel();d&&e.getSelectionType()===ops.OdtCursor.RangeSelection? -c.style.visibility="visible":c.style.visibility="hidden";a?(c.style.top="0",g=c.ownerDocument.createRange(),g.selectNode(c),f=g.getBoundingClientRect(),g.detach(),8>a.height&&(a={top:a.top-(8-a.height)/2,height:8}),c.style.height=l.adaptRangeDifferenceToZoomLevel(a.height,b)+"px",c.style.top=l.adaptRangeDifferenceToZoomLevel(a.top-f.top,b)+"px"):(c.style.height="1em",c.style.top="5%")}var c,b,a,d=!0,k=!1,g=!1,q,l=new core.DomUtils;this.handleUpdate=p;this.refreshCursorBlinking=function(){f||e.getSelectedRange().collapsed? -(k=!0,n(!0)):(k=!1,c.style.opacity="0")};this.setFocus=function(){k=!0;b.markAsFocussed(!0);n(!0)};this.removeFocus=function(){k=!1;b.markAsFocussed(!1);c.style.opacity="1"};this.show=function(){d=!0;p();b.markAsFocussed(!0)};this.hide=function(){d=!1;p();b.markAsFocussed(!1)};this.setAvatarImageUrl=function(a){b.setImageUrl(a)};this.setColor=function(a){c.style.borderColor=a;b.setColor(a)};this.getCursor=function(){return e};this.getFocusElement=function(){return c};this.toggleHandleVisibility=function(){b.isVisible()? -b.hide():b.show()};this.showHandle=function(){b.show()};this.hideHandle=function(){b.hide()};this.ensureVisible=function(){var a,b,d,f,g=e.getOdtDocument().getOdfCanvas().getElement().parentNode,h;d=g.offsetWidth-g.clientWidth+5;f=g.offsetHeight-g.clientHeight+5;h=c.getBoundingClientRect();a=h.left-d;b=h.top-f;d=h.right+d;f=h.bottom+f;h=g.getBoundingClientRect();bh.bottom&&(g.scrollTop+=f-h.bottom);ah.right&&(g.scrollLeft+=d-h.right); -p()};this.destroy=function(d){b.destroy(function(b){b?d(b):(a.removeChild(c),d())})};(function(){var d=e.getOdtDocument().getDOM();c=d.createElementNS(d.documentElement.namespaceURI,"span");c.style.top="5%";a=e.getNode();a.appendChild(c);b=new gui.Avatar(a,h);p()})()}; +runtime.loadClass("gui.SelectionMover");gui.ShadowCursor=function(h){var m=h.getDOM().createRange(),e=!0;this.removeFromOdtDocument=function(){};this.getMemberId=function(){return gui.ShadowCursor.ShadowCursorMemberId};this.getSelectedRange=function(){return m};this.setSelectedRange=function(h,l){m=h;e=!1!==l};this.hasForwardSelection=function(){return e};this.getOdtDocument=function(){return h};this.getSelectionType=function(){return ops.OdtCursor.RangeSelection};m.setStart(h.getRootNode(),0)}; +gui.ShadowCursor.ShadowCursorMemberId="";(function(){return gui.ShadowCursor})(); // Input 69 -/* - - 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. - - You should have received a copy of the GNU Affero General Public License - along with this code. If not, see . - - 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: https://github.com/kogmbh/WebODF/ -*/ -runtime.loadClass("odf.Namespaces");runtime.loadClass("xmldom.LSSerializer");runtime.loadClass("odf.OdfNodeFilter");runtime.loadClass("odf.TextSerializer"); -gui.Clipboard=function(){var e,h,f;this.setDataFromRange=function(f,m){var p=!0,c,b=f.clipboardData;c=runtime.getWindow();var a=m.startContainer.ownerDocument;!b&&c&&(b=c.clipboardData);b?(a=a.createElement("span"),a.appendChild(m.cloneContents()),c=b.setData("text/plain",h.writeToString(a)),p=p&&c,c=b.setData("text/html",e.writeToString(a,odf.Namespaces.namespaceMap)),p=p&&c,f.preventDefault()):p=!1;return p};e=new xmldom.LSSerializer;h=new odf.TextSerializer;f=new odf.OdfNodeFilter;e.filter=f;h.filter= -f}; +gui.Avatar=function(h,m){var e=this,p,l,q;this.setColor=function(a){l.style.borderColor=a};this.setImageUrl=function(a){e.isVisible()?l.src=a:q=a};this.isVisible=function(){return"block"===p.style.display};this.show=function(){q&&(l.src=q,q=void 0);p.style.display="block"};this.hide=function(){p.style.display="none"};this.markAsFocussed=function(a){p.className=a?"active":""};this.destroy=function(a){h.removeChild(p);a()};(function(){var a=h.ownerDocument,d=a.documentElement.namespaceURI;p=a.createElementNS(d, +"div");l=a.createElementNS(d,"img");l.width=64;l.height=64;p.appendChild(l);p.style.width="64px";p.style.height="70px";p.style.position="absolute";p.style.top="-80px";p.style.left="-34px";p.style.display=m?"block":"none";h.appendChild(p)})()}; // Input 70 -/* - - 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. - - You should have received a copy of the GNU Affero General Public License - along with this code. If not, see . - - 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: https://github.com/kogmbh/WebODF/ -*/ -runtime.loadClass("core.EventNotifier");runtime.loadClass("core.Utils");runtime.loadClass("ops.OpApplyDirectStyling");runtime.loadClass("gui.StyleHelper"); -gui.DirectTextStyler=function(e,h){function f(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 n(a,b){var c=f(a[0],b);return a.every(function(a){return c===f(a,b)})?c:void 0}function m(){var a=u.getCursor(h),a=(a=a&&a.getSelectedRange())&&s.getAppliedStyles(a)||[];a[0]&&B&&(a[0]=x.mergeObjects(a[0],B));return a}function p(){function a(b,d,e){b!==d&&(void 0===c&&(c={}),c[e]=d);return d}var b,c;A=m();I=a(I,A?s.isBold(A):!1,"isBold");z=a(z,A?s.isItalic(A):!1,"isItalic"); -N=a(N,A?s.hasUnderline(A):!1,"hasUnderline");G=a(G,A?s.hasStrikeThrough(A):!1,"hasStrikeThrough");b=A&&n(A,["style:text-properties","fo:font-size"]);R=a(R,b&&parseFloat(b),"fontSize");Z=a(Z,A&&n(A,["style:text-properties","style:font-name"]),"fontName");c&&C.emit(gui.DirectTextStyler.textStylingChanged,c)}function c(a){a.getMemberId()===h&&p()}function b(a){a===h&&p()}function a(a){a.getMemberId()===h&&p()}function d(){p()}function k(a){var b=u.getCursor(h);b&&u.getParagraphElement(b.getNode())=== -a.paragraphElement&&p()}function g(a,b){var c=u.getCursor(h);if(!c)return!1;c=s.getAppliedStyles(c.getSelectedRange());b(!a(c));return!0}function q(a){var b=u.getCursorSelection(h),c={"style:text-properties":a};0!==b.length?(a=new ops.OpApplyDirectStyling,a.init({memberid:h,position:b.position,length:b.length,setProperties:c}),e.enqueue([a])):(B=x.mergeObjects(B||{},c),p())}function l(a,b){var c={};c[a]=b;q(c)}function r(a){a=a.spec();B&&a.memberid===h&&"SplitParagraph"!==a.optype&&(B=null,p())}function t(a){l("fo:font-weight", -a?"bold":"normal")}function w(a){l("fo:font-style",a?"italic":"normal")}function v(a){l("style:text-underline-style",a?"solid":"none")}function y(a){l("style:text-line-through-style",a?"solid":"none")}var x=new core.Utils,u=e.getOdtDocument(),s=new gui.StyleHelper(u.getFormatting()),C=new core.EventNotifier([gui.DirectTextStyler.textStylingChanged]),B,A=[],I=!1,z=!1,N=!1,G=!1,R,Z;this.formatTextSelection=q;this.createCursorStyleOp=function(a,b){var c=null;B&&(c=new ops.OpApplyDirectStyling,c.init({memberid:h, -position:a,length:b,setProperties:B}),B=null,p());return c};this.setBold=t;this.setItalic=w;this.setHasUnderline=v;this.setHasStrikethrough=y;this.setFontSize=function(a){l("fo:font-size",a+"pt")};this.setFontName=function(a){l("style:font-name",a)};this.getAppliedStyles=function(){return A};this.toggleBold=g.bind(this,s.isBold,t);this.toggleItalic=g.bind(this,s.isItalic,w);this.toggleUnderline=g.bind(this,s.hasUnderline,v);this.toggleStrikethrough=g.bind(this,s.hasStrikeThrough,y);this.isBold=function(){return I}; -this.isItalic=function(){return z};this.hasUnderline=function(){return N};this.hasStrikeThrough=function(){return G};this.fontSize=function(){return R};this.fontName=function(){return Z};this.subscribe=function(a,b){C.subscribe(a,b)};this.unsubscribe=function(a,b){C.unsubscribe(a,b)};this.destroy=function(e){u.unsubscribe(ops.OdtDocument.signalCursorAdded,c);u.unsubscribe(ops.OdtDocument.signalCursorRemoved,b);u.unsubscribe(ops.OdtDocument.signalCursorMoved,a);u.unsubscribe(ops.OdtDocument.signalParagraphStyleModified, -d);u.unsubscribe(ops.OdtDocument.signalParagraphChanged,k);u.unsubscribe(ops.OdtDocument.signalOperationExecuted,r);e()};u.subscribe(ops.OdtDocument.signalCursorAdded,c);u.subscribe(ops.OdtDocument.signalCursorRemoved,b);u.subscribe(ops.OdtDocument.signalCursorMoved,a);u.subscribe(ops.OdtDocument.signalParagraphStyleModified,d);u.subscribe(ops.OdtDocument.signalParagraphChanged,k);u.subscribe(ops.OdtDocument.signalOperationExecuted,r);p()};gui.DirectTextStyler.textStylingChanged="textStyling/changed"; -(function(){return gui.DirectTextStyler})(); +runtime.loadClass("core.DomUtils");runtime.loadClass("gui.Avatar");runtime.loadClass("ops.OdtCursor"); +gui.Caret=function(h,m,e){function p(b){k&&f.parentNode&&(!c||b)&&(b&&void 0!==g&&runtime.clearTimeout(g),c=!0,a.style.opacity=b||"0"===a.style.opacity?"1":"0",g=runtime.setTimeout(function(){c=!1;p(!1)},500))}function l(a,b){var c=a.getBoundingClientRect(),d=0,f=0;c&&b&&(d=Math.max(c.top,b.top),f=Math.min(c.bottom,b.bottom));return f-d}function q(){var c;c=h.getSelectedRange().cloneRange();var d=h.getNode(),f,e=null;d.previousSibling&&(f=d.previousSibling.nodeType===Node.TEXT_NODE?d.previousSibling.textContent.length: +d.previousSibling.childNodes.length,c.setStart(d.previousSibling,0l(d,e))&&(e=f));c=e;d=h.getOdtDocument().getOdfCanvas().getZoomLevel();b&&h.getSelectionType()===ops.OdtCursor.RangeSelection? +a.style.visibility="visible":a.style.visibility="hidden";c?(a.style.top="0",e=a.ownerDocument.createRange(),e.selectNode(a),f=e.getBoundingClientRect(),e.detach(),8>c.height&&(c={top:c.top-(8-c.height)/2,height:8}),a.style.height=n.adaptRangeDifferenceToZoomLevel(c.height,d)+"px",a.style.top=n.adaptRangeDifferenceToZoomLevel(c.top-f.top,d)+"px"):(a.style.height="1em",a.style.top="5%")}var a,d,f,b=!0,k=!1,c=!1,g,n=new core.DomUtils;this.handleUpdate=q;this.refreshCursorBlinking=function(){e||h.getSelectedRange().collapsed? +(k=!0,p(!0)):(k=!1,a.style.opacity="0")};this.setFocus=function(){k=!0;d.markAsFocussed(!0);p(!0)};this.removeFocus=function(){k=!1;d.markAsFocussed(!1);a.style.opacity="1"};this.show=function(){b=!0;q();d.markAsFocussed(!0)};this.hide=function(){b=!1;q();d.markAsFocussed(!1)};this.setAvatarImageUrl=function(a){d.setImageUrl(a)};this.setColor=function(b){a.style.borderColor=b;d.setColor(b)};this.getCursor=function(){return h};this.getFocusElement=function(){return a};this.toggleHandleVisibility=function(){d.isVisible()? +d.hide():d.show()};this.showHandle=function(){d.show()};this.hideHandle=function(){d.hide()};this.ensureVisible=function(){var b,c,d,f,e=h.getOdtDocument().getOdfCanvas().getElement().parentNode,g;d=e.offsetWidth-e.clientWidth+5;f=e.offsetHeight-e.clientHeight+5;g=a.getBoundingClientRect();b=g.left-d;c=g.top-f;d=g.right+d;f=g.bottom+f;g=e.getBoundingClientRect();cg.bottom&&(e.scrollTop+=f-g.bottom);bg.right&&(e.scrollLeft+=d-g.right); +q()};this.destroy=function(b){d.destroy(function(c){c?b(c):(f.removeChild(a),b())})};(function(){var b=h.getOdtDocument().getDOM();a=b.createElementNS(b.documentElement.namespaceURI,"span");a.style.top="5%";f=h.getNode();f.appendChild(a);d=new gui.Avatar(f,m);q()})()}; // Input 71 /* @@ -2171,65 +2178,8 @@ d);u.unsubscribe(ops.OdtDocument.signalParagraphChanged,k);u.unsubscribe(ops.Odt @source: http://www.webodf.org/ @source: https://github.com/kogmbh/WebODF/ */ -runtime.loadClass("core.EventNotifier");runtime.loadClass("core.Utils");runtime.loadClass("odf.OdfUtils");runtime.loadClass("ops.OpAddStyle");runtime.loadClass("ops.OpSetParagraphStyle");runtime.loadClass("gui.StyleHelper"); -gui.DirectParagraphStyler=function(e,h,f){function n(){function a(b,d,e){b!==d&&(void 0===c&&(c={}),c[e]=d);return d}var b=l.getCursor(h),b=b&&b.getSelectedRange(),c;y=a(y,b?w.isAlignedLeft(b):!1,"isAlignedLeft");x=a(x,b?w.isAlignedCenter(b):!1,"isAlignedCenter");u=a(u,b?w.isAlignedRight(b):!1,"isAlignedRight");s=a(s,b?w.isAlignedJustified(b):!1,"isAlignedJustified");c&&v.emit(gui.DirectParagraphStyler.paragraphStylingChanged,c)}function m(a){a.getMemberId()===h&&n()}function p(a){a===h&&n()}function c(a){a.getMemberId()=== -h&&n()}function b(){n()}function a(a){var b=l.getCursor(h);b&&l.getParagraphElement(b.getNode())===a.paragraphElement&&n()}function d(a){var b=l.getCursor(h).getSelectedRange(),c=l.getCursorPosition(h),b=t.getParagraphElements(b),d=l.getFormatting();b.forEach(function(b){var g=c+l.getDistanceFromCursor(h,b,0),k=b.getAttributeNS(odf.Namespaces.textns,"style-name");b=f.generateStyleName();var m,g=g+1;k&&(m=d.createDerivedStyleObject(k,"paragraph",{}));m=a(m||{});k=new ops.OpAddStyle;k.init({memberid:h, -styleName:b,styleFamily:"paragraph",isAutomaticStyle:!0,setProperties:m});m=new ops.OpSetParagraphStyle;m.init({memberid:h,styleName:b,position:g});e.enqueue([k,m])})}function k(a){d(function(b){return r.mergeObjects(b,a)})}function g(a){k({"style:paragraph-properties":{"fo:text-align":a}})}function q(a,b){var c=l.getFormatting().getDefaultTabStopDistance(),d=b["style:paragraph-properties"],d=(d=d&&d["fo:margin-left"])&&t.parseLength(d);return r.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 l=e.getOdtDocument(),r=new core.Utils,t=new odf.OdfUtils,w=new gui.StyleHelper(l.getFormatting()),v=new core.EventNotifier([gui.DirectParagraphStyler.paragraphStylingChanged]),y,x,u,s;this.isAlignedLeft=function(){return y};this.isAlignedCenter=function(){return x};this.isAlignedRight=function(){return u};this.isAlignedJustified=function(){return s};this.alignParagraphLeft=function(){g("left");return!0};this.alignParagraphCenter=function(){g("center"); -return!0};this.alignParagraphRight=function(){g("right");return!0};this.alignParagraphJustified=function(){g("justify");return!0};this.indent=function(){d(q.bind(null,1));return!0};this.outdent=function(){d(q.bind(null,-1));return!0};this.subscribe=function(a,b){v.subscribe(a,b)};this.unsubscribe=function(a,b){v.unsubscribe(a,b)};this.destroy=function(d){l.unsubscribe(ops.OdtDocument.signalCursorAdded,m);l.unsubscribe(ops.OdtDocument.signalCursorRemoved,p);l.unsubscribe(ops.OdtDocument.signalCursorMoved, -c);l.unsubscribe(ops.OdtDocument.signalParagraphStyleModified,b);l.unsubscribe(ops.OdtDocument.signalParagraphChanged,a);d()};l.subscribe(ops.OdtDocument.signalCursorAdded,m);l.subscribe(ops.OdtDocument.signalCursorRemoved,p);l.subscribe(ops.OdtDocument.signalCursorMoved,c);l.subscribe(ops.OdtDocument.signalParagraphStyleModified,b);l.subscribe(ops.OdtDocument.signalParagraphChanged,a);n()};gui.DirectParagraphStyler.paragraphStylingChanged="paragraphStyling/changed";(function(){return gui.DirectParagraphStyler})(); +gui.PlainTextPasteboard=function(h,m){function e(e,h){e.init(h);return e}this.createPasteOps=function(p){var l=h.getCursorPosition(m),q=l,a=[];p.replace(/\r/g,"").split("\n").forEach(function(d){a.push(e(new ops.OpSplitParagraph,{memberid:m,position:q}));q+=1;a.push(e(new ops.OpInsertText,{memberid:m,position:q,text:d}));q+=d.length});a.push(e(new ops.OpRemoveText,{memberid:m,position:l,length:1}));return a}}; // Input 72 -/* - - Copyright (C) 2012-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. - - You should have received a copy of the GNU Affero General Public License - along with this code. If not, see . - - 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: https://github.com/kogmbh/WebODF/ -*/ -gui.KeyboardHandler=function(){function e(e,f){f||(f=h.None);return e+":"+f}var h=gui.KeyboardHandler.Modifier,f=null,n={};this.setDefault=function(e){f=e};this.bind=function(f,h,c){f=e(f,h);runtime.assert(!1===n.hasOwnProperty(f),"tried to overwrite the callback handler of key combo: "+f);n[f]=c};this.unbind=function(f,h){var c=e(f,h);delete n[c]};this.reset=function(){f=null;n={}};this.handleEvent=function(m){var p=m.keyCode,c=h.None;m.metaKey&&(c|=h.Meta);m.ctrlKey&&(c|=h.Ctrl);m.altKey&&(c|=h.Alt); -m.shiftKey&&(c|=h.Shift);p=e(p,c);p=n[p];c=!1;p?c=p():null!==f&&(c=f(m));c&&(m.preventDefault?m.preventDefault():m.returnValue=!1)}};gui.KeyboardHandler.Modifier={None:0,Meta:1,Ctrl:2,Alt:4,CtrlAlt:6,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 73 -runtime.loadClass("odf.Namespaces");runtime.loadClass("odf.ObjectNameGenerator"); -gui.ImageManager=function(e,h,f){var n={"image/gif":".gif","image/jpeg":".jpg","image/png":".png"},m=odf.Namespaces.textns,p=e.getOdtDocument(),c=p.getFormatting(),b={};this.insertImage=function(a,d,k,g){var q;runtime.assert(0q.width&&(l=q.width/k);g>q.height&&(r=q.height/g);l=Math.min(l,r);q=k*l;k=g*l;r=p.getOdfCanvas().odfContainer().rootElement.styles;g=a.toLowerCase();var l=n.hasOwnProperty(g)?n[g]:null,t;g=[];runtime.assert(null!==l,"Image type is not supported: "+a);l="Pictures/"+f.generateImageName()+l;t=new ops.OpSetBlob;t.init({memberid:h,filename:l,mimetype:a,content:d});g.push(t);c.getStyleElement("Graphics","graphic",[r])||(a=new ops.OpAddStyle,a.init({memberid:h,styleName:"Graphics",styleFamily:"graphic", -isAutomaticStyle:!1,setProperties:{"style:graphic-properties":{"text:anchor-type":"paragraph","svg:x":"0cm","svg:y":"0cm","style:wrap":"dynamic","style:number-wrapped-paragraphs":"no-limit","style:wrap-contour":"false","style:vertical-pos":"top","style:vertical-rel":"paragraph","style:horizontal-pos":"center","style:horizontal-rel":"paragraph"}}}),g.push(a));a=f.generateStyleName();d=new ops.OpAddStyle;d.init({memberid:h,styleName:a,styleFamily:"graphic",isAutomaticStyle:!0,setProperties:{"style:parent-style-name":"Graphics", -"style:graphic-properties":{"style:vertical-pos":"top","style:vertical-rel":"baseline","style:horizontal-pos":"center","style:horizontal-rel":"paragraph","fo:background-color":"transparent","style:background-transparency":"100%","style:shadow":"none","style:mirror":"none","fo:clip":"rect(0cm, 0cm, 0cm, 0cm)","draw:luminance":"0%","draw:contrast":"0%","draw:red":"0%","draw:green":"0%","draw:blue":"0%","draw:gamma":"100%","draw:color-inversion":"false","draw:image-opacity":"100%","draw:color-mode":"standard"}}}); -g.push(d);t=new ops.OpInsertImage;t.init({memberid:h,position:p.getCursorPosition(h),filename:l,frameWidth:q+"cm",frameHeight:k+"cm",frameStyleName:a,frameName:f.generateFrameName()});g.push(t);e.enqueue(g)}}; -// Input 74 -runtime.loadClass("odf.Namespaces"); -gui.ImageSelector=function(e){function h(){var c=e.getSizer(),b,a;b=m.createElement("div");b.id="imageSelector";b.style.borderWidth="1px";c.appendChild(b);n.forEach(function(c){a=m.createElement("div");a.className=c;b.appendChild(a)});return b}var f=odf.Namespaces.svgns,n="topLeft topRight bottomRight bottomLeft topMiddle rightMiddle bottomMiddle leftMiddle".split(" "),m=e.getElement().ownerDocument,p=!1;this.select=function(c){var b,a,d=m.getElementById("imageSelector");d||(d=h());p=!0;b=d.parentNode; -a=c.getBoundingClientRect();var k=b.getBoundingClientRect(),g=e.getZoomLevel();b=(a.left-k.left)/g-1;a=(a.top-k.top)/g-1;d.style.display="block";d.style.left=b+"px";d.style.top=a+"px";d.style.width=c.getAttributeNS(f,"width");d.style.height=c.getAttributeNS(f,"height")};this.clearSelection=function(){var c;p&&(c=m.getElementById("imageSelector"))&&(c.style.display="none");p=!1};this.isSelectorElement=function(c){var b=m.getElementById("imageSelector");return b?c===b||c.parentNode===b:!1}}; -// Input 75 /* Copyright (C) 2013 KO GmbH @@ -2267,10 +2217,196 @@ a=c.getBoundingClientRect();var k=b.getBoundingClientRect(),g=e.getZoomLevel();b @source: http://www.webodf.org/ @source: https://github.com/kogmbh/WebODF/ */ -gui.TextManipulator=function(e,h,f){function n(c){var b=new ops.OpRemoveText;b.init({memberid:h,position:c.position,length:c.length});return b}function m(c){0>c.length&&(c.position+=c.length,c.length=-c.length);return c}var p=e.getOdtDocument();this.enqueueParagraphSplittingOps=function(){var c=m(p.getCursorSelection(h)),b,a=[];0 + + @licstart + The JavaScript code in this page is free software: you can redistribute it + and/or modify it under the terms of the GNU Affero General Public License + (GNU AGPL) as published by the Free Software Foundation, either version 3 of + the License, or (at your option) any later version. The code is distributed + WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU AGPL for more details. + + You should have received a copy of the GNU Affero General Public License + along with this code. If not, see . + + 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: https://github.com/kogmbh/WebODF/ +*/ +runtime.loadClass("core.EventNotifier");runtime.loadClass("core.Utils");runtime.loadClass("ops.OpApplyDirectStyling");runtime.loadClass("gui.StyleHelper"); +gui.DirectTextStyler=function(h,m){function e(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 p(a,b){var c=e(a[0],b);return a.every(function(a){return c===e(a,b)})?c:void 0}function l(){var a=t.getCursor(m),a=(a=a&&a.getSelectedRange())&&s.getAppliedStyles(a)||[];a[0]&&A&&(a[0]=v.mergeObjects(a[0],A));return a}function q(){function a(b,d,f){b!==d&&(void 0===c&&(c={}),c[f]=d);return d}var b,c;C=l();I=a(I,C?s.isBold(C):!1,"isBold");z=a(z,C?s.isItalic(C):!1,"isItalic"); +M=a(M,C?s.hasUnderline(C):!1,"hasUnderline");H=a(H,C?s.hasStrikeThrough(C):!1,"hasStrikeThrough");b=C&&p(C,["style:text-properties","fo:font-size"]);R=a(R,b&&parseFloat(b),"fontSize");Z=a(Z,C&&p(C,["style:text-properties","style:font-name"]),"fontName");c&&D.emit(gui.DirectTextStyler.textStylingChanged,c)}function a(a){a.getMemberId()===m&&q()}function d(a){a===m&&q()}function f(a){a.getMemberId()===m&&q()}function b(){q()}function k(a){var b=t.getCursor(m);b&&t.getParagraphElement(b.getNode())=== +a.paragraphElement&&q()}function c(a,b){var c=t.getCursor(m);if(!c)return!1;c=s.getAppliedStyles(c.getSelectedRange());b(!a(c));return!0}function g(a){var b=t.getCursorSelection(m),c={"style:text-properties":a};0!==b.length?(a=new ops.OpApplyDirectStyling,a.init({memberid:m,position:b.position,length:b.length,setProperties:c}),h.enqueue([a])):(A=v.mergeObjects(A||{},c),q())}function n(a,b){var c={};c[a]=b;g(c)}function r(a){a=a.spec();A&&a.memberid===m&&"SplitParagraph"!==a.optype&&(A=null,q())}function u(a){n("fo:font-weight", +a?"bold":"normal")}function y(a){n("fo:font-style",a?"italic":"normal")}function x(a){n("style:text-underline-style",a?"solid":"none")}function w(a){n("style:text-line-through-style",a?"solid":"none")}var v=new core.Utils,t=h.getOdtDocument(),s=new gui.StyleHelper(t.getFormatting()),D=new core.EventNotifier([gui.DirectTextStyler.textStylingChanged]),A,C=[],I=!1,z=!1,M=!1,H=!1,R,Z;this.formatTextSelection=g;this.createCursorStyleOp=function(a,b){var c=null;A&&(c=new ops.OpApplyDirectStyling,c.init({memberid:m, +position:a,length:b,setProperties:A}),A=null,q());return c};this.setBold=u;this.setItalic=y;this.setHasUnderline=x;this.setHasStrikethrough=w;this.setFontSize=function(a){n("fo:font-size",a+"pt")};this.setFontName=function(a){n("style:font-name",a)};this.getAppliedStyles=function(){return C};this.toggleBold=c.bind(this,s.isBold,u);this.toggleItalic=c.bind(this,s.isItalic,y);this.toggleUnderline=c.bind(this,s.hasUnderline,x);this.toggleStrikethrough=c.bind(this,s.hasStrikeThrough,w);this.isBold=function(){return I}; +this.isItalic=function(){return z};this.hasUnderline=function(){return M};this.hasStrikeThrough=function(){return H};this.fontSize=function(){return R};this.fontName=function(){return Z};this.subscribe=function(a,b){D.subscribe(a,b)};this.unsubscribe=function(a,b){D.unsubscribe(a,b)};this.destroy=function(c){t.unsubscribe(ops.OdtDocument.signalCursorAdded,a);t.unsubscribe(ops.OdtDocument.signalCursorRemoved,d);t.unsubscribe(ops.OdtDocument.signalCursorMoved,f);t.unsubscribe(ops.OdtDocument.signalParagraphStyleModified, +b);t.unsubscribe(ops.OdtDocument.signalParagraphChanged,k);t.unsubscribe(ops.OdtDocument.signalOperationExecuted,r);c()};t.subscribe(ops.OdtDocument.signalCursorAdded,a);t.subscribe(ops.OdtDocument.signalCursorRemoved,d);t.subscribe(ops.OdtDocument.signalCursorMoved,f);t.subscribe(ops.OdtDocument.signalParagraphStyleModified,b);t.subscribe(ops.OdtDocument.signalParagraphChanged,k);t.subscribe(ops.OdtDocument.signalOperationExecuted,r);q()};gui.DirectTextStyler.textStylingChanged="textStyling/changed"; +(function(){return gui.DirectTextStyler})(); +// Input 74 +/* + + 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. + + You should have received a copy of the GNU Affero General Public License + along with this code. If not, see . + + 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: https://github.com/kogmbh/WebODF/ +*/ +runtime.loadClass("core.EventNotifier");runtime.loadClass("core.Utils");runtime.loadClass("odf.OdfUtils");runtime.loadClass("ops.OpAddStyle");runtime.loadClass("ops.OpSetParagraphStyle");runtime.loadClass("gui.StyleHelper"); +gui.DirectParagraphStyler=function(h,m,e){function p(){function a(b,d,f){b!==d&&(void 0===c&&(c={}),c[f]=d);return d}var b=n.getCursor(m),b=b&&b.getSelectedRange(),c;w=a(w,b?y.isAlignedLeft(b):!1,"isAlignedLeft");v=a(v,b?y.isAlignedCenter(b):!1,"isAlignedCenter");t=a(t,b?y.isAlignedRight(b):!1,"isAlignedRight");s=a(s,b?y.isAlignedJustified(b):!1,"isAlignedJustified");c&&x.emit(gui.DirectParagraphStyler.paragraphStylingChanged,c)}function l(a){a.getMemberId()===m&&p()}function q(a){a===m&&p()}function a(a){a.getMemberId()=== +m&&p()}function d(){p()}function f(a){var b=n.getCursor(m);b&&n.getParagraphElement(b.getNode())===a.paragraphElement&&p()}function b(a){var b=n.getCursor(m).getSelectedRange(),c=n.getCursorPosition(m),b=u.getParagraphElements(b),d=n.getFormatting();b.forEach(function(b){var f=c+n.getDistanceFromCursor(m,b,0),g=b.getAttributeNS(odf.Namespaces.textns,"style-name");b=e.generateStyleName();var k,f=f+1;g&&(k=d.createDerivedStyleObject(g,"paragraph",{}));k=a(k||{});g=new ops.OpAddStyle;g.init({memberid:m, +styleName:b,styleFamily:"paragraph",isAutomaticStyle:!0,setProperties:k});k=new ops.OpSetParagraphStyle;k.init({memberid:m,styleName:b,position:f});h.enqueue([g,k])})}function k(a){b(function(b){return r.mergeObjects(b,a)})}function c(a){k({"style:paragraph-properties":{"fo:text-align":a}})}function g(a,b){var c=n.getFormatting().getDefaultTabStopDistance(),d=b["style:paragraph-properties"],d=(d=d&&d["fo:margin-left"])&&u.parseLength(d);return r.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 n=h.getOdtDocument(),r=new core.Utils,u=new odf.OdfUtils,y=new gui.StyleHelper(n.getFormatting()),x=new core.EventNotifier([gui.DirectParagraphStyler.paragraphStylingChanged]),w,v,t,s;this.isAlignedLeft=function(){return w};this.isAlignedCenter=function(){return v};this.isAlignedRight=function(){return t};this.isAlignedJustified=function(){return s};this.alignParagraphLeft=function(){c("left");return!0};this.alignParagraphCenter=function(){c("center"); +return!0};this.alignParagraphRight=function(){c("right");return!0};this.alignParagraphJustified=function(){c("justify");return!0};this.indent=function(){b(g.bind(null,1));return!0};this.outdent=function(){b(g.bind(null,-1));return!0};this.subscribe=function(a,b){x.subscribe(a,b)};this.unsubscribe=function(a,b){x.unsubscribe(a,b)};this.destroy=function(b){n.unsubscribe(ops.OdtDocument.signalCursorAdded,l);n.unsubscribe(ops.OdtDocument.signalCursorRemoved,q);n.unsubscribe(ops.OdtDocument.signalCursorMoved, +a);n.unsubscribe(ops.OdtDocument.signalParagraphStyleModified,d);n.unsubscribe(ops.OdtDocument.signalParagraphChanged,f);b()};n.subscribe(ops.OdtDocument.signalCursorAdded,l);n.subscribe(ops.OdtDocument.signalCursorRemoved,q);n.subscribe(ops.OdtDocument.signalCursorMoved,a);n.subscribe(ops.OdtDocument.signalParagraphStyleModified,d);n.subscribe(ops.OdtDocument.signalParagraphChanged,f);p()};gui.DirectParagraphStyler.paragraphStylingChanged="paragraphStyling/changed";(function(){return gui.DirectParagraphStyler})(); +// Input 75 +/* + + Copyright (C) 2012-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. + + You should have received a copy of the GNU Affero General Public License + along with this code. If not, see . + + 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: https://github.com/kogmbh/WebODF/ +*/ +gui.KeyboardHandler=function(){function h(e,h){h||(h=m.None);return e+":"+h}var m=gui.KeyboardHandler.Modifier,e=null,p={};this.setDefault=function(h){e=h};this.bind=function(e,m,a){e=h(e,m);runtime.assert(!1===p.hasOwnProperty(e),"tried to overwrite the callback handler of key combo: "+e);p[e]=a};this.unbind=function(e,m){var a=h(e,m);delete p[a]};this.reset=function(){e=null;p={}};this.handleEvent=function(l){var q=l.keyCode,a=m.None;l.metaKey&&(a|=m.Meta);l.ctrlKey&&(a|=m.Ctrl);l.altKey&&(a|=m.Alt); +l.shiftKey&&(a|=m.Shift);q=h(q,a);q=p[q];a=!1;q?a=q():null!==e&&(a=e(l));a&&(l.preventDefault?l.preventDefault():l.returnValue=!1)}};gui.KeyboardHandler.Modifier={None:0,Meta:1,Ctrl:2,Alt:4,CtrlAlt:6,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 76 +runtime.loadClass("odf.Namespaces");runtime.loadClass("odf.ObjectNameGenerator"); +gui.ImageManager=function(h,m,e){var p={"image/gif":".gif","image/jpeg":".jpg","image/png":".png"},l=odf.Namespaces.textns,q=h.getOdtDocument(),a=q.getFormatting(),d={};this.insertImage=function(f,b,k,c){var g;runtime.assert(0g.width&&(n=g.width/k);c>g.height&&(r=g.height/c);n=Math.min(n,r);g=k*n;k=c*n;r=q.getOdfCanvas().odfContainer().rootElement.styles;c=f.toLowerCase();var n=p.hasOwnProperty(c)?p[c]:null,u;c=[];runtime.assert(null!==n,"Image type is not supported: "+f);n="Pictures/"+e.generateImageName()+n;u=new ops.OpSetBlob;u.init({memberid:m,filename:n,mimetype:f,content:b});c.push(u);a.getStyleElement("Graphics","graphic",[r])||(f=new ops.OpAddStyle,f.init({memberid:m,styleName:"Graphics",styleFamily:"graphic", +isAutomaticStyle:!1,setProperties:{"style:graphic-properties":{"text:anchor-type":"paragraph","svg:x":"0cm","svg:y":"0cm","style:wrap":"dynamic","style:number-wrapped-paragraphs":"no-limit","style:wrap-contour":"false","style:vertical-pos":"top","style:vertical-rel":"paragraph","style:horizontal-pos":"center","style:horizontal-rel":"paragraph"}}}),c.push(f));f=e.generateStyleName();b=new ops.OpAddStyle;b.init({memberid:m,styleName:f,styleFamily:"graphic",isAutomaticStyle:!0,setProperties:{"style:parent-style-name":"Graphics", +"style:graphic-properties":{"style:vertical-pos":"top","style:vertical-rel":"baseline","style:horizontal-pos":"center","style:horizontal-rel":"paragraph","fo:background-color":"transparent","style:background-transparency":"100%","style:shadow":"none","style:mirror":"none","fo:clip":"rect(0cm, 0cm, 0cm, 0cm)","draw:luminance":"0%","draw:contrast":"0%","draw:red":"0%","draw:green":"0%","draw:blue":"0%","draw:gamma":"100%","draw:color-inversion":"false","draw:image-opacity":"100%","draw:color-mode":"standard"}}}); +c.push(b);u=new ops.OpInsertImage;u.init({memberid:m,position:q.getCursorPosition(m),filename:n,frameWidth:g+"cm",frameHeight:k+"cm",frameStyleName:f,frameName:e.generateFrameName()});c.push(u);h.enqueue(c)}}; +// Input 77 +runtime.loadClass("odf.Namespaces"); +gui.ImageSelector=function(h){function m(){var a=h.getSizer(),d,f;d=l.createElement("div");d.id="imageSelector";d.style.borderWidth="1px";a.appendChild(d);p.forEach(function(a){f=l.createElement("div");f.className=a;d.appendChild(f)});return d}var e=odf.Namespaces.svgns,p="topLeft topRight bottomRight bottomLeft topMiddle rightMiddle bottomMiddle leftMiddle".split(" "),l=h.getElement().ownerDocument,q=!1;this.select=function(a){var d,f,b=l.getElementById("imageSelector");b||(b=m());q=!0;d=b.parentNode; +f=a.getBoundingClientRect();var k=d.getBoundingClientRect(),c=h.getZoomLevel();d=(f.left-k.left)/c-1;f=(f.top-k.top)/c-1;b.style.display="block";b.style.left=d+"px";b.style.top=f+"px";b.style.width=a.getAttributeNS(e,"width");b.style.height=a.getAttributeNS(e,"height")};this.clearSelection=function(){var a;q&&(a=l.getElementById("imageSelector"))&&(a.style.display="none");q=!1};this.isSelectorElement=function(a){var d=l.getElementById("imageSelector");return d?a===d||a.parentNode===d:!1}}; +// Input 78 +/* + + 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. + + You should have received a copy of the GNU Affero General Public License + along with this code. If not, see . + + 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: https://github.com/kogmbh/WebODF/ +*/ +runtime.loadClass("core.PositionFilter"); +gui.TextManipulator=function(h,m,e){function p(a){var b=new ops.OpRemoveText;b.init({memberid:m,position:a.position,length:a.length});return b}function l(a){0>a.length&&(a.position+=a.length,a.length=-a.length);return a}function q(f,b){var e=new core.PositionFilterChain,c=gui.SelectionMover.createPositionIterator(a.getRootElement(f)),g=b?c.nextPosition:c.previousPosition;e.addFilter("BaseFilter",a.getPositionFilter());e.addFilter("RootFilter",a.createRootFilter(m));for(c.setUnfilteredPosition(f,0);g();)if(e.acceptPosition(c)=== +d)return!0;return!1}var a=h.getOdtDocument(),d=core.PositionFilter.FilterResult.FILTER_ACCEPT;this.enqueueParagraphSplittingOps=function(){var d=l(a.getCursorSelection(m)),b,e=[];0 @@ -2309,85 +2445,44 @@ function(){var c=m(p.getCursorSelection(h));0!==c.length&&(c=n(c),e.enqueue([c]) @source: https://github.com/kogmbh/WebODF/ */ runtime.loadClass("core.EventNotifier");runtime.loadClass("core.PositionFilter");runtime.loadClass("ops.OpAddAnnotation");runtime.loadClass("ops.OpRemoveAnnotation");runtime.loadClass("gui.SelectionMover"); -gui.AnnotationManager=function(e,h){function f(){var b=c.getCursor(h),b=b&&b.getNode(),e;if(e=b){a:{for(e=c.getRootNode();b&&b!==e;){if(b.namespaceURI===k&&"annotation"===b.localName){b=!0;break a}b=b.parentNode}b=!1}e=!b}b=e;b!==a&&(a=b,d.emit(gui.AnnotationManager.annotatableChanged,a))}function n(a){a.getMemberId()===h&&f()}function m(a){a===h&&f()}function p(a){a.getMemberId()===h&&f()}var c=e.getOdtDocument(),b=c.getPositionFilter(),a=!1,d=new core.EventNotifier([gui.AnnotationManager.annotatableChanged]), -k=odf.Namespaces.officens,g=core.PositionFilter.FilterResult.FILTER_ACCEPT;this.isAnnotatable=function(){return a};this.addAnnotation=function(){var b=new ops.OpAddAnnotation,d=c.getCursorSelection(h),f=d.length,d=d.position;a&&(d=0<=f?d:d+f,f=Math.abs(f),b.init({memberid:h,position:d,length:f,name:h+Date.now()}),e.enqueue([b]))};this.removeAnnotation=function(a){var d,f;d=0;f=gui.SelectionMover.createPositionIterator(c.getRootNode());for(var k=new core.LoopWatchDog(1E3),m=!1;f.nextPosition();)if(k.check(), -m=Boolean(a.compareDocumentPosition(f.container())&Node.DOCUMENT_POSITION_CONTAINED_BY),b.acceptPosition(f)===g){if(m)break;d+=1}f=0;k=gui.SelectionMover.createPositionIterator(c.getRootNode());m=!1;k.setUnfilteredPosition(a,0);do{m=Boolean(a.compareDocumentPosition(k.container())&Node.DOCUMENT_POSITION_CONTAINED_BY);if(!m&&a!==k.container())break;b.acceptPosition(k)===g&&(f+=1)}while(k.nextPosition());a=new ops.OpRemoveAnnotation;a.init({memberid:h,position:d,length:f});f=new ops.OpMoveCursor;f.init({memberid:h, -position:d-1,length:0});e.enqueue([a,f])};this.subscribe=function(a,b){d.subscribe(a,b)};this.unsubscribe=function(a,b){d.unsubscribe(a,b)};this.destroy=function(a){c.unsubscribe(ops.OdtDocument.signalCursorAdded,n);c.unsubscribe(ops.OdtDocument.signalCursorRemoved,m);c.unsubscribe(ops.OdtDocument.signalCursorMoved,p);a()};c.subscribe(ops.OdtDocument.signalCursorAdded,n);c.subscribe(ops.OdtDocument.signalCursorRemoved,m);c.subscribe(ops.OdtDocument.signalCursorMoved,p);f()}; +gui.AnnotationManager=function(h,m){function e(){var e=a.getCursor(m),e=e&&e.getNode(),c;if(c=e){a:{for(c=a.getRootNode();e&&e!==c;){if(e.namespaceURI===b&&"annotation"===e.localName){e=!0;break a}e=e.parentNode}e=!1}c=!e}e=c;e!==d&&(d=e,f.emit(gui.AnnotationManager.annotatableChanged,d))}function p(a){a.getMemberId()===m&&e()}function l(a){a===m&&e()}function q(a){a.getMemberId()===m&&e()}var a=h.getOdtDocument(),d=!1,f=new core.EventNotifier([gui.AnnotationManager.annotatableChanged]),b=odf.Namespaces.officens; +this.isAnnotatable=function(){return d};this.addAnnotation=function(){var b=new ops.OpAddAnnotation,c=a.getCursorSelection(m),f=c.length,c=c.position;d&&(c=0<=f?c:c+f,f=Math.abs(f),b.init({memberid:m,position:c,length:f,name:m+Date.now()}),h.enqueue([b]))};this.removeAnnotation=function(b){var c,d;c=a.convertDomPointToCursorStep(b,0)+1;d=a.convertDomPointToCursorStep(b,b.childNodes.length);b=new ops.OpRemoveAnnotation;b.init({memberid:m,position:c,length:d-c});d=new ops.OpMoveCursor;d.init({memberid:m, +position:0 - - @licstart - The JavaScript code in this page is free software: you can redistribute it - and/or modify it under the terms of the GNU Affero General Public License - (GNU AGPL) as published by the Free Software Foundation, either version 3 of - the License, or (at your option) any later version. The code is distributed - WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU AGPL for more details. - - You should have received a copy of the GNU Affero General Public License - along with this code. If not, see . - - 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: https://github.com/kogmbh/WebODF/ -*/ -ops.MemberModel=function(){};ops.MemberModel.prototype.getMemberDetailsAndUpdates=function(e,h){};ops.MemberModel.prototype.unsubscribeMemberDetailsUpdates=function(e,h){};ops.MemberModel.prototype.close=function(e){}; // Input 80 +gui.EventManager=function(h){function m(a){var b=a.scrollX,d=a.scrollY;this.restore=function(){a.scrollX===b&&a.scrollY===d||a.scrollTo(b,d)}}function e(a){var b=a.scrollTop,d=a.scrollLeft;this.restore=function(){if(a.scrollTop!==b||a.scrollLeft!==d)a.scrollTop=b,a.scrollLeft=d}}function p(){return h.getDOM().activeElement===l}var l=h.getOdfCanvas().getElement(),q=runtime.getWindow(),a={beforecut:!0,beforepaste:!0},d={mousedown:!0,mouseup:!0};this.subscribe=function(f,b){var e=l;d[f]&&q&&(e=q);var c= +"on"+f,g=!1;e.attachEvent&&(g=e.attachEvent(c,b));!g&&e.addEventListener&&(e.addEventListener(f,b,!1),g=!0);g&&!a[f]||!e.hasOwnProperty(c)||(e[c]=b)};this.unsubscribe=function(a,b){var e=l;d[a]&&q&&(e=q);var c="on"+a;e.detachEvent&&e.detachEvent(c,b);e.removeEventListener&&e.removeEventListener(a,b,!1);e[c]===b&&(e[c]=null)};this.hasFocus=p;this.focus=function(){var a;if(!p()){for(a=l;a&&!a.scrollTop&&!a.scrollLeft;)a=a.parentNode;a=a?new e(a):q?new m(q):null;l.focus();a&&a.restore()}}}; +// Input 81 +runtime.loadClass("core.DomUtils");runtime.loadClass("core.Async");runtime.loadClass("core.ScheduledTask");runtime.loadClass("odf.OdfUtils");runtime.loadClass("odf.ObjectNameGenerator");runtime.loadClass("ops.OdtCursor");runtime.loadClass("ops.OpAddCursor");runtime.loadClass("ops.OpRemoveCursor");runtime.loadClass("gui.Clipboard");runtime.loadClass("gui.DirectTextStyler");runtime.loadClass("gui.DirectParagraphStyler");runtime.loadClass("gui.KeyboardHandler");runtime.loadClass("gui.ImageManager"); +runtime.loadClass("gui.ImageSelector");runtime.loadClass("gui.TextManipulator");runtime.loadClass("gui.AnnotationManager");runtime.loadClass("gui.EventManager");runtime.loadClass("gui.PlainTextPasteboard"); +gui.SessionController=function(){var h=core.PositionFilter.FilterResult.FILTER_ACCEPT;gui.SessionController=function(m,e,p,l){function q(a){a.preventDefault?a.preventDefault():a.returnValue=!1}function a(a,b,c){var d=new ops.OpMoveCursor;d.init({memberid:e,position:a,length:b||0,selectionType:c});return d}function d(b){b=J.getDistanceFromCursor(e,b,0);var c=null!==b?b+1:null,d;if(c||b)d=J.getCursorPosition(e),b=a(d+b,c-b,ops.OdtCursor.RegionSelection),m.enqueue([b]);X.focus()}function f(b,c){var d, +f,g,h;f=J.getOdfCanvas().getElement();d=c.detail;if(b){if(!b.anchorNode&&!b.focusNode){g=c.clientX;h=c.clientY;var k=J.getDOM();k.caretRangeFromPoint?(g=k.caretRangeFromPoint(g,h),g={container:g.startContainer,offset:g.startOffset}):k.caretPositionFromPoint?(g=k.caretPositionFromPoint(g,h),g={container:g.offsetNode,offset:g.offset}):g=null;if(!g)return;b.anchorNode=g.container;b.anchorOffset=g.offset;b.focusNode=b.anchorNode;b.focusOffset=b.anchorOffset}runtime.assert(null!==b.anchorNode&&null!== +b.focusNode,"anchorNode or focusNode is null");g=fa.containsNode(f,b.anchorNode);f=fa.containsNode(f,b.focusNode);if(g||f){if(g&&f)if(2===d){var k=/[A-Za-z0-9]/,l=gui.SelectionMover.createPositionIterator(J.getRootNode()),n=0 @@ -2425,8 +2520,47 @@ ops.MemberModel=function(){};ops.MemberModel.prototype.getMemberDetailsAndUpdate @source: http://www.webodf.org/ @source: https://github.com/kogmbh/WebODF/ */ -ops.TrivialMemberModel=function(){this.getMemberDetailsAndUpdates=function(e,h){h(e,{memberid:e,fullname:runtime.tr("Unknown Author"),color:"black",imageurl:"avatar-joe.png"})};this.unsubscribeMemberDetailsUpdates=function(e,h){};this.close=function(e){e()}}; -// Input 81 +ops.MemberModel=function(){};ops.MemberModel.prototype.getMemberDetailsAndUpdates=function(h,m){};ops.MemberModel.prototype.unsubscribeMemberDetailsUpdates=function(h,m){};ops.MemberModel.prototype.close=function(h){}; +// Input 83 +/* + + Copyright (C) 2012-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. + + You should have received a copy of the GNU Affero General Public License + along with this code. If not, see . + + 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: https://github.com/kogmbh/WebODF/ +*/ +ops.TrivialMemberModel=function(){this.getMemberDetailsAndUpdates=function(h,m){m(h,{memberid:h,fullname:runtime.tr("Unknown Author"),color:"black",imageurl:"avatar-joe.png"})};this.unsubscribeMemberDetailsUpdates=function(h,m){};this.close=function(h){h()}}; +// Input 84 /* Copyright (C) 2013 KO GmbH @@ -2464,8 +2598,8 @@ ops.TrivialMemberModel=function(){this.getMemberDetailsAndUpdates=function(e,h){ @source: http://www.webodf.org/ @source: https://github.com/kogmbh/WebODF/ */ -ops.OperationRouter=function(){};ops.OperationRouter.prototype.setOperationFactory=function(e){};ops.OperationRouter.prototype.setPlaybackFunction=function(e){};ops.OperationRouter.prototype.push=function(e){};ops.OperationRouter.prototype.close=function(e){}; -// Input 82 +ops.OperationRouter=function(){};ops.OperationRouter.prototype.setOperationFactory=function(h){};ops.OperationRouter.prototype.setPlaybackFunction=function(h){};ops.OperationRouter.prototype.push=function(h){};ops.OperationRouter.prototype.close=function(h){}; +// Input 85 /* Copyright (C) 2012 KO GmbH @@ -2503,11 +2637,11 @@ ops.OperationRouter=function(){};ops.OperationRouter.prototype.setOperationFacto @source: http://www.webodf.org/ @source: https://github.com/kogmbh/WebODF/ */ -ops.TrivialOperationRouter=function(){var e,h;this.setOperationFactory=function(f){e=f};this.setPlaybackFunction=function(e){h=e};this.push=function(f){f.forEach(function(f){f=f.spec();f.timestamp=(new Date).getTime();f=e.create(f);h(f)})};this.close=function(e){e()}}; -// Input 83 -gui.EditInfoHandle=function(e){var h=[],f,n=e.ownerDocument,m=n.documentElement.namespaceURI;this.setEdits=function(e){h=e;var c,b,a,d;f.innerHTML="";for(e=0;e @@ -2546,10 +2680,10 @@ d=n.createElementNS(m,"span"),d.className="editInfoTime",d.setAttributeNS("urn:w @source: https://github.com/kogmbh/WebODF/ */ runtime.loadClass("ops.EditInfo");runtime.loadClass("gui.EditInfoHandle"); -gui.EditInfoMarker=function(e,h){function f(a,b){return runtime.setTimeout(function(){c.style.opacity=a},b)}var n=this,m,p,c,b,a;this.addEdit=function(d,h){var g=Date.now()-h;e.addEdit(d,h);p.setEdits(e.getSortedEdits());c.setAttributeNS("urn:webodf:names:editinfo","editinfo:memberid",d);b&&runtime.clearTimeout(b);a&&runtime.clearTimeout(a);1E4>g?(f(1,0),b=f(0.5,1E4-g),a=f(0.2,2E4-g)):1E4<=g&&2E4>g?(f(0.5,0),a=f(0.2,2E4-g)):f(0.2,0)};this.getEdits=function(){return e.getEdits()};this.clearEdits=function(){e.clearEdits(); -p.setEdits([]);c.hasAttributeNS("urn:webodf:names:editinfo","editinfo:memberid")&&c.removeAttributeNS("urn:webodf:names:editinfo","editinfo:memberid")};this.getEditInfo=function(){return e};this.show=function(){c.style.display="block"};this.hide=function(){n.hideHandle();c.style.display="none"};this.showHandle=function(){p.show()};this.hideHandle=function(){p.hide()};this.destroy=function(a){m.removeChild(c);p.destroy(function(b){b?a(b):e.destroy(a)})};(function(){var a=e.getOdtDocument().getDOM(); -c=a.createElementNS(a.documentElement.namespaceURI,"div");c.setAttribute("class","editInfoMarker");c.onmouseover=function(){n.showHandle()};c.onmouseout=function(){n.hideHandle()};m=e.getNode();m.appendChild(c);p=new gui.EditInfoHandle(m);h||n.hide()})()}; -// Input 85 +gui.EditInfoMarker=function(h,m){function e(b,d){return runtime.setTimeout(function(){a.style.opacity=b},d)}var p=this,l,q,a,d,f;this.addEdit=function(b,k){var c=Date.now()-k;h.addEdit(b,k);q.setEdits(h.getSortedEdits());a.setAttributeNS("urn:webodf:names:editinfo","editinfo:memberid",b);d&&runtime.clearTimeout(d);f&&runtime.clearTimeout(f);1E4>c?(e(1,0),d=e(0.5,1E4-c),f=e(0.2,2E4-c)):1E4<=c&&2E4>c?(e(0.5,0),f=e(0.2,2E4-c)):e(0.2,0)};this.getEdits=function(){return h.getEdits()};this.clearEdits=function(){h.clearEdits(); +q.setEdits([]);a.hasAttributeNS("urn:webodf:names:editinfo","editinfo:memberid")&&a.removeAttributeNS("urn:webodf:names:editinfo","editinfo:memberid")};this.getEditInfo=function(){return h};this.show=function(){a.style.display="block"};this.hide=function(){p.hideHandle();a.style.display="none"};this.showHandle=function(){q.show()};this.hideHandle=function(){q.hide()};this.destroy=function(b){l.removeChild(a);q.destroy(function(a){a?b(a):h.destroy(b)})};(function(){var b=h.getOdtDocument().getDOM(); +a=b.createElementNS(b.documentElement.namespaceURI,"div");a.setAttribute("class","editInfoMarker");a.onmouseover=function(){p.showHandle()};a.onmouseout=function(){p.hideHandle()};l=h.getNode();l.appendChild(a);q=new gui.EditInfoHandle(l);m||p.hide()})()}; +// Input 88 /* Copyright (C) 2012-2013 KO GmbH @@ -2588,16 +2722,16 @@ c=a.createElementNS(a.documentElement.namespaceURI,"div");c.setAttribute("class" @source: https://github.com/kogmbh/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(e,h,f,n,m){function p(a,b,c){function d(b,c,e){c=b+'[editinfo|memberid="'+a+'"]'+e+c;a:{var f=t.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:t.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+"; }","");d("div.selectionOverlay","{ background-color: "+c+";}","")}function c(a){var b,c;for(c in v)v.hasOwnProperty(c)&&(b=v[c],a?b.show():b.hide())}function b(a){n.getCarets().forEach(function(b){a?b.showHandle():b.hideHandle()})}function a(a,b){var c=n.getCaret(a);b?(c&&(c.setAvatarImageUrl(b.imageurl),c.setColor(b.color)),p(a,b.fullname,b.color),h===a&&p("",b.fullname,b.color)): -runtime.log('MemberModel sent undefined data for member "'+a+'".')}function d(b){var c=b.getMemberId(),d=f.getMemberModel();n.registerCursor(b,x,u);m.registerCursor(b,!0);a(c,null);d.getMemberDetailsAndUpdates(c,a);runtime.log("+++ View here +++ eagerly created an Caret for '"+c+"'! +++")}function k(a){a=a.getMemberId();var b=m.getSelectionView(h),c=m.getSelectionView(gui.ShadowCursor.ShadowCursorMemberId),d=n.getCaret(h);a===h?(c.hide(),b.show(),d&&d.show()):a===gui.ShadowCursor.ShadowCursorMemberId&& -(c.show(),b.hide(),d&&d.hide())}function g(b){var c=!1,d;for(d in v)if(v.hasOwnProperty(d)&&v[d].getEditInfo().getEdits().hasOwnProperty(b)){c=!0;break}m.removeSelectionView(b);c||f.getMemberModel().unsubscribeMemberDetailsUpdates(b,a)}function q(a){var b=a.paragraphElement,c=a.memberId;a=a.timeStamp;var d,e="",g=b.getElementsByTagNameNS(w,"editinfo")[0];g?(e=g.getAttributeNS(w,"id"),d=v[e]):(e=Math.random().toString(),d=new ops.EditInfo(b,f.getOdtDocument()),d=new gui.EditInfoMarker(d,y),g=b.getElementsByTagNameNS(w, -"editinfo")[0],g.setAttributeNS(w,"id",e),v[e]=d);d.addEdit(c,new Date(a))}function l(){C=!0}function r(){s=runtime.getWindow().setInterval(function(){C&&(m.rerenderSelectionViews(),C=!1)},200)}var t,w="urn:webodf:names:editinfo",v={},y=void 0!==e.editInfoMarkersInitiallyVisible?Boolean(e.editInfoMarkersInitiallyVisible):!0,x=void 0!==e.caretAvatarsInitiallyVisible?Boolean(e.caretAvatarsInitiallyVisible):!0,u=void 0!==e.caretBlinksOnRangeSelect?Boolean(e.caretBlinksOnRangeSelect):!0,s,C=!1;this.showEditInfoMarkers= -function(){y||(y=!0,c(y))};this.hideEditInfoMarkers=function(){y&&(y=!1,c(y))};this.showCaretAvatars=function(){x||(x=!0,b(x))};this.hideCaretAvatars=function(){x&&(x=!1,b(x))};this.getSession=function(){return f};this.getCaret=function(a){return n.getCaret(a)};this.destroy=function(b){var c=f.getOdtDocument(),e=f.getMemberModel(),h=Object.keys(v).map(function(a){return v[a]});c.unsubscribe(ops.OdtDocument.signalCursorAdded,d);c.unsubscribe(ops.OdtDocument.signalCursorRemoved,g);c.unsubscribe(ops.OdtDocument.signalParagraphChanged, -q);c.unsubscribe(ops.OdtDocument.signalCursorMoved,k);c.unsubscribe(ops.OdtDocument.signalParagraphChanged,l);c.unsubscribe(ops.OdtDocument.signalTableAdded,l);c.unsubscribe(ops.OdtDocument.signalParagraphStyleModified,l);runtime.getWindow().clearInterval(s);n.getCarets().forEach(function(b){e.unsubscribeMemberDetailsUpdates(b.getCursor().getMemberId(),a)});t.parentNode.removeChild(t);(function G(a,c){c?b(c):a @@ -2636,147 +2770,50 @@ t.appendChild(document.createTextNode("@namespace editinfo url(urn:webodf:names: @source: https://github.com/kogmbh/WebODF/ */ runtime.loadClass("gui.Caret"); -gui.CaretManager=function(e){function h(a){return q.hasOwnProperty(a)?q[a]:null}function f(){return Object.keys(q).map(function(a){return q[a]})}function n(a){a===e.getInputMemberId()&&e.getSession().getOdtDocument().getOdfCanvas().getElement().removeAttribute("tabindex");delete q[a]}function m(a){a=a.getMemberId();a===e.getInputMemberId()&&(a=h(a))&&a.refreshCursorBlinking()}function p(){var a=h(e.getInputMemberId());r=!1;a&&a.ensureVisible()}function c(){var a=h(e.getInputMemberId());a&&(a.handleUpdate(), -r||(r=!0,runtime.setTimeout(p,50)))}function b(a){a.memberId===e.getInputMemberId()&&c()}function a(){var a=h(e.getInputMemberId());a&&a.setFocus()}function d(){var a=h(e.getInputMemberId());a&&a.removeFocus()}function k(){var a=h(e.getInputMemberId());a&&a.show()}function g(){var a=h(e.getInputMemberId());a&&a.hide()}var q={},l=runtime.getWindow(),r=!1;this.registerCursor=function(a,b,d){var f=a.getMemberId();b=new gui.Caret(a,b,d);q[f]=b;f===e.getInputMemberId()?(runtime.log("Starting to track input on new cursor of "+ -f),a.handleUpdate=c,e.getSession().getOdtDocument().getOdfCanvas().getElement().setAttribute("tabindex",-1),e.getEventManager().focus()):a.handleUpdate=b.handleUpdate;return b};this.getCaret=h;this.getCarets=f;this.destroy=function(c){var h=e.getSession().getOdtDocument(),p=e.getEventManager(),r=f();h.unsubscribe(ops.OdtDocument.signalParagraphChanged,b);h.unsubscribe(ops.OdtDocument.signalCursorMoved,m);h.unsubscribe(ops.OdtDocument.signalCursorRemoved,n);p.unsubscribe("focus",a);p.unsubscribe("blur", -d);l.removeEventListener("focus",k,!1);l.removeEventListener("blur",g,!1);(function u(a,b){b?c(b):a - - @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. - - You should have received a copy of the GNU Affero General Public License - along with this code. If not, see . - - 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: https://github.com/kogmbh/WebODF/ -*/ -gui.UndoManager=function(){};gui.UndoManager.prototype.subscribe=function(e,h){};gui.UndoManager.prototype.unsubscribe=function(e,h){};gui.UndoManager.prototype.setOdtDocument=function(e){};gui.UndoManager.prototype.saveInitialState=function(){};gui.UndoManager.prototype.resetInitialState=function(){};gui.UndoManager.prototype.setPlaybackFunction=function(e){};gui.UndoManager.prototype.hasUndoStates=function(){};gui.UndoManager.prototype.hasRedoStates=function(){}; -gui.UndoManager.prototype.moveForward=function(e){};gui.UndoManager.prototype.moveBackward=function(e){};gui.UndoManager.prototype.onOperationExecuted=function(e){};gui.UndoManager.signalUndoStackChanged="undoStackChanged";gui.UndoManager.signalUndoStateCreated="undoStateCreated";gui.UndoManager.signalUndoStateModified="undoStateModified";(function(){return gui.UndoManager})(); -// Input 88 -/* - - 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. - - You should have received a copy of the GNU Affero General Public License - along with this code. If not, see . - - 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: https://github.com/kogmbh/WebODF/ -*/ -gui.UndoStateRules=function(){function e(e){return e.spec().optype}function h(f){switch(e(f)){case "MoveCursor":case "AddCursor":case "RemoveCursor":return!1;default:return!0}}this.getOpType=e;this.isEditOperation=h;this.isPartOfOperationSet=function(f,n){if(h(f)){if(0===n.length)return!0;var m;if(m=h(n[n.length-1]))a:{m=n.filter(h);var p=e(f),c;b:switch(p){case "RemoveText":case "InsertText":c=!0;break b;default:c=!1}if(c&&p===e(m[0])){if(1===m.length){m=!0;break a}p=m[m.length-2].spec().position; -m=m[m.length-1].spec().position;c=f.spec().position;if(m===c-(m-p)){m=!0;break a}}m=!1}return m}return!0}}; -// Input 89 -/* - - 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. - - You should have received a copy of the GNU Affero General Public License - along with this code. If not, see . - - 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: https://github.com/kogmbh/WebODF/ -*/ -runtime.loadClass("core.DomUtils");runtime.loadClass("gui.UndoManager");runtime.loadClass("gui.UndoStateRules"); -gui.TrivialUndoManager=function(e){function h(){t.emit(gui.UndoManager.signalUndoStackChanged,{undoAvailable:c.hasUndoStates(),redoAvailable:c.hasRedoStates()})}function f(){q!==d&&q!==l[l.length-1]&&l.push(q)}function n(a){var c=a.previousSibling||a.nextSibling;a.parentNode.removeChild(a);b.normalizeTextNodes(c)}function m(a){return Object.keys(a).map(function(b){return a[b]})}function p(a){function b(a){var g=a.spec();if(e[g.memberid])switch(g.optype){case "AddCursor":c[g.memberid]||(c[g.memberid]= -a,delete e[g.memberid],f-=1);break;case "MoveCursor":d[g.memberid]||(d[g.memberid]=a)}}var c={},d={},e={},f,h=a.pop();g.getCursors().forEach(function(a){e[a.getMemberId()]=!0});for(f=Object.keys(e).length;h&&0 + + @licstart + The JavaScript code in this page is free software: you can redistribute it + and/or modify it under the terms of the GNU Affero General Public License + (GNU AGPL) as published by the Free Software Foundation, either version 3 of + the License, or (at your option) any later version. The code is distributed + WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU AGPL for more details. + + You should have received a copy of the GNU Affero General Public License + along with this code. If not, see . + + 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: https://github.com/kogmbh/WebODF/ +*/ +gui.UndoManager=function(){};gui.UndoManager.prototype.subscribe=function(h,m){};gui.UndoManager.prototype.unsubscribe=function(h,m){};gui.UndoManager.prototype.setOdtDocument=function(h){};gui.UndoManager.prototype.saveInitialState=function(){};gui.UndoManager.prototype.resetInitialState=function(){};gui.UndoManager.prototype.setPlaybackFunction=function(h){};gui.UndoManager.prototype.hasUndoStates=function(){};gui.UndoManager.prototype.hasRedoStates=function(){}; +gui.UndoManager.prototype.moveForward=function(h){};gui.UndoManager.prototype.moveBackward=function(h){};gui.UndoManager.prototype.onOperationExecuted=function(h){};gui.UndoManager.signalUndoStackChanged="undoStackChanged";gui.UndoManager.signalUndoStateCreated="undoStateCreated";gui.UndoManager.signalUndoStateModified="undoStateModified";(function(){return gui.UndoManager})(); // Input 91 /* @@ -2815,10 +2852,107 @@ r.appendChild(w);r.appendChild(v);r.appendChild(y);w.setAttributeNS("urn:webodf: @source: http://www.webodf.org/ @source: https://github.com/kogmbh/WebODF/ */ -runtime.loadClass("gui.SelectionView"); -gui.SelectionViewManager=function(){function e(){return Object.keys(h).map(function(e){return h[e]})}var h={};this.getSelectionView=function(e){return h.hasOwnProperty(e)?h[e]:null};this.getSelectionViews=e;this.removeSelectionView=function(e){h.hasOwnProperty(e)&&(h[e].destroy(function(){}),delete h[e])};this.hideSelectionView=function(e){h.hasOwnProperty(e)&&h[e].hide()};this.showSelectionView=function(e){h.hasOwnProperty(e)&&h[e].show()};this.rerenderSelectionViews=function(){Object.keys(h).forEach(function(e){h[e].visible()&& -h[e].rerender()})};this.registerCursor=function(e,n){var m=e.getMemberId(),p=new gui.SelectionView(e);n?p.show():p.hide();return h[m]=p};this.destroy=function(f){var h=e();(function p(c,b){b?f(b):c + + @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. + + You should have received a copy of the GNU Affero General Public License + along with this code. If not, see . + + 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: https://github.com/kogmbh/WebODF/ +*/ +runtime.loadClass("core.DomUtils");runtime.loadClass("gui.UndoManager");runtime.loadClass("gui.UndoStateRules"); +gui.TrivialUndoManager=function(h){function m(){u.emit(gui.UndoManager.signalUndoStackChanged,{undoAvailable:a.hasUndoStates(),redoAvailable:a.hasRedoStates()})}function e(){g!==b&&g!==n[n.length-1]&&n.push(g)}function p(a){var b=a.previousSibling||a.nextSibling;a.parentNode.removeChild(a);d.normalizeTextNodes(b)}function l(a){return Object.keys(a).map(function(b){return a[b]})}function q(a){function b(a){var c=a.spec();if(f[c.memberid])switch(c.optype){case "AddCursor":d[c.memberid]||(d[c.memberid]= +a,delete f[c.memberid],g-=1);break;case "MoveCursor":e[c.memberid]||(e[c.memberid]=a)}}var d={},e={},f={},g,h=a.pop();c.getCursors().forEach(function(a){f[a.getMemberId()]=!0});for(g=Object.keys(f).length;h&&0 + + @licstart + The JavaScript code in this page is free software: you can redistribute it + and/or modify it under the terms of the GNU Affero General Public License + (GNU AGPL) as published by the Free Software Foundation, either version 3 of + the License, or (at your option) any later version. The code is distributed + WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU AGPL for more details. + + You should have received a copy of the GNU Affero General Public License + along with this code. If not, see . + + 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: https://github.com/kogmbh/WebODF/ +*/ +runtime.loadClass("gui.SelectionView"); +gui.SelectionViewManager=function(){function h(){return Object.keys(m).map(function(e){return m[e]})}var m={};this.getSelectionView=function(e){return m.hasOwnProperty(e)?m[e]:null};this.getSelectionViews=h;this.removeSelectionView=function(e){m.hasOwnProperty(e)&&(m[e].destroy(function(){}),delete m[e])};this.hideSelectionView=function(e){m.hasOwnProperty(e)&&m[e].hide()};this.showSelectionView=function(e){m.hasOwnProperty(e)&&m[e].show()};this.rerenderSelectionViews=function(){Object.keys(m).forEach(function(e){m[e].visible()&& +m[e].rerender()})};this.registerCursor=function(e,h){var l=e.getMemberId(),q=new gui.SelectionView(e);h?q.show():q.hide();return m[l]=q};this.destroy=function(e){var m=h();(function q(a,d){d?e(d):a @@ -2856,25 +2990,23 @@ h[e].rerender()})};this.registerCursor=function(e,n){var m=e.getMemberId(),p=new @source: http://www.webodf.org/ @source: https://github.com/kogmbh/WebODF/ */ -runtime.loadClass("core.EventNotifier");runtime.loadClass("core.DomUtils");runtime.loadClass("odf.OdfUtils");runtime.loadClass("odf.Namespaces");runtime.loadClass("gui.SelectionMover");runtime.loadClass("core.PositionFilterChain"); -ops.OdtDocument=function(e){function h(){var a=e.odfContainer().getContentElement(),b=a&&a.localName;runtime.assert("text"===b,"Unsupported content element type '"+b+"'for OdtDocument");return a}function f(a){function b(a){for(;a&&!(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;d="string"===typeof a?k[a].getNode():a;return b(c)===b(d)? -q:l}}function n(a){var b=gui.SelectionMover.createPositionIterator(h());for(a+=1;0=e;e+=1){c=b.container();d=b.unfilteredDomOffset(); -if(c.nodeType===Node.TEXT_NODE&&" "===c.data[d]&&a.isSignificantWhitespace(c,d)){runtime.assert(" "===c.data[d],"upgradeWhitespaceToElement: textNode.data[offset] should be a literal space");var f=c.ownerDocument.createElementNS(odf.Namespaces.textns,"text:s");f.appendChild(c.ownerDocument.createTextNode(" "));c.deleteData(d,1);0= 0");r.acceptPosition(d)===q?(f=d.container(),f.nodeType===Node.TEXT_NODE&&(e=f,g=0)):a+=1;for(;0=e;e+=1){c=a.container();d=a.unfilteredDomOffset();if(c.nodeType===Node.TEXT_NODE&&" "===c.data[d]&&b.isSignificantWhitespace(c,d)){runtime.assert(" "===c.data[d],"upgradeWhitespaceToElement: textNode.data[offset] should be a literal space");var f=c.ownerDocument.createElementNS(odf.Namespaces.textns,"text:s");f.appendChild(c.ownerDocument.createTextNode(" "));c.deleteData(d,1);0 @@ -2913,7 +3045,7 @@ ops.OdtDocument.signalCursorRemoved="cursor/removed";ops.OdtDocument.signalCurso @source: https://github.com/kogmbh/WebODF/ */ runtime.loadClass("ops.TrivialMemberModel");runtime.loadClass("ops.TrivialOperationRouter");runtime.loadClass("ops.OperationFactory");runtime.loadClass("ops.OdtDocument"); -ops.Session=function(e){var h=new ops.OperationFactory,f=new ops.OdtDocument(e),n=new ops.TrivialMemberModel,m=null;this.setMemberModel=function(e){n=e};this.setOperationFactory=function(e){h=e;m&&m.setOperationFactory(h)};this.setOperationRouter=function(e){m=e;e.setPlaybackFunction(function(c){c.execute(f);f.emit(ops.OdtDocument.signalOperationExecuted,c)});e.setOperationFactory(h)};this.getMemberModel=function(){return n};this.getOperationFactory=function(){return h};this.getOdtDocument=function(){return f}; -this.enqueue=function(e){m.push(e)};this.close=function(e){m.close(function(c){c?e(c):n.close(function(b){b?e(b):f.close(e)})})};this.destroy=function(e){f.destroy(e)};this.setOperationRouter(new ops.TrivialOperationRouter)}; -// Input 94 +ops.Session=function(h){var m=new ops.OperationFactory,e=new ops.OdtDocument(h),p=new ops.TrivialMemberModel,l=null;this.setMemberModel=function(e){p=e};this.setOperationFactory=function(e){m=e;l&&l.setOperationFactory(m)};this.setOperationRouter=function(h){l=h;h.setPlaybackFunction(function(a){a.execute(e);e.emit(ops.OdtDocument.signalOperationExecuted,a)});h.setOperationFactory(m)};this.getMemberModel=function(){return p};this.getOperationFactory=function(){return m};this.getOdtDocument=function(){return e}; +this.enqueue=function(e){l.push(e)};this.close=function(h){l.close(function(a){a?h(a):p.close(function(a){a?h(a):e.close(h)})})};this.destroy=function(h){e.destroy(h)};this.setOperationRouter(new ops.TrivialOperationRouter)}; +// Input 97 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 webodfhelper url(urn:webodf:names:helper);\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*[webodfhelper|containsparagraphanchor] {\n position: relative;\n}\ntext|s {\n white-space: pre;\n}\ntext|tab {\n display: inline;\n white-space: pre;\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}\n\n.virtualSelections office|document *::selection {\n background: transparent;\n}\n.virtualSelections office|document *::-moz-selection {\n background: transparent;\n}\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 /* IMPORTANT: when changing these values ensure DEFAULT_CARET_TOP and DEFAULT_CARET_HEIGHT\n in Caret.js remain in sync */\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\n.selectionOverlay {\n position: absolute;\n z-index: 15;\n opacity: 0.2;\n pointer-events: none;\n top: 0;\n left: 0;\n width: 0;\n height: 0;\n}\n\n#imageSelector {\n display: none;\n position: absolute;\n border-style: solid;\n border-color: black;\n}\n\n#imageSelector > div {\n width: 5px;\n height: 5px;\n display: block;\n position: absolute;\n border: 1px solid black;\n background-color: #ffffff;\n}\n\n#imageSelector > .topLeft {\n top: -4px;\n left: -4px;\n}\n\n#imageSelector > .topRight {\n top: -4px;\n right: -4px;\n}\n\n#imageSelector > .bottomRight {\n right: -4px;\n bottom: -4px;\n}\n\n#imageSelector > .bottomLeft {\n bottom: -4px;\n left: -4px;\n}\n\n#imageSelector > .topMiddle {\n top: -4px;\n left: 50%;\n margin-left: -2.5px; /* half of the width defined in #imageSelector > div */\n}\n\n#imageSelector > .rightMiddle {\n top: 50%;\n right: -4px;\n margin-top: -2.5px; /* half of the height defined in #imageSelector > div */\n}\n\n#imageSelector > .bottomMiddle {\n bottom: -4px;\n left: 50%;\n margin-left: -2.5px; /* half of the width defined in #imageSelector > div */\n}\n\n#imageSelector > .leftMiddle {\n top: 50%;\n left: -4px;\n margin-top: -2.5px; /* half of the height defined in #imageSelector > div */\n}\n"; diff --git a/js/documents.js b/js/documents.js index 0c8e579d..f9cab1c7 100644 --- a/js/documents.js +++ b/js/documents.js @@ -278,7 +278,7 @@ var documentsMain = { parent.location.hash = ""; documentsMain.webodfEditorInstance.endEditing(); - documentsMain.webodfEditorInstance.close(function() { + documentsMain.webodfEditorInstance.closeSession(function() { // successfull shutdown - all is good. // TODO: proper session leaving call to server, either by webodfServerInstance or custom // documentsMain.webodfServerInstance.leaveSession(sessionId, memberId, function() {