コード例 #1
0
ファイル: TableSlideWriter.cs プロジェクト: ayumax/MDToPPTX
        public void AddContent(ShapeTree shapeTree1, uint ObjectID, PPTXTable Content, Dictionary <string, string> HyperLinkIDMap)
        {
            GraphicFrame graphicFrame1 = new GraphicFrame();

            AddTableCommonProperty(graphicFrame1, ObjectID);

            Transform transform1 = SlideWriterHelper.CreateTransform(Content.Transform);

            A.Graphic graphic1 = new A.Graphic();

            A.GraphicData graphicData1 = new A.GraphicData()
            {
                Uri = "http://schemas.openxmlformats.org/drawingml/2006/table"
            };


            A.Table table1 = new A.Table();

            A.TableProperties tableProperties1 = new A.TableProperties()
            {
                FirstRow = true, BandRow = true
            };
            A.TableStyleId tableStyleId1 = new A.TableStyleId();
            tableStyleId1.Text = "{5C22544A-7EE6-4342-B048-85BDC9FD1C3A}";

            tableProperties1.Append(tableStyleId1);
            table1.Append(tableProperties1);

            A.TableGrid tableGrid1 = new A.TableGrid();

            foreach (var tableColumn in Content.Columns)
            {
                tableGrid1.Append(CreateColumn(tableColumn.Width));
            }

            table1.Append(tableGrid1);

            foreach (var _tableRow in Content.Rows)
            {
                table1.Append(CreateRow(Content.Columns, _tableRow, HyperLinkIDMap));
            }


            graphicData1.Append(table1);

            graphic1.Append(graphicData1);

            graphicFrame1.Append(transform1);
            graphicFrame1.Append(graphic1);

            shapeTree1.Append(graphicFrame1);
        }
コード例 #2
0
ファイル: SlideWriter.cs プロジェクト: ayumax/MDToPPTX
        public void InsertNewSlide(PresentationDocument presentationDocument)
        {
            var       presentationPart = presentationDocument.PresentationPart;
            SlidePart slidePart1       = presentationPart.AddNewPart <SlidePart>();

            Slide slide1 = new Slide();

            slide1.AddNamespaceDeclaration("a", "http://schemas.openxmlformats.org/drawingml/2006/main");
            slide1.AddNamespaceDeclaration("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships");
            slide1.AddNamespaceDeclaration("p", "http://schemas.openxmlformats.org/presentationml/2006/main");

            var shapeTree = InitCommonProperty(slide1);

            uint objectID            = 4;
            var  slidePartChildIndex = SlideWriterHelper.CreateHyperLinkMap(SlideContent, slidePart1, HyperLinkIDMap);

            ImageWriter.CreateImageMap(SlideContent, slidePart1, slidePartChildIndex);

            foreach (var bodyContent in SlideContent.TextAreas)
            {
                if (bodyContent.Texts.Count > 0)
                {
                    AddTextBox(shapeTree, objectID++, bodyContent);
                }
            }

            objectID = ImageWriter.AddImageContents(shapeTree, objectID);

            foreach (var tableContent in SlideContent.Tables)
            {
                AddTableContent(shapeTree, objectID++, tableContent);
            }


            slide1.Save(slidePart1);

            // スライドレイアウトの設定
            var slideMaster = presentationPart.SlideMasterParts.First();
            var slideLayout = slideMaster.GetPartById(SlideLayouts.SlideLayouts[SlideContent.SlideLayout].ID);

            slidePart1.AddPart(slideLayout);

            SlideWriterHelper.SetSlideID(presentationPart, slidePart1);

            // Save the modified presentation.
            presentationPart.Presentation.Save();
        }
