From 8840f717da8af3218c94d0d99f409ed1c77f8fe7 Mon Sep 17 00:00:00 2001 From: Yegor Kozlov Date: Tue, 7 Feb 2012 10:46:55 +0000 Subject: [PATCH] Bugzilla 52527: avoid exception when matching shared formula records in HSSF git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1241419 13f79535-47bb-0310-9956-ffa450edef68 --- src/documentation/content/xdocs/status.xml | 1 + .../record/aggregates/SharedValueManager.java | 7 +++--- .../aggregates/TestSharedValueManager.java | 20 ++++++++++++++++++ test-data/spreadsheet/52527.xls | Bin 0 -> 33280 bytes 4 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 test-data/spreadsheet/52527.xls diff --git a/src/documentation/content/xdocs/status.xml b/src/documentation/content/xdocs/status.xml index 3f0996a3fc..af3bbee4c2 100644 --- a/src/documentation/content/xdocs/status.xml +++ b/src/documentation/content/xdocs/status.xml @@ -34,6 +34,7 @@ + 52527 - avoid exception when matching shared formula records in HSSF 52568 - Added methods to set/get an XWPFRun's text color 52566 - Added methods to set/get vertical alignment and color in XWPFTableCell 52562 - Added methods to get/set a table row's Can't Split and Repeat Header attributes in XWPF diff --git a/src/java/org/apache/poi/hssf/record/aggregates/SharedValueManager.java b/src/java/org/apache/poi/hssf/record/aggregates/SharedValueManager.java index 81abdb6fd9..7f6e4022d7 100644 --- a/src/java/org/apache/poi/hssf/record/aggregates/SharedValueManager.java +++ b/src/java/org/apache/poi/hssf/record/aggregates/SharedValueManager.java @@ -158,6 +158,9 @@ public final class SharedValueManager { */ public SharedFormulaRecord linkSharedFormulaRecord(CellReference firstCell, FormulaRecordAggregate agg) { SharedFormulaGroup result = findFormulaGroupForCell(firstCell); + if(null == result) { + throw new RuntimeException("Failed to find a matching shared formula record"); + } result.add(agg); return result.getSFR(); } @@ -170,10 +173,6 @@ public final class SharedValueManager { } } SharedFormulaGroup sfg = _groupsCache.get(getKeyForCache(cellRef)); - if(null == sfg) { - // TODO - fix file "15228.xls" so it opens in Excel after rewriting with POI - throw new RuntimeException("Failed to find a matching shared formula record"); - } return sfg; } diff --git a/src/testcases/org/apache/poi/hssf/record/aggregates/TestSharedValueManager.java b/src/testcases/org/apache/poi/hssf/record/aggregates/TestSharedValueManager.java index 7e359a3fb1..aea5b321e3 100644 --- a/src/testcases/org/apache/poi/hssf/record/aggregates/TestSharedValueManager.java +++ b/src/testcases/org/apache/poi/hssf/record/aggregates/TestSharedValueManager.java @@ -192,4 +192,24 @@ public final class TestSharedValueManager extends TestCase { throw new RuntimeException(e); } } + + public void testBug52527() { + HSSFWorkbook wb1 = HSSFTestDataSamples.openSampleWorkbook("52527.xls"); + HSSFWorkbook wb2 = HSSFTestDataSamples.writeOutAndReadBack(wb1); + + assertEquals("IF(H3,LINEST(N9:N14,K9:M14,FALSE),LINEST(N8:N14,K8:M14,FALSE))", + wb1.getSheetAt(0).getRow(4).getCell(11).getCellFormula()); + assertEquals("IF(H3,LINEST(N9:N14,K9:M14,FALSE),LINEST(N8:N14,K8:M14,FALSE))", + wb2.getSheetAt(0).getRow(4).getCell(11).getCellFormula()); + + assertEquals("1/SQRT(J9)", + wb1.getSheetAt(0).getRow(8).getCell(10).getCellFormula()); + assertEquals("1/SQRT(J9)", + wb2.getSheetAt(0).getRow(8).getCell(10).getCellFormula()); + + assertEquals("1/SQRT(J26)", + wb1.getSheetAt(0).getRow(25).getCell(10).getCellFormula()); + assertEquals("1/SQRT(J26)", + wb2.getSheetAt(0).getRow(25).getCell(10).getCellFormula()); + } } diff --git a/test-data/spreadsheet/52527.xls b/test-data/spreadsheet/52527.xls new file mode 100644 index 0000000000000000000000000000000000000000..b20d7d71ea6c65c047b760cee34db9b055df87a2 GIT binary patch literal 33280 zcmeHw3w&Hvwf8_cBDxSW5ZUHgh;GDe#2mz2#5}}&#A%2Hh%fH*_5EmmZL0pQs z46zci3XwLq#<vN&FTGheo?JWthsXl<={$6y{EGrf3tbVyEa4Tf}B@8uZXEwjtjxwgYma;1!xi zAILt!{$dv*Z+d0D&H7t$6n87+M(cB2<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