Browse Source

PPT解析功能添加

黄贺彬 5 years ago
parent
commit
f20cb90b11

+ 61 - 0
TEAMModelOS.Test.PPTX/ColorLibrary/ColorHelper.cs

@@ -1,5 +1,6 @@
 using System;
 using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
+using System.Drawing;
 using System.Text;
 using System.Text;
 
 
 namespace TEAMModelOS.Test.PPTX.ColorLibrary
 namespace TEAMModelOS.Test.PPTX.ColorLibrary
@@ -202,5 +203,65 @@ namespace TEAMModelOS.Test.PPTX.ColorLibrary
             B = B * 255;
             B = B * 255;
             return new ColorRGB((int)R, (int)G, (int)B);
             return new ColorRGB((int)R, (int)G, (int)B);
         }
         }
+        private static float HueToRGB(float p, float q, float h)
+        {
+            if (h < 0) h += 1;
+            if (h > 1) h -= 1;
+            if (6 * h < 1)
+            {
+                return p + ((q - p) * 6 * h);
+            }
+            if (2 * h < 1)
+            {
+                return q;
+            }
+            if (3 * h < 2)
+            {
+                return p + ((q - p) * 6 * ((2.0f / 3.0f) - h));
+            }
+            return p;
+        }
+
+        private static Color getColorLumModandOff(Color color, int lumMod=0, int lumOff=0)
+        {
+            float[] rgb = { color.R, color.G, color.B };
+            float r = rgb[0];
+            float g = rgb[1];
+            float b = rgb[2];
+            float min = Math.Min(r, Math.Min(g, b));
+            float max = Math.Max(r, Math.Max(g, b));
+
+            float h = 0;
+            if (max == min) h = 0;
+            else if (max == r) h = ((60 * (g - b) / (max - min)) + 360) % 360;
+            else if (max == g) h = (60 * (b - r) / (max - min)) + 120;
+            else if (max == b) h = (60 * (r - g) / (max - min)) + 240;
+
+            float l = (max + min) / 2;
+            l = l * (float)lumMod / 100000f + (float)lumOff / 100000f;
+
+            float s = 0;
+            if (max == min) s = 0;
+            else if (l <= .5f) s = (max - min) / (max + min);
+            else s = (max - min) / (2 - max - min);
+
+            h = h % 360.0f;
+            h /= 360f;
+
+            float q = 0;
+            if (l < 0.5) q = l * (1 + s);
+            else q = (l + s) - (s * l);
+            float p = 2 * l - q;
+            r = Math.Max(0, HueToRGB(p, q, h + (1.0f / 3.0f)));
+            g = Math.Max(0, HueToRGB(p, q, h));
+            b = Math.Max(0, HueToRGB(p, q, h - (1.0f / 3.0f)));
+
+            //r = Math.Min(r, 1.0f);
+            //g = Math.Min(g, 1.0f);
+            //b = Math.Min(b, 1.0f);
+
+            return Color.FromArgb((int)r, (int)g, (int)b);
+        }
+
     }
     }
 }
 }

+ 300 - 115
TEAMModelOS.Test.PPTX/PresentationConvert.cs

@@ -13,6 +13,7 @@ using System.Xml;
 using System.Xml.Linq;
 using System.Xml.Linq;
 using System.Xml.Xsl;
 using System.Xml.Xsl;
 using TEAMModelOS.SDK.Helper.Common.JsonHelper;
 using TEAMModelOS.SDK.Helper.Common.JsonHelper;
+using TEAMModelOS.Test.PPTX.PresentationElement;
 using ColorMap = DocumentFormat.OpenXml.Presentation.ColorMap;
 using ColorMap = DocumentFormat.OpenXml.Presentation.ColorMap;
 using Theme = DocumentFormat.OpenXml.Drawing.Theme;
 using Theme = DocumentFormat.OpenXml.Drawing.Theme;
 
 
