Kaynağa Gözat

1.PPT优化属性,去掉不必要的属性。
2.PPT解析优化多余的代码。
3.优化SVG路径中边框,填充。
4.移除PPT解析样式表,保证单页PPT元素的属性样式完整,可以被分享共用。

CrazyIter 5 yıl önce
ebeveyn
işleme
c29737ad5c

+ 3 - 5
TEAMModelOS.Service/Models/PowerPoint/Connector.cs

@@ -12,11 +12,9 @@ namespace HiTeachCC.Model.PowerPoint
         ///连接线 p:cxnSp
         /// </summary>
         public string CxnType { get; set; }
-        public string HeadEnd { get; set; }
-        public string TailEnd { get; set; }
-        [Newtonsoft.Json.JsonIgnore]
-        [System.Text.Json.Serialization.JsonIgnore]
+        //public string HeadEnd { get; set; }
+        //public string TailEnd { get; set; }
         public Border Border { get; set; }
-        public string BorderSha { get; set; }
+      
     }
 }

+ 1 - 0
TEAMModelOS.Service/Models/PowerPoint/Diagram.cs

@@ -6,5 +6,6 @@ namespace HiTeachCC.Model.PowerPoint
 {
     public class Diagram :Item
     {
+        public List<Item> Shapes { get; set; }
     }
 }

+ 10 - 10
TEAMModelOS.Service/Models/PowerPoint/Fill.cs

@@ -8,7 +8,7 @@ namespace HiTeachCC.Model.PowerPoint
     {
 
         public Fill() {
-            gradColor = new List<string>();
+            grad = new List<string>();
         }
         /// <summary>
         /// [a:noFill, solidFill, gradFill, blipFill, pattFill,        grpFill]
@@ -17,21 +17,21 @@ namespace HiTeachCC.Model.PowerPoint
         public int Type { get; set; }
         public string Color { get; set; }
         public string Image { get; set; }
-        public FillStyle FillStyle { get; set; }
-        [Newtonsoft.Json.JsonIgnore]
-        [System.Text.Json.Serialization.JsonIgnore]
-        public string SvgText { get; set; }
-        [Newtonsoft.Json.JsonIgnore]
-        [System.Text.Json.Serialization.JsonIgnore]
-        public string HtmlText { get; set; }
+        public FillStyle Style { get; set; }
+        //[Newtonsoft.Json.JsonIgnore]
+        //[System.Text.Json.Serialization.JsonIgnore]
+        //public string SvgText { get; set; }
+        //[Newtonsoft.Json.JsonIgnore]
+        //[System.Text.Json.Serialization.JsonIgnore]
+        //public string HtmlText { get; set; }
         //渐变填充投射方向
         public double Rot { get; set; }
         //渐变填充  以及前景色 背景色 的图案填充  颜色列表
-        public List<string> gradColor { get; set; }
+        public List<string> grad { get; set; }
         /// <summary>
         /// 图案填充的内置图形 ltDnDiag 等 48种内置图案
         /// </summary>
-        public string pattPrst { get; set; }
+        public string patt { get; set; }
 
     }
     /// <summary>

+ 1 - 1
TEAMModelOS.Service/Models/PowerPoint/FontStyle.cs

@@ -12,7 +12,7 @@ namespace HiTeachCC.Model.PowerPoint
         /// kerning、letter-spacing、word-spacing和text-decoration
         /// </summary>
         public string Color { get; set; }
-        public int Size { get; set; }
+        public double Size { get; set; }
         //inherit  继承父级
         public string Family { get; set; }
         public string Weight { get; set; }

+ 3 - 6
TEAMModelOS.Service/Models/PowerPoint/Math.cs

@@ -8,13 +8,10 @@ namespace HiTeachCC.Model.PowerPoint
     {
     
         public string Content { get; set; }
-        [Newtonsoft.Json.JsonIgnore]
-        [System.Text.Json.Serialization.JsonIgnore]
+        
         public Fill Fill { get; set; }
-        [Newtonsoft.Json.JsonIgnore]
-        [System.Text.Json.Serialization.JsonIgnore]
+        
         public Border Border { get; set; }
-        public string BorderSha { get; set; }
-        public string FillSha { get; set; }
+      
     }
 }

