Example #1
0
        public TFluent SetFontColor(OpenXmlColor color)
        {
            OpenXmlElement textBody       = this.element.GetOrCreateTextBody();
            BodyProperties bodyProperties = textBody.GetFirstChild <BodyProperties>() ?? textBody.AppendChild(new BodyProperties());

            foreach (Paragraph paragraph in textBody.Elements <Paragraph>())
            {
                ParagraphProperties  paragraphProperties  = paragraph.GetFirstChild <ParagraphProperties>() ?? paragraph.PrependChild(new ParagraphProperties());
                DefaultRunProperties defaultRunProperties = paragraphProperties.GetFirstChild <DefaultRunProperties>() ?? paragraphProperties.AppendChild(new DefaultRunProperties());
                defaultRunProperties.RemoveAllChildren <NoFill>();
                defaultRunProperties.RemoveAllChildren <SolidFill>();
                defaultRunProperties.RemoveAllChildren <GradientFill>();
                defaultRunProperties.RemoveAllChildren <BlipFill>();
                defaultRunProperties.RemoveAllChildren <PatternFill>();
                defaultRunProperties.RemoveAllChildren <GroupFill>();

                defaultRunProperties.AppendChild(new SolidFill().AppendChildFluent(color.CreateColorElement()));

                foreach (Run run in paragraph.Elements <Run>())
                {
                    RunProperties runProperties = run.GetFirstChild <RunProperties>() ?? run.PrependChild(new RunProperties());
                    runProperties.RemoveAllChildren <NoFill>();
                    runProperties.RemoveAllChildren <SolidFill>();
                    runProperties.RemoveAllChildren <GradientFill>();
                    runProperties.RemoveAllChildren <BlipFill>();
                    runProperties.RemoveAllChildren <PatternFill>();
                    runProperties.RemoveAllChildren <GroupFill>();

                    runProperties.AppendChild(new SolidFill().AppendChildFluent(color.CreateColorElement()));
                }
            }

            return(this.result);
        }
Example #2
0
        public static void SetFill(OpenXmlElement shapeProperties, OpenXmlColor color)
        {
            shapeProperties.RemoveAllChildren <NoFill>();
            shapeProperties.RemoveAllChildren <SolidFill>();
            shapeProperties.RemoveAllChildren <GradientFill>();
            shapeProperties.RemoveAllChildren <BlipFill>();
            shapeProperties.RemoveAllChildren <PatternFill>();
            shapeProperties.RemoveAllChildren <GroupFill>();

            shapeProperties.AppendChild(new SolidFill().AppendChildFluent(color.CreateColorElement()));
        }
        public TFluent SetFill(OpenXmlColor color)
        {
            OpenXmlElement shapeProperties = this.element.GetOrCreateShapeProperties();

            shapeProperties.RemoveAllChildren <NoFill>();
            shapeProperties.RemoveAllChildren <SolidFill>();
            shapeProperties.RemoveAllChildren <GradientFill>();
            shapeProperties.RemoveAllChildren <BlipFill>();
            shapeProperties.RemoveAllChildren <PatternFill>();
            shapeProperties.RemoveAllChildren <GroupFill>();

            shapeProperties.AppendChild(new SolidFill().AppendChildFluent(color.CreateColorElement()));

            return(this.result);
        }
Example #4
0
        public ITablePartStyle SetFontColor(OpenXmlColor color)
        {
            TableCellTextStyle tableCellTextStyle = this.tableCellTextStyleGenerator(true);

            tableCellTextStyle.RemoveAllChildren <SchemeColor>();
            tableCellTextStyle.RemoveAllChildren <HslColor>();
            tableCellTextStyle.RemoveAllChildren <RgbColorModelHex>();
            tableCellTextStyle.RemoveAllChildren <RgbColorModelPercentage>();
            tableCellTextStyle.RemoveAllChildren <SystemColor>();
            tableCellTextStyle.RemoveAllChildren <PresetColor>();

            tableCellTextStyle.AppendChild(color.CreateColorElement());

            return(this.result);
        }
Example #5
0
        public TFluent SetFill(OpenXmlColor color)
        {
            OpenXmlElement fill = this.fillGenerator(true);

            fill.RemoveAllChildren <NoFill>();
            fill.RemoveAllChildren <SolidFill>();
            fill.RemoveAllChildren <GradientFill>();
            fill.RemoveAllChildren <BlipFill>();
            fill.RemoveAllChildren <PatternFill>();
            fill.RemoveAllChildren <GroupFill>();

            fill.AppendChild(new SolidFill().AppendChildFluent(color.CreateColorElement()));

            return(this.result);
        }
