Selaa lähdekoodia

体检PPTX解析验证

黄贺彬 5 vuotta sitten
vanhempi
commit
a57383fd53
57 muutettua tiedostoa jossa 7006 lisäystä ja 15 poistoa
  1. 1 0
      TEAMModelOS.Service/Core/Implements/LoginInfoService.cs
  2. 66 0
      TEAMModelOS.Test.PPTX/ColorLibrary/ColorHSL.cs
  3. 72 0
      TEAMModelOS.Test.PPTX/ColorLibrary/ColorHSV.cs
  4. 206 0
      TEAMModelOS.Test.PPTX/ColorLibrary/ColorHelper.cs
  5. 83 0
      TEAMModelOS.Test.PPTX/ColorLibrary/ColorRGB.cs
  6. 36 0
      TEAMModelOS.Test.PPTX/PPTElement.cs
  7. 87 0
      TEAMModelOS.Test.PPTX/PPTLibrary/Animations/AnimationTypes.cs
  8. 104 0
      TEAMModelOS.Test.PPTX/PPTLibrary/Animations/EmphasisAnimation.cs
  9. 19 0
      TEAMModelOS.Test.PPTX/PPTLibrary/Animations/IAnimation.cs
  10. 710 0
      TEAMModelOS.Test.PPTX/PPTLibrary/Animations/JSONGenerator.cs
  11. 201 0
      TEAMModelOS.Test.PPTX/PPTLibrary/Animations/MotionPathAnimation.cs
  12. 102 0
      TEAMModelOS.Test.PPTX/PPTLibrary/Animations/SimpleAnimation.cs
  13. 13 0
      TEAMModelOS.Test.PPTX/PPTLibrary/Animations/TransitionAnimation.cs
  14. 12 0
      TEAMModelOS.Test.PPTX/PPTLibrary/CustPathList.cs
  15. 39 0
      TEAMModelOS.Test.PPTX/PPTLibrary/Dom/Globals.cs
  16. 7 0
      TEAMModelOS.Test.PPTX/PPTLibrary/Dom/IPPTDrawable.cs
  17. 68 0
      TEAMModelOS.Test.PPTX/PPTLibrary/Dom/PPTConnectionShape.cs
  18. 15 0
      TEAMModelOS.Test.PPTX/PPTLibrary/Dom/PPTContainerShape.cs
  19. 76 0
      TEAMModelOS.Test.PPTX/PPTLibrary/Dom/PPTGraphicFrame.cs
  20. 68 0
      TEAMModelOS.Test.PPTX/PPTLibrary/Dom/PPTGroupShape.cs
  21. 104 0
      TEAMModelOS.Test.PPTX/PPTLibrary/Dom/PPTImage.cs
  22. 6 0
      TEAMModelOS.Test.PPTX/PPTLibrary/Dom/PPTLayout.cs
  23. 9 0
      TEAMModelOS.Test.PPTX/PPTLibrary/Dom/PPTNonVisualShapeProp.cs
  24. 194 0
      TEAMModelOS.Test.PPTX/PPTLibrary/Dom/PPTShape.cs
  25. 166 0
      TEAMModelOS.Test.PPTX/PPTLibrary/Dom/PPTShapeBase.cs
  26. 189 0
      TEAMModelOS.Test.PPTX/PPTLibrary/Dom/PPTSlide.cs
  27. 410 0
      TEAMModelOS.Test.PPTX/PPTLibrary/Dom/PPTTexts/PPTParagraph.cs
  28. 358 0
      TEAMModelOS.Test.PPTX/PPTLibrary/Dom/PPTTexts/PPTRunProperties.cs
  29. 77 0
      TEAMModelOS.Test.PPTX/PPTLibrary/Dom/PPTVisualPPTShapeProp.cs
  30. 58 0
      TEAMModelOS.Test.PPTX/PPTLibrary/HtmlController/HtmlConnectionShape.cs
  31. 243 0
      TEAMModelOS.Test.PPTX/PPTLibrary/HtmlController/HtmlController.cs
  32. 60 0
      TEAMModelOS.Test.PPTX/PPTLibrary/HtmlController/HtmlGroupShape.cs
  33. 80 0
      TEAMModelOS.Test.PPTX/PPTLibrary/HtmlController/HtmlImage.cs
  34. 57 0
      TEAMModelOS.Test.PPTX/PPTLibrary/HtmlController/HtmlImageGIF.cs
  35. 19 0
      TEAMModelOS.Test.PPTX/PPTLibrary/HtmlController/HtmlPresentationElement.cs
  36. 427 0
      TEAMModelOS.Test.PPTX/PPTLibrary/HtmlController/HtmlShape.cs
  37. 139 0
      TEAMModelOS.Test.PPTX/PPTLibrary/HtmlController/HtmlSlide.cs
  38. 58 0
      TEAMModelOS.Test.PPTX/PPTLibrary/HtmlController/HtmlSmartArt.cs
  39. 125 0
      TEAMModelOS.Test.PPTX/PPTLibrary/HtmlController/HtmlText.cs
  40. 17 0
      TEAMModelOS.Test.PPTX/PPTLibrary/PPTBuilder/PPTConnectionShapeBuilder.cs
  41. 42 0
      TEAMModelOS.Test.PPTX/PPTLibrary/PPTBuilder/PPTContainerShapeBuilder.cs
  42. 16 0
      TEAMModelOS.Test.PPTX/PPTLibrary/PPTBuilder/PPTGraphicFrameBuilder.cs
  43. 16 0
      TEAMModelOS.Test.PPTX/PPTLibrary/PPTBuilder/PPTGroupShapeBuilder.cs
  44. 20 0
      TEAMModelOS.Test.PPTX/PPTLibrary/PPTBuilder/PPTImageBuilder.cs
  45. 261 0
      TEAMModelOS.Test.PPTX/PPTLibrary/PPTBuilder/PPTPresenationBuilder.cs
  46. 16 0
      TEAMModelOS.Test.PPTX/PPTLibrary/PPTBuilder/PPTShapeBuilder.cs
  47. 240 0
      TEAMModelOS.Test.PPTX/PPTXConvert.cs
  48. 679 0
      TEAMModelOS.Test.PPTX/PPTXConvertNew.cs
  49. 796 0
      TEAMModelOS.Test.PPTX/PresentationConvert.cs
  50. 21 0
      TEAMModelOS.Test.PPTX/PresentationElement/Content.cs
  51. 14 0
      TEAMModelOS.Test.PPTX/PresentationElement/Element.cs
  52. 22 0
      TEAMModelOS.Test.PPTX/PresentationElement/Position.cs
  53. 49 0
      TEAMModelOS.Test.PPTX/Program.cs
  54. 21 0
      TEAMModelOS.Test.PPTX/TEAMModelOS.Test.PPTX.csproj
  55. 7 0
      TEAMModelOS.sln
  56. 3 3
      TEAMModelOS/Controllers/Core/LoginController.cs
  57. 2 12
      TEAMModelOS/Startup.cs

+ 1 - 0
TEAMModelOS.Service/Core/Implements/LoginInfoService.cs

@@ -98,6 +98,7 @@ namespace TEAMModelOS.Service.Core.Implements
                 result.JwtToken = jwtToken;
                 await Save<LoginInfo>(loginInfo);
                 await SaveOrUpdate<TeamModelUser>(user);
+              //  JosnRPCResponse<TeamModelIdInfo> response = MessagePackHelper.JsonToObject<JosnRPCResponse<TeamModelIdInfo>>(jsonStr);
                 return result;
                 #endregion
                 /*

+ 66 - 0
TEAMModelOS.Test.PPTX/ColorLibrary/ColorHSL.cs

@@ -0,0 +1,66 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TEAMModelOS.Test.PPTX.ColorLibrary
+{
+    /// <summary>
+    /// 类      名:ColorHSL
+    /// 功      能:H 色相 \ S 饱和度(纯度) \ L 亮度 颜色模型 
+    /// </summary>
+    public class ColorHSL
+    {
+        public ColorHSL(int h, int s, int l)
+        {
+            this._h = h;
+            this._s = s;
+            this._l = l;
+        }
+
+        private int _h;
+        private int _s;
+        private int _l;
+
+        /// <summary>
+        /// 色相
+        /// </summary>
+        public int H
+        {
+            get { return this._h; }
+            set
+            {
+                this._h = value;
+                this._h = this._h > 360 ? 360 : this._h;
+                this._h = this._h < 0 ? 0 : this._h;
+            }
+        }
+
+        /// <summary>
+        /// 饱和度(纯度)
+        /// </summary>
+        public int S
+        {
+            get { return this._s; }
+            set
+            {
+                this._s = value;
+                this._s = this._s > 255 ? 255 : this._s;
+                this._s = this._s < 0 ? 0 : this._s;
+            }
+        }
+
+        /// <summary>
+        /// 饱和度
+        /// </summary>
+        public int L
+        {
+            get { return this._l; }
+            set
+            {
+                this._l = value;
+                this._l = this._l > 255 ? 255 : this._l;
+                this._l = this._l < 0 ? 0 : this._l;
+            }
+        }
+    }
+}

+ 72 - 0
TEAMModelOS.Test.PPTX/ColorLibrary/ColorHSV.cs

@@ -0,0 +1,72 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TEAMModelOS.Test.PPTX.ColorLibrary
+{
+    /// <summary>
+    /// 类      名:ColorHSV
+    /// 功      能:H 色相 \ S 饱和度(纯度) \ V 明度 颜色模型 
+    /// </summary>
+    public class ColorHSV
+    {
+        /// <summary>
+        /// 构造方法
+        /// </summary>
+        /// <param name="h"></param>
+        /// <param name="s"></param>
+        /// <param name="v"></param>
+        public ColorHSV(int h, int s, int v)
+        {
+            this._h = h;
+            this._s = s;
+            this._v = v;
+        }
+
+        private int _h;
+        private int _s;
+        private int _v;
+
+        /// <summary>
+        /// 色相
+        /// </summary>
+        public int H
+        {
+            get { return this._h; }
+            set
+            {
+                this._h = value;
+                this._h = this._h > 360 ? 360 : this._h;
+                this._h = this._h < 0 ? 0 : this._h;
+            }
+        }
+
+        /// <summary>
+        /// 饱和度(纯度)
+        /// </summary>
+        public int S
+        {
+            get { return this._s; }
+            set
+            {
+                this._s = value;
+                this._s = this._s > 255 ? 255 : this._s;
+                this._s = this._s < 0 ? 0 : this._s;
+            }
+        }
+
+        /// <summary>
+        /// 明度
+        /// </summary>
+        public int V
+        {
+            get { return this._v; }
+            set
+            {
+                this._v = value;
+                this._v = this._v > 255 ? 255 : this._v;
+                this._v = this._v < 0 ? 0 : this._v;
+            }
+        }
+    }
+}

+ 206 - 0
TEAMModelOS.Test.PPTX/ColorLibrary/ColorHelper.cs

@@ -0,0 +1,206 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TEAMModelOS.Test.PPTX.ColorLibrary
+{
+    /// <summary>
+    /// 类      名:ColorHelper
+    /// 功      能:提供从RGB到HSV/HSL色彩空间的相互转换
+    /// </summary>
+    public static class ColorHelper
+    {
+        /// <summary>
+        /// RGB转换HSV
+        /// </summary>
+        /// <param name="rgb"></param>
+        /// <returns></returns>
+        public static ColorHSV RgbToHsv(ColorRGB rgb)
+        {
+            float min, max, tmp, H, S, V;
+            float R = rgb.R * 1.0f / 255, G = rgb.G * 1.0f / 255, B = rgb.B * 1.0f / 255;
+            tmp = Math.Min(R, G);
+            min = Math.Min(tmp, B);
+            tmp = Math.Max(R, G);
+            max = Math.Max(tmp, B);
+            // H
+            H = 0;
+            if (max == min)
+            {
+                H = 0;
+            }
+            else if (max == R && G > B)
+            {
+                H = 60 * (G - B) * 1.0f / (max - min) + 0;
+            }
+            else if (max == R && G < B)
+            {
+                H = 60 * (G - B) * 1.0f / (max - min) + 360;
+            }
+            else if (max == G)
+            {
+                H = H = 60 * (B - R) * 1.0f / (max - min) + 120;
+            }
+            else if (max == B)
+            {
+                H = H = 60 * (R - G) * 1.0f / (max - min) + 240;
+            }
+            // S
+            if (max == 0)
+            {
+                S = 0;
+            }
+            else
+            {
+                S = (max - min) * 1.0f / max;
+            }
+            // V
+            V = max;
+            return new ColorHSV((int)H, (int)(S * 255), (int)(V * 255));
+        }
+
+        /// <summary>
+        /// HSV转换RGB
+        /// </summary>
+        /// <param name="hsv"></param>
+        /// <returns></returns>
+        public static ColorRGB HsvToRgb(ColorHSV hsv)
+        {
+            if (hsv.H == 360) hsv.H = 359; // 360为全黑,原因不明
+            float R = 0f, G = 0f, B = 0f;
+            if (hsv.S == 0)
+            {
+                return new ColorRGB(hsv.V, hsv.V, hsv.V);
+            }
+            float S = hsv.S * 1.0f / 255, V = hsv.V * 1.0f / 255;
+            int H1 = (int)(hsv.H * 1.0f / 60), H = hsv.H;
+            float F = H * 1.0f / 60 - H1;
+            float P = V * (1.0f - S);
+            float Q = V * (1.0f - F * S);
+            float T = V * (1.0f - (1.0f - F) * S);
+            switch (H1)
+            {
+                case 0: R = V; G = T; B = P; break;
+                case 1: R = Q; G = V; B = P; break;
+                case 2: R = P; G = V; B = T; break;
+                case 3: R = P; G = Q; B = V; break;
+                case 4: R = T; G = P; B = V; break;
+                case 5: R = V; G = P; B = Q; break;
+            }
+            R = R * 255;
+            G = G * 255;
+            B = B * 255;
+            while (R > 255) R -= 255;
+            while (R < 0) R += 255;
+            while (G > 255) G -= 255;
+            while (G < 0) G += 255;
+            while (B > 255) B -= 255;
+            while (B < 0) B += 255;
+            return new ColorRGB((int)R, (int)G, (int)B);
+        }
+
+        /// <summary>
+        /// RGB转换HSL
+        /// </summary>
+        /// <param name="rgb"></param>
+        /// <returns></returns>
+        public static ColorHSL RgbToHsl(ColorRGB rgb)
+        {
+            float min, max, tmp, H, S, L;
+            float R = rgb.R * 1.0f / 255, G = rgb.G * 1.0f / 255, B = rgb.B * 1.0f / 255;
+            tmp = Math.Min(R, G);
+            min = Math.Min(tmp, B);
+            tmp = Math.Max(R, G);
+            max = Math.Max(tmp, B);
+            // H
+            H = 0;
+            if (max == min)
+            {
+                H = 0;  // 此时H应为未定义,通常写为0
+            }
+            else if (max == R && G > B)
+            {
+                H = 60 * (G - B) * 1.0f / (max - min) + 0;
+            }
+            else if (max == R && G < B)
+            {
+                H = 60 * (G - B) * 1.0f / (max - min) + 360;
+            }
+            else if (max == G)
+            {
+                H = H = 60 * (B - R) * 1.0f / (max - min) + 120;
+            }
+            else if (max == B)
+            {
+                H = H = 60 * (R - G) * 1.0f / (max - min) + 240;
+            }
+            // L 
+            L = 0.5f * (max + min);
+            // S
+            S = 0;
+            if (L == 0 || max == min)
+            {
+                S = 0;
+            }
+            else if (0 < L && L < 0.5)
+            {
+                S = (max - min) / (L * 2);
+            }
+            else if (L > 0.5)
+            {
+                S = (max - min) / (2 - 2 * L);
+            }
+            return new ColorHSL((int)H, (int)(S * 255), (int)(L * 255));
+        }
+
+        /// <summary>
+        /// HSL转换RGB
+        /// </summary>
+        /// <param name="hsl"></param>
+        /// <returns></returns>
+        public static ColorRGB HslToRgb(ColorHSL hsl)
+        {
+            float R = 0f, G = 0f, B = 0f;
+            float S = hsl.S * 1.0f / 255, L = hsl.L * 1.0f / 255;
+            float temp1, temp2, temp3;
+            if (S == 0f) // 灰色
+            {
+                R = L;
+                G = L;
+                B = L;
+            }
+            else
+            {
+                if (L < 0.5f)
+                {
+                    temp2 = L * (1.0f + S);
+                }
+                else
+                {
+                    temp2 = L + S - L * S;
+                }
+                temp1 = 2.0f * L - temp2;
+                float H = hsl.H * 1.0f / 360;
+                // R
+                temp3 = H + 1.0f / 3.0f;
+                if (temp3 < 0) temp3 += 1.0f;
+                if (temp3 > 1) temp3 -= 1.0f;
+                R = temp3;
+                // G
+                temp3 = H;
+                if (temp3 < 0) temp3 += 1.0f;
+                if (temp3 > 1) temp3 -= 1.0f;
+                G = temp3;
+                // B
+                temp3 = H - 1.0f / 3.0f;
+                if (temp3 < 0) temp3 += 1.0f;
+                if (temp3 > 1) temp3 -= 1.0f;
+                B = temp3;
+            }
+            R = R * 255;
+            G = G * 255;
+            B = B * 255;
+            return new ColorRGB((int)R, (int)G, (int)B);
+        }
+    }
+}

+ 83 - 0
TEAMModelOS.Test.PPTX/ColorLibrary/ColorRGB.cs

@@ -0,0 +1,83 @@
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Text;
+
+namespace TEAMModelOS.Test.PPTX.ColorLibrary
+{
+    /// <summary>
+    /// 类      名:ColorRGB
+    /// 功      能:R 红色 \ G 绿色 \ B 蓝色 颜色模型
+    ///                 所有颜色模型的基类,RGB是用于输出到屏幕的颜色模式,所以所有模型都将转换成RGB输出
+    /// </summary>
+    public class ColorRGB
+    {
+        /// <summary>
+        /// 构造方法
+        /// </summary>
+        /// <param name="r"></param>
+        /// <param name="g"></param>
+        /// <param name="b"></param>
+        public ColorRGB(int r, int g, int b)
+        {
+            this._r = r;
+            this._g = g;
+            this._b = b;
+        }
+
+        private int _r;
+        private int _g;
+        private int _b;
+
+        /// <summary>
+        /// 红色
+        /// </summary>
+        public int R
+        {
+            get { return this._r; }
+            set
+            {
+                this._r = value;
+                this._r = this._r > 255 ? 255 : this._r;
+                this._r = this._r < 0 ? 0 : this._r;
+            }
+        }
+
+        /// <summary>
+        /// 绿色
+        /// </summary>
+        public int G
+        {
+            get { return this._g; }
+            set
+            {
+                this._g = value;
+                this._g = this._g > 255 ? 255 : this._g;
+                this._g = this._g < 0 ? 0 : this._g;
+            }
+        }
+
+        /// <summary>
+        /// 蓝色
+        /// </summary>
+        public int B
+        {
+            get { return this._b; }
+            set
+            {
+                this._b = value;
+                this._b = this._b > 255 ? 255 : this._b;
+                this._b = this._b < 0 ? 0 : this._b;
+            }
+        }
+
+        /// <summary>
+        /// 获取实际颜色
+        /// </summary>
+        /// <returns></returns>
+        public Color GetColor()
+        {
+            return Color.FromArgb(this._r, this._g, this._b);
+        }
+    } 
+}

+ 36 - 0
TEAMModelOS.Test.PPTX/PPTElement.cs

@@ -0,0 +1,36 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using DocumentFormat.OpenXml.Presentation; 
+namespace TEAMModelOS.Test.PPTX
+{
+  public  class PPTElement
+    {
+        //旋转角度
+        public int rot { get; set; }
+        //水平翻转
+        public bool flipH { get; set; }
+        //垂直翻转
+        public bool flipV { get; set; }
+        //x轴
+        public long offx { get; set; }
+        //y轴
+        public long offy { get; set; }
+        //宽度
+        public long extx { get; set; }
+        //高度
+        public long exty { get; set; }
+        //类型
+        public string   type { get; set; }
+        //文本 /或图片base64
+        public string text { get; set; }
+        //文本颜色
+        public string textColor { get; set; }
+        //填充颜色
+        public string fillColor { get; set;  }
+        //图形是否闭合
+        public bool complete { get; set;  }
+        //字体大小
+        public int fontSize { get; set;  }
+    }
+}

+ 87 - 0
TEAMModelOS.Test.PPTX/PPTLibrary/Animations/AnimationTypes.cs

@@ -0,0 +1,87 @@
+namespace ClearSlideLibrary.Animations
+{
+    internal class AnimationTypes
+    {
+        public const string FlyIn = "FlyIn";
+        public const string FlyOut = "FlyOut";
+        public const string Sling = "Sling";
+        public const string Appear = "Appear";
+        public const string Strips = "Strips";
+        public const string Blinds = "Blinds";
+        public const string Box = "Box";
+        public const string Glide = "Glide";
+        public const string Swivel = "Swivel";
+        public const string Ascend = "Ascend";
+        public const string Boomerang = "Boomerang";
+        public const string CenterRevolve = "CenterRevolve";
+        public const string Compress = "Compress";
+        public const string CrawlIn = "CrawlIn";
+        public const string CrawlOut = "CrawlOut";        
+        public const string Descend = "Descend";
+        public const string EaseIn = "EaseIn";
+        public const string EaseOut = "EaseOut";
+        public const string Expand = "Expand";
+        public const string Contract = "Contract";
+        public const string FadedZoom = "FadedZoom";
+        public const string FlashOnce = "FlashOnce";
+        public const string Fold = "Fold";
+        public const string GrowTurn = "GrowTurn";
+        public const string Pinwheel = "Pinwheel";
+        public const string RiseUp = "RiseUp";
+        public const string SinkDown = "SinkDown";        
+        public const string Spinner = "Spinner";
+        public const string Bounce = "Bounce";
+        public const string Credits = "Credits";
+        public const string CurveUp = "CurveUp";
+        public const string CurveDown = "CurveDown";        
+        public const string Dissolve = "Dissolve";
+        public const string Float = "Float";
+        public const string LightSpeed = "LightSpeed";
+        public const string Magnify = "Magnify";
+        public const string SpiralIn = "SpiralIn";
+        public const string SpiralOut = "SpiralOut";
+        public const string Stretch = "Stretch";
+        public const string Thread = "Thread";
+        public const string Wheel = "Wheel";
+        public const string Zoom = "Zoom";
+        public const string Spin = "Spin";
+        public const string GrowShrink = "GrowShrink";  
+        public const string Checkerboard = "Checkerboard";
+        public const string Circle = "Circle";
+        public const string Diamond = "Diamond";        
+        public const string Fade = "Fade";
+        public const string Plus = "Plus";
+        public const string Wipe = "Wipe";
+        public const string PeekOut = "PeekOut";
+        public const string PeekIn = "PeekIn";
+        public const string Split = "Split";
+        public const string Push = "Push";
+        public const string FadeThroughBlack = "FadeThroughBlack";
+        public const string Cut = "Cut";
+        public const string CutThroughBlack = "CutThroughBlack";
+        public const string DissolveIn = "DissolveIn";
+        public const string Wedge = "Wedge";
+        public const string UnCover = "UnCover";        
+        public const string Newsflash = "Newsflash";
+        public const string RandomBars = "RandomBars";
+        public const string MotionPath = "MotionPath";
+        public const string TypePath = "path";
+        public const string TypeEntrance = "entr";
+        public const string TypeExit = "exit";
+        public const string TypeEmphasis = "emph";
+        public const string ChangeFontColor = "ChangeFontColor";
+        public const string ColorWave = "ColorWave";
+        public const string ColorBlend = "ColorBlend";
+        public const string BrushOnColor = "BrushOnColor";
+        public const string Blast = "Blast";
+        public const string FlashBulb = "FlashBulb";
+        public const string Blink = "Blink";
+        public const string Transparency = "Transparency";
+        public const string VerticalHighlight = "VerticalHighlight";
+        public const string Flicker = "Flicker";
+        public const string Shimmer = "Shimmer";
+        public const string GrowwithColor = "GrowwithColor";
+        public const string Teeter = "Teeter";
+        public const string Wave = "Wave";
+    }
+}

+ 104 - 0
TEAMModelOS.Test.PPTX/PPTLibrary/Animations/EmphasisAnimation.cs

@@ -0,0 +1,104 @@
+using DocumentFormat.OpenXml.Presentation;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using DocumentFormat.OpenXml.Drawing;
+using DocumentFormat.OpenXml;
+using ClearSlideLibrary.Dom;
+
+
+
+namespace ClearSlideLibrary.Animations
+{
+    public class EmphasisAnimation : SimpleAnimation
+    {
+        public EmphasisAnimation()
+        {
+            
+        }
+        
+        public EmphasisAnimation(SimpleAnimation fromBase)
+        {
+            this.AdditionalData = fromBase.AdditionalData;          
+            this.InitialState = fromBase.InitialState;
+            this.InnerAnimations = fromBase.InnerAnimations;
+            this.Start = fromBase.Start;
+            this.Length = fromBase.Length;
+            this.ObjectId = fromBase.ObjectId;
+            this.Repetitions = fromBase.Repetitions;
+            this.timingType = fromBase.timingType;
+            this.Type = fromBase.Type;
+            
+            this.RGBColor = "[0,0,0]";
+            this.Transparency = 0;
+            this.RotationDegrees = 0;
+            this.ScaleX = 0;
+            this.ScaleY = 0;
+            e1 = 1;
+            e2 = 0;
+        }
+
+        public String RGBColor { get; set; }
+        public double Transparency { get; set; }
+        public int ScaleX { get; set; }
+        public int ScaleY { get; set; }
+        public int RotationDegrees { get; set; }
+        public int e1 { get; set; }
+        public int e2 { get; set; }
+
+        public override string GetJsonString()
+        {
+            return "{objectId:" + GetObjectIdForJSON() + ",start:" + Start + ",length:" + Length + ",repeat:" + Repetitions + ",state:" + InitialState +
+                   ",name:'" + Type + "',c7:0,additionalData:" + RotationDegrees + ",additionalData2:" + RotationDegrees + ",scaleX:" + ScaleX + ",scaleY:" + ScaleY +
+                   ",color:" + RGBColor + ",transparency:" +
+
+                   Transparency.ToString("0.##", System.Globalization.CultureInfo.GetCultureInfo("en-US").NumberFormat) + ",v:0,e0:" + GetE0Value() + ",e1:" + e1 + ",e2:" + e2 + GetE3Value() + "}";
+        }
+
+        public void setRgbColor(CommonTimeNode commonTimeNode, PPTSlide Slide)
+        {
+            RGBColor = "[0,0,0]";
+            foreach (Object xmlEl in commonTimeNode.Descendants())
+            {
+                if (xmlEl.GetType().Equals(typeof(RgbColorModelHex)))
+                {
+                    RgbColorModelHex rgb = (RgbColorModelHex)xmlEl;
+                    RGBColor = convertHEXtoRGB(((RgbColorModelHex)rgb).Val);
+                }
+                else if (xmlEl.GetType().Equals(typeof(SchemeColor)))
+                {
+                    string schemeCol = ((SchemeColor)xmlEl).Val;
+                    DocumentFormat.OpenXml.Drawing.ColorScheme allSchemeCols =
+                        Slide.SlideLayoutPart.SlideMasterPart.ThemePart.Theme.ThemeElements.ColorScheme;
+                    foreach (OpenXmlCompositeElement desc in allSchemeCols.Descendants())
+                    {
+                        string currSchemeCol = desc.LocalName;
+                        if (schemeCol == currSchemeCol ||
+                            (schemeCol == "bg1" && currSchemeCol == "lt1") ||
+                            (schemeCol == "bg2" && currSchemeCol == "lt2") ||
+                            (schemeCol == "tx1" && currSchemeCol == "dk1") ||
+                            (schemeCol == "tx2" && currSchemeCol == "dk2"))
+                        {
+                            if (typeof(RgbColorModelHex) == desc.FirstChild.GetType())
+                            {
+                                RGBColor = convertHEXtoRGB(((RgbColorModelHex)desc.FirstChild).Val);
+                            }
+                            else if (typeof(SystemColor) == desc.FirstChild.GetType())
+                            {
+                                RGBColor = convertHEXtoRGB(((SystemColor)desc.FirstChild).LastColor);
+                            }
+                        }
+                    }
+                    break;
+                }
+            }
+        }
+
+        private string convertHEXtoRGB(string hex)
+        {
+            var colorHtml = System.Drawing.ColorTranslator.FromHtml("#" + hex);
+            string rgb = "[" + colorHtml.R + "," + colorHtml.G + "," + colorHtml.B + "]";
+            return rgb;
+        }
+    }
+}

+ 19 - 0
TEAMModelOS.Test.PPTX/PPTLibrary/Animations/IAnimation.cs

@@ -0,0 +1,19 @@
+using DocumentFormat.OpenXml.Presentation;
+using System.Collections.Generic;
+
+namespace ClearSlideLibrary.Animations
+{
+    public interface IAnimation
+    {
+        string GetJsonString();
+        int Start { get; set; }
+        int Length { get; set; }
+        string ObjectId { get; set; }
+        int Repetitions { get; set; }
+        int InitialState { get; set; }
+        string Type { get; set; }
+        string AdditionalData { get; set; }
+        List<IAnimation> InnerAnimations { get; set; }
+        bool IsItEntranceAnimation();
+    }
+}

+ 710 - 0
TEAMModelOS.Test.PPTX/PPTLibrary/Animations/JSONGenerator.cs

@@ -0,0 +1,710 @@
+using ClearSlideLibrary.Dom;
+using DocumentFormat.OpenXml;
+using DocumentFormat.OpenXml.Presentation;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text.RegularExpressions;
+
+namespace ClearSlideLibrary.Animations
+{
+    public class JSONGenerator
+    {
+        public PPTSlide Slide { get; set; }
+
+        public JSONGenerator(PPTSlide slide)
+        {
+            this.Slide = slide;
+        }
+
+        public JSONGenerator(List<PPTSlide> slides)
+        {
+            this.Slide = slides.ElementAt(0); //TODO: add support for more than one slide
+        }
+
+        public string GetAnimaVariable()
+        {
+            return "var animations = " + GetAnimationsJSON() + ";";
+        }
+
+        /*
+         * Fix the timing for animations that need to start without a click. Make the tree simpler by removing nodes that are empty or nested.
+         * 
+         * When a node has a start type != ClickEffect , we add the Animations from this timenode to the animations list in the previous time node.
+         * If it is type After the previous one we need to set Delay = Length of the previous one. 
+         * 
+         * Removing nested nodes:
+         * Example 1: Node -> Node -> Node  - every node has a single child. In this case we can create one time node with the timing for both. 
+         * Example 2: We have only one node (one simple animation) and all the other are nested (inner animations) - we remove the parent time node and 
+         * add its timing to the timing of the nested animations.
+         * 
+         */
+
+        private List<IAnimation> fixAnimationTimings(List<IAnimation> animations)
+        {
+            animations = fixNestedAnimations(animations);
+
+
+            List<IAnimation> result = new List<IAnimation>();
+            if (animations == null || animations.Count == 0)
+                return result;
+            //If we have only one animation and all the others are nested  - add the delay to the inner animations and remove this one.
+            if (animations.Count == 1 && animations[0].InnerAnimations != null && animations[0].InnerAnimations.Count > 0)
+            {
+                foreach (IAnimation anim in animations[0].InnerAnimations)
+                    anim.Start += animations[0].Start;
+                return fixAnimationTimings(animations[0].InnerAnimations);
+            }
+            IAnimation previousAnimation = null;
+            foreach (IAnimation animation in animations)
+            {
+                SimpleAnimation sAnimation = (SimpleAnimation)animation;
+                if (previousAnimation == null)
+                {
+                    previousAnimation = sAnimation;
+                    continue;
+                }
+               //These are the cases where animation starts without a click. There migth be other cases which are not handled yet.
+                else if (sAnimation.timingType.HasValue && (
+                        TimeNodeValues.WithEffect.Equals(sAnimation.timingType.Value) ||
+                        TimeNodeValues.AfterEffect.Equals(sAnimation.timingType.Value) ||
+                        TimeNodeValues.WithGroup.Equals(sAnimation.timingType.Value) ||
+                        TimeNodeValues.AfterGroup.Equals(sAnimation.timingType.Value)))
+                {
+                    int newLenegth = 0;
+                    if (TimeNodeValues.AfterEffect.Equals(sAnimation.timingType.Value) ||
+                        TimeNodeValues.AfterGroup.Equals(sAnimation.timingType.Value))
+                    {
+                        /*If animation is a part of a group then it has delay according to the start of the parent time node (animation). 
+                         * In this case we use this delay because it is the proper way power point handles such animations. 
+                         * If by some reason there isn't such delay and the animation type is set to 'After' previous
+                         * we set the start point to right after the previous animation ends." */
+
+                        if (sAnimation.Start <= previousAnimation.Length + previousAnimation.Start) 
+                            sAnimation.Start = previousAnimation.Length + previousAnimation.Start;                      
+                        if (sAnimation.InnerAnimations != null)
+                            foreach (IAnimation anim in sAnimation.InnerAnimations)
+                                anim.Start = anim.Start + sAnimation.Start;
+                        newLenegth = sAnimation.Length + sAnimation.Start;
+                    }
+                    else
+                    {
+                        newLenegth = (sAnimation.Length + sAnimation.Start >
+                                           previousAnimation.Length + previousAnimation.Start)
+                                              ? sAnimation.Length + sAnimation.Start
+                                              : previousAnimation.Length + previousAnimation.Start;
+                    }
+
+                    /*Joins the current animation and the previous one and recalculates the length*/
+                    if (previousAnimation.InnerAnimations != null && previousAnimation.InnerAnimations.Count > 0)
+                    {
+
+                        previousAnimation.Length = newLenegth;
+                        if (sAnimation.InnerAnimations == null || sAnimation.InnerAnimations.Count == 0)
+                            previousAnimation.InnerAnimations.Add(sAnimation);
+                        else
+                            previousAnimation.InnerAnimations.AddRange(sAnimation.InnerAnimations);
+                        continue;
+                    }
+                    else
+                    {
+                        SimpleAnimation tempAnimation = new SimpleAnimation();
+                        tempAnimation.Length = newLenegth;
+                        tempAnimation.timingType = ((SimpleAnimation)previousAnimation).timingType;
+                        tempAnimation.InnerAnimations = new List<IAnimation>();
+
+                        if (previousAnimation.InnerAnimations == null || previousAnimation.InnerAnimations.Count == 0)
+                            tempAnimation.InnerAnimations.Add(previousAnimation);
+                        else
+                            tempAnimation.InnerAnimations.AddRange(previousAnimation.InnerAnimations);
+
+                        if (sAnimation.InnerAnimations == null || sAnimation.InnerAnimations.Count == 0)
+                            tempAnimation.InnerAnimations.Add(sAnimation);
+                        else
+                            tempAnimation.InnerAnimations.AddRange(sAnimation.InnerAnimations);
+                        previousAnimation = tempAnimation;
+                        continue;
+                    }
+                }
+                result.Add(previousAnimation);
+                previousAnimation = sAnimation;
+            }
+            result.Add(previousAnimation);
+            return result;
+        }
+
+        
+        /* 
+         * When the animation has only one inner animation then return the inner animation. Do this recursive until we get the real one.          
+         */
+        private IAnimation getAnimationFromNested(IAnimation sAnimation)
+        {
+            if (sAnimation.InnerAnimations != null && sAnimation.InnerAnimations.Count == 1)
+            {
+                sAnimation.InnerAnimations[0].Start += sAnimation.Start;
+                return getAnimationFromNested(sAnimation.InnerAnimations[0]);
+            }
+            if (((SimpleAnimation)sAnimation).timingType == null && sAnimation.InnerAnimations != null)
+                ((SimpleAnimation)sAnimation).timingType = ((SimpleAnimation)getAnimationFromNested(sAnimation.InnerAnimations[0])).timingType;
+            return sAnimation;
+        }
+
+
+        /*         
+         * Generating the JSON for the animations for one slide only. It has some support for nested animations but not everything works.                    
+         */
+
+        public string GetAnimationsJSON()
+        {
+            if (Slide == null)
+            {
+                return "{s1:{t:{i:1000,c:1,v:0,n:0},g:0,a:0,f:0,c:0}}";
+            }
+            String result = "";
+
+            int animations = 0;
+
+            List<IAnimation> fixedAnimations = fixAnimationTimings(Slide.Animations);
+            animations = fixedAnimations.Count;
+
+            if (Slide.Transition == null)
+            {             
+                result = "{s1:{t:{i:0,c:1,v:0,n:0},g:0,a:0,f:0,c:##ANIMATIONS_PLACEHOLDER##}}";
+            }
+            else
+            {
+                result = "{s1:{t:{i:" + (Slide.Transition.Length + Slide.Transition.Start) +
+                         ",c:" + Slide.Transition.GetJsonString() + "},g:0,a:0,f:0,c:##ANIMATIONS_PLACEHOLDER##}}";
+            }
+            if (animations == 0)
+            {
+                result = result.Replace("##ANIMATIONS_PLACEHOLDER##", "0");
+                return result;
+            }
+
+
+            SimpleAnimation checkEffectFirstAnim = (SimpleAnimation)fixedAnimations[0];
+            if (checkEffectFirstAnim.timingType.HasValue && checkEffectFirstAnim.timingType.Value != TimeNodeValues.ClickEffect)
+            {
+                result = result.Replace("n:0", "n:1");
+                //If it is just one Animation we change this in the transition! - the transition is like the first Animation!
+            }
+
+
+            string animationsString = "{i:" + animations + getAnimationsString(fixedAnimations, true) + "}";
+
+
+
+
+            result = result.Replace("##ANIMATIONS_PLACEHOLDER##", animationsString);
+
+            return result;
+        }
+
+
+        /*
+         * Generate JSON for animation tree. Recursive going into the tree - there is some difference in the animation string 
+         * for the first level and the next levels.         
+         */
+
+        private string getAnimationsString(List<IAnimation> animations, bool firstLevel)
+        {
+            String animationList = "";
+            int index = 0;
+            foreach (IAnimation animation in animations)
+            {
+                if (animation.InnerAnimations == null || animation.InnerAnimations.Count == 0)
+                {
+                    if (!firstLevel)
+                        animationList = animationList + ",c" + index++ + ":" + animation.GetJsonString();
+                    else
+                        animationList = animationList + ",c" + index++ + ":{i:" + (((SimpleAnimation)animation).getCalculatedLength() + animation.Start) + ",c0:" + animation.GetJsonString() + "}";
+                }
+                else
+                // Nested animatons (several animations in one time node, or in different time nodes that start together!
+                {
+                    String innerAnimationsString = getAnimationsString(animation.InnerAnimations, false);
+
+                    animationList = animationList + ",c" + index++ + ":{i:" + (((SimpleAnimation)animation).getCalculatedLength() + animation.Start) +
+                                    innerAnimationsString + "}";
+                }
+            }
+            return animationList;
+        }
+
+        public static IAnimation GenerateTransitionAnimationObject(Transition trans)
+        {
+            if (trans == null || trans.FirstChild == null)
+                return null;
+            TransitionAnimation result = new TransitionAnimation();
+            if (trans.Speed != null && TransitionSpeedValues.Fast.Equals(trans.Speed.Value))
+                result.Length = 500;
+            else if (trans.Speed != null && TransitionSpeedValues.Slow.Equals(trans.Speed.Value))
+                result.Length = 2000;
+            else if (trans.Duration != null)
+                result.Length = int.Parse(trans.Duration.Value);
+            else
+                result.Length = 1000;
+
+            result.Start = 0;
+            result.InitialState = -1;
+            result.Repetitions = 1;
+            if (trans.AdvanceOnClick != null)
+                result.AdvanceOnClick = trans.AdvanceOnClick.Value;
+            else result.AdvanceOnClick = true;
+
+            if (typeof(StripsTransition) == trans.FirstChild.GetType())
+            {
+                StripsTransition transition = (StripsTransition)trans.FirstChild;
+                result.Type = AnimationTypes.Strips;
+                if (transition.Direction != null &&
+                    TransitionCornerDirectionValues.RightUp.Equals(transition.Direction.Value))
+                    result.AdditionalData = "7";
+                else if (transition.Direction != null &&
+                         TransitionCornerDirectionValues.LeftDown.Equals(transition.Direction.Value))
+                    result.AdditionalData = "9";
+                else if (transition.Direction != null &&
+                         TransitionCornerDirectionValues.RightDown.Equals(transition.Direction.Value))
+                    result.AdditionalData = "8";
+                else
+                    result.AdditionalData = "6";
+            }
+            else if (typeof(PushTransition) == trans.FirstChild.GetType())
+            {
+                PushTransition transition = (PushTransition)trans.FirstChild;
+                result.Type = AnimationTypes.Push;
+                if (transition.Direction != null &&
+                    TransitionSlideDirectionValues.Right.Equals(transition.Direction.Value))
+                    result.AdditionalData = "3";
+                else if (transition.Direction != null &&
+                         TransitionSlideDirectionValues.Up.Equals(transition.Direction.Value))
+                    result.AdditionalData = "4";
+                else if (transition.Direction != null &&
+                         TransitionSlideDirectionValues.Left.Equals(transition.Direction.Value))
+                    result.AdditionalData = "2";
+                else result.AdditionalData = "1";
+            }
+            else if (typeof(WipeTransition) == trans.FirstChild.GetType())
+            {
+                WipeTransition transition = (WipeTransition)trans.FirstChild;
+                result.Type = AnimationTypes.Wipe;
+                if (transition.Direction != null &&
+                    TransitionSlideDirectionValues.Right.Equals(transition.Direction.Value))
+                    result.AdditionalData = "4";
+                else if (transition.Direction != null &&
+                         TransitionSlideDirectionValues.Up.Equals(transition.Direction.Value))
+                    result.AdditionalData = "3";
+                else if (transition.Direction != null &&
+                         TransitionSlideDirectionValues.Left.Equals(transition.Direction.Value))
+                    result.AdditionalData = "2";
+                else result.AdditionalData = "1";
+            }
+            else if (typeof(FadeTransition) == trans.FirstChild.GetType())
+            {
+                FadeTransition transition = (FadeTransition)trans.FirstChild;
+                result.Type = AnimationTypes.Fade;
+                if (transition.ThroughBlack != null && transition.ThroughBlack.Value)
+                    result.Type = AnimationTypes.FadeThroughBlack;
+                result.AdditionalData = "1";
+            }
+            else if (typeof(CutTransition) == trans.FirstChild.GetType())
+            {
+                CutTransition transition = (CutTransition)trans.FirstChild;
+                result.Type = AnimationTypes.Cut;
+                result.AdditionalData = "2";
+                if (transition.ThroughBlack != null && transition.ThroughBlack.Value)
+                {
+                    result.Type = AnimationTypes.CutThroughBlack;
+                    result.AdditionalData = "3";
+                }
+            }
+            else if (typeof(DissolveTransition) == trans.FirstChild.GetType())
+            {
+                result.Type = AnimationTypes.DissolveIn;
+                result.AdditionalData = "1";
+            }
+            else if (typeof(WedgeTransition) == trans.FirstChild.GetType())
+            {
+                result.Type = AnimationTypes.Wedge;
+                result.AdditionalData = "1";
+            }
+            else if (typeof(PullTransition) == trans.FirstChild.GetType())
+            {
+                PullTransition transition = (PullTransition)trans.FirstChild;
+                result.Type = AnimationTypes.UnCover;
+                if (transition.Direction != null && "d".Equals(transition.Direction.Value.ToString()))
+                    result.AdditionalData = "9";
+                else if (transition.Direction != null && "r".Equals(transition.Direction.Value.ToString()))
+                    result.AdditionalData = "11";
+                else if (transition.Direction != null && "u".Equals(transition.Direction.Value.ToString()))
+                    result.AdditionalData = "12";
+                else if (transition.Direction != null && "ld".Equals(transition.Direction.Value.ToString()))
+                    result.AdditionalData = "13";
+                else if (transition.Direction != null && "lu".Equals(transition.Direction.Value.ToString()))
+                    result.AdditionalData = "14";
+                else if (transition.Direction != null && "rd".Equals(transition.Direction.Value.ToString()))
+                    result.AdditionalData = "15";
+                else if (transition.Direction != null && "ru".Equals(transition.Direction.Value.ToString()))
+                    result.AdditionalData = "16";
+                else result.AdditionalData = "10";
+            }
+            else if (typeof(ZoomTransition) == trans.FirstChild.GetType())
+            {
+                ZoomTransition transition = (ZoomTransition)trans.FirstChild;
+                result.Type = AnimationTypes.Box;
+                if (transition.Direction != null && TransitionInOutDirectionValues.In == transition.Direction.Value)
+                    result.AdditionalData = "19";
+                else result.AdditionalData = "20";
+            }
+            else if (typeof(ZoomTransition) == trans.FirstChild.GetType())
+            {
+                ZoomTransition transition = (ZoomTransition)trans.FirstChild;
+                result.Type = AnimationTypes.Box;
+                if (transition.Direction != null && TransitionInOutDirectionValues.In == transition.Direction.Value)
+                    result.AdditionalData = "19";
+                else result.AdditionalData = "20";
+            }
+            else if (typeof(WheelTransition) == trans.FirstChild.GetType())
+            {
+                WheelTransition transition = (WheelTransition)trans.FirstChild;
+                result.Type = AnimationTypes.Wheel;
+                if (transition.Spokes != null && transition.Spokes.Value == 1)
+                    result.AdditionalData = "1";
+                else if (transition.Spokes != null && transition.Spokes.Value == 2)
+                    result.AdditionalData = "2";
+                else if (transition.Spokes != null && transition.Spokes.Value == 3)
+                    result.AdditionalData = "3";
+                else if (transition.Spokes != null && transition.Spokes.Value == 8)
+                    result.AdditionalData = "8";
+                else result.AdditionalData = "4";
+            }
+            else if (typeof(SplitTransition) == trans.FirstChild.GetType())
+            {
+                SplitTransition transition = (SplitTransition)trans.FirstChild;
+                result.Type = AnimationTypes.Split;
+                if (transition.Direction != null && TransitionInOutDirectionValues.In == transition.Direction.Value)
+                {
+                    if (transition.Orientation != null && DirectionValues.Vertical.Equals(transition.Orientation.Value))
+                        result.AdditionalData = "25";
+                    else
+                        result.AdditionalData = "23";
+                }
+                else
+                {
+                    if (transition.Orientation != null && DirectionValues.Vertical.Equals(transition.Orientation.Value))
+                        result.AdditionalData = "26";
+                    else
+                        result.AdditionalData = "24";
+                }
+            }
+            else if (typeof(CircleTransition) == trans.FirstChild.GetType())
+            {
+                result.Type = AnimationTypes.Circle;
+                result.AdditionalData = "20";
+            }
+            else if (typeof(DiamondTransition) == trans.FirstChild.GetType())
+            {
+                result.Type = AnimationTypes.Diamond;
+                result.AdditionalData = "20";
+            }
+            else if (typeof(PlusTransition) == trans.FirstChild.GetType())
+            {
+                result.Type = AnimationTypes.Plus;
+                result.AdditionalData = "20";
+            }
+            else if (typeof(NewsflashTransition) == trans.FirstChild.GetType())
+            {
+                result.Type = AnimationTypes.Newsflash;
+                result.AdditionalData = "20";
+            }
+            return result;
+        }
+
+
+        public SimpleAnimation getSimpleAnimationFromCommonTimeNodePreset(CommonTimeNode commonTimeNode, SlideSize SlideSizes)
+        {
+            SimpleAnimation result = new SimpleAnimation();
+            if (AnimationTypes.TypePath.Equals(commonTimeNode.PresetClass))
+            {
+                return new MotionPathAnimation(commonTimeNode, Slide.slideIndex, SlideSizes);
+            }
+            else if (AnimationTypes.TypeEntrance.Equals(commonTimeNode.PresetClass))
+            {
+                result.InitialState = 1;
+            }
+            else if (AnimationTypes.TypeExit.Equals(commonTimeNode.PresetClass))
+            {
+                result.InitialState = 2;
+            }
+            else if (AnimationTypes.TypeEmphasis.Equals(commonTimeNode.PresetClass))
+            {
+                result.InitialState = 3;
+            }
+            else return null;
+            if (commonTimeNode.PresetId == null)
+                return null;
+            result.timingType = commonTimeNode.NodeType;
+
+            //Get the speed from one of the nodes common behavior. Hopefully all nodes have the same speed (since the animation is the same).
+            foreach (Object xmlEl in commonTimeNode.Descendants())
+                if (xmlEl.GetType().Equals(typeof(CommonBehavior)))
+                {
+                    CommonBehavior bhvr = ((CommonBehavior)xmlEl);
+
+                    if (bhvr.CommonTimeNode != null)
+                    {
+                        result.FixAnimationTimings(bhvr, Slide.slideIndex);
+                        if (result.Length <= 1)
+                            continue;
+                        if (result.Start == 0)
+                        {
+                            Condition condition = commonTimeNode.StartConditionList.FirstChild as Condition;
+                            if (!condition.Delay.Equals("indefinite"))
+                                result.Start = int.Parse(condition.Delay);
+                        }
+                        break;
+                    }
+                }
+            if (result.Length <= 1)
+                result.Length = 100;  //Default value??
+            if (AnimationTypes.TypeEmphasis.Equals(commonTimeNode.PresetClass))
+                result = handleEmphasisAnimation(commonTimeNode, result);
+            else
+                result = handleEntranceAnimation(commonTimeNode, result);
+
+
+            if (result.AdditionalData == null || result.AdditionalData == "0") //There are default values. Horizontal In = horizontal + in ;)
+                switch (commonTimeNode.PresetSubtype.Value)
+                {
+                    case 0: result.AdditionalData = "0"; break;
+                    case 4: result.AdditionalData = "3"; break;   //From bottom
+                    case 2: result.AdditionalData = "2"; break;   //From right
+                    case 1: result.AdditionalData = "1"; break;   //From top
+                    case 8: result.AdditionalData = "4"; break;   //From left
+                    case 6: result.AdditionalData = "8"; break;  //Bottom right
+                    case 3: result.AdditionalData = "7"; break;  //Top right
+                    case 9: result.AdditionalData = "6"; break;  //Top right
+                    case 12: result.AdditionalData = "9"; break;  //Bottom left
+                    case 10: result.AdditionalData = "16"; break;  //Horizontal
+                    case 5: result.AdditionalData = "17"; break;   //Vertical
+                    case 26: result.AdditionalData = "23"; break;   //Horizontal in
+                    case 42: result.AdditionalData = "24"; break;   //Horizontal out
+                    case 21: result.AdditionalData = "25"; break;   //Vertical in
+                    case 37: result.AdditionalData = "26"; break;   //Vertical out       
+                    case 16: result.AdditionalData = "19"; break;   //in    
+                    case 32: result.AdditionalData = "20"; break;   //out
+                }
+
+            checkIsText(result);
+            return result;
+        }
+
+        private void checkIsText(SimpleAnimation result)
+        {
+            int res;
+            bool isTextWithEffect = int.TryParse(result.ObjectId, out res) && PPTShape.effectShapes.Contains(Slide.slideIndex + "_" + res);
+
+            int tryParse = 0;
+            if (!int.TryParse(result.ObjectId, out tryParse) || isTextWithEffect) {
+                return;//if it is like 123p -> return;
+            }
+            
+            foreach (PPTShapeBase shape in Slide.ContainerShape.Elements)
+                if (typeof(PPTShape).Equals(shape.GetType()) && ((PPTShape)shape).IsText)
+                {
+                    string shapeId = shape.NonVisualShapeProp.Id;
+                    string shapeObjectId = "s1s" + result.ObjectId;
+                    if (shapeId.Equals(shapeObjectId))
+                    {
+                        result.ObjectId = result.ObjectId + "p0";// TODO check when multiple paragraphs
+                    }
+                }
+        }
+
+        private EmphasisAnimation handleEmphasisAnimation(CommonTimeNode commonTimeNode, SimpleAnimation simpleAnim)
+        {
+            EmphasisAnimation result = new EmphasisAnimation(simpleAnim);
+            result.setRgbColor(commonTimeNode, Slide);
+
+            switch (commonTimeNode.PresetId.Value)  //Presets for Entrance/Exit
+            {
+                case 3: result.Type = AnimationTypes.ChangeFontColor; break;
+                case 19: result.Type = AnimationTypes.ColorBlend; break;
+                case 14: result.Type = AnimationTypes.Blast; break;
+                case 26: result.Type = AnimationTypes.FlashBulb; break;
+                case 35: result.Type = AnimationTypes.Blink; break;
+                case 9:
+                    {
+                        result.Type = AnimationTypes.Transparency;
+                        result.Transparency = getTransparence(commonTimeNode);
+                    } break;
+                case 20:
+                    {
+                        result.Type = AnimationTypes.ColorWave;
+                        result.Length *= 2;
+                        result.e2 = result.Length / 10;
+                        result.e1 = 2;
+                    } break;
+                case 16:
+                    {
+                        result.Type = AnimationTypes.BrushOnColor;
+                        result.e2 = result.Length / 25;
+                        result.e1 = 2;
+                    } break;
+                case 33:
+                    {
+                        result.Type = AnimationTypes.VerticalHighlight;
+                        result.Length *= 2;
+                    } break;
+                case 27:
+                    {
+                        result.Type = AnimationTypes.Flicker;
+                        result.Length *= 2;
+                    } break;
+                case 36:
+                    {
+                        result.Type = AnimationTypes.Shimmer;
+                        result.e2 = result.Length / 5;
+                        result.Length *= 2;
+                        foreach (Object obj in commonTimeNode.Descendants())
+                            if (obj.GetType().Equals(typeof(AnimateScale)))
+                            {
+                                ((EmphasisAnimation)result).ScaleX = ((AnimateScale)obj).ToPosition.X.Value / 1000;
+                                ((EmphasisAnimation)result).ScaleY = ((AnimateScale)obj).ToPosition.Y.Value / 1000;
+                                break;
+                            }
+                    } break;
+                case 28:
+                    {
+                        result.Type = AnimationTypes.GrowwithColor;
+                        result.e2 = result.Length / 10;
+                        result.e1 = 2;
+                    } break;
+                case 32:
+                    {
+                        result.Type = AnimationTypes.Teeter;
+                        result.Length *= 2;
+                    } break;
+                case 34:
+                    {
+                        result.Type = AnimationTypes.Wave;
+                        result.e2 = result.Length / 5;
+                        result.Length *= 2;
+                    } break;
+                case 8:
+                    {
+                        result.Type = AnimationTypes.Spin;
+                        foreach (Object obj in commonTimeNode.Descendants())
+                            if (obj.GetType().Equals(typeof(AnimateRotation)))
+                            {
+                                ((EmphasisAnimation)result).RotationDegrees = ((AnimateRotation)obj).By / 60000;
+                                break;
+                            }
+                    } break;
+                case 6:
+                    {
+                        result.Type = AnimationTypes.GrowShrink;
+                        foreach (Object obj in commonTimeNode.Descendants())
+                            if (obj.GetType().Equals(typeof(AnimateScale)))
+                            {
+                                ((EmphasisAnimation)result).ScaleX = ((AnimateScale)obj).ByPosition.X.Value / 1000;
+                                ((EmphasisAnimation)result).ScaleY = ((AnimateScale)obj).ByPosition.Y.Value / 1000;
+                                break;
+                            }
+                    } break;
+                default: return null;
+            }
+
+            return result;
+        }
+
+        private SimpleAnimation handleEntranceAnimation(CommonTimeNode commonTimeNode, SimpleAnimation result)
+        {
+            switch (commonTimeNode.PresetId.Value)  //Presets for Entrance/Exit
+            {
+                case 1: result.Type = AnimationTypes.Appear; break;
+                case 54: result.Type = AnimationTypes.Glide; break;
+                case 19: result.Type = AnimationTypes.Swivel; break;
+                case 42: result.Type = AnimationTypes.Ascend; break;
+                case 3: result.Type = AnimationTypes.Blinds; break;
+                case 4: result.Type = AnimationTypes.Box; break;
+                case 25: result.Type = AnimationTypes.Boomerang; break;
+                case 43: result.Type = AnimationTypes.CenterRevolve; break;
+                case 5: result.Type = AnimationTypes.Checkerboard; break;
+                case 50: result.Type = AnimationTypes.Compress; break;
+                case 7: result.Type = AnimationTypes.TypeEntrance.Equals(commonTimeNode.PresetClass) ? AnimationTypes.CrawlIn : AnimationTypes.CrawlOut; break;
+                case 47: result.Type = AnimationTypes.Descend; break;
+                case 48: result.Type = AnimationTypes.Sling; break;
+                case 29: result.Type = AnimationTypes.TypeEntrance.Equals(commonTimeNode.PresetClass) ? AnimationTypes.EaseIn : AnimationTypes.EaseOut; break;
+                case 55: result.Type = AnimationTypes.TypeEntrance.Equals(commonTimeNode.PresetClass) ? AnimationTypes.Expand : AnimationTypes.Contract; break;
+                case 10: result.Type = AnimationTypes.Fade; break;
+                case 53: result.Type = AnimationTypes.FadedZoom; break;
+                case 11: result.Type = AnimationTypes.FlashOnce; break;
+                case 2: result.Type = AnimationTypes.TypeEntrance.Equals(commonTimeNode.PresetClass) ? AnimationTypes.FlyIn : AnimationTypes.FlyOut; break;
+                case 58: result.Type = AnimationTypes.Fold; break;
+                case 31: result.Type = AnimationTypes.GrowTurn; break;
+                case 12: result.Type = AnimationTypes.TypeEntrance.Equals(commonTimeNode.PresetClass) ? AnimationTypes.PeekIn : AnimationTypes.PeekOut; break;
+                case 16: result.Type = AnimationTypes.Split; break;
+                case 35: result.Type = AnimationTypes.Pinwheel; break;
+                case 14: result.Type = AnimationTypes.RandomBars; break;
+                case 37: result.Type = AnimationTypes.TypeEntrance.Equals(commonTimeNode.PresetClass) ? AnimationTypes.RiseUp : AnimationTypes.SinkDown; break;
+                case 49: result.Type = AnimationTypes.Spinner; break;
+                case 22: result.Type = AnimationTypes.Wipe; break;
+                case 18: result.Type = AnimationTypes.Strips; break;
+                case 26: result.Type = AnimationTypes.Bounce; result.Length = (int)((result.Length * 100) / 29); break;//time tunning
+                case 6: result.Type = AnimationTypes.Circle; break;
+                case 28: result.Type = AnimationTypes.Credits; break;
+                case 52: result.Type = AnimationTypes.TypeEntrance.Equals(commonTimeNode.PresetClass) ? AnimationTypes.CurveUp : AnimationTypes.CurveDown; break;
+                case 8: result.Type = AnimationTypes.Diamond; break;
+                case 9: result.Type = AnimationTypes.Dissolve; break;
+                case 30: result.Type = AnimationTypes.Float; break;
+                case 34: result.Type = AnimationTypes.LightSpeed; result.Length = (int)((result.Length * 5) / 3); break;//time tunning
+                case 51: result.Type = AnimationTypes.Magnify; result.Length = (int)((result.Length * 200) / 77); break;//time tunning
+                case 13: result.Type = AnimationTypes.Plus; break;
+                case 15: result.Type = AnimationTypes.TypeEntrance.Equals(commonTimeNode.PresetClass) ? AnimationTypes.SpiralIn : AnimationTypes.SpiralOut; break;
+                case 17: result.Type = AnimationTypes.Stretch; break;
+                case 39: result.Type = AnimationTypes.Thread; break;
+                case 20: result.Type = AnimationTypes.Wedge; break;
+                case 21: result.Type = AnimationTypes.Wheel; result.AdditionalData = "" + commonTimeNode.PresetSubtype.Value; break;
+                case 23: result.Type = AnimationTypes.Zoom; break;
+
+                default: return null;
+            }
+
+            return result;
+        }
+
+        private double getTransparence(CommonTimeNode commonTimeNode)
+        {
+            if (typeof(AnimateEffect) == commonTimeNode.LastChild.LastChild.GetType())
+            {
+                AnimateEffect animEffect = (AnimateEffect)commonTimeNode.LastChild.LastChild;
+                string value = animEffect.PropertyList.Value;
+                if (value != null && value.IndexOf("opacity:") != -1)
+                {
+                    string opacityStr = value.Substring(9);//we need 0.75 from "opacity: 0.75"
+                    double opacity = double.Parse(opacityStr,CultureInfo.GetCultureInfo("en-US").NumberFormat);
+                    return 1 - opacity;
+                }
+            }
+
+            return 0;
+        }
+
+        private List<IAnimation> fixNestedAnimations(List<IAnimation> animations)
+        {
+            if (animations == null || animations.Count == 0)
+                return null;
+            List<IAnimation> result = new List<IAnimation>();
+            foreach (IAnimation anim in animations)
+            {
+                IAnimation animation = getAnimationFromNested(anim);
+                animation.InnerAnimations = fixNestedAnimations(animation.InnerAnimations);
+                result.Add(animation);
+            }
+            return result;
+        }
+
+    }
+}

