From: Jeremias Maerki Date: Wed, 13 Aug 2008 14:34:03 +0000 (+0000) Subject: Fixed border trait parsing for the area tree XML when CMYK or ICC colors were used. X-Git-Tag: fop-1_0~458 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=a31b0119d41994f4aff1eb5c1c8639c780e420b8;p=xmlgraphics-fop.git Fixed border trait parsing for the area tree XML when CMYK or ICC colors were used. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@685573 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/fop/traits/BorderProps.java b/src/java/org/apache/fop/traits/BorderProps.java index 20e362674..338743538 100644 --- a/src/java/org/apache/fop/traits/BorderProps.java +++ b/src/java/org/apache/fop/traits/BorderProps.java @@ -21,7 +21,8 @@ package org.apache.fop.traits; 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; @@ -162,13 +163,19 @@ public class BorderProps implements Serializable { 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)) { diff --git a/status.xml b/status.xml index a43ebf5e6..3b9d8d750 100644 --- a/status.xml +++ b/status.xml @@ -53,6 +53,9 @@ + + Fixed border trait parsing for the area tree XML when CMYK or ICC colors were used. + Fixed generation of "fonttbl" for RTF output to fix loading problem with AbiWord. diff --git a/test/java/org/apache/fop/traits/BorderPropsTestCase.java b/test/java/org/apache/fop/traits/BorderPropsTestCase.java index 6aea38512..0c08e05af 100644 --- a/test/java/org/apache/fop/traits/BorderPropsTestCase.java +++ b/test/java/org/apache/fop/traits/BorderPropsTestCase.java @@ -24,6 +24,8 @@ import java.awt.Color; 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; /** @@ -46,6 +48,11 @@ public class BorderPropsTestCase extends TestCase { 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();