You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by an...@apache.org on 2007/08/22 05:44:12 UTC

svn commit: r568398 - in /cocoon/trunk/blocks/cocoon-poi/cocoon-poi-impl: src/main/java/org/apache/cocoon/components/elementprocessor/impl/poi/hssf/elements/ColorCode.java status.xml

Author: antonio
Date: Tue Aug 21 20:44:11 2007
New Revision: 568398

URL: http://svn.apache.org/viewvc?rev=568398&view=rev
Log:

<action dev="AG" type="fix" fixes-bug="COCOON-1440" due-to="Krystian Nowak" due-to-email="krystian@man.poznan.pl">
  Color string normalization.
</action>

Modified:
    cocoon/trunk/blocks/cocoon-poi/cocoon-poi-impl/src/main/java/org/apache/cocoon/components/elementprocessor/impl/poi/hssf/elements/ColorCode.java
    cocoon/trunk/blocks/cocoon-poi/cocoon-poi-impl/status.xml

Modified: cocoon/trunk/blocks/cocoon-poi/cocoon-poi-impl/src/main/java/org/apache/cocoon/components/elementprocessor/impl/poi/hssf/elements/ColorCode.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-poi/cocoon-poi-impl/src/main/java/org/apache/cocoon/components/elementprocessor/impl/poi/hssf/elements/ColorCode.java?rev=568398&r1=568397&r2=568398&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-poi/cocoon-poi-impl/src/main/java/org/apache/cocoon/components/elementprocessor/impl/poi/hssf/elements/ColorCode.java (original)
+++ cocoon/trunk/blocks/cocoon-poi/cocoon-poi-impl/src/main/java/org/apache/cocoon/components/elementprocessor/impl/poi/hssf/elements/ColorCode.java Tue Aug 21 20:44:11 2007
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -31,6 +31,7 @@
     private static final int _green           = 1;
     private static final int _blue            = 2;
     private static final int _component_count = 3;
+    private static final String SEPARATOR = ":";
     private int[]            _components      = new int[ _component_count ];
     private String           rgbstring;
 
@@ -47,12 +48,13 @@
         if (value == null) {
             throw new IOException("cannot process a null color code");
         }
-        StringTokenizer tokenizer = new StringTokenizer(value.trim(), ":");
+        StringTokenizer tokenizer = new StringTokenizer(value.trim(), SEPARATOR);
 
         if (tokenizer.countTokens() != _component_count) {
             throw new IOException("color code must have exactly "
                       + _component_count + " components, no more, no less");
         }
+        StringBuffer constructedRgbString = new StringBuffer();
         for (int j = 0; j < _component_count; j++) {
             try {
                 _components[j] = Integer.parseInt(tokenizer.nextToken(), 16);
@@ -63,9 +65,16 @@
             if (_components[j] < 0 || _components[j] > 65535) {
                 throw new IOException("Component #" + j + " is out of range");
             }
+            if (j > 0) {
+                constructedRgbString.append(SEPARATOR);
+            }
+            constructedRgbString.append(
+                StringUtils.leftPad(Integer.toHexString(_components[j]), 4, '0').toUpperCase());
         }
+        rgbstring = constructedRgbString.toString();
     }
 
+
     /**
      * @return red component
      */
@@ -89,7 +98,7 @@
     public int getBlue() {
         return _components[_blue];
     }
-    
+
     public String toString() {
         return rgbstring;
     }

Modified: cocoon/trunk/blocks/cocoon-poi/cocoon-poi-impl/status.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-poi/cocoon-poi-impl/status.xml?rev=568398&r1=568397&r2=568398&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-poi/cocoon-poi-impl/status.xml (original)
+++ cocoon/trunk/blocks/cocoon-poi/cocoon-poi-impl/status.xml Tue Aug 21 20:44:11 2007
@@ -66,6 +66,9 @@
  <!-- The following list contains the changes since the latest 2.1.x version. -->
  <changes>
   <release version="@version@" date="@date@">
+    <action dev="AG" type="fix" fixes-bug="COCOON-1440" due-to="Krystian Nowak" due-to-email="krystian@man.poznan.pl">
+      Color string normalization.
+    </action> 
     <action dev="JH" type="fix" fixes-bug="COCOON-1976" due-to="Rob Berens">
       Prevent NPE in ElementProcessorSerializer on characters before first startElement.
     </action>