@@ -20,7 +21,8 @@ namespace TEAMModelOS.Test.PPTX
 {
 {
     public class PresentationConvert
     public class PresentationConvert
     {
     {
-        const double inchpixel = 96.0, inchpt = 72.0, pxBase = 914400.0, rotBase = 60000;
+        const int inchpixel = 96, inchpt = 72, pxBase = 914400,  ptBase = 12700;
+        const int rotBase = 60000;
         /// <summary>
         /// <summary>
         /// 处理一页PPT的元素
         /// 处理一页PPT的元素
         /// </summary>
         /// </summary>
@@ -28,52 +30,126 @@ namespace TEAMModelOS.Test.PPTX
         /// <param name="theme"></param>
         /// <param name="theme"></param>
         /// <param name="colorMap"></param>
         /// <param name="colorMap"></param>
         /// <returns></returns>
         /// <returns></returns>
-        public object GetSlideElement(SlidePart slidePart, Theme theme, ColorMap colorMap) {
-            List<PPTElement> elements = new List<PPTElement>();
+        public List<HtexElement> GetSlideElement(SlidePart slidePart, Theme theme, ColorMap colorMap)
+        {
+            List<HtexElement> elements = new List<HtexElement>();
             var shapeTrees = from shap in slidePart.Slide.Descendants<DocumentFormat.OpenXml.Presentation.ShapeTree>() select shap;
             var shapeTrees = from shap in slidePart.Slide.Descendants<DocumentFormat.OpenXml.Presentation.ShapeTree>() select shap;
-            if (shapeTrees.Count() > 0 && shapeTrees.First().ChildElements.Count > 0) {
+            if (shapeTrees.Count() > 0 && shapeTrees.First().ChildElements.Count > 0)
+            {
                 OpenXmlElementList openXmlElements = shapeTrees.First().ChildElements;
                 OpenXmlElementList openXmlElements = shapeTrees.First().ChildElements;
                 int index = 0;
                 int index = 0;
-                foreach (OpenXmlElement element in openXmlElements) {
-                    PPTElement pptElement = null;
-                    if (element is DocumentFormat.OpenXml.Presentation.Shape shape) {
-                        pptElement = ShapeConvert(shape, theme, colorMap);
+                foreach (OpenXmlElement element in openXmlElements)
+                {
+                    HtexElement pptElement = null;
+                    if (element is DocumentFormat.OpenXml.Presentation.Shape shape)
+                    { //p:sp
+                        pptElement = ShapeConvert(shape, theme, colorMap, index);
                     }
                     }
-                    if (element is DocumentFormat.OpenXml.Presentation.Picture picture)
+                    if (element is DocumentFormat.OpenXml.Presentation.Picture picture)//p:pic
                     {
                     {
-                        pptElement = PictureConvert(picture, slidePart);
+                        pptElement = PictureConvert(picture, slidePart, index);
                     }
                     }
-                    if (element is DocumentFormat.OpenXml.AlternateContent content)
+                    if (element is DocumentFormat.OpenXml.AlternateContent content)//mc:alternatecontent 
                     {
                     {
-                        pptElement = AlternateContentConvert(content, theme, colorMap);
+                        pptElement = AlternateContentConvert(content, theme, colorMap, index);
                     }
                     }
-                    if (element is DocumentFormat.OpenXml.Presentation.GraphicFrame graphicFrame)
+                    if (element is DocumentFormat.OpenXml.Presentation.GraphicFrame graphicFrame)//p:graphicFrame
                     {
                     {
-                        pptElement = GraphicFrameConvert(graphicFrame, theme, colorMap);
+                        pptElement = GraphicFrameConvert(graphicFrame, theme, colorMap, index);
+                    }
+                    if (element is DocumentFormat.OpenXml.Presentation.GroupShape groupShape)//p:grpSp
+                    {
+                        pptElement = GroupShapeConvert(groupShape, theme, colorMap, index);
+                    }
+                    if (element is DocumentFormat.OpenXml.Presentation.ConnectionShape connectionShape) // p:cxnSp
+                    {
+                        pptElement = ConnectionShapeConvert(connectionShape, theme, colorMap, index);
+                    }
+                    if (pptElement != null) {
+                        index++;
+                        elements.Add(pptElement);
                     }
                     }
-
-                    index++;
-                    elements.Add(pptElement);
                 }
                 }
             }
             }
             return elements;
             return elements;
         }
         }
-        public PPTElement GraphicFrameConvert(GraphicFrame graphicFrame, Theme theme, ColorMap colorMap) {
 
 
-            DocumentFormat.OpenXml.Drawing.GraphicData graphicData =  graphicFrame.ChildElements.First<DocumentFormat.OpenXml.Drawing.GraphicData>();
-            if (graphicData != null) {
+        public HtexElement GroupShapeConvert(GroupShape groupShape, Theme theme, ColorMap colorMap, int index)
+        {
+            return null;
+        }
+
+        public HtexElement ConnectionShapeConvert(ConnectionShape connectionShape, Theme theme, ColorMap colorMap, int index)
+        {
+            string type = "";
+            string fillColor = "";
+            ShapeProperties properties = connectionShape.ShapeProperties;
+            IEnumerable<DocumentFormat.OpenXml.Drawing.PresetGeometry> presetGeometries = GetPresetGeometry(properties);
+            if (presetGeometries.Count() > 0)
+            {
+                type = presetGeometries.FirstOrDefault().Preset;
+            }
+            HtexConnector element = new HtexConnector() { Type = type };
+            if (properties != null)
+            {
+                if (properties.Transform2D != null)
+                {
+                    element.OffX = properties.Transform2D.Offset.X  * inchpixel/pxBase;
+                    element.OffY = properties.Transform2D.Offset.Y * inchpixel / pxBase;
+                    element.ExtX = properties.Transform2D.Extents.Cx * inchpixel / pxBase;
+                    element.ExtY = properties.Transform2D.Extents.Cy * inchpixel / pxBase;
+                    element.FlipH = properties.Transform2D.HorizontalFlip != null ? BooleanValue.ToBoolean(properties.Transform2D.HorizontalFlip) : false;
+                    element.FlipV = properties.Transform2D.VerticalFlip != null ? BooleanValue.ToBoolean(properties.Transform2D.VerticalFlip) : false;
+                    element.Rot = (properties.Transform2D.Rotation != null ? properties.Transform2D.Rotation.Value : 0)/rotBase;
+
+                }
+                var headEnd = from shap in properties.Descendants<DocumentFormat.OpenXml.Drawing.HeadEnd>() select shap;
+                var tailEnd = from shap in properties.Descendants<DocumentFormat.OpenXml.Drawing.TailEnd>() select shap;
+                if (headEnd != null && headEnd.Count() > 0)
+                {
+                    element.HeadEnd = headEnd.First().Type;
+                }
+                if (tailEnd != null && tailEnd.Count() > 0)
+                {
+                    element.TailEnd = tailEnd.First().Type;
+                }
+                fillColor = GetPropertieFillColor(properties, theme, colorMap);
+            }
+            if (string.IsNullOrEmpty(fillColor))
+            {
+                fillColor = GetShapeStyleColor(connectionShape.ShapeStyle, "Fill", theme);
+            }
+            element.FillColor = fillColor;
+            return element;
+        }
+
+        public HtexElement GraphicFrameConvert(GraphicFrame graphicFrame, Theme theme, ColorMap colorMap, int index)
+        {
+
+            DocumentFormat.OpenXml.Drawing.GraphicData graphicData = graphicFrame.ChildElements.First<DocumentFormat.OpenXml.Drawing.GraphicData>();
+            if (graphicData != null)
+            {
                 OpenXmlElement element = graphicData.ChildElements.First();
                 OpenXmlElement element = graphicData.ChildElements.First();
                 if (element != null)
                 if (element != null)
                 {
                 {
                     if (element is DocumentFormat.OpenXml.Drawing.Table table)
                     if (element is DocumentFormat.OpenXml.Drawing.Table table)
                     {
                     {
-                       return  TableConvert(graphicFrame, theme, colorMap);
+                        return TableConvert(graphicFrame, theme, colorMap);
+                    }
+                    if (element is DocumentFormat.OpenXml.Drawing.Chart chart)
+                    {
+                        //return ChartConvert(graphicFrame, theme, colorMap);
+                    }
+                    if (element is DocumentFormat.OpenXml.Drawing.Diagram diagram)
+                    {
+                        //return DiagramConvert(graphicFrame, theme, colorMap);
                     }
                     }
                 }
                 }
             }
             }
-            return null; 
+            return null;
         }
         }
-        public PPTElement TableConvert(GraphicFrame graphicFrame, Theme theme, ColorMap colorMap) {
+        public HtexElement TableConvert(GraphicFrame graphicFrame, Theme theme, ColorMap colorMap)
+        {
 
 
             return null;
             return null;
         }
         }
@@ -83,91 +159,183 @@ namespace TEAMModelOS.Test.PPTX
         /// </summary>
         /// </summary>
         /// <param name="shape"></param>
         /// <param name="shape"></param>
         /// <returns></returns>
         /// <returns></returns>
-        public PPTElement ShapeConvert(Shape shape ,Theme theme ,ColorMap colorMap) {
-           // shape.base
+        public HtexElement ShapeConvert(Shape shape, Theme theme, ColorMap colorMap, int index)
+        {
+            // shape.base
             //文字颜色
             //文字颜色
             string textColor = "";
             string textColor = "";
             //填充颜色
             //填充颜色
             string fillColor = "";
             string fillColor = "";
             // 形状类型
             // 形状类型
-            string type = "text";
+            string type = "rect";
             //字体大小
             //字体大小
             int fontSize = 1800;
             int fontSize = 1800;
             //是否闭合形状
             //是否闭合形状
             bool complete = false;
             bool complete = false;
             ShapeProperties properties = shape.ShapeProperties;
             ShapeProperties properties = shape.ShapeProperties;
-            IEnumerable<DocumentFormat.OpenXml.Drawing.PresetGeometry> presetGeometries= GetPresetGeometry(properties);
-            if (presetGeometries.Count() > 0) {
+            IEnumerable<DocumentFormat.OpenXml.Drawing.PresetGeometry> presetGeometries = GetPresetGeometry(properties);
+            IEnumerable<DocumentFormat.OpenXml.Drawing.CustomGeometry> customGeometries = GetCustomGeometry(properties);
+            if (presetGeometries.Count() > 0)
+            {
                 type = presetGeometries.FirstOrDefault().Preset;
                 type = presetGeometries.FirstOrDefault().Preset;
             }
             }
-           
-            DocumentFormat.OpenXml.Drawing.Transform2D transform2D=  GetTransform2D(properties);
-            PPTElement element = new PPTElement() { type = type  ,fontSize=fontSize};
-            if (transform2D != null) {
-                element.complete = complete;
-                element.offx = properties.Transform2D.Offset.X;
-                element.offy = properties.Transform2D.Offset.Y;
-                element.extx = properties.Transform2D.Extents.Cx;
-                element.exty = properties.Transform2D.Extents.Cy;
-                element.flipH = properties.Transform2D.HorizontalFlip != null ? BooleanValue.ToBoolean(properties.Transform2D.HorizontalFlip) : false;
-                element.flipV = properties.Transform2D.VerticalFlip != null ? BooleanValue.ToBoolean(properties.Transform2D.VerticalFlip) : false;
-                element.rot = properties.Transform2D.Rotation != null ? properties.Transform2D.Rotation.Value : 0;
+            if (customGeometries.Count() > 0)
+            {
+                type = "custom";
             }
             }
 
 
+            DocumentFormat.OpenXml.Drawing.Transform2D transform2D = GetTransform2D(properties);
+            HtexContainer element = new HtexContainer() { Type = type };
+            if (transform2D != null)
+            {
+                element.Close = complete;
+                element.OffX = transform2D.Offset.X * inchpixel / pxBase;
+                element.OffY = transform2D.Offset.Y * inchpixel / pxBase;
+                element.ExtX = transform2D.Extents.Cx * inchpixel / pxBase;
+                element.ExtY = transform2D.Extents.Cy * inchpixel / pxBase;
+                element.FlipH = transform2D.HorizontalFlip != null ? BooleanValue.ToBoolean(transform2D.HorizontalFlip) : false;
+                element.FlipV = transform2D.VerticalFlip != null ? BooleanValue.ToBoolean(transform2D.VerticalFlip) : false;
+                element.Rot = transform2D.Rotation != null ? transform2D.Rotation.Value : 0;
+
+            }
+            element.Index = index;
             ///获取runs的文本及颜色信息
             ///获取runs的文本及颜色信息
             var runs = from shap in shape.Descendants<DocumentFormat.OpenXml.Drawing.Run>() select shap;
             var runs = from shap in shape.Descendants<DocumentFormat.OpenXml.Drawing.Run>() select shap;
-          
+
             foreach (var run in runs)
             foreach (var run in runs)
             {
             {
+                HtexText text = new HtexText() ;
                 var runprps = from shap in run.Descendants<DocumentFormat.OpenXml.Drawing.RunProperties>() select shap;
                 var runprps = from shap in run.Descendants<DocumentFormat.OpenXml.Drawing.RunProperties>() select shap;
                 DocumentFormat.OpenXml.Drawing.RunProperties runProperties = runprps.FirstOrDefault();
                 DocumentFormat.OpenXml.Drawing.RunProperties runProperties = runprps.FirstOrDefault();
 
 
-                if (runProperties != null  &&  fontSize == 1800) {
-                    fontSize = runProperties.FontSize!=null && runProperties.FontSize>0 ?runProperties.FontSize.Value: fontSize;
-                }    
+                if (runProperties != null)
+                {
+                    if (runProperties.FontSize != null) {
+                        text.FontSize = runProperties.FontSize;
+                    }
+                    if (runProperties.Italic != null)
+                    {
+                        text.FontItalic = runProperties.Italic;
+                    }
+                    if (runProperties.Bold != null)
+                    {
+                        text.FontBold = runProperties.Bold;
+                    }
+                    //if (runProperties.Italic != null)
+                    //{
+                    //    text.FontBold = runProperties.Bold;
+                    //}
+                    if (runProperties.Underline != null )
+                    {
+                        text.FontLine =(int)runProperties.Underline.Value;
+                    }
+                }
                 var schemeColor = from shap in run.Descendants<DocumentFormat.OpenXml.Drawing.SchemeColor>() select shap;
                 var schemeColor = from shap in run.Descendants<DocumentFormat.OpenXml.Drawing.SchemeColor>() select shap;
                 var rgbColors = from shap in run.Descendants<DocumentFormat.OpenXml.Drawing.RgbColorModelHex>() select shap;
                 var rgbColors = from shap in run.Descendants<DocumentFormat.OpenXml.Drawing.RgbColorModelHex>() select shap;
-                textColor =  GetSchemeColor(schemeColor ,theme ,colorMap);
-                if (string.IsNullOrEmpty(textColor)) {
-                    textColor = GetRgbColor(rgbColors);
+                textColor = GetSchemeColor(schemeColor, theme, colorMap);
+                if (string.IsNullOrEmpty(textColor))
+                {
+                    text.TextColor=textColor = GetRgbColor(rgbColors);
                 }
                 }
-                element.text = element.text + run.Text.InnerText;
+                text.Text = run.InnerText;
+                element.Texts.Add(text);
             }
             }
-            if (string.IsNullOrEmpty(textColor)) {
+            if (string.IsNullOrEmpty(textColor))
+            {
                 textColor = GetShapeStyleColor(shape.ShapeStyle, "Font", theme);
                 textColor = GetShapeStyleColor(shape.ShapeStyle, "Font", theme);
             }
             }
-            if (string.IsNullOrEmpty(fillColor)) {
+            if (string.IsNullOrEmpty(fillColor))
+            {
                 fillColor = GetShapeStyleColor(shape.ShapeStyle, "Fill", theme);
                 fillColor = GetShapeStyleColor(shape.ShapeStyle, "Fill", theme);
             }
             }
-            if (string.IsNullOrEmpty(fillColor)) {
+            if (string.IsNullOrEmpty(fillColor))
+            {
                 fillColor = GetPropertieFillColor(properties, theme, colorMap);
                 fillColor = GetPropertieFillColor(properties, theme, colorMap);
             }
             }
-            element.textColor = textColor;
-            element.fillColor = fillColor;
+            element.FillColor = fillColor;
             var custGeometrys = from shap in properties.Descendants<DocumentFormat.OpenXml.Drawing.CustomGeometry>() select shap;
             var custGeometrys = from shap in properties.Descendants<DocumentFormat.OpenXml.Drawing.CustomGeometry>() select shap;
             if (custGeometrys.Count() > 0)
             if (custGeometrys.Count() > 0)
             {
             {
                 var pathLists = from shap in custGeometrys.First().Descendants<DocumentFormat.OpenXml.Drawing.Path>() select shap;
                 var pathLists = from shap in custGeometrys.First().Descendants<DocumentFormat.OpenXml.Drawing.Path>() select shap;
                 if (pathLists.Count() > 0)
                 if (pathLists.Count() > 0)
                 {
                 {
-                    var moveTos = pathLists.First().ChildElements.OfType<DocumentFormat.OpenXml.Drawing.MoveTo>();
-                    var lineTos = pathLists.First().ChildElements.OfType<DocumentFormat.OpenXml.Drawing.LineTo>();
-                    var BezierTos = pathLists.First().ChildElements.OfType<DocumentFormat.OpenXml.Drawing.CubicBezierCurveTo>();
-
+                    element.Close = false;
+                    OpenXmlElementList elements = pathLists.First().ChildElements;
+                    foreach (OpenXmlElement xmlElement in elements)
+                    {
+                        //起点
+                        if (xmlElement is DocumentFormat.OpenXml.Drawing.MoveTo moveTo)
+                        {
+                            DocumentFormat.OpenXml.Drawing.Point point = moveTo.Point;
+                            HtexMoveToPath moveToPath = new HtexMoveToPath { Type = "MoveTo" };
+                            moveToPath.Pts.Add(new Point { X = int.Parse(point.X) * inchpixel / pxBase, Y = int.Parse(point.Y) * inchpixel / pxBase });
+                            element.Paths.Add(moveToPath);
+                        }
+                        //连线
+                        if (xmlElement is DocumentFormat.OpenXml.Drawing.LineTo linTo)
+                        {
+                            DocumentFormat.OpenXml.Drawing.Point point = linTo.Point;
+                            HtexLineToPath lineToPath = new HtexLineToPath { Type = "LineTo"  };
+                            lineToPath.Pts.Add(new Point { X = int.Parse(point.X) * inchpixel / pxBase, Y = int.Parse(point.Y) * inchpixel / pxBase });
+                            element.Paths.Add(lineToPath);
+                        }
+                        //三次贝塞尔曲线
+                        if (xmlElement is DocumentFormat.OpenXml.Drawing.CubicBezierCurveTo cubicBezierCurveTo)
+                        {
+                            OpenXmlElementList list = cubicBezierCurveTo.ChildElements;
+                            HtexCubicBezPath cubicBezPath = new HtexCubicBezPath { Type = "CubicBez" };
+                            foreach (var ls in list)
+                            {
+                                if (ls is DocumentFormat.OpenXml.Drawing.Point point)
+                                {
+                                    cubicBezPath.Pts.Add(new Point { X = int.Parse(point.X) * inchpixel / pxBase, Y = int.Parse(point.Y) * inchpixel / pxBase });
+                                }
+                            }
+                            element.Paths.Add(cubicBezPath);
+                        }
+                        //二次贝塞尔曲线
+                        if (xmlElement is DocumentFormat.OpenXml.Drawing.QuadraticBezierCurveTo quadraticBezierCurveTo)
+                        {
+                            OpenXmlElementList list = quadraticBezierCurveTo.ChildElements;
+                            HtexQuadBezPath quadBezPath = new HtexQuadBezPath { Type = "QuadBez" };
+                            foreach (var ls in list)
+                            {
+                                if (ls is DocumentFormat.OpenXml.Drawing.Point point)
+                                {
+                                    quadBezPath.Pts.Add(new Point { X = int.Parse(point.X) * inchpixel / pxBase, Y =int.Parse(point.Y) * inchpixel / pxBase });
+                                 
+                                }
+                            }
+                            element.Paths.Add(quadBezPath);
+                        }
+                        //处理曲线
+                        if (xmlElement is DocumentFormat.OpenXml.Drawing.ArcTo arcTO)
+                        {
+                            HtexArcToPath arcToPath = new HtexArcToPath() { WidthRadius = arcTO.WidthRadius, HeightRadius = arcTO.HeightRadius, StartAngle = arcTO.StartAngle, SwingAngle = arcTO.SwingAngle };
+                            element.Paths.Add(arcToPath);
+                        }
+                        ///判断路径是否闭合
+                        if (xmlElement is DocumentFormat.OpenXml.Drawing.CloseShapePath close)
+                        {
+                            if (close != null)
+                            {
+                                element.Close = true;
+                            }
+                        }
+                    }
                 }
                 }
             }
             }
-            return element; 
+            return element;
         }
         }
         /// <summary>
         /// <summary>
         /// 处理图片的元素
         /// 处理图片的元素
         /// </summary>
         /// </summary>
         /// <param name="picture"></param>
         /// <param name="picture"></param>
         /// <returns></returns>
         /// <returns></returns>
-        public PPTElement PictureConvert(Picture picture , SlidePart slidePart)
+        public HtexElement PictureConvert(Picture picture, SlidePart slidePart, int index)
         {
         {
             BlipFill blipFill = picture.BlipFill;
             BlipFill blipFill = picture.BlipFill;
             var imageRid = blipFill.Blip.Embed.Value;
             var imageRid = blipFill.Blip.Embed.Value;
-            string type = "picture";
             IdPartPair idParie = slidePart.Parts.Where(x => x.RelationshipId == imageRid).FirstOrDefault();
             IdPartPair idParie = slidePart.Parts.Where(x => x.RelationshipId == imageRid).FirstOrDefault();
             ImagePart imagePart = (ImagePart)idParie.OpenXmlPart;
             ImagePart imagePart = (ImagePart)idParie.OpenXmlPart;
             var contentType = imagePart.ContentType;
             var contentType = imagePart.ContentType;
@@ -181,18 +349,18 @@ namespace TEAMModelOS.Test.PPTX
                 base64 = "data:" + contentType + ";base64," + base64;
                 base64 = "data:" + contentType + ";base64," + base64;
             }
             }
             ShapeProperties properties = picture.ShapeProperties;
             ShapeProperties properties = picture.ShapeProperties;
-            PPTElement element = new PPTElement() { type = type };
+            HtexPicture element = new HtexPicture();
             if (properties != null && properties.Transform2D != null)
             if (properties != null && properties.Transform2D != null)
             {
             {
-                element.offx = properties.Transform2D.Offset.X;
-                element.offy = properties.Transform2D.Offset.Y;
-                element.extx = properties.Transform2D.Extents.Cx;
-                element.exty = properties.Transform2D.Extents.Cy;
-                element.flipH = properties.Transform2D.HorizontalFlip != null ? BooleanValue.ToBoolean(properties.Transform2D.HorizontalFlip) : false;
-                element.flipV = properties.Transform2D.VerticalFlip != null ? BooleanValue.ToBoolean(properties.Transform2D.VerticalFlip) : false;
-                element.rot = properties.Transform2D.Rotation != null ? properties.Transform2D.Rotation.Value : 0;
+                element.OffX = properties.Transform2D.Offset.X * inchpixel / pxBase;
+                element.OffY = properties.Transform2D.Offset.Y * inchpixel / pxBase;
+                element.ExtX = properties.Transform2D.Extents.Cx * inchpixel / pxBase;
+                element.ExtY = properties.Transform2D.Extents.Cy * inchpixel / pxBase;
+                element.FlipH = properties.Transform2D.HorizontalFlip != null ? BooleanValue.ToBoolean(properties.Transform2D.HorizontalFlip) : false;
+                element.FlipV = properties.Transform2D.VerticalFlip != null ? BooleanValue.ToBoolean(properties.Transform2D.VerticalFlip) : false;
+                element.Rot = properties.Transform2D.Rotation != null ? properties.Transform2D.Rotation.Value : 0;
             }
             }
-            element.text = base64;
+            element.Data = base64;
             return element;
             return element;
         }
         }
         /// <summary>
         /// <summary>
@@ -200,16 +368,18 @@ namespace TEAMModelOS.Test.PPTX
         /// </summary>
         /// </summary>
         /// <param name="picture"></param>
         /// <param name="picture"></param>
         /// <returns></returns>
         /// <returns></returns>
-        public PPTElement AlternateContentConvert(AlternateContent content, Theme theme, ColorMap colorMap)
+        public HtexElement AlternateContentConvert(AlternateContent content, Theme theme, ColorMap colorMap, int index)
         {
         {
-            AlternateContentChoice choice= content.ChildElements.First<AlternateContentChoice>();
+            AlternateContentChoice choice = content.ChildElements.First<AlternateContentChoice>();
             OpenXmlElement element = choice.ChildElements.First();
             OpenXmlElement element = choice.ChildElements.First();
-            if (element != null) {
+            if (element != null)
+            {
                 if (element is DocumentFormat.OpenXml.Presentation.Shape shape)
                 if (element is DocumentFormat.OpenXml.Presentation.Shape shape)
                 {
                 {
                     var textMaths = from shap in shape.Descendants<TextMath>() select shap;
                     var textMaths = from shap in shape.Descendants<TextMath>() select shap;
-                    if (textMaths.Count() > 0) {
-                      return  MathConvert(shape ,theme ,colorMap);
+                    if (textMaths.Count() > 0)
+                    {
+                        return MathConvert(shape, theme, colorMap);
                     }
                     }
                 }
                 }
             }
             }
@@ -222,7 +392,8 @@ namespace TEAMModelOS.Test.PPTX
         /// <param name="theme"></param>
         /// <param name="theme"></param>
         /// <param name="colorMap"></param>
         /// <param name="colorMap"></param>
         /// <returns></returns>
         /// <returns></returns>
-        public PPTElement MathConvert(DocumentFormat.OpenXml.Presentation.Shape shape, Theme theme, ColorMap colorMap) {
+        public HtexElement MathConvert(DocumentFormat.OpenXml.Presentation.Shape shape, Theme theme, ColorMap colorMap)
+        {
             //文字颜色
             //文字颜色
             string textColor = "";
             string textColor = "";
             //填充颜色
             //填充颜色
@@ -240,26 +411,27 @@ namespace TEAMModelOS.Test.PPTX
             //    type = presetGeometries.FirstOrDefault().Preset;
             //    type = presetGeometries.FirstOrDefault().Preset;
             //}
             //}
             DocumentFormat.OpenXml.Drawing.Transform2D transform2D = GetTransform2D(properties);
             DocumentFormat.OpenXml.Drawing.Transform2D transform2D = GetTransform2D(properties);
-            PPTElement element = new PPTElement() { type = type, fontSize = fontSize };
+            HtexContainer element = new HtexContainer() { Type = type };
             if (transform2D != null)
             if (transform2D != null)
             {
             {
-                element.complete = complete;
-                element.offx = properties.Transform2D.Offset.X;
-                element.offy = properties.Transform2D.Offset.Y;
-                element.extx = properties.Transform2D.Extents.Cx;
-                element.exty = properties.Transform2D.Extents.Cy;
-                element.flipH = properties.Transform2D.HorizontalFlip != null ? BooleanValue.ToBoolean(properties.Transform2D.HorizontalFlip) : false;
-                element.flipV = properties.Transform2D.VerticalFlip != null ? BooleanValue.ToBoolean(properties.Transform2D.VerticalFlip) : false;
-                element.rot = properties.Transform2D.Rotation != null ? properties.Transform2D.Rotation.Value : 0;
+                element.Close = complete;
+                element.OffX = properties.Transform2D.Offset.X * inchpixel / pxBase;
+                element.OffY = properties.Transform2D.Offset.Y * inchpixel / pxBase;
+                element.ExtX = properties.Transform2D.Extents.Cx * inchpixel / pxBase;
+                element.ExtY = properties.Transform2D.Extents.Cy * inchpixel / pxBase;
+                element.FlipH = properties.Transform2D.HorizontalFlip != null ? BooleanValue.ToBoolean(properties.Transform2D.HorizontalFlip) : false;
+                element.FlipV = properties.Transform2D.VerticalFlip != null ? BooleanValue.ToBoolean(properties.Transform2D.VerticalFlip) : false;
+                element.Rot = properties.Transform2D.Rotation != null ? properties.Transform2D.Rotation.Value : 0;
             }
             }
             //获取行内样式
             //获取行内样式
-            if (string.IsNullOrEmpty(textColor)) {
+            if (string.IsNullOrEmpty(textColor))
+            {
                 var rgbColor = from shap in shape.TextBody.Descendants<DocumentFormat.OpenXml.Drawing.RgbColorModelHex>() select shap;
                 var rgbColor = from shap in shape.TextBody.Descendants<DocumentFormat.OpenXml.Drawing.RgbColorModelHex>() select shap;
-                textColor =GetRgbColor(rgbColor);
+                textColor = GetRgbColor(rgbColor);
                 if (string.IsNullOrEmpty(textColor))
                 if (string.IsNullOrEmpty(textColor))
                 {
                 {
                     var schemes = from shap in shape.TextBody.Descendants<DocumentFormat.OpenXml.Drawing.SchemeColor>() select shap;
                     var schemes = from shap in shape.TextBody.Descendants<DocumentFormat.OpenXml.Drawing.SchemeColor>() select shap;
-                    textColor = GetSchemeColor(schemes ,theme ,colorMap);
+                    textColor = GetSchemeColor(schemes, theme, colorMap);
                 }
                 }
             }
             }
             if (string.IsNullOrEmpty(textColor))
             if (string.IsNullOrEmpty(textColor))
@@ -274,27 +446,28 @@ namespace TEAMModelOS.Test.PPTX
             {
             {
                 fillColor = GetPropertieFillColor(properties, theme, colorMap);
                 fillColor = GetPropertieFillColor(properties, theme, colorMap);
             }
             }
-            element.fillColor = fillColor;
-            element.textColor = textColor;
+            element.FillColor = fillColor;
             var textMaths = from shap in shape.Descendants<TextMath>() select shap;
             var textMaths = from shap in shape.Descendants<TextMath>() select shap;
-            var math= textMaths.First<TextMath>();
+            var math = textMaths.First<TextMath>();
             string elementData = ProcessOMath(math.InnerXml);
             string elementData = ProcessOMath(math.InnerXml);
-            element.text = elementData;
-            return element; 
+            element.Texts.Add(new HtexText { TextColor = textColor, Text = elementData, FontSize = fontSize });
+            return element;
         }
         }
         /// <summary>
         /// <summary>
         /// 处理元素的Transform2D属性
         /// 处理元素的Transform2D属性
         /// </summary>
         /// </summary>
         /// <param name="properties"></param>
         /// <param name="properties"></param>
         /// <returns></returns>
         /// <returns></returns>
-        public DocumentFormat.OpenXml.Drawing.Transform2D GetTransform2D(ShapeProperties properties) {
-            if (properties != null) {
+        public DocumentFormat.OpenXml.Drawing.Transform2D GetTransform2D(ShapeProperties properties)
+        {
+            if (properties != null)
+            {
                 return properties.Transform2D;
                 return properties.Transform2D;
             }
             }
-            return null; 
+            return null;
         }
         }
         /// <summary>
         /// <summary>
-        /// 处理元素的Transform2D属性
+        /// 处理元素的Transform2D 系统默认的元素
         /// </summary>
         /// </summary>
         /// <param name="properties"></param>
         /// <param name="properties"></param>
         /// <returns></returns>
         /// <returns></returns>
@@ -307,6 +480,15 @@ namespace TEAMModelOS.Test.PPTX
             }
             }
             return null;
             return null;
         }
         }
