public static void GraphicFrameExists(string filePath, string graphicFrameName) { using (PresentationDocument document = PresentationDocument.Open(filePath, false)) { var graphic = document.GetGraphicFrameByName(graphicFrameName); Assert.IsNotNull(graphic); } }
public static void TableExists(string filePath, string graphicFrameName) { using (PresentationDocument document = PresentationDocument.Open(filePath, false)) { var graphic = document.GetGraphicFrameByName(graphicFrameName); var table = graphic.Descendants <Table>().FirstOrDefault(); Assert.IsNotNull(table); } }
private static void ChartExists <T>(string filePath, string graphicFrameName) where T : OpenXmlElement { using (PresentationDocument document = PresentationDocument.Open(filePath, false)) { var shape = document.GetGraphicFrameByName(graphicFrameName); var chartReference = shape.Descendants <DocumentFormat.OpenXml.Drawing.Charts.ChartReference>().FirstOrDefault(); var chartPart = (ChartPart)shape.Ancestors <Slide>().First().SlidePart.GetPartById(chartReference.Id); var chart = chartPart.ChartSpace.Descendants <T>().First(); Assert.IsNotNull(chart); } }
public static void GraphicFrameHasTransform2D(string filePath, string graphicFrameName, Transform2D transform) { using (PresentationDocument document = PresentationDocument.Open(filePath, false)) { var graphic = document.GetGraphicFrameByName(graphicFrameName); var gfTransform = graphic.Transform; Assert.AreEqual(transform.Offset.X, gfTransform.Offset.X); Assert.AreEqual(transform.Offset.Y, gfTransform.Offset.Y); Assert.AreEqual(transform.Extents.Cx, gfTransform.Extents.Cx); Assert.AreEqual(transform.Extents.Cy, gfTransform.Extents.Cy); } }
public static void ContainsCellText(string filePath, string tableGraphicFrameName, string expectedText) { using (PresentationDocument document = PresentationDocument.Open(filePath, false)) { var table = document.GetGraphicFrameByName(tableGraphicFrameName); var text = ""; var runs = table.Descendants <Run>(); if (runs != null && runs.Count() > 0) { foreach (var run in runs) { if (run != null) { text += run.Text.Text; } } } Assert.AreEqual(expectedText, text); } }