|
@@ -31,6 +31,7 @@ namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
{
|
|
|
public class ShapeGenerator : IShapeGenerator
|
|
|
{
|
|
|
+ public string fileShaCode { get; set; }
|
|
|
bool isDone = false;
|
|
|
List<object> MsgQueue = new List<object>();
|
|
|
|
|
@@ -75,7 +76,8 @@ namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
|
|
|
public Dictionary<string, object> ConvertPPTX(IFormFile file, Dictionary<string, object> resdict)
|
|
|
{
|
|
|
- string shaCode = ShaHashHelper.GetSHA1(file.OpenReadStream());
|
|
|
+ string shaCode= fileShaCode = ShaHashHelper.GetSHA1(file.OpenReadStream());
|
|
|
+
|
|
|
using (PresentationDocument presentationDocument = PresentationDocument.Open(file.OpenReadStream(), false))
|
|
|
{
|
|
|
if (presentationDocument == null)
|
|
@@ -224,6 +226,7 @@ namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
layoutResObj.Add(Id, dict);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
// Open slideMasterXX.xml
|
|
|
var slideMasterContent = xdoc.GetTextByPath("//pkg:part[@pkg:name='" + masterFilename + "']");
|
|
|
var slideMasterTextStyles = slideMasterContent.GetTextByPath("pkg:xmlData/p:sldMaster/p:txStyles");
|
|
@@ -232,7 +235,7 @@ namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
//Open slideMasterXX.xml.rels
|
|
|
var slideMasterResFilename = masterFilename.Replace("slideMasters/slideMaster", "slideMasters/_rels/slideMaster") + ".rels";
|
|
|
var slideMasterResContent = xdoc.GetTextByPath("//pkg:part[@pkg:name='" + slideMasterResFilename + "']");
|
|
|
- RelationshipArray = slideLayoutResContent.GetTextByPathList("pkg:xmlData/rel:Relationships/rel:Relationship");
|
|
|
+ RelationshipArray = slideMasterResContent.GetTextByPathList("pkg:xmlData/rel:Relationships/rel:Relationship");
|
|
|
var themeFilename = "";
|
|
|
Dictionary<string, Dictionary<string, string>> masterResObj = new Dictionary<string, Dictionary<string, string>>();
|
|
|
for (int i = 0; i < RelationshipArray.Count; i++)
|
|
@@ -257,7 +260,7 @@ namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
{
|
|
|
themeContent = xdoc.GetTextByPath("//pkg:part[@pkg:name='" + themeFilename + "']");
|
|
|
}
|
|
|
-
|
|
|
+ Console.WriteLine(sldFileName, layoutFilename, masterFilename, themeFilename);
|
|
|
// =====< Step 3 >=====
|
|
|
var slideContent = xdoc.GetTextByPath("//pkg:part[@pkg:name='" + sldFileName + "']");
|
|
|
var spTreeNode = slideContent.GetTextByPath("pkg:xmlData/p:sld/p:cSld/p:spTree");
|
|
@@ -265,7 +268,7 @@ namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
{
|
|
|
zip = xdoc,
|
|
|
slideLayoutTables= slideLayoutTables,
|
|
|
- slideMasterTables = slideLayoutTables,
|
|
|
+ slideMasterTables = slideMasterTables,
|
|
|
slideMasterTextStyles= slideMasterTextStyles,
|
|
|
slideResObj= slideResObj,
|
|
|
layoutResObj= layoutResObj,
|
|
@@ -285,14 +288,14 @@ namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
return "";
|
|
|
}
|
|
|
|
|
|
- private dynamic ProcessNodesInSlide(string nodeKey, XmlNode nodeValue, WarpObj warpObj)
|
|
|
+ private async Task<dynamic> ProcessNodesInSlide(string nodeKey, XmlNode nodeValue, WarpObj warpObj)
|
|
|
{
|
|
|
var result = "";
|
|
|
|
|
|
switch (nodeKey)
|
|
|
{
|
|
|
case "p:sp": // Shape, Text
|
|
|
- result = ProcessSpNode(nodeValue, warpObj);
|
|
|
+ result = await ProcessSpNode(nodeValue, warpObj);
|
|
|
break;
|
|
|
case "p:cxnSp": // Shape, Text (with connection)
|
|
|
result = ProcessCxnSpNode(nodeValue, warpObj);
|
|
@@ -308,7 +311,7 @@ namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
break;
|
|
|
case "mc:AlternateContent": //Equations and formulas as Image
|
|
|
var mcFallbackNode = nodeValue.GetTextByPath("mc:Fallback/p:sp");
|
|
|
- result = ProcessSpNode(mcFallbackNode, warpObj);
|
|
|
+ result = await ProcessSpNode(mcFallbackNode, warpObj);
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
@@ -359,7 +362,7 @@ namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
throw new NotImplementedException();
|
|
|
}
|
|
|
|
|
|
- private string ProcessSpNode(XmlNode node , WarpObj warpObj)
|
|
|
+ private async Task<string> ProcessSpNode(XmlNode node , WarpObj warpObj)
|
|
|
{
|
|
|
|
|
|
/*
|
|
@@ -442,16 +445,23 @@ namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
// type = getTextByPathList(slideMasterSpNode, ["p:nvSpPr", "p:nvPr", "p:ph", "attrs", "type"]);
|
|
|
}
|
|
|
}
|
|
|
- string s = GenShape(node, slideLayoutSpNode, slideMasterSpNode, id, name, idx, type, order, warpObj);
|
|
|
+ string s = await GenShape(node, slideLayoutSpNode, slideMasterSpNode, id, name, idx, type, order, warpObj);
|
|
|
throw new NotImplementedException();
|
|
|
}
|
|
|
|
|
|
- private string GenShape(XmlNode node, XmlNode slideLayoutSpNode, XmlNode slideMasterSpNode, XmlNode id, XmlNode name, XmlNode idx, XmlNode type, XmlNode order, WarpObj warpObj)
|
|
|
+ private async Task<string> GenShape(XmlNode node, XmlNode slideLayoutSpNode, XmlNode slideMasterSpNode, XmlNode id, XmlNode name, XmlNode idx, XmlNode type, XmlNode order, WarpObj warpObj)
|
|
|
{
|
|
|
var xfrmList = "p:spPr/a:xfrm";
|
|
|
var slideXfrmNode = node.GetTextByPath(xfrmList);
|
|
|
- var slideLayoutXfrmNode = slideLayoutSpNode.GetTextByPath( xfrmList);
|
|
|
- var slideMasterXfrmNode = slideMasterSpNode.GetTextByPath( xfrmList);
|
|
|
+ XmlNode slideLayoutXfrmNode;
|
|
|
+ if (slideLayoutSpNode != null) {
|
|
|
+ slideLayoutXfrmNode = slideLayoutSpNode.GetTextByPath(xfrmList);
|
|
|
+ }
|
|
|
+ XmlNode slideMasterXfrmNode;
|
|
|
+ if (slideMasterSpNode != null) {
|
|
|
+ slideMasterXfrmNode = slideMasterSpNode.GetTextByPath(xfrmList);
|
|
|
+ }
|
|
|
+
|
|
|
var result = "";
|
|
|
var shpId = node.GetTextByPath("/@order");
|
|
|
var shapType = node.GetTextByPath("p:spPr/a:prstGeom/@prst");
|
|
@@ -471,7 +481,7 @@ namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
var rotate = AngleToDegrees(slideXfrmNode.GetTextByPath("@rot"));
|
|
|
|
|
|
//console.log("rotate: "+rotate);
|
|
|
- double txtRotate=0.0;
|
|
|
+ double txtRotate;
|
|
|
var txtXframeNode = node.GetTextByPath("p:txXfrm/@rot");
|
|
|
if (txtXframeNode != null)
|
|
|
{
|
|
@@ -504,7 +514,7 @@ namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
// "'>";
|
|
|
//result += "<defs>";
|
|
|
// Fill Color
|
|
|
- var fillColor = GetShapeFill(node, true, warpObj);
|
|
|
+ var Fill = await GetShapeFill(node, warpObj);
|
|
|
var grndFillFlg = false;
|
|
|
var imgFillFlg = false;
|
|
|
var clrFillType = GetFillType(node.GetTextByPath("p:spPr"));
|
|
@@ -512,8 +522,8 @@ namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
if (clrFillType == "GRADIENT_FILL")
|
|
|
{
|
|
|
grndFillFlg = true;
|
|
|
- var color_arry = fillColor.gradColor;
|
|
|
- var angl = fillColor.Rot;
|
|
|
+ var color_arry = Fill.gradColor;
|
|
|
+ var angl = Fill.Rot;
|
|
|
|
|
|
var svgGrdnt = GetSvgGradient(w, h, angl, color_arry, shpId);
|
|
|
//fill="url(#linGrd)"
|
|
@@ -522,7 +532,7 @@ namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
else if (clrFillType == "PIC_FILL")
|
|
|
{
|
|
|
imgFillFlg = true;
|
|
|
- var svgBgImg = GetSvgImagePattern(fillColor.Image, shpId.Value);
|
|
|
+ var svgBgImg = GetSvgImagePattern(Fill.Image, shpId.Value);
|
|
|
//fill="url(#imgPtrn)"
|
|
|
//console.log(svgBgImg)
|
|
|
result += svgBgImg;
|
|
@@ -538,7 +548,7 @@ namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
shapType.Value == "rightBrace" ||
|
|
|
shapType.Value == "rightBracket"))
|
|
|
{ //Temp. solution - TODO
|
|
|
- fillColor.HtmlText = "none";
|
|
|
+ Fill.HtmlText = "none";
|
|
|
}
|
|
|
}
|
|
|
// Border Color
|
|
@@ -713,7 +723,7 @@ namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
ptrn += "</pattern>";// '';
|
|
|
return ptrn;
|
|
|
}
|
|
|
- private object GetSvgGradient(double w, double h, double angl, List<string> color_arry, XmlNode shpId)
|
|
|
+ private string GetSvgGradient(double w, double h, double angl, List<string> color_arry, XmlNode shpId)
|
|
|
{
|
|
|
|
|
|
var stopsArray = GetMiddleStops(color_arry.Count - 2);
|
|
@@ -744,84 +754,7 @@ namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
|
|
|
return svg;
|
|
|
}
|
|
|
- private static List<double> SVGangle(double deg, double svgHeight, double svgWidth)
|
|
|
- {
|
|
|
- double w = svgWidth;
|
|
|
- double h = svgHeight;
|
|
|
- double ang = deg;
|
|
|
- double o = 2;
|
|
|
- double n = 2;
|
|
|
- double wc = w / 2;
|
|
|
- double hc = h / 2;
|
|
|
- double tx1 = 2;
|
|
|
- double ty1 = 2;
|
|
|
- double tx2 = 2;
|
|
|
- double ty2 = 2;
|
|
|
- double k = (((ang % 360) + 360) % 360);
|
|
|
- double j = (360 - k) * System. Math.PI / 180;
|
|
|
- double i = System.Math.Tan(j);
|
|
|
- double l = hc - i * wc;
|
|
|
-
|
|
|
- if (k == 0)
|
|
|
- {
|
|
|
- tx1 = w;
|
|
|
- ty1 = hc;
|
|
|
- tx2 = 0;
|
|
|
- ty2 = hc;
|
|
|
- }
|
|
|
- else if (k < 90)
|
|
|
- {
|
|
|
- n = w;
|
|
|
- o = 0;
|
|
|
- }
|
|
|
- else if (k == 90)
|
|
|
- {
|
|
|
- tx1 = wc;
|
|
|
- ty1 = 0;
|
|
|
- tx2 = wc;
|
|
|
- ty2 = h;
|
|
|
- }
|
|
|
- else if (k < 180)
|
|
|
- {
|
|
|
- n = 0;
|
|
|
- o = 0;
|
|
|
- }
|
|
|
- else if (k == 180)
|
|
|
- {
|
|
|
- tx1 = 0;
|
|
|
- ty1 = hc;
|
|
|
- tx2 = w;
|
|
|
- ty2 = hc;
|
|
|
- }
|
|
|
- else if (k < 270)
|
|
|
- {
|
|
|
- n = 0;
|
|
|
- o = h;
|
|
|
- }
|
|
|
- else if (k == 270)
|
|
|
- {
|
|
|
- tx1 = wc;
|
|
|
- ty1 = h;
|
|
|
- tx2 = wc;
|
|
|
- ty2 = 0;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- n = w;
|
|
|
- o = h;
|
|
|
- }
|
|
|
- // AM: I could not quite figure out what m, n, and o are supposed to represent from the original code on visualcsstools.com.
|
|
|
- var m = o + (n / i);
|
|
|
- tx1 = tx1 == 2 ? i * (m - l) / (System.Math.Pow(i, 2) + 1) : tx1;
|
|
|
- ty1 = ty1 == 2 ? i * tx1 + l : ty1;
|
|
|
- tx2 = tx2 == 2 ? w - tx1 : tx2;
|
|
|
- ty2 = ty2 == 2 ? h - ty1 : ty2;
|
|
|
- double x1 = System.Math.Round(tx2 / w * 100 * 100) / 100;
|
|
|
- double y1 = System.Math.Round(ty2 / h * 100 * 100) / 100;
|
|
|
- double x2 = System.Math.Round(tx1 / w * 100 * 100) / 100;
|
|
|
- double y2 = System.Math.Round(ty1 / h * 100 * 100) / 100;
|
|
|
- return new List<double> { x1 , y1 , x2 , y2 };
|
|
|
- }
|
|
|
+
|
|
|
private List<string> GetMiddleStops(int s)
|
|
|
{
|
|
|
var sArry = new List<string> { "0%" };
|
|
@@ -847,7 +780,7 @@ namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
sArry.Add("100%");
|
|
|
return sArry;
|
|
|
}
|
|
|
- public Fill GetShapeFill(XmlNode node, bool isSvgMode, WarpObj warpObj)
|
|
|
+ public async Task<Fill> GetShapeFill(XmlNode node, WarpObj warpObj)
|
|
|
{
|
|
|
|
|
|
// 1. presentationML
|
|
@@ -884,7 +817,7 @@ namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
else if (fillType == "PIC_FILL")
|
|
|
{
|
|
|
var shpFill = PowerPointHelper.GetTextByPath(node, "p:spPr/a:blipFill"); //node["p:spPr"]["a:blipFill"];
|
|
|
- fill = GetPicFill("slideBg", shpFill, warpObj);
|
|
|
+ fill = await GetPicFill("slideBg", shpFill, warpObj);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -899,72 +832,153 @@ namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
{
|
|
|
if (fillType == "GRADIENT_FILL")
|
|
|
{
|
|
|
- if (isSvgMode)
|
|
|
+ //if (isSvgMode)
|
|
|
+ //{
|
|
|
+ // // console.log("GRADIENT_FILL color", fillColor.color[0])
|
|
|
+ // return fill;
|
|
|
+ //}
|
|
|
+ //else
|
|
|
+ //{
|
|
|
+ var colorAry = fill.Color;
|
|
|
+ var rot = fill.Rot;
|
|
|
+
|
|
|
+ var bgcolor = "background: linear-gradient(" + rot + "deg,";
|
|
|
+ for (var i = 0; i < colorAry.Length; i++)
|
|
|
{
|
|
|
- // console.log("GRADIENT_FILL color", fillColor.color[0])
|
|
|
- return fill;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- var colorAry = fill.Color;
|
|
|
- var rot = fill.Rot;
|
|
|
-
|
|
|
- var bgcolor = "background: linear-gradient(" + rot + "deg,";
|
|
|
- for (var i = 0; i < colorAry.Length; i++)
|
|
|
+ if (i == colorAry.Length - 1)
|
|
|
{
|
|
|
- if (i == colorAry.Length - 1)
|
|
|
- {
|
|
|
- bgcolor += colorAry[i] + ");";
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- bgcolor += colorAry[i] + ", ";
|
|
|
- }
|
|
|
-
|
|
|
+ bgcolor += colorAry[i] + ");";
|
|
|
}
|
|
|
- return fill;
|
|
|
+ else
|
|
|
+ {
|
|
|
+ bgcolor += colorAry[i] + ", ";
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
+ fill.HtmlText = bgcolor;
|
|
|
+ return fill;
|
|
|
+ // }
|
|
|
}
|
|
|
else if (fillType == "PIC_FILL")
|
|
|
{
|
|
|
- if (isSvgMode)
|
|
|
- {
|
|
|
+ //if (isSvgMode)
|
|
|
+ //{
|
|
|
+ // return fill;
|
|
|
+ //}
|
|
|
+ //else
|
|
|
+ //{
|
|
|
+ fill.HtmlText = "background-image:url(" + fill.Image + ");";
|
|
|
return fill;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
-
|
|
|
- return fill;
|
|
|
- }
|
|
|
+ // }
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- if (isSvgMode)
|
|
|
- {
|
|
|
- // var color = new colz.Color(fill);
|
|
|
- // fill = color.rgb.toString();
|
|
|
-
|
|
|
- return fill;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- //console.log(node,"fillColor: ",fillColor,"fillType: ",fillType,"isSvgMode: ",isSvgMode)
|
|
|
- return fill;
|
|
|
- }
|
|
|
+ //if (isSvgMode)
|
|
|
+ //{
|
|
|
+ // var color = new colz.Color(fill);
|
|
|
+ // fill = color.rgb.toString();
|
|
|
+ fill.HtmlText = "background-color: #" + fill.Color + ";";
|
|
|
+ return fill;
|
|
|
+ //}
|
|
|
+ //else
|
|
|
+ //{
|
|
|
+ // //console.log(node,"fillColor: ",fillColor,"fillType: ",fillType,"isSvgMode: ",isSvgMode)
|
|
|
+ // return fill;
|
|
|
+ //}
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- if (isSvgMode)
|
|
|
- {
|
|
|
- return fill;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- return fill;
|
|
|
- }
|
|
|
+ //if (isSvgMode)
|
|
|
+ //{
|
|
|
+ // return fill;
|
|
|
+ //}
|
|
|
+ //else
|
|
|
+ //{
|
|
|
+ fill.SvgText = "none";
|
|
|
+ fill.HtmlText = "background-color: initial;";
|
|
|
+ return fill;
|
|
|
+ // }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private static List<double> SVGangle(double deg, double svgHeight, double svgWidth)
|
|
|
+ {
|
|
|
+ double w = svgWidth;
|
|
|
+ double h = svgHeight;
|
|
|
+ double ang = deg;
|
|
|
+ double o = 2;
|
|
|
+ double n = 2;
|
|
|
+ double wc = w / 2;
|
|
|
+ double hc = h / 2;
|
|
|
+ double tx1 = 2;
|
|
|
+ double ty1 = 2;
|
|
|
+ double tx2 = 2;
|
|
|
+ double ty2 = 2;
|
|
|
+ double k = (((ang % 360) + 360) % 360);
|
|
|
+ double j = (360 - k) * System.Math.PI / 180;
|
|
|
+ double i = System.Math.Tan(j);
|
|
|
+ double l = hc - i * wc;
|
|
|
|
|
|
+ if (k == 0)
|
|
|
+ {
|
|
|
+ tx1 = w;
|
|
|
+ ty1 = hc;
|
|
|
+ tx2 = 0;
|
|
|
+ ty2 = hc;
|
|
|
+ }
|
|
|
+ else if (k < 90)
|
|
|
+ {
|
|
|
+ n = w;
|
|
|
+ o = 0;
|
|
|
+ }
|
|
|
+ else if (k == 90)
|
|
|
+ {
|
|
|
+ tx1 = wc;
|
|
|
+ ty1 = 0;
|
|
|
+ tx2 = wc;
|
|
|
+ ty2 = h;
|
|
|
+ }
|
|
|
+ else if (k < 180)
|
|
|
+ {
|
|
|
+ n = 0;
|
|
|
+ o = 0;
|
|
|
+ }
|
|
|
+ else if (k == 180)
|
|
|
+ {
|
|
|
+ tx1 = 0;
|
|
|
+ ty1 = hc;
|
|
|
+ tx2 = w;
|
|
|
+ ty2 = hc;
|
|
|
+ }
|
|
|
+ else if (k < 270)
|
|
|
+ {
|
|
|
+ n = 0;
|
|
|
+ o = h;
|
|
|
+ }
|
|
|
+ else if (k == 270)
|
|
|
+ {
|
|
|
+ tx1 = wc;
|
|
|
+ ty1 = h;
|
|
|
+ tx2 = wc;
|
|
|
+ ty2 = 0;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ n = w;
|
|
|
+ o = h;
|
|
|
}
|
|
|
+ // AM: I could not quite figure out what m, n, and o are supposed to represent from the original code on visualcsstools.com.
|
|
|
+ var m = o + (n / i);
|
|
|
+ tx1 = tx1 == 2 ? i * (m - l) / (System.Math.Pow(i, 2) + 1) : tx1;
|
|
|
+ ty1 = ty1 == 2 ? i * tx1 + l : ty1;
|
|
|
+ tx2 = tx2 == 2 ? w - tx1 : tx2;
|
|
|
+ ty2 = ty2 == 2 ? h - ty1 : ty2;
|
|
|
+ double x1 = System.Math.Round(tx2 / w * 100 * 100) / 100;
|
|
|
+ double y1 = System.Math.Round(ty2 / h * 100 * 100) / 100;
|
|
|
+ double x2 = System.Math.Round(tx1 / w * 100 * 100) / 100;
|
|
|
+ double y2 = System.Math.Round(ty1 / h * 100 * 100) / 100;
|
|
|
+ return new List<double> { x1, y1, x2, y2 };
|
|
|
}
|
|
|
private Fill GetPatternFill(XmlNode node)
|
|
|
{
|
|
@@ -985,38 +999,41 @@ namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
var lo_color = GetSolidFill(gsLst[i]);
|
|
|
if (gsLst[i].GetTextByPath("a:srgbClr") != null)
|
|
|
{
|
|
|
- var mod = PowerPointHelper.GetTextByPath(node, "a:srgbClr/a:lumMod/@val");
|
|
|
- var off = PowerPointHelper.GetTextByPath(node, "a:srgbClr/a:lumOff/@val");
|
|
|
- double lumMod = 1.0;
|
|
|
- double lumOff = 1.0;
|
|
|
- if (mod!=null)
|
|
|
- {
|
|
|
- lumMod = double.Parse(mod.Value) /100000;
|
|
|
- }
|
|
|
- if (off!=null)
|
|
|
- {
|
|
|
- lumOff = double.Parse(off.Value) / 100000;
|
|
|
- }
|
|
|
+ //var mod = PowerPointHelper.GetTextByPath(gsLst[i], "a:srgbClr/a:lumMod/@val");
|
|
|
+ //var off = PowerPointHelper.GetTextByPath(gsLst[i], "a:srgbClr/a:lumOff/@val");
|
|
|
+ //double lumMod = 1.0;
|
|
|
+ //double lumOff = 1.0;
|
|
|
+ //if (mod!=null)
|
|
|
+ //{
|
|
|
+ // lumMod = double.Parse(mod.Value) /100000;
|
|
|
+ //}
|
|
|
+ //if (off!=null)
|
|
|
+ //{
|
|
|
+ // lumOff = double.Parse(off.Value) / 100000;
|
|
|
+ //}
|
|
|
//console.log([lumMod, lumOff]);
|
|
|
- lo_color = ApplyLumModify(lo_color, lumMod, lumOff);
|
|
|
+ lo_color.Color = PowerPointHelper.ColorToning(gsLst[i].OuterXml, lo_color.Color);
|
|
|
+ // lo_color = ApplyLumModify(lo_color, lumMod, lumOff);
|
|
|
}
|
|
|
else if (gsLst[i].GetTextByPath("a:schemeClr") != null)
|
|
|
- {
|
|
|
+ {
|
|
|
//a:schemeClr
|
|
|
- var mod = PowerPointHelper.GetTextByPath(node, "a:schemeClr/a:lumMod/@val");
|
|
|
- var off = PowerPointHelper.GetTextByPath(node, "a:schemeClr/a:lumOff/@val");
|
|
|
- double lumMod = 1.0;
|
|
|
- double lumOff = 1.0;
|
|
|
- if (mod != null)
|
|
|
- {
|
|
|
- lumMod = double.Parse(mod.Value) / 100000;
|
|
|
- }
|
|
|
- if (off != null)
|
|
|
- {
|
|
|
- lumOff = double.Parse(off.Value) / 100000;
|
|
|
- }
|
|
|
+ //var mod = PowerPointHelper.GetTextByPath(gsLst[i], "a:schemeClr/a:lumMod/@val");
|
|
|
+ //var off = PowerPointHelper.GetTextByPath(gsLst[i], "a:schemeClr/a:lumOff/@val");
|
|
|
+ //double lumMod = 1.0;
|
|
|
+ //double lumOff = 1.0;
|
|
|
+ //if (mod != null)
|
|
|
+ //{
|
|
|
+ // lumMod = double.Parse(mod.Value) / 100000;
|
|
|
+ //}
|
|
|
+ //if (off != null)
|
|
|
+ //{
|
|
|
+ // lumOff = double.Parse(off.Value) / 100000;
|
|
|
+ //}
|
|
|
//console.log([lumMod, lumOff]);
|
|
|
- lo_color = ApplyLumModify(lo_color, lumMod, lumOff);
|
|
|
+
|
|
|
+ lo_color.Color= PowerPointHelper.ColorToning(gsLst[i].OuterXml, lo_color.Color);
|
|
|
+ // lo_color = ApplyLumModify(lo_color, lumMod, lumOff);
|
|
|
}
|
|
|
color_ary.Add(lo_color.Color);
|
|
|
}
|
|
@@ -1034,34 +1051,34 @@ namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
Rot = rot
|
|
|
};
|
|
|
}
|
|
|
- private static Fill ApplyLumModify(Fill rgbStr, double factor, double offset)
|
|
|
- {
|
|
|
- Color color = ColorTranslator.FromHtml("#" + rgbStr.Color);
|
|
|
- ColorRGB RGB = new ColorRGB(color.R,color.G,color.B);
|
|
|
- ColorHSL HSL= ColorHelper.RgbToHsl(RGB);
|
|
|
- HSL.L= HSL.L * (1 + offset);
|
|
|
- RGB = ColorHelper.HslToRgb(HSL);
|
|
|
- color= Color.FromArgb(RGB.R, RGB.G, RGB.B);
|
|
|
- rgbStr.Color=ColorTranslator.ToHtml(color).Replace("#","");
|
|
|
- return rgbStr;
|
|
|
- }
|
|
|
- public static Position GetPosition(XmlNode slideSpNode, XmlNode slideLayoutSpNode, XmlNode slideMasterSpNode)
|
|
|
+ //private static Fill ApplyLumModify(Fill rgbStr, double factor, double offset)
|
|
|
+ //{
|
|
|
+ // Color color = ColorTranslator.FromHtml("#" + "1CADE4");
|
|
|
+ // ColorRGB RGB = new ColorRGB(color.R,color.G,color.B);
|
|
|
+ // ColorHSL HSL= ColorHelper.RgbToHsl(RGB);
|
|
|
+ // HSL.L= HSL.L * (1 + offset);
|
|
|
+ // RGB = ColorHelper.HslToRgb(HSL);
|
|
|
+ // color= Color.FromArgb(RGB.R, RGB.G, RGB.B);
|
|
|
+ // rgbStr.Color=ColorTranslator.ToHtml(color).Replace("#","");
|
|
|
+ // return rgbStr;
|
|
|
+ //}
|
|
|
+ public static Position GetPosition(XmlNode slideXfrmNode, XmlNode slideLayoutXfrmNode, XmlNode slideMasterXfrmNode)
|
|
|
{
|
|
|
|
|
|
XmlNode off = null;
|
|
|
double x, y;
|
|
|
|
|
|
- if (slideSpNode != null)
|
|
|
+ if (slideXfrmNode != null)
|
|
|
{
|
|
|
- off = PowerPointHelper.GetTextByPath(slideSpNode, "p:spPr/a:xfrm/a:off");
|
|
|
+ off = PowerPointHelper.GetTextByPath(slideXfrmNode, "a:off");
|
|
|
}
|
|
|
- else if (slideLayoutSpNode != null)
|
|
|
+ else if (slideLayoutXfrmNode != null)
|
|
|
{
|
|
|
- off = PowerPointHelper.GetTextByPath(slideLayoutSpNode, "p:spPr/a:xfrm/a:off");
|
|
|
+ off = PowerPointHelper.GetTextByPath(slideLayoutXfrmNode, "a:off");
|
|
|
}
|
|
|
- else if (slideMasterSpNode != null)
|
|
|
+ else if (slideMasterXfrmNode != null)
|
|
|
{
|
|
|
- off = PowerPointHelper.GetTextByPath(slideMasterSpNode, "p:spPr/a:xfrm/a:off");
|
|
|
+ off = PowerPointHelper.GetTextByPath(slideMasterXfrmNode, "a:off");
|
|
|
}
|
|
|
x = double.Parse(PowerPointHelper.GetTextByPath(off, "@x").Value) * px96 / px914400;
|
|
|
y = double.Parse(PowerPointHelper.GetTextByPath(off, "@y").Value) * px96 / px914400;
|
|
@@ -1109,11 +1126,11 @@ namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
}
|
|
|
else if (bgFillTyp == "GRADIENT_FILL")
|
|
|
{
|
|
|
- bgcolor = getBgGradientFill(bgPr, null, slideMasterContent);
|
|
|
+ bgcolor = GetBgGradientFill(bgPr, null, slideMasterContent);
|
|
|
}
|
|
|
else if (bgFillTyp == "PIC_FILL")
|
|
|
{
|
|
|
- bgcolor = getBgPicFill(bgPr, "slideBg", warpObj);
|
|
|
+ bgcolor = GetBgPicFill(bgPr, "slideBg", warpObj);
|
|
|
|
|
|
}
|
|
|
}
|
|
@@ -1126,9 +1143,9 @@ namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
- private string getBgPicFill(XmlNode bgPr, string sorce, WarpObj warpObj)
|
|
|
+ private string GetBgPicFill(XmlNode bgPr, string sorce, WarpObj warpObj)
|
|
|
{
|
|
|
- var bgcolor="";
|
|
|
+ string bgcolor;
|
|
|
var picFillBase64 = GetPicFill(sorce, bgPr.GetTextByPath("a:blipFill"), warpObj);
|
|
|
var ordr = bgPr["attrs"]["order"];
|
|
|
//a:srcRect
|
|
@@ -1137,47 +1154,56 @@ namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
return bgcolor;
|
|
|
}
|
|
|
|
|
|
- private static Fill GetPicFill(string type, XmlNode node, WarpObj warpObj)
|
|
|
+ private async Task<Fill> GetPicFill(string type, XmlNode node, WarpObj warpObj)
|
|
|
{
|
|
|
|
|
|
//Need to test/////////////////////////////////////////////
|
|
|
//rId
|
|
|
//TODO - Image Properties - Tile, Stretch, or Display Portion of Image
|
|
|
//(http://officeopenxml.com/drwPic-tile.php)
|
|
|
- var img = "";
|
|
|
+ // var img = "";
|
|
|
var rId = PowerPointHelper.GetTextByPath(node, "a:blip/@r:embed");//node["a:blip"]["attrs"]["r:embed"];
|
|
|
- var imgPath = "";
|
|
|
+ Dictionary<string, string> imgPath = new Dictionary<string, string>() ;
|
|
|
if (type == "slideBg")
|
|
|
{
|
|
|
- imgPath = warpObj.slideResObj[rId.Value][rId.Value];
|
|
|
-
|
|
|
- // imgPath = PowerPointHelper.GetTextByPath(warpObj, "slideResObj/" + rId + "/target").Value;
|
|
|
+ imgPath = warpObj.slideResObj[rId.Value];
|
|
|
}
|
|
|
else if (type == "layoutBg")
|
|
|
{
|
|
|
- imgPath = warpObj.layoutResObj[rId.Value][rId.Value];
|
|
|
+ imgPath = warpObj.layoutResObj[rId.Value];
|
|
|
}
|
|
|
else if (type == "masterBg")
|
|
|
{
|
|
|
- imgPath = warpObj.masterResObj[rId.Value][rId.Value];
|
|
|
+ imgPath = warpObj.masterResObj[rId.Value];
|
|
|
}
|
|
|
if (imgPath == null)
|
|
|
{
|
|
|
return null;
|
|
|
}
|
|
|
- var imgExt = imgPath.Split(".").Last();
|
|
|
- if (imgExt == "xml")
|
|
|
+ //var imgExt = imgPath["type"];
|
|
|
+ //if (imgExt == "xml")
|
|
|
+ //{
|
|
|
+ // return null;
|
|
|
+ //}
|
|
|
+
|
|
|
+ var imgData= warpObj.zip.GetTextByPath("//pkg:part[@pkg:name='"+ imgPath["target"] + "']");
|
|
|
+
|
|
|
+ if (imgData != null)
|
|
|
{
|
|
|
- return null;
|
|
|
+ AzureBlobModel model = await PowerPointHelper.SaveBase64ToBolob(imgData.InnerText, imgData.GetTextByPath("@pkg:contentType").Value,
|
|
|
+ fileShaCode + "/imgs", null, azureBlobDBRepository);
|
|
|
+ return new Fill { Type = 3, Image = model.BlobUrl };
|
|
|
}
|
|
|
+ else { return null; }
|
|
|
+
|
|
|
// var imgArrayBuffer = warpObj.zip.GetTextByPath(imgPath).Value.asArrayBuffer();
|
|
|
//var imgMimeType = GetMimeType(imgExt);
|
|
|
//img = "data:" + imgMimeType + ";base64," + base64ArrayBuffer(imgArrayBuffer);
|
|
|
- return new Fill { Type = 3, Image = img };
|
|
|
+
|
|
|
|
|
|
}
|
|
|
|
|
|
- private string getBgGradientFill(XmlNode bgPr, XmlNode phClr, XmlNode slideMasterContent)
|
|
|
+ private string GetBgGradientFill(XmlNode bgPr, XmlNode phClr, XmlNode slideMasterContent)
|
|
|
{
|
|
|
var bgcolor = "";
|
|
|
if (bgPr !=null)
|
|
@@ -1338,18 +1364,18 @@ namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
|
|
|
Fill fill = new Fill() { Color = "FFF" ,Type=1 };
|
|
|
|
|
|
- if (PowerPointHelper.GetTextByPath(node, "a:srgbClr").Value != null)
|
|
|
+ if (PowerPointHelper.GetTextByPath(node, "a:srgbClr") != null)
|
|
|
{
|
|
|
fill.Color = PowerPointHelper.GetTextByPath(node, "a:srgbClr/@val").Value; //#...
|
|
|
}
|
|
|
- else if (PowerPointHelper.GetTextByPath(node, "a:schemeClr").Value != null)//node["a:schemeClr"] != null)
|
|
|
+ else if (PowerPointHelper.GetTextByPath(node, "a:schemeClr") != null)//node["a:schemeClr"] != null)
|
|
|
{ //a:schemeClr
|
|
|
var schemeClr = PowerPointHelper.GetTextByPath(node, "a:schemeClr/@val");
|
|
|
//console.log(schemeClr)
|
|
|
fill.Color = GetSchemeColorFromTheme(schemeClr.Value, null); //#...
|
|
|
|
|
|
}
|
|
|
- else if (PowerPointHelper.GetTextByPath(node, "a:scrgbClr").Value != null)
|
|
|
+ else if (PowerPointHelper.GetTextByPath(node, "a:scrgbClr") != null)
|
|
|
{
|
|
|
//<a:scrgbClr r="50%" g="50%" b="50%"/> //Need to test/////////////////////////////////////////////
|
|
|
|
|
@@ -1364,14 +1390,14 @@ namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
//console.log("scrgbClr: " + scrgbClr);
|
|
|
|
|
|
}
|
|
|
- else if (PowerPointHelper.GetTextByPath(node, "a:prstClr").Value != null)
|
|
|
+ else if (PowerPointHelper.GetTextByPath(node, "a:prstClr") != null)
|
|
|
{
|
|
|
//<a:prstClr val="black"/> //Need to test/////////////////////////////////////////////
|
|
|
var prstClr = PowerPointHelper.GetTextByPath(node, "a:prstClr/@val");// node["a:prstClr"]["attrs"]["val"];
|
|
|
fill.Color = GetColorName2Hex(prstClr.Value);
|
|
|
//console.log("prstClr: " + prstClr+" => hexClr: "+color);
|
|
|
}
|
|
|
- else if (PowerPointHelper.GetTextByPath(node, "a:hslClr").Value != null)
|
|
|
+ else if (PowerPointHelper.GetTextByPath(node, "a:hslClr") != null)
|
|
|
{
|
|
|
//<a:hslClr hue="14400000" sat="100%" lum="50%"/> //Need to test/////////////////////////////////////////////
|
|
|
var defBultColorVals = PowerPointHelper.GetTextByPath(node, "a:hslClr");//["attrs"];
|
|
@@ -1387,7 +1413,7 @@ namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
//defBultColor = cnvrtHslColor2Hex(hslClr); //TODO
|
|
|
// console.log("hslClr: " + hslClr);
|
|
|
}
|
|
|
- else if (PowerPointHelper.GetTextByPath(node, "a:sysClr").Value != null)
|
|
|
+ else if (PowerPointHelper.GetTextByPath(node, "a:sysClr") != null)
|
|
|
{
|
|
|
//<a:sysClr val="windowText" lastClr="000000"/> //Need to test/////////////////////////////////////////////
|
|
|
var sysClr = PowerPointHelper.GetTextByPath(node, "a:sysClr/@lastClr").Value;
|
|
@@ -1406,29 +1432,35 @@ namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
|
|
|
if (slideLayoutClrOvride == null ||slideLayoutClrOvride.Count<=0)
|
|
|
{
|
|
|
- var sldLayoutClrOvr = PowerPointHelper.GetTextByPath(sldMasterNode, "p:sldMaster/p:clrMap");
|
|
|
-
|
|
|
- if (sldLayoutClrOvr != null)
|
|
|
- {
|
|
|
- //获取 overrideClrMapping所有属性节点 检查测试 是否slideLayoutClrOvride 需要被覆盖
|
|
|
- slideLayoutClrOvride = new Dictionary<string, string>() {
|
|
|
- { "accent1", sldLayoutClrOvr.GetTextByPath("@accent1").Value},
|
|
|
- { "accent2", sldLayoutClrOvr.GetTextByPath("@accent2").Value},
|
|
|
- { "accent3", sldLayoutClrOvr.GetTextByPath("@accent3").Value},
|
|
|
- { "accent4", sldLayoutClrOvr.GetTextByPath("@accent4").Value},
|
|
|
- { "accent5", sldLayoutClrOvr.GetTextByPath("@accent5").Value},
|
|
|
- { "accent6", sldLayoutClrOvr.GetTextByPath("@accent6").Value},
|
|
|
- { "bg1", sldLayoutClrOvr.GetTextByPath("@bg1").Value},
|
|
|
- { "bg2", sldLayoutClrOvr.GetTextByPath("@bg2").Value},
|
|
|
- { "folHlink", sldLayoutClrOvr.GetTextByPath("@folHlink").Value},
|
|
|
- { "hlink", sldLayoutClrOvr.GetTextByPath("@hlink").Value},
|
|
|
- { "tx1", sldLayoutClrOvr.GetTextByPath("@tx1").Value},
|
|
|
- { "tx2", sldLayoutClrOvr.GetTextByPath("@tx2").Value}
|
|
|
- };
|
|
|
+ if(sldMasterNode!= null) {
|
|
|
+ var sldLayoutClrOvr = PowerPointHelper.GetTextByPath(sldMasterNode, "p:sldMaster/p:clrMap");
|
|
|
+ if (sldLayoutClrOvr != null)
|
|
|
+ {
|
|
|
+ //获取 overrideClrMapping所有属性节点 检查测试 是否slideLayoutClrOvride 需要被覆盖
|
|
|
+ slideLayoutClrOvride = new Dictionary<string, string>() {
|
|
|
+ { "accent1", sldLayoutClrOvr.GetTextByPath("@accent1").Value},
|
|
|
+ { "accent2", sldLayoutClrOvr.GetTextByPath("@accent2").Value},
|
|
|
+ { "accent3", sldLayoutClrOvr.GetTextByPath("@accent3").Value},
|
|
|
+ { "accent4", sldLayoutClrOvr.GetTextByPath("@accent4").Value},
|
|
|
+ { "accent5", sldLayoutClrOvr.GetTextByPath("@accent5").Value},
|
|
|
+ { "accent6", sldLayoutClrOvr.GetTextByPath("@accent6").Value},
|
|
|
+ { "bg1", sldLayoutClrOvr.GetTextByPath("@bg1").Value},
|
|
|
+ { "bg2", sldLayoutClrOvr.GetTextByPath("@bg2").Value},
|
|
|
+ { "folHlink", sldLayoutClrOvr.GetTextByPath("@folHlink").Value},
|
|
|
+ { "hlink", sldLayoutClrOvr.GetTextByPath("@hlink").Value},
|
|
|
+ { "tx1", sldLayoutClrOvr.GetTextByPath("@tx1").Value},
|
|
|
+ { "tx2", sldLayoutClrOvr.GetTextByPath("@tx2").Value}
|
|
|
+ };
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ if (!schemeClr.StartsWith("a:"))
|
|
|
+ {
|
|
|
+ schemeClr = "a:" + schemeClr;
|
|
|
+ }
|
|
|
//console.log(slideLayoutClrOvride);
|
|
|
- var schmClrName = schemeClr.Substring(2);
|
|
|
+ var schmClrName = schemeClr.Replace("a:","");
|
|
|
+
|
|
|
if (slideLayoutClrOvride != null)
|
|
|
{
|
|
|
switch (schmClrName)
|
|
@@ -1462,10 +1494,10 @@ namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
}
|
|
|
}
|
|
|
//var refNode = PowerPointHelper.GetTextByPathList(themeContent, "a:theme/a:themeElements/a:clrScheme/"+ schemeClr.Value);
|
|
|
- var color = PowerPointHelper.GetTextByPath(themeContent, "a:theme/a:themeElements/a:clrScheme/" + schemeClr + "/a:srgbClr/@val");
|
|
|
+ var color = PowerPointHelper.GetTextByPath(themeContent, "pkg:xmlData/a:theme/a:themeElements/a:clrScheme/" + schemeClr + "/a:srgbClr/@val");
|
|
|
if (color == null)//&& refNode != null
|
|
|
{
|
|
|
- color = PowerPointHelper.GetTextByPath(themeContent, "a:theme/a:themeElements/a:clrScheme/" + schemeClr + "/a:sysClr/@lastClr");
|
|
|
+ color = PowerPointHelper.GetTextByPath(themeContent, "pkg:xmlData/a:theme/a:themeElements/a:clrScheme/" + schemeClr + "/a:sysClr/@lastClr");
|
|
|
}
|
|
|
//console.log(color)
|
|
|
return color.Value;
|
|
@@ -1615,7 +1647,7 @@ namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
{
|
|
|
var contentType = thumbnailNode.GetTextByPath("@pkg:contentType");
|
|
|
var thumbnail = thumbnailNode.InnerText;
|
|
|
- return await PowerPointHelper.SaveBase64ToBolob(thumbnail, contentType.Value, shaCode, "thumbnail", azureBlobDBRepository);
|
|
|
+ return await PowerPointHelper.SaveBase64ToBolob(thumbnail, contentType.Value, shaCode+"/imgs", "thumbnail", azureBlobDBRepository);
|
|
|
}
|
|
|
return null;
|
|
|
}
|