From: PJ Fanning Date: Sat, 24 Jul 2021 08:10:19 +0000 (+0000) Subject: remove some unnecessary casts from copy method X-Git-Tag: REL_5_1_0~123 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=49237e4e98657a75bbce0d75b3b5a1e5ccf460fd;p=poi.git remove some unnecessary casts from copy method git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1891763 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFRow.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFRow.java index 0484773ecc..d0aa2ff867 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFRow.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFRow.java @@ -34,6 +34,7 @@ import org.apache.poi.ss.usermodel.FormulaError; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.helpers.RowShifter; import org.apache.poi.ss.util.CellRangeAddress; +import org.apache.poi.ss.util.CellUtil; import org.apache.poi.util.Beta; import org.apache.poi.util.Internal; import org.apache.poi.xssf.model.StylesTable; @@ -650,8 +651,7 @@ public class XSSFRow implements Row, Comparable { // srcRow is blank. Overwrite cells with blank values, blank styles, etc per cell copy policy for (Cell destCell : this) { final XSSFCell srcCell = null; - // FIXME: remove type casting when copyCellFrom(Cell, CellCopyPolicy) is added to Cell interface - ((XSSFCell)destCell).copyCellFrom(srcCell, policy); + CellUtil.copyCell(srcCell, destCell, policy); } if (policy.isCopyMergedRegions()) { @@ -675,10 +675,9 @@ public class XSSFRow implements Row, Comparable { } else { - for (final Cell c : srcRow){ - final XSSFCell srcCell = (XSSFCell)c; - final XSSFCell destCell = createCell(srcCell.getColumnIndex()); - destCell.copyCellFrom(srcCell, policy); + for (final Cell c : srcRow) { + final XSSFCell destCell = createCell(c.getColumnIndex()); + destCell.copyCellFrom(c, policy); } final int sheetIndex = _sheet.getWorkbook().getSheetIndex(_sheet);