2014-05-16 00:33:34 +00:00
|
|
|
|
RELS.THEME = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme";
|
|
|
|
|
|
2014-06-02 05:19:07 +00:00
|
|
|
|
/* 20.1.6.2 clrScheme CT_ColorScheme */
|
2014-05-29 06:18:23 +00:00
|
|
|
|
function parse_clrScheme(t, opts) {
|
|
|
|
|
themes.themeElements.clrScheme = [];
|
|
|
|
|
var color = {};
|
2014-06-29 18:29:45 +00:00
|
|
|
|
t[0].match(tagregex).forEach(function(x) {
|
2014-05-29 06:18:23 +00:00
|
|
|
|
var y = parsexmltag(x);
|
|
|
|
|
switch(y[0]) {
|
2014-05-29 22:30:03 +00:00
|
|
|
|
case '<a:clrScheme': case '</a:clrScheme>': break;
|
2014-05-29 06:18:23 +00:00
|
|
|
|
|
|
|
|
|
/* 20.1.2.3.32 srgbClr CT_SRgbColor */
|
|
|
|
|
case '<a:srgbClr': color.rgb = y.val; break;
|
|
|
|
|
|
|
|
|
|
/* 20.1.2.3.33 sysClr CT_SystemColor */
|
|
|
|
|
case '<a:sysClr': color.rgb = y.lastClr; break;
|
|
|
|
|
|
|
|
|
|
/* 20.1.4.1.9 dk1 (Dark 1) */
|
|
|
|
|
case '<a:dk1>':
|
|
|
|
|
case '</a:dk1>':
|
|
|
|
|
/* 20.1.4.1.10 dk2 (Dark 2) */
|
|
|
|
|
case '<a:dk2>':
|
|
|
|
|
case '</a:dk2>':
|
|
|
|
|
/* 20.1.4.1.22 lt1 (Light 1) */
|
|
|
|
|
case '<a:lt1>':
|
|
|
|
|
case '</a:lt1>':
|
|
|
|
|
/* 20.1.4.1.23 lt2 (Light 2) */
|
|
|
|
|
case '<a:lt2>':
|
|
|
|
|
case '</a:lt2>':
|
|
|
|
|
/* 20.1.4.1.1 accent1 (Accent 1) */
|
|
|
|
|
case '<a:accent1>':
|
|
|
|
|
case '</a:accent1>':
|
|
|
|
|
/* 20.1.4.1.2 accent2 (Accent 2) */
|
|
|
|
|
case '<a:accent2>':
|
|
|
|
|
case '</a:accent2>':
|
|
|
|
|
/* 20.1.4.1.3 accent3 (Accent 3) */
|
|
|
|
|
case '<a:accent3>':
|
|
|
|
|
case '</a:accent3>':
|
|
|
|
|
/* 20.1.4.1.4 accent4 (Accent 4) */
|
|
|
|
|
case '<a:accent4>':
|
|
|
|
|
case '</a:accent4>':
|
|
|
|
|
/* 20.1.4.1.5 accent5 (Accent 5) */
|
|
|
|
|
case '<a:accent5>':
|
|
|
|
|
case '</a:accent5>':
|
|
|
|
|
/* 20.1.4.1.6 accent6 (Accent 6) */
|
|
|
|
|
case '<a:accent6>':
|
|
|
|
|
case '</a:accent6>':
|
|
|
|
|
/* 20.1.4.1.19 hlink (Hyperlink) */
|
|
|
|
|
case '<a:hlink>':
|
|
|
|
|
case '</a:hlink>':
|
|
|
|
|
/* 20.1.4.1.15 folHlink (Followed Hyperlink) */
|
|
|
|
|
case '<a:folHlink>':
|
|
|
|
|
case '</a:folHlink>':
|
|
|
|
|
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';
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-26 05:26:18 +00:00
|
|
|
|
/* 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 = /<a:clrScheme([^>]*)>[^\u2603]*<\/a:clrScheme>/;
|
|
|
|
|
var fntsregex = /<a:fontScheme([^>]*)>[^\u2603]*<\/a:fontScheme>/;
|
|
|
|
|
var fmtsregex = /<a:fmtScheme([^>]*)>[^\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 m[0] + ' not found in themeElements';
|
|
|
|
|
m[2](t, opts);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var themeltregex = /<a:themeElements([^>]*)>[^\u2603]*<\/a:themeElements>/;
|
|
|
|
|
|
2014-05-29 06:18:23 +00:00
|
|
|
|
/* 14.2.7 Theme Part */
|
|
|
|
|
function parse_theme_xml(data, opts) {
|
2014-10-26 05:26:18 +00:00
|
|
|
|
/* 20.1.6.9 theme CT_OfficeStyleSheet */
|
2014-06-05 07:06:20 +00:00
|
|
|
|
if(!data || data.length === 0) return themes;
|
2014-05-29 06:18:23 +00:00
|
|
|
|
|
|
|
|
|
var t;
|
|
|
|
|
|
2014-10-26 05:26:18 +00:00
|
|
|
|
/* themeElements CT_BaseStyles */
|
|
|
|
|
if(!(t=data.match(themeltregex))) throw 'themeElements not found in theme';
|
|
|
|
|
parse_themeElements(t[0], opts);
|
2014-05-29 06:18:23 +00:00
|
|
|
|
|
|
|
|
|
return themes;
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-16 00:33:34 +00:00
|
|
|
|
function write_theme() { return '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n<a:theme xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" name="Office Theme"><a:themeElements><a:clrScheme name="Office"><a:dk1><a:sysClr val="windowText" lastClr="000000"/></a:dk1><a:lt1><a:sysClr val="window" lastClr="FFFFFF"/></a:lt1><a:dk2><a:srgbClr val="1F497D"/></a:dk2><a:lt2><a:srgbClr val="EEECE1"/></a:lt2><a:accent1><a:srgbClr val="4F81BD"/></a:accent1><a:accent2><a:srgbClr val="C0504D"/></a:accent2><a:accent3><a:srgbClr val="9BBB59"/></a:accent3><a:accent4><a:srgbClr val="8064A2"/></a:accent4><a:accent5><a:srgbClr val="4BACC6"/></a:accent5><a:accent6><a:srgbClr val="F79646"/></a:accent6><a:hlink><a:srgbClr val="0000FF"/></a:hlink><a:folHlink><a:srgbClr val="800080"/></a:folHlink></a:clrScheme><a:fontScheme name="Office"><a:majorFont><a:latin typeface="Cambria"/><a:ea typeface=""/><a:cs typeface=""/><a:font script="Jpan" typeface="MS Pゴシック"/><a:font script="Hang" typeface="맑은 고딕"/><a:font script="Hans" typeface="宋体"/><a:font script="Hant" typeface="新細明體"/><a:font script="Arab" typeface="Times New Roman"/><a:font script="Hebr" typeface="Times New Roman"/><a:font script="Thai" typeface="Tahoma"/><a:font script="Ethi" typeface="Nyala"/><a:font script="Beng" typeface="Vrinda"/><a:font script="Gujr" typeface="Shruti"/><a:font script="Khmr" typeface="MoolBoran"/><a:font script="Knda" typeface="Tunga"/><a:font script="Guru" typeface="Raavi"/><a:font script="Cans" typeface="Euphemia"/><a:font script="Cher" typeface="Plantagenet Cherokee"/><a:font script="Yiii" typeface="Microsoft Yi Baiti"/><a:font script="Tibt" typeface="Microsoft Himalaya"/><a:font script="Thaa" typeface="MV Boli"/><a:font script="Deva" typeface="Mangal"/><a:font script="Telu" typeface="Gautami"/><a:font script="Taml" typeface="Latha"/><a:font script="Syrc" typeface="Estrangelo Edessa"/><a:font script="Orya" typeface="Kalinga"/><a:font script="Mlym" typeface="Kartika"/><a:font script="Laoo" typeface="DokChampa"/><a:font script="Sinh" typeface="Iskoola Pota"/><a:font script="Mong" typeface="Mongolian Baiti"/><a:font script="Viet" typeface="Times New Roman"/><a:font script="Uigh" typeface="Microsoft Uighur"/><a:font script="Geor" typeface="Sylfaen"/></a:majorFont><a:minorFont><a:latin typeface="Calibri"/><a:ea typeface=""/><a:cs typeface=""/><a:font script="Jpan" typeface="MS Pゴシック"/><a:font script="Hang" typeface="맑은 고딕"/><a:font script="Hans" typeface="宋体"/><a:font script="Hant" typeface="新細明體"/><a:font script="Arab" typeface="Arial"/><a:font script="Hebr" typeface="Arial"/><a:font script="Thai" typeface="Tahoma"/><a:font script="Ethi" typeface="Nyala"/><a:font script="Beng" typeface="Vrinda"/><a:font script="Gujr" typeface="Shruti"/><a:font script="Khmr" typeface="DaunPenh"/><a:font script="Knda" typeface="Tunga"/><a:font script="Guru" typeface="Raavi"/><a:font script="Cans" typeface="Euphemia"/><a:font script="Cher" typeface="Plantagenet Cherokee"/><a:font script="Yiii" typeface="Microsoft Yi Baiti"/><a:font script="Tibt" typeface="Microsoft Himalaya"/><a:font script="Thaa" typeface="MV Boli"/><a:font script="Deva" typeface="Mangal"/><a:font script="Telu" typeface="Gautami"/><a:font script="Taml" typeface="Latha"/><a:font script="Syrc" typeface="Estrangelo Edessa"/><a:font script="Orya" typeface="Kalinga"/><a:font script="Mlym" typeface="Kartika"/><a:font script="Laoo" typeface="DokChampa"/><a:font script="Sinh" typeface="Iskoola Pota"/><a:font script="Mong" typeface="Mongolian Baiti"/><a:font script="Viet" typeface="Arial"/><a:font script="Uigh" typeface="Microsoft Uighur"/><a:font script="Geor" typeface="Sylfaen"/></a:minorFont></a:fontScheme><a:fmtScheme name="Office"><a:fillStyleLst><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="50000"/><a:satMod val="300000"/></a:schemeClr></a:gs><a:gs pos="35000"><a:schemeClr val="phClr"><a:tint val="37000"/><a:satMod val="300000"/></a:schemeC
|