RELS.THEME = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme"; /* Even though theme layout is dk1 lt1 dk2 lt2, true order is lt1 dk1 lt2 dk2 */ var XLSXThemeClrScheme = [ '', '', '', '', '', '', '', '', '', '', '', '' ]; /* 20.1.6.2 clrScheme CT_ColorScheme */ function parse_clrScheme(t, themes, opts) { themes.themeElements.clrScheme = []; var color = {}; (t[0].match(tagregex)||[]).forEach(function(x) { var y = parsexmltag(x); switch(y[0]) { /* 20.1.6.2 clrScheme (Color Scheme) CT_ColorScheme */ case '': break; /* 20.1.2.3.32 srgbClr CT_SRgbColor */ case '': case '': case '': case '': case '': case '': case '': case '': case '': case '': case '': case '': case '': case '': case '': case '': case '': case '': case '': case '': case '': case '': case '': case '': if (y[0].charAt(1) === '/') { themes.themeElements.clrScheme[XLSXThemeClrScheme.indexOf(y[0])] = color; color = {}; } else { color.name = y[0].slice(3, y[0].length - 1); } break; default: if(opts && opts.WTF) throw new Error('Unrecognized ' + y[0] + ' in clrScheme'); } }); } /* 20.1.4.1.18 fontScheme CT_FontScheme */ function parse_fontScheme(/*::t, themes, opts*/) { } /* 20.1.4.1.15 fmtScheme CT_StyleMatrix */ function parse_fmtScheme(/*::t, themes, opts*/) { } var clrsregex = /]*)>[\s\S]*<\/a:clrScheme>/; var fntsregex = /]*)>[\s\S]*<\/a:fontScheme>/; var fmtsregex = /]*)>[\s\S]*<\/a:fmtScheme>/; /* 20.1.6.10 themeElements CT_BaseStyles */ function parse_themeElements(data, themes, opts) { themes.themeElements = {}; var t; [ /* clrScheme CT_ColorScheme */ ['clrScheme', clrsregex, parse_clrScheme], /* fontScheme CT_FontScheme */ ['fontScheme', fntsregex, parse_fontScheme], /* fmtScheme CT_StyleMatrix */ ['fmtScheme', fmtsregex, parse_fmtScheme] ].forEach(function(m) { if(!(t=data.match(m[1]))) throw new Error(m[0] + ' not found in themeElements'); m[2](t, themes, opts); }); } var themeltregex = /]*)>[\s\S]*<\/a:themeElements>/; /* 14.2.7 Theme Part */ function parse_theme_xml(data/*:string*/, opts) { /* 20.1.6.9 theme CT_OfficeStyleSheet */ if(!data || data.length === 0) return parse_theme_xml(write_theme()); var t; var themes = {}; /* themeElements CT_BaseStyles */ if(!(t=data.match(themeltregex))) throw new Error('themeElements not found in theme'); parse_themeElements(t[0], themes, opts); themes.raw = data; return themes; } function write_theme(Themes, opts)/*:string*/ { if(opts && opts.themeXLSX) return opts.themeXLSX; if(Themes && typeof Themes.raw == "string") return Themes.raw; var o = [XML_HEADER]; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; o[o.length] = ''; return o.join(""); }