You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ni...@apache.org on 2008/07/18 19:37:45 UTC

svn commit: r677979 - in /poi/branches/ooxml/src: documentation/content/xdocs/ ooxml/java/org/apache/poi/xssf/usermodel/ ooxml/testcases/org/apache/poi/xssf/usermodel/ testcases/org/apache/poi/hssf/data/

Author: nick
Date: Fri Jul 18 10:37:44 2008
New Revision: 677979

URL: http://svn.apache.org/viewvc?rev=677979&view=rev
Log:
Fix bug #45430 - Correct named range sheet reporting when no local sheet id is given in the xml

Added:
    poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java   (with props)
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/data/45430.xlsx   (with props)
Modified:
    poi/branches/ooxml/src/documentation/content/xdocs/changes.xml
    poi/branches/ooxml/src/documentation/content/xdocs/status.xml
    poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFName.java
    poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/AllXSSFUsermodelTests.java

Modified: poi/branches/ooxml/src/documentation/content/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/documentation/content/xdocs/changes.xml?rev=677979&r1=677978&r2=677979&view=diff
==============================================================================
--- poi/branches/ooxml/src/documentation/content/xdocs/changes.xml (original)
+++ poi/branches/ooxml/src/documentation/content/xdocs/changes.xml Fri Jul 18 10:37:44 2008
@@ -36,10 +36,9 @@
     </devs>
 
 		<!-- Don't forget to update status.xml too! -->
-<!--
         <release version="3.5.1-beta2" date="2008-??-??">
+           <action dev="POI-DEVELOPERS" type="fix">45430 - Correct named range sheet reporting when no local sheet id is given in the xml</action>
 		</release>
--->
         <release version="3.5.1-beta1" date="2008-07-18">
            <action dev="POI-DEVELOPERS" type="add">45018 - Support for fetching embeded documents from within an OOXML file</action>
            <action dev="POI-DEVELOPERS" type="add">Port support for setting a policy on missing / blank cells when fetching, to XSSF too</action>

Modified: poi/branches/ooxml/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/documentation/content/xdocs/status.xml?rev=677979&r1=677978&r2=677979&view=diff
==============================================================================
--- poi/branches/ooxml/src/documentation/content/xdocs/status.xml (original)
+++ poi/branches/ooxml/src/documentation/content/xdocs/status.xml Fri Jul 18 10:37:44 2008
@@ -33,10 +33,9 @@
 
 	<!-- Don't forget to update changes.xml too! -->
     <changes>
-<!--
         <release version="3.5.1-beta2" date="2008-??-??">
+           <action dev="POI-DEVELOPERS" type="fix">45430 - Correct named range sheet reporting when no local sheet id is given in the xml</action>
 		</release>
--->
         <release version="3.5.1-beta1" date="2008-07-18">
            <action dev="POI-DEVELOPERS" type="add">45018 - Support for fetching embeded documents from within an OOXML file</action>
            <action dev="POI-DEVELOPERS" type="add">Port support for setting a policy on missing / blank cells when fetching, to XSSF too</action>

Modified: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFName.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFName.java?rev=677979&r1=677978&r2=677979&view=diff
==============================================================================
--- poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFName.java (original)
+++ poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFName.java Fri Jul 18 10:37:44 2008
@@ -57,10 +57,21 @@
 	}
 	
 	public String getSheetName() {
-		long sheetId = ctName.getLocalSheetId();
-		if(sheetId >= 0) {
-			return workbook.getSheetName((int)sheetId);
+		if(ctName.isSetLocalSheetId()) {
+			// Given as explicit sheet id
+			long sheetId = ctName.getLocalSheetId();
+			if(sheetId >= 0) {
+				return workbook.getSheetName((int)sheetId);
+			}
+		} else {
+			// Is it embeded in the reference itself?
+			int excl = getReference().indexOf('!');
+			if(excl > -1) {
+				return getReference().substring(0, excl);
+			}
 		}
+		
+		// Not given at all
 		return null;
 	}
 

Modified: poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/AllXSSFUsermodelTests.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/AllXSSFUsermodelTests.java?rev=677979&r1=677978&r2=677979&view=diff
==============================================================================
--- poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/AllXSSFUsermodelTests.java (original)
+++ poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/AllXSSFUsermodelTests.java Fri Jul 18 10:37:44 2008
@@ -36,6 +36,7 @@
 	public static Test suite() {
 		TestSuite result = new TestSuite(AllXSSFUsermodelTests.class.getName());
 		result.addTestSuite(TestXSSFBorder.class);
+		result.addTestSuite(TestXSSFBugs.class);
 		result.addTestSuite(TestXSSFCellFill.class);
 		result.addTestSuite(TestXSSFHeaderFooter.class);
 		result.addTestSuite(TestXSSFSheetComments.class);

Added: poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java?rev=677979&view=auto
==============================================================================
--- poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java (added)
+++ poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java Fri Jul 18 10:37:44 2008
@@ -0,0 +1,58 @@
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
+package org.apache.poi.xssf.usermodel;
+
+import java.io.File;
+
+import junit.framework.TestCase;
+
+public class TestXSSFBugs extends TestCase {
+	private String getFilePath(String file) {
+		File xml = new File(
+				System.getProperty("HSSF.testdata.path") +
+				File.separator + file
+		);
+		assertTrue(xml.exists());
+		
+		return xml.toString();
+	}
+	
+	/**
+	 * Named ranges had the right reference, but
+	 *  the wrong sheet name
+	 */
+	public void test45430() throws Exception {
+		XSSFWorkbook wb = new XSSFWorkbook(getFilePath("45430.xlsx"));
+		assertEquals(3, wb.getNumberOfNames());
+		
+		assertEquals(0, wb.getNameAt(0).getCTName().getLocalSheetId());
+		assertFalse(wb.getNameAt(0).getCTName().isSetLocalSheetId());
+		assertEquals("SheetA!$A$1", wb.getNameAt(0).getReference());
+		assertEquals("SheetA", wb.getNameAt(0).getSheetName());
+		
+		assertEquals(0, wb.getNameAt(1).getCTName().getLocalSheetId());
+		assertFalse(wb.getNameAt(1).getCTName().isSetLocalSheetId());
+		assertEquals("SheetB!$A$1", wb.getNameAt(1).getReference());
+		assertEquals("SheetB", wb.getNameAt(1).getSheetName());
+		
+		assertEquals(0, wb.getNameAt(2).getCTName().getLocalSheetId());
+		assertFalse(wb.getNameAt(2).getCTName().isSetLocalSheetId());
+		assertEquals("SheetC!$A$1", wb.getNameAt(2).getReference());
+		assertEquals("SheetC", wb.getNameAt(2).getSheetName());
+	}
+}

Propchange: poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: poi/branches/ooxml/src/testcases/org/apache/poi/hssf/data/45430.xlsx
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/hssf/data/45430.xlsx?rev=677979&view=auto
==============================================================================
Binary file - no diff available.

Propchange: poi/branches/ooxml/src/testcases/org/apache/poi/hssf/data/45430.xlsx
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org