示例#1
0
        private void AddTableCommonProperty(GraphicFrame graphicFrame1, uint ObjectID)
        {
            NonVisualGraphicFrameProperties nonVisualGraphicFrameProperties1 = new NonVisualGraphicFrameProperties();

            NonVisualDrawingProperties nonVisualDrawingProperties2 = new NonVisualDrawingProperties()
            {
                Id = ObjectID, Name = $"Table{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=\"{7AB8EDC7-F9EF-4752-9A46-413B9437344B}\" />");

            nonVisualDrawingPropertiesExtension1.Append(openXmlUnknownElement1);

            nonVisualDrawingPropertiesExtensionList1.Append(nonVisualDrawingPropertiesExtension1);

            nonVisualDrawingProperties2.Append(nonVisualDrawingPropertiesExtensionList1);

            NonVisualGraphicFrameDrawingProperties nonVisualGraphicFrameDrawingProperties1 = new NonVisualGraphicFrameDrawingProperties();

            A.GraphicFrameLocks graphicFrameLocks1 = new A.GraphicFrameLocks()
            {
                NoGrouping = true
            };

            nonVisualGraphicFrameDrawingProperties1.Append(graphicFrameLocks1);

            ApplicationNonVisualDrawingProperties applicationNonVisualDrawingProperties2 = new ApplicationNonVisualDrawingProperties();

            ApplicationNonVisualDrawingPropertiesExtensionList applicationNonVisualDrawingPropertiesExtensionList1 = new ApplicationNonVisualDrawingPropertiesExtensionList();

            ApplicationNonVisualDrawingPropertiesExtension applicationNonVisualDrawingPropertiesExtension1 = new ApplicationNonVisualDrawingPropertiesExtension()
            {
                Uri = "{D42A27DB-BD31-4B8C-83A1-F6EECF244321}"
            };

            P14.ModificationId modificationId1 = new P14.ModificationId()
            {
                Val = (UInt32Value)833561296U
            };
            modificationId1.AddNamespaceDeclaration("p14", "http://schemas.microsoft.com/office/powerpoint/2010/main");

            applicationNonVisualDrawingPropertiesExtension1.Append(modificationId1);

            applicationNonVisualDrawingPropertiesExtensionList1.Append(applicationNonVisualDrawingPropertiesExtension1);

            applicationNonVisualDrawingProperties2.Append(applicationNonVisualDrawingPropertiesExtensionList1);

            nonVisualGraphicFrameProperties1.Append(nonVisualDrawingProperties2);
            nonVisualGraphicFrameProperties1.Append(nonVisualGraphicFrameDrawingProperties1);
            nonVisualGraphicFrameProperties1.Append(applicationNonVisualDrawingProperties2);

            graphicFrame1.Append(nonVisualGraphicFrameProperties1);
        }
