Master slide layouts

Hi.


I need to pick up all the text from master slides.
I tried with the following code:

Presentation presentation = new Presentation(“d:/master-slides.ppt”);
Slide slide = presentation.getMainMaster();
Shapes shapes = slide.getShapes();
for (int j = 0; j < shapes.getCount(); j++) {
Shape shape = shapes.get_Item(j);
if(!shape.isTextHolder()) {
TextFrame textFrame = shape.getTextFrame();
if (textFrame != null) System.out.println(textFrame.getText());
}
}

but it is picking up only text from MainMaster slide (and not from layout slides related to master slide). I also tried with following code:

Presentation presentation = new Presentation(“d:/master-slides.ppt”);
Slides slides = presentation.getMasters();
for (int i = 0; i < slides.getCount(); i++) {
Slide slide = slides.get_Item(i);
Shapes shapes = slide.getShapes();
for (int j = 0; j < shapes.getCount(); j++) {
Shape shape = shapes.get_Item(j);
if (!shape.isTextHolder()) {
TextFrame textFrame = shape.getTextFrame();
if (textFrame != null)
System.out.println("From " + (i + 1) + ". slide: "
+ textFrame.getText());
}
}
}

and it is picking up text from MainMaster slide and layout slides related to it but for every layout slide it prints every textbox inherited from MainMaster slide. This duplicates this kind of text. Can you tell me how to pick up all the text from master slides but not to duplicate text from layout slides that is inherited from MainMaster slide?

Thanks,
Slavko

Hi Slavko,


I have observed your requirements and have been able to reproduce the issue. Actually, there is a property getMasterShapeId() for the shape that gives you the master shape id if the shape is inherited from master. In your presentation case although the one textbox is inherited in all layout slides but the MasterShapeId for the inherited shape is returning 0 instead of actual master shape ID which is inherited. This seems to be an issue and I have created an issue with ID SLIDESJAVA-33895 in our issue tracking system to further investigate and resolve the issue. Once this issue will be fixed, you will get automatically notified if any shape is inherited or not. For inherited shape, you can skip the extraction.

For the time being, I suggest you to use Alternative Text property for the shape that is to be inherited in layout slides. So, you check the inherited shape with Alternative Text property and can skip it. The following sample code may serve the purpose for you temporarily. I have modified your source presentation by setting Alternative Text property for the inherited shape only.

public static void ExtractLayoutSlideText()throws Exception
{
Presentation presentation = new Presentation(“d:/Aspose Data/master-slides.ppt”);
SlideCollection slides = presentation.getMasters();
int firstTime=0;
// SlideCollection slides = presentation.getSlides();
int cnt= slides.getCount();
for (int i = 0; i <cnt; i++) {
Slide slide = slides.get_Item(i);
Shapes shapes = slide.getShapes();
for (int j = 0; j < shapes.getCount(); j++) {
Shape shape = shapes.get_Item(j);
int masterShapeID=shape.getMasterShapeId();
// System.out.println(“masterShapeID: " + masterShapeID +” ShapeID: “+shape.getShapeId()+” Alternative Text: “+shape.getAlternativeText()+”\n");
if(!shape.getAlternativeText().matches(“MasterShape”))
{
if (!shape.isTextHolder() )
{
// firstTime++;
TextFrame textFrame = shape.getTextFrame();
if (textFrame != null)
System.out.println("From " + (i + 1) + ". slide: "
+ textFrame.getText());
}
}
else
{

if (!shape.isTextHolder() && firstTime==0 )
{
firstTime++;
// firstTime++;
TextFrame textFrame = shape.getTextFrame();
if (textFrame != null)
System.out.println("From " + (i + 1) + ". slide: "
+ textFrame.getText());
}

}
}
}
}


Many Thanks,

The issues you have found earlier (filed as SLIDESJAVA-33895) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.

Hi Slavko,


Our development team has investigated the issue and have not found the reported issue as bug. Actually, If you open “./master-slides.ppt” in PowerPoint 2003, you can see 4 main master slides and can see that shapes “This is main page master Slide text box” are not inherited. Each main master slide contain its own independent shape “This is main page master Slide text box”. Our development team has also checked binary representation of “./master-slides.ppt” and I confirmed that MasterID in binaries of these shapes is 0.
Note that custom slide layouts is new feature of PPTX (PowerPoint 2007). PPT presentation can use prepackaged layouts and can have only main master slides, title master slides and slides.
So I think that repeating of this shapes and MasterId of 0 are not errors.

Many Thanks,