Author: gwoolsey
Date: Fri May 26 23:14:48 2017
New Revision: 1796359
URL: http://svn.apache.org/viewvc?rev=1796359&view=rev
Log:
Bug 60898 - XSSFColor's getARGB() method returns a wrong color value when a
workbook has a custom indexed color
teach XSSFColor and most things that create instances about indexed colors.
Null is a valid value for IndexedColorMap instances - the existing built-in
default colors are used.
Whenever a workbook style is accessible in the call hierarchy its color
mappings are passed down now.
Thanks for the unit test in the issue, it now passes.
Added:
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/CustomIndexedColorMap.java
(with props)
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/DefaultIndexedColorMap.java
(with props)
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/IndexedColorMap.java
(with props)
poi/trunk/test-data/spreadsheet/customIndexedColors.xlsx (with props)
Modified:
poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFExtendedColor.java
poi/trunk/src/java/org/apache/poi/ss/usermodel/ExtendedColor.java
poi/trunk/src/java/org/apache/poi/ss/usermodel/IndexedColors.java
poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/StylesTable.java
poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/ThemesTable.java
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFBorderFormatting.java
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFColor.java
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFColorScaleFormatting.java
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFConditionalFormattingRule.java
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCreationHelper.java
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDataBarFormatting.java
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDxfStyleProvider.java
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFont.java
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFontFormatting.java
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPatternFormatting.java
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFTableStyle.java
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/extensions/XSSFCellBorder.java
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/extensions/XSSFCellFill.java
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFColor.java
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFont.java
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/extensions/TestXSSFCellFill.java
Modified:
poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFExtendedColor.java
URL:
http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFExtendedColor.java?rev=1796359&r1=1796358&r2=1796359&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFExtendedColor.java
(original)
+++ poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFExtendedColor.java Fri
May 26 23:14:48 2017
@@ -22,6 +22,7 @@ import static org.apache.poi.hssf.record
import static org.apache.poi.hssf.record.common.ExtendedColor.TYPE_RGB;
import static org.apache.poi.hssf.record.common.ExtendedColor.TYPE_THEMED;
+import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.ss.usermodel.ExtendedColor;
/**
@@ -106,4 +107,19 @@ public class HSSFExtendedColor extends E
public void setTint(double tint) {
color.setTint(tint);
}
+
+ protected byte[] getIndexedRGB() {
+ if (isIndexed() && getIndex() > 0) {
+ int indexNum = getIndex();
+ HSSFColor indexed = HSSFColor.getIndexHash().get(indexNum);
+ if (indexed != null) {
+ byte[] rgb = new byte[3];
+ rgb[0] = (byte) indexed.getTriplet()[0];
+ rgb[1] = (byte) indexed.getTriplet()[1];
+ rgb[2] = (byte) indexed.getTriplet()[2];
+ return rgb;
+ }
+ } // else
+ return null;
+ }
}
Modified: poi/trunk/src/java/org/apache/poi/ss/usermodel/ExtendedColor.java
URL:
http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/usermodel/ExtendedColor.java?rev=1796359&r1=1796358&r2=1796359&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/usermodel/ExtendedColor.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/usermodel/ExtendedColor.java Fri May
26 23:14:48 2017
@@ -18,77 +18,80 @@ package org.apache.poi.ss.usermodel;
import java.util.Locale;
-import org.apache.poi.hssf.util.HSSFColor;
-
/**
* Represents a XSSF-style color (based on either a
* {@link org.apache.poi.xssf.usermodel.XSSFColor} or a
* {@link org.apache.poi.hssf.record.common.ExtendedColor}
*/
public abstract class ExtendedColor implements Color {
+
+ /**
+ *
+ * @param clr awt Color to set
+ */
protected void setColor(java.awt.Color clr) {
setRGB(new byte[]{(byte)clr.getRed(), (byte)clr.getGreen(),
(byte)clr.getBlue()});
}
/**
- * A boolean value indicating the color is automatic
+ * @return true if the color is automatic
*/
public abstract boolean isAuto();
/**
- * A boolean value indicating the color is indexed
+ * @return true if the color is indexed
*/
public abstract boolean isIndexed();
/**
- * A boolean value indicating the color is RGB / ARGB
+ * @return true if the color is RGB / ARGB
*/
public abstract boolean isRGB();
/**
- * A boolean value indicating the color is from a Theme
+ * @return true if the color is from a Theme
*/
public abstract boolean isThemed();
/**
- * Indexed Color value, if {@link #isIndexed()} is true
+ * @return Indexed Color index value, if {@link #isIndexed()} is true
*/
public abstract short getIndex();
/**
- * Index of Theme color, if {@link #isThemed()} is true
+ * @return Index of Theme color, if {@link #isThemed()} is true
*/
public abstract int getTheme();
/**
- * Standard Red Green Blue ctColor value (RGB).
+ * @return Standard Red Green Blue ctColor value (RGB) bytes.
* If there was an A (Alpha) value, it will be stripped.
*/
public abstract byte[] getRGB();
+
/**
- * Standard Alpha Red Green Blue ctColor value (ARGB).
+ * @return Standard Alpha Red Green Blue ctColor value (ARGB) bytes.
*/
public abstract byte[] getARGB();
/**
- * RGB or ARGB or null
+ * @return RGB or ARGB bytes or null
*/
protected abstract byte[] getStoredRBG();
/**
* Sets the Red Green Blue or Alpha Red Green Blue
+ * @param rgb bytes
*/
public abstract void setRGB(byte[] rgb);
+ /**
+ * @return RGB or ARGB bytes, either stored or by index
+ */
protected byte[] getRGBOrARGB() {
if (isIndexed() && getIndex() > 0) {
- int indexNum = getIndex();
- HSSFColor indexed = HSSFColor.getIndexHash().get(indexNum);
- if (indexed != null) {
- byte[] rgb = new byte[3];
- rgb[0] = (byte) indexed.getTriplet()[0];
- rgb[1] = (byte) indexed.getTriplet()[1];
- rgb[2] = (byte) indexed.getTriplet()[2];
+ byte[] rgb = getIndexedRGB();
+ if (rgb != null) {
return rgb;
}
}
@@ -96,9 +99,14 @@ public abstract class ExtendedColor impl
// Grab the colour
return getStoredRBG();
}
+
+ /**
+ * @return index color RGB bytes, if {@link #isIndexed()} == true, null if
not indexed or index is invalid
+ */
+ protected abstract byte[] getIndexedRGB();
/**
- * Standard Red Green Blue ctColor value (RGB) with applied tint.
+ * @return Standard Red Green Blue ctColor value (RGB) bytes with applied
tint.
* Alpha values are ignored.
*/
public byte[] getRGBWithTint() {
@@ -118,7 +126,7 @@ public abstract class ExtendedColor impl
}
/**
- * Return the ARGB value in hex format, eg FF00FF00.
+ * @return the ARGB value in hex string format, eg FF00FF00.
* Works for both regular and indexed colours.
*/
public String getARGBHex() {
@@ -142,6 +150,7 @@ public abstract class ExtendedColor impl
/**
* Sets the ARGB value from hex format, eg FF0077FF.
* Only works for regular (non-indexed) colours
+ * @param argb color ARGB hex string
*/
public void setARGBHex(String argb) {
if (argb.length() == 6 || argb.length() == 8) {
Modified: poi/trunk/src/java/org/apache/poi/ss/usermodel/IndexedColors.java
URL:
http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/usermodel/IndexedColors.java?rev=1796359&r1=1796358&r2=1796359&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/usermodel/IndexedColors.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/usermodel/IndexedColors.java Fri May
26 23:14:48 2017
@@ -31,7 +31,15 @@ package org.apache.poi.ss.usermodel;
*/
public enum IndexedColors {
- // 0-7?
+ // 0-7 duplicates of 8-15 for compatibility (OOXML spec pt.1 sec. 18.8.27)
+ BLACK1(0),
+ WHITE1(1),
+ RED1(2),
+ BRIGHT_GREEN1(3),
+ BLUE1(4),
+ YELLOW1(5),
+ PINK1(6),
+ TURQUOISE1(7),
BLACK(8),
WHITE(9),
RED(10),
@@ -51,7 +59,7 @@ public enum IndexedColors {
CORNFLOWER_BLUE(24),
MAROON(25),
LEMON_CHIFFON(26),
- // 27?
+ LIGHT_TURQUOISE1(27),
ORCHID(28),
CORAL(29),
ROYAL_BLUE(30),
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/StylesTable.java
URL:
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/StylesTable.java?rev=1796359&r1=1796358&r2=1796359&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/StylesTable.java
(original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/StylesTable.java Fri May
26 23:14:48 2017
@@ -41,6 +41,9 @@ import org.apache.poi.ss.usermodel.FontF
import org.apache.poi.ss.usermodel.FontScheme;
import org.apache.poi.ss.usermodel.TableStyle;
import org.apache.poi.util.Internal;
+import org.apache.poi.xssf.usermodel.CustomIndexedColorMap;
+import org.apache.poi.xssf.usermodel.DefaultIndexedColorMap;
+import org.apache.poi.xssf.usermodel.IndexedColorMap;
import org.apache.poi.xssf.usermodel.XSSFBuiltinTableStyle;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.apache.poi.xssf.usermodel.XSSFFactory;
@@ -51,24 +54,7 @@ import org.apache.poi.xssf.usermodel.XSS
import org.apache.poi.xssf.usermodel.extensions.XSSFCellBorder;
import org.apache.poi.xssf.usermodel.extensions.XSSFCellFill;
import org.apache.xmlbeans.XmlException;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorder;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorders;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCellStyleXfs;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCellXfs;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTDxf;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTDxfs;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFill;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFills;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFont;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFonts;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTNumFmt;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTNumFmts;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTStylesheet;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTTableStyle;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTTableStyles;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTXf;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.STPatternType;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.StyleSheetDocument;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.*;
/**
* Table of styles shared across all sheets in a workbook.
@@ -83,7 +69,9 @@ public class StylesTable extends POIXMLD
private final List<CTDxf> dxfs = new ArrayList<CTDxf>();
private final Map<String, TableStyle> tableStyles = new HashMap<String,
TableStyle>();
-
+
+ private IndexedColorMap indexedColors = new DefaultIndexedColorMap();
+
/**
* The first style id available for use as a custom style
*/
@@ -170,6 +158,8 @@ public class StylesTable extends POIXMLD
public void setTheme(ThemesTable theme) {
this.theme = theme;
+ if (theme != null) theme.setColorMap(getIndexedColors());
+
// Pass the themes table along to things which need to
// know about it, but have already been created by now
for(XSSFFont font : fonts) {
@@ -188,7 +178,7 @@ public class StylesTable extends POIXMLD
public void ensureThemesTable() {
if (theme != null) return;
- theme = (ThemesTable)workbook.createRelationship(XSSFRelation.THEME,
XSSFFactory.getInstance());
+ setTheme((ThemesTable)workbook.createRelationship(XSSFRelation.THEME,
XSSFFactory.getInstance()));
}
/**
@@ -204,6 +194,11 @@ public class StylesTable extends POIXMLD
CTStylesheet styleSheet = doc.getStyleSheet();
// Grab all the different bits we care about
+
+ // keep this first, as some constructors below want it
+ IndexedColorMap customColors =
CustomIndexedColorMap.fromColors(styleSheet.getColors());
+ if (customColors != null) indexedColors = customColors;
+
CTNumFmts ctfmts = styleSheet.getNumFmts();
if( ctfmts != null){
for (CTNumFmt nfmt : ctfmts.getNumFmtArray()) {
@@ -217,7 +212,7 @@ public class StylesTable extends POIXMLD
int idx = 0;
for (CTFont font : ctfonts.getFontArray()) {
// Create the font and save it. Themes Table supplied later
- XSSFFont f = new XSSFFont(font, idx);
+ XSSFFont f = new XSSFFont(font, idx, indexedColors);
fonts.add(f);
idx++;
}
@@ -225,14 +220,14 @@ public class StylesTable extends POIXMLD
CTFills ctfills = styleSheet.getFills();
if(ctfills != null){
for (CTFill fill : ctfills.getFillArray()) {
- fills.add(new XSSFCellFill(fill));
+ fills.add(new XSSFCellFill(fill, indexedColors));
}
}
CTBorders ctborders = styleSheet.getBorders();
if(ctborders != null) {
for (CTBorder border : ctborders.getBorderArray()) {
- borders.add(new XSSFCellBorder(border));
+ borders.add(new XSSFCellBorder(border, indexedColors));
}
}
@@ -249,7 +244,7 @@ public class StylesTable extends POIXMLD
if (ctTableStyles != null) {
int idx = 0;
for (CTTableStyle style :
Arrays.asList(ctTableStyles.getTableStyleArray())) {
- tableStyles.put(style.getName(), new XSSFTableStyle(idx,
styleDxfs, style));
+ tableStyles.put(style.getName(), new XSSFTableStyle(idx,
styleDxfs, style, indexedColors));
idx++;
}
}
@@ -716,8 +711,8 @@ public class StylesTable extends POIXMLD
fonts.add(xssfFont);
CTFill[] ctFill = createDefaultFills();
- fills.add(new XSSFCellFill(ctFill[0]));
- fills.add(new XSSFCellFill(ctFill[1]));
+ fills.add(new XSSFCellFill(ctFill[0], indexedColors));
+ fills.add(new XSSFCellFill(ctFill[1], indexedColors));
CTBorder ctBorder = createDefaultBorder();
borders.add(new XSSFCellBorder(ctBorder));
@@ -757,7 +752,7 @@ public class StylesTable extends POIXMLD
private static XSSFFont createDefaultFont() {
CTFont ctFont = CTFont.Factory.newInstance();
- XSSFFont xssfFont=new XSSFFont(ctFont, 0);
+ XSSFFont xssfFont=new XSSFFont(ctFont, 0, null);
xssfFont.setFontHeightInPoints(XSSFFont.DEFAULT_FONT_SIZE);
xssfFont.setColor(XSSFFont.DEFAULT_FONT_COLOR);//setTheme
xssfFont.setFontName(XSSFFont.DEFAULT_FONT_NAME);
@@ -881,4 +876,11 @@ public class StylesTable extends POIXMLD
}
return null;
}
+
+ /**
+ * @return default or custom indexed color to RGB mapping
+ */
+ public IndexedColorMap getIndexedColors() {
+ return indexedColors;
+ }
}
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/ThemesTable.java
URL:
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/ThemesTable.java?rev=1796359&r1=1796358&r2=1796359&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/ThemesTable.java
(original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/ThemesTable.java Fri May
26 23:14:48 2017
@@ -23,6 +23,7 @@ import java.io.OutputStream;
import org.apache.poi.POIXMLDocumentPart;
import org.apache.poi.openxml4j.opc.PackagePart;
+import org.apache.poi.xssf.usermodel.IndexedColorMap;
import org.apache.poi.xssf.usermodel.XSSFColor;
import org.apache.xmlbeans.XmlException;
import org.openxmlformats.schemas.drawingml.x2006.main.CTColor;
@@ -60,6 +61,7 @@ public class ThemesTable extends POIXMLD
public final String name;
}
+ private IndexedColorMap colorMap;
private ThemeDocument theme;
/**
@@ -96,6 +98,14 @@ public class ThemesTable extends POIXMLD
}
/**
+ * called from {@link StylesTable} when setting theme, used to adjust
colors if a custom indexed mapping is defined
+ * @param colorMap
+ */
+ protected void setColorMap(IndexedColorMap colorMap) {
+ this.colorMap = colorMap;
+ }
+
+ /**
* Convert a theme "index" (as used by fonts etc) into a color.
* @param idx A theme "index"
* @return The mapped XSSFColor, or null if not mapped.
@@ -132,7 +142,7 @@ public class ThemesTable extends POIXMLD
} else {
return null;
}
- return new XSSFColor(rgb);
+ return new XSSFColor(rgb, colorMap);
}
/**
Added:
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/CustomIndexedColorMap.java
URL:
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/CustomIndexedColorMap.java?rev=1796359&view=auto
==============================================================================
---
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/CustomIndexedColorMap.java
(added)
+++
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/CustomIndexedColorMap.java
Fri May 26 23:14:48 2017
@@ -0,0 +1,65 @@
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+package org.apache.poi.xssf.usermodel;
+
+import java.util.List;
+
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTColors;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRgbColor;
+
+/**
+ * custom index color map, i.e. from the styles.xml definition
+ */
+public class CustomIndexedColorMap implements IndexedColorMap {
+
+ private final byte[][] colorIndex;
+
+ /**
+ * @param colors array of RGB triplets indexed by color index
+ */
+ private CustomIndexedColorMap(byte [][] colors) {
+ this.colorIndex = colors;
+ }
+
+ public byte[] getRGB(int index) {
+ if (colorIndex == null || index < 0 || index >= colorIndex.length)
return null;
+ return colorIndex[index];
+ }
+
+ /**
+ * OOXML spec says if this exists it must have all indexes.
+ * <p/>
+ * From the OOXML Spec, Part 1, section 18.8.27:
+ * <p/><i>
+ * This element contains a sequence of RGB color values that correspond to
color indexes (zero-based). When
+ * using the default indexed color palette, the values are not written
out, but instead are implied. When the color
+ * palette has been modified from default, then the entire color palette
is written out.
+ * </i>
+ * @param colors CTColors from styles.xml possibly defining a custom color
indexing scheme
+ * @return custom indexed color map or null if none defined in the document
+ */
+ public static CustomIndexedColorMap fromColors(CTColors colors) {
+ if (colors == null || ! colors.isSetIndexedColors()) return null;
+
+ List<CTRgbColor> rgbColorList =
colors.getIndexedColors().getRgbColorList();
+ byte[][] customColorIndex = new byte[rgbColorList.size()][3];
+ for (int i=0; i < rgbColorList.size(); i++) {
+ customColorIndex[i] = rgbColorList.get(i).getRgb();
+ }
+ return new CustomIndexedColorMap(customColorIndex);
+ }
+}
Propchange:
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/CustomIndexedColorMap.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/DefaultIndexedColorMap.java
URL:
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/DefaultIndexedColorMap.java?rev=1796359&view=auto
==============================================================================
---
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/DefaultIndexedColorMap.java
(added)
+++
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/DefaultIndexedColorMap.java
Fri May 26 23:14:48 2017
@@ -0,0 +1,44 @@
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+package org.apache.poi.xssf.usermodel;
+
+import org.apache.poi.hssf.util.HSSFColor;
+
+/**
+ * Uses the legacy colors defined in HSSF for index lookups
+ */
+public class DefaultIndexedColorMap implements IndexedColorMap {
+
+ /**
+ * @see org.apache.poi.xssf.usermodel.IndexedColorMap#getRGB(int)
+ */
+ public byte[] getRGB(int index) {
+ return getDefaultRGB(index);
+ }
+
+ /**
+ * @param index
+ * @return RGB bytes from HSSF default color by index
+ */
+ public static byte[] getDefaultRGB(int index) {
+ HSSFColor hssfColor = HSSFColor.getIndexHash().get(index);
+ if (hssfColor == null) return null;
+ short[] rgbShort = hssfColor.getTriplet();
+ return new byte[] {(byte) rgbShort[0], (byte) rgbShort[1], (byte)
rgbShort[2]};
+ }
+
+}
Propchange:
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/DefaultIndexedColorMap.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/IndexedColorMap.java
URL:
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/IndexedColorMap.java?rev=1796359&view=auto
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/IndexedColorMap.java
(added)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/IndexedColorMap.java
Fri May 26 23:14:48 2017
@@ -0,0 +1,31 @@
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+package org.apache.poi.xssf.usermodel;
+
+/**
+ * Interface for color index to RGB mappings.
+ * May be either the default, built-in mappings
+ * or custom mappings defined in the document.
+ */
+public interface IndexedColorMap {
+
+ /**
+ * @param index color index to look up
+ * @return the RGB array for the index, or null if the index is
invalid/undefined
+ */
+ byte[] getRGB(int index);
+}
Propchange:
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/IndexedColorMap.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified:
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFBorderFormatting.java
URL:
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFBorderFormatting.java?rev=1796359&r1=1796358&r2=1796359&view=diff
==============================================================================
---
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFBorderFormatting.java
(original)
+++
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFBorderFormatting.java
Fri May 26 23:14:48 2017
@@ -20,19 +20,21 @@ import org.apache.poi.ss.usermodel.Borde
import org.apache.poi.ss.usermodel.BorderStyle;
import org.apache.poi.ss.usermodel.Color;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorder;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.STBorderStyle;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorderPr;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTColor;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.STBorderStyle;
/**
* XSSF high level representation for Border Formatting component
* of Conditional Formatting settings
*/
public class XSSFBorderFormatting implements BorderFormatting {
+ IndexedColorMap _colorMap;
CTBorder _border;
- /*package*/ XSSFBorderFormatting(CTBorder border) {
+ /*package*/ XSSFBorderFormatting(CTBorder border, IndexedColorMap
colorMap) {
_border = border;
+ _colorMap = colorMap;
}
/**
@@ -125,7 +127,7 @@ public class XSSFBorderFormatting implem
if(!_border.isSetBottom()) return null;
CTBorderPr pr = _border.getBottom();
- return new XSSFColor(pr.getColor());
+ return new XSSFColor(pr.getColor(), _colorMap);
}
@Override
public short getBottomBorderColor() {
@@ -139,7 +141,7 @@ public class XSSFBorderFormatting implem
if(!_border.isSetDiagonal()) return null;
CTBorderPr pr = _border.getDiagonal();
- return new XSSFColor(pr.getColor());
+ return new XSSFColor(pr.getColor(), _colorMap);
}
@Override
public short getDiagonalBorderColor() {
@@ -153,7 +155,7 @@ public class XSSFBorderFormatting implem
if(!_border.isSetLeft()) return null;
CTBorderPr pr = _border.getLeft();
- return new XSSFColor(pr.getColor());
+ return new XSSFColor(pr.getColor(), _colorMap);
}
@Override
public short getLeftBorderColor() {
@@ -167,7 +169,7 @@ public class XSSFBorderFormatting implem
if(!_border.isSetRight()) return null;
CTBorderPr pr = _border.getRight();
- return new XSSFColor(pr.getColor());
+ return new XSSFColor(pr.getColor(), _colorMap);
}
@Override
public short getRightBorderColor() {
@@ -181,7 +183,7 @@ public class XSSFBorderFormatting implem
if(!_border.isSetTop()) return null;
CTBorderPr pr = _border.getTop();
- return new XSSFColor(pr.getColor());
+ return new XSSFColor(pr.getColor(), _colorMap);
}
@Override
public short getTopBorderColor() {
Modified:
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java
URL:
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java?rev=1796359&r1=1796358&r2=1796359&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java
(original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java
Fri May 26 23:14:48 2017
@@ -204,14 +204,14 @@ public class XSSFCellStyle implements Ce
}
private void addFill(CTFill fill) {
- int idx = _stylesSource.putFill(new XSSFCellFill(fill));
+ int idx = _stylesSource.putFill(new
XSSFCellFill(fill,_stylesSource.getIndexedColors()));
_cellXf.setFillId(idx);
_cellXf.setApplyFill(true);
}
private void addBorder(CTBorder border) {
- int idx = _stylesSource.putBorder(new XSSFCellBorder(border, _theme));
+ int idx = _stylesSource.putBorder(new XSSFCellBorder(border,
_theme,_stylesSource.getIndexedColors()));
_cellXf.setBorderId(idx);
_cellXf.setApplyBorder(true);
@@ -834,7 +834,7 @@ public class XSSFCellStyle implements Ce
if(border == BorderStyle.NONE) ct.unsetBottom();
else pr.setStyle(STBorderStyle.Enum.forInt(border.getCode() + 1));
- int idx = _stylesSource.putBorder(new XSSFCellBorder(ct, _theme));
+ int idx = _stylesSource.putBorder(new XSSFCellBorder(ct, _theme,
_stylesSource.getIndexedColors()));
_cellXf.setBorderId(idx);
_cellXf.setApplyBorder(true);
@@ -864,7 +864,7 @@ public class XSSFCellStyle implements Ce
if(border == BorderStyle.NONE) ct.unsetLeft();
else pr.setStyle(STBorderStyle.Enum.forInt(border.getCode() + 1));
- int idx = _stylesSource.putBorder(new XSSFCellBorder(ct, _theme));
+ int idx = _stylesSource.putBorder(new XSSFCellBorder(ct, _theme,
_stylesSource.getIndexedColors()));
_cellXf.setBorderId(idx);
_cellXf.setApplyBorder(true);
@@ -895,7 +895,7 @@ public class XSSFCellStyle implements Ce
if(border == BorderStyle.NONE) ct.unsetRight();
else pr.setStyle(STBorderStyle.Enum.forInt(border.getCode() + 1));
- int idx = _stylesSource.putBorder(new XSSFCellBorder(ct, _theme));
+ int idx = _stylesSource.putBorder(new XSSFCellBorder(ct,
_theme,_stylesSource.getIndexedColors()));
_cellXf.setBorderId(idx);
_cellXf.setApplyBorder(true);
@@ -926,7 +926,7 @@ public class XSSFCellStyle implements Ce
if(border == BorderStyle.NONE) ct.unsetTop();
else pr.setStyle(STBorderStyle.Enum.forInt(border.getCode() + 1));
- int idx = _stylesSource.putBorder(new XSSFCellBorder(ct, _theme));
+ int idx = _stylesSource.putBorder(new XSSFCellBorder(ct,
_theme,_stylesSource.getIndexedColors()));
_cellXf.setBorderId(idx);
_cellXf.setApplyBorder(true);
@@ -957,7 +957,7 @@ public class XSSFCellStyle implements Ce
if(color != null) pr.setColor(color.getCTColor());
else pr.unsetColor();
- int idx = _stylesSource.putBorder(new XSSFCellBorder(ct, _theme));
+ int idx = _stylesSource.putBorder(new XSSFCellBorder(ct,
_theme,_stylesSource.getIndexedColors()));
_cellXf.setBorderId(idx);
_cellXf.setApplyBorder(true);
@@ -1244,7 +1244,7 @@ public class XSSFCellStyle implements Ce
if(color != null) pr.setColor(color.getCTColor());
else pr.unsetColor();
- int idx = _stylesSource.putBorder(new XSSFCellBorder(ct, _theme));
+ int idx = _stylesSource.putBorder(new XSSFCellBorder(ct,
_theme,_stylesSource.getIndexedColors()));
_cellXf.setBorderId(idx);
_cellXf.setApplyBorder(true);
@@ -1299,7 +1299,7 @@ public class XSSFCellStyle implements Ce
if(color != null) pr.setColor(color.getCTColor());
else pr.unsetColor();
- int idx = _stylesSource.putBorder(new XSSFCellBorder(ct, _theme));
+ int idx = _stylesSource.putBorder(new XSSFCellBorder(ct,
_theme,_stylesSource.getIndexedColors()));
_cellXf.setBorderId(idx);
_cellXf.setApplyBorder(true);
@@ -1356,7 +1356,7 @@ public class XSSFCellStyle implements Ce
if(color != null) pr.setColor(color.getCTColor());
else pr.unsetColor();
- int idx = _stylesSource.putBorder(new XSSFCellBorder(ct, _theme));
+ int idx = _stylesSource.putBorder(new XSSFCellBorder(ct,
_theme,_stylesSource.getIndexedColors()));
_cellXf.setBorderId(idx);
_cellXf.setApplyBorder(true);
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=1796359&r1=1796358&r2=1796359&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 Fri
May 26 23:14:48 2017
@@ -22,6 +22,7 @@ import org.apache.poi.ss.usermodel.Color
import org.apache.poi.ss.usermodel.ExtendedColor;
import org.apache.poi.ss.usermodel.IndexedColors;
import org.apache.poi.util.Internal;
+import org.apache.poi.util.Removal;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTColor;
/**
@@ -29,33 +30,62 @@ import org.openxmlformats.schemas.spread
*/
public class XSSFColor extends ExtendedColor {
private final CTColor ctColor;
+ private final IndexedColorMap indexedColorMap;
/**
- * Create an instance of XSSFColor from the supplied XML bean
+ * Create an instance of XSSFColor from the supplied XML bean, with
default color indexes
+ * @param color
+ * @deprecated 3.17 beta 1 - pass the workbook styles indexed color map,
if any
*/
+ @Deprecated
+ @Removal(version="3.19")
public XSSFColor(CTColor color) {
+ this(color, new DefaultIndexedColorMap());
+ }
+
+ /**
+ * Create an instance of XSSFColor from the supplied XML bean, with the
given color indexes
+ * @param color
+ * @param map
+ */
+ public XSSFColor(CTColor color, IndexedColorMap map) {
this.ctColor = color;
+ this.indexedColorMap = map;
}
/**
- * Create an new instance of XSSFColor
+ * Create an new instance of XSSFColor, without knowledge of any custom
indexed colors.
+ * This is OK for just transiently setting indexes, etc. but is
discouraged in read/get uses
*/
public XSSFColor() {
- this.ctColor = CTColor.Factory.newInstance();
+ this(CTColor.Factory.newInstance(), null);
}
+ /**
+ * TEST ONLY - does not know about custom indexed colors
+ * @param clr awt Color
+ */
public XSSFColor(java.awt.Color clr) {
this();
setColor(clr);
}
- public XSSFColor(byte[] rgb) {
- this();
+ /**
+ *
+ * @param rgb bytes
+ * @param colorMap
+ */
+ public XSSFColor(byte[] rgb, IndexedColorMap colorMap) {
+ this(CTColor.Factory.newInstance(), colorMap);
ctColor.setRgb(rgb);
}
- public XSSFColor(IndexedColors indexedColor) {
- this();
+ /**
+ * @param indexedColor color index (Enum named for default colors)
+ * @param colorMap
+ */
+ public XSSFColor(IndexedColors indexedColor, IndexedColorMap colorMap) {
+ this(CTColor.Factory.newInstance(), colorMap);
ctColor.setIndexed(indexedColor.index);
}
@@ -67,7 +97,7 @@ public class XSSFColor extends ExtendedC
return ctColor.getAuto();
}
/**
- * A boolean value indicating the ctColor is automatic and system ctColor
dependent.
+ * @param auto true if the ctColor is automatic and system ctColor
dependent.
*/
public void setAuto(boolean auto) {
ctColor.setAuto(auto);
@@ -82,7 +112,7 @@ public class XSSFColor extends ExtendedC
}
/**
- * A boolean value indicating the ctColor is RGB or ARGB based
+ * @return true if the ctColor is RGB or ARGB based
*/
@Override
public boolean isRGB() {
@@ -90,7 +120,7 @@ public class XSSFColor extends ExtendedC
}
/**
- * A boolean value indicating the ctColor is Theme based
+ * @return true if the ctColor is Theme based
*/
@Override
public boolean isThemed() {
@@ -98,7 +128,7 @@ public class XSSFColor extends ExtendedC
}
/**
- * A boolean value indicating if the ctColor has a alpha or not
+ * @return true if the ctColor has a alpha
*/
public boolean hasAlpha() {
if (! ctColor.isSetRgb()) {
@@ -108,7 +138,7 @@ public class XSSFColor extends ExtendedC
}
/**
- * A boolean value indicating if the ctColor has a tint or not
+ * @return true if the ctColor has a tint
*/
public boolean hasTint() {
if (!ctColor.isSetTint()) {
@@ -125,7 +155,7 @@ public class XSSFColor extends ExtendedC
return (short)ctColor.getIndexed();
}
/**
- * Indexed ctColor value. Only used for backwards compatibility.
References a ctColor in indexedColors.
+ * @return Indexed ctColor value. Only used for backwards compatibility.
References a ctColor in indexedColors.
*/
public short getIndexed() {
return getIndex();
@@ -133,6 +163,7 @@ public class XSSFColor extends ExtendedC
/**
* Indexed ctColor value. Only used for backwards compatibility.
References a ctColor in indexedColors.
+ * @param indexed color index
*/
public void setIndexed(int indexed) {
ctColor.setIndexed(indexed);
@@ -185,6 +216,14 @@ public class XSSFColor extends ExtendedC
return ctColor.getRgb();
}
+ protected byte[] getIndexedRGB() {
+ if (isIndexed()) {
+ if (indexedColorMap != null) return
indexedColorMap.getRGB(getIndex());
+ return DefaultIndexedColorMap.getDefaultRGB(getIndex());
+ }
+ return null;
+ }
+
/**
* Standard Alpha Red Green Blue ctColor value (ARGB).
*/
@@ -205,6 +244,7 @@ public class XSSFColor extends ExtendedC
/**
* Index into the <clrScheme> collection, referencing a particular
<sysClr> or
* <srgbClr> value expressed in the Theme part.
+ * @param theme index
*/
public void setTheme(int theme) {
ctColor.setTheme(theme);
Modified:
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFColorScaleFormatting.java
URL:
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFColorScaleFormatting.java?rev=1796359&r1=1796358&r2=1796359&view=diff
==============================================================================
---
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFColorScaleFormatting.java
(original)
+++
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFColorScaleFormatting.java
Fri May 26 23:14:48 2017
@@ -30,10 +30,12 @@ import org.openxmlformats.schemas.spread
* component of Conditional Formatting settings
*/
public class XSSFColorScaleFormatting implements ColorScaleFormatting {
- CTColorScale _scale;
+ private CTColorScale _scale;
+ private IndexedColorMap _indexedColorMap;
- /*package*/ XSSFColorScaleFormatting(CTColorScale scale){
+ /*package*/ XSSFColorScaleFormatting(CTColorScale scale, IndexedColorMap
colorMap){
_scale = scale;
+ _indexedColorMap = colorMap;
}
public int getNumControlPoints() {
@@ -54,7 +56,7 @@ public class XSSFColorScaleFormatting im
CTColor[] ctcols = _scale.getColorArray();
XSSFColor[] c = new XSSFColor[ctcols.length];
for (int i=0; i<ctcols.length; i++) {
- c[i] = new XSSFColor(ctcols[i]);
+ c[i] = new XSSFColor(ctcols[i], _indexedColorMap);
}
return c;
}
@@ -83,8 +85,11 @@ public class XSSFColorScaleFormatting im
_scale.setCfvoArray(cfvos);
}
+ /**
+ * @return color from scale
+ */
public XSSFColor createColor() {
- return new XSSFColor(_scale.addNewColor());
+ return new XSSFColor(_scale.addNewColor(), _indexedColorMap);
}
public XSSFConditionalFormattingThreshold createThreshold() {
return new XSSFConditionalFormattingThreshold(_scale.addNewCfvo());
Modified:
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFConditionalFormattingRule.java
URL:
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFConditionalFormattingRule.java?rev=1796359&r1=1796358&r2=1796359&view=diff
==============================================================================
---
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFConditionalFormattingRule.java
(original)
+++
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFConditionalFormattingRule.java
Fri May 26 23:14:48 2017
@@ -134,7 +134,7 @@ public class XSSFConditionalFormattingRu
border = dxf.getBorder();
}
- return new XSSFBorderFormatting(border);
+ return new XSSFBorderFormatting(border,
_sh.getWorkbook().getStylesSource().getIndexedColors());
}
/**
@@ -144,7 +144,7 @@ public class XSSFConditionalFormattingRu
CTDxf dxf = getDxf(false);
if(dxf == null || !dxf.isSetBorder()) return null;
- return new XSSFBorderFormatting(dxf.getBorder());
+ return new XSSFBorderFormatting(dxf.getBorder(),
_sh.getWorkbook().getStylesSource().getIndexedColors());
}
/**
@@ -162,7 +162,7 @@ public class XSSFConditionalFormattingRu
font = dxf.getFont();
}
- return new XSSFFontFormatting(font);
+ return new XSSFFontFormatting(font,
_sh.getWorkbook().getStylesSource().getIndexedColors());
}
/**
@@ -172,7 +172,7 @@ public class XSSFConditionalFormattingRu
CTDxf dxf = getDxf(false);
if(dxf == null || !dxf.isSetFont()) return null;
- return new XSSFFontFormatting(dxf.getFont());
+ return new XSSFFontFormatting(dxf.getFont(),
_sh.getWorkbook().getStylesSource().getIndexedColors());
}
/**
@@ -190,7 +190,7 @@ public class XSSFConditionalFormattingRu
fill = dxf.getFill();
}
- return new XSSFPatternFormatting(fill);
+ return new XSSFPatternFormatting(fill,
_sh.getWorkbook().getStylesSource().getIndexedColors());
}
/**
@@ -200,9 +200,14 @@ public class XSSFConditionalFormattingRu
CTDxf dxf = getDxf(false);
if(dxf == null || !dxf.isSetFill()) return null;
- return new XSSFPatternFormatting(dxf.getFill());
+ return new XSSFPatternFormatting(dxf.getFill(),
_sh.getWorkbook().getStylesSource().getIndexedColors());
}
+ /**
+ *
+ * @param color
+ * @return data bar formatting
+ */
public XSSFDataBarFormatting createDataBarFormatting(XSSFColor color) {
// Is it already there?
if (_cfRule.isSetDataBar() && _cfRule.getType() == STCfType.DATA_BAR)
@@ -228,12 +233,12 @@ public class XSSFConditionalFormattingRu
max.setType(STCfvoType.Enum.forString(RangeType.MAX.name));
// Wrap and return
- return new XSSFDataBarFormatting(bar);
+ return new XSSFDataBarFormatting(bar,
_sh.getWorkbook().getStylesSource().getIndexedColors());
}
public XSSFDataBarFormatting getDataBarFormatting() {
if (_cfRule.isSetDataBar()) {
CTDataBar bar = _cfRule.getDataBar();
- return new XSSFDataBarFormatting(bar);
+ return new XSSFDataBarFormatting(bar,
_sh.getWorkbook().getStylesSource().getIndexedColors());
} else {
return null;
}
@@ -314,12 +319,12 @@ public class XSSFConditionalFormattingRu
}
// Wrap and return
- return new XSSFColorScaleFormatting(scale);
+ return new XSSFColorScaleFormatting(scale,
_sh.getWorkbook().getStylesSource().getIndexedColors());
}
public XSSFColorScaleFormatting getColorScaleFormatting() {
if (_cfRule.isSetColorScale()) {
CTColorScale scale = _cfRule.getColorScale();
- return new XSSFColorScaleFormatting(scale);
+ return new XSSFColorScaleFormatting(scale,
_sh.getWorkbook().getStylesSource().getIndexedColors());
} else {
return null;
}
Modified:
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCreationHelper.java
URL:
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCreationHelper.java?rev=1796359&r1=1796358&r2=1796359&view=diff
==============================================================================
---
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCreationHelper.java
(original)
+++
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCreationHelper.java
Fri May 26 23:14:48 2017
@@ -21,6 +21,7 @@ import org.apache.poi.ss.usermodel.Creat
import org.apache.poi.ss.usermodel.Hyperlink;
import org.apache.poi.util.Internal;
import org.apache.poi.util.Removal;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTColor;
public class XSSFCreationHelper implements CreationHelper {
private final XSSFWorkbook workbook;
@@ -52,7 +53,7 @@ public class XSSFCreationHelper implemen
@Override
public XSSFColor createExtendedColor() {
- return new XSSFColor();
+ return new XSSFColor(CTColor.Factory.newInstance(),
workbook.getStylesSource().getIndexedColors());
}
/**
Modified:
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDataBarFormatting.java
URL:
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDataBarFormatting.java?rev=1796359&r1=1796358&r2=1796359&view=diff
==============================================================================
---
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDataBarFormatting.java
(original)
+++
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDataBarFormatting.java
Fri May 26 23:14:48 2017
@@ -27,10 +27,12 @@ import org.openxmlformats.schemas.spread
* component of Conditional Formatting settings
*/
public class XSSFDataBarFormatting implements DataBarFormatting {
+ IndexedColorMap _colorMap;
CTDataBar _databar;
- /*package*/ XSSFDataBarFormatting(CTDataBar databar){
+ /*package*/ XSSFDataBarFormatting(CTDataBar databar, IndexedColorMap
colorMap){
_databar = databar;
+ _colorMap = colorMap;
}
public boolean isIconOnly() {
@@ -64,7 +66,7 @@ public class XSSFDataBarFormatting imple
}
public XSSFColor getColor() {
- return new XSSFColor(_databar.getColor());
+ return new XSSFColor(_databar.getColor(), _colorMap);
}
public void setColor(Color color) {
_databar.setColor( ((XSSFColor)color).getCTColor() );
Modified:
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDxfStyleProvider.java
URL:
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDxfStyleProvider.java?rev=1796359&r1=1796358&r2=1796359&view=diff
==============================================================================
---
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDxfStyleProvider.java
(original)
+++
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDxfStyleProvider.java
Fri May 26 23:14:48 2017
@@ -30,6 +30,7 @@ import org.openxmlformats.schemas.spread
*/
public class XSSFDxfStyleProvider implements DifferentialStyleProvider {
+ private final IndexedColorMap colorMap;
private final BorderFormatting border;
private final FontFormatting font;
private final ExcelNumberFormat number;
@@ -39,24 +40,26 @@ public class XSSFDxfStyleProvider implem
/**
* @param dxf
* @param stripeSize 0 for non-stripe styles, > 1 for stripes
+ * @param colorMap
*/
- public XSSFDxfStyleProvider(CTDxf dxf, int stripeSize) {
+ public XSSFDxfStyleProvider(CTDxf dxf, int stripeSize, IndexedColorMap
colorMap) {
this.stripeSize = stripeSize;
+ this.colorMap = colorMap;
if (dxf == null) {
border = null;
font = null;
number = null;
fill = null;
} else {
- border = dxf.isSetBorder() ? new
XSSFBorderFormatting(dxf.getBorder()) : null;
- font = dxf.isSetFont() ? new XSSFFontFormatting(dxf.getFont()) :
null;
+ border = dxf.isSetBorder() ? new
XSSFBorderFormatting(dxf.getBorder(), colorMap) : null;
+ font = dxf.isSetFont() ? new XSSFFontFormatting(dxf.getFont(),
colorMap) : null;
if (dxf.isSetNumFmt()) {
CTNumFmt numFmt = dxf.getNumFmt();
number = new ExcelNumberFormat((int) numFmt.getNumFmtId(),
numFmt.getFormatCode());
} else {
number = null;
}
- fill = dxf.isSetFill() ? new XSSFPatternFormatting(dxf.getFill())
: null;
+ fill = dxf.isSetFill() ? new XSSFPatternFormatting(dxf.getFill(),
colorMap) : null;
}
}
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFont.java
URL:
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFont.java?rev=1796359&r1=1796358&r2=1796359&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFont.java
(original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFont.java Fri
May 26 23:14:48 2017
@@ -60,6 +60,7 @@ public class XSSFFont implements Font {
*/
public static final short DEFAULT_FONT_COLOR =
IndexedColors.BLACK.getIndex();
+ private IndexedColorMap _indexedColorMap;
private ThemesTable _themes;
private CTFont _ctFont;
private short _index;
@@ -74,9 +75,16 @@ public class XSSFFont implements Font {
_index = 0;
}
- public XSSFFont(CTFont font, int index) {
+ /**
+ * Called from parsing styles.xml
+ * @param font CTFont
+ * @param index font index
+ * @param colorMap for default or custom indexed colors
+ */
+ public XSSFFont(CTFont font, int index, IndexedColorMap colorMap) {
_ctFont = font;
_index = (short)index;
+ _indexedColorMap = colorMap;
}
/**
@@ -150,7 +158,7 @@ public class XSSFFont implements Font {
public XSSFColor getXSSFColor() {
CTColor ctColor = _ctFont.sizeOfColorArray() == 0 ? null :
_ctFont.getColorArray(0);
if(ctColor != null) {
- XSSFColor color = new XSSFColor(ctColor);
+ XSSFColor color = new XSSFColor(ctColor, _indexedColorMap);
if(_themes != null) {
_themes.inheritFromThemeAsRequired(color);
}
Modified:
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFontFormatting.java
URL:
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFontFormatting.java?rev=1796359&r1=1796358&r2=1796359&view=diff
==============================================================================
---
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFontFormatting.java
(original)
+++
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFontFormatting.java
Fri May 26 23:14:48 2017
@@ -33,10 +33,12 @@ import org.openxmlformats.schemas.spread
* @author Yegor Kozlov
*/
public class XSSFFontFormatting implements FontFormatting {
- CTFont _font;
+ private IndexedColorMap _colorMap;
+ private CTFont _font;
- /*package*/ XSSFFontFormatting(CTFont font){
+ /*package*/ XSSFFontFormatting(CTFont font, IndexedColorMap colorMap) {
_font = font;
+ _colorMap = colorMap;
}
/**
@@ -111,7 +113,7 @@ public class XSSFFontFormatting implemen
public XSSFColor getFontColor() {
if(_font.sizeOfColorArray() == 0) return null;
- return new XSSFColor(_font.getColorArray(0));
+ return new XSSFColor(_font.getColorArray(0), _colorMap);
}
@Override
Modified:
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPatternFormatting.java
URL:
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPatternFormatting.java?rev=1796359&r1=1796358&r2=1796359&view=diff
==============================================================================
---
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPatternFormatting.java
(original)
+++
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPatternFormatting.java
Fri May 26 23:14:48 2017
@@ -29,20 +29,22 @@ import org.openxmlformats.schemas.spread
* @author Yegor Kozlov
*/
public class XSSFPatternFormatting implements PatternFormatting {
+ IndexedColorMap _colorMap;
CTFill _fill;
- XSSFPatternFormatting(CTFill fill){
+ XSSFPatternFormatting(CTFill fill, IndexedColorMap colorMap) {
_fill = fill;
+ _colorMap = colorMap;
}
public XSSFColor getFillBackgroundColorColor() {
if(!_fill.isSetPatternFill()) return null;
- return new XSSFColor(_fill.getPatternFill().getBgColor());
+ return new XSSFColor(_fill.getPatternFill().getBgColor(), _colorMap);
}
public XSSFColor getFillForegroundColorColor() {
if(!_fill.isSetPatternFill() || !
_fill.getPatternFill().isSetFgColor())
return null;
- return new XSSFColor(_fill.getPatternFill().getFgColor());
+ return new XSSFColor(_fill.getPatternFill().getFgColor(), _colorMap);
}
public short getFillPattern() {
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
URL:
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java?rev=1796359&r1=1796358&r2=1796359&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
(original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java Fri
May 26 23:14:48 2017
@@ -4007,7 +4007,7 @@ public class XSSFSheet extends POIXMLDoc
if (!pr.isSetTabColor()) {
return null;
}
- return new XSSFColor(pr.getTabColor());
+ return new XSSFColor(pr.getTabColor(),
getWorkbook().getStylesSource().getIndexedColors());
}
/**
@@ -4020,7 +4020,7 @@ public class XSSFSheet extends POIXMLDoc
@Removal(version="3.17")
public void setTabColor(int colorIndex) {
IndexedColors indexedColor = IndexedColors.fromInt(colorIndex);
- XSSFColor color = new XSSFColor(indexedColor);
+ XSSFColor color = new XSSFColor(indexedColor,
getWorkbook().getStylesSource().getIndexedColors());
setTabColor(color);
}
Modified:
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFTableStyle.java
URL:
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFTableStyle.java?rev=1796359&r1=1796358&r2=1796359&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFTableStyle.java
(original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFTableStyle.java
Fri May 26 23:14:48 2017
@@ -42,9 +42,10 @@ public class XSSFTableStyle implements T
* @param index style definition index or built-in ordinal depending on use
* @param dxfs
* @param tableStyle
+ * @param colorMap indexed color map - default or custom
* @see TableStyle#getIndex()
*/
- public XSSFTableStyle(int index, CTDxfs dxfs, CTTableStyle tableStyle) {
+ public XSSFTableStyle(int index, CTDxfs dxfs, CTTableStyle tableStyle,
IndexedColorMap colorMap) {
this.name = tableStyle.getName();
this.index = index;
for (CTTableStyleElement element :
tableStyle.getTableStyleElementList()) {
@@ -60,7 +61,7 @@ public class XSSFTableStyle implements T
}
int stripeSize = 0;
if (element.isSetSize()) stripeSize = (int) element.getSize();
- if (dxf != null) dstyle = new XSSFDxfStyleProvider(dxf,
stripeSize);
+ if (dxf != null) dstyle = new XSSFDxfStyleProvider(dxf,
stripeSize, colorMap);
}
elementMap.put(type, dstyle);
}
Modified:
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/extensions/XSSFCellBorder.java
URL:
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/extensions/XSSFCellBorder.java?rev=1796359&r1=1796358&r2=1796359&view=diff
==============================================================================
---
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/extensions/XSSFCellBorder.java
(original)
+++
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/extensions/XSSFCellBorder.java
Fri May 26 23:14:48 2017
@@ -19,6 +19,7 @@ package org.apache.poi.xssf.usermodel.ex
import org.apache.poi.ss.usermodel.BorderStyle;
import org.apache.poi.xssf.model.ThemesTable;
+import org.apache.poi.xssf.usermodel.IndexedColorMap;
import org.apache.poi.xssf.usermodel.XSSFColor;
import org.apache.poi.util.Internal;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorder;
@@ -31,22 +32,37 @@ import org.openxmlformats.schemas.spread
* Color is optional.
*/
public class XSSFCellBorder {
+ private IndexedColorMap _indexedColorMap;
private ThemesTable _theme;
private CTBorder border;
/**
* Creates a Cell Border from the supplied XML definition
+ * @param border
+ * @param theme
+ * @param colorMap
*/
- public XSSFCellBorder(CTBorder border, ThemesTable theme) {
- this(border);
+ public XSSFCellBorder(CTBorder border, ThemesTable theme, IndexedColorMap
colorMap) {
+ this(border, colorMap);
this._theme = theme;
}
/**
* Creates a Cell Border from the supplied XML definition
+ * @param border
*/
public XSSFCellBorder(CTBorder border) {
+ this(border, null);
+ }
+
+ /**
+ *
+ * @param border
+ * @param colorMap
+ */
+ public XSSFCellBorder(CTBorder border, IndexedColorMap colorMap) {
this.border = border;
+ this._indexedColorMap = colorMap;
}
/**
@@ -117,7 +133,7 @@ public class XSSFCellBorder {
CTBorderPr borderPr = getBorder(side);
if(borderPr != null && borderPr.isSetColor()) {
- XSSFColor clr = new XSSFColor(borderPr.getColor());
+ XSSFColor clr = new XSSFColor(borderPr.getColor(),
_indexedColorMap);
if(_theme != null) {
_theme.inheritFromThemeAsRequired(clr);
}
Modified:
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/extensions/XSSFCellFill.java
URL:
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/extensions/XSSFCellFill.java?rev=1796359&r1=1796358&r2=1796359&view=diff
==============================================================================
---
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/extensions/XSSFCellFill.java
(original)
+++
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/extensions/XSSFCellFill.java
Fri May 26 23:14:48 2017
@@ -20,6 +20,7 @@ import org.openxmlformats.schemas.spread
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFill;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPatternFill;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.STPatternType;
+import org.apache.poi.xssf.usermodel.IndexedColorMap;
import org.apache.poi.xssf.usermodel.XSSFColor;
import org.apache.poi.util.Internal;
@@ -29,6 +30,7 @@ import org.apache.poi.util.Internal;
*/
public final class XSSFCellFill {
+ private IndexedColorMap _indexedColorMap;
private CTFill _fill;
/**
@@ -36,8 +38,9 @@ public final class XSSFCellFill {
*
* @param fill - fill
*/
- public XSSFCellFill(CTFill fill) {
+ public XSSFCellFill(CTFill fill, IndexedColorMap colorMap) {
_fill = fill;
+ _indexedColorMap = colorMap;
}
/**
@@ -57,7 +60,7 @@ public final class XSSFCellFill {
if (ptrn == null) return null;
CTColor ctColor = ptrn.getBgColor();
- return ctColor == null ? null : new XSSFColor(ctColor);
+ return ctColor == null ? null : new XSSFColor(ctColor,
_indexedColorMap);
}
/**
@@ -91,7 +94,7 @@ public final class XSSFCellFill {
if (ptrn == null) return null;
CTColor ctColor = ptrn.getFgColor();
- return ctColor == null ? null : new XSSFColor(ctColor);
+ return ctColor == null ? null : new XSSFColor(ctColor,
_indexedColorMap);
}
/**
Modified:
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java
URL:
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java?rev=1796359&r1=1796358&r2=1796359&view=diff
==============================================================================
---
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java
(original)
+++
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java
Fri May 26 23:14:48 2017
@@ -73,7 +73,7 @@ public class TestXSSFCellStyle {
assertEquals(1, stylesTable.putBorder(borderB));
ctFill = CTFill.Factory.newInstance();
- XSSFCellFill fill = new XSSFCellFill(ctFill);
+ XSSFCellFill fill = new XSSFCellFill(ctFill, null);
long fillId = stylesTable.putFill(fill);
assertEquals(2, fillId);
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=1796359&r1=1796358&r2=1796359&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
Fri May 26 23:14:48 2017
@@ -17,12 +17,16 @@
package org.apache.poi.xssf.usermodel;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import java.io.IOException;
import org.apache.poi.xssf.XSSFTestDataSamples;
import org.junit.Test;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTColors;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRgbColor;
public final class TestXSSFColor {
@@ -180,4 +184,21 @@ public final class TestXSSFColor {
wb.close();
}
+
+ @Test
+ public void testCustomIndexedColour() throws Exception {
+ XSSFWorkbook wb =
XSSFTestDataSamples.openSampleWorkbook("customIndexedColors.xlsx");
+ XSSFCell cell = wb.getSheetAt(1).getRow(0).getCell(0);
+ XSSFColor color = cell.getCellStyle().getFillForegroundColorColor();
+ CTColors ctColors = wb.getStylesSource().getCTStylesheet().getColors();
+
+ CTRgbColor ctRgbColor = ctColors.getIndexedColors()
+ .getRgbColorList()
+ .get(color.getIndex());
+
+ String hexRgb =
ctRgbColor.getDomNode().getAttributes().getNamedItem("rgb").getNodeValue();
+
+ assertEquals(hexRgb, color.getARGBHex());
+
+ }
}
Modified:
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFont.java
URL:
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFont.java?rev=1796359&r1=1796358&r2=1796359&view=diff
==============================================================================
---
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFont.java
(original)
+++
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFont.java
Fri May 26 23:14:48 2017
@@ -256,7 +256,7 @@ public final class TestXSSFFont extends
byte[] bytes =
Integer.toHexString(0xF1F1F1).getBytes(LocaleUtil.CHARSET_1252);
color.setRgb(bytes);
- XSSFColor newColor=new XSSFColor(color);
+ XSSFColor newColor=new XSSFColor(color, null);
xssfFont.setColor(newColor);
assertEquals(ctFont.getColorArray(0).getRgb()[2],newColor.getRGB()[2]);
Modified:
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java
URL:
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java?rev=1796359&r1=1796358&r2=1796359&view=diff
==============================================================================
---
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java
(original)
+++
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java
Fri May 26 23:14:48 2017
@@ -1892,7 +1892,7 @@ public final class TestXSSFSheet extends
try {
XSSFSheet sh = wb.createSheet();
assertTrue(sh.getCTWorksheet().getSheetPr() == null ||
!sh.getCTWorksheet().getSheetPr().isSetTabColor());
- sh.setTabColor(new XSSFColor(IndexedColors.RED));
+ sh.setTabColor(new XSSFColor(IndexedColors.RED, null));
assertTrue(sh.getCTWorksheet().getSheetPr().isSetTabColor());
assertEquals(IndexedColors.RED.index,
sh.getCTWorksheet().getSheetPr().getTabColor().getIndexed());
@@ -1908,8 +1908,8 @@ public final class TestXSSFSheet extends
XSSFSheet sh = wb.createSheet();
assertTrue(sh.getCTWorksheet().getSheetPr() == null ||
!sh.getCTWorksheet().getSheetPr().isSetTabColor());
assertNull(sh.getTabColor());
- sh.setTabColor(new XSSFColor(IndexedColors.RED));
- XSSFColor expected = new XSSFColor(IndexedColors.RED);
+ sh.setTabColor(new XSSFColor(IndexedColors.RED, null));
+ XSSFColor expected = new XSSFColor(IndexedColors.RED, null);
assertEquals(expected, sh.getTabColor());
} finally {
wb.close();
@@ -1925,7 +1925,7 @@ public final class TestXSSFSheet extends
assertNull(wb.getSheet("default").getTabColor());
// test indexed-colored sheet
- XSSFColor expected = new XSSFColor(IndexedColors.RED);
+ XSSFColor expected = new XSSFColor(IndexedColors.RED, null);
assertEquals(expected, wb.getSheet("indexedRed").getTabColor());
// test regular-colored (non-indexed, ARGB) sheet
Modified:
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/extensions/TestXSSFCellFill.java
URL:
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/extensions/TestXSSFCellFill.java?rev=1796359&r1=1796358&r2=1796359&view=diff
==============================================================================
---
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/extensions/TestXSSFCellFill.java
(original)
+++
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/extensions/TestXSSFCellFill.java
Fri May 26 23:14:48 2017
@@ -40,7 +40,7 @@ public class TestXSSFCellFill {
@Test
public void testGetFillBackgroundColor() {
CTFill ctFill = CTFill.Factory.newInstance();
- XSSFCellFill cellFill = new XSSFCellFill(ctFill);
+ XSSFCellFill cellFill = new XSSFCellFill(ctFill, null);
CTPatternFill ctPatternFill = ctFill.addNewPatternFill();
CTColor bgColor = ctPatternFill.addNewBgColor();
assertNotNull(cellFill.getFillBackgroundColor());
@@ -51,7 +51,7 @@ public class TestXSSFCellFill {
@Test
public void testGetFillForegroundColor() {
CTFill ctFill = CTFill.Factory.newInstance();
- XSSFCellFill cellFill = new XSSFCellFill(ctFill);
+ XSSFCellFill cellFill = new XSSFCellFill(ctFill, null);
CTPatternFill ctPatternFill = ctFill.addNewPatternFill();
CTColor fgColor = ctPatternFill.addNewFgColor();
assertNotNull(cellFill.getFillForegroundColor());
@@ -62,7 +62,7 @@ public class TestXSSFCellFill {
@Test
public void testGetSetPatternType() {
CTFill ctFill = CTFill.Factory.newInstance();
- XSSFCellFill cellFill = new XSSFCellFill(ctFill);
+ XSSFCellFill cellFill = new XSSFCellFill(ctFill, null);
CTPatternFill ctPatternFill = ctFill.addNewPatternFill();
ctPatternFill.setPatternType(STPatternType.SOLID);
assertEquals(FillPatternType.SOLID_FOREGROUND.ordinal(),
cellFill.getPatternType().intValue()-1);
@@ -71,7 +71,7 @@ public class TestXSSFCellFill {
@Test
public void testGetNotModifies() {
CTFill ctFill = CTFill.Factory.newInstance();
- XSSFCellFill cellFill = new XSSFCellFill(ctFill);
+ XSSFCellFill cellFill = new XSSFCellFill(ctFill, null);
CTPatternFill ctPatternFill = ctFill.addNewPatternFill();
ctPatternFill.setPatternType(STPatternType.DARK_DOWN);
assertEquals(8, cellFill.getPatternType().intValue());
Added: poi/trunk/test-data/spreadsheet/customIndexedColors.xlsx
URL:
http://svn.apache.org/viewvc/poi/trunk/test-data/spreadsheet/customIndexedColors.xlsx?rev=1796359&view=auto
==============================================================================
Binary file - no diff available.
Propchange: poi/trunk/test-data/spreadsheet/customIndexedColors.xlsx
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]