コード例 #3
0
ファイル: SlideWriter.cs プロジェクト: ayumax/MDToPPTX
        //private void AddContent(ShapeTree shapeTree1, uint ObjectID, PPTXTextArea Content, PlaceholderValues PlaceHolderType, uint PlaceHolderIndex = uint.MaxValue)
        //{
        //    Shape shape1 = new Shape();

        //    NonVisualShapeProperties nonVisualShapeProperties1 = new NonVisualShapeProperties();

        //    NonVisualDrawingProperties nonVisualDrawingProperties2 = new NonVisualDrawingProperties() { Id = ObjectID, Name = $"Content{ObjectID}" };

        //    NonVisualShapeDrawingProperties nonVisualShapeDrawingProperties1 = new NonVisualShapeDrawingProperties() { TextBox = true};
        //    A.ShapeLocks shapeLocks1 = new A.ShapeLocks() { NoGrouping = true };

        //    nonVisualShapeDrawingProperties1.Append(shapeLocks1);

        //    ApplicationNonVisualDrawingProperties applicationNonVisualDrawingProperties2 = new ApplicationNonVisualDrawingProperties();
        //    PlaceholderShape placeholderShape1 = new PlaceholderShape();// { Type = PlaceHolderType };
        //    if (PlaceHolderIndex != uint.MaxValue)
        //    {
        //        placeholderShape1.Index = PlaceHolderIndex;
        //    }

        //    applicationNonVisualDrawingProperties2.Append(placeholderShape1);

        //    nonVisualShapeProperties1.Append(nonVisualDrawingProperties2);
        //    nonVisualShapeProperties1.Append(nonVisualShapeDrawingProperties1);
        //    nonVisualShapeProperties1.Append(applicationNonVisualDrawingProperties2);
        //    ShapeProperties shapeProperties1 = new ShapeProperties();

        //    A.SolidFill solidFill1 = new A.SolidFill();

        //    A.SchemeColor schemeColor1 = new A.SchemeColor() { Val = A.SchemeColorValues.Accent1 };
        //    A.LuminanceModulation luminanceModulation1 = new A.LuminanceModulation() { Val = 20000 };
        //    A.LuminanceOffset luminanceOffset1 = new A.LuminanceOffset() { Val = 80000 };

        //    schemeColor1.Append(luminanceModulation1);
        //    schemeColor1.Append(luminanceOffset1);

        //    solidFill1.Append(schemeColor1);

        //    shapeProperties1.Append(solidFill1);

        //    TextBody textBody1 = new TextBody();
        //    A.BodyProperties bodyProperties1 = new A.BodyProperties();
        //    A.ListStyle listStyle1 = new A.ListStyle();

        //    textBody1.Append(bodyProperties1);
        //    textBody1.Append(listStyle1);

        //    A.Transform2D transform2D25 = SlideWriterHelper.CreateTransform2D(Content.Transform);
        //    if (transform2D25 != null)
        //    {
        //        shapeProperties1.Append(transform2D25);
        //    }

        //    shape1.Append(nonVisualShapeProperties1);
        //    shape1.Append(shapeProperties1);
        //    shape1.Append(textBody1);

        //    foreach (var _textLine in Content.Texts)
        //    {
        //        var paragraph = new A.Paragraph(SlideWriterHelper.CrateParagraphProperties(_textLine));

        //        foreach(var _textRun in _textLine.Texts)
        //        {
        //            paragraph.Append(new A.Run()
        //            {
        //                RunProperties = SlideWriterHelper.CreateRunProperties(_textRun, HyperLinkIDMap),
        //                Text = new A.Text(_textRun.Text)
        //            });
        //        }

        //        shape1.TextBody.Append(paragraph);
        //    }

        //    shapeTree1.Append(shape1);
        //}


        private void AddTextBox(ShapeTree shapeTree1, uint ObjectID, PPTXTextArea Content)
        {
            Shape shape1 = new Shape();

            NonVisualShapeProperties nonVisualShapeProperties1 = new NonVisualShapeProperties();

            NonVisualDrawingProperties nonVisualDrawingProperties2 = new NonVisualDrawingProperties()
            {
                Id = ObjectID, Name = $"Content{ObjectID}"
            };

            A.NonVisualDrawingPropertiesExtensionList nonVisualDrawingPropertiesExtensionList1 = new A.NonVisualDrawingPropertiesExtensionList();

            A.NonVisualDrawingPropertiesExtension nonVisualDrawingPropertiesExtension1 = new A.NonVisualDrawingPropertiesExtension()
            {
                Uri = "{FF2B5EF4-FFF2-40B4-BE49-F238E27FC236}"
            };

            OpenXmlUnknownElement openXmlUnknownElement1 = OpenXmlUnknownElement.CreateOpenXmlUnknownElement("<a16:creationId xmlns:a16=\"http://schemas.microsoft.com/office/drawing/2014/main\" id=\"{5FE2CA47-E73A-450F-9AE0-DF438874E2FB}\" />");

            nonVisualDrawingPropertiesExtension1.Append(openXmlUnknownElement1);

            nonVisualDrawingPropertiesExtensionList1.Append(nonVisualDrawingPropertiesExtension1);

            nonVisualDrawingProperties2.Append(nonVisualDrawingPropertiesExtensionList1);
            NonVisualShapeDrawingProperties nonVisualShapeDrawingProperties1 = new NonVisualShapeDrawingProperties()
            {
                TextBox = true
            };
            ApplicationNonVisualDrawingProperties applicationNonVisualDrawingProperties2 = new ApplicationNonVisualDrawingProperties();

            nonVisualShapeProperties1.Append(nonVisualDrawingProperties2);
            nonVisualShapeProperties1.Append(nonVisualShapeDrawingProperties1);
            nonVisualShapeProperties1.Append(applicationNonVisualDrawingProperties2);

            ShapeProperties shapeProperties1 = new ShapeProperties();


            A.PresetGeometry presetGeometry1 = new A.PresetGeometry()
            {
                Preset = A.ShapeTypeValues.Rectangle
            };
            A.AdjustValueList adjustValueList1 = new A.AdjustValueList();

            presetGeometry1.Append(adjustValueList1);

            TextBody textBody1 = new TextBody();

            A.BodyProperties bodyProperties1 = new A.BodyProperties();
            A.ListStyle      listStyle1      = new A.ListStyle();

            textBody1.Append(bodyProperties1);
            textBody1.Append(listStyle1);

            A.Transform2D transform2D25 = SlideWriterHelper.CreateTransform2D(Content.Transform);
            if (transform2D25 != null)
            {
                shapeProperties1.Append(transform2D25);
            }

            shapeProperties1.Append(presetGeometry1);

            if (Content.BackgroundColor.IsTransparent == false)
            {
                A.SolidFill solidFill1 = new A.SolidFill();
                solidFill1.Append(SlideWriterHelper.CreateRGBColorModeHex(Content.BackgroundColor));
                shapeProperties1.Append(solidFill1);
            }


            shape1.Append(nonVisualShapeProperties1);
            shape1.Append(shapeProperties1);
            shape1.Append(textBody1);

            foreach (var _textLine in Content.Texts)
            {
                var paragraph = new A.Paragraph(SlideWriterHelper.CrateParagraphProperties(_textLine));

                foreach (var _textRun in _textLine.Texts)
                {
                    paragraph.Append(new A.Run()
                    {
                        RunProperties = SlideWriterHelper.CreateRunProperties(_textRun, HyperLinkIDMap),
                        Text          = new A.Text(_textRun.Text)
                    });
                }

                shape1.TextBody.Append(paragraph);
            }

            shapeTree1.Append(shape1);
        }
