https://issues.apache.org/bugzilla/show_bug.cgi?id=51222
--- Comment #6 from Randy Gettman <[email protected]> --- I believe I have the explanation for why these specific colors get reversed. This also explains why black and white get reversed in Bugs 51236, 52079, and 53274. Whenever certain Theme colors are used, the following colors get swapped in POI: - FFFFFF and 000000 (white and black) (themes 0 and 1, respectively) - EEECE1 and 1F497D (tan and dark blue) (themes 2 and 3, respectively) Here is an excerpt from a typical “theme1.xml” file from an .xlsx file: <a:clrScheme name="Office"> <a:dk1><a:sysClr val="windowText" lastClr="000000"/></a:dk1> <a:lt1><a:sysClr val="window" lastClr="FFFFFF"/></a:lt1> <a:dk2><a:srgbClr val="1F497D"/></a:dk2> <a:lt2><a:srgbClr val="EEECE1"/></a:lt2> <a:accent1><a:srgbClr val="4F81BD"/></a:accent1> <a:accent2><a:srgbClr val="C0504D"/></a:accent2> <a:accent3><a:srgbClr val="9BBB59"/></a:accent3> <a:accent4><a:srgbClr val="8064A2"/></a:accent4> <a:accent5><a:srgbClr val="4BACC6"/></a:accent5> <a:accent6><a:srgbClr val="F79646"/></a:accent6> <a:hlink><a:srgbClr val="0000FF"/></a:hlink> <a:folHlink><a:srgbClr val="800080"/></a:folHlink> </a:clrScheme> However, theme 0 is NOT black, it’s white, and theme 1 is NOT white, it’s black. Additionally, theme 2 is NOT dark blue, it’s tan, and theme 3 is NOT tan, it’s dark blue. (The other theme colors are in order.) I’ve attached a spreadsheet “Themes.xlsx” that contains one cell per row, with text cells colored in theme color order (0-11). Changing the order of the color elements in the color scheme in theme1.xml does not affect the colors of the text in the resultant spreadsheet. Therefore, Excel is not taking the theme number as an array index into the list of theme colors; it must be mapping the theme number to specific theme color elements: - 0 => a:lt1 (LISTED SECOND in theme1.xml!) - 1 => a:dk1 (LISTED FIRST!) - 2 => a:lt2 (LISTED FOURTH!) - 3 => a:dk2 (LISTED THIRD!) - 4 => a:accent1 - 5 => a:accent2 - 6 => a:accent3 - 7 => a:accent4 - 8 => a:accent5 - 9 => a:accent6 - 10 => a:hlink - 11 => a:folHlink POI versions 3.8 and 3.9 applied a fix to this issue in XSSFColor.java and ThemesTable.java that is incorrect, namely, using the “correctRGB” method in XSSFColor.java, which flips black and white. But the fix itself is incorrect. It did not resolve the issue or explain why black and white get reversed. I have attached a patch that makes the following changes to resolve the above issues: - src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFColor.java: Removed the flawed “correctRGB” method, and removed all calls to it. (It was private, so all calls to it were only in XSSFColor.java.) - src/ooxml/java/org/apache/poi/xssf/model/ThemesTables.java: Introduced a Map of theme numbers to XSSFColors. Created a new private method “cacheThemeColors” that is called by the constructors to initialize the Map. Moved the logic that extracts the XSSFColor from the theme color element to a new private method “getXSSFColor”. The existing method “getThemeColor” now accesses the Map to retrieve an XSSFColor. - src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFColor.java: Changed a few incorrect “assertEquals” statements. When tinting white darker, the black/white flip no longer occurs, so white (255, 255, 255) gets tinted darker to (165, 165, 165), not to (0, 0, 0); the byte array is really [-91, -91, -91]. Later, when assigning the color black, now the correct byte array [0, 0, 0] is passed in instead of [-1, -1, -1], and the ARGB string is expected to be “FF000000” instead of “FFFFFFFF”. - src/ooxml/testcases/org/apache/poi/xssf/usermodel/extensions/TestXSSFCellFill.java: This attempted to verify a tinted theme color, dark blue (dk2), but the RGB codes in the test were for tan (lt2). These values are now corrected. - src/ooxml/testcases/org/apache/poi/xssf/model/TestThemesTable.java: A new JUnit test for ThemesTable.java. - test-data/spreadsheet/Themes.xlsx: This new spreadsheet is the same as the one mentioned above. It helps test ThemesTable.java in TestThemesTable.java. -- You are receiving this mail because: You are the assignee for the bug. --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
