poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ye...@apache.org
Subject svn commit: r996136 - in /poi/trunk/src: documentation/content/xdocs/status.xml java/org/apache/poi/hssf/model/InternalWorkbook.java ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java testcases/org/apache/poi/ss/usermodel/BaseTestNamedRange.java
Date Sat, 11 Sep 2010 12:45:59 GMT
Author: yegor
Date: Sat Sep 11 12:45:59 2010
New Revision: 996136

URL: http://svn.apache.org/viewvc?rev=996136&view=rev
Log:
fixed inconsistent behaviour between HSSF and XSSF when creating consecutive names, see Bugzilla
49907

Modified:
    poi/trunk/src/documentation/content/xdocs/status.xml
    poi/trunk/src/java/org/apache/poi/hssf/model/InternalWorkbook.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java
    poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestNamedRange.java

Modified: poi/trunk/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/status.xml?rev=996136&r1=996135&r2=996136&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Sat Sep 11 12:45:59 2010
@@ -34,6 +34,7 @@
 
     <changes>
         <release version="3.7-beta3" date="2010-??-??">
+           <action dev="poi-developers" type="fix">49907 - fixed inconsistent behaviour
between HSSF and XSSF when creating consecutive names</action>
            <action dev="poi-developers" type="add">Add getMimeType() method to HWPF
Picture, alongside existing file extension</action>
            <action dev="poi-developers" type="add">Add code for reading Ole10Native
data</action>
            <action dev="poi-developers" type="add">Add getMimeType() method to HSSF/XSSF
PictureData, alongside existing file extension</action>

Modified: poi/trunk/src/java/org/apache/poi/hssf/model/InternalWorkbook.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/model/InternalWorkbook.java?rev=996136&r1=996135&r2=996136&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/model/InternalWorkbook.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/model/InternalWorkbook.java Sat Sep 11 12:45:59
2010
@@ -1863,11 +1863,6 @@ public final class InternalWorkbook {
     {
 
         LinkTable linkTable = getOrCreateLinkTable();
-        if(linkTable.nameAlreadyExists(name)) {
-            throw new IllegalArgumentException(
-                "You are trying to assign a duplicated name record: "
-                + name.getNameText());
-        }
         linkTable.addName(name);
 
         return name;
@@ -1884,7 +1879,7 @@ public final class InternalWorkbook {
 
         NameRecord name = new NameRecord(builtInName, sheetNumber);
 
-        while(linkTable.nameAlreadyExists(name)) {
+        if(linkTable.nameAlreadyExists(name)) {
             throw new RuntimeException("Builtin (" + builtInName
                     + ") already exists for sheet (" + sheetNumber + ")");
         }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java?rev=996136&r1=996135&r2=996136&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java Sat Sep 11 12:45:59
2010
@@ -465,7 +465,9 @@ public class XSSFWorkbook extends POIXML
     }
 
     public XSSFName createName() {
-        XSSFName name = new XSSFName(CTDefinedName.Factory.newInstance(), this);
+        CTDefinedName ctName = CTDefinedName.Factory.newInstance();
+        ctName.setName("");
+        XSSFName name = new XSSFName(ctName, this);
         namedRanges.add(name);
         return name;
     }

Modified: poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestNamedRange.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestNamedRange.java?rev=996136&r1=996135&r2=996136&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestNamedRange.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestNamedRange.java Sat Sep 11
12:45:59 2010
@@ -559,4 +559,29 @@ public abstract class BaseTestNamedRange
         n.setFunction(false);
         assertFalse(n.isFunctionName());
     }
+
+    public final void testDefferedSetting() {
+        Workbook wb = _testDataProvider.createWorkbook();
+        Name n1 = wb.createName();
+        assertNull(n1.getRefersToFormula());
+        assertEquals("", n1.getNameName());
+
+        Name n2 = wb.createName();
+        assertNull(n2.getRefersToFormula());
+        assertEquals("", n2.getNameName());
+
+        n1.setNameName("sale_1");
+        n1.setRefersToFormula("10");
+
+        n2.setNameName("sale_2");
+        n2.setRefersToFormula("20");
+
+        try {
+            n2.setNameName("sale_1");
+            fail("Expected exception");
+        } catch(Exception e){
+            assertEquals("The workbook already contains this name: sale_1", e.getMessage());
+        }
+
+    }
 }



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


Mime
View raw message