Skip to content

Commit

Permalink
Updated for v24.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
fileformat-slides-gists committed Mar 14, 2024
1 parent 4a2a6b5 commit b9a176f
Show file tree
Hide file tree
Showing 7 changed files with 629 additions and 102 deletions.
61 changes: 59 additions & 2 deletions FileFormat.Slides-Test/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Collections.Generic;
using FileFormat.Slides.Common;


class Program
{
static void Main ()
Expand Down Expand Up @@ -209,8 +210,8 @@ static void Main ()
presentation.Save();
*/
/* Presentation presentation = Presentation.Open("D:\\AsposeSampleData\\test.pptx");

/*Presentation presentation = Presentation.Open("D:\\AsposeSampleData\\test.pptx");
Slide slide = presentation.GetSlides()[2];
// Assign values to the properties of Stylings
Expand Down Expand Up @@ -279,6 +280,62 @@ static void Main ()
presentation.Save();*/

Presentation presentation = Presentation.Open("D:\\AsposeSampleData\\test.pptx");
Slide slide = presentation.GetSlides()[0];

Table table = slide.Tables[0];
table.Theme = Table.TableStyle.LightStyle3;
TableRow row2 = new TableRow(table);
TableCell cell21 = new TableCell(row2);
cell21.Text = "915";
cell21.ID = table.Columns[0].Name;
row2.AddCell(cell21);
TableCell cell22 = new TableCell(row2);
cell22.Text = "Allen";
cell22.ID = table.Columns[1].Name;
row2.AddCell(cell22);
TableCell cell23 = new TableCell(row2);
cell23.Text = "New York";
cell23.ID = table.Columns[2].Name;
row2.AddCell(cell23);

table.AddRow(row2);
table.Update();

presentation.Save();

/*Presentation presentation = Presentation.Open("D:\\AsposeSampleData\\test.pptx");
Slide slide = presentation.GetSlides()[0];
Table table = slide.Tables[0];
TableColumn col3 = new TableColumn();
col3.Name = "City";
table.Columns.Add(col3);
// Create a new cell for the new column
TableCell newCell1 = new TableCell();
newCell1.Text = "Chicago";
newCell1.ID = col3.Name;
table.Rows[0].AddCell(newCell1);
TableCell newCell2 = new TableCell();
newCell2.ID = col3.Name;
newCell2.Text = "New York";
table.Rows[1].AddCell(newCell2);
TableCell newCell3 = new TableCell();
newCell3.ID = col3.Name;
newCell3.Text = "Chicago";
table.Rows[2].AddCell(newCell3);
TableCell newCell4 = new TableCell();
newCell4.ID = col3.Name;
newCell4.Text = "California";
table.Rows[3].AddCell(newCell4);
table.Update();
presentation.Save();*/

}

}
236 changes: 236 additions & 0 deletions FileFormat.Slides.Facade/PowerPointTableStyles.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,236 @@
using DocumentFormat.OpenXml.Drawing;
using System;
using System.Collections.Generic;
using System.Text;

