Przeglądaj źródła

PPT完善解析

CrazyIter 5 lat temu
rodzic
commit
3b23a665df

+ 5 - 5
TEAMModelOS.SDK/TEAMModelOS.SDK.csproj

@@ -1,7 +1,7 @@
 <Project Sdk="Microsoft.NET.Sdk">
 
   <PropertyGroup>
-    <TargetFramework>netcoreapp3.1</TargetFramework>
+    <TargetFramework>netcoreapp3.0</TargetFramework>
     <Version>2.0.3</Version>
     <AssemblyVersion>2.0.0.3</AssemblyVersion>
     <FileVersion>2.0.0.3</FileVersion>
@@ -15,13 +15,13 @@
     <PackageReference Include="IdentityModel" Version="4.0.0" />
     <PackageReference Include="LiteDB" Version="4.1.4" />
     <PackageReference Include="log4net" Version="2.0.8" />
-    <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.0" />
-    <PackageReference Include="Microsoft.AspNetCore.Authorization" Version="3.1.0" />
+    <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.0.0" />
+    <PackageReference Include="Microsoft.AspNetCore.Authorization" Version="3.0.0" />
     <PackageReference Include="Microsoft.AspNetCore.Http" Version="2.2.2" />
-    <PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.0" />
+    <PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.0.0" />
     <PackageReference Include="Microsoft.Azure.CosmosDB.BulkExecutor" Version="2.4.1-preview" />
     <PackageReference Include="Microsoft.Azure.DocumentDB.Core" Version="2.9.2" />
-    <PackageReference Include="Microsoft.Extensions.Configuration" Version="3.1.0" />
+    <PackageReference Include="Microsoft.Extensions.Configuration" Version="3.0.0" />
     <PackageReference Include="Microsoft.IdentityModel.Tokens" Version="5.6.0" />
     <PackageReference Include="Scrutor" Version="3.1.0" />
     <PackageReference Include="System.Drawing.Common" Version="4.7.0" />

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

@@ -13,10 +13,13 @@ namespace HiTeachCC.Model.PowerPoint
         /// </summary>
         public string Color { get; set; }
         public int Size { get; set; }
-        public string Type { get; set; }
-        public string Bold { get; set; }
-        public string Italic { get; set; }
+        //inherit  继承父级
+        public string Family { get; set; }
+        public string Weight { get; set; }
+        public string Style { get; set; }
         public string Decoration { get; set; }
         public string VertAlign { get; set; }
+        public string Align { get; set; }
+        public string Shadow { get; set; }
     }
 }

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

@@ -18,16 +18,25 @@ namespace HiTeachCC.Model.PowerPoint
     {
         public string Content { get; set; }
         public string Href { get; set; }
-      
+        public bool isbr { get; set; } = false;
         public FontStyle FontStyle { get; set; }
     }
 
-    public class BuChar{
-        public int MarginLeft { get; set; }
-        public int MarginRiht { 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 string Buchar { get; set; }
         public string Typeface { get; set; }
         public int  FontSize { get; set; }
+        public string Float { get; set; }
+        /// <summary>
+        /// ltr	默认。文本方向从左到右
+        /// rtl	文本方向从右到左。
+        /// inherit	规定应该从父元素继承 direction 属性的值。
+        /// </summary>
+        public string Direction { get; set; } = "inherit";
     }
 
     public class ParagraphStyle

+ 45 - 24
TEAMModelOS.Service/Models/PowerPoint/Path.cs

@@ -20,21 +20,25 @@ namespace HiTeachCC.Model.PowerPoint
     /// </summary>
     public class MoveToPath : Path
     {
-        public MoveToPath()
-        {
-            Pts = new List<Point> { };
-        }
-        public List<Point> Pts { get; set; }
+        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 string WidthRadius { get; set; }
-        public string HeightRadius { get; set; }
-        public string StartAngle { get; set; }
-        public string SwingAngle { get; set; }
+        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; }
     }
 
 
