2017-03-27 21:35:15 +00:00
|
|
|
RELS.CS = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chartsheet";
|
|
|
|
|
2017-04-08 06:55:35 +00:00
|
|
|
var CS_XML_ROOT = writextag('chartsheet', null, {
|
|
|
|
'xmlns': XMLNS.main[0],
|
|
|
|
'xmlns:r': XMLNS.r
|
|
|
|
});
|
|
|
|
|
2017-03-27 21:35:15 +00:00
|
|
|
/* 18.3 Worksheets also covers Chartsheets */
|
|
|
|
function parse_cs_xml(data/*:?string*/, opts, rels, wb, themes, styles)/*:Worksheet*/ {
|
|
|
|
if(!data) return data;
|
|
|
|
/* 18.3.1.12 chartsheet CT_ChartSheet */
|
|
|
|
if(!rels) rels = {'!id':{}};
|
|
|
|
var s = {'!type':"chart", '!chart':null, '!rel':""};
|
|
|
|
var m;
|
|
|
|
|
|
|
|
/* 18.3.1.36 drawing CT_Drawing */
|
|
|
|
if((m = data.match(/drawing r:id="(.*?)"/))) s['!rel'] = m[1];
|
|
|
|
|
|
|
|
if(rels['!id'][s['!rel']]) s['!chart'] = rels['!id'][s['!rel']];
|
|
|
|
return s;
|
|
|
|
}
|
2017-04-08 06:55:35 +00:00
|
|
|
function write_cs_xml(idx/*:number*/, opts, wb/*:Workbook*/, rels)/*:string*/ {
|
|
|
|
var o = [XML_HEADER, CS_XML_ROOT];
|
|
|
|
o[o.length] = writextag("drawing", null, {"r:id": "rId1"});
|
|
|
|
add_rels(rels, -1, "../drawings/drawing" + (idx+1) + ".xml", RELS.DRAW);
|
|
|
|
if(o.length>2) { o[o.length] = ('</chartsheet>'); o[1]=o[1].replace("/>",">"); }
|
|
|
|
return o.join("");
|
|
|
|
}
|
2017-03-27 21:35:15 +00:00
|
|
|
|
|
|
|
/* [MS-XLSB] 2.1.7.7 Chart Sheet */
|
|
|
|
function parse_cs_bin(data, opts, rels, wb, themes, styles)/*:Worksheet*/ {
|
|
|
|
if(!data) return data;
|
|
|
|
if(!rels) rels = {'!id':{}};
|
|
|
|
var s = {'!type':"chart", '!chart':null, '!rel':""};
|
2017-04-08 06:55:35 +00:00
|
|
|
var state = [];
|
2017-03-27 21:35:15 +00:00
|
|
|
var pass = false;
|
2017-04-08 06:55:35 +00:00
|
|
|
recordhopper(data, function cs_parse(val, Record, RT) {
|
2017-03-27 21:35:15 +00:00
|
|
|
switch(Record.n) {
|
|
|
|
|
|
|
|
case 'BrtDrawing': s['!rel'] = val; break;
|
|
|
|
|
2017-04-08 06:55:35 +00:00
|
|
|
case 'BrtUid': break;
|
|
|
|
case 'BrtMargins': break; // TODO
|
|
|
|
case 'BrtLegacyDrawing': break; // TODO
|
|
|
|
case 'BrtLegacyDrawingHF': break; // TODO
|
|
|
|
case 'BrtBkHim': break; // TODO
|
2017-03-27 21:35:15 +00:00
|
|
|
case 'BrtCsProp': break; // TODO
|
|
|
|
case 'BrtCsProtection': break; // TODO
|
2017-04-08 06:55:35 +00:00
|
|
|
case 'BrtCsProtectionIso': break; // TODO
|
2017-03-27 21:35:15 +00:00
|
|
|
case 'BrtCsPageSetup': break; // TODO
|
2017-04-08 06:55:35 +00:00
|
|
|
|
|
|
|
case 'BrtFRTBegin': pass = true; break;
|
|
|
|
case 'BrtFRTEnd': pass = false; break;
|
|
|
|
case 'BrtACBegin': state.push(R.n); break;
|
|
|
|
case 'BrtACEnd': state.pop(); break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
if((Record.n||"").indexOf("Begin") > 0) state.push(Record.n);
|
|
|
|
else if((Record.n||"").indexOf("End") > 0) state.pop();
|
|
|
|
else if(!pass || opts.WTF) throw new Error("Unexpected record " + RT + " " + Record.n);
|
2017-03-27 21:35:15 +00:00
|
|
|
}
|
|
|
|
}, opts);
|
|
|
|
|
|
|
|
if(rels['!id'][s['!rel']]) s['!chart'] = rels['!id'][s['!rel']];
|
|
|
|
return s;
|
|
|
|
}
|
2017-04-08 06:55:35 +00:00
|
|
|
function write_cs_bin(idx/*:number*/, opts, wb/*:Workbook*/, rels) {
|
|
|
|
var ba = buf_array();
|
|
|
|
write_record(ba, "BrtBeginSheet");
|
|
|
|
/* [BrtCsProp] */
|
|
|
|
/* CSVIEWS */
|
|
|
|
/* [[BrtCsProtectionIso] BrtCsProtection] */
|
|
|
|
/* [USERCSVIEWS] */
|
|
|
|
/* [BrtMargins] */
|
|
|
|
/* [BrtCsPageSetup] */
|
|
|
|
/* [HEADERFOOTER] */
|
|
|
|
/* BrtDrawing */
|
|
|
|
/* [BrtLegacyDrawing] */
|
|
|
|
/* [BrtLegacyDrawingHF] */
|
|
|
|
/* [BrtBkHim] */
|
|
|
|
/* [WEBPUBITEMS] */
|
|
|
|
/* FRTCHARTSHEET */
|
|
|
|
write_record(ba, "BrtEndSheet");
|
|
|
|
return ba.end();
|
|
|
|
}
|