Author: onealj
Date: Thu Mar 24 17:29:00 2016
New Revision: 1736469
URL: http://svn.apache.org/viewvc?rev=1736469&view=rev
Log:
bug 59224: change hasTint, add hasAlpha and unit tests. Patch from
[email protected]
Modified:
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFColor.java
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFColor.java
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFColor.java
URL:
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFColor.java?rev=1736469&r1=1736468&r2=1736469&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFColor.java
(original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFColor.java Thu
Mar 24 17:29:00 2016
@@ -90,9 +90,9 @@ public class XSSFColor extends ExtendedC
}
/**
- * A boolean value indicating if the ctColor has a tint or not
+ * A boolean value indicating if the ctColor has a alpha or not
*/
- public boolean hasTint() {
+ public boolean hasAlpha() {
if (! ctColor.isSetRgb()) {
return false;
}
@@ -100,6 +100,16 @@ public class XSSFColor extends ExtendedC
}
/**
+ * A boolean value indicating if the ctColor has a tint or not
+ */
+ public boolean hasTint() {
+ if (!ctColor.isSetTint()) {
+ return false;
+ }
+ return ctColor.getTint() != 0;
+ }
+
+ /**
* Indexed ctColor value. Only used for backwards compatibility.
References a ctColor in indexedColors.
*/
@Override
Modified:
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFColor.java
URL:
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFColor.java?rev=1736469&r1=1736468&r2=1736469&view=diff
==============================================================================
---
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFColor.java
(original)
+++
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFColor.java
Thu Mar 24 17:29:00 2016
@@ -43,6 +43,8 @@ public final class TestXSSFColor {
assertEquals(null, indexed.getRGB());
assertEquals(null, indexed.getRGBWithTint());
assertEquals(null, indexed.getARGBHex());
+ assertFalse(indexed.hasAlpha());
+ assertFalse(indexed.hasTint());
// Now move to one with indexed rgb values
indexed.setIndexed(59);
@@ -87,6 +89,8 @@ public final class TestXSSFColor {
// Now check the XSSFColor
assertEquals(0, rgb3.getIndexed());
assertEquals(-0.34999, rgb3.getTint(), 0.00001);
+ assertFalse(rgb3.hasAlpha());
+ assertTrue(rgb3.hasTint());
assertEquals("FFFFFFFF", rgb3.getARGBHex());
assertEquals(3, rgb3.getRGB().length);
@@ -118,6 +122,7 @@ public final class TestXSSFColor {
// Set another, is fine
rgb3.setRGB(new byte[] {16,17,18});
+ assertFalse(rgb3.hasAlpha());
assertEquals("FF101112", rgb3.getARGBHex());
assertEquals(0x10, rgb3.getCTColor().getRgb()[0]);
assertEquals(0x11, rgb3.getCTColor().getRgb()[1]);
@@ -140,6 +145,8 @@ public final class TestXSSFColor {
// Now check the XSSFColor
assertEquals(0, rgb4.getIndexed());
assertEquals(0.0, rgb4.getTint(), 0);
+ assertFalse(rgb4.hasTint());
+ assertTrue(rgb4.hasAlpha());
assertEquals("FFFF0000", rgb4.getARGBHex());
assertEquals(3, rgb4.getRGB().length);
@@ -163,6 +170,7 @@ public final class TestXSSFColor {
// Turn on tinting, and check it behaves
// TODO These values are suspected to be wrong...
rgb4.setTint(0.4);
+ assertTrue(rgb4.hasTint());
assertEquals(0.4, rgb4.getTint(), 0);
assertEquals(3, rgb4.getRGBWithTint().length);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]