+ 3 - 6
TEAMModelOS.Service/Models/PowerPoint/Media.cs

@@ -12,13 +12,10 @@ namespace HiTeachCC.Model.PowerPoint
         public string Url { get; set; }
         //图片或视频音频缩略图链接
         public string Image { get; set; }
-        [Newtonsoft.Json.JsonIgnore]
-        [System.Text.Json.Serialization.JsonIgnore]
+     
         public Fill Fill { get; set; }
-        [Newtonsoft.Json.JsonIgnore]
-        [System.Text.Json.Serialization.JsonIgnore]
+      
         public Border Border { get; set; }
-        public string BorderSha { get; set; }
-        public string FillSha { get; set; }
+     
     }
 }

+ 13 - 17
TEAMModelOS.Service/Models/PowerPoint/Paragraph.cs

@@ -6,38 +6,34 @@ namespace HiTeachCC.Model.PowerPoint
 {
     public class Paragraph
     {
-        [Newtonsoft.Json.JsonIgnore]
-        [System.Text.Json.Serialization.JsonIgnore]
-        public ParagraphStyle ParagraphStyle { get; set; }
+         
+        public ParagraphStyle Style { get; set; }
         public Paragraph() {
             Texts = new List<Text>();
         }
-        [Newtonsoft.Json.JsonIgnore]
-        [System.Text.Json.Serialization.JsonIgnore]
+ 
         public BuChar BuChar { get; set; }
         public List<Text> Texts { get; set; }
-        public string BuCharSha { get; set; }
-        public string StyleSha { get; set; }
+       
     }
     public class Text
     {
-        public string StyleSha { get; set; }
+      //  public string StyleSha { get; set; }
         public string Content { get; set; }
         public string Href { get; set; }
         public bool Isbr { get; set; } = false;
-        [Newtonsoft.Json.JsonIgnore]
-        [System.Text.Json.Serialization.JsonIgnore]
-        public FontStyle FontStyle { get; set; }
+        
+        public FontStyle Style { get; set; }
     }
 
     public class BuChar {
         //TYPE_BULPIC  TYPE_NUMERIC TYPE_BULLET  TYPE_NONE  没有图标的 只有缩进
         public string Type{ get; set; }
-        public double MarginLeft { get; set; }
-        public double MarginRiht { get; set; }
+        public double Left { get; set; }
+        public double Riht { get; set; }
         public string Buchar { get; set; }
         public string Typeface { get; set; }
-        public int  FontSize { get; set; }
+        public double  Size { get; set; }
         public string Float { get; set; }
         /// <summary>
         /// ltr	默认。文本方向从左到右
@@ -49,10 +45,10 @@ namespace HiTeachCC.Model.PowerPoint
 
     public class ParagraphStyle
     {
-        public string VertAlign { get; set; }
+        public string Vert { get; set; }
         // public string LeftMargin { get; set; }
-        public string HoriAlign { get; set; }
-        public string WritingMode { get; set; }
+        public string Hori { get; set; }
+        public string Writing { get; set; }
       
     }
 }

+ 0 - 100
TEAMModelOS.Service/Models/PowerPoint/Path.cs

@@ -1,100 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace HiTeachCC.Model.PowerPoint
-{
-    public abstract class Path
-    {   
-        double w { get; set; }
-        double h { get; set; }
-        public string Type { get; set; }
-    }
-    public   class ClosePath :Path
-    {
-        public bool Close { get; set; } = false;
-    }
-
-    /// <summary>
-    /// 起点 <a:moveTo>
-    /// </summary>
-    public class MoveToPath : Path
-    {
-        public double Mx { get; set; }
-        public double My { get; set; }
-        //public MoveToPath()
-        //{
-        //    Pts = new List<Point> { };
-        //}
-        //public List<Point> Pts { get; set; }
-    }
-    /// <summary>
-    /// 弧形 <a:arcTo>
-    /// </summary>
-    public class ArcToPath : Path
-    {
-        public double WidthRadius { get; set; }
-        public double HeightRadius { get; set; }
-        public double StartAngle { get; set; }
-        public double SwingAngle { get; set; }
-        //public string X { get; set; }
-        //public string Y { get; set; }
-    }
-
-
-    /// <summary>
-    /// 画线 <a:lnTo>
-    /// </summary>
-    public class LineToPath : Path
-    {
-        public double Lx { get; set; }
-        public double Ly { get; set; }
-        //public LineToPath()
-        //{
-        //    Pts = new List<Point> { };
-        //}
-        //public List<Point> Pts { get; set; }
-    }
-    /// <summary>
-    /// 三次贝塞尔曲线<a:cubicBezTo>
-    /// </summary>
-    public class CubicBezPath : Path
-    {
-        public double Cx1 { get; set; }
-        public double Cy1 { get; set; }
-
-        public double Cx2 { get; set; }
-        public double Cy2 { get; set; }
-
-        public double Cx3 { get; set; }
-        public double Cy3 { get; set; }
-
-
-        //public CubicBezPath()
-        //{
-        //    Pts = new List<Point> { };
-        //}
-        //public List<Point> Pts { get; set; }
-    }/// <summary>
-     /// 二次贝塞尔曲线  <a:quadBezTo>
-     /// </summary>
-    public class QuadBezPath : Path
-    {
-        public double Cx1 { get; set; }
-        public double Cy1 { get; set; }
-
-        public double Cx2 { get; set; }
-        public double Cy2 { get; set; }
-        //public QuadBezPath()
-        //{
-        //    Pts = new List<Point> { };
-        //}
-        //public List<Point> Pts { get; set; }
-    }
-
-    public class Point
-    {
-        public double X { get; set; }
-        public double Y { get; set; }
-    }
-}

+ 17 - 17
TEAMModelOS.Service/Models/PowerPoint/Pptx.cs

@@ -7,31 +7,31 @@ namespace HiTeachCC.Model.PowerPoint
     public class Pptx
     {
         public Pptx() {
-            slides = new List<Slide>();
-            size = new PptSize();
-            FontStyles = new Dictionary<string, FontStyle>();
-            Fills = new Dictionary<string, Fill>();
-            ParagraphStyles = new Dictionary<string, ParagraphStyle>();
-            BuChars = new Dictionary<string, BuChar>();
-            Borders = new Dictionary<string, Border>();
+            //slides = new List<Slide>();
+            //size = new PptSize();
+            //FontStyles = new Dictionary<string, FontStyle>();
+            //Fills = new Dictionary<string, Fill>();
+            //ParagraphStyles = new Dictionary<string, ParagraphStyle>();
+            //BuChars = new Dictionary<string, BuChar>();
+            //Borders = new Dictionary<string, Border>();
 
         }
-        public PptSize size { get; set; }
+        public PptSize Size { get; set; }
         //缩略图
         public string Thumbnail { get; set; }
         //PPT幻灯片集合
-        public List<string> HiXmls { get; set; }
-        public List<Slide> slides { get; set; }
-        public string PptUrl { get; set; }
+        //  public List<string> HiXmls { get; set; }
+        public List<Slide> Slides { get; set; }
+        // public string PptUrl { get; set; }
         public string Sha1Code { get; set; }
         //页数
-        public int PageSize { get; set; }
+        public int Page { get; set; }
 
-        public Dictionary<string, FontStyle> FontStyles { get;set;}
-        public Dictionary<string, Fill> Fills { get; set; }
-        public Dictionary<string, ParagraphStyle> ParagraphStyles { get; set; }
-        public Dictionary<string, BuChar> BuChars { get; set; }
-        public Dictionary<string, Border> Borders { get; set; }
+        //public Dictionary<string, FontStyle> FontStyles { get;set;}
+        //public Dictionary<string, Fill> Fills { get; set; }
+        //public Dictionary<string, ParagraphStyle> ParagraphStyles { get; set; }
+        //public Dictionary<string, BuChar> BuChars { get; set; }
+        //public Dictionary<string, Border> Borders { get; set; }
     }
     public class PptSize {
         //宽度

+ 20 - 33
TEAMModelOS.Service/Models/PowerPoint/Shape.cs

@@ -8,52 +8,45 @@ namespace HiTeachCC.Model.PowerPoint
     { 
         public string ShapeType;
         public List<Paragraph> Paragraph { get; set; }
-        [Newtonsoft.Json.JsonIgnore]
-        [System.Text.Json.Serialization.JsonIgnore]
         public Fill Fill { get; set; }
-        [Newtonsoft.Json.JsonIgnore]
-        [System.Text.Json.Serialization.JsonIgnore]
         public Border Border { get; set; }
        
-        public List<ShapeGuide> ShapeGuides { get; set; }
-        public List<Path> Paths { get; set; }
-        public string BorderSha { get; set; }
-        public string FillSha { get; set; }
+        //public List<ShapeGuide> ShapeGuides { get; set; }
+        //public List<Path> Paths { get; set; }
+        //public string BorderSha { get; set; }
+        //public string FillSha { get; set; }
 
     }
 
     public class Svg {
         public string Id { get; set; }
-        public string Width { get; set; }
-        public string Height { get; set; }
-        public string Top { get; set; }
-        public string Left { get; set; }
-        public string Style { get; set; }
+        //public string Width { get; set; }
+        //public string Height { get; set; }
+        //public string Top { get; set; }
+        //public string Left { get; set; }
+        //public string Style { get; set; }
         public List<SvgShape> SvgShape { get; set; }
-        [Newtonsoft.Json.JsonIgnore]
-        [System.Text.Json.Serialization.JsonIgnore]
-        public string Defs { get; set; }
-        public string Transform { get; set; }
-        [Newtonsoft.Json. JsonIgnore]
-        [System.Text.Json.Serialization.JsonIgnore]
-        public string SvgData { get; set; }
+        //public string Defs { get; set; }
+      //  public string Transform { get; set; }
+  
+       // public string SvgData { get; set; }
        
     }
 
     public abstract class SvgShape {
         // rect ,circle ,ellipse ,line ,polygon ,polyline ,path
         public string Type { get; set; }
-        public string Style { get; set; }
-        public string Stroke { get; set; }
+       // public string Style { get; set; }
+       // public string Stroke { get; set; }
         //描边的不透明度
        // public string StrokeOpacity { get; set; } = "1";
-        public string StrokeWidth { get; set; }
+      //  public string StrokeWidth { get; set; }
         // 虚线类型描边
-        public string StrokeDasharray { get; set; }
-        public string Fill { get; set; }
+       // public string StrokeDasharray { get; set; }
+       // public string Fill { get; set; }
         public string Transform { get; set; }
-        public string MarkerStart { get; set; }
-        public string MarkerEnd { get; set; }
+        public string Start { get; set; }
+        public string End { get; set; }
         //填充色的不透明度
         //  public string FillOpacity { get; set; } = "1";
     }
@@ -125,10 +118,4 @@ namespace HiTeachCC.Model.PowerPoint
         public string D { get; set; }
     
     }
-    public class ShapeGuide
-    {
-        public string Name { get; set; }
-        public string Fmla { get; set; }
-
-    }
 }

