2017-03-27 21:35:15 +00:00
|
|
|
RELS.CS = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chartsheet";
|
|
|
|
|
|
|
|
/* 18.3 Worksheets also covers Chartsheets */
|
2018-01-23 09:07:51 +00:00
|
|
|
function parse_cs_xml(data/*:?string*/, opts, idx/*:number*/, rels, wb/*::, themes, styles*/)/*:Worksheet*/ {
|
2017-03-27 21:35:15 +00:00
|
|
|
if(!data) return data;
|
|
|
|
/* 18.3.1.12 chartsheet CT_ChartSheet */
|
|
|
|
if(!rels) rels = {'!id':{}};
|
2019-11-15 01:46:49 +00:00
|
|
|
var s = ({'!type':"chart", '!drawel':null, '!rel':""}/*:any*/);
|
2017-03-27 21:35:15 +00:00
|
|
|
var m;
|
|
|
|
|
2017-11-20 01:51:14 +00:00
|
|
|
/* 18.3.1.83 sheetPr CT_ChartsheetPr */
|
|
|
|
var sheetPr = data.match(sheetprregex);
|
|
|
|
if(sheetPr) parse_ws_xml_sheetpr(sheetPr[0], s, wb, idx);
|
|
|
|
|
2017-03-27 21:35:15 +00:00
|
|
|
/* 18.3.1.36 drawing CT_Drawing */
|
|
|
|
if((m = data.match(/drawing r:id="(.*?)"/))) s['!rel'] = m[1];
|
|
|
|
|
2019-11-15 01:46:49 +00:00
|
|
|
if(rels['!id'][s['!rel']]) s['!drawel'] = rels['!id'][s['!rel']];
|
2017-03-27 21:35:15 +00:00
|
|
|
return s;
|
|
|
|
}
|
2017-04-08 06:55:35 +00:00
|
|
|
function write_cs_xml(idx/*:number*/, opts, wb/*:Workbook*/, rels)/*:string*/ {
|
2022-03-11 05:29:05 +00:00
|
|
|
var o = [XML_HEADER, writextag('chartsheet', null, {
|
|
|
|
'xmlns': XMLNS.main[0],
|
|
|
|
'xmlns:r': XMLNS.r
|
|
|
|
})];
|
2017-04-08 06:55:35 +00:00
|
|
|
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
|
|
|
|
2017-11-20 01:51:14 +00:00
|
|
|
/* [MS-XLSB] 2.4.331 BrtCsProp */
|
|
|
|
function parse_BrtCsProp(data, length/*:number*/) {
|
|
|
|
data.l += 10;
|
|
|
|
var name = parse_XLWideString(data, length - 10);
|
|
|
|
return { name: name };
|
|
|
|
}
|
|
|
|
|
2017-03-27 21:35:15 +00:00
|
|
|
/* [MS-XLSB] 2.1.7.7 Chart Sheet */
|
2018-01-23 09:07:51 +00:00
|
|
|
function parse_cs_bin(data, opts, idx/*:number*/, rels, wb/*::, themes, styles*/)/*:Worksheet*/ {
|
2017-03-27 21:35:15 +00:00
|
|
|
if(!data) return data;
|
|
|
|
if(!rels) rels = {'!id':{}};
|
2019-11-15 01:46:49 +00:00
|
|
|
var s = {'!type':"chart", '!drawel':null, '!rel':""};
|
2017-12-30 05:40:35 +00:00
|
|
|
var state/*:Array<string>*/ = [];
|
2017-03-27 21:35:15 +00:00
|
|
|
var pass = false;
|
2017-04-09 04:03:19 +00:00
|
|
|
recordhopper(data, function cs_parse(val, R_n, RT) {
|
|
|
|
switch(RT) {
|
2017-03-27 21:35:15 +00:00
|
|
|
|
2017-04-09 04:03:19 +00:00
|
|
|
case 0x0226: /* 'BrtDrawing' */
|
|
|
|
s['!rel'] = val; break;
|
2017-03-27 21:35:15 +00:00
|
|
|
|
2017-11-20 01:51:14 +00:00
|
|
|
case 0x028B: /* 'BrtCsProp' */
|
|
|
|
if(!wb.Sheets[idx]) wb.Sheets[idx] = {};
|
|
|
|
if(val.name) wb.Sheets[idx].CodeName = val.name;
|
|
|
|
break;
|
|
|
|
|
2017-04-09 04:03:19 +00:00
|
|
|
case 0x0232: /* 'BrtBkHim' */
|
|
|
|
case 0x028C: /* 'BrtCsPageSetup' */
|
|
|
|
case 0x029D: /* 'BrtCsProtection' */
|
|
|
|
case 0x02A7: /* 'BrtCsProtectionIso' */
|
|
|
|
case 0x0227: /* 'BrtLegacyDrawing' */
|
|
|
|
case 0x0228: /* 'BrtLegacyDrawingHF' */
|
|
|
|
case 0x01DC: /* 'BrtMargins' */
|
2018-03-19 21:42:55 +00:00
|
|
|
case 0x0C00: /* 'BrtUid' */
|
2017-04-09 04:03:19 +00:00
|
|
|
break;
|
2017-04-08 06:55:35 +00:00
|
|
|
|
2017-04-09 04:03:19 +00:00
|
|
|
case 0x0023: /* 'BrtFRTBegin' */
|
|
|
|
pass = true; break;
|
|
|
|
case 0x0024: /* 'BrtFRTEnd' */
|
|
|
|
pass = false; break;
|
|
|
|
case 0x0025: /* 'BrtACBegin' */
|
|
|
|
state.push(R_n); break;
|
|
|
|
case 0x0026: /* 'BrtACEnd' */
|
|
|
|
state.pop(); break;
|
2017-04-08 06:55:35 +00:00
|
|
|
|
|
|
|
default:
|
2017-04-09 04:03:19 +00:00
|
|
|
if((R_n||"").indexOf("Begin") > 0) state.push(R_n);
|
|
|
|
else if((R_n||"").indexOf("End") > 0) state.pop();
|
|
|
|
else if(!pass || opts.WTF) throw new Error("Unexpected record " + RT + " " + R_n);
|
2017-03-27 21:35:15 +00:00
|
|
|
}
|
|
|
|
}, opts);
|
|
|
|
|
2019-11-15 01:46:49 +00:00
|
|
|
if(rels['!id'][s['!rel']]) s['!drawel'] = rels['!id'][s['!rel']];
|
2017-03-27 21:35:15 +00:00
|
|
|
return s;
|
|
|
|
}
|
2018-01-23 09:07:51 +00:00
|
|
|
function write_cs_bin(/*::idx:number, opts, wb:Workbook, rels*/) {
|
2017-04-08 06:55:35 +00:00
|
|
|
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();
|
|
|
|
}
|