diff options
author | Andreas Beeker <kiwiwings@apache.org> | 2020-04-16 22:11:16 +0000 |
---|---|---|
committer | Andreas Beeker <kiwiwings@apache.org> | 2020-04-16 22:11:16 +0000 |
commit | 7daeb4278c5ace8d263db087f8014e779140423d (patch) | |
tree | 2f8a086e508c1842c2e2b641f7d89a1eab850e30 /src/ooxml/java/org | |
parent | cdefe69aab015c8ca06e8212969f81a4150273a2 (diff) | |
download | poi-7daeb4278c5ace8d263db087f8014e779140423d.tar.gz poi-7daeb4278c5ace8d263db087f8014e779140423d.zip |
Replace Allocate+System.arraycopy with Array.copyOf/Range and IOUtils.safelyClone
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1876640 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/ooxml/java/org')
-rw-r--r-- | src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFColor.java | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFColor.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFColor.java index 504a302955..a8507cd92e 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFColor.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFColor.java @@ -41,7 +41,7 @@ public class XSSFColor extends ExtendedColor { //noinspection deprecation return color == null ? null : new XSSFColor(color, map); } - + /** * Create an instance of XSSFColor from the supplied XML bean, with default color indexes * @param color The {@link CTColor} to use as color-value. @@ -52,7 +52,7 @@ public class XSSFColor extends ExtendedColor { 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 The {@link CTColor} to use as color-value. @@ -119,7 +119,7 @@ public class XSSFColor extends ExtendedColor { this(CTColor.Factory.newInstance(), colorMap); ctColor.setRgb(rgb); } - + /** * @param indexedColor color index (Enum named for default colors) * @param colorMap The IndexedColorMap to use instead of the default one @@ -167,7 +167,7 @@ public class XSSFColor extends ExtendedColor { public boolean isThemed() { return ctColor.isSetTheme(); } - + /** * @return true if the ctColor has a alpha */ @@ -215,14 +215,8 @@ public class XSSFColor extends ExtendedColor { return null; } - if(rgb.length == 4) { - // Need to trim off the alpha - byte[] tmp = new byte[3]; - System.arraycopy(rgb, 1, tmp, 0, 3); - return tmp; - } else { - return rgb; - } + // Need to trim off the alpha + return rgb.length == 4 ? Arrays.copyOfRange(rgb, 1, 4) : rgb; } /** @@ -258,7 +252,7 @@ public class XSSFColor extends ExtendedColor { } return null; } - + /** * Standard Alpha Red Green Blue ctColor value (ARGB). */ @@ -403,7 +397,7 @@ public class XSSFColor extends ExtendedColor { } return (XSSFColor)color; } - + @Override public int hashCode(){ return ctColor.toString().hashCode(); @@ -437,7 +431,7 @@ public class XSSFColor extends ExtendedColor { private boolean sameAuto(XSSFColor other) { return isAuto() == other.isAuto(); } - + @Override public boolean equals(Object o){ if(!(o instanceof XSSFColor)) { @@ -445,7 +439,7 @@ public class XSSFColor extends ExtendedColor { } XSSFColor other = (XSSFColor)o; - + // Compare each field in ctColor. // Cannot compare ctColor's XML string representation because equivalent // colors may have different relation namespace URI's |