Skip to content

Commit a3d802f

Browse files
v24.2.0 updates
1 parent 5b59373 commit a3d802f

File tree

10 files changed

+892
-25
lines changed

10 files changed

+892
-25
lines changed

FileFormat.Slides-Test/Program.cs

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,75 @@ static void Main ()
209209
210210
presentation.Save();
211211
*/
212+
213+
/* Presentation presentation = Presentation.Open("D:\\AsposeSampleData\\test.pptx");
214+
Slide slide = presentation.GetSlides()[2];
212215
216+
// Assign values to the properties of Stylings
217+
Stylings stylings = new Stylings();
218+
stylings.FontSize = 14;
219+
stylings.Alignment = FileFormat.Slides.Common.Enumerations.TextAlignment.Left;
220+
stylings.FontFamily = "Baguet Script";
221+
stylings.TextColor = Colors.Red;
222+
223+
Table table = new Table();
224+
225+
table.TableStylings = stylings;
226+
TableColumn col1 = new TableColumn();
227+
col1.Name = "ID";
228+
table.Columns.Add(col1);
229+
TableColumn col2 = new TableColumn();
230+
col2.Name = "Name";
231+
table.Columns.Add(col2);
232+
TableColumn col3 = new TableColumn();
233+
col3.Name = "City";
234+
table.Columns.Add(col3);
235+
//1st row
236+
// Assign values to the properties of Stylings
237+
Stylings rowstylings = new Stylings();
238+
rowstylings.FontSize = 14;
239+
rowstylings.Alignment = FileFormat.Slides.Common.Enumerations.TextAlignment.Left;
240+
rowstylings.FontFamily = "Baguet Script";
241+
rowstylings.TextColor = Colors.Green;
242+
TableRow row1 = new TableRow(table);
243+
row1.RowStylings = rowstylings;
244+
TableCell cell11 = new TableCell(row1);
245+
cell11.Text = "907";
246+
cell11.ID = col1.Name;
247+
row1.AddCell(cell11);
248+
TableCell cell12 = new TableCell(row1);
249+
cell12.Text = "John";
250+
cell12.ID = col2.Name;
251+
row1.AddCell(cell12);
252+
TableCell cell13 = new TableCell(row1);
253+
cell13.Text = "Chicago";
254+
cell13.ID = col3.Name;
255+
row1.AddCell(cell13);
256+
table.AddRow(row1);
257+
258+
//2nd Row
259+
TableRow row2 = new TableRow(table);
260+
TableCell cell21 = new TableCell(row2);
261+
cell21.Text = "908";
262+
cell21.ID = col1.Name;
263+
row2.AddCell(cell21);
264+
TableCell cell22 = new TableCell(row2);
265+
cell22.Text = "Chris";
266+
cell22.ID = col2.Name;
267+
row2.AddCell(cell22);
268+
TableCell cell23 = new TableCell(row2);
269+
cell23.Text = "New York";
270+
cell23.ID = col3.Name;
271+
row2.AddCell(cell23);
272+
table.AddRow(row2);
273+
274+
table.Width = 500.0;
275+
table.Height = 200.0;
276+
table.X = 300.0;
277+
table.Y = 500.0;
278+
slide.AddTable(table);
279+
280+
presentation.Save();*/
213281

214282
}
215283

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Data;
4+
using System.Text;
5+
6+
namespace FileFormat.Slides.Common
7+
{
8+
public static class SampleData
9+
{
10+
public static DataTable GenerateSampleDataTable ()
11+
{
12+
// Create a DataTable with columns
13+
DataTable dataTable = new DataTable();
14+
dataTable.Columns.Add("ID", typeof(int));
15+
dataTable.Columns.Add("Name", typeof(string));
16+
dataTable.Columns.Add("Email", typeof(string));
17+
18+
// Add the first row
19+
DataRow row1 = dataTable.NewRow();
20+
row1["ID"] = 897;
21+
row1["Name"] = "Umar";
22+
row1["Email"] = "[email protected]";
23+
dataTable.Rows.Add(row1);
24+
25+
// Add the second row
26+
DataRow row2 = dataTable.NewRow();
27+
row2["ID"] = 897;
28+
row2["Name"] = "Asif";
29+
row2["Email"] = "[email protected]";
30+
dataTable.Rows.Add(row2);
31+
32+
return dataTable;
33+
}
34+
}
35+
}

