Browse Source

Merge branch 'master' of http://106.12.23.251:10080/CDHABOOK/TEAMModelHTEX

黄贺彬 4 years ago
parent
commit
f8338f0aab

+ 32 - 0
HTEXLib/DOCX/OpenXmlTool/WORDHelper.cs

@@ -46,6 +46,38 @@ namespace HTEXLib.DOCX.OpenXmlTool
             xmlnsManager.AddNamespace("wp", "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing");
             xmlnsManager.AddNamespace("wp", "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing");
             xmlnsManager.AddNamespace("wp", "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing");
             xmlnsManager.AddNamespace("wp", "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing");
             xmlnsManager.AddNamespace("wps", "http://schemas.microsoft.com/office/word/2010/wordprocessingShape");
             xmlnsManager.AddNamespace("wps", "http://schemas.microsoft.com/office/word/2010/wordprocessingShape");
+            xmlnsManager.AddNamespace("wpc", "http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas");
+            xmlnsManager.AddNamespace("cx", "http://schemas.microsoft.com/office/drawing/2014/chartex");
+            xmlnsManager.AddNamespace("cx1", "http://schemas.microsoft.com/office/drawing/2015/9/8/chartex");
+            xmlnsManager.AddNamespace("cx2", "http://schemas.microsoft.com/office/drawing/2015/10/21/chartex");
+            xmlnsManager.AddNamespace("cx3", "http://schemas.microsoft.com/office/drawing/2016/5/9/chartex");
+            xmlnsManager.AddNamespace("cx4", "http://schemas.microsoft.com/office/drawing/2016/5/10/chartex");
+            xmlnsManager.AddNamespace("cx5", "http://schemas.microsoft.com/office/drawing/2016/5/11/chartex");
+            xmlnsManager.AddNamespace("cx6", "http://schemas.microsoft.com/office/drawing/2016/5/12/chartex");
+            xmlnsManager.AddNamespace("cx7", "http://schemas.microsoft.com/office/drawing/2016/5/13/chartex");
+            xmlnsManager.AddNamespace("cx8", "http://schemas.microsoft.com/office/drawing/2016/5/14/chartex");
+            xmlnsManager.AddNamespace("mc", "http://schemas.openxmlformats.org/markup-compatibility/2006");
+            xmlnsManager.AddNamespace("aink", "http://schemas.microsoft.com/office/drawing/2016/ink");
+            xmlnsManager.AddNamespace("am3d", "http://schemas.microsoft.com/office/drawing/2017/model3d");
+            xmlnsManager.AddNamespace("o", "urn:schemas-microsoft-com:office:office");
+            xmlnsManager.AddNamespace("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships");
+            xmlnsManager.AddNamespace("m", "http://schemas.openxmlformats.org/officeDocument/2006/math");
+            xmlnsManager.AddNamespace("v", "urn:schemas-microsoft-com:vml");
+            xmlnsManager.AddNamespace("wp14", "http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing");
+            xmlnsManager.AddNamespace("wp", "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing");
+            xmlnsManager.AddNamespace("w10", "urn:schemas-microsoft-com:office:word");
+            xmlnsManager.AddNamespace("w", "http://schemas.openxmlformats.org/wordprocessingml/2006/main");
+            xmlnsManager.AddNamespace("w14", "http://schemas.microsoft.com/office/word/2010/wordml");
+            xmlnsManager.AddNamespace("w15", "http://schemas.microsoft.com/office/word/2012/wordml");
+            xmlnsManager.AddNamespace("w16cex", "http://schemas.microsoft.com/office/word/2018/wordml/cex");
+            xmlnsManager.AddNamespace("w16cid", "http://schemas.microsoft.com/office/word/2016/wordml/cid");
+            xmlnsManager.AddNamespace("w16", "http://schemas.microsoft.com/office/word/2018/wordml");
+            xmlnsManager.AddNamespace("w16se", "http://schemas.microsoft.com/office/word/2015/wordml/symex");
+            xmlnsManager.AddNamespace("wpg", "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup");
+            xmlnsManager.AddNamespace("wpi", "http://schemas.microsoft.com/office/word/2010/wordprocessingInk");
+            xmlnsManager.AddNamespace("wne", "http://schemas.microsoft.com/office/word/2006/wordml");
+            xmlnsManager.AddNamespace("wps", "http://schemas.microsoft.com/office/word/2010/wordprocessingShape");
+            xmlnsManager.AddNamespace("pt14", "http://powertools.codeplex.com/2011");
         }
         }
         /// <summary>
         /// <summary>
         ///  处理 LineReference   轮廓  a:lnRef
         ///  处理 LineReference   轮廓  a:lnRef