@@ -43,32 +47,49 @@ namespace HiTeachCC.Model.PowerPoint
     /// </summary>
     public class LineToPath : Path
     {
-        public LineToPath()
-        {
-            Pts = new List<Point> { };
-        }
-        public List<Point> Pts { get; set; }
+        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 CubicBezPath()
-        {
-            Pts = new List<Point> { };
-        }
-        public List<Point> Pts { get; set; }
+        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 QuadBezPath()
-        {
-            Pts = new List<Point> { };
-        }
-        public List<Point> Pts { get; set; }
+        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

+ 4 - 4
TEAMModelOS.Service/Models/Syllabus/SyllabusNode.cs

@@ -9,8 +9,8 @@ namespace TEAMModelOS.Service.Models.Syllabus
     {
 
         public SyllabusNode() {
-            resources = new List<string>();
-            knowledges = new List<string>();
+            //resources = new List<string>();
+            //knowledges = new List<string>();
         }
         /// <summary>
         /// 
@@ -75,8 +75,8 @@ namespace TEAMModelOS.Service.Models.Syllabus
         /// </summary>
         [Required(ErrorMessage = "{0} 必须填写")]
         public int status { get; set; } = 1;
-        public List<string> resources { get; set; }
-        public List<string> knowledges { get; set; }
+        public  bool resource { get; set; }
+        public bool knowledge { get; set; }
         
     }
 }

+ 9 - 9
TEAMModelOS.Service/Services/PowerPoint/Implement/PowerPointService.cs

@@ -737,7 +737,7 @@ namespace HiTeachCC.Service.PowerPoint.Implement
                 {
                     DocumentFormat.OpenXml.Drawing.Point point = moveTo.Point;
                     MoveToPath moveToPath = new MoveToPath { Type = "MoveTo" };
-                    moveToPath.Pts.Add(new HiTeachCC.Model.PowerPoint. Point { X = double.Parse(point.X) * inchpixel / pxBase, Y = double.Parse(point.Y) * inchpixel / pxBase });
+                  //  moveToPath.Pts.Add(new HiTeachCC.Model.PowerPoint. Point { X = double.Parse(point.X) * inchpixel / pxBase, Y = double.Parse(point.Y) * inchpixel / pxBase });
                     Paths.Add(moveToPath);
                 }
                 //连线
@@ -745,7 +745,7 @@ namespace HiTeachCC.Service.PowerPoint.Implement
                 {
                     DocumentFormat.OpenXml.Drawing.Point point = linTo.Point;
                     LineToPath lineToPath = new LineToPath { Type = "LineTo" };
-                    lineToPath.Pts.Add(new HiTeachCC.Model.PowerPoint.Point { X = double.Parse(point.X) * inchpixel / pxBase, Y = double.Parse(point.Y) * inchpixel / pxBase });
+                    //lineToPath.Pts.Add(new HiTeachCC.Model.PowerPoint.Point { X = double.Parse(point.X) * inchpixel / pxBase, Y = double.Parse(point.Y) * inchpixel / pxBase });
                     Paths.Add(lineToPath);
                 }
                 //三次贝塞尔曲线
@@ -757,7 +757,7 @@ namespace HiTeachCC.Service.PowerPoint.Implement
                     {
                         if (ls is DocumentFormat.OpenXml.Drawing.Point point)
                         {
-                            cubicBezPath.Pts.Add(new HiTeachCC.Model.PowerPoint.Point { X = double.Parse(point.X) * inchpixel / pxBase, Y = double.Parse(point.Y) * inchpixel / pxBase });
+                           // cubicBezPath.Pts.Add(new HiTeachCC.Model.PowerPoint.Point { X = double.Parse(point.X) * inchpixel / pxBase, Y = double.Parse(point.Y) * inchpixel / pxBase });
                         }
                     }
                     Paths.Add(cubicBezPath);
