Author: kiwiwings
Date: Sun Feb 19 21:36:45 2017
New Revision: 1783698
URL: http://svn.apache.org/viewvc?rev=1783698&view=rev
Log:
BugFix for JDK-6623219
Modified:
poi/trunk/src/java/org/apache/poi/sl/draw/DrawTextParagraph.java
poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestPPTX2PNG.java
Modified: poi/trunk/src/java/org/apache/poi/sl/draw/DrawTextParagraph.java
URL:
http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/sl/draw/DrawTextParagraph.java?rev=1783698&r1=1783697&r2=1783698&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/sl/draw/DrawTextParagraph.java (original)
+++ poi/trunk/src/java/org/apache/poi/sl/draw/DrawTextParagraph.java Sun Feb 19
21:36:45 2017
@@ -649,12 +649,12 @@ public class DrawTextParagraph implement
// check for unsupported characters and add a fallback font for
these
char textChr[] = runText.toCharArray();
- int nextEnd = f.canDisplayUpTo(textChr, 0, textChr.length);
+ int nextEnd = canDisplayUpTo(f, textChr, 0, textChr.length);
int last = nextEnd;
boolean isNextValid = (nextEnd == 0);
while ( nextEnd != -1 && nextEnd <= textChr.length ) {
if (isNextValid) {
- nextEnd = f.canDisplayUpTo(textChr, nextEnd,
textChr.length);
+ nextEnd = canDisplayUpTo(f, textChr, nextEnd,
textChr.length);
isNextValid = false;
} else {
if (nextEnd >= textChr.length ||
f.canDisplay(Character.codePointAt(textChr, nextEnd, textChr.length)) ) {
@@ -728,4 +728,43 @@ public class DrawTextParagraph implement
}
return attStr;
}
+
+ /**
+ * Indicates whether or not this {@code Font} can display the characters
in the specified {@code text}
+ * starting at {@code start} and ending at {@code limit}.<p>
+ *
+ * This is a workaround for the Java 6 implementation of {@link
Font#canDisplayUpTo(char[], int, int)}
+ *
+ * @param font the font to inspect
+ * @param text the specified array of {@code char} values
+ * @param start the specified starting offset (in
+ * {@code char}s) into the specified array of
+ * {@code char} values
+ * @param limit the specified ending offset (in
+ * {@code char}s) into the specified array of
+ * {@code char} values
+ * @return an offset into {@code text} that points
+ * to the first character in {@code text} that this
+ * {@code Font} cannot display; or {@code -1} if
+ * this {@code Font} can display all characters in
+ * {@code text}.
+ *
+ * @see <a
href="https://bugs.openjdk.java.net/browse/JDK-6623219">Font.canDisplayUpTo
does not work with supplementary characters</a>
+ */
+ protected static int canDisplayUpTo(Font font, char[] text, int start, int
limit) {
+ for (int i = start; i < limit; i++) {
+ char c = text[i];
+ if (font.canDisplay(c)) {
+ continue;
+ }
+ if (!Character.isHighSurrogate(c)) {
+ return i;
+ }
+ if (!font.canDisplay(Character.codePointAt(text, i, limit))) {
+ return i;
+ }
+ i++;
+ }
+ return -1;
+ }
}
Modified:
poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestPPTX2PNG.java
URL:
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestPPTX2PNG.java?rev=1783698&r1=1783697&r2=1783698&view=diff
==============================================================================
---
poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestPPTX2PNG.java
(original)
+++
poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestPPTX2PNG.java
Sun Feb 19 21:36:45 2017
@@ -47,7 +47,7 @@ public class TestPPTX2PNG {
private static final POIDataSamples samples =
POIDataSamples.getSlideShowInstance();
private static final File basedir = null;
private static final String files =
- "53446.ppt, alterman_security.ppt, alterman_security.pptx, KEY02.pptx,
themes.pptx, backgrounds.pptx, layouts.pptx, sample.pptx, shapes.pptx";
+ "53446.ppt, alterman_security.ppt, alterman_security.pptx, KEY02.pptx,
themes.pptx, backgrounds.pptx, layouts.pptx, sample.pptx, shapes.pptx,
54880_chinese.ppt";
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]