You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by je...@apache.org on 2006/07/10 16:12:20 UTC
svn commit: r420533 - in
/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc:
RtfListStyleText.java RtfStringConverter.java
Author: jeremias
Date: Mon Jul 10 07:12:20 2006
New Revision: 420533
URL: http://svn.apache.org/viewvc?rev=420533&view=rev
Log:
Escape Unicode characters properly for list-item labels.
Modified:
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfListStyleText.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfStringConverter.java
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfListStyleText.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfListStyleText.java?rev=420533&r1=420532&r2=420533&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfListStyleText.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfListStyleText.java Mon Jul 10 07:12:20 2006
@@ -63,7 +63,8 @@
item.writeGroupMark(true);
//item.writeControlWord("pndec");
item.writeOneAttribute(RtfListTable.LIST_FONT_TYPE, "2");
- item.writeControlWord("pntxtb " + text);
+ item.writeControlWord("pntxtb");
+ RtfStringConverter.getInstance().writeRtfString(item.writer, text);
item.writeGroupMark(false);
}
@@ -103,7 +104,8 @@
}
}
element.writeOneAttributeNS(
- RtfListTable.LIST_TEXT_FORM, "\\'" + sCount + text);
+ RtfListTable.LIST_TEXT_FORM, "\\'" + sCount
+ + RtfStringConverter.getInstance().escape(text));
element.writeGroupMark(false);
element.writeGroupMark(true);
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfStringConverter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfStringConverter.java?rev=420533&r1=420532&r2=420533&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfStringConverter.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfStringConverter.java Mon Jul 10 07:12:20 2006
@@ -78,7 +78,20 @@
if (str == null) {
return;
}
+ w.write(escape(str));
+ }
+
+ /**
+ * Escapes a String as required by the RTF spec.
+ * @param str String to be escaped
+ * @return the escaped string
+ */
+ public String escape(String str) {
+ if (str == null) {
+ return null;
+ }
+ StringBuffer sb = new StringBuffer(Math.max(16, str.length()));
// TODO: could be made more efficient (binary lookup, etc.)
for (int i = 0; i < str.length(); i++) {
final Character c = new Character(str.charAt(i));
@@ -102,20 +115,21 @@
if (replacement != null) {
// RTF-escaped char
- w.write('\\');
- w.write(replacement);
- w.write(' ');
+ sb.append('\\');
+ sb.append(replacement);
+ sb.append(' ');
} else if (c.charValue() > 127) {
// write unicode representation - contributed by Michel Jacobson
// <ja...@idf.ext.jussieu.fr>
- w.write("\\u");
- w.write(Integer.toString((int)c.charValue()));
- w.write("\\\'3f");
+ sb.append("\\u");
+ sb.append(Integer.toString((int)c.charValue()));
+ sb.append("\\\'3f");
} else {
// plain char that is understood by RTF natively
- w.write(c.charValue());
+ sb.append(c.charValue());
}
}
+ return sb.toString();
}
-
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org