You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by LarryB <be...@us.ibm.com> on 2009/07/30 20:57:02 UTC
Text positions in ppt
I'm trying to determine the (x,y) coordinates for TextRuns within a slide (so
I can figure out which one is *really* the title!). Can someone point me to
some sample code?
Thanks very much,
Larry
--
View this message in context: http://www.nabble.com/Text-positions-in-ppt-tp24745154p24745154.html
Sent from the POI - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org
Re: Text positions in ppt
Posted by Yegor Kozlov <ye...@dinom.ru>.
> I'm trying to determine the (x,y) coordinates for TextRuns within a slide (so
> I can figure out which one is *really* the title!). Can someone point me to
> some sample code?
>
The code you need is in Slide#getTitle(), see
ihttp://svn.apache.org/repos/asf/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Slide.java
To test whether a shape is the title use the following code:
for(Shape sh : slide.getShapes()){
if(sh instanceof TextShape){
TextShape tx = (TextShape)sh;
TextRun run = tx.getTextRun();
int type = run.getRunType();
if (type == TextHeaderAtom.CENTER_TITLE_TYPE || type == TextHeaderAtom.TITLE_TYPE ){
//got title
String title = run.getText();
}
}
}
Yegor
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org
Re: Text positions in ppt
Posted by Yegor Kozlov <ye...@dinom.ru>.
> I have a partial answer here:
> http://www.nabble.com/Re-2-%3A-org.apache.poi.hslf.model.TextRun-p4767544.html
>
TextBox is a subclass of TextShape which is a base class of all shapes that can hold text.
The correct code should test for TextShape, not for TextBox:
if (sh[i] instanceof TextShape){
TextShape box = (TextShape)
String text = box.getText();
...
}
Yegor
> I'm running into problems with that, however. Not all the Shapes that
> contain text are TextBoxes; in the presentations I've looked at, some are
> Pictures, some are AutoShapes. I need to get the location for every
> TextRun. If I could access the getShapeId() method in TextRun, it would let
> me find the shape corresponding to each, but that method is protected. Any
> tips on how to proceed?
>
> Thanks much,
> Larry
>
>
> LarryB wrote:
>> I'm trying to determine the (x,y) coordinates for TextRuns within a slide
>> (so I can figure out which one is *really* the title!). Can someone point
>> me to some sample code?
>>
>> Thanks very much,
>> Larry
>>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org
Re: Text positions in ppt
Posted by LarryB <be...@us.ibm.com>.
I have a partial answer here:
http://www.nabble.com/Re-2-%3A-org.apache.poi.hslf.model.TextRun-p4767544.html
I'm running into problems with that, however. Not all the Shapes that
contain text are TextBoxes; in the presentations I've looked at, some are
Pictures, some are AutoShapes. I need to get the location for every
TextRun. If I could access the getShapeId() method in TextRun, it would let
me find the shape corresponding to each, but that method is protected. Any
tips on how to proceed?
Thanks much,
Larry
LarryB wrote:
>
> I'm trying to determine the (x,y) coordinates for TextRuns within a slide
> (so I can figure out which one is *really* the title!). Can someone point
> me to some sample code?
>
> Thanks very much,
> Larry
>
--
View this message in context: http://www.nabble.com/Text-positions-in-ppt-tp24745154p24759944.html
Sent from the POI - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org