Skip to content

Commit 8f17a98

Browse files
committed
Bug fix: incorrect processing of "Section Title" slides
1 parent dcbe05c commit 8f17a98

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

SoftUni-PowerPoint-Converter/SoftUniPowerPointConverter.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public static void ConvertAndFixPresentation(string pptSourceFileName,
8484
{
8585
if (!appWindowVisible)
8686
{
87-
// Quit the MS Word application
87+
// Quit the MS PowerPoint application
8888
pptApp.Quit();
8989

9090
// Release any associated .NET proxies for the COM objects, which are not in use
@@ -357,6 +357,7 @@ static void FixSectionTitleSlides(Presentation presentation)
357357
{
358358
// Collect the texts from the slide (expecting title and subtitle)
359359
List<string> slideTexts = new List<string>();
360+
List<Shape> shapesForDelete = new List<Shape>();
360361
foreach (Shape shape in slide.Shapes)
361362
{
362363
try
@@ -368,7 +369,7 @@ static void FixSectionTitleSlides(Presentation presentation)
368369
&& shape.TextFrame.TextRange.Text != "")
369370
{
370371
slideTexts.Add(shape.TextFrame.TextRange.Text);
371-
shape.Delete();
372+
shapesForDelete.Add(shape);
372373
}
373374
}
374375
catch (Exception)
@@ -377,8 +378,14 @@ static void FixSectionTitleSlides(Presentation presentation)
377378
}
378379
}
379380

380-
// Put the slide texts into the placeholders (and delete the empty placeholders)
381-
for (int i = 0; i < slide.Shapes.Placeholders.Count; i++)
381+
// Delete all shapes, holding the slide texts
382+
foreach (var shape in shapesForDelete)
383+
{
384+
shape.Delete();
385+
}
386+
387+
// Put the slide texts into the placeholders (and delete the empty placeholders)
388+
for (int i = 0; i < slide.Shapes.Placeholders.Count; i++)
382389
{
383390
Shape placeholder = slide.Shapes.Placeholders[i+1];
384391
if (i < slideTexts.Count)

0 commit comments

Comments
 (0)