Bug 45150 - Mutiple Textboxes from a Slide all return the same Text.
Summary: Mutiple Textboxes from a Slide all return the same Text.
Status: RESOLVED REMIND
Alias: None
Product: POI
Classification: Unclassified
Component: HSLF (show other bugs)
Version: 3.0-FINAL
Hardware: PC Windows XP
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-06-06 05:23 UTC by Daniel
Modified: 2015-07-07 11:13 UTC (History)
0 users



Attachments
The presentation i want to import. (562.50 KB, application/vnd.ms-powerpoint)
2008-06-06 06:21 UTC, Daniel
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel 2008-06-06 05:23:02 UTC
I use:

Shape[] shapes = slide.getShapes();

for (int i = 0; i < shapes.length; i++) {
 if ( shapes[i] instanceof TextBox ) {
	TextBox textBox = (TextBox) shapes[i];						        System.out.println(textBox.getText());
     }
}

For Example : 

I have 4 Textboxes on a slide.
They are all saved in the Shape[].

The method "getText" always returns the same text even if the texts in the
presentation are different.

Is it just a mistake made by myself or a bug?
Im using Poi 3.0.2 Final.
Comment 1 Yegor Kozlov 2008-06-06 05:52:37 UTC
Please try poi-3.1-beta2. If the problem persists, attach the problem file to this bug. 

Regards,
Yegor 
Comment 2 Daniel 2008-06-06 06:21:03 UTC
Created attachment 22087 [details]
The presentation i want to import.

Its just about the first slide.

Different texts..
I get all the boxes and the borderstyles etc.

but the texts are always the same.

Any suggestions?

Beta 3.1.2 is nearly useless for me because textboxes are handled as autoshapes(?).
Comment 3 Yegor Kozlov 2008-06-06 06:32:32 UTC
AutoShape extends TextShape. See the javadocs.

Change your code as follows and try 3.1-beta2. 

for (int i = 0; i < shapes.length; i++) {
 if ( shapes[i] instanceof TextShape) {
        TextShape textBox = (TextShape) shapes[i];                                 
                System.out.println(textBox.getText());
     }
}

Yegor
Comment 4 Daniel 2008-06-06 07:29:42 UTC
Could you be so nice and show me the way you would walk through the slide

to get

the 4 textboxes
the autoform (leftrightarrow) and how to make a differen bethween them?

im kinda blocked now -.-
Comment 5 Daniel 2008-06-06 07:42:14 UTC
Errr, the different texts from the textboxes are more interesting..


it seems for me as if they all had the same textrun?
no different formatting anymore ...
Comment 6 Yegor Kozlov 2008-06-06 11:51:20 UTC
Where was this presentation created? Which version of PowerPoint or OpenOffice? All shapes have shapeId=0 and this is why HSLF fails to link shapes and text runs. 


Regards,
Yegor
Comment 7 Yegor Kozlov 2008-06-06 11:53:25 UTC
(In reply to comment #4)
> Could you be so nice and show me the way you would walk through the slide
> 
> to get
> 
> the 4 textboxes
> the autoform (leftrightarrow) and how to make a differen bethween them?
> 
> im kinda blocked now -.-
> 

Something like this:

/**
 * Recursively walk the slides and print basic shape properties
 *
 * @author Yegor Kozlov
 */
public class SlideWalker {

    public static void main(String[] args) throws Exception {

        SlideShow ppt = new SlideShow(new FileInputStream(args[0]));

        Slide[] slide = ppt.getSlides();
        for (int i = 0; i < slide.length; i++) {
            System.out.println("Slide: " + slide[i].getTitle());
            Shape[] shape = slide[i].getShapes();
            for (int j = 0; j < shape.length; j++) {
                print(shape[j]);
            }
        }
    }

    public static void print(Shape shape) throws Exception {
        if(shape instanceof ShapeGroup){
            ShapeGroup group = (ShapeGroup)shape;
            Shape[] sh = group.getShapes();
            for (int i = 0; i < sh.length; i++) {
                print(sh[i]);
            }
        } else {
            System.out.println("Name: " + shape.getShapeName());
            System.out.println("  " + shape.getClass().getName());
            System.out.println("  " + shape.getAnchor());
            if(shape instanceof TextShape){
                String text = ((TextShape)shape).getText();
                if(text != null) System.out.println("  " + text);
            }
        }
    }
}
Comment 8 Daniel 2008-06-09 01:17:30 UTC
(In reply to comment #6)
> Where was this presentation created? Which version of PowerPoint or OpenOffice?
> All shapes have shapeId=0 and this is why HSLF fails to link shapes and text
> runs. 
> 
> 
> Regards,
> Yegor
> 

Guess it was Powerpoint 2000.
I´ll check the result now if i create a presentation with 2003.
Comment 9 Yegor Kozlov 2008-11-16 05:38:27 UTC
I'm marking it as NEEDINFO. If you have more ppt files demonstrating the same issue, please re-open this bug and upload the files. I will try to figure out the pattern.

Yegor
Comment 10 Dominik Stadler 2015-07-07 11:13:51 UTC
Closing this as we did not get more information about the problem for a long time now.