+ 2 - 3
TEAMModelOS.Service/Models/PowerPoint/Slide.cs

@@ -11,10 +11,9 @@ namespace HiTeachCC.Model.PowerPoint
             Item = new List<Item>();
         }
         public List<Item> Item { get; set; }
-        [Newtonsoft.Json.JsonIgnore]
-        [System.Text.Json.Serialization.JsonIgnore]
+      
         public Fill Fill { get; set; }
-        public string FillSha { get; set; }
+  
         public int Index { get; set; }
         //宽度
         public double Width { get; set; }

+ 0 - 14
TEAMModelOS.Service/Models/PowerPoint/Style.cs

@@ -1,14 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.Xml;
-
-namespace HiTeachCC.Model.PowerPoint
-{
-    public class Style
-    {
-        public XmlDocument IdTable { get; set; }
-        public XmlDocument IdxTable { get; set; }
-        public XmlDocument TypeTable { get; set; }
-    }
-}

+ 6 - 11
TEAMModelOS.Service/Models/PowerPoint/Table.cs

@@ -11,7 +11,7 @@ namespace HiTeachCC.Model.PowerPoint
         }
         //内容排版方向 左书写 右书写
         public string Dir { get; set; }
-        public string BorderCollapse { get; set; } = "collapse";
+        public string Collapse { get; set; } = "collapse";
        // public Border Border { get; set; }
        // public Fill Fill { get; set; }
         public List<Tr> Tr { get; set; }
