[bug-61792] basic test

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1815873 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
PJ Fanning 2017-11-20 23:58:13 +00:00
parent d4f15fafa9
commit c1ae77c8ce
3 changed files with 26 additions and 1 deletions

View File

@ -378,6 +378,10 @@ public class DrawTextParagraph implements Drawable {
Slide<?,?> slide = (Slide<?,?>)graphics.getRenderingHint(Drawable.CURRENT_SLIDE);
return (slide == null) ? "" : Integer.toString(slide.getSlideNumber());
}
return getRenderableText(tr);
}
String getRenderableText(TextRun tr) {
String txt = tr.getRawText();
txt.replace("\t", tab2space(tr)).replace("\u000b", "\n");

View File

@ -94,8 +94,10 @@ public class XSLFTextRun implements TextRun {
return "\n";
}
return getRenderableText(((CTRegularTextRun)_r).getT());
}
String txt = ((CTRegularTextRun)_r).getT();
String getRenderableText(String txt){
// TODO: finish support for tabs
txt.replace("\t", " ");

View File

@ -77,4 +77,23 @@ public class TestXSLFTextRun {
ppt.close();
}
@Test
public void testUnicodeSurrogates() throws Exception {
final String unicodeSurrogates = "\uD835\uDF4A\uD835\uDF4B\uD835\uDF4C\uD835\uDF4D\uD835\uDF4E"
+ "\uD835\uDF4F\uD835\uDF50\uD835\uDF51\uD835\uDF52\uD835\uDF53\uD835\uDF54\uD835"
+ "\uDF55\uD835\uDF56\uD835\uDF57\uD835\uDF58\uD835\uDF59\uD835\uDF5A\uD835\uDF5B"
+ "\uD835\uDF5C\uD835\uDF5D\uD835\uDF5E\uD835\uDF5F\uD835\uDF60\uD835\uDF61\uD835"
+ "\uDF62\uD835\uDF63\uD835\uDF64\uD835\uDF65\uD835\uDF66\uD835\uDF67\uD835\uDF68"
+ "\uD835\uDF69\uD835\uDF6A\uD835\uDF6B\uD835\uDF6C\uD835\uDF6D\uD835\uDF6E\uD835"
+ "\uDF6F\uD835\uDF70\uD835\uDF71\uD835\uDF72\uD835\uDF73\uD835\uDF74\uD835\uDF75"
+ "\uD835\uDF76\uD835\uDF77\uD835\uDF78\uD835\uDF79\uD835\uDF7A";
try (XMLSlideShow ppt = new XMLSlideShow()) {
XSLFSlide slide = ppt.createSlide();
XSLFTextShape sh = slide.createAutoShape();
XSLFTextRun r = sh.addNewTextParagraph().addNewTextRun();
assertEquals(unicodeSurrogates, r.getRenderableText(unicodeSurrogates));
}
}
}