@@ -771,7 +771,7 @@ namespace HiTeachCC.Service.PowerPoint.Implement
                     {
                         if (ls is DocumentFormat.OpenXml.Drawing.Point point)
                         {
-                            quadBezPath.Pts.Add(new HiTeachCC.Model.PowerPoint.Point { X = double.Parse(point.X) * inchpixel / pxBase, Y = double.Parse(point.Y) * inchpixel / pxBase });
+                            //quadBezPath.Pts.Add(new HiTeachCC.Model.PowerPoint.Point { X = double.Parse(point.X) * inchpixel / pxBase, Y = double.Parse(point.Y) * inchpixel / pxBase });
 
                         }
                     }
@@ -780,8 +780,8 @@ namespace HiTeachCC.Service.PowerPoint.Implement
                 //处理曲线
                 if (xmlElement is DocumentFormat.OpenXml.Drawing.ArcTo arcTO)
                 {
-                    ArcToPath arcToPath = new ArcToPath() { WidthRadius = arcTO.WidthRadius, HeightRadius = arcTO.HeightRadius, StartAngle = arcTO.StartAngle, SwingAngle = arcTO.SwingAngle };
-                    Paths.Add(arcToPath);
+                    //ArcToPath arcToPath = new ArcToPath() { WidthRadius = arcTO.WidthRadius, HeightRadius = arcTO.HeightRadius, StartAngle = arcTO.StartAngle, SwingAngle = arcTO.SwingAngle };
+                  //  Paths.Add(arcToPath);
                 }
                 ///判断路径是否闭合
                 if (xmlElement is DocumentFormat.OpenXml.Drawing.CloseShapePath close)
@@ -887,9 +887,9 @@ namespace HiTeachCC.Service.PowerPoint.Implement
             {
                 Color = color,
                 Size = font_size,
-                Type = font_family,
-                Bold = font_weight,
-                Italic = font_style,
+                Family = font_family,
+                Weight = font_weight,
+                Style = font_style,
                 Decoration = text_decoration,
                 VertAlign = vertical_align
             };

Plik diff jest za duży
+ 846 - 70
TEAMModelOS.Service/Services/PowerPoint/Implement/ShapeGenerator.cs


+ 7 - 2
TEAMModelOS.Service/Services/PowerPoint/Implement/ShapeHelper.cs

@@ -454,12 +454,17 @@ namespace TEAMModelOS.Service.Services.PowerPoint.Implement
             //处理前景色 
             var fgClr = node.GetTextByPath("a:fgClr");
             string fgclr = GetSolidFill(fgClr, slideLayoutClrOvride, slideMasterContent, themeContent);
-            fgclr = PowerPointHelper.ColorToning(fgClr.OuterXml, fgclr);
+            if (fgClr != null) {
+                fgclr = PowerPointHelper.ColorToning(fgClr.OuterXml, fgclr);
+            }
+            
             fill.gradColor.Add(fgclr);
             // 处理背景色
             var bgClr = node.GetTextByPath("a:bgClr");
             string bgclr = GetSolidFill(bgClr, slideLayoutClrOvride, slideMasterContent, themeContent);
-            bgclr = PowerPointHelper.ColorToning(bgClr.OuterXml, bgclr);
+            if (bgClr != null) {
+                bgclr = PowerPointHelper.ColorToning(bgClr.OuterXml, bgclr);
+            }
             //处理内置图案属性
             var prst = node.GetTextByPath("@prst");
             if (prst != null)

+ 1 - 1
TEAMModelOS.Service/Services/PowerPoint/Implement/ShapeSvg.cs

@@ -1199,7 +1199,7 @@ namespace TEAMModelOS.Service.Services.PowerPoint.Implement
 
 
 
-        private static string ShapeArc(double cX, double cY, double rX, double rY, double stAng, double endAng, bool isClose)
+        public static string ShapeArc(double cX, double cY, double rX, double rY, double stAng, double endAng, bool isClose)
         {
             string dData = "";
             var angle = stAng;

+ 18 - 0
TEAMModelOS.sln

@@ -11,6 +11,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TEAMModelOS.Service", "TEAM
 EndProject
 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TEAMModelOS.Grpc", "TEAMModelOS.Grpc\TEAMModelOS.Grpc.csproj", "{75C46F80-6FDB-4589-A045-1C10F3FCD225}"
 EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Test", "Test", "{53913D96-CC85-4698-9241-84761C58EAC3}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TEAMModelOS.JsonRPC", "TEAMModelOS.JsonRPC\TEAMModelOS.JsonRPC.csproj", "{62889C98-D423-4F80-AB07-0BB3F842CF8D}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TEAMModelOS.JsonRPC3", "TEAMModelOS.JsonRPC3\TEAMModelOS.JsonRPC3.csproj", "{100F1A4F-84AE-4282-8E52-D009AAE914EB}"
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
@@ -33,10 +39,22 @@ Global
 		{75C46F80-6FDB-4589-A045-1C10F3FCD225}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{75C46F80-6FDB-4589-A045-1C10F3FCD225}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{75C46F80-6FDB-4589-A045-1C10F3FCD225}.Release|Any CPU.Build.0 = Release|Any CPU
+		{62889C98-D423-4F80-AB07-0BB3F842CF8D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{62889C98-D423-4F80-AB07-0BB3F842CF8D}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{62889C98-D423-4F80-AB07-0BB3F842CF8D}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{62889C98-D423-4F80-AB07-0BB3F842CF8D}.Release|Any CPU.Build.0 = Release|Any CPU
+		{100F1A4F-84AE-4282-8E52-D009AAE914EB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{100F1A4F-84AE-4282-8E52-D009AAE914EB}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{100F1A4F-84AE-4282-8E52-D009AAE914EB}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{100F1A4F-84AE-4282-8E52-D009AAE914EB}.Release|Any CPU.Build.0 = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE
 	EndGlobalSection
+	GlobalSection(NestedProjects) = preSolution
+		{62889C98-D423-4F80-AB07-0BB3F842CF8D} = {53913D96-CC85-4698-9241-84761C58EAC3}
+		{100F1A4F-84AE-4282-8E52-D009AAE914EB} = {53913D96-CC85-4698-9241-84761C58EAC3}
+	EndGlobalSection
 	GlobalSection(ExtensibilityGlobals) = postSolution
 		SolutionGuid = {76440725-5E50-4288-851F-BA5C0BC8E8C6}
 	EndGlobalSection

+ 1 - 1
TEAMModelOS/Controllers/Core/ClassRoomController.cs

@@ -13,7 +13,7 @@ namespace TEAMModelOS.Controllers.Syllabus
 {
     [Route("api/[controller]")]
     [ApiController]
-    public  class ClassroomController:BaseController
+    public  class ClassroomController : BaseController
     {
         public readonly IAzureCosmosDBRepository cosmosrepository;
         public ClassroomController(IAzureCosmosDBRepository _cosmosrepository) {

+ 20 - 19
TEAMModelOS/Controllers/Core/CommonController.cs

@@ -12,6 +12,7 @@ using TEAMModelOS.Models;
 using TEAMModelOS.SDK.Context.Exception;
 using TEAMModelOS.SDK.Extension.DataResult.JsonRpcRequest;
 using TEAMModelOS.SDK.Extension.DataResult.JsonRpcResponse;
+using TEAMModelOS.SDK.Helper.Common.JsonHelper;
 using TEAMModelOS.SDK.Helper.Common.JsonHelper.JsonPath;
 using TEAMModelOS.SDK.Module.AzureCosmosDB.Interfaces;
 using static System.Text.Json.JsonElement;
@@ -43,38 +44,37 @@ namespace TEAMModelOS.Controllers.Syllabus
             string contentRootPath = webHostEnvironment.ContentRootPath;
             JsonDocument document = await GetJson(contentRootPath, "/JsonFile/Core/BaseDataDefault.json");
 
-            string data = getJson(contentRootPath, "/JsonFile/Core/BaseDataDefault.json");
-
-            JArray parsedJson = JArray.Parse(data);
+            //string data = getJson(contentRootPath, "/JsonFile/Core/BaseDataDefault.json");
+            //JArray parsedJson = JArray.Parse(data);
             if (!request.@params)
             {
             
-                List<JObject> jsonElements = new List<JObject>();
-                foreach (JObject element in parsedJson )
-                {
-                    if (element.TryGetValue("lang", out JToken json))
-                    {
-                        if (json.ToString().Equals(request.lang))
-                        {
-                            jsonElements.Add(element);
-                        }
-                    }
-                }
-                //foreach (JsonElement element in document.RootElement.EnumerateArray())
+                List<JsonElement> jsonElements = new List<JsonElement>();
+                //foreach (JObject element in parsedJson )
                 //{
-                //    if (element.TryGetProperty("lang", out JsonElement json))
+                //    if (element.TryGetValue("lang", out JToken json))
                 //    {
-                //        if (json.GetString().Equals(request.lang))
+                //        if (json.ToString().Equals(request.lang))
                 //        {
                 //            jsonElements.Add(element);
                 //        }
                 //    }
                 //}
+                foreach (JsonElement element in document.RootElement.EnumerateArray())
+                {
+                    if (element.TryGetProperty("lang", out JsonElement json))
+                    {
+                        if (json.GetString().Equals(request.lang))
+                        {
+                            jsonElements.Add(element);
+                        }
+                    }
+                }
                 return builder.Data(jsonElements).build();
             }
             else
             {
-                return builder.Data(parsedJson).build();
+                return builder.Data(document.RootElement).build();
             }
         }
 
@@ -126,7 +126,8 @@ namespace TEAMModelOS.Controllers.Syllabus
         {
             JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
             IQueryable<dynamic>  data =   azureCosmosDBRepository.FindByDict(request.@params.collectionName,request.@params.queryDict);
-            return builder.Data(data).build();
+            JsonElement json = JsonApiHelper.FromApiJson<JsonElement>( data.ToJson());
+            return builder.Data(json).build();
         }
     }
 }

+ 3 - 1
TEAMModelOS/Startup.cs

@@ -98,7 +98,8 @@ namespace TEAMModelOS
             //    });
             //});
             services.AddMemoryCache();
-            services.AddControllers().AddNewtonsoftJson().AddJsonOptions(options => { options.JsonSerializerOptions.IgnoreNullValues = true; });
+          //  services.AddJsonRpc();
+            services.AddControllers();//.AddNewtonsoftJson().AddJsonOptions(options => { options.JsonSerializerOptions.IgnoreNullValues = true; });
             //上传文件最大处理
             services.Configure<FormOptions>(x =>
             {   x.BufferBodyLengthLimit= long.MaxValue;
@@ -145,6 +146,7 @@ namespace TEAMModelOS
             //调用放在之后、UseRouting 和 UseCors,但在 UseEndpoints之前
             app.UseAuthentication();
             app.UseAuthorization();
+          //  app.UseJsonRpc();
             app.UseEndpoints(endpoints =>
             {
                 endpoints.MapControllers();

+ 4 - 3
TEAMModelOS/TEAMModelOS.csproj

@@ -10,10 +10,11 @@
   </PropertyGroup>
 
   <ItemGroup>
-    <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.0" />
-    <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="3.1.0" />
-    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.0" />
+    <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.0.0" />
+    <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="3.0.0" />
+    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.0.0" />
     <PackageReference Include="VueCliMiddleware" Version="3.0.0" />
+    <PackageReference Include="EdjCase.JsonRpc.Router" Version="3.0.1" />
   </ItemGroup>
 
   <ItemGroup>