|
@@ -251,5 +251,122 @@ namespace HTEXLib.Builders
|
|
|
}
|
|
|
return pptContainerShape;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ public PPTContainerShape GetPPTContainerShape(SlideMasterPart slidePart, PPTSlide slide)
|
|
|
+ {
|
|
|
+ var pptContainerShape = new PPTContainerShape();
|
|
|
+ pptContainerShape.Elements = new List<PPTShapeBase>();
|
|
|
+ var ShapeTree = slidePart.SlideMaster.Descendants<DocumentFormat.OpenXml.Presentation.ShapeTree>().FirstOrDefault();
|
|
|
+ if (ShapeTree == null)
|
|
|
+ {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ var objs = ShapeTree.ChildElements;
|
|
|
+ foreach (object obj in objs)
|
|
|
+ {
|
|
|
+ PPTShapeBase shape = null;
|
|
|
+ if (typeof(DocumentFormat.OpenXml.Presentation.Shape).Equals(obj.GetType()))
|
|
|
+ {
|
|
|
+ DocumentFormat.OpenXml.Presentation.Shape pshape = (DocumentFormat.OpenXml.Presentation.Shape)obj;
|
|
|
+ if (pshape.Parent.LocalName == "Choice" || pshape.Parent.LocalName == "Fallback")
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //p:sp
|
|
|
+ PPTShape shapeppt = new PPTShape(slidePart, pshape, slide);
|
|
|
+ if (shapeppt.IsText)
|
|
|
+ {
|
|
|
+ shape = shapeppt;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ else if (typeof(Picture).Equals(obj.GetType()))
|
|
|
+ {
|
|
|
+ //p:pic
|
|
|
+ shape = new PPTImage(slidePart, (Picture)obj, slide);
|
|
|
+ }
|
|
|
+ else if (typeof(GraphicFrame).Equals(obj.GetType()))
|
|
|
+ {
|
|
|
+ //p:graphicFrame Chart, Diagram, Table
|
|
|
+ var graphicFrame = new PPTGraphicFrame(slidePart, (GraphicFrame)obj, slide);
|
|
|
+ var GraphicDataChildren = graphicFrame.element.Graphic.GraphicData.ChildElements;
|
|
|
+
|
|
|
+ foreach (var clild in GraphicDataChildren)
|
|
|
+ {
|
|
|
+ if (clild is DocumentFormat.OpenXml.Drawing.Table Table)
|
|
|
+ {
|
|
|
+ shape = new PPTTable(slidePart, graphicFrame, Table, slide);
|
|
|
+ }
|
|
|
+ if (clild is DocumentFormat.OpenXml.Drawing.Charts.ChartReference Chart)
|
|
|
+ {
|
|
|
+ shape = new PPTChart(slidePart, graphicFrame, Chart, slide);
|
|
|
+ }
|
|
|
+ if (clild is DocumentFormat.OpenXml.Drawing.Diagrams.RelationshipIds Diagram)
|
|
|
+ {
|
|
|
+ shape = new PPTDiagram(slidePart, graphicFrame, Diagram, slide);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (typeof(GroupShape).Equals(obj.GetType()))
|
|
|
+ {
|
|
|
+ //p:grpSp
|
|
|
+ shape = new PPTGroupShape(slidePart, (GroupShape)obj, slide);
|
|
|
+ }
|
|
|
+ else if (typeof(ConnectionShape).Equals(obj.GetType()))
|
|
|
+ {
|
|
|
+ //p:cxnSp
|
|
|
+ shape = new PPTConnectionShape(slidePart, (ConnectionShape)obj, slide);
|
|
|
+ }
|
|
|
+ else if (typeof(AlternateContent).Equals(obj.GetType()))
|
|
|
+ {
|
|
|
+ ///Equations and formulas as Image 处理公式 方程等
|
|
|
+ AlternateContent alternateContent = (AlternateContent)obj;
|
|
|
+ // shape= new PPTAlternateContent(slidePart, (DocumentFormat.OpenXml.AlternateContent)obj, slide);
|
|
|
+ var AlternateContentChoice = alternateContent.GetFirstChild<AlternateContentChoice>();
|
|
|
+ var shp = AlternateContentChoice.GetFirstChild<DocumentFormat.OpenXml.Presentation.Shape>();
|
|
|
+ if (shp != null)
|
|
|
+ {
|
|
|
+ var Paragraphs = shp.TextBody.Elements<DocumentFormat.OpenXml.Drawing.Paragraph>();
|
|
|
+ foreach (var pa in Paragraphs)
|
|
|
+ {
|
|
|
+ // var a = pa.GetFirstChild<DocumentFormat.OpenXml.Office2010.Drawing.TextMath>();
|
|
|
+ // OfficeMath
|
|
|
+ ///公式插入 线性 专用,普通文本区别
|
|
|
+ var oMath = shp.GetPPTXNodeByPath("//p:txBody/a:p/a14:m/m:oMathPara/m:oMath");
|
|
|
+ if (oMath != null)
|
|
|
+ {
|
|
|
+ var element = alternateContent.ChildElements.Where(x => typeof(AlternateContentFallback).Equals(x.GetType())).FirstOrDefault();
|
|
|
+ AlternateContentFallback alternateContentFallback = null;
|
|
|
+ if (element != null)
|
|
|
+ {
|
|
|
+ alternateContentFallback = (AlternateContentFallback)element;
|
|
|
+ }
|
|
|
+ shape = new PPTMath(slidePart, AlternateContentChoice, alternateContentFallback, slide);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ if (shape != null)
|
|
|
+ {
|
|
|
+ bool exist = false;
|
|
|
+ foreach (var elm in pptContainerShape.Elements)
|
|
|
+ {
|
|
|
+ if (elm.suid == shape.suid)
|
|
|
+ {
|
|
|
+ exist = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!exist)
|
|
|
+ {
|
|
|
+ pptContainerShape.Elements.Add(shape);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return pptContainerShape;
|
|
|
+ }
|
|
|
}
|
|
|
}
|