+ 8 - 5
HTEXLib/DOCX/OpenXmlTool/WmlToHtmlConverter.cs

@@ -3985,7 +3985,7 @@ namespace OpenXmlPowerTools
                     //application.EnablePartialTrustCode = true;
                     //application.EnablePartialTrustCode = true;
                     //mathxml = expected;
                     //mathxml = expected;
 
 
-                    MemoryStream memoryStream = new MemoryStream();
+                   // MemoryStream memoryStream = new MemoryStream();
                     //Metafile inFile = new Metafile(pp.OpenXmlPart.GetStream());
                     //Metafile inFile = new Metafile(pp.OpenXmlPart.GetStream());
                     ////Metafile outFile = new Metafile(memoryStream, Graphics.FromHwnd(IntPtr.Zero).GetHdc(), EmfType.EmfOnly);
                     ////Metafile outFile = new Metafile(memoryStream, Graphics.FromHwnd(IntPtr.Zero).GetHdc(), EmfType.EmfOnly);
                     //inFile.Save(memoryStream, ImageFormat.Png);
                     //inFile.Save(memoryStream, ImageFormat.Png);
@@ -4092,12 +4092,13 @@ namespace OpenXmlPowerTools
                 var imagePart = (ImagePart)pp.OpenXmlPart;
                 var imagePart = (ImagePart)pp.OpenXmlPart;
                 if (imagePart == null) return null;
                 if (imagePart == null) return null;
                 string hyperlinkUri = null;
                 string hyperlinkUri = null;
-                var contentType = imagePart.ContentType;
-                if (!ImageContentTypes.Contains(contentType))
-                    return null;
-
+                
+               // WORDHelper.GetWordNodeByPath(wordDoc.MainDocumentPart.GetXDocument(), "//[@name='"+imagePart.Uri+"']");
                 using (var partStream = imagePart.GetStream())
                 using (var partStream = imagePart.GetStream())
                 {
                 {
+                    var contentType = imagePart.ContentType;
+                    if (!ImageContentTypes.Contains(contentType))
+                        return null;
                     try
                     try
                     {
                     {
                         using (var bitmap = new Bitmap(partStream))
                         using (var bitmap = new Bitmap(partStream))
@@ -4140,12 +4141,14 @@ namespace OpenXmlPowerTools
                     {
                     {
                         return null; //throw new Exception(e.StackTrace);
                         return null; //throw new Exception(e.StackTrace);
                     }
                     }
+                    finally { partStream.Close(); }
                 }
                 }
             }
             }
             catch (ArgumentOutOfRangeException)
             catch (ArgumentOutOfRangeException)
             {
             {
                 return null;
                 return null;
             }
             }
+            
         }
         }
 
 
         private static float? HeightInPoints(IEnumerable<string> tokens)
         private static float? HeightInPoints(IEnumerable<string> tokens)

+ 2 - 2
HTEXLib/PPTX/Controller/HtexController.cs