+ 201 - 0
TEAMModelOS.Test.PPTX/PPTLibrary/Animations/MotionPathAnimation.cs

@@ -0,0 +1,201 @@
+using DocumentFormat.OpenXml.Presentation;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using ClearSlideLibrary.PPTBuilder;
+using ClearSlideLibrary.Dom;
+
+namespace ClearSlideLibrary.Animations
+{
+    /*
+     *   Generates animation for a motion path. I am not sure if it works for all kinds of paths because there are lines, curves, lassos etc.
+     *   It calculates the distance for each part of the path (each curve, line etc - not between each point). 
+     *   We calculate the whole distance and give each part timing =  (PartDistance / WholeDistance) * wholeTime.
+     *   The speed in the path is constant. In PowerPoint there is acceleration and deceleration but we don't care about that yet ;)
+     */
+    class MotionPathAnimation : SimpleAnimation
+    {
+        private List<PathPart> motionPath;
+        private SlideSize SlideSizes;
+        public int MultiplierX()
+        {
+            if (SlideSizes == null || SlideSizes.Cx == 0)
+            {
+                return 1;
+            }
+            else if (SlideSizes.Cx < Globals.LEAST_COMMON_MULTIPLE_100_254)
+            {
+                return Convert.ToInt32((double)(Globals.LEAST_COMMON_MULTIPLE_100_254) / SlideSizes.Cx);
+            }
+            else
+            {
+                return Convert.ToInt32(SlideSizes.Cx / (double)(Globals.LEAST_COMMON_MULTIPLE_100_254));
+            }
+        }
+
+        public int MultiplierY()
+        {
+            if (SlideSizes == null || SlideSizes.Cy == 0)
+            {
+                return 1;
+            }
+            else if (SlideSizes.Cy < Globals.LEAST_COMMON_MULTIPLE_100_254)
+            {
+                return Convert.ToInt32((double)(Globals.LEAST_COMMON_MULTIPLE_100_254) / SlideSizes.Cy);
+            }
+            else
+            {
+                return Convert.ToInt32(SlideSizes.Cy / (double)(Globals.LEAST_COMMON_MULTIPLE_100_254));
+            }
+        }
+        public MotionPathAnimation(CommonTimeNode commonTimeNode, int slideIndex, SlideSize SlideSizes)
+        {
+
+
+            this.SlideSizes = SlideSizes;
+            InitialState = 4;
+            timingType = commonTimeNode.NodeType;
+            Type = AnimationTypes.MotionPath;
+            AnimateMotion motion = null;
+            foreach (Object xmlEl in commonTimeNode.Descendants())
+                if (xmlEl.GetType().Equals(typeof(AnimateMotion)))
+                    motion = (AnimateMotion)xmlEl;
+            if (motion == null)
+                return;
+            String path = motion.Path.Value;
+            String[] parts = path.Split();
+            motionPath = new List<PathPart>();
+            int indexPart = -1;
+            bool isX = true;
+            foreach (string part in parts)
+            {
+                if ("".Equals(part) || "E".Equals(part))  //We add our End tag 
+                    continue;
+                Double coords = 0.0;
+                if (!Double.TryParse(part, NumberStyles.Float, CultureInfo.InvariantCulture, out coords))
+                {
+                    isX = true;
+                    if (indexPart >= 0)
+                    {  //FIX FOR POINTS WITH 3 COORDINATES UNTIL WE KNOW WHAT THEY ARE.
+                        List<PathPoint> previousPartPoints = motionPath[indexPart].points;
+                        if (previousPartPoints[previousPartPoints.Count - 1].Y.CompareTo(0) == 0)
+                            previousPartPoints.Remove(previousPartPoints[previousPartPoints.Count - 1]);
+                    }
+
+                    indexPart++;
+                    motionPath.Add(new PathPart());
+                    motionPath[indexPart].typeCharacter = part;
+                }
+                else if (isX)
+                {
+                    coords = coords * MultiplierX();
+                    PathPoint newPoint = new PathPoint();
+                    newPoint.X = coords;
+                    motionPath[indexPart].points.Add(newPoint);   // We have a new point
+                    isX = !isX;
+                }
+                else
+                {
+                    coords = coords * MultiplierY();
+                    motionPath[indexPart].points[motionPath[indexPart].points.Count - 1].Y = coords;  //Set Y for the last point
+                    isX = !isX;
+                }
+            }
+
+
+            FixAnimationTimings(motion.CommonBehavior, slideIndex);
+            generateAdditionDataString(motionPath);
+
+        }
+
+        private void generateAdditionDataString(List<PathPart> motionPath)
+        {
+            double wholeDistance = 0.0;
+            PathPoint lastPoint = null;
+            foreach (PathPart part in motionPath)
+            {
+                wholeDistance += part.Distance(lastPoint);
+                lastPoint = part.LastPoint();
+            }
+            PathPart previousPart = null;
+            String result = "";
+            foreach (PathPart part in motionPath)
+            {
+                result += "|" + part.typeCharacter + " ";
+                bool needsComma = false;
+                if (previousPart != null && previousPart.LastPoint()!=null)
+                {
+                    needsComma = true;
+                    result += previousPart.LastPoint().X.ToString("0.##########", CultureInfo.CreateSpecificCulture("en-GB")) + "," +
+                                previousPart.LastPoint().Y.ToString("0.##########", CultureInfo.CreateSpecificCulture("en-GB"));
+                }
+                foreach (PathPoint point in part.points)
+                {
+                    result += (needsComma ? "," : "") +
+                                point.X.ToString("0.##########", CultureInfo.CreateSpecificCulture("en-GB")) + "," +
+                                point.Y.ToString("0.##########", CultureInfo.CreateSpecificCulture("en-GB"));
+                    needsComma = true;
+                }
+                if (previousPart != null) //First part doesn't have timing
+                {
+                    double timing = (part.Distance(previousPart.LastPoint()) / wholeDistance) * ((double)Length / (double)1000);
+                    result += "," + timing.ToString("0.##########", CultureInfo.CreateSpecificCulture("en-GB"));
+                }
+
+                previousPart = part;
+            }
+
+            result += "|E " + previousPart.LastPoint().X.ToString("0.##########", CultureInfo.CreateSpecificCulture("en-GB")) + "," +
+                                previousPart.LastPoint().Y.ToString("0.##########", CultureInfo.CreateSpecificCulture("en-GB"));
+            AdditionalData = "'" + result + "'";
+
+        }
+
+
+        private class PathPart
+        {
+            public string typeCharacter { get; set; }
+            public List<PathPoint> points { get; set; }
+            public PathPart()
+            {
+                points = new List<PathPoint>();
+            }
+            public PathPoint LastPoint()
+            {
+                if (points == null || points.Count == 0)
+                    return null;
+                return points[points.Count - 1];
+            }
+            public double Distance(PathPoint LastPoint)
+            {
+                double result = 0.0;
+                if (points.Count == 1 && LastPoint != null)
+                    return distanceBetweenPoints(points[0], LastPoint);
+                PathPoint previousPoint = null;
+                foreach (PathPoint point in points)
+                {
+                    if (previousPoint != null)
+                        result += distanceBetweenPoints(point, previousPoint);
+                    previousPoint = point;
+                }
+                return result;
+            }
+
+            private static double distanceBetweenPoints(PathPoint point1, PathPoint point2)
+            {
+                return Math.Sqrt(Math.Pow(point1.X - point2.X, 2) + Math.Pow(point1.Y - point2.Y, 2));
+            }
+        }
+
+
+        class PathPoint
+        {
+            public double X { get; set; }
+            public double Y { get; set; }
+        }
+
+    }
+}

+ 102 - 0
TEAMModelOS.Test.PPTX/PPTLibrary/Animations/SimpleAnimation.cs

@@ -0,0 +1,102 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using DocumentFormat.OpenXml.Presentation;
+using ClearSlideLibrary.Dom;
+
+namespace ClearSlideLibrary.Animations
+{
+    public class SimpleAnimation : IAnimation
+    {
+        public SimpleAnimation()
+        {
+            AdditionalData = "0";
+            ObjectId = "0";
+        }
+        public int Start { get; set; }
+        public int Length { get; set; }
+        public string ObjectId { get; set; }
+        public int Repetitions { get; set; }
+        public int InitialState { get; set; }
+        public string Type { get; set; }
+        public string AdditionalData { get; set; }
+        public List<IAnimation> InnerAnimations { get; set; }
+        public DocumentFormat.OpenXml.EnumValue<DocumentFormat.OpenXml.Presentation.TimeNodeValues> timingType { get; set; }
+
+        public int getCalculatedLength()
+        {
+            if (InnerAnimations==null || InnerAnimations.Count==0)
+                return Length;
+            int res=0;
+            foreach (SimpleAnimation anim in InnerAnimations)
+                res = res < anim.getCalculatedLength()+anim.Start?  anim.getCalculatedLength()+anim.Start : res;
+            return res;
+        }
+
+        public bool IsItEntranceAnimation()
+        {
+            return InitialState == 1; //I am not sure if it is correct ;)
+        }
+
+        protected string GetObjectIdForJSON()
+        {
+            int res = 0;
+            string result = int.TryParse(ObjectId, out res) ? ObjectId : "'" + ObjectId + "'";
+            return result;
+        }
+        protected string GetE3Value()
+        {
+            int res = 0;
+            string result = int.TryParse(ObjectId, out res) ? "": ",e3:['s1s" + ObjectId + "']";
+            return result;
+        }
+        public virtual string GetJsonString()
+        {
+
+            return "{objectId:" + GetObjectIdForJSON() + ",start:" + Start + ",length:" + Length + ",repeat:" + Repetitions + ",state:" + InitialState +
+                   ",name:'" + Type + "',additionalData:" + AdditionalData + ",v:0"+",e0:" + GetE0Value() + ",e1:1,e2:0"+ GetE3Value() 
+                                                                                + "}";
+        }
+
+        protected string GetE0Value()//if image then 3 else 2
+        {
+            int res = 0;
+            return int.TryParse(ObjectId, out res) ? "3" : "2";
+        }
+
+        public void FixAnimationTimings(CommonBehavior behavior, int slideIndex)
+        {
+            String intValue = behavior.TargetElement.ShapeTarget.ShapeId.Value;
+            ObjectId = intValue == null ? "" + 0 : intValue;
+            int spd = behavior.CommonTimeNode.Speed == null ? 100 : behavior.CommonTimeNode.Speed.Value;
+            intValue = behavior.CommonTimeNode.Duration;
+            Length = intValue == null  || intValue == "indefinite"? 0 : int.Parse(intValue)*spd/100;
+            int delay = 0;
+            if (behavior.CommonTimeNode.StartConditionList != null &&
+                behavior.CommonTimeNode.StartConditionList.Any())
+            {
+                foreach (Condition cond in behavior.CommonTimeNode.StartConditionList)
+                    if (cond.Delay != null && cond.Delay.HasValue)
+                        delay = delay + int.Parse(cond.Delay.Value);
+            }
+
+            if (behavior.TargetElement.ShapeTarget.TextElement != null && behavior.TargetElement.ShapeTarget.TextElement.ParagraphIndexRange != null)
+            {
+                int res = 0;
+                bool isTextWithEffect = int.TryParse(ObjectId, out res) && PPTShape.effectShapes.Contains(slideIndex + "_" + res);
+                if (!isTextWithEffect)
+                {
+                    ObjectId = ObjectId + "p" + behavior.TargetElement.ShapeTarget.TextElement.ParagraphIndexRange.Start;
+                }
+                
+                //TODO: add support for paragraph start-end index range
+            }
+
+            intValue = behavior.CommonTimeNode.RepeatDuration;
+            Repetitions = intValue == null ? 1 : int.Parse(intValue);
+            InnerAnimations = new List<IAnimation>();
+            Start = delay;
+
+        }
+    }
+}

+ 13 - 0
TEAMModelOS.Test.PPTX/PPTLibrary/Animations/TransitionAnimation.cs

@@ -0,0 +1,13 @@
+namespace ClearSlideLibrary.Animations
+{
+    internal class TransitionAnimation : SimpleAnimation
+    {
+        public bool AdvanceOnClick { get; set; }
+        
+        public override string GetJsonString()
+        {
+            return "{objectId:" + GetObjectIdForJSON() + ",start:" + Start + ",length:" + Length + ",repeat:" + Repetitions + ",state:" + InitialState +
+                   ",name:'" + Type + "',additionalData:" + AdditionalData + "},v:0,n:" + (AdvanceOnClick ? "0" : "1");
+        }
+    }
+}

+ 12 - 0
TEAMModelOS.Test.PPTX/PPTLibrary/CustPathList.cs

@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TEAMModelOS.Test.PPTX.PPTLibrary
+{
+    public  class CustPathList
+    {
+        public int x { get; set; }
+        public int y { get; set; }
+    }
+}

+ 39 - 0
TEAMModelOS.Test.PPTX/PPTLibrary/Dom/Globals.cs