+        public IEnumerable<DocumentFormat.OpenXml.Drawing.CustomGeometry> GetCustomGeometry(ShapeProperties properties)
+        {
+            if (properties != null)
+            {
+                var customGeometrys = from shap in properties.Descendants<DocumentFormat.OpenXml.Drawing.CustomGeometry>() select shap;
+                return customGeometrys;
+            }
+            return null;
+        }
         /// <summary>
         /// <summary>
         /// 处理元素属性的填充色
         /// 处理元素属性的填充色
         /// </summary>
         /// </summary>
@@ -318,14 +500,14 @@ namespace TEAMModelOS.Test.PPTX
             if (properties != null)
             if (properties != null)
             {
             {
                 var solidFills = from shape in properties.Descendants<DocumentFormat.OpenXml.Drawing.SolidFill>() select shape;
                 var solidFills = from shape in properties.Descendants<DocumentFormat.OpenXml.Drawing.SolidFill>() select shape;
-                if ( solidFills.Count() > 0)
+                if (solidFills.Count() > 0)
                 {
                 {
                     var propRgbColor = from shape in solidFills.First().Descendants<DocumentFormat.OpenXml.Drawing.RgbColorModelHex>() select shape;
                     var propRgbColor = from shape in solidFills.First().Descendants<DocumentFormat.OpenXml.Drawing.RgbColorModelHex>() select shape;
                     fillColor = GetRgbColor(propRgbColor);
                     fillColor = GetRgbColor(propRgbColor);
                     if (string.IsNullOrEmpty(fillColor))
                     if (string.IsNullOrEmpty(fillColor))
                     {
                     {
                         var colorScheme = from shape in solidFills.First().Descendants<DocumentFormat.OpenXml.Drawing.SchemeColor>() select shape;
                         var colorScheme = from shape in solidFills.First().Descendants<DocumentFormat.OpenXml.Drawing.SchemeColor>() select shape;
-                        fillColor = GetSchemeColor(colorScheme,  theme, colorMap);
+                        fillColor = GetSchemeColor(colorScheme, theme, colorMap);
                     }
                     }
                 }
                 }
             }
             }