@@ -22,22 +22,17 @@ namespace HiTeachCC.Model.PowerPoint
         {
             Td = new List<Td>();
         }
-        [Newtonsoft.Json.JsonIgnore]
-        [System.Text.Json.Serialization.JsonIgnore]
+       
         public Fill Fill { get; set; }
         public  double height { get; set; }
         public List<Td> Td { get; set; }
-        [Newtonsoft.Json.JsonIgnore]
-        [System.Text.Json.Serialization.JsonIgnore]
-        public List<string> Borders { get; set; }
-        public List<string> BorderSha { get; set; }
-        public string FillSha { get; set; }
+    
+        public List<Border> Borders { get; set; }
     }
     public class Td
     {
         public double width { get; set; }
-        [Newtonsoft.Json.JsonIgnore]
-        [System.Text.Json.Serialization.JsonIgnore]
+    
         public Fill Fill { get; set; }
         public int Rowspan { get; set; }
         public int Colspan { get; set; }
@@ -45,6 +40,6 @@ namespace HiTeachCC.Model.PowerPoint
         public int VMerge { get; set; }
         public int HMerge { get; set; }
         public List<Paragraph> Paragraphs { get; set; }
-        public string FillSha { get; set; }
+      
     }
 }

Dosya farkı çok büyük olduğundan ihmal edildi
+ 262 - 264
TEAMModelOS.Service/Services/PowerPoint/Implement/PowerPointService.cs