示例#2
0
        public void AddVideo(SlidePart slidepart, string videoFilePath, string videoCoverPath, D.Transform2D transform)
        {
            Slide     slide        = slidepart.Slide;
            ShapeTree shapeTree1   = slidepart.Slide.CommonSlideData.ShapeTree;
            var       ptrlid       = Doc.PresentationPart.GetIdOfPart(slidepart);
            var       picID        = AnalysisHelper.GetMaxId(shapeTree1);
            string    imgEmbedId   = string.Format("imgId{0}{1}{2}", ptrlid, picID, 1);
            string    videoEmbedId = string.Format("vidId{0}{1}{2}", ptrlid, picID, 2);
            string    mediaEmbedId = string.Format("medId{0}{1}{2}", ptrlid, picID, 3);

            Picture picture1 = new Picture();
            NonVisualPictureProperties nonVisualPictureProperties1 = new NonVisualPictureProperties();

            NonVisualDrawingProperties nonVisualDrawingProperties2 =
                new NonVisualDrawingProperties()
            {
                Id = (UInt32Value)3U, Name = videoEmbedId + ""
            };

            D.HyperlinkOnClick hyperlinkOnClick1 = new D.HyperlinkOnClick()
            {
                Id = "", Action = "ppaction://media"
            };
            nonVisualDrawingProperties2.Append(hyperlinkOnClick1);

            NonVisualPictureDrawingProperties nonVisualPictureDrawingProperties1 = new NonVisualPictureDrawingProperties();

            D.PictureLocks pictureLocks1 = new D.PictureLocks()
            {
                NoChangeAspect = true
            };
            nonVisualPictureDrawingProperties1.Append(pictureLocks1);

            ApplicationNonVisualDrawingProperties applicationNonVisualDrawingProperties2 = new ApplicationNonVisualDrawingProperties();

            D.VideoFromFile videoFromFile1 = new D.VideoFromFile()
            {
                Link = videoEmbedId
            };

            ApplicationNonVisualDrawingPropertiesExtensionList applicationNonVisualDrawingPropertiesExtensionList1 =
                new ApplicationNonVisualDrawingPropertiesExtensionList();
            ApplicationNonVisualDrawingPropertiesExtension applicationNonVisualDrawingPropertiesExtension1 =
                new ApplicationNonVisualDrawingPropertiesExtension()
            {
                Uri = "{DAA4B4D4-6D71-4841-9C94-3DE7FCFB9230}"
            };

            P14.Media media1 = new P14.Media()
            {
                Embed = mediaEmbedId
            };
            media1.AddNamespaceDeclaration("p14", "http://schemas.microsoft.com/office/powerpoint/2010/main");
            applicationNonVisualDrawingPropertiesExtension1.Append(media1);
            applicationNonVisualDrawingPropertiesExtensionList1.Append(applicationNonVisualDrawingPropertiesExtension1);

            applicationNonVisualDrawingProperties2.Append(videoFromFile1);
            applicationNonVisualDrawingProperties2.Append(applicationNonVisualDrawingPropertiesExtensionList1);

            nonVisualPictureProperties1.Append(nonVisualDrawingProperties2);
            nonVisualPictureProperties1.Append(nonVisualPictureDrawingProperties1);
            nonVisualPictureProperties1.Append(applicationNonVisualDrawingProperties2);

            BlipFill blipFill1 = new BlipFill();

            D.Blip blip1 = new D.Blip()
            {
                Embed = imgEmbedId
            };

            D.Stretch       stretch1       = new D.Stretch();
            D.FillRectangle fillRectangle1 = new D.FillRectangle();

            stretch1.Append(fillRectangle1);

            blipFill1.Append(blip1);
            blipFill1.Append(stretch1);

            ShapeProperties shapeProperties1 = new ShapeProperties();

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

            presetGeometry1.Append(adjustValueList1);

            shapeProperties1.Append(transform);
            shapeProperties1.Append(presetGeometry1);

            picture1.Append(nonVisualPictureProperties1);
            picture1.Append(blipFill1);
            picture1.Append(shapeProperties1);

            shapeTree1.Append(picture1);

            if (!(slide.Timing?.ChildElements?.Count > 0))
            {
                AnalysisHelper.InitTiming(slide);
            }

            ImagePart imagePart = slidepart.AddImagePart(AnalysisHelper.GetImagePartType(videoCoverPath), imgEmbedId);

            using (var data = File.OpenRead(videoCoverPath))
            {
                imagePart.FeedData(data);
            };

            Doc.PartExtensionProvider.AddPartExtension("video/mp4", ".mp4");
            MediaDataPart mediaDataPart1 = Doc.CreateMediaDataPart("video/mp4", ".mp4");

            using (System.IO.Stream mediaDataPart1Stream = File.OpenRead(videoFilePath))
            {
                mediaDataPart1.FeedData(mediaDataPart1Stream);
            }
            slidepart.AddVideoReferenceRelationship(mediaDataPart1, videoEmbedId);
            slidepart.AddMediaReferenceRelationship(mediaDataPart1, mediaEmbedId);
            slide.Save();
        }