mirror of https://github.com/apache/poi.git
throw exception if wrong Color class is used
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1902623 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
6602122926
commit
4cda0c91fd
|
@ -833,12 +833,15 @@ public class XSSFCellStyle implements CellStyle, Duplicatable {
|
||||||
* Set the background fill color represented as a {@link org.apache.poi.ss.usermodel.Color} value.
|
* Set the background fill color represented as a {@link org.apache.poi.ss.usermodel.Color} value.
|
||||||
* <br>
|
* <br>
|
||||||
* @param color the color to use
|
* @param color the color to use
|
||||||
|
* @throws IllegalArgumentException if you provide a <code>Color</code> instance that is not a {@link XSSFColor}
|
||||||
* @since POI 5.2.3
|
* @since POI 5.2.3
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setFillBackgroundColor(org.apache.poi.ss.usermodel.Color color) {
|
public void setFillBackgroundColor(org.apache.poi.ss.usermodel.Color color) {
|
||||||
if (color instanceof XSSFColor) {
|
if (color instanceof XSSFColor) {
|
||||||
setFillBackgroundColor((XSSFColor)color);
|
setFillBackgroundColor((XSSFColor)color);
|
||||||
|
} else {
|
||||||
|
throw new IllegalArgumentException("XSSFCellStyle only accepts XSSFColor instances");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -900,12 +903,15 @@ public class XSSFCellStyle implements CellStyle, Duplicatable {
|
||||||
* Set the foreground fill color represented as a {@link org.apache.poi.ss.usermodel.Color} value.
|
* Set the foreground fill color represented as a {@link org.apache.poi.ss.usermodel.Color} value.
|
||||||
* <br>
|
* <br>
|
||||||
* @param color the color to use
|
* @param color the color to use
|
||||||
|
* @throws IllegalArgumentException if you provide a <code>Color</code> instance that is not a {@link XSSFColor}
|
||||||
* @since POI 5.2.3
|
* @since POI 5.2.3
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setFillForegroundColor(org.apache.poi.ss.usermodel.Color color) {
|
public void setFillForegroundColor(org.apache.poi.ss.usermodel.Color color) {
|
||||||
if (color instanceof XSSFColor) {
|
if (color instanceof XSSFColor) {
|
||||||
setFillForegroundColor((XSSFColor)color);
|
setFillForegroundColor((XSSFColor)color);
|
||||||
|
} else {
|
||||||
|
throw new IllegalArgumentException("XSSFCellStyle only accepts XSSFColor instances");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -642,6 +642,7 @@ public final class HSSFCellStyle implements CellStyle, Duplicatable {
|
||||||
* Set the background fill color represented as a {@link org.apache.poi.ss.usermodel.Color} value.
|
* Set the background fill color represented as a {@link org.apache.poi.ss.usermodel.Color} value.
|
||||||
* <br>
|
* <br>
|
||||||
* @param color the color to use
|
* @param color the color to use
|
||||||
|
* @throws IllegalArgumentException if you provide a <code>Color</code> instance that is not a {@link HSSFColor}
|
||||||
* @since POI 5.2.3
|
* @since POI 5.2.3
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@ -650,6 +651,8 @@ public final class HSSFCellStyle implements CellStyle, Duplicatable {
|
||||||
if (color instanceof HSSFColor) {
|
if (color instanceof HSSFColor) {
|
||||||
short index2 = ((HSSFColor)color).getIndex2();
|
short index2 = ((HSSFColor)color).getIndex2();
|
||||||
if (index2 != -1) setFillBackgroundColor(index2);
|
if (index2 != -1) setFillBackgroundColor(index2);
|
||||||
|
} else {
|
||||||
|
throw new IllegalArgumentException("HSSFCellStyle only accepts HSSFColor instances");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -698,6 +701,7 @@ public final class HSSFCellStyle implements CellStyle, Duplicatable {
|
||||||
* Set the foreground fill color represented as a {@link org.apache.poi.ss.usermodel.Color} value.
|
* Set the foreground fill color represented as a {@link org.apache.poi.ss.usermodel.Color} value.
|
||||||
* <br>
|
* <br>
|
||||||
* @param color the color to use
|
* @param color the color to use
|
||||||
|
* @throws IllegalArgumentException if you provide a <code>Color</code> instance that is not a {@link HSSFColor}
|
||||||
* @since POI 5.2.3
|
* @since POI 5.2.3
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@ -706,6 +710,8 @@ public final class HSSFCellStyle implements CellStyle, Duplicatable {
|
||||||
if (color instanceof HSSFColor) {
|
if (color instanceof HSSFColor) {
|
||||||
short index2 = ((HSSFColor)color).getIndex2();
|
short index2 = ((HSSFColor)color).getIndex2();
|
||||||
if (index2 != -1) setFillForegroundColor(index2);
|
if (index2 != -1) setFillForegroundColor(index2);
|
||||||
|
} else {
|
||||||
|
throw new IllegalArgumentException("HSSFCellStyle only accepts HSSFColor instances");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue