diff --git a/js/3rdparty/webodf/editor/Editor.js b/js/3rdparty/webodf/editor/Editor.js index 78add05a..644f4b5d 100644 --- a/js/3rdparty/webodf/editor/Editor.js +++ b/js/3rdparty/webodf/editor/Editor.js @@ -110,7 +110,6 @@ define("webodf/editor/Editor", [ pendingEditorReadyCallback = editorReadyCallback; odfCanvas.load(initialDocumentUrl); - odfCanvas.setEditable(false); } diff --git a/js/3rdparty/webodf/editor/EditorSession.js b/js/3rdparty/webodf/editor/EditorSession.js index e9a11b77..d890a8e0 100644 --- a/js/3rdparty/webodf/editor/EditorSession.js +++ b/js/3rdparty/webodf/editor/EditorSession.js @@ -66,7 +66,7 @@ define("webodf/editor/EditorSession", [ var EditorSession = function EditorSession(session, localMemberId, config) { var self = this, currentParagraphNode = null, - currentNamedStyleName = null, + currentCommonStyleName = null, currentStyleName = null, caretManager, odtDocument = session.getOdtDocument(), @@ -79,8 +79,8 @@ define("webodf/editor/EditorSession", [ EditorSession.signalMemberRemoved, EditorSession.signalCursorMoved, EditorSession.signalParagraphChanged, - EditorSession.signalCommonParagraphStyleCreated, - EditorSession.signalCommonParagraphStyleDeleted, + EditorSession.signalCommonStyleCreated, + EditorSession.signalCommonStyleDeleted, EditorSession.signalParagraphStyleModified, EditorSession.signalUndoStackChanged]); @@ -113,24 +113,31 @@ define("webodf/editor/EditorSession", [ function checkParagraphStyleName() { var newStyleName, - newNamedStyleName; + newCommonStyleName; newStyleName = currentParagraphNode.getAttributeNS(textns, 'style-name'); + if (newStyleName !== currentStyleName) { currentStyleName = newStyleName; - // check if named style is still the same - newNamedStyleName = formatting.getFirstNamedParentStyleNameOrSelf(newStyleName); - if (!newNamedStyleName) { - // TODO: how to handle default styles? - return; - } - // a named style - if (newNamedStyleName !== currentNamedStyleName) { - currentNamedStyleName = newNamedStyleName; + // check if common style is still the same + newCommonStyleName = formatting.getFirstCommonParentStyleNameOrSelf(newStyleName); + if (!newCommonStyleName) { + // Default style, empty-string name + currentCommonStyleName = newStyleName = currentStyleName = ""; self.emit(EditorSession.signalParagraphChanged, { type: 'style', node: currentParagraphNode, - styleName: currentNamedStyleName + styleName: currentCommonStyleName + }); + return; + } + // a common style + if (newCommonStyleName !== currentCommonStyleName) { + currentCommonStyleName = newCommonStyleName; + self.emit(EditorSession.signalParagraphChanged, { + type: 'style', + node: currentParagraphNode, + styleName: currentCommonStyleName }); } } @@ -222,11 +229,11 @@ define("webodf/editor/EditorSession", [ } function onStyleCreated(newStyleName) { - self.emit(EditorSession.signalCommonParagraphStyleCreated, newStyleName); + self.emit(EditorSession.signalCommonStyleCreated, newStyleName); } function onStyleDeleted(styleName) { - self.emit(EditorSession.signalCommonParagraphStyleDeleted, styleName); + self.emit(EditorSession.signalCommonStyleDeleted, styleName); } function onParagraphStyleModified(styleName) { @@ -289,7 +296,7 @@ define("webodf/editor/EditorSession", [ }; this.getCurrentParagraphStyle = function () { - return currentNamedStyleName; + return currentCommonStyleName; }; /** @@ -316,7 +323,7 @@ define("webodf/editor/EditorSession", [ this.setCurrentParagraphStyle = function (value) { var op; - if (currentNamedStyleName !== value) { + if (currentCommonStyleName !== value) { op = new ops.OpSetParagraphStyle(); op.init({ memberid: localMemberId, @@ -341,8 +348,17 @@ define("webodf/editor/EditorSession", [ session.enqueue(op); }; + /** + * Takes a style name and returns the corresponding paragraph style + * element. If the style name is an empty string, the default style + * is returned. + * @param {!string} styleName + * @return {Element} + */ this.getParagraphStyleElement = function (styleName) { - return odtDocument.getParagraphStyleElement(styleName); + return (styleName === "") + ? formatting.getDefaultStyleElement('paragraph') + : odtDocument.getParagraphStyleElement(styleName); }; /** @@ -354,8 +370,26 @@ define("webodf/editor/EditorSession", [ return formatting.isStyleUsed(styleElement); }; + function getDefaultParagraphStyleAttributes () { + var styleNode = formatting.getDefaultStyleElement('paragraph'); + if (styleNode) { + return formatting.getInheritedStyleAttributes(styleNode); + } + + return null; + }; + + /** + * Returns the attributes of a given paragraph style name + * (with inheritance). If the name is an empty string, + * the attributes of the default style are returned. + * @param {!string} styleName + * @return {Object} + */ this.getParagraphStyleAttributes = function (styleName) { - return odtDocument.getParagraphStyleAttributes(styleName); + return (styleName === "") + ? getDefaultParagraphStyleAttributes() + : odtDocument.getParagraphStyleAttributes(styleName); }; /** @@ -387,7 +421,7 @@ define("webodf/editor/EditorSession", [ */ this.cloneParagraphStyle = function (styleName, newStyleDisplayName) { var newStyleName = uniqueParagraphStyleNCName(newStyleDisplayName), - styleNode = odtDocument.getParagraphStyleElement(styleName), + styleNode = self.getParagraphStyleElement(styleName), formatting = odtDocument.getFormatting(), op, setProperties, attributes, i; @@ -406,10 +440,11 @@ define("webodf/editor/EditorSession", [ setProperties['style:display-name'] = newStyleDisplayName; - op = new ops.OpAddParagraphStyle(); + op = new ops.OpAddStyle(); op.init({ memberid: localMemberId, styleName: newStyleName, + styleFamily: 'paragraph', setProperties: setProperties }); session.enqueue(op); @@ -419,10 +454,11 @@ define("webodf/editor/EditorSession", [ this.deleteStyle = function (styleName) { var op; - op = new ops.OpRemoveParagraphStyle(); + op = new ops.OpRemoveStyle(); op.init({ memberid: localMemberId, - styleName: styleName + styleName: styleName, + styleFamily: 'paragraph' }); session.enqueue(op); }; @@ -522,8 +558,8 @@ define("webodf/editor/EditorSession", [ odtDocument.unsubscribe(ops.OdtDocument.signalCursorAdded, onCursorAdded); odtDocument.unsubscribe(ops.OdtDocument.signalCursorRemoved, onCursorRemoved); odtDocument.unsubscribe(ops.OdtDocument.signalCursorMoved, onCursorMoved); - odtDocument.unsubscribe(ops.OdtDocument.signalCommonParagraphStyleCreated, onStyleCreated); - odtDocument.unsubscribe(ops.OdtDocument.signalCommonParagraphStyleDeleted, onStyleDeleted); + odtDocument.unsubscribe(ops.OdtDocument.signalCommonStyleCreated, onStyleCreated); + odtDocument.unsubscribe(ops.OdtDocument.signalCommonStyleDeleted, onStyleDeleted); odtDocument.unsubscribe(ops.OdtDocument.signalParagraphStyleModified, onParagraphStyleModified); odtDocument.unsubscribe(ops.OdtDocument.signalParagraphChanged, trackCurrentParagraph); odtDocument.unsubscribe(ops.OdtDocument.signalUndoStackChanged, undoStackModified); @@ -564,8 +600,8 @@ define("webodf/editor/EditorSession", [ odtDocument.subscribe(ops.OdtDocument.signalCursorAdded, onCursorAdded); odtDocument.subscribe(ops.OdtDocument.signalCursorRemoved, onCursorRemoved); odtDocument.subscribe(ops.OdtDocument.signalCursorMoved, onCursorMoved); - odtDocument.subscribe(ops.OdtDocument.signalCommonParagraphStyleCreated, onStyleCreated); - odtDocument.subscribe(ops.OdtDocument.signalCommonParagraphStyleDeleted, onStyleDeleted); + odtDocument.subscribe(ops.OdtDocument.signalCommonStyleCreated, onStyleCreated); + odtDocument.subscribe(ops.OdtDocument.signalCommonStyleDeleted, onStyleDeleted); odtDocument.subscribe(ops.OdtDocument.signalParagraphStyleModified, onParagraphStyleModified); odtDocument.subscribe(ops.OdtDocument.signalParagraphChanged, trackCurrentParagraph); odtDocument.subscribe(ops.OdtDocument.signalUndoStackChanged, undoStackModified); @@ -578,8 +614,8 @@ define("webodf/editor/EditorSession", [ /**@const*/EditorSession.signalMemberRemoved = "memberRemoved"; /**@const*/EditorSession.signalCursorMoved = "cursorMoved"; /**@const*/EditorSession.signalParagraphChanged = "paragraphChanged"; - /**@const*/EditorSession.signalCommonParagraphStyleCreated = "styleCreated"; - /**@const*/EditorSession.signalCommonParagraphStyleDeleted = "styleDeleted"; + /**@const*/EditorSession.signalCommonStyleCreated = "styleCreated"; + /**@const*/EditorSession.signalCommonStyleDeleted = "styleDeleted"; /**@const*/EditorSession.signalParagraphStyleModified = "paragraphStyleModified"; /**@const*/EditorSession.signalUndoStackChanged = "signalUndoStackChanged"; diff --git a/js/3rdparty/webodf/editor/Tools.js b/js/3rdparty/webodf/editor/Tools.js index e88b59a8..4810e133 100644 --- a/js/3rdparty/webodf/editor/Tools.js +++ b/js/3rdparty/webodf/editor/Tools.js @@ -116,29 +116,32 @@ define("webodf/editor/Tools", [ // Simple Style Selector [B, I, U, S] if (args.directStylingEnabled) { - simpleStyles = new SimpleStyles(onToolDone, function (widget) { + simpleStyles = new SimpleStyles(function (widget) { widget.placeAt(toolbar); widget.startup(); }); sessionSubscribers.push(simpleStyles); + simpleStyles.onToolDone = onToolDone; } // Paragraph direct alignment buttons if (args.directStylingEnabled) { - paragraphAlignment = new ParagraphAlignment(onToolDone, function (widget) { + paragraphAlignment = new ParagraphAlignment(function (widget) { widget.placeAt(toolbar); widget.startup(); }); sessionSubscribers.push(paragraphAlignment); + paragraphAlignment.onToolDone = onToolDone; } // Paragraph Style Selector - currentStyle = new CurrentStyle(onToolDone, function (widget) { + currentStyle = new CurrentStyle(function (widget) { widget.placeAt(toolbar); widget.startup(); }); sessionSubscribers.push(currentStyle); + currentStyle.onToolDone = onToolDone; // Zoom Level Selector zoomSlider = new ZoomSlider(function (widget) { @@ -146,6 +149,7 @@ define("webodf/editor/Tools", [ widget.startup(); }); sessionSubscribers.push(zoomSlider); + zoomSlider.onToolDone = onToolDone; // Load if (loadOdtFile) { @@ -174,6 +178,7 @@ define("webodf/editor/Tools", [ }, onClick: function () { saveOdtFile(); + onToolDone(); } }); saveButton.placeAt(toolbar); @@ -195,6 +200,7 @@ define("webodf/editor/Tools", [ }; }); sessionSubscribers.push(paragraphStylesDialog); + paragraphStylesDialog.onToolDone = onToolDone; formatMenuButton = new DropDownButton({ dropDown: formatDropDownMenu, diff --git a/js/3rdparty/webodf/editor/nls/de/myResources.js b/js/3rdparty/webodf/editor/nls/de/myResources.js index 6b4197ca..109078be 100644 --- a/js/3rdparty/webodf/editor/nls/de/myResources.js +++ b/js/3rdparty/webodf/editor/nls/de/myResources.js @@ -91,5 +91,6 @@ define({ size: "Größe", color: "Farbe", text: "Text", - background: "Hintergrund" + background: "Hintergrund", + defaultStyle: "Grundstil" }); diff --git a/js/3rdparty/webodf/editor/nls/myResources.js b/js/3rdparty/webodf/editor/nls/myResources.js index b9940f33..fb5b0a10 100644 --- a/js/3rdparty/webodf/editor/nls/myResources.js +++ b/js/3rdparty/webodf/editor/nls/myResources.js @@ -90,7 +90,8 @@ define({ size: "Size", color: "Color", text: "Text", - background: "Background" + background: "Background", + defaultStyle: "Default Style" }, de: true, diff --git a/js/3rdparty/webodf/editor/widgets/paragraphAlignment.js b/js/3rdparty/webodf/editor/widgets/paragraphAlignment.js index 453d60d1..97c6cf2a 100644 --- a/js/3rdparty/webodf/editor/widgets/paragraphAlignment.js +++ b/js/3rdparty/webodf/editor/widgets/paragraphAlignment.js @@ -42,8 +42,9 @@ define("webodf/editor/widgets/paragraphAlignment", [ function (ToggleButton, Button) { "use strict"; - var ParagraphAlignment = function (onToolDone, callback) { - var widget = {}, + var ParagraphAlignment = function (callback) { + var self = this, + widget = {}, directParagraphStyler, justifyLeft, justifyCenter, @@ -60,7 +61,7 @@ define("webodf/editor/widgets/paragraphAlignment", [ iconClass: "dijitEditorIcon dijitEditorIconJustifyLeft", onChange: function () { directParagraphStyler.alignParagraphLeft(); - onToolDone(); + self.onToolDone(); } }); @@ -72,7 +73,7 @@ define("webodf/editor/widgets/paragraphAlignment", [ iconClass: "dijitEditorIcon dijitEditorIconJustifyCenter", onChange: function () { directParagraphStyler.alignParagraphCenter(); - onToolDone(); + self.onToolDone(); } }); @@ -84,7 +85,7 @@ define("webodf/editor/widgets/paragraphAlignment", [ iconClass: "dijitEditorIcon dijitEditorIconJustifyRight", onChange: function () { directParagraphStyler.alignParagraphRight(); - onToolDone(); + self.onToolDone(); } }); @@ -96,7 +97,7 @@ define("webodf/editor/widgets/paragraphAlignment", [ iconClass: "dijitEditorIcon dijitEditorIconJustifyFull", onChange: function () { directParagraphStyler.alignParagraphJustified(); - onToolDone(); + self.onToolDone(); } }); @@ -107,7 +108,7 @@ define("webodf/editor/widgets/paragraphAlignment", [ iconClass: "dijitEditorIcon dijitEditorIconOutdent", onClick: function () { directParagraphStyler.outdent(); - onToolDone(); + self.onToolDone(); } }); @@ -118,7 +119,7 @@ define("webodf/editor/widgets/paragraphAlignment", [ iconClass: "dijitEditorIcon dijitEditorIconIndent", onClick: function () { directParagraphStyler.indent(); - onToolDone(); + self.onToolDone(); } }); @@ -179,6 +180,8 @@ define("webodf/editor/widgets/paragraphAlignment", [ }); }; + this.onToolDone = function () {}; + callback(widget); }; diff --git a/js/3rdparty/webodf/editor/widgets/paragraphStyles.js b/js/3rdparty/webodf/editor/widgets/paragraphStyles.js index cc4f4cd2..aec34eee 100644 --- a/js/3rdparty/webodf/editor/widgets/paragraphStyles.js +++ b/js/3rdparty/webodf/editor/widgets/paragraphStyles.js @@ -46,23 +46,40 @@ define("webodf/editor/widgets/paragraphStyles", var ParagraphStyles = function (callback) { var self = this, editorSession, - select; + select, + translator = document.translator, + defaultStyleUIId = ":default"; this.widget = function () { return select; }; + /* + * In this widget, we name the default style + * (which is referred to as "" in webodf) as + * ":default". The ":" is disallowed in an NCName, so this + * avoids clashes with other styles. + */ + this.value = function () { - return select.get('value'); + var value = select.get('value'); + if (value === defaultStyleUIId) { + value = ""; + } + return value; }; this.setValue = function (value) { + if (value === "") { + value = defaultStyleUIId; + } select.set('value', value); }; // events this.onAdd = null; this.onRemove = null; + this.onChange = function () {}; function populateStyles() { var i, selectionList, availableStyles; @@ -71,7 +88,11 @@ define("webodf/editor/widgets/paragraphStyles", return; } - selectionList = []; + // Populate the Default Style always + selectionList = [{ + label: translator("defaultStyle"), + value: defaultStyleUIId + }]; availableStyles = editorSession ? editorSession.getAvailableParagraphStyles() : []; for (i = 0; i < availableStyles.length; i += 1) { @@ -85,29 +106,38 @@ define("webodf/editor/widgets/paragraphStyles", select.addOption(selectionList); } - function addStyle(newStyleName) { + function addStyle(styleInfo) { var stylens = "urn:oasis:names:tc:opendocument:xmlns:style:1.0", - newStyleElement = editorSession.getParagraphStyleElement(newStyleName); + newStyleElement; + if (styleInfo.family !== 'paragraph') { + return; + } + + newStyleElement = editorSession.getParagraphStyleElement(styleInfo.name); if (select) { select.addOption({ - value: newStyleName, + value: styleInfo.name, label: newStyleElement.getAttributeNS(stylens, 'display-name') }); } if (self.onAdd) { - self.onAdd(newStyleName); + self.onAdd(styleInfo.name); } } - function removeStyle(styleName) { + function removeStyle(styleInfo) { + if (styleInfo.family !== 'paragraph') { + return; + } + if (select) { - select.removeOption(styleName); + select.removeOption(styleInfo.name); } if (self.onRemove) { - self.onRemove(styleName); + self.onRemove(styleInfo.name); } } @@ -123,19 +153,28 @@ define("webodf/editor/widgets/paragraphStyles", populateStyles(); + // Call ParagraphStyles's onChange handler every time + // the select's onchange is called, and pass the value + // as reported by ParagraphStyles.value(), because we do not + // want to expose the internal naming like ":default" outside this + // class. + select.onChange = function () { + self.onChange(self.value()); + }; + return cb(); }); } this.setEditorSession = function(session) { if (editorSession) { - editorSession.unsubscribe(EditorSession.signalCommonParagraphStyleCreated, addStyle); - editorSession.unsubscribe(EditorSession.signalCommonParagraphStyleDeleted, removeStyle); + editorSession.unsubscribe(EditorSession.signalCommonStyleCreated, addStyle); + editorSession.unsubscribe(EditorSession.signalCommonStyleDeleted, removeStyle); } editorSession = session; if (editorSession) { - editorSession.subscribe(EditorSession.signalCommonParagraphStyleCreated, addStyle); - editorSession.subscribe(EditorSession.signalCommonParagraphStyleDeleted, removeStyle); + editorSession.subscribe(EditorSession.signalCommonStyleCreated, addStyle); + editorSession.subscribe(EditorSession.signalCommonStyleDeleted, removeStyle); populateStyles(); } }; diff --git a/js/3rdparty/webodf/editor/widgets/paragraphStylesDialog.js b/js/3rdparty/webodf/editor/widgets/paragraphStylesDialog.js index a7513d3f..8eab4b27 100644 --- a/js/3rdparty/webodf/editor/widgets/paragraphStylesDialog.js +++ b/js/3rdparty/webodf/editor/widgets/paragraphStylesDialog.js @@ -38,7 +38,8 @@ define("webodf/editor/widgets/paragraphStylesDialog", [], function () { "use strict"; return function ParagraphStylesDialog(callback) { - var editorSession, + var self = this, + editorSession, dialog, stylePicker, alignmentPane, fontEffectsPane; @@ -246,7 +247,8 @@ define("webodf/editor/widgets/paragraphStylesDialog", [], function () { function openStyle(value) { alignmentPane.setStyle(value); fontEffectsPane.setStyle(value); - if (editorSession.isStyleUsed(editorSession.getParagraphStyleElement(value))) { + // If it is a default (nameless) style or is used, make it undeletable. + if (value === "" || editorSession.isStyleUsed(editorSession.getParagraphStyleElement(value))) { deleteButton.domNode.style.display = 'none'; } else { deleteButton.domNode.style.display = 'block'; @@ -273,7 +275,7 @@ define("webodf/editor/widgets/paragraphStylesDialog", [], function () { stylePicker.setValue(stylePicker.widget().getOptions(0)); }; - stylePicker.widget().onChange = openStyle; + stylePicker.onChange = openStyle; stylePicker.setEditorSession(editorSession); }); a = new AlignmentPane(function (pane) { @@ -300,6 +302,8 @@ define("webodf/editor/widgets/paragraphStylesDialog", [], function () { stylePicker.setValue(currentStyle); } }; + + dialog.onHide = self.onToolDone; }); tabContainer.startup(); @@ -324,6 +328,8 @@ define("webodf/editor/widgets/paragraphStylesDialog", [], function () { } }; + this.onToolDone = function () {}; + // init makeWidget(function (dialog) { return callback(dialog); diff --git a/js/3rdparty/webodf/editor/widgets/simpleStyles.js b/js/3rdparty/webodf/editor/widgets/simpleStyles.js index 3afb897c..9d9e16f5 100644 --- a/js/3rdparty/webodf/editor/widgets/simpleStyles.js +++ b/js/3rdparty/webodf/editor/widgets/simpleStyles.js @@ -43,8 +43,9 @@ define("webodf/editor/widgets/simpleStyles", [ function (FontPicker, ToggleButton, NumberSpinner) { "use strict"; - var SimpleStyles = function(onToolDone, callback) { - var widget = {}, + var SimpleStyles = function(callback) { + var self = this, + widget = {}, directTextStyler, boldButton, italicButton, @@ -62,7 +63,7 @@ define("webodf/editor/widgets/simpleStyles", [ iconClass: "dijitEditorIcon dijitEditorIconBold", onChange: function (checked) { directTextStyler.setBold(checked); - onToolDone(); + self.onToolDone(); } }); @@ -74,7 +75,7 @@ define("webodf/editor/widgets/simpleStyles", [ iconClass: "dijitEditorIcon dijitEditorIconItalic", onChange: function (checked) { directTextStyler.setItalic(checked); - onToolDone(); + self.onToolDone(); } }); @@ -86,7 +87,7 @@ define("webodf/editor/widgets/simpleStyles", [ iconClass: "dijitEditorIcon dijitEditorIconUnderline", onChange: function (checked) { directTextStyler.setHasUnderline(checked); - onToolDone(); + self.onToolDone(); } }); @@ -98,7 +99,7 @@ define("webodf/editor/widgets/simpleStyles", [ iconClass: "dijitEditorIcon dijitEditorIconStrikethrough", onChange: function (checked) { directTextStyler.setHasStrikethrough(checked); - onToolDone(); + self.onToolDone(); } }); @@ -110,8 +111,17 @@ define("webodf/editor/widgets/simpleStyles", [ smallDelta: 1, constraints: {min:6, max:96}, intermediateChanges: true, - onChange: function(value) { + onChange: function (value) { directTextStyler.setFontSize(value); + }, + onClick: function () { + self.onToolDone(); + }, + onInput: function () { + // Do not process any input in the text box; + // even paste events will not be processed + // so that no corrupt values can exist + return false; } }); @@ -120,7 +130,7 @@ define("webodf/editor/widgets/simpleStyles", [ fontPickerWidget.setAttribute('disabled', true); fontPickerWidget.onChange = function(value) { directTextStyler.setFontName(value); - onToolDone(); + self.onToolDone(); }; widget.children = [boldButton, italicButton, underlineButton, strikethroughButton, fontPickerWidget, fontSizeSpinner]; @@ -182,6 +192,8 @@ define("webodf/editor/widgets/simpleStyles", [ }); }; + this.onToolDone = function () {}; + callback(widget); }; diff --git a/js/3rdparty/webodf/editor/widgets/toolbarWidgets/currentStyle.js b/js/3rdparty/webodf/editor/widgets/toolbarWidgets/currentStyle.js index 7aa7a735..47e7c718 100644 --- a/js/3rdparty/webodf/editor/widgets/toolbarWidgets/currentStyle.js +++ b/js/3rdparty/webodf/editor/widgets/toolbarWidgets/currentStyle.js @@ -41,23 +41,24 @@ define("webodf/editor/widgets/toolbarWidgets/currentStyle", function (EditorSession) { "use strict"; - return function CurrentStyle(onToolDone, callback) { - var editorSession, + return function CurrentStyle(callback) { + var self = this, + editorSession, paragraphStyles; function selectParagraphStyle(info) { if (paragraphStyles) { if (info.type === 'style') { - paragraphStyles.widget().set("value", info.styleName); + paragraphStyles.setValue(info.styleName); } } } - function setParagraphStyle(value) { + function setParagraphStyle() { if (editorSession) { - editorSession.setCurrentParagraphStyle(value); - onToolDone(); + editorSession.setCurrentParagraphStyle(paragraphStyles.value()); } + self.onToolDone(); } function makeWidget(callback) { @@ -89,6 +90,8 @@ define("webodf/editor/widgets/toolbarWidgets/currentStyle", } }; + this.onToolDone = function () {}; + makeWidget(function (widget) { return callback(widget); }); diff --git a/js/3rdparty/webodf/editor/widgets/zoomSlider.js b/js/3rdparty/webodf/editor/widgets/zoomSlider.js index 09d8b383..fccf8ffb 100644 --- a/js/3rdparty/webodf/editor/widgets/zoomSlider.js +++ b/js/3rdparty/webodf/editor/widgets/zoomSlider.js @@ -39,7 +39,8 @@ define("webodf/editor/widgets/zoomSlider", [], function () { "use strict"; return function ZoomSlider(callback) { - var editorSession, + var self = this, + editorSession, slider; function makeWidget(callback) { @@ -64,8 +65,9 @@ define("webodf/editor/widgets/zoomSlider", [], function () { if (editorSession) { editorSession.getOdfCanvas().setZoomLevel(value / 100.0); } + self.onToolDone(); }; - + return callback(slider); }); } @@ -75,6 +77,8 @@ define("webodf/editor/widgets/zoomSlider", [], function () { // if (slider) { slider.setValue(editorSession.getOdfCanvas().getZoomLevel() ); TODO! }; + this.onToolDone = function () {}; + // init makeWidget(function (widget) { return callback(widget); diff --git a/js/3rdparty/webodf/webodf-debug.js b/js/3rdparty/webodf/webodf-debug.js index ddd8c63a..fc180be7 100644 --- a/js/3rdparty/webodf/webodf-debug.js +++ b/js/3rdparty/webodf/webodf-debug.js @@ -3011,6 +3011,40 @@ core.Utils = function Utils() { } this.mergeObjects = mergeObjects }; +/* + + 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. + + As additional permission under GNU AGPL version 3 section 7, you + may distribute non-source (e.g., minimized or compacted) forms of + that code without the copy of the GNU GPL normally required by + section 4, provided you include this license notice and a URL + through which recipients can access the Corresponding Source. + + As a special exception to the AGPL, any HTML file which merely makes function + calls to this code, and for that purpose includes it by reference shall be + deemed a separate work for copyright law purposes. In addition, the copyright + holders of this code give you permission to combine this code with free + software libraries that are released under the GNU LGPL. You may copy and + distribute such a system following the terms of the GNU AGPL for this code + and the LGPL for the libraries. If you modify this code, you may extend this + exception to your version of the code, but you are not obligated to do so. + If you do not wish to do so, delete this exception statement from your + version. + + This license applies to this entire compilation. + @licend + @source: http://www.webodf.org/ + @source: http://gitorious.org/webodf/webodf/ +*/ core.DomUtils = function DomUtils() { function findStablePoint(container, offset) { if(offset < container.childNodes.length) { @@ -3077,18 +3111,23 @@ core.DomUtils = function DomUtils() { return elements } this.getNodesInRange = getNodesInRange; - function mergeTextNodes(node1, node2) { - if(node1.nodeType === Node.TEXT_NODE) { - if(node1.length === 0) { - node1.parentNode.removeChild(node1) - }else { - if(node2.nodeType === Node.TEXT_NODE) { - node1.appendData(node2.data); - node2.parentNode.removeChild(node2) + function mergeTextNodes(node, nextNode) { + var mergedNode = null; + if(node.nodeType === Node.TEXT_NODE) { + if(node.length === 0) { + node.parentNode.removeChild(node); + if(nextNode.nodeType === Node.TEXT_NODE) { + mergedNode = nextNode } + }else { + if(nextNode.nodeType === Node.TEXT_NODE) { + node.appendData(nextNode.data); + nextNode.parentNode.removeChild(nextNode) + } + mergedNode = node } } - return node1 + return mergedNode } function normalizeTextNodes(node) { if(node && node.nextSibling) { @@ -3130,6 +3169,42 @@ core.DomUtils = function DomUtils() { return parent === descendant || parent.contains(descendant) } this.containsNode = containsNode; + function getPositionInContainingNode(node, container) { + var offset = 0, n; + while(node.parentNode !== container) { + runtime.assert(node.parentNode !== null, "parent is null"); + node = (node.parentNode) + } + n = container.firstChild; + while(n !== node) { + offset += 1; + n = n.nextSibling + } + return offset + } + function comparePoints(c1, o1, c2, o2) { + if(c1 === c2) { + return o2 - o1 + } + var comparison = c1.compareDocumentPosition(c2); + if(comparison === 2) { + comparison = -1 + }else { + if(comparison === 4) { + comparison = 1 + }else { + if(comparison === 10) { + o1 = getPositionInContainingNode(c1, c2); + comparison = o1 < o2 ? 1 : -1 + }else { + o2 = getPositionInContainingNode(c2, c1); + comparison = o2 < o1 ? -1 : 1 + } + } + } + return comparison + } + this.comparePoints = comparePoints; function containsNodeForBrokenWebKit(parent, descendant) { return parent === descendant || Boolean(parent.compareDocumentPosition(descendant) & Node.DOCUMENT_POSITION_CONTAINED_BY) } @@ -3706,23 +3781,6 @@ core.PositionIterator = function PositionIterator(root, whatToShow, filter, expa this.getCurrentNode = function() { return walker.currentNode }; - this.domOffset = function() { - if(walker.currentNode.nodeType === Node.TEXT_NODE) { - return currentPos - } - var c = 0, startNode = walker.currentNode, n; - if(currentPos === 1) { - n = walker.lastChild() - }else { - n = walker.previousSibling() - } - while(n) { - c += 1; - n = walker.previousSibling() - } - walker.currentNode = startNode; - return c - }; this.unfilteredDomOffset = function() { if(walker.currentNode.nodeType === Node.TEXT_NODE) { return currentPos @@ -3750,7 +3808,7 @@ core.PositionIterator = function PositionIterator(root, whatToShow, filter, expa return sibling }; this.setUnfilteredPosition = function(container, offset) { - var filterResult; + var filterResult, node; runtime.assert(container !== null && container !== undefined, "PositionIterator.setUnfilteredPosition called without container"); walker.currentNode = container; if(container.nodeType === Node.TEXT_NODE) { @@ -3771,6 +3829,14 @@ core.PositionIterator = function PositionIterator(root, whatToShow, filter, expa return true } filterResult = nodeFilter(container); + node = container.parentNode; + while(node && node !== root && filterResult === NodeFilter.FILTER_ACCEPT) { + filterResult = nodeFilter(node); + if(filterResult !== NodeFilter.FILTER_ACCEPT) { + walker.currentNode = node + } + node = node.parentNode + } if(offset < container.childNodes.length && filterResult !== NodeFilter.FILTER_REJECT) { walker.currentNode = container.childNodes[offset]; filterResult = nodeFilter(walker.currentNode); @@ -6000,9 +6066,9 @@ odf.OdfNodeFilter = function OdfNodeFilter() { @source: http://gitorious.org/webodf/webodf/ */ odf.Namespaces = function() { - var drawns = "urn:oasis:names:tc:opendocument:xmlns:drawing:1.0", fons = "urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0", officens = "urn:oasis:names:tc:opendocument:xmlns:office:1.0", presentationns = "urn:oasis:names:tc:opendocument:xmlns:presentation:1.0", stylens = "urn:oasis:names:tc:opendocument:xmlns:style:1.0", svgns = "urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0", tablens = "urn:oasis:names:tc:opendocument:xmlns:table:1.0", textns = "urn:oasis:names:tc:opendocument:xmlns:text:1.0", - dr3dns = "urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0", numberns = "urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0", xlinkns = "http://www.w3.org/1999/xlink", xmlns = "http://www.w3.org/XML/1998/namespace", dcns = "http://purl.org/dc/elements/1.1/", webodfns = "urn:webodf", namespaceMap = {"draw":drawns, "fo":fons, "office":officens, "presentation":presentationns, "style":stylens, "svg":svgns, "table":tablens, "text":textns, "dr3d":dr3dns, "numberns":numberns, "xlink":xlinkns, "xml":xmlns, - "dc":dcns, "webodf":webodfns}, namespaces; + var dbns = "urn:oasis:names:tc:opendocument:xmlns:database:1.0", dcns = "http://purl.org/dc/elements/1.1/", dr3dns = "urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0", drawns = "urn:oasis:names:tc:opendocument:xmlns:drawing:1.0", chartns = "urn:oasis:names:tc:opendocument:xmlns:chart:1.0", fons = "urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0", formns = "urn:oasis:names:tc:opendocument:xmlns:form:1.0", numberns = "urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0", officens = "urn:oasis:names:tc:opendocument:xmlns:office:1.0", + presentationns = "urn:oasis:names:tc:opendocument:xmlns:presentation:1.0", stylens = "urn:oasis:names:tc:opendocument:xmlns:style:1.0", svgns = "urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0", tablens = "urn:oasis:names:tc:opendocument:xmlns:table:1.0", textns = "urn:oasis:names:tc:opendocument:xmlns:text:1.0", xlinkns = "http://www.w3.org/1999/xlink", xmlns = "http://www.w3.org/XML/1998/namespace", webodfns = "urn:webodf", namespaceMap = {"db":dbns, "dc":dcns, "dr3d":dr3dns, "draw":drawns, + "chart":chartns, "fo":fons, "form":formns, "numberns":numberns, "office":officens, "presentation":presentationns, "style":stylens, "svg":svgns, "table":tablens, "text":textns, "xlink":xlinkns, "xml":xmlns, "webodf":webodfns}, namespaces; function forEachPrefix(cb) { var prefix; for(prefix in namespaceMap) { @@ -6020,53 +6086,90 @@ odf.Namespaces = function() { namespaces.forEachPrefix = forEachPrefix; namespaces.resolvePrefix = resolvePrefix; namespaces.namespaceMap = namespaceMap; + namespaces.dbns = dbns; + namespaces.dcns = dcns; + namespaces.dr3dns = dr3dns; namespaces.drawns = drawns; + namespaces.chartns = chartns; namespaces.fons = fons; + namespaces.formns = formns; + namespaces.numberns = numberns; namespaces.officens = officens; namespaces.presentationns = presentationns; namespaces.stylens = stylens; namespaces.svgns = svgns; namespaces.tablens = tablens; namespaces.textns = textns; - namespaces.dr3dns = dr3dns; - namespaces.numberns = numberns; namespaces.xlinkns = xlinkns; namespaces.xmlns = xmlns; - namespaces.dcns = dcns; namespaces.webodfns = webodfns; return namespaces }(); +/* + + 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. + + As additional permission under GNU AGPL version 3 section 7, you + may distribute non-source (e.g., minimized or compacted) forms of + that code without the copy of the GNU GPL normally required by + section 4, provided you include this license notice and a URL + through which recipients can access the Corresponding Source. + + As a special exception to the AGPL, any HTML file which merely makes function + calls to this code, and for that purpose includes it by reference shall be + deemed a separate work for copyright law purposes. In addition, the copyright + holders of this code give you permission to combine this code with free + software libraries that are released under the GNU LGPL. You may copy and + distribute such a system following the terms of the GNU AGPL for this code + and the LGPL for the libraries. If you modify this code, you may extend this + exception to your version of the code, but you are not obligated to do so. + If you do not wish to do so, delete this exception statement from your + version. + + This license applies to this entire compilation. + @licend + @source: http://www.webodf.org/ + @source: http://gitorious.org/webodf/webodf/ +*/ runtime.loadClass("xmldom.XPath"); +runtime.loadClass("odf.Namespaces"); odf.StyleInfo = function StyleInfo() { - var chartns = "urn:oasis:names:tc:opendocument:xmlns:chart:1.0", dbns = "urn:oasis:names:tc:opendocument:xmlns:database:1.0", dr3dns = "urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0", drawns = "urn:oasis:names:tc:opendocument:xmlns:drawing:1.0", formns = "urn:oasis:names:tc:opendocument:xmlns:form:1.0", numberns = "urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0", officens = "urn:oasis:names:tc:opendocument:xmlns:office:1.0", presentationns = "urn:oasis:names:tc:opendocument:xmlns:presentation:1.0", - stylens = "urn:oasis:names:tc:opendocument:xmlns:style:1.0", tablens = "urn:oasis:names:tc:opendocument:xmlns:table:1.0", textns = "urn:oasis:names:tc:opendocument:xmlns:text:1.0", nsprefixes = {"urn:oasis:names:tc:opendocument:xmlns:chart:1.0":"chart:", "urn:oasis:names:tc:opendocument:xmlns:database:1.0":"db:", "urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0":"dr3d:", "urn:oasis:names:tc:opendocument:xmlns:drawing:1.0":"draw:", "urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0":"fo:", - "urn:oasis:names:tc:opendocument:xmlns:form:1.0":"form:", "urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0":"number:", "urn:oasis:names:tc:opendocument:xmlns:office:1.0":"office:", "urn:oasis:names:tc:opendocument:xmlns:presentation:1.0":"presentation:", "urn:oasis:names:tc:opendocument:xmlns:style:1.0":"style:", "urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0":"svg:", "urn:oasis:names:tc:opendocument:xmlns:table:1.0":"table:", "urn:oasis:names:tc:opendocument:xmlns:text:1.0":"chart:", - "http://www.w3.org/XML/1998/namespace":"xml:"}, elementstyles = {"text":[{ens:stylens, en:"tab-stop", ans:stylens, a:"leader-text-style"}, {ens:stylens, en:"drop-cap", ans:stylens, a:"style-name"}, {ens:textns, en:"notes-configuration", ans:textns, a:"citation-body-style-name"}, {ens:textns, en:"notes-configuration", ans:textns, a:"citation-style-name"}, {ens:textns, en:"a", ans:textns, a:"style-name"}, {ens:textns, en:"alphabetical-index", ans:textns, a:"style-name"}, {ens:textns, en:"linenumbering-configuration", - ans:textns, a:"style-name"}, {ens:textns, en:"list-level-style-number", ans:textns, a:"style-name"}, {ens:textns, en:"ruby-text", ans:textns, a:"style-name"}, {ens:textns, en:"span", ans:textns, a:"style-name"}, {ens:textns, en:"a", ans:textns, a:"visited-style-name"}, {ens:stylens, en:"text-properties", ans:stylens, a:"text-line-through-text-style"}, {ens:textns, en:"alphabetical-index-source", ans:textns, a:"main-entry-style-name"}, {ens:textns, en:"index-entry-bibliography", ans:textns, a:"style-name"}, - {ens:textns, en:"index-entry-chapter", ans:textns, a:"style-name"}, {ens:textns, en:"index-entry-link-end", ans:textns, a:"style-name"}, {ens:textns, en:"index-entry-link-start", ans:textns, a:"style-name"}, {ens:textns, en:"index-entry-page-number", ans:textns, a:"style-name"}, {ens:textns, en:"index-entry-span", ans:textns, a:"style-name"}, {ens:textns, en:"index-entry-tab-stop", ans:textns, a:"style-name"}, {ens:textns, en:"index-entry-text", ans:textns, a:"style-name"}, {ens:textns, en:"index-title-template", - ans:textns, a:"style-name"}, {ens:textns, en:"list-level-style-bullet", ans:textns, a:"style-name"}, {ens:textns, en:"outline-level-style", ans:textns, a:"style-name"}], "paragraph":[{ens:drawns, en:"caption", ans:drawns, a:"text-style-name"}, {ens:drawns, en:"circle", ans:drawns, a:"text-style-name"}, {ens:drawns, en:"connector", ans:drawns, a:"text-style-name"}, {ens:drawns, en:"control", ans:drawns, a:"text-style-name"}, {ens:drawns, en:"custom-shape", ans:drawns, a:"text-style-name"}, {ens:drawns, - en:"ellipse", ans:drawns, a:"text-style-name"}, {ens:drawns, en:"frame", ans:drawns, a:"text-style-name"}, {ens:drawns, en:"line", ans:drawns, a:"text-style-name"}, {ens:drawns, en:"measure", ans:drawns, a:"text-style-name"}, {ens:drawns, en:"path", ans:drawns, a:"text-style-name"}, {ens:drawns, en:"polygon", ans:drawns, a:"text-style-name"}, {ens:drawns, en:"polyline", ans:drawns, a:"text-style-name"}, {ens:drawns, en:"rect", ans:drawns, a:"text-style-name"}, {ens:drawns, en:"regular-polygon", - ans:drawns, a:"text-style-name"}, {ens:officens, en:"annotation", ans:drawns, a:"text-style-name"}, {ens:formns, en:"column", ans:formns, a:"text-style-name"}, {ens:stylens, en:"style", ans:stylens, a:"next-style-name"}, {ens:tablens, en:"body", ans:tablens, a:"paragraph-style-name"}, {ens:tablens, en:"even-columns", ans:tablens, a:"paragraph-style-name"}, {ens:tablens, en:"even-rows", ans:tablens, a:"paragraph-style-name"}, {ens:tablens, en:"first-column", ans:tablens, a:"paragraph-style-name"}, - {ens:tablens, en:"first-row", ans:tablens, a:"paragraph-style-name"}, {ens:tablens, en:"last-column", ans:tablens, a:"paragraph-style-name"}, {ens:tablens, en:"last-row", ans:tablens, a:"paragraph-style-name"}, {ens:tablens, en:"odd-columns", ans:tablens, a:"paragraph-style-name"}, {ens:tablens, en:"odd-rows", ans:tablens, a:"paragraph-style-name"}, {ens:textns, en:"notes-configuration", ans:textns, a:"default-style-name"}, {ens:textns, en:"alphabetical-index-entry-template", ans:textns, a:"style-name"}, - {ens:textns, en:"bibliography-entry-template", ans:textns, a:"style-name"}, {ens:textns, en:"h", ans:textns, a:"style-name"}, {ens:textns, en:"illustration-index-entry-template", ans:textns, a:"style-name"}, {ens:textns, en:"index-source-style", ans:textns, a:"style-name"}, {ens:textns, en:"object-index-entry-template", ans:textns, a:"style-name"}, {ens:textns, en:"p", ans:textns, a:"style-name"}, {ens:textns, en:"table-index-entry-template", ans:textns, a:"style-name"}, {ens:textns, en:"table-of-content-entry-template", - ans:textns, a:"style-name"}, {ens:textns, en:"table-index-entry-template", ans:textns, a:"style-name"}, {ens:textns, en:"user-index-entry-template", ans:textns, a:"style-name"}, {ens:stylens, en:"page-layout-properties", ans:stylens, a:"register-truth-ref-style-name"}], "chart":[{ens:chartns, en:"axis", ans:chartns, a:"style-name"}, {ens:chartns, en:"chart", ans:chartns, a:"style-name"}, {ens:chartns, en:"data-label", ans:chartns, a:"style-name"}, {ens:chartns, en:"data-point", ans:chartns, a:"style-name"}, - {ens:chartns, en:"equation", ans:chartns, a:"style-name"}, {ens:chartns, en:"error-indicator", ans:chartns, a:"style-name"}, {ens:chartns, en:"floor", ans:chartns, a:"style-name"}, {ens:chartns, en:"footer", ans:chartns, a:"style-name"}, {ens:chartns, en:"grid", ans:chartns, a:"style-name"}, {ens:chartns, en:"legend", ans:chartns, a:"style-name"}, {ens:chartns, en:"mean-value", ans:chartns, a:"style-name"}, {ens:chartns, en:"plot-area", ans:chartns, a:"style-name"}, {ens:chartns, en:"regression-curve", - ans:chartns, a:"style-name"}, {ens:chartns, en:"series", ans:chartns, a:"style-name"}, {ens:chartns, en:"stock-gain-marker", ans:chartns, a:"style-name"}, {ens:chartns, en:"stock-loss-marker", ans:chartns, a:"style-name"}, {ens:chartns, en:"stock-range-line", ans:chartns, a:"style-name"}, {ens:chartns, en:"subtitle", ans:chartns, a:"style-name"}, {ens:chartns, en:"title", ans:chartns, a:"style-name"}, {ens:chartns, en:"wall", ans:chartns, a:"style-name"}], "section":[{ens:textns, en:"alphabetical-index", - ans:textns, a:"style-name"}, {ens:textns, en:"bibliography", ans:textns, a:"style-name"}, {ens:textns, en:"illustration-index", ans:textns, a:"style-name"}, {ens:textns, en:"index-title", ans:textns, a:"style-name"}, {ens:textns, en:"object-index", ans:textns, a:"style-name"}, {ens:textns, en:"section", ans:textns, a:"style-name"}, {ens:textns, en:"table-of-content", ans:textns, a:"style-name"}, {ens:textns, en:"table-index", ans:textns, a:"style-name"}, {ens:textns, en:"user-index", ans:textns, - a:"style-name"}], "ruby":[{ens:textns, en:"ruby", ans:textns, a:"style-name"}], "table":[{ens:dbns, en:"query", ans:dbns, a:"style-name"}, {ens:dbns, en:"table-representation", ans:dbns, a:"style-name"}, {ens:tablens, en:"background", ans:tablens, a:"style-name"}, {ens:tablens, en:"table", ans:tablens, a:"style-name"}], "table-column":[{ens:dbns, en:"column", ans:dbns, a:"style-name"}, {ens:tablens, en:"table-column", ans:tablens, a:"style-name"}], "table-row":[{ens:dbns, en:"query", ans:dbns, - a:"default-row-style-name"}, {ens:dbns, en:"table-representation", ans:dbns, a:"default-row-style-name"}, {ens:tablens, en:"table-row", ans:tablens, a:"style-name"}], "table-cell":[{ens:dbns, en:"column", ans:dbns, a:"default-cell-style-name"}, {ens:tablens, en:"table-column", ans:tablens, a:"default-cell-style-name"}, {ens:tablens, en:"table-row", ans:tablens, a:"default-cell-style-name"}, {ens:tablens, en:"body", ans:tablens, a:"style-name"}, {ens:tablens, en:"covered-table-cell", ans:tablens, - a:"style-name"}, {ens:tablens, en:"even-columns", ans:tablens, a:"style-name"}, {ens:tablens, en:"covered-table-cell", ans:tablens, a:"style-name"}, {ens:tablens, en:"even-columns", ans:tablens, a:"style-name"}, {ens:tablens, en:"even-rows", ans:tablens, a:"style-name"}, {ens:tablens, en:"first-column", ans:tablens, a:"style-name"}, {ens:tablens, en:"first-row", ans:tablens, a:"style-name"}, {ens:tablens, en:"last-column", ans:tablens, a:"style-name"}, {ens:tablens, en:"last-row", ans:tablens, - a:"style-name"}, {ens:tablens, en:"odd-columns", ans:tablens, a:"style-name"}, {ens:tablens, en:"odd-rows", ans:tablens, a:"style-name"}, {ens:tablens, en:"table-cell", ans:tablens, a:"style-name"}], "graphic":[{ens:dr3dns, en:"cube", ans:drawns, a:"style-name"}, {ens:dr3dns, en:"extrude", ans:drawns, a:"style-name"}, {ens:dr3dns, en:"rotate", ans:drawns, a:"style-name"}, {ens:dr3dns, en:"scene", ans:drawns, a:"style-name"}, {ens:dr3dns, en:"sphere", ans:drawns, a:"style-name"}, {ens:drawns, en:"caption", - ans:drawns, a:"style-name"}, {ens:drawns, en:"circle", ans:drawns, a:"style-name"}, {ens:drawns, en:"connector", ans:drawns, a:"style-name"}, {ens:drawns, en:"control", ans:drawns, a:"style-name"}, {ens:drawns, en:"custom-shape", ans:drawns, a:"style-name"}, {ens:drawns, en:"ellipse", ans:drawns, a:"style-name"}, {ens:drawns, en:"frame", ans:drawns, a:"style-name"}, {ens:drawns, en:"g", ans:drawns, a:"style-name"}, {ens:drawns, en:"line", ans:drawns, a:"style-name"}, {ens:drawns, en:"measure", - ans:drawns, a:"style-name"}, {ens:drawns, en:"page-thumbnail", ans:drawns, a:"style-name"}, {ens:drawns, en:"path", ans:drawns, a:"style-name"}, {ens:drawns, en:"polygon", ans:drawns, a:"style-name"}, {ens:drawns, en:"polyline", ans:drawns, a:"style-name"}, {ens:drawns, en:"rect", ans:drawns, a:"style-name"}, {ens:drawns, en:"regular-polygon", ans:drawns, a:"style-name"}, {ens:officens, en:"annotation", ans:drawns, a:"style-name"}], "presentation":[{ens:dr3dns, en:"cube", ans:presentationns, a:"style-name"}, - {ens:dr3dns, en:"extrude", ans:presentationns, a:"style-name"}, {ens:dr3dns, en:"rotate", ans:presentationns, a:"style-name"}, {ens:dr3dns, en:"scene", ans:presentationns, a:"style-name"}, {ens:dr3dns, en:"sphere", ans:presentationns, a:"style-name"}, {ens:drawns, en:"caption", ans:presentationns, a:"style-name"}, {ens:drawns, en:"circle", ans:presentationns, a:"style-name"}, {ens:drawns, en:"connector", ans:presentationns, a:"style-name"}, {ens:drawns, en:"control", ans:presentationns, a:"style-name"}, - {ens:drawns, en:"custom-shape", ans:presentationns, a:"style-name"}, {ens:drawns, en:"ellipse", ans:presentationns, a:"style-name"}, {ens:drawns, en:"frame", ans:presentationns, a:"style-name"}, {ens:drawns, en:"g", ans:presentationns, a:"style-name"}, {ens:drawns, en:"line", ans:presentationns, a:"style-name"}, {ens:drawns, en:"measure", ans:presentationns, a:"style-name"}, {ens:drawns, en:"page-thumbnail", ans:presentationns, a:"style-name"}, {ens:drawns, en:"path", ans:presentationns, a:"style-name"}, - {ens:drawns, en:"polygon", ans:presentationns, a:"style-name"}, {ens:drawns, en:"polyline", ans:presentationns, a:"style-name"}, {ens:drawns, en:"rect", ans:presentationns, a:"style-name"}, {ens:drawns, en:"regular-polygon", ans:presentationns, a:"style-name"}, {ens:officens, en:"annotation", ans:presentationns, a:"style-name"}], "drawing-page":[{ens:drawns, en:"page", ans:drawns, a:"style-name"}, {ens:presentationns, en:"notes", ans:drawns, a:"style-name"}, {ens:stylens, en:"handout-master", ans:drawns, - a:"style-name"}, {ens:stylens, en:"master-page", ans:drawns, a:"style-name"}], "list-style":[{ens:textns, en:"list", ans:textns, a:"style-name"}, {ens:textns, en:"numbered-paragraph", ans:textns, a:"style-name"}, {ens:textns, en:"list-item", ans:textns, a:"style-override"}, {ens:stylens, en:"style", ans:stylens, a:"list-style-name"}], "data":[{ens:stylens, en:"style", ans:stylens, a:"data-style-name"}, {ens:stylens, en:"style", ans:stylens, a:"percentage-data-style-name"}, {ens:presentationns, - en:"date-time-decl", ans:stylens, a:"data-style-name"}, {ens:textns, en:"creation-date", ans:stylens, a:"data-style-name"}, {ens:textns, en:"creation-time", ans:stylens, a:"data-style-name"}, {ens:textns, en:"database-display", ans:stylens, a:"data-style-name"}, {ens:textns, en:"date", ans:stylens, a:"data-style-name"}, {ens:textns, en:"editing-duration", ans:stylens, a:"data-style-name"}, {ens:textns, en:"expression", ans:stylens, a:"data-style-name"}, {ens:textns, en:"meta-field", ans:stylens, - a:"data-style-name"}, {ens:textns, en:"modification-date", ans:stylens, a:"data-style-name"}, {ens:textns, en:"modification-time", ans:stylens, a:"data-style-name"}, {ens:textns, en:"print-date", ans:stylens, a:"data-style-name"}, {ens:textns, en:"print-time", ans:stylens, a:"data-style-name"}, {ens:textns, en:"table-formula", ans:stylens, a:"data-style-name"}, {ens:textns, en:"time", ans:stylens, a:"data-style-name"}, {ens:textns, en:"user-defined", ans:stylens, a:"data-style-name"}, {ens:textns, - en:"user-field-get", ans:stylens, a:"data-style-name"}, {ens:textns, en:"user-field-input", ans:stylens, a:"data-style-name"}, {ens:textns, en:"variable-get", ans:stylens, a:"data-style-name"}, {ens:textns, en:"variable-input", ans:stylens, a:"data-style-name"}, {ens:textns, en:"variable-set", ans:stylens, a:"data-style-name"}], "page-layout":[{ens:presentationns, en:"notes", ans:stylens, a:"page-layout-name"}, {ens:stylens, en:"handout-master", ans:stylens, a:"page-layout-name"}, {ens:stylens, - en:"master-page", ans:stylens, a:"page-layout-name"}]}, elements, xpath = new xmldom.XPath; + var chartns = odf.Namespaces.chartns, dbns = odf.Namespaces.dbns, dr3dns = odf.Namespaces.dr3dns, drawns = odf.Namespaces.drawns, formns = odf.Namespaces.formns, numberns = odf.Namespaces.numberns, officens = odf.Namespaces.officens, presentationns = odf.Namespaces.presentationns, stylens = odf.Namespaces.stylens, tablens = odf.Namespaces.tablens, textns = odf.Namespaces.textns, nsprefixes = {"urn:oasis:names:tc:opendocument:xmlns:chart:1.0":"chart:", "urn:oasis:names:tc:opendocument:xmlns:database:1.0":"db:", + "urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0":"dr3d:", "urn:oasis:names:tc:opendocument:xmlns:drawing:1.0":"draw:", "urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0":"fo:", "urn:oasis:names:tc:opendocument:xmlns:form:1.0":"form:", "urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0":"number:", "urn:oasis:names:tc:opendocument:xmlns:office:1.0":"office:", "urn:oasis:names:tc:opendocument:xmlns:presentation:1.0":"presentation:", "urn:oasis:names:tc:opendocument:xmlns:style:1.0":"style:", + "urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0":"svg:", "urn:oasis:names:tc:opendocument:xmlns:table:1.0":"table:", "urn:oasis:names:tc:opendocument:xmlns:text:1.0":"chart:", "http://www.w3.org/XML/1998/namespace":"xml:"}, elementstyles = {"text":[{ens:stylens, en:"tab-stop", ans:stylens, a:"leader-text-style"}, {ens:stylens, en:"drop-cap", ans:stylens, a:"style-name"}, {ens:textns, en:"notes-configuration", ans:textns, a:"citation-body-style-name"}, {ens:textns, en:"notes-configuration", + ans:textns, a:"citation-style-name"}, {ens:textns, en:"a", ans:textns, a:"style-name"}, {ens:textns, en:"alphabetical-index", ans:textns, a:"style-name"}, {ens:textns, en:"linenumbering-configuration", ans:textns, a:"style-name"}, {ens:textns, en:"list-level-style-number", ans:textns, a:"style-name"}, {ens:textns, en:"ruby-text", ans:textns, a:"style-name"}, {ens:textns, en:"span", ans:textns, a:"style-name"}, {ens:textns, en:"a", ans:textns, a:"visited-style-name"}, {ens:stylens, en:"text-properties", + ans:stylens, a:"text-line-through-text-style"}, {ens:textns, en:"alphabetical-index-source", ans:textns, a:"main-entry-style-name"}, {ens:textns, en:"index-entry-bibliography", ans:textns, a:"style-name"}, {ens:textns, en:"index-entry-chapter", ans:textns, a:"style-name"}, {ens:textns, en:"index-entry-link-end", ans:textns, a:"style-name"}, {ens:textns, en:"index-entry-link-start", ans:textns, a:"style-name"}, {ens:textns, en:"index-entry-page-number", ans:textns, a:"style-name"}, {ens:textns, + en:"index-entry-span", ans:textns, a:"style-name"}, {ens:textns, en:"index-entry-tab-stop", ans:textns, a:"style-name"}, {ens:textns, en:"index-entry-text", ans:textns, a:"style-name"}, {ens:textns, en:"index-title-template", ans:textns, a:"style-name"}, {ens:textns, en:"list-level-style-bullet", ans:textns, a:"style-name"}, {ens:textns, en:"outline-level-style", ans:textns, a:"style-name"}], "paragraph":[{ens:drawns, en:"caption", ans:drawns, a:"text-style-name"}, {ens:drawns, en:"circle", ans:drawns, + a:"text-style-name"}, {ens:drawns, en:"connector", ans:drawns, a:"text-style-name"}, {ens:drawns, en:"control", ans:drawns, a:"text-style-name"}, {ens:drawns, en:"custom-shape", ans:drawns, a:"text-style-name"}, {ens:drawns, en:"ellipse", ans:drawns, a:"text-style-name"}, {ens:drawns, en:"frame", ans:drawns, a:"text-style-name"}, {ens:drawns, en:"line", ans:drawns, a:"text-style-name"}, {ens:drawns, en:"measure", ans:drawns, a:"text-style-name"}, {ens:drawns, en:"path", ans:drawns, a:"text-style-name"}, + {ens:drawns, en:"polygon", ans:drawns, a:"text-style-name"}, {ens:drawns, en:"polyline", ans:drawns, a:"text-style-name"}, {ens:drawns, en:"rect", ans:drawns, a:"text-style-name"}, {ens:drawns, en:"regular-polygon", ans:drawns, a:"text-style-name"}, {ens:officens, en:"annotation", ans:drawns, a:"text-style-name"}, {ens:formns, en:"column", ans:formns, a:"text-style-name"}, {ens:stylens, en:"style", ans:stylens, a:"next-style-name"}, {ens:tablens, en:"body", ans:tablens, a:"paragraph-style-name"}, + {ens:tablens, en:"even-columns", ans:tablens, a:"paragraph-style-name"}, {ens:tablens, en:"even-rows", ans:tablens, a:"paragraph-style-name"}, {ens:tablens, en:"first-column", ans:tablens, a:"paragraph-style-name"}, {ens:tablens, en:"first-row", ans:tablens, a:"paragraph-style-name"}, {ens:tablens, en:"last-column", ans:tablens, a:"paragraph-style-name"}, {ens:tablens, en:"last-row", ans:tablens, a:"paragraph-style-name"}, {ens:tablens, en:"odd-columns", ans:tablens, a:"paragraph-style-name"}, + {ens:tablens, en:"odd-rows", ans:tablens, a:"paragraph-style-name"}, {ens:textns, en:"notes-configuration", ans:textns, a:"default-style-name"}, {ens:textns, en:"alphabetical-index-entry-template", ans:textns, a:"style-name"}, {ens:textns, en:"bibliography-entry-template", ans:textns, a:"style-name"}, {ens:textns, en:"h", ans:textns, a:"style-name"}, {ens:textns, en:"illustration-index-entry-template", ans:textns, a:"style-name"}, {ens:textns, en:"index-source-style", ans:textns, a:"style-name"}, + {ens:textns, en:"object-index-entry-template", ans:textns, a:"style-name"}, {ens:textns, en:"p", ans:textns, a:"style-name"}, {ens:textns, en:"table-index-entry-template", ans:textns, a:"style-name"}, {ens:textns, en:"table-of-content-entry-template", ans:textns, a:"style-name"}, {ens:textns, en:"table-index-entry-template", ans:textns, a:"style-name"}, {ens:textns, en:"user-index-entry-template", ans:textns, a:"style-name"}, {ens:stylens, en:"page-layout-properties", ans:stylens, a:"register-truth-ref-style-name"}], + "chart":[{ens:chartns, en:"axis", ans:chartns, a:"style-name"}, {ens:chartns, en:"chart", ans:chartns, a:"style-name"}, {ens:chartns, en:"data-label", ans:chartns, a:"style-name"}, {ens:chartns, en:"data-point", ans:chartns, a:"style-name"}, {ens:chartns, en:"equation", ans:chartns, a:"style-name"}, {ens:chartns, en:"error-indicator", ans:chartns, a:"style-name"}, {ens:chartns, en:"floor", ans:chartns, a:"style-name"}, {ens:chartns, en:"footer", ans:chartns, a:"style-name"}, {ens:chartns, en:"grid", + ans:chartns, a:"style-name"}, {ens:chartns, en:"legend", ans:chartns, a:"style-name"}, {ens:chartns, en:"mean-value", ans:chartns, a:"style-name"}, {ens:chartns, en:"plot-area", ans:chartns, a:"style-name"}, {ens:chartns, en:"regression-curve", ans:chartns, a:"style-name"}, {ens:chartns, en:"series", ans:chartns, a:"style-name"}, {ens:chartns, en:"stock-gain-marker", ans:chartns, a:"style-name"}, {ens:chartns, en:"stock-loss-marker", ans:chartns, a:"style-name"}, {ens:chartns, en:"stock-range-line", + ans:chartns, a:"style-name"}, {ens:chartns, en:"subtitle", ans:chartns, a:"style-name"}, {ens:chartns, en:"title", ans:chartns, a:"style-name"}, {ens:chartns, en:"wall", ans:chartns, a:"style-name"}], "section":[{ens:textns, en:"alphabetical-index", ans:textns, a:"style-name"}, {ens:textns, en:"bibliography", ans:textns, a:"style-name"}, {ens:textns, en:"illustration-index", ans:textns, a:"style-name"}, {ens:textns, en:"index-title", ans:textns, a:"style-name"}, {ens:textns, en:"object-index", + ans:textns, a:"style-name"}, {ens:textns, en:"section", ans:textns, a:"style-name"}, {ens:textns, en:"table-of-content", ans:textns, a:"style-name"}, {ens:textns, en:"table-index", ans:textns, a:"style-name"}, {ens:textns, en:"user-index", ans:textns, a:"style-name"}], "ruby":[{ens:textns, en:"ruby", ans:textns, a:"style-name"}], "table":[{ens:dbns, en:"query", ans:dbns, a:"style-name"}, {ens:dbns, en:"table-representation", ans:dbns, a:"style-name"}, {ens:tablens, en:"background", ans:tablens, + a:"style-name"}, {ens:tablens, en:"table", ans:tablens, a:"style-name"}], "table-column":[{ens:dbns, en:"column", ans:dbns, a:"style-name"}, {ens:tablens, en:"table-column", ans:tablens, a:"style-name"}], "table-row":[{ens:dbns, en:"query", ans:dbns, a:"default-row-style-name"}, {ens:dbns, en:"table-representation", ans:dbns, a:"default-row-style-name"}, {ens:tablens, en:"table-row", ans:tablens, a:"style-name"}], "table-cell":[{ens:dbns, en:"column", ans:dbns, a:"default-cell-style-name"}, {ens:tablens, + en:"table-column", ans:tablens, a:"default-cell-style-name"}, {ens:tablens, en:"table-row", ans:tablens, a:"default-cell-style-name"}, {ens:tablens, en:"body", ans:tablens, a:"style-name"}, {ens:tablens, en:"covered-table-cell", ans:tablens, a:"style-name"}, {ens:tablens, en:"even-columns", ans:tablens, a:"style-name"}, {ens:tablens, en:"covered-table-cell", ans:tablens, a:"style-name"}, {ens:tablens, en:"even-columns", ans:tablens, a:"style-name"}, {ens:tablens, en:"even-rows", ans:tablens, a:"style-name"}, + {ens:tablens, en:"first-column", ans:tablens, a:"style-name"}, {ens:tablens, en:"first-row", ans:tablens, a:"style-name"}, {ens:tablens, en:"last-column", ans:tablens, a:"style-name"}, {ens:tablens, en:"last-row", ans:tablens, a:"style-name"}, {ens:tablens, en:"odd-columns", ans:tablens, a:"style-name"}, {ens:tablens, en:"odd-rows", ans:tablens, a:"style-name"}, {ens:tablens, en:"table-cell", ans:tablens, a:"style-name"}], "graphic":[{ens:dr3dns, en:"cube", ans:drawns, a:"style-name"}, {ens:dr3dns, + en:"extrude", ans:drawns, a:"style-name"}, {ens:dr3dns, en:"rotate", ans:drawns, a:"style-name"}, {ens:dr3dns, en:"scene", ans:drawns, a:"style-name"}, {ens:dr3dns, en:"sphere", ans:drawns, a:"style-name"}, {ens:drawns, en:"caption", ans:drawns, a:"style-name"}, {ens:drawns, en:"circle", ans:drawns, a:"style-name"}, {ens:drawns, en:"connector", ans:drawns, a:"style-name"}, {ens:drawns, en:"control", ans:drawns, a:"style-name"}, {ens:drawns, en:"custom-shape", ans:drawns, a:"style-name"}, {ens:drawns, + en:"ellipse", ans:drawns, a:"style-name"}, {ens:drawns, en:"frame", ans:drawns, a:"style-name"}, {ens:drawns, en:"g", ans:drawns, a:"style-name"}, {ens:drawns, en:"line", ans:drawns, a:"style-name"}, {ens:drawns, en:"measure", ans:drawns, a:"style-name"}, {ens:drawns, en:"page-thumbnail", ans:drawns, a:"style-name"}, {ens:drawns, en:"path", ans:drawns, a:"style-name"}, {ens:drawns, en:"polygon", ans:drawns, a:"style-name"}, {ens:drawns, en:"polyline", ans:drawns, a:"style-name"}, {ens:drawns, en:"rect", + ans:drawns, a:"style-name"}, {ens:drawns, en:"regular-polygon", ans:drawns, a:"style-name"}, {ens:officens, en:"annotation", ans:drawns, a:"style-name"}], "presentation":[{ens:dr3dns, en:"cube", ans:presentationns, a:"style-name"}, {ens:dr3dns, en:"extrude", ans:presentationns, a:"style-name"}, {ens:dr3dns, en:"rotate", ans:presentationns, a:"style-name"}, {ens:dr3dns, en:"scene", ans:presentationns, a:"style-name"}, {ens:dr3dns, en:"sphere", ans:presentationns, a:"style-name"}, {ens:drawns, en:"caption", + ans:presentationns, a:"style-name"}, {ens:drawns, en:"circle", ans:presentationns, a:"style-name"}, {ens:drawns, en:"connector", ans:presentationns, a:"style-name"}, {ens:drawns, en:"control", ans:presentationns, a:"style-name"}, {ens:drawns, en:"custom-shape", ans:presentationns, a:"style-name"}, {ens:drawns, en:"ellipse", ans:presentationns, a:"style-name"}, {ens:drawns, en:"frame", ans:presentationns, a:"style-name"}, {ens:drawns, en:"g", ans:presentationns, a:"style-name"}, {ens:drawns, en:"line", + ans:presentationns, a:"style-name"}, {ens:drawns, en:"measure", ans:presentationns, a:"style-name"}, {ens:drawns, en:"page-thumbnail", ans:presentationns, a:"style-name"}, {ens:drawns, en:"path", ans:presentationns, a:"style-name"}, {ens:drawns, en:"polygon", ans:presentationns, a:"style-name"}, {ens:drawns, en:"polyline", ans:presentationns, a:"style-name"}, {ens:drawns, en:"rect", ans:presentationns, a:"style-name"}, {ens:drawns, en:"regular-polygon", ans:presentationns, a:"style-name"}, {ens:officens, + en:"annotation", ans:presentationns, a:"style-name"}], "drawing-page":[{ens:drawns, en:"page", ans:drawns, a:"style-name"}, {ens:presentationns, en:"notes", ans:drawns, a:"style-name"}, {ens:stylens, en:"handout-master", ans:drawns, a:"style-name"}, {ens:stylens, en:"master-page", ans:drawns, a:"style-name"}], "list-style":[{ens:textns, en:"list", ans:textns, a:"style-name"}, {ens:textns, en:"numbered-paragraph", ans:textns, a:"style-name"}, {ens:textns, en:"list-item", ans:textns, a:"style-override"}, + {ens:stylens, en:"style", ans:stylens, a:"list-style-name"}], "data":[{ens:stylens, en:"style", ans:stylens, a:"data-style-name"}, {ens:stylens, en:"style", ans:stylens, a:"percentage-data-style-name"}, {ens:presentationns, en:"date-time-decl", ans:stylens, a:"data-style-name"}, {ens:textns, en:"creation-date", ans:stylens, a:"data-style-name"}, {ens:textns, en:"creation-time", ans:stylens, a:"data-style-name"}, {ens:textns, en:"database-display", ans:stylens, a:"data-style-name"}, {ens:textns, + en:"date", ans:stylens, a:"data-style-name"}, {ens:textns, en:"editing-duration", ans:stylens, a:"data-style-name"}, {ens:textns, en:"expression", ans:stylens, a:"data-style-name"}, {ens:textns, en:"meta-field", ans:stylens, a:"data-style-name"}, {ens:textns, en:"modification-date", ans:stylens, a:"data-style-name"}, {ens:textns, en:"modification-time", ans:stylens, a:"data-style-name"}, {ens:textns, en:"print-date", ans:stylens, a:"data-style-name"}, {ens:textns, en:"print-time", ans:stylens, + a:"data-style-name"}, {ens:textns, en:"table-formula", ans:stylens, a:"data-style-name"}, {ens:textns, en:"time", ans:stylens, a:"data-style-name"}, {ens:textns, en:"user-defined", ans:stylens, a:"data-style-name"}, {ens:textns, en:"user-field-get", ans:stylens, a:"data-style-name"}, {ens:textns, en:"user-field-input", ans:stylens, a:"data-style-name"}, {ens:textns, en:"variable-get", ans:stylens, a:"data-style-name"}, {ens:textns, en:"variable-input", ans:stylens, a:"data-style-name"}, {ens:textns, + en:"variable-set", ans:stylens, a:"data-style-name"}], "page-layout":[{ens:presentationns, en:"notes", ans:stylens, a:"page-layout-name"}, {ens:stylens, en:"handout-master", ans:stylens, a:"page-layout-name"}, {ens:stylens, en:"master-page", ans:stylens, a:"page-layout-name"}]}, elements, xpath = new xmldom.XPath; function hasDerivedStyles(odfbody, nsResolver, styleElement) { var nodes, xp, resolver = nsResolver("style"), styleName = styleElement.getAttributeNS(resolver, "name"), styleFamily = styleElement.getAttributeNS(resolver, "family"); xp = "//style:*[@style:parent-style-name='" + styleName + "'][@style:family='" + styleFamily + "']"; @@ -6332,8 +6435,9 @@ odf.StyleInfo = function StyleInfo() { @source: http://gitorious.org/webodf/webodf/ */ runtime.loadClass("core.DomUtils"); +runtime.loadClass("odf.Namespaces"); odf.OdfUtils = function OdfUtils() { - var textns = "urn:oasis:names:tc:opendocument:xmlns:text:1.0", drawns = "urn:oasis:names:tc:opendocument:xmlns:drawing:1.0", whitespaceOnly = /^\s*$/, domUtils = new core.DomUtils; + var textns = odf.Namespaces.textns, drawns = odf.Namespaces.drawns, whitespaceOnly = /^\s*$/, domUtils = new core.DomUtils; function isParagraph(e) { var name = e && e.localName; return(name === "p" || name === "h") && e.namespaceURI === textns @@ -6532,6 +6636,12 @@ odf.OdfUtils = function OdfUtils() { return false } this.isSignificantWhitespace = isSignificantWhitespace; + this.isDowngradableSpaceElement = function(node) { + if(node.namespaceURI === textns && node.localName === "s") { + return scanLeftForNonWhitespace(previousNode(node)) && scanRightForAnyCharacter(nextNode(node)) + } + return false + }; function getFirstNonWhitespaceChild(node) { var child = node && node.firstChild; while(child && child.nodeType === Node.TEXT_NODE && whitespaceOnly.test(child.nodeValue)) { @@ -6847,13 +6957,13 @@ odf.TextStyleApplicator = function TextStyleApplicator(styleNameGenerator, forma return node.localName === "span" && node.namespaceURI === textns } function moveToNewSpan(startNode, limits) { - var document = startNode.ownerDocument, originalContainer = (startNode.parentNode), styledContainer, trailingContainer, moveTrailing, node = startNode, nextNode, loopGuard = new core.LoopWatchDog(1E3); + var document = startNode.ownerDocument, originalContainer = (startNode.parentNode), styledContainer, trailingContainer, moveTrailing, node, nextNode, loopGuard = new core.LoopWatchDog(1E3), styledNodes = []; if(!isTextSpan(originalContainer)) { styledContainer = document.createElementNS(textns, "text:span"); originalContainer.insertBefore(styledContainer, startNode); moveTrailing = false }else { - if(startNode.previousSibling && !domUtils.rangeContainsNode(limits, startNode.previousSibling)) { + if(startNode.previousSibling && !domUtils.rangeContainsNode(limits, (originalContainer.firstChild))) { styledContainer = originalContainer.cloneNode(false); originalContainer.parentNode.insertBefore(styledContainer, originalContainer.nextSibling); moveTrailing = true @@ -6862,14 +6972,18 @@ odf.TextStyleApplicator = function TextStyleApplicator(styleNameGenerator, forma moveTrailing = true } } - while(node && (node === startNode || domUtils.rangeContainsNode(limits, node))) { + styledNodes.push(startNode); + node = startNode.nextSibling; + while(node && domUtils.rangeContainsNode(limits, node)) { loopGuard.check(); - nextNode = node.nextSibling; + styledNodes.push(node); + node = node.nextSibling + } + styledNodes.forEach(function(node) { if(node.parentNode !== styledContainer) { styledContainer.appendChild(node) } - node = nextNode - } + }); if(node && moveTrailing) { trailingContainer = styledContainer.cloneNode(false); styledContainer.parentNode.insertBefore(trailingContainer, styledContainer.nextSibling); @@ -7038,14 +7152,14 @@ odf.Style2CSS = function Style2CSS() { if(name) { namepart = "[" + prefix + '|style-name="' + name + '"]' }else { - namepart = "[" + prefix + "|style-name]" + namepart = "" } if(prefix === "presentation") { prefix = "draw"; if(name) { namepart = '[presentation|style-name="' + name + '"]' }else { - namepart = "[presentation|style-name]" + namepart = "" } } selector = prefix + "|" + familytagnames[family].join(namepart + "," + prefix + "|") + namepart; @@ -7507,6 +7621,40 @@ odf.Style2CSS = function Style2CSS() { } } }; +/* + + 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. + + As additional permission under GNU AGPL version 3 section 7, you + may distribute non-source (e.g., minimized or compacted) forms of + that code without the copy of the GNU GPL normally required by + section 4, provided you include this license notice and a URL + through which recipients can access the Corresponding Source. + + As a special exception to the AGPL, any HTML file which merely makes function + calls to this code, and for that purpose includes it by reference shall be + deemed a separate work for copyright law purposes. In addition, the copyright + holders of this code give you permission to combine this code with free + software libraries that are released under the GNU LGPL. You may copy and + distribute such a system following the terms of the GNU AGPL for this code + and the LGPL for the libraries. If you modify this code, you may extend this + exception to your version of the code, but you are not obligated to do so. + If you do not wish to do so, delete this exception statement from your + version. + + This license applies to this entire compilation. + @licend + @source: http://www.webodf.org/ + @source: http://gitorious.org/webodf/webodf/ +*/ runtime.loadClass("core.Base64"); runtime.loadClass("core.Zip"); runtime.loadClass("xmldom.LSSerializer"); @@ -8347,7 +8495,7 @@ odf.Formatting = function Formatting() { return inheritedPropertiesMap } this.getInheritedStyleAttributes = getInheritedStyleAttributes; - this.getFirstNamedParentStyleNameOrSelf = function(styleName) { + this.getFirstCommonParentStyleNameOrSelf = function(styleName) { var automaticStyleElementList = odfContainer.rootElement.automaticStyles, styleElementList = odfContainer.rootElement.styles, styleElement; styleElement = getStyleElement(styleName, "paragraph", [automaticStyleElementList]); while(styleElement) { @@ -9093,7 +9241,7 @@ odf.OdfCanvas = function() { odf.OdfCanvas = function OdfCanvas(element) { runtime.assert(element !== null && element !== undefined, "odf.OdfCanvas constructor needs DOM element"); runtime.assert(element.ownerDocument !== null && element.ownerDocument !== undefined, "odf.OdfCanvas constructor needs DOM"); - var self = this, doc = (element.ownerDocument), odfcontainer, formatting = new odf.Formatting, selectionWatcher = new SelectionWatcher(element), pageSwitcher, sizer, annotationsPane, allowAnnotations = false, annotationManager, webodfcss, fontcss, stylesxmlcss, positioncss, editable = false, zoomLevel = 1, eventHandlers = {}, editparagraph, loadingQueue = new LoadingQueue; + var self = this, doc = (element.ownerDocument), odfcontainer, formatting = new odf.Formatting, selectionWatcher = new SelectionWatcher(element), pageSwitcher, sizer, annotationsPane, allowAnnotations = false, annotationManager, webodfcss, fontcss, stylesxmlcss, positioncss, zoomLevel = 1, eventHandlers = {}, loadingQueue = new LoadingQueue; function loadImages(container, odffragment, stylesheet) { var i, images, node; function loadImage(name, container, node, stylesheet) { @@ -9275,73 +9423,9 @@ odf.OdfCanvas = function() { } this["load"] = load; this.load = load; - function stopEditing() { - if(!editparagraph) { - return - } - var fragment = editparagraph.ownerDocument.createDocumentFragment(); - while(editparagraph.firstChild) { - fragment.insertBefore(editparagraph.firstChild, null) - } - editparagraph.parentNode.replaceChild(fragment, editparagraph) - } this.save = function(callback) { - stopEditing(); odfcontainer.save(callback) }; - function cancelEvent(event) { - if(event.preventDefault) { - event.preventDefault(); - event.stopPropagation() - }else { - event.returnValue = false; - event.cancelBubble = true - } - } - function processClick(evt) { - evt = evt || window.event; - var e = evt.target, selection = window.getSelection(), range = selection.rangeCount > 0 ? selection.getRangeAt(0) : null, startContainer = range && range.startContainer, startOffset = range && range.startOffset, endContainer = range && range.endContainer, endOffset = range && range.endOffset, clickdoc, ns; - while(e && !((e.localName === "p" || e.localName === "h") && e.namespaceURI === textns)) { - e = e.parentNode - } - if(!editable) { - return - } - if(!e || e.parentNode === editparagraph) { - return - } - clickdoc = e.ownerDocument; - ns = clickdoc.documentElement.namespaceURI; - if(!editparagraph) { - editparagraph = clickdoc.createElementNS(ns, "p"); - editparagraph.style.margin = "0px"; - editparagraph.style.padding = "0px"; - editparagraph.style.border = "0px"; - editparagraph.setAttribute("contenteditable", true) - }else { - if(editparagraph.parentNode) { - stopEditing() - } - } - e.parentNode.replaceChild(editparagraph, e); - editparagraph.appendChild(e); - editparagraph.focus(); - if(range) { - selection.removeAllRanges(); - range = e.ownerDocument.createRange(); - range.setStart(startContainer, startOffset); - range.setEnd(endContainer, endOffset); - selection.addRange(range) - } - cancelEvent(evt) - } - this.setEditable = function(iseditable) { - listenEvent(element, "click", processClick); - editable = iseditable; - if(!editable) { - stopEditing() - } - }; this.addListener = function(eventName, handler) { switch(eventName) { case "selectionchange": @@ -10254,7 +10338,7 @@ ops.OpInsertTable = function OpInsertTable() { @source: http://gitorious.org/webodf/webodf/ */ ops.OpInsertText = function OpInsertText() { - var self = this, optype = "InsertText", memberid, timestamp, position, text; + var self = this, space = " ", tab = "\t", optype = "InsertText", memberid, timestamp, position, text; this.init = function(data) { memberid = data.memberid; timestamp = data.timestamp; @@ -10312,63 +10396,66 @@ ops.OpInsertText = function OpInsertText() { } return result }; - function triggerLayoutInWebkit(odtDocument, textNode) { - var parent = textNode.parentNode, next = textNode.nextSibling, impactedCursors = []; - odtDocument.getCursors().forEach(function(cursor) { - var range = cursor.getSelectedRange(); - if(range && (range.startContainer === textNode || range.endContainer === textNode)) { - impactedCursors.push({cursor:cursor, startContainer:range.startContainer, startOffset:range.startOffset, endContainer:range.endContainer, endOffset:range.endOffset}) - } - }); + function triggerLayoutInWebkit(textNode) { + var parent = textNode.parentNode, next = textNode.nextSibling; parent.removeChild(textNode); - parent.insertBefore(textNode, next); - impactedCursors.forEach(function(entry) { - var range = entry.cursor.getSelectedRange(); - range.setStart(entry.startContainer, entry.startOffset); - range.setEnd(entry.endContainer, entry.endOffset) - }) + parent.insertBefore(textNode, next) + } + function requiresSpaceElement(text, index) { + return text[index] === space && (index === 0 || text[index - 1] === space) } this.execute = function(odtDocument) { - var domPosition, previousNode, parent, refNode, ownerDocument = odtDocument.getDOM(), paragraphElement, textns = "urn:oasis:names:tc:opendocument:xmlns:text:1.0", space = " ", tab = "\t", append = true, startIndex = 0, textToInsert, spaceTag, node, i; + var domPosition, previousNode, parentElement, nextNode, ownerDocument = odtDocument.getDOM(), paragraphElement, textns = "urn:oasis:names:tc:opendocument:xmlns:text:1.0", toInsertIndex = 0, spaceTag, spaceElement, i; + function insertTextNode(toInsertText) { + parentElement.insertBefore(ownerDocument.createTextNode(toInsertText), nextNode) + } + odtDocument.upgradeWhitespacesAtPosition(position); domPosition = odtDocument.getPositionInTextNode(position, memberid); if(domPosition) { previousNode = domPosition.textNode; - parent = previousNode.parentNode; - refNode = previousNode.nextSibling; + nextNode = previousNode.nextSibling; + parentElement = previousNode.parentNode; paragraphElement = odtDocument.getParagraphElement(previousNode); - if(domPosition.offset !== previousNode.length) { - refNode = previousNode.splitText(domPosition.offset) - } for(i = 0;i < text.length;i += 1) { - if(text[i] === space || text[i] === tab) { - if(startIndex < i) { - textToInsert = text.substring(startIndex, i); - if(append) { - previousNode.appendData(textToInsert) - }else { - parent.insertBefore(ownerDocument.createTextNode(textToInsert), refNode) + if(requiresSpaceElement(text, i) || text[i] === tab) { + if(toInsertIndex === 0) { + if(domPosition.offset !== previousNode.length) { + nextNode = previousNode.splitText(domPosition.offset) + } + if(0 < i) { + previousNode.appendData(text.substring(0, i)) + } + }else { + if(toInsertIndex < i) { + insertTextNode(text.substring(toInsertIndex, i)) } } - startIndex = i + 1; - append = false; + toInsertIndex = i + 1; spaceTag = text[i] === space ? "text:s" : "text:tab"; - node = ownerDocument.createElementNS(textns, spaceTag); - node.appendChild(ownerDocument.createTextNode(text[i])); - parent.insertBefore(node, refNode) + spaceElement = ownerDocument.createElementNS(textns, spaceTag); + spaceElement.appendChild(ownerDocument.createTextNode(text[i])); + parentElement.insertBefore(spaceElement, nextNode) } } - textToInsert = text.substring(startIndex); - if(textToInsert.length > 0) { - if(append) { - previousNode.appendData(textToInsert) - }else { - parent.insertBefore(ownerDocument.createTextNode(textToInsert), refNode) + if(toInsertIndex === 0) { + previousNode.insertData(domPosition.offset, text) + }else { + if(toInsertIndex < text.length) { + insertTextNode(text.substring(toInsertIndex)) } } - triggerLayoutInWebkit(odtDocument, previousNode); + triggerLayoutInWebkit(previousNode); if(previousNode.length === 0) { previousNode.parentNode.removeChild(previousNode) } + if(position > 0) { + odtDocument.downgradeWhitespacesAtPosition(position - 1); + if(position > 1) { + odtDocument.downgradeWhitespacesAtPosition(position - 2) + } + } + odtDocument.downgradeWhitespacesAtPosition(position); + odtDocument.downgradeWhitespacesAtPosition(position + text.length); odtDocument.getOdfCanvas().refreshSize(); odtDocument.emit(ops.OdtDocument.signalParagraphChanged, {paragraphElement:paragraphElement, memberId:memberid, timeStamp:timestamp}); odtDocument.getOdfCanvas().rerenderAnnotations(); @@ -10580,6 +10667,7 @@ ops.OpRemoveText = function OpRemoveText() { destinationParagraph = paragraphs.reduce(function(destination, paragraph) { return mergeParagraphs(destination, paragraph, collapseRules) }); + odtDocument.downgradeWhitespacesAtPosition(position); odtDocument.fixCursorPositions(); odtDocument.getOdfCanvas().refreshSize(); odtDocument.emit(ops.OdtDocument.signalParagraphChanged, {paragraphElement:destinationParagraph || paragraphElement, memberId:memberid, timeStamp:timestamp}); @@ -10725,6 +10813,9 @@ ops.OpSplitParagraph = function OpSplitParagraph() { if(odfUtils.isListItem(splitChildNode)) { splitChildNode = splitChildNode.childNodes[0] } + if(domPosition.textNode.length === 0) { + domPosition.textNode.parentNode.removeChild(domPosition.textNode) + } odtDocument.fixCursorPositions(memberid); odtDocument.getOdfCanvas().refreshSize(); odtDocument.emit(ops.OdtDocument.signalParagraphChanged, {paragraphElement:paragraphNode, memberId:memberid, timeStamp:timestamp}); @@ -10781,8 +10872,8 @@ ops.OpSetParagraphStyle = function OpSetParagraphStyle() { this.transform = function(otherOp, hasPriority) { var otherOpspec = otherOp.spec(), otherOpType = otherOpspec.optype, result = [self]; switch(otherOpType) { - case "RemoveParagraphStyle": - if(otherOpspec.styleName === styleName) { + case "RemoveStyle": + if(otherOpspec.styleName === styleName && otherOpspec.styleFamily === "paragraph") { styleName = "" } break @@ -10790,21 +10881,19 @@ ops.OpSetParagraphStyle = function OpSetParagraphStyle() { return result }; this.execute = function(odtDocument) { - var domPosition, paragraphNode; - domPosition = odtDocument.getPositionInTextNode(position); - if(domPosition) { - paragraphNode = odtDocument.getParagraphElement(domPosition.textNode); - if(paragraphNode) { - if(styleName !== "") { - paragraphNode.setAttributeNS(textns, "text:style-name", styleName) - }else { - paragraphNode.removeAttributeNS(textns, "style-name") - } - odtDocument.getOdfCanvas().refreshSize(); - odtDocument.emit(ops.OdtDocument.signalParagraphChanged, {paragraphElement:paragraphNode, timeStamp:timestamp, memberId:memberid}); - odtDocument.getOdfCanvas().rerenderAnnotations(); - return true + var iterator, paragraphNode; + iterator = odtDocument.getIteratorAtPosition(position); + paragraphNode = odtDocument.getParagraphElement(iterator.container()); + if(paragraphNode) { + if(styleName !== "") { + paragraphNode.setAttributeNS(textns, "text:style-name", styleName) + }else { + paragraphNode.removeAttributeNS(textns, "style-name") } + odtDocument.getOdfCanvas().refreshSize(); + odtDocument.emit(ops.OdtDocument.signalParagraphChanged, {paragraphElement:paragraphNode, timeStamp:timestamp, memberId:memberid}); + odtDocument.getOdfCanvas().rerenderAnnotations(); + return true } return false }; @@ -10945,11 +11034,13 @@ ops.OpUpdateParagraphStyle = function OpUpdateParagraphStyle() { } } break; - case "RemoveParagraphStyle": - if(otherOpspec.styleName === styleName) { - result = [] - }else { - dropStyleReferencingAttributes(otherOpspec.styleName) + case "RemoveStyle": + if(otherOpspec.styleFamily === "paragraph") { + if(otherOpspec.styleName === styleName) { + result = [] + }else { + dropStyleReferencingAttributes(otherOpspec.styleName) + } } break } @@ -10957,7 +11048,11 @@ ops.OpUpdateParagraphStyle = function OpUpdateParagraphStyle() { }; this.execute = function(odtDocument) { var formatting = odtDocument.getFormatting(), styleNode, paragraphPropertiesNode, textPropertiesNode; - styleNode = odtDocument.getParagraphStyleElement(styleName); + if(styleName !== "") { + styleNode = odtDocument.getParagraphStyleElement(styleName) + }else { + styleNode = formatting.getDefaultStyleElement("paragraph") + } if(styleNode) { paragraphPropertiesNode = styleNode.getElementsByTagNameNS(stylens, "paragraph-properties")[0]; textPropertiesNode = styleNode.getElementsByTagNameNS(stylens, "text-properties")[0]; @@ -11025,12 +11120,13 @@ ops.OpUpdateParagraphStyle = function OpUpdateParagraphStyle() { @source: http://gitorious.org/webodf/webodf/ */ runtime.loadClass("odf.Namespaces"); -ops.OpAddParagraphStyle = function OpAddParagraphStyle() { - var self = this, memberid, timestamp, styleName, isAutomaticStyle, setProperties, stylens = odf.Namespaces.stylens; +ops.OpAddStyle = function OpAddStyle() { + var self = this, memberid, timestamp, styleName, styleFamily, isAutomaticStyle, setProperties, stylens = odf.Namespaces.stylens; this.init = function(data) { memberid = data.memberid; timestamp = data.timestamp; styleName = data.styleName; + styleFamily = data.styleFamily; isAutomaticStyle = data.isAutomaticStyle === "true" || data.isAutomaticStyle === true; setProperties = data.setProperties }; @@ -11045,7 +11141,7 @@ ops.OpAddParagraphStyle = function OpAddParagraphStyle() { } this.transform = function(otherOp, hasPriority) { var otherOpspec = otherOp.spec(); - if(otherOpspec.optype === "RemoveParagraphStyle") { + if(otherOpspec.optype === "RemoveStyle" && otherOpspec.styleFamily === styleFamily) { dropStyleReferencingAttributes(otherOpspec.styleName) } return[self] @@ -11058,7 +11154,7 @@ ops.OpAddParagraphStyle = function OpAddParagraphStyle() { if(setProperties) { formatting.updateStyle(styleNode, setProperties) } - styleNode.setAttributeNS(stylens, "style:family", "paragraph"); + styleNode.setAttributeNS(stylens, "style:family", styleFamily); styleNode.setAttributeNS(stylens, "style:name", styleName); if(isAutomaticStyle) { odfContainer.rootElement.automaticStyles.appendChild(styleNode) @@ -11067,12 +11163,12 @@ ops.OpAddParagraphStyle = function OpAddParagraphStyle() { } odtDocument.getOdfCanvas().refreshCSS(); if(!isAutomaticStyle) { - odtDocument.emit(ops.OdtDocument.signalCommonParagraphStyleCreated, styleName) + odtDocument.emit(ops.OdtDocument.signalCommonStyleCreated, {name:styleName, family:styleFamily}) } return true }; this.spec = function() { - return{optype:"AddParagraphStyle", memberid:memberid, timestamp:timestamp, styleName:styleName, isAutomaticStyle:isAutomaticStyle, setProperties:setProperties} + return{optype:"AddStyle", memberid:memberid, timestamp:timestamp, styleName:styleName, styleFamily:styleFamily, isAutomaticStyle:isAutomaticStyle, setProperties:setProperties} } }; /* @@ -11109,12 +11205,13 @@ ops.OpAddParagraphStyle = function OpAddParagraphStyle() { @source: http://www.webodf.org/ @source: http://gitorious.org/webodf/webodf/ */ -ops.OpRemoveParagraphStyle = function OpRemoveParagraphStyle() { - var self = this, optype = "RemoveParagraphStyle", memberid, timestamp, styleName; +ops.OpRemoveStyle = function OpRemoveStyle() { + var self = this, optype = "RemoveStyle", memberid, timestamp, styleName, styleFamily; this.init = function(data) { memberid = data.memberid; timestamp = data.timestamp; - styleName = data.styleName + styleName = data.styleName; + styleFamily = data.styleFamily }; function getStyleReferencingAttributes(setProperties) { var attributes = []; @@ -11131,22 +11228,32 @@ ops.OpRemoveParagraphStyle = function OpRemoveParagraphStyle() { var otherOpspec = otherOp.spec(), otherOpType = otherOpspec.optype, helperOp, setAttributes, result = [self]; switch(otherOpType) { case optype: - if(otherOpspec.styleName === styleName) { + if(otherOpspec.styleName === styleName && otherOpspec.styleFamily === styleFamily) { result = [] } break; - case "AddParagraphStyle": - ; case "UpdateParagraphStyle": - setAttributes = getStyleReferencingAttributes(otherOpspec.setProperties); - if(setAttributes.length > 0) { - helperOp = new ops.OpUpdateParagraphStyle; - helperOp.init({memberid:memberid, timestamp:timestamp, styleName:otherOpspec.styleName, removedProperties:{attributes:setAttributes.join(",")}}); - result = [helperOp, self] + if(styleFamily === "paragraph") { + setAttributes = getStyleReferencingAttributes(otherOpspec.setProperties); + if(setAttributes.length > 0) { + helperOp = new ops.OpUpdateParagraphStyle; + helperOp.init({memberid:memberid, timestamp:timestamp, styleName:otherOpspec.styleName, removedProperties:{attributes:setAttributes.join(",")}}); + result = [helperOp, self] + } + } + break; + case "AddStyle": + if(otherOpspec.styleFamily === styleFamily) { + setAttributes = getStyleReferencingAttributes(otherOpspec.setProperties); + if(setAttributes.length > 0) { + helperOp = new ops.OpUpdateParagraphStyle; + helperOp.init({memberid:memberid, timestamp:timestamp, styleName:otherOpspec.styleName, removedProperties:{attributes:setAttributes.join(",")}}); + result = [helperOp, self] + } } break; case "SetParagraphStyle": - if(otherOpspec.styleName === styleName) { + if(styleFamily === "paragraph" && otherOpspec.styleName === styleName) { otherOpspec.styleName = ""; helperOp = new ops.OpSetParagraphStyle; helperOp.init(otherOpspec); @@ -11157,17 +11264,17 @@ ops.OpRemoveParagraphStyle = function OpRemoveParagraphStyle() { return result }; this.execute = function(odtDocument) { - var styleNode = odtDocument.getParagraphStyleElement(styleName); + var styleNode = odtDocument.getStyleElement(styleName, styleFamily); if(!styleNode) { return false } styleNode.parentNode.removeChild(styleNode); odtDocument.getOdfCanvas().refreshCSS(); - odtDocument.emit(ops.OdtDocument.signalCommonParagraphStyleDeleted, styleName); + odtDocument.emit(ops.OdtDocument.signalCommonStyleDeleted, {name:styleName, family:styleFamily}); return true }; this.spec = function() { - return{optype:optype, memberid:memberid, timestamp:timestamp, styleName:styleName} + return{optype:optype, memberid:memberid, timestamp:timestamp, styleName:styleName, styleFamily:styleFamily} } }; /* @@ -11284,13 +11391,17 @@ ops.OpAddAnnotation = function OpAddAnnotation() { return annotationEnd } function insertNodeAtPosition(odtDocument, node, insertPosition) { - var previousNode, domPosition = odtDocument.getPositionInTextNode(insertPosition, memberid); + var previousNode, parentNode, domPosition = odtDocument.getPositionInTextNode(insertPosition, memberid); if(domPosition) { previousNode = domPosition.textNode; + parentNode = previousNode.parentNode; if(domPosition.offset !== previousNode.length) { previousNode.splitText(domPosition.offset) } - previousNode.parentNode.insertBefore(node, previousNode.nextSibling) + parentNode.insertBefore(node, previousNode.nextSibling); + if(previousNode.length === 0) { + parentNode.removeChild(previousNode) + } } } function countSteps(number, stepCounter, positionFilter) { @@ -11452,8 +11563,8 @@ runtime.loadClass("ops.OpRemoveText"); runtime.loadClass("ops.OpSplitParagraph"); runtime.loadClass("ops.OpSetParagraphStyle"); runtime.loadClass("ops.OpUpdateParagraphStyle"); -runtime.loadClass("ops.OpAddParagraphStyle"); -runtime.loadClass("ops.OpRemoveParagraphStyle"); +runtime.loadClass("ops.OpAddStyle"); +runtime.loadClass("ops.OpRemoveStyle"); runtime.loadClass("ops.OpAddAnnotation"); runtime.loadClass("ops.OpRemoveAnnotation"); ops.OperationFactory = function OperationFactory() { @@ -11475,18 +11586,19 @@ ops.OperationFactory = function OperationFactory() { } } function init() { - specs = {AddCursor:constructor(ops.OpAddCursor), ApplyDirectStyling:constructor(ops.OpApplyDirectStyling), InsertTable:constructor(ops.OpInsertTable), InsertText:constructor(ops.OpInsertText), RemoveText:constructor(ops.OpRemoveText), SplitParagraph:constructor(ops.OpSplitParagraph), SetParagraphStyle:constructor(ops.OpSetParagraphStyle), UpdateParagraphStyle:constructor(ops.OpUpdateParagraphStyle), AddParagraphStyle:constructor(ops.OpAddParagraphStyle), RemoveParagraphStyle:constructor(ops.OpRemoveParagraphStyle), - MoveCursor:constructor(ops.OpMoveCursor), RemoveCursor:constructor(ops.OpRemoveCursor), AddAnnotation:constructor(ops.OpAddAnnotation), RemoveAnnotation:constructor(ops.OpRemoveAnnotation)} + specs = {AddCursor:constructor(ops.OpAddCursor), ApplyDirectStyling:constructor(ops.OpApplyDirectStyling), InsertTable:constructor(ops.OpInsertTable), InsertText:constructor(ops.OpInsertText), RemoveText:constructor(ops.OpRemoveText), SplitParagraph:constructor(ops.OpSplitParagraph), SetParagraphStyle:constructor(ops.OpSetParagraphStyle), UpdateParagraphStyle:constructor(ops.OpUpdateParagraphStyle), AddStyle:constructor(ops.OpAddStyle), RemoveStyle:constructor(ops.OpRemoveStyle), MoveCursor:constructor(ops.OpMoveCursor), + RemoveCursor:constructor(ops.OpRemoveCursor), AddAnnotation:constructor(ops.OpAddAnnotation), RemoveAnnotation:constructor(ops.OpRemoveAnnotation)} } init() }; runtime.loadClass("core.Cursor"); +runtime.loadClass("core.DomUtils"); runtime.loadClass("core.PositionIterator"); runtime.loadClass("core.PositionFilter"); runtime.loadClass("core.LoopWatchDog"); runtime.loadClass("odf.OdfUtils"); gui.SelectionMover = function SelectionMover(cursor, rootNode) { - var odfUtils, positionIterator, cachedXOffset, timeoutHandle, FILTER_ACCEPT = core.PositionFilter.FilterResult.FILTER_ACCEPT; + var odfUtils, domUtils, positionIterator, cachedXOffset, timeoutHandle, FILTER_ACCEPT = core.PositionFilter.FilterResult.FILTER_ACCEPT; function getIteratorAtCursor() { positionIterator.setUnfilteredPosition(cursor.getNode(), 0); return positionIterator @@ -11729,41 +11841,6 @@ gui.SelectionMover = function SelectionMover(cursor, rootNode) { range.detach(); return count } - function getPositionInContainingNode(node, container) { - var offset = 0, n; - while(node.parentNode !== container) { - runtime.assert(node.parentNode !== null, "parent is null"); - node = (node.parentNode) - } - n = container.firstChild; - while(n !== node) { - offset += 1; - n = n.nextSibling - } - return offset - } - function comparePoints(c1, o1, c2, o2) { - if(c1 === c2) { - return o2 - o1 - } - var comparison = c1.compareDocumentPosition(c2); - if(comparison === 2) { - comparison = -1 - }else { - if(comparison === 4) { - comparison = 1 - }else { - if(comparison === 10) { - o1 = getPositionInContainingNode(c1, c2); - comparison = o1 < o2 ? 1 : -1 - }else { - o2 = getPositionInContainingNode(c2, c1); - comparison = o2 < o1 ? -1 : 1 - } - } - } - return comparison - } 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; @@ -11772,7 +11849,7 @@ gui.SelectionMover = function SelectionMover(cursor, rootNode) { runtime.assert(Boolean(targetNode), "SelectionMover.countStepsToPosition: positionIterator.container() returned null"); targetOffset = iterator.unfilteredDomOffset(); iterator.setUnfilteredPosition(c, o); - comparison = comparePoints(targetNode, targetOffset, iterator.container(), iterator.unfilteredDomOffset()); + comparison = domUtils.comparePoints(targetNode, targetOffset, iterator.container(), iterator.unfilteredDomOffset()); if(comparison < 0) { while(iterator.nextPosition()) { watch.check(); @@ -11791,7 +11868,7 @@ gui.SelectionMover = function SelectionMover(cursor, rootNode) { watch.check(); if(filter.acceptPosition(iterator) === FILTER_ACCEPT) { steps -= 1; - if(comparePoints(targetNode, targetOffset, iterator.container(), iterator.unfilteredDomOffset()) <= 0) { + if(domUtils.comparePoints(targetNode, targetOffset, iterator.container(), iterator.unfilteredDomOffset()) <= 0) { break } } @@ -11805,6 +11882,7 @@ gui.SelectionMover = function SelectionMover(cursor, rootNode) { }; function init() { odfUtils = new odf.OdfUtils; + domUtils = new core.DomUtils; positionIterator = gui.SelectionMover.createPositionIterator(rootNode); var range = rootNode.ownerDocument.createRange(); range.setStart(positionIterator.container(), positionIterator.unfilteredDomOffset()); @@ -11870,9 +11948,9 @@ runtime.loadClass("ops.OpInsertText"); runtime.loadClass("ops.OpRemoveText"); runtime.loadClass("ops.OpSplitParagraph"); runtime.loadClass("ops.OpSetParagraphStyle"); -runtime.loadClass("ops.OpAddParagraphStyle"); +runtime.loadClass("ops.OpAddStyle"); runtime.loadClass("ops.OpUpdateParagraphStyle"); -runtime.loadClass("ops.OpRemoveParagraphStyle"); +runtime.loadClass("ops.OpRemoveStyle"); ops.OperationTransformer = function OperationTransformer() { var operationFactory; function transformOpVsOp(opA, opB) { @@ -12154,7 +12232,15 @@ gui.Caret = function Caret(cursor, avatarInitiallyVisible, blinkOnRangeSelect) { this.removeFocus = function() { shouldBlink = false; avatar.markAsFocussed(false); - span.style.opacity = "0" + span.style.opacity = "1" + }; + this.show = function() { + span.style.visibility = "visible"; + avatar.markAsFocussed(true) + }; + this.hide = function() { + span.style.visibility = "hidden"; + avatar.markAsFocussed(false) }; this.setAvatarImageUrl = function(url) { avatar.setImageUrl(url) @@ -12613,7 +12699,7 @@ gui.DirectTextStyler.textStylingChanged = "textStyling/changed"; runtime.loadClass("core.EventNotifier"); runtime.loadClass("core.Utils"); runtime.loadClass("odf.OdfUtils"); -runtime.loadClass("ops.OpAddParagraphStyle"); +runtime.loadClass("ops.OpAddStyle"); runtime.loadClass("ops.OpSetParagraphStyle"); runtime.loadClass("gui.StyleHelper"); gui.DirectParagraphStyler = function DirectParagraphStyler(session, inputMemberId, styleNameGenerator) { @@ -12676,17 +12762,17 @@ gui.DirectParagraphStyler = function DirectParagraphStyler(session, inputMemberI function applyParagraphDirectStyling(applyDirectStyling) { var range = odtDocument.getCursor(inputMemberId).getSelectedRange(), position = odtDocument.getCursorPosition(inputMemberId), paragraphs = odfUtils.getParagraphElements(range), formatting = odtDocument.getFormatting(); paragraphs.forEach(function(paragraph) { - var paragraphStartPoint = position + odtDocument.getDistanceFromCursor(inputMemberId, paragraph, 0), paragraphStyleName = paragraph.getAttributeNS(odf.Namespaces.textns, "style-name"), newParagraphStyleName = styleNameGenerator.generateName(), opAddParagraphStyle, opSetParagraphStyle, paragraphProperties; + var paragraphStartPoint = position + odtDocument.getDistanceFromCursor(inputMemberId, paragraph, 0), paragraphStyleName = paragraph.getAttributeNS(odf.Namespaces.textns, "style-name"), newParagraphStyleName = styleNameGenerator.generateName(), opAddStyle, opSetParagraphStyle, paragraphProperties; paragraphStartPoint += 1; if(paragraphStyleName) { paragraphProperties = formatting.createDerivedStyleObject(paragraphStyleName, "paragraph", {}) } paragraphProperties = applyDirectStyling(paragraphProperties || {}); - opAddParagraphStyle = new ops.OpAddParagraphStyle; - opAddParagraphStyle.init({memberid:inputMemberId, styleName:newParagraphStyleName, isAutomaticStyle:true, setProperties:paragraphProperties}); + opAddStyle = new ops.OpAddStyle; + opAddStyle.init({memberid:inputMemberId, styleName:newParagraphStyleName, styleFamily:"paragraph", isAutomaticStyle:true, setProperties:paragraphProperties}); opSetParagraphStyle = new ops.OpSetParagraphStyle; opSetParagraphStyle.init({memberid:inputMemberId, styleName:newParagraphStyleName, position:paragraphStartPoint}); - session.enqueue(opAddParagraphStyle); + session.enqueue(opAddStyle); session.enqueue(opSetParagraphStyle) }) } @@ -12775,6 +12861,7 @@ runtime.loadClass("gui.KeyboardHandler"); runtime.loadClass("gui.DirectTextStyler"); runtime.loadClass("gui.DirectParagraphStyler"); gui.SessionController = function() { + var FILTER_ACCEPT = core.PositionFilter.FilterResult.FILTER_ACCEPT; gui.SessionController = function SessionController(session, inputMemberId, args) { var window = (runtime.getWindow()), odtDocument = session.getOdtDocument(), utils = new core.Utils, domUtils = new core.DomUtils, odfUtils = new odf.OdfUtils, clipboard = new gui.Clipboard, keyDownHandler = new gui.KeyboardHandler, keyPressHandler = new gui.KeyboardHandler, keyboardMovementsFilter = new core.PositionFilterChain, baseFilter = odtDocument.getPositionFilter(), clickStartedWithinContainer = false, styleNameGenerator = new odf.StyleNameGenerator("auto" + utils.hashString(inputMemberId) + "_", odtDocument.getFormatting()), undoManager = null, directTextStyler = args && args.directStylingEnabled ? new gui.DirectTextStyler(session, inputMemberId) : null, directParagraphStyler = args && args.directStylingEnabled ? new gui.DirectParagraphStyler(session, inputMemberId, styleNameGenerator) : null; @@ -12866,48 +12953,120 @@ gui.SessionController = function() { } return{node:newNode, offset:newOffset} } + function isTextSpan(node) { + return node.namespaceURI === odf.Namespaces.textns && node.localName === "span" + } + 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) { + startPoint = {node:selection.anchorNode, offset:selection.anchorOffset}; + endPoint = {node:selection.focusNode, offset:selection.focusOffset} + }else { + startPoint = {node:selection.focusNode, offset:selection.focusOffset}; + endPoint = {node:selection.anchorNode, offset:selection.anchorOffset} + } + iterator.setUnfilteredPosition(startPoint.node, startPoint.offset); + while(iterator.previousPosition()) { + currentNode = iterator.getCurrentNode(); + if(currentNode.nodeType === Node.TEXT_NODE) { + c = currentNode.data[iterator.unfilteredDomOffset()]; + if(!alphaNumeric.test(c)) { + break + } + }else { + if(!isTextSpan(currentNode)) { + break + } + } + startPoint.node = iterator.container(); + startPoint.offset = iterator.unfilteredDomOffset() + } + iterator.setUnfilteredPosition(endPoint.node, endPoint.offset); + do { + currentNode = iterator.getCurrentNode(); + if(currentNode.nodeType === Node.TEXT_NODE) { + c = currentNode.data[iterator.unfilteredDomOffset()]; + if(!alphaNumeric.test(c)) { + break + } + }else { + if(!isTextSpan(currentNode)) { + break + } + } + }while(iterator.nextPosition()); + endPoint.node = iterator.container(); + endPoint.offset = iterator.unfilteredDomOffset(); + if(isForwardSelection) { + selection.anchorNode = startPoint.node; + selection.anchorOffset = startPoint.offset; + selection.focusNode = endPoint.node; + selection.focusOffset = endPoint.offset + }else { + selection.focusNode = startPoint.node; + selection.focusOffset = startPoint.offset; + selection.anchorNode = endPoint.node; + selection.anchorOffset = endPoint.offset + } + } + function expandToParagraphBoundaries(selection) { + var anchorParagraph = odtDocument.getParagraphElement(selection.anchorNode), focusParagraph = odtDocument.getParagraphElement(selection.focusNode); + if(anchorParagraph) { + selection.anchorNode = anchorParagraph; + selection.anchorOffset = 0 + } + if(focusParagraph) { + selection.focusNode = focusParagraph; + selection.focusOffset = focusParagraph.childNodes.length + } + } + function mutableSelection(selection) { + return{anchorNode:selection.anchorNode, anchorOffset:selection.anchorOffset, focusNode:selection.focusNode, focusOffset:selection.focusOffset} + } function getSelection(e) { - var canvasElement = odtDocument.getOdfCanvas().getElement(), selection = window.getSelection(), anchorNode, anchorOffset, focusNode, focusOffset, anchorNodeInsideCanvas, focusNodeInsideCanvas, caretPos, node; + var canvasElement = odtDocument.getOdfCanvas().getElement(), selection = mutableSelection(window.getSelection()), clickCount = e.detail, anchorNodeInsideCanvas, focusNodeInsideCanvas, caretPos, node; if(selection.anchorNode === null && selection.focusNode === null) { caretPos = caretPositionFromPoint(e.clientX, e.clientY); if(!caretPos) { return null } - anchorNode = (caretPos.container); - anchorOffset = caretPos.offset; - focusNode = anchorNode; - focusOffset = anchorOffset - }else { - anchorNode = (selection.anchorNode); - anchorOffset = selection.anchorOffset; - focusNode = (selection.focusNode); - focusOffset = selection.focusOffset + selection.anchorNode = (caretPos.container); + selection.anchorOffset = caretPos.offset; + selection.focusNode = selection.anchorNode; + selection.focusOffset = selection.anchorOffset } - runtime.assert(anchorNode !== null && focusNode !== null, "anchorNode is null or focusNode is null"); - anchorNodeInsideCanvas = domUtils.containsNode(canvasElement, anchorNode); - focusNodeInsideCanvas = domUtils.containsNode(canvasElement, focusNode); + runtime.assert(selection.anchorNode !== null && selection.focusNode !== null, "anchorNode is null or focusNode is null"); + anchorNodeInsideCanvas = domUtils.containsNode(canvasElement, selection.anchorNode); + focusNodeInsideCanvas = domUtils.containsNode(canvasElement, selection.focusNode); if(!anchorNodeInsideCanvas && !focusNodeInsideCanvas) { return null } if(!anchorNodeInsideCanvas) { - node = findClosestPosition(anchorNode); - anchorNode = node.node; - anchorOffset = node.offset + node = findClosestPosition(selection.anchorNode); + selection.anchorNode = node.node; + selection.anchorOffset = node.offset } if(!focusNodeInsideCanvas) { - node = findClosestPosition(focusNode); - focusNode = node.node; - focusOffset = node.offset + node = findClosestPosition(selection.focusNode); + selection.focusNode = node.node; + selection.focusOffset = node.offset + } + if(clickCount === 2) { + expandToWordBoundaries(selection) + }else { + if(clickCount === 3) { + expandToParagraphBoundaries(selection) + } } canvasElement.focus(); - return{anchorNode:anchorNode, anchorOffset:anchorOffset, focusNode:focusNode, focusOffset:focusOffset} + return selection } 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) === 1) { + if(baseFilter.acceptPosition(iterator) === FILTER_ACCEPT) { if(inside) { break } @@ -12924,7 +13083,7 @@ gui.SessionController = function() { if(!inside && node !== iterator.container()) { break } - if(baseFilter.acceptPosition(iterator) === 1) { + if(baseFilter.acceptPosition(iterator) === FILTER_ACCEPT) { length += 1 } }while(iterator.nextPosition()); @@ -12960,68 +13119,6 @@ gui.SessionController = function() { function handleContextMenu(e) { selectRange(e) } - function isTextSpan(node) { - return node.namespaceURI === odf.Namespaces.textns && node.localName === "span" - } - function selectWord() { - var canvasElement = odtDocument.getOdfCanvas().getElement(), alphaNumeric = /[A-Za-z0-9]/, stepsToStart = 0, stepsToEnd = 0, iterator, cursorNode, oldPosition, currentNode, c, op; - if(!domUtils.containsNode(canvasElement, window.getSelection().focusNode)) { - return - } - iterator = gui.SelectionMover.createPositionIterator(odtDocument.getRootNode()); - cursorNode = odtDocument.getCursor(inputMemberId).getNode(); - iterator.setUnfilteredPosition(cursorNode, 0); - while(iterator.previousPosition()) { - currentNode = iterator.getCurrentNode(); - if(currentNode.nodeType === Node.TEXT_NODE) { - c = currentNode.data[iterator.unfilteredDomOffset()]; - if(!alphaNumeric.test(c)) { - break - } - stepsToStart -= 1 - }else { - if(!isTextSpan(currentNode)) { - break - } - } - } - iterator.setUnfilteredPosition(cursorNode, 0); - do { - currentNode = iterator.getCurrentNode(); - if(currentNode.nodeType === Node.TEXT_NODE) { - c = currentNode.data[iterator.unfilteredDomOffset()]; - if(!alphaNumeric.test(c)) { - break - } - stepsToEnd += 1 - }else { - if(!isTextSpan(currentNode)) { - break - } - } - }while(iterator.nextPosition()); - if(stepsToStart !== 0 || stepsToEnd !== 0) { - oldPosition = odtDocument.getCursorPosition(inputMemberId); - op = createOpMoveCursor(oldPosition + stepsToStart, Math.abs(stepsToStart) + Math.abs(stepsToEnd)); - session.enqueue(op) - } - } - function selectParagraph() { - var canvasElement = odtDocument.getOdfCanvas().getElement(), iterator, paragraphNode, oldPosition, stepsToStart, stepsToEnd, op; - if(!domUtils.containsNode(canvasElement, window.getSelection().focusNode)) { - return - } - paragraphNode = odtDocument.getParagraphElement(odtDocument.getCursor(inputMemberId).getNode()); - stepsToStart = odtDocument.getDistanceFromCursor(inputMemberId, paragraphNode, 0); - iterator = gui.SelectionMover.createPositionIterator(odtDocument.getRootNode()); - iterator.moveToEndOfNode(paragraphNode); - stepsToEnd = odtDocument.getDistanceFromCursor(inputMemberId, paragraphNode, iterator.unfilteredDomOffset()); - if(stepsToStart !== 0 || stepsToEnd !== 0) { - oldPosition = odtDocument.getCursorPosition(inputMemberId); - op = createOpMoveCursor(oldPosition + stepsToStart, Math.abs(stepsToStart) + Math.abs(stepsToEnd)); - session.enqueue(op) - } - } function extendCursorByAdjustment(lengthAdjust) { var selection = odtDocument.getCursorSelection(inputMemberId), stepCounter = odtDocument.getCursor(inputMemberId).getStepCounter(), newLength; if(lengthAdjust !== 0) { @@ -13229,9 +13326,13 @@ gui.SessionController = function() { session.enqueue(op) } function enqueueParagraphSplittingOps() { - var position = odtDocument.getCursorPosition(inputMemberId), op; + var selection = toForwardSelection(odtDocument.getCursorSelection(inputMemberId)), op; + if(selection.length > 0) { + op = createOpRemoveSelection(selection); + session.enqueue(op) + } op = new ops.OpSplitParagraph; - op.init({memberid:inputMemberId, position:position}); + op.init({memberid:inputMemberId, position:selection.position}); session.enqueue(op); return true } @@ -13323,23 +13424,13 @@ gui.SessionController = function() { clickStartedWithinContainer = e.target && domUtils.containsNode(odtDocument.getOdfCanvas().getElement(), e.target) } function handleMouseUp(event) { - var target = event.target, clickCount = event.detail, annotationNode = null; + var target = event.target, annotationNode = null; if(target.className === "annotationRemoveButton") { annotationNode = domUtils.getElementsByTagNameNS(target.parentNode, odf.Namespaces.officens, "annotation")[0]; removeAnnotation(annotationNode) }else { if(clickStartedWithinContainer) { - if(clickCount === 1) { - selectRange(event) - }else { - if(clickCount === 2) { - selectWord() - }else { - if(clickCount === 3) { - selectParagraph() - } - } - } + selectRange(event) } } } @@ -14137,7 +14228,7 @@ gui.SessionView = function() { */ runtime.loadClass("gui.Caret"); gui.CaretManager = function CaretManager(sessionController) { - var carets = {}; + var carets = {}, window = runtime.getWindow(); function getCaret(memberId) { return carets.hasOwnProperty(memberId) ? carets[memberId] : null } @@ -14185,6 +14276,18 @@ gui.CaretManager = function CaretManager(sessionController) { caret.removeFocus() } } + function showLocalCaret() { + var caret = getCaret(sessionController.getInputMemberId()); + if(caret) { + caret.show() + } + } + function hideLocalCaret() { + var caret = getCaret(sessionController.getInputMemberId()); + if(caret) { + caret.hide() + } + } this.registerCursor = function(cursor, caretAvatarInitiallyVisible, blinkOnRangeSelect) { var memberid = cursor.getMemberId(), canvasElement = getCanvasElement(), caret = new gui.Caret(cursor, caretAvatarInitiallyVisible, blinkOnRangeSelect); carets[memberid] = caret; @@ -14203,8 +14306,10 @@ gui.CaretManager = function CaretManager(sessionController) { odtDocument.unsubscribe(ops.OdtDocument.signalParagraphChanged, ensureLocalCaretVisible); odtDocument.unsubscribe(ops.OdtDocument.signalCursorMoved, refreshLocalCaretBlinking); odtDocument.unsubscribe(ops.OdtDocument.signalCursorRemoved, removeCaret); - canvasElement.onfocus = null; - canvasElement.onblur = null; + canvasElement.removeEventListener("focus", focusLocalCaret, false); + canvasElement.removeEventListener("blur", blurLocalCaret, false); + window.removeEventListener("focus", showLocalCaret, false); + window.removeEventListener("blur", hideLocalCaret, false); (function destroyCaret(i, err) { if(err) { callback(err) @@ -14224,8 +14329,10 @@ gui.CaretManager = function CaretManager(sessionController) { odtDocument.subscribe(ops.OdtDocument.signalParagraphChanged, ensureLocalCaretVisible); odtDocument.subscribe(ops.OdtDocument.signalCursorMoved, refreshLocalCaretBlinking); odtDocument.subscribe(ops.OdtDocument.signalCursorRemoved, removeCaret); - canvasElement.onfocus = focusLocalCaret; - canvasElement.onblur = blurLocalCaret + canvasElement.addEventListener("focus", focusLocalCaret, false); + canvasElement.addEventListener("blur", blurLocalCaret, false); + window.addEventListener("focus", showLocalCaret, false); + window.addEventListener("blur", hideLocalCaret, false) } init() }; @@ -14977,13 +15084,15 @@ gui.TrivialUndoManager.signalDocumentRootReplaced = "documentRootReplaced"; @source: http://gitorious.org/webodf/webodf/ */ runtime.loadClass("core.EventNotifier"); +runtime.loadClass("core.DomUtils"); runtime.loadClass("odf.OdfUtils"); +runtime.loadClass("odf.Namespaces"); runtime.loadClass("gui.SelectionMover"); runtime.loadClass("gui.StyleHelper"); runtime.loadClass("core.PositionFilterChain"); ops.OdtDocument = function OdtDocument(odfCanvas) { - var self = this, textns = "urn:oasis:names:tc:opendocument:xmlns:text:1.0", odfUtils, cursors = {}, eventNotifier = new core.EventNotifier([ops.OdtDocument.signalCursorAdded, ops.OdtDocument.signalCursorRemoved, ops.OdtDocument.signalCursorMoved, ops.OdtDocument.signalParagraphChanged, ops.OdtDocument.signalParagraphStyleModified, ops.OdtDocument.signalCommonParagraphStyleCreated, ops.OdtDocument.signalCommonParagraphStyleDeleted, ops.OdtDocument.signalTableAdded, ops.OdtDocument.signalOperationExecuted, - ops.OdtDocument.signalUndoStackChanged]), FILTER_ACCEPT = core.PositionFilter.FilterResult.FILTER_ACCEPT, FILTER_REJECT = core.PositionFilter.FilterResult.FILTER_REJECT, filter; + 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; function getRootNode() { var element = odfCanvas.odfContainer().getContentElement(), localName = element && element.localName; runtime.assert(localName === "text", "Unsupported content element type '" + localName + "'for OdtDocument"); @@ -15097,7 +15206,7 @@ ops.OdtDocument = function OdtDocument(odfCanvas) { var iterator = gui.SelectionMover.createPositionIterator(getRootNode()); position += 1; while(position > 0 && iterator.nextPosition()) { - if(filter.acceptPosition(iterator) === 1) { + if(filter.acceptPosition(iterator) === FILTER_ACCEPT) { position -= 1 } } @@ -15107,7 +15216,7 @@ ops.OdtDocument = function OdtDocument(odfCanvas) { 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) === 1) { + if(filter.acceptPosition(iterator) === FILTER_ACCEPT) { node = iterator.container(); if(node.nodeType === Node.TEXT_NODE) { lastTextNode = (node); @@ -15120,13 +15229,13 @@ ops.OdtDocument = function OdtDocument(odfCanvas) { if(!iterator.nextPosition()) { return null } - if(filter.acceptPosition(iterator) === 1) { + if(filter.acceptPosition(iterator) === FILTER_ACCEPT) { position -= 1; node = iterator.container(); if(node.nodeType === Node.TEXT_NODE) { if(node !== lastTextNode) { lastTextNode = (node); - nodeOffset = iterator.domOffset() + nodeOffset = iterator.unfilteredDomOffset() }else { nodeOffset += 1 } @@ -15156,25 +15265,25 @@ ops.OdtDocument = function OdtDocument(odfCanvas) { while(nodeOffset === 0 && cursorNode.nextSibling && cursorNode.nextSibling.localName === "cursor") { cursorNode.parentNode.insertBefore(cursorNode, cursorNode.nextSibling.nextSibling) } - if(cursorNode && lastTextNode.length > 0) { + 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 + 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 + } } } while(lastTextNode.previousSibling && lastTextNode.previousSibling.nodeType === Node.TEXT_NODE) { lastTextNode.previousSibling.appendData(lastTextNode.data); - nodeOffset = lastTextNode.length + lastTextNode.previousSibling.length; + nodeOffset = lastTextNode.previousSibling.length; lastTextNode = (lastTextNode.previousSibling); lastTextNode.parentNode.removeChild(lastTextNode.nextSibling) } @@ -15183,10 +15292,12 @@ ops.OdtDocument = function OdtDocument(odfCanvas) { function getParagraphElement(node) { return odfUtils.getParagraphElement(node) } + function getStyleElement(styleName, styleFamily) { + return odfCanvas.getFormatting().getStyleElement(styleName, styleFamily) + } + this.getStyleElement = getStyleElement; function getParagraphStyleElement(styleName) { - var node; - node = odfCanvas.getFormatting().getStyleElement(styleName, "paragraph"); - return node + return getStyleElement(styleName, "paragraph") } function getParagraphStyleAttributes(styleName) { var node = getParagraphStyleElement(styleName); @@ -15197,7 +15308,7 @@ ops.OdtDocument = function OdtDocument(odfCanvas) { } function upgradeWhitespaceToElement(textNode, offset) { runtime.assert(textNode.data[offset] === " ", "upgradeWhitespaceToElement: textNode.data[offset] should be a literal space"); - var space = textNode.ownerDocument.createElementNS(textns, "text:s"); + var space = textNode.ownerDocument.createElementNS(odf.Namespaces.textns, "text:s"); space.appendChild(textNode.ownerDocument.createTextNode(" ")); textNode.deleteData(offset, 1); if(offset > 0) { @@ -15221,6 +15332,27 @@ ops.OdtDocument = function OdtDocument(odfCanvas) { } } this.upgradeWhitespacesAtPosition = upgradeWhitespacesAtPosition; + this.downgradeWhitespacesAtPosition = function(position) { + var iterator = getIteratorAtPosition(position), container, offset, firstSpaceElementChild, lastSpaceElementChild; + container = iterator.container(); + offset = iterator.unfilteredDomOffset(); + while(!odfUtils.isCharacterElement(container) && container.childNodes[offset]) { + container = container.childNodes[offset]; + offset = 0 + } + if(container.nodeType === Node.TEXT_NODE) { + container = container.parentNode + } + if(odfUtils.isDowngradableSpaceElement(container)) { + firstSpaceElementChild = container.firstChild; + lastSpaceElementChild = container.lastChild; + domUtils.mergeIntoParent(container); + if(lastSpaceElementChild !== firstSpaceElementChild) { + domUtils.normalizeTextNodes(lastSpaceElementChild) + } + domUtils.normalizeTextNodes(firstSpaceElementChild) + } + }; this.getParagraphStyleElement = getParagraphStyleElement; this.getParagraphElement = getParagraphElement; this.getParagraphStyleAttributes = getParagraphStyleAttributes; @@ -15255,7 +15387,7 @@ ops.OdtDocument = function OdtDocument(odfCanvas) { if(getParagraphElement(iterator.container()) !== paragraph) { return length } - if(filter.acceptPosition(iterator) === 1) { + if(filter.acceptPosition(iterator) === FILTER_ACCEPT) { length += 1 } }while(iterator.nextPosition()); @@ -15366,7 +15498,8 @@ ops.OdtDocument = function OdtDocument(odfCanvas) { }; function init() { filter = new TextPositionFilter; - odfUtils = new odf.OdfUtils + odfUtils = new odf.OdfUtils; + domUtils = new core.DomUtils } init() }; @@ -15375,8 +15508,8 @@ ops.OdtDocument.signalCursorRemoved = "cursor/removed"; ops.OdtDocument.signalCursorMoved = "cursor/moved"; ops.OdtDocument.signalParagraphChanged = "paragraph/changed"; ops.OdtDocument.signalTableAdded = "table/added"; -ops.OdtDocument.signalCommonParagraphStyleCreated = "style/created"; -ops.OdtDocument.signalCommonParagraphStyleDeleted = "style/deleted"; +ops.OdtDocument.signalCommonStyleCreated = "style/created"; +ops.OdtDocument.signalCommonStyleDeleted = "style/deleted"; ops.OdtDocument.signalParagraphStyleModified = "paragraphstyle/modified"; ops.OdtDocument.signalOperationExecuted = "operation/executed"; ops.OdtDocument.signalUndoStackChanged = "undo/changed"; diff --git a/js/3rdparty/webodf/webodf.js b/js/3rdparty/webodf/webodf.js index 3d932e87..c5a5f6f7 100644 --- a/js/3rdparty/webodf/webodf.js +++ b/js/3rdparty/webodf/webodf.js @@ -37,78 +37,78 @@ var core={},gui={},xmldom={},odf={},ops={}; // Input 1 function Runtime(){}Runtime.ByteArray=function(l){};Runtime.prototype.getVariable=function(l){};Runtime.prototype.toJson=function(l){};Runtime.prototype.fromJson=function(l){};Runtime.ByteArray.prototype.slice=function(l,m){};Runtime.ByteArray.prototype.length=0;Runtime.prototype.byteArrayFromArray=function(l){};Runtime.prototype.byteArrayFromString=function(l,m){};Runtime.prototype.byteArrayToString=function(l,m){};Runtime.prototype.concatByteArrays=function(l,m){}; -Runtime.prototype.read=function(l,m,e,c){};Runtime.prototype.readFile=function(l,m,e){};Runtime.prototype.readFileSync=function(l,m){};Runtime.prototype.loadXML=function(l,m){};Runtime.prototype.writeFile=function(l,m,e){};Runtime.prototype.isFile=function(l,m){};Runtime.prototype.getFileSize=function(l,m){};Runtime.prototype.deleteFile=function(l,m){};Runtime.prototype.log=function(l,m){};Runtime.prototype.setTimeout=function(l,m){};Runtime.prototype.clearTimeout=function(l){}; -Runtime.prototype.libraryPaths=function(){};Runtime.prototype.type=function(){};Runtime.prototype.getDOMImplementation=function(){};Runtime.prototype.parseXML=function(l){};Runtime.prototype.getWindow=function(){};Runtime.prototype.assert=function(l,m,e){};var IS_COMPILED_CODE=!0; -Runtime.byteArrayToString=function(l,m){function e(b){var a="",h,f=b.length;for(h=0;hd?a+=String.fromCharCode(d):(h+=1,c=b[h],194<=d&&224>d?a+=String.fromCharCode((d&31)<<6|c&63):(h+=1,k=b[h],224<=d&&240>d?a+=String.fromCharCode((d&15)<<12|(c&63)<<6|k&63):(h+=1,q=b[h],240<=d&&245>d&&(d=(d&7)<<18|(c&63)<<12|(k&63)<<6|q&63,d-=65536,a+=String.fromCharCode((d>>10)+55296,(d&1023)+56320))))); -return a}var b;"utf8"===m?b=c(l):("binary"!==m&&this.log("Unsupported encoding: "+m),b=e(l));return b};Runtime.getVariable=function(l){try{return eval(l)}catch(m){}};Runtime.toJson=function(l){return JSON.stringify(l)};Runtime.fromJson=function(l){return JSON.parse(l)};Runtime.getFunctionName=function(l){return void 0===l.name?(l=/function\s+(\w+)/.exec(l))&&l[1]:l.name}; -function BrowserRuntime(l){function m(a,h){var f,d,b;void 0!==h?b=a:h=a;l?(d=l.ownerDocument,b&&(f=d.createElement("span"),f.className=b,f.appendChild(d.createTextNode(b)),l.appendChild(f),l.appendChild(d.createTextNode(" "))),f=d.createElement("span"),0k?(d[e]=k,e+=1):2048>k?(d[e]=192|k>>>6,d[e+1]=128|k&63,e+=2):(d[e]=224|k>>>12&15,d[e+1]=128|k>>>6&63,d[e+2]=128|k&63,e+=3)}else for("binary"!== -h&&c.log("unknown encoding: "+h),f=a.length,d=new c.ByteArray(f),b=0;bd.status||0===d.status?f(null):f("Status "+String(d.status)+": "+d.responseText|| -d.statusText):f("File "+a+" is empty."))};h=h.buffer&&!d.sendAsBinary?h.buffer:c.byteArrayToString(h,"binary");try{d.sendAsBinary?d.sendAsBinary(h):d.send(h)}catch(e){c.log("HUH? "+e+" "+h),f(e.message)}};this.deleteFile=function(a,h){delete b[a];var f=new XMLHttpRequest;f.open("DELETE",a,!0);f.onreadystatechange=function(){4===f.readyState&&(200>f.status&&300<=f.status?h(f.responseText):h(null))};f.send(null)};this.loadXML=function(a,h){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?h(null,f.responseXML):h(f.responseText):h("File "+a+" is empty."))};try{f.send(null)}catch(d){h(d.message)}};this.isFile=function(a,h){c.getFileSize(a,function(a){h(-1!==a)})};this.getFileSize=function(a,h){var f=new XMLHttpRequest;f.open("HEAD",a,!0);f.onreadystatechange=function(){if(4===f.readyState){var d=f.getResponseHeader("Content-Length");d?h(parseInt(d, -10)):e(a,"binary",function(d,k){d?h(-1):h(k.length)})}};f.send(null)};this.log=m;this.assert=function(a,h,f){if(!a)throw m("alert","ASSERTION FAILED:\n"+h),f&&f(),h;};this.setTimeout=function(a,h){return setTimeout(function(){a()},h)};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, +Runtime.prototype.read=function(l,m,h,a){};Runtime.prototype.readFile=function(l,m,h){};Runtime.prototype.readFileSync=function(l,m){};Runtime.prototype.loadXML=function(l,m){};Runtime.prototype.writeFile=function(l,m,h){};Runtime.prototype.isFile=function(l,m){};Runtime.prototype.getFileSize=function(l,m){};Runtime.prototype.deleteFile=function(l,m){};Runtime.prototype.log=function(l,m){};Runtime.prototype.setTimeout=function(l,m){};Runtime.prototype.clearTimeout=function(l){}; +Runtime.prototype.libraryPaths=function(){};Runtime.prototype.type=function(){};Runtime.prototype.getDOMImplementation=function(){};Runtime.prototype.parseXML=function(l){};Runtime.prototype.getWindow=function(){};Runtime.prototype.assert=function(l,m,h){};var IS_COMPILED_CODE=!0; +Runtime.byteArrayToString=function(l,m){function h(a){var g="",d,b=a.length;for(d=0;dc?g+=String.fromCharCode(c):(d+=1,q=a[d],194<=c&&224>c?g+=String.fromCharCode((c&31)<<6|q&63):(d+=1,k=a[d],224<=c&&240>c?g+=String.fromCharCode((c&15)<<12|(q&63)<<6|k&63):(d+=1,f=a[d],240<=c&&245>c&&(c=(c&7)<<18|(q&63)<<12|(k&63)<<6|f&63,c-=65536,g+=String.fromCharCode((c>>10)+55296,(c&1023)+56320))))); +return g}var b;"utf8"===m?b=a(l):("binary"!==m&&this.log("Unsupported encoding: "+m),b=h(l));return b};Runtime.getVariable=function(l){try{return eval(l)}catch(m){}};Runtime.toJson=function(l){return JSON.stringify(l)};Runtime.fromJson=function(l){return JSON.parse(l)};Runtime.getFunctionName=function(l){return void 0===l.name?(l=/function\s+(\w+)/.exec(l))&&l[1]:l.name}; +function BrowserRuntime(l){function m(g,d){var a,c,b;void 0!==d?b=g:d=g;l?(c=l.ownerDocument,b&&(a=c.createElement("span"),a.className=b,a.appendChild(c.createTextNode(b)),l.appendChild(a),l.appendChild(c.createTextNode(" "))),a=c.createElement("span"),0k?(c[f]=k,f+=1):2048>k?(c[f]=192|k>>>6,c[f+1]=128|k&63,f+=2):(c[f]=224|k>>>12&15,c[f+1]=128|k>>>6&63,c[f+2]=128|k&63,f+=3)}else for("binary"!== +d&&a.log("unknown encoding: "+d),b=g.length,c=new a.ByteArray(b),e=0;ec.status||0===c.status?e(null):e("Status "+String(c.status)+": "+c.responseText|| +c.statusText):e("File "+g+" is empty."))};d=d.buffer&&!c.sendAsBinary?d.buffer:a.byteArrayToString(d,"binary");try{c.sendAsBinary?c.sendAsBinary(d):c.send(d)}catch(h){a.log("HUH? "+h+" "+d),e(h.message)}};this.deleteFile=function(g,d){delete b[g];var a=new XMLHttpRequest;a.open("DELETE",g,!0);a.onreadystatechange=function(){4===a.readyState&&(200>a.status&&300<=a.status?d(a.responseText):d(null))};a.send(null)};this.loadXML=function(a,d){var b=new XMLHttpRequest;b.open("GET",a,!0);b.overrideMimeType&& +b.overrideMimeType("text/xml");b.onreadystatechange=function(){4===b.readyState&&(0!==b.status||b.responseText?200===b.status||0===b.status?d(null,b.responseXML):d(b.responseText):d("File "+a+" is empty."))};try{b.send(null)}catch(c){d(c.message)}};this.isFile=function(g,d){a.getFileSize(g,function(a){d(-1!==a)})};this.getFileSize=function(a,d){var b=new XMLHttpRequest;b.open("HEAD",a,!0);b.onreadystatechange=function(){if(4===b.readyState){var c=b.getResponseHeader("Content-Length");c?d(parseInt(c, +10)):h(a,"binary",function(c,k){c?d(-1):d(k.length)})}};b.send(null)};this.log=m;this.assert=function(a,d,b){if(!a)throw m("alert","ASSERTION FAILED:\n"+d),b&&b(),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 l(h,a,d){h=c.resolve(b,h);"binary"!==a?e.readFile(h,a,d):e.readFile(h,null,d)}var m=this,e=require("fs"),c=require("path"),b="",n,a;this.ByteArray=function(h){return new Buffer(h)};this.byteArrayFromArray=function(h){var a=new Buffer(h.length),d,b=h.length;for(d=0;d").implementation} -function RhinoRuntime(){function l(a,b){var f;void 0!==b?f=a:b=a;"alert"===f&&print("\n!!!!! ALERT !!!!!");print(b);"alert"===f&&print("!!!!! ALERT !!!!!")}var m=this,e=Packages.javax.xml.parsers.DocumentBuilderFactory.newInstance(),c,b,n="";e.setValidating(!1);e.setNamespaceAware(!0);e.setExpandEntityReferences(!1);e.setSchema(null);b=Packages.org.xml.sax.EntityResolver({resolveEntity:function(a,b){var f=new Packages.java.io.FileReader(b);return new Packages.org.xml.sax.InputSource(f)}});c=e.newDocumentBuilder(); -c.setEntityResolver(b);this.ByteArray=function(a){return[a]};this.byteArrayFromArray=function(a){return a};this.byteArrayFromString=function(a,b){var f=[],d,c=a.length;for(d=0;d").implementation} +function RhinoRuntime(){function l(a,b){var e;void 0!==b?e=a:b=a;"alert"===e&&print("\n!!!!! ALERT !!!!!");print(b);"alert"===e&&print("!!!!! ALERT !!!!!")}var m=this,h=Packages.javax.xml.parsers.DocumentBuilderFactory.newInstance(),a,b,e="";h.setValidating(!1);h.setNamespaceAware(!0);h.setExpandEntityReferences(!1);h.setSchema(null);b=Packages.org.xml.sax.EntityResolver({resolveEntity:function(a,b){var e=new Packages.java.io.FileReader(b);return new Packages.org.xml.sax.InputSource(e)}});a=h.newDocumentBuilder(); +a.setEntityResolver(b);this.ByteArray=function(a){return[a]};this.byteArrayFromArray=function(a){return a};this.byteArrayFromString=function(a,b){var e=[],c,h=a.length;for(c=0;c>>18],b+=p[d>>>12&63],b+=p[d>>>6&63],b+=p[d&63];k===g+1?(d=a[k]<<4,b+=p[d>>>6],b+=p[d&63],b+="=="):k===g&&(d=a[k]<<10|a[k+1]<<2,b+=p[d>>>12],b+=p[d>>>6&63],b+=p[d&63],b+="=");return b}function e(a){a=a.replace(/[^A-Za-z0-9+\/]+/g,"");var d=[],b=a.length%4,k,g=a.length,h;for(k=0;k>16,h>>8&255,h&255);d.length-=[0,0,2,1][b];return d}function c(a){var d=[],b,k=a.length,g;for(b=0;bg?d.push(g):2048>g?d.push(192|g>>>6,128|g&63):d.push(224|g>>>12&15,128|g>>>6&63,128|g&63);return d}function b(a){var d=[],b,k=a.length,g,h,f;for(b=0;bg?d.push(g):(b+=1,h=a[b],224>g?d.push((g&31)<<6|h&63):(b+=1,f=a[b],d.push((g&15)<<12|(h&63)<<6|f&63)));return d}function n(a){return m(l(a))} -function a(a){return String.fromCharCode.apply(String,e(a))}function h(a){return b(l(a))}function f(a){a=b(a);for(var d="",k=0;kd?k+=String.fromCharCode(d):(f+=1,g=a.charCodeAt(f)&255,224>d?k+=String.fromCharCode((d&31)<<6|g&63):(f+=1,h=a.charCodeAt(f)&255,k+=String.fromCharCode((d&15)<<12|(g&63)<<6|h&63)));return k}function t(a,b){function k(){var c= -f+g;c>a.length&&(c=a.length);h+=d(a,f,c);f=c;c=f===a.length;b(h,c)&&!c&&runtime.setTimeout(k,0)}var g=1E5,h="",f=0;a.length>>18],b+=u[c>>>12&63],b+=u[c>>>6&63],b+=u[c&63];f===k+1?(c=a[f]<<4,b+=u[c>>>6],b+=u[c&63],b+="=="):f===k&&(c=a[f]<<10|a[f+1]<<2,b+=u[c>>>12],b+=u[c>>>6&63],b+=u[c&63],b+="=");return b}function h(a){a=a.replace(/[^A-Za-z0-9+\/]+/g,"");var c=[],b=a.length%4,f,k=a.length,n;for(f=0;f>16,n>>8&255,n&255);c.length-=[0,0,2,1][b];return c}function a(a){var c=[],b,f=a.length,k;for(b=0;bk?c.push(k):2048>k?c.push(192|k>>>6,128|k&63):c.push(224|k>>>12&15,128|k>>>6&63,128|k&63);return c}function b(a){var c=[],b,f=a.length,k,n,g;for(b=0;bk?c.push(k):(b+=1,n=a[b],224>k?c.push((k&31)<<6|n&63):(b+=1,g=a[b],c.push((k&15)<<12|(n&63)<<6|g&63)));return c}function e(a){return m(l(a))} +function g(a){return String.fromCharCode.apply(String,h(a))}function d(a){return b(l(a))}function p(a){a=b(a);for(var c="",f=0;fc?f+=String.fromCharCode(c):(g+=1,k=a.charCodeAt(g)&255,224>c?f+=String.fromCharCode((c&31)<<6|k&63):(g+=1,n=a.charCodeAt(g)&255,f+=String.fromCharCode((c&15)<<12|(k&63)<<6|n&63)));return f}function q(a,b){function f(){var d= +g+k;d>a.length&&(d=a.length);n+=c(a,g,d);g=d;d=g===a.length;b(n,d)&&!d&&runtime.setTimeout(f,0)}var k=1E5,n="",g=0;a.length>>8):(ia(a&255),ia(a>>>8))},V=function(){v=(v<<5^g[B+3-1]&255)&8191;s=w[32768+v];w[B&32767]=s;w[32768+v]=B},X=function(a,d){z>16-d?(u|=a<>16-z,z+=d-16):(u|=a<a;a++)g[a]=g[a+32768];L-=32768;B-=32768;y-=32768;for(a=0;8192>a;a++)d=w[32768+a],w[32768+a]=32768<=d?d-32768:0;for(a=0;32768>a;a++)d=w[a],w[a]=32768<=d?d-32768:0;b+=32768}C||(a=Ba(g,B+K,b),0>=a?C=!0:K+=a)},Ca=function(a){var d=ea,b=B,k,h=N,f=32506=qa&&(d>>=2);do if(k=a,g[k+h]===p&&g[k+h-1]===e&&g[k]===g[b]&&g[++k]===g[b+1]){b+=2;k++;do++b;while(g[b]=== -g[++k]&&g[++b]===g[++k]&&g[++b]===g[++k]&&g[++b]===g[++k]&&g[++b]===g[++k]&&g[++b]===g[++k]&&g[++b]===g[++k]&&g[++b]===g[++k]&&bh){L=a;h=k;if(258<=k)break;e=g[b+h-1];p=g[b+h]}a=w[a&32767]}while(a>f&&0!==--d);return h},va=function(a,d){r[U++]=d;0===a?Y[d].fc++:(a--,Y[ba[d]+256+1].fc++,Z[(256>a?ja[a]:ja[256+(a>>7)])&255].fc++,p[na++]=a,x|=la);la<<=1;0===(U&7)&&(ka[W++]=x,x=0,la=1);if(2g;g++)b+=Z[g].fc*(5+ha[g]);b>>=3;if(na< -parseInt(U/2,10)&&b>=1,b<<=1;while(0<--d);return b>>1},Ea=function(a,d){var b=[];b.length=16;var k=0,g;for(g=1;15>=g;g++)k=k+H[g-1]<<1,b[g]=k;for(k=0;k<=d;k++)g=a[k].dl,0!==g&&(a[k].fc=Da(b[g]++,g))},za=function(a){var d=a.dyn_tree,b=a.static_tree,k=a.elems,g,h=-1,f=k;ca=0;fa=573;for(g= -0;gca;)g=R[++ca]=2>h?++h:0,d[g].fc=1,O[g]=0,S--,null!==b&&(oa-=b[g].dl);a.max_code=h;for(g=ca>>1;1<=g;g--)ya(d,g);do g=R[1],R[1]=R[ca--],ya(d,1),b=R[1],R[--fa]=g,R[--fa]=b,d[f].fc=d[g].fc+d[b].fc,O[f]=O[g]>O[b]+1?O[g]:O[b]+1,d[g].dl=d[b].dl=f,R[1]=f++,ya(d,1);while(2<=ca);R[--fa]=R[1];f=a.dyn_tree;g=a.extra_bits;var k=a.extra_base,b=a.max_code,c=a.max_length,e=a.static_tree,p,s,q,n,r=0;for(s=0;15>=s;s++)H[s]=0;f[R[fa]].dl=0;for(a=fa+1;573>a;a++)p= -R[a],s=f[f[p].dl].dl+1,s>c&&(s=c,r++),f[p].dl=s,p>b||(H[s]++,q=0,p>=k&&(q=g[p-k]),n=f[p].fc,S+=n*(s+q),null!==e&&(oa+=n*(e[p].dl+q)));if(0!==r){do{for(s=c-1;0===H[s];)s--;H[s]--;H[s+1]+=2;H[c]--;r-=2}while(0b||(f[g].dl!==s&&(S+=(s-f[g].dl)*f[g].fc,f[g].fc=s),p--)}Ea(d,h)},Fa=function(a,d){var b,k=-1,g,h=a[0].dl,f=0,c=7,e=4;0===h&&(c=138,e=3);a[d+1].dl=65535;for(b=0;b<=d;b++)g=h,h=a[b+1].dl,++f=f?T[17].fc++:T[18].fc++,f=0,k=g,0===h?(c=138,e=3):g===h?(c=6,e=3):(c=7,e=4))},Ga=function(){8b?ja[b]:ja[256+(b>>7)])&255,ga(c,d),e=ha[c],0!==e&&(b-=ma[c],X(b,e))),f>>=1;while(k=f?(ga(17,T),X(f-3,3)):(ga(18,T),X(f-11,7));f=0;k=g;0===h?(c=138,e=3):g===h?(c=6,e=3):(c=7,e=4)}},Ja=function(){var a;for(a=0;286>a;a++)Y[a].fc=0;for(a=0;30>a;a++)Z[a].fc=0;for(a=0;19>a;a++)T[a].fc=0;Y[256].fc=1;x=U=na=W=S=oa=0;la=1},wa=function(a){var d,b,k,h;h=B-y;ka[W]=x;za(P);za(J);Fa(Y,P.max_code);Fa(Z,J.max_code);za(G);for(k=18;3<=k&&0===T[ua[k]].dl;k--);S+=3*(k+1)+14;d=S+3+7>>3;b= -oa+3+7>>3;b<=d&&(d=b);if(h+4<=d&&0<=y)for(X(0+a,3),Ga(),da(h),da(~h),k=0;ka.len&&(c=a.len);for(e=0;et-k&&(c= -t-k);for(e=0;ep;p++)for(F[p]=e,c=0;c<1<p;p++)for(ma[p]=e,c=0;c<1<>=7;30>p;p++)for(ma[p]=e<<7,c=0;c<1<=c;c++)H[c]=0;for(c=0;143>=c;)Q[c++].dl=8,H[8]++;for(;255>=c;)Q[c++].dl=9,H[9]++;for(;279>=c;)Q[c++].dl=7,H[7]++;for(;287>=c;)Q[c++].dl=8,H[8]++;Ea(Q,287);for(c=0;30>c;c++)$[c].dl=5,$[c].fc=Da(c,5);Ja()}for(c=0;8192>c;c++)w[32768+c]=0;pa=aa[M].max_lazy;qa=aa[M].good_length;ea=aa[M].max_chain;y=B=0;K=Ba(g,0,65536);if(0>=K)C=!0,K=0;else{for(C=!1;262> -K&&!C;)xa();for(c=v=0;2>c;c++)v=(v<<5^g[c]&255)&8191}a=null;k=t=0;3>=M?(N=2,D=0):(D=2,I=0);q=!1}f=!0;if(0===K)return q=!0,0}c=Ka(b,d,h);if(c===h)return h;if(q)return c;if(3>=M)for(;0!==K&&null===a;){V();0!==s&&32506>=B-s&&(D=Ca(s),D>K&&(D=K));if(3<=D)if(p=va(B-L,D-3),K-=D,D<=pa){D--;do B++,V();while(0!==--D);B++}else B+=D,D=0,v=g[B]&255,v=(v<<5^g[B+1]&255)&8191;else p=va(0,g[B]&255),K--,B++;p&&(wa(0),y=B);for(;262>K&&!C;)xa()}else for(;0!==K&&null===a;){V();N=D;A=L;D=2;0!==s&&(N=B-s)&& -(D=Ca(s),D>K&&(D=K),3===D&&4096K&&!C;)xa()}0===K&&(0!==I&&va(0,g[B-1]&255),wa(1),q=!0);return c+Ka(b,c+d,h-c)};this.deflate=function(k,c){var e,s;ta=k;E=0;"undefined"===String(typeof c)&&(c=6);(e=c)?1>e?e=1:9e;e++)Y[e]=new l;Z=[];Z.length=61;for(e=0;61>e;e++)Z[e]=new l;Q=[];Q.length=288;for(e=0;288>e;e++)Q[e]=new l;$=[];$.length=30;for(e=0;30>e;e++)$[e]=new l;T=[];T.length=39;for(e=0;39>e;e++)T[e]=new l;P=new m;J=new m;G=new m;H=[];H.length=16;R=[];R.length=573;O=[];O.length=573;ba=[];ba.length=256;ja=[];ja.length=512;F=[];F.length=29;ma=[];ma.length=30;ka=[];ka.length=1024}var q=Array(1024),u=[],t=[];for(e=La(q,0,q.length);0>>8):(W(a&255),W(a>>>8))},ba=function(){w=(w<<5^n[A+3-1]&255)&8191;v=x[32768+w];x[A&32767]=v;x[32768+w]=A},ca=function(a,c){y>16-c?(r|=a<>16-y,y+=c-16):(r|=a<a;a++)n[a]=n[a+32768];P-=32768;A-=32768;t-=32768;for(a=0;8192>a;a++)c=x[32768+a],x[32768+a]=32768<=c?c-32768:0;for(a=0;32768>a;a++)c=x[a],x[a]=32768<=c?c-32768:0;b+=32768}G||(a=Ba(n,A+M,b),0>=a?G=!0:M+=a)},Ca=function(a){var c=ea,b=A,f,k=L,g=32506=oa&&(c>>=2);do if(f=a,n[f+k]===v&&n[f+k-1]===e&&n[f]===n[b]&&n[++f]===n[b+1]){b+=2;f++;do++b; +while(n[b]===n[++f]&&n[++b]===n[++f]&&n[++b]===n[++f]&&n[++b]===n[++f]&&n[++b]===n[++f]&&n[++b]===n[++f]&&n[++b]===n[++f]&&n[++b]===n[++f]&&bk){P=a;k=f;if(258<=f)break;e=n[b+k-1];v=n[b+k]}a=x[a&32767]}while(a>g&&0!==--c);return k},va=function(a,b){s[D++]=b;0===a?V[b].fc++:(a--,V[U[b]+256+1].fc++,Z[(256>a?ha[a]:ha[256+(a>>7)])&255].fc++,u[ja++]=a,aa|=C);C<<=1;0===(D&7)&&(ia[ka++]=aa,aa=0,C=1);if(2k;k++)c+=Z[k].fc*(5+pa[k]); +c>>=3;if(ja>=1,c<<=1;while(0<--b);return c>>1},Ea=function(a,c){var b=[];b.length=16;var f=0,k;for(k=1;15>=k;k++)f=f+X[k-1]<<1,b[k]=f;for(f=0;f<=c;f++)k=a[f].dl,0!==k&&(a[f].fc=Da(b[k]++,k))},za=function(a){var b=a.dyn_tree,c=a.static_tree,f=a.elems,k,n=-1,g=f;Q=0; +Y=573;for(k=0;kQ;)k=R[++Q]=2>n?++n:0,b[k].fc=1,$[k]=0,ma--,null!==c&&(la-=c[k].dl);a.max_code=n;for(k=Q>>1;1<=k;k--)ya(b,k);do k=R[1],R[1]=R[Q--],ya(b,1),c=R[1],R[--Y]=k,R[--Y]=c,b[g].fc=b[k].fc+b[c].fc,$[g]=$[k]>$[c]+1?$[k]:$[c]+1,b[k].dl=b[c].dl=g,R[1]=g++,ya(b,1);while(2<=Q);R[--Y]=R[1];g=a.dyn_tree;k=a.extra_bits;var f=a.extra_base,c=a.max_code,d=a.max_length,e=a.static_tree,v,h,s,l,m=0;for(h=0;15>=h;h++)X[h]=0;g[R[Y]].dl=0;for(a=Y+1;573> +a;a++)v=R[a],h=g[g[v].dl].dl+1,h>d&&(h=d,m++),g[v].dl=h,v>c||(X[h]++,s=0,v>=f&&(s=k[v-f]),l=g[v].fc,ma+=l*(h+s),null!==e&&(la+=l*(e[v].dl+s)));if(0!==m){do{for(h=d-1;0===X[h];)h--;X[h]--;X[h+1]+=2;X[d]--;m-=2}while(0c||(g[k].dl!==h&&(ma+=(h-g[k].dl)*g[k].fc,g[k].fc=h),v--)}Ea(b,n)},Fa=function(a,b){var c,f=-1,k,n=a[0].dl,g=0,d=7,e=4;0===n&&(d=138,e=3);a[b+1].dl=65535;for(c=0;c<=b;c++)k=n,n=a[c+1].dl,++g=g?B[17].fc++:B[18].fc++,g=0,f=k,0===n?(d=138,e=3):k===n?(d=6,e=3):(d=7,e=4))},Ga=function(){8c?ha[c]:ha[256+(c>>7)])&255,da(d,b),e=pa[d],0!==e&&(c-=ga[d],ca(c,e))),g>>=1;while(f=g?(da(17,B),ca(g-3,3)):(da(18,B),ca(g-11,7));g=0;f=k;0===n?(d=138,e=3):k===n?(d=6,e=3):(d=7,e=4)}},Ja=function(){var a;for(a=0;286>a;a++)V[a].fc=0;for(a=0;30>a;a++)Z[a].fc=0;for(a=0;19>a;a++)B[a].fc=0;V[256].fc=1;aa=D=ja=ka=ma=la=0;C=1},wa=function(a){var c,b,f,k;k=A-t;ia[ka]=aa;za(H);za(E);Fa(V,H.max_code);Fa(Z,E.max_code);za(T);for(f=18;3<=f&&0===B[ra[f]].dl;f--);ma+=3*(f+1)+ +14;c=ma+3+7>>3;b=la+3+7>>3;b<=c&&(c=b);if(k+4<=c&&0<=t)for(ca(0+a,3),Ga(),fa(k),fa(~k),f=0;fg.len&&(d=g.len);for(v=0;vq-k&&(d=q-k);for(v=0;vh;h++)for(K[h]=e,d=0;d< +1<h;h++)for(ga[h]=e,d=0;d<1<>=7;30>h;h++)for(ga[h]=e<<7,d=0;d<1<=d;d++)X[d]=0;for(d=0;143>=d;)O[d++].dl=8,X[8]++;for(;255>=d;)O[d++].dl=9,X[9]++;for(;279>=d;)O[d++].dl=7,X[7]++;for(;287>=d;)O[d++].dl=8,X[8]++;Ea(O,287);for(d=0;30>d;d++)S[d].dl=5,S[d].fc=Da(d,5);Ja()}for(d=0;8192>d;d++)x[32768+d]=0;na=ta[N].max_lazy;oa=ta[N].good_length;ea=ta[N].max_chain;t=A=0;M=Ba(n,0,65536);if(0>=M)G=!0,M=0; +else{for(G=!1;262>M&&!G;)xa();for(d=w=0;2>d;d++)w=(w<<5^n[d]&255)&8191}g=null;k=q=0;3>=N?(L=2,z=0):(z=2,J=0);f=!1}p=!0;if(0===M)return f=!0,0}d=Ka(a,c,b);if(d===b)return b;if(f)return d;if(3>=N)for(;0!==M&&null===g;){ba();0!==v&&32506>=A-v&&(z=Ca(v),z>M&&(z=M));if(3<=z)if(h=va(A-P,z-3),M-=z,z<=na){z--;do A++,ba();while(0!==--z);A++}else A+=z,z=0,w=n[A]&255,w=(w<<5^n[A+1]&255)&8191;else h=va(0,n[A]&255),M--,A++;h&&(wa(0),t=A);for(;262>M&&!G;)xa()}else for(;0!==M&&null===g;){ba();L=z;F=P;z=2;0!==v&& +(L=A-v)&&(z=Ca(v),z>M&&(z=M),3===z&&4096M&&!G;)xa()}0===M&&(0!==J&&va(0,n[A-1]&255),wa(1),f=!0);return d+Ka(a,d+c,b-d)};this.deflate=function(a,f){var k,v;sa=a;ua=0;"undefined"===String(typeof f)&&(f=6);(k=f)?1>k?k=1:9k;k++)V[k]=new l;Z=[];Z.length=61;for(k=0;61>k;k++)Z[k]=new l;O=[];O.length=288;for(k=0;288>k;k++)O[k]=new l;S=[];S.length=30;for(k=0;30>k;k++)S[k]=new l;B=[];B.length=39;for(k=0;39>k;k++)B[k]=new l;H=new m;E=new m;T=new m;X=[];X.length=16;R=[];R.length=573;$=[];$.length=573;U=[];U.length=256;ha=[];ha.length=512;K=[];K.length=29;ga=[];ga.length=30;ia=[];ia.length=1024}var h=Array(1024),t=[],r=[];for(k=La(h,0,h.length);0>8&255])};this.appendUInt32LE=function(c){m.appendArray([c&255,c>>8&255,c>>16&255,c>>24&255])};this.appendString=function(c){e=runtime.concatByteArrays(e, -runtime.byteArrayFromString(c,l))};this.getLength=function(){return e.length};this.getByteArray=function(){return e}}; +core.ByteArrayWriter=function(l){var m=this,h=new runtime.ByteArray(0);this.appendByteArrayWriter=function(a){h=runtime.concatByteArrays(h,a.getByteArray())};this.appendByteArray=function(a){h=runtime.concatByteArrays(h,a)};this.appendArray=function(a){h=runtime.concatByteArrays(h,runtime.byteArrayFromArray(a))};this.appendUInt16LE=function(a){m.appendArray([a&255,a>>8&255])};this.appendUInt32LE=function(a){m.appendArray([a&255,a>>8&255,a>>16&255,a>>24&255])};this.appendString=function(a){h=runtime.concatByteArrays(h, +runtime.byteArrayFromString(a,l))};this.getLength=function(){return h.length};this.getByteArray=function(){return h}}; // Input 6 -core.RawInflate=function(){var l,m,e=null,c,b,n,a,h,f,d,t,k,q,g,p,r,w,u=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535],z=[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],y=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,99,99],v=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],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],A=[16,17,18, -0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],I=function(){this.list=this.next=null},D=function(){this.n=this.b=this.e=0;this.t=null},N=function(a,b,d,k,g,c){this.BMAX=16;this.N_MAX=288;this.status=0;this.root=null;this.m=0;var h=Array(this.BMAX+1),f,e,p,s,q,n,r,m=Array(this.BMAX+1),l,w,u,t=new D,y=Array(this.BMAX);s=Array(this.N_MAX);var v,z=Array(this.BMAX+1),A,B,L;L=this.root=null;for(q=0;qq&&(c=q);for(A=1<(A-=h[n])){this.status=2;this.m=c;return}if(0>(A-=h[q]))this.status=2,this.m=c;else{h[q]+=A;z[1]=n=0;l=h;w=1;for(u=2;0<--q;)z[u++]=n+=l[w++];l=a;q=w=0;do 0!=(n=l[w++])&&(s[z[n]++]=q);while(++qv+m[1+s];){v+=m[1+s];s++;B=(B=p-v)>c?c:B;if((e=1<<(n=r-v))>a+1)for(e-=a+1,u=r;++nf&&v>v-m[s],y[s-1][n].e=t.e,y[s-1][n].b=t.b,y[s-1][n].n=t.n,y[s-1][n].t=t.t)}t.b=r-v;w>=b?t.e=99:l[w]l[w]?16:15,t.n=l[w++]): -(t.e=g[l[w]-d],t.n=k[l[w++]-d]);e=1<>v;n>=1)q^=n;for(q^=n;(q&(1<>=b;a-=b},K=function(a,b,c){var f,e,s;if(0==c)return 0;for(s=0;;){B(g);e=k.list[L(g)];for(f=e.e;16 -f;f++)m[A[f]]=0;g=7;f=new N(m,19,19,null,null,g);if(0!=f.status)return-1;k=f.root;g=f.m;e=r+l;for(c=h=0;cf)m[c++]=h=f;else if(16==f){B(2);f=3+L(2);C(2);if(c+f>e)return-1;for(;0e)return-1;for(;0J;J++)P[J]=8;for(;256>J;J++)P[J]=9;for(;280>J;J++)P[J]=7;for(;288>J;J++)P[J]=8;b=7;J=new N(P,288,257,z,y,b);if(0!=J.status){alert("HufBuild error: "+J.status);Q=-1;break b}e=J.root;b=J.m;for(J=0;30>J;J++)P[J]=5;ea=5;J=new N(P,30,0,v,s,ea);if(1s&&(d=s);for(A=1<(A-=n[l])){this.status=2;this.m=d;return}if(0>(A-=n[s]))this.status=2,this.m=d;else{n[s]+=A;w[1]=l=0;x=n;p=1;for(u=2;0<--s;)w[u++]=l+=x[p++];x=a;s=p=0;do 0!=(l=x[p++])&&(h[w[l]++]=s);while(++sy+t[1+h];){y+=t[1+h];h++;F=(F=v-y)>d?d:F;if((e=1<<(l=m-y))>a+1)for(e-=a+1,u=m;++lg&&y>y-t[h],q[h-1][l].e=r.e,q[h-1][l].b=r.b,q[h-1][l].n=r.n,q[h-1][l].t=r.t)}r.b=m-y;p>=c?r.e=99:x[p]x[p]?16:15,r.n=x[p++]): +(r.e=k[x[p]-b],r.n=f[x[p++]-b]);e=1<>y;l>=1)s^=l;for(s^=l;(s&(1<>=a;g-=a},M=function(a,b,g){var e,v,h;if(0==g)return 0;for(h=0;;){A(n);v=k.list[P(n)];for(e=v.e;16 +e;e++)p[F[e]]=0;n=7;e=new L(p,19,19,null,null,n);if(0!=e.status)return-1;k=e.root;n=e.m;h=l+m;for(d=g=0;de)p[d++]=g=e;else if(16==e){A(2);e=3+P(2);G(2);if(d+e>h)return-1;for(;0h)return-1;for(;0E;E++)H[E]=8;for(;256>E;E++)H[E]=9;for(;280>E;E++)H[E]=7;for(;288>E;E++)H[E]=8;b=7;E=new L(H,288,257,y,t,b);if(0!=E.status){alert("HufBuild error: "+E.status);O=-1;break b}h=E.root;b=E.m;for(E=0;30>E;E++)H[E]=5;ea=5;E=new L(H,30,0,w,v,ea);if(1l))throw runtime.log("alert","watchdog timeout"),"timeout!";if(0m))throw runtime.log("alert","watchdog loop overflow"),"loop overflow";}}; +core.LoopWatchDog=function(l,m){var h=Date.now(),a=0;this.check=function(){var b;if(l&&(b=Date.now(),b-h>l))throw runtime.log("alert","watchdog timeout"),"timeout!";if(0m))throw runtime.log("alert","watchdog loop overflow"),"loop overflow";}}; // Input 8 -core.Utils=function(){function l(m,e){e&&Array.isArray(e)?m=(m||[]).concat(e.map(function(c){return l({},c)})):e&&"object"===typeof e?(m=m||{},Object.keys(e).forEach(function(c){m[c]=l(m[c],e[c])})):m=e;return m}this.hashString=function(m){var e=0,c,b;c=0;for(b=m.length;c=e.compareBoundaryPoints(e.START_TO_START,c)&&0<=e.compareBoundaryPoints(e.END_TO_END,c)};this.rangesIntersect=function(e,c){return 0>=e.compareBoundaryPoints(e.END_TO_START,c)&&0<=e.compareBoundaryPoints(e.START_TO_END,c)};this.getNodesInRange=function(e,c){var b=[],n,a=e.startContainer.ownerDocument.createTreeWalker(e.commonAncestorContainer,NodeFilter.SHOW_ALL,c,!1);for(n=a.currentNode=e.startContainer;n;){if(c(n)=== -NodeFilter.FILTER_ACCEPT)b.push(n);else if(c(n)===NodeFilter.FILTER_REJECT)break;n=n.parentNode}b.reverse();for(n=a.nextNode();n;)b.push(n),n=a.nextNode();return b};this.normalizeTextNodes=function(e){e&&e.nextSibling&&(e=l(e,e.nextSibling));e&&e.previousSibling&&l(e.previousSibling,e)};this.rangeContainsNode=function(e,c){var b=c.ownerDocument.createRange(),n=c.nodeType===Node.TEXT_NODE?c.length:c.childNodes.length;b.setStart(e.startContainer,e.startOffset);b.setEnd(e.endContainer,e.endOffset);n= -0===b.comparePoint(c,0)&&0===b.comparePoint(c,n);b.detach();return n};this.mergeIntoParent=function(e){for(var c=e.parentNode;e.firstChild;)c.insertBefore(e.firstChild,e);c.removeChild(e);return c};this.getElementsByTagNameNS=function(e,c,b){return Array.prototype.slice.call(e.getElementsByTagNameNS(c,b))};this.rangeIntersectsNode=function(e,c){var b=c.nodeType===Node.TEXT_NODE?c.length:c.childNodes.length;return 0>=e.comparePoint(c,0)&&0<=e.comparePoint(c,b)};this.containsNode=function(e,c){return e=== -c||e.contains(c)};(function(e){var c=runtime.getWindow();null!==c&&(c=c.navigator.appVersion.toLowerCase(),c=-1===c.indexOf("chrome")&&(-1!==c.indexOf("applewebkit")||-1!==c.indexOf("safari")))&&(e.containsNode=m)})(this)}; +/* + + 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. + + As additional permission under GNU AGPL version 3 section 7, you + may distribute non-source (e.g., minimized or compacted) forms of + that code without the copy of the GNU GPL normally required by + section 4, provided you include this license notice and a URL + through which recipients can access the Corresponding Source. + + As a special exception to the AGPL, any HTML file which merely makes function + calls to this code, and for that purpose includes it by reference shall be + deemed a separate work for copyright law purposes. In addition, the copyright + holders of this code give you permission to combine this code with free + software libraries that are released under the GNU LGPL. You may copy and + distribute such a system following the terms of the GNU AGPL for this code + and the LGPL for the libraries. If you modify this code, you may extend this + exception to your version of the code, but you are not obligated to do so. + If you do not wish to do so, delete this exception statement from your + version. + + This license applies to this entire compilation. + @licend + @source: http://www.webodf.org/ + @source: http://gitorious.org/webodf/webodf/ +*/ +core.DomUtils=function(){function l(a,b){var e=null;a.nodeType===Node.TEXT_NODE&&(0===a.length?(a.parentNode.removeChild(a),b.nodeType===Node.TEXT_NODE&&(e=b)):(b.nodeType===Node.TEXT_NODE&&(a.appendData(b.data),b.parentNode.removeChild(b)),e=a));return e}function m(a,b){for(var e=0,g;a.parentNode!==b;)runtime.assert(null!==a.parentNode,"parent is null"),a=a.parentNode;for(g=b.firstChild;g!==a;)e+=1,g=g.nextSibling;return e}function h(a,b){return a===b||Boolean(a.compareDocumentPosition(b)&Node.DOCUMENT_POSITION_CONTAINED_BY)} +this.splitBoundaries=function(a){var b=[],e;if(a.startContainer.nodeType===Node.TEXT_NODE||a.endContainer.nodeType===Node.TEXT_NODE){e=a.endContainer;var g=a.endOffset;if(g=a.compareBoundaryPoints(a.START_TO_START,b)&&0<=a.compareBoundaryPoints(a.END_TO_END,b)};this.rangesIntersect=function(a,b){return 0>=a.compareBoundaryPoints(a.END_TO_START,b)&&0<=a.compareBoundaryPoints(a.START_TO_END,b)}; +this.getNodesInRange=function(a,b){var e=[],g,d=a.startContainer.ownerDocument.createTreeWalker(a.commonAncestorContainer,NodeFilter.SHOW_ALL,b,!1);for(g=d.currentNode=a.startContainer;g;){if(b(g)===NodeFilter.FILTER_ACCEPT)e.push(g);else if(b(g)===NodeFilter.FILTER_REJECT)break;g=g.parentNode}e.reverse();for(g=d.nextNode();g;)e.push(g),g=d.nextNode();return e};this.normalizeTextNodes=function(a){a&&a.nextSibling&&(a=l(a,a.nextSibling));a&&a.previousSibling&&l(a.previousSibling,a)};this.rangeContainsNode= +function(a,b){var e=b.ownerDocument.createRange(),g=b.nodeType===Node.TEXT_NODE?b.length:b.childNodes.length;e.setStart(a.startContainer,a.startOffset);e.setEnd(a.endContainer,a.endOffset);g=0===e.comparePoint(b,0)&&0===e.comparePoint(b,g);e.detach();return g};this.mergeIntoParent=function(a){for(var b=a.parentNode;a.firstChild;)b.insertBefore(a.firstChild,a);b.removeChild(a);return b};this.getElementsByTagNameNS=function(a,b,e){return Array.prototype.slice.call(a.getElementsByTagNameNS(b,e))};this.rangeIntersectsNode= +function(a,b){var e=b.nodeType===Node.TEXT_NODE?b.length:b.childNodes.length;return 0>=a.comparePoint(b,0)&&0<=a.comparePoint(b,e)};this.containsNode=function(a,b){return a===b||a.contains(b)};this.comparePoints=function(a,b,e,g){if(a===e)return g-b;var d=a.compareDocumentPosition(e);2===d?d=-1:4===d?d=1:10===d?(b=m(a,e),d=b";return runtime.parseXML(e)}; -core.UnitTestRunner=function(){function l(b){a+=1;runtime.log("fail",b)}function m(a,b){var c;try{if(a.length!==b.length)return l("array of length "+a.length+" should be "+b.length+" long"),!1;for(c=0;c1/h?"-0":String(h),l(d+" should be "+a+". Was "+c+".")):l(d+" should be "+a+" (of type "+typeof a+"). Was "+h+" (of type "+typeof h+").")}var a=0,h;h=function(a,d){var c=Object.keys(a),k=Object.keys(d);c.sort();k.sort();return m(c,k)&&Object.keys(a).every(function(k){var g= -a[k],c=d[k];return b(g,c)?!0:(l(g+" should be "+c+" for key "+k),!1)})};this.areNodesEqual=c;this.shouldBeNull=function(a,b){n(a,b,"null")};this.shouldBeNonNull=function(a,b){var c,k;try{k=eval(b)}catch(h){c=h}c?l(b+" should be non-null. Threw exception "+c):null!==k?runtime.log("pass",b+" is non-null."):l(b+" should be non-null. Was "+k)};this.shouldBe=n;this.countFailedTests=function(){return a}}; -core.UnitTester=function(){function l(c,b){return""+c+""}var m=0,e={};this.runTests=function(c,b,n){function a(k){if(0===k.length)e[h]=t,m+=f.countFailedTests(),b();else{q=k[0];var g=Runtime.getFunctionName(q);runtime.log("Running "+g);p=f.countFailedTests();d.setUp();q(function(){d.tearDown();t[g]=p===f.countFailedTests();a(k.slice(1))})}}var h=Runtime.getFunctionName(c),f=new core.UnitTestRunner,d=new c(f),t={},k,q,g,p,r="BrowserRuntime"=== -runtime.type();if(e.hasOwnProperty(h))runtime.log("Test "+h+" has already run.");else{r?runtime.log("Running "+l(h,'runSuite("'+h+'");')+": "+d.description()+""):runtime.log("Running "+h+": "+d.description);g=d.tests();for(k=0;kRunning "+l(c,'runTest("'+h+'","'+c+'")')+""):runtime.log("Running "+c),p=f.countFailedTests(),d.setUp(),q(),d.tearDown(),t[c]=p===f.countFailedTests()); -a(d.asyncTests())}};this.countFailedTests=function(){return m};this.results=function(){return e}}; +core.UnitTest.cleanupTestAreaDiv=function(){var l=runtime.getWindow().document,m=l.getElementById("testarea");runtime.assert(!!m&&m.parentNode===l.body,'Test environment broken, found no div with id "testarea" below body.');l.body.removeChild(m)};core.UnitTest.createOdtDocument=function(l,m){var h="",h=h+"";return runtime.parseXML(h)}; +core.UnitTestRunner=function(){function l(a){g+=1;runtime.log("fail",a)}function m(a,c){var b;try{if(a.length!==c.length)return l("array of length "+a.length+" should be "+c.length+" long"),!1;for(b=0;b1/f?"-0":String(f),l(c+" should be "+a+". Was "+d+".")):l(c+" should be "+a+" (of type "+typeof a+"). Was "+f+" (of type "+typeof f+").")}var g=0,d;d=function(a,c){var d=Object.keys(a),k=Object.keys(c);d.sort();k.sort();return m(d,k)&&Object.keys(a).every(function(f){var k= +a[f],d=c[f];return b(k,d)?!0:(l(k+" should be "+d+" for key "+f),!1)})};this.areNodesEqual=a;this.shouldBeNull=function(a,b){e(a,b,"null")};this.shouldBeNonNull=function(a,b){var d,k;try{k=eval(b)}catch(f){d=f}d?l(b+" should be non-null. Threw exception "+d):null!==k?runtime.log("pass",b+" is non-null."):l(b+" should be non-null. Was "+k)};this.shouldBe=e;this.countFailedTests=function(){return g}}; +core.UnitTester=function(){function l(a,b){return""+a+""}var m=0,h={};this.runTests=function(a,b,e){function g(a){if(0===a.length)h[d]=q,m+=p.countFailedTests(),b();else{f=a[0];var k=Runtime.getFunctionName(f);runtime.log("Running "+k);u=p.countFailedTests();c.setUp();f(function(){c.tearDown();q[k]=u===p.countFailedTests();g(a.slice(1))})}}var d=Runtime.getFunctionName(a),p=new core.UnitTestRunner,c=new a(p),q={},k,f,n,u,s="BrowserRuntime"=== +runtime.type();if(h.hasOwnProperty(d))runtime.log("Test "+d+" has already run.");else{s?runtime.log("Running "+l(d,'runSuite("'+d+'");')+": "+c.description()+""):runtime.log("Running "+d+": "+c.description);n=c.tests();for(k=0;kRunning "+l(a,'runTest("'+d+'","'+a+'")')+""):runtime.log("Running "+a),u=p.countFailedTests(),c.setUp(),f(),c.tearDown(),q[a]=u===p.countFailedTests()); +g(c.asyncTests())}};this.countFailedTests=function(){return m};this.results=function(){return h}}; // Input 13 -core.PositionIterator=function(l,m,e,c){function b(){this.acceptNode=function(a){return a.nodeType===Node.TEXT_NODE&&0===a.length?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}}function n(a){this.acceptNode=function(b){return b.nodeType===Node.TEXT_NODE&&0===b.length?NodeFilter.FILTER_REJECT:a.acceptNode(b)}}function a(){var a=f.currentNode.nodeType;d=a===Node.TEXT_NODE?f.currentNode.length-1:a===Node.ELEMENT_NODE?1:0}var h=this,f,d,t;this.nextPosition=function(){if(f.currentNode===l)return!1; -if(0===d&&f.currentNode.nodeType===Node.ELEMENT_NODE)null===f.firstChild()&&(d=1);else if(f.currentNode.nodeType===Node.TEXT_NODE&&d+1 "+a.length),runtime.assert(0<=b,"Error in setPosition: "+b+" < 0"), -b===a.length&&(d=void 0,f.nextSibling()?d=0:f.parentNode()&&(d=1),runtime.assert(void 0!==d,"Error in setPosition: position not valid.")),!0;g=t(a);b "+a.length),runtime.assert(0<=b,"Error in setPosition: "+b+" < 0"),b===a.length&&(c=void 0,p.nextSibling()?c=0:p.parentNode()&&(c=1),runtime.assert(void 0!==c,"Error in setPosition: position not valid.")),!0;e=q(a);for(g=a.parentNode;g&&g!==l&&e===NodeFilter.FILTER_ACCEPT;)e= +q(g),e!==NodeFilter.FILTER_ACCEPT&&(p.currentNode=g),g=g.parentNode;b>>8^k;return d^-1}function c(a){return new Date((a>>25&127)+1980,(a>>21&15)-1,a>>16&31,a>>11&15,a>>5&63,(a&31)<<1)}function b(a){var b=a.getFullYear();return 1980>b?0:b-1980<< -25|a.getMonth()+1<<21|a.getDate()<<16|a.getHours()<<11|a.getMinutes()<<5|a.getSeconds()>>1}function n(a,b){var d,g,k,h,f,e,n,r=this;this.load=function(b){if(void 0!==r.data)b(null,r.data);else{var d=f+34+g+k+256;d+n>p&&(d=p-n);runtime.read(a,n,d,function(d,g){if(d||null===g)b(d,g);else a:{var c=g,k=new core.ByteArray(c),p=k.readUInt32LE(),n;if(67324752!==p)b("File entry signature is wrong."+p.toString()+" "+c.length.toString(),null);else{k.pos+=22;p=k.readUInt16LE();n=k.readUInt16LE();k.pos+=p+n; -if(h){c=c.slice(k.pos,k.pos+f);if(f!==c.length){b("The amount of compressed bytes read was "+c.length.toString()+" instead of "+f.toString()+" for "+r.filename+" in "+a+".",null);break a}c=w(c,e)}else c=c.slice(k.pos,k.pos+e);e!==c.length?b("The amount of bytes read was "+c.length.toString()+" instead of "+e.toString()+" for "+r.filename+" in "+a+".",null):(r.data=c,b(null,c))}}})}};this.set=function(a,b,d,g){r.filename=a;r.data=b;r.compressed=d;r.date=g};this.error=null;b&&(d=b.readUInt32LE(),33639248!== -d?this.error="Central directory entry has wrong signature at position "+(b.pos-4).toString()+' for file "'+a+'": '+b.data.length.toString():(b.pos+=6,h=b.readUInt16LE(),this.date=c(b.readUInt32LE()),b.readUInt32LE(),f=b.readUInt32LE(),e=b.readUInt32LE(),g=b.readUInt16LE(),k=b.readUInt16LE(),d=b.readUInt16LE(),b.pos+=8,n=b.readUInt32LE(),this.filename=runtime.byteArrayToString(b.data.slice(b.pos,b.pos+g),"utf8"),b.pos+=g+k+d))}function a(a,b){if(22!==a.length)b("Central directory length should be 22.", -u);else{var d=new core.ByteArray(a),c;c=d.readUInt32LE();101010256!==c?b("Central directory signature is wrong: "+c.toString(),u):(c=d.readUInt16LE(),0!==c?b("Zip files with non-zero disk numbers are not supported.",u):(c=d.readUInt16LE(),0!==c?b("Zip files with non-zero disk numbers are not supported.",u):(c=d.readUInt16LE(),r=d.readUInt16LE(),c!==r?b("Number of entries is inconsistent.",u):(c=d.readUInt32LE(),d=d.readUInt16LE(),d=p-22-c,runtime.read(l,d,p-d,function(a,d){if(a||null===d)b(a,u);else a:{var c= -new core.ByteArray(d),k,h;g=[];for(k=0;kp?m("File '"+l+"' cannot be read.",u):runtime.read(l,p-22,22,function(b,d){b||null===m||null===d?m(b,u):a(d,m)})})}; +2932959818,3654703836,1088359270,936918E3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117],c,f,k=a.length,d=0,d=0;c=-1;for(f=0;f>>8^d;return c^-1}function a(a){return new Date((a>>25&127)+1980,(a>>21&15)-1,a>>16&31,a>>11&15,a>>5&63,(a&31)<<1)}function b(a){var b=a.getFullYear();return 1980>b?0:b-1980<< +25|a.getMonth()+1<<21|a.getDate()<<16|a.getHours()<<11|a.getMinutes()<<5|a.getSeconds()>>1}function e(b,c){var f,k,d,e,g,n,h,s=this;this.load=function(a){if(void 0!==s.data)a(null,s.data);else{var c=g+34+k+d+256;c+h>u&&(c=u-h);runtime.read(b,h,c,function(c,f){if(c||null===f)a(c,f);else a:{var k=f,d=new core.ByteArray(k),h=d.readUInt32LE(),v;if(67324752!==h)a("File entry signature is wrong."+h.toString()+" "+k.length.toString(),null);else{d.pos+=22;h=d.readUInt16LE();v=d.readUInt16LE();d.pos+=h+v; +if(e){k=k.slice(d.pos,d.pos+g);if(g!==k.length){a("The amount of compressed bytes read was "+k.length.toString()+" instead of "+g.toString()+" for "+s.filename+" in "+b+".",null);break a}k=x(k,n)}else k=k.slice(d.pos,d.pos+n);n!==k.length?a("The amount of bytes read was "+k.length.toString()+" instead of "+n.toString()+" for "+s.filename+" in "+b+".",null):(s.data=k,a(null,k))}}})}};this.set=function(a,b,c,f){s.filename=a;s.data=b;s.compressed=c;s.date=f};this.error=null;c&&(f=c.readUInt32LE(),33639248!== +f?this.error="Central directory entry has wrong signature at position "+(c.pos-4).toString()+' for file "'+b+'": '+c.data.length.toString():(c.pos+=6,e=c.readUInt16LE(),this.date=a(c.readUInt32LE()),c.readUInt32LE(),g=c.readUInt32LE(),n=c.readUInt32LE(),k=c.readUInt16LE(),d=c.readUInt16LE(),f=c.readUInt16LE(),c.pos+=8,h=c.readUInt32LE(),this.filename=runtime.byteArrayToString(c.data.slice(c.pos,c.pos+k),"utf8"),c.pos+=k+d+f))}function g(a,b){if(22!==a.length)b("Central directory length should be 22.", +r);else{var c=new core.ByteArray(a),f;f=c.readUInt32LE();101010256!==f?b("Central directory signature is wrong: "+f.toString(),r):(f=c.readUInt16LE(),0!==f?b("Zip files with non-zero disk numbers are not supported.",r):(f=c.readUInt16LE(),0!==f?b("Zip files with non-zero disk numbers are not supported.",r):(f=c.readUInt16LE(),s=c.readUInt16LE(),f!==s?b("Number of entries is inconsistent.",r):(f=c.readUInt32LE(),c=c.readUInt16LE(),c=u-22-f,runtime.read(l,c,u-c,function(a,c){if(a||null===c)b(a,r);else a:{var f= +new core.ByteArray(c),k,d;n=[];for(k=0;ku?m("File '"+l+"' cannot be read.",r):runtime.read(l,u-22,22,function(a,b){a||null===m||null===b?m(a,r):g(b,m)})})}; // Input 18 -core.CSSUnits=function(){var l={"in":1,cm:2.54,mm:25.4,pt:72,pc:12};this.convert=function(m,e,c){return m*l[c]/l[e]};this.convertMeasure=function(m,e){var c,b;m&&e?(c=parseFloat(m),b=m.replace(c.toString(),""),c=this.convert(c,b,e)):c="";return c.toString()};this.getUnits=function(m){return m.substr(m.length-2,m.length)}}; +core.CSSUnits=function(){var l={"in":1,cm:2.54,mm:25.4,pt:72,pc:12};this.convert=function(m,h,a){return m*l[a]/l[h]};this.convertMeasure=function(l,h){var a,b;l&&h?(a=parseFloat(l),b=l.replace(a.toString(),""),a=this.convert(a,b,h)):a="";return a.toString()};this.getUnits=function(l){return l.substr(l.length-2,l.length)}}; // Input 19 xmldom.LSSerializerFilter=function(){}; // Input 20 "function"!==typeof Object.create&&(Object.create=function(l){var m=function(){};m.prototype=l;return new m}); -xmldom.LSSerializer=function(){function l(b){var c=b||{},a=function(a){var b={},d;for(d in a)a.hasOwnProperty(d)&&(b[a[d]]=d);return b}(b),h=[c],f=[a],d=0;this.push=function(){d+=1;c=h[d]=Object.create(c);a=f[d]=Object.create(a)};this.pop=function(){h[d]=void 0;f[d]=void 0;d-=1;c=h[d];a=f[d]};this.getLocalNamespaceDefinitions=function(){return a};this.getQName=function(b){var d=b.namespaceURI,h=0,g;if(!d)return b.localName;if(g=a[d])return g+":"+b.localName;do{g||!b.prefix?(g="ns"+h,h+=1):g=b.prefix; -if(c[g]===d)break;if(!c[g]){c[g]=d;a[d]=g;break}g=null}while(null===g);return g+":"+b.localName}}function m(b){return b.replace(/&/g,"&").replace(//g,">").replace(/'/g,"'").replace(/"/g,""")}function e(b,n){var a="",h=c.filter?c.filter.acceptNode(n):NodeFilter.FILTER_ACCEPT,f;if(h===NodeFilter.FILTER_ACCEPT&&n.nodeType===Node.ELEMENT_NODE){b.push();f=b.getQName(n);var d,l=n.attributes,k,q,g,p="",r;d="<"+f;k=l.length;for(q=0;q")}if(h===NodeFilter.FILTER_ACCEPT||h===NodeFilter.FILTER_SKIP){for(h=n.firstChild;h;)a+=e(b,h),h=h.nextSibling;n.nodeValue&&(a+=m(n.nodeValue))}f&&(a+="",b.pop());return a}var c=this;this.filter=null;this.writeToString=function(b,c){if(!b)return"";var a=new l(c);return e(a,b)}}; +xmldom.LSSerializer=function(){function l(a){var e=a||{},g=function(a){var b={},c;for(c in a)a.hasOwnProperty(c)&&(b[a[c]]=c);return b}(a),d=[e],h=[g],c=0;this.push=function(){c+=1;e=d[c]=Object.create(e);g=h[c]=Object.create(g)};this.pop=function(){d[c]=void 0;h[c]=void 0;c-=1;e=d[c];g=h[c]};this.getLocalNamespaceDefinitions=function(){return g};this.getQName=function(a){var b=a.namespaceURI,c=0,d;if(!b)return a.localName;if(d=g[b])return d+":"+a.localName;do{d||!a.prefix?(d="ns"+c,c+=1):d=a.prefix; +if(e[d]===b)break;if(!e[d]){e[d]=b;g[b]=d;break}d=null}while(null===d);return d+":"+a.localName}}function m(a){return a.replace(/&/g,"&").replace(//g,">").replace(/'/g,"'").replace(/"/g,""")}function h(b,e){var g="",d=a.filter?a.filter.acceptNode(e):NodeFilter.FILTER_ACCEPT,l;if(d===NodeFilter.FILTER_ACCEPT&&e.nodeType===Node.ELEMENT_NODE){b.push();l=b.getQName(e);var c,q=e.attributes,k,f,n,u="",s;c="<"+l;k=q.length;for(f=0;f")}if(d===NodeFilter.FILTER_ACCEPT||d===NodeFilter.FILTER_SKIP){for(d=e.firstChild;d;)g+=h(b,d),d=d.nextSibling;e.nodeValue&&(g+=m(e.nodeValue))}l&&(g+="",b.pop());return g}var a=this;this.filter=null;this.writeToString=function(a,e){if(!a)return"";var g=new l(e);return h(g,a)}}; // Input 21 -xmldom.RelaxNGParser=function(){function l(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 m(a){if(2>=a.e.length)return a;var b={name:a.name,e:a.e.slice(0,2)};return m({name:a.name,e:[b].concat(a.e.slice(2))})}function e(a){a=a.split(":",2);var b="",c;1===a.length?a=["",a[0]]:b=a[0];for(c in h)h[c]===b&&(a[0]=c);return a}function c(a,b){for(var k=0,h,g,f=a.name;a.e&&k=a.e.length)return a;var b={name:a.name,e:a.e.slice(0,2)};return m({name:a.name,e:[b].concat(a.e.slice(2))})}function h(a){a=a.split(":",2);var b="",k;1===a.length?a=["",a[0]]:b=a[0];for(k in d)d[k]===b&&(a[0]=k);return a}function a(b,d){for(var k=0,f,e,g=b.name;b.e&&k=c.length)return b;0===g&&(g=0);for(var k=c.item(g);k.namespaceURI===d;){g+=1;if(g>=c.length)return b;k=c.item(g)}return k=h(a,b.attDeriv(a,c.item(g)),c,g+1)}function f(a,b,c){c.e[0].a?(a.push(c.e[0].text),b.push(c.e[0].a.ns)):f(a,b,c.e[0]);c.e[1].a?(a.push(c.e[1].text),b.push(c.e[1].a.ns)): -f(a,b,c.e[1])}var d="http://www.w3.org/2000/xmlns/",t,k,q,g,p,r,w,u,z,y,v={type:"notAllowed",nullable:!1,hash:"notAllowed",textDeriv:function(){return v},startTagOpenDeriv:function(){return v},attDeriv:function(){return v},startTagCloseDeriv:function(){return v},endTagDeriv:function(){return v}},s={type:"empty",nullable:!0,hash:"empty",textDeriv:function(){return v},startTagOpenDeriv:function(){return v},attDeriv:function(){return v},startTagCloseDeriv:function(){return s},endTagDeriv:function(){return v}}, -A={type:"text",nullable:!0,hash:"text",textDeriv:function(){return A},startTagOpenDeriv:function(){return v},attDeriv:function(){return v},startTagCloseDeriv:function(){return A},endTagDeriv:function(){return v}},I,D,N;t=c("choice",function(a,b){if(a===v)return b;if(b===v||a===b)return a},function(a,c){var d={},g;b(d,{p1:a,p2:c});c=a=void 0;for(g in d)d.hasOwnProperty(g)&&(void 0===a?a=d[g]:c=void 0===c?d[g]:t(c,d[g]));return function(a,b){return{type:"choice",p1:a,p2:b,nullable:a.nullable||b.nullable, -textDeriv:function(c,d){return t(a.textDeriv(c,d),b.textDeriv(c,d))},startTagOpenDeriv:e(function(c){return t(a.startTagOpenDeriv(c),b.startTagOpenDeriv(c))}),attDeriv:function(c,d){return t(a.attDeriv(c,d),b.attDeriv(c,d))},startTagCloseDeriv:l(function(){return t(a.startTagCloseDeriv(),b.startTagCloseDeriv())}),endTagDeriv:l(function(){return t(a.endTagDeriv(),b.endTagDeriv())})}}(a,c)});k=function(a,b,c){return function(){var d={},g=0;return function(h,k){var f=b&&b(h,k),e,p;if(void 0!==f)return f; -f=h.hash||h.toString();e=k.hash||k.toString();f=f.length)return b;0===k&&(k=0);for(var e=f.item(k);e.namespaceURI===c;){k+=1;if(k>=f.length)return b;e=f.item(k)}return e=d(a,b.attDeriv(a,f.item(k)),f,k+1)}function p(a,b,c){c.e[0].a?(a.push(c.e[0].text),b.push(c.e[0].a.ns)):p(a,b,c.e[0]);c.e[1].a?(a.push(c.e[1].text),b.push(c.e[1].a.ns)): +p(a,b,c.e[1])}var c="http://www.w3.org/2000/xmlns/",q,k,f,n,u,s,x,r,y,t,w={type:"notAllowed",nullable:!1,hash:"notAllowed",textDeriv:function(){return w},startTagOpenDeriv:function(){return w},attDeriv:function(){return w},startTagCloseDeriv:function(){return w},endTagDeriv:function(){return w}},v={type:"empty",nullable:!0,hash:"empty",textDeriv:function(){return w},startTagOpenDeriv:function(){return w},attDeriv:function(){return w},startTagCloseDeriv:function(){return v},endTagDeriv:function(){return w}}, +F={type:"text",nullable:!0,hash:"text",textDeriv:function(){return F},startTagOpenDeriv:function(){return w},attDeriv:function(){return w},startTagCloseDeriv:function(){return F},endTagDeriv:function(){return w}},J,z,L;q=a("choice",function(a,b){if(a===w)return b;if(b===w||a===b)return a},function(a,c){var f={},k;b(f,{p1:a,p2:c});c=a=void 0;for(k in f)f.hasOwnProperty(k)&&(void 0===a?a=f[k]:c=void 0===c?f[k]:q(c,f[k]));return function(a,b){return{type:"choice",p1:a,p2:b,nullable:a.nullable||b.nullable, +textDeriv:function(c,f){return q(a.textDeriv(c,f),b.textDeriv(c,f))},startTagOpenDeriv:h(function(c){return q(a.startTagOpenDeriv(c),b.startTagOpenDeriv(c))}),attDeriv:function(c,f){return q(a.attDeriv(c,f),b.attDeriv(c,f))},startTagCloseDeriv:l(function(){return q(a.startTagCloseDeriv(),b.startTagCloseDeriv())}),endTagDeriv:l(function(){return q(a.endTagDeriv(),b.endTagDeriv())})}}(a,c)});k=function(a,b,c){return function(){var f={},k=0;return function(d,e){var g=b&&b(d,e),n,h;if(void 0!==g)return g; +g=d.hash||d.toString();n=e.hash||e.toString();gNode.ELEMENT_NODE;){if(d!==Node.COMMENT_NODE&&(d!==Node.TEXT_NODE||!/^\s+$/.test(b.currentNode.nodeValue)))return[new l("Not allowed node of type "+ -d+".")];d=(c=b.nextSibling())?c.nodeType:0}if(!c)return[new l("Missing element "+a.names)];if(a.names&&-1===a.names.indexOf(n[c.namespaceURI]+":"+c.localName))return[new l("Found "+c.nodeName+" instead of "+a.names+".",c)];if(b.firstChild()){for(e=m(a.e[1],b,c);b.nextSibling();)if(d=b.currentNode.nodeType,!(b.currentNode&&b.currentNode.nodeType===Node.TEXT_NODE&&/^\s+$/.test(b.currentNode.nodeValue)||d===Node.COMMENT_NODE))return[new l("Spurious content.",b.currentNode)];if(b.parentNode()!==c)return[new l("Implementation error.")]}else e= -m(a.e[1],b,c);b.nextSibling();return e}var c,b,n;b=function(a,c,f,d){var n=a.name,k=null;if("text"===n)a:{for(var q=(a=c.currentNode)?a.nodeType:0;a!==f&&3!==q;){if(1===q){k=[new l("Element not allowed here.",a)];break a}q=(a=c.nextSibling())?a.nodeType:0}c.nextSibling();k=null}else if("data"===n)k=null;else if("value"===n)d!==a.text&&(k=[new l("Wrong value, should be '"+a.text+"', not '"+d+"'",f)]);else if("list"===n)k=null;else if("attribute"===n)a:{if(2!==a.e.length)throw"Attribute with wrong # of elements: "+ -a.e.length;n=a.localnames.length;for(k=0;kNode.ELEMENT_NODE;){if(c!==Node.COMMENT_NODE&&(c!==Node.TEXT_NODE||!/^\s+$/.test(b.currentNode.nodeValue)))return[new l("Not allowed node of type "+ +c+".")];c=(h=b.nextSibling())?h.nodeType:0}if(!h)return[new l("Missing element "+a.names)];if(a.names&&-1===a.names.indexOf(e[h.namespaceURI]+":"+h.localName))return[new l("Found "+h.nodeName+" instead of "+a.names+".",h)];if(b.firstChild()){for(q=m(a.e[1],b,h);b.nextSibling();)if(c=b.currentNode.nodeType,!(b.currentNode&&b.currentNode.nodeType===Node.TEXT_NODE&&/^\s+$/.test(b.currentNode.nodeValue)||c===Node.COMMENT_NODE))return[new l("Spurious content.",b.currentNode)];if(b.parentNode()!==h)return[new l("Implementation error.")]}else q= +m(a.e[1],b,h);b.nextSibling();return q}var a,b,e;b=function(a,d,e,c){var q=a.name,k=null;if("text"===q)a:{for(var f=(a=d.currentNode)?a.nodeType:0;a!==e&&3!==f;){if(1===f){k=[new l("Element not allowed here.",a)];break a}f=(a=d.nextSibling())?a.nodeType:0}d.nextSibling();k=null}else if("data"===q)k=null;else if("value"===q)c!==a.text&&(k=[new l("Wrong value, should be '"+a.text+"', not '"+c+"'",e)]);else if("list"===q)k=null;else if("attribute"===q)a:{if(2!==a.e.length)throw"Attribute with wrong # of elements: "+ +a.e.length;q=a.localnames.length;for(k=0;k=f&&c.push(m(a.substring(b,d)))):"["===a[d]&&(0>=f&&(b=d+1),f+=1),d+=1;return d};xmldom.XPathIterator.prototype.next=function(){};xmldom.XPathIterator.prototype.reset=function(){};d=function(d,f,g){var e,n,m,l;for(e=0;e=g&&c.push(m(a.substring(b,d)))):"["===a[d]&&(0>=g&&(b=d+1),g+=1),d+=1;return d};xmldom.XPathIterator.prototype.next=function(){};xmldom.XPathIterator.prototype.reset=function(){};c=function(c,f,e){var h,l,m,r;for(h=0;h=(m.getBoundingClientRect().top-y.bottom)/u?c.style.top=Math.abs(m.getBoundingClientRect().top-y.bottom)/u+20+"px":c.style.top="0px");n.style.left=d.getBoundingClientRect().width/u+"px";var d=n.style,m=n.getBoundingClientRect().left/u,z=n.getBoundingClientRect().top/u,y=c.getBoundingClientRect().left/u,v=c.getBoundingClientRect().top/u,s=0,A= -0,s=y-m,s=s*s,A=v-z,A=A*A,m=Math.sqrt(s+A);d.width=m+"px";u=Math.asin((c.getBoundingClientRect().top-n.getBoundingClientRect().top)/(u*parseFloat(n.style.width)));n.style.transform="rotate("+u+"rad)";n.style.MozTransform="rotate("+u+"rad)";n.style.WebkitTransform="rotate("+u+"rad)";n.style.msTransform="rotate("+u+"rad)";b&&(u=t.getComputedStyle(b,":before").content)&&"none"!==u&&(u=u.substring(1,u.length-1),b.firstChild?b.firstChild.nodeValue=u:b.appendChild(f.createTextNode(u)))}}var h=[],f=m.ownerDocument, -d=new odf.OdfUtils,t=runtime.getWindow();runtime.assert(Boolean(t),"Expected to be run in an environment which has a global window, like a browser.");this.rerenderAnnotations=a;this.addAnnotation=function(d){b(!0);h.push({node:d.node,end:d.end});n();var e=f.createElement("div"),g=f.createElement("div"),p=f.createElement("div"),m=f.createElement("div"),l=f.createElement("div"),u=d.node;e.className="annotationWrapper";u.parentNode.insertBefore(e,u);g.className="annotationNote";g.appendChild(u);l.className= -"annotationRemoveButton";g.appendChild(l);p.className="annotationConnector horizontal";m.className="annotationConnector angular";e.appendChild(g);e.appendChild(p);e.appendChild(m);d.end&&c(d);a()};this.forgetAnnotations=function(){for(;h.length;){var a=h[0],c=h.indexOf(a),d=a.node,e=d.parentNode.parentNode;"div"===e.localName&&(e.parentNode.insertBefore(d,e),e.parentNode.removeChild(e));a=a.node.getAttributeNS(odf.Namespaces.officens,"name");a=f.querySelectorAll('span.annotationHighlight[annotation="'+ -a+'"]');e=d=void 0;for(d=0;d=(m.getBoundingClientRect().top-t.bottom)/r?c.style.top=Math.abs(m.getBoundingClientRect().top-t.bottom)/r+20+"px":c.style.top="0px");g.style.left=e.getBoundingClientRect().width/r+"px";var e=g.style,m=g.getBoundingClientRect().left/r,y=g.getBoundingClientRect().top/r,t=c.getBoundingClientRect().left/r,w=c.getBoundingClientRect().top/r,v=0,F= +0,v=t-m,v=v*v,F=w-y,F=F*F,m=Math.sqrt(v+F);e.width=m+"px";r=Math.asin((c.getBoundingClientRect().top-g.getBoundingClientRect().top)/(r*parseFloat(g.style.width)));g.style.transform="rotate("+r+"rad)";g.style.MozTransform="rotate("+r+"rad)";g.style.WebkitTransform="rotate("+r+"rad)";g.style.msTransform="rotate("+r+"rad)";b&&(r=q.getComputedStyle(b,":before").content)&&"none"!==r&&(r=r.substring(1,r.length-1),b.firstChild?b.firstChild.nodeValue=r:b.appendChild(p.createTextNode(r)))}}var d=[],p=m.ownerDocument, +c=new odf.OdfUtils,q=runtime.getWindow();runtime.assert(Boolean(q),"Expected to be run in an environment which has a global window, like a browser.");this.rerenderAnnotations=g;this.addAnnotation=function(c){b(!0);d.push({node:c.node,end:c.end});e();var f=p.createElement("div"),h=p.createElement("div"),l=p.createElement("div"),m=p.createElement("div"),x=p.createElement("div"),r=c.node;f.className="annotationWrapper";r.parentNode.insertBefore(f,r);h.className="annotationNote";h.appendChild(r);x.className= +"annotationRemoveButton";h.appendChild(x);l.className="annotationConnector horizontal";m.className="annotationConnector angular";f.appendChild(h);f.appendChild(l);f.appendChild(m);c.end&&a(c);g()};this.forgetAnnotations=function(){for(;d.length;){var a=d[0],c=d.indexOf(a),e=a.node,g=e.parentNode.parentNode;"div"===g.localName&&(g.parentNode.insertBefore(e,g),g.parentNode.removeChild(g));a=a.node.getAttributeNS(odf.Namespaces.officens,"name");a=p.querySelectorAll('span.annotationHighlight[annotation="'+ +a+'"]');g=e=void 0;for(e=0;e + + @licstart + The JavaScript code in this page is free software: you can redistribute it + and/or modify it under the terms of the GNU Affero General Public License + (GNU AGPL) as published by the Free Software Foundation, either version 3 of + the License, or (at your option) any later version. The code is distributed + WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU AGPL for more details. + + As additional permission under GNU AGPL version 3 section 7, you + may distribute non-source (e.g., minimized or compacted) forms of + that code without the copy of the GNU GPL normally required by + section 4, provided you include this license notice and a URL + through which recipients can access the Corresponding Source. + + As a special exception to the AGPL, any HTML file which merely makes function + calls to this code, and for that purpose includes it by reference shall be + deemed a separate work for copyright law purposes. In addition, the copyright + holders of this code give you permission to combine this code with free + software libraries that are released under the GNU LGPL. You may copy and + distribute such a system following the terms of the GNU AGPL for this code + and the LGPL for the libraries. If you modify this code, you may extend this + exception to your version of the code, but you are not obligated to do so. + If you do not wish to do so, delete this exception statement from your + version. + + This license applies to this entire compilation. + @licend + @source: http://www.webodf.org/ + @source: http://gitorious.org/webodf/webodf/ +*/ +runtime.loadClass("xmldom.XPath");runtime.loadClass("odf.Namespaces"); +odf.StyleInfo=function(){function l(a,b){for(var c=v[a.localName],d=c&&c[a.namespaceURI],f=d?d.length:0,e,c=0;ca.value||"%"===a.unit)?null:a}function r(a){return(a=g(a))&&"%"!==a.unit?null:a}function w(a){switch(a.namespaceURI){case odf.Namespaces.drawns:case odf.Namespaces.svgns:case odf.Namespaces.dr3dns:return!1;case odf.Namespaces.textns:switch(a.localName){case "note-body":case "ruby-text":return!1}break;case odf.Namespaces.officens:switch(a.localName){case "annotation":case "binary-data":case "event-listeners":return!1}break;default:switch(a.localName){case "editinfo":return!1}}return!0} -var u="urn:oasis:names:tc:opendocument:xmlns:text:1.0",z="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0",y=/^\s*$/,v=new core.DomUtils;this.isParagraph=l;this.getParagraphElement=m;this.isWithinTrackedChanges=function(a,b){for(;a&&a!==b;){if(a.namespaceURI===u&&"tracked-changes"===a.localName)return!0;a=a.parentNode}return!1};this.isListItem=function(a){return"list-item"===(a&&a.localName)&&a.namespaceURI===u};this.isODFWhitespace=e;this.isGroupingElement=c;this.isCharacterElement=b;this.firstChild= -n;this.lastChild=a;this.previousNode=h;this.nextNode=f;this.scanLeftForNonWhitespace=d;this.lookLeftForCharacter=function(a){var c;c=0;a.nodeType===Node.TEXT_NODE&&0=b.value||"%"===b.unit)?null:b;return b||r(a)};this.parseFoLineHeight=function(a){return p(a)|| -r(a)};this.getImpactedParagraphs=function(a){var b=a.commonAncestorContainer,c=[];for(b.nodeType===Node.ELEMENT_NODE&&(c=v.getElementsByTagNameNS(b,u,"p").concat(v.getElementsByTagNameNS(b,u,"h")));b&&!l(b);)b=b.parentNode;b&&c.push(b);return c.filter(function(b){return v.rangeIntersectsNode(a,b)})};this.getTextNodes=function(a,b){var c=a.startContainer.ownerDocument.createRange(),d;d=v.getNodesInRange(a,function(d){c.selectNodeContents(d);if(d.nodeType===Node.TEXT_NODE){if(b&&v.rangesIntersect(a, -c)||v.containsRange(a,c))return Boolean(m(d)&&(!e(d.textContent)||q(d,0)))?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT}else if(v.rangesIntersect(a,c)&&w(d))return NodeFilter.FILTER_SKIP;return NodeFilter.FILTER_REJECT});c.detach();return d};this.getTextElements=function(a,d){var g=a.startContainer.ownerDocument.createRange(),f;f=v.getNodesInRange(a,function(f){var h=f.nodeType;g.selectNodeContents(f);if(h===Node.TEXT_NODE){if(v.containsRange(a,g)&&(d||Boolean(m(f)&&(!e(f.textContent)||q(f,0)))))return NodeFilter.FILTER_ACCEPT}else if(b(f)){if(v.containsRange(a, -g))return NodeFilter.FILTER_ACCEPT}else if(w(f)||c(f))return NodeFilter.FILTER_SKIP;return NodeFilter.FILTER_REJECT});g.detach();return f};this.getParagraphElements=function(a){var b=a.startContainer.ownerDocument.createRange(),d;d=v.getNodesInRange(a,function(d){b.selectNodeContents(d);if(l(d)){if(v.rangesIntersect(a,b))return NodeFilter.FILTER_ACCEPT}else if(w(d)||c(d))return NodeFilter.FILTER_SKIP;return NodeFilter.FILTER_REJECT});b.detach();return d}}; +runtime.loadClass("core.DomUtils");runtime.loadClass("odf.Namespaces"); +odf.OdfUtils=function(){function l(a){var b=a&&a.localName;return("p"===b||"h"===b)&&a.namespaceURI===r}function m(a){for(;a&&!l(a);)a=a.parentNode;return a}function h(a){return/^[ \t\r\n]+$/.test(a)}function a(a){var b=a&&a.localName;return/^(span|p|h|a|meta)$/.test(b)&&a.namespaceURI===r||"span"===b&&"annotationHighlight"===a.className?!0:!1}function b(a){var b=a&&a.localName,c,d=!1;b&&(c=a.namespaceURI,c===r?d="s"===b||"tab"===b||"line-break"===b:c===y&&(d="frame"===b&&"as-char"===a.getAttributeNS(r, +"anchor-type")));return d}function e(b){for(;null!==b.firstChild&&a(b);)b=b.firstChild;return b}function g(b){for(;null!==b.lastChild&&a(b);)b=b.lastChild;return b}function d(a){for(;!l(a)&&null===a.previousSibling;)a=a.parentNode;return l(a)?null:g(a.previousSibling)}function p(a){for(;!l(a)&&null===a.nextSibling;)a=a.parentNode;return l(a)?null:e(a.nextSibling)}function c(a){for(var c=!1;a;)if(a.nodeType===Node.TEXT_NODE)if(0===a.length)a=d(a);else return!h(a.data.substr(a.length-1,1));else b(a)? +(c=!0,a=null):a=d(a);return c}function q(a){var c=!1;for(a=a&&e(a);a;){if(a.nodeType===Node.TEXT_NODE&&0a.value||"%"===a.unit)?null:a}function s(a){return(a=n(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 r=odf.Namespaces.textns,y=odf.Namespaces.drawns,t=/^\s*$/,w=new core.DomUtils;this.isParagraph=l;this.getParagraphElement=m;this.isWithinTrackedChanges=function(a,b){for(;a&&a!==b;){if(a.namespaceURI===r&&"tracked-changes"===a.localName)return!0;a=a.parentNode}return!1};this.isListItem=function(a){return"list-item"===(a&&a.localName)&&a.namespaceURI===r};this.isODFWhitespace=h;this.isGroupingElement=a;this.isCharacterElement=b;this.firstChild=e;this.lastChild=g;this.previousNode=d;this.nextNode= +p;this.scanLeftForNonWhitespace=c;this.lookLeftForCharacter=function(a){var f;f=0;a.nodeType===Node.TEXT_NODE&&0=b.value|| +"%"===b.unit)?null:b;return b||s(a)};this.parseFoLineHeight=function(a){return u(a)||s(a)};this.getImpactedParagraphs=function(a){var b=a.commonAncestorContainer,c=[];for(b.nodeType===Node.ELEMENT_NODE&&(c=w.getElementsByTagNameNS(b,r,"p").concat(w.getElementsByTagNameNS(b,r,"h")));b&&!l(b);)b=b.parentNode;b&&c.push(b);return c.filter(function(b){return w.rangeIntersectsNode(a,b)})};this.getTextNodes=function(a,b){var c=a.startContainer.ownerDocument.createRange(),d;d=w.getNodesInRange(a,function(d){c.selectNodeContents(d); +if(d.nodeType===Node.TEXT_NODE){if(b&&w.rangesIntersect(a,c)||w.containsRange(a,c))return Boolean(m(d)&&(!h(d.textContent)||f(d,0)))?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT}else if(w.rangesIntersect(a,c)&&x(d))return NodeFilter.FILTER_SKIP;return NodeFilter.FILTER_REJECT});c.detach();return d};this.getTextElements=function(c,d){var e=c.startContainer.ownerDocument.createRange(),k;k=w.getNodesInRange(c,function(k){var g=k.nodeType;e.selectNodeContents(k);if(g===Node.TEXT_NODE){if(w.containsRange(c, +e)&&(d||Boolean(m(k)&&(!h(k.textContent)||f(k,0)))))return NodeFilter.FILTER_ACCEPT}else if(b(k)){if(w.containsRange(c,e))return NodeFilter.FILTER_ACCEPT}else if(x(k)||a(k))return NodeFilter.FILTER_SKIP;return NodeFilter.FILTER_REJECT});e.detach();return k};this.getParagraphElements=function(b){var c=b.startContainer.ownerDocument.createRange(),d;d=w.getNodesInRange(b,function(d){c.selectNodeContents(d);if(l(d)){if(w.rangesIntersect(b,c))return NodeFilter.FILTER_ACCEPT}else if(x(d)||a(d))return NodeFilter.FILTER_SKIP; +return NodeFilter.FILTER_REJECT});c.detach();return d}}; // Input 30 /* @@ -565,7 +603,7 @@ g))return NodeFilter.FILTER_ACCEPT}else if(w(f)||c(f))return NodeFilter.FILTER_S @source: http://gitorious.org/webodf/webodf/ */ runtime.loadClass("odf.OdfUtils"); -odf.TextSerializer=function(){function l(c){var b="",n=m.filter?m.filter.acceptNode(c):NodeFilter.FILTER_ACCEPT,a=c.nodeType,h;if(n===NodeFilter.FILTER_ACCEPT||n===NodeFilter.FILTER_SKIP)for(h=c.firstChild;h;)b+=l(h),h=h.nextSibling;n===NodeFilter.FILTER_ACCEPT&&(a===Node.ELEMENT_NODE&&e.isParagraph(c)?b+="\n":a===Node.TEXT_NODE&&c.textContent&&(b+=c.textContent));return b}var m=this,e=new odf.OdfUtils;this.filter=null;this.writeToString=function(c){return c?l(c):""}}; +odf.TextSerializer=function(){function l(a){var b="",e=m.filter?m.filter.acceptNode(a):NodeFilter.FILTER_ACCEPT,g=a.nodeType,d;if(e===NodeFilter.FILTER_ACCEPT||e===NodeFilter.FILTER_SKIP)for(d=a.firstChild;d;)b+=l(d),d=d.nextSibling;e===NodeFilter.FILTER_ACCEPT&&(g===Node.ELEMENT_NODE&&h.isParagraph(a)?b+="\n":g===Node.TEXT_NODE&&a.textContent&&(b+=a.textContent));return b}var m=this,h=new odf.OdfUtils;this.filter=null;this.writeToString=function(a){return a?l(a):""}}; // Input 31 /* @@ -602,10 +640,10 @@ odf.TextSerializer=function(){function l(c){var b="",n=m.filter?m.filter.acceptN @source: http://gitorious.org/webodf/webodf/ */ runtime.loadClass("core.DomUtils");runtime.loadClass("core.LoopWatchDog");runtime.loadClass("odf.Namespaces"); -odf.TextStyleApplicator=function(l,m,e){function c(a){function b(a,c){return"object"===typeof a&&"object"===typeof c?Object.keys(a).every(function(d){return b(a[d],c[d])}):a===c}this.isStyleApplied=function(c){c=m.getAppliedStylesForElement(c);return b(a,c)}}function b(b){var c={};this.applyStyleToContainer=function(k){var n;n=k.getAttributeNS(a,"style-name");var g=k.ownerDocument;n=n||"";if(!c.hasOwnProperty(n)){var p=n,r;r=n?m.createDerivedStyleObject(n,"text",b):b;g=g.createElementNS(h,"style:style"); -m.updateStyle(g,r);g.setAttributeNS(h,"style:name",l.generateName());g.setAttributeNS(h,"style:family","text");g.setAttributeNS(f,"scope","document-content");e.appendChild(g);c[p]=g}n=c[n].getAttributeNS(h,"name");k.setAttributeNS(a,"text:style-name",n)}}var n=new core.DomUtils,a=odf.Namespaces.textns,h=odf.Namespaces.stylens,f="urn:webodf:names:scope";this.applyStyle=function(d,f,h){var e={},g,m,l,w;runtime.assert(h&&h["style:text-properties"],"applyStyle without any text properties");e["style:text-properties"]= -h["style:text-properties"];l=new b(e);w=new c(e);d.forEach(function(b){g=w.isStyleApplied(b);if(!1===g){var c=b.ownerDocument,d=b.parentNode,h,e=b,k=new core.LoopWatchDog(1E3);"span"===d.localName&&d.namespaceURI===a?(b.previousSibling&&!n.rangeContainsNode(f,b.previousSibling)?(c=d.cloneNode(!1),d.parentNode.insertBefore(c,d.nextSibling)):c=d,h=!0):(c=c.createElementNS(a,"text:span"),d.insertBefore(c,b),h=!1);for(;e&&(e===b||n.rangeContainsNode(f,e));)k.check(),d=e.nextSibling,e.parentNode!==c&& -c.appendChild(e),e=d;if(e&&h)for(b=c.cloneNode(!1),c.parentNode.insertBefore(b,c.nextSibling);e;)k.check(),d=e.nextSibling,b.appendChild(e),e=d;m=c;l.applyStyleToContainer(m)}})}}; +odf.TextStyleApplicator=function(l,m,h){function a(a){function b(a,c){return"object"===typeof a&&"object"===typeof c?Object.keys(a).every(function(d){return b(a[d],c[d])}):a===c}this.isStyleApplied=function(d){d=m.getAppliedStylesForElement(d);return b(a,d)}}function b(a){var b={};this.applyStyleToContainer=function(e){var f;f=e.getAttributeNS(d,"style-name");var g=e.ownerDocument;f=f||"";if(!b.hasOwnProperty(f)){var u=f,s;s=f?m.createDerivedStyleObject(f,"text",a):a;g=g.createElementNS(p,"style:style"); +m.updateStyle(g,s);g.setAttributeNS(p,"style:name",l.generateName());g.setAttributeNS(p,"style:family","text");g.setAttributeNS("urn:webodf:names:scope","scope","document-content");h.appendChild(g);b[u]=g}f=b[f].getAttributeNS(p,"name");e.setAttributeNS(d,"text:style-name",f)}}function e(a,b){var e=a.ownerDocument,f=a.parentNode,h,l,m=new core.LoopWatchDog(1E3);l=[];"span"!==f.localName||f.namespaceURI!==d?(h=e.createElementNS(d,"text:span"),f.insertBefore(h,a),f=!1):(a.previousSibling&&!g.rangeContainsNode(b, +f.firstChild)?(h=f.cloneNode(!1),f.parentNode.insertBefore(h,f.nextSibling)):h=f,f=!0);l.push(a);for(e=a.nextSibling;e&&g.rangeContainsNode(b,e);)m.check(),l.push(e),e=e.nextSibling;l.forEach(function(a){a.parentNode!==h&&h.appendChild(a)});if(e&&f)for(l=h.cloneNode(!1),h.parentNode.insertBefore(l,h.nextSibling);e;)m.check(),f=e.nextSibling,l.appendChild(e),e=f;return h}var g=new core.DomUtils,d=odf.Namespaces.textns,p=odf.Namespaces.stylens;this.applyStyle=function(c,d,g){var f={},h,l,m,x;runtime.assert(g&& +g["style:text-properties"],"applyStyle without any text properties");f["style:text-properties"]=g["style:text-properties"];m=new b(f);x=new a(f);c.forEach(function(a){h=x.isStyleApplied(a);!1===h&&(l=e(a,d),m.applyStyleToContainer(l))})}}; // Input 32 /* @@ -642,49 +680,86 @@ c.appendChild(e),e=d;if(e&&h)for(b=c.cloneNode(!1),c.parentNode.insertBefore(b,c @source: http://gitorious.org/webodf/webodf/ */ runtime.loadClass("odf.Namespaces");runtime.loadClass("odf.OdfUtils");runtime.loadClass("xmldom.XPath");runtime.loadClass("core.CSSUnits"); -odf.Style2CSS=function(){function l(a){var b={},c,d;if(!a)return b;for(a=a.firstChild;a;){if(d=a.namespaceURI!==p||"style"!==a.localName&&"default-style"!==a.localName?a.namespaceURI===u&&"list-style"===a.localName?"list":a.namespaceURI!==p||"page-layout"!==a.localName&&"default-page-layout"!==a.localName?void 0:"page":a.getAttributeNS(p,"family"))(c=a.getAttributeNS&&a.getAttributeNS(p,"name"))||(c=""),d=b[d]=b[d]||{},d[c]=a;a=a.nextSibling}return b}function m(a,b){if(!b||!a)return null;if(a[b])return a[b]; -var c,d;for(c in a)if(a.hasOwnProperty(c)&&(d=m(a[c].derivedStyles,b)))return d;return null}function e(a,b,c){var d=b[a],f,g;d&&(f=d.getAttributeNS(p,"parent-style-name"),g=null,f&&(g=m(c,f),!g&&b[f]&&(e(f,b,c),g=b[f],b[f]=null)),g?(g.derivedStyles||(g.derivedStyles={}),g.derivedStyles[a]=d):c[a]=d)}function c(a,b){for(var c in a)a.hasOwnProperty(c)&&(e(c,a,b),a[c]=null)}function b(a,b){var c=v[a],d;if(null===c)return null;d=b?"["+c+'|style-name="'+b+'"]':"["+c+"|style-name]";"presentation"===c&& -(c="draw",d=b?'[presentation|style-name="'+b+'"]':"[presentation|style-name]");return c+"|"+s[a].join(d+","+c+"|")+d}function n(a,c,d){var f=[],g,h;f.push(b(a,c));for(g in d.derivedStyles)if(d.derivedStyles.hasOwnProperty(g))for(h in c=n(a,g,d.derivedStyles[g]),c)c.hasOwnProperty(h)&&f.push(c[h]);return f}function a(a,b,c){if(!a)return null;for(a=a.firstChild;a;){if(a.namespaceURI===b&&a.localName===c)return b=a;a=a.nextSibling}return null}function h(a,b){var c="",d,f;for(d in b)if(b.hasOwnProperty(d)&& -(d=b[d],f=a.getAttributeNS(d[0],d[1]))){f=f.trim();if(M.hasOwnProperty(d[1])){var g=f.indexOf(" "),h=void 0,e=void 0;-1!==g?(h=f.substring(0,g),e=f.substring(g)):(h=f,e="");(h=Y.parseLength(h))&&("pt"===h.unit&&0.75>h.value)&&(f="0.75pt"+e)}d[2]&&(c+=d[2]+":"+f+";")}return c}function f(b){return(b=a(b,p,"text-properties"))?Y.parseFoFontSize(b.getAttributeNS(g,"font-size")):null}function d(a){a=a.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i,function(a,b,c,d){return b+b+c+c+d+d});return(a=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(a))? -{r:parseInt(a[1],16),g:parseInt(a[2],16),b:parseInt(a[3],16)}:null}function t(a,b,c,d){b='text|list[text|style-name="'+b+'"]';var f=c.getAttributeNS(u,"level"),g;c=Y.getFirstNonWhitespaceChild(c);c=Y.getFirstNonWhitespaceChild(c);var h;c&&(g=c.attributes,h=g["fo:text-indent"]?g["fo:text-indent"].value:void 0,g=g["fo:margin-left"]?g["fo:margin-left"].value:void 0);h||(h="-0.6cm");c="-"===h.charAt(0)?h.substring(1):"-"+h;for(f=f&&parseInt(f,10);1 text|list-item > text|list",f-=1;f=b+" > text|list-item > *:not(text|list):first-child"; -void 0!==g&&(g=f+"{margin-left:"+g+";}",a.insertRule(g,a.cssRules.length));d=b+" > text|list-item > *:not(text|list):first-child:before{"+d+";";d+="counter-increment:list;";d+="margin-left:"+h+";";d+="width:"+c+";";d+="display:inline-block}";try{a.insertRule(d,a.cssRules.length)}catch(e){throw e;}}function k(b,c,e,m){if("list"===c)for(var l=m.firstChild,r,s;l;){if(l.namespaceURI===u)if(r=l,"list-level-style-number"===l.localName){var v=r;s=v.getAttributeNS(p,"num-format");var M=v.getAttributeNS(p, -"num-suffix"),F={1:"decimal",a:"lower-latin",A:"upper-latin",i:"lower-roman",I:"upper-roman"},v=v.getAttributeNS(p,"num-prefix")||"",v=F.hasOwnProperty(s)?v+(" counter(list, "+F[s]+")"):s?v+("'"+s+"';"):v+" ''";M&&(v+=" '"+M+"'");s="content: "+v+";";t(b,e,r,s)}else"list-level-style-image"===l.localName?(s="content: none;",t(b,e,r,s)):"list-level-style-bullet"===l.localName&&(s="content: '"+r.getAttributeNS(u,"bullet-char")+"';",t(b,e,r,s));l=l.nextSibling}else if("page"===c)if(M=r=e="",l=m.getElementsByTagNameNS(p, -"page-layout-properties")[0],r=l.parentNode.parentNode.parentNode.masterStyles,M="",e+=h(l,ea),s=l.getElementsByTagNameNS(p,"background-image"),0g.value)&&(f="0.75pt"+k)}d[2]&&(c+=d[2]+":"+f+";")}return c}function p(a){return(a=g(a,u,"text-properties"))?V.parseFoFontSize(a.getAttributeNS(n,"font-size")):null}function c(a){a=a.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i,function(a,b,c,d){return b+b+c+c+d+d});return(a=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(a))?{r:parseInt(a[1],16),g:parseInt(a[2],16),b:parseInt(a[3], +16)}:null}function q(a,b,c,d){b='text|list[text|style-name="'+b+'"]';var f=c.getAttributeNS(r,"level"),e;c=V.getFirstNonWhitespaceChild(c);c=V.getFirstNonWhitespaceChild(c);var g;c&&(e=c.attributes,g=e["fo:text-indent"]?e["fo:text-indent"].value:void 0,e=e["fo:margin-left"]?e["fo:margin-left"].value:void 0);g||(g="-0.6cm");c="-"===g.charAt(0)?g.substring(1):"-"+g;for(f=f&&parseInt(f,10);1 text|list-item > text|list",f-=1;f=b+" > text|list-item > *:not(text|list):first-child";void 0!==e&& +(e=f+"{margin-left:"+e+";}",a.insertRule(e,a.cssRules.length));d=b+" > text|list-item > *:not(text|list):first-child:before{"+d+";";d+="counter-increment:list;";d+="margin-left:"+g+";";d+="width:"+c+";";d+="display:inline-block}";try{a.insertRule(d,a.cssRules.length)}catch(k){throw k;}}function k(a,b,h,l){if("list"===b)for(var m=l.firstChild,s,v;m;){if(m.namespaceURI===r)if(s=m,"list-level-style-number"===m.localName){var w=s;v=w.getAttributeNS(u,"num-format");var N=w.getAttributeNS(u,"num-suffix"), +K={1:"decimal",a:"lower-latin",A:"upper-latin",i:"lower-roman",I:"upper-roman"},w=w.getAttributeNS(u,"num-prefix")||"",w=K.hasOwnProperty(v)?w+(" counter(list, "+K[v]+")"):v?w+("'"+v+"';"):w+" ''";N&&(w+=" '"+N+"'");v="content: "+w+";";q(a,h,s,v)}else"list-level-style-image"===m.localName?(v="content: none;",q(a,h,s,v)):"list-level-style-bullet"===m.localName&&(v="content: '"+s.getAttributeNS(r,"bullet-char")+"';",q(a,h,s,v));m=m.nextSibling}else if("page"===b)if(N=s=h="",m=l.getElementsByTagNameNS(u, +"page-layout-properties")[0],s=m.parentNode.parentNode.parentNode.masterStyles,N="",h+=d(m,ea),v=m.getElementsByTagNameNS(u,"background-image"),0 + + @licstart + The JavaScript code in this page is free software: you can redistribute it + and/or modify it under the terms of the GNU Affero General Public License + (GNU AGPL) as published by the Free Software Foundation, either version 3 of + the License, or (at your option) any later version. The code is distributed + WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU AGPL for more details. + + As additional permission under GNU AGPL version 3 section 7, you + may distribute non-source (e.g., minimized or compacted) forms of + that code without the copy of the GNU GPL normally required by + section 4, provided you include this license notice and a URL + through which recipients can access the Corresponding Source. + + As a special exception to the AGPL, any HTML file which merely makes function + calls to this code, and for that purpose includes it by reference shall be + deemed a separate work for copyright law purposes. In addition, the copyright + holders of this code give you permission to combine this code with free + software libraries that are released under the GNU LGPL. You may copy and + distribute such a system following the terms of the GNU AGPL for this code + and the LGPL for the libraries. If you modify this code, you may extend this + exception to your version of the code, but you are not obligated to do so. + If you do not wish to do so, delete this exception statement from your + version. + + This license applies to this entire compilation. + @licend + @source: http://www.webodf.org/ + @source: http://gitorious.org/webodf/webodf/ +*/ runtime.loadClass("core.Base64");runtime.loadClass("core.Zip");runtime.loadClass("xmldom.LSSerializer");runtime.loadClass("odf.StyleInfo");runtime.loadClass("odf.Namespaces");runtime.loadClass("odf.OdfNodeFilter"); -odf.OdfContainer=function(){function l(a,b,c){for(a=a?a.firstChild:null;a;){if(a.localName===c&&a.namespaceURI===b)return a;a=a.nextSibling}return null}function m(a){var b,c=k.length;for(b=0;bc)break;f=f.nextSibling}a.insertBefore(b,f)}}}function n(a){this.OdfContainer=a}function a(a, -b,c,d){var f=this;this.size=0;this.type=null;this.name=a;this.container=c;this.onchange=this.onreadystatechange=this.document=this.mimetype=this.url=null;this.EMPTY=0;this.LOADING=1;this.DONE=2;this.state=this.EMPTY;this.load=function(){null!==d&&(this.mimetype=b,d.loadAsDataURL(a,b,function(a,b){a&&runtime.log(a);f.url=b;if(f.onchange)f.onchange(f);if(f.onstatereadychange)f.onstatereadychange(f)}))}}var h=new odf.StyleInfo,f="urn:oasis:names:tc:opendocument:xmlns:office:1.0",d="urn:oasis:names:tc:opendocument:xmlns:manifest:1.0", -t="urn:webodf:names:scope",k="meta settings scripts font-face-decls styles automatic-styles master-styles body".split(" "),q=(new Date).getTime()+"_webodf_",g=new core.Base64;n.prototype=new function(){};n.prototype.constructor=n;n.namespaceURI=f;n.localName="document";a.prototype.load=function(){};a.prototype.getUrl=function(){return this.data?"data:;base64,"+g.toBase64(this.data):null};odf.OdfContainer=function r(g,k){function m(a){for(var b=a.firstChild,c;b;)c=b.nextSibling,b.nodeType===Node.ELEMENT_NODE? -m(b):b.nodeType===Node.PROCESSING_INSTRUCTION_NODE&&a.removeChild(b),b=c}function y(a,b){for(var c=a&&a.firstChild;c;)c.nodeType===Node.ELEMENT_NODE&&c.setAttributeNS(t,"scope",b),c=c.nextSibling}function v(a,b){var c=null,d,f,g;if(a)for(c=a.cloneNode(!0),d=c.firstChild;d;)f=d.nextSibling,d.nodeType===Node.ELEMENT_NODE&&(g=d.getAttributeNS(t,"scope"))&&g!==b&&c.removeChild(d),d=f;return c}function s(a){var b=G.rootElement.ownerDocument,c;if(a){m(a.documentElement);try{c=b.importNode(a.documentElement, -!0)}catch(d){}}return c}function A(a){G.state=a;if(G.onchange)G.onchange(G);if(G.onstatereadychange)G.onstatereadychange(G)}function I(a){ca=null;G.rootElement=a;a.fontFaceDecls=l(a,f,"font-face-decls");a.styles=l(a,f,"styles");a.automaticStyles=l(a,f,"automatic-styles");a.masterStyles=l(a,f,"master-styles");a.body=l(a,f,"body");a.meta=l(a,f,"meta")}function D(a){a=s(a);var c=G.rootElement;a&&"document-styles"===a.localName&&a.namespaceURI===f?(c.fontFaceDecls=l(a,f,"font-face-decls"),b(c,c.fontFaceDecls), -c.styles=l(a,f,"styles"),b(c,c.styles),c.automaticStyles=l(a,f,"automatic-styles"),y(c.automaticStyles,"document-styles"),b(c,c.automaticStyles),c.masterStyles=l(a,f,"master-styles"),b(c,c.masterStyles),h.prefixStyleNames(c.automaticStyles,q,c.masterStyles)):A(r.INVALID)}function N(a){a=s(a);var c,d,g;if(a&&"document-content"===a.localName&&a.namespaceURI===f){c=G.rootElement;d=l(a,f,"font-face-decls");if(c.fontFaceDecls&&d)for(g=d.firstChild;g;)c.fontFaceDecls.appendChild(g),g=d.firstChild;else d&& -(c.fontFaceDecls=d,b(c,d));d=l(a,f,"automatic-styles");y(d,"document-content");if(c.automaticStyles&&d)for(g=d.firstChild;g;)c.automaticStyles.appendChild(g),g=d.firstChild;else d&&(c.automaticStyles=d,b(c,d));c.body=l(a,f,"body");b(c,c.body)}else A(r.INVALID)}function B(a){a=s(a);var c;a&&("document-meta"===a.localName&&a.namespaceURI===f)&&(c=G.rootElement,c.meta=l(a,f,"meta"),b(c,c.meta))}function L(a){a=s(a);var c;a&&("document-settings"===a.localName&&a.namespaceURI===f)&&(c=G.rootElement,c.settings= -l(a,f,"settings"),b(c,c.settings))}function C(a){a=s(a);var b;if(a&&"manifest"===a.localName&&a.namespaceURI===d)for(b=G.rootElement,b.manifest=a,a=b.manifest.firstChild;a;)a.nodeType===Node.ELEMENT_NODE&&("file-entry"===a.localName&&a.namespaceURI===d)&&(R[a.getAttributeNS(d,"full-path")]=a.getAttributeNS(d,"media-type")),a=a.nextSibling}function K(a){var b=a.shift(),c,d;b?(c=b[0],d=b[1],H.loadAsDOM(c,function(b,c){d(c);b||G.state===r.INVALID||K(a)})):A(r.DONE)}function ea(a){var b="";odf.Namespaces.forEachPrefix(function(a, -c){b+=" xmlns:"+a+'="'+c+'"'});return''}function pa(){var a=new xmldom.LSSerializer,b=ea("document-meta");a.filter=new odf.OdfNodeFilter;b+=a.writeToString(G.rootElement.meta,odf.Namespaces.namespaceMap);return b+""}function M(a,b){var c=document.createElementNS(d,"manifest:file-entry");c.setAttributeNS(d,"manifest:full-path",a);c.setAttributeNS(d,"manifest:media-type",b);return c}function qa(){var a= -runtime.parseXML(''),b=l(a,d,"manifest"),c=new xmldom.LSSerializer,f;for(f in R)R.hasOwnProperty(f)&&b.appendChild(M(f,R[f]));c.filter=new odf.OdfNodeFilter;return'\n'+c.writeToString(a,odf.Namespaces.namespaceMap)}function Y(){var a=new xmldom.LSSerializer,b=ea("document-settings");a.filter=new odf.OdfNodeFilter;b+=a.writeToString(G.rootElement.settings,odf.Namespaces.namespaceMap); -return b+""}function Z(){var a=odf.Namespaces.namespaceMap,b=new xmldom.LSSerializer,c=v(G.rootElement.automaticStyles,"document-styles"),d=G.rootElement.masterStyles&&G.rootElement.masterStyles.cloneNode(!0),f=ea("document-styles");h.removePrefixFromStyleNames(c,q,d);b.filter=new e(d,c);f+=b.writeToString(G.rootElement.fontFaceDecls,a);f+=b.writeToString(G.rootElement.styles,a);f+=b.writeToString(c,a);f+=b.writeToString(d,a);return f+""}function Q(){var a= -odf.Namespaces.namespaceMap,b=new xmldom.LSSerializer,d=v(G.rootElement.automaticStyles,"document-content"),f=ea("document-content");b.filter=new c(G.rootElement.body,d);f+=b.writeToString(d,a);f+=b.writeToString(G.rootElement.body,a);return f+""}function $(a,b){runtime.loadXML(a,function(a,c){if(a)b(a);else{var d=s(c);d&&"document"===d.localName&&d.namespaceURI===f?(I(d),A(r.DONE)):A(r.INVALID)}})}function T(){function a(b,c){var g;c||(c=b);g=document.createElementNS(f, -c);d[b]=g;d.appendChild(g)}var b=new core.Zip("",null),c=runtime.byteArrayFromString("application/vnd.oasis.opendocument.text","utf8"),d=G.rootElement,g=document.createElementNS(f,"text");b.save("mimetype",c,!1,new Date);a("meta");a("settings");a("scripts");a("fontFaceDecls","font-face-decls");a("styles");a("automaticStyles","automatic-styles");a("masterStyles","master-styles");a("body");d.body.appendChild(g);A(r.DONE);return b}function P(){var a,b=new Date;a=runtime.byteArrayFromString(Y(),"utf8"); -H.save("settings.xml",a,!0,b);a=runtime.byteArrayFromString(pa(),"utf8");H.save("meta.xml",a,!0,b);a=runtime.byteArrayFromString(Z(),"utf8");H.save("styles.xml",a,!0,b);a=runtime.byteArrayFromString(Q(),"utf8");H.save("content.xml",a,!0,b);a=runtime.byteArrayFromString(qa(),"utf8");H.save("META-INF/manifest.xml",a,!0,b)}function J(a,b){P();H.writeAs(a,function(a){b(a)})}var G=this,H,R={},ca;this.onstatereadychange=k;this.rootElement=this.state=this.onchange=null;this.setRootElement=I;this.getContentElement= -function(){var a;ca||(a=G.rootElement.body,ca=a.getElementsByTagNameNS(f,"text")[0]||a.getElementsByTagNameNS(f,"presentation")[0]||a.getElementsByTagNameNS(f,"spreadsheet")[0]);return ca};this.getDocumentType=function(){var a=G.getContentElement();return a&&a.localName};this.getPart=function(b){return new a(b,R[b],G,H)};this.getPartData=function(a,b){H.load(a,b)};this.createByteArray=function(a,b){P();H.createByteArray(a,b)};this.saveAs=J;this.save=function(a){J(g,a)};this.getUrl=function(){return g}; -this.state=r.LOADING;this.rootElement=function(a){var b=document.createElementNS(a.namespaceURI,a.localName),c;a=new a;for(c in a)a.hasOwnProperty(c)&&(b[c]=a[c]);return b}(n);H=g?new core.Zip(g,function(a,b){H=b;a?$(g,function(b){a&&(H.error=a+"\n"+b,A(r.INVALID))}):K([["styles.xml",D],["content.xml",N],["meta.xml",B],["settings.xml",L],["META-INF/manifest.xml",C]])}):T()};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 l(a,b,c){for(a=a?a.firstChild:null;a;){if(a.localName===c&&a.namespaceURI===b)return a;a=a.nextSibling}return null}function m(a){var b,c=p.length;for(b=0;bc)break;e=e.nextSibling}a.insertBefore(b,e)}}}function e(a){this.OdfContainer= +a}function g(a,b,c,d){var e=this;this.size=0;this.type=null;this.name=a;this.container=c;this.onchange=this.onreadystatechange=this.document=this.mimetype=this.url=null;this.EMPTY=0;this.LOADING=1;this.DONE=2;this.state=this.EMPTY;this.load=function(){null!==d&&(this.mimetype=b,d.loadAsDataURL(a,b,function(a,b){a&&runtime.log(a);e.url=b;if(e.onchange)e.onchange(e);if(e.onstatereadychange)e.onstatereadychange(e)}))}}var d=new odf.StyleInfo,p="meta settings scripts font-face-decls styles automatic-styles master-styles body".split(" "), +c=(new Date).getTime()+"_webodf_",q=new core.Base64;e.prototype=new function(){};e.prototype.constructor=e;e.namespaceURI="urn:oasis:names:tc:opendocument:xmlns:office:1.0";e.localName="document";g.prototype.load=function(){};g.prototype.getUrl=function(){return this.data?"data:;base64,"+q.toBase64(this.data):null};odf.OdfContainer=function f(n,m){function s(a){for(var b=a.firstChild,c;b;)c=b.nextSibling,b.nodeType===Node.ELEMENT_NODE?s(b):b.nodeType===Node.PROCESSING_INSTRUCTION_NODE&&a.removeChild(b), +b=c}function x(a,b){for(var c=a&&a.firstChild;c;)c.nodeType===Node.ELEMENT_NODE&&c.setAttributeNS("urn:webodf:names:scope","scope",b),c=c.nextSibling}function r(a,b){var c=null,d,e,f;if(a)for(c=a.cloneNode(!0),d=c.firstChild;d;)e=d.nextSibling,d.nodeType===Node.ELEMENT_NODE&&(f=d.getAttributeNS("urn:webodf:names:scope","scope"))&&f!==b&&c.removeChild(d),d=e;return c}function y(a){var b=B.rootElement.ownerDocument,c;if(a){s(a.documentElement);try{c=b.importNode(a.documentElement,!0)}catch(d){}}return c} +function t(a){B.state=a;if(B.onchange)B.onchange(B);if(B.onstatereadychange)B.onstatereadychange(B)}function p(a){T=null;B.rootElement=a;a.fontFaceDecls=l(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","font-face-decls");a.styles=l(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","styles");a.automaticStyles=l(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","automatic-styles");a.masterStyles=l(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","master-styles");a.body=l(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0", +"body");a.meta=l(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","meta")}function v(a){a=y(a);var e=B.rootElement;a&&"document-styles"===a.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===a.namespaceURI?(e.fontFaceDecls=l(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","font-face-decls"),b(e,e.fontFaceDecls),e.styles=l(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","styles"),b(e,e.styles),e.automaticStyles=l(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","automatic-styles"), +x(e.automaticStyles,"document-styles"),b(e,e.automaticStyles),e.masterStyles=l(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","master-styles"),b(e,e.masterStyles),d.prefixStyleNames(e.automaticStyles,c,e.masterStyles)):t(f.INVALID)}function q(a){a=y(a);var c,d,e;if(a&&"document-content"===a.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===a.namespaceURI){c=B.rootElement;d=l(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","font-face-decls");if(c.fontFaceDecls&&d)for(e=d.firstChild;e;)c.fontFaceDecls.appendChild(e), +e=d.firstChild;else d&&(c.fontFaceDecls=d,b(c,d));d=l(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","automatic-styles");x(d,"document-content");if(c.automaticStyles&&d)for(e=d.firstChild;e;)c.automaticStyles.appendChild(e),e=d.firstChild;else d&&(c.automaticStyles=d,b(c,d));c.body=l(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","body");b(c,c.body)}else t(f.INVALID)}function J(a){a=y(a);var c;a&&("document-meta"===a.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===a.namespaceURI)&& +(c=B.rootElement,c.meta=l(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","meta"),b(c,c.meta))}function z(a){a=y(a);var c;a&&("document-settings"===a.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===a.namespaceURI)&&(c=B.rootElement,c.settings=l(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","settings"),b(c,c.settings))}function L(a){a=y(a);var b;if(a&&"manifest"===a.localName&&"urn:oasis:names:tc:opendocument:xmlns:manifest:1.0"===a.namespaceURI)for(b=B.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)&&(E[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 A(a){var b=a.shift(),c,d;b?(c=b[0],d=b[1],H.loadAsDOM(c,function(b,c){d(c);b||B.state===f.INVALID||A(a)})):t(f.DONE)}function P(a){var b="";odf.Namespaces.forEachPrefix(function(a, +c){b+=" xmlns:"+a+'="'+c+'"'});return''}function G(){var a=new xmldom.LSSerializer,b=P("document-meta");a.filter=new odf.OdfNodeFilter;b+=a.writeToString(B.rootElement.meta,odf.Namespaces.namespaceMap);return b+""}function M(a,b){var c=document.createElementNS("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0","manifest:file-entry");c.setAttributeNS("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0", +"manifest:full-path",a);c.setAttributeNS("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0","manifest:media-type",b);return c}function ea(){var a=runtime.parseXML(''),b=l(a,"urn:oasis:names:tc:opendocument:xmlns:manifest:1.0","manifest"),c=new xmldom.LSSerializer,d;for(d in E)E.hasOwnProperty(d)&&b.appendChild(M(d,E[d]));c.filter=new odf.OdfNodeFilter;return'\n'+ +c.writeToString(a,odf.Namespaces.namespaceMap)}function na(){var a=new xmldom.LSSerializer,b=P("document-settings");a.filter=new odf.OdfNodeFilter;b+=a.writeToString(B.rootElement.settings,odf.Namespaces.namespaceMap);return b+""}function N(){var a=odf.Namespaces.namespaceMap,b=new xmldom.LSSerializer,e=r(B.rootElement.automaticStyles,"document-styles"),f=B.rootElement.masterStyles&&B.rootElement.masterStyles.cloneNode(!0),g=P("document-styles");d.removePrefixFromStyleNames(e, +c,f);b.filter=new h(f,e);g+=b.writeToString(B.rootElement.fontFaceDecls,a);g+=b.writeToString(B.rootElement.styles,a);g+=b.writeToString(e,a);g+=b.writeToString(f,a);return g+""}function oa(){var b=odf.Namespaces.namespaceMap,c=new xmldom.LSSerializer,d=r(B.rootElement.automaticStyles,"document-content"),e=P("document-content");c.filter=new a(B.rootElement.body,d);e+=c.writeToString(d,b);e+=c.writeToString(B.rootElement.body,b);return e+""}function V(a, +b){runtime.loadXML(a,function(a,c){if(a)b(a);else{var d=y(c);d&&"document"===d.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===d.namespaceURI?(p(d),t(f.DONE)):t(f.INVALID)}})}function Z(){function a(b,c){var e;c||(c=b);e=document.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0",c);d[b]=e;d.appendChild(e)}var b=new core.Zip("",null),c=runtime.byteArrayFromString("application/vnd.oasis.opendocument.text","utf8"),d=B.rootElement,e=document.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0", +"text");b.save("mimetype",c,!1,new Date);a("meta");a("settings");a("scripts");a("fontFaceDecls","font-face-decls");a("styles");a("automaticStyles","automatic-styles");a("masterStyles","master-styles");a("body");d.body.appendChild(e);t(f.DONE);return b}function O(){var a,b=new Date;a=runtime.byteArrayFromString(na(),"utf8");H.save("settings.xml",a,!0,b);a=runtime.byteArrayFromString(G(),"utf8");H.save("meta.xml",a,!0,b);a=runtime.byteArrayFromString(N(),"utf8");H.save("styles.xml",a,!0,b);a=runtime.byteArrayFromString(oa(), +"utf8");H.save("content.xml",a,!0,b);a=runtime.byteArrayFromString(ea(),"utf8");H.save("META-INF/manifest.xml",a,!0,b)}function S(a,b){O();H.writeAs(a,function(a){b(a)})}var B=this,H,E={},T;this.onstatereadychange=m;this.rootElement=this.state=this.onchange=null;this.setRootElement=p;this.getContentElement=function(){var a;T||(a=B.rootElement.body,T=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 T};this.getDocumentType=function(){var a=B.getContentElement();return a&&a.localName};this.getPart=function(a){return new g(a,E[a],B,H)};this.getPartData=function(a,b){H.load(a,b)};this.createByteArray=function(a,b){O();H.createByteArray(a,b)};this.saveAs=S;this.save=function(a){S(n,a)};this.getUrl=function(){return n};this.state=f.LOADING;this.rootElement=function(a){var b=document.createElementNS(a.namespaceURI, +a.localName),c;a=new a;for(c in a)a.hasOwnProperty(c)&&(b[c]=a[c]);return b}(e);H=n?new core.Zip(n,function(a,b){H=b;a?V(n,function(b){a&&(H.error=a+"\n"+b,t(f.INVALID))}):A([["styles.xml",v],["content.xml",q],["meta.xml",J],["settings.xml",z],["META-INF/manifest.xml",L]])}):Z()};odf.OdfContainer.EMPTY=0;odf.OdfContainer.LOADING=1;odf.OdfContainer.DONE=2;odf.OdfContainer.INVALID=3;odf.OdfContainer.SAVING=4;odf.OdfContainer.MODIFIED=5;odf.OdfContainer.getContainer=function(a){return new odf.OdfContainer(a, +null)};return odf.OdfContainer}(); // Input 34 /* @@ -721,9 +796,9 @@ this.state=r.LOADING;this.rootElement=function(a){var b=document.createElementNS @source: http://gitorious.org/webodf/webodf/ */ runtime.loadClass("core.Base64");runtime.loadClass("xmldom.XPath");runtime.loadClass("odf.OdfContainer"); -odf.FontLoader=function(){function l(c,b,n,a,h){var f,d=0,m;for(m in c)if(c.hasOwnProperty(m)){if(d===n){f=m;break}d+=1}f?b.getPartData(c[f].href,function(d,m){if(d)runtime.log(d);else{var g="@font-face { font-family: '"+(c[f].family||f)+"'; src: url(data:application/x-font-ttf;charset=binary;base64,"+e.convertUTF8ArrayToBase64(m)+') format("truetype"); }';try{a.insertRule(g,a.cssRules.length)}catch(p){runtime.log("Problem inserting rule in CSS: "+runtime.toJson(p)+"\nRule: "+g)}}l(c,b,n+1,a,h)}): -h&&h()}var m=new xmldom.XPath,e=new core.Base64;odf.FontLoader=function(){this.loadFonts=function(c,b){for(var e=c.rootElement.fontFaceDecls;b.cssRules.length;)b.deleteRule(b.cssRules.length-1);if(e){var a={},h,f,d,t;if(e)for(e=m.getODFElementsWithXPath(e,"style:font-face[svg:font-face-src]",odf.Namespaces.resolvePrefix),h=0;h text|list-item > *:first-child:before {";if(ga=V.getAttributeNS(s, -"style-name")){V=p[ga];C=L.getFirstNonWhitespaceChild(V);V=void 0;if(C)if("list-level-style-number"===C.localName){V=C.getAttributeNS(z,"num-format");ga=C.getAttributeNS(z,"num-suffix");var x="",x={1:"decimal",a:"lower-latin",A:"upper-latin",i:"lower-roman",I:"upper-roman"},E=void 0,E=C.getAttributeNS(z,"num-prefix")||"",E=x.hasOwnProperty(V)?E+(" counter(list, "+x[V]+")"):V?E+("'"+V+"';"):E+" ''";ga&&(E+=" '"+ga+"'");V=x="content: "+E+";"}else"list-level-style-image"===C.localName?V="content: none;": -"list-level-style-bullet"===C.localName&&(V="content: '"+C.getAttributeNS(s,"bullet-char")+"';");C=V}if(X){for(V=l[X];V;)X=V,V=l[X];y+="counter-increment:"+X+";";C?(C=C.replace("list",X),y+=C):y+="content:counter("+X+");"}else X="",C?(C=C.replace("list",u),y+=C):y+="content: counter("+u+");",y+="counter-increment:"+u+";",e.insertRule("text|list#"+u+" {counter-reset:"+u+"}",e.cssRules.length);y+="}";l[u]=X;y&&e.insertRule(y,e.cssRules.length)}O.insertBefore(K,O.firstChild);A();D(g);if(!b&&(g=[H],la.hasOwnProperty("statereadychange")))for(e= -la.statereadychange,C=0;C text|list-item > *:first-child:before {";if(C=z.getAttributeNS(v,"style-name")){z= +r[C];D=P.getFirstNonWhitespaceChild(z);z=void 0;if(D)if("list-level-style-number"===D.localName){z=D.getAttributeNS(y,"num-format");C=D.getAttributeNS(y,"num-suffix");var ca="",ca={1:"decimal",a:"lower-latin",A:"upper-latin",i:"lower-roman",I:"upper-roman"},da=void 0,da=D.getAttributeNS(y,"num-prefix")||"",da=ca.hasOwnProperty(z)?da+(" counter(list, "+ca[z]+")"):z?da+("'"+z+"';"):da+" ''";C&&(da+=" '"+C+"'");z=ca="content: "+da+";"}else"list-level-style-image"===D.localName?z="content: none;":"list-level-style-bullet"=== +D.localName&&(z="content: '"+D.getAttributeNS(v,"bullet-char")+"';");D=z}if(G){for(z=m[G];z;)G=z,z=m[G];B+="counter-increment:"+G+";";D?(D=D.replace("list",G),B+=D):B+="content:counter("+G+");"}else G="",D?(D=D.replace("list",u),B+=D):B+="content: counter("+u+");",B+="counter-increment:"+u+";",l.insertRule("text|list#"+u+" {counter-reset:"+u+"}",l.cssRules.length);B+="}";m[u]=G;B&&l.insertRule(B,l.cssRules.length)}Q.insertBefore(M,Q.firstChild);t();F(h);if(!b&&(h=[E],ja.hasOwnProperty("statereadychange")))for(l= +ja.statereadychange,D=0;Dd?-h.countBackwardSteps(-d, -f):0;a.move(d);b&&(f=0b?-h.countBackwardSteps(-b,f):0,a.move(f,!0));e.emit(ops.OdtDocument.signalCursorMoved,a);return!0};this.spec=function(){return{optype:"MoveCursor",memberid:m,timestamp:e,position:c,length:b}}}; +ops.OpMoveCursor=function(){var l=this,m,h,a,b;this.init=function(e){m=e.memberid;h=e.timestamp;a=parseInt(e.position,10);b=void 0!==e.length?parseInt(e.length,10):0};this.merge=function(e){return"MoveCursor"===e.optype&&e.memberid===m?(a=e.position,b=e.length,h=e.timestamp,!0):!1};this.transform=function(e,g){var d=e.spec(),h=a+b,c,q=[l];switch(d.optype){case "RemoveText":c=d.position+d.length;c<=a?a-=d.length:d.positionc?-d.countBackwardSteps(-c, +h):0;g.move(c);b&&(h=0b?-d.countBackwardSteps(-b,h):0,g.move(h,!0));e.emit(ops.OdtDocument.signalCursorMoved,g);return!0};this.spec=function(){return{optype:"MoveCursor",memberid:m,timestamp:h,position:a,length:b}}}; // Input 46 /* @@ -1170,11 +1244,11 @@ f):0;a.move(d);b&&(f=0b?-h.countBackwardSteps(-b,f @source: http://www.webodf.org/ @source: http://gitorious.org/webodf/webodf/ */ -ops.OpInsertTable=function(){function l(a,c){var d;if(1===t.length)d=t[0];else if(3===t.length)switch(a){case 0:d=t[0];break;case b-1:d=t[2];break;default:d=t[1]}else d=t[a];if(1===d.length)return d[0];if(3===d.length)switch(c){case 0:return d[0];case n-1:return d[2];default:return d[1]}return d[c]}var m=this,e,c,b,n,a,h,f,d,t;this.init=function(k){e=k.memberid;c=k.timestamp;a=parseInt(k.position,10);b=parseInt(k.initialRows,10);n=parseInt(k.initialColumns,10);h=k.tableName;f=k.tableStyleName;d=k.tableColumnStyleName; -t=k.tableCellStyleMatrix};this.transform=function(b,c){var d=b.spec(),f=[m];switch(d.optype){case "InsertTable":f=null;break;case "AddAnnotation":d.position=a.textNode.length?null:a.textNode.splitText(a.offset));for(a=a.textNode;a!==f;)if(a=a.parentNode,d=a.cloneNode(!1),k){for(l&&d.appendChild(l);k.nextSibling;)d.appendChild(k.nextSibling); -a.parentNode.insertBefore(d,a.nextSibling);k=a;l=d}else a.parentNode.insertBefore(d,a),k=d,l=a;b.isListItem(l)&&(l=l.childNodes[0]);n.fixCursorPositions(m);n.getOdfCanvas().refreshSize();n.emit(ops.OdtDocument.signalParagraphChanged,{paragraphElement:h,memberId:m,timeStamp:e});n.emit(ops.OdtDocument.signalParagraphChanged,{paragraphElement:l,memberId:m,timeStamp:e});n.getOdfCanvas().rerenderAnnotations();return!0};this.spec=function(){return{optype:"SplitParagraph",memberid:m,timestamp:e,position:c}}}; +ops.OpSplitParagraph=function(){var l=this,m,h,a,b=new odf.OdfUtils;this.init=function(b){m=b.memberid;h=b.timestamp;a=parseInt(b.position,10)};this.transform=function(b,g){var d=b.spec(),h=[l];switch(d.optype){case "SplitParagraph":d.position=g.textNode.length?null:g.textNode.splitText(g.offset));for(c=g.textNode;c!==l;)if(c=c.parentNode,q=c.cloneNode(!1),f){for(k&&q.appendChild(k);f.nextSibling;)q.appendChild(f.nextSibling); +c.parentNode.insertBefore(q,c.nextSibling);f=c;k=q}else c.parentNode.insertBefore(q,c),f=q,k=c;b.isListItem(k)&&(k=k.childNodes[0]);0===g.textNode.length&&g.textNode.parentNode.removeChild(g.textNode);e.fixCursorPositions(m);e.getOdfCanvas().refreshSize();e.emit(ops.OdtDocument.signalParagraphChanged,{paragraphElement:d,memberId:m,timeStamp:h});e.emit(ops.OdtDocument.signalParagraphChanged,{paragraphElement:k,memberId:m,timeStamp:h});e.getOdfCanvas().rerenderAnnotations();return!0};this.spec=function(){return{optype:"SplitParagraph", +memberid:m,timestamp:h,position:a}}}; // Input 50 /* @@ -1330,8 +1404,8 @@ a.parentNode.insertBefore(d,a.nextSibling);k=a;l=d}else a.parentNode.insertBefor @source: http://www.webodf.org/ @source: http://gitorious.org/webodf/webodf/ */ -ops.OpSetParagraphStyle=function(){var l=this,m,e,c,b;this.init=function(n){m=n.memberid;e=n.timestamp;c=n.position;b=n.styleName};this.transform=function(c,a){var e=c.spec(),f=[l];switch(e.optype){case "RemoveParagraphStyle":e.styleName===b&&(b="")}return f};this.execute=function(n){var a;if(a=n.getPositionInTextNode(c))if(a=n.getParagraphElement(a.textNode))return""!==b?a.setAttributeNS("urn:oasis:names:tc:opendocument:xmlns:text:1.0","text:style-name",b):a.removeAttributeNS("urn:oasis:names:tc:opendocument:xmlns:text:1.0", -"style-name"),n.getOdfCanvas().refreshSize(),n.emit(ops.OdtDocument.signalParagraphChanged,{paragraphElement:a,timeStamp:e,memberId:m}),n.getOdfCanvas().rerenderAnnotations(),!0;return!1};this.spec=function(){return{optype:"SetParagraphStyle",memberid:m,timestamp:e,position:c,styleName:b}}}; +ops.OpSetParagraphStyle=function(){var l=this,m,h,a,b;this.init=function(e){m=e.memberid;h=e.timestamp;a=e.position;b=e.styleName};this.transform=function(a,g){var d=a.spec(),h=[l];switch(d.optype){case "RemoveStyle":d.styleName===b&&"paragraph"===d.styleFamily&&(b="")}return h};this.execute=function(e){var g;g=e.getIteratorAtPosition(a);return(g=e.getParagraphElement(g.container()))?(""!==b?g.setAttributeNS("urn:oasis:names:tc:opendocument:xmlns:text:1.0","text:style-name",b):g.removeAttributeNS("urn:oasis:names:tc:opendocument:xmlns:text:1.0", +"style-name"),e.getOdfCanvas().refreshSize(),e.emit(ops.OdtDocument.signalParagraphChanged,{paragraphElement:g,timeStamp:h,memberId:m}),e.getOdfCanvas().rerenderAnnotations(),!0):!1};this.spec=function(){return{optype:"SetParagraphStyle",memberid:m,timestamp:h,position:a,styleName:b}}}; // Input 51 /* @@ -1368,11 +1442,11 @@ ops.OpSetParagraphStyle=function(){var l=this,m,e,c,b;this.init=function(n){m=n. @source: http://gitorious.org/webodf/webodf/ */ runtime.loadClass("odf.Namespaces"); -ops.OpUpdateParagraphStyle=function(){function l(a,b){var c,d,f=b?b.split(","):[];for(c=0;ck?-g.countBackwardSteps(-k,d):0,m.move(d),h.emit(ops.OdtDocument.signalCursorMoved,m));h.getOdfCanvas().addAnnotation(f);return!0};this.spec=function(){return{optype:"AddAnnotation",memberid:e,timestamp:c,position:b, -length:n,name:a}}}; +ops.OpAddAnnotation=function(){function l(a,b,c){var e=a.getPositionInTextNode(c,h);e&&(a=e.textNode,c=a.parentNode,e.offset!==a.length&&a.splitText(e.offset),c.insertBefore(b,a.nextSibling),0===a.length&&c.removeChild(a))}var m=this,h,a,b,e,g;this.init=function(d){h=d.memberid;a=parseInt(d.timestamp,10);b=parseInt(d.position,10);e=parseInt(d.length,10)||0;g=d.name};this.transform=function(a,g){var c=a.spec(),h=b+e,k=[m];switch(c.optype){case "AddAnnotation":c.positionk?-n.countBackwardSteps(-k,c):0,q.move(c),d.emit(ops.OdtDocument.signalCursorMoved,q));d.getOdfCanvas().addAnnotation(m);return!0};this.spec=function(){return{optype:"AddAnnotation", +memberid:h,timestamp:a,position:b,length:e,name:g}}}; // Input 55 /* @@ -1524,9 +1599,9 @@ length:n,name:a}}}; @source: http://gitorious.org/webodf/webodf/ */ runtime.loadClass("odf.Namespaces");runtime.loadClass("core.DomUtils"); -ops.OpRemoveAnnotation=function(){var l,m,e,c,b;this.init=function(n){l=n.memberid;m=n.timestamp;e=parseInt(n.position,10);c=parseInt(n.length,10);b=new core.DomUtils};this.transform=function(b,a){return null};this.execute=function(c){for(var a=c.getIteratorAtPosition(e).container(),h,f=null,d=null;a.namespaceURI!==odf.Namespaces.officens||"annotation"!==a.localName;)a=a.parentNode;if(null===a)return!1;f=a;(h=f.getAttributeNS(odf.Namespaces.officens,"name"))&&(d=b.getElementsByTagNameNS(c.getRootNode(), -odf.Namespaces.officens,"annotation-end").filter(function(a){return h===a.getAttributeNS(odf.Namespaces.officens,"name")})[0]||null);c.getOdfCanvas().forgetAnnotations();for(a=b.getElementsByTagNameNS(f,odf.Namespaces.webodfns+":names:cursor","cursor");a.length;)f.parentNode.insertBefore(a.pop(),f);f.parentNode.removeChild(f);d&&d.parentNode.removeChild(d);c.fixCursorPositions();c.getOdfCanvas().refreshAnnotations();return!0};this.spec=function(){return{optype:"RemoveAnnotation",memberid:l,timestamp:m, -position:e,length:c}}}; +ops.OpRemoveAnnotation=function(){var l,m,h,a,b;this.init=function(e){l=e.memberid;m=e.timestamp;h=parseInt(e.position,10);a=parseInt(e.length,10);b=new core.DomUtils};this.transform=function(a,b){return null};this.execute=function(a){for(var g=a.getIteratorAtPosition(h).container(),d,l=null,c=null;g.namespaceURI!==odf.Namespaces.officens||"annotation"!==g.localName;)g=g.parentNode;if(null===g)return!1;l=g;(d=l.getAttributeNS(odf.Namespaces.officens,"name"))&&(c=b.getElementsByTagNameNS(a.getRootNode(), +odf.Namespaces.officens,"annotation-end").filter(function(a){return d===a.getAttributeNS(odf.Namespaces.officens,"name")})[0]||null);a.getOdfCanvas().forgetAnnotations();for(g=b.getElementsByTagNameNS(l,odf.Namespaces.webodfns+":names:cursor","cursor");g.length;)l.parentNode.insertBefore(g.pop(),l);l.parentNode.removeChild(l);c&&c.parentNode.removeChild(c);a.fixCursorPositions();a.getOdfCanvas().refreshAnnotations();return!0};this.spec=function(){return{optype:"RemoveAnnotation",memberid:l,timestamp:m, +position:h,length:a}}}; // Input 56 /* @@ -1562,23 +1637,23 @@ position:e,length:c}}}; @source: http://www.webodf.org/ @source: http://gitorious.org/webodf/webodf/ */ -runtime.loadClass("ops.OpAddCursor");runtime.loadClass("ops.OpApplyDirectStyling");runtime.loadClass("ops.OpRemoveCursor");runtime.loadClass("ops.OpMoveCursor");runtime.loadClass("ops.OpInsertTable");runtime.loadClass("ops.OpInsertText");runtime.loadClass("ops.OpRemoveText");runtime.loadClass("ops.OpSplitParagraph");runtime.loadClass("ops.OpSetParagraphStyle");runtime.loadClass("ops.OpUpdateParagraphStyle");runtime.loadClass("ops.OpAddParagraphStyle");runtime.loadClass("ops.OpRemoveParagraphStyle"); -runtime.loadClass("ops.OpAddAnnotation");runtime.loadClass("ops.OpRemoveAnnotation"); -ops.OperationFactory=function(){function l(e){return function(){return new e}}var m;this.register=function(e,c){m[e]=c};this.create=function(e){var c=null,b=m[e.optype];b&&(c=b(e),c.init(e));return c};m={AddCursor:l(ops.OpAddCursor),ApplyDirectStyling:l(ops.OpApplyDirectStyling),InsertTable:l(ops.OpInsertTable),InsertText:l(ops.OpInsertText),RemoveText:l(ops.OpRemoveText),SplitParagraph:l(ops.OpSplitParagraph),SetParagraphStyle:l(ops.OpSetParagraphStyle),UpdateParagraphStyle:l(ops.OpUpdateParagraphStyle), -AddParagraphStyle:l(ops.OpAddParagraphStyle),RemoveParagraphStyle:l(ops.OpRemoveParagraphStyle),MoveCursor:l(ops.OpMoveCursor),RemoveCursor:l(ops.OpRemoveCursor),AddAnnotation:l(ops.OpAddAnnotation),RemoveAnnotation:l(ops.OpRemoveAnnotation)}}; +runtime.loadClass("ops.OpAddCursor");runtime.loadClass("ops.OpApplyDirectStyling");runtime.loadClass("ops.OpRemoveCursor");runtime.loadClass("ops.OpMoveCursor");runtime.loadClass("ops.OpInsertTable");runtime.loadClass("ops.OpInsertText");runtime.loadClass("ops.OpRemoveText");runtime.loadClass("ops.OpSplitParagraph");runtime.loadClass("ops.OpSetParagraphStyle");runtime.loadClass("ops.OpUpdateParagraphStyle");runtime.loadClass("ops.OpAddStyle");runtime.loadClass("ops.OpRemoveStyle");runtime.loadClass("ops.OpAddAnnotation"); +runtime.loadClass("ops.OpRemoveAnnotation"); +ops.OperationFactory=function(){function l(h){return function(){return new h}}var m;this.register=function(h,a){m[h]=a};this.create=function(h){var a=null,b=m[h.optype];b&&(a=b(h),a.init(h));return a};m={AddCursor:l(ops.OpAddCursor),ApplyDirectStyling:l(ops.OpApplyDirectStyling),InsertTable:l(ops.OpInsertTable),InsertText:l(ops.OpInsertText),RemoveText:l(ops.OpRemoveText),SplitParagraph:l(ops.OpSplitParagraph),SetParagraphStyle:l(ops.OpSetParagraphStyle),UpdateParagraphStyle:l(ops.OpUpdateParagraphStyle), +AddStyle:l(ops.OpAddStyle),RemoveStyle:l(ops.OpRemoveStyle),MoveCursor:l(ops.OpMoveCursor),RemoveCursor:l(ops.OpRemoveCursor),AddAnnotation:l(ops.OpAddAnnotation),RemoveAnnotation:l(ops.OpRemoveAnnotation)}}; // Input 57 -runtime.loadClass("core.Cursor");runtime.loadClass("core.PositionIterator");runtime.loadClass("core.PositionFilter");runtime.loadClass("core.LoopWatchDog");runtime.loadClass("odf.OdfUtils"); -gui.SelectionMover=function(l,m){function e(){z.setUnfilteredPosition(l.getNode(),0);return z}function c(a,b){var c,d=null;a&&(c=b?a[a.length-1]:a[0]);c&&(d={top:c.top,left:b?c.right:c.left,bottom:c.bottom});return d}function b(a,d,f,e){var g=a.nodeType;f.setStart(a,d);f.collapse(!e);e=c(f.getClientRects(),!0===e);!e&&0a?-1:1;for(a=Math.abs(a);0n?l.previousPosition():l.nextPosition());)if(H.check(),k.acceptPosition(l)===s&&(r+=1,p=l.container(),w=b(p,l.unfilteredDomOffset(),G),w.top!==z)){if(w.top!==J&&J!==z)break;J=w.top;w=Math.abs(P-w.left);if(null===u||wa?(d=k.previousPosition,f=-1):(d=k.nextPosition,f=1);for(g=b(k.container(),k.unfilteredDomOffset(),p);d.call(k);)if(c.acceptPosition(k)===s){if(u.getParagraphElement(k.getCurrentNode())!==n)break;h=b(k.container(),k.unfilteredDomOffset(),p);if(h.bottom!==g.bottom&&(g=h.top>=g.top&&h.bottomg.bottom,!g))break;l+=f;g=h}p.detach();return l}function p(a,b){for(var c=0,d;a.parentNode!==b;)runtime.assert(null!==a.parentNode,"parent is null"), -a=a.parentNode;for(d=b.firstChild;d!==a;)c+=1,d=d.nextSibling;return c}function r(a,b,c,d){if(a===c)return d-b;var f=a.compareDocumentPosition(c);2===f?f=-1:4===f?f=1:10===f?(b=p(a,c),f=bf)for(;d.nextPosition()&&(k.check(),c.acceptPosition(d)===s&&(h+=1),d.container()!==a||d.unfilteredDomOffset()!==b););else if(0=r(a,b,d.container(),d.unfilteredDomOffset()))););return h}var u,z,y,v,s=core.PositionFilter.FilterResult.FILTER_ACCEPT;this.movePointForward=function(a,b){return n(a,b,z.nextPosition)};this.movePointBackward= -function(a,b){return n(a,b,z.previousPosition)};this.getStepCounter=function(){return{countForwardSteps:h,countBackwardSteps:t,convertForwardStepsBetweenFilters:f,convertBackwardStepsBetweenFilters:d,countLinesSteps:q,countStepsToLineBoundary:g,countStepsToPosition:w,isPositionWalkable:a,countStepsToValidPosition:k}};(function(){u=new odf.OdfUtils;z=gui.SelectionMover.createPositionIterator(m);var a=m.ownerDocument.createRange();a.setStart(z.container(),z.unfilteredDomOffset());a.collapse(!0);l.setSelectedRange(a)})()}; -gui.SelectionMover.createPositionIterator=function(l){var m=new function(){this.acceptNode=function(e){return"urn:webodf:names:cursor"===e.namespaceURI||"urn:webodf:names:editinfo"===e.namespaceURI?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}};return new core.PositionIterator(l,5,m,!1)};(function(){return gui.SelectionMover})(); +runtime.loadClass("core.Cursor");runtime.loadClass("core.DomUtils");runtime.loadClass("core.PositionIterator");runtime.loadClass("core.PositionFilter");runtime.loadClass("core.LoopWatchDog");runtime.loadClass("odf.OdfUtils"); +gui.SelectionMover=function(l,m){function h(){r.setUnfilteredPosition(l.getNode(),0);return r}function a(a,b){var c,d=null;a&&(c=b?a[a.length-1]:a[0]);c&&(d={top:c.top,left:b?c.right:c.left,bottom:c.bottom});return d}function b(c,d,e,f){var g=c.nodeType;e.setStart(c,d);e.collapse(!f);f=a(e.getClientRects(),!0===f);!f&&0a?-1:1;for(a=Math.abs(a);0l?n.previousPosition():n.nextPosition());)if(T.check(),k.acceptPosition(n)===w&&(s+=1,r=n.container(),t=b(r,n.unfilteredDomOffset(),E),t.top!==S)){if(t.top!==H&&H!==S)break;H=t.top;t=Math.abs(B-t.left);if(null===x||ta?(d=k.previousPosition,e=-1):(d=k.nextPosition,e=1);for(f=b(k.container(),k.unfilteredDomOffset(),r);d.call(k);)if(c.acceptPosition(k)===w){if(s.getParagraphElement(k.getCurrentNode())!==l)break;g=b(k.container(),k.unfilteredDomOffset(),r);if(g.bottom!==f.bottom&&(f=g.top>=f.top&&g.bottomf.bottom,!f))break;n+=e;f=g}r.detach();return n}function u(a,b,c){runtime.assert(null!==a,"SelectionMover.countStepsToPosition called with element===null"); +var d=h(),e=d.container(),f=d.unfilteredDomOffset(),g=0,k=new core.LoopWatchDog(1E3);d.setUnfilteredPosition(a,b);a=d.container();runtime.assert(Boolean(a),"SelectionMover.countStepsToPosition: positionIterator.container() returned null");b=d.unfilteredDomOffset();d.setUnfilteredPosition(e,f);e=x.comparePoints(a,b,d.container(),d.unfilteredDomOffset());if(0>e)for(;d.nextPosition()&&(k.check(),c.acceptPosition(d)===w&&(g+=1),d.container()!==a||d.unfilteredDomOffset()!==b););else if(0=x.comparePoints(a,b,d.container(),d.unfilteredDomOffset()))););return g}var s,x,r,y,t,w=core.PositionFilter.FilterResult.FILTER_ACCEPT;this.movePointForward=function(a,b){return e(a,b,r.nextPosition)};this.movePointBackward=function(a,b){return e(a,b,r.previousPosition)};this.getStepCounter=function(){return{countForwardSteps:d,countBackwardSteps:q,convertForwardStepsBetweenFilters:p,convertBackwardStepsBetweenFilters:c,countLinesSteps:f,countStepsToLineBoundary:n, +countStepsToPosition:u,isPositionWalkable:g,countStepsToValidPosition:k}};(function(){s=new odf.OdfUtils;x=new core.DomUtils;r=gui.SelectionMover.createPositionIterator(m);var a=m.ownerDocument.createRange();a.setStart(r.container(),r.unfilteredDomOffset());a.collapse(!0);l.setSelectedRange(a)})()}; +gui.SelectionMover.createPositionIterator=function(l){var m=new function(){this.acceptNode=function(h){return"urn:webodf:names:cursor"===h.namespaceURI||"urn:webodf:names:editinfo"===h.namespaceURI?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}};return new core.PositionIterator(l,5,m,!1)};(function(){return gui.SelectionMover})(); // Input 58 /* @@ -1614,13 +1689,13 @@ gui.SelectionMover.createPositionIterator=function(l){var m=new function(){this. @source: http://www.webodf.org/ @source: http://gitorious.org/webodf/webodf/ */ -runtime.loadClass("ops.OpAddCursor");runtime.loadClass("ops.OpRemoveCursor");runtime.loadClass("ops.OpMoveCursor");runtime.loadClass("ops.OpInsertTable");runtime.loadClass("ops.OpInsertText");runtime.loadClass("ops.OpRemoveText");runtime.loadClass("ops.OpSplitParagraph");runtime.loadClass("ops.OpSetParagraphStyle");runtime.loadClass("ops.OpAddParagraphStyle");runtime.loadClass("ops.OpUpdateParagraphStyle");runtime.loadClass("ops.OpRemoveParagraphStyle"); -ops.OperationTransformer=function(){function l(e,c){for(var b,n,a,h=[],f=[];0=b&&(h=-c.movePointBackward(-b,a));e.handleUpdate();return h};this.handleUpdate=function(){};this.getStepCounter=function(){return c.getStepCounter()};this.getMemberId=function(){return l};this.getNode=function(){return b.getNode()};this.getAnchorNode=function(){return b.getAnchorNode()};this.getSelectedRange=function(){return b.getSelectedRange()}; -this.getOdtDocument=function(){return m};b=new core.Cursor(m.getDOM(),l);c=new gui.SelectionMover(b,m.getRootNode())}; +ops.OdtCursor=function(l,m){var h=this,a,b;this.removeFromOdtDocument=function(){b.remove()};this.move=function(b,g){var d=0;0=b&&(d=-a.movePointBackward(-b,g));h.handleUpdate();return d};this.handleUpdate=function(){};this.getStepCounter=function(){return a.getStepCounter()};this.getMemberId=function(){return l};this.getNode=function(){return b.getNode()};this.getAnchorNode=function(){return b.getAnchorNode()};this.getSelectedRange=function(){return b.getSelectedRange()}; +this.getOdtDocument=function(){return m};b=new core.Cursor(m.getDOM(),l);a=new gui.SelectionMover(b,m.getRootNode())}; // Input 60 /* @@ -1656,16 +1731,17 @@ this.getOdtDocument=function(){return m};b=new core.Cursor(m.getDOM(),l);c=new g @source: http://www.webodf.org/ @source: http://gitorious.org/webodf/webodf/ */ -ops.EditInfo=function(l,m){function e(){var c=[],a;for(a in b)b.hasOwnProperty(a)&&c.push({memberid:a,time:b[a].time});c.sort(function(a,b){return a.time-b.time});return c}var c,b={};this.getNode=function(){return c};this.getOdtDocument=function(){return m};this.getEdits=function(){return b};this.getSortedEdits=function(){return e()};this.addEdit=function(c,a){b[c]={time:a}};this.clearEdits=function(){b={}};this.destroy=function(b){l.removeChild(c);b()};c=m.getDOM().createElementNS("urn:webodf:names:editinfo", -"editinfo");l.insertBefore(c,l.firstChild)}; +ops.EditInfo=function(l,m){function h(){var a=[],g;for(g in b)b.hasOwnProperty(g)&&a.push({memberid:g,time:b[g].time});a.sort(function(a,b){return a.time-b.time});return a}var a,b={};this.getNode=function(){return a};this.getOdtDocument=function(){return m};this.getEdits=function(){return b};this.getSortedEdits=function(){return h()};this.addEdit=function(a,g){b[a]={time:g}};this.clearEdits=function(){b={}};this.destroy=function(b){l.removeChild(a);b()};a=m.getDOM().createElementNS("urn:webodf:names:editinfo", +"editinfo");l.insertBefore(a,l.firstChild)}; // Input 61 -gui.Avatar=function(l,m){var e=this,c,b,n;this.setColor=function(a){b.style.borderColor=a};this.setImageUrl=function(a){e.isVisible()?b.src=a:n=a};this.isVisible=function(){return"block"===c.style.display};this.show=function(){n&&(b.src=n,n=void 0);c.style.display="block"};this.hide=function(){c.style.display="none"};this.markAsFocussed=function(a){c.className=a?"active":""};this.destroy=function(a){l.removeChild(c);a()};(function(){var a=l.ownerDocument,e=a.documentElement.namespaceURI;c=a.createElementNS(e, -"div");b=a.createElementNS(e,"img");b.width=64;b.height=64;c.appendChild(b);c.style.width="64px";c.style.height="70px";c.style.position="absolute";c.style.top="-80px";c.style.left="-34px";c.style.display=m?"block":"none";l.appendChild(c)})()}; +gui.Avatar=function(l,m){var h=this,a,b,e;this.setColor=function(a){b.style.borderColor=a};this.setImageUrl=function(a){h.isVisible()?b.src=a:e=a};this.isVisible=function(){return"block"===a.style.display};this.show=function(){e&&(b.src=e,e=void 0);a.style.display="block"};this.hide=function(){a.style.display="none"};this.markAsFocussed=function(b){a.className=b?"active":""};this.destroy=function(b){l.removeChild(a);b()};(function(){var e=l.ownerDocument,d=e.documentElement.namespaceURI;a=e.createElementNS(d, +"div");b=e.createElementNS(d,"img");b.width=64;b.height=64;a.appendChild(b);a.style.width="64px";a.style.height="70px";a.style.position="absolute";a.style.top="-80px";a.style.left="-34px";a.style.display=m?"block":"none";l.appendChild(a)})()}; // Input 62 runtime.loadClass("gui.Avatar");runtime.loadClass("ops.OdtCursor"); -gui.Caret=function(l,m,e){function c(e){h&&a.parentNode&&(!f||e)&&(e&&void 0!==d&&runtime.clearTimeout(d),f=!0,b.style.opacity=e||"0"===b.style.opacity?"1":"0",d=runtime.setTimeout(function(){f=!1;c(!1)},500))}var b,n,a,h=!1,f=!1,d;this.refreshCursorBlinking=function(){e||l.getSelectedRange().collapsed?(h=!0,c(!0)):(h=!1,b.style.opacity="0")};this.setFocus=function(){h=!0;n.markAsFocussed(!0);c(!0)};this.removeFocus=function(){h=!1;n.markAsFocussed(!1);b.style.opacity="0"};this.setAvatarImageUrl= -function(a){n.setImageUrl(a)};this.setColor=function(a){b.style.borderColor=a;n.setColor(a)};this.getCursor=function(){return l};this.getFocusElement=function(){return b};this.toggleHandleVisibility=function(){n.isVisible()?n.hide():n.show()};this.showHandle=function(){n.show()};this.hideHandle=function(){n.hide()};this.ensureVisible=function(){var a,c,d,f,e=l.getOdtDocument().getOdfCanvas().getElement().parentNode,h;d=e.offsetWidth-e.clientWidth+5;f=e.offsetHeight-e.clientHeight+5;h=b.getBoundingClientRect(); -a=h.left-d;c=h.top-f;d=h.right+d;f=h.bottom+f;h=e.getBoundingClientRect();ch.bottom&&(e.scrollTop+=f-h.bottom);ah.right&&(e.scrollLeft+=d-h.right)};this.destroy=function(c){n.destroy(function(d){d?c(d):(a.removeChild(b),c())})};(function(){var c=l.getOdtDocument().getDOM();b=c.createElementNS(c.documentElement.namespaceURI,"span");a=l.getNode();a.appendChild(b);n=new gui.Avatar(a,m)})()}; +gui.Caret=function(l,m,h){function a(e){d&&g.parentNode&&(!p||e)&&(e&&void 0!==c&&runtime.clearTimeout(c),p=!0,b.style.opacity=e||"0"===b.style.opacity?"1":"0",c=runtime.setTimeout(function(){p=!1;a(!1)},500))}var b,e,g,d=!1,p=!1,c;this.refreshCursorBlinking=function(){h||l.getSelectedRange().collapsed?(d=!0,a(!0)):(d=!1,b.style.opacity="0")};this.setFocus=function(){d=!0;e.markAsFocussed(!0);a(!0)};this.removeFocus=function(){d=!1;e.markAsFocussed(!1);b.style.opacity="1"};this.show=function(){b.style.visibility= +"visible";e.markAsFocussed(!0)};this.hide=function(){b.style.visibility="hidden";e.markAsFocussed(!1)};this.setAvatarImageUrl=function(a){e.setImageUrl(a)};this.setColor=function(a){b.style.borderColor=a;e.setColor(a)};this.getCursor=function(){return l};this.getFocusElement=function(){return b};this.toggleHandleVisibility=function(){e.isVisible()?e.hide():e.show()};this.showHandle=function(){e.show()};this.hideHandle=function(){e.hide()};this.ensureVisible=function(){var a,c,d,e,g=l.getOdtDocument().getOdfCanvas().getElement().parentNode, +h;d=g.offsetWidth-g.clientWidth+5;e=g.offsetHeight-g.clientHeight+5;h=b.getBoundingClientRect();a=h.left-d;c=h.top-e;d=h.right+d;e=h.bottom+e;h=g.getBoundingClientRect();ch.bottom&&(g.scrollTop+=e-h.bottom);ah.right&&(g.scrollLeft+=d-h.right)};this.destroy=function(a){e.destroy(function(c){c?a(c):(g.removeChild(b),a())})};(function(){var a=l.getOdtDocument().getDOM();b=a.createElementNS(a.documentElement.namespaceURI,"span");g=l.getNode(); +g.appendChild(b);e=new gui.Avatar(g,m)})()}; // Input 63 /* @@ -1701,8 +1777,8 @@ a=h.left-d;c=h.top-f;d=h.right+d;f=h.bottom+f;h=e.getBoundingClientRect();ca.length&&(a.position+=a.length,a.length=-a.length);return a}function Q(a){var b=new ops.OpRemoveText;b.init({memberid:m,position:a.position,length:a.length});return b}function $(){var a=Z(x.getCursorSelection(m)), -b=null;0===a.length?0a.length&&(a.position+=a.length,a.length=-a.length);return a}function S(a){var b=new ops.OpRemoveText;b.init({memberid:h,position:a.position,length:a.length});return b}function B(){var a=O(C.getCursorSelection(h)),b=null;0===a.length?0k?(e(1,0),h=e(0.5,1E4-k),f=e(0.2,2E4-k)):1E4<=k&&2E4>k?(e(0.5,0),f=e(0.2,2E4-k)):e(0.2,0)};this.getEdits= -function(){return l.getEdits()};this.clearEdits=function(){l.clearEdits();n.setEdits([]);a.hasAttributeNS("urn:webodf:names:editinfo","editinfo:memberid")&&a.removeAttributeNS("urn:webodf:names:editinfo","editinfo:memberid")};this.getEditInfo=function(){return l};this.show=function(){a.style.display="block"};this.hide=function(){c.hideHandle();a.style.display="none"};this.showHandle=function(){n.show()};this.hideHandle=function(){n.hide()};this.destroy=function(c){b.removeChild(a);n.destroy(function(a){a? -c(a):l.destroy(c)})};(function(){var d=l.getOdtDocument().getDOM();a=d.createElementNS(d.documentElement.namespaceURI,"div");a.setAttribute("class","editInfoMarker");a.onmouseover=function(){c.showHandle()};a.onmouseout=function(){c.hideHandle()};b=l.getNode();b.appendChild(a);n=new gui.EditInfoHandle(b);m||c.hide()})()}; +gui.EditInfoMarker=function(l,m){function h(a,b){return runtime.getWindow().setTimeout(function(){g.style.opacity=a},b)}var a=this,b,e,g,d,p;this.addEdit=function(a,b){var k=Date.now()-b;l.addEdit(a,b);e.setEdits(l.getSortedEdits());g.setAttributeNS("urn:webodf:names:editinfo","editinfo:memberid",a);if(d){var f=d;runtime.getWindow().clearTimeout(f)}p&&(f=p,runtime.getWindow().clearTimeout(f));1E4>k?(h(1,0),d=h(0.5,1E4-k),p=h(0.2,2E4-k)):1E4<=k&&2E4>k?(h(0.5,0),p=h(0.2,2E4-k)):h(0.2,0)};this.getEdits= +function(){return l.getEdits()};this.clearEdits=function(){l.clearEdits();e.setEdits([]);g.hasAttributeNS("urn:webodf:names:editinfo","editinfo:memberid")&&g.removeAttributeNS("urn:webodf:names:editinfo","editinfo:memberid")};this.getEditInfo=function(){return l};this.show=function(){g.style.display="block"};this.hide=function(){a.hideHandle();g.style.display="none"};this.showHandle=function(){e.show()};this.hideHandle=function(){e.hide()};this.destroy=function(a){b.removeChild(g);e.destroy(function(b){b? +a(b):l.destroy(a)})};(function(){var c=l.getOdtDocument().getDOM();g=c.createElementNS(c.documentElement.namespaceURI,"div");g.setAttribute("class","editInfoMarker");g.onmouseover=function(){a.showHandle()};g.onmouseout=function(){a.hideHandle()};b=l.getNode();b.appendChild(g);e=new gui.EditInfoHandle(b);m||a.hide()})()}; // Input 74 /* @@ -2077,13 +2153,13 @@ c(a):l.destroy(c)})};(function(){var d=l.getOdtDocument().getDOM();a=d.createEle @source: http://gitorious.org/webodf/webodf/ */ runtime.loadClass("gui.Caret");runtime.loadClass("ops.TrivialMemberModel");runtime.loadClass("ops.EditInfo");runtime.loadClass("gui.EditInfoMarker");gui.SessionViewOptions=function(){this.caretBlinksOnRangeSelect=this.caretAvatarsInitiallyVisible=this.editInfoMarkersInitiallyVisible=!0}; -gui.SessionView=function(){return function(l,m,e){function c(a,b,c){function d(b,c,f){c=b+'[editinfo|memberid^="'+a+'"]'+f+c;a:{var e=t.firstChild;for(b=b+'[editinfo|memberid^="'+a+'"]'+f;e;){if(e.nodeType===Node.TEXT_NODE&&0===e.data.indexOf(b)){b=e;break a}e=e.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+"; }","")}function b(a){var b,c;for(c in q)q.hasOwnProperty(c)&&(b=q[c],a?b.show():b.hide())}function n(a){e.getCarets().forEach(function(b){a?b.showHandle():b.hideHandle()})}function a(a,b){var d=e.getCaret(a);b?(d&&(d.setAvatarImageUrl(b.imageurl),d.setColor(b.color)),c(a,b.fullname,b.color)):runtime.log('MemberModel sent undefined data for member "'+a+'".')}function h(b){var c=b.getMemberId(), -d=m.getMemberModel();e.registerCursor(b,p,r);a(c,null);d.getMemberDetailsAndUpdates(c,a);runtime.log("+++ View here +++ eagerly created an Caret for '"+c+"'! +++")}function f(b){var c=!1,d;for(d in q)if(q.hasOwnProperty(d)&&q[d].getEditInfo().getEdits().hasOwnProperty(b)){c=!0;break}c||m.getMemberModel().unsubscribeMemberDetailsUpdates(b,a)}function d(a){var b=a.paragraphElement,c=a.memberId;a=a.timeStamp;var d,f="",e=b.getElementsByTagNameNS(k,"editinfo")[0];e?(f=e.getAttributeNS(k,"id"),d=q[f]): -(f=Math.random().toString(),d=new ops.EditInfo(b,m.getOdtDocument()),d=new gui.EditInfoMarker(d,g),e=b.getElementsByTagNameNS(k,"editinfo")[0],e.setAttributeNS(k,"id",f),q[f]=d);d.addEdit(c,new Date(a))}var t,k="urn:webodf:names:editinfo",q={},g=void 0!==l.editInfoMarkersInitiallyVisible?Boolean(l.editInfoMarkersInitiallyVisible):!0,p=void 0!==l.caretAvatarsInitiallyVisible?Boolean(l.caretAvatarsInitiallyVisible):!0,r=void 0!==l.caretBlinksOnRangeSelect?Boolean(l.caretBlinksOnRangeSelect):!0;this.showEditInfoMarkers= -function(){g||(g=!0,b(g))};this.hideEditInfoMarkers=function(){g&&(g=!1,b(g))};this.showCaretAvatars=function(){p||(p=!0,n(p))};this.hideCaretAvatars=function(){p&&(p=!1,n(p))};this.getSession=function(){return m};this.getCaret=function(a){return e.getCaret(a)};this.destroy=function(b){var c=m.getOdtDocument(),g=m.getMemberModel(),k=Object.keys(q).map(function(a){return q[a]});c.subscribe(ops.OdtDocument.signalCursorAdded,h);c.subscribe(ops.OdtDocument.signalCursorRemoved,f);c.subscribe(ops.OdtDocument.signalParagraphChanged, -d);e.getCarets().forEach(function(b){g.unsubscribeMemberDetailsUpdates(b.getCursor().getMemberId(),a)});t.parentNode.removeChild(t);(function s(a,c){c?b(c):ab?-1:b-1})};c.slideChange=function(b){var e=c.getPages(c.odf_canvas.odfContainer().rootElement),a=-1,h=0;e.forEach(function(b){b=b[1];b.hasAttribute("slide_current")&&(a=h,b.removeAttribute("slide_current"));h+=1});b=b(a,e.length);-1===b&&(b=a);e[b][1].setAttribute("slide_current", -"1");document.getElementById("pagelist").selectedIndex=b;"cont"===c.slide_mode&&m.scrollBy(0,e[b][1].getBoundingClientRect().top-30)};c.selectSlide=function(b){c.slideChange(function(c,a){return b>=a||0>b?-1:b})};c.scrollIntoContView=function(b){var e=c.getPages(c.odf_canvas.odfContainer().rootElement);0!==e.length&&m.scrollBy(0,e[b][1].getBoundingClientRect().top-30)};c.getPages=function(b){b=b.getElementsByTagNameNS(odf.Namespaces.drawns,"page");var c=[],a;for(a=0;aa?-1:a-1})};a.slideChange=function(b){var e=a.getPages(a.odf_canvas.odfContainer().rootElement),g=-1,d=0;e.forEach(function(a){a=a[1];a.hasAttribute("slide_current")&&(g=d,a.removeAttribute("slide_current"));d+=1});b=b(g,e.length);-1===b&&(b=g);e[b][1].setAttribute("slide_current", +"1");document.getElementById("pagelist").selectedIndex=b;"cont"===a.slide_mode&&m.scrollBy(0,e[b][1].getBoundingClientRect().top-30)};a.selectSlide=function(b){a.slideChange(function(a,g){return b>=g||0>b?-1:b})};a.scrollIntoContView=function(b){var e=a.getPages(a.odf_canvas.odfContainer().rootElement);0!==e.length&&m.scrollBy(0,e[b][1].getBoundingClientRect().top-30)};a.getPages=function(a){a=a.getElementsByTagNameNS(odf.Namespaces.drawns,"page");var e=[],g;for(g=0;g=a.rangeCount||!p)||(a=a.getRangeAt(0),p.setPoint(a.startContainer,a.startOffset))}function n(){var a=l.ownerDocument.defaultView.getSelection(),b,c;a.removeAllRanges();p&&p.node()&&(b=p.node(),c=b.ownerDocument.createRange(), -c.setStart(b,p.position()),c.collapse(!0),a.addRange(c))}function a(a){var d=a.charCode||a.keyCode;if(p=null,p&&37===d)b(),p.stepBackward(),n();else if(16<=d&&20>=d||33<=d&&40>=d)return;c(a)}function h(a){c(a)}function f(a){for(var b=a.firstChild;b&&b!==a;)b.nodeType===Node.ELEMENT_NODE&&f(b),b=b.nextSibling||b.parentNode;var c,d,e,b=a.attributes;c="";for(e=b.length-1;0<=e;e-=1)d=b.item(e),c=c+" "+d.nodeName+'="'+d.nodeValue+'"';a.setAttribute("customns_name",a.nodeName);a.setAttribute("customns_atts", -c);b=a.firstChild;for(d=/^\s*$/;b&&b!==a;)c=b,b=b.nextSibling||b.parentNode,c.nodeType===Node.TEXT_NODE&&d.test(c.nodeValue)&&c.parentNode.removeChild(c)}function d(a,b){for(var c=a.firstChild,f,e,g;c&&c!==a;){if(c.nodeType===Node.ELEMENT_NODE)for(d(c,b),f=c.attributes,g=f.length-1;0<=g;g-=1)e=f.item(g),"http://www.w3.org/2000/xmlns/"!==e.namespaceURI||b[e.nodeValue]||(b[e.nodeValue]=e.localName);c=c.nextSibling||c.parentNode}}function t(){var a=l.ownerDocument.createElement("style"),b;b={};d(l,b); -var c={},f,e,g=0;for(f in b)if(b.hasOwnProperty(f)&&f){e=b[f];if(!e||c.hasOwnProperty(e)||"xmlns"===e){do e="ns"+g,g+=1;while(c.hasOwnProperty(e));b[f]=e}c[e]=!0}a.type="text/css";b="@namespace customns url(customns);\n"+k;a.appendChild(l.ownerDocument.createTextNode(b));m=m.parentNode.replaceChild(a,m)}var k,q,g,p=null;l.id||(l.id="xml"+String(Math.random()).substring(2));q="#"+l.id+" ";k=q+"*,"+q+":visited, "+q+":link {display:block; margin: 0px; margin-left: 10px; font-size: medium; color: black; background: white; font-variant: normal; font-weight: normal; font-style: normal; font-family: sans-serif; text-decoration: none; white-space: pre-wrap; height: auto; width: auto}\n"+ -q+":before {color: blue; content: '<' attr(customns_name) attr(customns_atts) '>';}\n"+q+":after {color: blue; content: '';}\n"+q+"{overflow: auto;}\n";(function(b){e(b,"click",h);e(b,"keydown",a);e(b,"drop",c);e(b,"dragend",c);e(b,"beforepaste",c);e(b,"paste",c)})(l);this.updateCSS=t;this.setXML=function(a){a=a.documentElement||a;g=a=l.ownerDocument.importNode(a,!0);for(f(a);l.lastChild;)l.removeChild(l.lastChild);l.appendChild(a);t();p=new core.PositionIterator(a)};this.getXML= -function(){return g}}; +gui.XMLEdit=function(l,m){function h(a,b,c){a.addEventListener?a.addEventListener(b,c,!1):a.attachEvent?a.attachEvent("on"+b,c):a["on"+b]=c}function a(a){a.preventDefault?a.preventDefault():a.returnValue=!1}function b(){var a=l.ownerDocument.defaultView.getSelection();!a||(0>=a.rangeCount||!u)||(a=a.getRangeAt(0),u.setPoint(a.startContainer,a.startOffset))}function e(){var a=l.ownerDocument.defaultView.getSelection(),b,c;a.removeAllRanges();u&&u.node()&&(b=u.node(),c=b.ownerDocument.createRange(), +c.setStart(b,u.position()),c.collapse(!0),a.addRange(c))}function g(c){var d=c.charCode||c.keyCode;if(u=null,u&&37===d)b(),u.stepBackward(),e();else if(16<=d&&20>=d||33<=d&&40>=d)return;a(c)}function d(b){a(b)}function p(a){for(var b=a.firstChild;b&&b!==a;)b.nodeType===Node.ELEMENT_NODE&&p(b),b=b.nextSibling||b.parentNode;var c,d,e,b=a.attributes;c="";for(e=b.length-1;0<=e;e-=1)d=b.item(e),c=c+" "+d.nodeName+'="'+d.nodeValue+'"';a.setAttribute("customns_name",a.nodeName);a.setAttribute("customns_atts", +c);b=a.firstChild;for(d=/^\s*$/;b&&b!==a;)c=b,b=b.nextSibling||b.parentNode,c.nodeType===Node.TEXT_NODE&&d.test(c.nodeValue)&&c.parentNode.removeChild(c)}function c(a,b){for(var d=a.firstChild,e,f,g;d&&d!==a;){if(d.nodeType===Node.ELEMENT_NODE)for(c(d,b),e=d.attributes,g=e.length-1;0<=g;g-=1)f=e.item(g),"http://www.w3.org/2000/xmlns/"!==f.namespaceURI||b[f.nodeValue]||(b[f.nodeValue]=f.localName);d=d.nextSibling||d.parentNode}}function q(){var a=l.ownerDocument.createElement("style"),b;b={};c(l,b); +var d={},e,f,g=0;for(e in b)if(b.hasOwnProperty(e)&&e){f=b[e];if(!f||d.hasOwnProperty(f)||"xmlns"===f){do f="ns"+g,g+=1;while(d.hasOwnProperty(f));b[e]=f}d[f]=!0}a.type="text/css";b="@namespace customns url(customns);\n"+k;a.appendChild(l.ownerDocument.createTextNode(b));m=m.parentNode.replaceChild(a,m)}var k,f,n,u=null;l.id||(l.id="xml"+String(Math.random()).substring(2));f="#"+l.id+" ";k=f+"*,"+f+":visited, "+f+":link {display:block; margin: 0px; margin-left: 10px; font-size: medium; color: black; background: white; font-variant: normal; font-weight: normal; font-style: normal; font-family: sans-serif; text-decoration: none; white-space: pre-wrap; height: auto; width: auto}\n"+ +f+":before {color: blue; content: '<' attr(customns_name) attr(customns_atts) '>';}\n"+f+":after {color: blue; content: '';}\n"+f+"{overflow: auto;}\n";(function(b){h(b,"click",d);h(b,"keydown",g);h(b,"drop",a);h(b,"dragend",a);h(b,"beforepaste",a);h(b,"paste",a)})(l);this.updateCSS=q;this.setXML=function(a){a=a.documentElement||a;n=a=l.ownerDocument.importNode(a,!0);for(p(a);l.lastChild;)l.removeChild(l.lastChild);l.appendChild(a);q();u=new core.PositionIterator(a)};this.getXML= +function(){return n}}; // Input 78 /* @@ -2212,8 +2289,8 @@ gui.UndoManager.prototype.moveForward=function(l){};gui.UndoManager.prototype.mo @source: http://www.webodf.org/ @source: http://gitorious.org/webodf/webodf/ */ -gui.UndoStateRules=function(){function l(e){return e.spec().optype}function m(e){switch(l(e)){case "MoveCursor":case "AddCursor":case "RemoveCursor":return!1;default:return!0}}this.getOpType=l;this.isEditOperation=m;this.isPartOfOperationSet=function(e,c){if(m(e)){if(0===c.length)return!0;var b;if(b=m(c[c.length-1]))a:{b=c.filter(m);var n=l(e),a;b:switch(n){case "RemoveText":case "InsertText":a=!0;break b;default:a=!1}if(a&&n===l(b[0])){if(1===b.length){b=!0;break a}n=b[b.length-2].spec().position; -b=b[b.length-1].spec().position;a=e.spec().position;if(b===a-(b-n)){b=!0;break a}}b=!1}return b}return!0}}; +gui.UndoStateRules=function(){function l(h){return h.spec().optype}function m(h){switch(l(h)){case "MoveCursor":case "AddCursor":case "RemoveCursor":return!1;default:return!0}}this.getOpType=l;this.isEditOperation=m;this.isPartOfOperationSet=function(h,a){if(m(h)){if(0===a.length)return!0;var b;if(b=m(a[a.length-1]))a:{b=a.filter(m);var e=l(h),g;b:switch(e){case "RemoveText":case "InsertText":g=!0;break b;default:g=!1}if(g&&e===l(b[0])){if(1===b.length){b=!0;break a}e=b[b.length-2].spec().position; +b=b[b.length-1].spec().position;g=h.spec().position;if(b===g-(b-e)){b=!0;break a}}b=!1}return b}return!0}}; // Input 80 /* @@ -2250,12 +2327,12 @@ b=b[b.length-1].spec().position;a=e.spec().position;if(b===a-(b-n)){b=!0;break a @source: http://gitorious.org/webodf/webodf/ */ runtime.loadClass("core.DomUtils");runtime.loadClass("gui.UndoManager");runtime.loadClass("gui.UndoStateRules"); -gui.TrivialUndoManager=function(l){function m(){r.emit(gui.UndoManager.signalUndoStackChanged,{undoAvailable:a.hasUndoStates(),redoAvailable:a.hasRedoStates()})}function e(){q!==d&&q!==g[g.length-1]&&g.push(q)}function c(a){var b=a.previousSibling||a.nextSibling;a.parentNode.removeChild(a);h.normalizeTextNodes(b)}function b(a){return Object.keys(a).map(function(b){return a[b]})}function n(a){function c(a){var b=a.spec();if(e[b.memberid])switch(b.optype){case "AddCursor":d[b.memberid]||(d[b.memberid]= -a,delete e[b.memberid],g-=1);break;case "MoveCursor":f[b.memberid]||(f[b.memberid]=a)}}var d={},f={},e={},g,h=a.pop();k.getCursors().forEach(function(a){e[a.getMemberId()]=!0});for(g=Object.keys(e).length;h&&0=f;f+=1){b=a.container();d=a.unfilteredDomOffset();if(b.nodeType===Node.TEXT_NODE&&" "===b.data[d]&& -h.isSignificantWhitespace(b,d)){runtime.assert(" "===b.data[d],"upgradeWhitespaceToElement: textNode.data[offset] should be a literal space");var e=b.ownerDocument.createElementNS("urn:oasis:names:tc:opendocument:xmlns:text:1.0","text:s");e.appendChild(b.ownerDocument.createTextNode(" "));b.deleteData(d,1);0= 0");1===q.acceptPosition(d)?(h=d.container(),h.nodeType===Node.TEXT_NODE&&(e=h,k=0)):b+=1;for(;0=e;e+=1){c=b.container();d=b.unfilteredDomOffset();if(c.nodeType===Node.TEXT_NODE&& +" "===c.data[d]&&p.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");u.acceptPosition(c)===f?(g=c.container(),g.nodeType===Node.TEXT_NODE&&(e=g,h=0)):a+=1;for(;0 draw|image:nth-of-type(n+2) {\n display: none;\n}\ntext|list:before {\n display: none;\n content:\"\";\n}\ntext|list {\n counter-reset: list;\n}\ntext|list-item {\n display: block;\n}\ntext|number {\n display:none;\n}\n\ntext|a {\n color: blue;\n text-decoration: underline;\n cursor: pointer;\n}\ntext|note-citation {\n vertical-align: super;\n font-size: smaller;\n}\ntext|note-body {\n display: none;\n}\ntext|note:hover text|note-citation {\n background: #dddddd;\n}\ntext|note:hover text|note-body {\n display: block;\n left:1em;\n max-width: 80%;\n position: absolute;\n background: #ffffaa;\n}\nsvg|title, svg|desc {\n display: none;\n}\nvideo {\n width: 100%;\n height: 100%\n}\n\n/* below set up the cursor */\ncursor|cursor {\n display: inline;\n width: 0px;\n height: 1em;\n /* making the position relative enables the avatar to use\n the cursor as reference for its absolute position */\n position: relative;\n z-index: 1;\n}\ncursor|cursor > span {\n display: inline;\n position: absolute;\n top: 5%; /* push down the caret; 0px can do the job, 5% looks better, 10% is a bit over */\n height: 1em;\n border-left: 2px solid black;\n outline: none;\n}\n\ncursor|cursor > div {\n padding: 3px;\n box-shadow: 0px 0px 5px rgba(50, 50, 50, 0.75);\n border: none !important;\n border-radius: 5px;\n opacity: 0.3;\n}\n\ncursor|cursor > div > img {\n border-radius: 5px;\n}\n\ncursor|cursor > div.active {\n opacity: 0.8;\n}\n\ncursor|cursor > div:after {\n content: ' ';\n position: absolute;\n width: 0px;\n height: 0px;\n border-style: solid;\n border-width: 8.7px 5px 0 5px;\n border-color: black transparent transparent transparent;\n\n top: 100%;\n left: 43%;\n}\n\n\n.editInfoMarker {\n position: absolute;\n width: 10px;\n height: 100%;\n left: -20px;\n opacity: 0.8;\n top: 0;\n border-radius: 5px;\n background-color: transparent;\n box-shadow: 0px 0px 5px rgba(50, 50, 50, 0.75);\n}\n.editInfoMarker:hover {\n box-shadow: 0px 0px 8px rgba(0, 0, 0, 1);\n}\n\n.editInfoHandle {\n position: absolute;\n background-color: black;\n padding: 5px;\n border-radius: 5px;\n opacity: 0.8;\n box-shadow: 0px 0px 5px rgba(50, 50, 50, 0.75);\n bottom: 100%;\n margin-bottom: 10px;\n z-index: 3;\n left: -25px;\n}\n.editInfoHandle:after {\n content: ' ';\n position: absolute;\n width: 0px;\n height: 0px;\n border-style: solid;\n border-width: 8.7px 5px 0 5px;\n border-color: black transparent transparent transparent;\n\n top: 100%;\n left: 5px;\n}\n.editInfo {\n font-family: sans-serif;\n font-weight: normal;\n font-style: normal;\n text-decoration: none;\n color: white;\n width: 100%;\n height: 12pt;\n}\n.editInfoColor {\n float: left;\n width: 10pt;\n height: 10pt;\n border: 1px solid white;\n}\n.editInfoAuthor {\n float: left;\n margin-left: 5pt;\n font-size: 10pt;\n text-align: left;\n height: 12pt;\n line-height: 12pt;\n}\n.editInfoTime {\n float: right;\n margin-left: 30pt;\n font-size: 8pt;\n font-style: italic;\n color: yellow;\n height: 12pt;\n line-height: 12pt;\n}\n\n.annotationWrapper {\n display: inline;\n position: relative;\n}\n\n.annotationRemoveButton:before {\n content: '\u00d7';\n color: white;\n padding: 5px;\n line-height: 1em;\n}\n\n.annotationRemoveButton {\n width: 20px;\n height: 20px;\n border-radius: 10px;\n background-color: black;\n box-shadow: 0px 0px 5px rgba(50, 50, 50, 0.75);\n position: absolute;\n top: -10px;\n left: -10px;\n z-index: 3;\n text-align: center;\n font-family: sans-serif;\n font-style: normal;\n font-weight: normal;\n text-decoration: none;\n font-size: 15px;\n}\n.annotationRemoveButton:hover {\n cursor: pointer;\n box-shadow: 0px 0px 5px rgba(0, 0, 0, 1);\n}\n\n.annotationNote {\n width: 4cm;\n position: absolute;\n display: inline;\n z-index: 10;\n}\n.annotationNote > office|annotation {\n display: block;\n text-align: left;\n}\n\n.annotationConnector {\n position: absolute;\n display: inline;\n z-index: 2;\n border-top: 1px dashed brown;\n}\n.annotationConnector.angular {\n -moz-transform-origin: left top;\n -webkit-transform-origin: left top;\n -ms-transform-origin: left top;\n transform-origin: left top;\n}\n.annotationConnector.horizontal {\n left: 0;\n}\n.annotationConnector.horizontal:before {\n content: '';\n display: inline;\n position: absolute;\n width: 0px;\n height: 0px;\n border-style: solid;\n border-width: 8.7px 5px 0 5px;\n border-color: brown transparent transparent transparent;\n top: -1px;\n left: -5px;\n}\n\noffice|annotation {\n width: 100%;\n height: 100%;\n display: none;\n background: rgb(198, 238, 184);\n background: -moz-linear-gradient(90deg, rgb(198, 238, 184) 30%, rgb(180, 196, 159) 100%);\n background: -webkit-linear-gradient(90deg, rgb(198, 238, 184) 30%, rgb(180, 196, 159) 100%);\n background: -o-linear-gradient(90deg, rgb(198, 238, 184) 30%, rgb(180, 196, 159) 100%);\n background: -ms-linear-gradient(90deg, rgb(198, 238, 184) 30%, rgb(180, 196, 159) 100%);\n background: linear-gradient(180deg, rgb(198, 238, 184) 30%, rgb(180, 196, 159) 100%);\n box-shadow: 0 3px 4px -3px #ccc;\n}\n\noffice|annotation > dc|creator {\n display: block;\n font-size: 10pt;\n font-weight: normal;\n font-style: normal;\n font-family: sans-serif;\n color: white;\n background-color: brown;\n padding: 4px;\n}\noffice|annotation > dc|date {\n display: block;\n font-size: 10pt;\n font-weight: normal;\n font-style: normal;\n font-family: sans-serif;\n border: 4px solid transparent;\n}\noffice|annotation > text|list {\n display: block;\n padding: 5px;\n}\n\n/* This is very temporary CSS. This must go once\n * we start bundling webodf-default ODF styles for annotations.\n */\noffice|annotation text|p {\n font-size: 10pt;\n color: black;\n font-weight: normal;\n font-style: normal;\n text-decoration: none;\n font-family: sans-serif;\n}\n\ndc|*::selection {\n background: transparent;\n}\ndc|*::-moz-selection {\n background: transparent;\n}\n\n#annotationsPane {\n background-color: #EAEAEA;\n width: 4cm;\n height: 100%;\n display: none;\n position: absolute;\n outline: 1px solid #ccc;\n}\n\n.annotationHighlight {\n background-color: yellow;\n position: relative;\n}\n";