コード例 #4
0
ファイル: TableSlideWriter.cs プロジェクト: ayumax/MDToPPTX
        private A.TableRow CreateRow(List <PPTXTableColumn> Cols, PPTXTableRow Row, Dictionary <string, string> HyperLinkIDMap)
        {
            A.TableRow tableRow1 = new A.TableRow()
            {
                Height = (Int64)(Row.Height * 100)
            };

            foreach (var Cell in Cols.Select((Col, ColIndex) => new { Col = Col, ColIndex = ColIndex }))
            {
                A.TableCell tableCell1 = new A.TableCell();

                A.TextBody       textBody1       = new A.TextBody();
                A.BodyProperties bodyProperties1 = new A.BodyProperties();
                A.ListStyle      listStyle1      = new A.ListStyle();

                textBody1.Append(bodyProperties1);
                textBody1.Append(listStyle1);

                var _texts = Row.Cells[Cell.ColIndex].Texts.Texts;
                if (_texts.Count == 0)
                {
                    _texts.Add(new PPTXTextRun());
                }

                foreach (var _textLine in _texts)
                {
                    var paragraph = new A.Paragraph();

                    var cellAlign = A.TextAlignmentTypeValues.Center;
                    switch (Cell.Col.Alignment)
                    {
                    case PPTXTableColumnAlign.Left:
                        cellAlign = A.TextAlignmentTypeValues.Left;
                        break;

                    case PPTXTableColumnAlign.Right:
                        cellAlign = A.TextAlignmentTypeValues.Right;
                        break;
                    }

                    paragraph.Append(new A.ParagraphProperties()
                    {
                        Alignment = cellAlign
                    });

                    paragraph.Append(new A.Run()
                    {
                        RunProperties = SlideWriterHelper.CreateRunProperties(_textLine, HyperLinkIDMap),
                        Text          = new A.Text(_textLine.Text)
                    });

                    textBody1.Append(paragraph);
                }

                A.TableCellProperties tableCellProperties1 = new A.TableCellProperties();

                tableCell1.Append(textBody1);
                tableCell1.Append(tableCellProperties1);

                tableRow1.Append(tableCell1);
            }


            A.ExtensionList extensionList4 = new A.ExtensionList();

            tableRow1.Append(extensionList4);

            return(tableRow1);
        }