+ 15 - 15
TEAMModelOS.Service/Services/PowerPoint/Implement/ShapeHelper.cs

@@ -571,10 +571,10 @@ namespace TEAMModelOS.Service.Services.PowerPoint.Implement
             ty1 = ty1 == 2 ? i * tx1 + l : ty1;
             tx2 = tx2 == 2 ? w - tx1 : tx2;
             ty2 = ty2 == 2 ? h - ty1 : ty2;
-            double x1 = System.Math.Round(tx2 / w * 100 * 100) / 100;
-            double y1 = System.Math.Round(ty2 / h * 100 * 100) / 100;
-            double x2 = System.Math.Round(tx1 / w * 100 * 100) / 100;
-            double y2 = System.Math.Round(ty1 / h * 100 * 100) / 100;
+            double x1 = System.Math.Round(tx2 / w * 100 * 100) / 100.0;
+            double y1 = System.Math.Round(ty2 / h * 100 * 100) / 100.0;
+            double x2 = System.Math.Round(tx1 / w * 100 * 100) / 100.0;
+            double y2 = System.Math.Round(ty1 / h * 100 * 100) / 100.0;
             return new List<double> { x1, y1, x2, y2 };
         }
         public static Fill GetPatternFill(XmlNode node, Dictionary<string, string> slideLayoutClrOvride, XmlNode slideMasterContent, XmlNode themeContent)
@@ -587,7 +587,7 @@ namespace TEAMModelOS.Service.Services.PowerPoint.Implement
                 fgclr = ShapeHelper.ColorToning(fgClr.OuterXml, fgclr);
             }
             
-            fill.gradColor.Add(fgclr);
+            fill.grad.Add(fgclr);
             // 处理背景色
             var bgClr = node.GetTextByPath("a:bgClr");
             string bgclr = GetSolidFill(bgClr, slideLayoutClrOvride, slideMasterContent, themeContent);
