From: Nick Burch Date: Tue, 21 Sep 2010 11:16:12 +0000 (+0000) Subject: Fix bug #49966 - Correctly remove calcChain entries for XSSF cells that stop holding... X-Git-Tag: REL_3_7_BETA3~5 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=8d0eb2afe9102272d1b767c91fce7430bd225839;p=poi.git Fix bug #49966 - Correctly remove calcChain entries for XSSF cells that stop holding formulas git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@999314 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/documentation/content/xdocs/status.xml b/src/documentation/content/xdocs/status.xml index 736f3549b4..81a4a3beab 100644 --- a/src/documentation/content/xdocs/status.xml +++ b/src/documentation/content/xdocs/status.xml @@ -34,6 +34,7 @@ + 49966 - Correctly remove calcChain entries for XSSF cells that stop holding formulas 47582 - XSSFCellStyle support for creating a style in one workbook based on a style from a different one 49931 - Avoid concurrency problems when re-ordering multiple HSSF header records for a PageSettingsBlock 49765 - Fix XWPFDocument.addPicture so that it correctly sets up relationships diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java index 93efe4b377..e0998bc590 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java @@ -721,11 +721,15 @@ public final class XSSFCell implements Cell { * @see #CELL_TYPE_ERROR */ public void setCellType(int cellType) { + int prevType = getCellType(); + if(isPartOfArrayFormulaGroup()){ notifyArrayFormulaChanging(); } - - int prevType = getCellType(); + if(prevType == CELL_TYPE_FORMULA && cellType != CELL_TYPE_FORMULA) { + getSheet().getWorkbook().onDeleteFormula(this); + } + switch (cellType) { case CELL_TYPE_BLANK: setBlank(); diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java index 53747f5e3f..f61717f475 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java @@ -365,9 +365,12 @@ public class XSSFRow implements Row, Comparable { } XSSFCell xcell = (XSSFCell)cell; - if(xcell.isPartOfArrayFormulaGroup()){ + if(xcell.isPartOfArrayFormulaGroup()) { xcell.notifyArrayFormulaChanging(); } + if(cell.getCellType() == Cell.CELL_TYPE_FORMULA) { + _sheet.getWorkbook().onDeleteFormula(xcell); + } _cells.remove(cell.getColumnIndex()); } diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java index 8ae7f9a858..00d2ffee7e 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java @@ -833,7 +833,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable