Ver código fonte

表格解析,图表,图示,颜色

CrazyIter 4 anos atrás
pai
commit
68db93992b

+ 11 - 10
HTEXLib/Builders/PPTContainerShapeBuilder.cs

@@ -38,7 +38,7 @@ namespace HTEXLib.Builders
                 else if (typeof(GroupShape).Equals(obj.GetType()))
                 {
                     //p:grpSp
-                    pptContainerShape.Elements.Add(new PPTGroupShape(slidePart, (GroupShape)obj));
+                    pptContainerShape.Elements.Add(new PPTGroupShape(slidePart, (GroupShape)obj,slide));
                 }
                 else if (typeof(ConnectionShape).Equals(obj.GetType()))
                 {
@@ -53,13 +53,13 @@ namespace HTEXLib.Builders
                     if (element != null)
                     {
                         AlternateContentFallback alternateContentFallback = (AlternateContentFallback)element;
-                        if (typeof(DocumentFormat.OpenXml.Presentation.Shape).Equals(alternateContentFallback.ChildElements.First().GetType()))
+                        if (alternateContentFallback.ChildElements.First() is DocumentFormat.OpenXml.Presentation.Shape shapea)
                         {
-                            pptContainerShape.Elements.Add(new PPTShape(slidePart, (DocumentFormat.OpenXml.Presentation.Shape)alternateContentFallback.First(), slide));
+                            pptContainerShape.Elements.Add(new PPTShape(slidePart, shapea, slide));
                         }
-                        else if (typeof(Picture).Equals(alternateContentFallback.ChildElements.First().GetType()))
+                        else if (alternateContentFallback.ChildElements.First() is DocumentFormat.OpenXml.Presentation.Picture Picturea)
                         {
-                            pptContainerShape.Elements.Add(new PPTImage(slidePart, (Picture)obj));
+                            pptContainerShape.Elements.Add(new PPTImage(slidePart, Picturea));
                         }
                     }
                     //MathML
@@ -96,7 +96,7 @@ namespace HTEXLib.Builders
                 else if (typeof(GroupShape).Equals(obj.GetType()))
                 {
                     //p:grpSp
-                    pptContainerShape.Elements.Add(new PPTGroupShape(slidePart, (GroupShape)obj));
+                    pptContainerShape.Elements.Add(new PPTGroupShape(slidePart, (GroupShape)obj,slide));
                 }
                 else if (typeof(ConnectionShape).Equals(obj.GetType()))
                 {
@@ -109,12 +109,13 @@ namespace HTEXLib.Builders
                     var  element = alternateContent.ChildElements.Where(x =>typeof(AlternateContentFallback).Equals(x.GetType())).FirstOrDefault();
                     if (element != null) {
                         AlternateContentFallback alternateContentFallback = (AlternateContentFallback)element;
-                        if (typeof(DocumentFormat.OpenXml.Presentation.Shape) .Equals(alternateContentFallback.ChildElements.First().GetType()))
+                        if (alternateContentFallback.ChildElements.First() is DocumentFormat.OpenXml.Presentation.Shape shapea)
                         {
-                            pptContainerShape.Elements.Add(new PPTShape(slidePart, (DocumentFormat.OpenXml.Presentation.Shape)alternateContentFallback.First(), slide));
+                            pptContainerShape.Elements.Add(new PPTShape(slidePart, shapea, slide));
                         }
-                        else if(typeof(Picture).Equals(alternateContentFallback.ChildElements.First().GetType()) ) {
-                            pptContainerShape.Elements.Add(new PPTImage(slidePart, (Picture)obj));
+                        else if (alternateContentFallback.ChildElements.First() is DocumentFormat.OpenXml.Presentation.Picture Picturea)
+                        {
+                            pptContainerShape.Elements.Add(new PPTImage(slidePart, Picturea));
                         }
                     }
                     //MathML

+ 1 - 1
HTEXLib/Controller/HtexController.cs

@@ -144,7 +144,7 @@ namespace HTEXLib.Controller
                 ////foreach (PPTSlide pptSlide in _mSlides)
                 ////{
                 ///string dirpath = Path.Combine(_filePath, _fileName);
-                HtexSlide htexSlide = new HtexSlide(_mSlide, "SC", _mSlide.slideIndex)
+                HtexSlide htexSlide = new HtexSlide(_mSlide,  _mSlide.slideIndex)
                 {
                     ContainerShape = _mSlide.ContainerShape,
                    

+ 10 - 0
HTEXLib/Helpers/ColorHelpers/ColorConverter.cs

@@ -294,6 +294,16 @@ namespace HTEXLib
 
             return outColor.R.ToString("X2") + outColor.G.ToString("X2") + outColor.B.ToString("X2");
         }
+
+        internal string SetComp(string colorHex)
+        {
+            Color c = ColorTranslator.FromHtml("#" + colorHex);
+            var rn = 255 - c.R;
+            var gn = 255 - c.G;
+            var bn = 255 - c.B;
+            return rn.ToString("X2") + gn.ToString("X2") +bn.ToString("X2");
+        }
+
         public string SetHueMod(Color c, double hue)
         {
 

+ 490 - 18
HTEXLib/Helpers/ShapeHelpers/PPTXHelper.cs

@@ -58,12 +58,482 @@ namespace HTEXLib.Helpers.ShapeHelpers
             if (shapeStyle == null) {
                 return null;
             }
-            string LineColor = StyleMatrixReferenceColors(shapeStyle.LineReference, slide);
-            string FillColor = StyleMatrixReferenceColors(shapeStyle.FillReference, slide);
-            string EffectColor = StyleMatrixReferenceColors(shapeStyle.EffectReference, slide);
+            string LineColor = DoMatrixReferenceColors(shapeStyle.LineReference, slide);
+            string FillColor = DoMatrixReferenceColors(shapeStyle.FillReference, slide);
+            string EffectColor = DoMatrixReferenceColors(shapeStyle.EffectReference, slide);
             string FontColor = FontReferenceColors(shapeStyle.FontReference, slide);
             return new SlideColor { LineColor = LineColor, FillColor = FillColor, EffectColor = EffectColor, FontColor = FontColor };
         }
+        public static HTEXLib.Models.HTEX.ShapeStyle DoShapeProperties(GroupShapeProperties shapeProperties, PPTSlide slide, string type, string partForm)
+        {
+            //Outline
+            var lnNode = shapeProperties.GetFirstChild<Outline>();
+            Border border = null;
+            if (lnNode != null)
+            {
+                border = DoOutline(lnNode, slide, type);
+            }
+            Fill fill = new Fill() { type = -1 };
+            var gradFill = shapeProperties.GetFirstChild<GradientFill>();
+            if (gradFill != null)
+            {
+                fill.type = 2;
+                fill.gradientFill = DoGradientFill(gradFill, slide);
+            }
+            var noFill = shapeProperties.GetFirstChild<NoFill>();
+            if (noFill != null)
+            {
+                fill.type = 0;
+            }
+            var pattFill = shapeProperties.GetFirstChild<PatternFill>();
+            if (pattFill != null)
+            {
+                HtexPattFill htexPattFill = DoPattFill(pattFill, slide);
+                fill.type = 4;
+                fill.pattFill = htexPattFill;
+            }
+            var solidFill = shapeProperties.GetFirstChild<SolidFill>();
+            if (solidFill != null)
+            {
+                fill.type = 1;
+                fill.solidFill = DoSolidFill(solidFill, slide);
+            }
+            var groupFill = shapeProperties.GetFirstChild<GroupFill>();
+            if (groupFill != null)
+            {
+                fill.type = 5;
+                //  fill.solidFill = ReadSolidFillColors(new SolidFill(solidFill.ToString()), slide);
+            }
+            var blipFill = shapeProperties.GetFirstChild<DocumentFormat.OpenXml.Drawing.BlipFill>();
+            if (blipFill != null)
+            {
+                fill.type = 3;
+                fill.blipFill = DoBlipFill(blipFill, slide, partForm);
+                //  fill.solidFill = ReadSolidFillColors(new SolidFill(solidFill.ToString()), slide);
+            }
+            var EffectList = shapeProperties.GetFirstChild<EffectList>();
+            var EffectDag = shapeProperties.GetFirstChild<EffectDag>();
+            var Scene3DType = shapeProperties.GetFirstChild<Scene3DType>();
+            var Shape3DType = shapeProperties.GetFirstChild<Shape3DType>();
+            var ShapePropertiesExtensionList = shapeProperties.GetFirstChild<ShapePropertiesExtensionList>();
+            return new HTEXLib.Models.HTEX.ShapeStyle { fill = fill, border = border };
+        }
+        public static HTEXLib.Models.HTEX.ShapeStyle DoTableProperties(TableProperties shapeProperties, PPTSlide slide, string type, string partForm)
+        {
+            Fill fill = new Fill() { type = -1 };
+            var gradFill = shapeProperties.GetFirstChild<GradientFill>();
+            if (gradFill != null)
+            {
+                fill.type = 2;
+                fill.gradientFill = DoGradientFill(gradFill, slide);
+            }
+            var noFill = shapeProperties.GetFirstChild<NoFill>();
+            if (noFill != null)
+            {
+                fill.type = 0;
+            }
+            var pattFill = shapeProperties.GetFirstChild<PatternFill>();
+            if (pattFill != null)
+            {
+                HtexPattFill htexPattFill = DoPattFill(pattFill, slide);
+                fill.type = 4;
+                fill.pattFill = htexPattFill;
+            }
+            var solidFill = shapeProperties.GetFirstChild<SolidFill>();
+            if (solidFill != null)
+            {
+                fill.type = 1;
+                fill.solidFill = DoSolidFill(solidFill, slide);
+            }
+            var groupFill = shapeProperties.GetFirstChild<GroupFill>();
+            if (groupFill != null)
+            {
+                fill.type = 5;
+                //  fill.solidFill = ReadSolidFillColors(new SolidFill(solidFill.ToString()), slide);
+            }
+            var blipFill = shapeProperties.GetFirstChild<DocumentFormat.OpenXml.Drawing.BlipFill>();
+            if (blipFill != null)
+            {
+                fill.type = 3;
+                fill.blipFill = DoBlipFill(blipFill, slide, partForm);
+                //  fill.solidFill = ReadSolidFillColors(new SolidFill(solidFill.ToString()), slide);
+            }
+            var EffectList = shapeProperties.GetFirstChild<EffectList>();
+            var EffectDag = shapeProperties.GetFirstChild<EffectDag>();
+            var TableStyle = shapeProperties.GetFirstChild<TableStyle>();
+
+            var TableStyleId = shapeProperties.GetFirstChild<TableStyleId>();
+            var ShapePropertiesExtensionList = shapeProperties.GetFirstChild<DocumentFormat.OpenXml.Drawing.ExtensionList>();
+
+            return new HTEXLib.Models.HTEX.ShapeStyle { fill = fill};
+        }
+
+        public static void DoTableStyle(TableStyle tableStyle, PPTSlide slide, string type, string partForm) {
+            var TableBackground = tableStyle.TableBackground;
+            if (TableBackground != null)
+            {
+                var shapeProperties = TableBackground.GetFirstChild<FillProperties>();
+                Fill fill = DoFillProperties(shapeProperties , partForm,slide );
+                var FillReference = TableBackground.GetFirstChild<FillReference>();
+                DoFillReference(slide, fill, FillReference);
+                //TODO
+                TableBackground.GetFirstChild<EffectPropertiesType>();
+                TableBackground.GetFirstChild<EffectReference>();
+            }
+            //TablePartStyleType
+            var WholeTable = tableStyle.WholeTable;
+            if (WholeTable != null) {
+                DoTablePartStyleType(WholeTable, slide, type, partForm);
+            }
+            var Band1Horizontal = tableStyle.Band1Horizontal;
+            if (Band1Horizontal != null)
+            {
+                DoTablePartStyleType(Band1Horizontal, slide, type, partForm);
+            }
+            var Band2Horizontal = tableStyle.Band2Horizontal;
+            if (Band2Horizontal != null)
+            {
+                DoTablePartStyleType(Band2Horizontal, slide, type, partForm);
+            }
+            var Band1Vertical = tableStyle.Band1Vertical;
+            if (Band1Vertical != null)
+            {
+                DoTablePartStyleType(Band1Vertical, slide, type, partForm);
+            }
+            var Band2Vertical = tableStyle.Band2Vertical;
+            if (Band2Vertical != null)
+            {
+                DoTablePartStyleType(Band2Vertical, slide, type, partForm);
+            }
+            var LastColumn = tableStyle.LastColumn;
+            if (LastColumn != null)
+            {
+                DoTablePartStyleType(LastColumn, slide, type, partForm);
+            }
+            var FirstColumn = tableStyle.FirstColumn;
+            if (FirstColumn != null)
+            {
+                DoTablePartStyleType(FirstColumn, slide, type, partForm);
+            }
+            var FirstRow = tableStyle.FirstRow;
+            if (FirstRow != null)
+            {
+                DoTablePartStyleType(FirstRow, slide, type, partForm);
+            }
+            var LastRow = tableStyle.LastRow;
+            if (LastRow != null)
+            {
+                DoTablePartStyleType(LastRow, slide, type, partForm);
+            }
+            var SoutheastCell = tableStyle.SoutheastCell;
+            if (SoutheastCell != null)
+            {
+                DoTablePartStyleType(SoutheastCell, slide, type, partForm);
+            }
+            var SouthwestCell = tableStyle.SouthwestCell;
+            if (SouthwestCell != null)
+            {
+                DoTablePartStyleType(SouthwestCell, slide, type, partForm);
+            }
+            var NortheastCell = tableStyle.NortheastCell;
+            if (NortheastCell != null)
+            {
+                DoTablePartStyleType(NortheastCell, slide, type, partForm);
+            }
+            var NorthwestCell = tableStyle.NorthwestCell;
+            if (NorthwestCell != null)
+            {
+                DoTablePartStyleType(NorthwestCell, slide, type, partForm);
+            }
+            var ExtensionList = tableStyle.ExtensionList;
+        }
+
+        private static void DoFillReference(PPTSlide slide, Fill fill, FillReference FillReference)
+        {
+            if (FillReference != null)
+            {
+                if (fill.type == -1)
+                {
+                    string color = null;
+                    if (FillReference.RgbColorModelPercentage != null)
+                    {
+                        color = ReadColor(FillReference.RgbColorModelPercentage);
+                    }
+                    if (FillReference.RgbColorModelHex != null)
+                    {
+                        color = ReadColor(FillReference.RgbColorModelHex);
+                    }
+                    if (FillReference.HslColor != null)
+                    {
+                        color = ReadColor(FillReference.HslColor);
+                    }
+                    if (FillReference.SystemColor != null)
+                    {
+                        color = ReadColor(FillReference.SystemColor, slide);
+                    }
+                    if (FillReference.SchemeColor != null)
+                    {
+                        color = ReadColor(FillReference.SchemeColor, slide);
+                    }
+                    if (FillReference.PresetColor != null)
+                    {
+                        color = ReadColor(FillReference.PresetColor);
+                    }
+                    fill.solidFill = color;
+                    fill.type = 2;
+                }
+            }
+        }
+
+        private static Fill DoFillProperties(FillProperties shapeProperties , string partForm, PPTSlide slide)
+        {
+            Fill fill = new Fill() { type = -1 };
+            if (shapeProperties != null)
+            {
+
+                var gradFill = shapeProperties.GetFirstChild<GradientFill>();
+                if (gradFill != null)
+                {
+                    fill.type = 2;
+                    fill.gradientFill = DoGradientFill(gradFill, slide);
+                }
+                var noFill = shapeProperties.GetFirstChild<NoFill>();
+                if (noFill != null)
+                {
+                    fill.type = 0;
+                }
+                var pattFill = shapeProperties.GetFirstChild<PatternFill>();
+                if (pattFill != null)
+                {
+                    HtexPattFill htexPattFill = DoPattFill(pattFill, slide);
+                    fill.type = 4;
+                    fill.pattFill = htexPattFill;
+                }
+                var solidFill = shapeProperties.GetFirstChild<SolidFill>();
+                if (solidFill != null)
+                {
+                    fill.type = 1;
+                    fill.solidFill = DoSolidFill(solidFill, slide);
+                }
+                var groupFill = shapeProperties.GetFirstChild<GroupFill>();
+                if (groupFill != null)
+                {
+                    fill.type = 5;
+                    //  fill.solidFill = ReadSolidFillColors(new SolidFill(solidFill.ToString()), slide);
+                }
+                var blipFill = shapeProperties.GetFirstChild<DocumentFormat.OpenXml.Drawing.BlipFill>();
+                if (blipFill != null)
+                {
+                    fill.type = 3;
+                    fill.blipFill = DoBlipFill(blipFill, slide, partForm);
+                    //  fill.solidFill = ReadSolidFillColors(new SolidFill(solidFill.ToString()), slide);
+                }
+            }
+
+            return fill;
+        }
+
+        public static void DoTablePartStyleType(TablePartStyleType tablePartStyleType, PPTSlide slide, string type, string partForm) {
+            //表格单元格文本样式。
+            var TableCellTextStyle = tablePartStyleType.GetFirstChild<TableCellTextStyle>();
+            if (TableCellTextStyle != null) {
+                FontStyle fontStyle = new FontStyle { };
+                //字体加粗以及斜体
+                if (TableCellTextStyle.Bold != null && TableCellTextStyle.Bold.Value == BooleanStyleValues.On)
+                {
+                    fontStyle.bold = true;
+                }
+                else {
+                    fontStyle.bold = false;
+                }
+                if (TableCellTextStyle.Italic != null && TableCellTextStyle.Italic.Value == BooleanStyleValues.On)
+                {
+                    fontStyle.italic = true;
+                }
+                //字体颜色
+                string color = null;
+                var RgbColorModelPercentage = TableCellTextStyle.GetFirstChild<RgbColorModelPercentage>();
+                if (RgbColorModelPercentage != null)
+                {
+                    color = ReadColor(RgbColorModelPercentage);
+                }
+                var RgbColorModelHex = TableCellTextStyle.GetFirstChild<RgbColorModelHex>();
+                if (RgbColorModelHex != null)
+                {
+                    color = ReadColor(RgbColorModelHex);
+                }
+                var HslColor = TableCellTextStyle.GetFirstChild<DocumentFormat.OpenXml.Drawing.HslColor>();
+                if (HslColor != null)
+                {
+                    color = ReadColor(HslColor);
+                }
+                var SystemColor = TableCellTextStyle.GetFirstChild<SystemColor>();
+                if (SystemColor != null)
+                {
+                    color = ReadColor(SystemColor, slide);
+                }
+                var SchemeColor = TableCellTextStyle.GetFirstChild<SchemeColor>();
+                if (SchemeColor != null)
+                {
+                    color = ReadColor(SchemeColor, slide);
+                }
+                var PresetColor = TableCellTextStyle.GetFirstChild<PresetColor>();
+                if (PresetColor != null)
+                {
+                    color = ReadColor(PresetColor);
+                }
+                fontStyle.color = color;
+                var FontReference = TableCellTextStyle.GetFirstChild<DocumentFormat.OpenXml.Drawing.FontReference>();
+                if (color == null && FontReference != null)
+                {
+
+                    if (FontReference.RgbColorModelPercentage != null)
+                    {
+                        color = ReadColor(FontReference.RgbColorModelPercentage);
+                    }
+
+                    if (FontReference.RgbColorModelHex != null)
+                    {
+                        color = ReadColor(FontReference.RgbColorModelHex);
+                    }
+
+                    if (FontReference.HslColor != null)
+                    {
+                        color = ReadColor(FontReference.HslColor);
+                    }
+
+                    if (FontReference.SystemColor != null)
+                    {
+                        color = ReadColor(FontReference.SystemColor, slide);
+                    }
+
+                    if (FontReference.SchemeColor != null)
+                    {
+                        color = ReadColor(FontReference.SchemeColor, slide);
+                    }
+
+                    if (FontReference.PresetColor != null)
+                    {
+                        color = ReadColor(FontReference.PresetColor);
+                    }
+                    fontStyle.color = color;
+                }
+                //字体属性
+                var font = TableCellTextStyle.GetFirstChild<DocumentFormat.OpenXml.Drawing.Fonts>();
+                var LatinFont=  font.LatinFont;
+                var EastAsianFont= font.EastAsianFont; 
+                var ComplexScriptFont=  font.ComplexScriptFont;
+                if (EastAsianFont != null)
+                {
+                    fontStyle.family= DoTextFontType(EastAsianFont,slide);
+                }
+                if (ComplexScriptFont != null)
+                {
+                    fontStyle.family = DoTextFontType(ComplexScriptFont, slide);
+                }
+                if (LatinFont != null)
+                {
+                    fontStyle.family = DoTextFontType(LatinFont, slide);
+                }
+                var SupplementalFont=  font.GetFirstChild<SupplementalFont>();
+                if (SupplementalFont != null) {
+                    fontStyle.family = SupplementalFont.Typeface;
+                }
+            }
+            //表格单元格样式。
+            var TableCellStyle = tablePartStyleType.GetFirstChild<TableCellStyle>();
+            if (TableCellStyle != null)
+            {
+                var TableCellBorders= TableCellStyle.TableCellBorders;
+                if (TableCellBorders != null) {
+                    var LeftBorder = TableCellBorders.LeftBorder;
+                    if (LeftBorder != null) {
+                        Border border=  DoOutline(LeftBorder.Outline, slide, "tbl");
+                        if (LeftBorder.LineReference!=null&& border.color.type == -1) {
+                            border.color.solidFill=DoMatrixReferenceColors(LeftBorder.LineReference, slide);
+                            border.color.type = 2;
+                        }
+                    }
+                    var RightBorder = TableCellBorders.RightBorder;
+                    if (RightBorder != null)
+                    {
+                        Border border = DoOutline(RightBorder.Outline, slide, "tbl");
+                        if (RightBorder.LineReference != null && border.color.type == -1)
+                        {
+                            border.color.solidFill = DoMatrixReferenceColors(RightBorder.LineReference, slide);
+                            border.color.type = 2;
+                        }
+                    }
+                    var TopBorder = TableCellBorders.TopBorder;
+                    if (TopBorder != null)
+                    {
+                        Border border = DoOutline(TopBorder.Outline, slide, "tbl");
+                        if (TopBorder.LineReference != null && border.color.type == -1)
+                        {
+                            border.color.solidFill = DoMatrixReferenceColors(TopBorder.LineReference, slide);
+                            border.color.type = 2;
+                        }
+                    }
+                    var BottomBorder = TableCellBorders.BottomBorder;
+                    if (BottomBorder != null)
+                    {
+                        Border border = DoOutline(BottomBorder.Outline, slide, "tbl");
+                        if (BottomBorder.LineReference != null && border.color.type == -1)
+                        {
+                            border.color.solidFill = DoMatrixReferenceColors(BottomBorder.LineReference, slide);
+                            border.color.type = 2;
+                        }
+                    }
+                    var InsideHorizontalBorder = TableCellBorders.InsideHorizontalBorder;
+                    if (InsideHorizontalBorder != null)
+                    {
+                        Border border = DoOutline(InsideHorizontalBorder.Outline, slide, "tbl");
+                        if (InsideHorizontalBorder.LineReference != null && border.color.type == -1)
+                        {
+                            border.color.solidFill = DoMatrixReferenceColors(InsideHorizontalBorder.LineReference, slide);
+                            border.color.type = 2;
+                        }
+                    }
+                    var InsideVerticalBorder = TableCellBorders.InsideVerticalBorder;
+                    if (InsideVerticalBorder != null)
+                    {
+                        Border border = DoOutline(InsideVerticalBorder.Outline, slide, "tbl");
+                        if (InsideVerticalBorder.LineReference != null && border.color.type == -1)
+                        {
+                            border.color.solidFill = DoMatrixReferenceColors(InsideVerticalBorder.LineReference, slide);
+                            border.color.type = 2;
+                        }
+                    }
+                    var TopLeftToBottomRightBorder = TableCellBorders.TopLeftToBottomRightBorder;
+                    if (TopLeftToBottomRightBorder != null)
+                    {
+                        Border border = DoOutline(TopLeftToBottomRightBorder.Outline, slide, "tbl");
+                        if (TopLeftToBottomRightBorder.LineReference != null && border.color.type == -1)
+                        {
+                            border.color.solidFill = DoMatrixReferenceColors(TopLeftToBottomRightBorder.LineReference, slide);
+                            border.color.type = 2;
+                        }
+                    }
+                    var TopRightToBottomLeftBorder = TableCellBorders.TopRightToBottomLeftBorder;
+                    if (TopRightToBottomLeftBorder != null)
+                    {
+                        Border border = DoOutline(TopRightToBottomLeftBorder.Outline, slide, "tbl");
+                        if (TopRightToBottomLeftBorder.LineReference != null && border.color.type == -1)
+                        {
+                            border.color.solidFill = DoMatrixReferenceColors(TopRightToBottomLeftBorder.LineReference, slide);
+                            border.color.type = 2;
+                        }
+                    }
+                }
+                var FillProperties = TableCellStyle.GetFirstChild<FillProperties>();
+                Fill fill = DoFillProperties(FillProperties, partForm, slide);
+                var FillReference = TableCellStyle.GetFirstChild<FillReference>();
+                DoFillReference(slide, fill, FillReference);
+                //TODO
+                var Cell3DProperties = TableCellStyle.GetFirstChild<Cell3DProperties>();
+
+            }
+        }
         /// <summary>
         /// 
         /// </summary>
@@ -75,7 +545,7 @@ namespace HTEXLib.Helpers.ShapeHelpers
             Border border = null;
             if (lnNode != null)
             {
-                border  = DoLn(lnNode, slide,type);
+                border  = DoOutline(lnNode, slide,type);
             }
             Fill fill = new Fill() { type = -1 };
             var gradFill = shapeProperties.GetFirstChild<GradientFill>();
@@ -100,7 +570,7 @@ namespace HTEXLib.Helpers.ShapeHelpers
             if (solidFill != null)
             {
                 fill.type = 1;
-                fill.solidFill = ReadSolidFillColors(solidFill, slide);
+                fill.solidFill = DoSolidFill(solidFill, slide);
             }
             var groupFill = shapeProperties.GetFirstChild<GroupFill>();
             if (groupFill != null)
@@ -148,7 +618,7 @@ namespace HTEXLib.Helpers.ShapeHelpers
             if (solidFill != null)
             {
                 fill.type = 1;
-                fill.solidFill = ReadSolidFillColors(solidFill, slide);
+                fill.solidFill = DoSolidFill(solidFill, slide);
             }
             var groupFill = shapeProperties.GetFirstChild<GroupFill>();
             if (groupFill != null)
@@ -304,12 +774,15 @@ namespace HTEXLib.Helpers.ShapeHelpers
             //TODO 图片元素的更多信息需要后期继续实现,如滤镜,裁剪,图片颜色,图片校正等
             return htexBlipFill;
         }
+
+         
+
         /// <summary>
         /// a:ln 图形的外边
         /// </summary>
         /// <param name="shapeProperties"></param>
         /// <param name="slide"></param>
-        public static Border DoLn(DocumentFormat.OpenXml.Drawing.Outline outline, PPTSlide slide,string  Shapetype) {
+        public static Border DoOutline(DocumentFormat.OpenXml.Drawing.Outline outline, PPTSlide slide,string  Shapetype) {
             Border border = new Border() {color= new Fill { type=-1} };
             //20.1.10.35     EMUs. 1 pt = 12700 EMUs.
             double? Width = null;
@@ -376,7 +849,7 @@ namespace HTEXLib.Helpers.ShapeHelpers
             if (solidFill != null)
             {
                 border.color.type = 1;
-                border.color.solidFill = ReadSolidFillColors(solidFill, slide);
+                border.color.solidFill = DoSolidFill(solidFill, slide);
             }
             if (Width!=null && Width > 0) {
                 border.type = "solid";
@@ -653,7 +1126,6 @@ namespace HTEXLib.Helpers.ShapeHelpers
         
         public static string ColorTypeColors(GradientStop Color, PPTSlide slide)
         {
-            //TODO  还有其他来源的颜色 派生的子类
             string FontColor = "";
             if (Color.RgbColorModelHex != null)
             {
@@ -683,7 +1155,6 @@ namespace HTEXLib.Helpers.ShapeHelpers
         }
         public static string ColorTypeColors(ColorType Color, PPTSlide slide)
         {
-            //TODO  还有其他来源的颜色 派生的子类
             string FontColor = "";
             if (Color.RgbColorModelHex != null)
             {
@@ -741,8 +1212,11 @@ namespace HTEXLib.Helpers.ShapeHelpers
             return FontColor;
         }
 
-        public static string StyleMatrixReferenceColors(StyleMatrixReferenceType Color, PPTSlide slide) {
+        public static string DoMatrixReferenceColors(StyleMatrixReferenceType Color, PPTSlide slide) {
             string FontColor = "";
+            if (Color == null) {
+                return FontColor;
+            }
             if (Color.RgbColorModelHex != null)
             {
                 FontColor = ReadColor(Color.RgbColorModelHex);
@@ -771,7 +1245,7 @@ namespace HTEXLib.Helpers.ShapeHelpers
         }
 
           
-        public static string ReadSolidFillColors(SolidFill Color, PPTSlide slide)
+        public static string DoSolidFill(SolidFill Color, PPTSlide slide)
         {
             string FontColor = "";
             if (Color.RgbColorModelHex != null)
@@ -828,7 +1302,7 @@ namespace HTEXLib.Helpers.ShapeHelpers
         }
         public static string ReadColor(DocumentFormat.OpenXml.Drawing.SchemeColor SchemeColor,PPTSlide slide) {
             string FontColor = "";
-            FontColor = ReadThemeSchemeColor(SchemeColor, slide);
+            FontColor = DoSchemeColor(SchemeColor, slide);
             FontColor = "#" + ShapeHelper.ColorToning(SchemeColor.OuterXml, FontColor.Replace("#", ""));
             return FontColor;
         }
@@ -854,7 +1328,7 @@ namespace HTEXLib.Helpers.ShapeHelpers
             return FontColor;
         }
 
-        public static string ReadFontFamilyFromTheme(LatinFont latinFonts, PPTSlide slide)
+        public static string DoTextFontType(TextFontType latinFonts, PPTSlide slide)
         {
             string FontFamily = "";
             FontScheme allSchemeFonts =
@@ -894,7 +1368,7 @@ namespace HTEXLib.Helpers.ShapeHelpers
             }
             return FontFamily;
         }
-        public static string ReadThemeSchemeColor(SchemeColor schemeColor, PPTSlide slide)
+        public static string DoSchemeColor(SchemeColor schemeColor, PPTSlide slide)
         {
             var light1Color1= slide.SlideLayoutPart.SlideMasterPart.
                       ThemePart;
@@ -1040,8 +1514,6 @@ namespace HTEXLib.Helpers.ShapeHelpers
             return FontColor;
         }
 
-
-        
-
+       
     }
 }

+ 12 - 5
HTEXLib/Helpers/ShapeHelpers/ShapeHelper.cs

@@ -140,8 +140,9 @@ namespace HTEXLib
             XmlNode alphaOff = doc.SelectSingleNode("//a:alphaOff/@val", xmlnsManager);
             if (alphaOff != null)
             {
-                // Color color= ColorTranslator.FromHtml("#" + colorHex);
-                //   color = Color.FromArgb(byte.Parse(int.Parse(alpha.Value)/100000+""),color.R,color.G,color.B);
+                Color color = ColorTranslator.FromHtml("#" + colorHex);
+                //color.A * (int.Parse(alpha.Value) / 100000);
+                color = Color.FromArgb(color.A- color.A * (int.Parse(alphaOff.Value) / 100000), color.R, color.G, color.B);
             }
             XmlNode shade = doc.SelectSingleNode("//a:shade/@val", xmlnsManager);
             if (shade != null)
@@ -152,10 +153,16 @@ namespace HTEXLib
             XmlNode alpha = doc.SelectSingleNode("//a:alpha/@val", xmlnsManager);
             if (alpha != null)
             {
-                // Color color= ColorTranslator.FromHtml("#" + colorHex);
-                //   color = Color.FromArgb(byte.Parse(int.Parse(alpha.Value)/100000+""),color.R,color.G,color.B);
+                 Color color= ColorTranslator.FromHtml("#" + colorHex);
+                //color.A * (int.Parse(alpha.Value) / 100000);
+                //TODO是用255计算 还是颜色本身的A alpha计算
+                color = Color.FromArgb(color.A * (int.Parse(alpha.Value) / 100000), color.R,color.G,color.B);
+            }
+            //TODO  //颜色调和 说明网站  https://c-rex.net/projects/samples/ooxml/e1/Part4/OOXML_P4_DOCX_comp_topic_ID0EATEJB.html
+            XmlNode comp = doc.SelectSingleNode("//a:comp", xmlnsManager);
+            if (comp != null) {
+                colorHex = converter.SetComp(colorHex);
             }
-            XmlNode comp = doc.SelectSingleNode("//a:comp/@val", xmlnsManager);
             XmlNode inv = doc.SelectSingleNode("//a:inv/@val", xmlnsManager);
             XmlNode alphaMod = doc.SelectSingleNode("//a:alphaMod/@val", xmlnsManager);
             XmlNode gray = doc.SelectSingleNode("//a:gray/@val", xmlnsManager);

+ 0 - 2
HTEXLib/Models/ExamItem.cs

@@ -59,8 +59,6 @@ namespace HTEXLib
         /// </summary>
         public List<ProcessRes> repairResource { get; set; }
 
-
-
         public string subjectCode { get; set; }
         public string periodCode { get; set; }
         public List<string> gradeCode { get; set; }

+ 4 - 1
HTEXLib/Models/Group.cs

@@ -8,6 +8,9 @@ namespace HTEXLib
     {
         public List<Item> shapes { get; set; }
 
-       
+        public Fill fill { get; set; } = new Fill() { type = -1 };
+        public Border border { get; set; } = new Border();
+
+
     }
 }

+ 1 - 1
HTEXLib/Models/HTEX/HtexConnectionShape.cs

@@ -53,7 +53,7 @@ namespace HTEXLib.Models.HTEX
             var shapeTypeNode = connectionShape.element.ShapeProperties.GetFirstChild<PresetGeometry>();
             var shapeType= shapeTypeNode.Preset.InnerText;
             var otl = connectionShape.element.ShapeProperties.GetFirstChild<Outline>();
-            var shapeBorder = PPTXHelper.DoLn(otl, slide,type);
+            var shapeBorder = PPTXHelper.DoOutline(otl, slide,type);
             //从ShapeProperties 获取 p:spPr
             //再从 ShapeStyle 获取 p:spPr
             if (shapeBorder.color == null|| shapeBorder.color.type==-1) {

+ 1 - 1
HTEXLib/Models/HTEX/HtexElement.cs

@@ -16,7 +16,7 @@ namespace HTEXLib.Models.HTEX
         protected string fontColor;
         protected string id;
         protected PPTSlide slide;
-        protected string cssClass;
+       // protected string cssClass;
         protected bool invisible;
         protected bool animatable;
         protected int index;

+ 84 - 0
HTEXLib/Models/HTEX/HtexGraphicFrame.cs

@@ -0,0 +1,84 @@
+using DocumentFormat.OpenXml.Drawing.Diagrams;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace HTEXLib.Models.HTEX
+{
+    public class HtexGraphicFrame : HtexElement
+    {
+        public HtexGraphicFrame(string id, double rot, double width, double height,
+                               double top, double left, bool invisible,
+                               bool animatable, int index, Inner.PPTGraphicFrame graphicFrame, PPTSlide slide, string partForm)
+        // frameId, width, height, top, left, visible, animatable
+        {
+            base.slide = slide;
+            this.rot = rot;
+            this.graphicFrame = graphicFrame;
+            base.id = id;
+            base.top = top;
+            base.left = left;
+            base.width = width;
+            base.height = height;
+            base.invisible = invisible;
+            base.animatable = animatable;
+            base.index = index;
+            base.type = "GraphicFrame";
+            base.partForm = partForm;
+        }
+        public Inner.PPTGraphicFrame graphicFrame { get; set; }
+
+        public override List<Item> DrawElement()
+        {
+            var GraphicDataChildren = graphicFrame.element.Graphic.GraphicData.ChildElements;
+            foreach (var clild in GraphicDataChildren) {
+                if (clild is DocumentFormat.OpenXml.Drawing.Table Table) {
+                    var tal = Table;
+                }
+                if (clild is DocumentFormat.OpenXml.Drawing.Charts.ChartReference Chart)
+                {
+                    var ChartNode = slide.SlidePart.Parts.Where(x => x.RelationshipId == Chart.Id).FirstOrDefault();
+                    var url = ChartNode.OpenXmlPart.Uri.ToString().Replace("../", "/ppt/");
+                }
+                if (clild is DocumentFormat.OpenXml.Drawing.Diagrams.RelationshipIds Diagram)
+                {
+                  
+                    DoDiagram(Diagram);
+                    
+                }
+            }
+            return null; 
+        }
+
+        private void DoDiagram(RelationshipIds Diagram)
+        { 
+            //datapart r:dm="rId2" layoutpart r:lo="rId3"  stylepart r:qs="rId4" colorpart r:cs="rId5" />
+            var DataPart = Diagram.DataPart.Value;
+            var LayoutPart = Diagram.LayoutPart.Value;
+            var StylePart = Diagram.StylePart.Value;
+            var ColorPart = Diagram.ColorPart.Value;
+            var Data = slide.SlidePart.Parts.Where(x => x.RelationshipId == DataPart).FirstOrDefault();
+            var Layout = slide.SlidePart.Parts.Where(x => x.RelationshipId == LayoutPart).FirstOrDefault();
+            var Style = slide.SlidePart.Parts.Where(x => x.RelationshipId == StylePart).FirstOrDefault();
+            var Color = slide.SlidePart.Parts.Where(x => x.RelationshipId == ColorPart).FirstOrDefault();
+
+            if (Layout != null)
+            {
+                var url = Layout.OpenXmlPart.Uri.ToString().Replace("../", "/ppt/");
+            }
+            if (Style != null)
+            {
+                var url = Style.OpenXmlPart.Uri.ToString().Replace("../", "/ppt/");
+            }
+            if (Color != null)
+            {
+                var url = Color.OpenXmlPart.Uri.ToString().Replace("../", "/ppt/");
+            }
+            if (Data != null)
+            {
+                var url = Data.OpenXmlPart.Uri.ToString().Replace("../", "/ppt/");
+            }
+        }
+    }
+}

+ 17 - 1
HTEXLib/Models/HTEX/HtexGroupShape.cs

@@ -1,3 +1,4 @@
+using HTEXLib.Helpers.ShapeHelpers;
 using System;
 using System.Collections.Generic;
 using System.Text;
@@ -27,7 +28,22 @@ namespace HTEXLib.Models.HTEX
         public Inner.PPTGroupShape groupShape { get; set; }
         public override List<Item> DrawElement()
         {
-            return null; 
+            Position position = new Position { cx = width, cy = height, x = left, y = top, rot = rot };
+            var ShapeStyle = PPTXHelper.DoShapeProperties(groupShape.element.GroupShapeProperties, slide, type, partForm);
+            Group group = new Group() { position = position, type = type, index = index, animatable = animatable, invisible = invisible };
+            group.border = ShapeStyle.border;
+            group.fill = ShapeStyle.fill;
+            //SlideColor slideColor = PPTXHelper.DoShapeStyle(groupShape.element.ShapeStyle, slide, type);
+            HtexSlide htexSlide = new HtexSlide(slide, slide.slideIndex)
+            {
+                ContainerShape = groupShape.containerShape
+
+            };
+            var elements= htexSlide.DrawElement();
+            if (elements != null) {
+                group.shapes = elements;
+            }
+            return new List<Item>() { group }; 
         }
     }
 }

+ 1 - 1
HTEXLib/Models/HTEX/HtexImage.cs

@@ -106,7 +106,7 @@ namespace HTEXLib.Models.HTEX
             }
             HtexBlipFill htexBlipFill = PPTXHelper.DoBlipFill(image.element.BlipFill, slide,partForm);
             media.image = htexBlipFill;
-
+            //TODO  处理公式图片
             return new List<Item>() { media }; 
         }
     }

