/* 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 '': break; /* 20.1.2.3.33 sysClr CT_SystemColor */ case '': break; /* 20.1.4.1.1 accent1 (Accent 1) */ /* 20.1.4.1.2 accent2 (Accent 2) */ /* 20.1.4.1.3 accent3 (Accent 3) */ /* 20.1.4.1.4 accent4 (Accent 4) */ /* 20.1.4.1.5 accent5 (Accent 5) */ /* 20.1.4.1.6 accent6 (Accent 6) */ /* 20.1.4.1.9 dk1 (Dark 1) */ /* 20.1.4.1.10 dk2 (Dark 2) */ /* 20.1.4.1.15 folHlink (Followed Hyperlink) */ /* 20.1.4.1.19 hlink (Hyperlink) */ /* 20.1.4.1.22 lt1 (Light 1) */ /* 20.1.4.1.23 lt2 (Light 2) */ 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*/) { } /* 20.1.6.10 themeElements CT_BaseStyles */ function parse_themeElements(data, themes, opts) { themes.themeElements = {}; var t; /* clrScheme CT_ColorScheme */ if(!(t=str_match_xml(data, "a:clrScheme"))) throw new Error('clrScheme not found in themeElements'); parse_clrScheme(t, themes, opts); /* fontScheme CT_FontScheme */ if(!(t=str_match_xml(data, "a:fontScheme"))) throw new Error('fontScheme not found in themeElements'); parse_fontScheme(t, themes, opts); /* fmtScheme CT_StyleMatrix */ if(!(t=str_match_xml(data, "a:fmtScheme"))) throw new Error('fmtScheme not found in themeElements'); parse_fmtScheme(t, themes, opts); } /* 14.2.7 Theme Part */ function parse_theme_xml(data/*:string*/, opts) { /* 20.1.6.9 theme CT_OfficeStyleSheet */ if(!data || data.length === 0) data = write_theme(); var t; var themes = {}; /* themeElements CT_BaseStyles */ if(!(t=str_match_xml(data, "a:themeElements"))) 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(""); }