@@ -339,9 +521,10 @@ namespace TEAMModelOS.Test.PPTX
         /// <param name="colorType"></param>
         /// <param name="colorType"></param>
         /// <param name="theme"></param>
         /// <param name="theme"></param>
         /// <returns></returns>
         /// <returns></returns>
-        public string GetShapeStyleColor(DocumentFormat.OpenXml.Presentation.ShapeStyle shapeStyle, string colorType, Theme theme) {
+        public string GetShapeStyleColor(DocumentFormat.OpenXml.Presentation.ShapeStyle shapeStyle, string colorType, Theme theme)
+        {
             if (shapeStyle == null)
             if (shapeStyle == null)
-            { 
+            {
                 return "";
                 return "";
             }
             }
             // 效果颜色
             // 效果颜色
@@ -390,9 +573,10 @@ namespace TEAMModelOS.Test.PPTX
         /// </summary>
         /// </summary>
         /// <param name="rgbColors"></param>
         /// <param name="rgbColors"></param>
         /// <returns></returns>
         /// <returns></returns>
-        public string  GetRgbColor(IEnumerable<DocumentFormat.OpenXml.Drawing.RgbColorModelHex> rgbColors) {
+        public string GetRgbColor(IEnumerable<DocumentFormat.OpenXml.Drawing.RgbColorModelHex> rgbColors)
+        {
             string rgbColor = "";
             string rgbColor = "";
-            if ( rgbColors.Count() > 0)
+            if (rgbColors.Count() > 0)
             {
             {
                 rgbColor = rgbColors.FirstOrDefault().Val;
                 rgbColor = rgbColors.FirstOrDefault().Val;
             }
             }
@@ -403,8 +587,9 @@ namespace TEAMModelOS.Test.PPTX
         /// </summary>
         /// </summary>
         /// <param name="presentationFile"></param>
         /// <param name="presentationFile"></param>
         /// <returns></returns>
         /// <returns></returns>
-        public  object LoadPresentation(string presentationFile) {
-            using (PresentationDocument presentationDocument =PresentationDocument.Open(presentationFile, false))
+        public object LoadPresentation(string presentationFile)
+        {
+            using (PresentationDocument presentationDocument = PresentationDocument.Open(presentationFile, false))
             {
             {
                 if (presentationDocument == null)
                 if (presentationDocument == null)
                 {
                 {
@@ -445,7 +630,7 @@ namespace TEAMModelOS.Test.PPTX
                         }
                         }
                     }
                     }
                 }
                 }
-                return null; 
+                return null;
             }
             }
         }
         }
         /// <summary>
         /// <summary>
