]> source.dussan.org Git - poi.git/commitdiff
[github-360] HSSFExtendedColor does not set RGB colors properly. Thanks to XenoAmess...
authorPJ Fanning <fanningpj@apache.org>
Fri, 15 Jul 2022 20:54:22 +0000 (20:54 +0000)
committerPJ Fanning <fanningpj@apache.org>
Fri, 15 Jul 2022 20:54:22 +0000 (20:54 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1902747 13f79535-47bb-0310-9956-ffa450edef68

poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFFont.java
poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFExtendedColor.java
poi/src/test/java/org/apache/poi/ss/usermodel/BaseTestFont.java

index 251cf3257b06245271db950ddf3e40bf0f5b7f36..9553d595bbd4264d6d0434c0957ee7a6eb35da45 100644 (file)
@@ -52,7 +52,7 @@ import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTVerticalAlignFontPr
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.STFontScheme;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.STUnderlineValues;
 
-public final class TestXSSFFont extends BaseTestFont{
+public final class TestXSSFFont extends BaseTestFont {
 
     public TestXSSFFont() {
         super(XSSFITestDataProvider.instance);
index b17826318568fa2a5bad65bee5e2dda5c682ae64..54390cb59a5549076e87ee673a256b0b35f34826 100644 (file)
@@ -89,6 +89,7 @@ public class HSSFExtendedColor extends ExtendedColor {
             byte[] rgba = new byte[4];
             System.arraycopy(rgb, 0, rgba, 0, 3);
             rgba[3] = -1;
+            color.setRGBA(rgba);
         } else {
             // Shuffle from ARGB to RGBA
             byte a = rgb[0];
index d8e1e6dde37a5356924213df5a87f4e9e9f47f50..5d260994192ceb11ff5e03fbcc37a622daa51a9a 100644 (file)
@@ -17,6 +17,7 @@
 
 package org.apache.poi.ss.usermodel;
 
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -27,6 +28,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.io.IOException;
 
+import org.apache.commons.codec.binary.Hex;
 import org.apache.poi.ss.ITestDataProvider;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.params.ParameterizedTest;
@@ -220,4 +222,14 @@ public abstract class BaseTestFont {
             );
         }
     }
+
+    @Test
+    void testRGBColor() throws Exception {
+        try (Workbook wb1 = _testDataProvider.createWorkbook()) {
+            String colorHex = "FFEB84";
+            ExtendedColor color = wb1.getCreationHelper().createExtendedColor();
+            color.setRGB(Hex.decodeHex(colorHex));
+            assertArrayEquals(Hex.decodeHex(colorHex), color.getRGB());
+        }
+    }
 }