[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
This commit is contained in:
PJ Fanning 2022-07-15 20:54:22 +00:00
parent 8fbe3966dd
commit 67a4ac400e
3 changed files with 14 additions and 1 deletions

View 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);

View 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];

View 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());
}
}
}