Bug 52682 - Strings ending by '\r' are not handled by textbox
Summary: Strings ending by '\r' are not handled by textbox
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: HSLF (show other bugs)
Version: 3.8-dev
Hardware: PC Windows XP
: P2 major (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-02-16 14:02 UTC by charter
Modified: 2012-03-01 09:54 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description charter 2012-02-16 14:02:09 UTC
When i try to insert a textbox ending by the char '\r' or '\n' the slide "crash" (not the whole slideshow).

EX :

SlideShow ppt = new SlideShow();
Slide s = ppt.createSlide();
TextBox tb = new TextBox();

tb.getTextRun().setText("Test");    <-- WORKS
OR
tb.getTextRun().setText("Test\r");  <-- FAIL

s1.addShape(tb);

Possible cause : Class TextRun

In storeText the last char is striped if it's a '\r'

if(s.endsWith("\r")) {
  s = s.substring(0, s.length()-1);
}

but in setRawText the string is used unstripped

HERE ->  _rtRuns[0].setText(s);
AND THERE -> _rtRuns[0] = new RichTextRun(this,0,s.length());

I've removed the following part because there's no "implicit" line return. 

if(s.endsWith("\r")) {
  s = s.substring(0, s.length()-1);
}
Comment 1 Yegor Kozlov 2012-03-01 09:54:09 UTC
Should be fixed in r1295488.

I agree that the part removing trailing '\r' is extra:. Firstly because there is no implicit line return and, secondly, it is absolutely legal to set text with trailing '\r', I don't see why we should strip it off. 

Yegor