Browse Source

[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
tags/REL_5_2_3
PJ Fanning 1 year ago
parent
commit
67a4ac400e

+ 1
- 1
poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFFont.java 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);

+ 1
- 0
poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFExtendedColor.java 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];

+ 12
- 0
poi/src/test/java/org/apache/poi/ss/usermodel/BaseTestFont.java 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());
}
}
}

Loading…
Cancel
Save