+ 0 - 14
HTEXLib/Models/HTEX/HtexImageGIF.cs

@@ -1,14 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace HTEXLib.Models.HTEX
-{
-    public class HtexImageGIF : HtexElement
-    {
-        public override List<Item> DrawElement()
-        {
-            throw new NotImplementedException();
-        }
-    }
-}

+ 101 - 3
HTEXLib/Models/HTEX/HtexShape.cs

@@ -4,6 +4,7 @@ using HTEXLib.Models.Inner;
 using System;
 using System.Collections.Generic;
 using System.Drawing;
+using System.Linq;
 using System.Text;
 
 namespace HTEXLib.Models.HTEX
@@ -45,6 +46,8 @@ namespace HTEXLib.Models.HTEX
             //position = position ,mediaType = "image",type = type,index = index,animatable = animatable ,invisible = invisible
             Shape shape = new Shape() { paragraph = DrawText(),position=position ,type=type,index=index,animatable=animatable,invisible=invisible };
             var shapeTypeNode = Shape.element.ShapeProperties.GetFirstChild<PresetGeometry>();
+            var shapeTypeCustom = Shape.element.ShapeProperties.GetFirstChild<CustomGeometry>();
+
             var shapeType = shapeTypeNode.Preset.InnerText;
             SlideColor slideColor = PPTXHelper.DoShapeStyle(Shape.element.ShapeStyle, slide,type);
             //从ShapeProperties 获取 p:spPr