@@ -463,7 +648,7 @@ namespace TEAMModelOS.Test.PPTX
                 DocumentFormat.OpenXml.Drawing.SystemColor sysColor = colorScheme.Dark1Color.ChildElements.First<DocumentFormat.OpenXml.Drawing.SystemColor>();
                 DocumentFormat.OpenXml.Drawing.SystemColor sysColor = colorScheme.Dark1Color.ChildElements.First<DocumentFormat.OpenXml.Drawing.SystemColor>();
                 if (sysColor != null)
                 if (sysColor != null)
                 {
                 {
-                    return  sysColor.LastColor;
+                    return sysColor.LastColor;
                 }
                 }
                 DocumentFormat.OpenXml.Drawing.RgbColorModelHex rgbColor = colorScheme.Dark1Color.ChildElements.First<DocumentFormat.OpenXml.Drawing.RgbColorModelHex>();
                 DocumentFormat.OpenXml.Drawing.RgbColorModelHex rgbColor = colorScheme.Dark1Color.ChildElements.First<DocumentFormat.OpenXml.Drawing.RgbColorModelHex>();
                 if (rgbColor != null)
                 if (rgbColor != null)
@@ -496,7 +681,7 @@ namespace TEAMModelOS.Test.PPTX
                 DocumentFormat.OpenXml.Drawing.RgbColorModelHex rgbColor = colorScheme.Accent1Color.ChildElements.First<DocumentFormat.OpenXml.Drawing.RgbColorModelHex>();
                 DocumentFormat.OpenXml.Drawing.RgbColorModelHex rgbColor = colorScheme.Accent1Color.ChildElements.First<DocumentFormat.OpenXml.Drawing.RgbColorModelHex>();
                 if (rgbColor != null)
                 if (rgbColor != null)
                 {
                 {
-                    return  rgbColor.Val;
+                    return rgbColor.Val;
                 }
                 }
                 return colorStr;
                 return colorStr;
             }
             }
