Ejemplo n.º 1
0
 public Shape AddText(SlidePart sldpart, string text, PPTTextStyle textStyle, D.Transform2D transform)
 {
     return(AddText(sldpart.Slide.CommonSlideData.ShapeTree, text, textStyle, transform));
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 添加文本
        /// </summary>
        private Shape AddText(ShapeTree tree, string text, PPTTextStyle textStyle, D.Transform2D transform)
        {
            //Picture
            Shape textShape = tree.AppendChild(new Shape());
            uint  maxid     = AnalysisHelper.GetMaxId(tree);

            textShape.NonVisualShapeProperties = new P.NonVisualShapeProperties
                                                 (
                new P.NonVisualDrawingProperties()
            {
                Id   = maxid + 1,
                Name = $"TEXT{maxid + 1}"
            },
                new P.NonVisualShapeDrawingProperties
                (
                    new D.ShapeLocks()
            {
                NoGrouping = true
            }
                ),
                new ApplicationNonVisualDrawingProperties
                (
                    new PlaceholderShape()
            {
                Type = PlaceholderValues.Body
            }
                )
                                                 );
            //位置
            textShape.ShapeProperties = new ShapeProperties()
            {
                Transform2D = transform
            };

            textShape.TextBody = new TextBody(
                new D.BodyProperties(),
                new D.ListStyle(),
                new D.Paragraph(new D.Run()
            {
                Text = new D.Text()
                {
                    Text = text
                },
                RunProperties = new D.RunProperties
                                (
                    new D.SolidFill()
                {
                    RgbColorModelHex = new D.RgbColorModelHex()
                    {
                        Val = HexBinaryValue.FromString(textStyle.Color.Replace("#", ""))
                    }
                }
                                )
                {
                    FontSize            = (int)(textStyle.FontSize * 100), //20*100 字号20
                    Underline           = textStyle.IsUnderline ? D.TextUnderlineValues.Single : D.TextUnderlineValues.None,
                    Italic              = textStyle.IsItalic,
                    Bold                = textStyle.IsBold,
                    AlternativeLanguage = "zh-CN",
                    Language            = "en-US",
                    Kumimoji            = true,
                    Dirty               = false,
                    SpellingError       = false
                },
            },
                                new D.EndParagraphRunProperties(
                                    new D.SolidFill()
            {
                RgbColorModelHex = new D.RgbColorModelHex()
                {
                    Val = HexBinaryValue.FromString(textStyle.Color.Replace("#", ""))
                }
            }
                                    )
            {
                FontSize            = (int)(textStyle.FontSize * 100), //20*100 字号20
                Underline           = textStyle.IsUnderline ? D.TextUnderlineValues.Single : D.TextUnderlineValues.None,
                Italic              = textStyle.IsItalic,
                Bold                = textStyle.IsBold,
                AlternativeLanguage = "zh-CN",
                Language            = "en-US",
                Kumimoji            = true,
                Dirty               = false,
                SpellingError       = false
            }
                                ));

            return(textShape);
        }
Ejemplo n.º 3
0
        public Shape AddText(int sldIdx, string text, PPTTextStyle textStyle, D.Transform2D transform)
        {
            var tree = Doc.GetShapeTree(sldIdx);

            return(AddText(tree, text, textStyle, transform));
        }