diff --git a/dist/pptxgen.cjs.js b/dist/pptxgen.cjs.js index e48485711..763c99cc2 100644 --- a/dist/pptxgen.cjs.js +++ b/dist/pptxgen.cjs.js @@ -712,7 +712,7 @@ function valToPts(pt) { */ function convertRotationDegrees(d) { d = d || 0; - return (d > 360 ? d - 360 : d) * 60000; + return Math.round((d > 360 ? d - 360 : d) * 60000); } /** * Converts component value to hex value @@ -768,7 +768,7 @@ function createColorElement(colorStr, innerElements) { * { size: 8, color: 'FFFFFF', opacity: 0.75 }; */ function createGlowElement(options, defaults) { - var strXml = '', opts = getMix(defaults, options), size = opts['size'] * ONEPT, color = opts['color'], opacity = opts['opacity'] * 100000; + var strXml = '', opts = getMix(defaults, options), size = Math.round(opts['size'] * ONEPT), color = opts['color'], opacity = Math.round(opts['opacity'] * 100000); strXml += ""; strXml += createColorElement(color, ""); strXml += ""; @@ -797,9 +797,9 @@ function genXmlColorSelection(shapeFill, backColor) { if (shapeFill.color) colorVal = shapeFill.color; if (shapeFill.alpha) - internalElements += ""; // @deprecated v3.3.0 + internalElements += ""; // @deprecated v3.3.0 if (shapeFill.transparency) - internalElements += ""; + internalElements += ""; } switch (fillType) { case 'solid': @@ -1942,7 +1942,7 @@ function slideObjectToXml(slide) { strSlideXml += ' '; strSlideXml += ' '; if (slide._slideNumberProps.fontFace || slide._slideNumberProps.fontSize || slide._slideNumberProps.color) { - strSlideXml += ''; + strSlideXml += ''; if (slide._slideNumberProps.color) strSlideXml += genXmlColorSelection(slide._slideNumberProps.color); if (slide._slideNumberProps.fontFace) @@ -2084,17 +2084,17 @@ function genXmlParagraphProperties(textObj, isDefault) { } } if (textObj.options.lineSpacing) - strXmlLnSpc = ""; + strXmlLnSpc = ""; // OPTION: indent if (textObj.options.indentLevel && !isNaN(Number(textObj.options.indentLevel)) && textObj.options.indentLevel > 0) { paragraphPropXml += " lvl=\"" + textObj.options.indentLevel + "\""; } // OPTION: Paragraph Spacing: Before/After if (textObj.options.paraSpaceBefore && !isNaN(Number(textObj.options.paraSpaceBefore)) && textObj.options.paraSpaceBefore > 0) { - strXmlParaSpc += ""; + strXmlParaSpc += ""; } if (textObj.options.paraSpaceAfter && !isNaN(Number(textObj.options.paraSpaceAfter)) && textObj.options.paraSpaceAfter > 0) { - strXmlParaSpc += ""; + strXmlParaSpc += ""; } // OPTION: bullet // NOTE: OOXML uses the unicode character set for Bullets @@ -2169,13 +2169,13 @@ function genXmlTextRunProperties(opts, isDefault) { var runPropsTag = isDefault ? 'a:defRPr' : 'a:rPr'; // BEGIN runProperties (ex: ``) runProps += '<' + runPropsTag + ' lang="' + (opts.lang ? opts.lang : 'en-US') + '"' + (opts.lang ? ' altLang="en-US"' : ''); - runProps += opts.fontSize ? ' sz="' + Math.round(opts.fontSize) + '00"' : ''; // NOTE: Use round so sizes like '7.5' wont cause corrupt pres. - runProps += opts.bold ? ' b="1"' : ''; - runProps += opts.italic ? ' i="1"' : ''; - runProps += opts.strike ? ' strike="sngStrike"' : ''; - runProps += opts.underline || opts.hyperlink ? ' u="sng"' : ''; + runProps += opts.fontSize ? ' sz="' + Math.round(opts.fontSize * 100) + '"' : ''; // NOTE: Use round so sizes like '7.5' wont cause corrupt pres. + runProps += opts.hasOwnProperty("bold") ? ' b="' + (opts.bold ? 1 : 0) + '"' : ''; + runProps += opts.hasOwnProperty("italic") ? ' i="' + (opts.italic ? 1 : 0) + '"' : ''; + runProps += opts.hasOwnProperty("strike") ? ' strike="' + (opts.strike ? 'sngStrike' : 'noStrike') + '"' : ''; + runProps += opts.hasOwnProperty("underline") || opts.hyperlink ? ' u="' + (opts.underline || opts.hyperlink ? 'sng' : 'none') + '"' : ''; runProps += opts.subscript ? ' baseline="-40000"' : opts.superscript ? ' baseline="30000"' : ''; - runProps += opts.charSpacing ? ' spc="' + opts.charSpacing * 100 + '" kern="0"' : ''; // IMPORTANT: Also disable kerning; otherwise text won't actually expand + runProps += opts.charSpacing ? ' spc="' + Math.round(opts.charSpacing * 100) + '" kern="0"' : ''; // IMPORTANT: Also disable kerning; otherwise text won't actually expand runProps += ' dirty="0">'; // Color / Font / Outline are children of , so add them now before closing the runProperties tag if (opts.color || opts.fontFace || opts.outline) { @@ -2459,7 +2459,7 @@ function genXmlTextBody(slideObj) { Object.entries(opts).forEach(function (_a) { var key = _a[0], val = _a[1]; // NOTE: This loop will pick up unecessary keys (`x`, etc.), but it doesnt hurt anything - if (key !== 'bullet' && !textObj.options[key]) + if (key !== 'bullet' && !textObj.options.hasOwnProperty(key)) textObj.options[key] = val; }); // D: Add formatted textrun @@ -2475,19 +2475,19 @@ function genXmlTextBody(slideObj) { */ if (slideObj._type === SLIDE_OBJECT_TYPES.tablecell && (opts.fontSize || opts.fontFace)) { if (opts.fontFace) { - strSlideXml += "'; + strSlideXml += "'; strSlideXml += ""; strSlideXml += ""; strSlideXml += ""; strSlideXml += ''; } else { - strSlideXml += "'; + strSlideXml += "'; } } else if (reqsClosingFontSize) { // Empty [lineBreak] lines should not contain runProp, however, they need to specify fontSize in `endParaRPr` - strSlideXml += "'; + strSlideXml += "'; } else { strSlideXml += ""; // Added 20180101 to address PPT-2007 issues @@ -4623,7 +4623,7 @@ function makeXmlCharts(rel) { strXml += ' '; strXml += ' '; strXml += ' '; - strXml += " "; + strXml += " "; strXml += ' '; strXml += ' '; strXml += ' '; @@ -4657,7 +4657,7 @@ function makeXmlCharts(rel) { strXml += ' '; strXml += ' '; strXml += ' '; - strXml += rel.opts.legendFontSize ? '' : ''; + strXml += rel.opts.legendFontSize ? '' : ''; if (rel.opts.legendColor) strXml += genXmlColorSelection(rel.opts.legendColor); if (rel.opts.legendFontFace) @@ -4763,7 +4763,7 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, isMultiTypeC strXml += ''; } else if (opts.chartColorsOpacity) { - strXml += '' + createColorElement(seriesColor, '') + ''; + strXml += '' + createColorElement(seriesColor, '') + ''; } else { strXml += '' + createColorElement(seriesColor) + ''; @@ -4801,7 +4801,7 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, isMultiTypeC strXml += ' '; strXml += ' '; strXml += ' '; - strXml += ' '; + strXml += ' '; strXml += ' ' + createColorElement(opts.dataLabelColor || DEF_FONT_COLOR) + ''; strXml += ' '; strXml += ' '; @@ -4934,7 +4934,7 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, isMultiTypeC strXml += ' '; strXml += ' '; strXml += - ' '; + ' '; strXml += ' ' + createColorElement(opts.dataLabelColor || DEF_FONT_COLOR) + ''; strXml += ' '; strXml += ' '; @@ -5008,7 +5008,7 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, isMultiTypeC strXml += ''; } else if (opts.chartColorsOpacity) { - strXml += '' + createColorElement(tmpSerColor, '') + ''; + strXml += '' + createColorElement(tmpSerColor, '') + ''; } else { strXml += '' + createColorElement(tmpSerColor) + ''; @@ -5236,7 +5236,7 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, isMultiTypeC strXml += ' '; strXml += ' '; strXml += ' '; - strXml += ' '; + strXml += ' '; strXml += ' ' + createColorElement(opts.dataLabelColor || DEF_FONT_COLOR) + ''; strXml += ' '; strXml += ' '; @@ -5293,7 +5293,7 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, isMultiTypeC strXml += ''; } else if (opts.chartColorsOpacity) { - strXml += '' + createColorElement(tmpSerColor, '') + ''; + strXml += '' + createColorElement(tmpSerColor, '') + ''; } else { strXml += '' + createColorElement(tmpSerColor) + ''; @@ -5376,7 +5376,7 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, isMultiTypeC strXml += ' '; strXml += ' '; strXml += ' '; - strXml += ' '; + strXml += ' '; strXml += ' ' + createColorElement(opts.dataLabelColor || DEF_FONT_COLOR) + ''; strXml += ' '; strXml += ' '; @@ -5465,7 +5465,7 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, isMultiTypeC strXml += ' '; strXml += ' '; strXml += ' '; - strXml += " "; + strXml += " "; strXml += ' ' + createColorElement(opts.dataLabelColor || DEF_FONT_COLOR) + ''; strXml += " "; strXml += ' '; @@ -5607,7 +5607,7 @@ function makeCatAxis(opts, axisId, valAxisId) { strXml += ' '; strXml += ' '; strXml += ' '; - strXml += ' '; + strXml += ' '; strXml += ' '; strXml += ' '; strXml += ' '; @@ -5710,7 +5710,7 @@ function makeValAxis(opts, valAxisId) { strXml += ' '; strXml += ' '; strXml += ' '; - strXml += ' '; + strXml += ' '; strXml += ' '; strXml += ' '; strXml += ' '; @@ -5775,7 +5775,7 @@ function makeSerAxis(opts, axisId, valAxisId) { strXml += ' '; strXml += ' '; strXml += ' '; - strXml += ' '; + strXml += ' '; strXml += ' '; strXml += ' '; strXml += ' '; @@ -5819,7 +5819,7 @@ function makeSerAxis(opts, axisId, valAxisId) { function genXmlTitle(opts) { var align = opts.titleAlign === 'left' || opts.titleAlign === 'right' ? "" : ""; var rotate = opts.rotate ? "" : ""; // don't specify rotation to get default (ex. vertical for cat axis) - var sizeAttr = opts.fontSize ? 'sz="' + Math.round(opts.fontSize) + '00"' : ''; // only set the font size if specified. Powerpoint will handle the default size + var sizeAttr = opts.fontSize ? 'sz="' + Math.round(opts.fontSize * 100) + '"' : ''; // only set the font size if specified. Powerpoint will handle the default size var layout = opts.titlePos && opts.titlePos.x && opts.titlePos.y ? "" : ""; @@ -5857,7 +5857,7 @@ function createShadowElement(options, defaults) { console.warn("`shadow` options must be an object. Ex: `{shadow: {type:'none'}}`"); return ''; } - var strXml = '', opts = getMix(defaults, options), type = opts['type'] || 'outer', blur = valToPts(opts['blur']), offset = valToPts(opts['offset']), angle = opts['angle'] * 60000, color = opts['color'], opacity = opts['opacity'] * 100000, rotateWithShape = opts['rotateWithShape'] ? 1 : 0; + var strXml = '', opts = getMix(defaults, options), type = opts['type'] || 'outer', blur = valToPts(opts['blur']), offset = valToPts(opts['offset']), angle = Math.round(opts['angle'] * 60000), color = opts['color'], opacity = Math.round(opts['opacity'] * 100000), rotateWithShape = opts['rotateWithShape'] ? 1 : 0; strXml += '';