|
@@ -1,31 +1,21 @@
|
|
|
-using DocumentFormat.OpenXml.Drawing;
|
|
|
using DocumentFormat.OpenXml.Packaging;
|
|
|
-using DocumentFormat.OpenXml.Presentation;
|
|
|
using HiTeachCC.Model.PowerPoint;
|
|
|
using HiTeachCC.Service.PowerPoint.Interface;
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
-using System.Drawing;
|
|
|
using System.IO;
|
|
|
-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.ColorHelper;
|
|
|
-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 TEAMModelOS.Service.Models.PowerPoint.Inner;
|
|
|
using TEAMModelOS.Service.Services.PowerPoint.Implement;
|
|
|
-using ColorMap = DocumentFormat.OpenXml.Presentation.ColorMap;
|
|
|
using Fill = HiTeachCC.Model.PowerPoint.Fill;
|
|
|
using Media = HiTeachCC.Model.PowerPoint.Media;
|
|
|
using Position = HiTeachCC.Model.PowerPoint.Position;
|
|
@@ -39,7 +29,7 @@ namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
private List<object> MsgQueue = new List<object>();
|
|
|
|
|
|
private Dictionary<string, string> slideLayoutClrOvride { get; set; }
|
|
|
- // private XmlNode themeContent { get; set; }
|
|
|
+ // private XmlNode themeContent { get; set; }
|
|
|
|
|
|
private int chartID = 0;
|
|
|
private int _order = 1;
|
|
@@ -53,7 +43,7 @@ namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
public readonly IAzureBlobDBRepository azureBlobDBRepository;
|
|
|
|
|
|
public ShapeGenerator(IAzureBlobDBRepository _azureBlobDBRepository)
|
|
|
- {
|
|
|
+ {
|
|
|
azureBlobDBRepository = _azureBlobDBRepository;
|
|
|
}
|
|
|
|
|
@@ -63,7 +53,7 @@ namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
|
|
|
if (FileType.GetExtention(file.FileName).ToLower().Equals("pptx"))
|
|
|
{
|
|
|
- await ConvertPPTX(file, resdict);
|
|
|
+ await ConvertPPTX(file, resdict);
|
|
|
return resdict;
|
|
|
}
|
|
|
else if (FileType.GetExtention(file.FileName).ToLower().Equals("pdf"))
|
|
@@ -81,18 +71,18 @@ namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
{
|
|
|
string shaCode = fileShaCode = ShaHashHelper.GetSHA1(file.OpenReadStream());
|
|
|
|
|
|
- PresentationDocument presentationDocument = PresentationDocument.Open(file.OpenReadStream(), false);
|
|
|
- if (presentationDocument == null)
|
|
|
- {
|
|
|
- throw new ArgumentNullException("presentationDocument");
|
|
|
- }
|
|
|
- XDocument xdoc = presentationDocument.ToFlatOpcDocument();
|
|
|
- XmlDocument xmlDocument = new XmlDocument();
|
|
|
- xmlDocument.LoadXml(xdoc.ToString());
|
|
|
-
|
|
|
- var rslt_ary = await ProcessPPTX(xmlDocument, shaCode);
|
|
|
- //TODO
|
|
|
- return null;
|
|
|
+ PresentationDocument presentationDocument = PresentationDocument.Open(file.OpenReadStream(), false);
|
|
|
+ if (presentationDocument == null)
|
|
|
+ {
|
|
|
+ throw new ArgumentNullException("presentationDocument");
|
|
|
+ }
|
|
|
+ XDocument xdoc = presentationDocument.ToFlatOpcDocument();
|
|
|
+ XmlDocument xmlDocument = new XmlDocument();
|
|
|
+ xmlDocument.LoadXml(xdoc.ToString());
|
|
|
+
|
|
|
+ var rslt_ary = await ProcessPPTX(xmlDocument, shaCode);
|
|
|
+ //TODO
|
|
|
+ return null;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -111,20 +101,20 @@ namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
//获取全部的/ppt/slideLayouts/slideLayout1.xml--->>/ppt/slideLayouts/slideLayout(n).xml
|
|
|
var slideLayoutNodes = xdoc.GetTextByPathList("//pkg:part[@pkg:contentType='application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml']");
|
|
|
//获取ppt的宽高
|
|
|
- var slideSize = ShapeHelper. GetSlideSize(xdoc);
|
|
|
+ var slideSize = ShapeHelper.GetSlideSize(xdoc);
|
|
|
post_ary.Add(new Dictionary<string, object> { { "slideSize", slideSize } });
|
|
|
//加载当前PPT使用到的PPT节点
|
|
|
- var themeContent = LoadTheme(xdoc);
|
|
|
+ var themeContent = LoadTheme(xdoc);
|
|
|
//获取所有的表格样式节点
|
|
|
var tableStyles = xdoc.GetTextByPath("//pkg:part[@pkg:name='/ppt/tableStyles.xml']/pkg:xmlData/a:tblStyleLst");
|
|
|
//处理slide1---slide(n)
|
|
|
int numOfSlides = slideNodes.Count;
|
|
|
-
|
|
|
+
|
|
|
for (int i = 0; i < numOfSlides; i++)
|
|
|
{
|
|
|
string filename = slideNodes[i].GetTextByPath("@pkg:name").Value;
|
|
|
//处理当前页的幻灯片
|
|
|
- string slideHtml = await ProcessSingleSlide(xdoc, slideNodes[i], filename, i, slideSize ,themeContent);
|
|
|
+ string slideHtml = await ProcessSingleSlide(xdoc, slideNodes[i], filename, i, slideSize, themeContent);
|
|
|
post_ary.Add(new Dictionary<string, object> { { "slide", slideHtml } });
|
|
|
post_ary.Add(new Dictionary<string, object> { { "progress-update", (i + 1) * 100 / numOfSlides } });
|
|
|
|
|
@@ -149,9 +139,9 @@ namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
return cssText;
|
|
|
}
|
|
|
|
|
|
- public async Task<string> ProcessSingleSlide(XmlDocument xdoc, XmlNode xnode, string sldFileName, int index, dynamic slideSize ,XmlNode themeContent)
|
|
|
+ public async Task<string> ProcessSingleSlide(XmlDocument xdoc, XmlNode xnode, string sldFileName, int index, dynamic slideSize, XmlNode themeContent)
|
|
|
{
|
|
|
-
|
|
|
+
|
|
|
var resName = sldFileName.Replace("slides/slide", "slides/_rels/slide") + ".rels";
|
|
|
var RelationshipArray = xdoc.GetTextByPathList("//pkg:part[@pkg:name='" + resName + "']/pkg:xmlData/rel:Relationships/rel:Relationship");
|
|
|
Dictionary<string, Dictionary<string, string>> slideResObj = new Dictionary<string, Dictionary<string, string>>();
|
|
@@ -181,7 +171,7 @@ namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
}
|
|
|
// Open slideLayoutXX.xml
|
|
|
var slideLayoutContent = xdoc.GetTextByPath("//pkg:part[@pkg:name='" + layoutFilename + "']");
|
|
|
- NodesTable slideLayoutTables =ShapeHelper. IndexNodes(slideLayoutContent.GetTextByPath("pkg:xmlData/p:sldLayout"));
|
|
|
+ NodesTable slideLayoutTables = ShapeHelper.IndexNodes(slideLayoutContent.GetTextByPath("pkg:xmlData/p:sldLayout"));
|
|
|
///ppt/slides/slide5.xml 也包含a:overrideClrMapping
|
|
|
////ppt/slideLayouts/slideLayout13.xml 也包含a:overrideClrMapping
|
|
|
var sldLayoutClrOvr = slideLayoutContent.GetTextByPath("pkg:xmlData/p:sldLayout/p:clrMapOvr/a:overrideClrMapping");
|
|
@@ -277,8 +267,8 @@ namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
layoutResObj = layoutResObj,
|
|
|
masterResObj = masterResObj,
|
|
|
slideLayoutContent = slideLayoutContent,
|
|
|
- slideMasterContent=slideMasterContent,
|
|
|
- themeContent=themeContent
|
|
|
+ slideMasterContent = slideMasterContent,
|
|
|
+ themeContent = themeContent
|
|
|
};
|
|
|
var bgColor = GetSlideBackgroundFill(slideContent, index, warpObj);
|
|
|
string result = "<div class='slide' style='width:" + slideSize.width + "px; height:" + slideSize.height + "px;" + bgColor + "'>";
|
|
@@ -289,47 +279,46 @@ namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
int order = 1;
|
|
|
foreach (XmlNode node in nodes)
|
|
|
{
|
|
|
- result += await ProcessNodesInSlide(node.Name, node , order, warpObj);
|
|
|
+ result += await ProcessNodesInSlide(node.Name, node, order, warpObj);
|
|
|
order += 1;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- public async Task<string> ProcessNodesInSlide(string nodeKey, XmlNode node ,int order, WarpObj warpObj)
|
|
|
+ public async Task<string> ProcessNodesInSlide(string nodeKey, XmlNode node, int order, WarpObj warpObj)
|
|
|
{
|
|
|
- string result ="";
|
|
|
-
|
|
|
- switch (nodeKey)
|
|
|
- {
|
|
|
- case "p:sp": // Shape, Text
|
|
|
- result = await ProcessSpNode(node, order, warpObj);
|
|
|
- break;
|
|
|
- case "p:cxnSp": // Shape, Text (with connection)
|
|
|
- result = await ProcessCxnSpNode(node, order, warpObj);
|
|
|
- break;
|
|
|
- case "p:pic": // Picture
|
|
|
- await ProcessPicNode(node, order, warpObj);
|
|
|
- break;
|
|
|
- case "p:graphicFrame": // Chart, Diagram, Table
|
|
|
- result = ProcessGraphicFrameNode(node, order, warpObj);
|
|
|
- break;
|
|
|
- case "p:grpSp":
|
|
|
- await ProcessGroupSpNode(node, order, warpObj);
|
|
|
- break;
|
|
|
- case "mc:AlternateContent": //Equations and formulas as Image
|
|
|
- var mcFallbackNode = node.GetTextByPath("mc:Fallback/p:sp");
|
|
|
- result = await ProcessSpNode(mcFallbackNode, order, warpObj);
|
|
|
- break;
|
|
|
- default:
|
|
|
- break;
|
|
|
- }
|
|
|
-
|
|
|
+ string result = "";
|
|
|
+
|
|
|
+ switch (nodeKey)
|
|
|
+ {
|
|
|
+ case "p:sp": // Shape, Text
|
|
|
+ result = await ProcessSpNode(node, order, warpObj);
|
|
|
+ break;
|
|
|
+ case "p:cxnSp": // Shape, Text (with connection)
|
|
|
+ result = await ProcessCxnSpNode(node, order, warpObj);
|
|
|
+ break;
|
|
|
+ case "p:pic": // Picture
|
|
|
+ await ProcessPicNode(node, order, warpObj);
|
|
|
+ break;
|
|
|
+ case "p:graphicFrame": // Chart, Diagram, Table
|
|
|
+ result = ProcessGraphicFrameNode(node, order, warpObj);
|
|
|
+ break;
|
|
|
+ case "p:grpSp":
|
|
|
+ await ProcessGroupSpNode(node, order, warpObj);
|
|
|
+ break;
|
|
|
+ case "mc:AlternateContent": //Equations and formulas as Image 处理公式 方程等
|
|
|
+ var mcFallbackNode = node.GetTextByPath("mc:Fallback/p:sp");
|
|
|
+ result = await ProcessSpNode(mcFallbackNode, order, warpObj);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- public async Task<string> ProcessGroupSpNode(XmlNode node, int order, WarpObj warpObj)
|
|
|
+ public async Task<string> ProcessGroupSpNode(XmlNode node, int order, WarpObj warpObj)
|
|
|
{
|
|
|
var factor = 1.00 * px96 / px914400;
|
|
|
|
|
@@ -348,7 +337,7 @@ namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
var nodes = node.ChildNodes;
|
|
|
foreach (XmlNode nd in nodes)
|
|
|
{
|
|
|
- result += await ProcessNodesInSlide(nd.Name, nd ,order, warpObj);
|
|
|
+ result += await ProcessNodesInSlide(nd.Name, nd, order, warpObj);
|
|
|
order += 1;
|
|
|
}
|
|
|
|
|
@@ -361,7 +350,8 @@ namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
{
|
|
|
var result = "";
|
|
|
var graphicTypeUri = node.GetTextByPath("a:graphic/a:graphicData/uri");
|
|
|
- if (graphicTypeUri != null) {
|
|
|
+ if (graphicTypeUri != null)
|
|
|
+ {
|
|
|
switch (graphicTypeUri.Value)
|
|
|
{
|
|
|
case "http://schemas.openxmlformats.org/drawingml/2006/table":
|
|
@@ -377,14 +367,14 @@ namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
public string GenDiagram(XmlNode node, WarpObj warpObj)
|
|
|
{
|
|
|
- return "";
|
|
|
+ return "";
|
|
|
}
|
|
|
|
|
|
public string GenChart(XmlNode node, WarpObj warpObj)
|
|
@@ -403,7 +393,7 @@ namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
|
|
|
var id = node.GetTextByPath("p:nvCxnSpPr/p:cNvPr/@id");
|
|
|
var name = node.GetTextByPath("p:nvCxnSpPr/p:cNvPr/@name");
|
|
|
- return await GenShape(node, null, null, id, name, null, null, order, warpObj);
|
|
|
+ return await GenShape(node, null, null, id, name, null, null, order, warpObj);
|
|
|
}
|
|
|
|
|
|
public async Task<string> ProcessSpNode(XmlNode node, int order, WarpObj warpObj)
|
|
@@ -424,8 +414,8 @@ namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
var name = node.GetTextByPath("p:nvSpPr/p:cNvPr/@name");
|
|
|
var idx = node.GetTextByPath("p:nvSpPr/p:nvPr/p:ph/@idx");
|
|
|
var type = node.GetTextByPath("p:nvSpPr/p:nvPr/p:ph/@type");
|
|
|
-
|
|
|
- XmlNode slideLayoutSpNode =ShapeHelper. GetNodesTable(id,idx,type,warpObj, "Layout");
|
|
|
+
|
|
|
+ XmlNode slideLayoutSpNode = ShapeHelper.GetNodesTable(id, idx, type, warpObj, "Layout");
|
|
|
XmlNode slideMasterSpNode = ShapeHelper.GetNodesTable(id, idx, type, warpObj, "Master");
|
|
|
if (type == null)
|
|
|
{
|
|
@@ -445,10 +435,10 @@ namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
}
|
|
|
}
|
|
|
string s = await GenShape(node, slideLayoutSpNode, slideMasterSpNode, id, name, idx, type, order, warpObj);
|
|
|
-
|
|
|
+
|
|
|
return "";
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public async Task<string> GenShape(XmlNode node, XmlNode slideLayoutSpNode, XmlNode slideMasterSpNode, XmlNode id, XmlNode name, XmlNode idx, XmlNode type, int order, WarpObj warpObj)
|
|
|
{
|
|
|
var xfrmList = "p:spPr/a:xfrm";
|
|
@@ -463,10 +453,12 @@ namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
{
|
|
|
slideMasterXfrmNode = slideMasterSpNode.GetTextByPath(xfrmList);
|
|
|
}
|
|
|
- if (slideXfrmNode == null) {
|
|
|
+ if (slideXfrmNode == null)
|
|
|
+ {
|
|
|
slideXfrmNode = slideLayoutXfrmNode;
|
|
|
}
|
|
|
- if (slideXfrmNode == null) {
|
|
|
+ if (slideXfrmNode == null)
|
|
|
+ {
|
|
|
slideXfrmNode = slideMasterXfrmNode;
|
|
|
}
|
|
|
var result = "";
|
|
@@ -484,14 +476,14 @@ namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
isFlipH = 1;
|
|
|
}
|
|
|
//rotate
|
|
|
- var rotate =ShapeHelper. AngleToDegrees(slideXfrmNode.GetTextByPath("@rot"));
|
|
|
+ var rotate = ShapeHelper.AngleToDegrees(slideXfrmNode.GetTextByPath("@rot"));
|
|
|
|
|
|
//console.log("rotate: "+rotate);
|
|
|
double txtRotate;
|
|
|
var txtXframeNode = node.GetTextByPath("p:txXfrm/@rot");
|
|
|
if (txtXframeNode != null)
|
|
|
{
|
|
|
- txtRotate =ShapeHelper. AngleToDegrees(txtXframeNode) + 90;
|
|
|
+ txtRotate = ShapeHelper.AngleToDegrees(txtXframeNode) + 90;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -501,7 +493,7 @@ namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
{
|
|
|
|
|
|
|
|
|
- Position position = ShapeHelper. GetPosition(slideXfrmNode, slideLayoutXfrmNode, slideMasterXfrmNode);
|
|
|
+ Position position = ShapeHelper.GetPosition(slideXfrmNode, slideLayoutXfrmNode, slideMasterXfrmNode);
|
|
|
position.Rot = rotate;
|
|
|
position.FlipH = isFlipH;
|
|
|
position.FlipV = isFlipV;
|
|
@@ -518,7 +510,7 @@ namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
var Fill = await GetShapeFill(node, warpObj);
|
|
|
var grndFillFlg = false;
|
|
|
var imgFillFlg = false;
|
|
|
- var clrFillType = ShapeHelper. GetFillType(node.GetTextByPath("p:spPr"));
|
|
|
+ var clrFillType = ShapeHelper.GetFillType(node.GetTextByPath("p:spPr"));
|
|
|
/////////////////////////////////////////
|
|
|
if (clrFillType == "GRADIENT_FILL")
|
|
|
{
|
|
@@ -526,34 +518,41 @@ namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
var color_arry = Fill.gradColor;
|
|
|
var angl = Fill.Rot;
|
|
|
|
|
|
- var svgGrdnt =ShapeHelper. GetSvgGradient(position.Cx,position.Cy, angl, color_arry, order, slideLayoutClrOvride, warpObj. themeContent);
|
|
|
+ var svgGrdnt = ShapeHelper.GetSvgGradient(position.Cx, position.Cy, angl, color_arry, order, slideLayoutClrOvride, warpObj.themeContent);
|
|
|
//fill="url(#linGrd)"
|
|
|
result += svgGrdnt;
|
|
|
}
|
|
|
else if (clrFillType == "PIC_FILL")
|
|
|
{
|
|
|
imgFillFlg = true;
|
|
|
- var svgBgImg = ShapeHelper. GetSvgImagePattern(Fill.Image, order);
|
|
|
+ var svgBgImg = ShapeHelper.GetSvgImagePattern(Fill.Image, order);
|
|
|
//fill="url(#imgPtrn)"
|
|
|
//console.log(svgBgImg)
|
|
|
result += svgBgImg;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- if (clrFillType != "SOLID_FILL" && clrFillType != "PATTERN_FILL" &&
|
|
|
- (shapType.Value == "arc" ||
|
|
|
- shapType.Value == "bracketPair" ||
|
|
|
- shapType.Value == "bracePair" ||
|
|
|
- shapType.Value == "leftBracket" ||
|
|
|
- shapType.Value == "leftBrace" ||
|
|
|
- shapType.Value == "rightBrace" ||
|
|
|
- shapType.Value == "rightBracket"))
|
|
|
- { //Temp. solution - TODO
|
|
|
+ if (clrFillType != null && clrFillType != "SOLID_FILL" && clrFillType != "PATTERN_FILL")
|
|
|
+ {
|
|
|
Fill.HtmlText = "none";
|
|
|
}
|
|
|
+ if (shapType != null)
|
|
|
+ {
|
|
|
+ if (shapType.Value == "arc" ||
|
|
|
+ shapType.Value == "bracketPair" ||
|
|
|
+ shapType.Value == "bracePair" ||
|
|
|
+ shapType.Value == "leftBracket" ||
|
|
|
+ shapType.Value == "leftBrace" ||
|
|
|
+ shapType.Value == "rightBrace" ||
|
|
|
+ shapType.Value == "rightBracket")
|
|
|
+ { //Temp. solution - TODO
|
|
|
+ Fill.HtmlText = "none";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
// Border Color
|
|
|
- var border =ShapeHelper. GetBorder(node, true, "shape" , slideLayoutClrOvride, warpObj.themeContent);
|
|
|
+ var border = ShapeHelper.GetBorder(node, true, "shape", slideLayoutClrOvride, warpObj.themeContent);
|
|
|
|
|
|
var headEndNodeAttrs = node.GetTextByPath("p:spPr/a:ln/a:headEnd");
|
|
|
var tailEndNodeAttrs = node.GetTextByPath("p:spPr/a:ln/a:tailEnd");
|
|
@@ -567,8 +566,8 @@ namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
result += triangleMarker;
|
|
|
}
|
|
|
result += "</defs>";
|
|
|
- }
|
|
|
-
|
|
|
+ }
|
|
|
+
|
|
|
return result;
|
|
|
}
|
|
|
|
|
@@ -581,38 +580,82 @@ namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
/// <param name="index"></param>
|
|
|
/// <param name="warpObj"></param>
|
|
|
/// <returns></returns>
|
|
|
- public async Task<Fill> GetSlideBackgroundFill(XmlNode slideContent , int index, WarpObj warpObj)
|
|
|
+ public async Task<Fill> GetSlideBackgroundFill(XmlNode slideContent, int index, WarpObj warpObj)
|
|
|
{
|
|
|
var bgPr = slideContent.GetTextByPath("p:sld/p:cSld/p:bg/p:bgPr");
|
|
|
var bgRef = slideContent.GetTextByPath("p:sld/p:cSld/p:bg/p:bgRef");
|
|
|
if (bgPr != null)
|
|
|
{
|
|
|
- var bgFillTyp = ShapeHelper. GetFillType(bgPr);
|
|
|
+ var bgFillTyp = ShapeHelper.GetFillType(bgPr);
|
|
|
if (bgFillTyp == "SOLID_FILL")
|
|
|
{
|
|
|
var sldFill = bgPr.GetTextByPath("a:solidFill");
|
|
|
- var bgColor =ShapeHelper. GetSolidFill(sldFill, slideLayoutClrOvride,warpObj.slideMasterContent, warpObj.themeContent);
|
|
|
- bgColor= PowerPointHelper.ColorToning(sldFill.OuterXml, bgColor);
|
|
|
+ var bgColor = ShapeHelper.GetSolidFill(sldFill, slideLayoutClrOvride, warpObj.slideMasterContent, warpObj.themeContent);
|
|
|
+ bgColor = PowerPointHelper.ColorToning(sldFill.OuterXml, bgColor);
|
|
|
|
|
|
return new Fill { Type = 1, Color = bgColor };
|
|
|
}
|
|
|
else if (bgFillTyp == "GRADIENT_FILL")
|
|
|
{
|
|
|
- return ShapeHelper. GetBgGradientFill(bgPr, null ,slideLayoutClrOvride, warpObj.slideMasterContent, warpObj.themeContent);
|
|
|
+ return ShapeHelper.GetBgGradientFill(bgPr, null, slideLayoutClrOvride, warpObj.slideMasterContent, warpObj.themeContent);
|
|
|
}
|
|
|
else if (bgFillTyp == "PIC_FILL")
|
|
|
{
|
|
|
- return await GetPicFill("slideBg", bgPr.GetTextByPath("a:blipFill"), warpObj) ;
|
|
|
+ return await GetPicFill("slideBg", bgPr.GetTextByPath("a:blipFill"), warpObj);
|
|
|
|
|
|
}
|
|
|
}
|
|
|
else if (bgRef != null)
|
|
|
{
|
|
|
- XmlNode phClr;
|
|
|
-
|
|
|
- string color= ShapeHelper.GetSolidFill(bgRef, slideLayoutClrOvride, warpObj.slideMasterContent, warpObj.themeContent);
|
|
|
- color = PowerPointHelper.ColorToning(bgRef.OuterXml, color);
|
|
|
+ string phClr = ShapeHelper.GetSolidFill(bgRef, slideLayoutClrOvride, warpObj.slideMasterContent, warpObj.themeContent);
|
|
|
+ phClr = PowerPointHelper.ColorToning(bgRef.OuterXml, phClr);
|
|
|
var idx = bgRef.GetTextByPath("@idx");
|
|
|
+ if (idx != null)
|
|
|
+ {
|
|
|
+ int value = int.Parse(idx.Value);
|
|
|
+ if (value == 0 || value == 1000)
|
|
|
+ {
|
|
|
+ return new Fill { Type = 0 };
|
|
|
+ //no background
|
|
|
+ }
|
|
|
+ else if (value > 0 && value < 1000)
|
|
|
+ {
|
|
|
+ //fillStyleLst in themeContent
|
|
|
+ //themeContent["a:fmtScheme"]["a:fillStyleLst"]
|
|
|
+ //bgcolor = "background: red;";
|
|
|
+ }
|
|
|
+ else if (value > 1000)
|
|
|
+ {
|
|
|
+ var trueIdx = value - 1000;
|
|
|
+ var bgFillLst = warpObj.themeContent.GetTextByPath("a:theme/a:themeElements/a:fmtScheme/a:bgFillStyleLst");
|
|
|
+ if (bgFillLst != null) {
|
|
|
+ XmlNodeList nodeList = bgFillLst.ChildNodes;
|
|
|
+ if (trueIdx < nodeList.Count) {
|
|
|
+ string type= ShapeHelper.GetFillType(nodeList[trueIdx - 1]);
|
|
|
+ if (type.Equals("SOLID_FILL"))
|
|
|
+ {
|
|
|
+ if (string.IsNullOrEmpty(phClr))
|
|
|
+ {
|
|
|
+ phClr = ShapeHelper.GetSolidFill(nodeList[trueIdx - 1], slideLayoutClrOvride, warpObj.slideMasterContent, warpObj.themeContent);
|
|
|
+ }
|
|
|
+ phClr = PowerPointHelper.ColorToning(nodeList[trueIdx - 1].Value, phClr);
|
|
|
+ return new Fill { Type = 1, Color = phClr };
|
|
|
+ }
|
|
|
+ else if (type.Equals("GRADIENT_FILL"))
|
|
|
+ {
|
|
|
+ return ShapeHelper.GetBgGradientFill(nodeList[trueIdx - 1], phClr, slideLayoutClrOvride, warpObj.slideMasterContent, warpObj.themeContent);
|
|
|
+ }
|
|
|
+ else if (type.Equals("PIC_FILL"))
|
|
|
+ {
|
|
|
+ return await GetPicFill("slideBg", nodeList[trueIdx - 1].GetTextByPath("a:blipFill"), warpObj);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ return new Fill { Type = 0 };
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
//var node = bgRef.GetTextByPath("");
|
|
|
//if (bgRef["a:srgbClr"] !== undefined)
|
|
|
//{
|
|
@@ -627,14 +670,91 @@ namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
+ bgPr =warpObj. slideLayoutContent.GetTextByPath("p:sldLayout/p:cSld/p:bg/p:bgPr");
|
|
|
+ bgRef = warpObj. slideLayoutContent.GetTextByPath("p:sldLayout/p:cSld/p:bg/p:bgRef");
|
|
|
+ if (bgPr != null)
|
|
|
+ {
|
|
|
+ var bgFillTyp = ShapeHelper.GetFillType(bgPr);
|
|
|
+ if (bgFillTyp == "SOLID_FILL")
|
|
|
+ {
|
|
|
+ var sldFill = bgPr.GetTextByPath("a:solidFill");
|
|
|
+ var bgColor = ShapeHelper.GetSolidFill(sldFill, slideLayoutClrOvride, warpObj.slideMasterContent, warpObj.themeContent);
|
|
|
+ bgColor = PowerPointHelper.ColorToning(sldFill.OuterXml, bgColor);
|
|
|
+
|
|
|
+ return new Fill { Type = 1, Color = bgColor };
|
|
|
+ }
|
|
|
+ else if (bgFillTyp == "GRADIENT_FILL")
|
|
|
+ {
|
|
|
+ return ShapeHelper.GetBgGradientFill(bgPr, null, slideLayoutClrOvride, warpObj.slideMasterContent, warpObj.themeContent);
|
|
|
+ }
|
|
|
+ else if (bgFillTyp == "PIC_FILL")
|
|
|
+ {
|
|
|
+ return await GetPicFill("slideBg", bgPr.GetTextByPath("a:blipFill"), warpObj);
|
|
|
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (bgRef != null)
|
|
|
+ {
|
|
|
+ string phClr = ShapeHelper.GetSolidFill(bgRef, slideLayoutClrOvride, warpObj.slideMasterContent, warpObj.themeContent);
|
|
|
+ phClr = PowerPointHelper.ColorToning(bgRef.OuterXml, phClr);
|
|
|
+ var idx = bgRef.GetTextByPath("@idx");
|
|
|
+ if (idx != null)
|
|
|
+ {
|
|
|
+ int value = int.Parse(idx.Value);
|
|
|
+ if (value == 0 || value == 1000)
|
|
|
+ {
|
|
|
+ return new Fill { Type = 0 };
|
|
|
+ //no background
|
|
|
+ }
|
|
|
+ else if (value > 0 && value < 1000)
|
|
|
+ {
|
|
|
+ //fillStyleLst in themeContent
|
|
|
+ //themeContent["a:fmtScheme"]["a:fillStyleLst"]
|
|
|
+ //bgcolor = "background: red;";
|
|
|
+ }
|
|
|
+ else if (value > 1000)
|
|
|
+ {
|
|
|
+ var trueIdx = value - 1000;
|
|
|
+ var bgFillLst = warpObj.themeContent.GetTextByPath("a:theme/a:themeElements/a:fmtScheme/a:bgFillStyleLst");
|
|
|
+ if (bgFillLst != null)
|
|
|
+ {
|
|
|
+ XmlNodeList nodeList = bgFillLst.ChildNodes;
|
|
|
+ if (trueIdx < nodeList.Count)
|
|
|
+ {
|
|
|
+ string type = ShapeHelper.GetFillType(nodeList[trueIdx - 1]);
|
|
|
+ if (type.Equals("SOLID_FILL"))
|
|
|
+ {
|
|
|
+ if (string.IsNullOrEmpty(phClr))
|
|
|
+ {
|
|
|
+ phClr = ShapeHelper.GetSolidFill(nodeList[trueIdx - 1], slideLayoutClrOvride, warpObj.slideMasterContent, warpObj.themeContent);
|
|
|
+ }
|
|
|
+ phClr = PowerPointHelper.ColorToning(nodeList[trueIdx - 1].Value, phClr);
|
|
|
+ return new Fill { Type = 1, Color = phClr };
|
|
|
+ }
|
|
|
+ else if (type.Equals("GRADIENT_FILL"))
|
|
|
+ {
|
|
|
+ return ShapeHelper.GetBgGradientFill(nodeList[trueIdx - 1], phClr, slideLayoutClrOvride, warpObj.slideMasterContent, warpObj.themeContent);
|
|
|
+ }
|
|
|
+ else if (type.Equals("PIC_FILL"))
|
|
|
+ {
|
|
|
+ return await GetPicFill("slideBg", nodeList[trueIdx - 1].GetTextByPath("a:blipFill"), warpObj);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return new Fill { Type = 0 };
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
- public async Task<Fill> GetPicFill(string type, XmlNode node, WarpObj warpObj)
|
|
|
+
|
|
|
+ public async Task<Fill> GetPicFill(string type, XmlNode node, WarpObj warpObj)
|
|
|
{
|
|
|
|
|
|
//Need to test/////////////////////////////////////////////
|
|
@@ -642,7 +762,7 @@ namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
//TODO - Image Properties - Tile, Stretch, or Display Portion of Image
|
|
|
//(http://officeopenxml.com/drwPic-tile.php)
|
|
|
// var img = "";
|
|
|
- var rId = node.GetTextByPath( "a:blip/@r:embed");//node["a:blip"]["attrs"]["r:embed"];
|
|
|
+ var rId = node.GetTextByPath("a:blip/@r:embed");//node["a:blip"]["attrs"]["r:embed"];
|
|
|
Dictionary<string, string> imgPath = new Dictionary<string, string>();
|
|
|
if (type == "slideBg")
|
|
|
{
|
|
@@ -692,7 +812,7 @@ namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
// From slide
|
|
|
//Fill Type:
|
|
|
//console.log("ShapeFill: ", node)
|
|
|
- var fillType =ShapeHelper. GetFillType(node.GetTextByPath( "p:spPr"));
|
|
|
+ var fillType = ShapeHelper.GetFillType(node.GetTextByPath("p:spPr"));
|
|
|
Fill fill = new Fill();
|
|
|
//0
|
|
|
if (fillType == "NO_FILL")
|
|
@@ -706,16 +826,16 @@ namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
//1纯色填充
|
|
|
else if (fillType == "SOLID_FILL")
|
|
|
{
|
|
|
- XmlNode shpFill = node.GetTextByPath( "p:spPr/a:solidFill");// node["p:spPr"]["a:solidFill"];
|
|
|
- string color =ShapeHelper. GetSolidFill(shpFill, slideLayoutClrOvride,warpObj.slideMasterContent, warpObj. themeContent);
|
|
|
+ XmlNode shpFill = node.GetTextByPath("p:spPr/a:solidFill");// node["p:spPr"]["a:solidFill"];
|
|
|
+ string color = ShapeHelper.GetSolidFill(shpFill, slideLayoutClrOvride, warpObj.slideMasterContent, warpObj.themeContent);
|
|
|
return new Fill { Type = 1, Color = color };
|
|
|
}
|
|
|
//2渐变色填充
|
|
|
else if (fillType == "GRADIENT_FILL")
|
|
|
{
|
|
|
- var shpFill = node.GetTextByPath( "p:spPr/a:gradFill");// node["p:spPr"]["a:gradFill"];
|
|
|
+ var shpFill = node.GetTextByPath("p:spPr/a:gradFill");// node["p:spPr"]["a:gradFill"];
|
|
|
// fillColor = GetSolidFill(shpFill);
|
|
|
- fill =ShapeHelper. GetGradientFill(shpFill, slideLayoutClrOvride,warpObj.slideMasterContent, warpObj.themeContent);
|
|
|
+ fill = ShapeHelper.GetGradientFill(shpFill, slideLayoutClrOvride, warpObj.slideMasterContent, warpObj.themeContent);
|
|
|
//console.log("shpFill",shpFill,grndColor.color)
|
|
|
}//3图片 纹理填充
|
|
|
else if (fillType == "PIC_FILL")
|
|
@@ -739,17 +859,17 @@ namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
</a:bgClr>
|
|
|
</a:pattFill>
|
|
|
*/
|
|
|
- var shpFill = node.GetTextByPath( "p:spPr/a:pattFill");// node["p:spPr"]["a:pattFill"];
|
|
|
- fill =ShapeHelper. GetPatternFill(shpFill, slideLayoutClrOvride, warpObj.slideMasterContent, warpObj.themeContent);
|
|
|
+ var shpFill = node.GetTextByPath("p:spPr/a:pattFill");// node["p:spPr"]["a:pattFill"];
|
|
|
+ fill = ShapeHelper.GetPatternFill(shpFill, slideLayoutClrOvride, warpObj.slideMasterContent, warpObj.themeContent);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
// 2. drawingML namespace
|
|
|
if (fill == null)
|
|
|
{
|
|
|
- var clrName = node.GetTextByPath( "p:style/a:fillRef");
|
|
|
- string color = ShapeHelper. GetSolidFill(clrName, slideLayoutClrOvride,warpObj.slideMasterContent, warpObj.themeContent);
|
|
|
+ var clrName = node.GetTextByPath("p:style/a:fillRef");
|
|
|
+ string color = ShapeHelper.GetSolidFill(clrName, slideLayoutClrOvride, warpObj.slideMasterContent, warpObj.themeContent);
|
|
|
}
|
|
|
|
|
|
if (fill != null)
|
|
@@ -763,13 +883,14 @@ namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
//}
|
|
|
//else
|
|
|
//{
|
|
|
- var colorAry = fill.Color;
|
|
|
+ var colorAry = fill.gradColor;
|
|
|
var rot = fill.Rot;
|
|
|
|
|
|
var bgcolor = "background: linear-gradient(" + rot + "deg,";
|
|
|
- for (var i = 0; i < colorAry.Length; i++)
|
|
|
+
|
|
|
+ for (var i = 0; i < colorAry.Count; i++)
|
|
|
{
|
|
|
- if (i == colorAry.Length - 1)
|
|
|
+ if (i == colorAry.Count - 1)
|
|
|
{
|
|
|
bgcolor += colorAry[i] + ");";
|
|
|
}
|
|
@@ -827,8 +948,8 @@ namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
public async Task<AzureBlobModel> GetThumbnailModel(XmlDocument xdoc, string shaCode)
|
|
|
{
|
|
|
var thumbnailNode = xdoc.GetTextByPath("//pkg:part[@pkg:name='/docProps/thumbnail.jpeg']");
|
|
@@ -864,7 +985,7 @@ namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
fileExt = "." + sp[sp.Length - 1];
|
|
|
}
|
|
|
//data:image/jpeg;base64,
|
|
|
-
|
|
|
+
|
|
|
if (string.IsNullOrEmpty(fileName))
|
|
|
{
|
|
|
Stream stream = new MemoryStream(Convert.FromBase64String(data));
|
|
@@ -921,6 +1042,7 @@ namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
if (rid != null)
|
|
|
{
|
|
|
var imgName = warpObj.slideResObj[rid.Value]["target"];
|
|
|
+ Console.WriteLine(imgName);
|
|
|
if (!string.IsNullOrEmpty(imgName))
|
|
|
{
|
|
|
var imgData = warpObj.zip.GetTextByPath("//pkg:part[@pkg:name='" + imgName + "']");
|