From 93449602c572ecd8008053a1d4c19c7e7294779f Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Wed, 26 May 2010 14:51:49 +0000 Subject: [PATCH] Add unit test to show that the behaviour in bug #48923 is as expected git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@948462 13f79535-47bb-0310-9956-ffa450edef68 --- .../poi/xssf/usermodel/TestXSSFBugs.java | 35 ++++++++++++++++++ test-data/spreadsheet/48923.xlsx | Bin 0 -> 10126 bytes 2 files changed, 35 insertions(+) create mode 100644 test-data/spreadsheet/48923.xlsx diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java index f521cb53ba..ea2c8fd59f 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java @@ -24,6 +24,7 @@ import org.apache.poi.openxml4j.opc.OPCPackage; import org.apache.poi.openxml4j.opc.PackagePart; import org.apache.poi.openxml4j.opc.PackagingURIHelper; import org.apache.poi.ss.usermodel.BaseTestBugzillaIssues; +import org.apache.poi.ss.usermodel.Name; import org.apache.poi.xssf.XSSFITestDataProvider; import org.apache.poi.xssf.XSSFTestDataSamples; import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet; @@ -158,4 +159,38 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { CTWorksheet sh = wb.getSheetAt(0).getCTWorksheet(); assertNotNull(sh.getPhoneticPr()); } + + /** + * Names which are defined with a Sheet + * should return that sheet index properly + */ + public void test48923() throws Exception { + XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("48923.xlsx"); + assertEquals(4, wb.getNumberOfNames()); + + Name b1 = wb.getName("NameB1"); + Name b2 = wb.getName("NameB2"); + Name sheet2 = wb.getName("NameSheet2"); + Name test = wb.getName("Test"); + + assertNotNull(b1); + assertEquals("NameB1", b1.getNameName()); + assertEquals("Sheet1", b1.getSheetName()); + assertEquals(-1, b1.getSheetIndex()); + + assertNotNull(b2); + assertEquals("NameB2", b2.getNameName()); + assertEquals("Sheet1", b2.getSheetName()); + assertEquals(-1, b2.getSheetIndex()); + + assertNotNull(sheet2); + assertEquals("NameSheet2", sheet2.getNameName()); + assertEquals("Sheet2", sheet2.getSheetName()); + assertEquals(-1, sheet2.getSheetIndex()); + + assertNotNull(test); + assertEquals("Test", test.getNameName()); + assertEquals("Sheet1", test.getSheetName()); + assertEquals(-1, test.getSheetIndex()); + } } diff --git a/test-data/spreadsheet/48923.xlsx b/test-data/spreadsheet/48923.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..34aba5902b3c3efd4fa3a8fa5e50e88115c2a0bf GIT binary patch literal 10126 zcmeHt1y@_^wswHxMT@(;d+{R0U5ZO^cPmmHiaQi{X>s3Z@#0p3LyNSyOOV11-TU00 z&F=Yr!2Qk|V`Z(3WIoB7^LeMf%5pGIumErX1ONa)4pJfj%F_UES`3@WceT{x?BJ>-~aY2SD$-J{Y9nRzz+YJ{kI z*$j=L72NS-p-47_0ttJR!acyJ;>6t#$7^2zl<#@cYMGu~etbUk6e-}Xo6*+j)V0`? z>)lsNh=1TPekths5+i2=orWHU8Klr(MfK4Jc2W;~M1i#S^(GTuEa=)J4V@&CWVbs( zz^wZZJvj{N=c@$gk=%{LMJc)EOIW?h>PEcONcV~8J>>9v3L#@b%4tx+6iU_;pz!J{MUw?h$1?b zW{aHgrGDS~VooY35ek`yCO*pX&V9*F<2CONdX1c|ZXg)bVdAmPw~}2?GG^FJQ!uoX z61hHeX>x)H0Nmfh0F?i>DjPJ|D9<5OlZPxiWWX4dp|hE-3oFaRD_Q=~e^=xGnN=8- zFb-LPPx}w0+r&3+cI>4Q@`_sJrCZ6>Nj_2?kTygYP>Eh%1j7W%nk-IUd> zrA|r&WL4~Gp?guo3G|+|_N>U!M9T$ISXf~V5X2A}zgk|gHS{b@$^g#Zl-5Q@60{`U zQU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