/* 18.8.5 borders CT_Borders */
function parse_borders(t, styles, themes, opts) {
styles.Borders = [];
var border = {};
var pass = false;
(t[0].match(tagregex)||[]).forEach(function(x) {
var y = parsexmltag(x);
switch(strip_ns(y[0])) {
case '': case '': break;
/* 18.8.4 border CT_Border */
case '': case '':
border = /*::(*/{}/*:: :any)*/;
if(y.diagonalUp) border.diagonalUp = parsexmlbool(y.diagonalUp);
if(y.diagonalDown) border.diagonalDown = parsexmlbool(y.diagonalDown);
styles.Borders.push(border);
break;
case '': break;
/* note: not in spec, appears to be CT_BorderPr */
case '': break;
case '': break;
case '': break;
/* note: not in spec, appears to be CT_BorderPr */
case '': break;
case '': break;
case '': break;
/* 18.8.43 top CT_BorderPr */
case '': break;
case '': break;
case '': break;
/* 18.8.6 bottom CT_BorderPr */
case '': break;
case '': break;
case '': break;
/* 18.8.13 diagonal CT_BorderPr */
case '': case '': break;
case '': break;
/* 18.8.25 horizontal CT_BorderPr */
case '': case '': break;
case '': break;
/* 18.8.44 vertical CT_BorderPr */
case '': case '': break;
case '': break;
/* 18.8.37 start CT_BorderPr */
case '': case '': break;
case '': break;
/* 18.8.16 end CT_BorderPr */
case '': case '': break;
case '': break;
/* 18.8.? color CT_Color */
case '':
break;
case '': case '': break;
/* 18.2.10 extLst CT_ExtensionList ? */
case '': case '': break;
case '': pass = false; break;
default: if(opts && opts.WTF) {
if(!pass) throw new Error('unrecognized ' + y[0] + ' in borders');
}
}
});
}
/* 18.8.21 fills CT_Fills */
function parse_fills(t, styles, themes, opts) {
styles.Fills = [];
var fill = {};
var pass = false;
(t[0].match(tagregex)||[]).forEach(function(x) {
var y = parsexmltag(x);
switch(strip_ns(y[0])) {
case '': case '': break;
/* 18.8.20 fill CT_Fill */
case '': case '':
fill = {}; styles.Fills.push(fill); break;
case '': break;
/* 18.8.24 gradientFill CT_GradientFill */
case '': break;
case '': styles.Fills.push(fill); fill = {}; break;
/* 18.8.32 patternFill CT_PatternFill */
case '':
if(y.patternType) fill.patternType = y.patternType;
break;
case '': case '': break;
/* 18.8.3 bgColor CT_Color */
case '': case '': break;
/* 18.8.19 fgColor CT_Color */
case '': case '': break;
/* 18.8.38 stop CT_GradientStop */
case '': break;
case '': break;
/* 18.8.? color CT_Color */
case '': break;
case '': break;
/* 18.2.10 extLst CT_ExtensionList ? */
case '': case '': break;
case '': pass = false; break;
default: if(opts && opts.WTF) {
if(!pass) throw new Error('unrecognized ' + y[0] + ' in fills');
}
}
});
}
/* 18.8.23 fonts CT_Fonts */
function parse_fonts(t, styles, themes, opts) {
styles.Fonts = [];
var font = {};
var pass = false;
(t[0].match(tagregex)||[]).forEach(function(x) {
var y = parsexmltag(x);
switch(strip_ns(y[0])) {
case '': case '': break;
/* 18.8.22 font CT_Font */
case '': break;
case '': case '':
styles.Fonts.push(font);
font = {};
break;
/* 18.8.29 name CT_FontName */
case '': case '': break;
/* 18.8.2 b CT_BooleanProperty */
case '': font.bold = 1; break;
/* 18.8.26 i CT_BooleanProperty */
case '': font.italic = 1; break;
/* 18.4.13 u CT_UnderlineProperty */
case '': font.underline = 1; break;
/* 18.4.10 strike CT_BooleanProperty */
case '': font.strike = 1; break;
/* 18.4.2 outline CT_BooleanProperty */
case '': font.outline = 1; break;
/* 18.8.36 shadow CT_BooleanProperty */
case '': font.shadow = 1; break;
/* 18.8.12 condense CT_BooleanProperty */
case '': font.condense = 1; break;
/* 18.8.17 extend CT_BooleanProperty */
case '': font.extend = 1; break;
/* 18.4.11 sz CT_FontSize */
case '': case '': break;
/* 18.4.14 vertAlign CT_VerticalAlignFontProperty */
case '': case '': break;
/* 18.8.18 family CT_FontFamily */
case '': case '': break;
/* 18.8.35 scheme CT_FontScheme */
case '': case '': break;
/* 18.4.1 charset CT_IntProperty */
case '': case '': break;
/* note: sometimes mc:AlternateContent appears bare */
case '': pass = false; break;
/* 18.2.10 extLst CT_ExtensionList ? */
case '': case '': break;
case '': pass = false; break;
default: if(opts && opts.WTF) {
if(!pass) throw new Error('unrecognized ' + y[0] + ' in fonts');
}
}
});
}
/* 18.8.31 numFmts CT_NumFmts */
function parse_numFmts(t, styles, opts) {
styles.NumberFmt = [];
var k/*Array*/ = (keys(table_fmt)/*:any*/);
for(var i=0; i < k.length; ++i) styles.NumberFmt[k[i]] = table_fmt[k[i]];
var m = t[0].match(tagregex);
if(!m) return;
for(i=0; i < m.length; ++i) {
var y = parsexmltag(m[i]);
switch(strip_ns(y[0])) {
case '': case '': case '': break;
case '0) {
if(j > 0x188) {
for(j = 0x188; j > 0x3c; --j) if(styles.NumberFmt[j] == null) break;
styles.NumberFmt[j] = f;
}
SSF__load(f,j);
}
} break;
case '': break;
default: if(opts.WTF) throw new Error('unrecognized ' + y[0] + ' in numFmts');
}
}
}
function write_numFmts(NF/*:{[n:number|string]:string}*//*::, opts*/) {
var o = [""];
[[5,8],[23,26],[41,44],[/*63*/50,/*66],[164,*/392]].forEach(function(r) {
for(var i = r[0]; i <= r[1]; ++i) if(NF[i] != null) o[o.length] = (writextag('numFmt',null,{numFmtId:i,formatCode:escapexml(NF[i])}));
});
if(o.length === 1) return "";
o[o.length] = ("");
o[0] = writextag('numFmts', null, { count:o.length-2 }).replace("/>", ">");
return o.join("");
}
/* 18.8.10 cellXfs CT_CellXfs */
var cellXF_uint = [ "numFmtId", "fillId", "fontId", "borderId", "xfId" ];
var cellXF_bool = [ "applyAlignment", "applyBorder", "applyFill", "applyFont", "applyNumberFormat", "applyProtection", "pivotButton", "quotePrefix" ];
function parse_cellXfs(t, styles, opts) {
styles.CellXf = [];
var xf;
var pass = false;
(t[0].match(tagregex)||[]).forEach(function(x) {
var y = parsexmltag(x), i = 0;
switch(strip_ns(y[0])) {
case '': case '': case '': break;
/* 18.8.45 xf CT_Xf */
case '': case '':
xf = y;
delete xf[0];
for(i = 0; i < cellXF_uint.length; ++i) if(xf[cellXF_uint[i]])
xf[cellXF_uint[i]] = parseInt(xf[cellXF_uint[i]], 10);
for(i = 0; i < cellXF_bool.length; ++i) if(xf[cellXF_bool[i]])
xf[cellXF_bool[i]] = parsexmlbool(xf[cellXF_bool[i]]);
if(styles.NumberFmt && xf.numFmtId > 0x188) {
for(i = 0x188; i > 0x3c; --i) if(styles.NumberFmt[xf.numFmtId] == styles.NumberFmt[i]) { xf.numFmtId = i; break; }
}
styles.CellXf.push(xf); break;
case '': break;
/* 18.8.1 alignment CT_CellAlignment */
case '': case '':
var alignment = {};
if(y.vertical) alignment.vertical = y.vertical;
if(y.horizontal) alignment.horizontal = y.horizontal;
if(y.textRotation != null) alignment.textRotation = y.textRotation;
if(y.indent) alignment.indent = y.indent;
if(y.wrapText) alignment.wrapText = parsexmlbool(y.wrapText);
xf.alignment = alignment;
break;
case '': break;
/* 18.8.33 protection CT_CellProtection */
case '':
break;
case '': case '': break;
/* note: sometimes mc:AlternateContent appears bare */
case '': pass = true; break;
case '': pass = false; break;
/* 18.2.10 extLst CT_ExtensionList ? */
case '': case '': break;
case '': pass = false; break;
default: if(opts && opts.WTF) {
if(!pass) throw new Error('unrecognized ' + y[0] + ' in cellXfs');
}
}
});
}
function write_cellXfs(cellXfs)/*:string*/ {
var o/*:Array*/ = [];
o[o.length] = (writextag('cellXfs',null));
cellXfs.forEach(function(c) {
o[o.length] = (writextag('xf', null, c));
});
o[o.length] = ("");
if(o.length === 2) return "";
o[0] = writextag('cellXfs',null, {count:o.length-2}).replace("/>",">");
return o.join("");
}
/* 18.8 Styles CT_Stylesheet*/
var parse_sty_xml= /*#__PURE__*/(function make_pstyx() {
var numFmtRegex = /<(?:\w+:)?numFmts([^>]*)>[\S\s]*?<\/(?:\w+:)?numFmts>/;
var cellXfRegex = /<(?:\w+:)?cellXfs([^>]*)>[\S\s]*?<\/(?:\w+:)?cellXfs>/;
var fillsRegex = /<(?:\w+:)?fills([^>]*)>[\S\s]*?<\/(?:\w+:)?fills>/;
var fontsRegex = /<(?:\w+:)?fonts([^>]*)>[\S\s]*?<\/(?:\w+:)?fonts>/;
var bordersRegex = /<(?:\w+:)?borders([^>]*)>[\S\s]*?<\/(?:\w+:)?borders>/;
return function parse_sty_xml(data, themes, opts) {
var styles = {};
if(!data) return styles;
data = str_remove_ng(data, "").replace(//gm,"");
/* 18.8.39 styleSheet CT_Stylesheet */
var t;
/* 18.8.31 numFmts CT_NumFmts ? */
if((t=data.match(numFmtRegex))) parse_numFmts(t, styles, opts);
/* 18.8.23 fonts CT_Fonts ? */
if((t=data.match(fontsRegex))) parse_fonts(t, styles, themes, opts);
/* 18.8.21 fills CT_Fills ? */
if((t=data.match(fillsRegex))) parse_fills(t, styles, themes, opts);
/* 18.8.5 borders CT_Borders ? */
if((t=data.match(bordersRegex))) parse_borders(t, styles, themes, opts);
/* 18.8.9 cellStyleXfs CT_CellStyleXfs ? */
/* 18.8.8 cellStyles CT_CellStyles ? */
/* 18.8.10 cellXfs CT_CellXfs ? */
if((t=data.match(cellXfRegex))) parse_cellXfs(t, styles, opts);
/* 18.8.15 dxfs CT_Dxfs ? */
/* 18.8.42 tableStyles CT_TableStyles ? */
/* 18.8.11 colors CT_Colors ? */
/* 18.2.10 extLst CT_ExtensionList ? */
return styles;
};
})();
function write_sty_xml(wb/*:Workbook*/, opts)/*:string*/ {
var o = [XML_HEADER, writextag('styleSheet', null, {
'xmlns': XMLNS_main[0],
'xmlns:vt': XMLNS.vt
})], w;
if(wb.SSF && (w = write_numFmts(wb.SSF)) != null) o[o.length] = w;
o[o.length] = ('');
o[o.length] = ('');
o[o.length] = ('');
o[o.length] = ('');
if((w = write_cellXfs(opts.cellXfs))) o[o.length] = (w);
o[o.length] = ('');
o[o.length] = ('');
o[o.length] = ('');
if(o.length>2){ o[o.length] = (''); o[1]=o[1].replace("/>",">"); }
return o.join("");
}