@@ -505,12 +690,12 @@ namespace TEAMModelOS.Test.PPTX
                 DocumentFormat.OpenXml.Drawing.SystemColor sysColor = colorScheme.Accent2Color.ChildElements.First<DocumentFormat.OpenXml.Drawing.SystemColor>();
                 DocumentFormat.OpenXml.Drawing.SystemColor sysColor = colorScheme.Accent2Color.ChildElements.First<DocumentFormat.OpenXml.Drawing.SystemColor>();
                 if (sysColor != null)
                 if (sysColor != null)
                 {
                 {
-                    return  sysColor.LastColor;
+                    return sysColor.LastColor;
                 }
                 }
                 DocumentFormat.OpenXml.Drawing.RgbColorModelHex rgbColor = colorScheme.Accent2Color.ChildElements.First<DocumentFormat.OpenXml.Drawing.RgbColorModelHex>();
                 DocumentFormat.OpenXml.Drawing.RgbColorModelHex rgbColor = colorScheme.Accent2Color.ChildElements.First<DocumentFormat.OpenXml.Drawing.RgbColorModelHex>();
                 if (rgbColor != null)
                 if (rgbColor != null)
                 {
                 {
-                    return  rgbColor.Val;
+                    return rgbColor.Val;
                 }
                 }
                 return colorStr;
                 return colorStr;
             }
             }
@@ -524,7 +709,7 @@ namespace TEAMModelOS.Test.PPTX
                 DocumentFormat.OpenXml.Drawing.RgbColorModelHex rgbColor = colorScheme.Accent3Color.ChildElements.First<DocumentFormat.OpenXml.Drawing.RgbColorModelHex>();
                 DocumentFormat.OpenXml.Drawing.RgbColorModelHex rgbColor = colorScheme.Accent3Color.ChildElements.First<DocumentFormat.OpenXml.Drawing.RgbColorModelHex>();
                 if (rgbColor != null)
                 if (rgbColor != null)
                 {
                 {
-                    return  rgbColor.Val;
+                    return rgbColor.Val;
                 }
                 }
                 return colorStr;
                 return colorStr;
             }
             }
@@ -580,7 +765,7 @@ namespace TEAMModelOS.Test.PPTX
                 DocumentFormat.OpenXml.Drawing.RgbColorModelHex rgbColor = colorScheme.Light1Color.ChildElements.First<DocumentFormat.OpenXml.Drawing.RgbColorModelHex>();
                 DocumentFormat.OpenXml.Drawing.RgbColorModelHex rgbColor = colorScheme.Light1Color.ChildElements.First<DocumentFormat.OpenXml.Drawing.RgbColorModelHex>();
                 if (rgbColor != null)
                 if (rgbColor != null)
                 {
                 {
-                    return   rgbColor.Val;
+                    return rgbColor.Val;
                 }
                 }
                 return colorStr;
                 return colorStr;
             }
             }
@@ -594,7 +779,7 @@ namespace TEAMModelOS.Test.PPTX
                 DocumentFormat.OpenXml.Drawing.RgbColorModelHex rgbColor = colorScheme.Light2Color.ChildElements.First<DocumentFormat.OpenXml.Drawing.RgbColorModelHex>();
                 DocumentFormat.OpenXml.Drawing.RgbColorModelHex rgbColor = colorScheme.Light2Color.ChildElements.First<DocumentFormat.OpenXml.Drawing.RgbColorModelHex>();
                 if (rgbColor != null)
                 if (rgbColor != null)
                 {
                 {
-                    return  rgbColor.Val;
+                    return rgbColor.Val;
                 }
                 }
                 return colorStr;
                 return colorStr;
             }
             }