@@ -0,0 +1,39 @@
+namespace ClearSlideLibrary.Dom
+{
+    using System.Drawing;
+    using System.Drawing.Drawing2D;
+    using System.Drawing.Imaging;
+    using System.IO;
+
+    public static class Globals
+    {
+        // public const string ROOT_DIR = Path.GetDirectoryName(Path.GetDirectoryName(Environment.CurrentDirectory));
+        public const string STORAGE_DIR = "PictureExtracts";
+        public const string IMAGE_TO_SHAPE_MAPPING_FILE = "imageShapeMappingFile.txt";
+        public const int LEAST_COMMON_MULTIPLE_100_254 = 12700; //8000;
+        public const int PercentageConstant = 100000;
+        public const int FontPoint = 100;
+
+
+        public static Image ScaleByPercent(Image imgPhoto, int Percent)
+        {
+            //float nPercent = ((float)Percent / 100);
+            //int sourceWidth = imgPhoto.Width;
+            //int sourceHeight = imgPhoto.Height;
+
+            int destWidth = Percent; //(int)(sourceWidth * nPercent);
+            int destHeight = Percent;//(int)(sourceHeight * nPercent);
+
+            Bitmap  bmPhoto = new Bitmap(destWidth, destHeight);
+            bmPhoto.SetResolution(imgPhoto.HorizontalResolution,
+                                    imgPhoto.VerticalResolution);
+
+            Graphics grPhoto = Graphics.FromImage(bmPhoto);
+            grPhoto.InterpolationMode = InterpolationMode.HighQualityBicubic;
+
+            grPhoto.DrawImage(imgPhoto, 0, 0, destWidth, destHeight);
+            grPhoto.Dispose();
+            return bmPhoto;
+        }
+    }
+}

+ 7 - 0
TEAMModelOS.Test.PPTX/PPTLibrary/Dom/IPPTDrawable.cs

@@ -0,0 +1,7 @@
+namespace ClearSlideLibrary.Dom
+{
+    internal interface IPPTDrawable
+    {
+        void CreateImage(string pathToFile);
+    }
+}

+ 68 - 0
TEAMModelOS.Test.PPTX/PPTLibrary/Dom/PPTConnectionShape.cs

@@ -0,0 +1,68 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using DocumentFormat.OpenXml.Packaging;
+using DocumentFormat.OpenXml.Presentation;
+
+
+namespace ClearSlideLibrary.Dom
+{
+    public class PPTConnectionShape : PPTShapeBase
+    {
+        public PPTConnectionShape(SlidePart slidePart, ConnectionShape connectionShape)
+        {
+            SetConnectionShapeVisualProperties(slidePart, connectionShape);
+            SetConnectionShapeNonVisualProperties(slidePart, connectionShape);
+        }
+
+
+        private void SetConnectionShapeNonVisualProperties(SlidePart slidePart, 
+                                                           ConnectionShape connectionShape)
+        {
+            if (connectionShape.NonVisualConnectionShapeProperties.NonVisualDrawingProperties.HyperlinkOnClick != null)
+                foreach (HyperlinkRelationship link in slidePart.HyperlinkRelationships)
+                    if (link.Id.Equals(connectionShape.NonVisualConnectionShapeProperties.NonVisualDrawingProperties.HyperlinkOnClick.Id))
+                        ClickLinkUrl = link.Uri.IsAbsoluteUri ? link.Uri.AbsoluteUri : link.Uri.OriginalString;
+
+            if (connectionShape.NonVisualConnectionShapeProperties.NonVisualDrawingProperties.HyperlinkOnHover != null)
+                foreach (HyperlinkRelationship link in slidePart.HyperlinkRelationships)
+                    if (link.Id.Equals(connectionShape.NonVisualConnectionShapeProperties.NonVisualDrawingProperties.HyperlinkOnHover.Id))
+                        HoverLinkUrl = link.Uri.IsAbsoluteUri ? link.Uri.AbsoluteUri : link.Uri.OriginalString;
+            var nonVisualShapeProp = new PPTNonVisualShapeProp
+            {
+                Id = "s1s" +  //HARD CODED: we split it into separate HTML files!
+                connectionShape.NonVisualConnectionShapeProperties.NonVisualDrawingProperties.Id,
+                Name = connectionShape.LocalName,
+                Type = "PPTConnectionShape"
+            };
+            base.NonVisualShapeProp = nonVisualShapeProp;
+        }
+
+        private void SetConnectionShapeVisualProperties(SlidePart slidePart,
+                                                        ConnectionShape connectionShape)
+        {
+            base.VisualShapeProp = new PPTVisualPPTShapeProp();
+            if (connectionShape.ShapeProperties.Transform2D != null)
+            {
+                base.VisualShapeProp.Extents = connectionShape.ShapeProperties.Transform2D.Extents;
+                base.VisualShapeProp.Offset = connectionShape.ShapeProperties.Transform2D.Offset;
+            }
+            else
+            {
+                ShapeTree shapeTree = slidePart.SlideLayoutPart.SlideLayout.CommonSlideData.ShapeTree;
+                ConnectionShape layoutShape;
+                if (shapeTree != null)
+                {
+                    layoutShape = shapeTree.GetFirstChild<ConnectionShape>();
+                    if (layoutShape.ShapeProperties.Transform2D != null)
+                    {
+                        base.VisualShapeProp.Extents = layoutShape.ShapeProperties.Transform2D.Extents;
+                        base.VisualShapeProp.Offset = layoutShape.ShapeProperties.Transform2D.Offset;
+                    }
+                }
+            }
+        }
+    }
+}

+ 15 - 0
TEAMModelOS.Test.PPTX/PPTLibrary/Dom/PPTContainerShape.cs

@@ -0,0 +1,15 @@
+using System.Collections.Generic;
+
+namespace ClearSlideLibrary.Dom
+{
+    public class PPTContainerShape
+    {
+
+
+        public List<PPTShapeBase> Elements { get; set; }
+        public PPTContainerShape()
+        {
+        }
+
+    }
+}

+ 76 - 0
TEAMModelOS.Test.PPTX/PPTLibrary/Dom/PPTGraphicFrame.cs

@@ -0,0 +1,76 @@
+using DocumentFormat.OpenXml.Packaging;
+using DocumentFormat.OpenXml.Presentation;
+
+namespace ClearSlideLibrary.Dom
+{
+    public class PPTGraphicFrame : PPTShapeBase
+    {
+        public PPTGraphicFrame(SlidePart slidePart, GraphicFrame gfarame)
+        {
+            SetGraphicFrameVisualProperties(slidePart, gfarame);
+            SetGraphicFrameNonVisualProperties(slidePart,gfarame);
+        }
+
+
+        private void SetGraphicFrameNonVisualProperties(SlidePart slidePart,GraphicFrame gfarame)
+        {
+
+            if (gfarame.NonVisualGraphicFrameProperties.NonVisualDrawingProperties.HyperlinkOnClick != null)
+                foreach (HyperlinkRelationship link in slidePart.HyperlinkRelationships)
+                    if (link.Id.Equals(gfarame.NonVisualGraphicFrameProperties.NonVisualDrawingProperties.HyperlinkOnClick.Id))
+                        ClickLinkUrl = link.Uri.IsAbsoluteUri ? link.Uri.AbsoluteUri : link.Uri.OriginalString;
+
+            if (gfarame.NonVisualGraphicFrameProperties.NonVisualDrawingProperties.HyperlinkOnHover != null)
+                foreach (HyperlinkRelationship link in slidePart.HyperlinkRelationships)
+                    if (link.Id.Equals(gfarame.NonVisualGraphicFrameProperties.NonVisualDrawingProperties.HyperlinkOnHover.Id))
+                        HoverLinkUrl = link.Uri.IsAbsoluteUri ? link.Uri.AbsoluteUri : link.Uri.OriginalString;
+
+            var nonVisualShapeProp = new PPTNonVisualShapeProp
+                                         {
+                                             Id = "s1s" + //HARD CODED: we split it into separate HTML files!
+                                                  gfarame.NonVisualGraphicFrameProperties.NonVisualDrawingProperties.Id,
+                                             Name = gfarame.LocalName,
+                                             Type = "PPTGraphicFrame"
+                                         };
+            base.NonVisualShapeProp = nonVisualShapeProp;
+        }
+
+        private void SetGraphicFrameVisualProperties(SlidePart slidePart,
+                                                     GraphicFrame gfarame)
+        {
+            base.VisualShapeProp = new PPTVisualPPTShapeProp();
+            if (gfarame.Transform != null)
+            {
+                base.VisualShapeProp.Extents = gfarame.Transform.Extents;
+                base.VisualShapeProp.Offset = gfarame.Transform.Offset;
+            }
+            else
+            {
+                //Petco change get properties from layout for GraphicFrame object.
+                DocumentFormat.OpenXml.Presentation.ShapeTree shapeTree =
+                   slidePart.SlideLayoutPart.SlideLayout.CommonSlideData.ShapeTree;
+                DocumentFormat.OpenXml.Presentation.GraphicFrame layoutShape;
+                if (shapeTree != null)
+                {
+                    layoutShape = shapeTree.GetFirstChild<DocumentFormat.OpenXml.Presentation.GraphicFrame>();
+                    if (layoutShape.Transform != null)
+                    {
+                        base.VisualShapeProp.Extents = layoutShape.Transform.Extents;
+                        base.VisualShapeProp.Offset = layoutShape.Transform.Offset;
+                    }
+                }
+            }
+        }
+
+        public void CreateImage(string targetDir)
+        {
+            /*
+            Image image = base.SourceImage;
+            Size size = new Size(base.shPr.PixelWidth, base.shPr.PixelHeight);
+
+            string path = Path.Combine(targetDir, base.nvSpPr.Id + defaultImageType );
+            //image.Save(Path.Combine(path));
+            */
+        }
+    }
+}

+ 68 - 0
TEAMModelOS.Test.PPTX/PPTLibrary/Dom/PPTGroupShape.cs

@@ -0,0 +1,68 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using DocumentFormat.OpenXml.Packaging;
+
+namespace ClearSlideLibrary.Dom
+{
+    public class PPTGroupShape : PPTShapeBase
+    {
+        public PPTGroupShape(SlidePart slidePart, DocumentFormat.OpenXml.Presentation.GroupShape groupShape)
+        {
+            SetGroupShapeVisualProperties(slidePart, groupShape);
+            SetGroupShapeNonVisualProperties(slidePart,groupShape);
+        }
+
+
+        private void SetGroupShapeNonVisualProperties(SlidePart slidePart,DocumentFormat.OpenXml.Presentation.GroupShape groupShape)
+        {
+            if (groupShape.NonVisualGroupShapeProperties.NonVisualDrawingProperties.HyperlinkOnClick != null)
+                foreach (HyperlinkRelationship link in slidePart.HyperlinkRelationships)
+                    if (link.Id.Equals(groupShape.NonVisualGroupShapeProperties.NonVisualDrawingProperties.HyperlinkOnClick.Id))
+                        ClickLinkUrl = link.Uri.IsAbsoluteUri ? link.Uri.AbsoluteUri : link.Uri.OriginalString;
+
+            if (groupShape.NonVisualGroupShapeProperties.NonVisualDrawingProperties.HyperlinkOnHover != null)
+                foreach (HyperlinkRelationship link in slidePart.HyperlinkRelationships)
+                    if (link.Id.Equals(groupShape.NonVisualGroupShapeProperties.NonVisualDrawingProperties.HyperlinkOnHover.Id))
+                        HoverLinkUrl = link.Uri.IsAbsoluteUri ? link.Uri.AbsoluteUri : link.Uri.OriginalString;
+
+            var nonVisualShapeProp = new PPTNonVisualShapeProp
+            {
+                Id = "s1s" +  //HARD CODED: we split it into separate HTML files!
+                groupShape.NonVisualGroupShapeProperties.NonVisualDrawingProperties.Id,
+                Name = groupShape.LocalName,
+                Type = "PPTGroupShape"
+            };
+            base.NonVisualShapeProp = nonVisualShapeProp;
+        }
+
+        private void SetGroupShapeVisualProperties(SlidePart slidePart, DocumentFormat.OpenXml.Presentation.GroupShape groupShape)
+        {
+            base.VisualShapeProp = new PPTVisualPPTShapeProp();
+            if (groupShape.GroupShapeProperties.TransformGroup != null)
+            {
+                base.VisualShapeProp.Extents = groupShape.GroupShapeProperties.TransformGroup.Extents;
+                base.VisualShapeProp.Offset = groupShape.GroupShapeProperties.TransformGroup.Offset;
+            }
+            else
+            {
+                DocumentFormat.OpenXml.Presentation.ShapeTree shapeTree =
+                    slidePart.SlideLayoutPart.SlideLayout.CommonSlideData.ShapeTree;
+                DocumentFormat.OpenXml.Presentation.GroupShape layoutShape;
+                if (shapeTree != null)
+                {
+                    layoutShape = shapeTree.GetFirstChild<DocumentFormat.OpenXml.Presentation.GroupShape>();
+                    if (layoutShape.GroupShapeProperties.TransformGroup != null)
+                    {
+                        base.VisualShapeProp.Extents = layoutShape.GroupShapeProperties.TransformGroup.Extents;
+                        base.VisualShapeProp.Offset = layoutShape.GroupShapeProperties.TransformGroup.Offset;
+                    }
+                }
+            }
+        }
+    }
+
+}
+

+ 104 - 0
TEAMModelOS.Test.PPTX/PPTLibrary/Dom/PPTImage.cs

@@ -0,0 +1,104 @@
+using DocumentFormat.OpenXml.Packaging;
+using DocumentFormat.OpenXml.Presentation;
+using System;
+
+namespace ClearSlideLibrary.Dom
+{
+    public class PPTImage : PPTShapeBase
+    {
+        public PPTImage(SlidePart slidePart, Picture picture)
+        {
+            GetShapeVisualProperties(slidePart, picture);
+            GetShapeNonVisualProperties(slidePart, picture);
+        }
+
+        //Image specific properties
+        public string RelatedImageId { get; set; }
+        public string FileName { get; set; }
+        public string TargetName { get; set; }
+        public string FileExtension { get; set; }
+        public bool HasEffects { get; set; }
+
+        private void GetShapeVisualProperties(SlidePart slidePart, Picture picture)
+        {
+            base.VisualShapeProp = new PPTVisualPPTShapeProp();
+
+            if (picture.ShapeProperties.Transform2D != null)
+            {
+                base.VisualShapeProp.Extents = picture.ShapeProperties.Transform2D.Extents;
+                base.VisualShapeProp.Offset = picture.ShapeProperties.Transform2D.Offset;
+                string rId = picture.BlipFill.Blip.Embed.Value;
+                ImagePart imagePart = (ImagePart)slidePart.GetPartById(rId);
+                FileExtension = imagePart.Uri.OriginalString.Substring(imagePart.Uri.OriginalString.LastIndexOf(".") + 1).ToLower();
+            }
+            else
+            {
+                ShapeTree shapeTree =
+              slidePart.SlideLayoutPart.SlideLayout.CommonSlideData.ShapeTree;
+                if (shapeTree != null)
+                {
+                    var layoutShape = shapeTree.GetFirstChild<Picture>();
+                    if (layoutShape.ShapeProperties.Transform2D != null)
+                    {
+                        VisualShapeProp.Extents = layoutShape.ShapeProperties.Transform2D.Extents;
+                        VisualShapeProp.Offset = layoutShape.ShapeProperties.Transform2D.Offset;
+                    }
+                }
+                //base.SetSlideLayoutVisualShapeProperties(slidePart,picture);
+            }
+            DocumentFormat.OpenXml.Drawing.EffectList effectList = picture.ShapeProperties.GetFirstChild<DocumentFormat.OpenXml.Drawing.EffectList>();
+            if (effectList != null)
+            {
+                recalculatePropertiesWithEffect(effectList);
+            }
+        }
+
+        private void recalculatePropertiesWithEffect(DocumentFormat.OpenXml.Drawing.EffectList effectList)
+        {
+            if (effectList.Reflection != null)
+            {
+                //Reflection doubles the image size - check for other animations!
+                if (effectList.Reflection.HorizontalRatio != null)
+                {
+                    VisualShapeProp.Extents.Cx *= 2;
+                }
+
+                if (effectList.Reflection.VerticalRatio != null)
+                {
+                    VisualShapeProp.Extents.Cy *= 2;
+                }
+
+            }
+
+        }
+
+        private void GetShapeNonVisualProperties(SlidePart slidePart, Picture shape)
+        {
+
+            if (shape.NonVisualPictureProperties.NonVisualDrawingProperties.HyperlinkOnClick != null)
+                foreach (HyperlinkRelationship link in slidePart.HyperlinkRelationships)
+                {
+                    if (link.Id.Equals(shape.NonVisualPictureProperties.NonVisualDrawingProperties.HyperlinkOnClick.Id))
+                    {
+                        ClickLinkUrl = link.Uri.IsAbsoluteUri ? link.Uri.AbsoluteUri : link.Uri.OriginalString;
+                    }
+                }
+            if (shape.NonVisualPictureProperties.NonVisualDrawingProperties.HyperlinkOnHover != null)
+                foreach (HyperlinkRelationship link in slidePart.HyperlinkRelationships)
+                {
+                    if (link.Id.Equals(shape.NonVisualPictureProperties.NonVisualDrawingProperties.HyperlinkOnHover.Id))
+                    {
+                        HoverLinkUrl = link.Uri.IsAbsoluteUri ? link.Uri.AbsoluteUri : link.Uri.OriginalString;
+                    }
+                }
+            var nonVisualShapeProp = new PPTNonVisualShapeProp
+                                         {
+                                             Id = "s1s" + //HARD CODED: we split it into separate HTML files!
+                                                  shape.NonVisualPictureProperties.NonVisualDrawingProperties.Id,
+                                             Name = shape.LocalName,
+                                             Type = "PPTImage"
+                                         };
+            base.NonVisualShapeProp = nonVisualShapeProp;
+        }
+    }
+}

+ 6 - 0
TEAMModelOS.Test.PPTX/PPTLibrary/Dom/PPTLayout.cs

@@ -0,0 +1,6 @@
+namespace ClearSlideLibrary.Dom
+{
+    public class PPTLayout : PPTShapeBase
+    {
+    }
+}

+ 9 - 0
TEAMModelOS.Test.PPTX/PPTLibrary/Dom/PPTNonVisualShapeProp.cs

@@ -0,0 +1,9 @@
+namespace ClearSlideLibrary.Dom
+{
+    public class PPTNonVisualShapeProp
+    {
+        public string Name { get; set; }
+        public string Id { get; set; }
+        public string Type { get; set; }
+    }
+}

+ 194 - 0
TEAMModelOS.Test.PPTX/PPTLibrary/Dom/PPTShape.cs

@@ -0,0 +1,194 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using DocumentFormat.OpenXml.Drawing;
+using DocumentFormat.OpenXml.Packaging;
+using DocumentFormat.OpenXml.Presentation;
+using ClearSlideLibrary.Dom.PPTTexts;
+using Shape = DocumentFormat.OpenXml.Presentation.Shape;
+using TextBody = DocumentFormat.OpenXml.Presentation.TextBody;
+using DocumentFormat.OpenXml;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Drawing.Imaging;
+using System.IO;
+
+namespace ClearSlideLibrary.Dom
+{
+    public class PPTShape : PPTShapeBase
+    {
+        // contains values of type: slideIndex_shapeId
+        public static LinkedList<string> effectShapes = new LinkedList<string>();
+        private const double RotationIndex = 60000;
+        private const string PictureBulletDirName = "PictureBullet";
+
+        public Boolean IsText { get; set; }
+        public PPTSlide slide { get; set; }
+        private PlaceholderShape placeholder;
+
+        // Create a new linked list of strings.
+        public LinkedList<PPTParagraph> Texts = new LinkedList<PPTParagraph>();
+
+        public PPTShape(SlidePart slidePart, Shape shape, PPTSlide slide): base()
+        {
+            this.slide = slide;
+
+            SetShapeVisualProperties(slidePart, shape);
+            SetShapeNonVisualProperties(slidePart, shape);
+            SetSpecificProperties(slidePart, shape);
+
+        }
+
+
+        private void SetShapeNonVisualProperties(SlidePart slidePart, Shape shape)
+        {
+
+            if (shape.NonVisualShapeProperties.NonVisualDrawingProperties.HyperlinkOnClick != null)
+
+                foreach (HyperlinkRelationship link in slidePart.HyperlinkRelationships)
+                {
+                    if (link.Id.Equals(shape.NonVisualShapeProperties.NonVisualDrawingProperties.HyperlinkOnClick.Id))
+                    {
+                        ClickLinkUrl = link.Uri.IsAbsoluteUri ? link.Uri.AbsoluteUri : link.Uri.OriginalString;
+
+                    }
+                }
+            if (shape.NonVisualShapeProperties.NonVisualDrawingProperties.HyperlinkOnHover != null)
+                foreach (HyperlinkRelationship link in slidePart.HyperlinkRelationships)
+                {
+                    if (link.Id.Equals(shape.NonVisualShapeProperties.NonVisualDrawingProperties.HyperlinkOnHover.Id))
+                    {
+                        HoverLinkUrl = link.Uri.IsAbsoluteUri ? link.Uri.AbsoluteUri : link.Uri.OriginalString;
+                    }
+                }
+
+            var nonVisualShapeProp = new PPTNonVisualShapeProp
+                                         {
+                                             Id = "s1s" + //HARD CODED: we split it into separate HTML files!
+                                                  shape.NonVisualShapeProperties.NonVisualDrawingProperties.Id,
+                                             Name = shape.LocalName,
+                                             Type = "PPTShape"
+                                         };
+            base.NonVisualShapeProp = nonVisualShapeProp;
+        }
+
+        private void SetShapeVisualProperties(SlidePart slidePart, Shape shape)
+        {
+
+            if (shape.NonVisualShapeProperties.ApplicationNonVisualDrawingProperties.PlaceholderShape != null)
+            {
+                placeholder = shape.NonVisualShapeProperties.ApplicationNonVisualDrawingProperties.
+                                        PlaceholderShape;
+                if (placeholder.Type == null)
+                    placeholder.Type = PlaceholderValues.Body;
+            }
+
+
+            base.VisualShapeProp = new PPTVisualPPTShapeProp();
+            base.SetSlideLayoutVisualShapeProperties(slidePart, shape);
+            if (shape.ShapeProperties.Transform2D != null)
+            {
+                Int32Value rot = shape.ShapeProperties.Transform2D.Rotation;
+                if (rot != null)
+                {
+                    double degrees = Math.Round(rot / RotationIndex);
+                    if (degrees < 0)
+                    {
+                        degrees = 360 + degrees;
+                    }
+                    base.VisualShapeProp.Rotate = degrees;
+                }
+
+                base.VisualShapeProp.Extents = shape.ShapeProperties.Transform2D.Extents;
+                base.VisualShapeProp.Offset = shape.ShapeProperties.Transform2D.Offset;
+            }
+        }
+
+        private void SetSpecificProperties(SlidePart slidePart, Shape shape)
+        {
+            IsText = true;
+            //Check if this is text
+            if (shape.TextBody == null)
+            {
+                IsText = false;
+                return;
+            }
+
+            if (shape.TextBody.BodyProperties != null)
+            {
+                if (shape.TextBody.BodyProperties.Anchor != null)
+                    VerticalAlign = shape.TextBody.BodyProperties.Anchor;
+                if (shape.TextBody.BodyProperties.GetFirstChild<NormalAutoFit>() != null &&
+                    shape.TextBody.BodyProperties.GetFirstChild<NormalAutoFit>().FontScale != null)
+                    fontScale = shape.TextBody.BodyProperties.GetFirstChild<NormalAutoFit>().FontScale.Value;
+
+            }
+            int index = 0;
+            foreach (var paragraph in shape.TextBody.Descendants<Paragraph>())
+            {
+                var par = new PPTParagraph(slide, placeholder)
+                {
+                    Paragraph = index++
+                };
+
+                if (paragraph.ParagraphProperties != null)
+                {
+                    int level = paragraph.ParagraphProperties.Level == null ?
+                               -1 : paragraph.ParagraphProperties.Level.Value;
+                    par.Level = level;
+                }
+
+                par.SetParagraphProperties(paragraph, slidePart,
+                                           shapeListStyleMaster, shapeListStyleLayout);
+                bool hasText = false;
+                foreach (var obj in paragraph.ChildElements)
+                {
+                    hasText = GetParagraphChildElements(shape, par, hasText, obj);
+                }
+                //This is because when we set paragraph properties we add the bullet to the text runs.
+                //If we don't have text it still outputs the bullet character. 
+                if (par.bullet != null && hasText)
+                {
+                    par.RunPropList.Insert(0, par.bullet);
+                }
+                Texts.AddLast(par);
+            }
+        }
+
+        private bool GetParagraphChildElements(Shape shape, PPTParagraph par, bool hasText, OpenXmlElement obj)
+        {
+            if (obj is Run)
+            {
+                Run run = (Run)obj;
+                hasText = true;
+                PPTRunProperties runProp = new PPTRunProperties(par.defaultRunProperties);
+                runProp.Text = run.Text.Text;
+                runProp.SetRunProperties(run.RunProperties, shape, ref effectShapes);
+                runProp.FontSize = Math.Round(fontScale * runProp.FontSize / Globals.PercentageConstant);
+                par.RunPropList.Add(runProp);
+            }
+
+            else if (obj is Field)
+            {
+                Field run = (Field)obj;
+                hasText = true;
+                PPTRunProperties runProp = new PPTRunProperties(par.defaultRunProperties);
+                runProp.Text = run.Text.Text;
+                runProp.SetRunProperties(run.RunProperties, shape, ref effectShapes);
+                runProp.FontSize = Math.Round(fontScale * runProp.FontSize / Globals.PercentageConstant);
+                par.RunPropList.Add(runProp);
+            }
+
+            else if (obj is Break)
+            {
+                Break aBreak = (Break)obj;
+                PPTRunProperties runProp = new PPTRunProperties(par.defaultRunProperties);
+                runProp.SetRunProperties(aBreak.RunProperties, shape, ref effectShapes);
+                runProp.FontSize = Math.Round(fontScale * runProp.FontSize / Globals.PercentageConstant);
+                runProp.isBreak = true;
+                par.RunPropList.Add(runProp);
+            }
+            return hasText;
+        }
+    }
+}

+ 166 - 0
TEAMModelOS.Test.PPTX/PPTLibrary/Dom/PPTShapeBase.cs

@@ -0,0 +1,166 @@
+using DocumentFormat.OpenXml.Packaging;
+using DocumentFormat.OpenXml.Presentation;
+using DocumentFormat.OpenXml;
+using System.Collections.Generic;
+using System;
+using System.Globalization;
+using System.Linq;
+
+
+namespace ClearSlideLibrary.Dom
+{
+    public class PPTShapeBase
+    {
+        public PPTVisualPPTShapeProp VisualShapeProp { get; set; }
+        public PPTNonVisualShapeProp NonVisualShapeProp { get; set; }
+        public bool Invisible { get; set; }
+        public bool Animatable { get; set; }
+        public String ClickLinkUrl { get; set; }
+        public String HoverLinkUrl { get; set; }
+        public DocumentFormat.OpenXml.Drawing.ListStyle shapeListStyleMaster { get; set; }
+        public DocumentFormat.OpenXml.Drawing.ListStyle shapeListStyleLayout { get; set; }
+        public DocumentFormat.OpenXml.Drawing.TextAnchoringTypeValues VerticalAlign { get; set; }
+        public int fontScale = 100000;
+        public int BottomInset { get; set; }
+        public int TopInset { get; set; }
+        public int LeftInset { get; set; }
+        public int RightInset { get; set; }
+
+        public PPTShapeBase()
+        {
+            //Default values for the inserts are part of the inch. One inch is 72pixels
+            int inchPixel=72; 
+            BottomInset= inchPixel/20;
+            TopInset=inchPixel/20;
+            LeftInset=inchPixel/10;
+            RightInset = inchPixel/10;
+
+        }
+        protected void SetSlideLayoutVisualShapeProperties(SlidePart slidePart, Shape shape)
+        {
+            VisualShapeProp = new PPTVisualPPTShapeProp();
+
+            ShapeTree shapeTree =
+                slidePart.SlideLayoutPart.SlideLayout.CommonSlideData.ShapeTree;
+
+            if (shapeTree != null)
+            {
+              //  var layoutShape = shapeTree.GetFirstChild<Shape>();
+                GetShapesPropFromMasterPartLayout(slidePart, shape, 1);
+                fillPropertiesFromMasterShape(shape, false, false);
+            }
+        }
+
+        private void FillFromInheritedShapes(IEnumerable<Shape> masterShapes, PlaceholderShape placeholderFromShape, bool isLayout){
+
+            if (placeholderFromShape.Index != null && placeholderFromShape.Index.HasValue &&
+                 placeholderFromShape.Type != null && placeholderFromShape.Type.HasValue)
+            {
+                foreach (Shape masterShape in masterShapes)
+                    if (masterShape.NonVisualShapeProperties.ApplicationNonVisualDrawingProperties.PlaceholderShape != null &&
+                        masterShape.NonVisualShapeProperties.ApplicationNonVisualDrawingProperties.PlaceholderShape.Index != null &&
+                           masterShape.NonVisualShapeProperties.ApplicationNonVisualDrawingProperties.PlaceholderShape.Index.HasValue &&
+                            masterShape.NonVisualShapeProperties.ApplicationNonVisualDrawingProperties.PlaceholderShape.Index.Value ==
+                            placeholderFromShape.Index.Value &&
+                        masterShape.NonVisualShapeProperties.ApplicationNonVisualDrawingProperties.PlaceholderShape.Type != null &&
+                            masterShape.NonVisualShapeProperties.ApplicationNonVisualDrawingProperties.PlaceholderShape.Type.HasValue &&
+                             masterShape.NonVisualShapeProperties.ApplicationNonVisualDrawingProperties.PlaceholderShape.Type.Value ==
+                             placeholderFromShape.Type.Value)
+                    {
+                        fillPropertiesFromMasterShape(masterShape, isLayout, true);
+                        return;
+                    }
+            }
+
+
+            
+            if (placeholderFromShape.Index != null && placeholderFromShape.Index.HasValue)
+            {
+
+                foreach (Shape masterShape in masterShapes)
+                    if (masterShape.NonVisualShapeProperties.ApplicationNonVisualDrawingProperties.PlaceholderShape != null &&
+                        masterShape.NonVisualShapeProperties.ApplicationNonVisualDrawingProperties.PlaceholderShape.Index != null &&
+                           masterShape.NonVisualShapeProperties.ApplicationNonVisualDrawingProperties.PlaceholderShape.Index.HasValue &&
+                            masterShape.NonVisualShapeProperties.ApplicationNonVisualDrawingProperties.PlaceholderShape.Index.Value ==
+                            placeholderFromShape.Index.Value)
+                        {
+                            fillPropertiesFromMasterShape(masterShape, isLayout,true);
+                            return;
+                        }
+            }
+
+            if (placeholderFromShape.Type != null && placeholderFromShape.Type.HasValue)
+            {
+               foreach (Shape masterShape in masterShapes)                    
+                    {
+                        if (masterShape.NonVisualShapeProperties.ApplicationNonVisualDrawingProperties.PlaceholderShape != null &&
+                            masterShape.NonVisualShapeProperties.ApplicationNonVisualDrawingProperties.PlaceholderShape.Type != null &&
+                            masterShape.NonVisualShapeProperties.ApplicationNonVisualDrawingProperties.PlaceholderShape.Type.HasValue &&
+                             masterShape.NonVisualShapeProperties.ApplicationNonVisualDrawingProperties.PlaceholderShape.Type.Value ==
+                             placeholderFromShape.Type.Value)
+                          {
+                              fillPropertiesFromMasterShape(masterShape, isLayout, true);
+                              return;
+                          }                          
+                      } 
+             }
+                
+
+            
+        }
+        private void GetShapesPropFromMasterPartLayout(SlidePart slidePart, Shape shape, int slideNumber)
+        {
+
+            if (shape.NonVisualShapeProperties.ApplicationNonVisualDrawingProperties.PlaceholderShape == null) //If there is no placeholder
+                return; 
+            IEnumerator<SlideLayoutPart> slPart = slidePart.SlideLayoutPart.
+                SlideMasterPart.SlideLayoutParts.GetEnumerator();
+
+        
+
+            var masterShapes =slidePart.SlideLayoutPart.SlideMasterPart.SlideMaster.CommonSlideData.ShapeTree.Descendants<Shape>();
+            FillFromInheritedShapes(masterShapes, shape.NonVisualShapeProperties.ApplicationNonVisualDrawingProperties.PlaceholderShape,false);
+            var layoutShapes = slidePart.SlideLayoutPart.SlideLayout.Descendants<Shape>();
+            FillFromInheritedShapes(layoutShapes, shape.NonVisualShapeProperties.ApplicationNonVisualDrawingProperties.PlaceholderShape,true );
+
+        }
+
+        private void fillPropertiesFromMasterShape(DocumentFormat.OpenXml.Presentation.Shape masterShape, bool isLayout, bool addListStyle)
+        {
+            if (null != masterShape.TextBody)
+            {
+                if (masterShape.TextBody.ListStyle != null && addListStyle)
+                {
+                    if(isLayout)
+                        shapeListStyleLayout = masterShape.TextBody.ListStyle;
+                    else
+                        shapeListStyleMaster = masterShape.TextBody.ListStyle;
+                }
+                if (masterShape.TextBody.BodyProperties != null && masterShape.TextBody.BodyProperties.Anchor!=null)
+                    VerticalAlign = masterShape.TextBody.BodyProperties.Anchor;
+                if(masterShape.TextBody.BodyProperties.TopInset != null){
+                    TopInset = (int)Math.Round((double)masterShape.TextBody.BodyProperties.TopInset.Value / 12700);
+                }
+                if(masterShape.TextBody.BodyProperties.BottomInset != null){
+                    BottomInset=(int)Math.Round((double)masterShape.TextBody.BodyProperties.BottomInset.Value / 12700);
+                }
+                if(masterShape.TextBody.BodyProperties.RightInset != null){
+                    RightInset = (int)Math.Round((double)masterShape.TextBody.BodyProperties.RightInset.Value / 12700);
+                }
+                if(masterShape.TextBody.BodyProperties.LeftInset != null){
+                    LeftInset = (int)Math.Round((double)masterShape.TextBody.BodyProperties.LeftInset.Value / 12700);
+                }
+                
+                if (masterShape.TextBody.BodyProperties != null && 
+                    masterShape.TextBody.BodyProperties.GetFirstChild<DocumentFormat.OpenXml.Drawing.NormalAutoFit>() != null &&
+                      masterShape.TextBody.BodyProperties.GetFirstChild<DocumentFormat.OpenXml.Drawing.NormalAutoFit>().FontScale != null)
+                    fontScale = masterShape.TextBody.BodyProperties.GetFirstChild<DocumentFormat.OpenXml.Drawing.NormalAutoFit>().FontScale.Value;
+            }
+            if (masterShape.ShapeProperties.Transform2D != null)
+            {
+                VisualShapeProp.Extents = masterShape.ShapeProperties.Transform2D.Extents;
+                VisualShapeProp.Offset = masterShape.ShapeProperties.Transform2D.Offset;
+            }
+        }
+    }
+}

+ 189 - 0
TEAMModelOS.Test.PPTX/PPTLibrary/Dom/PPTSlide.cs

