Procházet zdrojové kódy

调整形状的SVG的路径。将Rect,Line,Polyline,Polygon,Ellipse都转成svg path

CrazyIter_Bin před 4 roky
rodič
revize
f351082832

+ 3 - 3
HTEXLib/HTEXLib.csproj

@@ -4,9 +4,9 @@
     <Description>PPTX&amp;DOCX解析</Description>
     <PackageReleaseNotes>PPTX&amp;DOCX解析</PackageReleaseNotes>
     <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
-    <Version>2.0.2</Version>
-    <AssemblyVersion>2.0.2.2</AssemblyVersion>
-    <FileVersion>2.0.2.2</FileVersion>
+    <Version>2.0.4</Version>
+    <AssemblyVersion>2.0.4.4</AssemblyVersion>
+    <FileVersion>2.0.4.4</FileVersion>
   </PropertyGroup>
   <ItemGroup>
     <PackageReference Include="DocumentFormat.OpenXml" Version="2.11.3" />

+ 8 - 8
HTEXLib/PPTX/Builders/HtexBuilder.cs

@@ -25,10 +25,10 @@ namespace HTEXLib.Builders
             {
                 return 1;
             }
-            else if (SlideSizes.Cx < Globals.px914400)
-            {
-                return Globals.px914400  *1.0/ SlideSizes.Cx *Globals.px96;
-            }
+            //else if (SlideSizes.Cx < Globals.px914400)
+            //{
+            //    return Globals.px914400  *1.0/ SlideSizes.Cx *Globals.px96;
+            //}
             else
             {
                 return SlideSizes.Cx*1.0 * Globals.px96 / Globals.px914400;
@@ -41,10 +41,10 @@ namespace HTEXLib.Builders
             {
                 return 1;
             }
-            else if (SlideSizes.Cy < Globals.px914400)
-            {
-                return Globals.px12700 *1.0   / SlideSizes.Cy * Globals.px96;
-            }
+            //else if (SlideSizes.Cy < Globals.px914400)
+            //{
+            //    return Globals.px12700 *1.0   / SlideSizes.Cy * Globals.px96;
+            //}
             else
             {
                 return SlideSizes.Cy *1.0 * Globals.px96 / Globals.px914400;

+ 178 - 136
HTEXLib/PPTX/Helpers/ShapeHelpers/SvgHelper.cs

@@ -20,8 +20,8 @@ namespace HTEXLib.Helpers
         public static Svg GenShapeSvg(OpenXmlElement node, string shapeType, Position position, Border shapeBorder) {
             int? isFlipV = position.flipV;
             string shapType = shapeType;
-            double w = System.Math.Round(position.cy, degree);
-            double h = System.Math.Round(position.cx, degree);  ;
+            double w = System.Math.Round(position.cx, degree);
+            double h = System.Math.Round(position.cy, degree);  ;
             GenShapeDelegate genShapeDelegate;
             Svg resultSvg = null;
             Border border = shapeBorder;
@@ -929,7 +929,7 @@ namespace HTEXLib.Helpers
 
             }
             var shapAdjst_val = 0.5;
-            string points;
+            string points="M";
             //  string MarkerStart = "";
             // string MarkerEnd = "";
             if (shapAdjst != null)
@@ -937,31 +937,32 @@ namespace HTEXLib.Helpers
                 shapAdjst_val = double.Parse(shapAdjst.Value.Substring(4)) * 1.0 / 100000;
                 if (isFlipV == 1)
                 {
-                    points = w + " 0," + ((1 - shapAdjst_val) * w) + " 0," + ((1 - shapAdjst_val) * w) + " " + h + ",0 " + h;
+                    points = w + " 0,L" + ((1 - shapAdjst_val) * w) + " 0,L" + ((1 - shapAdjst_val) * w) + " " + h + ",L0 " + h;
                 }
                 else
                 {
-                    points = "0 0," + (shapAdjst_val) * w + " 0," + (shapAdjst_val) * w + " " + h + "," + w + " " + h;
+                    points = "0 0,L" + (shapAdjst_val) * w + " 0,L" + (shapAdjst_val) * w + " " + h + ",L" + w + " " + h;
                 }
             }
             else
             {
                 if (isFlipV == 1)
                 {
-                    points = w + " 0," + ((1 - shapAdjst_val) * w) + " 0," + ((1 - shapAdjst_val) * w) + " " + h + ",0 " + h;
+                    points = w + " 0,L" + ((1 - shapAdjst_val) * w) + " 0,L" + ((1 - shapAdjst_val) * w) + " " + h + ",L0 " + h;
                 }
                 else
                 {
-                    points = "0 0," + (shapAdjst_val) * w + " 0," + (shapAdjst_val) * w + " " + h + "," + w + " " + h;
+                    points = "0 0,L" + (shapAdjst_val) * w + " 0,L" + (shapAdjst_val) * w + " " + h + ",L" + w + " " + h;
                 }
             }
-            List<SvgShape> shapes = new List<SvgShape>() {new Polyline {
-                type = "polyline",
+            List<SvgShape> shapes = new List<SvgShape>() {new SvgPath {
+                type = "path",
                 //Fill = "transparent",
                // Stroke = "#" + border.Color,
                 // StrokeWidth = border.Width ,
                 // StrokeDasharray = border.Stroke,
-                points=points,
+                //points=points,
+                d=points,
                  start=border.headEnd,
                 end=border.tailEnd,
             } };
@@ -997,12 +998,12 @@ namespace HTEXLib.Helpers
 
             }
             double adj2 = (1 - adj1);
-            List<SvgShape> shapes = new List<SvgShape>() {new Polygon {
-                type = "polygon",
+            List<SvgShape> shapes = new List<SvgShape>() {new SvgPath {
+                type = "path",
 
-                points= adj1 * w + " 0," + adj1 * w + " " + adj1 * h + ",0 " + adj1 * h + ",0 " + adj2 * h + "," +
-                                adj1 * w + " " + adj2 * h + "," + adj1 * w + " " + h + "," + adj2 * w + " " + h + "," + adj2 * w + " " + adj2 * h + "," + w + " " + adj2 * h + "," +
-                                +w + " " + adj1 * h + "," + adj2 * w + " " + adj1 * h + "," + adj2 * w + " 0",
+                d= "M"+adj1 * w + " 0,L" + adj1 * w + " " + adj1 * h + ",L0 " + adj1 * h + ",L0 " + adj2 * h + ",L" +
+                                adj1 * w + " " + adj2 * h + ",L" + adj1 * w + " " + h + ",L" + adj2 * w + " " + h + ",L" + adj2 * w + " " + adj2 * h + ",L" + w + " " + adj2 * h + ",L" +
+                                +w + " " + adj1 * h + ",L" + adj2 * w + " " + adj1 * h + ",L" + adj2 * w + " 0 z",
             } };
             return new Svg { svgShape = shapes };
         }
@@ -3387,16 +3388,25 @@ namespace HTEXLib.Helpers
                 Y1 = 0;
                 Y2 = h;
             }
-            List<SvgShape> shapes = new List<SvgShape>() {new Line {
-                type = "line",
+            //List<SvgShape> shapes = new List<SvgShape>() {new Line {
+            //    type = "line",
+            //    start=border.headEnd,
+            //    end=border.tailEnd,
+            //    x1=X1,
+            //    x2=X2,
+            //    y1=Y1,
+            //    y2=Y2
+            //} };
+            List<SvgShape> shapes = new List<SvgShape>() {new SvgPath {
+                type = "path",
                 start=border.headEnd,
                 end=border.tailEnd,
-                x1=X1,
-                x2=X2,
-                y1=Y1,
-                y2=Y2
+                d="M"+X1+" "+Y1+",L"+X2+" "+ Y2,
+                //x1=X1,
+                //x2=X2,
+                //y1=Y1,
+                //y2=Y2
             } };
-
             return new Svg { svgShape = shapes };
         }
         /// <summary>
@@ -3530,11 +3540,11 @@ namespace HTEXLib.Helpers
                 }
             }
            
-            List<SvgShape> shapes = new List<SvgShape>() {new Polygon {
-                type = "polygon",
+            List<SvgShape> shapes = new List<SvgShape>() {new SvgPath {
+                type = "path",
 
-                points= w + " " + h * 1.0 / 2 + "," + sAdj2_val * w + " 0," + sAdj2_val * w + " " + sAdj1_val * h + ",0 " + sAdj1_val * h +
-                                ",0 " + (1 - sAdj1_val) * h + "," + sAdj2_val * w + " " + (1 - sAdj1_val) * h + ", " + sAdj2_val * w + " " + h ,
+                d="M"+ w + " " + h * 1.0 / 2 + ",L" + sAdj2_val * w + " 0,L" + sAdj2_val * w + " " + sAdj1_val * h + ",L0 " + sAdj1_val * h +
+                                ",L0 " + (1 - sAdj1_val) * h + ",L" + sAdj2_val * w + " " + (1 - sAdj1_val) * h + ",L" + sAdj2_val * w + " " + h+" z" ,
             } };
             return new Svg { svgShape = shapes };
         }
@@ -3579,11 +3589,10 @@ namespace HTEXLib.Helpers
                 }
             }
             