@@ -71,9 +74,104 @@ namespace HTEXLib.Models.HTEX
             else {
                 shape.fill = ShapeStyle.fill;
             }
-            Svg svg = PPTXSvg.GenShapeSvg(Shape.element, index, shapeType, position,  shape.border);
-            shape.svg = svg;
-            shape.shapeType = shapeType;
+
+            if (shapeTypeNode != null&& !string.IsNullOrEmpty(shapeType)) {
+                Svg svg = PPTXSvg.GenShapeSvg(Shape.element, index, shapeType, position, shape.border);
+                shape.svg = svg;
+                shape.shapeType = shapeType;
+            }
+            if (shapeTypeCustom!=null) {
+                var pathlist=  shapeTypeCustom.GetFirstChild<PathList>();
+                var path=  pathlist.GetFirstChild<DocumentFormat.OpenXml.Drawing.Path>();
+                var pathChildren = path.ChildElements;
+                if (pathChildren != null) {
+                    var start=  pathChildren.Where(x =>x is MoveTo).FirstOrDefault();
+                    var close= pathChildren.Where(x => x is CloseShapePath).FirstOrDefault();
+                    var spX = 96.0;
+                    var spY = 96.0;
+                    if (start != null) {
+                        var point =  start.GetFirstChild<DocumentFormat.OpenXml.Drawing.Point>();
+                        spX = System.Math.Round(double.Parse(point.X.Value )* Globals.px96 *1.0/ Globals.px914400, Globals. degree);
+                        spY = System.Math.Round(double.Parse(point.Y.Value) * Globals.px96 * 1.0 / Globals.px914400, Globals.degree);
+                    }
+                    var d = "M" + spX + "," + spY;
+                    foreach (var child in pathChildren) {
+                        if (child is LineTo lineTo) {
+                            var elm= lineTo.GetFirstChild<DocumentFormat.OpenXml.Drawing.Point>();
+                            if (elm != null) {
+                                var Lx = System.Math.Round(double.Parse(elm.X.Value) * Globals.px96 * 1.0 / Globals.px914400, Globals.degree);
+                                var Ly = System.Math.Round(double.Parse(elm.Y.Value) * Globals.px96 * 1.0 / Globals.px914400, Globals.degree);
+                                d += " L" + Lx + "," + Ly;
+                            }
+                        }
+                        if (child is ArcTo arcTo)
+                        {
+                            var WidthRadius = arcTo.WidthRadius;
+                            var HeightRadius = arcTo.HeightRadius;
+                            var StartAngle = arcTo.StartAngle;
+                            var SwingAngle = arcTo.SwingAngle;
+                            var wR= System.Math.Round(double.Parse(WidthRadius.Value) * Globals.px96 * 1.0 / Globals.px914400, Globals.degree);
+                            var hR = System.Math.Round(double.Parse(HeightRadius.Value) * Globals.px96 * 1.0 / Globals.px914400, Globals.degree);
+                            var stAng = System.Math.Round(double.Parse(StartAngle.Value) * Globals.px96 * 1.0 / Globals.px914400, Globals.degree);
+                            var swAng = System.Math.Round(double.Parse(SwingAngle.Value) * Globals.px96 * 1.0 / Globals.px914400, Globals.degree);
+                            var endAng = stAng + swAng;
+                            d +=PPTXSvg .ShapeArc(wR, hR, wR, hR, stAng, endAng, false);
+                        }
+                        if (child is QuadraticBezierCurveTo quadraticBezierCurveTo)
+                        {
+                            var elms= quadraticBezierCurveTo.Elements<DocumentFormat.OpenXml.Drawing.Point>();
+                            if (elms != null) {
+                                var list = elms.ToList();
+                                var Cx1 = double.Parse(list[0].X.Value) * Globals.px96 * 1.0 / Globals.px914400;
+                                var Cy1 = double.Parse(list[0].Y.Value) * Globals.px96 * 1.0 / Globals.px914400;
+
+                                var Cx2 = double.Parse(list[1].X.Value) * Globals.px96 * 1.0 / Globals.px914400;
+                                var Cy2 = double.Parse(list[1].Y.Value) * Globals.px96 * 1.0 / Globals.px914400;
+
+                                var Cx3 = double.Parse(list[2].X.Value) * Globals.px96 * 1.0 / Globals.px914400;
+                                var Cy3 = double.Parse(list[2].Y.Value) * Globals.px96 * 1.0 / Globals.px914400;
+                                d += " C" + System.Math.Round(Cx1, Globals.degree) + "," + System.Math.Round(Cy1, Globals.degree) + " " + System.Math.Round(Cx2, Globals.degree) + "," + System.Math.Round(Cy2, Globals.degree) + " " + System.Math.Round(Cx3, Globals.degree) + "," + System.Math.Round(Cy3, Globals.degree);
+                            }
+                        }
+                        if (child is CubicBezierCurveTo cubicBezierCurveTo)
+                        {
+                            var elms = cubicBezierCurveTo.Elements<DocumentFormat.OpenXml.Drawing.Point>();
+                            if (elms != null)
+                            {
+                                var list = elms.ToList();
+                                var Cx1 = double.Parse(list[0].X.Value) * Globals.px96 * 1.0 / Globals.px914400;
+                                var Cy1 = double.Parse(list[0].Y.Value) * Globals.px96 * 1.0 / Globals.px914400;
+
+                                var Cx2 = double.Parse(list[1].X.Value) * Globals.px96 * 1.0 / Globals.px914400;
+                                var Cy2 = double.Parse(list[1].Y.Value) * Globals.px96 * 1.0 / Globals.px914400;
+                                d += " Q" + System.Math.Round(Cx1, Globals.degree) + "," + System.Math.Round(Cy1, Globals.degree) + " " + System.Math.Round(Cx2, Globals.degree) + "," + System.Math.Round(Cy2, Globals.degree);
+                            }
+                        }
+                    }
+                    //是否关闭svg
+                    if (close != null)
+                    {
+                        d += " z";
+                    }
+                    List<SvgShape> shapes = new List<SvgShape>() {
+                    new SvgPath {
+                        type = "path",
+                        // Fill = (!imgFillFlg ? (grndFillFlg ? "url(#linGrd_" + order + ")" : Fill.Color) : "url(#imgPtrn_" + order + ")"),
+                        //Stroke = "#" + shapeBorder.Color,
+                        //StrokeWidth = shapeBorder.Width + "",
+                        //StrokeDasharray = shapeBorder.Stroke,
+                        d=d,
+                        start=shape.border.headEnd!=null?shape.border.headEnd:null,
+                        end=shape.border.tailEnd!=null?shape.border.tailEnd:null,
+                        }
+                    };
+                    shape.svg = new Svg { 
+                        id=index+"",
+                        svgShape=shapes
+                    };
+                    shape.shapeType = "custom";
+                }
+            }
             var elmt = new List<Item> ();
             elmt.Add(shape);
             return elmt;

