|
@@ -1,107 +0,0 @@
|
|
|
-using DocumentFormat.OpenXml.Drawing;
|
|
|
-using DocumentFormat.OpenXml.Packaging;
|
|
|
-using DocumentFormat.OpenXml.Presentation;
|
|
|
-using HiTeachCC.Model.PowerPoint;
|
|
|
-using HiTeachCC.Service.Core.Implement;
|
|
|
-using HiTeachCC.Service.Core.Interface;
|
|
|
-using HiTeachCC.Service.PowerPoint.Interface;
|
|
|
-using Microsoft.AspNetCore.Http;
|
|
|
-using System;
|
|
|
-using System.Collections.Generic;
|
|
|
-using System.Linq;
|
|
|
-using System.Text;
|
|
|
-using System.Threading.Tasks;
|
|
|
-using System.Xml;
|
|
|
-using System.Xml.Linq;
|
|
|
-using System.Xml.XPath;
|
|
|
-using TEAMModelOS.SDK.Context.Constant;
|
|
|
-using TEAMModelOS.SDK.Context.Constant.Common;
|
|
|
-using TEAMModelOS.SDK.Context.Exception;
|
|
|
-using TEAMModelOS.SDK.Helper.Common.JsonHelper;
|
|
|
-using TEAMModelOS.SDK.Helper.Common.StringHelper;
|
|
|
-using TEAMModelOS.SDK.Helper.Security.ShaHash;
|
|
|
-using TEAMModelOS.SDK.Module.AzureBlob.Container;
|
|
|
-using TEAMModelOS.SDK.Module.AzureBlob.Interfaces;
|
|
|
-using ColorMap = DocumentFormat.OpenXml.Presentation.ColorMap;
|
|
|
-
|
|
|
-namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
-{
|
|
|
- public class ShapeGenerator :BaseService, IShapeGenerator
|
|
|
- {
|
|
|
- bool isDone = false;
|
|
|
- List<object> MsgQueue = new List<object>();
|
|
|
-
|
|
|
- // dynamic slideLayoutClrOvride;
|
|
|
- XmlDocument themeContent;
|
|
|
-
|
|
|
- int chartID = 0;
|
|
|
- int _order = 1;
|
|
|
- int titleFontSize = 42;
|
|
|
- int bodyFontSize = 20;
|
|
|
- int otherFontSize = 16;
|
|
|
- bool isSlideMode = false;
|
|
|
- Dictionary<string, object> styleTable = new Dictionary<string, object>();
|
|
|
- const double inchpixel = 96.00, inchpt = 72.00, pxBase = 914400.00, ptBase = 12700;
|
|
|
- const double rotBase = 60000.00;
|
|
|
- private readonly IAzureBlobDBRepository azureBlobDBRepository;
|
|
|
-
|
|
|
- public ShapeGenerator(IAzureBlobDBRepository _azureBlobDBRepository)
|
|
|
- {
|
|
|
- azureBlobDBRepository = _azureBlobDBRepository;
|
|
|
- }
|
|
|
-
|
|
|
- public async Task<Dictionary<string, object>> LoadPresentation(IFormFile file)
|
|
|
- {
|
|
|
- Dictionary<string, object> resdict = new Dictionary<string, object>();
|
|
|
-
|
|
|
- if (FileType.GetExtention(file.FileName).ToLower().Equals("pptx"))
|
|
|
- {
|
|
|
- ConvertPPTX(file, resdict);
|
|
|
- return resdict;
|
|
|
- }
|
|
|
- else if (FileType.GetExtention(file.FileName).ToLower().Equals("pdf"))
|
|
|
- {
|
|
|
- // await ProcessPDF(file, resdict);
|
|
|
- return resdict;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- throw new BizException(500, "file type does not support!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public Dictionary<string, object> ConvertPPTX(IFormFile file, Dictionary<string, object> resdict) {
|
|
|
- string shaCode = ShaHashHelper.GetSHA1(file.OpenReadStream());
|
|
|
- using (PresentationDocument presentationDocument = PresentationDocument.Open(file.OpenReadStream(), false))
|
|
|
- {
|
|
|
- if (presentationDocument == null)
|
|
|
- {
|
|
|
- throw new ArgumentNullException("presentationDocument");
|
|
|
- }
|
|
|
-
|
|
|
- XDocument xdoc = presentationDocument.ToFlatOpcDocument();
|
|
|
- var rslt_ary = ProcessPPTX(xdoc);
|
|
|
- return null;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// 加载PPTX文件
|
|
|
- /// </summary>
|
|
|
- /// <param name="presentationFile"></param>
|
|
|
- /// <returns></returns>
|
|
|
- public async Task<Dictionary<string, object>> ProcessPPTX(XDocument xdoc)
|
|
|
- {
|
|
|
- Dictionary<string, object> post_ary = new Dictionary<string, object>();
|
|
|
- try {
|
|
|
- var thumbnail = xdoc.GetTextByPath("//pkg:part[@pkg:name='/docProps/thumbnail.jpeg']");
|
|
|
- if (thumbnail != null) {
|
|
|
-
|
|
|
- }
|
|
|
- } catch (Exception e ) {
|
|
|
- throw new BizException(e.Message);
|
|
|
- }
|
|
|
- return null;
|
|
|
- }
|
|
|
- }
|
|
|
-}
|