@@ -0,0 +1,189 @@
+using System;
+using System.Collections.Generic;
+using ClearSlideLibrary.Animations;
+using ClearSlideLibrary.Dom.PPTTexts;
+using ClearSlideLibrary.PPTBuilder;
+using DocumentFormat.OpenXml;
+using DocumentFormat.OpenXml.Packaging;
+using DocumentFormat.OpenXml.Presentation;
+
+namespace ClearSlideLibrary.Dom
+{
+    public class PPTSlide : PPTShapeBase
+    {
+
+        public PPTSlide(SlidePart slidePart, int slideIndex, DefaultTextStyle defaultTextStyle,string fileName, SlideSize SlideSizes)
+        {
+            this.advanceAfterTime = -1;
+            this.slideIndex = slideIndex;
+            this.fileName = fileName;
+            this.defaultTextStyle = defaultTextStyle;
+            SlideLayoutPart = slidePart.SlideLayoutPart;
+            SetShapeNonVisualProperties(slidePart);
+            SetSpecificProperties(slidePart);
+            Id = "s1s0";
+            Transition = JSONGenerator.GenerateTransitionAnimationObject(slidePart.Slide.Transition);
+            Animations = new List<IAnimation>();
+            AddAnimations(slidePart.Slide.Timing, Animations, SlideSizes);
+        }
+
+
+        //Slide specific properties
+        public DefaultTextStyle defaultTextStyle { get; set; }
+        public PPTContainerShape ContainerShape { get; set; }
+        public TextStyles textStyles { get; set; }
+        public SlideLayoutPart SlideLayoutPart { get; set; }
+        public List<IAnimation> Animations { get; set; }
+        public string Id { get; set; }
+        public IAnimation Transition { get; set; }
+        public int slideIndex;
+        public string fileName;
+        public int advanceAfterTime { get; set; }
+        
+        //Petco:Check if there is objects with animation.
+        public void CheckAndSetAnimatableProperty(string animObjectId)
+        {
+            int tryParse = 0;
+            if (int.TryParse(animObjectId, out tryParse))
+            {
+
+                foreach (PPTShapeBase shape in ContainerShape.Elements)
+                    SetAnimatable(animObjectId, shape);
+            }
+            else
+            {
+                foreach (PPTShapeBase shapeBase in ContainerShape.Elements)
+                    if (typeof(PPTShape).Equals(shapeBase.GetType()) && ((PPTShape)shapeBase).IsText)
+                        foreach (PPTParagraph text in ((PPTShape)shapeBase).Texts)
+                        {
+                            if ((shapeBase.NonVisualShapeProp.Id + "p" + text.Paragraph).Equals("s1s" + animObjectId))
+                            {
+                                text.Animatable = true;
+                            }
+                        }
+            }
+        }
+
+        private static void SetAnimatable(string animObjectId, PPTShapeBase bshape)
+        {
+            string shapeId = bshape.NonVisualShapeProp.Id;
+            string shapeObjectId = "s1s" + animObjectId;
+            if (shapeId.Equals(shapeObjectId))
+            {
+                bshape.Animatable = true;
+            }
+        }
+
+        public void MakeShapeInvisible(String shapeId)
+        {
+            foreach (PPTShapeBase shape in ContainerShape.Elements)
+                if (shape.NonVisualShapeProp.Id.Equals(shapeId))
+                {
+                    shape.Invisible = true;
+                    return;
+                }
+                else if (typeof(PPTShape).Equals(shape.GetType()) && ((PPTShape)shape).IsText)
+                {
+                    foreach (PPTParagraph text in ((PPTShape)shape).Texts)
+                        if ((shape.NonVisualShapeProp.Id + "p" + text.Paragraph).Equals(shapeId))
+                        {
+                            text.Invisible = true;
+                            return;
+                        }
+                }
+              
+        }
+
+        public void AddAnimations(OpenXmlCompositeElement element, List<IAnimation> resultList, SlideSize SlideSizes)
+        {
+            if (element==null)
+                return;
+
+            List<AnimateMotion> motions = new List<AnimateMotion>();
+            IAnimation animationForThisNode = null;
+            if (element.GetType().Equals(typeof(CommonTimeNode)))
+            {
+                CommonTimeNode node = (CommonTimeNode)element;
+                animationForThisNode = new JSONGenerator(this).getSimpleAnimationFromCommonTimeNodePreset(node, SlideSizes);
+
+                if (animationForThisNode != null)
+                {
+                    resultList.Add(animationForThisNode);
+                    //Check if object id is presented in animation list.
+                    CheckAndSetAnimatableProperty(animationForThisNode.ObjectId);
+
+                    if ((animationForThisNode.InnerAnimations == null ||
+                         animationForThisNode.InnerAnimations.Count == 0) &&
+                        animationForThisNode.IsItEntranceAnimation())
+
+                        MakeShapeInvisible("s1s" + animationForThisNode.ObjectId);
+                    else if (animationForThisNode.InnerAnimations != null)
+                        foreach (IAnimation anAnimation in animationForThisNode.InnerAnimations)
+                            if (anAnimation.IsItEntranceAnimation())
+                                MakeShapeInvisible("s1s" + animationForThisNode.ObjectId);
+                    return;
+                }
+                else
+                {
+                    /*
+                     * Sometimes there are common time nodes without animations in them. They are used for grouping animations.                      
+                     * Usually animations are grouped for timing purposes like adding delay to all, or start a group after another. 
+                     * It's a tree structure and here we try to follow it as much as possible. Later we will strip the unnecessary nodes 
+                     */
+
+                    animationForThisNode = new SimpleAnimation();
+                    if (node.NodeType != null)
+                        ((SimpleAnimation)animationForThisNode).timingType = node.NodeType;
+                    int delay = 0;
+                    if (node.StartConditionList != null)
+                        foreach (Condition cond in node.StartConditionList)
+                            if (cond.Delay != null && "indefinite" != cond.Delay.Value && cond.Delay.HasValue)
+                                delay = delay + int.Parse(cond.Delay.Value);
+                    if (delay > 0)
+                    {
+                        animationForThisNode.Start = delay;
+                    }
+                }
+
+                if (animationForThisNode != null)
+                {
+                    animationForThisNode.InnerAnimations = new List<IAnimation>();
+                    resultList.Add(animationForThisNode);
+                }
+
+            }
+
+            //Go recursive in the Open XML tree
+
+            foreach (OpenXmlElement obj in element.ChildElements)
+            {
+                if (obj.GetType().IsSubclassOf(typeof(OpenXmlCompositeElement)))
+                {
+                    if (animationForThisNode == null)
+                        AddAnimations((OpenXmlCompositeElement)obj, resultList, SlideSizes);
+                    else
+                        AddAnimations((OpenXmlCompositeElement)obj, animationForThisNode.InnerAnimations, SlideSizes);
+                }
+            }
+        }
+
+        private void SetSpecificProperties(SlidePart slidePart)
+        {
+            textStyles = slidePart.SlideLayoutPart.SlideMasterPart.SlideMaster.TextStyles;
+            var groupShapeBuilder = new PPTContainerShapeBuilder();
+            ContainerShape = groupShapeBuilder.GetPPTContainerShape(slidePart, this);
+           
+        }
+
+        private void SetShapeNonVisualProperties(SlidePart slidePart)
+        {
+            var nonVisualShapeProp = new PPTNonVisualShapeProp
+            {
+                Id = "s1s1",
+                Name = slidePart.Slide.LocalName,
+                Type = "PPTSlide"
+            };
+            base.NonVisualShapeProp = nonVisualShapeProp;
+        }
+    }
+}

+ 410 - 0
TEAMModelOS.Test.PPTX/PPTLibrary/Dom/PPTTexts/PPTParagraph.cs

@@ -0,0 +1,410 @@
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using DocumentFormat.OpenXml;
+using DocumentFormat.OpenXml.Drawing;
+using DocumentFormat.OpenXml.Packaging;
+using DocumentFormat.OpenXml.Presentation;
+
+namespace ClearSlideLibrary.Dom.PPTTexts
+{
+    public class PPTParagraph
+    {
+
+        public List<PPTRunProperties> RunPropList { get; set; }
+        public string Align { get; set; }//ctr, l, r, just, dist, thai, justLow
+        public string FontAlign { get; set; }//auto, b, base, ctr, t
+        public Int32 Indent { get; set; }
+        public Int32 Level { get; set; }
+        public Int32 marginLeft { get; set; }
+        public Int32 marginRight { get; set; }
+        public Int32 defTabSize { get; set; }
+        public bool Invisible { get; set; }
+        public bool Animatable { get; set; }
+        public int Paragraph { get; set; }
+        public PPTRunProperties bullet = null;
+        public PPTRunProperties defaultRunProperties { get; set; }
+        public DocumentFormat.OpenXml.Drawing.SpaceAfter spaceAfter { get; set; }
+        public DocumentFormat.OpenXml.Drawing.SpaceBefore spaceBefore { get; set; }
+        public DocumentFormat.OpenXml.Drawing.LineSpacing lineSpacing { get; set; }
+        public PPTSlide slide { get; set; }
+        private PlaceholderShape placeholder;
+
+        public PPTParagraph(PPTSlide slide, PlaceholderShape placeholder)
+        {
+            this.slide = slide;
+            this.Align = "";
+            this.FontAlign = "";
+            this.Indent = 0;
+            this.Level = 0;
+            this.marginLeft = 0;
+            this.marginRight = 0;
+            this.placeholder = placeholder;
+            this.defTabSize = 0;
+            RunPropList = new List<PPTRunProperties>();
+        }
+
+
+        public int getLineSpacingInPointsFromFont(int fontHeight)
+        {
+            if (lineSpacing == null)
+                return fontHeight;
+            if (lineSpacing.SpacingPoints != null)
+                return lineSpacing.SpacingPoints.Val;
+            if (lineSpacing.SpacingPercent != null)
+                return lineSpacing.SpacingPercent.Val * fontHeight / Globals.PercentageConstant;
+            return fontHeight;
+        }
+        public int getSpaceBeforePoints()
+        {
+            return getSpacingInPoints(spaceBefore, 0);
+        }
+        public int getSpaceBeforePoints(int height)
+        {
+            return getSpacingInPoints(spaceBefore, height);
+        }
+
+        public int getSpaceAfterPoints()
+        {
+            return getSpacingInPoints(spaceAfter, 0);
+        }
+        public int getSpaceAfterPoints(int height)
+        {
+            return getSpacingInPoints(spaceAfter, height);
+        }
+
+        private int getSpacingInPoints(DocumentFormat.OpenXml.Drawing.TextSpacingType spacing, int height)
+        {
+            if (spacing == null)
+                return 0;
+            if (spacing.SpacingPoints != null)
+                return spacing.SpacingPoints.Val / Globals.FontPoint;
+            if (spacing.SpacingPercent.Val != null && height != 0)
+                return spacing.SpacingPercent.Val * height / Globals.PercentageConstant;
+            return 0;
+        }
+
+        public void SetParagraphProperties(Paragraph paragraph, SlidePart slidePart,
+                        DocumentFormat.OpenXml.Drawing.ListStyle shapeListStyleMaster,
+                        DocumentFormat.OpenXml.Drawing.ListStyle shapeListStyleLayout)
+        {
+
+            TextListStyleType listStyleType = this.slide.defaultTextStyle;
+            if (slide.textStyles != null)
+            {
+                if (placeholder != null)
+                    if (placeholder.Type.Value.Equals(PlaceholderValues.Body)
+                        || placeholder.Type.Value.Equals(PlaceholderValues.SubTitle))
+                    {
+                        listStyleType = slide.textStyles.BodyStyle;
+                    }
+                    else if (placeholder.Type.Value.Equals(PlaceholderValues.Title)
+                            || placeholder.Type.Value.Equals(PlaceholderValues.CenteredTitle))
+                    {
+                        listStyleType = slide.textStyles.TitleStyle;
+                    }
+                    else
+                        listStyleType = slide.textStyles.OtherStyle;
+                //Check what should we add here for all placeholder values. 
+                //Should we take it by placeholder value or there is another property?
+            }
+            TextParagraphPropertiesType baseProperties = getParagraphPropFromTextListStyle(listStyleType, Level);
+            TextParagraphPropertiesType basePropertiesMaster = getParagraphPropFromTextListStyle(shapeListStyleMaster, Level);
+            TextParagraphPropertiesType basePropertiesLayout = getParagraphPropFromTextListStyle(shapeListStyleLayout, Level);
+
+            defaultRunProperties = new PPTRunProperties(slide);
+
+
+            if (baseProperties != null)
+            {
+                this.FillParagraphProperties(baseProperties, slidePart);
+            }
+            if (basePropertiesMaster != null)
+            {
+                this.FillParagraphProperties(basePropertiesMaster, slidePart);
+            }
+            if (basePropertiesLayout != null)
+            {
+                this.FillParagraphProperties(basePropertiesLayout, slidePart);
+            }
+            if (paragraph.ParagraphProperties != null)
+            {
+                this.FillParagraphProperties(paragraph.ParagraphProperties, slidePart);
+            }
+        }
+
+        private TextParagraphPropertiesType getParagraphPropFromTextListStyle(OpenXmlCompositeElement listStyleType, int level)
+        {
+            if (listStyleType != null)
+            {
+                if (listStyleType is TextListStyleType)
+                {
+                    TextListStyleType parPropType = (TextListStyleType)listStyleType;
+                    switch (level)
+                    {
+                        case 0: return parPropType.Level1ParagraphProperties;
+                        case 1: return parPropType.Level2ParagraphProperties;
+                        case 2: return parPropType.Level3ParagraphProperties;
+                        case 3: return parPropType.Level4ParagraphProperties;
+                        case 4: return parPropType.Level5ParagraphProperties;
+                        case 5: return parPropType.Level6ParagraphProperties;
+                        case 6: return parPropType.Level7ParagraphProperties;
+                        case 7: return parPropType.Level8ParagraphProperties;
+                        case 8: return parPropType.Level9ParagraphProperties;
+                        default: return parPropType.Level1ParagraphProperties;
+                    }
+                }
+                else if (listStyleType is ListStyle)
+                {
+                    ListStyle parPropType = (ListStyle)listStyleType;
+                    switch (level)
+                    {
+                        case 0: return parPropType.Level1ParagraphProperties;
+                        case 1: return parPropType.Level2ParagraphProperties;
+                        case 2: return parPropType.Level3ParagraphProperties;
+                        case 3: return parPropType.Level4ParagraphProperties;
+                        case 4: return parPropType.Level5ParagraphProperties;
+                        case 5: return parPropType.Level6ParagraphProperties;
+                        case 6: return parPropType.Level7ParagraphProperties;
+                        case 7: return parPropType.Level8ParagraphProperties;
+                        case 8: return parPropType.Level9ParagraphProperties;
+                        default: return parPropType.Level1ParagraphProperties;
+                    }
+                }
+            }
+            return null;
+        }
+
+
+        private void FillParagraphProperties(TextParagraphPropertiesType baseProperties, SlidePart slidePart)
+        {
+            if (baseProperties.LineSpacing != null)
+            {
+                lineSpacing = baseProperties.LineSpacing;
+            }
+            if (baseProperties.SpaceAfter != null)
+            {
+                spaceAfter = baseProperties.SpaceAfter;
+            }
+            if (baseProperties.SpaceBefore != null)
+            {
+                spaceBefore = baseProperties.SpaceBefore;
+            }
+            if (baseProperties.Alignment != null)
+            {
+                Align = baseProperties.Alignment.Value.ToString();
+            }
+            if (baseProperties.FontAlignment != null)
+            {
+                FontAlign = baseProperties.FontAlignment.Value.ToString();
+            }
+
+            if (baseProperties.LeftMargin != null)
+            {
+                marginLeft = baseProperties.LeftMargin.Value / Globals.LEAST_COMMON_MULTIPLE_100_254;
+            }
+            if (baseProperties.RightMargin != null)
+            {
+                marginRight = baseProperties.RightMargin.Value / Globals.LEAST_COMMON_MULTIPLE_100_254;
+            }
+
+            if (baseProperties.Indent != null)
+            {
+                Indent = baseProperties.Indent.Value / Globals.LEAST_COMMON_MULTIPLE_100_254;
+            }
+
+            defaultRunProperties.ReadDefaultRunProperties(baseProperties);
+            this.ReadBullets(baseProperties, slidePart);
+
+            if (baseProperties.GetFirstChild<NoBullet>() != null)
+            {
+                bullet = null;
+            }
+
+        }
+
+        private void ReadBullets(TextParagraphPropertiesType baseProperties, SlidePart slidePart)
+        {
+            var bulletProp = new PPTRunProperties(slide);
+            bulletProp.isBullet = true;
+
+            if (baseProperties != null)
+            {
+                if (baseProperties.GetFirstChild<CharacterBullet>() != null)
+                {
+                    this.ReadCharacterBullets(baseProperties, bulletProp);
+                }
+                else if (baseProperties.GetFirstChild<PictureBullet>() != null)
+                {
+                    this.ReadPictureBullets(baseProperties, bulletProp, slidePart);
+                }
+            }
+        }
+
+        private void ReadPictureBullets(TextParagraphPropertiesType baseProperties, PPTRunProperties bulletProp, SlidePart slidePart)
+        {
+            this.SetBulletProperties(baseProperties, bulletProp);
+            var picBul = baseProperties.GetFirstChild<PictureBullet>();
+            if (picBul != null)
+            {
+                string embed = picBul.Blip.Embed.Value;
+
+                string projectDir = System.IO.Path.GetDirectoryName(
+                                    System.IO.Path.GetDirectoryName(Environment.CurrentDirectory));
+                string storageDir = System.IO.Path.Combine(projectDir, Globals.STORAGE_DIR);
+                string path = "";
+                if (slide.slideIndex >= 1)
+                {
+                    path = slide.fileName+"_"+ slide.slideIndex;
+                }
+                else
+                {
+                    path = slide.fileName;
+                }
+                string pictureBulletDir = System.IO.Path.Combine(storageDir, path);
+                bulletProp.Text = path + "\\" + embed + ".png";
+                try
+                {
+                    bulletProp.bulletSize = this.ExtractPictureBulletImage(bulletProp, embed, pictureBulletDir, slidePart);
+                }
+                catch (IOException iex)
+                {
+                    Console.WriteLine(iex.Message);
+                }
+            }
+        }
+
+        private void ReadCharacterBullets(TextParagraphPropertiesType baseProperties, PPTRunProperties bulletProp)
+        {
+            bulletProp.Text = "" + baseProperties.GetFirstChild<CharacterBullet>().Char;
+            this.SetBulletProperties(baseProperties, bulletProp);
+        }
+
+        private void SetBulletProperties(TextParagraphPropertiesType baseProperties, PPTRunProperties bulletProp)
+        {
+            this.ReadBulletFont(baseProperties, bulletProp);
+            this.ReadBulletColor(baseProperties, bulletProp);
+            this.ReadBulletSizePercentage(baseProperties, bulletProp);
+            bulletProp.Left = marginLeft;
+            bullet = bulletProp;
+
+        }
+
+        private void ReadBulletColor(TextParagraphPropertiesType baseProperties, PPTRunProperties bulletProp)
+        {
+            BulletColor buCol = baseProperties.GetFirstChild<BulletColor>();
+            if (buCol != null)
+            {
+                if (buCol.RgbColorModelHex != null)
+                {
+                    bulletProp.FontColor = "#" + buCol.RgbColorModelHex.Val.Value;
+                }
+                else
+                {
+                    if (buCol.GetFirstChild<SchemeColor>() != null)
+                    {
+                        bulletProp.ReadThemeSchemeColor(buCol.GetFirstChild<SchemeColor>());
+                    }
+                }
+            }
+        }
+
+        private void ReadBulletFont(TextParagraphPropertiesType baseProperties, PPTRunProperties bulletProp)
+        {
+            BulletFont font = baseProperties.GetFirstChild<BulletFont>();
+            if (font != null)
+            {
+                if (font.Typeface != null)
+                    bulletProp.FontFamily = font.Typeface;
+                if (font.PitchFamily != null)
+                {
+                    bulletProp.FontSize = font.PitchFamily;
+                }
+                else
+                {
+                    var latinFonts = font.GetFirstChild<LatinFont>();
+                    if (latinFonts != null)
+                    {
+                        bulletProp.ReadFontFamilyFromTheme(latinFonts);
+                    }
+                }
+            }
+            else
+            {
+                bulletProp.FontSize = defaultRunProperties.FontSize;
+            }
+        }
+
+        private void ReadBulletSizePercentage(TextParagraphPropertiesType baseProperties, PPTRunProperties bulletProp)
+        {
+            if (baseProperties.GetFirstChild<BulletSizePercentage>() != null)
+            {
+                BulletSizePercentage pct = baseProperties.GetFirstChild<BulletSizePercentage>();
+                if (bulletProp.bulletSize != 0)
+                {
+                    bulletProp.bulletSize = bulletProp.bulletSize * pct.Val / Globals.PercentageConstant;
+                }
+                else
+                {
+                    bulletProp.bulletSize = ClearSlideLibrary.HtmlController.HtmlText.DefaultBulletSize;
+                    bulletProp.bulletSize = bulletProp.bulletSize * pct.Val / Globals.PercentageConstant;
+                }
+            }
+        }
+
+        private int ExtractPictureBulletImage(PPTRunProperties bulletProp, string embed,
+                                              string realDir, SlidePart slidePart)
+        {
+            int imageSize = 0;
+            try
+            {
+                OpenXmlPart masterPart = slide.SlideLayoutPart.SlideMasterPart.GetPartById(embed);
+                if (masterPart != null)
+                {
+                    if (masterPart.ContentType.Equals("image/png"))
+                    {
+                        imageSize = CreateImage(bulletProp, embed, realDir, imageSize, masterPart);
+                    }
+                    else
+                    {
+                        OpenXmlPart sldPart = slidePart.GetPartById(embed);
+                        if (sldPart != null)
+                        {
+                            if (sldPart.ContentType.Equals("image/png"))
+                            {
+                                imageSize = CreateImage(bulletProp, embed, realDir, imageSize, sldPart);
+                            }
+                        }
+                    }
+                }
+            }
+            catch (ArgumentOutOfRangeException aoex)
+            {
+                Console.WriteLine(aoex.Message);
+            }
+            catch (ArgumentException aex)
+            {
+                Console.WriteLine(aex.Message);
+            }
+            return imageSize;
+        }
+
+        private int CreateImage(PPTRunProperties bulletProp, string embed, string realDir, int imageSize, OpenXmlPart sldPart)
+        {
+
+            if (!System.IO.Directory.Exists(realDir))
+                System.IO.Directory.CreateDirectory(realDir);
+
+            Image image = Image.FromStream(sldPart.GetStream());
+            Image scaledImage = Globals.ScaleByPercent(image, (int)bulletProp.FontSize);
+            imageSize = scaledImage.Height;
+            string imageName = System.IO.Path.Combine(realDir, embed + ".png");
+            scaledImage.Save(imageName);
+            return imageSize;
+        }
+    }
+}

+ 358 - 0
TEAMModelOS.Test.PPTX/PPTLibrary/Dom/PPTTexts/PPTRunProperties.cs

@@ -0,0 +1,358 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using DocumentFormat.OpenXml;
+using DocumentFormat.OpenXml.Drawing;
+using DocumentFormat.OpenXml.Packaging;
+using DocumentFormat.OpenXml.Presentation;
+
+
+namespace ClearSlideLibrary.Dom.PPTTexts
+{
+
+    public class PPTRunProperties
+    {
+        public double FontSize { get; set; }
+        public int Top { get; set; }
+        public int Left { get; set; }
+        public int Spacing { get; set; }
+        public string FontFamily { get; set; }
+        public string FontColor { get; set; }
+        public string Text { get; set; }
+        public bool Bold { get; set; }
+        public bool Italic { get; set; }
+        public string Underline { get; set; }
+        public bool Invisible { get; set; }
+        public bool Animatable { get; set; }
+        public bool isBreak { get; set; }
+        public bool isBullet { get; set; }
+        public int bulletSize { get; set; }
+        public PPTSlide slide { get; set; }
+
+        public PPTRunProperties(PPTSlide slide)
+        {
+            //Default Fonts
+            this.slide = slide;
+            this.FontFamily = "Calibri";
+            this.FontSize = 32;
+            this.Bold = false;
+            this.Italic = false;
+            this.FontColor = "#000000";
+            this.Top = 0;
+            this.Left = 0;
+        }
+
+        public PPTRunProperties(PPTRunProperties copy)
+        {
+            this.FontColor = copy.FontColor;
+            this.FontFamily = copy.FontFamily;
+            this.FontSize = copy.FontSize;
+            this.Top = copy.Top;
+            this.Left = copy.Left;
+            this.Italic = copy.Italic;
+            this.Bold = copy.Bold;
+            this.Invisible = copy.Invisible;
+            this.isBreak = copy.isBreak;
+            this.Animatable = copy.Animatable;
+            this.Spacing = copy.Spacing;
+            this.Text = copy.Text;
+            this.slide = copy.slide;
+        }
+
+        public void SetRunProperties(RunProperties runProperties, 
+                     DocumentFormat.OpenXml.Presentation.Shape shape,
+                     ref LinkedList<string> effectShapes)
+        {
+            if (runProperties != null)
+            {
+                EffectList effects = runProperties.GetFirstChild<EffectList>();
+                GradientFill gradient = runProperties.GetFirstChild<GradientFill>();
+
+                if ((shape.TextBody.BodyProperties != null && shape.TextBody.BodyProperties.FromWordArt!=null && shape.TextBody.BodyProperties.FromWordArt) ||     
+                    (effects != null && effects.HasChildren)||
+                    (gradient != null && gradient.HasChildren))
+                {
+                    UInt32Value id = shape.NonVisualShapeProperties.NonVisualDrawingProperties.Id;
+                    effectShapes.AddLast(slide.slideIndex + "_" + id.Value);
+                }
+
+
+                //get the text color.
+                var solidFill = runProperties.GetFirstChild<SolidFill>();
+                if (solidFill != null)
+                {
+                    this.ReadSolidFillColors(solidFill);
+                }
+                if (runProperties.FontSize != null)
+                {
+                    FontSize = runProperties.FontSize / Globals.FontPoint;
+                }
+                if (runProperties.Bold != null)
+                {
+                    Bold = runProperties.Bold;
+                }
+
+                if (runProperties.Italic != null)
+                {
+                    Italic = runProperties.Italic;
+                }
+                if (runProperties.Underline != null)
+                {
+                    Underline = runProperties.Underline.Value.ToString();
+                }
+                if (runProperties.Spacing != null)
+                {
+                    Spacing = runProperties.Spacing.Value;
+                }
+
+                var latinFonts = runProperties.GetFirstChild<LatinFont>();
+                var coplexScriptFonts = runProperties.Descendants<ComplexScriptFont>();
+
+                if (latinFonts != null)
+                {
+                    this.ReadFontFamilyFromTheme(latinFonts);
+                }
+                else if (coplexScriptFonts.GetEnumerator().Current != null)
+                {
+                   FontFamily = coplexScriptFonts.GetEnumerator().Current.Typeface;
+                }
+            }
+        }
+
+        public void ReadDefaultRunProperties(TextParagraphPropertiesType baseProperties)
+        {
+            var defRun = baseProperties.GetFirstChild<DefaultRunProperties>();
+            if (defRun != null)
+            {
+                if (defRun.FontSize != null)
+                {
+                    FontSize = defRun.FontSize / Globals.FontPoint;
+                    //Console.WriteLine("The def font size is:" + fontProp.FontSize);
+                }
+                if (defRun.Bold != null)
+                {
+                    if (!Bold)
+                    {
+                        Bold = defRun.Bold;
+                    }
+                }
+                if (defRun.Italic != null)
+                {
+                    if (!Italic)
+                    {
+                        Italic = defRun.Italic;
+                    }
+                }
+                if (defRun.Spacing != null)
+                {
+                    Spacing = defRun.Spacing;
+                }
+                var solidFill = defRun.GetFirstChild<SolidFill>();
+
+                if (solidFill != null)
+                {
+                    this.ReadSolidFillColors(solidFill);
+                }
+                var latinFonts = defRun.GetFirstChild<LatinFont>();
+                this.ReadFontFamilyFromTheme(latinFonts);
+            }
+        }
+
+        private void ReadSolidFillColors(SolidFill solidFill)
+        {
+            if (solidFill.RgbColorModelHex != null)
+            {
+                FontColor = "#" + solidFill.RgbColorModelHex.Val;
+            }
+            else if (solidFill.RgbColorModelPercentage != null)
+            {
+                int red = solidFill.RgbColorModelPercentage.RedPortion.Value;
+                int green = solidFill.RgbColorModelPercentage.GreenPortion.Value;
+                int blue = solidFill.RgbColorModelPercentage.BluePortion.Value;
+
+                var colorFromRGB = System.Drawing.Color.FromArgb(red, green, blue);
+                string fontcolor = System.Drawing.ColorTranslator.ToHtml(colorFromRGB);
+                FontColor = fontcolor;
+            }
+            else if (solidFill.SystemColor != null)
+            {
+                FontColor = "#" + solidFill.SystemColor.LastColor.Value;
+            }
+            if (solidFill.SchemeColor != null)
+            {
+                this.ReadThemeSchemeColor(solidFill.SchemeColor);
+            }
+        }
+
+        public void ReadFontFamilyFromTheme(LatinFont latinFonts)
+        {
+            FontScheme allSchemeFonts =
+                    slide.SlideLayoutPart.SlideMasterPart.ThemePart.Theme
+                    .ThemeElements.FontScheme;
+
+            var minorFont = allSchemeFonts.GetFirstChild<MinorFont>();
+            var majorFont = allSchemeFonts.GetFirstChild<MajorFont>();
+            if (latinFonts != null)
+            {
+                FontFamily = latinFonts.Typeface.Value;
+
+                if (latinFonts.Typeface.Value.Equals("+mj-lt"))
+                {
+                    FontFamily = majorFont.LatinFont.Typeface.Value;
+                }
+                else if (latinFonts.Typeface.Value.Equals("+mj-cs"))
+                {
+                    FontFamily = majorFont.ComplexScriptFont.Typeface.Value;
+                }
+                else if (latinFonts.Typeface.Value.Equals("+mj-ea"))
+                {
+                    FontFamily = majorFont.EastAsianFont.Typeface.Value;
+                }
+                else if (latinFonts.Typeface.Value.Equals("+mn-lt"))
+                {
+                    FontFamily = minorFont.LatinFont.Typeface.Value;
+                }
+                else if (latinFonts.Typeface.Value.Equals("+mn-cs"))
+                {
+                    FontFamily = minorFont.ComplexScriptFont.Typeface.Value;
+                }
+                else if (latinFonts.Typeface.Value.Equals("+mn-ea"))
+                {
+                    FontFamily = minorFont.EastAsianFont.Typeface.Value;
+                }
+            }
+        }
+        public void ReadThemeSchemeColor(SchemeColor schemeColor)
+        {
+            if (schemeColor.Val == "bg1")
+            {
+                Light1Color light1Color = slide.SlideLayoutPart.SlideMasterPart.
+                    ThemePart.Theme.ThemeElements.ColorScheme.Light1Color;
+                if (light1Color.RgbColorModelHex != null)
+                {
+                    FontColor = "#" + light1Color.RgbColorModelHex.Val.Value;
+                }
+                else if (light1Color.SystemColor != null)
+                {
+                    FontColor = "#" + light1Color.SystemColor.LastColor.Value;
+                }
+            }
+            else if (schemeColor.Val == "bg2")
+            {
+                Light2Color light2Color = slide.SlideLayoutPart.SlideMasterPart.
+                    ThemePart.Theme.ThemeElements.ColorScheme.Light2Color;
+                if (light2Color.RgbColorModelHex != null)
+                {
+                    FontColor = "#" + light2Color.RgbColorModelHex.Val.Value;
+                }
+                else if (light2Color.SystemColor != null)
+                {
+                    FontColor = "#" + light2Color.SystemColor.LastColor.Value;
+                }
+            }
+            else if (schemeColor.Val == "tx1")
+            {
+                Dark1Color dark1Color = slide.SlideLayoutPart.SlideMasterPart.
+                   ThemePart.Theme.ThemeElements.ColorScheme.Dark1Color;
+                if (dark1Color.RgbColorModelHex != null)
+                {
+                    FontColor = "#" + dark1Color.RgbColorModelHex.Val.Value;
+                }
+                else if (dark1Color.SystemColor != null)
+                {
+                    FontColor = "#" + dark1Color.SystemColor.LastColor.Value;
+                }
+            }
+            else if (schemeColor.Val == "tx2")
+            {
+                Dark2Color dark2Color = slide.SlideLayoutPart.SlideMasterPart.
+                 ThemePart.Theme.ThemeElements.ColorScheme.Dark2Color;
+                if (dark2Color.RgbColorModelHex != null)
+                {
+                    FontColor = "#" + dark2Color.RgbColorModelHex.Val.Value;
+                }
+                else if (dark2Color.SystemColor != null)
+                {
+                    FontColor = "#" + dark2Color.SystemColor.LastColor.Value;
+                }
+            }
+            else if (schemeColor.Val == "hlink")
+            {
+                Hyperlink HyperLink = slide.SlideLayoutPart.SlideMasterPart.
+                 ThemePart.Theme.ThemeElements.ColorScheme.Hyperlink;
+                if (HyperLink.RgbColorModelHex != null)
+                {
+                    FontColor = "#" + HyperLink.RgbColorModelHex.Val.Value;
+                }
+            }
+            else if (schemeColor.Val == "folHlink")
+            {
+                FollowedHyperlinkColor folHyperLink = slide.SlideLayoutPart.SlideMasterPart.
+                 ThemePart.Theme.ThemeElements.ColorScheme.FollowedHyperlinkColor;
+                if (folHyperLink.RgbColorModelHex != null)
+                {
+                    FontColor = "#" + folHyperLink.RgbColorModelHex.Val.Value;
+                }
+            }
+            this.ReadAccentSchemeColors(schemeColor);
+        }
+
+        private void ReadAccentSchemeColors(SchemeColor schemeColor)
+        {
+            for (int i = 1; i <= 6; i++)
+            {
+                if (schemeColor.Val == "accent" + i)
+                {
+                    switch (i)
+                    {
+                        case 1:
+                            {
+                                Accent1Color c = slide.SlideLayoutPart.SlideMasterPart.
+                                        ThemePart.Theme.ThemeElements.ColorScheme.Accent1Color;
+                                if (c.RgbColorModelHex != null)
+                                    FontColor = "#" + c.RgbColorModelHex.Val.Value;
+                            } break;
+                        case 2:
+                            {
+                                Accent2Color c = slide.SlideLayoutPart.SlideMasterPart.
+                                        ThemePart.Theme.ThemeElements.ColorScheme.Accent2Color;
+                                if (c.RgbColorModelHex != null)
+                                    FontColor = "#" + c.RgbColorModelHex.Val.Value;
+                            } break;
+                        case 3:
+                            {
+                                Accent3Color c = slide.SlideLayoutPart.SlideMasterPart.
+                                           ThemePart.Theme.ThemeElements.ColorScheme.Accent3Color;
+                                if (c.RgbColorModelHex != null)
+                                    FontColor = "#" + c.RgbColorModelHex.Val.Value;
+                            } break;
+                        case 4:
+                            {
+                                Accent4Color c = slide.SlideLayoutPart.SlideMasterPart.
+                                    ThemePart.Theme.ThemeElements.ColorScheme.Accent4Color;
+                                if (c.RgbColorModelHex != null)
+                                    FontColor = "#" + c.RgbColorModelHex.Val.Value;
+                            } break;
+                        case 5:
+                            {
+                                Accent5Color c = slide.SlideLayoutPart.SlideMasterPart.
+                                           ThemePart.Theme.ThemeElements.ColorScheme.Accent5Color;
+                                if (c.RgbColorModelHex != null)
+                                    FontColor = "#" + c.RgbColorModelHex.Val.Value;
+                            } break;
+                        case 6:
+                            {
+                                Accent6Color c = slide.SlideLayoutPart.SlideMasterPart.
+                                           ThemePart.Theme.ThemeElements.ColorScheme.Accent6Color;
+                                if (c.RgbColorModelHex != null)
+                                    FontColor = "#" + c.RgbColorModelHex.Val.Value;
+                            } break;
+                        default: { } break;
+                    }
+                }
+            }
+        }
+    }
+}

+ 77 - 0
TEAMModelOS.Test.PPTX/PPTLibrary/Dom/PPTVisualPPTShapeProp.cs

@@ -0,0 +1,77 @@
+using System;
+using DocumentFormat.OpenXml.Drawing;
+
+namespace ClearSlideLibrary.Dom
+{
+    public class PPTVisualPPTShapeProp
+    {
+      
+        public Offset Offset
+        {
+            get;
+            set;
+            
+        }
+
+        public Extents Extents
+        {
+            get; 
+            set ;
+        }
+
+        public double Rotate
+        {
+            get;
+            set;
+        }
+
+        public int PixelWidth(){
+            if (Extents == null || Extents.Cx == 0)
+            {
+               return 1;
+            }
+             else if (Extents.Cx < Globals.LEAST_COMMON_MULTIPLE_100_254)
+            {
+                return
+                    Convert.ToInt32((double)(Globals.LEAST_COMMON_MULTIPLE_100_254) / Extents.Cx);
+            }
+            else
+            {
+               return
+                    Convert.ToInt32(Extents.Cx / (double)(Globals.LEAST_COMMON_MULTIPLE_100_254));
+            }
+        }
+      
+        public int PixelHeight(){
+            if (Extents == null || Extents.Cy == 0)
+            {
+                return 1;
+            }
+            else if (Extents.Cy < Globals.LEAST_COMMON_MULTIPLE_100_254)
+            {
+               return
+                    Convert.ToInt32((double)(Globals.LEAST_COMMON_MULTIPLE_100_254) / Extents.Cy);
+            }
+            else
+            {
+               return
+                    Convert.ToInt32(Extents.Cy / (double)(Globals.LEAST_COMMON_MULTIPLE_100_254));
+            }
+        }
+
+        public int Top() {
+            if (Offset == null)
+                return 0;
+            return  Convert.ToInt32(Offset.Y / (double)(Globals.LEAST_COMMON_MULTIPLE_100_254)); 
+        }
+        public int Left() {
+            if (Offset == null)
+                return 0;
+            return Convert.ToInt32(Offset.X / (double)(Globals.LEAST_COMMON_MULTIPLE_100_254)); 
+        }             
+
+
+        public SolidFill SolidFill { get; set; }
+
+    }
+}

+ 58 - 0
TEAMModelOS.Test.PPTX/PPTLibrary/HtmlController/HtmlConnectionShape.cs