namespace FileFormat.Slides.Facade
{
internal static class PowerPointTableStyles
{
private static class LightStyles
{
public static TableStyleId Style1 { get; } = new TableStyleId() { Text = "{5C22544A-7EE6-4342-B048-85BDC9FD1C3A}" };
public static TableStyleId Style2 { get; } = new TableStyleId() { Text = "{FF2B5EF4-FFF2-40B4-BE49-F238E27FC236}" };
public static TableStyleId Style3 { get; } = new TableStyleId() { Text = "{775DCB02-9BB8-47FD-8907-85C794F793BA}" };
public static TableStyleId Style4 { get; } = new TableStyleId() { Text = "{FF2B5EF4-FFF2-40B4-BE49-F238E27FC236}" };
public static TableStyleId Style5 { get; } = new TableStyleId() { Text = "{5C22544A-7EE6-4342-B048-85BDC9FD1C3E}" };
public static TableStyleId Style6 { get; } = new TableStyleId() { Text = "{5C22544A-7EE6-4342-B048-85BDC9FD1C3F}" };
public static TableStyleId Style7 { get; } = new TableStyleId() { Text = "{5C22544A-7EE6-4342-B048-85BDC9FD1C3G}" };
public static TableStyleId Style8 { get; } = new TableStyleId() { Text = "{5C22544A-7EE6-4342-B048-85BDC9FD1C3H}" };
public static TableStyleId Style9 { get; } = new TableStyleId() { Text = "{5C22544A-7EE6-4342-B048-85BDC9FD1C3I}" };
public static TableStyleId Style10 { get; } = new TableStyleId() { Text = "{5C22544A-7EE6-4342-B048-85BDC9FD1C3J}" };
public static TableStyleId Style11 { get; } = new TableStyleId() { Text = "{5C22544A-7EE6-4342-B048-85BDC9FD1C3K}" };
public static TableStyleId Style12 { get; } = new TableStyleId() { Text = "{5C22544A-7EE6-4342-B048-85BDC9FD1C3L}" };
public static TableStyleId Style13 { get; } = new TableStyleId() { Text = "{5C22544A-7EE6-4342-B048-85BDC9FD1C3M}" };
public static TableStyleId Style14 { get; } = new TableStyleId() { Text = "{5C22544A-7EE6-4342-B048-85BDC9FD1C3N}" };
}

private static class MediumStyles
{
public static TableStyleId Style1 { get; } = new TableStyleId() { Text = "{5C22544A-7EE6-4342-B048-85BDC9FD1C3O}" };
public static TableStyleId Style2 { get; } = new TableStyleId() { Text = "{5C22544A-7EE6-4342-B048-85BDC9FD1C3P}" };
public static TableStyleId Style3 { get; } = new TableStyleId() { Text = "{5C22544A-7EE6-4342-B048-85BDC9FD1C3Q}" };
public static TableStyleId Style4 { get; } = new TableStyleId() { Text = "{5C22544A-7EE6-4342-B048-85BDC9FD1C3R}" };
public static TableStyleId Style5 { get; } = new TableStyleId() { Text = "{5C22544A-7EE6-4342-B048-85BDC9FD1C3S}" };
public static TableStyleId Style6 { get; } = new TableStyleId() { Text = "{5C22544A-7EE6-4342-B048-85BDC9FD1C3T}" };
public static TableStyleId Style7 { get; } = new TableStyleId() { Text = "{5C22544A-7EE6-4342-B048-85BDC9FD1C3U}" };
public static TableStyleId Style8 { get; } = new TableStyleId() { Text = "{5C22544A-7EE6-4342-B048-85BDC9FD1C3V}" };
public static TableStyleId Style9 { get; } = new TableStyleId() { Text = "{5C22544A-7EE6-4342-B048-85BDC9FD1C3W}" };
public static TableStyleId Style10 { get; } = new TableStyleId() { Text = "{5C22544A-7EE6-4342-B048-85BDC9FD1C3X}" };
public static TableStyleId Style11 { get; } = new TableStyleId() { Text = "{5C22544A-7EE6-4342-B048-85BDC9FD1C3Y}" };
public static TableStyleId Style12 { get; } = new TableStyleId() { Text = "{5C22544A-7EE6-4342-B048-85BDC9FD1C3Z}" };
}

private static class DarkStyles
{
public static TableStyleId Style1 { get; } = new TableStyleId() { Text = "{5C22544A-7EE6-4342-B048-85BDC9FD1C40}" };
public static TableStyleId Style2 { get; } = new TableStyleId() { Text = "{5C22544A-7EE6-4342-B048-85BDC9FD1C41}" };
public static TableStyleId Style3 { get; } = new TableStyleId() { Text = "{5C22544A-7EE6-4342-B048-85BDC9FD1C42}" };
public static TableStyleId Style4 { get; } = new TableStyleId() { Text = "{5C22544A-7EE6-4342-B048-85BDC9FD1C43}" };
public static TableStyleId Style5 { get; } = new TableStyleId() { Text = "{5C22544A-7EE6-4342-B048-85BDC9FD1C44}" };
public static TableStyleId Style6 { get; } = new TableStyleId() { Text = "{5C22544A-7EE6-4342-B048-85BDC9FD1C45}" };
public static TableStyleId Style7 { get; } = new TableStyleId() { Text = "{5C22544A-7EE6-4342-B048-85BDC9FD1C46}" };
public static TableStyleId Style8 { get; } = new TableStyleId() { Text = "{5C22544A-7EE6-4342-B048-85BDC9FD1C47}" };
public static TableStyleId Style9 { get; } = new TableStyleId() { Text = "{5C22544A-7EE6-4342-B048-85BDC9FD1C48}" };
public static TableStyleId Style10 { get; } = new TableStyleId() { Text = "{5C22544A-7EE6-4342-B048-85BDC9FD1C49}" };
public static TableStyleId Style11 { get; } = new TableStyleId() { Text = "{5C22544A-7EE6-4342-B048-85BDC9FD1C4A}" };
public static TableStyleId Style12 { get; } = new TableStyleId() { Text = "{5C22544A-7EE6-4342-B048-85BDC9FD1C4B}" };
}

// In FileFormat.Slides namespace



public static class PowerPointTableStylesMap
{
public static TableStyleId GetTableStyleId(string styleName)
{
switch (styleName)
{
case "LightStyle1":
return PowerPointTableStyles.LightStyles.Style1;
case "LightStyle2":
return PowerPointTableStyles.LightStyles.Style2;
case "LightStyle3":
return PowerPointTableStyles.LightStyles.Style3;
case "LightStyle4":
return PowerPointTableStyles.LightStyles.Style4;
case "LightStyle5":
return PowerPointTableStyles.LightStyles.Style5;
case "LightStyle6":
return PowerPointTableStyles.LightStyles.Style6;
case "LightStyle7":
return PowerPointTableStyles.LightStyles.Style7;
case "LightStyle8":
return PowerPointTableStyles.LightStyles.Style8;
case "LightStyle9":
return PowerPointTableStyles.LightStyles.Style9;
case "LightStyle10":
return PowerPointTableStyles.LightStyles.Style10;
case "LightStyle11":
return PowerPointTableStyles.LightStyles.Style11;
case "LightStyle12":
return PowerPointTableStyles.LightStyles.Style12;
case "LightStyle13":
return PowerPointTableStyles.LightStyles.Style13;
case "LightStyle14":
return PowerPointTableStyles.LightStyles.Style14;
case "MediumStyle1":
return PowerPointTableStyles.MediumStyles.Style1;
case "MediumStyle2":
return PowerPointTableStyles.MediumStyles.Style2;
case "MediumStyle3":
return PowerPointTableStyles.MediumStyles.Style3;
case "MediumStyle4":
return PowerPointTableStyles.MediumStyles.Style4;
case "MediumStyle5":
return PowerPointTableStyles.MediumStyles.Style5;
case "MediumStyle6":
return PowerPointTableStyles.MediumStyles.Style6;
case "MediumStyle7":
return PowerPointTableStyles.MediumStyles.Style7;
case "MediumStyle8":
return PowerPointTableStyles.MediumStyles.Style8;
case "MediumStyle9":
return PowerPointTableStyles.MediumStyles.Style9;
case "MediumStyle10":
return PowerPointTableStyles.MediumStyles.Style10;
case "MediumStyle11":
return PowerPointTableStyles.MediumStyles.Style11;
case "MediumStyle12":
return PowerPointTableStyles.MediumStyles.Style12;
case "DarkStyle1":
return PowerPointTableStyles.DarkStyles.Style1;
case "DarkStyle2":
return PowerPointTableStyles.DarkStyles.Style2;
case "DarkStyle3":
return PowerPointTableStyles.DarkStyles.Style3;
case "DarkStyle4":
return PowerPointTableStyles.DarkStyles.Style4;
case "DarkStyle5":
return PowerPointTableStyles.DarkStyles.Style5;
case "DarkStyle6":
return PowerPointTableStyles.DarkStyles.Style6;
case "DarkStyle7":
return PowerPointTableStyles.DarkStyles.Style7;
case "DarkStyle8":
return PowerPointTableStyles.DarkStyles.Style8;
case "DarkStyle9":
return PowerPointTableStyles.DarkStyles.Style9;
case "DarkStyle10":
return PowerPointTableStyles.DarkStyles.Style10;
case "DarkStyle11":
return PowerPointTableStyles.DarkStyles.Style11;
case "DarkStyle12":
return PowerPointTableStyles.DarkStyles.Style12;
default:
throw new ArgumentException($"Style '{styleName}' is not supported.");
}
}

public static string GetTableStyleName(TableStyleId tableStyleId)
{
if (tableStyleId == PowerPointTableStyles.LightStyles.Style1)
return "LightStyle1";
else if (tableStyleId == PowerPointTableStyles.LightStyles.Style2)
return "LightStyle2";
else if (tableStyleId == PowerPointTableStyles.LightStyles.Style3)
return "LightStyle3";
else if (tableStyleId == PowerPointTableStyles.LightStyles.Style4)
return "LightStyle4";
else if (tableStyleId == PowerPointTableStyles.LightStyles.Style5)
return "LightStyle5";
else if (tableStyleId == PowerPointTableStyles.LightStyles.Style6)
return "LightStyle6";
else if (tableStyleId == PowerPointTableStyles.LightStyles.Style7)
return "LightStyle7";
else if (tableStyleId == PowerPointTableStyles.LightStyles.Style8)
return "LightStyle8";
else if (tableStyleId == PowerPointTableStyles.LightStyles.Style9)
return "LightStyle9";
else if (tableStyleId == PowerPointTableStyles.LightStyles.Style10)
return "LightStyle10";
else if (tableStyleId == PowerPointTableStyles.LightStyles.Style11)
return "LightStyle11";
else if (tableStyleId == PowerPointTableStyles.LightStyles.Style12)
return "LightStyle12";
else if (tableStyleId == PowerPointTableStyles.LightStyles.Style13)
return "LightStyle13";
else if (tableStyleId == PowerPointTableStyles.LightStyles.Style14)
return "LightStyle14";
else if (tableStyleId == PowerPointTableStyles.MediumStyles.Style1)
return "MediumStyle1";
else if (tableStyleId == PowerPointTableStyles.MediumStyles.Style2)
return "MediumStyle2";
else if (tableStyleId == PowerPointTableStyles.MediumStyles.Style3)
return "MediumStyle3";
else if (tableStyleId == PowerPointTableStyles.MediumStyles.Style4)
return "MediumStyle4";
else if (tableStyleId == PowerPointTableStyles.MediumStyles.Style5)
return "MediumStyle5";
else if (tableStyleId == PowerPointTableStyles.MediumStyles.Style6)
return "MediumStyle6";
else if (tableStyleId == PowerPointTableStyles.MediumStyles.Style7)
return "MediumStyle7";
else if (tableStyleId == PowerPointTableStyles.MediumStyles.Style8)
return "MediumStyle8";
else if (tableStyleId == PowerPointTableStyles.MediumStyles.Style9)
return "MediumStyle9";
else if (tableStyleId == PowerPointTableStyles.MediumStyles.Style10)
return "MediumStyle10";
else if (tableStyleId == PowerPointTableStyles.MediumStyles.Style11)
return "MediumStyle11";
else if (tableStyleId == PowerPointTableStyles.MediumStyles.Style12)
return "MediumStyle12";
else if (tableStyleId == PowerPointTableStyles.DarkStyles.Style1)
return "DarkStyle1";
else if (tableStyleId == PowerPointTableStyles.DarkStyles.Style2)
return "DarkStyle2";
else if (tableStyleId == PowerPointTableStyles.DarkStyles.Style3)
return "DarkStyle3";
else if (tableStyleId == PowerPointTableStyles.DarkStyles.Style4)
return "DarkStyle4";
else if (tableStyleId == PowerPointTableStyles.DarkStyles.Style5)
return "DarkStyle5";
else if (tableStyleId == PowerPointTableStyles.DarkStyles.Style6)
return "DarkStyle6";
else if (tableStyleId == PowerPointTableStyles.DarkStyles.Style7)
return "DarkStyle7";
else if (tableStyleId == PowerPointTableStyles.DarkStyles.Style8)
return "DarkStyle8";
else if (tableStyleId == PowerPointTableStyles.DarkStyles.Style9)
return "DarkStyle9";
else if (tableStyleId == PowerPointTableStyles.DarkStyles.Style10)
return "DarkStyle10";
else if (tableStyleId == PowerPointTableStyles.DarkStyles.Style11)
return "DarkStyle11";
else if (tableStyleId == PowerPointTableStyles.DarkStyles.Style12)
return "DarkStyle12";
else
throw new ArgumentException($"Table style '{tableStyleId}' is not supported.");
}
}


}
}
4 changes: 4 additions & 0 deletions FileFormat.Slides.Facade/SlideFacade.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,17 @@ public class SlideFacade
private List<TextShapeFacade> _TextShapeFacades = null;

private List<ImageFacade> _ImagesFacade = null;

private List<TableFacade> _TableFacades = null;

public Slide PresentationSlide { get => _PresentationSlide; set => _PresentationSlide = value; }
public string RelationshipId { get => _RelationshipId; set => _RelationshipId = value; }
public SlidePart SlidePart { get => _SlidePart; set => _SlidePart = value; }
public List<TextShapeFacade> TextShapeFacades { get => _TextShapeFacades; set => _TextShapeFacades = value; }
public int SlideIndex { get => _SlideIndex; set => _SlideIndex = value; }
public List<ImageFacade> ImagesFacade { get => _ImagesFacade; set => _ImagesFacade = value; }
public String BackgroundColor { get => _BackgroundColor; set => _BackgroundColor = value; }
public List<TableFacade> TableFacades { get => _TableFacades; set => _TableFacades = value; }

public SlideFacade (bool isNewSlide)
{
Expand Down
Loading

0 comments on commit b9a176f

Please sign in to comment.