Example #6
0
        public static void SetStroke(OpenXmlElement shapeProperties, OpenXmlColor color)
        {
            Outline outline = shapeProperties.GetFirstChild <Outline>() ?? shapeProperties.AppendChild(new Outline()
            {
                Width = 12700
            });

            outline.RemoveAllChildren <NoFill>();
            outline.RemoveAllChildren <SolidFill>();
            outline.RemoveAllChildren <GradientFill>();
            outline.RemoveAllChildren <BlipFill>();
            outline.RemoveAllChildren <PatternFill>();
            outline.RemoveAllChildren <GroupFill>();

            outline.AppendChild(new SolidFill().AppendChildFluent(color.CreateColorElement()));
        }
Example #7
0
        public TFluent SetStroke(OpenXmlColor color)
        {
            Outline outline = this.outlineGenerator(true);

            this.InitializeOutline(outline);

            outline.RemoveAllChildren <NoFill>();
            outline.RemoveAllChildren <SolidFill>();
            outline.RemoveAllChildren <GradientFill>();
            outline.RemoveAllChildren <BlipFill>();
            outline.RemoveAllChildren <PatternFill>();
            outline.RemoveAllChildren <GroupFill>();

            outline.AppendChild(new SolidFill().AppendChildFluent(color.CreateColorElement()));

            return(this.result);
        }
        public TFluent SetStroke(OpenXmlColor color)
        {
            OpenXmlElement shapeProperties = this.element.GetOrCreateShapeProperties();
            Outline        outline         = shapeProperties.GetFirstChild <Outline>() ?? shapeProperties.AppendChild(new Outline()
            {
                Width = 12700
            });

            outline.RemoveAllChildren <NoFill>();
            outline.RemoveAllChildren <SolidFill>();
            outline.RemoveAllChildren <GradientFill>();
            outline.RemoveAllChildren <BlipFill>();
            outline.RemoveAllChildren <PatternFill>();
            outline.RemoveAllChildren <GroupFill>();

            outline.AppendChild(new SolidFill().AppendChildFluent(color.CreateColorElement()));

            return(this.result);
        }
        public TFluent SetPatternFill(DocumentFormat.OpenXml.Drawing.PresetPatternValues pattern, OpenXmlColor background, OpenXmlColor foreground)
        {
            OpenXmlElement shapeProperties = this.element.GetOrCreateShapeProperties();

            shapeProperties.RemoveAllChildren <NoFill>();
            shapeProperties.RemoveAllChildren <SolidFill>();
            shapeProperties.RemoveAllChildren <GradientFill>();
            shapeProperties.RemoveAllChildren <BlipFill>();
            shapeProperties.RemoveAllChildren <PatternFill>();
            shapeProperties.RemoveAllChildren <GroupFill>();

            shapeProperties.AppendChild(new PatternFill()
            {
                Preset          = pattern,
                BackgroundColor = new BackgroundColor()
                                  .AppendChildFluent(background.CreateColorElement()),
                ForegroundColor = new ForegroundColor()
                                  .AppendChildFluent(foreground.CreateColorElement()),
            });

            return(this.result);
        }
Example #10
0
        public TFluent SetPatternFill(DocumentFormat.OpenXml.Drawing.PresetPatternValues pattern, OpenXmlColor background, OpenXmlColor foreground)
        {
            OpenXmlElement fill = this.fillGenerator(true);

            fill.RemoveAllChildren <NoFill>();
            fill.RemoveAllChildren <SolidFill>();
            fill.RemoveAllChildren <GradientFill>();
            fill.RemoveAllChildren <BlipFill>();
            fill.RemoveAllChildren <PatternFill>();
            fill.RemoveAllChildren <GroupFill>();

            fill.AppendChild(new PatternFill()
            {
                Preset          = pattern,
                BackgroundColor = new BackgroundColor()
                                  .AppendChildFluent(background.CreateColorElement()),
                ForegroundColor = new ForegroundColor()
                                  .AppendChildFluent(foreground.CreateColorElement()),
            });

            return(this.result);
        }