FileFormat.Slides.Common/Utility.cs

Lines changed: 77 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System;
1+
using FileFormat.Slides.Common.Enumerations;
2+
using System;
23
using System.Collections.Generic;
34
using System.Text;
45

@@ -63,8 +64,18 @@ public static long PixelsToEmu (double pixelsValue)
6364

6465
return (long)(pixelsValue * emuPerInch / pixelsPerInch);
6566
}
66-
67-
67+
public static Stylings DeserializeStyling(string stylingInfo)
68+
{
69+
// Here you would deserialize the styling information from the string format
70+
// For example, JSON deserialization
71+
return Newtonsoft.Json.JsonConvert.DeserializeObject<Stylings>(stylingInfo);
72+
}
73+
public static string SerializeStyling(Stylings styling)
74+
{
75+
// Here you would serialize the styling object into a string format
76+
// For simplicity, let's assume it's JSON serialization
77+
return Newtonsoft.Json.JsonConvert.SerializeObject(styling);
78+
}
6879

6980
}
7081
/// <summary>
@@ -193,4 +204,67 @@ public static string ConstructMessage (Exception Ex, string Operation)
193204
return $"Error in Operation {Operation} at FileFormat.Words: {Ex.Message} \n Inner Exception: {Ex.InnerException?.Message ?? "N/A"}";
194205
}
195206
}
207+
208+
/// <summary>
209+
/// Represents the stylings applied to text elements.
210+
/// </summary>
211+
public struct Stylings
212+
{
213+
private int _fontSize;
214+
private TextAlignment _alignment;
215+
private string _fontFamily;
216+
private string _textColor;
217+
218+
/// <summary>
219+
/// Initializes a new instance of the Stylings struct with default values.
220+
/// </summary>
221+
/// <param name="fontSize">The font size (default is 12).</param>
222+
/// <param name="alignment">The text alignment (default is TextAlignment.Left).</param>
223+
/// <param name="fontFamily">The font family (default is "Calibri").</param>
224+
/// <param name="textColor">The text color in hexadecimal format (default is "#000000").</param>
225+
public Stylings(int fontSize = 12, TextAlignment alignment = TextAlignment.Left, string fontFamily = "Calibri", string textColor = "#000000")
226+
{
227+
_fontSize = fontSize;
228+
_alignment = alignment;
229+
_fontFamily = fontFamily;
230+
_textColor = textColor;
231+
}
232+
233+
/// <summary>
234+
/// Gets or sets the font size.
235+
/// </summary>
236+
public int FontSize
237+
{
238+
get => _fontSize;
239+
set => _fontSize = value;
240+
}
241+
242+
/// <summary>
243+
/// Gets or sets the text alignment.
244+
/// </summary>
245+
public TextAlignment Alignment
246+
{
247+
get => _alignment;
248+
set => _alignment = value;
249+
}
250+
251+
/// <summary>
252+
/// Gets or sets the font family.
253+
/// </summary>
254+
public string FontFamily
255+
{
256+
get => _fontFamily;
257+
set => _fontFamily = value ?? "Calibri"; // Set default value if null
258+
}
259+
260+
/// <summary>
261+
/// Gets or sets the text color in hexadecimal format.
262+
/// </summary>
263+
public string TextColor
264+
{
265+
get => _textColor;
266+
set => _textColor = value ?? "#000000"; // Set default value if null
267+
}
268+
}
269+
196270
}

FileFormat.Slides.Facade/SlideFacade.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ public void AddImage (ImageFacade picture )
179179
{
180180
_PresentationSlide.CommonSlideData.ShapeTree.Append(picture.Image);
181181
}
182-
182+
183183
public void Update ()
184184
{
185185
this.SetSlideBackground(_BackgroundColor);

0 commit comments

Comments
 (0)