@@ -0,0 +1,58 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ClearSlideLibrary.HtmlController
+{
+    class HtmlConnectionShape:HtmlPresentationElement
+    {
+
+        public HtmlConnectionShape(string id, int width, int height,
+               int top, int left, bool invisible, bool animatable)
+        {
+            base.id = id;
+            base.top = top;
+            base.left = left;
+            base.width = width;
+            base.height = height;
+            base.invisible = invisible;
+            base.animatable = animatable;
+        }
+
+        public override string DrawElement()
+        {
+            StringBuilder connectionShapeBuilder = new StringBuilder();
+            string style = invisible ? "DC0" : "DC1";
+
+             //the object has animation.
+            if (animatable)
+            {
+                connectionShapeBuilder.Append("<div id=\"" + id + "\" style=\"top:" + top.ToString() + "px;left:" + left.ToString() +
+                               "px;height:" + height.ToString() + "px;width:" + width.ToString() + "px;\">");
+                connectionShapeBuilder.Append("<div class=\"" + style + "\" id=\"" + id + "c" + "\">");
+                connectionShapeBuilder.Append("<img />");
+                connectionShapeBuilder.Append("</div>");
+                connectionShapeBuilder.Append("</div>");
+            }
+            else
+            {
+                    connectionShapeBuilder.Append("<div id=\"" + id + "\" style=\"top:" + top.ToString() + "px;left:" + left.ToString() +
+                                     "px;height:" + height.ToString() + "px;width:" + width.ToString() + "px;\">");
+                    connectionShapeBuilder.Append("<img/>");
+                    connectionShapeBuilder.Append("</div>");
+            }
+            return connectionShapeBuilder.ToString();
+        }
+
+        public override string ToString()
+        {
+            Console.WriteLine("The top is:" + top);
+            Console.WriteLine("The left is:" + left);
+            Console.WriteLine("The width is:" + width);
+            Console.WriteLine("The height is:" + height);
+            return string.Format("[{0}, {1}, {2}, {3}]", top, left, width, height);
+        }
+    }
+}

+ 243 - 0
TEAMModelOS.Test.PPTX/PPTLibrary/HtmlController/HtmlController.cs

@@ -0,0 +1,243 @@
+using System;
+using System.Text;
+using System.IO;
+using System.Collections.Generic;
+using ClearSlideLibrary.Dom;
+using ClearSlideLibrary.Animations;
+
+namespace ClearSlideLibrary.HtmlController
+{
+    public class HtmlController
+    {
+        private readonly int _numberOfSlides;
+        private readonly int _allSlidesCount;
+        private readonly int _slideIndex;
+        private readonly string _fileName;
+        private readonly string _baseFileName;
+        private readonly string _filePath;
+        private readonly StringBuilder _htmlPart;
+        private readonly PPTSlide _mSlide;
+        private const string JS_DIR_NAME = "temp";
+        public int SlideWidth { get; set; }
+        public int SlideHeight { get; set; }
+
+
+        public HtmlController(string filepath, string filename,
+                              PPTSlide aSlide, int slideCounter, int slidesNumber)
+        {
+            _baseFileName = filename;
+            try
+            {
+                if (filename.Length != 0)
+                {
+                    if (slidesNumber != 1)
+                    {
+                        this._fileName = filename +"_" +slideCounter.ToString();
+                    }
+                    else
+                    {
+                        this._fileName = filename;
+                    }
+                }
+                this._mSlide = aSlide;
+                _numberOfSlides = 1;
+                _allSlidesCount = slidesNumber;
+                _slideIndex = slideCounter;
+                this._filePath = filepath;
+                this._htmlPart = new StringBuilder();
+            }
+            catch (ArgumentNullException ex)
+            {
+                Console.WriteLine("The passed value for filename:" + ex.Message);
+                return;
+            }
+        }
+
+        public void GenerateHtml()
+        {
+            this.GenerateHeader();
+            this.GenerateBody();
+            this.WriteTofile(_htmlPart);
+        }
+
+        private void WriteTofile(StringBuilder content)
+        {
+            string htmlFilePath = this._filePath + "\\" + this._fileName;
+            string outFileName = htmlFilePath + ".html";
+            FileStream fs = File.Create(outFileName, 1024);
+            Byte[] htmlcontent = new UTF8Encoding(true).GetBytes(content.ToString());
+            fs.Write(htmlcontent, 0, htmlcontent.Length);
+            fs.Close();
+
+            string outputDirWithFileNameAdded = Path.Combine(_filePath, _fileName);
+            CopyJSFiles(_filePath, outputDirWithFileNameAdded);
+        }
+
+        private void CopyJSFiles(string destinationDirForHtmlFile, string newOutputDir)
+        {
+            string sourceDir = Path.Combine(destinationDirForHtmlFile, JS_DIR_NAME);
+            string destDir = newOutputDir;
+            DirectoryInfo src = new DirectoryInfo(sourceDir);
+            DirectoryInfo dest = new DirectoryInfo(destDir);
+            FileInfo[] files = src.GetFiles();
+            foreach (FileInfo file in files)
+            {
+                try
+                {
+                    if (file.Exists)
+                    {
+                        file.CopyTo(Path.Combine(dest.FullName,
+                                                 file.Name));
+                    }
+                }
+                catch (IOException iex)
+                {
+                    Console.WriteLine(iex.Message);
+                }
+            }
+        }
+
+        private void GenerateHeader()
+        {
+            string numbers = DynamicHeaderJSPart();
+            AppendHeader(numbers);
+        }
+
+        private string DynamicHeaderJSPart()
+        {
+            if (_numberOfSlides == 1)
+            {
+                return "[0,1,1]";
+            }
+            else
+            {
+                int count = 0;
+                StringBuilder numbers = new StringBuilder();
+                numbers.Append("[");
+                while (count <= _numberOfSlides - 1)
+                {
+                    numbers.Append(count.ToString());
+                    numbers.Append(",");
+                    count++;
+                }
+                numbers.Append(count);
+                int length = numbers.ToString().Length;
+                string outputString = numbers.ToString().Remove(length - 1, 1);
+                return outputString + "]";
+            }
+        }
+
+        private void AppendHeader(string numbers)
+        {
+            string SC = ".SC {height: " + SlideHeight + "px; width: " + SlideWidth + "px; display: none;}";
+            string DC = ".DC1 {top: 0px; left: 0px; height: 100%; width: 100%; opacity: 1; }";
+            string DC0 = ".DC0 {top: 0px; left: 0px; height: 100%; width: 100%; opacity: 0;}";
+            _htmlPart.Append("<!DOCTYPE html>");
+            _htmlPart.Append("<html><head>");
+            _htmlPart.Append("<title>" + this._fileName + "</title>");
+            _htmlPart.Append("<meta content=\"text/html;charset=UTF-8\"  http-equiv=\"content-type\"/>");
+            _htmlPart.Append("<meta content=\"width=device-width, initial-scale=1,"
+                             + "maximum-scale=1, user-scalable=0\"name=\"viewport\"/>");
+            _htmlPart.Append("<link href=\"" + this._fileName + "/c.css\" rel=\"stylesheet\" type=\"text/css\"/>");
+            _htmlPart.Append("<script type=\"text/javascript\" src=\"" + this._fileName + "/jquery.js\"></script>");
+            _htmlPart.Append("<script type=\"text/javascript\" src=\"" + this._fileName + "/animationUtils.js\"></script>");
+            _htmlPart.Append("<script type=\"text/javascript\" src=\"" + this._fileName + "/animations.js\"></script>");
+            _htmlPart.Append("<script type=\"text/javascript\" src=\"" + this._fileName + "/player.js\"></script>");
+            _htmlPart.Append("<script type=\"text/javascript\">var gv = {w: 0,h: 0,t: 1,a: " +
+                             "'" + this._fileName + "'" + ",v: 0,sh:" + SlideHeight + ",sw:" + SlideWidth + ",s: 0,i:" + numbers +
+                             ",f:1,r:1};</script>");
+            _htmlPart.Append("<style type=\"text/css\">" + SC + "</style>");
+            _htmlPart.Append("<style type=\"text/css\">" + DC + DC0 + "</style>");
+            _htmlPart.Append("</head>");
+        }
+
+        private void GenerateBody()
+        {
+            _htmlPart.Append("<body id=\"bodyid\""
+                             + "style=\"background-color:Black;height:100%;width:100%;overflow:hidden;margin:0px;" +
+                             "user-select: none;-khtml-user-select: none;-ms-user-select: none;-o-user-select: text;" +
+                             "-webkit-user-select: none;-moz-user-select: none;-webkit-tap-highlight-color:rgba(0,0,0,0);\"" +
+                             "onkeydown=\"keychanger(event)\">");
+            AppendPlayer();
+            _htmlPart.Append("<div id=\"resizer\" style=\"left:0px;top:0px;height:" + SlideHeight + "px;width:" + SlideWidth + "px; overflow:hidden;-moz-transform-origin: 0 0;-o-transform-origin: 0 0;  -webkit-transform-origin: 0 0; -ms-transform-origin: 0 0;\">");
+
+            DynamicBodyPart();
+
+            _htmlPart.Append("<div id=\"loadingImg\" style=\"height:100%;width:100%;display:none;\">");
+            _htmlPart.Append("<img style=\"height:30px;width:130px;top:255px;left:295px;\" src=\"" + this._fileName + "/pre.gif\" />");
+            _htmlPart.Append("</div>");
+            _htmlPart.Append("</div>");
+            _htmlPart.Append("<script type=\"text/javascript\">");
+            
+
+            string staticJS =
+                (_mSlide.advanceAfterTime >= 0 ? "var advanceAfterSlide='" + _mSlide.advanceAfterTime + "'; var advanceSlideUrl = '" + _baseFileName + "_" + (_slideIndex + 1) + ".html?autoStart=true';" : "") +
+                "var lastAnimationPlaying=false;if ((document.createElement('canvas').getContext) ? true : false) { if (gv.b != 1) gfl(); $(window).resize(resizer);$(document).ready(resizer);" +
+                "if(window.location.toString().indexOf(\"autoStart=true\")>0){$(window).bind('load', atLoadAutoStart); }else { $(window).bind('load', atload);}" +
+                "} else { document.getElementById('resizer').innerHTML = ''; document.getElementById('toolbar').innerHTML = '';  document.getElementById('toolbar').style.width = '0px'; document.getElementById('idpre').innerHTML =" +
+                "'Oops! Your browser does not support HTML5. You need to upgrade your browser to view this presentation.' }";
+
+            //Dynamic part from the generated JavaScript file.
+            string anima = new ClearSlideLibrary.Animations.JSONGenerator(_mSlide).GetAnimaVariable();
+
+            _htmlPart.Append(staticJS);
+            _htmlPart.Append(anima);            
+            _htmlPart.Append("</script>");
+            _htmlPart.Append("</body></html>");
+        }
+
+        private void DynamicBodyPart()
+        {
+            if (_numberOfSlides != 0)
+            {
+                ////foreach (PPTSlide pptSlide in _mSlides)
+                ////{
+                string dirpath = Path.Combine(_filePath, _fileName);
+                HtmlSlide slide = new HtmlSlide(_mSlide.Id, "SC", this._fileName, dirpath, _mSlide.slideIndex)
+                {
+                    ContainerShape = _mSlide.ContainerShape
+                };
+                _htmlPart.Append(slide.DrawElement());
+
+                //}
+            }
+        }
+
+        private void AppendPlayer()
+        {
+            _htmlPart.Append("<div id=\"idpre\" style=\"z-index:1000;height:100%;width:100%;color:white;\">");
+            _htmlPart.Append("<img id=\"play\" style=\"display:none;height:200px;width:200px;cursor:pointer;position:absolute;\"");
+            _htmlPart.Append("onclick=\"fnPre()\" src=\"" + this._fileName + "/pre.png\" alt=\"click to begin\" />");
+            _htmlPart.Append("</div>");
+
+            _htmlPart.Append("<div class=\"toolbar\" id=\"toolbar\" style=\"bottom:0px;\">");
+            _htmlPart.Append("<div id=\"ddiv\" style=\"height:50px;\">");
+
+            _htmlPart.Append("<div class=\"\" id=\"time\" style=\"display:none;\">");
+            _htmlPart.Append("<span id=\"times\" style=\"font-weight:bold; color: #525151;\">00:00</span>");
+            _htmlPart.Append("</div>");
+
+            _htmlPart.Append("<div class=\"progress\" id=\"progress\" style=\"display:none;-moz-transform-origin: 0 0;-o-transform-origin: 0 0;-webkit-transform-origin: 0 0; -ms-transform-origin: 0 0;opacity:0;\">");
+
+            _htmlPart.Append("<div class=\"progressbar\" id=\"Bar\"> </div>");
+            _htmlPart.Append("</div>");
+            String nextUrl = _slideIndex >= _allSlidesCount ? "'" + _fileName + ".html'" : "'" + _baseFileName + "_" + (_slideIndex + 1) + ".html?autoStart=true'";
+            String prevUrl = _slideIndex <= 1 ? "'" + _fileName + ".html'" : "'" + _baseFileName + "_" + (_slideIndex - 1) + ".html?autoStart=true'";
+            _htmlPart.Append("<div id=\"buttonDiv\" style=\"width:150px; height:50px; opacity:0;\">");
+            _htmlPart.Append("<div class=\"next\" style=\"background-image: url('" + this._fileName + "/arrow.png')\" onclick=\"window.location = " + nextUrl + " ; fnPre()\"></div>");
+            _htmlPart.Append("<div class=\"next2\" style=\"background-image: url('" + this._fileName + "/arrow.png')\" onclick=\"next()\"></div>");
+            _htmlPart.Append("<div class=\"play\" id=\"playB\" style=\"background-image: url('" + this._fileName + "/arrow.png')\" onclick=\"next()\"></div>");
+            _htmlPart.Append("<div class=\"prev\" style=\"background-image: url('" + this._fileName + "/arrow.png')\" onclick=\"window.location = " + prevUrl + "; fnPre()\"></div>");
+            _htmlPart.Append("<div class=\"prev2\" style=\"background-image: url('" + this._fileName + "/arrow.png')\" onclick=\"prev()\"></div>");
+            _htmlPart.Append("</div>");
+
+            _htmlPart.Append("<div id=\"status\" style=\"display:none;width:34px;height:21px;\" title=\"goto\">");
+
+            _htmlPart.Append("<div id=\"statustotal\" style=\"top:1px;left:16px;font-size:14px;\">/ 1</div>");
+            _htmlPart.Append("<input id=\"current\" style=\"width:10px; top:3px;font-size:14px; height:16px;\" onkeypress=\"EnterCurrent(event)\"  maxlength=\"1\" type=\"text\"/>");
+            _htmlPart.Append("</div>");
+            _htmlPart.Append("</div>");
+            _htmlPart.Append("</div>");
+        }
+    }
+}

+ 60 - 0
TEAMModelOS.Test.PPTX/PPTLibrary/HtmlController/HtmlGroupShape.cs

@@ -0,0 +1,60 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ClearSlideLibrary.HtmlController
+{
+    class HtmlGroupShape : HtmlPresentationElement
+    {
+
+        public HtmlGroupShape(string id, int width, int height,
+                      int top, int left, bool invisible,
+                      bool animatable)
+        {
+            base.id = id;
+            base.top = top;
+            base.left = left;
+            base.width = width;
+            base.height = height;
+            base.invisible = invisible;
+            base.animatable = animatable;
+        }
+
+        public override string DrawElement()
+        {
+            StringBuilder shapeBuilder = new StringBuilder();
+            string style = invisible ? "DC0" : "DC1";
+
+            //the object has animation.
+            if (animatable)
+            {
+                shapeBuilder.Append("<div id=\"" + id + "\" style=\"top:" + top.ToString() + "px;left:" + left.ToString() +
+                               "px;height:" + height.ToString() + "px;width:" + width.ToString() + "px;\">");
+                shapeBuilder.Append("<div class=\"" + style + "\" id=\"" + id + "c" + "\">");
+                shapeBuilder.Append("<img />");
+                shapeBuilder.Append("</div>");
+                shapeBuilder.Append("</div>");
+            }
+            else
+            {
+                shapeBuilder.Append("<div id=\"" + id + "\" style=\"top:" + top.ToString() + "px;left:" + left.ToString() +
+                                 "px;height:" + height.ToString() + "px;width:" + width.ToString() + "px;\">");
+                shapeBuilder.Append("<img/>");
+                shapeBuilder.Append("</div>");
+            }
+            return shapeBuilder.ToString();
+        }
+
+        public override string ToString()
+        {
+            Console.WriteLine("The top is:" + top);
+            Console.WriteLine("The left is:" + left);
+            Console.WriteLine("The width is:" + width);
+            Console.WriteLine("The height is:" + height);
+            return string.Format("[{0}, {1}, {2}, {3}]", top, left, width, height);
+        }
+    }
+}
+

+ 80 - 0
TEAMModelOS.Test.PPTX/PPTLibrary/HtmlController/HtmlImage.cs

@@ -0,0 +1,80 @@
+using System;
+using System.Text;
+
+namespace ClearSlideLibrary.HtmlController
+{
+    internal class HtmlImage : HtmlPresentationElement
+    {
+        public string HyperLink { get; set; }
+        public string FileExtension { get; set; }
+
+        public HtmlImage(string id, int width, int height,
+                         int top, int left, bool invisible,
+                         bool animatable, string extension)
+        {
+            base.id = id;
+            base.top = top;
+            base.left = left;
+            base.width = width;
+            base.height = height;
+            base.invisible = invisible;
+            base.animatable = animatable;
+            this.FileExtension = extension;
+        }
+
+        public override string DrawElement()
+        {
+            StringBuilder imageBuilder = new StringBuilder();
+
+            //add hyperlink into output html tag as style element.
+            string hyperlinkString="";
+            bool cursorPointer = false;
+            if (HyperLink != null)
+            {
+                cursorPointer = true;
+                hyperlinkString = "onclick=\"openHyperLink(this,1,'" + HyperLink + "')\" onmouseout=\"OutListener()\" onmouseover=\"OverListener()\"";
+            }
+              
+            string style = invisible ? "DC0" : "DC1";
+            String idForHtml = id;
+            if ("gif".Equals(FileExtension))
+                idForHtml += ".gif";
+            else if ("jpg".Equals(FileExtension) || "jpeg".Equals(FileExtension))
+                idForHtml += ".jpg";
+            else if ("bmp".Equals(FileExtension))
+                idForHtml += ".bmp";
+            else
+                idForHtml += ".png";
+
+            if (animatable)
+            {
+                imageBuilder.Append("<div id=\"" + id + "\" style=\"top:" + top.ToString() + "px;left:" + left.ToString() +
+                               "px;height:" + height.ToString() + "px;width:" + width.ToString() + "px;" + (cursorPointer ? "cursor:pointer" : "") + "\"" + hyperlinkString + ">");
+                imageBuilder.Append("<div class=\"" + style + "\" id=\"" + idForHtml + "\">");                
+                imageBuilder.Append("<img />");                
+                imageBuilder.Append("</div>");
+                imageBuilder.Append("</div>");
+            }
+            else
+            {
+                imageBuilder.Append("<div id=\"" + id + "\" style=\"top:" + top.ToString() + "px;left:" + left.ToString() +
+                                    "px;height:" + height.ToString() + "px;width:" + width.ToString() + "px;" + (cursorPointer ? "cursor:pointer" : "") + "\"" + hyperlinkString + ">");
+                imageBuilder.Append("<div class=\"" + style + "\" id=\"" + idForHtml + "\">");
+                imageBuilder.Append("<img />");
+                imageBuilder.Append("</div>");
+                imageBuilder.Append("</div>");
+            }
+
+            return imageBuilder.ToString();
+        }
+
+        public override string ToString()
+        {
+            Console.WriteLine("The top is:" + top);
+            Console.WriteLine("The left is:" + left);
+            Console.WriteLine("The width is:" + width);
+            Console.WriteLine("The height is:" + height);
+            return string.Format("[{0}, {1}, {2}, {3}]", top, left, width, height);
+        }
+    }
+}

+ 57 - 0
TEAMModelOS.Test.PPTX/PPTLibrary/HtmlController/HtmlImageGIF.cs

@@ -0,0 +1,57 @@
+using System;
+using System.Text;
+
+namespace ClearSlideLibrary.HtmlController
+{
+    internal class HtmlImageGIF : HtmlPresentationElement
+    {
+        private readonly string _src;
+        private readonly string _nameOfImage;
+
+        public int Width
+        {
+            set { base.width = value; }
+        }
+
+        public int Height
+        {
+            set { base.height = value; }
+        }
+
+
+        public HtmlImageGIF(string slideId, string src,
+                            string nameOfImage, int top, int left)
+        {
+            base.id = slideId;
+            base.top = top;
+            base.left = left;
+            this._src = src;
+            this._nameOfImage = nameOfImage;
+        }
+
+        public override string DrawElement()
+        {
+            StringBuilder imageBuilder = new StringBuilder();
+
+            string imageId = id + "s" + _nameOfImage;
+            string source = _src + "/" + imageId + ".gif";
+  
+            imageBuilder.Append("<div id=\"" + imageId + "\" style=\"top:" + top.ToString() + "px;left:" +
+                                left.ToString() + "px;height:" + height.ToString() + "px;width:" + width.ToString() +
+                                "px;\">");
+            imageBuilder.Append("<img src=\"" + source + "\" />");
+            imageBuilder.Append("</div>");
+            return imageBuilder.ToString();
+        }
+
+        public override string ToString()
+        {
+            Console.WriteLine("The top is:" + this.top);
+            Console.WriteLine("The left is:" + this.left);
+            Console.WriteLine("The width is:" + this.width);
+            Console.WriteLine("The height is:" + this.height);
+            Console.WriteLine("The src is:" + _src);
+            return string.Format("[{0}, {1}, {2}, {3},{4}]", top, left, width, height, _src);
+        }
+    }
+}

+ 19 - 0
TEAMModelOS.Test.PPTX/PPTLibrary/HtmlController/HtmlPresentationElement.cs

@@ -0,0 +1,19 @@
+namespace ClearSlideLibrary.HtmlController
+{
+    internal abstract class HtmlPresentationElement
+    {
+        protected int top;
+        protected int left;
+        protected int width;
+        protected int height;
+        protected double fontSize;
+        protected string fontFamily;
+        protected string fontColor;
+        protected string id;
+        protected string cssClass;
+        protected bool invisible;
+        protected bool animatable;  
+
+        public abstract string DrawElement();
+    }
+}

+ 427 - 0
TEAMModelOS.Test.PPTX/PPTLibrary/HtmlController/HtmlShape.cs

@@ -0,0 +1,427 @@
+using System;
+using System.Text;
+using System.Collections.Generic;
+using System.Linq;
+using ClearSlideLibrary.Dom;
+using System.Drawing;
+using ClearSlideLibrary.Dom.PPTTexts;
+
+
+namespace ClearSlideLibrary.HtmlController
+{
+    internal class HtmlShape : HtmlPresentationElement
+    {
+        public PPTShape Shape { get; set; }
+        public double Rotate { get; set; }
+        public string HyperLink { get; set; }        
+        private int slideIndex;
+
+        public HtmlShape(string id, int width, int height,
+                         int top, int left, bool invisible,
+                         bool animatable, int slideIndex)
+        {
+            base.id = id;
+            base.top = top;
+            base.left = left;
+            base.width = width;
+            base.height = height;
+            base.invisible = invisible;
+            base.animatable = animatable;
+            this.slideIndex = slideIndex;
+        }
+
+        public override string DrawElement()
+        {
+            StringBuilder shapeBuilder = new StringBuilder();
+            //we need this for text (if any in the shape).
+            /*string slideId = id.Substring(0, 2);
+            int slideNumber = Int32.Parse(slideId.Substring(1, 1));
+            string shapeId = id.Substring(2, 2);
+            int shapeNumber = Int32.Parse(shapeId.Substring(1, 1));*/
+
+            string style = invisible ? "DC0" : "DC1";
+
+            //the object has animation.
+            if (animatable)
+            {
+
+                shapeBuilder.Append("<div id=\"" + id + "\" style=\"top:" + top.ToString() + "px;left:" + left.ToString() +
+                               "px;height:" + height.ToString() + "px;width:" + width.ToString() + "px;\">");
+                shapeBuilder.Append("<div class=\"" + style + "\" id=\"" + id + "c" + "\">");
+                shapeBuilder.Append("<img />");
+                shapeBuilder.Append("</div>");
+                shapeBuilder.Append("</div>");
+                if (Shape.IsText)
+                {
+                    if (Shape.Texts != null)
+                    {
+                        DrawText(shapeBuilder);
+                    }
+                }
+            }
+            else
+            {
+                shapeBuilder.Append("<div id=\"" + id + "\" style=\"top:" + top.ToString() + "px;left:" + left.ToString() +
+                                 "px;height:" + height.ToString() + "px;width:" + width.ToString() + "px;\">");
+                shapeBuilder.Append("<img/>");
+                shapeBuilder.Append("</div>");
+                if (Shape.IsText)
+                {
+                    if (Shape.Texts != null)
+                    {
+                        DrawText(shapeBuilder);
+                    }
+                }
+
+
+            }
+            return shapeBuilder.ToString();
+        }
+
+        private void DrawText(StringBuilder shapeBuilder)
+        {
+            int top = getTopForCurrentAnchoring(this.Shape.VerticalAlign, this.Shape.Texts);
+
+
+            foreach (var par in Shape.Texts)
+            {
+
+                //If top add spacing before - otherwise not (I think)
+                int paragraphTop = this.top + (this.Shape.VerticalAlign.Equals(DocumentFormat.OpenXml.Drawing.TextAnchoringTypeValues.Top) ? par.getSpaceBeforePoints() : 0); 
+
+                string htmlStyle = par.Invisible ? "DC0" : "DC1";
+                if (par.Animatable)
+                {
+                    shapeBuilder.Append("<div id=\"" + id + "p" + par.Paragraph + "\" style=\"top:" + paragraphTop + "px;left:" + this.left.ToString() +
+                                   "px;height:" + height.ToString() + "px;width:" + width.ToString() + "px;\">");
+                    shapeBuilder.Append("<div class=\"" + htmlStyle + "\" id=\"" + id + "p" + par.Paragraph + "c" + "\">");
+                }
+                else
+                {
+                    shapeBuilder.Append("<div id=\"" + id + "p" + par.Paragraph + "\" style=\"top:" + (this.top).ToString() + "px;left:" + this.left.ToString() +
+                                     "px;height:" + height.ToString() + "px;width:" + width.ToString() + "px;\">");
+                }
+
+                int newTop = par.getSpaceBeforePoints();
+                int left = 0;
+
+                List<HtmlText> textElements = new List<HtmlText>();
+                if (par.RunPropList == null || par.RunPropList.Count == 0 && par.defaultRunProperties != null)  //Only paragraph!
+                {
+                    float points = float.Parse(par.defaultRunProperties.FontSize.ToString()) * 72.0F / 96.0F;
+                    Font font = new System.Drawing.Font(par.defaultRunProperties.FontFamily.ToString(), points);
+                    newTop = font.Height;
+                }
+                List<HtmlText> processedElements = new List<HtmlText>();
+                foreach (var text in breakTextsToShape(par))
+                {
+                    float points = float.Parse(text.FontSize.ToString()) * 72.0F / 96.0F;
+                    Font font = new System.Drawing.Font(text.FontFamily.ToString(), points);
+                    if (text.Bold) font = new System.Drawing.Font(text.FontFamily.ToString(), points, FontStyle.Bold);
+                    else if (text.Italic)
+                        font = new System.Drawing.Font(text.FontFamily.ToString(), points, FontStyle.Italic);
+                    else if (text.Underline != null && text.Underline.Equals("Single"))
+                    font = new System.Drawing.Font(text.FontFamily.ToString(), points, FontStyle.Underline);
+                    newTop = font.Height > newTop ? font.Height : newTop;                    
+                    newTop = par.getLineSpacingInPointsFromFont(newTop);
+
+
+                    if (text.isBreak)
+                    {
+                        top += newTop;
+                        left = 0;
+                        fixLeftSpacingForAlignment(processedElements, par,font);
+                        processedElements.Clear();
+                        continue;
+                    }
+                    String currentString =  text.Text.TrimEnd()+ getStringFromTextElements(processedElements);
+                    //Text must already be broken to lines
+                    //Size size = MeasureString(currentString, font);
+//                     if (size.Width > this.width - par.Indent - par.marginLeft - par.marginRight) 
+//                     {
+//                         top += newTop;
+//                         left = 0;
+//                         fixLeftSpacingForAlignment(processedElements, par, font);
+//                         processedElements.Clear();
+//                     }
+
+
+                    HtmlText t1 = new HtmlText(left: left,
+                                               top: top,
+                                               fontFamily: text.FontFamily,
+                                               fontColor: text.FontColor,
+                                               fontSize: text.FontSize,
+                                               isBullet: text.isBullet,
+                                               bold: text.Bold,
+                                               italic: text.Italic,
+                                               underline: text.Underline,                                               
+                                               id: id,
+                                               slideIndex: slideIndex)
+                    {
+                        Rotate = Rotate                      
+                    };
+
+                    t1.width = MeasureString(text.Text, font);
+
+                    if (text.isBullet && text.Text != null && text.Text.Contains("rId"))
+                    {
+                        t1.PictureBullet = true;
+                        t1.width = text.bulletSize;
+                        t1.bulletSize = text.bulletSize;
+                        newTop = text.bulletSize;
+                    }
+                    t1.Text = text.Text;
+                    textElements.Add(t1);
+                    processedElements.Add(t1);
+                }
+                fixLeftSpacingForAlignment(processedElements, par);
+
+                HtmlText lastTxt = null;
+                List<HtmlText> mergedTextElements = new List<HtmlText>();
+                foreach (HtmlText textElement in textElements)
+                {
+                    if (lastTxt == null || !lastTxt.sameProps(textElement))
+                        mergedTextElements.Add(textElement);
+                    else
+                        mergedTextElements[mergedTextElements.Count - 1].Text += textElement.Text;
+
+                    lastTxt = textElement;
+                }
+
+                foreach (HtmlText textElement in mergedTextElements)
+                    shapeBuilder.Append(textElement.DrawElement());
+                top += newTop;
+                top += par.getSpaceAfterPoints(newTop);
+                top += par.getSpaceBeforePoints(newTop);
+
+
+                shapeBuilder.Append("</div>");
+                if (par.Animatable)
+                    shapeBuilder.Append("</div>");
+            }
+        }
+        private String getStringFromTextElements(List<HtmlText> elements)
+        {
+            if (elements == null || elements.Count == 0)
+                return "";
+            StringBuilder result=new StringBuilder();
+            foreach(HtmlText el in elements){
+                result.Append(el.Text);          
+            }            
+            return result.ToString();
+        }
+        //We have two similar methods. This is worse because it uses the Width property of each element instead of measuring the whole string. 
+        //There is mistake in the calculations coming from that and the difference is bigger when there are more elements. 
+        private void fixLeftSpacingForAlignment(List<HtmlText> textElements, PPTParagraph par)
+        {
+            int combinedWidth = 0;
+
+            foreach (HtmlText textElement in textElements)
+                combinedWidth += textElement.width;
+            int bulletOffset = 0;
+            if (par.bullet != null && textElements.Count > 0 && !textElements[0].isBullet)
+            {
+                combinedWidth += par.bullet.bulletSize;
+                bulletOffset = par.bullet.bulletSize;
+            }
+            
+            int currentLeft = 0;
+            if ("Center".Equals(par.Align))
+                currentLeft = ((this.width - par.Indent - bulletOffset - par.marginLeft - par.marginRight - Shape.LeftInset - Shape.RightInset) - combinedWidth) / 2;
+            else if ("Right".Equals(par.Align))
+                currentLeft = (this.width - par.Indent - bulletOffset - par.marginLeft - par.marginRight - Shape.LeftInset - Shape.RightInset) - combinedWidth;
+
+            foreach (HtmlText textElement in textElements)
+            {
+                textElement.setLeft(currentLeft + par.Indent + bulletOffset + par.marginLeft + Shape.LeftInset);
+                currentLeft += textElement.width;
+            }
+        }
+
+        //We have two similar methods - this one is better because it measures the whole string with the font. 
+        private void fixLeftSpacingForAlignment(List<HtmlText> textElements, PPTParagraph par, Font font)
+        {
+            int combinedWidth = 0;
+          
+            StringBuilder combinedText = new StringBuilder();
+            foreach (HtmlText textElement in textElements)
+            {
+                if(textElement.PictureBullet)
+                    combinedWidth += textElement.bulletSize;
+                else
+                combinedText.Append(textElement.Text);
+            }
+            int bulletOffset = 0;
+            if (par.bullet != null && textElements.Count > 0 && !textElements[0].isBullet)
+            {
+                bulletOffset = par.bullet.bulletSize;
+                combinedWidth += par.bullet.bulletSize;
+            }
+            combinedWidth += MeasureString(combinedText.ToString(), font);
+         
+            int firstLeft = 0;
+            if ("Center".Equals(par.Align))
+                firstLeft = ((this.width - par.Indent - bulletOffset - par.marginLeft - par.marginRight - Shape.LeftInset - Shape.RightInset) - combinedWidth) / 2;
+            else if ("Right".Equals(par.Align))
+                firstLeft = (this.width - par.Indent - bulletOffset - par.marginLeft - par.marginRight - Shape.LeftInset - Shape.RightInset) - combinedWidth;
+            combinedText = new StringBuilder();
+            combinedWidth = 0; //Now used only for picture bullets!
+            foreach (HtmlText textElement in textElements)
+            {
+                textElement.setLeft(firstLeft + par.Indent + bulletOffset + par.marginLeft + combinedWidth + Shape.LeftInset + MeasureString(combinedText.ToString(), font));
+                if (textElement.PictureBullet)
+                    combinedWidth += textElement.bulletSize;
+                else
+                    combinedText.Append(textElement.Text);
+            }
+        }
+
+        private int getTopForCurrentAnchoring(DocumentFormat.OpenXml.Drawing.TextAnchoringTypeValues anchoring, LinkedList<PPTParagraph> paragraphList)
+        {
+            if (anchoring.Equals(DocumentFormat.OpenXml.Drawing.TextAnchoringTypeValues.Top))
+                return Shape.TopInset;
+
+            int combinedHeight = 0;
+            foreach (PPTParagraph par in paragraphList)
+            {
+                int newTop = 0;
+                IEnumerable<PPTRunProperties> splitText=breakTextsToShape(par);
+                foreach (var text in splitText)
+                {
+                    float points = float.Parse(text.FontSize.ToString()) * 72.0F / 96.0F;
+                    Font font = new System.Drawing.Font(text.FontFamily.ToString(), points);
+                    if (text.Bold) font = new System.Drawing.Font(text.FontFamily.ToString(), points, FontStyle.Bold);
+                    else if (text.Italic) font = new System.Drawing.Font(text.FontFamily.ToString(), points, FontStyle.Italic);
+                    else if (text.Underline != null && text.Underline.Equals("Single"))
+                        font = new System.Drawing.Font(text.FontFamily.ToString(), points, FontStyle.Underline);                    
+                    if (text.isBreak)
+                    {
+                        combinedHeight += newTop;
+                        newTop = font.Height;
+                        continue;
+                    }
+                    
+                    newTop = font.Height > newTop ? font.Height : newTop;
+
+                }
+                combinedHeight += par.getLineSpacingInPointsFromFont(newTop);
+                combinedHeight += par.getSpaceBeforePoints(newTop);
+                combinedHeight += par.getSpaceAfterPoints(newTop);                
+            }
+
+            combinedHeight += Shape.TopInset + Shape.BottomInset;
+            if (anchoring.Equals(DocumentFormat.OpenXml.Drawing.TextAnchoringTypeValues.Bottom))
+                return this.height - combinedHeight;
+
+            return (this.height - combinedHeight) / 2;  //Center align
+
+
+
+        }
+
+        private IEnumerable<PPTRunProperties> breakTextsToShape(PPTParagraph par)
+        {
+            List<Dom.PPTTexts.PPTRunProperties> list = par.RunPropList;
+            List<PPTRunProperties> result = new List<PPTRunProperties>();            
+            String previousToken = null;
+            int bulletSize = 0;
+            foreach (var text in list)
+            {
+                float points = float.Parse(text.FontSize.ToString()) * 72.0F / 96.0F;
+                Font font = new System.Drawing.Font(text.FontFamily.ToString(), points);
+                if (text.Bold) font = new System.Drawing.Font(text.FontFamily.ToString(), points, FontStyle.Bold);
+                else if (text.Italic) font = new System.Drawing.Font(text.FontFamily.ToString(), points, FontStyle.Italic);
+                else if (text.Underline != null && text.Underline.Equals("Single"))
+                    font = new System.Drawing.Font(text.FontFamily.ToString(), points, FontStyle.Underline);
+
+                int size = 0;
+                if (text.isBullet && text.Text != null && text.Text.Contains("rId"))
+                    bulletSize = text.bulletSize;
+                else
+                    size = MeasureString((previousToken == null ? "" : previousToken + " ") + text.Text, font);
+                if (text.isBreak || size + bulletSize < this.width - par.Indent -par.marginLeft - par.marginRight - Shape.LeftInset - Shape.RightInset)
+                {
+                    if (text.Text != null && text.Text.Trim() != "" && !(text.isBullet && text.Text.Contains("rId")))
+                    {
+                        previousToken = (previousToken == null ? "" : previousToken ) + text.Text;
+                    }
+                    if (text.isBreak)
+                        previousToken = null;
+                    result.Add(text);                    
+                    continue;
+                }
+
+             //   previousToken = null;
+
+                string[] tokens= text.Text.Split(' ');
+                int index = 0;
+                foreach (string token in tokens)
+                {
+                    index++;           
+                    int combinedSize = MeasureString((previousToken == null ? "" : previousToken + " ")+token , font);
+
+                    if (combinedSize + bulletSize > this.width - par.Indent - par.marginLeft - par.marginRight - Shape.LeftInset - Shape.RightInset)
+                    {
+                        PPTRunProperties temp = new PPTRunProperties(text);                        
+                        temp.Text = "";
+                        temp.isBreak = true;
+                        result.Add(temp);
+
+                        temp=new PPTRunProperties(text);
+                        temp.Text=index<tokens.Length? token+" ":token;
+                        result.Add(temp);
+                        previousToken = token;                        
+                    }
+                    else
+                    {
+                        PPTRunProperties temp = new PPTRunProperties(text);
+                        temp.Text = index < tokens.Length ? token + " " : token;
+                        result.Add(temp);
+                        previousToken = (previousToken == null ? "" : previousToken + " ") + token;
+                    }                    
+                }
+            }
+            return result;
+        }
+
+        public static int MeasureString(string s, Font font)
+        {
+            s = s.Replace("\t", "aaaa");//TODO the replace is dirty hack for measuring tabulations
+
+            StringFormat stringFormat = new StringFormat(StringFormat.GenericTypographic);            
+            CharacterRange[] rng = { new CharacterRange(0, s.Length) };
+            stringFormat.SetMeasurableCharacterRanges(rng);
+            Graphics g= Graphics.FromImage(new Bitmap(100, 100));
+            //Use measure character ranges with a big box because we used this for measurement only
+            //Later we might better use this for drawing the text. 
+            Region[] regions =g.MeasureCharacterRanges(s, font, new Rectangle(0, 0, 10000,3000), stringFormat); 
+            foreach (Region region in regions)
+            {                
+                RectangleF rect = region.GetBounds(g);
+                return (int)Math.Round(rect.Width);
+            }
+            return 0;
+
+// 
+//             SizeF result;
+//             using (var image = new Bitmap(1, 1))
+//             {
+//                 using (var g = Graphics.FromImage(image))
+//                 {
+//                     result = g.MeasureString(s, font);
+//                 }
+//             }
+// 
+//             return result.ToSize();
+        }
+
+        public override string ToString()
+        {
+            Console.WriteLine("The top is:" + top);
+            Console.WriteLine("The left is:" + left);
+            Console.WriteLine("The width is:" + width);
+            Console.WriteLine("The height is:" + height);
+            return string.Format("[{0}, {1}, {2}, {3}]", top, left, width, height);
+        }
+    }
+}

