private IResult SetReflectionEffect(XlsxReflectionShapeEffect reflection) { if (reflection.Show == YesNo.No) { return BooleanResult.SuccessResult; } var root = XmlWriter.GetXmlNode(XmlChartHelper.ChartSpaceRootNode); if (root == null) { return BooleanResult.SuccessResult; } try { var exist = XmlWriter.TryGetElementFrom(root, "c:spPr", out var shapePropertiesNode); shapePropertiesNode.AddEffectContainerNode(reflection, XmlWriter); if (!exist) { root.AppendChild(shapePropertiesNode); } return BooleanResult.SuccessResult; } catch (Exception e) { return BooleanResult.FromException(e); } }
private IResult SetReflectionEffect(XlsxReflectionShapeEffect reflection, string pictureName) { if (reflection.Show == YesNo.No) { return(BooleanResult.SuccessResult); } var pictureNode = XmlWriter.GetXmlNode($"xdr:wsDr/xdr:twoCellAnchor/xdr:pic/xdr:nvPicPr/xdr:cNvPr[@name='{pictureName}']"); var root = pictureNode?.ParentNode?.ParentNode; if (root == null) { return(BooleanResult.SuccessResult); } try { var exist = XmlWriter.TryGetElementFrom(root, "xdr:spPr", out var shapePropertiesNode); shapePropertiesNode.AddEffectContainerNode(reflection, XmlWriter); if (!exist) { root.AppendChild(shapePropertiesNode); } return(BooleanResult.SuccessResult); } catch (Exception e) { return(BooleanResult.FromException(e)); } }
/// <summary> /// Adds an <b>effectLst</b> node (Effect Container) to the node of type <b>spPr</b> (Shape properties) specified. Not supported in <b>EPPlus</b> library. /// </summary> /// <param name="node"><c>spPr</c> node (Shape properties).</param> /// <param name="reflection">Reflection from model.</param> /// <param name="documentHelper">Target xml document helper.</param> /// <remarks> /// For more information please see <a href="http://www.schemacentral.com/sc/ooxml/e-a_effectLst-1.html">http://www.schemacentral.com/sc/ooxml/e-a_effectLst-1.html</a> /// </remarks> /// <exception cref="ArgumentNullException">If <paramref name="node"/> is <b>null</b>.</exception> /// <exception cref="ArgumentNullException">If <paramref name="reflection"/> is <b>null</b>.</exception> public static void AddEffectContainerNode(this XmlNode node, XlsxReflectionShapeEffect reflection, IXmlHelper documentHelper) { SentinelHelper.ArgumentNull(node, nameof(node)); SentinelHelper.ArgumentNull(reflection, nameof(reflection)); var effectContainerNode = documentHelper.CreateOrDefaultAndAppendElementToNode(node, "a", "effectLst");; effectContainerNode.AddReflectionNode(reflection, documentHelper); }
/// <summary> /// Adds a <b>reflection</b> node to the nodes of type <b>effectLst</b> specified. Not supported in <b>EPPlus</b> library. /// </summary> /// <param name="effectLstNode"><b>outerShdw</b> node (glow).</param> /// <param name="reflection">Reflection from model.</param> /// <param name="documentHelper">Target xml document helper.</param> /// <remarks> /// For more information please see <a href="http://officeopenxml.com/drwSp-effects.phpl">http://officeopenxml.com/drwSp-effects.php</a> /// </remarks> private static void AddReflectionNode(this XmlNode effectLstNode, XlsxReflectionShapeEffect reflection, IXmlHelper documentHelper) { var blurRadAttr = documentHelper.CreateAttribute("blurRad"); blurRadAttr.Value = $"{reflection.Blur * OfficeOpenXmlHelper.EMU_PER_POINT}"; var staAttr = documentHelper.CreateAttribute("stA"); staAttr.Value = $"{reflection.Transparency * OfficeOpenXmlHelper.ST_PERCENTAGE}"; var endaAttr = documentHelper.CreateAttribute("endA"); endaAttr.Value = $"{0.3 * OfficeOpenXmlHelper.ST_PERCENTAGE}"; var endPosAttr = documentHelper.CreateAttribute("endPos"); endPosAttr.Value = $"{reflection.Size * OfficeOpenXmlHelper.ST_PERCENTAGE}"; var distAttr = documentHelper.CreateAttribute("dist"); distAttr.Value = $"{reflection.Offset * OfficeOpenXmlHelper.ST_PERCENTAGE}"; var dirAttr = documentHelper.CreateAttribute("dir"); dirAttr.Value = $"{90 * OfficeOpenXmlHelper.ST_POSITIVE_FIXED_ANGLE}"; var syAttr = documentHelper.CreateAttribute("sy"); syAttr.Value = $"{-100 * OfficeOpenXmlHelper.ST_PERCENTAGE}"; var algnAttr = documentHelper.CreateAttribute("algn"); algnAttr.Value = "bl"; var rotWithShapeAttr = documentHelper.CreateAttribute("rotWithShape"); rotWithShapeAttr.Value = "0"; var reflectionNode = documentHelper.CreateOrDefaultAndAppendElementToNode(effectLstNode, "a", "reflection"); reflectionNode.Attributes?.Append(blurRadAttr); reflectionNode.Attributes?.Append(staAttr); reflectionNode.Attributes?.Append(endaAttr); reflectionNode.Attributes?.Append(endPosAttr); if (reflection.Offset != 0.0f) { reflectionNode.Attributes?.Append(distAttr); } reflectionNode.Attributes?.Append(dirAttr); reflectionNode.Attributes?.Append(syAttr); reflectionNode.Attributes?.Append(algnAttr); reflectionNode.Attributes?.Append(rotWithShapeAttr); }