diff --git a/src/java/org/apache/poi/sl/draw/DrawTextParagraph.java b/src/java/org/apache/poi/sl/draw/DrawTextParagraph.java index 1b086430c..c0c7eb21f 100644 --- a/src/java/org/apache/poi/sl/draw/DrawTextParagraph.java +++ b/src/java/org/apache/poi/sl/draw/DrawTextParagraph.java @@ -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"); diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextRun.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextRun.java index 6e62e4ae4..3f686ecec 100644 --- a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextRun.java +++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextRun.java @@ -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", " "); diff --git a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextRun.java b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextRun.java index de6085433..1640d499e 100644 --- a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextRun.java +++ b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextRun.java @@ -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)); + } + } }