+ 139 - 0
TEAMModelOS.Test.PPTX/PPTLibrary/HtmlController/HtmlSlide.cs

@@ -0,0 +1,139 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using ClearSlideLibrary.Dom;
+using System.IO;
+
+namespace ClearSlideLibrary.HtmlController
+{
+    internal class HtmlSlide : HtmlPresentationElement
+    {
+        public PPTContainerShape ContainerShape { get; set; }
+        private readonly string _fileName;
+        private readonly string dirPath;
+        private int slideIndex;
+        
+        public HtmlSlide(string slideid, string slideClass, string fileName, string dirpath, int slideIndex)
+        {
+            base.id = slideid;
+            base.cssClass = slideClass;
+            this._fileName = fileName;
+            this.dirPath = dirpath;
+            this.slideIndex = slideIndex;
+        }
+
+        public override string DrawElement()
+        {
+            StringBuilder slideBuilder = new StringBuilder(1000);
+            slideBuilder.Append("<div class=\"" + cssClass + "\" id=\"" + id + "\"><img />");
+            try
+            {
+              
+                GenerateElements(slideBuilder);
+            }
+            catch (ArgumentNullException ex)
+            {
+                Console.WriteLine("The slide has no shapes." + ex);
+            }
+            slideBuilder.Append("</div>");
+
+            return slideBuilder.ToString();
+        }
+
+        private void GenerateElements(StringBuilder slide)
+        {
+            if (ContainerShape.Elements.Count > 0)
+            {
+                foreach (PPTShapeBase baseShape in ContainerShape.Elements)
+                {
+                    DrawShapeHtml(slide, baseShape);
+                }
+            }
+        }
+
+        private void DrawShapeHtml(StringBuilder slide, PPTShapeBase baseShape)
+        {
+            int left = baseShape.VisualShapeProp.Left();
+            int width = baseShape.VisualShapeProp.PixelWidth();
+            int top = baseShape.VisualShapeProp.Top();
+            int height = baseShape.VisualShapeProp.PixelHeight();
+            string Id = baseShape.NonVisualShapeProp.Id;
+            bool invisible = baseShape.Invisible;
+            bool animatable = baseShape.Animatable;
+            string clickLinkUrl = baseShape.ClickLinkUrl;
+
+
+            //simple fix (not good but work for now).
+            DirectoryInfo dest = new DirectoryInfo(dirPath);
+            FileInfo[] files = dest.GetFiles();
+
+            foreach (FileInfo file in files)
+            {
+                string fname = Path.GetFileNameWithoutExtension(file.Name);
+
+                if (fname.Equals(Id))
+                {
+                    if (baseShape is PPTGraphicFrame)
+                    {
+                        HtmlSmartArt htmlSmartArt = new HtmlSmartArt(Id, width, height, top,
+                                                                    left, invisible, animatable);
+                        slide.Append(htmlSmartArt.DrawElement());
+                    }
+                    else if (baseShape is PPTGroupShape)
+                    {
+                        HtmlGroupShape htmlShape = new HtmlGroupShape(Id, width, height, top,
+                                                                        left, invisible, animatable);
+                        slide.Append(htmlShape.DrawElement());
+                    }
+                    else if (baseShape is PPTConnectionShape)
+                    {
+                        HtmlConnectionShape htmlShape =
+                            new HtmlConnectionShape(Id, width, height, top,
+                                                    left, invisible, animatable);
+                        slide.Append(htmlShape.DrawElement());
+                    }
+                    else if (baseShape is PPTShape)
+                    {
+                        PPTShape s = (PPTShape)baseShape;
+
+                        HtmlShape htmlShape = new HtmlShape(Id, width, height, top,
+                                                             left, invisible, animatable, slideIndex)
+                                                 {
+                                                     Shape = s,
+                                                     Rotate = s.VisualShapeProp.Rotate,
+                                                     HyperLink = clickLinkUrl
+                                                 };
+                        slide.Append(htmlShape.DrawElement());
+                    }
+                    else if (baseShape is PPTImage)
+                    {
+                        string imageName = baseShape.NonVisualShapeProp.Name;
+              
+                        //TODO Differentiate between gif and other image types.
+
+                        //HtmlImageGIF image = new HtmlImageGIF(Id, _fileName, imageName,top, left);
+                        //slide.Append(image.DrawElement());
+
+                        HtmlImage htmlImage = new HtmlImage(Id, width, height,
+                                                            top, left, invisible, animatable,((PPTImage)baseShape).FileExtension )
+                                                            {
+                                                                HyperLink = clickLinkUrl
+                                                            };
+                      
+                        slide.Append(htmlImage.DrawElement());
+                    }
+                }
+            }
+
+        }
+
+
+        public override string ToString()
+        {
+            Console.WriteLine("The id is:" + id);
+            Console.WriteLine("The css class is:" + cssClass);
+
+            return id + cssClass;
+        }
+    }
+}

+ 58 - 0
TEAMModelOS.Test.PPTX/PPTLibrary/HtmlController/HtmlSmartArt.cs

@@ -0,0 +1,58 @@
+using System;
+using System.Text;
+
+namespace ClearSlideLibrary.HtmlController
+{
+    internal class HtmlSmartArt : HtmlPresentationElement
+    {
+        public HtmlSmartArt(string id, int width, int height,
+                            int top, int left, bool invisible,
+                            bool animatable)
+           // frameId, width, height, top, left, visible, animatable
+        {
+            base.id = id;
+            base.top = top;
+            base.left = left;
+            base.width = width;
+            base.height = height;
+            base.invisible = invisible;
+            base.animatable = animatable;
+        }
+
+        public override string DrawElement()
+        {
+            StringBuilder smartArtBuilder = new StringBuilder();
+
+            string style = invisible ? "DC0" : "DC1";
+            //the object has animation.
+            if (animatable)
+            {
+                smartArtBuilder.Append("<div id=\"" + id + "\" style=\"top:"
+                                  + top.ToString() + "px;left:" + left.ToString() + "px;height:"
+                                  + height.ToString() + "px;width:" + width.ToString() + "px;\">");
+                smartArtBuilder.Append("<div class=\"" + style + "\" id=\"" + id + "c" + "\">");
+                smartArtBuilder.Append("<img />");
+                smartArtBuilder.Append("</div>");
+                smartArtBuilder.Append("</div>");
+            }
+            else
+            {
+                smartArtBuilder.Append("<div id=\"" + id + "\" style=\"top:"
+                                    + top.ToString() + "px;left:" + left.ToString() + "px;height:"
+                                    + height.ToString() + "px;width:" + width.ToString() + "px;\">");
+                smartArtBuilder.Append("<img/>");
+                smartArtBuilder.Append("</div>");
+            }
+            return smartArtBuilder.ToString();
+        }
+
+        public override string ToString()
+        {
+            Console.WriteLine("The top is:" + top);
+            Console.WriteLine("The left is:" + left);
+            Console.WriteLine("The width is:" + width);
+            Console.WriteLine("The height is:" + height);
+            return string.Format("[{0}, {1}, {2}, {3}]", top, left, width, height);
+        }
+    }
+}

+ 125 - 0
TEAMModelOS.Test.PPTX/PPTLibrary/HtmlController/HtmlText.cs

@@ -0,0 +1,125 @@
+using System;
+using System.Text;
+using ClearSlideLibrary.Dom;
+
+namespace ClearSlideLibrary.HtmlController
+{
+    internal class HtmlText : HtmlPresentationElement
+    {
+        public string id { get; set; }
+        public string Text { get; set; }
+        public bool PictureBullet { get; set; }
+        public bool isBullet { get; set; }
+        public const int DefaultBulletSize = 12;
+        public int bulletSize { get; set; }
+        private bool bold;
+        private bool italic;
+        private string underline;
+        public int slideIndex;
+        public int width { get; set; }
+        public double Rotate { get; set; }
+        public void setLeft(int newLeft)
+        {
+            left = newLeft;
+        }
+
+      
+
+        public HtmlText(int left, int top, string fontFamily, string fontColor, double fontSize, bool isBullet,
+                         bool bold, bool italic, string underline, string id, int slideIndex)
+        {
+            base.fontSize = fontSize;
+            base.left = left;
+            base.top = top;
+            base.fontFamily = fontFamily;
+            this.isBullet = isBullet;
+            base.fontColor = fontColor;
+            this.bold = bold;
+            this.italic = italic;
+            this.id = id;
+            this.slideIndex = slideIndex;
+
+            if (underline != null)
+            {
+                if (underline.Equals("Single"))
+                {
+                    this.underline = "underline";
+                }
+                else if (underline.Equals("None"))
+                {
+                    this.underline = "none";
+                }
+            }
+            else this.underline = "none";
+        }
+
+        public override string DrawElement()
+        {
+            if (id != null)
+            {
+                id = id.Substring(3);
+                int tryParse = 0;
+                if (int.TryParse(id, out tryParse))
+                {
+                    if (PPTShape.effectShapes.Contains(slideIndex + "_" + tryParse))
+                    {
+                        return "";
+                    }
+                }
+            }
+
+            string rot = "";
+            if (Rotate != 0.0)
+            {
+                rot = "-o-transform:rotate(" + Rotate + "deg);-ms-transform:rotate(" + Rotate + "deg);-moz-transform:rotate(" + Rotate + "deg);-webkit-transform:rotate(" + Rotate + "deg);";
+
+            }
+            StringBuilder textBuilder = new StringBuilder();
+            if (Text != null)
+            {
+                if (PictureBullet)
+                {
+                    textBuilder.Append("<pre style=\"top:" + top.ToString() + "px;left:" + left.ToString() + "px;" + rot + "\">");
+                    textBuilder.Append("<br/><img width=\"" + bulletSize + "\" height=\"" + bulletSize + "\" src="+Text+">");
+                    textBuilder.Append("</pre>");
+                }
+                else
+                {
+                    textBuilder.Append("<pre style=\"top:" + top.ToString() + "px;left:" + left.ToString() + "px; font-size:" + fontSize.ToString() + "px; color:" + fontColor + (italic ? ";font-style:italic" : "") + (bold ? ";font-weight:bold" : "") +(this.underline.Equals("none") ? "": ";text-decoration:" + this.underline) + ";font-family:" + fontFamily + ";" + rot + "\">");
+                    textBuilder.Append(Text);
+                    textBuilder.Append("</pre>");
+                }
+            }
+
+            return textBuilder.ToString();
+        }
+
+        public override string ToString()
+        {
+            Console.WriteLine("The top is:" + top);
+            Console.WriteLine("The left is:" + left);
+            Console.WriteLine("The text is:" + Text);
+            Console.WriteLine("The text color is:" + fontColor);
+            Console.WriteLine("The text size is:" + fontSize);
+            Console.WriteLine("The text family is:" + fontFamily);
+            Console.WriteLine("The height is:" + height);
+            return string.Format("[{0}, {1}, {2}, {3}, {4}, {5}]",
+                          top, left, Text, fontColor, fontSize, fontFamily);
+        }
+
+        public bool sameProps(HtmlText other)
+        {
+            if (other == null)
+            {
+                return false;
+            }
+            return this.top == other.top
+                && this.fontSize == other.fontSize
+                && this.fontColor == other.fontColor
+                && this.italic == other.italic
+                && this.bold == other.bold
+                && this.underline == other.underline
+                && this.fontFamily == other.fontFamily;
+        }
+    }
+}

+ 17 - 0
TEAMModelOS.Test.PPTX/PPTLibrary/PPTBuilder/PPTConnectionShapeBuilder.cs

@@ -0,0 +1,17 @@
+using System.Linq;
+using ClearSlideLibrary.Dom;
+using DocumentFormat.OpenXml.Packaging;
+using System.Collections.Generic;
+using DocumentFormat.OpenXml.Presentation;
+
+namespace ClearSlideLibrary.PPTBuilder
+{
+    internal class PPTConnectionShapeBuilder
+    {
+        internal List<PPTConnectionShape> GetConnectionShapes(SlidePart slidePart)
+        {
+            return slidePart.Slide.Descendants<ConnectionShape>().Select(shape => new PPTConnectionShape(slidePart, shape)).ToList();
+        }
+
+    }
+}

+ 42 - 0
TEAMModelOS.Test.PPTX/PPTLibrary/PPTBuilder/PPTContainerShapeBuilder.cs

@@ -0,0 +1,42 @@
+using ClearSlideLibrary.Dom;
+using DocumentFormat.OpenXml.Packaging;
+using DocumentFormat.OpenXml.Presentation;
+using System.Collections.Generic;
+
+namespace ClearSlideLibrary.PPTBuilder
+{
+    internal class PPTContainerShapeBuilder
+    {
+        public PPTContainerShape GetPPTContainerShape(SlidePart slidePart, PPTSlide slide)
+        {
+            var pptContainerShape = new PPTContainerShape();
+            pptContainerShape.Elements = new List<PPTShapeBase>();
+            foreach (object obj in slidePart.Slide.Descendants())
+            {
+                if (typeof(Shape).Equals(obj.GetType()))
+                {
+                    pptContainerShape.Elements.Add(new PPTShape(slidePart,(Shape)obj, slide));
+                }
+                else if (typeof(Picture).Equals(obj.GetType()))
+                {
+                    pptContainerShape.Elements.Add(new PPTImage(slidePart, (Picture)obj));
+                }
+                else if (typeof(GraphicFrame).Equals(obj.GetType()))
+                {
+                    pptContainerShape.Elements.Add(new PPTGraphicFrame(slidePart, (GraphicFrame)obj));
+                }
+                else if (typeof(GroupShape).Equals(obj.GetType()))
+                {
+                    pptContainerShape.Elements.Add(new PPTGroupShape(slidePart, (GroupShape)obj));
+                }
+                else if (typeof(ConnectionShape).Equals(obj.GetType()))
+                {
+                    pptContainerShape.Elements.Add(new PPTConnectionShape(slidePart, (ConnectionShape)obj));
+                } 
+            }   
+
+
+            return pptContainerShape;
+        }
+    }
+}

+ 16 - 0
TEAMModelOS.Test.PPTX/PPTLibrary/PPTBuilder/PPTGraphicFrameBuilder.cs

@@ -0,0 +1,16 @@
+using System.Linq;
+using ClearSlideLibrary.Dom;
+using DocumentFormat.OpenXml.Packaging;
+using System.Collections.Generic;
+using DocumentFormat.OpenXml.Presentation;
+
+namespace ClearSlideLibrary.PPTBuilder
+{
+    public class PPTGraphicFrameBuilder
+    {
+        internal List<PPTGraphicFrame> GetGraphicFrames(SlidePart slidePart)
+        {
+            return slidePart.Slide.Descendants<GraphicFrame>().Select(graphicFrame => new PPTGraphicFrame(slidePart, graphicFrame)).ToList();
+        }
+    }
+}

+ 16 - 0
TEAMModelOS.Test.PPTX/PPTLibrary/PPTBuilder/PPTGroupShapeBuilder.cs

@@ -0,0 +1,16 @@
+using System.Linq;
+using ClearSlideLibrary.Dom;
+using DocumentFormat.OpenXml.Packaging;
+using System.Collections.Generic;
+using DocumentFormat.OpenXml.Presentation;
+
+namespace ClearSlideLibrary.PPTBuilder
+{
+    internal class PPTGroupShapeBuilder
+    {
+        internal List<PPTGroupShape> GetGroupShapes(SlidePart slidePart)
+        {
+            return slidePart.Slide.Descendants<GroupShape>().Select(shape => new PPTGroupShape(slidePart, shape)).ToList();
+        }
+    }
+}

+ 20 - 0
TEAMModelOS.Test.PPTX/PPTLibrary/PPTBuilder/PPTImageBuilder.cs

@@ -0,0 +1,20 @@
+using System.Collections.Generic;
+using System.Linq;
+using ClearSlideLibrary.Dom;
+using DocumentFormat.OpenXml.Packaging;
+using Picture = DocumentFormat.OpenXml.Presentation.Picture;
+
+namespace ClearSlideLibrary.PPTBuilder
+{
+    public class PPTImageBuilder
+    {
+        public PPTImageBuilder()
+        {
+        }
+
+        public List<PPTImage> GetImages(SlidePart slidePart)
+        {
+            return slidePart.Slide.Descendants<Picture>().Select(picture => new PPTImage(slidePart, picture)).ToList();
+        }
+    }
+}

+ 261 - 0
TEAMModelOS.Test.PPTX/PPTLibrary/PPTBuilder/PPTPresenationBuilder.cs

@@ -0,0 +1,261 @@
+using System;
+using System.IO;
+using System.Collections.Generic;
+using ClearSlideLibrary.Dom;
+using DocumentFormat.OpenXml.Packaging;
+using DocumentFormat.OpenXml.Presentation;
+using Path = System.IO.Path;
+using Shape = DocumentFormat.OpenXml.Presentation.Shape;
+using System.Linq;
+using System.Text;
+using System.Xml;
+using System.Xml.Linq;
+using DocumentFormat.OpenXml.Drawing;
+using DocumentFormat.OpenXml;
+
+
+namespace ClearSlideLibrary.PPTBuilder
+{
+    
+    public class PPTPresenationBuilder
+    {
+        public SlideSize SlideSizes { get; set; }
+
+        public int getSlideWidth()
+        {
+            if (SlideSizes == null || SlideSizes.Cx == 0)
+            {
+                return 1;
+            }
+            else if (SlideSizes.Cx < Globals.LEAST_COMMON_MULTIPLE_100_254)
+            {
+                return Convert.ToInt32((double)(Globals.LEAST_COMMON_MULTIPLE_100_254) / SlideSizes.Cx);
+            }
+            else
+            {
+                return Convert.ToInt32(SlideSizes.Cx / (double)(Globals.LEAST_COMMON_MULTIPLE_100_254));
+            }
+        }
+
+        public int getSlideHeight()
+        {
+            if (SlideSizes == null || SlideSizes.Cy == 0)
+            {
+                return 1;
+            }
+            else if (SlideSizes.Cy < Globals.LEAST_COMMON_MULTIPLE_100_254)
+            {
+                return Convert.ToInt32((double)(Globals.LEAST_COMMON_MULTIPLE_100_254) / SlideSizes.Cy);
+            }
+            else
+            {
+                return Convert.ToInt32(SlideSizes.Cy / (double)(Globals.LEAST_COMMON_MULTIPLE_100_254));
+            }
+        }
+
+
+        public List<PPTSlide> GetPPTSlides(string pathToPresentation)
+        {
+            string fileFromPath = Path.GetFileName(pathToPresentation);
+            var inf = new FileInfo(fileFromPath);
+            string fileName = Path.GetFileNameWithoutExtension(inf.Name);
+
+            string dir = Path.GetDirectoryName(Path.GetDirectoryName(Environment.CurrentDirectory));
+            string destDir = Path.Combine(dir, Globals.STORAGE_DIR);
+
+            PresentationDocument presentationDocument = null;
+            try
+            {
+                presentationDocument = PresentationDocument.Open(pathToPresentation, false);
+                //get the slide sizes.
+                Presentation presentation = presentationDocument.PresentationPart.Presentation;
+                SlideSizes = presentation.SlideSize;
+
+            }
+            catch (Exception ex)
+            {
+                throw new FileNotFoundException(
+                    "PPTPresenationController.Ctor Unable to open Power Point Presentation.Path - "
+                    + pathToPresentation, ex.InnerException);
+            }
+            if (presentationDocument == null)
+            {
+                throw new ArgumentNullException("Presentation Document missing");
+            }
+            IEnumerable<SlidePart> slideParts = GetPresentationSlideParts(presentationDocument);
+            preserveWhitespaces(slideParts);//bug fix; whitespaces in separate runs are not preserved
+
+            List<PPTSlide> pptSlides = GetPPTSlidesFromParts(slideParts, presentationDocument.PresentationPart.Presentation.DefaultTextStyle, fileName);
+            presentationDocument.Close();
+            List<PPTImage> pictures=new List<PPTImage>();
+            foreach (PPTSlide slide in pptSlides)
+                foreach (PPTShapeBase baseShape in slide.ContainerShape.Elements)
+                    if (typeof(PPTImage).Equals(baseShape.GetType()))
+                        pictures.Add((PPTImage)baseShape);
+
+            
+
+
+            //var pptInteropt = new PPTBackgroundBuilderInterop(pathToPresentation, pictures);
+            //pptInteropt.ExportPresentationImages(destDir);
+            //pptInteropt = null;
+            //GC.Collect();
+
+         
+
+            return pptSlides;
+        }
+
+        private IEnumerable<SlidePart> GetPresentationSlideParts(PresentationDocument presentationDocument)
+        {
+            var slideParts = new List<SlidePart>();
+
+            PresentationPart presentationPart = presentationDocument.PresentationPart;
+            if (presentationPart != null && presentationPart.Presentation != null)
+            {
+                Presentation presentation = presentationPart.Presentation;
+
+                if (presentation.SlideIdList != null)
+                {
+                    foreach (var slideId in presentation.SlideIdList.Elements<SlideId>())
+                    {
+                        try
+                        {
+                            slideParts.Add((SlidePart)presentationPart.GetPartById(slideId.RelationshipId));
+                        }
+                        catch (Exception ex)
+                        {
+                            throw new ArgumentNullException("Unable to add slide part." + ex.InnerException);
+                        }
+                    }
+                }
+            }
+
+            return slideParts;
+        }
+
+        private List<PPTSlide> GetPPTSlidesFromParts(IEnumerable<SlidePart> slideParts, DefaultTextStyle defaultTextStyle, string fileName)
+        {
+            var pptSlides = new List<PPTSlide>();
+            int slideIndex = 1;
+
+            foreach (SlidePart slidePart in slideParts)
+            {
+                if (slideIndex > 1 && slidePart.Slide.Transition!=null && slidePart.Slide.Transition.AdvanceAfterTime!=null)
+                {
+                    pptSlides[pptSlides.Count - 1].advanceAfterTime = int.Parse(slidePart.Slide.Transition.AdvanceAfterTime.Value);
+                }
+                var pptSlide = new PPTSlide(slidePart, slideIndex++, defaultTextStyle, fileName, SlideSizes);
+                
+                pptSlides.Add(pptSlide);
+            }
+
+            return pptSlides;
+        }
+        private void preserveWhitespaces(IEnumerable<SlidePart> slideParts)
+        {
+            Dictionary<String, String> xTraverseMap = xTraverse(slideParts);
+            openXmlTraverse(slideParts, xTraverseMap);
+        }
+
+        private Dictionary<String, String> xTraverse(IEnumerable<SlidePart> slideParts)
+        {
+            Dictionary<String, String> result = new Dictionary<string, string>();
+
+            XNamespace p = "http://schemas.openxmlformats.org/presentationml/2006/main";
+            XNamespace a = "http://schemas.openxmlformats.org/drawingml/2006/main";
+            int slideNumber = 0;
+            foreach (SlidePart slidePart in slideParts)
+            {
+                XDocument slideXDoc = slidePart.GetXDocument();
+                IEnumerable<XElement> shapes = slideXDoc.Root.Element(p + "cSld").Element(p + "spTree").Elements(p + "sp");
+                int shapeNumber = 0;
+                foreach (XElement shape in shapes)
+                {
+                    IEnumerable<XElement> paragraphs = shape.Element(p + "txBody").Elements(a + "p");
+                    int paragraphNumber = 0;
+                    foreach (XElement paragraph in paragraphs)
+                    {
+                        IEnumerable<XElement> runs = paragraph.Elements(a + "r");
+
+                        int runNumber = 0;
+                        foreach (XElement run in runs)
+                        {
+                            string value = run.Element(a + "t").Value;
+                            if (value.Trim() == "" || value.Trim() == "/t")
+                            {
+                                result.Add(
+                                    slideNumber + "_" + shapeNumber + "_" + paragraphNumber + "_" + runNumber, value);
+                            }
+
+                            runNumber++;
+                        }
+                        paragraphNumber++;
+                    }
+                    shapeNumber++;
+                }
+                slideNumber++;
+            }
+            return result;
+        }
+
+        private void openXmlTraverse(IEnumerable<SlidePart> slideParts, Dictionary<String, String> xTraverseMap)
+        {
+            int slideNumber = 0;
+            foreach (SlidePart slidePart in slideParts)
+            {
+                int shapeNumber = 0;
+                foreach (Shape shape in slidePart.Slide.Descendants<Shape>())
+                {
+                    int paragraphNumber = 0;
+                    foreach (Paragraph paragraph in shape.Descendants<Paragraph>())
+                    {
+                        int runNumber = 0;
+                        foreach (Run run in paragraph.Descendants<Run>())
+                        {
+                            string txt = run.Text.Text;
+                            string key = slideNumber + "_" + shapeNumber + "_" + paragraphNumber + "_" + runNumber;
+                            string val;
+                            if (txt == "" && xTraverseMap.TryGetValue(key, out val))
+                            {
+                                run.Text.Text = val;
+                            }
+                            runNumber++;
+                        }
+                        paragraphNumber++;
+                    }
+                    shapeNumber++;
+                }
+                slideNumber++;
+            }
+        }
+    }
+
+    public static class PtOpenXmlExtensions
+    {
+        public static XDocument GetXDocument(this OpenXmlPart part)
+        {
+
+            XDocument partXDocument = part.Annotation<XDocument>();
+            if (partXDocument != null)
+                return partXDocument;
+            using (Stream partStream = part.GetStream())
+            using (XmlReader partXmlReader = XmlReader.Create(partStream))
+                partXDocument = XDocument.Load(partXmlReader);
+            part.AddAnnotation(partXDocument);
+            return partXDocument;
+        }
+
+        public static void PutXDocument(this OpenXmlPart part)
+        {
+            XDocument partXDocument = part.GetXDocument();
+            if (partXDocument != null)
+            {
+                using (Stream partStream = part.GetStream(FileMode.Create, FileAccess.Write))
+                using (XmlWriter partXmlWriter = XmlWriter.Create(partStream))
+                    partXDocument.Save(partXmlWriter);
+            }
+        }
+    }
+
+}

+ 16 - 0
TEAMModelOS.Test.PPTX/PPTLibrary/PPTBuilder/PPTShapeBuilder.cs

@@ -0,0 +1,16 @@
+using System.Linq;
+using ClearSlideLibrary.Dom;
+using DocumentFormat.OpenXml.Packaging;
+using System.Collections.Generic;
+using DocumentFormat.OpenXml.Presentation;
+
+namespace ClearSlideLibrary.PPTBuilder
+{
+    internal class PPTShapeBuilder
+    {
+        internal List<PPTShape> GetShapes(SlidePart slidePart, PPTSlide slide)
+        {
+            return slidePart.Slide.Descendants<Shape>().Select(shape => new PPTShape(slidePart, shape, slide)).ToList();
+        }
+    }
+}

+ 240 - 0
TEAMModelOS.Test.PPTX/PPTXConvert.cs

@@ -0,0 +1,240 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using DocumentFormat.OpenXml.Packaging;
+using DocumentFormat.OpenXml.Presentation;
+using D = DocumentFormat.OpenXml.Drawing;
+using System.IO.Packaging;
+using System.IO;
+using TEAMModelOS.SDK.Helper.Common.JsonHelper;
+using ClearSlideLibrary.Dom;
+using OpenXmlPowerTools;
+using System.Drawing;
+using DocumentFormat.OpenXml.Office2010.Drawing;
+
+namespace TEAMModelOS.Test.PPTX
+{
+    public class PPTXConvert
+    {
+        public static void GetSlideTitles(string presentationFile, string store)
+        {
+            // Open the presentation as read-only.
+            using (PresentationDocument presentationDocument =
+                PresentationDocument.Open(presentationFile, false))
+            {
+                GetSlideTitles(presentationDocument, store);
+            }
+        }
+        public static void GetSlideTitles(PresentationDocument presentationDocument, string store)
+        {
+            if (presentationDocument == null)
+            {
+                throw new ArgumentNullException("presentationDocument");
+            }
+
+            // Get a PresentationPart object from the PresentationDocument object.
+            PresentationPart presentationPart = presentationDocument.PresentationPart;
+
+            if (presentationPart != null &&
+                presentationPart.Presentation != null)
+            {
+                // Get a Presentation object from the PresentationPart object.
+                Presentation presentation = presentationPart.Presentation;
+
+                if (presentation.SlideIdList != null)
+                {
+
+
+                    // Get the title of each slide in the slide order.
+                    foreach (var slideId in presentation.SlideIdList.Elements<SlideId>())
+                    {
+                        Console.WriteLine(slideId.Id + "");
+                        SlidePart slidePart = presentationPart.GetPartById(slideId.RelationshipId) as SlidePart;
+
+                        // Get the slide title.
+                        GetSlide(slidePart, store);
+
+                        // An empty title can also be added.
+
+                    }
+
+                }
+
+            }
+
+        }
+
+        // Get the title string of the slide.
+        public static void GetSlide(SlidePart slidePart, string store)
+        {
+            if (slidePart == null)
+            {
+                throw new ArgumentNullException("presentationDocument");
+            }
+
+            // Declare a paragraph separator.
+            string titleSeparator = null;
+
+            if (slidePart.Slide != null)
+            {
+                // 获取有文本内容的元素
+                var textsShapes = from shape in slidePart.Slide.Descendants<Shape>()  select shape;
+                // 获取公式
+                var textMaths = from shape in slidePart.Slide.Descendants<TextMath>() select shape.Parent.Parent;
+                // 获取图片的元素
+                var pictures = from shape in slidePart.Slide.Descendants<Picture>() select shape;
+                //获取预设的几何模型 
+                var presetGeometry = from shape in slidePart.Slide.Descendants<DocumentFormat.OpenXml.Drawing.PresetGeometry>()where string.IsNullOrEmpty(shape.Parent.Parent.InnerText.Trim()) select shape.Parent.Parent;
+                List<string> a = new List<string>();
+                foreach (var s in pictures)
+                {
+                    BlipFill blipFill = s.BlipFill;
+                    var imageRid = blipFill.Blip.Embed.Value;
+                    
+                    IdPartPair idParie = slidePart.Parts.Where(x => x.RelationshipId == imageRid).FirstOrDefault();
+                    ImagePart imagePart = (ImagePart)idParie.OpenXmlPart;
+                    var contentType = imagePart.ContentType;
+                    using (var stream = imagePart.GetStream())
+                    {
+                        byte[] buffer = new byte[stream.Length];
+                        stream.Read(buffer, 0, buffer.Length);
+                        stream.Close();
+                        string base64 = System.Convert.ToBase64String(buffer);
+                        base64 = "data:" + contentType + ";base64," + base64;
+                        a.Add(base64);
+                    }
+                }
+
+                StringBuilder titleText = new StringBuilder();
+                int index = 1;
+                List<PPTElement> pptShapes = new List<PPTElement>();
+                foreach (var shape in pictures)
+                {
+                    Console.WriteLine(index++);
+                    ShapeProperties properties = shape.ShapeProperties;
+                    PPTElement pptShape = null;
+                    if (properties != null && properties.Transform2D != null)
+                    {
+                        pptShape = new PPTElement
+                        {
+                            offx = properties.Transform2D.Offset.X,
+                            offy = properties.Transform2D.Offset.Y,
+                            extx = properties.Transform2D.Extents.Cx,
+                            exty = properties.Transform2D.Extents.Cy,
+                        };
+                    }
+                    Console.WriteLine(shape.CloneNode(false).XName.LocalName);
+                    //   pptShape.text = shape.TextBody;
+                    pptShapes.Add(pptShape);
+                }
+
+
+
+                foreach (var shape in textsShapes)
+                {
+                    // Get the text in each paragraph in this shape.
+                    foreach (var paragraph in shape.TextBody.Descendants<D.Paragraph>())
+                    {
+                        // Add a line break.
+                        titleText.Append(titleSeparator);
+
+                        foreach (var text in paragraph.Descendants<D.Text>())
+                        {
+                            titleText.Append(text.Text);
+                        }
+
+                        titleSeparator = "\n";
+                    }
+                }
+                if (titleText.Length == 0)
+                    return;
+                LinkedList<string> texts = new LinkedList<string>();
+
+                foreach (var paragraph in slidePart.Slide.Descendants<D.Paragraph>())
+                {
+                    StringBuilder allText = new StringBuilder();
+                    foreach (var text in paragraph.Descendants<D.Text>())
+                    {
+                        allText.Append(text.Text);
+                    }
+                    if (allText.Length > 0)
+                    {
+                        if (allText.ToString() == titleText.ToString()) ;
+                        else texts.AddLast(allText.ToString());
+                    }
+                }
+                if (texts.Count > 0)
+                {
+                    System.IO.StreamWriter file = new System.IO.StreamWriter(store, true);
+
+                    file.Write("{\"Title\":\"" + titleText.ToString() + "\",");
+                    file.Write("\"Content\":\"");
+                    string inter = "";
+                    foreach (var text in texts)
+                    {
+                        file.Write(inter + text);
+                        inter = ",";
+                    }
+                    file.WriteLine("\"}");
+                    file.Close();
+                }
+
+            }
+
+            return;
+        }
+
+        // Determines whether the shape is a title shape.
+        private static bool IsTitleShape(Shape shape)
+        {
+            var placeholderShape = shape.NonVisualShapeProperties.ApplicationNonVisualDrawingProperties.GetFirstChild<PlaceholderShape>();
+            if (placeholderShape != null && placeholderShape.Type != null && placeholderShape.Type.HasValue)
+            {
+                switch ((PlaceholderValues)placeholderShape.Type)
+                {
+                    // Any title shape.
+                    case PlaceholderValues.Title:
+                        return true;
+                    // A centered title.
+                    case PlaceholderValues.CenteredTitle:
+                        return true;
+
+                    default:
+                        return false;
+                }
+            }
+            return false;
+        }
+        public static void FixPowerpoint(string fileName)
+        {
+            //Opening the package associated with file
+            Console.WriteLine(fileName);
+            using (Package wdPackage = Package.Open(fileName, FileMode.Open, FileAccess.ReadWrite))
+            {
+                //Uri of the printer settings part
+                var binPartUri = new Uri("/ppt/printerSettings/printerSettings1.bin", UriKind.Relative);
+                if (wdPackage.PartExists(binPartUri))
+                {
+                    //Uri of the presentation part which contains the relationship
+                    var presPartUri = new Uri("/ppt/presentation.xml", UriKind.RelativeOrAbsolute);
+                    var presPart = wdPackage.GetPart(presPartUri);
+                    //Getting the relationship from the URI
+                    var presentationPartRels =
+                        presPart.GetRelationships().Where(a => a.RelationshipType.Equals("http://schemas.openxmlformats.org/officeDocument/2006/relationships/printerSettings",
+                            StringComparison.InvariantCultureIgnoreCase)).SingleOrDefault();
+                    if (presentationPartRels != null)
+                    {
+                        //Delete the relationship
+                        presPart.DeleteRelationship(presentationPartRels.Id);
+                    }
+
+                    //Delete the part
+                    wdPackage.DeletePart(binPartUri);
+                }
+                wdPackage.Close();
+            }
+        }
+    }
+}

