poi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject [Bug 59224] New: XSSFColor.hasTint() has wrong implementation
Date Wed, 23 Mar 2016 20:54:17 GMT
https://bz.apache.org/bugzilla/show_bug.cgi?id=59224

            Bug ID: 59224
           Summary: XSSFColor.hasTint() has wrong implementation
           Product: POI
           Version: 3.14-FINAL
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XSSF
          Assignee: dev@poi.apache.org
          Reporter: gubespam@gmail.com

It appears that XSSFColor.hasTint() has an incorrect implementation. It checks
to see if the RGB array is length 4 as the determining factor. But other
methods in this class indicate that an length of 4 means the color has an
*alpha* value.

As a concrete example, try creating a xlsx spreadsheet in Excel, with a color
that has a tint value. The hasTint() method will return false, but the
getTint() method returns a non-zero value.

So, I think hasTint() should just be renamed to hasAlpha() (and method's
javadoc comment updated), and a new method created called hasTint(), with an
implemention like below:

    /**
     * A boolean value indicating if the ctColor has alpha or not
     */
    public boolean hasAlpha() {
        if (! ctColor.isSetRgb()) {
            return false;
        }
        return ctColor.getRgb().length == 4;
    }

    /**
     * A boolean value indicating if the ctColor has a tint or not
     */
    public boolean hasTint() {
        return ctColor.getTint() != 0;
    }

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


Mime
View raw message