-            List<SvgShape> shapes = new List<SvgShape>() {new Polygon {
-                type = "polygon",
-
-                points= "0 " + h * 1.0 / 2 + "," + sAdj2_val * w + " " + h + "," + sAdj2_val * w + " " + (1 - sAdj1_val) * h + "," + w + " " + (1 - sAdj1_val) * h +
-                                "," + w + " " + sAdj1_val * h + "," + sAdj2_val * w + " " + sAdj1_val * h + ", " + sAdj2_val * w + " 0",
+            List<SvgShape> shapes = new List<SvgShape>() {new SvgPath {
+                type = "path",
+                d= "M0 " + h * 1.0 / 2 + ",L" + sAdj2_val * w + " " + h + ",L" + sAdj2_val * w + " " + (1 - sAdj1_val) * h + ",L" + w + " " + (1 - sAdj1_val) * h +
+                                ",L" + w + " " + sAdj1_val * h + ",L" + sAdj2_val * w + " " + sAdj1_val * h + ",L" + sAdj2_val * w + " 0 z",
             } };
             return new Svg { svgShape = shapes };
         }
@@ -3632,11 +3641,11 @@ namespace HTEXLib.Helpers
                 sAdj2_val = 0.212;
             }
            
-            List<SvgShape> shapes = new List<SvgShape>() {new Polygon {
-                type = "polygon",
+            List<SvgShape> shapes = new List<SvgShape>() {new SvgPath {
+                type = "path",
 
-                points= (0.5 - sAdj1_val) * w + " 0," + (0.5 - sAdj1_val) * w + " " + (1 - sAdj2_val) * h + ",0 " + (1 - sAdj2_val) * h + "," + (w * 1.0 / 2) + " " + h +
-                                "," + w + " " + (1 - sAdj2_val) * h + "," + (0.5 + sAdj1_val) * w + " " + (1 - sAdj2_val) * h + ", " + (0.5 + sAdj1_val) * w + " 0",
+                d= "M"+(0.5 - sAdj1_val) * w + " 0,L" + (0.5 - sAdj1_val) * w + " " + (1 - sAdj2_val) * h + ",L0 " + (1 - sAdj2_val) * h + ",L" + (w * 1.0 / 2) + " " + h +
+                                ",L" + w + " " + (1 - sAdj2_val) * h + ",L" + (0.5 + sAdj1_val) * w + " " + (1 - sAdj2_val) * h + ",L " + (0.5 + sAdj1_val) * w + " 0 z",
             } };
             return new Svg { svgShape = shapes };
         }
@@ -3695,11 +3704,11 @@ namespace HTEXLib.Helpers
                     }
                 }
             }