+ 679 - 0
TEAMModelOS.Test.PPTX/PPTXConvertNew.cs

@@ -0,0 +1,679 @@
+using DocumentFormat.OpenXml;
+using DocumentFormat.OpenXml.Office2010.Drawing;
+using DocumentFormat.OpenXml.Packaging;
+using DocumentFormat.OpenXml.Presentation;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Text.RegularExpressions;
+using System.Xml;
+using System.Xml.Linq;
+using System.Xml.Xsl;
+using TEAMModelOS.SDK.Helper.Common.JsonHelper;
+using ColorMap = DocumentFormat.OpenXml.Presentation.ColorMap;
+using Theme = DocumentFormat.OpenXml.Drawing.Theme;
+
+namespace TEAMModelOS.Test.PPTX
+{
+    public class PPTXConvertNew
+    {
+        public static void GetSlideTitles(string presentationFile) {
+            using (PresentationDocument presentationDocument =
+                PresentationDocument.Open(presentationFile, false))
+            {
+                if (presentationDocument == null)
+                {
+                    throw new ArgumentNullException("presentationDocument");
+                }
+
+                // Get a PresentationPart object from the PresentationDocument object.
+                PresentationPart presentationPart = presentationDocument.PresentationPart;
+               
+                
+                if (presentationPart != null &&
+                    presentationPart.Presentation != null)
+                {
+
+
+                    var slideMasterParts = presentationPart.SlideMasterParts;
+
+                    ColorMap colorMap = null;
+                    Theme theme = null;
+                    foreach (var slideMasterPart in slideMasterParts)
+                    {
+                        if (colorMap != null && theme != null)
+                        {
+                            break;
+                        }
+                        colorMap = slideMasterPart.SlideMaster.ColorMap;
+                        theme = slideMasterPart.ThemePart.Theme;
+                    }
+
+                    // Get a Presentation object from the PresentationPart object.
+                    Presentation presentation = presentationPart.Presentation;
+                    if (presentation.SlideIdList != null)
+                    {
+                        //获取PPT 一页大小
+                        int x=  presentation.SlideSize.Cx;
+                        int y = presentation.SlideSize.Cy;
+                        // Get the title of each slide in the slide order.
+                        // 获取的是几页PPT数量
+                        foreach (var slideId in presentation.SlideIdList.Elements<SlideId>())
+                        {
+                            // 获取这一页 PPT 的id 
+                            string id = slideId.RelationshipId;
+                            SlidePart slidePart = presentationPart.GetPartById(slideId.RelationshipId) as SlidePart;
+                            
+                            //获取当前页 PPT 的所有元素
+                            GetSlideElement(slidePart  , theme , colorMap);
+                        }
+
+                    }
+
+                }
+            }
+        }
+
+        public static Object GetSlideElement(SlidePart slidePart , Theme theme , ColorMap colorMap)
+        {
+            double inchpixel = 96.0, inchpt = 72.0,pxBase=914400.0 , rotBase = 60000;
+            double pxConvert = inchpixel / pxBase;
+            if (slidePart == null)
+            {
+                throw new ArgumentNullException("presentationDocument");
+            }
+
+            
+           // var  aaa= from shape in presentationPart.SlideMasterParts.Descendants<ColorMap>() select shape;  
+          var shaps = from shape in slidePart.Slide.Descendants<Shape>() select shape;
+
+            List<string> repeatElement = new List<string>();
+
+            var elements = from shape in slidePart.Slide  select shape;
+            List<PPTElement> pptElements = new List<PPTElement>();
+            var pictures =    from shap  in elements.FirstOrDefault().Descendants<Picture>() select shap;
+            var textMaths = from shap in elements.FirstOrDefault().Descendants<TextMath>() select shap;
+            foreach (var math in textMaths) {
+                string type = "math";
+                var mathShape = (Shape) math.Parent.Parent.Parent;
+                string textColor = "",fillColor="";
+
+                var rgbColor = from shape in mathShape.TextBody.Descendants<DocumentFormat.OpenXml.Drawing.RgbColorModelHex>() select shape;
+                if (rgbColor != null && rgbColor.Count() > 0) {
+                    textColor = rgbColor.FirstOrDefault().Val;
+                }
+                fillColor = ShapForColor(mathShape, "Fill", theme);
+                if (string.IsNullOrEmpty(textColor)) {
+                    textColor = ShapForColor(mathShape, "Font", theme);
+                }
+                repeatElement.Add(mathShape.OuterXml);
+                string elementData = ProcessOMath(math.InnerXml);
+                ShapeProperties properties =  mathShape.ShapeProperties;
+
+                if (string.IsNullOrEmpty(fillColor)) {
+                    var solidFills = from shape in properties.Descendants<DocumentFormat.OpenXml.Drawing.SolidFill>() select shape;
+                    if (solidFills != null && solidFills.Count() > 0)
+                    {
+                        var propRgbColor = from shape in solidFills.First().Descendants<DocumentFormat.OpenXml.Drawing.RgbColorModelHex>() select shape;
+                        if (propRgbColor != null && propRgbColor.Count() > 0)
+                        {
+                            fillColor = propRgbColor.FirstOrDefault().Val;
+                        }
+                        if (string.IsNullOrEmpty(fillColor))
+                        {
+                            var colorScheme = from shape in solidFills.First().Descendants<DocumentFormat.OpenXml.Drawing.SchemeColor>() select shape;
+                            if (colorScheme.Count() > 0) {
+                                fillColor = ColorForThemeClr(SchemeColorForColorMap(colorScheme.FirstOrDefault().Val.Value, colorMap), theme);
+                            }
+                        }
+                    }
+                }
+               
+                PPTElement element = new PPTElement() { type = type };
+                if (properties != null && properties.Transform2D != null)
+                {
+                    element.offx = properties.Transform2D.Offset.X;
+                    element.offy = properties.Transform2D.Offset.Y;
+                    element.extx = properties.Transform2D.Extents.Cx;
+                    element.exty = properties.Transform2D.Extents.Cy;
+                    element.flipH = properties.Transform2D.HorizontalFlip != null ? BooleanValue.ToBoolean(properties.Transform2D.HorizontalFlip) : false;
+                    element.flipV = properties.Transform2D.VerticalFlip != null ? BooleanValue.ToBoolean(properties.Transform2D.VerticalFlip) : false;
+                    element.rot = properties.Transform2D.Rotation != null ? properties.Transform2D.Rotation.Value : 0;
+                }
+                element.text = elementData;
+                element.fillColor = fillColor;
+                element.textColor = textColor;
+                pptElements.Add(element);
+            }
+
+            foreach (var picture in pictures) {
+                BlipFill blipFill = picture.BlipFill;
+                var imageRid = blipFill.Blip.Embed.Value;
+                string type = "picture";
+                IdPartPair idParie = slidePart.Parts.Where(x => x.RelationshipId == imageRid).FirstOrDefault();
+                ImagePart imagePart = (ImagePart)idParie.OpenXmlPart;
+                var contentType = imagePart.ContentType;
+                string base64 = "";
+                using (var stream = imagePart.GetStream())
+                {
+                    byte[] buffer = new byte[stream.Length];
+                    stream.Read(buffer, 0, buffer.Length);
+                    stream.Close();
+                    base64 = System.Convert.ToBase64String(buffer);
+                    base64 = "data:" + contentType + ";base64," + base64;
+                }
+                ShapeProperties properties = picture.ShapeProperties;
+                PPTElement element = new PPTElement() { type = type };
+                if (properties != null && properties.Transform2D != null)
+                {
+                    element.offx = properties.Transform2D.Offset.X;
+                    element.offy = properties.Transform2D.Offset.Y;
+                    element.extx = properties.Transform2D.Extents.Cx;
+                    element.exty = properties.Transform2D.Extents.Cy;
+                    element.flipH = properties.Transform2D.HorizontalFlip != null ? BooleanValue.ToBoolean(properties.Transform2D.HorizontalFlip) : false;
+                    element.flipV = properties.Transform2D.VerticalFlip != null ? BooleanValue.ToBoolean(properties.Transform2D.VerticalFlip) : false;
+                    element.rot = properties.Transform2D.Rotation != null ? properties.Transform2D.Rotation.Value : 0;
+                }
+                element.text = base64;
+                pptElements.Add(element);
+            }
+            List<Shape> shapes = shaps.ToList();
+
+            for (int  i= 0; i< shapes.Count;i++ ) {
+                if (shapes[i].Parent.OuterXml.StartsWith("<mc:Fallback")) {
+                    shapes.RemoveAt(i);
+                }
+            }
+            for (int i = 0; i < shapes.Count; i++)
+            {
+                foreach (string enm in repeatElement)
+                {
+                    if (enm.Equals(shapes[i].OuterXml))
+                    {
+                        shapes.RemoveAt(i);
+                    }
+                }
+            }
+            //  获取文本框 和 图形(形状)
+            foreach (Shape shapeIn in shapes) {
+                ShapeProperties properties = shapeIn.ShapeProperties;
+                var presetGeometrys = from shap in properties.Descendants<DocumentFormat.OpenXml.Drawing.PresetGeometry>() select shap;
+                string type = "text";
+                bool complete = false;
+                if (presetGeometrys.Count() > 0)
+                {
+                    DocumentFormat.OpenXml.Drawing.PresetGeometry presetGeometry = presetGeometrys.FirstOrDefault();
+                    type = presetGeometry.Preset;
+                }
+                PPTElement element = new PPTElement() { type = type };
+                if (properties != null && properties.Transform2D != null) {
+                    complete = true;
+                    element.offx = properties.Transform2D.Offset.X;
+                    element.offy = properties.Transform2D.Offset.Y;
+                    element.extx = properties.Transform2D.Extents.Cx;
+                    element.exty = properties.Transform2D.Extents.Cy;
+                    element.flipH = properties.Transform2D.HorizontalFlip != null ? BooleanValue.ToBoolean(properties.Transform2D.HorizontalFlip) : false;
+                    element.flipV = properties.Transform2D.VerticalFlip != null ? BooleanValue.ToBoolean(properties.Transform2D.VerticalFlip) : false;
+                    element.rot = properties.Transform2D.Rotation != null ? properties.Transform2D.Rotation.Value : 0;
+                }
+                // Console.WriteLine(colorMap.);
+
+                string textColor = "", fillColor = "";
+
+                var runs = from shap in shapeIn.Descendants<DocumentFormat.OpenXml.Drawing.Run>() select shap;
+                foreach (var run in runs) {
+                    var runprps = from shap in run.Descendants<DocumentFormat.OpenXml.Drawing.RunProperties>() select shap;
+                    var schemeColor = from shap in run.Descendants<DocumentFormat.OpenXml.Drawing.SchemeColor>() select shap;
+                    if (string.IsNullOrEmpty(textColor)) {
+                        if (schemeColor != null && schemeColor.Count() > 0)
+                        {
+                            foreach (var sc in schemeColor)
+                            {
+                                DocumentFormat.OpenXml.Drawing.SchemeColorValues schemeColorValues = sc.Val.Value;
+                                //颜色寻找
+                                textColor = ColorForThemeClr(SchemeColorForColorMap(schemeColorValues, colorMap), theme);
+                            }
+                        }
+                    }
+                    DocumentFormat.OpenXml.Drawing.RunProperties runProperties = runprps.FirstOrDefault();
+                    element.text = element.text + run.Text.InnerText;
+                }
+
+                var rgbColor = from shape in shapeIn.TextBody.Descendants<DocumentFormat.OpenXml.Drawing.RgbColorModelHex>() select shape;
+                if (string.IsNullOrEmpty(textColor) && rgbColor != null && rgbColor.Count() > 0)
+                {
+                    textColor = rgbColor.FirstOrDefault().Val;
+                }
+
+                if (string.IsNullOrEmpty(textColor)) {
+                    textColor = ShapForColor(shapeIn, "Font", theme);
+                }
+                //if (element.text.Equals("33333"))
+                //{
+                //    fillColor = ShapForColor(shapeIn, "Fill", theme);
+
+                //}
+
+                fillColor= ShapForColor(shapeIn, "Fill", theme);
+                if (string.IsNullOrEmpty(fillColor)) {
+                    var solidFills = from shape in properties.Descendants<DocumentFormat.OpenXml.Drawing.SolidFill>() select shape;
+                    if (solidFills != null && solidFills.Count() > 0)
+                    {
+                        var propRgbColor = from shape in solidFills.First().Descendants<DocumentFormat.OpenXml.Drawing.RgbColorModelHex>() select shape;
+                        if (propRgbColor != null && propRgbColor.Count() > 0)
+                        {
+                            fillColor = propRgbColor.FirstOrDefault().Val;
+                        }
+                        if (string.IsNullOrEmpty(fillColor))
+                        {
+                            var colorScheme = from shape in solidFills.First().Descendants<DocumentFormat.OpenXml.Drawing.SchemeColor>() select shape;
+                            if (colorScheme.Count() > 0)
+                            {
+                                fillColor = ColorForThemeClr(SchemeColorForColorMap(colorScheme.FirstOrDefault().Val.Value, colorMap), theme);
+                            }
+                        }
+                    }
+                }
+                element.textColor = textColor;
+                element.fillColor = fillColor;
+
+                var custGeometrys = from shap in properties.Descendants<DocumentFormat.OpenXml.Drawing.CustomGeometry>() select shap;
+                if (custGeometrys.Count() > 0) {
+                    var pathLists = from shap in custGeometrys.First().Descendants<DocumentFormat.OpenXml.Drawing.Path>() select shap;
+                    if (pathLists.Count() > 0) {
+                        var moveTos= pathLists.First().ChildElements.OfType<DocumentFormat.OpenXml.Drawing.MoveTo>();
+                        var lineTos = pathLists.First().ChildElements.OfType<DocumentFormat.OpenXml.Drawing.LineTo>();
+                        var BezierTos = pathLists.First().ChildElements.OfType<DocumentFormat.OpenXml.Drawing.CubicBezierCurveTo>();
+                        
+                    }
+                }
+                if (complete) {
+                    pptElements.Add(element);
+                }
+                //  element.text = shapeIn.InnerText;
+            }
+            return pptElements; 
+        }
+
+
+        public static   string ShapForColor(Shape shape , string colorType ,Theme theme) {
+            if (shape.ShapeStyle == null)
+            {
+                return "";
+            }
+
+            DocumentFormat.OpenXml.Presentation.ShapeStyle shapeStyle = shape.ShapeStyle;
+            if (shapeStyle == null)
+            {
+                return "";
+            }
+            if (colorType.Equals("Effect")) {
+                DocumentFormat.OpenXml.Drawing.SchemeColor EffectcolorScheme = shapeStyle.EffectReference.ChildElements.First<DocumentFormat.OpenXml.Drawing.SchemeColor>();
+              return  ColorForThemeClr(EffectcolorScheme.Val, theme);
+            }
+            if (colorType.Equals("Line"))
+            {
+                DocumentFormat.OpenXml.Drawing.SchemeColor LinecolorScheme = shapeStyle.LineReference.ChildElements.First<DocumentFormat.OpenXml.Drawing.SchemeColor>();
+                return ColorForThemeClr(LinecolorScheme.Val, theme);
+            }
+            if (colorType.Equals("Fill"))
+            {
+                DocumentFormat.OpenXml.Drawing.SchemeColor FillcolorScheme = shapeStyle.FillReference.ChildElements.First<DocumentFormat.OpenXml.Drawing.SchemeColor>();
+                return ColorForThemeClr(FillcolorScheme.Val, theme);
+            }
+            if (colorType.Equals("Font"))
+            {
+                DocumentFormat.OpenXml.Drawing.SchemeColor FontcolorScheme = shapeStyle.FontReference.ChildElements.First<DocumentFormat.OpenXml.Drawing.SchemeColor>();
+                return ColorForThemeClr(FontcolorScheme.Val, theme);
+            }
+            return "";
+        }
+
+        public static string ColorForThemeClr(string scv, Theme theme) {
+            DocumentFormat.OpenXml.Drawing.ColorScheme colorScheme =  theme.ThemeElements.ColorScheme;
+            string colorStr = "";
+            if (scv.Equals("dk1"))
+            {
+                DocumentFormat.OpenXml.Drawing.SystemColor sysColor= colorScheme.Dark1Color.ChildElements.First<DocumentFormat.OpenXml.Drawing.SystemColor>();
+                if (sysColor != null) {
+                  return  colorStr = sysColor.LastColor;
+                }
+                DocumentFormat.OpenXml.Drawing.RgbColorModelHex rgbColor = colorScheme.Dark1Color.ChildElements.First<DocumentFormat.OpenXml.Drawing.RgbColorModelHex>();
+                if (rgbColor != null)
+                {
+                   return colorStr = rgbColor.Val;
+                }
+                return colorStr;
+            }
+            if (scv.Equals("dk2"))
+            {
+                DocumentFormat.OpenXml.Drawing.SystemColor sysColor = colorScheme.Dark2Color.ChildElements.First<DocumentFormat.OpenXml.Drawing.SystemColor>();
+                if (sysColor != null)
+                {
+                    return colorStr = sysColor.LastColor;
+                }
+                DocumentFormat.OpenXml.Drawing.RgbColorModelHex rgbColor = colorScheme.Dark2Color.ChildElements.First<DocumentFormat.OpenXml.Drawing.RgbColorModelHex>();
+                if (rgbColor != null)
+                {
+                    return colorStr = rgbColor.Val;
+                }
+                return colorStr;
+            }
+            else if (scv.Equals("accent1"))
+            {
+                DocumentFormat.OpenXml.Drawing.SystemColor sysColor = colorScheme.Accent1Color.ChildElements.First<DocumentFormat.OpenXml.Drawing.SystemColor>();
+                if (sysColor != null)
+                {
+                    return colorStr = sysColor.LastColor;
+                }
+                DocumentFormat.OpenXml.Drawing.RgbColorModelHex rgbColor = colorScheme.Accent1Color.ChildElements.First<DocumentFormat.OpenXml.Drawing.RgbColorModelHex>();
+                if (rgbColor != null)
+                {
+                    return colorStr = rgbColor.Val;
+                }
+                return colorStr;
+            }
+            else if (scv.Equals("accent2"))
+            {
+                DocumentFormat.OpenXml.Drawing.SystemColor sysColor = colorScheme.Accent2Color.ChildElements.First<DocumentFormat.OpenXml.Drawing.SystemColor>();
+                if (sysColor != null)
+                {
+                    return colorStr = sysColor.LastColor;
+                }
+                DocumentFormat.OpenXml.Drawing.RgbColorModelHex rgbColor = colorScheme.Accent2Color.ChildElements.First<DocumentFormat.OpenXml.Drawing.RgbColorModelHex>();
+                if (rgbColor != null)
+                {
+                    return colorStr = rgbColor.Val;
+                }
+                return colorStr;
+            }
+            else if (scv.Equals("accent3"))
+            {
+                DocumentFormat.OpenXml.Drawing.SystemColor sysColor = colorScheme.Accent3Color.ChildElements.First<DocumentFormat.OpenXml.Drawing.SystemColor>();
+                if (sysColor != null)
+                {
+                    return colorStr = sysColor.LastColor;
+                }
+                DocumentFormat.OpenXml.Drawing.RgbColorModelHex rgbColor = colorScheme.Accent3Color.ChildElements.First<DocumentFormat.OpenXml.Drawing.RgbColorModelHex>();
+                if (rgbColor != null)
+                {
+                    return colorStr = rgbColor.Val;
+                }
+                return colorStr;
+            }
+            else if (scv.Equals("accent4"))
+            {
+                DocumentFormat.OpenXml.Drawing.SystemColor sysColor = colorScheme.Accent4Color.ChildElements.First<DocumentFormat.OpenXml.Drawing.SystemColor>();
+                if (sysColor != null)
+                {
+                    return colorStr = sysColor.LastColor;
+                }
+                DocumentFormat.OpenXml.Drawing.RgbColorModelHex rgbColor = colorScheme.Accent4Color.ChildElements.First<DocumentFormat.OpenXml.Drawing.RgbColorModelHex>();
+                if (rgbColor != null)
+                {
+                    return colorStr = rgbColor.Val;
+                }
+                return colorStr;
+            }
+            else if (scv.Equals("accent5"))
+            {
+                DocumentFormat.OpenXml.Drawing.SystemColor sysColor = colorScheme.Accent5Color.ChildElements.First<DocumentFormat.OpenXml.Drawing.SystemColor>();
+                if (sysColor != null)
+                {
+                    return colorStr = sysColor.LastColor;
+                }
+                DocumentFormat.OpenXml.Drawing.RgbColorModelHex rgbColor = colorScheme.Accent5Color.ChildElements.First<DocumentFormat.OpenXml.Drawing.RgbColorModelHex>();
+                if (rgbColor != null)
+                {
+                    return colorStr = rgbColor.Val;
+                }
+                return colorStr;
+            }
+            else if (scv.Equals("accent6"))
+            {
+                DocumentFormat.OpenXml.Drawing.SystemColor sysColor = colorScheme.Accent6Color.ChildElements.First<DocumentFormat.OpenXml.Drawing.SystemColor>();
+                if (sysColor != null)
+                {
+                    return colorStr = sysColor.LastColor;
+                }
+                DocumentFormat.OpenXml.Drawing.RgbColorModelHex rgbColor = colorScheme.Accent6Color.ChildElements.First<DocumentFormat.OpenXml.Drawing.RgbColorModelHex>();
+                if (rgbColor != null)
+                {
+                    return colorStr = rgbColor.Val;
+                }
+                return colorStr;
+            }
+            else if (scv.Equals("lt1"))
+            {
+                DocumentFormat.OpenXml.Drawing.SystemColor sysColor = colorScheme.Light1Color.ChildElements.First<DocumentFormat.OpenXml.Drawing.SystemColor>();
+                if (sysColor != null)
+                {
+                    return colorStr = sysColor.LastColor;
+                }
+                DocumentFormat.OpenXml.Drawing.RgbColorModelHex rgbColor = colorScheme.Light1Color.ChildElements.First<DocumentFormat.OpenXml.Drawing.RgbColorModelHex>();
+                if (rgbColor != null)
+                {
+                    return colorStr = rgbColor.Val;
+                }
+                return colorStr;
+            }
+            else if (scv.Equals("lt2"))
+            {
+                DocumentFormat.OpenXml.Drawing.SystemColor sysColor = colorScheme.Light2Color.ChildElements.First<DocumentFormat.OpenXml.Drawing.SystemColor>();
+                if (sysColor != null)
+                {
+                    return colorStr = sysColor.LastColor;
+                }
+                DocumentFormat.OpenXml.Drawing.RgbColorModelHex rgbColor = colorScheme.Light2Color.ChildElements.First<DocumentFormat.OpenXml.Drawing.RgbColorModelHex>();
+                if (rgbColor != null)
+                {
+                    return colorStr = rgbColor.Val;
+                }
+                return colorStr;
+            }
+            else if (scv.Equals("hlink"))
+            {
+                DocumentFormat.OpenXml.Drawing.SystemColor sysColor = colorScheme.Hyperlink.ChildElements.First<DocumentFormat.OpenXml.Drawing.SystemColor>();
+                if (sysColor != null)
+                {
+                    return colorStr = sysColor.LastColor;
+                }
+                DocumentFormat.OpenXml.Drawing.RgbColorModelHex rgbColor = colorScheme.Hyperlink.ChildElements.First<DocumentFormat.OpenXml.Drawing.RgbColorModelHex>();
+                if (rgbColor != null)
+                {
+                    return colorStr = rgbColor.Val;
+                }
+                return colorStr;
+            }
+            else if (scv.Equals("folHlink"))
+            {
+                DocumentFormat.OpenXml.Drawing.SystemColor sysColor = colorScheme.FollowedHyperlinkColor.ChildElements.First<DocumentFormat.OpenXml.Drawing.SystemColor>();
+                if (sysColor != null)
+                {
+                    return colorStr = sysColor.LastColor;
+                }
+                DocumentFormat.OpenXml.Drawing.RgbColorModelHex rgbColor = colorScheme.FollowedHyperlinkColor.ChildElements.First<DocumentFormat.OpenXml.Drawing.RgbColorModelHex>();
+                if (rgbColor != null)
+                {
+                    return colorStr = rgbColor.Val;
+                }
+                return colorStr;
+            }
+            return ""; 
+        }
+
+       public static string SchemeColorForColorMap(DocumentFormat.OpenXml.Drawing.SchemeColorValues schemeColorValues  , ColorMap colorMap ) {
+            string scv = schemeColorValues.ToString();
+            if (scv.Equals("Text1"))
+            {
+               return colorMap.Text1.ToString();
+            }
+            if (scv.Equals("Text2"))
+            {
+                return colorMap.Text2.ToString();
+            }
+            else if (scv.Equals("Accent1")) {
+                return colorMap.Accent1.ToString();
+            }
+            else if (scv.Equals("Accent2"))
+            {
+                return colorMap.Accent2.ToString();
+            }
+            else if (scv.Equals("Accent3"))
+            {
+                return colorMap.Accent3.ToString();
+            }
+            else if (scv.Equals("Accent4"))
+            {
+                return colorMap.Accent4.ToString();
+            }
+            else if (scv.Equals("Accent5"))
+            {
+                return colorMap.Accent5.ToString();
+            }
+            else if (scv.Equals("Accent6"))
+            {
+                return colorMap.Accent6.ToString();
+            }
+            else if (scv.Equals("Background1"))
+            {
+                return colorMap.Background1.ToString();
+            }
+            else if (scv.Equals("Background2"))
+            {
+                return colorMap.Background2.ToString();
+            }
+            else if (scv.Equals("Hyperlink"))
+            {
+                return colorMap.Hyperlink.ToString();
+            }
+            else if (scv.Equals("FollowedHyperlink"))
+            {
+                return colorMap.FollowedHyperlink.ToString();
+            }
+            else if (scv.Equals("PhColor"))
+            {
+                return "PhColor";
+            }
+            else if (scv.Equals("Dark1"))
+            {
+                return "dk1";
+            }
+            else if (scv.Equals("Dark2"))
+            {
+                return "dk2";
+            }
+            else if (scv.Equals("Light1"))
+            {
+                return "lt1";
+            }
+            else if (scv.Equals("Light2"))
+            {
+                return "lt2";
+            }
+            return null; 
+        }
+
+
+        private static readonly Regex EmojiRegex = new Regex("&#x?[A-Fa-f0-9]+;");
+        private static string ReplaceInvalidXmlCharacterReferences(string input)
+        {
+            if (input.IndexOf("&#") == -1)
+                return input;
+
+            return EmojiRegex.Replace(input, match =>
+            {
+                string ncr = match.Value;
+                uint num;
+                var frmt = NumberFormatInfo.InvariantInfo;
+
+                bool isParsed =
+                    ncr[2] == 'x' ?   // the x must be lowercase in XML documents
+                    uint.TryParse(ncr.Substring(3, ncr.Length - 4), NumberStyles.AllowHexSpecifier, frmt, out num) :
+                    uint.TryParse(ncr.Substring(2, ncr.Length - 3), NumberStyles.Integer, frmt, out num);
+
+                return isParsed && !XmlConvert.IsXmlChar((char)num) ? "" : ncr;
+            });
+        }
+
+        public static Dictionary<string,string> stringEncode(string xml) {
+
+            Dictionary<string, string> codeValues = new Dictionary<string, string>() ;
+            Char[] charstr = xml.ToCharArray();
+            int len = charstr.Length;
+            for (int i = 0; i< len;i++) {
+                var stringBuilder = "";
+                string str = Char.ToString(charstr[i]);
+                if ( Char.GetUnicodeCategory(charstr[i]) == UnicodeCategory.Surrogate) {
+                    string str1 = Char.ToString(charstr[i+1]);
+                    str = str + str1;
+                    var bytes = Encoding.UTF32.GetBytes(str);
+                    for (var j = 0;j < bytes.Length; j += 2)
+                    {
+                        stringBuilder = bytes[j + 1].ToString("x").PadLeft(2, '0') + bytes[j].ToString("x").PadLeft(2, '0') + stringBuilder;
+                    }
+                    var id = Convert.ToInt64(stringBuilder, 16);
+                    i = i + 1;
+                    string code =  id +"";
+                    codeValues.TryAdd(str, code);
+                }
+            }
+            return codeValues;
+        }
+
+
+        public static string ProcessOMath(string innerXml )
+        {
+            Dictionary<string ,string> codeValues =  stringEncode(innerXml);
+            if (codeValues != null) {
+                foreach (string codeValue in codeValues.Keys) {
+                    innerXml= Regex.Replace(innerXml, codeValue, codeValues[codeValue] );
+                }
+            }
+
+            XElement element = XElement.Load(new StringReader(innerXml));
+            List<XElement> elements  = element.Elements().ToList();
+            element =elements.Where(x => x.Name.LocalName.Equals("oMath")).FirstOrDefault();
+            XslCompiledTransform xslTransform = new XslCompiledTransform();
+            xslTransform.Load("E:/document/OMML2MML.XSL");
+            string mathXml = element.ToString();
+           
+            string officeML = string.Empty;
+            using (TextReader tr = new StringReader(mathXml))
+            {
+
+                using (XmlReader reader = XmlReader.Create(tr))
+                {
+                    using (MemoryStream ms = new MemoryStream())
+                    {
+                        XmlWriterSettings settings = xslTransform.OutputSettings.Clone();
+                        settings.ConformanceLevel = ConformanceLevel.Fragment;
+                        settings.OmitXmlDeclaration = true;
+                        settings.Encoding= Encoding.Unicode;
+                         XmlWriter xw = XmlWriter.Create(ms, settings);
+                        xslTransform.Transform(reader, xw);
+                        ms.Seek(0, SeekOrigin.Begin);
+                        using (StreamReader sr = new StreamReader(ms, Encoding.UTF8))
+                        {
+                            officeML = sr.ReadToEnd();
+                        }
+                    }
+
+                }
+            }
+            officeML = officeML.Replace("mml:", "");
+            if (codeValues != null)
+            {
+                foreach (string codeValue in codeValues.Keys)
+                {
+                    officeML = Regex.Replace(officeML, codeValues[codeValue],codeValue);
+                }
+            }
+            return officeML;
+        }
+
+    }
+}

+ 796 - 0
TEAMModelOS.Test.PPTX/PresentationConvert.cs

