Exemple #1
0
        private string GetSlideTransitionsDuration(SlidePart slidePart)
        {
            string returnDuration = "0";

            try
            {
                Slide slide1 = slidePart.Slide;

                var transitions = slide1.Descendants <Transition>();
                foreach (var transition in transitions)
                {
                    if (transition.Duration != null && transition.Duration.HasValue)
                    {
                        return(transition.Duration);
                    }
                    break;
                }
            }
            catch (Exception ex)
            {
                //Do nothing
            }

            return(returnDuration);
        }
        private void CheckTransitionIssues(Slide slide, String currentSlideRelID, PresentationDocument document)
        {
            var transitionElements = slide.Descendants <Transition>();

            foreach (var transitionElement in transitionElements)
            {
                CheckForAutoTransition(currentSlideRelID, transitionElement);
                CheckForNoMouseClickTransition(currentSlideRelID, transitionElement);
            }
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="slide"></param>
 private void ApplyCorrectionOnSlide(Slide slide)
 {
     foreach (var run in slide.Descendants <OXD.Run>())
     {
         if (string.IsNullOrEmpty(run.Text.Text))
         {
             run.Text.Text = " ";
         }
     }
 }
        public void UpdateSlideAdvanceAfterTime(SlidePart slidePart, double aatMS)
        {
            Slide slide = slidePart.Slide;

            var transitions       = slide.Descendants <Transition>();
            var transitionWithAAT = transitions.FirstOrDefault(t => t.AdvanceAfterTime.HasValue);

            if (transitionWithAAT != null)
            {
                transitionWithAAT.AdvanceAfterTime.Value = aatMS.ToString();
            }
        }
Exemple #5
0
        public virtual void DiscoverShapes()
        {
            var shapes = Slide.Descendants <DocumentFormat.OpenXml.Presentation.Shape>().Where(s => s.ElementName().ToUpper().StartsWith("DATA:"));

            Shapes.AddRange(shapes.Select(s => ShapeElement.Create(s.ElementName().Substring(5).Trim(), s, this)).Where(s => s != null));
            var graphicFrames = Slide.Descendants <DocumentFormat.OpenXml.Presentation.GraphicFrame>().Where(s => s.ElementName().ToUpper().StartsWith("DATA:"));

            foreach (var item in graphicFrames)
            {
                string name = item.ElementName().Substring(5).Trim();
                if (item.Graphic.GraphicData.FirstElement <Table>() != null)
                {
                    TableElement table = TableElement.Create(name, item, this);
                    if (table != null)
                    {
                        Shapes.Add(table);
                    }
                }
                else if (item.Graphic.GraphicData.FirstElement <ChartReference>() != null)
                {
                    ChartElement chart = ChartElement.Create(name, item, this);
                    if (chart != null)
                    {
                        Shapes.Add(chart);
                    }
                }
            }
            var paragraphs = Slide.Descendants <Paragraph>();

            foreach (var item in paragraphs)
            {
                if (!item.Ancestors <Table>().Any())
                {
                    if (textTagRegex.Match(item.InnerText).Success)
                    {
                        foreach (Match match in textTagRegex.Matches(item.InnerText))
                        {
                            McKinsey.PowerPointGenerator.Elements.TextElement text = McKinsey.PowerPointGenerator.Elements.TextElement.Create(match.Groups["tag"].Value, item, this);
                            if (text != null)
                            {
                                Shapes.Add(text);
                            }
                        }
                    }
                }
            }
            foreach (ShapeElementBase item in Shapes)
            {
                item.Slide = this;
            }
        }
        private void CheckForVideo(Slide slide, String currentSlideRelID, SlidePart slidePart, PresentationDocument document)
        {
            var videos = slide.Descendants <VideoFromFile>();

            foreach (VideoFromFile video in videos)
            {
                String  path          = slidePart.GetReferenceRelationship(video.Link).Uri.OriginalString;
                String  fileExtension = System.IO.Path.GetExtension(path);
                String  description   = $"Found video on slide {SlideModel.rIdtoSlideIndex(currentSlideRelID)}, file extension is {fileExtension}";
                Boolean fixable;
                String  filename = System.IO.Path.GetFileName(path);
                if (fileExtension == ".mp4")
                {
                    fixable = false;
                }
                else
                {
                    fixable = true;
                }
                IIssue issue = new VideoIssueItem(filename, video, description, fixable);
                powerpoint.slides[currentSlideRelID].addToIssueList(issue);
            }
        }
Exemple #7
0
        public static string GetSlideTitle(this Slide slide)
        {
            if (slide == null) throw new ArgumentNullException(nameof(slide));

            string paragraphSeparator = null;
            var shapes = slide.Descendants<Shape>().Where(x => ShapeExtensions.IsTitleShape(x));

            var builder = new StringBuilder();
            foreach (var shape in shapes)
            {
                foreach (var paragraph in shape.Descendants<DocumentFormat.OpenXml.Drawing.Paragraph>())
                {
                    builder.Append(paragraphSeparator);
                    foreach (var text in paragraph.Descendants<DocumentFormat.OpenXml.Drawing.Text>())
                    {
                        builder.Append(text.Text);
                    }

                    paragraphSeparator = Environment.NewLine;
                }
            }

            return builder.ToString();
        }