Open
Description
Describe the bug
My code repeatedly works on the same powerpoint file.
-My code attaches MP3 audio
-My code attaches playfrom timing to play automatically
-My code attaches transition to next slide after x milliseconds
The transition seems to cause the XML to be malformed. After saving the resulting file in PowerPoint, closing the file and reopening the timing and transition are not executed anymore as if they do not exist.
To Reproduce
public static void AddTransitionAfterMilliseconds(SlidePart slidePart, long milliseconds)
{
// Create a new Transition element.
Transition transition = new Transition();
transition.AdvanceAfterTime = milliseconds.ToString(); // time in milliseconds
transition.AdvanceOnClick = false; // do not allow click to advance
CommonSlideData commonSlideData = slidePart.Slide.CommonSlideData!;
// Check for an existing transition and remove it if present.
var transitions = commonSlideData.Elements<Transition>().ToList();
foreach (var tr in transitions)
{
tr.Remove();
}
transitions = slidePart.Slide.Elements<Transition>().ToList();
foreach (var tr in transitions)
{
tr.Remove();
}
var alternateContents = slidePart.Slide.Descendants<AlternateContent>().ToList();
foreach (var altContent in alternateContents)
{
transitions = altContent.Elements<Transition>().ToList();
foreach (var tr in transitions)
{
tr.Remove();
}
}
// Append the transition element to CommonSlideData.
commonSlideData.Append(transition);
slidePart.Slide.Save();
}
Steps to reproduce the behavior:
- apply the transition with the previous code
Observed behavior
Structure of slide.xml is malformed
Expected behavior
After opening and saving with newest PowerPoint (this causes structural changes) the audio are still played and transition executed.
Desktop (please complete the following information):
- OS: [e.g. Windows]
- Office version: Microsoft® PowerPoint® für Microsoft 365 MSO (Version 2501 Build 16.0.18429.20132) 64 Bit
- .NET Target: .NET core 8.0.13
- DocumentFormat.OpenXml Version: 3.2
Metadata
Metadata
Assignees
Labels
No labels
Activity