From: Peter Herweg Date: Sat, 3 Jan 2004 13:43:12 +0000 (+0000) Subject: bug fixed: The first occurence of a custom color was displayed with wrong color X-Git-Tag: Root_Temp_KnuthStylePageBreaking~938 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=5997aec0171a4b7b4ffe34f23cd611215f3e8acf;p=xmlgraphics-fop.git bug fixed: The first occurence of a custom color was displayed with wrong color git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197108 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfColorTable.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfColorTable.java index 01f21baf9..53351b624 100644 --- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfColorTable.java +++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfColorTable.java @@ -187,14 +187,21 @@ public class RtfColorTable { int retVal; if (o == null) { + //The color currently does not exist, so add it to the table. + //First add it, then read the size as index (to return it). + //So the first added color gets index 1. That is OK, because + //index 0 is reserved for auto-colored. addColor (identifier); retVal = colorTable.size (); } else { - retVal = ((Integer) o).intValue (); + //The color was found. Before returning the index, increment + //it by one. Because index 0 is reserved for auto-colored, but + //is not contained in colorTable. + retVal = ((Integer) o).intValue () + 1; } - return new Integer(retVal + 1); + return new Integer(retVal); } /** @@ -212,6 +219,8 @@ public class RtfColorTable { header.writeGroupMark (true); //Don't use writeControlWord, because it appends a blank, //which may confuse Wordpad. + //This also implicitly writes the first color (=index 0), which + //is reserved for auto-colored. header.write ("\\colortbl;"); int len = colorTable.size ();