X-Git-Url: http://git.roojs.org/?p=Pman.Core;a=blobdiff_plain;f=Pman.Gnumeric.js;h=a346fba734682380cd2b22c54273ea66c514bbf0;hp=2574bd27b3cc8cf6ca5b3f0343ff55b2011941d1;hb=HEAD;hpb=c296361e147ac9c426d1cc83c44c90c042676fa7 diff --git a/Pman.Gnumeric.js b/Pman.Gnumeric.js index 2574bd27..a346fba7 100644 --- a/Pman.Gnumeric.js +++ b/Pman.Gnumeric.js @@ -148,6 +148,13 @@ Roo.extend(Pman.Gnumeric, Roo.util.Observable, { rowOffset : 0, + /** + * @type {String} format - either XLSX (if images are used) or XLS - as ssconvert does not do images that well. + */ + + format : 'xlsx', + + /** * load: * run the connection, parse document and fire load event.. @@ -211,7 +218,7 @@ Roo.extend(Pman.Gnumeric, Roo.util.Observable, { // we wil only support AA not AAA var top = Math.floor(c/26); var bot = c % 26; - var cc = top > 0 ? String.fromCharCode('A'.charCodeAt(0) + top) : ''; + var cc = top > 0 ? String.fromCharCode('A'.charCodeAt(0) + (top-1)) : ''; cc += String.fromCharCode('A'.charCodeAt(0) + bot); return cc+'' +r; @@ -1164,11 +1171,22 @@ Roo.extend(Pman.Gnumeric, Roo.util.Observable, { var ww = 0.01; // offset a bit... var hh = 0.01; // + var rowHeight = typeof(this.rowInfoDom[row]) == 'undefined' ? 100 : + this.rowInfoDom[row].getAttribute('Unit')*1; + + var ww2 = 1 - ((colwidth - width) / this.colInfo[endcol]); - var hh2 = 0.99; + var hh2 = 1 - ((rowHeight - height) / rowHeight); var offset_str = ww + ' ' + hh + ' ' + ww2 + ' '+hh2; + // offset string 0.01 0.01 0.01 0.392 << last one needs to be calculated based on proportions. + // so what are our dimentions.. + + + + + //alert(offset_str); soi.setAttribute('ObjectOffset', offset_str); soi.setAttribute('ObjectAnchorType','16 16 16 16'); @@ -1178,9 +1196,14 @@ Roo.extend(Pman.Gnumeric, Roo.util.Observable, { soi.setAttribute('crop-left','0.000000'); soi.setAttribute('crop-right','0.000000'); + + + + var content = this.doc.createElement('Content'); content.setAttribute('image-type', type ? type : 'jpeg'); content.setAttribute('size-bytes', size); + content.appendChild( this.doc.createTextNode(data)); soi.appendChild(content); objs.appendChild(soi); @@ -1218,6 +1241,7 @@ Roo.extend(Pman.Gnumeric, Roo.util.Observable, { * @param {Number} width image height * */ + writeImage : function (row, col, data, width, height, type) { @@ -1274,8 +1298,12 @@ Roo.extend(Pman.Gnumeric, Roo.util.Observable, { var ww = 0.01; // offset a bit... var hh = 0.01; // + var rowHeight = typeof(this.rowInfoDom[row]) == 'undefined' ? 100 : + this.rowInfoDom[row].getAttribute('Unit')*1; + + var ww2 = 1 - ((colwidth - width) / this.colInfo[endcol]); - var hh2 = 0.99; + var hh2 = 1 - ((rowHeight - height) / rowHeight); var offset_str = ww + ' ' + hh + ' ' + ww2 + ' '+hh2; @@ -1360,7 +1388,7 @@ Roo.extend(Pman.Gnumeric, Roo.util.Observable, { var content = this.doc.createElement('Content'); content.setAttribute('image-type', type ? type : 'jpeg'); content.setAttribute('size-bytes', size); - content.textContent = data; + content.appendChild( this.doc.createTextNode(data)); soi.appendChild(content); objs.appendChild(soi); @@ -1416,6 +1444,7 @@ Roo.extend(Pman.Gnumeric, Roo.util.Observable, { var content = this.doc.createElement('Content'); content.setAttribute('image-type', type ? type : 'jpeg'); content.setAttribute('name', name); + soi.appendChild(content); objs.appendChild(soi); @@ -1687,22 +1716,28 @@ Roo.extend(Pman.Gnumeric, Roo.util.Observable, { } var ser = new XMLSerializer(); + Roo.get(document.body).mask("Downloading"); var x = new Pman.Download({ method: 'POST', - timeout : 120000, // quite a long wait.. 2 minutes. + timeout :240000, // quite a long wait.. 2 minutes. params : { xml : ser.serializeToString(this.doc), - format : 'xls', //xml + format : this.format, debug : 0 }, url : (this.downloadURL || (baseURL + '/GnumericToExcel/')) + name + '.xls', success : function() { + Roo.get(document.body).unmask(); Roo.MessageBox.alert("Alert", "File should have downloaded now"); if (callback) { callback(); } - } + }, + failure : function() { + Roo.get(document.body).unmask(); + Roo.MessageBox.alert("Alert", "Download failed"); + } }); }