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/branches/Temp_AreaTreeNewDesign@685579 13f79535-47bb-0310-9956-ffa450edef68tags/fop-1_0
@@ -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)) { |
@@ -53,6 +53,9 @@ | |||
<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> |
@@ -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(); |