コード例 #5
0
ファイル: ImageSlideWriter.cs プロジェクト: ayumax/MDToPPTX
        public void AddImageContent(ShapeTree shapeTree1, uint ObjectID, PPTXImage Content)
        {
            Picture picture3 = new Picture();

            NonVisualPictureProperties nonVisualPictureProperties3 = new NonVisualPictureProperties();

            NonVisualDrawingProperties nonVisualDrawingProperties83 = new NonVisualDrawingProperties()
            {
                Id = ObjectID, Name = $"Content{ObjectID}"
            };

            A.NonVisualDrawingPropertiesExtensionList nonVisualDrawingPropertiesExtensionList5 = new A.NonVisualDrawingPropertiesExtensionList();

            nonVisualDrawingProperties83.Append(nonVisualDrawingPropertiesExtensionList5);

            NonVisualPictureDrawingProperties nonVisualPictureDrawingProperties3 = new NonVisualPictureDrawingProperties();

            A.PictureLocks pictureLocks3 = new A.PictureLocks()
            {
                NoChangeAspect = true
            };

            nonVisualPictureDrawingProperties3.Append(pictureLocks3);
            ApplicationNonVisualDrawingProperties applicationNonVisualDrawingProperties83 = new ApplicationNonVisualDrawingProperties();

            nonVisualPictureProperties3.Append(nonVisualDrawingProperties83);
            nonVisualPictureProperties3.Append(nonVisualPictureDrawingProperties3);
            nonVisualPictureProperties3.Append(applicationNonVisualDrawingProperties83);

            BlipFill blipFill3 = new BlipFill();

            A.Blip blip3 = new A.Blip()
            {
                Embed = ImageIDMap[Content.ImageFilePath]
            };

            A.BlipExtensionList blipExtensionList1 = new A.BlipExtensionList();

            blip3.Append(blipExtensionList1);

            A.Stretch       stretch3       = new A.Stretch();
            A.FillRectangle fillRectangle3 = new A.FillRectangle();

            stretch3.Append(fillRectangle3);

            blipFill3.Append(blip3);
            blipFill3.Append(stretch3);

            ShapeProperties shapeProperties70 = new ShapeProperties();


            A.PresetGeometry presetGeometry10 = new A.PresetGeometry()
            {
                Preset = A.ShapeTypeValues.Rectangle
            };
            A.AdjustValueList adjustValueList10 = new A.AdjustValueList();

            presetGeometry10.Append(adjustValueList10);

            A.Transform2D transform2D25 = SlideWriterHelper.CreateTransform2D(Content.Transform);
            if (transform2D25 != null)
            {
                shapeProperties70.Append(transform2D25);
            }

            shapeProperties70.Append(presetGeometry10);

            picture3.Append(nonVisualPictureProperties3);
            picture3.Append(blipFill3);
            picture3.Append(shapeProperties70);

            shapeTree1.Append(picture3);
        }