You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by fa...@apache.org on 2019/03/19 05:59:00 UTC
svn commit: r1855806 - in /poi/trunk/src:
java/org/apache/poi/ss/util/CellUtil.java
testcases/org/apache/poi/ss/util/BaseTestCellUtil.java
Author: fanningpj
Date: Tue Mar 19 05:59:00 2019
New Revision: 1855806
URL: http://svn.apache.org/viewvc?rev=1855806&view=rev
Log:
[bug-63268] fix issue where CellUtil.setFont is adding unnecessary styles
Modified:
poi/trunk/src/java/org/apache/poi/ss/util/CellUtil.java
poi/trunk/src/testcases/org/apache/poi/ss/util/BaseTestCellUtil.java
Modified: poi/trunk/src/java/org/apache/poi/ss/util/CellUtil.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/util/CellUtil.java?rev=1855806&r1=1855805&r2=1855806&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/util/CellUtil.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/util/CellUtil.java Tue Mar 19 05:59:00 2019
@@ -84,9 +84,12 @@ public final class CellUtil {
FILL_BACKGROUND_COLOR,
INDENTION,
DATA_FORMAT,
- FONT,
ROTATION
)));
+ private static final Set<String> intValues = Collections.unmodifiableSet(
+ new HashSet<>(Arrays.asList(
+ FONT
+ )));
private static final Set<String> booleanValues = Collections.unmodifiableSet(
new HashSet<>(Arrays.asList(
LOCKED,
@@ -369,6 +372,8 @@ public final class CellUtil {
for (final String key : src.keySet()) {
if (shortValues.contains(key)) {
dest.put(key, getShort(src, key));
+ } else if (intValues.contains(key)) {
+ dest.put(key, getInt(src, key));
} else if (booleanValues.contains(key)) {
dest.put(key, getBoolean(src, key));
} else if (borderTypeValues.contains(key)) {
Modified: poi/trunk/src/testcases/org/apache/poi/ss/util/BaseTestCellUtil.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/util/BaseTestCellUtil.java?rev=1855806&r1=1855805&r2=1855806&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/util/BaseTestCellUtil.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/util/BaseTestCellUtil.java Tue Mar 19 05:59:00 2019
@@ -378,4 +378,23 @@ public abstract class BaseTestCellUtil {
wb1.close();
}
+
+ /**
+ * bug 63268
+ * @since POI 4.1.0
+ */
+ @Test
+ public void setFontShouldNotCreateDuplicateStyle() throws IOException {
+ Workbook wb1 = _testDataProvider.createWorkbook();
+ Cell c = wb1.createSheet().createRow(1).createCell(1);
+ Font f = wb1.createFont();
+
+ CellUtil.setFont(c, f);
+ int num1 = wb1.getNumCellStyles();
+
+ CellUtil.setFont(c, f);
+ int num2 = wb1.getNumCellStyles();
+ assertEquals(num1, num2);
+ wb1.close();
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org