@@ -603,7 +788,7 @@ namespace TEAMModelOS.Test.PPTX
                 DocumentFormat.OpenXml.Drawing.SystemColor sysColor = colorScheme.Hyperlink.ChildElements.First<DocumentFormat.OpenXml.Drawing.SystemColor>();
                 DocumentFormat.OpenXml.Drawing.SystemColor sysColor = colorScheme.Hyperlink.ChildElements.First<DocumentFormat.OpenXml.Drawing.SystemColor>();
                 if (sysColor != null)
                 if (sysColor != null)
                 {
                 {
-                    return  sysColor.LastColor;
+                    return sysColor.LastColor;
                 }
                 }
                 DocumentFormat.OpenXml.Drawing.RgbColorModelHex rgbColor = colorScheme.Hyperlink.ChildElements.First<DocumentFormat.OpenXml.Drawing.RgbColorModelHex>();
                 DocumentFormat.OpenXml.Drawing.RgbColorModelHex rgbColor = colorScheme.Hyperlink.ChildElements.First<DocumentFormat.OpenXml.Drawing.RgbColorModelHex>();
                 if (rgbColor != null)
                 if (rgbColor != null)
@@ -617,12 +802,12 @@ namespace TEAMModelOS.Test.PPTX
                 DocumentFormat.OpenXml.Drawing.SystemColor sysColor = colorScheme.FollowedHyperlinkColor.ChildElements.First<DocumentFormat.OpenXml.Drawing.SystemColor>();
                 DocumentFormat.OpenXml.Drawing.SystemColor sysColor = colorScheme.FollowedHyperlinkColor.ChildElements.First<DocumentFormat.OpenXml.Drawing.SystemColor>();
                 if (sysColor != null)
                 if (sysColor != null)
                 {
                 {
-                    return  sysColor.LastColor;
+                    return sysColor.LastColor;
                 }
                 }
                 DocumentFormat.OpenXml.Drawing.RgbColorModelHex rgbColor = colorScheme.FollowedHyperlinkColor.ChildElements.First<DocumentFormat.OpenXml.Drawing.RgbColorModelHex>();
                 DocumentFormat.OpenXml.Drawing.RgbColorModelHex rgbColor = colorScheme.FollowedHyperlinkColor.ChildElements.First<DocumentFormat.OpenXml.Drawing.RgbColorModelHex>();
                 if (rgbColor != null)
                 if (rgbColor != null)
                 {
                 {
-                    return   rgbColor.Val;
+                    return rgbColor.Val;
                 }
                 }
                 return colorStr;
                 return colorStr;
             }
             }

+ 0 - 21
TEAMModelOS.Test.PPTX/PresentationElement/Content.cs

@@ -1,21 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace TEAMModelOS.Test.PPTX.PresentationElement
-{
-    public class Content
-    {
-        public string type { get; set; }
-        //文本 /或图片base64
-        public string text { get; set; }
-        //文本颜色
-        public string textColor { get; set; }
-        //填充颜色
-        public string fillColor { get; set; }
-        //图形是否闭合
-        public bool complete { get; set; }
-        //字体大小
-        public int fontSize { get; set; }
-    }
-}

+ 0 - 14
TEAMModelOS.Test.PPTX/PresentationElement/Element.cs

@@ -1,14 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace TEAMModelOS.Test.PPTX.PresentationElement
-{
-    public class Element
-    {
-        public Position  position{get;set;}
-        public List<Content> contents { get; set; }
-
-        public List<>
-    }
-}

+ 19 - 0
TEAMModelOS.Test.PPTX/PresentationElement/HtexChart.cs

@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TEAMModelOS.Test.PPTX.PresentationElement
+{
+    public class HtexChart : HtexPosition 
+    {
+        public string Type { get; set; }
+        public string ChartId { get; set; }
+        public ChartData ChartData { get; set; }
+    }
+
+    public class ChartData{
+        public string ColName { get; set; }
+        public string[] DataRow { get; set; }
+        public string[] RowNames { get; set; }
+    }
+}

+ 18 - 0
TEAMModelOS.Test.PPTX/PresentationElement/HtexConnector.cs

@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TEAMModelOS.Test.PPTX.PresentationElement
+{
+    public class HtexConnector : HtexPosition
+    {
+
+        /// <summary>
+        ///连接线 p:cxnSp
+        /// </summary>
+        public string Type { get; set; }
+        public string HeadEnd{ get; set; }
+        public string TailEnd { get; set; }
+        public string FillColor { get; set; }
+    }
+}

+ 102 - 0
TEAMModelOS.Test.PPTX/PresentationElement/HtexContainer.cs

@@ -0,0 +1,102 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TEAMModelOS.Test.PPTX.PresentationElement
+{
+    public class HtexContainer : HtexPosition
+    {
+
+        public HtexContainer() {
+            Texts = new List<HtexText>();
+            Paths = new List<HtexPath>();
+        }
+        /// <summary>
+        /// p:sp
+        /// </summary>
+        public string Type { get; set; }
+
+        //文字排版 横版  竖版
+        public string TextLayout { get; set; }
+        //文字位置
+        public string TextAlign { get; set; } = "left";
+
+        //容器填充颜色
+        public string FillColor { get; set; }
+        //图形是否闭合
+        public bool Close { get; set; } = false;
+        public List<HtexText> Texts { get; set; }
+        public List<HtexPath> Paths { get; set; }
+
+    }
+
+    public abstract class HtexPath
+    {
+        public string Type { get; set; }
+
+    }
+    //public abstract class HtexClosePath :HtexPath
+    //{
+    //    public bool Close { get; set; } = false;
+    //}
+
+    /// <summary>
+    /// 起点 <a:moveTo>
+    /// </summary>
+    public class HtexMoveToPath : HtexPath
+    {
+        public HtexMoveToPath()
+        {
+            Pts = new List<Point> { };
+        }
+        public List<Point> Pts { get; set; }
+    }
+    /// <summary>
+    /// 弧形 <a:arcTo>
+    /// </summary>
+    public class HtexArcToPath : HtexPath
+    {
+        public string WidthRadius { get; set; }
+        public string HeightRadius { get; set; }
+        public string StartAngle { get; set; }
+        public string SwingAngle { get; set; }
+    }
+
+
+    /// <summary>
+    /// 画线 <a:lnTo>
+    /// </summary>
+    public class HtexLineToPath : HtexPath
+    {
+        public HtexLineToPath()
+        {
+            Pts = new List<Point> { };
+        }
+        public List<Point> Pts { get; set; }
+    }
+    /// <summary>
+    /// 三次贝塞尔曲线<a:cubicBezTo>
+    /// </summary>
+    public class HtexCubicBezPath : HtexPath
+    {
+        public HtexCubicBezPath()
+        {
+            Pts = new List<Point> { };
+        }
+        public List<Point> Pts { get; set; }
+    }/// <summary>
+     /// 二次贝塞尔曲线  <a:quadBezTo>
+     /// </summary>
+    public class HtexQuadBezPath : HtexPath
+    {
+        public HtexQuadBezPath()
+        {
+            Pts = new List<Point> { };
+        }
+        public List<Point> Pts { get; set; }
+    }
+    public class Point{
+        public int X { get; set; }
+        public int  Y { get; set; }
+    }
+}

+ 10 - 0
TEAMModelOS.Test.PPTX/PresentationElement/HtexElement.cs

@@ -0,0 +1,10 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TEAMModelOS.Test.PPTX.PresentationElement
+{
+    public interface HtexElement
+    {
+    }
+}

