You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by saloyer <an...@hotmail.com> on 2009/06/24 23:35:42 UTC

RichTextRun.setText works great but can't keep the same character style

Hi all,

I am using POI to change some text from ppt files. The change part works
perfect. I iterate over the slides, get textRuns, then get richTextRuns and
lastly set new text. But i have a problem. When there are more than one
richtextruns in a text run if i change the text i can't keep the same
character style (font, colour etc.). I will try to explain that with an
exampe. Say i have a text with bullet:

*Bold Example text with font Tahoma, red and italic example text with font
Times New Roman

POI parses that text into two richTextRuns as expected. When i change some
words in the text (I get the text form richtextrun and then set it with new
one), it changes correctly but i lost the font style and colour of both
richTextRuns. The text becomes raw, and font turns to Arial as colour turns
to black. This situation happens only when there are different richTextRuns
in textRun and when i try to change text in it. Is this a bug or a
limitation of POI? Or am i doing something wrong?
-- 
View this message in context: http://www.nabble.com/RichTextRun.setText-works-great-but-can%27t-keep-the-same-character-style-tp24193351p24193351.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: RichTextRun.setText works great but can't keep the same character style

Posted by saloyer <an...@hotmail.com>.
Today for six hours, i was on it but nothing changed. To see what is going
on, I saved the attributes (font, colour, allignment, bullet, indent
level...) of richtextrun into an array before changing its text. Then
printed out the attributes. After it, i set the text, and one by one set the
attributes of richTextRun. Then i printed out again. The result was same as
expected. Although text is changed the attributes not. Richtextrun with new
text had same attributes as the old one. But the odd thing is when it is
saved into the ppt file, it losts the style as i mentioned above.

Another strange thing: I did something tricky to get the expected result.
Get the complete slide and cloned all its components (text boxes, text runs,
richtextruns etc.) Before cloning richTextRuns i changed the texts. It
worked for the situation above but this time i lost bullets and indend
levels, also there were some strange chars instead of "enter character". I
mean there were no new lines.

These are what i have gotten recently. I have to use POI's power for my app.
but before continuing i need to solve this problem because it is the heart
of my needs. Please guide me in my way.  


David Fisher wrote:
> 
> You are the edge of what POI can do. It may be a bug or it may a  
> request for enhancement. HSLF support is fairly strong for reading and  
> writing, but not yet strong for editing. Yegor can fill you in on  
> details, but you'll likely need to wait until tomorrow for his response.
> 
> If you are interested in trying to fix this yourself he can give you  
> guidance.
> 
> Regards,
> Dave
> 
> On Jun 24, 2009, at 2:35 PM, saloyer wrote:
> 
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/RichTextRun.setText-works-great-but-can%27t-keep-the-same-character-style-tp24193351p24211528.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: RichTextRun.setText works great but can't keep the same character style

Posted by David Fisher <df...@jmlafferty.com>.
You are the edge of what POI can do. It may be a bug or it may a  
request for enhancement. HSLF support is fairly strong for reading and  
writing, but not yet strong for editing. Yegor can fill you in on  
details, but you'll likely need to wait until tomorrow for his response.

If you are interested in trying to fix this yourself he can give you  
guidance.

Regards,
Dave

On Jun 24, 2009, at 2:35 PM, saloyer wrote:

>
> Hi all,
>
> I am using POI to change some text from ppt files. The change part  
> works
> perfect. I iterate over the slides, get textRuns, then get  
> richTextRuns and
> lastly set new text. But i have a problem. When there are more than  
> one
> richtextruns in a text run if i change the text i can't keep the same
> character style (font, colour etc.). I will try to explain that with  
> an
> exampe. Say i have a text with bullet:
>
> *Bold Example text with font Tahoma, red and italic example text  
> with font
> Times New Roman
>
> POI parses that text into two richTextRuns as expected. When i  
> change some
> words in the text (I get the text form richtextrun and then set it  
> with new
> one), it changes correctly but i lost the font style and colour of  
> both
> richTextRuns. The text becomes raw, and font turns to Arial as  
> colour turns
> to black. This situation happens only when there are different  
> richTextRuns
> in textRun and when i try to change text in it. Is this a bug or a
> limitation of POI? Or am i doing something wrong?
> -- 
> View this message in context: http://www.nabble.com/RichTextRun.setText-works-great-but-can%27t-keep-the-same-character-style-tp24193351p24193351.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
>


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