poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject svn commit: r953180 - in /poi/trunk/src: documentation/content/xdocs/status.xml java/org/apache/poi/hssf/model/InternalWorkbook.java testcases/org/apache/poi/hssf/usermodel/TestBugs.java
Date Wed, 09 Jun 2010 22:56:16 GMT
Author: nick
Date: Wed Jun  9 22:56:16 2010
New Revision: 953180

URL: http://svn.apache.org/viewvc?rev=953180&view=rev
Log:
Fix bug #46664 - fix up Tab IDs when adding new sheets, so that print areas don't end up invalid

Modified:
    poi/trunk/src/documentation/content/xdocs/status.xml
    poi/trunk/src/java/org/apache/poi/hssf/model/InternalWorkbook.java
    poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.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=953180&r1=953179&r2=953180&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Wed Jun  9 22:56:16 2010
@@ -34,6 +34,7 @@
 
     <changes>
         <release version="3.7-SNAPSHOT" date="2010-??-??">
+           <action dev="POI-DEVELOPERS" type="fix">46664 - fix up Tab IDs when adding
new sheets, so that print areas don't end up invalid</action>
            <action dev="POI-DEVELOPERS" type="fix">45269 - improve replaceText on HWPF
ranges</action>
            <action dev="POI-DEVELOPERS" type="fix">47815 - correct documentation on
what happens when you request a String from a non-string Formula cell</action>
            <action dev="POI-DEVELOPERS" type="fix">49386 - avoid NPE when extracting
OOXML file properties which are dates</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=953180&r1=953179&r2=953180&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 Wed Jun  9 22:56:16
2010
@@ -712,6 +712,15 @@ public final class InternalWorkbook {
             boundsheets.add(bsr);
             getOrCreateLinkTable().checkExternSheet(sheetnum);
             fixTabIdRecord();
+        } else {
+           // Ensure we have enough tab IDs
+           // Can be a few short if new sheets were added
+           if(records.getTabpos() > 0) {
+              TabIdRecord tir = ( TabIdRecord ) records.get(records.getTabpos());
+              if(tir._tabids.length < boundsheets.size()) {
+                 fixTabIdRecord();
+              }
+           }
         }
     }
 

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java?rev=953180&r1=953179&r2=953180&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java Wed Jun  9 22:56:16
2010
@@ -35,6 +35,8 @@ import org.apache.poi.hssf.model.Interna
 import org.apache.poi.hssf.record.CellValueRecordInterface;
 import org.apache.poi.hssf.record.EmbeddedObjectRefSubRecord;
 import org.apache.poi.hssf.record.NameRecord;
+import org.apache.poi.hssf.record.Record;
+import org.apache.poi.hssf.record.TabIdRecord;
 import org.apache.poi.hssf.record.aggregates.FormulaRecordAggregate;
 import org.apache.poi.hssf.record.common.UnicodeString;
 import org.apache.poi.hssf.record.formula.DeletedArea3DPtg;
@@ -1590,6 +1592,48 @@ public final class TestBugs extends Base
     }
     
     /**
+     * Newly created sheets need to get a 
+     *  proper TabID, otherwise print setup
+     *  gets confused on them. 
+     */
+    public void test46664() throws Exception {
+       HSSFWorkbook wb = new HSSFWorkbook();
+       HSSFSheet sheet = wb.createSheet("new_sheet");
+       HSSFRow row = sheet.createRow((short)0);
+       row.createCell(0).setCellValue(new HSSFRichTextString("Column A"));
+       row.createCell(1).setCellValue(new HSSFRichTextString("Column B"));
+       row.createCell(2).setCellValue(new HSSFRichTextString("Column C"));
+       row.createCell(3).setCellValue(new HSSFRichTextString("Column D"));
+       row.createCell(4).setCellValue(new HSSFRichTextString("Column E"));
+       row.createCell(5).setCellValue(new HSSFRichTextString("Column F"));
+
+       //set print area from column a to column c (on first row)
+       wb.setPrintArea(
+               0, //sheet index
+               0, //start column
+               2, //end column
+               0, //start row
+               0  //end row
+       );
+       
+       wb = writeOutAndReadBack(wb);
+       
+       // Ensure the tab index
+       TabIdRecord tr = null;
+       for(Record r : wb.getWorkbook().getRecords()) {
+          if(r instanceof TabIdRecord) {
+             tr = (TabIdRecord)r;
+          }
+       }
+       assertNotNull(tr);
+       assertEquals(1, tr._tabids.length);
+       assertEquals(0, tr._tabids[0]);
+       
+       // Ensure the print setup
+       assertEquals("new_sheet!$A$1:$C$1", wb.getPrintArea(0));
+    }
+    
+    /**
      * Problems with formula references to 
      *  sheets via URLs
      */



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


Mime
View raw message