You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2016/03/23 21:54:17 UTC

[Bug 59224] New: XSSFColor.hasTint() has wrong implementation

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


[Bug 59224] XSSFColor.hasTint() has wrong implementation

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59224

Javen O'Neal <on...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED

--- Comment #3 from Javen O'Neal <on...@apache.org> ---
Applied in r1736469.

-- 
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


[Bug 59224] XSSFColor.hasTint() has wrong implementation

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59224

gubespam@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |gubespam@gmail.com
                 OS|                            |All

-- 
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


[Bug 59224] XSSFColor.hasTint() has wrong implementation

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59224

--- Comment #2 from Javen O'Neal <on...@apache.org> ---
Created attachment 33700
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=33700&action=edit
change hasTint, add hasAlpha and unit tests

Is this all that needs to be modified?

-- 
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


[Bug 59224] XSSFColor.hasTint() has wrong implementation

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59224

--- Comment #1 from Javen O'Neal <on...@apache.org> ---
Should hasTint return false if tint is not set?

    public boolean hasTint() {
        if (!ctColor.isSetTint()) {
            return false;
        }
        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