Free Support Forum - aspose.com

mainMaster

Hi,

can you help me about this:
Why text
"Click to edit Master title style
Click to edit Master subtitle style" from mainMaster is printed when execute the following code, code print just the text that is not textHolder?

public class MainMasterTest {
private void iterateMainShapes(Shapes sld) {
for (int shpIdx = 0; shpIdx < sld.size(); shpIdx++) {
Shape shp = sld.get(shpIdx);
Paragraphs paras = null;
// Check if shape holds a textholder
if (shp.getPlaceholder() != null && shp.isTextHolder() == true) {
// Get the place holder as an Object instance
Object obj = shp.getPlaceholder();
// First type of place holder. It is TextHolder
if (obj instanceof TextHolder) {
// Cast object into TextHolder object
TextHolder txtHolder = (TextHolder) obj;
paras = txtHolder.getParagraphs();
// iterateParagraphs(paras, portionList);
} else if (obj instanceof Placeholder) // Second type of place
// holder(Shape)
{
// Cast the object into Placeholder object
Placeholder placeHolder = (Placeholder) obj;
// getShapeRef() returns the Shape object which contains
// real properties of a Placeholder.
paras = placeHolder.getShapeRef().getTextFrame()
.getParagraphs();
// iterateParagraphs(paras, portionList);
}
} else {
if (!shp.isTextHolder()) {
if (shp.getTextFrame() != null) {
paras = shp.getTextFrame().getParagraphs();
}// if
}// else
// Print the text on Console
if (paras != null) {
int parasCount = paras.size();
for (int paraIdx = 0; paraIdx < parasCount; paraIdx++) {
Paragraph para = paras.get(paraIdx);
// print the text on console
System.out.println(para.getText());
}
}// end if
}
}
}

@Test
public void mainMasterTest() {
try {
Presentation presentation = new Presentation(new FileInputStream(
new File("D:/Bojan/20101227_PPT/_102_FINAL EEM Complete Deck - For Translation.ppt")));
Slide mainMaster = presentation.getMainMaster();
Shapes shapes = mainMaster.getShapes();
iterateMainShapes(shapes);
} catch (Exception e) {
System.out.println(e.toString());
}
}
}

Hi Bojan,


I have worked with the code snippet shared by you along with presentation shared. In your code you are accessing the slide main master and accessing the shapes inside for displaying the text inside their text frames. I have opened the presentation is slide master view and have seen the text inside the master title slide. It has two text holders inside it that contains the same text that you have referred and it display that correctly. If I am missing some thing here then please kindly elaborate in more detail that what out put you were expecting. In my humble suggestion the output that has been exhibited is fine. For your kind reference, I have shared the print screen of master title slide and it contains the same text that is shown while code traversal.

Many Thanks,
Thanks for help,

but, with this code I want to get all text from mainMaster that is not generic, ie shape who is not TextHolder. Here is a simpler code. You say "It has two text holders inside it that contains the same text that you have referred and it display that correctly. " but in code I have conditions "if (!shp.isTextHolder())". That is a problem.

public class MainMasterTest {
private void iterateMainShapes(Shapes sld) {
for (int shpIdx = 0; shpIdx < sld.size(); shpIdx++) {
Shape shp = sld.get(shpIdx);
Paragraphs paras = null;
if (!shp.isTextHolder()) {
if (shp.getTextFrame() != null) {
paras = shp.getTextFrame().getParagraphs();
}
if (paras != null) {
int parasCount = paras.size();
for (int paraIdx = 0; paraIdx < parasCount; paraIdx++) {
Paragraph para = paras.get(paraIdx);
System.out.println(para.getText());
}
}
}
}
}

@Test
public void mainMasterTest() {
try {
Presentation presentation = new Presentation(
"D:/Bojan/20101227_PPT/_102_FINAL EEM Complete Deck - For Translation.ppt");
Slide mainMaster = presentation.getMainMaster();
Shapes shapes = mainMaster.getShapes();
iterateMainShapes(shapes);
} catch (Exception e) {
System.out.println(e.toString());
}
}
}
Thanks,
Bojan

Hi Bojan,


I am still trying to completely understand the issue shared by you. Please proceed to this documentation link for extracting text from all shapes inside slide. I also like to comment that there are different types of shapes that can contain text inside them. Some are placeholders that have text text holders inside them, some shapes are text holders, some shapes are rectangles or others and have text inside them. So, one need to traverse every type of shape. The link that I have shared with you extract entire text from each type of shape inside slide. You can alter the slide to master slide and make things workable for you. Please share, if I may help you any further in this regard.

Many Thanks,
Many thanks for help,

you are help me for this but I have problem with attached file when change text in mainMaster in TextFrame, like in follow code, saved file cannot open in PowerPoint. Can you check this.

public class MainMasterTest {

private void iterateMainShapes(Shapes sld) {

for (int shpIdx = 0; shpIdx < sld.size(); shpIdx++) {
Shape shp = sld.get(shpIdx);

Paragraphs paras = null;

if (shp.getTextFrame() != null) {
paras = shp.getTextFrame().getParagraphs();
}
if (paras != null) {
int parasCount = paras.size();
for (int paraIdx = 0; paraIdx < parasCount; paraIdx++) {
Paragraph para = paras.get(paraIdx);
System.out.println(para.getText());
para.setText("asasfasf");
}
}
}
}

@Test
public void mainMasterTest() {

try {
Presentation presentation = new Presentation(
"D:/Bojan/20101227_PPT1/_102_FINAL EEM Complete Deck - For Translation.ppt");

Slide mainMaster = presentation.getMainMaster();

Shapes shapes = mainMaster.getShapes();

iterateMainShapes(shapes);

presentation.save("D:/Bojan/20101227_PPT1/Sad11.ppt", SaveFormat.PPT);

} catch (Exception e) {
System.out.println(e.toString());
}
}
}

Thanks,
Bojan

Hi Bojan,


I have worked with the presentation and code snippet shared by you and have been able to observe the issue. An issue with ID 31938 has been created in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be automatically notified once the issue is resolved.

We are sorry for your inconvenience,

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


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