import java.awt.Color;
import java.io.Serializable;
-import java.util.StringTokenizer;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.fo.Constants;
public static BorderProps valueOf(FOUserAgent foUserAgent, String s) {
if (s.startsWith("(") && s.endsWith(")")) {
s = s.substring(1, s.length() - 1);
- StringTokenizer st = new StringTokenizer(s, ",");
- String style = st.nextToken();
- String color = st.nextToken();
- int width = Integer.parseInt(st.nextToken());
+ Pattern pattern = Pattern.compile("([^,\\(]+(?:\\(.*\\))?)");
+ Matcher m = pattern.matcher(s);
+ boolean found;
+ found = m.find();
+ String style = m.group();
+ found = m.find();
+ String color = m.group();
+ found = m.find();
+ int width = Integer.parseInt(m.group());
int mode = SEPARATE;
- if (st.hasMoreTokens()) {
- String ms = st.nextToken();
+ found = m.find();
+ if (found) {
+ String ms = m.group();
if ("collapse-inner".equalsIgnoreCase(ms)) {
mode = COLLAPSE_INNER;
} else if ("collapse-outer".equalsIgnoreCase(ms)) {
<changes>
<release version="FOP Trunk" date="TBD">
+ <action context="Renderers" dev="JM" type="fix">
+ Fixed border trait parsing for the area tree XML when CMYK or ICC colors were used.
+ </action>
<action context="Renderers" dev="JM" type="fix" fixes-bug="45606" due-to="Pavel Kysilka">
Fixed generation of "fonttbl" for RTF output to fix loading problem with AbiWord.
</action>
import junit.framework.TestCase;
import org.apache.fop.fo.Constants;
+import org.apache.fop.util.CMYKColorSpace;
+import org.apache.fop.util.ColorExt;
import org.apache.fop.util.ColorUtil;
/**
BorderProps b2 = BorderProps.valueOf(null, ser);
assertEquals(b1, b2);
+ float[] cmyk = new float[] {1.0f, 1.0f, 0.5f, 1.0f};
+ CMYKColorSpace cmykCs = CMYKColorSpace.getInstance();
+ float[] rgb = cmykCs.toRGB(cmyk);
+ col = ColorExt.createFromFoRgbIcc(rgb[0], rgb[1], rgb[2],
+ null, "#CMYK", cmykCs, cmyk);
b1 = new BorderProps(Constants.EN_INSET, 9999,
col, BorderProps.SEPARATE);
ser = b1.toString();