RELS.THEME = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme"; /* 20.1.6.2 clrScheme CT_ColorScheme */ function parse_clrScheme(t, opts) { themes.themeElements.clrScheme = []; var color = {}; (t[0].match(tagregex)||[]).forEach(function(x) { var y = parsexmltag(x); switch(y[0]) { case '': break; /* 20.1.2.3.32 srgbClr CT_SRgbColor */ case '': case '': /* 20.1.4.1.10 dk2 (Dark 2) */ case '': case '': /* 20.1.4.1.22 lt1 (Light 1) */ case '': case '': /* 20.1.4.1.23 lt2 (Light 2) */ case '': case '': /* 20.1.4.1.1 accent1 (Accent 1) */ case '': case '': /* 20.1.4.1.2 accent2 (Accent 2) */ case '': case '': /* 20.1.4.1.3 accent3 (Accent 3) */ case '': case '': /* 20.1.4.1.4 accent4 (Accent 4) */ case '': case '': /* 20.1.4.1.5 accent5 (Accent 5) */ case '': case '': /* 20.1.4.1.6 accent6 (Accent 6) */ case '': case '': /* 20.1.4.1.19 hlink (Hyperlink) */ case '': case '': /* 20.1.4.1.15 folHlink (Followed Hyperlink) */ case '': case '': if (y[0][1] === '/') { themes.themeElements.clrScheme.push(color); color = {}; } else { color.name = y[0].substring(3, y[0].length - 1); } break; default: if(opts.WTF) throw 'unrecognized ' + y[0] + ' in clrScheme'; } }); } /* 20.1.4.1.18 fontScheme CT_FontScheme */ function parse_fontScheme(t, opts) { } /* 20.1.4.1.15 fmtScheme CT_StyleMatrix */ function parse_fmtScheme(t, opts) { } var clrsregex = /]*)>[^\u2603]*<\/a:clrScheme>/; var fntsregex = /]*)>[^\u2603]*<\/a:fontScheme>/; var fmtsregex = /]*)>[^\u2603]*<\/a:fmtScheme>/; /* 20.1.6.10 themeElements CT_BaseStyles */ function parse_themeElements(data, 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, opts); }); } var themeltregex = /]*)>[^\u2603]*<\/a:themeElements>/; /* 14.2.7 Theme Part */ function parse_theme_xml(data, opts) { /* 20.1.6.9 theme CT_OfficeStyleSheet */ if(!data || data.length === 0) return themes; var t; /* themeElements CT_BaseStyles */ if(!(t=data.match(themeltregex))) throw 'themeElements not found in theme'; parse_themeElements(t[0], opts); return themes; } function write_theme() { 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(""); }