-            List<SvgShape> shapes = new List<SvgShape>() {new Polygon {
-                type = "polygon",
+            List<SvgShape> shapes = new List<SvgShape>() {new SvgPath {
+                type = "path",
 
-                points=   (w * 1.0 / 2) + " 0,0 " + sAdj2_val * h + "," + (0.5 - sAdj1_val) * w + " " + sAdj2_val * h + "," + (0.5 - sAdj1_val) * w + " " + h +
-                                "," + (0.5 + sAdj1_val) * w + " " + h + "," + (0.5 + sAdj1_val) * w + " " + sAdj2_val * h + ", " + w + " " + sAdj2_val * h ,
+                d=   "M"+(w * 1.0 / 2) + " 0,0 " + sAdj2_val * h + ",L" + (0.5 - sAdj1_val) * w + " " + sAdj2_val * h + ",L" + (0.5 - sAdj1_val) * w + " " + h +
+                                ",L" + (0.5 + sAdj1_val) * w + " " + h + ",L" + (0.5 + sAdj1_val) * w + " " + sAdj2_val * h + ",L" + w + " " + sAdj2_val * h +" z" ,
             } };
             return new Svg { svgShape = shapes };
         }
@@ -3742,11 +3751,11 @@ namespace HTEXLib.Helpers
                     }
                 }
             }
-            List<SvgShape> shapes = new List<SvgShape>() {new Polygon {
-                type = "polygon",
-                points= "0 " + h * 1.0 / 2 + "," + sAdj2_val * w + " " + h + "," + sAdj2_val * w + " " + (1 - sAdj1_val) * h + "," + (1 - sAdj2_val) * w + " " + (1 - sAdj1_val) * h +
-                                "," + (1 - sAdj2_val) * w + " " + h + "," + w + " " + h * 1.0 / 2 + ", " + (1 - sAdj2_val) * w + " 0," + (1 - sAdj2_val) * w + " " + sAdj1_val * h + "," +
-                                sAdj2_val * w + " " + sAdj1_val * h + "," + sAdj2_val * w + " 0",
+            List<SvgShape> shapes = new List<SvgShape>() {new SvgPath {
+                type = "path",
+                d= "M0 " + h * 1.0 / 2 + ",L" + sAdj2_val * w + " " + h + ",L" + sAdj2_val * w + " " + (1 - sAdj1_val) * h + ",L" + (1 - sAdj2_val) * w + " " + (1 - sAdj1_val) * h +
+                                ",L" + (1 - sAdj2_val) * w + " " + h + ",L" + w + " " + h * 1.0 / 2 + ",L" + (1 - sAdj2_val) * w + " 0,L" + (1 - sAdj2_val) * w + " " + sAdj1_val * h + ",L" +
+                                sAdj2_val * w + " " + sAdj1_val * h + ",L" + sAdj2_val * w + " 0 z",
             } };
             return new Svg { svgShape = shapes };
         }
@@ -3777,12 +3786,12 @@ namespace HTEXLib.Helpers
                     }
                 }
             }
-            List<SvgShape> shapes = new List<SvgShape>() {new Polygon {
-                type = "polygon",
+            List<SvgShape> shapes = new List<SvgShape>() {new SvgPath {
+                type = "path",
 
-                points= w * 1.0 / 2 + " 0,0 " + sAdj2_val * h + "," + sAdj1_val * w + " " + sAdj2_val * h + "," + sAdj1_val * w + " " + (1 - sAdj2_val) * h +
-                                ",0 " + (1 - sAdj2_val) * h + "," + w * 1.0 / 2 + " " + h + ", " + w + " " + (1 - sAdj2_val) * h + "," + (1 - sAdj1_val) * w + " " + (1 - sAdj2_val) * h + "," +
-                                (1 - sAdj1_val) * w + " " + sAdj2_val * h + "," + w + " " + sAdj2_val * h ,
+                d="M"+ w * 1.0 / 2 + " 0,L0 " + sAdj2_val * h + "," + sAdj1_val * w + " " + sAdj2_val * h + ",L" + sAdj1_val * w + " " + (1 - sAdj2_val) * h +
+                                ",L0 " + (1 - sAdj2_val) * h + ",L" + w * 1.0 / 2 + " " + h + ",L" + w + " " + (1 - sAdj2_val) * h + ",L" + (1 - sAdj1_val) * w + " " + (1 - sAdj2_val) * h + ",L" +
+                                (1 - sAdj1_val) * w + " " + sAdj2_val * h + ",L" + w + " " + sAdj2_val * h+" z" ,
             } };
             return new Svg { svgShape = shapes };
         }
@@ -8075,10 +8084,9 @@ namespace HTEXLib.Helpers
             }
 
             string points = ShapeStar(adj, double.Parse(starNum));
