aboutsummaryrefslogtreecommitdiffstats
path: root/poi
diff options
context:
space:
mode:
authorPJ Fanning <fanningpj@apache.org>2022-07-15 20:54:22 +0000
committerPJ Fanning <fanningpj@apache.org>2022-07-15 20:54:22 +0000
commit67a4ac400ef880c4e406a27d0c7edd4bc048a291 (patch)
treef6aec8cbdb919caf2c88a74b8afaca64d1dc0438 /poi
parent8fbe3966dd0d18130d5f8e5625e9b1c69ce0c297 (diff)
downloadpoi-67a4ac400ef880c4e406a27d0c7edd4bc048a291.tar.gz
poi-67a4ac400ef880c4e406a27d0c7edd4bc048a291.zip
[github-360] HSSFExtendedColor does not set RGB colors properly. Thanks to XenoAmess. This closes #360
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1902747 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi')
-rw-r--r--poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFExtendedColor.java1
-rw-r--r--poi/src/test/java/org/apache/poi/ss/usermodel/BaseTestFont.java12
2 files changed, 13 insertions, 0 deletions
diff --git a/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFExtendedColor.java b/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFExtendedColor.java
index b178263185..54390cb59a 100644
--- a/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFExtendedColor.java
+++ b/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFExtendedColor.java
@@ -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];
diff --git a/poi/src/test/java/org/apache/poi/ss/usermodel/BaseTestFont.java b/poi/src/test/java/org/apache/poi/ss/usermodel/BaseTestFont.java
index d8e1e6dde3..5d26099419 100644
--- a/poi/src/test/java/org/apache/poi/ss/usermodel/BaseTestFont.java
+++ b/poi/src/test/java/org/apache/poi/ss/usermodel/BaseTestFont.java
@@ -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());
+ }
+ }
}