1 /** 2 * Copyright (C) 2012-2013 KO GmbH <copyright@kogmbh.com> 3 * 4 * @licstart 5 * This file is part of WebODF. 6 * 7 * WebODF is free software: you can redistribute it and/or modify it 8 * under the terms of the GNU Affero General Public License (GNU AGPL) 9 * as published by the Free Software Foundation, either version 3 of 10 * the License, or (at your option) any later version. 11 * 12 * WebODF is distributed in the hope that it will be useful, but 13 * WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU Affero General Public License for more details. 16 * 17 * You should have received a copy of the GNU Affero General Public License 18 * along with WebODF. If not, see <http://www.gnu.org/licenses/>. 19 * @licend 20 * 21 * @source: http://www.webodf.org/ 22 * @source: https://github.com/kogmbh/WebODF/ 23 */ 24 25 /*global ops */ 26 27 /** 28 * @constructor 29 * @implements ops.Operation 30 */ 31 ops.OpSetBlob = function OpSetBlob() { 32 "use strict"; 33 34 var memberid, timestamp, filename, mimetype, content; 35 36 /** 37 * @param {!ops.OpSetBlob.InitSpec} data 38 */ 39 this.init = function (data) { 40 memberid = data.memberid; 41 timestamp = data.timestamp; 42 filename = data.filename; 43 mimetype = data.mimetype; 44 content = data.content; 45 }; 46 47 this.isEdit = true; 48 this.group = undefined; 49 50 /** 51 * @param {!ops.Document} document 52 */ 53 this.execute = function (document) { 54 var odtDocument = /**@type{ops.OdtDocument}*/(document); 55 odtDocument.getOdfCanvas().odfContainer().setBlob(filename, mimetype, content); 56 return true; 57 }; 58 59 /** 60 * @return {!ops.OpSetBlob.Spec} 61 */ 62 this.spec = function () { 63 return { 64 optype: "SetBlob", 65 memberid: memberid, 66 timestamp: timestamp, 67 filename: filename, 68 mimetype: mimetype, 69 content: content 70 }; 71 }; 72 }; 73 /**@typedef{{ 74 optype:string, 75 memberid:string, 76 timestamp:number, 77 filename:string, 78 mimetype:string, 79 content:string 80 }}*/ 81 ops.OpSetBlob.Spec; 82 /**@typedef{{ 83 memberid:string, 84 timestamp:(number|undefined), 85 filename:string, 86 mimetype:string, 87 content:string 88 }}*/ 89 ops.OpSetBlob.InitSpec; 90