You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Constantin Volozhin <cv...@pragmaticsoft.com> on 2008/08/11 15:23:59 UTC

getTextRuns() returns null

Hi. getTextRuns() from following code returns null. Is this ok? How I
can get added text via slide? I need to get text from slide shapes and
replace it by another text. But I always get null.


try {
            Slide slide = ppObject.createSlide();
            
            TextBox shape = new TextBox();
            
            TextRun textRun = shape.createTextRun();
            textRun.setText("TEST");
            
            slide.addShape(shape);
            
            TextRun[] textRuns = slide.getTextRuns();
           
            
        } catch (IOException e) {
            e.printStackTrace();
        }





---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: getTextRuns() returns null

Posted by Constantin Volozhin <cv...@pragmaticsoft.com>.
Thank you very much!! It works!
The second code snippet from my last mail are working now also! :-)


> Fixed in r685064.
> 
> The array of Slide's text runs was not updated when new text shapes were added.
> 
> 
> Yegor
> 
> > Hi. getTextRuns() from following code returns null. Is this ok? How I
> > can get added text via slide? I need to get text from slide shapes and
> > replace it by another text. But I always get null.
> > 
> > 
> > try {
> >             Slide slide = ppObject.createSlide();
> >             
> >             TextBox shape = new TextBox();
> >             
> >             TextRun textRun = shape.createTextRun();
> >             textRun.setText("TEST");
> >             
> >             slide.addShape(shape);
> >             
> >             TextRun[] textRuns = slide.getTextRuns();
> >            
> >             
> >         } catch (IOException e) {
> >             e.printStackTrace();
> >         }
> > 
> > 
> > 
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> > For additional commands, e-mail: user-help@poi.apache.org
> > 
> > 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: getTextRuns() returns null

Posted by Yegor Kozlov <ye...@dinom.ru>.
Fixed in r685064.

The array of Slide's text runs was not updated when new text shapes were added.


Yegor

> Hi. getTextRuns() from following code returns null. Is this ok? How I
> can get added text via slide? I need to get text from slide shapes and
> replace it by another text. But I always get null.
> 
> 
> try {
>             Slide slide = ppObject.createSlide();
>             
>             TextBox shape = new TextBox();
>             
>             TextRun textRun = shape.createTextRun();
>             textRun.setText("TEST");
>             
>             slide.addShape(shape);
>             
>             TextRun[] textRuns = slide.getTextRuns();
>            
>             
>         } catch (IOException e) {
>             e.printStackTrace();
>         }
> 
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: getTextRuns() returns null

Posted by Yegor Kozlov <ye...@dinom.ru>.
Can you create a bug in bugzilla and attach sample code to reproduce the problem?
If it requires a template ppt, attach it also.

Yegor

> Thanks, I will be very grateful.
> 
> 
> One more thing:
> 
> The result of following code is ok - shape_new has text. But when I try
> to get shapes by getShapes() on slide and get shape's text I have null
> also.
> Is this getTextRuns() related issue also? Is some walkaround of this
> issue present?
> 
>             
> Shape[] shapes = templateSlide.getShapes();
> 
> for (int i = 0; i < shapes.length; i++) {
> 
>   if (shapes[i] instanceof AutoShape) {
>     AutoShape shape = (AutoShape) shapes[i];
>     AutoShape shape_new = new AutoShape(shape.getShapeType());
>     String text = shape.getText();
> 
>     if (text != null) {
>       // SET TEXT FOR NEW SHAPE
>       shape_new.setText(text);
>     }
> 
>     slide.addShape(shape_new);
>   }
> }
> 
> 
>> It looks like a bug.
>>
>> The array of Slide's text runs is not updated when new text shapes are added.
>> I will see if I can include the fix in the next maintenance release.
>>
>> Yegor
>>
>>> Hi. getTextRuns() from following code returns null. Is this ok? How I
>>> can get added text via slide? I need to get text from slide shapes and
>>> replace it by another text. But I always get null.
>>>
>>>
>>> try {
>>>             Slide slide = ppObject.createSlide();
>>>             
>>>             TextBox shape = new TextBox();
>>>             
>>>             TextRun textRun = shape.createTextRun();
>>>             textRun.setText("TEST");
>>>             
>>>             slide.addShape(shape);
>>>             
>>>             TextRun[] textRuns = slide.getTextRuns();
>>>            
>>>             
>>>         } catch (IOException e) {
>>>             e.printStackTrace();
>>>         }
>>>
>>>
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
>>> For additional commands, e-mail: user-help@poi.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
>> For additional commands, e-mail: user-help@poi.apache.org
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: getTextRuns() returns null

Posted by Constantin Volozhin <cv...@pragmaticsoft.com>.
Thanks, I will be very grateful.


One more thing:

The result of following code is ok - shape_new has text. But when I try
to get shapes by getShapes() on slide and get shape's text I have null
also.
Is this getTextRuns() related issue also? Is some walkaround of this
issue present?

            
Shape[] shapes = templateSlide.getShapes();

for (int i = 0; i < shapes.length; i++) {

  if (shapes[i] instanceof AutoShape) {
    AutoShape shape = (AutoShape) shapes[i];
    AutoShape shape_new = new AutoShape(shape.getShapeType());
    String text = shape.getText();

    if (text != null) {
      // SET TEXT FOR NEW SHAPE
      shape_new.setText(text);
    }

    slide.addShape(shape_new);
  }
}


> It looks like a bug.
> 
> The array of Slide's text runs is not updated when new text shapes are added.
> I will see if I can include the fix in the next maintenance release.
> 
> Yegor
> 
> > Hi. getTextRuns() from following code returns null. Is this ok? How I
> > can get added text via slide? I need to get text from slide shapes and
> > replace it by another text. But I always get null.
> > 
> > 
> > try {
> >             Slide slide = ppObject.createSlide();
> >             
> >             TextBox shape = new TextBox();
> >             
> >             TextRun textRun = shape.createTextRun();
> >             textRun.setText("TEST");
> >             
> >             slide.addShape(shape);
> >             
> >             TextRun[] textRuns = slide.getTextRuns();
> >            
> >             
> >         } catch (IOException e) {
> >             e.printStackTrace();
> >         }
> > 
> > 
> > 
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> > For additional commands, e-mail: user-help@poi.apache.org
> > 
> > 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: getTextRuns() returns null

Posted by Yegor Kozlov <ye...@dinom.ru>.
It looks like a bug.

The array of Slide's text runs is not updated when new text shapes are added.
I will see if I can include the fix in the next maintenance release.

Yegor

> Hi. getTextRuns() from following code returns null. Is this ok? How I
> can get added text via slide? I need to get text from slide shapes and
> replace it by another text. But I always get null.
> 
> 
> try {
>             Slide slide = ppObject.createSlide();
>             
>             TextBox shape = new TextBox();
>             
>             TextRun textRun = shape.createTextRun();
>             textRun.setText("TEST");
>             
>             slide.addShape(shape);
>             
>             TextRun[] textRuns = slide.getTextRuns();
>            
>             
>         } catch (IOException e) {
>             e.printStackTrace();
>         }
> 
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org