+ 14 - 0
TEAMModelOS.Test.PPTX/PresentationElement/HtexInfo.cs

@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TEAMModelOS.Test.PPTX.PresentationElement
+{
+    public  class HtexInfo
+    {
+        public List<HtexSlide> Slides { get; set; }
+        public int Pages { get; set; }
+        public int Width { get; set; }
+        public int Height { get; set; }
+    }
+}

+ 12 - 0
TEAMModelOS.Test.PPTX/PresentationElement/HtexPicture.cs

@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TEAMModelOS.Test.PPTX.PresentationElement
+{
+    public class HtexPicture : HtexPosition
+    {
+        public string Type { get; set; } = "Picture";
+        public string Data { get; set; }
+    }
+}

+ 26 - 0
TEAMModelOS.Test.PPTX/PresentationElement/HtexPosition.cs

@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TEAMModelOS.Test.PPTX.PresentationElement
+{
+    public abstract class HtexPosition : HtexElement
+    {
+        //旋转角度
+        public int Rot { get; set; }
+        //水平翻转
+        public bool FlipH { get; set; }
+        //垂直翻转
+        public bool FlipV { get; set; }
+        //x轴
+        public long OffX { get; set; }
+        //y轴
+        public long OffY { get; set; }
+        //宽度
+        public long ExtX { get; set; }
+        //高度
+        public long ExtY { get; set; }
+        //层级
+        public int Index { get; set;  }
+    }
+}

+ 16 - 0
TEAMModelOS.Test.PPTX/PresentationElement/HtexSlide.cs

@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TEAMModelOS.Test.PPTX.PresentationElement
+{
+    public  class HtexSlide
+    {
+
+        public int Width { get; set; }
+        public int Height { get; set; }
+        public List<HtexElement> Contents { get; set; }
+
+
+    }
+}

+ 13 - 0
TEAMModelOS.Test.PPTX/PresentationElement/HtexTable.cs

@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TEAMModelOS.Test.PPTX.PresentationElement
+{
+     public class HtexTable : HtexPosition
+    {
+        public string Type { get; set; }
+        public int Row { get; }
+        public int Cell { get; }
+    }
+}

+ 64 - 0
TEAMModelOS.Test.PPTX/PresentationElement/HtexText.cs

@@ -0,0 +1,64 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TEAMModelOS.Test.PPTX.PresentationElement
+{
+    public class HtexText
+    { 
+        //文本
+        public string Text { get; set; }
+        //文本颜色
+        public string TextColor { get; set; } = "000000";//黑色
+        //字体大小
+        public int FontSize { get; set; } = 1800;
+        //字体
+        public string Font { get; set; } = "default";
+        //字体加粗
+        public bool FontBold { get; set; } = false;
+        //字体斜体
+        public bool FontItalic { get; set; } = false;
+        //0 没有线 1 下划线 2 删除线 3上划线
+        public int FontLine { get; set; } = 0;
+
+        /*
+         *  Dash	7	
+            文本下划线枚举 (虚线)。 当项目作为 xml 序列出时,其值为"虚线"。
+            DashHeavy	8	
+            文本下划线枚举 (粗虚线)。 当项目作为 xml 序列出时,其值为"dashHeavy"。
+            DashLong	9	
+            文本下划线枚举 (长虚)。 当项目作为 xml 序列出时,其值为"dashLong"。
+            DashLongHeavy	10	
+            文本下划线枚举 (粗 Long 虚线)。 当项目作为 xml 序列出时,其值为"dashLongHeavy"。
+            DotDash	11	
+            文本下划线枚举 (划线)。 当项目作为 xml 序列出时,其值为"dotDash"。
+            DotDashHeavy	12	
+            文本下划线枚举 (粗点划线)。 当项目作为 xml 序列出时,其值为"dotDashHeavy"。
+            DotDotDash	13	
+            文本下划线枚举 (点点划线)。 当项目作为 xml 序列出时,其值为"dotDotDash"。
+            DotDotDashHeavy	14	
+            文本下划线枚举 (粗点划线)。 当项目作为 xml 序列出时,其值为"dotDotDashHeavy"。
+            Dotted	5	
+            文本下划线枚举 (虚线)。 当项目作为 xml 序列出时,其值为"虚线"。
+            Double	3	
+            文本下划线枚举 (Double)。 当项目作为 xml 序列出时,其值为"双击"。
+            Heavy	4	
+            文本下划线枚举 (大量)。 当项目出序列化为 xml 时,其值为"高"。
+            HeavyDotted	6	
+            文本下划线枚举 (粗虚线)。 当项目作为 xml 序列出时,其值为"dottedHeavy"。
+            None	0	
+            文本下划线枚举 (无)。 项目为 xml 序列化出时, 其值为"none"。
+            Single	2	
+            文本下划线枚举 (单个)。 当项目作为 xml 序列出时,其值为"sng"。
+            Wavy	15	
+            文本下划线枚举 (波浪)。 当项目作为 xml 序列出时,其值为"波浪形"。
+            WavyDouble	17	
+            文本下划线枚举 (双波浪)。 当项目作为 xml 序列出时,其值为"wavyDbl"。
+            WavyHeavy	16	
+            文本下划线枚举 (粗波浪)。 当项目作为 xml 序列出时,其值为"wavyHeavy"。
+            Words	1	
+            文本下划线枚举 (字)。 当项目作为 xml 序列出时,其值为"单词"。
+         */
+
+    }
+}

+ 10 - 0
TEAMModelOS.Test.PPTX/PresentationElement/HtexTheme.cs

@@ -0,0 +1,10 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TEAMModelOS.Test.PPTX.PresentationElement
+{
+    public class HtexTheme
+    {
+    }
+}

+ 0 - 22
TEAMModelOS.Test.PPTX/PresentationElement/Position.cs

@@ -1,22 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace TEAMModelOS.Test.PPTX.PresentationElement
-{
-    public class Position
-    {
-        //旋转角度
-        public int rot { get; set; }
-        //水平翻转
-        public bool flipH { get; set; }
-        //垂直翻转
-        public bool flipV { get; set; }
-        //x轴
-        public long offx { get; set; }
-        //y轴
-        public long offy { get; set; }
-        //宽度
-        public long extx { get; set; }
-    }
-}

+ 7 - 1
TEAMModelOS.Test.PPTX/Program.cs

@@ -15,6 +15,8 @@ namespace TEAMModelOS.Test.PPTX
     {
     {
         static void Main(string[] args)
         static void Main(string[] args)
         {
         {
+            PresentationConvert presentation = new PresentationConvert();
+            presentation.LoadPresentation("E:\\document\\123.pptx");
             ///白色灰度值计算
             ///白色灰度值计算
             double rw = 255, gw = 255, bw = 255;
             double rw = 255, gw = 255, bw = 255;
             ///ED7D31的RGB
             ///ED7D31的RGB
@@ -44,6 +46,10 @@ namespace TEAMModelOS.Test.PPTX
             ColorRGB  color=ColorHelper.HslToRgb(colorHSL);
             ColorRGB  color=ColorHelper.HslToRgb(colorHSL);
             System.Drawing.Color s = ColorTranslator.FromHtml("#ED7D31");
             System.Drawing.Color s = ColorTranslator.FromHtml("#ED7D31");
             PPTXConvertNew.GetSlideTitles("E:\\document\\123.pptx");
             PPTXConvertNew.GetSlideTitles("E:\\document\\123.pptx");
+
+           // Color ss =  getColorLumModandOff(ColorTranslator.FromHtml("#4472C4"), 75000, 0);
+           //string sn= ColorTranslator.ToHtml(ss);
         }
         }
-    }  
+
+    }
 }
 }