Reputation: 3
How can I delete master slides and all slides depending on these master slides, which should be deleted?
If deleting does not work, perhaps there is a workaround? E.g.
I tried to delete master slides this way: If I do this from the array (see below function I used) that contains the layout subfiles xml data, the powerpoint file gets corrupt and I have to repair it when I open it. Then I see that the deleted master slide has been replaced by an empty (default) one.
$files = $TBS->Plugin(OPENTBS_GET_FILES);
Thanks for any ideas
Upvotes: 0
Views: 59
Reputation: 5552
You can delete slides using:
$TBS->PlugIn(OPENTBS_DELETE_SLIDES, …);
But for now it cannot delete Master Slides (OpenTBS 1.12.1).
And you can hide (or display) slides using:
$TBS->PlugIn(OPENTBS_DISPLAY_SLIDES, …);
OpenTBS has no provided feature for finding slides corresponding to a specific Master Slide, but the following code gives you the list of Slides in the PPTX and their Layout / Master Slide information.
You can use it to deleted the targeted slides. And leave unused Master Slides remain in the PPTX.
// Establish the list of Layouts an their associated MasterSlides
$layout_lst = array();
$file_master_lst = $TBS->Plugin(OPENTBS_GET_FILES_BY_TYPE, 'slidem');
foreach ($file_master_lst as $file) {
$name = basename($file); // name of the file
$rel_file = dirname($file) . '/_rels/' . $name . '.rels'; // path of the corresponding rel file
$TBS->PlugIn(OPENTBS_SELECT_FILE, $rel_file); // open a read the rel file
$pattern = '|Target=\"\.\.\/slideLayouts\/([^"]*)|'; // layouts of the master slide
preg_match_all($pattern, $TBS->Source, $matches);
foreach ($matches[1] as $m) {
$layout_lst[$m] = $name;
}
}
// Establish the list of Slides an their associated MasterSlides and Layouts
$slide_lst = array();
$file_slide_lst = $TBS->Plugin(OPENTBS_GET_FILES_BY_TYPE, 'slide');
foreach ($file_slide_lst as $file) {
$name = basename($file); // name of the file
$rel_file = dirname($file) . '/_rels/' . $name . '.rels'; // path of the corresponding rel file
$TBS->PlugIn(OPENTBS_SELECT_FILE, $rel_file); // open a read the rel file
$pattern = '|Target=\"\.\.\/slideLayouts\/([^"]*)|'; // layout of the slide
preg_match_all($pattern, $TBS->Source, $matches);
foreach ($matches[1] as $m) {
$slide_lst[] = array(
'file_path' => $file,
'file_name' => $name,
'layout' => $m,
'masterSlide' => $layout_lst[$m],
);
}
}
var_export($slide_lst);
Upvotes: 0