+ 5 - 5
HTEXLib/Models/HTEX/HtexSlide.cs

@@ -11,9 +11,9 @@ namespace HTEXLib.Models.HTEX
     {
         public PPTContainerShape ContainerShape { get; set; }
         private int slideIndex;
-        public HtexSlide(PPTSlide slide, string slideClass, int slideIndex) {
+        public HtexSlide(PPTSlide slide, int slideIndex) {
             base.slide = slide;
-            base.cssClass = slideClass;
+            //base.cssClass = slideClass;
             this.slideIndex = slideIndex;
         }
         public override List<Item> DrawElement()
@@ -64,7 +64,7 @@ namespace HTEXLib.Models.HTEX
 
             if (baseShape is PPTGraphicFrame graphicFrame)
             {
-                HtexSmartArt htmlSmartArt = new HtexSmartArt(Id, rot, width, height, top,
+                HtexGraphicFrame htmlSmartArt = new HtexGraphicFrame(Id, rot, width, height, top,
                                                             left, invisible, animatable ,index,graphicFrame,slide,baseShape.PartForm);
                 return htmlSmartArt.DrawElement();
             }
@@ -118,9 +118,9 @@ namespace HTEXLib.Models.HTEX
         public override string ToString()
         {
             Console.WriteLine("The id is:" + slide.Id);
-            Console.WriteLine("The css class is:" + cssClass);
+           // Console.WriteLine("The css class is:" + cssClass);
 
-            return slide.Id + cssClass;
+            return slide.Id ;
         }
     }
 }

+ 0 - 35
HTEXLib/Models/HTEX/HtexSmartArt.cs

@@ -1,35 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace HTEXLib.Models.HTEX
-{
-    public class HtexSmartArt : HtexElement
-    {
-        public HtexSmartArt(string id, double rot, double width, double height,
-                               double top, double left, bool invisible,
-                               bool animatable, int index, Inner.PPTGraphicFrame graphicFrame, PPTSlide slide, string partForm)
-        // frameId, width, height, top, left, visible, animatable
-        {
-            base.slide = slide;
-            this.rot = rot;
-            this.graphicFrame = graphicFrame;
-            base.id = id;
-            base.top = top;
-            base.left = left;
-            base.width = width;
-            base.height = height;
-            base.invisible = invisible;
-            base.animatable = animatable;
-            base.index = index;
-            base.type = "Diagram";
-            base.partForm = partForm;
-        }
-        public Inner.PPTGraphicFrame graphicFrame { get; set; }
-
-        public override List<Item> DrawElement()
-        {
-            throw new NotImplementedException();
-        }
-    }
-}

+ 2 - 1
HTEXLib/Models/PPTX/PPTConnectionShape.cs

@@ -39,7 +39,8 @@ namespace HTEXLib.Models.Inner
                         HoverLinkUrl = link.Uri.IsAbsoluteUri ? link.Uri.AbsoluteUri : link.Uri.OriginalString;
             var nonVisualShapeProp = new PPTNonVisualShapeProp
             {
-                Id = "s1s" +  //HARD CODED: we split it into separate HTML files!
+               
+                Id = PartForm + "PPTConnectionShape" +
                 connectionShape.NonVisualConnectionShapeProperties.NonVisualDrawingProperties.Id,
                 Name = connectionShape.LocalName,
                 Type = "PPTConnectionShape"

+ 1 - 1
HTEXLib/Models/PPTX/PPTGraphicFrame.cs

@@ -37,7 +37,7 @@ namespace HTEXLib.Models.Inner
 
             var nonVisualShapeProp = new PPTNonVisualShapeProp
             {
-                Id = "s1s" + //HARD CODED: we split it into separate HTML files!
+                Id = PartForm + "PPTGraphicFrame" +
                                                   gfarame.NonVisualGraphicFrameProperties.NonVisualDrawingProperties.Id,
                 Name = gfarame.LocalName,
                 Type = "PPTGraphicFrame"

+ 62 - 9
HTEXLib/Models/PPTX/PPTGroupShape.cs

@@ -3,6 +3,7 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using DocumentFormat.OpenXml;
 using DocumentFormat.OpenXml.Drawing;
 using DocumentFormat.OpenXml.Packaging;
 using DocumentFormat.OpenXml.Presentation;
@@ -11,7 +12,7 @@ namespace HTEXLib.Models.Inner
 {
     public class PPTGroupShape : PPTShapeBase
     {
-        public PPTGroupShape(OpenXmlPart openXmlPart, DocumentFormat.OpenXml.Presentation.GroupShape groupShape)
+        public PPTGroupShape(OpenXmlPart openXmlPart, DocumentFormat.OpenXml.Presentation.GroupShape groupShape ,PPTSlide slide)
         {
             if (openXmlPart is SlidePart slidePart)
             {
@@ -21,6 +22,7 @@ namespace HTEXLib.Models.Inner
             {
                 PartForm = "layout";
             }
+            base.slide = slide;
             element = groupShape;
             SetGroupShapeVisualProperties(openXmlPart, groupShape);
             SetGroupShapeNonVisualProperties(openXmlPart, groupShape);
@@ -29,14 +31,65 @@ namespace HTEXLib.Models.Inner
 
         private void SetChildShape(OpenXmlPart openXmlPart, DocumentFormat.OpenXml.Presentation.GroupShape groupShape)
         {
-            var ConnectionShapes= groupShape.Elements<DocumentFormat.OpenXml.Presentation.ConnectionShape>();
-            var GraphicElements= groupShape.Elements<DocumentFormat.OpenXml.Presentation.GraphicElement>();
-            var GroupShapes = groupShape.Elements<DocumentFormat.OpenXml.Presentation.GroupShape>();
-            var Pictures=  groupShape.Elements<DocumentFormat.OpenXml.Presentation.Picture>();
-            var Shapes=  groupShape.Elements<DocumentFormat.OpenXml.Presentation.Shape>();
+            //var ConnectionShapes= groupShape.Elements<DocumentFormat.OpenXml.Presentation.ConnectionShape>();
+            //var GraphicFrames= groupShape.Elements<DocumentFormat.OpenXml.Presentation.GraphicFrame>();
+            //var GroupShapes = groupShape.Elements<DocumentFormat.OpenXml.Presentation.GroupShape>();
+            //var Pictures=  groupShape.Elements<DocumentFormat.OpenXml.Presentation.Picture>();
+            //var Shapes=  groupShape.Elements<DocumentFormat.OpenXml.Presentation.Shape>();
+            var children = groupShape.ChildElements;
+            var pptContainerShape = new PPTContainerShape();
+            pptContainerShape.Elements = new List<PPTShapeBase>();
+            foreach (var shap in children) {
+                if (shap is DocumentFormat.OpenXml.Presentation.ConnectionShape ConnectionShape) {
+                    //p:cxnSp
+                    pptContainerShape.Elements.Add(new PPTConnectionShape(openXmlPart, ConnectionShape));
+                }
+                if (shap is DocumentFormat.OpenXml.Presentation.GraphicFrame GraphicFrame)
+                {
+                    //p:graphicFrame  Chart, Diagram, Table
+                    pptContainerShape.Elements.Add(new PPTGraphicFrame(openXmlPart, GraphicFrame));
+                }
+                if (shap is DocumentFormat.OpenXml.AlternateContent alternateContent)
+                {
+                    ///Equations and formulas as Image  处理公式 方程等
+                  
+                    var element = alternateContent.ChildElements.Where(x => typeof(AlternateContentFallback).Equals(x.GetType())).FirstOrDefault();
+                    if (element != null)
+                    {
+                        AlternateContentFallback alternateContentFallback = (AlternateContentFallback)element;
+                        if (alternateContentFallback.ChildElements.First() is DocumentFormat.OpenXml.Presentation.Shape shapea)
+                        {
+                            pptContainerShape.Elements.Add(new PPTShape(openXmlPart, shapea, slide));
+                        }
+                        else if (alternateContentFallback.ChildElements.First() is DocumentFormat.OpenXml.Presentation.Picture Picturea)
+                        {
+                            pptContainerShape.Elements.Add(new PPTImage(openXmlPart, Picturea));
+                        }
+                    }
+                    //MathML
+                    // pptContainerShape.Elements.Add(new PPTAlternateContent(slidePart, (AlternateContent)obj, slide));
+                    ///  处理公式 方程等
+                }
+                if (shap is DocumentFormat.OpenXml.Presentation.GroupShape GroupShape)
+                {
+                    //p:grpSp
+                    pptContainerShape.Elements.Add(new PPTGroupShape(openXmlPart, GroupShape,slide));
 
+                }
+                if (shap is DocumentFormat.OpenXml.Presentation.Picture Picture)
+                {
+                    //p:pic
+                    pptContainerShape.Elements.Add(new PPTImage(openXmlPart, Picture));
+                }
+                if (shap is DocumentFormat.OpenXml.Presentation.Shape Shape)
+                {
+                    //p:sp
+                    pptContainerShape.Elements.Add(new PPTShape(openXmlPart, Shape, slide));
+                }
+            }
+            containerShape= pptContainerShape;
         }
-        public List<PPTShapeBase> shapeBases { get; set; } = new List<PPTShapeBase>();
+        public PPTContainerShape containerShape { get; set; } = new PPTContainerShape();
         public DocumentFormat.OpenXml.Presentation.GroupShape element { get; set; }
         private void SetGroupShapeNonVisualProperties(OpenXmlPart slidePart, DocumentFormat.OpenXml.Presentation.GroupShape groupShape)
         {
@@ -52,12 +105,13 @@ namespace HTEXLib.Models.Inner
 
             var nonVisualShapeProp = new PPTNonVisualShapeProp
             {
-                Id = "s1s" +  //HARD CODED: we split it into separate HTML files!
+                Id = PartForm + "PPTGroupShape" +                                   
                 groupShape.NonVisualGroupShapeProperties.NonVisualDrawingProperties.Id,
                 Name = groupShape.LocalName,
                 Type = "PPTGroupShape"
             };
             base.NonVisualShapeProp = nonVisualShapeProp;
+            
         }
 
         private void SetGroupShapeVisualProperties(OpenXmlPart openXmlPart, DocumentFormat.OpenXml.Presentation.GroupShape groupShape)
@@ -95,5 +149,4 @@ namespace HTEXLib.Models.Inner
             }
         }
     }
-
 }

+ 1 - 1
HTEXLib/Models/PPTX/PPTImage.cs

@@ -126,7 +126,7 @@ namespace HTEXLib.Models.Inner
                 }
             var nonVisualShapeProp = new PPTNonVisualShapeProp
             {
-                Id = "s1s" + //HARD CODED: we split it into separate HTML files!
+                Id = PartForm + "PPTImage" +
                                                   shape.NonVisualPictureProperties.NonVisualDrawingProperties.Id,
                 Name = shape.LocalName,
                 Type = "PPTImage"

+ 9 - 0
HTEXLib/Models/PPTX/PPTParagraph.cs

@@ -327,10 +327,19 @@ namespace HTEXLib.Models.Inner
                 else
                 {
                     var latinFonts = font.GetFirstChild<LatinFont>();
+                    var EastAsianFont = font.GetFirstChild<EastAsianFont>();
+                    var ComplexScriptFont = font.GetFirstChild<ComplexScriptFont>();
                     if (latinFonts != null)
                     {
                         bulletProp.ReadFontFamilyFromTheme(latinFonts);
                     }
+                    if (EastAsianFont != null) {
+                        bulletProp.ReadFontFamilyFromTheme(EastAsianFont);
+                    }
+                    if (ComplexScriptFont != null)
+                    {
+                        bulletProp.ReadFontFamilyFromTheme(ComplexScriptFont);
+                    }
                 }
             }
             else

+ 31 - 3
HTEXLib/Models/PPTX/PPTRunProperties.cs

@@ -107,9 +107,18 @@ namespace HTEXLib.Models.Inner
                     Spacing = runProperties.Spacing.Value;
                 }
 
-                var latinFonts = runProperties.GetFirstChild<LatinFont>();
                 var coplexScriptFonts = runProperties.Descendants<ComplexScriptFont>();
-
+                var latinFonts = runProperties.GetFirstChild<LatinFont>();
+                var EastAsianFont = runProperties.GetFirstChild<EastAsianFont>();
+                var ComplexScriptFont = runProperties.GetFirstChild<ComplexScriptFont>();
+                if (EastAsianFont != null)
+                {
+                    this.ReadFontFamilyFromTheme(EastAsianFont);
+                }
+                if (ComplexScriptFont != null)
+                {
+                    this.ReadFontFamilyFromTheme(ComplexScriptFont);
+                }
                 if (latinFonts != null)
                 {
                     this.ReadFontFamilyFromTheme(latinFonts);
@@ -157,6 +166,25 @@ namespace HTEXLib.Models.Inner
                 }
                 var latinFonts = defRun.GetFirstChild<LatinFont>();
                 this.ReadFontFamilyFromTheme(latinFonts);
+                var coplexScriptFonts = defRun.Descendants<ComplexScriptFont>();
+                var EastAsianFont = defRun.GetFirstChild<EastAsianFont>();
+                var ComplexScriptFont = defRun.GetFirstChild<ComplexScriptFont>();
+                if (EastAsianFont != null)
+                {
+                    this.ReadFontFamilyFromTheme(EastAsianFont);
+                }
+                if (ComplexScriptFont != null)
+                {
+                    this.ReadFontFamilyFromTheme(ComplexScriptFont);
+                }
+                if (latinFonts != null)
+                {
+                    this.ReadFontFamilyFromTheme(latinFonts);
+                }
+                else if (coplexScriptFonts.GetEnumerator().Current != null)
+                {
+                    FontFamily = coplexScriptFonts.GetEnumerator().Current.Typeface;
+                }
             }
         }
 
@@ -186,7 +214,7 @@ namespace HTEXLib.Models.Inner
             }
         }
 
-        public void ReadFontFamilyFromTheme(LatinFont latinFonts)
+        public void ReadFontFamilyFromTheme(TextFontType latinFonts)
         {
             FontScheme allSchemeFonts =
                     slide.SlideLayoutPart.SlideMasterPart.ThemePart.Theme

+ 1 - 1
HTEXLib/Models/PPTX/PPTShape.cs

@@ -76,7 +76,7 @@ namespace HTEXLib.Models.Inner
 
             var nonVisualShapeProp = new PPTNonVisualShapeProp
             {
-                Id = "s1s" + //HARD CODED: we split it into separate HTML files!
+                Id = PartForm + "PPTShape" +
                                                   shape.NonVisualShapeProperties.NonVisualDrawingProperties.Id,
                 Name = shape.LocalName,
                 Type = "PPTShape"