@@ -0,0 +1,796 @@
+using DocumentFormat.OpenXml;
+using DocumentFormat.OpenXml.Office2010.Drawing;
+using DocumentFormat.OpenXml.Packaging;
+using DocumentFormat.OpenXml.Presentation;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Text.RegularExpressions;
+using System.Xml;
+using System.Xml.Linq;
+using System.Xml.Xsl;
+using TEAMModelOS.SDK.Helper.Common.JsonHelper;
+using ColorMap = DocumentFormat.OpenXml.Presentation.ColorMap;
+using Theme = DocumentFormat.OpenXml.Drawing.Theme;
+
+namespace TEAMModelOS.Test.PPTX
+{
+    public class PresentationConvert
+    {
+        const double inchpixel = 96.0, inchpt = 72.0, pxBase = 914400.0, rotBase = 60000;
+        /// <summary>
+        /// 处理一页PPT的元素
+        /// </summary>
+        /// <param name="slidePart"></param>
+        /// <param name="theme"></param>
+        /// <param name="colorMap"></param>
+        /// <returns></returns>
+        public object GetSlideElement(SlidePart slidePart, Theme theme, ColorMap colorMap) {
+            List<PPTElement> elements = new List<PPTElement>();
+            var shapeTrees = from shap in slidePart.Slide.Descendants<DocumentFormat.OpenXml.Presentation.ShapeTree>() select shap;
+            if (shapeTrees.Count() > 0 && shapeTrees.First().ChildElements.Count > 0) {
+                OpenXmlElementList openXmlElements = shapeTrees.First().ChildElements;
+                int index = 0;
+                foreach (OpenXmlElement element in openXmlElements) {
+                    PPTElement pptElement = null;
+                    if (element is DocumentFormat.OpenXml.Presentation.Shape shape) {
+                        pptElement = ShapeConvert(shape, theme, colorMap);
+                    }
+                    if (element is DocumentFormat.OpenXml.Presentation.Picture picture)
+                    {
+                        pptElement = PictureConvert(picture, slidePart);
+                    }
+                    if (element is DocumentFormat.OpenXml.AlternateContent content)
+                    {
+                        pptElement = AlternateContentConvert(content, theme, colorMap);
+                    }
+                    if (element is DocumentFormat.OpenXml.Presentation.GraphicFrame graphicFrame)
+                    {
+                        pptElement = GraphicFrameConvert(graphicFrame, theme, colorMap);
+                    }
+
+                    index++;
+                    elements.Add(pptElement);
+                }
+            }
+            return elements;
+        }
+        public PPTElement GraphicFrameConvert(GraphicFrame graphicFrame, Theme theme, ColorMap colorMap) {
+
+            DocumentFormat.OpenXml.Drawing.GraphicData graphicData =  graphicFrame.ChildElements.First<DocumentFormat.OpenXml.Drawing.GraphicData>();
+            if (graphicData != null) {
+                OpenXmlElement element = graphicData.ChildElements.First();
+                if (element != null)
+                {
+                    if (element is DocumentFormat.OpenXml.Drawing.Table table)
+                    {
+                       return  TableConvert(graphicFrame, theme, colorMap);
+                    }
+                }
+            }
+            return null; 
+        }
+        public PPTElement TableConvert(GraphicFrame graphicFrame, Theme theme, ColorMap colorMap) {
+
+            return null;
+        }
+
+        /// <summary>
+        /// 处理普通形状的元素
+        /// </summary>
+        /// <param name="shape"></param>
+        /// <returns></returns>
+        public PPTElement ShapeConvert(Shape shape ,Theme theme ,ColorMap colorMap) {
+           // shape.base
+            //文字颜色
+            string textColor = "";
+            //填充颜色
+            string fillColor = "";
+            // 形状类型
+            string type = "text";
+            //字体大小
+            int fontSize = 1800;
+            //是否闭合形状
+            bool complete = false;
+            ShapeProperties properties = shape.ShapeProperties;
+            IEnumerable<DocumentFormat.OpenXml.Drawing.PresetGeometry> presetGeometries= GetPresetGeometry(properties);
+            if (presetGeometries.Count() > 0) {
+                type = presetGeometries.FirstOrDefault().Preset;
+            }
+           
+            DocumentFormat.OpenXml.Drawing.Transform2D transform2D=  GetTransform2D(properties);
+            PPTElement element = new PPTElement() { type = type  ,fontSize=fontSize};
+            if (transform2D != null) {
+                element.complete = complete;
+                element.offx = properties.Transform2D.Offset.X;
+                element.offy = properties.Transform2D.Offset.Y;
+                element.extx = properties.Transform2D.Extents.Cx;
+                element.exty = properties.Transform2D.Extents.Cy;
+                element.flipH = properties.Transform2D.HorizontalFlip != null ? BooleanValue.ToBoolean(properties.Transform2D.HorizontalFlip) : false;
+                element.flipV = properties.Transform2D.VerticalFlip != null ? BooleanValue.ToBoolean(properties.Transform2D.VerticalFlip) : false;
+                element.rot = properties.Transform2D.Rotation != null ? properties.Transform2D.Rotation.Value : 0;
+            }
+
+            ///获取runs的文本及颜色信息
+            var runs = from shap in shape.Descendants<DocumentFormat.OpenXml.Drawing.Run>() select shap;
+          
+            foreach (var run in runs)
+            {
+                var runprps = from shap in run.Descendants<DocumentFormat.OpenXml.Drawing.RunProperties>() select shap;
+                DocumentFormat.OpenXml.Drawing.RunProperties runProperties = runprps.FirstOrDefault();
+
+                if (runProperties != null  &&  fontSize == 1800) {
+                    fontSize = runProperties.FontSize!=null && runProperties.FontSize>0 ?runProperties.FontSize.Value: fontSize;
+                }    
+                var schemeColor = from shap in run.Descendants<DocumentFormat.OpenXml.Drawing.SchemeColor>() select shap;
+                var rgbColors = from shap in run.Descendants<DocumentFormat.OpenXml.Drawing.RgbColorModelHex>() select shap;
+                textColor =  GetSchemeColor(schemeColor ,theme ,colorMap);
+                if (string.IsNullOrEmpty(textColor)) {
+                    textColor = GetRgbColor(rgbColors);
+                }
+                element.text = element.text + run.Text.InnerText;
+            }
+            if (string.IsNullOrEmpty(textColor)) {
+                textColor = GetShapeStyleColor(shape.ShapeStyle, "Font", theme);
+            }
+            if (string.IsNullOrEmpty(fillColor)) {
+                fillColor = GetShapeStyleColor(shape.ShapeStyle, "Fill", theme);
+            }
+            if (string.IsNullOrEmpty(fillColor)) {
+                fillColor = GetPropertieFillColor(properties, theme, colorMap);
+            }
+            element.textColor = textColor;
+            element.fillColor = fillColor;
+            var custGeometrys = from shap in properties.Descendants<DocumentFormat.OpenXml.Drawing.CustomGeometry>() select shap;
+            if (custGeometrys.Count() > 0)
+            {
+                var pathLists = from shap in custGeometrys.First().Descendants<DocumentFormat.OpenXml.Drawing.Path>() select shap;
+                if (pathLists.Count() > 0)
+                {
+                    var moveTos = pathLists.First().ChildElements.OfType<DocumentFormat.OpenXml.Drawing.MoveTo>();
+                    var lineTos = pathLists.First().ChildElements.OfType<DocumentFormat.OpenXml.Drawing.LineTo>();
+                    var BezierTos = pathLists.First().ChildElements.OfType<DocumentFormat.OpenXml.Drawing.CubicBezierCurveTo>();
+
+                }
+            }
+            return element; 
+        }
+        /// <summary>
+        /// 处理图片的元素
+        /// </summary>
+        /// <param name="picture"></param>
+        /// <returns></returns>
+        public PPTElement PictureConvert(Picture picture , SlidePart slidePart)
+        {
+            BlipFill blipFill = picture.BlipFill;
+            var imageRid = blipFill.Blip.Embed.Value;
+            string type = "picture";
+            IdPartPair idParie = slidePart.Parts.Where(x => x.RelationshipId == imageRid).FirstOrDefault();
+            ImagePart imagePart = (ImagePart)idParie.OpenXmlPart;
+            var contentType = imagePart.ContentType;
+            string base64 = "";
+            using (var stream = imagePart.GetStream())
+            {
+                byte[] buffer = new byte[stream.Length];
+                stream.Read(buffer, 0, buffer.Length);
+                stream.Close();
+                base64 = System.Convert.ToBase64String(buffer);
+                base64 = "data:" + contentType + ";base64," + base64;
+            }
+            ShapeProperties properties = picture.ShapeProperties;
+            PPTElement element = new PPTElement() { type = type };
+            if (properties != null && properties.Transform2D != null)
+            {
+                element.offx = properties.Transform2D.Offset.X;
+                element.offy = properties.Transform2D.Offset.Y;
+                element.extx = properties.Transform2D.Extents.Cx;
+                element.exty = properties.Transform2D.Extents.Cy;
+                element.flipH = properties.Transform2D.HorizontalFlip != null ? BooleanValue.ToBoolean(properties.Transform2D.HorizontalFlip) : false;
+                element.flipV = properties.Transform2D.VerticalFlip != null ? BooleanValue.ToBoolean(properties.Transform2D.VerticalFlip) : false;
+                element.rot = properties.Transform2D.Rotation != null ? properties.Transform2D.Rotation.Value : 0;
+            }
+            element.text = base64;
+            return element;
+        }
+        /// <summary>
+        /// 处理兼容元素
+        /// </summary>
+        /// <param name="picture"></param>
+        /// <returns></returns>
+        public PPTElement AlternateContentConvert(AlternateContent content, Theme theme, ColorMap colorMap)
+        {
+            AlternateContentChoice choice= content.ChildElements.First<AlternateContentChoice>();
+            OpenXmlElement element = choice.ChildElements.First();
+            if (element != null) {
+                if (element is DocumentFormat.OpenXml.Presentation.Shape shape)
+                {
+                    var textMaths = from shap in shape.Descendants<TextMath>() select shap;
+                    if (textMaths.Count() > 0) {
+                      return  MathConvert(shape ,theme ,colorMap);
+                    }
+                }
+            }
+            return null;
+        }
+        /// <summary>
+        /// 处理公式
+        /// </summary>
+        /// <param name="shape"></param>
+        /// <param name="theme"></param>
+        /// <param name="colorMap"></param>
+        /// <returns></returns>
+        public PPTElement MathConvert(DocumentFormat.OpenXml.Presentation.Shape shape, Theme theme, ColorMap colorMap) {
+            //文字颜色
+            string textColor = "";
+            //填充颜色
+            string fillColor = "";
+            // 形状类型
+            string type = "math";
+            //字体大小
+            int fontSize = 1800;
+            //是否闭合形状
+            bool complete = true;
+            ShapeProperties properties = shape.ShapeProperties;
+            //IEnumerable<DocumentFormat.OpenXml.Drawing.PresetGeometry> presetGeometries = GetPresetGeometry(properties);
+            //if (presetGeometries.Count() > 0)
+            //{
+            //    type = presetGeometries.FirstOrDefault().Preset;
+            //}
+            DocumentFormat.OpenXml.Drawing.Transform2D transform2D = GetTransform2D(properties);
+            PPTElement element = new PPTElement() { type = type, fontSize = fontSize };
+            if (transform2D != null)
+            {
+                element.complete = complete;
+                element.offx = properties.Transform2D.Offset.X;
+                element.offy = properties.Transform2D.Offset.Y;
+                element.extx = properties.Transform2D.Extents.Cx;
+                element.exty = properties.Transform2D.Extents.Cy;
+                element.flipH = properties.Transform2D.HorizontalFlip != null ? BooleanValue.ToBoolean(properties.Transform2D.HorizontalFlip) : false;
+                element.flipV = properties.Transform2D.VerticalFlip != null ? BooleanValue.ToBoolean(properties.Transform2D.VerticalFlip) : false;
+                element.rot = properties.Transform2D.Rotation != null ? properties.Transform2D.Rotation.Value : 0;
+            }
+            //获取行内样式
+            if (string.IsNullOrEmpty(textColor)) {
+                var rgbColor = from shap in shape.TextBody.Descendants<DocumentFormat.OpenXml.Drawing.RgbColorModelHex>() select shap;
+                textColor =GetRgbColor(rgbColor);
+                if (string.IsNullOrEmpty(textColor))
+                {
+                    var schemes = from shap in shape.TextBody.Descendants<DocumentFormat.OpenXml.Drawing.SchemeColor>() select shap;
+                    textColor = GetSchemeColor(schemes ,theme ,colorMap);
+                }
+            }
+            if (string.IsNullOrEmpty(textColor))
+            {
+                textColor = GetShapeStyleColor(shape.ShapeStyle, "Font", theme);
+            }
+            if (string.IsNullOrEmpty(fillColor))
+            {
+                fillColor = GetShapeStyleColor(shape.ShapeStyle, "Fill", theme);
+            }
+            if (string.IsNullOrEmpty(fillColor))
+            {
+                fillColor = GetPropertieFillColor(properties, theme, colorMap);
+            }
+            element.fillColor = fillColor;
+            element.textColor = textColor;
+            var textMaths = from shap in shape.Descendants<TextMath>() select shap;
+            var math= textMaths.First<TextMath>();
+            string elementData = ProcessOMath(math.InnerXml);
+            element.text = elementData;
+            return element; 
+        }
+        /// <summary>
+        /// 处理元素的Transform2D属性
+        /// </summary>
+        /// <param name="properties"></param>
+        /// <returns></returns>
+        public DocumentFormat.OpenXml.Drawing.Transform2D GetTransform2D(ShapeProperties properties) {
+            if (properties != null) {
+                return properties.Transform2D;
+            }
+            return null; 
+        }
+        /// <summary>
+        /// 处理元素的Transform2D属性
+        /// </summary>
+        /// <param name="properties"></param>
+        /// <returns></returns>
+        public IEnumerable<DocumentFormat.OpenXml.Drawing.PresetGeometry> GetPresetGeometry(ShapeProperties properties)
+        {
+            if (properties != null)
+            {
+                var presetGeometrys = from shap in properties.Descendants<DocumentFormat.OpenXml.Drawing.PresetGeometry>() select shap;
+                return presetGeometrys;
+            }
+            return null;
+        }
+        /// <summary>
+        /// 处理元素属性的填充色
+        /// </summary>
+        /// <param name="properties"></param>
+        /// <returns></returns>
+        public string GetPropertieFillColor(ShapeProperties properties, Theme theme, ColorMap colorMap)
+        {
+            string fillColor = "";
+            if (properties != null)
+            {
+                var solidFills = from shape in properties.Descendants<DocumentFormat.OpenXml.Drawing.SolidFill>() select shape;
+                if ( solidFills.Count() > 0)
+                {
+                    var propRgbColor = from shape in solidFills.First().Descendants<DocumentFormat.OpenXml.Drawing.RgbColorModelHex>() select shape;
+                    fillColor = GetRgbColor(propRgbColor);
+                    if (string.IsNullOrEmpty(fillColor))
+                    {
+                        var colorScheme = from shape in solidFills.First().Descendants<DocumentFormat.OpenXml.Drawing.SchemeColor>() select shape;
+                        fillColor = GetSchemeColor(colorScheme,  theme, colorMap);
+                    }
+                }
+            }
+            return fillColor;
+        }
+
+        /// <summary>
+        /// 获取ShapeStyle样式表 各种属性 的颜色
+        /// </summary>
+        /// <param name="shapeStyle"></param>
+        /// <param name="colorType"></param>
+        /// <param name="theme"></param>
+        /// <returns></returns>
+        public string GetShapeStyleColor(DocumentFormat.OpenXml.Presentation.ShapeStyle shapeStyle, string colorType, Theme theme) {
+            if (shapeStyle == null)
+            { 
+                return "";
+            }
+            // 效果颜色
+            if (colorType.Equals("Effect"))
+            {
+                DocumentFormat.OpenXml.Drawing.SchemeColor EffectcolorScheme = shapeStyle.EffectReference.ChildElements.First<DocumentFormat.OpenXml.Drawing.SchemeColor>();
+                return ColorForThemeClr(EffectcolorScheme.Val, theme);
+            }
+            // 线条颜色
+            if (colorType.Equals("Line"))
+            {
+                DocumentFormat.OpenXml.Drawing.SchemeColor LinecolorScheme = shapeStyle.LineReference.ChildElements.First<DocumentFormat.OpenXml.Drawing.SchemeColor>();
+                return ColorForThemeClr(LinecolorScheme.Val, theme);
+            }
+            // 填充色
+            if (colorType.Equals("Fill"))
+            {
+                DocumentFormat.OpenXml.Drawing.SchemeColor FillcolorScheme = shapeStyle.FillReference.ChildElements.First<DocumentFormat.OpenXml.Drawing.SchemeColor>();
+                return ColorForThemeClr(FillcolorScheme.Val, theme);
+            }
+            // 字体颜色
+            if (colorType.Equals("Font"))
+            {
+                DocumentFormat.OpenXml.Drawing.SchemeColor FontcolorScheme = shapeStyle.FontReference.ChildElements.First<DocumentFormat.OpenXml.Drawing.SchemeColor>();
+                return ColorForThemeClr(FontcolorScheme.Val, theme);
+            }
+            return "";
+        }
+
+        /// <summary>
+        /// 获取声明式颜色
+        /// </summary>
+        /// <param name="rgbColors"></param>
+        /// <returns></returns>
+        public string GetSchemeColor(IEnumerable<DocumentFormat.OpenXml.Drawing.SchemeColor> colorScheme, Theme theme, ColorMap colorMap)
+        {
+            string rgbColor = "";
+            if (colorScheme.Count() > 0)
+            {
+                rgbColor = ColorForThemeClr(SchemeColorForColorMap(colorScheme.FirstOrDefault().Val.Value, colorMap), theme);
+            }
+            return rgbColor;
+        }
+        /// <summary>
+        /// 获取RGBColor
+        /// </summary>
+        /// <param name="rgbColors"></param>
+        /// <returns></returns>
+        public string  GetRgbColor(IEnumerable<DocumentFormat.OpenXml.Drawing.RgbColorModelHex> rgbColors) {
+            string rgbColor = "";
+            if ( rgbColors.Count() > 0)
+            {
+                rgbColor = rgbColors.FirstOrDefault().Val;
+            }
+            return rgbColor;
+        }
+        /// <summary>
+        /// 加载PPTX文件
+        /// </summary>
+        /// <param name="presentationFile"></param>
+        /// <returns></returns>
+        public  object LoadPresentation(string presentationFile) {
+            using (PresentationDocument presentationDocument =PresentationDocument.Open(presentationFile, false))
+            {
+                if (presentationDocument == null)
+                {
+                    throw new ArgumentNullException("presentationDocument");
+                }
+                // Get a PresentationPart object from the PresentationDocument object.
+                PresentationPart presentationPart = presentationDocument.PresentationPart;
+                if (presentationPart != null && presentationPart.Presentation != null)
+                {
+                    var slideMasterParts = presentationPart.SlideMasterParts;
+                    ColorMap colorMap = null;
+                    Theme theme = null;
+                    foreach (var slideMasterPart in slideMasterParts)
+                    {
+                        if (colorMap != null && theme != null)
+                        {
+                            break;
+                        }
+                        colorMap = slideMasterPart.SlideMaster.ColorMap;
+                        theme = slideMasterPart.ThemePart.Theme;
+                    }
+                    // Get a Presentation object from the PresentationPart object.
+                    Presentation presentation = presentationPart.Presentation;
+                    if (presentation.SlideIdList != null)
+                    {
+                        //获取PPT 一页大小
+                        int x = presentation.SlideSize.Cx;
+                        int y = presentation.SlideSize.Cy;
+                        // Get the title of each slide in the slide order.
+                        // 获取的是几页PPT数量
+                        foreach (var slideId in presentation.SlideIdList.Elements<SlideId>())
+                        {
+                            // 获取这一页 PPT 的id 
+                            string id = slideId.RelationshipId;
+                            SlidePart slidePart = presentationPart.GetPartById(slideId.RelationshipId) as SlidePart;
+                            //获取当前页 PPT 的所有元素
+                            GetSlideElement(slidePart, theme, colorMap);
+                        }
+                    }
+                }
+                return null; 
+            }
+        }
+        /// <summary>
+        /// 在主题Theme中获取颜色
+        /// </summary>
+        /// <param name="scv"></param>
+        /// <param name="theme"></param>
+        /// <returns></returns>
+        public static string ColorForThemeClr(string scv, Theme theme)
+        {
+            DocumentFormat.OpenXml.Drawing.ColorScheme colorScheme = theme.ThemeElements.ColorScheme;
+            string colorStr = "";
+            if (scv.Equals("dk1"))
+            {
+                DocumentFormat.OpenXml.Drawing.SystemColor sysColor = colorScheme.Dark1Color.ChildElements.First<DocumentFormat.OpenXml.Drawing.SystemColor>();
+                if (sysColor != null)
+                {
+                    return  sysColor.LastColor;
+                }
+                DocumentFormat.OpenXml.Drawing.RgbColorModelHex rgbColor = colorScheme.Dark1Color.ChildElements.First<DocumentFormat.OpenXml.Drawing.RgbColorModelHex>();
+                if (rgbColor != null)
+                {
+                    return rgbColor.Val;
+                }
+                return colorStr;
+            }
+            if (scv.Equals("dk2"))
+            {
+                DocumentFormat.OpenXml.Drawing.SystemColor sysColor = colorScheme.Dark2Color.ChildElements.First<DocumentFormat.OpenXml.Drawing.SystemColor>();
+                if (sysColor != null)
+                {
+                    return sysColor.LastColor;
+                }
+                DocumentFormat.OpenXml.Drawing.RgbColorModelHex rgbColor = colorScheme.Dark2Color.ChildElements.First<DocumentFormat.OpenXml.Drawing.RgbColorModelHex>();
+                if (rgbColor != null)
+                {
+                    return rgbColor.Val;
+                }
+                return colorStr;
+            }
+            else if (scv.Equals("accent1"))
+            {
+                DocumentFormat.OpenXml.Drawing.SystemColor sysColor = colorScheme.Accent1Color.ChildElements.First<DocumentFormat.OpenXml.Drawing.SystemColor>();
+                if (sysColor != null)
+                {
+                    return sysColor.LastColor;
+                }
+                DocumentFormat.OpenXml.Drawing.RgbColorModelHex rgbColor = colorScheme.Accent1Color.ChildElements.First<DocumentFormat.OpenXml.Drawing.RgbColorModelHex>();
+                if (rgbColor != null)
+                {
+                    return  rgbColor.Val;
+                }
+                return colorStr;
+            }
+            else if (scv.Equals("accent2"))
+            {
+                DocumentFormat.OpenXml.Drawing.SystemColor sysColor = colorScheme.Accent2Color.ChildElements.First<DocumentFormat.OpenXml.Drawing.SystemColor>();
+                if (sysColor != null)
+                {
+                    return  sysColor.LastColor;
+                }
+                DocumentFormat.OpenXml.Drawing.RgbColorModelHex rgbColor = colorScheme.Accent2Color.ChildElements.First<DocumentFormat.OpenXml.Drawing.RgbColorModelHex>();
+                if (rgbColor != null)
+                {
+                    return  rgbColor.Val;
+                }
+                return colorStr;
+            }
+            else if (scv.Equals("accent3"))
+            {
+                DocumentFormat.OpenXml.Drawing.SystemColor sysColor = colorScheme.Accent3Color.ChildElements.First<DocumentFormat.OpenXml.Drawing.SystemColor>();
+                if (sysColor != null)
+                {
+                    return sysColor.LastColor;
+                }
+                DocumentFormat.OpenXml.Drawing.RgbColorModelHex rgbColor = colorScheme.Accent3Color.ChildElements.First<DocumentFormat.OpenXml.Drawing.RgbColorModelHex>();
+                if (rgbColor != null)
+                {
+                    return  rgbColor.Val;
+                }
+                return colorStr;
+            }
+            else if (scv.Equals("accent4"))
+            {
+                DocumentFormat.OpenXml.Drawing.SystemColor sysColor = colorScheme.Accent4Color.ChildElements.First<DocumentFormat.OpenXml.Drawing.SystemColor>();
+                if (sysColor != null)
+                {
+                    return sysColor.LastColor;
+                }
+                DocumentFormat.OpenXml.Drawing.RgbColorModelHex rgbColor = colorScheme.Accent4Color.ChildElements.First<DocumentFormat.OpenXml.Drawing.RgbColorModelHex>();
+                if (rgbColor != null)
+                {
+                    return rgbColor.Val;
+                }
+                return colorStr;
+            }
+            else if (scv.Equals("accent5"))
+            {
+                DocumentFormat.OpenXml.Drawing.SystemColor sysColor = colorScheme.Accent5Color.ChildElements.First<DocumentFormat.OpenXml.Drawing.SystemColor>();
+                if (sysColor != null)
+                {
+                    return sysColor.LastColor;
+                }
+                DocumentFormat.OpenXml.Drawing.RgbColorModelHex rgbColor = colorScheme.Accent5Color.ChildElements.First<DocumentFormat.OpenXml.Drawing.RgbColorModelHex>();
+                if (rgbColor != null)
+                {
+                    return rgbColor.Val;
+                }
+                return colorStr;
+            }
+            else if (scv.Equals("accent6"))
+            {
+                DocumentFormat.OpenXml.Drawing.SystemColor sysColor = colorScheme.Accent6Color.ChildElements.First<DocumentFormat.OpenXml.Drawing.SystemColor>();
+                if (sysColor != null)
+                {
+                    return sysColor.LastColor;
+                }
+                DocumentFormat.OpenXml.Drawing.RgbColorModelHex rgbColor = colorScheme.Accent6Color.ChildElements.First<DocumentFormat.OpenXml.Drawing.RgbColorModelHex>();
+                if (rgbColor != null)
+                {
+                    return rgbColor.Val;
+                }
+                return colorStr;
+            }
+            else if (scv.Equals("lt1"))
+            {
+                DocumentFormat.OpenXml.Drawing.SystemColor sysColor = colorScheme.Light1Color.ChildElements.First<DocumentFormat.OpenXml.Drawing.SystemColor>();
+                if (sysColor != null)
+                {
+                    return sysColor.LastColor;
+                }
+                DocumentFormat.OpenXml.Drawing.RgbColorModelHex rgbColor = colorScheme.Light1Color.ChildElements.First<DocumentFormat.OpenXml.Drawing.RgbColorModelHex>();
+                if (rgbColor != null)
+                {
+                    return   rgbColor.Val;
+                }
+                return colorStr;
+            }
+            else if (scv.Equals("lt2"))
+            {
+                DocumentFormat.OpenXml.Drawing.SystemColor sysColor = colorScheme.Light2Color.ChildElements.First<DocumentFormat.OpenXml.Drawing.SystemColor>();
+                if (sysColor != null)
+                {
+                    return sysColor.LastColor;
+                }
+                DocumentFormat.OpenXml.Drawing.RgbColorModelHex rgbColor = colorScheme.Light2Color.ChildElements.First<DocumentFormat.OpenXml.Drawing.RgbColorModelHex>();
+                if (rgbColor != null)
+                {
+                    return  rgbColor.Val;
+                }
+                return colorStr;
+            }
+            else if (scv.Equals("hlink"))
+            {
+                DocumentFormat.OpenXml.Drawing.SystemColor sysColor = colorScheme.Hyperlink.ChildElements.First<DocumentFormat.OpenXml.Drawing.SystemColor>();
+                if (sysColor != null)
+                {
+                    return  sysColor.LastColor;
+                }
+                DocumentFormat.OpenXml.Drawing.RgbColorModelHex rgbColor = colorScheme.Hyperlink.ChildElements.First<DocumentFormat.OpenXml.Drawing.RgbColorModelHex>();
+                if (rgbColor != null)
+                {
+                    return rgbColor.Val;
+                }
+                return colorStr;
+            }
+            else if (scv.Equals("folHlink"))
+            {
+                DocumentFormat.OpenXml.Drawing.SystemColor sysColor = colorScheme.FollowedHyperlinkColor.ChildElements.First<DocumentFormat.OpenXml.Drawing.SystemColor>();
+                if (sysColor != null)
+                {
+                    return  sysColor.LastColor;
+                }
+                DocumentFormat.OpenXml.Drawing.RgbColorModelHex rgbColor = colorScheme.FollowedHyperlinkColor.ChildElements.First<DocumentFormat.OpenXml.Drawing.RgbColorModelHex>();
+                if (rgbColor != null)
+                {
+                    return   rgbColor.Val;
+                }
+                return colorStr;
+            }
+            return "";
+        }
+        /// <summary>
+        /// 按照ColorMap 去寻找对应的颜色 
+        /// </summary>
+        /// <param name="schemeColorValues"></param>
+        /// <param name="colorMap"></param>
+        /// <returns></returns>
+        public static string SchemeColorForColorMap(DocumentFormat.OpenXml.Drawing.SchemeColorValues schemeColorValues, ColorMap colorMap)
+        {
+            string scv = schemeColorValues.ToString();
+            if (scv.Equals("Text1"))
+            {
+                return colorMap.Text1.ToString();
+            }
+            if (scv.Equals("Text2"))
+            {
+                return colorMap.Text2.ToString();
+            }
+            else if (scv.Equals("Accent1"))
+            {
+                return colorMap.Accent1.ToString();
+            }
+            else if (scv.Equals("Accent2"))
+            {
+                return colorMap.Accent2.ToString();
+            }
+            else if (scv.Equals("Accent3"))
+            {
+                return colorMap.Accent3.ToString();
+            }
+            else if (scv.Equals("Accent4"))
+            {
+                return colorMap.Accent4.ToString();
+            }
+            else if (scv.Equals("Accent5"))
+            {
+                return colorMap.Accent5.ToString();
+            }
+            else if (scv.Equals("Accent6"))
+            {
+                return colorMap.Accent6.ToString();
+            }
+            else if (scv.Equals("Background1"))
+            {
+                return colorMap.Background1.ToString();
+            }
+            else if (scv.Equals("Background2"))
+            {
+                return colorMap.Background2.ToString();
+            }
+            else if (scv.Equals("Hyperlink"))
+            {
+                return colorMap.Hyperlink.ToString();
+            }
+            else if (scv.Equals("FollowedHyperlink"))
+            {
+                return colorMap.FollowedHyperlink.ToString();
+            }
+            else if (scv.Equals("PhColor"))
+            {
+                return "PhColor";
+            }
+            else if (scv.Equals("Dark1"))
+            {
+                return "dk1";
+            }
+            else if (scv.Equals("Dark2"))
+            {
+                return "dk2";
+            }
+            else if (scv.Equals("Light1"))
+            {
+                return "lt1";
+            }
+            else if (scv.Equals("Light2"))
+            {
+                return "lt2";
+            }
+            return null;
+        }
+
+        /// <summary>
+        /// 转换Surrogate 类型的编码的字符串
+        /// </summary>
+        /// <param name="xml"></param>
+        /// <returns></returns>
+        public static Dictionary<string, string> StringEncode(string xml)
+        {
+            Dictionary<string, string> codeValues = new Dictionary<string, string>();
+            Char[] charstr = xml.ToCharArray();
+            int len = charstr.Length;
+            for (int i = 0; i < len; i++)
+            {
+                var stringBuilder = "";
+                string str = Char.ToString(charstr[i]);
+                if (Char.GetUnicodeCategory(charstr[i]) == UnicodeCategory.Surrogate)
+                {
+                    string str1 = Char.ToString(charstr[i + 1]);
+                    str += str1;
+                    var bytes = Encoding.UTF32.GetBytes(str);
+                    for (var j = 0; j < bytes.Length; j += 2)
+                    {
+                        stringBuilder = bytes[j + 1].ToString("x").PadLeft(2, '0') + bytes[j].ToString("x").PadLeft(2, '0') + stringBuilder;
+                    }
+                    var id = Convert.ToInt64(stringBuilder, 16);
+                    i += 1;
+                    string code = id + "";
+                    codeValues.TryAdd(str, code);
+                }
+            }
+            return codeValues;
+        }
+
+        /// <summary>
+        /// 根据OfficeML转换为MathML
+        /// </summary>
+        /// <param name="innerXml"></param>
+        /// <returns></returns>
+        public static string ProcessOMath(string innerXml)
+        {
+            Dictionary<string, string> codeValues = StringEncode(innerXml);
+            if (codeValues != null)
+            {
+                foreach (string codeValue in codeValues.Keys)
+                {
+                    innerXml = Regex.Replace(innerXml, codeValue, codeValues[codeValue]);
+                }
+            }
+            XElement element = XElement.Load(new StringReader(innerXml));
+            List<XElement> elements = element.Elements().ToList();
+            element = elements.Where(x => x.Name.LocalName.Equals("oMath")).FirstOrDefault();
+            XslCompiledTransform xslTransform = new XslCompiledTransform();
+            xslTransform.Load("E:/document/OMML2MML.XSL");
+            string mathXml = element.ToString();
+            string officeML = string.Empty;
+            using (TextReader tr = new StringReader(mathXml))
+            {
+                using (XmlReader reader = XmlReader.Create(tr))
+                {
+                    using (MemoryStream ms = new MemoryStream())
+                    {
+                        XmlWriterSettings settings = xslTransform.OutputSettings.Clone();
+                        settings.ConformanceLevel = ConformanceLevel.Fragment;
+                        settings.OmitXmlDeclaration = true;
+                        settings.Encoding = Encoding.Unicode;
+                        XmlWriter xw = XmlWriter.Create(ms, settings);
+                        xslTransform.Transform(reader, xw);
+                        ms.Seek(0, SeekOrigin.Begin);
+                        using (StreamReader sr = new StreamReader(ms, Encoding.UTF8))
+                        {
+                            officeML = sr.ReadToEnd();
+                        }
+                    }
+                }
+            }
+            officeML = officeML.Replace("mml:", "");
+            if (codeValues != null)
+            {
+                foreach (string codeValue in codeValues.Keys)
+                {
+                    officeML = Regex.Replace(officeML, codeValues[codeValue], codeValue);
+                }
+            }
+            return officeML;
+        }
+    }
+}

+ 21 - 0
TEAMModelOS.Test.PPTX/PresentationElement/Content.cs

@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TEAMModelOS.Test.PPTX.PresentationElement
+{
+    public class Content
+    {
+        public string type { get; set; }
+        //文本 /或图片base64
+        public string text { get; set; }
+        //文本颜色
+        public string textColor { get; set; }
+        //填充颜色
+        public string fillColor { get; set; }
+        //图形是否闭合
+        public bool complete { get; set; }
+        //字体大小
+        public int fontSize { get; set; }
+    }
+}

+ 14 - 0
TEAMModelOS.Test.PPTX/PresentationElement/Element.cs

@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TEAMModelOS.Test.PPTX.PresentationElement
+{
+    public class Element
+    {
+        public Position  position{get;set;}
+        public List<Content> contents { get; set; }
+
+        public List<>
+    }
+}

+ 22 - 0
TEAMModelOS.Test.PPTX/PresentationElement/Position.cs

@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TEAMModelOS.Test.PPTX.PresentationElement
+{
+    public class Position
+    {
+        //旋转角度
+        public int rot { get; set; }
+        //水平翻转
+        public bool flipH { get; set; }
+        //垂直翻转
+        public bool flipV { get; set; }
+        //x轴
+        public long offx { get; set; }
+        //y轴
+        public long offy { get; set; }
+        //宽度
+        public long extx { get; set; }
+    }
+}

+ 49 - 0
TEAMModelOS.Test.PPTX/Program.cs

@@ -0,0 +1,49 @@
+
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Drawing.Imaging;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using TEAMModelOS.Test.PPTX.ColorLibrary;
+
+namespace TEAMModelOS.Test.PPTX
+{
+    class Program
+    {
+        static void Main(string[] args)
+        {
+            ///白色灰度值计算
+            double rw = 255, gw = 255, bw = 255;
+            ///ED7D31的RGB
+            int ra = 237, ga = 125, ba = 49;
+            double pw = 40000 * 96.0 / 914400 / 10;
+            //double pa = 0.4;
+            double pa = 1 - pw;
+            double rn = rw * pw + ra * pa;
+            double gn = gw * pw + ga * pa;
+            double bn = bw * pw + ba * pa;
+            Console.WriteLine(rn + "," + gn + "," + bn);
+
+            double rnn = ra - (ra - rw) * pw;
+            double gnn = ga - (ga - gw) * pw;
+            double bnn = ba - (ba - bw) * pw;
+            Console.WriteLine(rnn + "," + gnn + "," + bnn);
+
+
+            double rnnn = ra * (1 - 0.4) + (255 - 255 * (1 - 0.4));
+            double gnnn = ga * (1 - 0.4) + (255 - 255 * (1 - 0.4));
+            double bnnn = ba * (1 - 0.4) + (255 - 255 * (1 - 0.4));
+            Console.WriteLine(rnn + "," + gnn + "," + bnn);
+            ColorHSL colorHSL=  ColorHelper.RgbToHsl(new ColorRGB(ra,ga,ba) );
+            colorHSL.H = (int)(colorHSL.H * pa);
+            colorHSL.L = (int)(colorHSL.L * pa);
+            colorHSL.S = (int)(colorHSL.S * pa);
+            ColorRGB  color=ColorHelper.HslToRgb(colorHSL);
+            System.Drawing.Color s = ColorTranslator.FromHtml("#ED7D31");
+            PPTXConvertNew.GetSlideTitles("E:\\document\\123.pptx");
+        }
+    }  
+}

+ 21 - 0
TEAMModelOS.Test.PPTX/TEAMModelOS.Test.PPTX.csproj

@@ -0,0 +1,21 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <OutputType>Exe</OutputType>
+    <TargetFramework>netcoreapp2.2</TargetFramework>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <ProjectReference Include="..\TEAMModelOS.Model\TEAMModelOS.Model.csproj" />
+    <ProjectReference Include="..\TEAMModelOS.SDK\TEAMModelOS.SDK.csproj" />
+  </ItemGroup>
+
+  <ItemGroup>
+    <Folder Include="SlideConvert\" />
+  </ItemGroup>
+
+  <ItemGroup>
+    <PackageReference Include="Svg" Version="3.0.9-g6ea47b4039" />
+  </ItemGroup>
+
+</Project>

+ 7 - 0
TEAMModelOS.sln

@@ -29,6 +29,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TEAMModelOS.Test.OfficeDoc"
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TeamModelOS.OfficeDoc.Test", "TeamModelOS.OfficeDoc.Test\TeamModelOS.OfficeDoc.Test.csproj", "{E5E2E853-AAE9-45D8-A59B-BC054434F9AD}"
 EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TEAMModelOS.Test.PPTX", "TEAMModelOS.Test.PPTX\TEAMModelOS.Test.PPTX.csproj", "{7A537ADF-61AC-42D6-AF49-A0AAF57E3B5C}"
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
@@ -67,6 +69,10 @@ Global
 		{E5E2E853-AAE9-45D8-A59B-BC054434F9AD}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{E5E2E853-AAE9-45D8-A59B-BC054434F9AD}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{E5E2E853-AAE9-45D8-A59B-BC054434F9AD}.Release|Any CPU.Build.0 = Release|Any CPU
+		{7A537ADF-61AC-42D6-AF49-A0AAF57E3B5C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{7A537ADF-61AC-42D6-AF49-A0AAF57E3B5C}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{7A537ADF-61AC-42D6-AF49-A0AAF57E3B5C}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{7A537ADF-61AC-42D6-AF49-A0AAF57E3B5C}.Release|Any CPU.Build.0 = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE
@@ -80,6 +86,7 @@ Global
 		{519FE59A-2D7B-407C-952B-4F497B8BA07E} = {CFBC5D78-72A7-4330-B779-F6826194F48A}
 		{98D55090-23B0-4362-872D-A184D95085C6} = {CFBC5D78-72A7-4330-B779-F6826194F48A}
 		{E5E2E853-AAE9-45D8-A59B-BC054434F9AD} = {CFBC5D78-72A7-4330-B779-F6826194F48A}
+		{7A537ADF-61AC-42D6-AF49-A0AAF57E3B5C} = {CFBC5D78-72A7-4330-B779-F6826194F48A}
 	EndGlobalSection
 	GlobalSection(ExtensibilityGlobals) = postSolution
 		SolutionGuid = {5C55F286-63D0-4235-BDE0-D7AD32B0EDEB}

+ 3 - 3
TEAMModelOS/Controllers/Core/LoginController.cs

@@ -47,7 +47,7 @@ namespace TEAMModelOS.Controllers.Core
         public async Task<BaseJosnRPCResponse> CheckLogin(JosnRPCRequest<TicketInfo> request)
         {  
             JsonRPCResponseBuilder responseBuilder = JsonRPCResponseBuilder.custom();
-#if DEBUG
+ 
             if (ValidateHelper.IsValid(request.@params))
             {
                 LoginResult result = await  _loginInfoService.CheckLoginAsync(request.@params);
@@ -64,9 +64,9 @@ namespace TEAMModelOS.Controllers.Core
             {
                 responseBuilder.Error(false, ResponseCode.FAILED, "ticket error!");
             }
-#else
+ 
             responseBuilder.Error(false, ResponseCode.FAILED, "ticket error!");
-#endif
+ 
             return responseBuilder.build();
         }
         /// <summary>

+ 2 - 12
TEAMModelOS/Startup.cs

@@ -56,7 +56,7 @@ namespace TEAMModelOS
                 x.MultipartBodyLengthLimit = long.MaxValue; // In case of multipart
                 x.MultipartHeadersLengthLimit = int.MaxValue;
             });
-#if DEBUG
+
             //Table配置
             services.AddAzureTableStorage().AddConnection(Configuration.GetSection("Azure:Table").Get<AzureTableOptions>());
             //使用Blob配置
@@ -70,21 +70,15 @@ namespace TEAMModelOS
                    .WithSingletonLifetime());
             //引入Jwt配置
             services.JwtAuth(Configuration.GetSection("JwtSetting"));
-#endif
             //HttpContextAccessor,并用来访问HttpContext。
             services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
-#if DEBUG
             services.AddHttp();
             services.AddSingleton<SeedData.SeedDataService>();
-#endif
         }
 
         // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
-#if DEBUG
         public void Configure(IApplicationBuilder app, IHostingEnvironment env, SeedDataService seedDataService)
-#else
-        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
-#endif
+
         {
             if (env.IsDevelopment())
             {
@@ -104,11 +98,9 @@ namespace TEAMModelOS
             }
             // 如果你想使用官方认证,必须在上边ConfigureService 中,配置JWT的认证服务 (.AddAuthentication 和 .AddJwtBearer 二者缺一不可)
             app.UseAuthentication();
-#if DEBUG
 
             app.UseMiddleware<JwtAuthorizationFilter>();
             app.UseMiddleware<HttpGlobalExceptionInvoke>();
-#endif
             app.UseHttpsRedirection();
             app.UseStaticFiles();
             //app.UseCookiePolicy();
@@ -123,9 +115,7 @@ namespace TEAMModelOS
                     name: "spa-fallback",
                     defaults: new { controller = "Home", action = "Index" });
             });
-#if DEBUG
             seedDataService.SeedData();
-#endif
         }
     }
 }