OpenXML - PresentationML - newMasterPart.SlideMaster.Preserve = false, is not working

494 views Asked by At

I'm trying to use the Preserve attribute of Slide Master, in order to clear unreferenced Slide Masters.

My aim is to clone all slides in a presentation(has only one slide) to a base presentation(has only one slide) and change the layout of the cloned slides to the layout of the base presentation.

The approach I took was,

(Base presentation denoted as B, to be cloned presentation is denoted as C)

Copy the slide part of the slide of C into B.

Copy the master of the C into B.

Set the SlideMaster.Preserve attribute to false in newly copied master.

Delete existing layout parts of the newly added slides pars in B(cloned slides from C).

Add the required layout part from B to the newly added slide parts.

Traverse through LayoutId's and re order them to contain unique values.

But when I open the resultant file, although there are no reference to the MasterSlide copied from C. It still exists.

Note: Although i change the layout slide in the same code snippet, in practice it will be performed at a different execution path, hence not coping the MasterSlides of C is not an option.

Base Presentation (B) enter image description here

Master Slide of Base enter image description here

Clone presentation (C) enter image description here

Master Slide of Clone presentation enter image description here

Resultant Output enter image description here

Master slides of Output enter image description here

Although there is no references to the second master slide, it still prevails even after setting the preserve attribute to false.

A code sample is can be dowloaded from Post2.zip

Files in Post2:

BaseSlide.pptx (basepresentation)

ToBeCloned.pptx (clone presentation)

Out2.pptx (resulting presentation)

Any help is greatly appreciated. Thanks.

0

There are 0 answers