Exemple #1
0
        private IResult SetSoftEdgeEffect(XlsxSoftEdgeShapeEffect softEdge)
        {
            if (softEdge.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(softEdge, XmlWriter);
                if (!exist)
                {
                    root.AppendChild(shapePropertiesNode);
                }

                return BooleanResult.SuccessResult;
            }
            catch (Exception e)
            {
                return BooleanResult.FromException(e);
            }
        }
Exemple #2
0
        private IResult SetSoftEdgeEffect(XlsxSoftEdgeShapeEffect softEdge, string pictureName)
        {
            if (softEdge.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(softEdge, 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="softEdge">Soft edge 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="softEdge"/> is <b>null</b>.</exception>
        public static void AddEffectContainerNode(this XmlNode node, XlsxSoftEdgeShapeEffect softEdge, IXmlHelper documentHelper)
        {
            SentinelHelper.ArgumentNull(node, nameof(node));
            SentinelHelper.ArgumentNull(softEdge, nameof(softEdge));

            var effectContainerNode = documentHelper.CreateOrDefaultAndAppendElementToNode(node, "a", "effectLst");;

            effectContainerNode.AddSoftEdgeNode(softEdge, documentHelper);
        }
        /// <summary>
        /// Adds a <b>softEdge</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="softEdge">Soft edge from model.</param>
        /// <param name="documentHelper">Target xml document helper.</param>
        /// <remarks>
        /// For more information please see <a href="http://officeopenxml.com/drwSp-effects.php">http://officeopenxml.com/drwSp-effects.php</a>
        /// </remarks>
        private static void AddSoftEdgeNode(this XmlNode effectLstNode, XlsxSoftEdgeShapeEffect softEdge, IXmlHelper documentHelper)
        {
            var radAttr = documentHelper.CreateAttribute("rad");

            radAttr.Value = $"{softEdge.Size * OfficeOpenXmlHelper.EMU_PER_POINT}";

            var reflectionNode = documentHelper.CreateOrDefaultAndAppendElementToNode(effectLstNode, "a", "softEdge");

            reflectionNode.Attributes?.Append(radAttr);
        }