|
@@ -32,7 +32,7 @@ namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
|
|
|
private Dictionary<string, string> slideLayoutClrOvride { get; set; }
|
|
|
// private XmlNode themeContent { get; set; }
|
|
|
-
|
|
|
+ private const int degree = 3;
|
|
|
private int chartID = 0;
|
|
|
private int _order = 1;
|
|
|
private int titleFontSize = 42;
|
|
@@ -93,45 +93,47 @@ namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
/// </summary>
|
|
|
/// <param name="presentationFile"></param>
|
|
|
/// <returns></returns>
|
|
|
- public async Task<List<Dictionary<string, object>>> ProcessPPTX(XmlDocument xdoc, string shaCode)
|
|
|
+ public async Task< Dictionary<string, object>> ProcessPPTX(XmlDocument xdoc, string shaCode)
|
|
|
{
|
|
|
- List<Dictionary<string, object>> post_ary = new List<Dictionary<string, object>>();
|
|
|
+ // List<Dictionary<string, object>> post_ary = new List<Dictionary<string, object>>();
|
|
|
+ Dictionary<string, object> post_ary = new Dictionary<string, object>();
|
|
|
var dateBefore = DateTimeOffset.Now.UtcTicks;
|
|
|
AzureBlobModel thumbnailModel = await GetThumbnailModel(xdoc, shaCode);
|
|
|
- post_ary.Add(new Dictionary<string, object> { { "pptx-thumb", thumbnailModel } });
|
|
|
+ post_ary.Add( "pptx-thumb", thumbnailModel );
|
|
|
//获取全部的/ppt/slides/slide1.xml--->>/ppt/slides/slide(n).xml
|
|
|
var slideNodes = xdoc.GetTextByPathList("//pkg:part[@pkg:contentType='application/vnd.openxmlformats-officedocument.presentationml.slide+xml']");
|
|
|
//获取全部的/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);
|
|
|
- post_ary.Add(new Dictionary<string, object> { { "slideSize", slideSize } });
|
|
|
+ post_ary.Add( "slideSize", slideSize );
|
|
|
//加载当前PPT使用到的PPT节点
|
|
|
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;
|
|
|
-
|
|
|
+ List<Slide> slides = new List<Slide>();
|
|
|
for (int i = 0; i < numOfSlides; i++)
|
|
|
{
|
|
|
string filename = slideNodes[i].GetTextByPath("@pkg:name").Value;
|
|
|
//处理当前页的幻灯片
|
|
|
- Slide 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 } });
|
|
|
+ Slide slide = await ProcessSingleSlide(xdoc, slideNodes[i], filename, i, slideSize, themeContent);
|
|
|
+ slides.Add(slide);
|
|
|
+ // post_ary.Add(new Dictionary<string, object> { { "slide", slideHtml } });
|
|
|
+ // post_ary.Add(new Dictionary<string, object> { { "progress-update", (i + 1) * 100 / numOfSlides } });
|
|
|
|
|
|
}
|
|
|
- post_ary.Add(new Dictionary<string, object> { { "globalCSS", GenGlobalCSS() } });
|
|
|
+ post_ary.Add( "slide", slides );
|
|
|
+ //post_ary.Add( "globalCSS", GenGlobalCSS() );
|
|
|
var dateAfter = DateTimeOffset.Now.UtcTicks;
|
|
|
- post_ary.Add(new Dictionary<string, object> { { "ExecutionTime", dateAfter - dateBefore } });
|
|
|
+ // post_ary.Add( "ExecutionTime", dateAfter - dateBefore );
|
|
|
return post_ary;
|
|
|
}
|
|
|
|
|
|
public Dictionary<string, string> GenGlobalCSS()
|
|
|
{
|
|
|
Dictionary<string, string> cssText = new Dictionary<string, string>();
|
|
|
-
|
|
|
foreach (var key in styleTable.Keys)
|
|
|
{
|
|
|
// cssText += "div ." + styleTable[key]["name"] + "{" + styleTable[key]["text"] + "}\n"; //section > div
|
|
@@ -594,10 +596,18 @@ namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
{
|
|
|
Svg svg = ShapeSvg.GenShapeSvg(node, order, shapeType, isFlipV, position, grndFillFlg, imgFillFlg, Fill, shapeBorder, headEndNodeAttrs, tailEndNodeAttrs);
|
|
|
shapeSvg.SvgShape = svg.SvgShape;
|
|
|
- shapeSvg.SvgData = svg.SvgData;
|
|
|
+ // shapeSvg.SvgData = svg.SvgData;
|
|
|
if (ShapeType.Equals("Sp"))
|
|
|
+
|
|
|
{
|
|
|
- Shape shape = new Shape { Border = shapeBorder, Fill = Fill, Svg = shapeSvg, Type = "Sp", Position = position, Index = order, ShapeType = shapeType.Value };
|
|
|
+ Shape shape = new Shape { Border = shapeBorder, Svg = shapeSvg, Type = "Sp", Position = position, Index = order, ShapeType = shapeType.Value };
|
|
|
+ if (Fill.Type == 0)
|
|
|
+ {
|
|
|
+ shape.Fill = null;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ shape.Fill = Fill;
|
|
|
+ }
|
|
|
var txbody = node.GetTextByPath("p:txBody");
|
|
|
if (txbody != null)
|
|
|
{
|
|
@@ -631,8 +641,8 @@ namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
var spY = 96.0;
|
|
|
if (startPoint != null)
|
|
|
{
|
|
|
- spX = double.Parse(startPoint.GetTextByPath("@x").Value) * 96 / 914400;
|
|
|
- spY = double.Parse(startPoint.GetTextByPath("@y").Value) * 96 / 914400;
|
|
|
+ spX = System.Math.Round(double.Parse(startPoint.GetTextByPath("@x").Value) * 96 / 914400,degree);
|
|
|
+ spY = System.Math.Round(double.Parse(startPoint.GetTextByPath("@y").Value) * 96 / 914400,degree);
|
|
|
}
|
|
|
var d = "M" + spX + "," + spY;
|
|
|
// List<HiTeachCC.Model.PowerPoint.Path> Paths = new List<Model.PowerPoint.Path>();
|
|
@@ -649,7 +659,7 @@ namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
// Lx = double.Parse(Lx.Value) * px96 / px914400,
|
|
|
// Ly = double.Parse(Lx.Value) * px96 / px914400,
|
|
|
//});
|
|
|
- d += " L" + Lx + "," + Ly;
|
|
|
+ d += " L" + System.Math.Round(Lx,degree) + "," + System.Math.Round(Ly,degree);
|
|
|
}
|
|
|
if (childNode.Name.Equals("a:cubicBezTo"))
|
|
|
{
|
|
@@ -673,7 +683,7 @@ namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
// Cx3 = double.Parse(Cx3.Value) * px96 / px914400,
|
|
|
// Cy3 = double.Parse(Cy3.Value) * px96 / px914400
|
|
|
// });
|
|
|
- d += " C" + Cx1 + "," + Cy1 + " " + Cx2 + "," + Cy2 + " " + Cx3 + "," + Cy3;
|
|
|
+ d += " C" + System.Math.Round(Cx1,degree) + "," + System.Math.Round(Cy1,degree) + " " + System.Math.Round(Cx2,degree) + "," + System.Math.Round(Cy2,degree) + " " + System.Math.Round(Cx3,degree) + "," + System.Math.Round(Cy3,degree);
|
|
|
}
|
|
|
if (childNode.Name.Equals("a:quadBezTo"))
|
|
|
{
|
|
@@ -694,7 +704,7 @@ namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
// Cx2 = double.Parse(Cx2.Value) * px96 / px914400,
|
|
|
// Cy2 = double.Parse(Cy2.Value) * px96 / px914400
|
|
|
//});
|
|
|
- d += " Q" + Cx1 + "," + Cy1 + " " + Cx2 + "," + Cy2;
|
|
|
+ d += " Q" + System.Math.Round(Cx1,degree) + "," + System.Math.Round(Cy1,degree) + " " + System.Math.Round(Cx2,degree) + "," + System.Math.Round(Cy2,degree);
|
|
|
}
|
|
|
if (childNode.Name.Equals("a:arcTo"))
|
|
|
{
|
|
@@ -734,8 +744,16 @@ namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
}
|
|
|
};
|
|
|
shapeSvg.SvgShape = shapes;
|
|
|
- shapeSvg.SvgData = result;
|
|
|
- Shape shape = new Shape { Border = shapeBorder, Fill = Fill, Svg = shapeSvg, Type = "Sp", Position = position, Index = order, ShapeType = "custom" };
|
|
|
+ // shapeSvg.SvgData = result;
|
|
|
+ Shape shape = new Shape { Border = shapeBorder, Svg = shapeSvg, Type = "Sp", Position = position, Index = order, ShapeType = "custom" };
|
|
|
+ if (Fill.Type == 0)
|
|
|
+ {
|
|
|
+ shape.Fill = null;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ shape.Fill = Fill;
|
|
|
+ }
|
|
|
var txbody = node.GetTextByPath("p:txBody");
|
|
|
if (txbody != null)
|
|
|
{
|
|
@@ -746,7 +764,15 @@ namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- Shape shape = new Shape { Border = shapeBorder, Fill = Fill, Svg = shapeSvg, Type = "Sp", Position = position, Index = order, ShapeType = "rect" };
|
|
|
+ Shape shape = new Shape { Border = shapeBorder, Svg = shapeSvg, Type = "Sp", Position = position, Index = order, ShapeType = "rect" };
|
|
|
+ if (Fill.Type == 0)
|
|
|
+ {
|
|
|
+ shape.Fill = null;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ shape.Fill = Fill;
|
|
|
+ }
|
|
|
var txbody = node.GetTextByPath("p:txBody");
|
|
|
if (txbody != null)
|
|
|
{
|
|
@@ -769,6 +795,10 @@ namespace HiTeachCC.Service.PowerPoint.Implement
|
|
|
foreach (XmlNode pNode in ps)
|
|
|
{
|
|
|
BuChar buChar = await GenBuChar(pNode, spNode, slideLayoutSpNode, slideMasterSpNode, type, warpObj);
|
|
|
+ if (buChar != null && (buChar.Buchar == null || buChar.Buchar.Equals("TYPE_NONE"))) {
|
|
|
+ buChar = null;
|
|
|
+ }
|
|
|
+
|
|
|
string HorizontalAlign = GetHorizontalAlign(pNode, slideLayoutSpNode, slideMasterSpNode, type, slideMasterTextStyles);
|
|
|
Paragraph paragraph = new Paragraph
|
|
|
{
|