Skip to content

Commit e5280c1

Browse files
Added 24.4.0
1 parent b9a176f commit e5280c1

17 files changed

+623
-63
lines changed

FileFormat.Slides-Test/Program.cs

+51-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
using FileFormat.Slides.Common;
99

1010

11+
1112
class Program
1213
{
13-
static void Main ()
14+
static void Main()
1415
{
1516
/* Create new Presentation
1617
Presentation presentation = Presentation.Create("D:\\AsposeSampleResults\\test2.pptx");
@@ -280,7 +281,7 @@ static void Main ()
280281
281282
presentation.Save();*/
282283

283-
Presentation presentation = Presentation.Open("D:\\AsposeSampleData\\test.pptx");
284+
/*Presentation presentation = Presentation.Open("D:\\AsposeSampleData\\test.pptx");
284285
Slide slide = presentation.GetSlides()[0];
285286
286287
Table table = slide.Tables[0];
@@ -302,7 +303,7 @@ static void Main ()
302303
table.AddRow(row2);
303304
table.Update();
304305
305-
presentation.Save();
306+
presentation.Save();*/
306307

307308
/*Presentation presentation = Presentation.Open("D:\\AsposeSampleData\\test.pptx");
308309
Slide slide = presentation.GetSlides()[0];
@@ -335,7 +336,54 @@ static void Main ()
335336
table.Update();
336337
337338
presentation.Save();*/
339+
/*
340+
Presentation presentation = Presentation.Create("D:\\AsposeSampleResults\\comment.pptx");
341+
CommentAuthor author = new CommentAuthor();
342+
author.Name= "umar";
343+
author.InitialLetter = "u";
344+
author.ColorIndex = 2;
345+
author.Id = 1;
346+
presentation.CreateAuthor(author);
347+
CommentAuthor author2 = new CommentAuthor();
348+
author2.Name = "hp";
349+
author2.InitialLetter = "h";
350+
author2.ColorIndex = 3;
351+
author2.Id = 2;
352+
presentation.CreateAuthor(author2);
353+
354+
Slide slide1 = new Slide();
355+
slide1.SlidePresentation = presentation;
356+
Comment comment1 = new Comment();
357+
comment1.AuthorId = presentation.GetCommentAuthors()[0].Id;
358+
comment1.Text = "First programmatic comment";
359+
comment1.InsertedAt=DateTime.Now;
360+
Comment comment2 = new Comment();
361+
comment2.AuthorId = presentation.GetCommentAuthors()[1].Id;
362+
comment2.Text = "2nd programmatic comment";
363+
comment2.InsertedAt = DateTime.Now;
364+
slide1.AddComment(comment1);
365+
slide1.AddComment(comment2);
366+
presentation.AppendSlide(slide1);
367+
// presentation.RemoveCommentAuthor(presentation.GetCommentAuthors()[0]);
338368
369+
presentation.Save();
370+
*/
371+
/*Presentation presentation = Presentation.Open("D:\\AsposeSampleData\\comment.pptx");
372+
Slide slide = presentation.GetSlides()[0];
373+
var comments=slide.GetComments();
374+
comments[0].Remove();
375+
presentation.Save();*/
376+
377+
/*Presentation presentation = Presentation.Open("D:\\AsposeSampleData\\comment.pptx");
378+
Slide slide = presentation.GetSlides()[0];
379+
Comment comment1 = new Comment();
380+
comment1.AuthorId = presentation.GetCommentAuthors()[1].Id;
381+
comment1.Text = "2nd Programmatic comment in an existing presentation";
382+
comment1.InsertedAt = DateTime.Now;
383+
384+
slide.AddComment(comment1);
385+
presentation.Save();
386+
*/
339387
}
340388

341389
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
using System.Linq;
2+
using System.Text;
3+
using DocumentFormat.OpenXml;
4+
using DocumentFormat.OpenXml.Drawing;
5+
using DocumentFormat.OpenXml.Packaging;
6+
using DocumentFormat.OpenXml.Presentation;
7+
using P = DocumentFormat.OpenXml.Presentation;
8+
using D = DocumentFormat.OpenXml.Drawing;
9+
using Text = DocumentFormat.OpenXml.Drawing.Text;
10+
using NonVisualGroupShapeProperties = DocumentFormat.OpenXml.Presentation.NonVisualGroupShapeProperties;
11+
using P14 = DocumentFormat.OpenXml.Office2010.PowerPoint;
12+
using P15 = DocumentFormat.OpenXml.Office2013.PowerPoint;
13+
using FileFormat.Slides.Common.Enumerations;
14+
using FileFormat.Slides.Common;
15+
using System.Collections.Generic;
16+
using System;
17+
using DocumentFormat.OpenXml.Bibliography;
18+
19+
namespace FileFormat.Slides.Facade
20+
{
21+
public class CommentAuthorFacade
22+
{
23+
private String _Name;
24+
private int _Index;
25+
private String _InitialLetter;
26+
private int _ColorIndex;
27+
28+
public string Name { get => _Name; set => _Name = value; }
29+
public int Index { get => _Index; set => _Index = value; }
30+
public string InitialLetter { get => _InitialLetter; set => _InitialLetter = value; }
31+
public int ColorIndex { get => _ColorIndex; set => _ColorIndex = value; }
32+
public CommentAuthorFacade() { }
33+
34+
public void CreateAuthor( ref CommentAuthorList commentAuthorList1) {
35+
36+
UInt32Value id = new UInt32Value { Value = (uint)_Index };
37+
UInt32Value color_index = new UInt32Value { Value = (uint)_ColorIndex };
38+
CommentAuthor commentAuthor1 = new CommentAuthor() { Id = id, Name = _Name, Initials = _InitialLetter, LastIndex = id, ColorIndex = color_index };
39+
40+
CommentAuthorExtensionList commentAuthorExtensionList1 = new CommentAuthorExtensionList();
41+
42+
CommentAuthorExtension commentAuthorExtension1 = new CommentAuthorExtension() { Uri = "{19B8F6BF-5375-455C-9EA6-DF929625EA0E}" };
43+
44+
P15.PresenceInfo presenceInfo1 = new P15.PresenceInfo() { UserId = _Name, ProviderId = "None" };
45+
presenceInfo1.AddNamespaceDeclaration("p15", "http://schemas.microsoft.com/office/powerpoint/2012/main");
46+
47+
commentAuthorExtension1.Append(presenceInfo1);
48+
49+
commentAuthorExtensionList1.Append(commentAuthorExtension1);
50+
51+
commentAuthor1.Append(commentAuthorExtensionList1);
52+
53+
commentAuthorList1.Append(commentAuthor1);
54+
}
55+
}
56+
}
+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
using System.Linq;
2+
using DocumentFormat.OpenXml;
3+
using DocumentFormat.OpenXml.Packaging;
4+
using DocumentFormat.OpenXml.Presentation;
5+
using P = DocumentFormat.OpenXml.Presentation;
6+
using P14 = DocumentFormat.OpenXml.Office2010.PowerPoint;
7+
using P15 = DocumentFormat.OpenXml.Office2013.PowerPoint;
8+
using FileFormat.Slides.Common;
9+
using System;
10+
11+
12+
namespace FileFormat.Slides.Facade
13+
{
14+
public class CommentFacade
15+
{
16+
private SlidePart _associatedSlidePart;
17+
private CommentAuthorsPart _authorsPart;
18+
private SlideCommentsPart _CommentPart;
19+
private string _relationshipId;
20+
21+
22+
23+
public SlidePart AssociatedSlidePart { get => _associatedSlidePart; }
24+
25+
public string RelationshipId { get => _relationshipId; set => _relationshipId = value; }
26+
public CommentAuthorsPart AuthorsPart { get => _authorsPart; set => _authorsPart = value; }
27+
public SlideCommentsPart CommentPart { get => _CommentPart; set => _CommentPart = value; }
28+
29+
public CommentFacade()
30+
{
31+
32+
}
33+
public void SetAssociatedSlidePart(SlidePart slidePart, CommentAuthorsPart authorPart)
34+
{
35+
// Initialize objects
36+
var commentsPart= slidePart.SlideCommentsPart;
37+
_associatedSlidePart = slidePart;
38+
if (slidePart.SlideCommentsPart == null)
39+
{
40+
_relationshipId = Utility.GetUniqueRelationshipId();
41+
commentsPart = _associatedSlidePart.AddNewPart<SlideCommentsPart>(_relationshipId);
42+
}
43+
AuthorsPart = authorPart;
44+
_CommentPart = commentsPart;
45+
46+
if(_CommentPart.CommentList == null)
47+
_CommentPart.CommentList=new CommentList();
48+
49+
}
50+
51+
public void GenerateComment( UInt32Value authorId, string text, DateTime dateTime, long x, long y)
52+
{
53+
var comment = new Comment()
54+
{
55+
AuthorId = authorId,
56+
DateTime = System.Xml.XmlConvert.ToDateTime(dateTime.ToString("o"), System.Xml.XmlDateTimeSerializationMode.RoundtripKind),
57+
Index = new UInt32Value { Value = (uint)_CommentPart.CommentList.Count() + 1 }
58+
};
59+
60+
P.Position position = new P.Position() { X = x, Y = y };
61+
var commentText = new P.Text() { Text = text };
62+
63+
var commentExtensionList = new CommentExtensionList();
64+
var commentExtension = new CommentExtension() { Uri = "{C676402C-5697-4E1C-873F-D02D1690AC5C}" };
65+
var threadingInfo = new P15.ThreadingInfo() { TimeZoneBias = -300 };
66+
threadingInfo.AddNamespaceDeclaration("p15", "http://schemas.microsoft.com/office/powerpoint/2012/main");
67+
commentExtension.Append(threadingInfo);
68+
commentExtensionList.Append(commentExtension);
69+
70+
comment.Append(position);
71+
comment.Append(commentText);
72+
comment.Append(commentExtensionList);
73+
74+
_CommentPart.CommentList.Append(comment);
75+
}
76+
77+
public void RemoveComment(int id)
78+
{
79+
Comment comment = _CommentPart.CommentList.Elements<Comment>().FirstOrDefault(c => c.Index == id);
80+
comment.Remove();
81+
}
82+
83+
84+
}
85+
}

FileFormat.Slides.Facade/FileFormat.Slides.Facade.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
<PropertyGroup>
44
<TargetFramework>netcoreapp3.1</TargetFramework>
5+
<GenerateDocumentationFile>True</GenerateDocumentationFile>
56
</PropertyGroup>
67

78
<ItemGroup>

0 commit comments

Comments
 (0)