@@ -598,9 +598,9 @@ namespace TEAMModelOS.Service.Services.PowerPoint.Implement
             var prst = node.GetTextByPath("@prst");
             if (prst != null)
             {
-                fill.pattPrst = prst.Value;
+                fill.patt = prst.Value;
             }
-            fill.gradColor.Add(bgclr);
+            fill.grad.Add(bgclr);
             return fill;
         }
 
@@ -632,7 +632,7 @@ namespace TEAMModelOS.Service.Services.PowerPoint.Implement
             return new Fill()
             {
                 Type = 2,
-                gradColor = color_ary,
+                grad = color_ary,
                 Rot = rot
             };
         }
@@ -742,7 +742,7 @@ namespace TEAMModelOS.Service.Services.PowerPoint.Implement
             {
                 return 0;
             }
-            return double.Parse(angle.Value) / 60000.00;
+            return double.Parse(angle.Value) / rot60000;
         }
 
         public static XmlNode GetNodesTable(XmlNode id, XmlNode idx, XmlNode type, WarpObj warpObj, string LayoutOrMaster)
@@ -844,7 +844,7 @@ namespace TEAMModelOS.Service.Services.PowerPoint.Implement
                 var tint = solidFill.GetTextByPath("a:srgbClr/a:tint/@val");
                 if (tint != null)
                 {
-                    opcity = double.Parse(tint.Value) / 100000;
+                    opcity = double.Parse(tint.Value) / 100000.0;
                 }
             }
             else if (solidFill.GetTextByPath("a:schemeClr") != null)
@@ -852,7 +852,7 @@ namespace TEAMModelOS.Service.Services.PowerPoint.Implement
                 var tint = solidFill.GetTextByPath("a:schemeClr/a:tint/@val");
                 if (tint != null)
                 {
-                    opcity = double.Parse(tint.Value) / 100000;
+                    opcity = double.Parse(tint.Value) / 100000.0;
                 }
             }
             else if (solidFill.GetTextByPath("a:scrgbClr") != null)
@@ -860,7 +860,7 @@ namespace TEAMModelOS.Service.Services.PowerPoint.Implement
                 var tint = solidFill.GetTextByPath("a:scrgbClr/a:tint/@val");
                 if (tint != null)
                 {
-                    opcity = double.Parse(tint.Value) / 100000;
+                    opcity = double.Parse(tint.Value) / 100000.0;
                 }
 
             }
@@ -869,7 +869,7 @@ namespace TEAMModelOS.Service.Services.PowerPoint.Implement
                 var tint = solidFill.GetTextByPath("a:prstClr/a:tint/@val");
                 if (tint != null)
                 {
-                    opcity = double.Parse(tint.Value) / 100000;
+                    opcity = double.Parse(tint.Value) / 100000.0;
                 }
             }
             else if (solidFill.GetTextByPath("a:hslClr") != null)
@@ -877,7 +877,7 @@ namespace TEAMModelOS.Service.Services.PowerPoint.Implement
                 var tint = solidFill.GetTextByPath("a:hslClr/a:tint/@val");
                 if (tint != null)
                 {
-                    opcity = double.Parse(tint.Value) / 100000;
+                    opcity = double.Parse(tint.Value) / 100000.0;
                 }
             }
             else if (solidFill.GetTextByPath("a:sysClr") != null)
@@ -885,7 +885,7 @@ namespace TEAMModelOS.Service.Services.PowerPoint.Implement
                 var tint = solidFill.GetTextByPath("a:sysClr/a:tint/@val");
                 if (tint != null)
                 {
-                    opcity = double.Parse(tint.Value) / 100000;
+                    opcity = double.Parse(tint.Value) / 100000.0;
                 }
             }
             return opcity;

Dosya farkı çok büyük olduğundan ihmal edildi
+ 583 - 583
TEAMModelOS.Service/Services/PowerPoint/Implement/ShapeSvg.cs