@@ -158,7 +158,7 @@ namespace HTEXLib.Controller
             {
             {
                 Shape htexGroup = new Shape
                 Shape htexGroup = new Shape
                 {
                 {
-                    type = "Sp",
+                    type = "Group",
                     style = group.style,
                     style = group.style,
                     index = group.index,
                     index = group.index,
                     uid = group.uid,
                     uid = group.uid,
@@ -204,7 +204,7 @@ namespace HTEXLib.Controller
                 Shape htexGroup = new Shape
                 Shape htexGroup = new Shape
                 {
                 {
                     //  type = group.type,
                     //  type = group.type,
-                    type = "Sp",
+                    type = "Group",
                     style = group.style,
                     style = group.style,
                     index = group.index,
                     index = group.index,
                     uid = group.uid,
                     uid = group.uid,

+ 1 - 0
HTEXLib/PPTX/Helpers/ShapeHelpers/PPTXHelper.cs

@@ -260,6 +260,7 @@ namespace HTEXLib.Helpers.ShapeHelpers
                     {
                     {
                         d += " z";
                         d += " z";
                     }
                     }
+                    d = d.Replace(",", " ");
                     Svg  shapes = 
                     Svg  shapes = 
                     new Svg  {
                     new Svg  {
                         type = "path",
                         type = "path",

+ 1 - 0
HTEXLib/PPTX/Helpers/ShapeHelpers/SvgHelper.cs

@@ -669,6 +669,7 @@ namespace HTEXLib.Helpers
                 default:
                 default:
                     break;
                     break;
             }
             }
+            resultSvg.d= resultSvg.d.Replace(",", " ").Replace("E-05","");
             return resultSvg;
             return resultSvg;
         }
         }
 
 

+ 1 - 1
HTEXLib/PPTX/Models/HTEX/HtexChart.cs

@@ -131,7 +131,7 @@ namespace HTEXLib.Models.HTEX
             chart.style.effect= shapeStyleChart != null ? shapeStyleChart.effect : null;
             chart.style.effect= shapeStyleChart != null ? shapeStyleChart.effect : null;
             chart.svg = new Svg {
             chart.svg = new Svg {
                 type = "path",
                 type = "path",
-                d = "M" + 0 + " " + 0 + ",L" + position.cx + " " + 0 + ",L" + position.cx + " " + position.cy + ",L" + 0 + " " + position.cy + " z",
+                d = "M" + 0 + " " + 0 + " L" + position.cx + " " + 0 + " L" + position.cx + " " + position.cy + " L" + 0 + " " + position.cy + " z",
                 close = true
                 close = true
                 //new Rect {
                 //new Rect {
                 //    x=position.x, 
                 //    x=position.x, 

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

@@ -64,7 +64,7 @@ namespace HTEXLib.Models.HTEX
                 SlideColor slideColor = PPTXHelper.DoShapeStyle(connectionShape.element.ShapeStyle, slide,type);
                 SlideColor slideColor = PPTXHelper.DoShapeStyle(connectionShape.element.ShapeStyle, slide,type);
                 if (slideColor != null) {
                 if (slideColor != null) {
                     shapeBorder.color.solidFill = slideColor.LineColor;
                     shapeBorder.color.solidFill = slideColor.LineColor;
-                    shapeBorder.color.type = 2;
+                    shapeBorder.color.type = 1;
                 }
                 }
             }
             }
            
            

+ 1 - 1
HTEXLib/PPTX/Models/HTEX/HtexDiagram.cs

@@ -157,7 +157,7 @@ namespace HTEXLib.Models.HTEX
             diagram.svg = new Svg
             diagram.svg = new Svg
             {
             {
                 type = "path",
                 type = "path",
-                d = "M" + 0 + " " + 0 + ",L" + position.cx + " " + 0 + ",L" + position.cx + " " + position.cy + ",L" + 0 + " " + position.cy + " z",
+                d = "M" + 0 + " " + 0 + " L" + position.cx + " " + 0 + " L" + position.cx + " " + position.cy + " L" + 0 + " " + position.cy + " z",
                 close = true
                 close = true
                 //new Rect 
                 //new Rect 
                 //{
                 //{

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

@@ -68,7 +68,7 @@ namespace HTEXLib.Models.HTEX
             group.svg = new Svg
             group.svg = new Svg
             {
             {
                 type = "path",
                 type = "path",
-                d = "M" + 0 + " " + 0 + ",L" + position.cx + " " + 0 + ",L" + position.cx + " " + position.cy + ",L" + 0 + " " + position.cy + " z",
+                d = "M" + 0 + " " + 0 + " L" + position.cx + " " + 0 + " L" + position.cx + " " + position.cy + " L" + 0 + " " + position.cy + " z",
                 close = true
                 close = true
                 //new Rect
                 //new Rect
                 //{
                 //{

+ 3 - 3
HTEXLib/PPTX/Models/HTEX/HtexImage.cs

@@ -94,7 +94,7 @@ namespace HTEXLib.Models.HTEX
                 if (slideColor != null)
                 if (slideColor != null)
                 {
                 {
                     media.style.border.color.solidFill = slideColor.LineColor;
                     media.style.border.color.solidFill = slideColor.LineColor;
-                    media.style.border.color.type = 2;
+                    media.style.border.color.type = 1;
                 }
                 }
             }
             }
             else
             else
@@ -106,7 +106,7 @@ namespace HTEXLib.Models.HTEX
                 if (slideColor != null)
                 if (slideColor != null)
                 {
                 {
                     media.style.fill.solidFill = slideColor.FillColor;
                     media.style.fill.solidFill = slideColor.FillColor;
-                    media.style.fill.type = 2;
+                    media.style.fill.type = 1;
                 }
                 }
             }
             }
             else
             else
@@ -132,7 +132,7 @@ namespace HTEXLib.Models.HTEX
             media.svg = new Svg
             media.svg = new Svg
             {
             {
                 type = "path",
                 type = "path",
-                d = "M" + 0 + " " + 0 + ",L" + position.cx + " " + 0 + ",L" + position.cx + " " + position.cy + ",L" + 0 + " " + position.cy + " z",
+                d = "M" + 0 + " " + 0 + " L" + position.cx + " " + 0 + " L" + position.cx + " " + position.cy + " L" + 0 + " " + position.cy + " z",
                 close = true
                 close = true
                 //new Rect
                 //new Rect
                 //{
                 //{

+ 3 - 3
HTEXLib/PPTX/Models/HTEX/HtexMath.cs

@@ -57,7 +57,7 @@ namespace HTEXLib.Models.HTEX
                 if (slideColor != null)
                 if (slideColor != null)
                 {
                 {
                     math.style.border.color.solidFill = slideColor.LineColor;
                     math.style.border.color.solidFill = slideColor.LineColor;
-                    math.style.border.color.type = 2;
+                    math.style.border.color.type = 1;
                 }
                 }
             }
             }
             else
             else
@@ -69,7 +69,7 @@ namespace HTEXLib.Models.HTEX
                 if (slideColor != null)
                 if (slideColor != null)
                 {
                 {
                     math.style.fill.solidFill = slideColor.FillColor;
                     math.style.fill.solidFill = slideColor.FillColor;
-                    math.style.fill.type = 2;
+                    math.style.fill.type = 1;
                 }
                 }
             }
             }
             else
             else
@@ -179,7 +179,7 @@ namespace HTEXLib.Models.HTEX
             math.svg = new Svg
             math.svg = new Svg
             {
             {
                 type = "path",
                 type = "path",
-                d = "M" + 0 + " " + 0 + ",L" + position.cx + " " + 0 + ",L" + position.cx + " " + position.cy + ",L" + 0 + " " + position.cy + " z",
+                d = "M" + 0 + " " + 0 + " L" + position.cx + " " + 0 + " L" + position.cx + " " + position.cy + " L" + 0 + " " + position.cy + " z",
                 close=true
                 close=true
                 //new Rect
                 //new Rect
                 //{
                 //{

+ 2 - 2
HTEXLib/PPTX/Models/HTEX/HtexShape.cs

@@ -64,7 +64,7 @@ namespace HTEXLib.Models.HTEX
                 if (slideColor != null)
                 if (slideColor != null)
                 {
                 {
                     shape.style.border.color.solidFill = slideColor.LineColor;
                     shape.style.border.color.solidFill = slideColor.LineColor;
-                    shape.style.border.color.type = 2;
+                    shape.style.border.color.type = 1;
                 }
                 }
             }
             }
             else
             else
@@ -76,7 +76,7 @@ namespace HTEXLib.Models.HTEX
                 if (slideColor != null)
                 if (slideColor != null)
                 {
                 {
                     shape.style.fill.solidFill = slideColor.FillColor;
                     shape.style.fill.solidFill = slideColor.FillColor;
-                    shape.style.fill.type = 2;
+                    shape.style.fill.type = 1;
                 }
                 }
             }
             }
             else
             else