-            List<SvgShape> shapes = new List<SvgShape>() {new Polygon {
-                type = "polygon",
-
-                points=points
+            List<SvgShape> shapes = new List<SvgShape>() {new SvgPath {
+                type = "path",
+                d=points
             } };
             return new Svg { svgShape = shapes };
         }
@@ -8089,13 +8097,20 @@ namespace HTEXLib.Helpers
             var numPoints = starNum;/*1-100*/
             var center =System. Math.Max(innerRadius, outerRadius);
             var angle = System.Math.PI * 1.0 / numPoints;
-            var points = "";
-
-            for (var i = 0; i < numPoints * 2; i++)
+            var points = "M";
+            var len = numPoints * 2;
+            for (var i = 0; i < len; i++)
             {
                 var radius = ((i % 2) > 0) ? innerRadius : outerRadius;
-                points += center + radius * System.Math.Sin(i * angle);
-                points += center - radius * System.Math.Cos(i * angle);
+                points += center + radius * System.Math.Sin(i * angle)+" ";
+                if (i == len - 1)
+                {
+                    points += center - radius * System.Math.Cos(i * angle) + " z";
+                }
+                else {
+                    points += center - radius * System.Math.Cos(i * angle) + ",L";
+                }
+              
             }
 
             return points;
@@ -8115,10 +8130,10 @@ namespace HTEXLib.Helpers
         /// <returns></returns>
         private static Svg Dodecagon(OpenXmlElement node, string shapType, double w, double h, Border border)
         {
-            List<SvgShape> shapes = new List<SvgShape>() {new Polygon {
-                type = "polygon",
-                points= (3 * 1.0 / 8) * w + " 0," + w * 1.0 / 8 + " " + h * 1.0 / 8 + ",0 " + (3 * 1.0 / 8) * h + ",0 " + (5 * 1.0 / 8) * h + "," + w * 1.0 / 8 + " " + (7 * 1.0 / 8) * h + "," + (3 * 1.0 / 8) * w + " " + h + "," +
-                        (5 * 1.0 / 8) * w + " " + h + "," + (7 * 1.0 / 8) * w + " " + (7 * 1.0 / 8) * h + "," + w + " " + (5 * 1.0 / 8) * h + "," + w + " " + (3 * 1.0 / 8) * h + "," + (7 * 1.0 / 8) * w + " " + h * 1.0 / 8 + "," + (5 * 1.0 / 8) * w + " 0"
+            List<SvgShape> shapes = new List<SvgShape>() {new SvgPath {
+                type = "path",
+                d= "M"+(3 * 1.0 / 8) * w + " 0,L" + w * 1.0 / 8 + " " + h * 1.0 / 8 + ",L0 " + (3 * 1.0 / 8) * h + ",L0 " + (5 * 1.0 / 8) * h + ",L" + w * 1.0 / 8 + " " + (7 * 1.0 / 8) * h + ",L" + (3 * 1.0 / 8) * w + " " + h + ",L" +
+                        (5 * 1.0 / 8) * w + " " + h + ",L" + (7 * 1.0 / 8) * w + " " + (7 * 1.0 / 8) * h + ",L" + w + " " + (5 * 1.0 / 8) * h + ",L" + w + " " + (3 * 1.0 / 8) * h + ",L" + (7 * 1.0 / 8) * w + " " + h * 1.0 / 8 + ",L" + (5 * 1.0 / 8) * w + " 0 z"
             } };
             return new Svg { svgShape = shapes };
         }
@@ -8137,10 +8152,10 @@ namespace HTEXLib.Helpers
         /// <returns></returns>
         private static Svg Decagon(OpenXmlElement node, string shapType, double w, double h, Border border)
         {
-            List<SvgShape> shapes = new List<SvgShape>() {new Polygon {
-                type = "polygon",
-                points= (3 * 1.0 / 8) * w + " 0," + w * 1.0 / 8 + " " + h * 1.0 / 8 + ",0 " + h * 1.0 / 2 + "," + w * 1.0 / 8 + " " + (7 * 1.0 / 8) * h + "," + (3 * 1.0 / 8) * w + " " + h + "," +
-                        (5 * 1.0 / 8) * w + " " + h + "," + (7 * 1.0 / 8) * w + " " + (7 * 1.0 / 8) * h + "," + w + " " + h * 1.0 / 2 + "," + (7 * 1.0 / 8) * w + " " + h * 1.0 / 8 + "," + (5 * 1.0 / 8) * w + " 0"
+            List<SvgShape> shapes = new List<SvgShape>() {new SvgPath {
+                type = "path",
+                d="M"+ (3 * 1.0 / 8) * w + " 0,L" + w * 1.0 / 8 + " " + h * 1.0 / 8 + ",L0 " + h * 1.0 / 2 + ",L" + w * 1.0 / 8 + " " + (7 * 1.0 / 8) * h + ",L" + (3 * 1.0 / 8) * w + " " + h + ",L" +
+                        (5 * 1.0 / 8) * w + " " + h + ",L" + (7 * 1.0 / 8) * w + " " + (7 * 1.0 / 8) * h + ",L" + w + " " + h * 1.0 / 2 + ",L" + (7 * 1.0 / 8) * w + " " + h * 1.0 / 8 + ",L" + (5 * 1.0 / 8) * w + " 0 z"
             } };
             return new Svg { svgShape = shapes };
         }
@@ -8175,11 +8190,10 @@ namespace HTEXLib.Helpers
             }
             double adj2 = (1 - adj1);
 
-            List<SvgShape> shapes = new List<SvgShape>() {new Polygon {
-                type = "polygon",
-
-                points= adj1 * w + " 0,0 " + adj1 * h + ",0 " + adj2 * h + "," + adj1 * w + " " + h + "," + adj2 * w + " " + h + "," +
-                    w + " " + adj2 * h + "," + w + " " + adj1 * h + "," + adj2 * w + " 0"
+            List<SvgShape> shapes = new List<SvgShape>() {new SvgPath {
+                type = "path",
+                d= "M"+ adj1 * w + " 0,L0 " + adj1 * h + ",L0 " + adj2 * h + ",L" + adj1 * w + " " + h + ",L" + adj2 * w + " " + h + ",L" +
+                    w + " " + adj2 * h + ",L" + w + " " + adj1 * h + ",L" + adj2 * w + " 0"
             } };
             return new Svg { svgShape = shapes };
         }
@@ -8199,11 +8213,10 @@ namespace HTEXLib.Helpers
         private static Svg Heptagon(OpenXmlElement node, string shapType, double w, double h, Border border)
         {
            
-            List<SvgShape> shapes = new List<SvgShape>() {new Polygon {
-                type = "polygon",
-
-                points=(0.5 * w) + " 0," + w*1.0 / 8 + " " + h*1.0 / 4.0+ ",0 " + (5*1.0 / 8.0) * h + "," + w*1.0 / 4.0+ " " + h + "," + (3*1.0 / 4.0) * w + " " + h + "," +
-                    w + " " + (5*1.0 / 8.0) * h + "," + (7*1.0 / 8.0) * w + " " + h*1.0 / 4.0
+            List<SvgShape> shapes = new List<SvgShape>() {new SvgPath {
+                type = "path",
+                d="M"+(0.5 * w) + " 0,L" + w*1.0 / 8 + " " + h*1.0 / 4.0+ ",L0 " + (5*1.0 / 8.0) * h + ",L" + w*1.0 / 4.0+ " " + h + ",L" + (3*1.0 / 4.0) * w + " " + h + ",L" +
+                    w + " " + (5*1.0 / 8.0) * h + ",L" + (7*1.0 / 8.0) * w + " " + h*1.0 / 4.0+" z"
             } };
             return new Svg { svgShape = shapes };
         }
@@ -8263,9 +8276,9 @@ namespace HTEXLib.Helpers
         }
         private static Svg Pentagon(OpenXmlElement node, string shapType, double w, double h, Border border)
         {
-            List<SvgShape> shapes = new List<SvgShape>() {new Polygon {
-                type = "polygon",
-                points = (0.5 * w) + " 0,0 " + (0.375 * h) + "," + (0.15 * w) + " " + h + "," + 0.85 * w + " " + h + "," + w + " " + 0.375 * h ,
+            List<SvgShape> shapes = new List<SvgShape>() {new SvgPath {
+                type = "path",
+                d ="M" +(0.5 * w) + " 0,L0 " + (0.375 * h) + ",L" + (0.15 * w) + " " + h + ",L" + 0.85 * w + " " + h + ",L" + w + " " + 0.375 * h+" z" ,
             } };
             return new Svg { svgShape = shapes };
         }
@@ -8306,10 +8319,10 @@ namespace HTEXLib.Helpers
                 double adjst = double.Parse(shapAdjst.Value.Substring(4)) * 1.0 / 100000;
                 adjst_val = adjst * 1.0 / max_adj_const;
             }
-            List<SvgShape> shapes = new List<SvgShape>() {new Polygon {
-                type = "polygon",
+            List<SvgShape> shapes = new List<SvgShape>() {new SvgPath {
+                type = "path",
 
-                points = adjst_val * w + " 0,0 " + h + "," + (1 - adjst_val) * w + " " + h + "," + w + " 0",
+                d ="M"+ adjst_val * w + " 0,L0 " + h + ",L" + (1 - adjst_val) * w + " " + h + ",L" + w + " 0 z",
             } };
             return new Svg { svgShape = shapes };
         }
@@ -8352,9 +8365,9 @@ namespace HTEXLib.Helpers
                 adjst_val = 0;
                 cnstVal = h * 1.0 / 5;
             }
-            List<SvgShape> shapes = new List<SvgShape>() {new Polygon {
-                type = "polygon",
-                points = (w * adjst_val) + " " + cnstVal + ",0 " + h + "," + w + " " + h + "," + (1 - adjst_val) * w + " 0" ,
+            List<SvgShape> shapes = new List<SvgShape>() {new SvgPath {
+                type = "path",
+                d = "M"+(w * adjst_val) + " " + cnstVal + ",L0 " + h + ",L" + w + " " + h + ",L" + (1 - adjst_val) * w + " 0 z" ,
                 transform=transform
             } };
             return new Svg { svgShape = shapes };
@@ -8374,18 +8387,18 @@ namespace HTEXLib.Helpers
         /// <returns></returns>
         private static Svg Diamond(OpenXmlElement node, string shapType, double w, double h, Border border)
         {
-            List<SvgShape> shapes = new List<SvgShape>() {new Polygon {
-                type = "polygon",
+            List<SvgShape> shapes = new List<SvgShape>() {new SvgPath {
+                type = "path",
 
-                points =(w*1.0 / 2.0) + " 0,0 " + (h*1.0 / 2.0) + "," + (w*1.0 / 2.0) + " " + h + "," + w + " " + (h*1.0 / 2.0),
+                d ="M"+(w*1.0 / 2.0) + " 0,L0 " + (h*1.0 / 2.0) + ",L" + (w*1.0 / 2.0) + " " + h + ",L" + w + " " + (h*1.0 / 2.0)+" z",
             } };
             if (shapType == "flowChartSort")
             {
-                shapes.Add(new Polyline
+                shapes.Add(new SvgPath
                 {
-                    type = "polyline",
+                    type = "path",
 
-                    points = "0 " + h * 1.0 / 2.0 + "," + w + " " + h * 1.0 / 2.0
+                    d = "M0 " + h * 1.0 / 2.0 + ",L" + w + " " + h * 1.0 / 2.0
                 });
             }
             return new Svg { svgShape = shapes };
@@ -8423,9 +8436,9 @@ namespace HTEXLib.Helpers
             {
                 transform = "rotate(180 " + w * 1.0 / 2.0 + "," + h * 1.0 / 2.0 + ")";
             }
-            List<SvgShape> shapes = new List<SvgShape>() {new Polygon {
-                type = "polygon",
-                points =(w * shapAdjst_val) + " 0,0 " + h + "," + w + " " + h,
+            List<SvgShape> shapes = new List<SvgShape>() {new SvgPath {
+                type = "path",
+                d ="M"+(w * shapAdjst_val) + " 0,L0 " + h + ",L" + w + " " + h+" z",
                 transform=transform
             } };
             return new Svg { svgShape = shapes };
@@ -8445,9 +8458,9 @@ namespace HTEXLib.Helpers
         /// <returns></returns>
         private static Svg RtTriangle(OpenXmlElement node, string shapType, double w, double h, Border border)
         {
-            List<SvgShape> shapes = new List<SvgShape>() {new Polygon {
-                type = "polygon",
-                points ="0 0,0 " + h + "," + w + " " + h
+            List<SvgShape> shapes = new List<SvgShape>() {new SvgPath {
+                type = "path",
+                d ="M0 0,L0 " + h + ",L" + w + " " + h+" z"
             } };
             return new Svg { svgShape = shapes };
         }
@@ -8687,27 +8700,35 @@ namespace HTEXLib.Helpers
         /// <returns></returns>
         private static Svg Ellipse(OpenXmlElement node, string shapType, double w, double h, Border border)
         {
-            List<SvgShape> shapes = new List<SvgShape>() {new Ellipse {
-                type = "ellipse",
-
-                cx= (w*1.0 / 2.0),
-                cy=(h*1.0 / 2.0) ,
-                rx=(w*1.0 / 2.0),
-                ry= (h*1.0 / 2.0)
-            } };
+            List<SvgShape> shapes = new List<SvgShape>() {
+                new SvgPath{ 
+                    type="path",
+                    d="M" + ((w*1.0 / 2.0)-(w*1.0 / 2.0)) + " " + (h*1.0 / 2.0) +
+                       " a" + (w*1.0 / 2.0) + " " + (h*1.0 / 2.0) + " 0 1 0 " + 2*(w*1.0 / 2.0) + " 0" +
+                       " a" + (w*1.0 / 2.0) + " " + (h*1.0 / 2.0) + " 0 1 0 " + (-2*(w*1.0 / 2.0)) + " 0" +
+                       " z"
+                }
+                //new Ellipse {
+                //    type = "ellipse",
+                //    cx= (w*1.0 / 2.0),
+                //    cy=(h*1.0 / 2.0) ,
+                //    rx=(w*1.0 / 2.0),
+                //    ry= (h*1.0 / 2.0)
+                //}
+            };
             if (shapType == "flowChartOr")
             {
-                shapes.Add(new Polyline
+                shapes.Add(new SvgPath
                 {
-                    type = "polyline",
+                    type = "path",
 
-                    points = w * 1.0 / .0 + " " + 0 + "," + w * 1.0 / 2.0,
+                    d = "M"+w * 1.0 / .0 + " " + 0 + ",L" + w * 1.0 / 2.0,
                 });
-                shapes.Add(new Polyline
+                shapes.Add(new SvgPath
                 {
-                    type = "polyline",
+                    type = "path",
 
-                    points = 0 + " " + h * 1.0 / 2.0 + "," + w + " " + h * 1.0 / 2.0,
+                    d ="M"+ 0 + " " + h * 1.0 / 2.0 + ",L" + w + " " + h * 1.0 / 2.0,
                 });
             }
             else if (shapType == "flowChartSummingJunction")
@@ -8720,17 +8741,17 @@ namespace HTEXLib.Helpers
                 ir = hc + idx;
                 it = vc - idy;
                 ib = vc + idy;
-                shapes.Add(new Polyline
+                shapes.Add(new SvgPath
                 {
-                    type = "polyline",
+                    type = "path",
 
-                    points = il + " " + it + "," + ir + " " + ib,
+                    d = "M"+il + " " + it + ",L" + ir + " " + ib,
                 });
-                shapes.Add(new Polyline
+                shapes.Add(new SvgPath
                 {
-                    type = "polyline",
+                    type = "path",
 
-                    points = ir + " " + it + "," + il + " " + ib,
+                    d = "M" + ir + " " + it + ",L" + il + " " + ib,
                 });
             }
             return new Svg { svgShape = shapes };
@@ -8780,7 +8801,6 @@ namespace HTEXLib.Helpers
                             " z";
             List<SvgShape> shapes = new List<SvgShape>() {new SvgPath {
                 type = "path",
-
                 d=d,
             } };
             return new Svg { svgShape = shapes };
@@ -9819,36 +9839,58 @@ namespace HTEXLib.Helpers
         private static Svg Rect(OpenXmlElement node, string shapType, double w, double h, Border border)
         {
             List<SvgShape> shapes = new List<SvgShape>();
-            shapes.Add(new Rect
+            //shapes.Add(new Rect
+            //{
+            //    type = "rect",
+            //    x = 0,
+            //    y = 0,
+            //    width = w,
+            //    height =h,
+            //});
+            shapes.Add(new SvgPath
             {
-                type = "rect",
-                x = 0,
-                y = 0,
-                width = w,
-                height =h,
+                type = "path",
+                //  d = "M" + 0 + " " + 0 + "h" + w + "v" + h + "h" + (-w) + " z"
+                d = "M" + 0 + " " + 0 + ",L" + w + " " + 0 + ",L" + w+" "+h+",L"+0+" "+h + " z"
+                //x = 0,
+                //y = 0,
+                //width = w,
+                //height = h,
             });
+            //if (shapType == "flowChartPredefinedProcess")
+            //{
+            //    shapes.Add(new Rect
+            //    {
+            //        type = "rect",
+            //        x = w * (1.0 / 8.0),
+            //        y = 0,
+            //        width = w * (6.0 / 8.0),
+            //        height = h,
+            //    });
+            //}
             if (shapType == "flowChartPredefinedProcess")
             {
-                shapes.Add(new Rect
+                shapes.Add(new SvgPath
                 {
-                    type = "rect",
-                    x = w * (1.0 / 8.0),
-                    y = 0,
-                    width = w * (6.0 / 8.0),
-                    height = h,
+                    type = "path",
+                    d = "M" + w * (1.0 / 8.0) + " " + 0 + ",L" + (w * (7.0 / 8.0)) + " " + 0 + ",L" + (w * (7.0 / 8.0)) + " " + h + ",L" + w * (1.0 / 8.0) + " " + h+ " z"
+                    //x = w * (1.0 / 8.0),
+                    //y = 0,
+                    //width = w * (6.0 / 8.0),
+                    //height = h,
                 });
             }
             else if (shapType == "flowChartInternalStorage")
             {
-                shapes.Add(new Polyline
+                shapes.Add(new SvgPath
                 {
-                    type = "polyline",
-                    points = w * (1.0/ 8.0) + " 0," + w * (1.0  / 8.0) + " " + h,
+                    type = "path",
+                    d = "M"+w * (1.0/ 8.0) + " 0,L" + w * (1.0  / 8.0) + " " + h,
                 });
-                shapes.Add(new Polyline
+                shapes.Add(new SvgPath
                 {
-                    type = "polyline",
-                    points = h * (1.0  / 8.0) + "," + w + " " + h * (1.0  / 8.0),
+                    type = "path",
+                    d = "M" +h * (1.0  / 8.0) + ",L" + w + " " + h * (1.0  / 8.0),
                 });
             }
             return new Svg { svgShape = shapes };

+ 14 - 7
HTEXLib/PPTX/Models/HTEX/HtexChart.cs

@@ -129,13 +129,20 @@ namespace HTEXLib.Models.HTEX
             chart.style.fill = shapeStyleChart != null ? shapeStyleChart.fill : null;
             chart.style.border = shapeStyleChart != null ? shapeStyleChart.border : null;
             chart.style.effect= shapeStyleChart != null ? shapeStyleChart.effect : null;
-            chart.svg = new Svg { svgShape = new List<SvgShape> { new Rect {
-                x=position.x, 
-                y = position.y,
-                width=position.cx,
-                height=position.cy,
-                type="rect"
-            } } };
+            chart.svg = new Svg { svgShape = new List<SvgShape> {
+                new SvgPath{
+                        type="path",
+                        d = "M" + 0 + " " + 0 + ",L" + position.cx + " " + 0 + ",L" + position.cx+" "+position.cy+",L"+0+" "+position.cy + " z"
+                    }
+                //new Rect {
+                //    x=position.x, 
+                //    y = position.y,
+                //    width=position.cx,
+                //    height=position.cy,
+                //    type="rect"
+                //    } 
+                } 
+            };
             if (chart.style != null) {
                 if (chart.style.fill.type == -1 || chart.style.fill.type == 0)
                 {

+ 13 - 9
HTEXLib/PPTX/Models/HTEX/HtexDiagram.cs

@@ -157,15 +157,19 @@ namespace HTEXLib.Models.HTEX
             diagram.svg = new Svg
             {
                 svgShape = new List<SvgShape> 
-                { 
-                    new Rect 
-                    {
-                        x=position.x,
-                        y = position.y,
-                        width=position.cx,
-                        height=position.cy,
-                        type="rect"
-                    } 
+                {
+                     new SvgPath{
+                        type="path",
+                        d = "M" + 0 + " " + 0 + ",L" + position.cx + " " + 0 + ",L" + position.cx+" "+position.cy+",L"+0+" "+position.cy + " z"
+                    }
+                    //new Rect 
+                    //{
+                    //    x=position.x,
+                    //    y = position.y,
+                    //    width=position.cx,
+                    //    height=position.cy,
+                    //    type="rect"
+                    //} 
                 }
             };
             return diagram;

+ 18 - 12
HTEXLib/PPTX/Models/HTEX/HtexGroupShape.cs

@@ -34,7 +34,7 @@ namespace HTEXLib.Models.HTEX
         {
             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() { sid = sid, type = type, index = index,uid=groupShape.suid,subName= groupShape .NonVisualShapeProp.SubName};
+            Group group = new Group() { sid = sid, type = type, index = index, uid = groupShape.suid, subName = groupShape.NonVisualShapeProp.SubName };
             group.style.border = ShapeStyle.border;
             group.style.fill = ShapeStyle.fill;
             group.style.effect = ShapeStyle.effect;
@@ -44,11 +44,13 @@ namespace HTEXLib.Models.HTEX
                 ContainerShape = groupShape.containerShape,
                 FromGroup = true
             };
-            var elements= htexSlide.DrawElement();
-            if (elements != null) {
+            var elements = htexSlide.DrawElement();
+            if (elements != null)
+            {
                 group.shapes = elements;
             }
-            if (group.style != null) {
+            if (group.style != null)
+            {
                 if (group.style.fill.type == -1 || group.style.fill.type == 0)
                 {
                     group.style.fill = null;
@@ -67,17 +69,21 @@ namespace HTEXLib.Models.HTEX
             {
                 svgShape = new List<SvgShape>
                 {
-                    new Rect
-                    {
-                        x=position.x,
-                        y = position.y,
-                        width=position.cx,
-                        height=position.cy,
-                        type="rect"
+                    new SvgPath{
+                        type="path",
+                        d = "M" + 0 + " " + 0 + ",L" + position.cx + " " + 0 + ",L" + position.cx+" "+position.cy+",L"+0+" "+position.cy + " z"
                     }
+                    //new Rect
+                    //{
+                    //    x=position.x,
+                    //    y = position.y,
+                    //    width=position.cx,
+                    //    height=position.cy,
+                    //    type="rect"
+                    //}
                 }
             };
-            return new List<Item>() { group }; 
+            return new List<Item>() { group };
         }
     }
 }

+ 11 - 7
HTEXLib/PPTX/Models/HTEX/HtexImage.cs

@@ -133,14 +133,18 @@ namespace HTEXLib.Models.HTEX
             {
                 svgShape = new List<SvgShape>
                 {
-                    new Rect
-                    {
-                        x=position.x,
-                        y = position.y,
-                        width=position.cx,
-                        height=position.cy,
-                        type="rect"
+                    new SvgPath{
+                        type="path",
+                        d = "M" + 0 + " " + 0 + ",L" + position.cx + " " + 0 + ",L" + position.cx+" "+position.cy+",L"+0+" "+position.cy + " z"
                     }
+                    //new Rect
+                    //{
+                    //    x=position.x,
+                    //    y = position.y,
+                    //    width=position.cx,
+                    //    height=position.cy,
+                    //    type="rect"
+                    //}
                 }
             };
             media.links = slide.hyperlinks;

+ 11 - 7
HTEXLib/PPTX/Models/HTEX/HtexMath.cs

@@ -180,14 +180,18 @@ namespace HTEXLib.Models.HTEX
             {
                 svgShape = new List<SvgShape>
                 {
-                    new Rect
-                    {
-                        x=position.x,
-                        y = position.y,
-                        width=position.cx,
-                        height=position.cy,
-                        type="rect"
+                    new SvgPath{
+                        type="path",
+                        d = "M" + 0 + " " + 0 + ",L" + position.cx + " " + 0 + ",L" + position.cx+" "+position.cy+",L"+0+" "+position.cy + " z"
                     }
+                    //new Rect
+                    //{
+                    //    x=position.x,
+                    //    y = position.y,
+                    //    width=position.cx,
+                    //    height=position.cy,
+                    //    type="rect"
+                    //}
                 }
             };
             math.links = slide.hyperlinks;

+ 14 - 14
HTEXLib/PPTX/Models/PPTX/DSPShape.cs

@@ -308,11 +308,11 @@ namespace HTEXLib.Models.PPTX
                 {
                     position.cx = 1;
                 }
-                else if (extents.Cx < Globals.px914400)
-                {
+                //else if (extents.Cx < Globals.px914400)
+                //{
 
-                    position.cx = Globals.px914400 * 1.0 / extents.Cx * Globals.px96;
-                }
+                //    position.cx = Globals.px914400 * 1.0 / extents.Cx * Globals.px96;
+                //}
                 else
                 {
                     position.cx = extents.Cx * 1.0 * Globals.px96 / Globals.px914400;
@@ -322,11 +322,11 @@ namespace HTEXLib.Models.PPTX
                 {
                     position.cy = 1;
                 }
-                else if (extents.Cy < Globals.px914400)
-                {
-                    position.cy =
-                       Globals.px914400 * 1.0 / extents.Cy * Globals.px96;
-                }
+                //else if (extents.Cy < Globals.px914400)
+                //{
+                //    position.cy =
+                //       Globals.px914400 * 1.0 / extents.Cy * Globals.px96;
+                //}
                 else
                 {
                     position.cy =
@@ -381,11 +381,11 @@ namespace HTEXLib.Models.PPTX
                 {
                     dspPosition.cy = 1;
                 }
-                else if (extents.Cy < Globals.px914400)
-                {
-                    dspPosition.cy =
-                       Globals.px914400 * 1.0 / extents.Cy * Globals.px96;
-                }
+                //else if (extents.Cy < Globals.px914400)
+                //{
+                //    dspPosition.cy =
+                //       Globals.px914400 * 1.0 / extents.Cy * Globals.px96;
+                //}
                 else
                 {
                     dspPosition.cy =

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

@@ -76,7 +76,7 @@ namespace HTEXLib.Models.Inner
                 if (shapeTree != null)
                 {
                     var layoutShape = shapeTree.GetFirstChild<Picture>();
-                    if (layoutShape.ShapeProperties.Transform2D != null)
+                    if (layoutShape != null&&layoutShape.ShapeProperties.Transform2D != null)
                     {
                         VisualShapeProp.Extents = layoutShape.ShapeProperties.Transform2D.Extents;
                         VisualShapeProp.Offset = layoutShape.ShapeProperties.Transform2D.Offset;

+ 10 - 10
HTEXLib/PPTX/Models/PPTX/PPTVisualPPTShapeProp.cs

@@ -33,11 +33,11 @@ namespace HTEXLib.Models.Inner
             {
                 return 1;
             }
-            else if (Extents.Cx < Globals.px914400)
-            {
-                return
-                     Globals.px914400 * 1.0 / Extents.Cx*Globals.px96 ;
-            }
+            //else if (Extents.Cx < Globals.px914400)
+            //{
+            //    return
+            //         Globals.px914400 * 1.0 / Extents.Cx*Globals.px96 ;
+            //}
             else
             {
                 return
@@ -51,11 +51,11 @@ namespace HTEXLib.Models.Inner
             {
                 return 1;
             }
-            else if (Extents.Cy < Globals.px914400)
-            {
-                return
-                   Globals.px914400 * 1.0 / Extents.Cy * Globals.px96;
-            }
+            //else if (Extents.Cy < Globals.px914400)
+            //{
+            //    return
+            //       Globals.px914400 * 1.0 / Extents.Cy * Globals.px96;
+            //}
             else
             {
                 return

+ 8 - 0
HTEXTest/Program.cs

@@ -91,6 +91,14 @@ namespace HTEXTest
 
         static void Main(string[] args)
         {
+
+            List<double> ds = new List<double>();
+            ds.Add(0); 
+            ds.Add(51.222);
+            ds.Add(60);
+            ds.Add(70);
+            ds.Add(80);
+           
             Console.WriteLine(2.ToString().PadRight(4, '0') + 1.ToString().PadLeft(3, '0'));
             Console.WriteLine(25.ToString().PadRight(4, '0') + 10.ToString().PadLeft(3, '0'));
             Console.WriteLine(225.ToString().PadRight(4, '0') + 110.ToString().PadLeft(3, '0'));